@powerhousedao/codegen 6.0.0-dev.151 → 6.0.0-dev.153
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/dist/{file-builders-CNatGM0p.mjs → file-builders-C2QoGrDi.mjs} +466 -467
- package/dist/file-builders-C2QoGrDi.mjs.map +1 -0
- package/dist/index.mjs +32 -34
- package/dist/index.mjs.map +1 -1
- package/dist/src/file-builders/index.mjs +2 -2
- package/dist/src/templates/index.d.mts +2 -3
- package/dist/src/templates/index.d.mts.map +1 -1
- package/dist/src/templates/index.mjs +1 -1
- package/dist/{templates-Bn7kq5sb.mjs → templates-Cu_xr8aR.mjs} +1767 -3
- package/dist/templates-Cu_xr8aR.mjs.map +1 -0
- package/package.json +6 -4
- package/dist/file-builders-CNatGM0p.mjs.map +0 -1
- package/dist/templates-Bn7kq5sb.mjs.map +0 -1
|
@@ -1,6 +1,1770 @@
|
|
|
1
1
|
import { getActionInputName, getActionInputTypeNames, getActionType, getActionTypeName } from "./src/name-builders/index.mjs";
|
|
2
2
|
import { camelCase, capitalCase, constantCase, kebabCase, pascalCase } from "change-case";
|
|
3
|
-
|
|
3
|
+
function isEOL(c) {
|
|
4
|
+
return c === 10 || c === 13;
|
|
5
|
+
}
|
|
6
|
+
function isWhiteSpace(c) {
|
|
7
|
+
return c === 9 || c === 32;
|
|
8
|
+
}
|
|
9
|
+
function isWhiteSpaceOrEOL(c) {
|
|
10
|
+
return isWhiteSpace(c) || isEOL(c);
|
|
11
|
+
}
|
|
12
|
+
function isFlowIndicator(c) {
|
|
13
|
+
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region ../../node_modules/.pnpm/@jsr+std__yaml@1.0.12/node_modules/@jsr/std__yaml/_type/binary.js
|
|
17
|
+
const BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
|
|
18
|
+
function resolveYamlBinary(data) {
|
|
19
|
+
if (data === null) return false;
|
|
20
|
+
let code;
|
|
21
|
+
let bitlen = 0;
|
|
22
|
+
const max = data.length;
|
|
23
|
+
const map = BASE64_MAP;
|
|
24
|
+
for (let idx = 0; idx < max; idx++) {
|
|
25
|
+
code = map.indexOf(data.charAt(idx));
|
|
26
|
+
if (code > 64) continue;
|
|
27
|
+
if (code < 0) return false;
|
|
28
|
+
bitlen += 6;
|
|
29
|
+
}
|
|
30
|
+
return bitlen % 8 === 0;
|
|
31
|
+
}
|
|
32
|
+
function constructYamlBinary(data) {
|
|
33
|
+
const input = data.replace(/[\r\n=]/g, "");
|
|
34
|
+
const max = input.length;
|
|
35
|
+
const map = BASE64_MAP;
|
|
36
|
+
const result = [];
|
|
37
|
+
let bits = 0;
|
|
38
|
+
for (let idx = 0; idx < max; idx++) {
|
|
39
|
+
if (idx % 4 === 0 && idx) {
|
|
40
|
+
result.push(bits >> 16 & 255);
|
|
41
|
+
result.push(bits >> 8 & 255);
|
|
42
|
+
result.push(bits & 255);
|
|
43
|
+
}
|
|
44
|
+
bits = bits << 6 | map.indexOf(input.charAt(idx));
|
|
45
|
+
}
|
|
46
|
+
const tailbits = max % 4 * 6;
|
|
47
|
+
if (tailbits === 0) {
|
|
48
|
+
result.push(bits >> 16 & 255);
|
|
49
|
+
result.push(bits >> 8 & 255);
|
|
50
|
+
result.push(bits & 255);
|
|
51
|
+
} else if (tailbits === 18) {
|
|
52
|
+
result.push(bits >> 10 & 255);
|
|
53
|
+
result.push(bits >> 2 & 255);
|
|
54
|
+
} else if (tailbits === 12) result.push(bits >> 4 & 255);
|
|
55
|
+
return new Uint8Array(result);
|
|
56
|
+
}
|
|
57
|
+
function representYamlBinary(object) {
|
|
58
|
+
const max = object.length;
|
|
59
|
+
const map = BASE64_MAP;
|
|
60
|
+
let result = "";
|
|
61
|
+
let bits = 0;
|
|
62
|
+
for (let idx = 0; idx < max; idx++) {
|
|
63
|
+
if (idx % 3 === 0 && idx) {
|
|
64
|
+
result += map[bits >> 18 & 63];
|
|
65
|
+
result += map[bits >> 12 & 63];
|
|
66
|
+
result += map[bits >> 6 & 63];
|
|
67
|
+
result += map[bits & 63];
|
|
68
|
+
}
|
|
69
|
+
bits = (bits << 8) + object[idx];
|
|
70
|
+
}
|
|
71
|
+
const tail = max % 3;
|
|
72
|
+
if (tail === 0) {
|
|
73
|
+
result += map[bits >> 18 & 63];
|
|
74
|
+
result += map[bits >> 12 & 63];
|
|
75
|
+
result += map[bits >> 6 & 63];
|
|
76
|
+
result += map[bits & 63];
|
|
77
|
+
} else if (tail === 2) {
|
|
78
|
+
result += map[bits >> 10 & 63];
|
|
79
|
+
result += map[bits >> 4 & 63];
|
|
80
|
+
result += map[bits << 2 & 63];
|
|
81
|
+
result += map[64];
|
|
82
|
+
} else if (tail === 1) {
|
|
83
|
+
result += map[bits >> 2 & 63];
|
|
84
|
+
result += map[bits << 4 & 63];
|
|
85
|
+
result += map[64];
|
|
86
|
+
result += map[64];
|
|
87
|
+
}
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
function isBinary(obj) {
|
|
91
|
+
return obj instanceof Uint8Array;
|
|
92
|
+
}
|
|
93
|
+
const binary = {
|
|
94
|
+
tag: "tag:yaml.org,2002:binary",
|
|
95
|
+
construct: constructYamlBinary,
|
|
96
|
+
kind: "scalar",
|
|
97
|
+
predicate: isBinary,
|
|
98
|
+
represent: representYamlBinary,
|
|
99
|
+
resolve: resolveYamlBinary
|
|
100
|
+
};
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region ../../node_modules/.pnpm/@jsr+std__yaml@1.0.12/node_modules/@jsr/std__yaml/_type/bool.js
|
|
103
|
+
const YAML_TRUE_BOOLEANS = [
|
|
104
|
+
"true",
|
|
105
|
+
"True",
|
|
106
|
+
"TRUE"
|
|
107
|
+
];
|
|
108
|
+
const YAML_FALSE_BOOLEANS = [
|
|
109
|
+
"false",
|
|
110
|
+
"False",
|
|
111
|
+
"FALSE"
|
|
112
|
+
];
|
|
113
|
+
const YAML_BOOLEANS = [...YAML_TRUE_BOOLEANS, ...YAML_FALSE_BOOLEANS];
|
|
114
|
+
const bool = {
|
|
115
|
+
tag: "tag:yaml.org,2002:bool",
|
|
116
|
+
kind: "scalar",
|
|
117
|
+
defaultStyle: "lowercase",
|
|
118
|
+
predicate: (value) => typeof value === "boolean" || value instanceof Boolean,
|
|
119
|
+
construct: (data) => YAML_TRUE_BOOLEANS.includes(data),
|
|
120
|
+
resolve: (data) => YAML_BOOLEANS.includes(data),
|
|
121
|
+
represent: {
|
|
122
|
+
lowercase: (object) => {
|
|
123
|
+
return (object instanceof Boolean ? object.valueOf() : object) ? "true" : "false";
|
|
124
|
+
},
|
|
125
|
+
uppercase: (object) => {
|
|
126
|
+
return (object instanceof Boolean ? object.valueOf() : object) ? "TRUE" : "FALSE";
|
|
127
|
+
},
|
|
128
|
+
camelcase: (object) => {
|
|
129
|
+
return (object instanceof Boolean ? object.valueOf() : object) ? "True" : "False";
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region ../../node_modules/.pnpm/@jsr+std__yaml@1.0.12/node_modules/@jsr/std__yaml/_utils.js
|
|
135
|
+
function isObject(value) {
|
|
136
|
+
return value !== null && typeof value === "object";
|
|
137
|
+
}
|
|
138
|
+
function isNegativeZero(i) {
|
|
139
|
+
return i === 0 && Number.NEGATIVE_INFINITY === 1 / i;
|
|
140
|
+
}
|
|
141
|
+
function isPlainObject(object) {
|
|
142
|
+
return Object.prototype.toString.call(object) === "[object Object]";
|
|
143
|
+
}
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region ../../node_modules/.pnpm/@jsr+std__yaml@1.0.12/node_modules/@jsr/std__yaml/_type/float.js
|
|
146
|
+
const YAML_FLOAT_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
|
|
147
|
+
function resolveYamlFloat(data) {
|
|
148
|
+
if (!YAML_FLOAT_PATTERN.test(data) || data[data.length - 1] === "_") return false;
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
function constructYamlFloat(data) {
|
|
152
|
+
let value = data.replace(/_/g, "").toLowerCase();
|
|
153
|
+
const sign = value[0] === "-" ? -1 : 1;
|
|
154
|
+
if (value[0] && "+-".includes(value[0])) value = value.slice(1);
|
|
155
|
+
if (value === ".inf") return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
156
|
+
if (value === ".nan") return NaN;
|
|
157
|
+
return sign * parseFloat(value);
|
|
158
|
+
}
|
|
159
|
+
const SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
|
160
|
+
function representYamlFloat(object, style) {
|
|
161
|
+
const value = object instanceof Number ? object.valueOf() : object;
|
|
162
|
+
if (isNaN(value)) switch (style) {
|
|
163
|
+
case "lowercase": return ".nan";
|
|
164
|
+
case "uppercase": return ".NAN";
|
|
165
|
+
case "camelcase": return ".NaN";
|
|
166
|
+
}
|
|
167
|
+
else if (Number.POSITIVE_INFINITY === value) switch (style) {
|
|
168
|
+
case "lowercase": return ".inf";
|
|
169
|
+
case "uppercase": return ".INF";
|
|
170
|
+
case "camelcase": return ".Inf";
|
|
171
|
+
}
|
|
172
|
+
else if (Number.NEGATIVE_INFINITY === value) switch (style) {
|
|
173
|
+
case "lowercase": return "-.inf";
|
|
174
|
+
case "uppercase": return "-.INF";
|
|
175
|
+
case "camelcase": return "-.Inf";
|
|
176
|
+
}
|
|
177
|
+
else if (isNegativeZero(value)) return "-0.0";
|
|
178
|
+
const res = value.toString(10);
|
|
179
|
+
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
|
|
180
|
+
}
|
|
181
|
+
function isFloat(object) {
|
|
182
|
+
if (object instanceof Number) object = object.valueOf();
|
|
183
|
+
return typeof object === "number" && (object % 1 !== 0 || isNegativeZero(object));
|
|
184
|
+
}
|
|
185
|
+
const float = {
|
|
186
|
+
tag: "tag:yaml.org,2002:float",
|
|
187
|
+
construct: constructYamlFloat,
|
|
188
|
+
defaultStyle: "lowercase",
|
|
189
|
+
kind: "scalar",
|
|
190
|
+
predicate: isFloat,
|
|
191
|
+
represent: representYamlFloat,
|
|
192
|
+
resolve: resolveYamlFloat
|
|
193
|
+
};
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region ../../node_modules/.pnpm/@jsr+std__yaml@1.0.12/node_modules/@jsr/std__yaml/_type/int.js
|
|
196
|
+
function isCharCodeInRange(c, lower, upper) {
|
|
197
|
+
return lower <= c && c <= upper;
|
|
198
|
+
}
|
|
199
|
+
function isHexCode(c) {
|
|
200
|
+
return isCharCodeInRange(c, 48, 57) || isCharCodeInRange(c, 65, 70) || isCharCodeInRange(c, 97, 102);
|
|
201
|
+
}
|
|
202
|
+
function isOctCode(c) {
|
|
203
|
+
return isCharCodeInRange(c, 48, 55);
|
|
204
|
+
}
|
|
205
|
+
function isDecCode(c) {
|
|
206
|
+
return isCharCodeInRange(c, 48, 57);
|
|
207
|
+
}
|
|
208
|
+
function resolveYamlInteger(data) {
|
|
209
|
+
const max = data.length;
|
|
210
|
+
let index = 0;
|
|
211
|
+
let hasDigits = false;
|
|
212
|
+
if (!max) return false;
|
|
213
|
+
let ch = data[index];
|
|
214
|
+
if (ch === "-" || ch === "+") ch = data[++index];
|
|
215
|
+
if (ch === "0") {
|
|
216
|
+
if (index + 1 === max) return true;
|
|
217
|
+
ch = data[++index];
|
|
218
|
+
if (ch === "b") {
|
|
219
|
+
index++;
|
|
220
|
+
for (; index < max; index++) {
|
|
221
|
+
ch = data[index];
|
|
222
|
+
if (ch === "_") continue;
|
|
223
|
+
if (ch !== "0" && ch !== "1") return false;
|
|
224
|
+
hasDigits = true;
|
|
225
|
+
}
|
|
226
|
+
return hasDigits && ch !== "_";
|
|
227
|
+
}
|
|
228
|
+
if (ch === "x") {
|
|
229
|
+
index++;
|
|
230
|
+
for (; index < max; index++) {
|
|
231
|
+
ch = data[index];
|
|
232
|
+
if (ch === "_") continue;
|
|
233
|
+
if (!isHexCode(data.charCodeAt(index))) return false;
|
|
234
|
+
hasDigits = true;
|
|
235
|
+
}
|
|
236
|
+
return hasDigits && ch !== "_";
|
|
237
|
+
}
|
|
238
|
+
for (; index < max; index++) {
|
|
239
|
+
ch = data[index];
|
|
240
|
+
if (ch === "_") continue;
|
|
241
|
+
if (!isOctCode(data.charCodeAt(index))) return false;
|
|
242
|
+
hasDigits = true;
|
|
243
|
+
}
|
|
244
|
+
return hasDigits && ch !== "_";
|
|
245
|
+
}
|
|
246
|
+
if (ch === "_") return false;
|
|
247
|
+
for (; index < max; index++) {
|
|
248
|
+
ch = data[index];
|
|
249
|
+
if (ch === "_") continue;
|
|
250
|
+
if (!isDecCode(data.charCodeAt(index))) return false;
|
|
251
|
+
hasDigits = true;
|
|
252
|
+
}
|
|
253
|
+
if (!hasDigits || ch === "_") return false;
|
|
254
|
+
return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
|
|
255
|
+
}
|
|
256
|
+
function constructYamlInteger(data) {
|
|
257
|
+
let value = data;
|
|
258
|
+
if (value.includes("_")) value = value.replace(/_/g, "");
|
|
259
|
+
let sign = 1;
|
|
260
|
+
let ch = value[0];
|
|
261
|
+
if (ch === "-" || ch === "+") {
|
|
262
|
+
if (ch === "-") sign = -1;
|
|
263
|
+
value = value.slice(1);
|
|
264
|
+
ch = value[0];
|
|
265
|
+
}
|
|
266
|
+
if (value === "0") return 0;
|
|
267
|
+
if (ch === "0") {
|
|
268
|
+
if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
|
|
269
|
+
if (value[1] === "x") return sign * parseInt(value, 16);
|
|
270
|
+
return sign * parseInt(value, 8);
|
|
271
|
+
}
|
|
272
|
+
return sign * parseInt(value, 10);
|
|
273
|
+
}
|
|
274
|
+
function isInteger(object) {
|
|
275
|
+
if (object instanceof Number) object = object.valueOf();
|
|
276
|
+
return typeof object === "number" && object % 1 === 0 && !isNegativeZero(object);
|
|
277
|
+
}
|
|
278
|
+
const int = {
|
|
279
|
+
tag: "tag:yaml.org,2002:int",
|
|
280
|
+
construct: constructYamlInteger,
|
|
281
|
+
defaultStyle: "decimal",
|
|
282
|
+
kind: "scalar",
|
|
283
|
+
predicate: isInteger,
|
|
284
|
+
represent: {
|
|
285
|
+
binary(object) {
|
|
286
|
+
const value = object instanceof Number ? object.valueOf() : object;
|
|
287
|
+
return value >= 0 ? `0b${value.toString(2)}` : `-0b${value.toString(2).slice(1)}`;
|
|
288
|
+
},
|
|
289
|
+
octal(object) {
|
|
290
|
+
const value = object instanceof Number ? object.valueOf() : object;
|
|
291
|
+
return value >= 0 ? `0${value.toString(8)}` : `-0${value.toString(8).slice(1)}`;
|
|
292
|
+
},
|
|
293
|
+
decimal(object) {
|
|
294
|
+
return (object instanceof Number ? object.valueOf() : object).toString(10);
|
|
295
|
+
},
|
|
296
|
+
hexadecimal(object) {
|
|
297
|
+
const value = object instanceof Number ? object.valueOf() : object;
|
|
298
|
+
return value >= 0 ? `0x${value.toString(16).toUpperCase()}` : `-0x${value.toString(16).toUpperCase().slice(1)}`;
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
resolve: resolveYamlInteger
|
|
302
|
+
};
|
|
303
|
+
//#endregion
|
|
304
|
+
//#region ../../node_modules/.pnpm/@jsr+std__yaml@1.0.12/node_modules/@jsr/std__yaml/_type/map.js
|
|
305
|
+
const map = {
|
|
306
|
+
tag: "tag:yaml.org,2002:map",
|
|
307
|
+
resolve() {
|
|
308
|
+
return true;
|
|
309
|
+
},
|
|
310
|
+
construct(data) {
|
|
311
|
+
return data !== null ? data : {};
|
|
312
|
+
},
|
|
313
|
+
kind: "mapping"
|
|
314
|
+
};
|
|
315
|
+
//#endregion
|
|
316
|
+
//#region ../../node_modules/.pnpm/@jsr+std__yaml@1.0.12/node_modules/@jsr/std__yaml/_type/merge.js
|
|
317
|
+
const merge = {
|
|
318
|
+
tag: "tag:yaml.org,2002:merge",
|
|
319
|
+
kind: "scalar",
|
|
320
|
+
resolve: (data) => data === "<<" || data === null,
|
|
321
|
+
construct: (data) => data
|
|
322
|
+
};
|
|
323
|
+
//#endregion
|
|
324
|
+
//#region ../../node_modules/.pnpm/@jsr+std__yaml@1.0.12/node_modules/@jsr/std__yaml/_type/nil.js
|
|
325
|
+
const nil = {
|
|
326
|
+
tag: "tag:yaml.org,2002:null",
|
|
327
|
+
kind: "scalar",
|
|
328
|
+
defaultStyle: "lowercase",
|
|
329
|
+
predicate: (object) => object === null,
|
|
330
|
+
construct: () => null,
|
|
331
|
+
resolve: (data) => {
|
|
332
|
+
return data === "~" || data === "null" || data === "Null" || data === "NULL";
|
|
333
|
+
},
|
|
334
|
+
represent: {
|
|
335
|
+
lowercase: () => "null",
|
|
336
|
+
uppercase: () => "NULL",
|
|
337
|
+
camelcase: () => "Null"
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
//#endregion
|
|
341
|
+
//#region ../../node_modules/.pnpm/@jsr+std__yaml@1.0.12/node_modules/@jsr/std__yaml/_type/omap.js
|
|
342
|
+
function resolveYamlOmap(data) {
|
|
343
|
+
const objectKeys = /* @__PURE__ */ new Set();
|
|
344
|
+
for (const object of data) {
|
|
345
|
+
if (!isPlainObject(object)) return false;
|
|
346
|
+
const keys = Object.keys(object);
|
|
347
|
+
if (keys.length !== 1) return false;
|
|
348
|
+
for (const key of keys) {
|
|
349
|
+
if (objectKeys.has(key)) return false;
|
|
350
|
+
objectKeys.add(key);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return true;
|
|
354
|
+
}
|
|
355
|
+
const omap = {
|
|
356
|
+
tag: "tag:yaml.org,2002:omap",
|
|
357
|
+
kind: "sequence",
|
|
358
|
+
resolve: resolveYamlOmap,
|
|
359
|
+
construct(data) {
|
|
360
|
+
return data;
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
//#endregion
|
|
364
|
+
//#region ../../node_modules/.pnpm/@jsr+std__yaml@1.0.12/node_modules/@jsr/std__yaml/_type/pairs.js
|
|
365
|
+
function resolveYamlPairs(data) {
|
|
366
|
+
if (data === null) return true;
|
|
367
|
+
return data.every((it) => isPlainObject(it) && Object.keys(it).length === 1);
|
|
368
|
+
}
|
|
369
|
+
const pairs = {
|
|
370
|
+
tag: "tag:yaml.org,2002:pairs",
|
|
371
|
+
construct(data) {
|
|
372
|
+
return data?.flatMap(Object.entries) ?? [];
|
|
373
|
+
},
|
|
374
|
+
kind: "sequence",
|
|
375
|
+
resolve: resolveYamlPairs
|
|
376
|
+
};
|
|
377
|
+
//#endregion
|
|
378
|
+
//#region ../../node_modules/.pnpm/@jsr+std__yaml@1.0.12/node_modules/@jsr/std__yaml/_type/regexp.js
|
|
379
|
+
const REGEXP = /^\/(?<regexp>[\s\S]+)\/(?<modifiers>[gismuy]*)$/;
|
|
380
|
+
const regexp = {
|
|
381
|
+
tag: "tag:yaml.org,2002:js/regexp",
|
|
382
|
+
kind: "scalar",
|
|
383
|
+
resolve(data) {
|
|
384
|
+
if (data === null || !data.length) return false;
|
|
385
|
+
if (data.charAt(0) === "/") {
|
|
386
|
+
const groups = data.match(REGEXP)?.groups;
|
|
387
|
+
if (!groups) return false;
|
|
388
|
+
const modifiers = groups.modifiers ?? "";
|
|
389
|
+
if (new Set(modifiers).size < modifiers.length) return false;
|
|
390
|
+
}
|
|
391
|
+
return true;
|
|
392
|
+
},
|
|
393
|
+
construct(data) {
|
|
394
|
+
const { regexp = data, modifiers = "" } = data.match(REGEXP)?.groups ?? {};
|
|
395
|
+
return new RegExp(regexp, modifiers);
|
|
396
|
+
},
|
|
397
|
+
predicate: (object) => object instanceof RegExp,
|
|
398
|
+
represent: (object) => object.toString()
|
|
399
|
+
};
|
|
400
|
+
//#endregion
|
|
401
|
+
//#region ../../node_modules/.pnpm/@jsr+std__yaml@1.0.12/node_modules/@jsr/std__yaml/_type/seq.js
|
|
402
|
+
const seq = {
|
|
403
|
+
tag: "tag:yaml.org,2002:seq",
|
|
404
|
+
kind: "sequence",
|
|
405
|
+
resolve: () => true,
|
|
406
|
+
construct: (data) => data !== null ? data : []
|
|
407
|
+
};
|
|
408
|
+
//#endregion
|
|
409
|
+
//#region ../../node_modules/.pnpm/@jsr+std__yaml@1.0.12/node_modules/@jsr/std__yaml/_type/set.js
|
|
410
|
+
const set = {
|
|
411
|
+
tag: "tag:yaml.org,2002:set",
|
|
412
|
+
kind: "mapping",
|
|
413
|
+
construct: (data) => data !== null ? data : {},
|
|
414
|
+
resolve: (data) => {
|
|
415
|
+
if (data === null) return true;
|
|
416
|
+
return Object.values(data).every((it) => it === null);
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
//#endregion
|
|
420
|
+
//#region ../../node_modules/.pnpm/@jsr+std__yaml@1.0.12/node_modules/@jsr/std__yaml/_type/str.js
|
|
421
|
+
const str = {
|
|
422
|
+
tag: "tag:yaml.org,2002:str",
|
|
423
|
+
kind: "scalar",
|
|
424
|
+
resolve: () => true,
|
|
425
|
+
construct: (data) => data !== null ? data : ""
|
|
426
|
+
};
|
|
427
|
+
//#endregion
|
|
428
|
+
//#region ../../node_modules/.pnpm/@jsr+std__yaml@1.0.12/node_modules/@jsr/std__yaml/_type/timestamp.js
|
|
429
|
+
const YAML_DATE_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$");
|
|
430
|
+
const YAML_TIMESTAMP_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");
|
|
431
|
+
function resolveYamlTimestamp(data) {
|
|
432
|
+
if (data === null) return false;
|
|
433
|
+
if (YAML_DATE_REGEXP.exec(data) !== null) return true;
|
|
434
|
+
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
|
|
435
|
+
return false;
|
|
436
|
+
}
|
|
437
|
+
function constructYamlTimestamp(data) {
|
|
438
|
+
let match = YAML_DATE_REGEXP.exec(data);
|
|
439
|
+
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
440
|
+
if (match === null) throw new Error("Cannot construct YAML timestamp: date resolve error");
|
|
441
|
+
const year = +match[1];
|
|
442
|
+
const month = +match[2] - 1;
|
|
443
|
+
const day = +match[3];
|
|
444
|
+
if (!match[4]) return new Date(Date.UTC(year, month, day));
|
|
445
|
+
const hour = +match[4];
|
|
446
|
+
const minute = +match[5];
|
|
447
|
+
const second = +match[6];
|
|
448
|
+
let fraction = 0;
|
|
449
|
+
if (match[7]) {
|
|
450
|
+
let partFraction = match[7].slice(0, 3);
|
|
451
|
+
while (partFraction.length < 3) partFraction += "0";
|
|
452
|
+
fraction = +partFraction;
|
|
453
|
+
}
|
|
454
|
+
let delta = null;
|
|
455
|
+
if (match[9] && match[10]) {
|
|
456
|
+
const tzHour = +match[10];
|
|
457
|
+
const tzMinute = +(match[11] || 0);
|
|
458
|
+
delta = (tzHour * 60 + tzMinute) * 6e4;
|
|
459
|
+
if (match[9] === "-") delta = -delta;
|
|
460
|
+
}
|
|
461
|
+
const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
462
|
+
if (delta) date.setTime(date.getTime() - delta);
|
|
463
|
+
return date;
|
|
464
|
+
}
|
|
465
|
+
function representYamlTimestamp(date) {
|
|
466
|
+
return date.toISOString();
|
|
467
|
+
}
|
|
468
|
+
const timestamp = {
|
|
469
|
+
tag: "tag:yaml.org,2002:timestamp",
|
|
470
|
+
construct: constructYamlTimestamp,
|
|
471
|
+
predicate(object) {
|
|
472
|
+
return object instanceof Date;
|
|
473
|
+
},
|
|
474
|
+
kind: "scalar",
|
|
475
|
+
represent: representYamlTimestamp,
|
|
476
|
+
resolve: resolveYamlTimestamp
|
|
477
|
+
};
|
|
478
|
+
//#endregion
|
|
479
|
+
//#region ../../node_modules/.pnpm/@jsr+std__yaml@1.0.12/node_modules/@jsr/std__yaml/_type/undefined.js
|
|
480
|
+
const undefinedType = {
|
|
481
|
+
tag: "tag:yaml.org,2002:js/undefined",
|
|
482
|
+
kind: "scalar",
|
|
483
|
+
resolve() {
|
|
484
|
+
return true;
|
|
485
|
+
},
|
|
486
|
+
construct() {},
|
|
487
|
+
predicate(object) {
|
|
488
|
+
return typeof object === "undefined";
|
|
489
|
+
},
|
|
490
|
+
represent() {
|
|
491
|
+
return "";
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
//#endregion
|
|
495
|
+
//#region ../../node_modules/.pnpm/@jsr+std__yaml@1.0.12/node_modules/@jsr/std__yaml/_schema.js
|
|
496
|
+
function createTypeMap(implicitTypes, explicitTypes) {
|
|
497
|
+
const result = {
|
|
498
|
+
fallback: /* @__PURE__ */ new Map(),
|
|
499
|
+
mapping: /* @__PURE__ */ new Map(),
|
|
500
|
+
scalar: /* @__PURE__ */ new Map(),
|
|
501
|
+
sequence: /* @__PURE__ */ new Map()
|
|
502
|
+
};
|
|
503
|
+
const fallbackMap = result.fallback;
|
|
504
|
+
for (const type of [...implicitTypes, ...explicitTypes]) {
|
|
505
|
+
result[type.kind].set(type.tag, type);
|
|
506
|
+
fallbackMap.set(type.tag, type);
|
|
507
|
+
}
|
|
508
|
+
return result;
|
|
509
|
+
}
|
|
510
|
+
function createSchema({ explicitTypes = [], implicitTypes = [], include }) {
|
|
511
|
+
if (include) {
|
|
512
|
+
implicitTypes.push(...include.implicitTypes);
|
|
513
|
+
explicitTypes.push(...include.explicitTypes);
|
|
514
|
+
}
|
|
515
|
+
return {
|
|
516
|
+
implicitTypes,
|
|
517
|
+
explicitTypes,
|
|
518
|
+
typeMap: createTypeMap(implicitTypes, explicitTypes)
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Standard YAML's failsafe schema.
|
|
523
|
+
*
|
|
524
|
+
* @see {@link http://www.yaml.org/spec/1.2/spec.html#id2802346}
|
|
525
|
+
*/ const FAILSAFE_SCHEMA = createSchema({ explicitTypes: [
|
|
526
|
+
str,
|
|
527
|
+
seq,
|
|
528
|
+
map
|
|
529
|
+
] });
|
|
530
|
+
/**
|
|
531
|
+
* Standard YAML's JSON schema.
|
|
532
|
+
*
|
|
533
|
+
* @see {@link http://www.yaml.org/spec/1.2/spec.html#id2803231}
|
|
534
|
+
*/ const JSON_SCHEMA = createSchema({
|
|
535
|
+
implicitTypes: [
|
|
536
|
+
nil,
|
|
537
|
+
bool,
|
|
538
|
+
int,
|
|
539
|
+
float
|
|
540
|
+
],
|
|
541
|
+
include: FAILSAFE_SCHEMA
|
|
542
|
+
});
|
|
543
|
+
/**
|
|
544
|
+
* Standard YAML's core schema.
|
|
545
|
+
*
|
|
546
|
+
* @see {@link http://www.yaml.org/spec/1.2/spec.html#id2804923}
|
|
547
|
+
*/ const CORE_SCHEMA = createSchema({ include: JSON_SCHEMA });
|
|
548
|
+
/**
|
|
549
|
+
* Default YAML schema. It is not described in the YAML specification.
|
|
550
|
+
*/ const DEFAULT_SCHEMA = createSchema({
|
|
551
|
+
explicitTypes: [
|
|
552
|
+
binary,
|
|
553
|
+
omap,
|
|
554
|
+
pairs,
|
|
555
|
+
set
|
|
556
|
+
],
|
|
557
|
+
implicitTypes: [timestamp, merge],
|
|
558
|
+
include: CORE_SCHEMA
|
|
559
|
+
});
|
|
560
|
+
/***
|
|
561
|
+
* Extends JS-YAML default schema with additional JavaScript types
|
|
562
|
+
* It is not described in the YAML specification.
|
|
563
|
+
* Functions are no longer supported for security reasons.
|
|
564
|
+
*
|
|
565
|
+
* @example
|
|
566
|
+
* ```ts
|
|
567
|
+
* import { parse } from "@std/yaml";
|
|
568
|
+
*
|
|
569
|
+
* const data = parse(
|
|
570
|
+
* `
|
|
571
|
+
* regexp:
|
|
572
|
+
* simple: !!js/regexp foobar
|
|
573
|
+
* modifiers: !!js/regexp /foobar/mi
|
|
574
|
+
* undefined: !!js/undefined ~
|
|
575
|
+
* `,
|
|
576
|
+
* { schema: "extended" },
|
|
577
|
+
* );
|
|
578
|
+
* ```
|
|
579
|
+
*/ const EXTENDED_SCHEMA = createSchema({
|
|
580
|
+
explicitTypes: [regexp, undefinedType],
|
|
581
|
+
include: DEFAULT_SCHEMA
|
|
582
|
+
});
|
|
583
|
+
const SCHEMA_MAP = new Map([
|
|
584
|
+
["core", CORE_SCHEMA],
|
|
585
|
+
["default", DEFAULT_SCHEMA],
|
|
586
|
+
["failsafe", FAILSAFE_SCHEMA],
|
|
587
|
+
["json", JSON_SCHEMA],
|
|
588
|
+
["extended", EXTENDED_SCHEMA]
|
|
589
|
+
]);
|
|
590
|
+
//#endregion
|
|
591
|
+
//#region ../../node_modules/.pnpm/@jsr+std__yaml@1.0.12/node_modules/@jsr/std__yaml/_loader_state.js
|
|
592
|
+
const CONTEXT_FLOW_IN = 1;
|
|
593
|
+
const CONTEXT_FLOW_OUT = 2;
|
|
594
|
+
const CONTEXT_BLOCK_IN = 3;
|
|
595
|
+
const CONTEXT_BLOCK_OUT = 4;
|
|
596
|
+
const CHOMPING_CLIP = 1;
|
|
597
|
+
const CHOMPING_STRIP = 2;
|
|
598
|
+
const CHOMPING_KEEP = 3;
|
|
599
|
+
const PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
600
|
+
const PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
|
601
|
+
const PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
|
602
|
+
const PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
|
603
|
+
const PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
|
604
|
+
const ESCAPED_HEX_LENGTHS = new Map([
|
|
605
|
+
[120, 2],
|
|
606
|
+
[117, 4],
|
|
607
|
+
[85, 8]
|
|
608
|
+
]);
|
|
609
|
+
const SIMPLE_ESCAPE_SEQUENCES = new Map([
|
|
610
|
+
[48, "\0"],
|
|
611
|
+
[97, "\x07"],
|
|
612
|
+
[98, "\b"],
|
|
613
|
+
[116, " "],
|
|
614
|
+
[9, " "],
|
|
615
|
+
[110, "\n"],
|
|
616
|
+
[118, "\v"],
|
|
617
|
+
[102, "\f"],
|
|
618
|
+
[114, "\r"],
|
|
619
|
+
[101, "\x1B"],
|
|
620
|
+
[32, " "],
|
|
621
|
+
[34, "\""],
|
|
622
|
+
[47, "/"],
|
|
623
|
+
[92, "\\"],
|
|
624
|
+
[78, "
"],
|
|
625
|
+
[95, "\xA0"],
|
|
626
|
+
[76, "\u2028"],
|
|
627
|
+
[80, "\u2029"]
|
|
628
|
+
]);
|
|
629
|
+
/**
|
|
630
|
+
* Converts a hexadecimal character code to its decimal value.
|
|
631
|
+
*/ function hexCharCodeToNumber(charCode) {
|
|
632
|
+
if (48 <= charCode && charCode <= 57) return charCode - 48;
|
|
633
|
+
const lc = charCode | 32;
|
|
634
|
+
if (97 <= lc && lc <= 102) return lc - 97 + 10;
|
|
635
|
+
return -1;
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Converts a decimal character code to its decimal value.
|
|
639
|
+
*/ function decimalCharCodeToNumber(charCode) {
|
|
640
|
+
if (48 <= charCode && charCode <= 57) return charCode - 48;
|
|
641
|
+
return -1;
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* Converts a Unicode code point to a string.
|
|
645
|
+
*/ function codepointToChar(codepoint) {
|
|
646
|
+
if (codepoint <= 65535) return String.fromCharCode(codepoint);
|
|
647
|
+
return String.fromCharCode((codepoint - 65536 >> 10) + 55296, (codepoint - 65536 & 1023) + 56320);
|
|
648
|
+
}
|
|
649
|
+
const INDENT = 4;
|
|
650
|
+
const MAX_LENGTH = 75;
|
|
651
|
+
const DELIMITERS = "\0\r\n
\u2028\u2029";
|
|
652
|
+
function getSnippet(buffer, position) {
|
|
653
|
+
if (!buffer) return null;
|
|
654
|
+
let start = position;
|
|
655
|
+
let end = position;
|
|
656
|
+
let head = "";
|
|
657
|
+
let tail = "";
|
|
658
|
+
while (start > 0 && !DELIMITERS.includes(buffer.charAt(start - 1))) {
|
|
659
|
+
start--;
|
|
660
|
+
if (position - start > MAX_LENGTH / 2 - 1) {
|
|
661
|
+
head = " ... ";
|
|
662
|
+
start += 5;
|
|
663
|
+
break;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
while (end < buffer.length && !DELIMITERS.includes(buffer.charAt(end))) {
|
|
667
|
+
end++;
|
|
668
|
+
if (end - position > MAX_LENGTH / 2 - 1) {
|
|
669
|
+
tail = " ... ";
|
|
670
|
+
end -= 5;
|
|
671
|
+
break;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
const snippet = buffer.slice(start, end);
|
|
675
|
+
const indent = " ".repeat(INDENT);
|
|
676
|
+
const caretIndent = " ".repeat(INDENT + position - start + head.length);
|
|
677
|
+
return `${indent + head + snippet + tail}\n${caretIndent}^`;
|
|
678
|
+
}
|
|
679
|
+
function markToString(buffer, position, line, column) {
|
|
680
|
+
let where = `at line ${line + 1}, column ${column + 1}`;
|
|
681
|
+
const snippet = getSnippet(buffer, position);
|
|
682
|
+
if (snippet) where += `:\n${snippet}`;
|
|
683
|
+
return where;
|
|
684
|
+
}
|
|
685
|
+
function getIndentStatus(lineIndent, parentIndent) {
|
|
686
|
+
if (lineIndent > parentIndent) return 1;
|
|
687
|
+
if (lineIndent < parentIndent) return -1;
|
|
688
|
+
return 0;
|
|
689
|
+
}
|
|
690
|
+
function writeFoldedLines(count) {
|
|
691
|
+
if (count === 1) return " ";
|
|
692
|
+
if (count > 1) return "\n".repeat(count - 1);
|
|
693
|
+
return "";
|
|
694
|
+
}
|
|
695
|
+
var Scanner = class {
|
|
696
|
+
source;
|
|
697
|
+
#length;
|
|
698
|
+
position = 0;
|
|
699
|
+
constructor(source) {
|
|
700
|
+
source += "\0";
|
|
701
|
+
this.source = source;
|
|
702
|
+
this.#length = source.length;
|
|
703
|
+
}
|
|
704
|
+
peek(offset = 0) {
|
|
705
|
+
return this.source.charCodeAt(this.position + offset);
|
|
706
|
+
}
|
|
707
|
+
next() {
|
|
708
|
+
this.position += 1;
|
|
709
|
+
}
|
|
710
|
+
eof() {
|
|
711
|
+
return this.position >= this.#length - 1;
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
var LoaderState = class {
|
|
715
|
+
#scanner;
|
|
716
|
+
lineIndent = 0;
|
|
717
|
+
lineStart = 0;
|
|
718
|
+
line = 0;
|
|
719
|
+
onWarning;
|
|
720
|
+
allowDuplicateKeys;
|
|
721
|
+
implicitTypes;
|
|
722
|
+
typeMap;
|
|
723
|
+
checkLineBreaks = false;
|
|
724
|
+
tagMap = /* @__PURE__ */ new Map();
|
|
725
|
+
anchorMap = /* @__PURE__ */ new Map();
|
|
726
|
+
constructor(input, { schema = DEFAULT_SCHEMA, onWarning, allowDuplicateKeys = false }) {
|
|
727
|
+
this.#scanner = new Scanner(input);
|
|
728
|
+
this.onWarning = onWarning;
|
|
729
|
+
this.allowDuplicateKeys = allowDuplicateKeys;
|
|
730
|
+
this.implicitTypes = schema.implicitTypes;
|
|
731
|
+
this.typeMap = schema.typeMap;
|
|
732
|
+
this.readIndent();
|
|
733
|
+
}
|
|
734
|
+
skipWhitespaces() {
|
|
735
|
+
let ch = this.#scanner.peek();
|
|
736
|
+
while (isWhiteSpace(ch)) {
|
|
737
|
+
this.#scanner.next();
|
|
738
|
+
ch = this.#scanner.peek();
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
skipComment() {
|
|
742
|
+
let ch = this.#scanner.peek();
|
|
743
|
+
if (ch !== 35) return;
|
|
744
|
+
this.#scanner.next();
|
|
745
|
+
ch = this.#scanner.peek();
|
|
746
|
+
while (ch !== 0 && !isEOL(ch)) {
|
|
747
|
+
this.#scanner.next();
|
|
748
|
+
ch = this.#scanner.peek();
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
readIndent() {
|
|
752
|
+
let ch = this.#scanner.peek();
|
|
753
|
+
while (ch === 32) {
|
|
754
|
+
this.lineIndent += 1;
|
|
755
|
+
this.#scanner.next();
|
|
756
|
+
ch = this.#scanner.peek();
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
#createError(message) {
|
|
760
|
+
const mark = markToString(this.#scanner.source, this.#scanner.position, this.line, this.#scanner.position - this.lineStart);
|
|
761
|
+
return /* @__PURE__ */ new SyntaxError(`${message} ${mark}`);
|
|
762
|
+
}
|
|
763
|
+
dispatchWarning(message) {
|
|
764
|
+
const error = this.#createError(message);
|
|
765
|
+
this.onWarning?.(error);
|
|
766
|
+
}
|
|
767
|
+
yamlDirectiveHandler(args) {
|
|
768
|
+
if (args.length !== 1) throw this.#createError("Cannot handle YAML directive: YAML directive accepts exactly one argument");
|
|
769
|
+
const match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
770
|
+
if (match === null) throw this.#createError("Cannot handle YAML directive: ill-formed argument");
|
|
771
|
+
const major = parseInt(match[1], 10);
|
|
772
|
+
const minor = parseInt(match[2], 10);
|
|
773
|
+
if (major !== 1) throw this.#createError("Cannot handle YAML directive: unacceptable YAML version");
|
|
774
|
+
this.checkLineBreaks = minor < 2;
|
|
775
|
+
if (minor !== 1 && minor !== 2) this.dispatchWarning("Cannot handle YAML directive: unsupported YAML version");
|
|
776
|
+
return args[0] ?? null;
|
|
777
|
+
}
|
|
778
|
+
tagDirectiveHandler(args) {
|
|
779
|
+
if (args.length !== 2) throw this.#createError(`Cannot handle tag directive: directive accepts exactly two arguments, received ${args.length}`);
|
|
780
|
+
const handle = args[0];
|
|
781
|
+
const prefix = args[1];
|
|
782
|
+
if (!PATTERN_TAG_HANDLE.test(handle)) throw this.#createError(`Cannot handle tag directive: ill-formed handle (first argument) in "${handle}"`);
|
|
783
|
+
if (this.tagMap.has(handle)) throw this.#createError(`Cannot handle tag directive: previously declared suffix for "${handle}" tag handle`);
|
|
784
|
+
if (!PATTERN_TAG_URI.test(prefix)) throw this.#createError("Cannot handle tag directive: ill-formed tag prefix (second argument) of the TAG directive");
|
|
785
|
+
this.tagMap.set(handle, prefix);
|
|
786
|
+
}
|
|
787
|
+
captureSegment(start, end, checkJson) {
|
|
788
|
+
if (start < end) {
|
|
789
|
+
const result = this.#scanner.source.slice(start, end);
|
|
790
|
+
if (checkJson) for (let position = 0; position < result.length; position++) {
|
|
791
|
+
const character = result.charCodeAt(position);
|
|
792
|
+
if (!(character === 9 || 32 <= character && character <= 1114111)) throw this.#createError(`Expected valid JSON character: received "${character}"`);
|
|
793
|
+
}
|
|
794
|
+
else if (PATTERN_NON_PRINTABLE.test(result)) throw this.#createError("Stream contains non-printable characters");
|
|
795
|
+
return result;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
readBlockSequence(tag, anchor, nodeIndent) {
|
|
799
|
+
let detected = false;
|
|
800
|
+
const result = [];
|
|
801
|
+
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
802
|
+
let ch = this.#scanner.peek();
|
|
803
|
+
while (ch !== 0) {
|
|
804
|
+
if (ch !== 45) break;
|
|
805
|
+
if (!isWhiteSpaceOrEOL(this.#scanner.peek(1))) break;
|
|
806
|
+
detected = true;
|
|
807
|
+
this.#scanner.next();
|
|
808
|
+
if (this.skipSeparationSpace(true, -1)) {
|
|
809
|
+
if (this.lineIndent <= nodeIndent) {
|
|
810
|
+
result.push(null);
|
|
811
|
+
ch = this.#scanner.peek();
|
|
812
|
+
continue;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
const line = this.line;
|
|
816
|
+
const newState = this.composeNode({
|
|
817
|
+
parentIndent: nodeIndent,
|
|
818
|
+
nodeContext: CONTEXT_BLOCK_IN,
|
|
819
|
+
allowToSeek: false,
|
|
820
|
+
allowCompact: true
|
|
821
|
+
});
|
|
822
|
+
if (newState) result.push(newState.result);
|
|
823
|
+
this.skipSeparationSpace(true, -1);
|
|
824
|
+
ch = this.#scanner.peek();
|
|
825
|
+
if ((this.line === line || this.lineIndent > nodeIndent) && ch !== 0) throw this.#createError("Cannot read block sequence: bad indentation of a sequence entry");
|
|
826
|
+
else if (this.lineIndent < nodeIndent) break;
|
|
827
|
+
}
|
|
828
|
+
if (detected) return {
|
|
829
|
+
tag,
|
|
830
|
+
anchor,
|
|
831
|
+
kind: "sequence",
|
|
832
|
+
result
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
mergeMappings(destination, source, overridableKeys) {
|
|
836
|
+
if (!isObject(source)) throw this.#createError("Cannot merge mappings: the provided source object is unacceptable");
|
|
837
|
+
for (const [key, value] of Object.entries(source)) {
|
|
838
|
+
if (Object.hasOwn(destination, key)) continue;
|
|
839
|
+
Object.defineProperty(destination, key, {
|
|
840
|
+
value,
|
|
841
|
+
writable: true,
|
|
842
|
+
enumerable: true,
|
|
843
|
+
configurable: true
|
|
844
|
+
});
|
|
845
|
+
overridableKeys.add(key);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
storeMappingPair(result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) {
|
|
849
|
+
if (Array.isArray(keyNode)) {
|
|
850
|
+
keyNode = Array.prototype.slice.call(keyNode);
|
|
851
|
+
for (let index = 0; index < keyNode.length; index++) {
|
|
852
|
+
if (Array.isArray(keyNode[index])) throw this.#createError("Cannot store mapping pair: nested arrays are not supported inside keys");
|
|
853
|
+
if (typeof keyNode === "object" && isPlainObject(keyNode[index])) keyNode[index] = "[object Object]";
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
if (typeof keyNode === "object" && isPlainObject(keyNode)) keyNode = "[object Object]";
|
|
857
|
+
keyNode = String(keyNode);
|
|
858
|
+
if (keyTag === "tag:yaml.org,2002:merge") if (Array.isArray(valueNode)) for (let index = 0; index < valueNode.length; index++) this.mergeMappings(result, valueNode[index], overridableKeys);
|
|
859
|
+
else this.mergeMappings(result, valueNode, overridableKeys);
|
|
860
|
+
else {
|
|
861
|
+
if (!this.allowDuplicateKeys && !overridableKeys.has(keyNode) && Object.hasOwn(result, keyNode)) {
|
|
862
|
+
this.line = startLine || this.line;
|
|
863
|
+
this.#scanner.position = startPos || this.#scanner.position;
|
|
864
|
+
throw this.#createError("Cannot store mapping pair: duplicated key");
|
|
865
|
+
}
|
|
866
|
+
Object.defineProperty(result, keyNode, {
|
|
867
|
+
value: valueNode,
|
|
868
|
+
writable: true,
|
|
869
|
+
enumerable: true,
|
|
870
|
+
configurable: true
|
|
871
|
+
});
|
|
872
|
+
overridableKeys.delete(keyNode);
|
|
873
|
+
}
|
|
874
|
+
return result;
|
|
875
|
+
}
|
|
876
|
+
readLineBreak() {
|
|
877
|
+
const ch = this.#scanner.peek();
|
|
878
|
+
if (ch === 10) this.#scanner.next();
|
|
879
|
+
else if (ch === 13) {
|
|
880
|
+
this.#scanner.next();
|
|
881
|
+
if (this.#scanner.peek() === 10) this.#scanner.next();
|
|
882
|
+
} else throw this.#createError("Cannot read line: line break not found");
|
|
883
|
+
this.line += 1;
|
|
884
|
+
this.lineStart = this.#scanner.position;
|
|
885
|
+
}
|
|
886
|
+
skipSeparationSpace(allowComments, checkIndent) {
|
|
887
|
+
let lineBreaks = 0;
|
|
888
|
+
let ch = this.#scanner.peek();
|
|
889
|
+
while (ch !== 0) {
|
|
890
|
+
this.skipWhitespaces();
|
|
891
|
+
ch = this.#scanner.peek();
|
|
892
|
+
if (allowComments) {
|
|
893
|
+
this.skipComment();
|
|
894
|
+
ch = this.#scanner.peek();
|
|
895
|
+
}
|
|
896
|
+
if (isEOL(ch)) {
|
|
897
|
+
this.readLineBreak();
|
|
898
|
+
ch = this.#scanner.peek();
|
|
899
|
+
lineBreaks++;
|
|
900
|
+
this.lineIndent = 0;
|
|
901
|
+
this.readIndent();
|
|
902
|
+
ch = this.#scanner.peek();
|
|
903
|
+
} else break;
|
|
904
|
+
}
|
|
905
|
+
if (checkIndent !== -1 && lineBreaks !== 0 && this.lineIndent < checkIndent) this.dispatchWarning("deficient indentation");
|
|
906
|
+
return lineBreaks;
|
|
907
|
+
}
|
|
908
|
+
testDocumentSeparator() {
|
|
909
|
+
let ch = this.#scanner.peek();
|
|
910
|
+
if ((ch === 45 || ch === 46) && ch === this.#scanner.peek(1) && ch === this.#scanner.peek(2)) {
|
|
911
|
+
ch = this.#scanner.peek(3);
|
|
912
|
+
if (ch === 0 || isWhiteSpaceOrEOL(ch)) return true;
|
|
913
|
+
}
|
|
914
|
+
return false;
|
|
915
|
+
}
|
|
916
|
+
readPlainScalar(tag, anchor, nodeIndent, withinFlowCollection) {
|
|
917
|
+
let ch = this.#scanner.peek();
|
|
918
|
+
if (isWhiteSpaceOrEOL(ch) || isFlowIndicator(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) return;
|
|
919
|
+
let following;
|
|
920
|
+
if (ch === 63 || ch === 45) {
|
|
921
|
+
following = this.#scanner.peek(1);
|
|
922
|
+
if (isWhiteSpaceOrEOL(following) || withinFlowCollection && isFlowIndicator(following)) return;
|
|
923
|
+
}
|
|
924
|
+
let result = "";
|
|
925
|
+
let captureEnd = this.#scanner.position;
|
|
926
|
+
let captureStart = this.#scanner.position;
|
|
927
|
+
let hasPendingContent = false;
|
|
928
|
+
let line = 0;
|
|
929
|
+
while (ch !== 0) {
|
|
930
|
+
if (ch === 58) {
|
|
931
|
+
following = this.#scanner.peek(1);
|
|
932
|
+
if (isWhiteSpaceOrEOL(following) || withinFlowCollection && isFlowIndicator(following)) break;
|
|
933
|
+
} else if (ch === 35) {
|
|
934
|
+
if (isWhiteSpaceOrEOL(this.#scanner.peek(-1))) break;
|
|
935
|
+
} else if (this.#scanner.position === this.lineStart && this.testDocumentSeparator() || withinFlowCollection && isFlowIndicator(ch)) break;
|
|
936
|
+
else if (isEOL(ch)) {
|
|
937
|
+
line = this.line;
|
|
938
|
+
const lineStart = this.lineStart;
|
|
939
|
+
const lineIndent = this.lineIndent;
|
|
940
|
+
this.skipSeparationSpace(false, -1);
|
|
941
|
+
if (this.lineIndent >= nodeIndent) {
|
|
942
|
+
hasPendingContent = true;
|
|
943
|
+
ch = this.#scanner.peek();
|
|
944
|
+
continue;
|
|
945
|
+
} else {
|
|
946
|
+
this.#scanner.position = captureEnd;
|
|
947
|
+
this.line = line;
|
|
948
|
+
this.lineStart = lineStart;
|
|
949
|
+
this.lineIndent = lineIndent;
|
|
950
|
+
break;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
if (hasPendingContent) {
|
|
954
|
+
const segment = this.captureSegment(captureStart, captureEnd, false);
|
|
955
|
+
if (segment) result += segment;
|
|
956
|
+
result += writeFoldedLines(this.line - line);
|
|
957
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
958
|
+
hasPendingContent = false;
|
|
959
|
+
}
|
|
960
|
+
if (!isWhiteSpace(ch)) captureEnd = this.#scanner.position + 1;
|
|
961
|
+
this.#scanner.next();
|
|
962
|
+
ch = this.#scanner.peek();
|
|
963
|
+
}
|
|
964
|
+
const segment = this.captureSegment(captureStart, captureEnd, false);
|
|
965
|
+
if (segment) result += segment;
|
|
966
|
+
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
967
|
+
if (result) return {
|
|
968
|
+
tag,
|
|
969
|
+
anchor,
|
|
970
|
+
kind: "scalar",
|
|
971
|
+
result
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
readSingleQuotedScalar(tag, anchor, nodeIndent) {
|
|
975
|
+
let ch = this.#scanner.peek();
|
|
976
|
+
if (ch !== 39) return;
|
|
977
|
+
let result = "";
|
|
978
|
+
this.#scanner.next();
|
|
979
|
+
let captureStart = this.#scanner.position;
|
|
980
|
+
let captureEnd = this.#scanner.position;
|
|
981
|
+
ch = this.#scanner.peek();
|
|
982
|
+
while (ch !== 0) {
|
|
983
|
+
if (ch === 39) {
|
|
984
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, true);
|
|
985
|
+
if (segment) result += segment;
|
|
986
|
+
this.#scanner.next();
|
|
987
|
+
ch = this.#scanner.peek();
|
|
988
|
+
if (ch === 39) {
|
|
989
|
+
captureStart = this.#scanner.position;
|
|
990
|
+
this.#scanner.next();
|
|
991
|
+
captureEnd = this.#scanner.position;
|
|
992
|
+
} else {
|
|
993
|
+
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
994
|
+
return {
|
|
995
|
+
tag,
|
|
996
|
+
anchor,
|
|
997
|
+
kind: "scalar",
|
|
998
|
+
result
|
|
999
|
+
};
|
|
1000
|
+
}
|
|
1001
|
+
} else if (isEOL(ch)) {
|
|
1002
|
+
const segment = this.captureSegment(captureStart, captureEnd, true);
|
|
1003
|
+
if (segment) result += segment;
|
|
1004
|
+
result += writeFoldedLines(this.skipSeparationSpace(false, nodeIndent));
|
|
1005
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
1006
|
+
} else if (this.#scanner.position === this.lineStart && this.testDocumentSeparator()) throw this.#createError("Unexpected end of the document within a single quoted scalar");
|
|
1007
|
+
else {
|
|
1008
|
+
this.#scanner.next();
|
|
1009
|
+
captureEnd = this.#scanner.position;
|
|
1010
|
+
}
|
|
1011
|
+
ch = this.#scanner.peek();
|
|
1012
|
+
}
|
|
1013
|
+
throw this.#createError("Unexpected end of the stream within a single quoted scalar");
|
|
1014
|
+
}
|
|
1015
|
+
readDoubleQuotedScalar(tag, anchor, nodeIndent) {
|
|
1016
|
+
let ch = this.#scanner.peek();
|
|
1017
|
+
if (ch !== 34) return;
|
|
1018
|
+
let result = "";
|
|
1019
|
+
this.#scanner.next();
|
|
1020
|
+
let captureEnd = this.#scanner.position;
|
|
1021
|
+
let captureStart = this.#scanner.position;
|
|
1022
|
+
let tmp;
|
|
1023
|
+
ch = this.#scanner.peek();
|
|
1024
|
+
while (ch !== 0) {
|
|
1025
|
+
if (ch === 34) {
|
|
1026
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, true);
|
|
1027
|
+
if (segment) result += segment;
|
|
1028
|
+
this.#scanner.next();
|
|
1029
|
+
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
1030
|
+
return {
|
|
1031
|
+
tag,
|
|
1032
|
+
anchor,
|
|
1033
|
+
kind: "scalar",
|
|
1034
|
+
result
|
|
1035
|
+
};
|
|
1036
|
+
}
|
|
1037
|
+
if (ch === 92) {
|
|
1038
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, true);
|
|
1039
|
+
if (segment) result += segment;
|
|
1040
|
+
this.#scanner.next();
|
|
1041
|
+
ch = this.#scanner.peek();
|
|
1042
|
+
if (isEOL(ch)) this.skipSeparationSpace(false, nodeIndent);
|
|
1043
|
+
else if (ch < 256 && SIMPLE_ESCAPE_SEQUENCES.has(ch)) {
|
|
1044
|
+
result += SIMPLE_ESCAPE_SEQUENCES.get(ch);
|
|
1045
|
+
this.#scanner.next();
|
|
1046
|
+
} else if ((tmp = ESCAPED_HEX_LENGTHS.get(ch) ?? 0) > 0) {
|
|
1047
|
+
let hexLength = tmp;
|
|
1048
|
+
let hexResult = 0;
|
|
1049
|
+
for (; hexLength > 0; hexLength--) {
|
|
1050
|
+
this.#scanner.next();
|
|
1051
|
+
ch = this.#scanner.peek();
|
|
1052
|
+
if ((tmp = hexCharCodeToNumber(ch)) >= 0) hexResult = (hexResult << 4) + tmp;
|
|
1053
|
+
else throw this.#createError("Cannot read double quoted scalar: expected hexadecimal character");
|
|
1054
|
+
}
|
|
1055
|
+
result += codepointToChar(hexResult);
|
|
1056
|
+
this.#scanner.next();
|
|
1057
|
+
} else throw this.#createError("Cannot read double quoted scalar: unknown escape sequence");
|
|
1058
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
1059
|
+
} else if (isEOL(ch)) {
|
|
1060
|
+
const segment = this.captureSegment(captureStart, captureEnd, true);
|
|
1061
|
+
if (segment) result += segment;
|
|
1062
|
+
result += writeFoldedLines(this.skipSeparationSpace(false, nodeIndent));
|
|
1063
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
1064
|
+
} else if (this.#scanner.position === this.lineStart && this.testDocumentSeparator()) throw this.#createError("Unexpected end of the document within a double quoted scalar");
|
|
1065
|
+
else {
|
|
1066
|
+
this.#scanner.next();
|
|
1067
|
+
captureEnd = this.#scanner.position;
|
|
1068
|
+
}
|
|
1069
|
+
ch = this.#scanner.peek();
|
|
1070
|
+
}
|
|
1071
|
+
throw this.#createError("Unexpected end of the stream within a double quoted scalar");
|
|
1072
|
+
}
|
|
1073
|
+
readFlowCollection(tag, anchor, nodeIndent) {
|
|
1074
|
+
let ch = this.#scanner.peek();
|
|
1075
|
+
let terminator;
|
|
1076
|
+
let isMapping = true;
|
|
1077
|
+
let result = {};
|
|
1078
|
+
if (ch === 91) {
|
|
1079
|
+
terminator = 93;
|
|
1080
|
+
isMapping = false;
|
|
1081
|
+
result = [];
|
|
1082
|
+
} else if (ch === 123) terminator = 125;
|
|
1083
|
+
else return;
|
|
1084
|
+
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
1085
|
+
this.#scanner.next();
|
|
1086
|
+
ch = this.#scanner.peek();
|
|
1087
|
+
let readNext = true;
|
|
1088
|
+
let valueNode = null;
|
|
1089
|
+
let keyNode = null;
|
|
1090
|
+
let keyTag = null;
|
|
1091
|
+
let isExplicitPair = false;
|
|
1092
|
+
let isPair = false;
|
|
1093
|
+
let following = 0;
|
|
1094
|
+
let line = 0;
|
|
1095
|
+
const overridableKeys = /* @__PURE__ */ new Set();
|
|
1096
|
+
while (ch !== 0) {
|
|
1097
|
+
this.skipSeparationSpace(true, nodeIndent);
|
|
1098
|
+
ch = this.#scanner.peek();
|
|
1099
|
+
if (ch === terminator) {
|
|
1100
|
+
this.#scanner.next();
|
|
1101
|
+
return {
|
|
1102
|
+
tag,
|
|
1103
|
+
anchor,
|
|
1104
|
+
kind: isMapping ? "mapping" : "sequence",
|
|
1105
|
+
result
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
if (!readNext) throw this.#createError("Cannot read flow collection: missing comma between flow collection entries");
|
|
1109
|
+
keyTag = keyNode = valueNode = null;
|
|
1110
|
+
isPair = isExplicitPair = false;
|
|
1111
|
+
if (ch === 63) {
|
|
1112
|
+
following = this.#scanner.peek(1);
|
|
1113
|
+
if (isWhiteSpaceOrEOL(following)) {
|
|
1114
|
+
isPair = isExplicitPair = true;
|
|
1115
|
+
this.#scanner.next();
|
|
1116
|
+
this.skipSeparationSpace(true, nodeIndent);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
line = this.line;
|
|
1120
|
+
const newState = this.composeNode({
|
|
1121
|
+
parentIndent: nodeIndent,
|
|
1122
|
+
nodeContext: CONTEXT_FLOW_IN,
|
|
1123
|
+
allowToSeek: false,
|
|
1124
|
+
allowCompact: true
|
|
1125
|
+
});
|
|
1126
|
+
if (newState) {
|
|
1127
|
+
keyTag = newState.tag || null;
|
|
1128
|
+
keyNode = newState.result;
|
|
1129
|
+
}
|
|
1130
|
+
this.skipSeparationSpace(true, nodeIndent);
|
|
1131
|
+
ch = this.#scanner.peek();
|
|
1132
|
+
if ((isExplicitPair || this.line === line) && ch === 58) {
|
|
1133
|
+
isPair = true;
|
|
1134
|
+
this.#scanner.next();
|
|
1135
|
+
ch = this.#scanner.peek();
|
|
1136
|
+
this.skipSeparationSpace(true, nodeIndent);
|
|
1137
|
+
const newState = this.composeNode({
|
|
1138
|
+
parentIndent: nodeIndent,
|
|
1139
|
+
nodeContext: CONTEXT_FLOW_IN,
|
|
1140
|
+
allowToSeek: false,
|
|
1141
|
+
allowCompact: true
|
|
1142
|
+
});
|
|
1143
|
+
if (newState) valueNode = newState.result;
|
|
1144
|
+
}
|
|
1145
|
+
if (isMapping) this.storeMappingPair(result, overridableKeys, keyTag, keyNode, valueNode);
|
|
1146
|
+
else if (isPair) result.push(this.storeMappingPair({}, overridableKeys, keyTag, keyNode, valueNode));
|
|
1147
|
+
else result.push(keyNode);
|
|
1148
|
+
this.skipSeparationSpace(true, nodeIndent);
|
|
1149
|
+
ch = this.#scanner.peek();
|
|
1150
|
+
if (ch === 44) {
|
|
1151
|
+
readNext = true;
|
|
1152
|
+
this.#scanner.next();
|
|
1153
|
+
ch = this.#scanner.peek();
|
|
1154
|
+
} else readNext = false;
|
|
1155
|
+
}
|
|
1156
|
+
throw this.#createError("Cannot read flow collection: unexpected end of the stream within a flow collection");
|
|
1157
|
+
}
|
|
1158
|
+
readBlockScalar(tag, anchor, nodeIndent) {
|
|
1159
|
+
let chomping = CHOMPING_CLIP;
|
|
1160
|
+
let didReadContent = false;
|
|
1161
|
+
let detectedIndent = false;
|
|
1162
|
+
let textIndent = nodeIndent;
|
|
1163
|
+
let emptyLines = 0;
|
|
1164
|
+
let atMoreIndented = false;
|
|
1165
|
+
let ch = this.#scanner.peek();
|
|
1166
|
+
let folding = false;
|
|
1167
|
+
if (ch === 124) folding = false;
|
|
1168
|
+
else if (ch === 62) folding = true;
|
|
1169
|
+
else return;
|
|
1170
|
+
let result = "";
|
|
1171
|
+
let tmp = 0;
|
|
1172
|
+
while (ch !== 0) {
|
|
1173
|
+
this.#scanner.next();
|
|
1174
|
+
ch = this.#scanner.peek();
|
|
1175
|
+
if (ch === 43 || ch === 45) if (CHOMPING_CLIP === chomping) chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
1176
|
+
else throw this.#createError("Cannot read block: chomping mode identifier repeated");
|
|
1177
|
+
else if ((tmp = decimalCharCodeToNumber(ch)) >= 0) if (tmp === 0) throw this.#createError("Cannot read block: indentation width must be greater than 0");
|
|
1178
|
+
else if (!detectedIndent) {
|
|
1179
|
+
textIndent = nodeIndent + tmp - 1;
|
|
1180
|
+
detectedIndent = true;
|
|
1181
|
+
} else throw this.#createError("Cannot read block: indentation width identifier repeated");
|
|
1182
|
+
else break;
|
|
1183
|
+
}
|
|
1184
|
+
if (isWhiteSpace(ch)) {
|
|
1185
|
+
this.skipWhitespaces();
|
|
1186
|
+
this.skipComment();
|
|
1187
|
+
ch = this.#scanner.peek();
|
|
1188
|
+
}
|
|
1189
|
+
while (ch !== 0) {
|
|
1190
|
+
this.readLineBreak();
|
|
1191
|
+
this.lineIndent = 0;
|
|
1192
|
+
ch = this.#scanner.peek();
|
|
1193
|
+
while ((!detectedIndent || this.lineIndent < textIndent) && ch === 32) {
|
|
1194
|
+
this.lineIndent++;
|
|
1195
|
+
this.#scanner.next();
|
|
1196
|
+
ch = this.#scanner.peek();
|
|
1197
|
+
}
|
|
1198
|
+
if (!detectedIndent && this.lineIndent > textIndent) textIndent = this.lineIndent;
|
|
1199
|
+
if (isEOL(ch)) {
|
|
1200
|
+
emptyLines++;
|
|
1201
|
+
continue;
|
|
1202
|
+
}
|
|
1203
|
+
if (this.lineIndent < textIndent) {
|
|
1204
|
+
if (chomping === CHOMPING_KEEP) result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
|
|
1205
|
+
else if (chomping === CHOMPING_CLIP) {
|
|
1206
|
+
if (didReadContent) result += "\n";
|
|
1207
|
+
}
|
|
1208
|
+
break;
|
|
1209
|
+
}
|
|
1210
|
+
if (folding) if (isWhiteSpace(ch)) {
|
|
1211
|
+
atMoreIndented = true;
|
|
1212
|
+
result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
|
|
1213
|
+
} else if (atMoreIndented) {
|
|
1214
|
+
atMoreIndented = false;
|
|
1215
|
+
result += "\n".repeat(emptyLines + 1);
|
|
1216
|
+
} else if (emptyLines === 0) {
|
|
1217
|
+
if (didReadContent) result += " ";
|
|
1218
|
+
} else result += "\n".repeat(emptyLines);
|
|
1219
|
+
else result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
|
|
1220
|
+
didReadContent = true;
|
|
1221
|
+
detectedIndent = true;
|
|
1222
|
+
emptyLines = 0;
|
|
1223
|
+
const captureStart = this.#scanner.position;
|
|
1224
|
+
while (!isEOL(ch) && ch !== 0) {
|
|
1225
|
+
this.#scanner.next();
|
|
1226
|
+
ch = this.#scanner.peek();
|
|
1227
|
+
}
|
|
1228
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, false);
|
|
1229
|
+
if (segment) result += segment;
|
|
1230
|
+
}
|
|
1231
|
+
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
1232
|
+
return {
|
|
1233
|
+
tag,
|
|
1234
|
+
anchor,
|
|
1235
|
+
kind: "scalar",
|
|
1236
|
+
result
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1239
|
+
readBlockMapping(tag, anchor, nodeIndent, flowIndent) {
|
|
1240
|
+
const result = {};
|
|
1241
|
+
const overridableKeys = /* @__PURE__ */ new Set();
|
|
1242
|
+
let allowCompact = false;
|
|
1243
|
+
let line;
|
|
1244
|
+
let pos;
|
|
1245
|
+
let keyTag = null;
|
|
1246
|
+
let keyNode = null;
|
|
1247
|
+
let valueNode = null;
|
|
1248
|
+
let atExplicitKey = false;
|
|
1249
|
+
let detected = false;
|
|
1250
|
+
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
1251
|
+
let ch = this.#scanner.peek();
|
|
1252
|
+
while (ch !== 0) {
|
|
1253
|
+
const following = this.#scanner.peek(1);
|
|
1254
|
+
line = this.line;
|
|
1255
|
+
pos = this.#scanner.position;
|
|
1256
|
+
if ((ch === 63 || ch === 58) && isWhiteSpaceOrEOL(following)) {
|
|
1257
|
+
if (ch === 63) {
|
|
1258
|
+
if (atExplicitKey) {
|
|
1259
|
+
this.storeMappingPair(result, overridableKeys, keyTag, keyNode, null);
|
|
1260
|
+
keyTag = null;
|
|
1261
|
+
keyNode = null;
|
|
1262
|
+
valueNode = null;
|
|
1263
|
+
}
|
|
1264
|
+
detected = true;
|
|
1265
|
+
atExplicitKey = true;
|
|
1266
|
+
allowCompact = true;
|
|
1267
|
+
} else if (atExplicitKey) {
|
|
1268
|
+
atExplicitKey = false;
|
|
1269
|
+
allowCompact = true;
|
|
1270
|
+
} else throw this.#createError("Cannot read block as explicit mapping pair is incomplete: a key node is missed or followed by a non-tabulated empty line");
|
|
1271
|
+
this.#scanner.next();
|
|
1272
|
+
ch = following;
|
|
1273
|
+
} else {
|
|
1274
|
+
const newState = this.composeNode({
|
|
1275
|
+
parentIndent: flowIndent,
|
|
1276
|
+
nodeContext: CONTEXT_FLOW_OUT,
|
|
1277
|
+
allowToSeek: false,
|
|
1278
|
+
allowCompact: true
|
|
1279
|
+
});
|
|
1280
|
+
if (!newState) break;
|
|
1281
|
+
if (this.line === line) {
|
|
1282
|
+
ch = this.#scanner.peek();
|
|
1283
|
+
this.skipWhitespaces();
|
|
1284
|
+
ch = this.#scanner.peek();
|
|
1285
|
+
if (ch === 58) {
|
|
1286
|
+
this.#scanner.next();
|
|
1287
|
+
ch = this.#scanner.peek();
|
|
1288
|
+
if (!isWhiteSpaceOrEOL(ch)) throw this.#createError("Cannot read block: a whitespace character is expected after the key-value separator within a block mapping");
|
|
1289
|
+
if (atExplicitKey) {
|
|
1290
|
+
this.storeMappingPair(result, overridableKeys, keyTag, keyNode, null);
|
|
1291
|
+
keyTag = null;
|
|
1292
|
+
keyNode = null;
|
|
1293
|
+
valueNode = null;
|
|
1294
|
+
}
|
|
1295
|
+
detected = true;
|
|
1296
|
+
atExplicitKey = false;
|
|
1297
|
+
allowCompact = false;
|
|
1298
|
+
keyTag = newState.tag;
|
|
1299
|
+
keyNode = newState.result;
|
|
1300
|
+
} else if (detected) throw this.#createError("Cannot read an implicit mapping pair: missing colon");
|
|
1301
|
+
else {
|
|
1302
|
+
const { kind, result } = newState;
|
|
1303
|
+
return {
|
|
1304
|
+
tag,
|
|
1305
|
+
anchor,
|
|
1306
|
+
kind,
|
|
1307
|
+
result
|
|
1308
|
+
};
|
|
1309
|
+
}
|
|
1310
|
+
} else if (detected) throw this.#createError("Cannot read a block mapping entry: a multiline key may not be an implicit key");
|
|
1311
|
+
else {
|
|
1312
|
+
const { kind, result } = newState;
|
|
1313
|
+
return {
|
|
1314
|
+
tag,
|
|
1315
|
+
anchor,
|
|
1316
|
+
kind,
|
|
1317
|
+
result
|
|
1318
|
+
};
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
if (this.line === line || this.lineIndent > nodeIndent) {
|
|
1322
|
+
const newState = this.composeNode({
|
|
1323
|
+
parentIndent: nodeIndent,
|
|
1324
|
+
nodeContext: CONTEXT_BLOCK_OUT,
|
|
1325
|
+
allowToSeek: true,
|
|
1326
|
+
allowCompact
|
|
1327
|
+
});
|
|
1328
|
+
if (newState) if (atExplicitKey) keyNode = newState.result;
|
|
1329
|
+
else valueNode = newState.result;
|
|
1330
|
+
if (!atExplicitKey) {
|
|
1331
|
+
this.storeMappingPair(result, overridableKeys, keyTag, keyNode, valueNode, line, pos);
|
|
1332
|
+
keyTag = keyNode = valueNode = null;
|
|
1333
|
+
}
|
|
1334
|
+
this.skipSeparationSpace(true, -1);
|
|
1335
|
+
ch = this.#scanner.peek();
|
|
1336
|
+
}
|
|
1337
|
+
if (this.lineIndent > nodeIndent && ch !== 0) throw this.#createError("Cannot read block: bad indentation of a mapping entry");
|
|
1338
|
+
else if (this.lineIndent < nodeIndent) break;
|
|
1339
|
+
}
|
|
1340
|
+
if (atExplicitKey) this.storeMappingPair(result, overridableKeys, keyTag, keyNode, null);
|
|
1341
|
+
if (detected) return {
|
|
1342
|
+
tag,
|
|
1343
|
+
anchor,
|
|
1344
|
+
kind: "mapping",
|
|
1345
|
+
result
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
readTagProperty(tag) {
|
|
1349
|
+
let isVerbatim = false;
|
|
1350
|
+
let isNamed = false;
|
|
1351
|
+
let tagHandle = "";
|
|
1352
|
+
let tagName;
|
|
1353
|
+
let ch = this.#scanner.peek();
|
|
1354
|
+
if (ch !== 33) return;
|
|
1355
|
+
if (tag !== null) throw this.#createError("Cannot read tag property: duplication of a tag property");
|
|
1356
|
+
this.#scanner.next();
|
|
1357
|
+
ch = this.#scanner.peek();
|
|
1358
|
+
if (ch === 60) {
|
|
1359
|
+
isVerbatim = true;
|
|
1360
|
+
this.#scanner.next();
|
|
1361
|
+
ch = this.#scanner.peek();
|
|
1362
|
+
} else if (ch === 33) {
|
|
1363
|
+
isNamed = true;
|
|
1364
|
+
tagHandle = "!!";
|
|
1365
|
+
this.#scanner.next();
|
|
1366
|
+
ch = this.#scanner.peek();
|
|
1367
|
+
} else tagHandle = "!";
|
|
1368
|
+
let position = this.#scanner.position;
|
|
1369
|
+
if (isVerbatim) {
|
|
1370
|
+
do {
|
|
1371
|
+
this.#scanner.next();
|
|
1372
|
+
ch = this.#scanner.peek();
|
|
1373
|
+
} while (ch !== 0 && ch !== 62);
|
|
1374
|
+
if (!this.#scanner.eof()) {
|
|
1375
|
+
tagName = this.#scanner.source.slice(position, this.#scanner.position);
|
|
1376
|
+
this.#scanner.next();
|
|
1377
|
+
ch = this.#scanner.peek();
|
|
1378
|
+
} else throw this.#createError("Cannot read tag property: unexpected end of stream");
|
|
1379
|
+
} else {
|
|
1380
|
+
while (ch !== 0 && !isWhiteSpaceOrEOL(ch)) {
|
|
1381
|
+
if (ch === 33) if (!isNamed) {
|
|
1382
|
+
tagHandle = this.#scanner.source.slice(position - 1, this.#scanner.position + 1);
|
|
1383
|
+
if (!PATTERN_TAG_HANDLE.test(tagHandle)) throw this.#createError("Cannot read tag property: named tag handle contains invalid characters");
|
|
1384
|
+
isNamed = true;
|
|
1385
|
+
position = this.#scanner.position + 1;
|
|
1386
|
+
} else throw this.#createError("Cannot read tag property: tag suffix cannot contain an exclamation mark");
|
|
1387
|
+
this.#scanner.next();
|
|
1388
|
+
ch = this.#scanner.peek();
|
|
1389
|
+
}
|
|
1390
|
+
tagName = this.#scanner.source.slice(position, this.#scanner.position);
|
|
1391
|
+
if (PATTERN_FLOW_INDICATORS.test(tagName)) throw this.#createError("Cannot read tag property: tag suffix cannot contain flow indicator characters");
|
|
1392
|
+
}
|
|
1393
|
+
if (tagName && !PATTERN_TAG_URI.test(tagName)) throw this.#createError(`Cannot read tag property: invalid characters in tag name "${tagName}"`);
|
|
1394
|
+
if (isVerbatim) return tagName;
|
|
1395
|
+
else if (this.tagMap.has(tagHandle)) return this.tagMap.get(tagHandle) + tagName;
|
|
1396
|
+
else if (tagHandle === "!") return `!${tagName}`;
|
|
1397
|
+
else if (tagHandle === "!!") return `tag:yaml.org,2002:${tagName}`;
|
|
1398
|
+
throw this.#createError(`Cannot read tag property: undeclared tag handle "${tagHandle}"`);
|
|
1399
|
+
}
|
|
1400
|
+
readAnchorProperty(anchor) {
|
|
1401
|
+
let ch = this.#scanner.peek();
|
|
1402
|
+
if (ch !== 38) return;
|
|
1403
|
+
if (anchor !== null) throw this.#createError("Cannot read anchor property: duplicate anchor property");
|
|
1404
|
+
this.#scanner.next();
|
|
1405
|
+
ch = this.#scanner.peek();
|
|
1406
|
+
const position = this.#scanner.position;
|
|
1407
|
+
while (ch !== 0 && !isWhiteSpaceOrEOL(ch) && !isFlowIndicator(ch)) {
|
|
1408
|
+
this.#scanner.next();
|
|
1409
|
+
ch = this.#scanner.peek();
|
|
1410
|
+
}
|
|
1411
|
+
if (this.#scanner.position === position) throw this.#createError("Cannot read anchor property: name of an anchor node must contain at least one character");
|
|
1412
|
+
return this.#scanner.source.slice(position, this.#scanner.position);
|
|
1413
|
+
}
|
|
1414
|
+
readAlias() {
|
|
1415
|
+
if (this.#scanner.peek() !== 42) return;
|
|
1416
|
+
this.#scanner.next();
|
|
1417
|
+
let ch = this.#scanner.peek();
|
|
1418
|
+
const position = this.#scanner.position;
|
|
1419
|
+
while (ch !== 0 && !isWhiteSpaceOrEOL(ch) && !isFlowIndicator(ch)) {
|
|
1420
|
+
this.#scanner.next();
|
|
1421
|
+
ch = this.#scanner.peek();
|
|
1422
|
+
}
|
|
1423
|
+
if (this.#scanner.position === position) throw this.#createError("Cannot read alias: alias name must contain at least one character");
|
|
1424
|
+
const alias = this.#scanner.source.slice(position, this.#scanner.position);
|
|
1425
|
+
if (!this.anchorMap.has(alias)) throw this.#createError(`Cannot read alias: unidentified alias "${alias}"`);
|
|
1426
|
+
this.skipSeparationSpace(true, -1);
|
|
1427
|
+
return this.anchorMap.get(alias);
|
|
1428
|
+
}
|
|
1429
|
+
resolveTag(state) {
|
|
1430
|
+
switch (state.tag) {
|
|
1431
|
+
case null:
|
|
1432
|
+
case "!": return state;
|
|
1433
|
+
case "?":
|
|
1434
|
+
for (const type of this.implicitTypes) {
|
|
1435
|
+
if (!type.resolve(state.result)) continue;
|
|
1436
|
+
const result = type.construct(state.result);
|
|
1437
|
+
state.result = result;
|
|
1438
|
+
state.tag = type.tag;
|
|
1439
|
+
const { anchor } = state;
|
|
1440
|
+
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
1441
|
+
return state;
|
|
1442
|
+
}
|
|
1443
|
+
return state;
|
|
1444
|
+
}
|
|
1445
|
+
const kind = state.kind ?? "fallback";
|
|
1446
|
+
const type = this.typeMap[kind].get(state.tag);
|
|
1447
|
+
if (!type) throw this.#createError(`Cannot resolve unknown tag !<${state.tag}>`);
|
|
1448
|
+
if (state.result !== null && type.kind !== state.kind) throw this.#createError(`Unacceptable node kind for !<${state.tag}> tag: it should be "${type.kind}", not "${state.kind}"`);
|
|
1449
|
+
if (!type.resolve(state.result)) throw this.#createError(`Cannot resolve a node with !<${state.tag}> explicit tag`);
|
|
1450
|
+
const result = type.construct(state.result);
|
|
1451
|
+
state.result = result;
|
|
1452
|
+
const { anchor } = state;
|
|
1453
|
+
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
1454
|
+
return state;
|
|
1455
|
+
}
|
|
1456
|
+
composeNode({ parentIndent, nodeContext, allowToSeek, allowCompact }) {
|
|
1457
|
+
let indentStatus = 1;
|
|
1458
|
+
let atNewLine = false;
|
|
1459
|
+
const allowBlockScalars = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
|
|
1460
|
+
let allowBlockCollections = allowBlockScalars;
|
|
1461
|
+
const allowBlockStyles = allowBlockScalars;
|
|
1462
|
+
if (allowToSeek) {
|
|
1463
|
+
if (this.skipSeparationSpace(true, -1)) {
|
|
1464
|
+
atNewLine = true;
|
|
1465
|
+
indentStatus = getIndentStatus(this.lineIndent, parentIndent);
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
let tag = null;
|
|
1469
|
+
let anchor = null;
|
|
1470
|
+
if (indentStatus === 1) while (true) {
|
|
1471
|
+
const newTag = this.readTagProperty(tag);
|
|
1472
|
+
if (newTag) tag = newTag;
|
|
1473
|
+
else {
|
|
1474
|
+
const newAnchor = this.readAnchorProperty(anchor);
|
|
1475
|
+
if (!newAnchor) break;
|
|
1476
|
+
anchor = newAnchor;
|
|
1477
|
+
}
|
|
1478
|
+
if (this.skipSeparationSpace(true, -1)) {
|
|
1479
|
+
atNewLine = true;
|
|
1480
|
+
allowBlockCollections = allowBlockStyles;
|
|
1481
|
+
indentStatus = getIndentStatus(this.lineIndent, parentIndent);
|
|
1482
|
+
} else allowBlockCollections = false;
|
|
1483
|
+
}
|
|
1484
|
+
if (allowBlockCollections) allowBlockCollections = atNewLine || allowCompact;
|
|
1485
|
+
if (indentStatus === 1) {
|
|
1486
|
+
const flowIndent = CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext ? parentIndent : parentIndent + 1;
|
|
1487
|
+
if (allowBlockCollections) {
|
|
1488
|
+
const blockIndent = this.#scanner.position - this.lineStart;
|
|
1489
|
+
const blockSequenceState = this.readBlockSequence(tag, anchor, blockIndent);
|
|
1490
|
+
if (blockSequenceState) return this.resolveTag(blockSequenceState);
|
|
1491
|
+
const blockMappingState = this.readBlockMapping(tag, anchor, blockIndent, flowIndent);
|
|
1492
|
+
if (blockMappingState) return this.resolveTag(blockMappingState);
|
|
1493
|
+
}
|
|
1494
|
+
const flowCollectionState = this.readFlowCollection(tag, anchor, flowIndent);
|
|
1495
|
+
if (flowCollectionState) return this.resolveTag(flowCollectionState);
|
|
1496
|
+
if (allowBlockScalars) {
|
|
1497
|
+
const blockScalarState = this.readBlockScalar(tag, anchor, flowIndent);
|
|
1498
|
+
if (blockScalarState) return this.resolveTag(blockScalarState);
|
|
1499
|
+
}
|
|
1500
|
+
const singleQuoteState = this.readSingleQuotedScalar(tag, anchor, flowIndent);
|
|
1501
|
+
if (singleQuoteState) return this.resolveTag(singleQuoteState);
|
|
1502
|
+
const doubleQuoteState = this.readDoubleQuotedScalar(tag, anchor, flowIndent);
|
|
1503
|
+
if (doubleQuoteState) return this.resolveTag(doubleQuoteState);
|
|
1504
|
+
const alias = this.readAlias();
|
|
1505
|
+
if (alias) {
|
|
1506
|
+
if (tag !== null || anchor !== null) throw this.#createError("Cannot compose node: alias node should not have any properties");
|
|
1507
|
+
return this.resolveTag({
|
|
1508
|
+
tag,
|
|
1509
|
+
anchor,
|
|
1510
|
+
kind: null,
|
|
1511
|
+
result: alias
|
|
1512
|
+
});
|
|
1513
|
+
}
|
|
1514
|
+
const plainScalarState = this.readPlainScalar(tag, anchor, flowIndent, CONTEXT_FLOW_IN === nodeContext);
|
|
1515
|
+
if (plainScalarState) {
|
|
1516
|
+
plainScalarState.tag ??= "?";
|
|
1517
|
+
return this.resolveTag(plainScalarState);
|
|
1518
|
+
}
|
|
1519
|
+
} else if (indentStatus === 0 && CONTEXT_BLOCK_OUT === nodeContext && allowBlockCollections) {
|
|
1520
|
+
const blockIndent = this.#scanner.position - this.lineStart;
|
|
1521
|
+
const newState = this.readBlockSequence(tag, anchor, blockIndent);
|
|
1522
|
+
if (newState) return this.resolveTag(newState);
|
|
1523
|
+
}
|
|
1524
|
+
const newState = this.resolveTag({
|
|
1525
|
+
tag,
|
|
1526
|
+
anchor,
|
|
1527
|
+
kind: null,
|
|
1528
|
+
result: null
|
|
1529
|
+
});
|
|
1530
|
+
if (newState.tag !== null || newState.anchor !== null) return newState;
|
|
1531
|
+
}
|
|
1532
|
+
readDirectives() {
|
|
1533
|
+
let hasDirectives = false;
|
|
1534
|
+
let version = null;
|
|
1535
|
+
let ch = this.#scanner.peek();
|
|
1536
|
+
while (ch !== 0) {
|
|
1537
|
+
this.skipSeparationSpace(true, -1);
|
|
1538
|
+
ch = this.#scanner.peek();
|
|
1539
|
+
if (this.lineIndent > 0 || ch !== 37) break;
|
|
1540
|
+
hasDirectives = true;
|
|
1541
|
+
this.#scanner.next();
|
|
1542
|
+
ch = this.#scanner.peek();
|
|
1543
|
+
let position = this.#scanner.position;
|
|
1544
|
+
while (ch !== 0 && !isWhiteSpaceOrEOL(ch)) {
|
|
1545
|
+
this.#scanner.next();
|
|
1546
|
+
ch = this.#scanner.peek();
|
|
1547
|
+
}
|
|
1548
|
+
const directiveName = this.#scanner.source.slice(position, this.#scanner.position);
|
|
1549
|
+
const directiveArgs = [];
|
|
1550
|
+
if (directiveName.length < 1) throw this.#createError("Cannot read document: directive name length must be greater than zero");
|
|
1551
|
+
while (ch !== 0) {
|
|
1552
|
+
this.skipWhitespaces();
|
|
1553
|
+
this.skipComment();
|
|
1554
|
+
ch = this.#scanner.peek();
|
|
1555
|
+
if (isEOL(ch)) break;
|
|
1556
|
+
position = this.#scanner.position;
|
|
1557
|
+
while (ch !== 0 && !isWhiteSpaceOrEOL(ch)) {
|
|
1558
|
+
this.#scanner.next();
|
|
1559
|
+
ch = this.#scanner.peek();
|
|
1560
|
+
}
|
|
1561
|
+
directiveArgs.push(this.#scanner.source.slice(position, this.#scanner.position));
|
|
1562
|
+
}
|
|
1563
|
+
if (ch !== 0) this.readLineBreak();
|
|
1564
|
+
switch (directiveName) {
|
|
1565
|
+
case "YAML":
|
|
1566
|
+
if (version !== null) throw this.#createError("Cannot handle YAML directive: duplication of %YAML directive");
|
|
1567
|
+
version = this.yamlDirectiveHandler(directiveArgs);
|
|
1568
|
+
break;
|
|
1569
|
+
case "TAG":
|
|
1570
|
+
this.tagDirectiveHandler(directiveArgs);
|
|
1571
|
+
break;
|
|
1572
|
+
default:
|
|
1573
|
+
this.dispatchWarning(`unknown document directive "${directiveName}"`);
|
|
1574
|
+
break;
|
|
1575
|
+
}
|
|
1576
|
+
ch = this.#scanner.peek();
|
|
1577
|
+
}
|
|
1578
|
+
return hasDirectives;
|
|
1579
|
+
}
|
|
1580
|
+
readDocument() {
|
|
1581
|
+
const documentStart = this.#scanner.position;
|
|
1582
|
+
this.checkLineBreaks = false;
|
|
1583
|
+
this.tagMap = /* @__PURE__ */ new Map();
|
|
1584
|
+
this.anchorMap = /* @__PURE__ */ new Map();
|
|
1585
|
+
const hasDirectives = this.readDirectives();
|
|
1586
|
+
this.skipSeparationSpace(true, -1);
|
|
1587
|
+
let result = null;
|
|
1588
|
+
if (this.lineIndent === 0 && this.#scanner.peek() === 45 && this.#scanner.peek(1) === 45 && this.#scanner.peek(2) === 45) {
|
|
1589
|
+
this.#scanner.position += 3;
|
|
1590
|
+
this.skipSeparationSpace(true, -1);
|
|
1591
|
+
} else if (hasDirectives) throw this.#createError("Cannot read document: directives end mark is expected");
|
|
1592
|
+
const newState = this.composeNode({
|
|
1593
|
+
parentIndent: this.lineIndent - 1,
|
|
1594
|
+
nodeContext: CONTEXT_BLOCK_OUT,
|
|
1595
|
+
allowToSeek: false,
|
|
1596
|
+
allowCompact: true
|
|
1597
|
+
});
|
|
1598
|
+
if (newState) result = newState.result;
|
|
1599
|
+
this.skipSeparationSpace(true, -1);
|
|
1600
|
+
if (this.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(this.#scanner.source.slice(documentStart, this.#scanner.position))) this.dispatchWarning("non-ASCII line breaks are interpreted as content");
|
|
1601
|
+
if (this.#scanner.position === this.lineStart && this.testDocumentSeparator()) {
|
|
1602
|
+
if (this.#scanner.peek() === 46) {
|
|
1603
|
+
this.#scanner.position += 3;
|
|
1604
|
+
this.skipSeparationSpace(true, -1);
|
|
1605
|
+
}
|
|
1606
|
+
} else if (!this.#scanner.eof()) throw this.#createError("Cannot read document: end of the stream or a document separator is expected");
|
|
1607
|
+
return result;
|
|
1608
|
+
}
|
|
1609
|
+
*readDocuments() {
|
|
1610
|
+
while (!this.#scanner.eof()) yield this.readDocument();
|
|
1611
|
+
}
|
|
1612
|
+
};
|
|
1613
|
+
//#endregion
|
|
1614
|
+
//#region ../../node_modules/.pnpm/@jsr+std__yaml@1.0.12/node_modules/@jsr/std__yaml/parse.js
|
|
1615
|
+
function sanitizeInput(input) {
|
|
1616
|
+
input = String(input);
|
|
1617
|
+
if (input.length > 0) {
|
|
1618
|
+
if (!isEOL(input.charCodeAt(input.length - 1))) input += "\n";
|
|
1619
|
+
if (input.charCodeAt(0) === 65279) input = input.slice(1);
|
|
1620
|
+
}
|
|
1621
|
+
return input;
|
|
1622
|
+
}
|
|
1623
|
+
/**
|
|
1624
|
+
* Parse and return a YAML string as a parsed YAML document object.
|
|
1625
|
+
*
|
|
1626
|
+
* Note: This does not support functions. Untrusted data is safe to parse.
|
|
1627
|
+
*
|
|
1628
|
+
* @example Usage
|
|
1629
|
+
* ```ts
|
|
1630
|
+
* import { parse } from "@std/yaml/parse";
|
|
1631
|
+
* import { assertEquals } from "@std/assert";
|
|
1632
|
+
*
|
|
1633
|
+
* const data = parse(`
|
|
1634
|
+
* id: 1
|
|
1635
|
+
* name: Alice
|
|
1636
|
+
* `);
|
|
1637
|
+
*
|
|
1638
|
+
* assertEquals(data, { id: 1, name: "Alice" });
|
|
1639
|
+
* ```
|
|
1640
|
+
*
|
|
1641
|
+
* @throws {SyntaxError} Throws error on invalid YAML.
|
|
1642
|
+
* @param content YAML string to parse.
|
|
1643
|
+
* @param options Parsing options.
|
|
1644
|
+
* @returns Parsed document.
|
|
1645
|
+
*/ function parse(content, options = {}) {
|
|
1646
|
+
content = sanitizeInput(content);
|
|
1647
|
+
const documentGenerator = new LoaderState(content, {
|
|
1648
|
+
...options,
|
|
1649
|
+
schema: SCHEMA_MAP.get(options.schema)
|
|
1650
|
+
}).readDocuments();
|
|
1651
|
+
const document = documentGenerator.next().value;
|
|
1652
|
+
if (!documentGenerator.next().done) throw new SyntaxError("Found more than 1 document in the stream: expected a single document");
|
|
1653
|
+
return document ?? null;
|
|
1654
|
+
}
|
|
1655
|
+
//#endregion
|
|
1656
|
+
//#region ../../node_modules/.pnpm/@jsr+tmpl__core@0.6.3/node_modules/@jsr/tmpl__core/mod.js
|
|
1657
|
+
/**
|
|
1658
|
+
* Core module for @tmpl/core
|
|
1659
|
+
*
|
|
1660
|
+
* This module exports the core functionality of the @tmpl/core library.
|
|
1661
|
+
*/ var _computedKey = Symbol.for("Deno.customInspect");
|
|
1662
|
+
var TemplateClass = class TemplateClass extends String {
|
|
1663
|
+
type;
|
|
1664
|
+
raw;
|
|
1665
|
+
data;
|
|
1666
|
+
error;
|
|
1667
|
+
parser;
|
|
1668
|
+
constructor(type, template, substitutions, parser, options) {
|
|
1669
|
+
const substTemplateRaw = [];
|
|
1670
|
+
for (let i = 0; i < template.raw.length; i++) substTemplateRaw.push(template.raw[i].replace(/\\([`$])/g, "$1"));
|
|
1671
|
+
const raw = String.raw({ raw: substTemplateRaw }, ...substitutions);
|
|
1672
|
+
let str = raw.toString();
|
|
1673
|
+
if (typeof options?.indent === "number") if (options.indent > 0) {
|
|
1674
|
+
const indent = " ".repeat(options.indent);
|
|
1675
|
+
str = str.replace(/^(?!\s*$)/gm, indent);
|
|
1676
|
+
} else str = str.replace(/^\s+/gm, (match) => {
|
|
1677
|
+
return match.slice(0, match.length + options.indent);
|
|
1678
|
+
});
|
|
1679
|
+
if (options?.indent === false) {
|
|
1680
|
+
const lines = str.split("\n");
|
|
1681
|
+
const indent = (lines.find((line) => line.trim() !== "") || "").match(/^\s+/)?.[0]?.length || 0;
|
|
1682
|
+
str = lines.map((line) => line.slice(indent)).join("\n");
|
|
1683
|
+
}
|
|
1684
|
+
super(str);
|
|
1685
|
+
this.type = type;
|
|
1686
|
+
this.raw = raw;
|
|
1687
|
+
this.parser = parser;
|
|
1688
|
+
}
|
|
1689
|
+
[_computedKey]() {
|
|
1690
|
+
return this.valueOf();
|
|
1691
|
+
}
|
|
1692
|
+
indent(value) {
|
|
1693
|
+
return new TemplateClass(this.type, { raw: [this.raw] }, [], void 0, { indent: value });
|
|
1694
|
+
}
|
|
1695
|
+
noindent() {
|
|
1696
|
+
return this.indent(false);
|
|
1697
|
+
}
|
|
1698
|
+
throw() {
|
|
1699
|
+
if (this.error) throw this.error;
|
|
1700
|
+
return this;
|
|
1701
|
+
}
|
|
1702
|
+
parse(parser) {
|
|
1703
|
+
this.parser = parser ?? this.parser;
|
|
1704
|
+
try {
|
|
1705
|
+
this.data = this.parser?.(this.raw);
|
|
1706
|
+
} catch (error) {
|
|
1707
|
+
this.error = error;
|
|
1708
|
+
}
|
|
1709
|
+
return this;
|
|
1710
|
+
}
|
|
1711
|
+
};
|
|
1712
|
+
/**
|
|
1713
|
+
* Generic template function for any file extension
|
|
1714
|
+
*
|
|
1715
|
+
* @param extension The file extension (without the dot)
|
|
1716
|
+
* @returns A template tag function for the specified extension
|
|
1717
|
+
*/ function tag(type, parser, options) {
|
|
1718
|
+
return (template, ...substitutions) => new TemplateClass(type, template, substitutions, parser, options);
|
|
1719
|
+
}
|
|
1720
|
+
const html = tag("html");
|
|
1721
|
+
const css = tag("css");
|
|
1722
|
+
const js = tag("js");
|
|
1723
|
+
const ts = tag("ts");
|
|
1724
|
+
tag("jsx");
|
|
1725
|
+
const tsx = tag("tsx");
|
|
1726
|
+
const json = tag("json", JSON.parse);
|
|
1727
|
+
tag("xml");
|
|
1728
|
+
const yaml = tag("yaml", parse);
|
|
1729
|
+
tag("toml");
|
|
1730
|
+
tag("ini");
|
|
1731
|
+
tag("csv");
|
|
1732
|
+
const md = tag("md");
|
|
1733
|
+
tag("tex");
|
|
1734
|
+
tag("rst");
|
|
1735
|
+
tag("sql");
|
|
1736
|
+
tag("graphql");
|
|
1737
|
+
tag("sh");
|
|
1738
|
+
tag("ps1");
|
|
1739
|
+
tag("bat");
|
|
1740
|
+
tag("py");
|
|
1741
|
+
tag("rb");
|
|
1742
|
+
tag("go");
|
|
1743
|
+
tag("rs");
|
|
1744
|
+
tag("c");
|
|
1745
|
+
tag("cpp");
|
|
1746
|
+
tag("cs");
|
|
1747
|
+
tag("java");
|
|
1748
|
+
tag("php");
|
|
1749
|
+
tag("swift");
|
|
1750
|
+
tag("kt");
|
|
1751
|
+
tag("scala");
|
|
1752
|
+
tag("dart");
|
|
1753
|
+
tag("lua");
|
|
1754
|
+
tag("pl");
|
|
1755
|
+
tag("r");
|
|
1756
|
+
tag("elm");
|
|
1757
|
+
tag("fs");
|
|
1758
|
+
tag("clj");
|
|
1759
|
+
tag("hs");
|
|
1760
|
+
tag("dockerfile");
|
|
1761
|
+
tag("makefile");
|
|
1762
|
+
tag("mk");
|
|
1763
|
+
tag("svg");
|
|
1764
|
+
tag("diff");
|
|
1765
|
+
tag("proto");
|
|
1766
|
+
tag("sol");
|
|
1767
|
+
//#endregion
|
|
4
1768
|
//#region src/templates/app/components/CreateDocument.ts
|
|
5
1769
|
const createDocumentFileTemplate = tsx`
|
|
6
1770
|
import type { DocumentModelModule } from "document-model";
|
|
@@ -4608,6 +6372,6 @@ function camel(name) {
|
|
|
4608
6372
|
return p.charAt(0).toLowerCase() + p.slice(1);
|
|
4609
6373
|
}
|
|
4610
6374
|
//#endregion
|
|
4611
|
-
export { tsConfigTemplate as $, documentModelHooksFileTemplate as A, claudeSettingsLocalTemplate as At, getModuleExportType as B, appDriveContentsFileTemplate as Bt, makeActionsImports as C, documentModelsIndexTemplate as Ct, documentModelSrcIndexFileTemplate as D, dockerfileTemplate as Dt, documentModelSrcUtilsTemplate as E, nginxConfTemplate as Et, documentModelPhFactoriesFileTemplate as F, folderTreeFileTemplate as Ft, documentModelGenControllerFileTemplate as G, documentModelDocumentTypeTemplate as H, documentModelOperationsModuleOperationsFileTemplate as I, appFoldersFileTemplate as It, documentEditorModuleFileTemplate as J, documentModelGenActionsFileTemplate as K, documentModelOperationsModuleErrorFileTemplate as L, appFilesFileTemplate as Lt, documentModelGenTypesTemplate as M, appEditorFileTemplate as Mt, documentModelSchemaIndexTemplate as N, appConfigFileTemplate as Nt, documentModelModuleFileTemplate as O, connectEntrypointTemplate as Ot, documentModelGenReducerFileTemplate as P, driveExplorerNavigationBreadcrumbsFileTemplate as Pt, viteConfigTemplate as Q, documentModelOperationsModuleCreatorsFileTemplate as R, emptyStateFileTemplate as Rt, makeActionImportNames as S, editorsTemplate as St, documentModelTestFileTemplate as T, switchboardEntrypointTemplate as Tt, documentModelDocumentSchemaFileTemplate as U, documentModelGenIndexFileTemplate as V, createDocumentFileTemplate as Vt, documentModelGenCreatorsFileTemplate as W, docsFromCliHelpTemplate as X, documentEditorEditorFileTemplate as Y, vitestConfigTemplate as Z, analyticsFactoryTemplate as _, gitIgnoreTemplate as _t, subgraphLibFileTemplate as a, buildPowerhouseConfigTemplate as at, upgradeManifestTemplate as b, eslintConfigTemplate as bt, relationalDbProcessorTemplate as c, exportsTemplate as ct, relationalDbFactoryTemplate as d, mcpTemplate as dt, tsconfigPathsTemplate as et, processorsIndexTemplate as f, mainTsxTemplate as ft, analyticsIndexTemplate as g, indexHtmlTemplate as gt, analyticsProcessorTemplate as h, legacyIndexHtmlTemplate as ht, customSubgraphSchemaTemplate as i, ManifestTemplate as it, documentModelGenUtilsTemplate as j, agentsTemplate as jt, documentModelIndexTemplate as k, cursorMcpTemplate as kt, relationalDbMigrationsTemplate as l, packageJsonTemplate as lt, factoryBuildersTemplate as m, indexTsTemplate as mt, documentModelSubgraphSchemaTemplate as n, styleTemplate as nt, subgraphIndexFileTemplate as o, packageJsonExportsTemplate as ot, processorsFactoryTemplate as p, licenseTemplate as pt, documentModelRootActionsFileTemplate as q, customSubgraphResolversTemplate as r, readmeTemplate as rt, relationalDbSchemaTemplate as s, packageJsonScriptsTemplate as st, documentModelSubgraphResolversTemplate as t, subgraphsIndexTemplate as tt, relationalDbIndexTemplate as u, npmrcTemplate as ut, documentModelUtilsTemplate as v, syncAndPublishWorkflowTemplate as vt, makeTestCaseForAction as w, documentModelsTemplate as wt, documentModelOperationsModuleTestFileTemplate as x, editorsIndexTemplate as xt, upgradeTransitionTemplate as y, geminiSettingsTemplate as yt, documentModelOperationModuleActionsFileTemplate as z, driveExplorerFileTemplate as zt };
|
|
6375
|
+
export { tsConfigTemplate as $, documentModelHooksFileTemplate as A, claudeSettingsLocalTemplate as At, getModuleExportType as B, appDriveContentsFileTemplate as Bt, makeActionsImports as C, documentModelsIndexTemplate as Ct, documentModelSrcIndexFileTemplate as D, dockerfileTemplate as Dt, documentModelSrcUtilsTemplate as E, nginxConfTemplate as Et, documentModelPhFactoriesFileTemplate as F, folderTreeFileTemplate as Ft, documentModelGenControllerFileTemplate as G, documentModelDocumentTypeTemplate as H, ts as Ht, documentModelOperationsModuleOperationsFileTemplate as I, appFoldersFileTemplate as It, documentEditorModuleFileTemplate as J, documentModelGenActionsFileTemplate as K, documentModelOperationsModuleErrorFileTemplate as L, appFilesFileTemplate as Lt, documentModelGenTypesTemplate as M, appEditorFileTemplate as Mt, documentModelSchemaIndexTemplate as N, appConfigFileTemplate as Nt, documentModelModuleFileTemplate as O, connectEntrypointTemplate as Ot, documentModelGenReducerFileTemplate as P, driveExplorerNavigationBreadcrumbsFileTemplate as Pt, viteConfigTemplate as Q, documentModelOperationsModuleCreatorsFileTemplate as R, emptyStateFileTemplate as Rt, makeActionImportNames as S, editorsTemplate as St, documentModelTestFileTemplate as T, switchboardEntrypointTemplate as Tt, documentModelDocumentSchemaFileTemplate as U, documentModelGenIndexFileTemplate as V, createDocumentFileTemplate as Vt, documentModelGenCreatorsFileTemplate as W, docsFromCliHelpTemplate as X, documentEditorEditorFileTemplate as Y, vitestConfigTemplate as Z, analyticsFactoryTemplate as _, gitIgnoreTemplate as _t, subgraphLibFileTemplate as a, buildPowerhouseConfigTemplate as at, upgradeManifestTemplate as b, eslintConfigTemplate as bt, relationalDbProcessorTemplate as c, exportsTemplate as ct, relationalDbFactoryTemplate as d, mcpTemplate as dt, tsconfigPathsTemplate as et, processorsIndexTemplate as f, mainTsxTemplate as ft, analyticsIndexTemplate as g, indexHtmlTemplate as gt, analyticsProcessorTemplate as h, legacyIndexHtmlTemplate as ht, customSubgraphSchemaTemplate as i, ManifestTemplate as it, documentModelGenUtilsTemplate as j, agentsTemplate as jt, documentModelIndexTemplate as k, cursorMcpTemplate as kt, relationalDbMigrationsTemplate as l, packageJsonTemplate as lt, factoryBuildersTemplate as m, indexTsTemplate as mt, documentModelSubgraphSchemaTemplate as n, styleTemplate as nt, subgraphIndexFileTemplate as o, packageJsonExportsTemplate as ot, processorsFactoryTemplate as p, licenseTemplate as pt, documentModelRootActionsFileTemplate as q, customSubgraphResolversTemplate as r, readmeTemplate as rt, relationalDbSchemaTemplate as s, packageJsonScriptsTemplate as st, documentModelSubgraphResolversTemplate as t, subgraphsIndexTemplate as tt, relationalDbIndexTemplate as u, npmrcTemplate as ut, documentModelUtilsTemplate as v, syncAndPublishWorkflowTemplate as vt, makeTestCaseForAction as w, documentModelsTemplate as wt, documentModelOperationsModuleTestFileTemplate as x, editorsIndexTemplate as xt, upgradeTransitionTemplate as y, geminiSettingsTemplate as yt, documentModelOperationModuleActionsFileTemplate as z, driveExplorerFileTemplate as zt };
|
|
4612
6376
|
|
|
4613
|
-
//# sourceMappingURL=templates-
|
|
6377
|
+
//# sourceMappingURL=templates-Cu_xr8aR.mjs.map
|