@nfdi4plants/arctrl 3.0.0 → 3.0.3
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/ts/ts/CWL/Decode.d.ts +15 -11
- package/dist/ts/ts/CWL/Decode.d.ts.map +1 -1
- package/dist/ts/ts/CWL/Decode.js +73 -23
- package/dist/ts/ts/CWL/Encode.d.ts +8 -1
- package/dist/ts/ts/CWL/Encode.d.ts.map +1 -1
- package/dist/ts/ts/CWL/Encode.js +15 -11
- package/dist/ts/ts/CWL/Requirements.d.ts +1 -1
- package/dist/ts/ts/CWL/Requirements.js +1 -1
- package/dist/ts/ts/CWL/WorkflowSteps.d.ts +1 -1
- package/dist/ts/ts/CWL/WorkflowSteps.js +1 -1
- package/dist/ts/ts/Conversion/Basic.d.ts.map +1 -1
- package/dist/ts/ts/Conversion/Basic.js +6 -6
- package/dist/ts/ts/Conversion/Workflow.js +3 -3
- package/dist/ts/ts/Core/DataContext.d.ts +21 -29
- package/dist/ts/ts/Core/DataContext.d.ts.map +1 -1
- package/dist/ts/ts/Core/DataContext.js +70 -84
- package/dist/ts/ts/Core/Datamap.d.ts.map +1 -1
- package/dist/ts/ts/Core/Datamap.js +9 -10
- package/dist/ts/ts/Json/Datamap/DataContext.d.ts.map +1 -1
- package/dist/ts/ts/Json/Datamap/DataContext.js +6 -6
- package/dist/ts/ts/ROCrate/LDTypes/Dataset.js +1 -1
- package/dist/ts/ts/ROCrateIO.d.ts +1 -0
- package/dist/ts/ts/ROCrateIO.d.ts.map +1 -1
- package/dist/ts/ts/ROCrateIO.js +6 -3
- package/dist/ts/ts/Spreadsheet/DatamapTable/DatamapColumn.d.ts.map +1 -1
- package/dist/ts/ts/Spreadsheet/DatamapTable/DatamapColumn.js +1 -2
- package/dist/ts/ts/Spreadsheet/DatamapTable/DatamapHeader.d.ts.map +1 -1
- package/dist/ts/ts/Spreadsheet/DatamapTable/DatamapHeader.js +6 -7
- package/dist/ts/ts/Spreadsheet/DatamapTable/DatamapTable.d.ts.map +1 -1
- package/dist/ts/ts/Spreadsheet/DatamapTable/DatamapTable.js +2 -2
- package/dist/ts/ts/Yaml/ValidationPackage.d.ts +1 -1
- package/dist/ts/ts/Yaml/ValidationPackage.js +6 -6
- package/dist/ts/ts/Yaml/ValidationPackagesConfig.d.ts +1 -1
- package/dist/ts/ts/Yaml/ValidationPackagesConfig.js +6 -6
- package/dist/ts/ts/Yaml.js +1 -1
- package/dist/ts/ts/fable_modules/{YAMLicious.1.0.0-alpha.3 → YAMLicious.1.0.0-alpha.5}/Encode.fs.js +9 -9
- package/dist/ts/ts/fable_modules/YAMLicious.1.0.0-alpha.5/Escapes.fs.js +313 -0
- package/dist/ts/ts/fable_modules/{YAMLicious.1.0.0-alpha.3 → YAMLicious.1.0.0-alpha.5}/FlowToBlock.fs.js +14 -12
- package/dist/ts/ts/fable_modules/YAMLicious.1.0.0-alpha.5/Persil.fs.js +562 -0
- package/dist/ts/ts/fable_modules/{YAMLicious.1.0.0-alpha.3 → YAMLicious.1.0.0-alpha.5}/Preprocessing.fs.js +52 -12
- package/dist/ts/ts/fable_modules/YAMLicious.1.0.0-alpha.5/Reader.fs.js +1314 -0
- package/dist/ts/ts/fable_modules/{YAMLicious.1.0.0-alpha.3 → YAMLicious.1.0.0-alpha.5}/Regex.fs.js +7 -1
- package/dist/ts/ts/fable_modules/YAMLicious.1.0.0-alpha.5/RegexActivePatterns.fs.js +313 -0
- package/dist/ts/ts/fable_modules/YAMLicious.1.0.0-alpha.5/StringBuffer.fs.js +60 -0
- package/dist/ts/ts/fable_modules/YAMLicious.1.0.0-alpha.5/Writer.fs.js +391 -0
- package/dist/ts/ts/fable_modules/YAMLicious.1.0.0-alpha.5/YAMLiciousTypes.fs.js +317 -0
- package/package.json +1 -1
- package/dist/ts/ts/fable_modules/YAMLicious.1.0.0-alpha.3/Persil.fs.js +0 -45
- package/dist/ts/ts/fable_modules/YAMLicious.1.0.0-alpha.3/Reader.fs.js +0 -539
- package/dist/ts/ts/fable_modules/YAMLicious.1.0.0-alpha.3/RegexActivePatterns.fs.js +0 -216
- package/dist/ts/ts/fable_modules/YAMLicious.1.0.0-alpha.3/Writer.fs.js +0 -164
- package/dist/ts/ts/fable_modules/YAMLicious.1.0.0-alpha.3/YAMLiciousTypes.fs.js +0 -152
- /package/dist/ts/ts/fable_modules/{YAMLicious.1.0.0-alpha.3 → YAMLicious.1.0.0-alpha.5}/Decode.fs.js +0 -0
- /package/dist/ts/ts/fable_modules/{YAMLicious.1.0.0-alpha.3 → YAMLicious.1.0.0-alpha.5}/Interop/JsInterop.fs.js +0 -0
|
@@ -0,0 +1,562 @@
|
|
|
1
|
+
import { max, length, takeWhile, toList } from '../../../node_modules/@fable-org/fable-library-js/Seq.js';
|
|
2
|
+
import { comparePrimitives, getEnumerator, disposeSafe, equals } from '../../../node_modules/@fable-org/fable-library-js/Util.js';
|
|
3
|
+
import { parse } from '../../../node_modules/@fable-org/fable-library-js/Int32.js';
|
|
4
|
+
import { QuotedStringKind_SingleQuotedString, StringMapEntry, QuotedStringKind_DoubleQuotedString, YAMLDirective } from './YAMLiciousTypes.fs.js';
|
|
5
|
+
import { StringBuffer_$ctor, StringBuffer__Append_244C7CD6, StringBuffer__get_Length, StringBuffer__get_Item_Z524259A4, StringBuffer__Append_Z721C83C5 } from './StringBuffer.fs.js';
|
|
6
|
+
import { item, tryHead, tryFind, takeWhile as takeWhile$1, take, append } from '../../../node_modules/@fable-org/fable-library-js/Array.js';
|
|
7
|
+
import { trimStart, trimEnd, replace, substring, toText, printf, isNullOrWhiteSpace, split } from '../../../node_modules/@fable-org/fable-library-js/String.js';
|
|
8
|
+
import { toString } from '../../../node_modules/@fable-org/fable-library-js/Types.js';
|
|
9
|
+
import { addToDict } from '../../../node_modules/@fable-org/fable-library-js/MapUtil.js';
|
|
10
|
+
import { FSharpSet__Contains, ofList, empty } from '../../../node_modules/@fable-org/fable-library-js/Set.js';
|
|
11
|
+
import { value, defaultArg, map, unwrap } from '../../../node_modules/@fable-org/fable-library-js/Option.js';
|
|
12
|
+
import { replace as replace$1, match } from '../../../node_modules/@fable-org/fable-library-js/RegExp.js';
|
|
13
|
+
import { ofArray, isEmpty, head, tail, toArray, reverse } from '../../../node_modules/@fable-org/fable-library-js/List.js';
|
|
14
|
+
import { isWhiteSpace } from '../../../node_modules/@fable-org/fable-library-js/Char.js';
|
|
15
|
+
import { add, empty as empty$1 } from '../../../node_modules/@fable-org/fable-library-js/Map.js';
|
|
16
|
+
|
|
17
|
+
function nextStringIndex(dict) {
|
|
18
|
+
if (dict.size === 0) {
|
|
19
|
+
return 0;
|
|
20
|
+
} else {
|
|
21
|
+
return max(dict.keys(), {
|
|
22
|
+
Compare: comparePrimitives
|
|
23
|
+
}) + 1 | 0;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function foldSingleQuoted(s) {
|
|
27
|
+
const lines = s.split("\n");
|
|
28
|
+
const sb = StringBuffer_$ctor();
|
|
29
|
+
for (let i = 0; i <= lines.length - 1; i++) {
|
|
30
|
+
let line = item(i, lines);
|
|
31
|
+
if (i > 0) {
|
|
32
|
+
line = trimStart(line);
|
|
33
|
+
}
|
|
34
|
+
if (i < lines.length - 1) {
|
|
35
|
+
line = trimEnd(line);
|
|
36
|
+
}
|
|
37
|
+
if (line.length === 0) {
|
|
38
|
+
StringBuffer__Append_244C7CD6(sb, "\n");
|
|
39
|
+
} else {
|
|
40
|
+
if (StringBuffer__get_Length(sb) > 0 && StringBuffer__get_Item_Z524259A4(sb, StringBuffer__get_Length(sb) - 1) !== "\n") {
|
|
41
|
+
StringBuffer__Append_Z721C83C5(sb, " ");
|
|
42
|
+
}
|
|
43
|
+
StringBuffer__Append_Z721C83C5(sb, line);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return replace(toString(sb), "''", "'");
|
|
47
|
+
}
|
|
48
|
+
function parseSingleQuotedSegment(s, startIndex) {
|
|
49
|
+
const content = StringBuffer_$ctor();
|
|
50
|
+
let i = startIndex + 1;
|
|
51
|
+
let closed = false;
|
|
52
|
+
while (i < s.length && !closed) {
|
|
53
|
+
const ch = s[i];
|
|
54
|
+
if (ch === "'") {
|
|
55
|
+
if (i + 1 < s.length && s[i + 1] === "'") {
|
|
56
|
+
StringBuffer__Append_Z721C83C5(content, "''");
|
|
57
|
+
i = i + 2 | 0;
|
|
58
|
+
} else {
|
|
59
|
+
closed = true;
|
|
60
|
+
i = i + 1 | 0;
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
StringBuffer__Append_244C7CD6(content, ch);
|
|
64
|
+
i = i + 1 | 0;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return [closed, toString(content), i];
|
|
68
|
+
}
|
|
69
|
+
function parseDoubleQuotedSegment(s, startIndex) {
|
|
70
|
+
const content = StringBuffer_$ctor();
|
|
71
|
+
let i = startIndex + 1;
|
|
72
|
+
let closed = false;
|
|
73
|
+
let escaped = false;
|
|
74
|
+
while (i < s.length && !closed) {
|
|
75
|
+
const ch = s[i];
|
|
76
|
+
if (escaped) {
|
|
77
|
+
StringBuffer__Append_244C7CD6(content, ch);
|
|
78
|
+
escaped = false;
|
|
79
|
+
i = i + 1 | 0;
|
|
80
|
+
} else {
|
|
81
|
+
switch (ch) {
|
|
82
|
+
case '"': {
|
|
83
|
+
closed = true;
|
|
84
|
+
i = i + 1 | 0;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
case "\\": {
|
|
88
|
+
StringBuffer__Append_244C7CD6(content, ch);
|
|
89
|
+
escaped = true;
|
|
90
|
+
i = i + 1 | 0;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
default: {
|
|
94
|
+
StringBuffer__Append_244C7CD6(content, ch);
|
|
95
|
+
i = i + 1 | 0;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return [closed, toString(content), i];
|
|
101
|
+
}
|
|
102
|
+
function isTokenBoundaryStart(s, quoteIndex) {
|
|
103
|
+
let c, c_1;
|
|
104
|
+
let i = quoteIndex - 1;
|
|
105
|
+
while (i >= 0 && (c = s[i], c === " " ? true : c === " ")) {
|
|
106
|
+
i = i - 1 | 0;
|
|
107
|
+
}
|
|
108
|
+
if (i < 0) {
|
|
109
|
+
return true;
|
|
110
|
+
} else {
|
|
111
|
+
const matchValue = s[i];
|
|
112
|
+
switch (matchValue) {
|
|
113
|
+
case "\n":
|
|
114
|
+
case "\r":
|
|
115
|
+
case ",":
|
|
116
|
+
case "-":
|
|
117
|
+
case ":":
|
|
118
|
+
case "?":
|
|
119
|
+
case "[":
|
|
120
|
+
case "{":
|
|
121
|
+
return true;
|
|
122
|
+
default: {
|
|
123
|
+
let start = i;
|
|
124
|
+
while (start >= 0 && !(c_1 = s[start], ((((((((c_1 === " " ? true : c_1 === " ") ? true : c_1 === "\n") ? true : c_1 === "\r") ? true : c_1 === ":") ? true : c_1 === "-") ? true : c_1 === ",") ? true : c_1 === "[") ? true : c_1 === "{") ? true : c_1 === "?")) {
|
|
125
|
+
start = start - 1 | 0;
|
|
126
|
+
}
|
|
127
|
+
const token = substring(s, start + 1, i - start);
|
|
128
|
+
if (token.startsWith("!")) {
|
|
129
|
+
return true;
|
|
130
|
+
} else {
|
|
131
|
+
return token.startsWith("&");
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function isTokenBoundaryEnd(s, nextIndex) {
|
|
138
|
+
let c;
|
|
139
|
+
let i = nextIndex;
|
|
140
|
+
while (i < s.length && (c = s[i], c === " " ? true : c === " ")) {
|
|
141
|
+
i = i + 1 | 0;
|
|
142
|
+
}
|
|
143
|
+
if (i >= s.length) {
|
|
144
|
+
return true;
|
|
145
|
+
} else {
|
|
146
|
+
const matchValue = s[i];
|
|
147
|
+
switch (matchValue) {
|
|
148
|
+
case "\n":
|
|
149
|
+
case "\r":
|
|
150
|
+
case "#":
|
|
151
|
+
case ",":
|
|
152
|
+
case ":":
|
|
153
|
+
case "]":
|
|
154
|
+
case "}":
|
|
155
|
+
return true;
|
|
156
|
+
default:
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function replaceQuotedStrings(target, dict, protectedBlockScalarLines, s) {
|
|
162
|
+
const sb = StringBuffer_$ctor();
|
|
163
|
+
let i = 0;
|
|
164
|
+
let n = nextStringIndex(dict);
|
|
165
|
+
let inComment = false;
|
|
166
|
+
const length = s.length | 0;
|
|
167
|
+
let lineIndex = 0;
|
|
168
|
+
const appendPlaceholder = (entry) => {
|
|
169
|
+
const currentN = n | 0;
|
|
170
|
+
n = n + 1 | 0;
|
|
171
|
+
addToDict(dict, currentN, entry);
|
|
172
|
+
StringBuffer__Append_Z721C83C5(sb, toText(printf("<s f=%i/>"))(currentN));
|
|
173
|
+
};
|
|
174
|
+
const appendChar = (c) => {
|
|
175
|
+
StringBuffer__Append_244C7CD6(sb, c);
|
|
176
|
+
if (c === "\n") {
|
|
177
|
+
lineIndex = lineIndex + 1 | 0;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
const appendText = (text) => {
|
|
181
|
+
const enumerator = getEnumerator(text.split(""));
|
|
182
|
+
try {
|
|
183
|
+
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
184
|
+
appendChar(enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]());
|
|
185
|
+
}
|
|
186
|
+
} finally {
|
|
187
|
+
disposeSafe(enumerator);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
const advanceLineIndex = (startIndex, endIndex) => {
|
|
191
|
+
for (let j = startIndex; j <= endIndex - 1; j++) {
|
|
192
|
+
if (s[j] === "\n") {
|
|
193
|
+
lineIndex = lineIndex + 1 | 0;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
while (i < length) {
|
|
198
|
+
const c_2 = s[i];
|
|
199
|
+
if (FSharpSet__Contains(protectedBlockScalarLines, lineIndex)) {
|
|
200
|
+
appendChar(c_2);
|
|
201
|
+
i = i + 1 | 0;
|
|
202
|
+
if (c_2 === "\n") {
|
|
203
|
+
inComment = false;
|
|
204
|
+
}
|
|
205
|
+
} else if (inComment) {
|
|
206
|
+
appendChar(c_2);
|
|
207
|
+
i = i + 1 | 0;
|
|
208
|
+
if (c_2 === "\n") {
|
|
209
|
+
inComment = false;
|
|
210
|
+
}
|
|
211
|
+
} else {
|
|
212
|
+
switch (c_2) {
|
|
213
|
+
case '"': {
|
|
214
|
+
if (equals(target, QuotedStringKind_DoubleQuotedString())) {
|
|
215
|
+
if (isTokenBoundaryStart(s, i)) {
|
|
216
|
+
const patternInput_2 = parseDoubleQuotedSegment(s, i);
|
|
217
|
+
const nextIndex_2 = patternInput_2[2] | 0;
|
|
218
|
+
if (patternInput_2[0] && isTokenBoundaryEnd(s, nextIndex_2)) {
|
|
219
|
+
appendPlaceholder(new StringMapEntry(patternInput_2[1], QuotedStringKind_DoubleQuotedString()));
|
|
220
|
+
advanceLineIndex(i, nextIndex_2);
|
|
221
|
+
} else {
|
|
222
|
+
appendText(substring(s, i, nextIndex_2 - i));
|
|
223
|
+
}
|
|
224
|
+
i = nextIndex_2 | 0;
|
|
225
|
+
} else {
|
|
226
|
+
appendChar(c_2);
|
|
227
|
+
i = i + 1 | 0;
|
|
228
|
+
}
|
|
229
|
+
} else {
|
|
230
|
+
const nextIndex_3 = parseDoubleQuotedSegment(s, i)[2] | 0;
|
|
231
|
+
appendText(substring(s, i, nextIndex_3 - i));
|
|
232
|
+
i = nextIndex_3 | 0;
|
|
233
|
+
}
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
case "#": {
|
|
237
|
+
inComment = true;
|
|
238
|
+
appendChar(c_2);
|
|
239
|
+
i = i + 1 | 0;
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
case "'": {
|
|
243
|
+
if (equals(target, QuotedStringKind_SingleQuotedString())) {
|
|
244
|
+
if (isTokenBoundaryStart(s, i)) {
|
|
245
|
+
const patternInput = parseSingleQuotedSegment(s, i);
|
|
246
|
+
const nextIndex = patternInput[2] | 0;
|
|
247
|
+
if (patternInput[0] && isTokenBoundaryEnd(s, nextIndex)) {
|
|
248
|
+
appendPlaceholder(new StringMapEntry(foldSingleQuoted(patternInput[1]), QuotedStringKind_SingleQuotedString()));
|
|
249
|
+
advanceLineIndex(i, nextIndex);
|
|
250
|
+
} else {
|
|
251
|
+
appendText(substring(s, i, nextIndex - i));
|
|
252
|
+
}
|
|
253
|
+
i = nextIndex | 0;
|
|
254
|
+
} else {
|
|
255
|
+
appendChar(c_2);
|
|
256
|
+
i = i + 1 | 0;
|
|
257
|
+
}
|
|
258
|
+
} else {
|
|
259
|
+
const nextIndex_1 = parseSingleQuotedSegment(s, i)[2] | 0;
|
|
260
|
+
appendText(substring(s, i, nextIndex_1 - i));
|
|
261
|
+
i = nextIndex_1 | 0;
|
|
262
|
+
}
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
default: {
|
|
266
|
+
appendChar(c_2);
|
|
267
|
+
i = i + 1 | 0;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return toString(sb);
|
|
273
|
+
}
|
|
274
|
+
function encodingCleanUp(s) {
|
|
275
|
+
return replace(s, "\r\n", "\n");
|
|
276
|
+
}
|
|
277
|
+
function countLeadingSpaces(line) {
|
|
278
|
+
return length(takeWhile((c) => c === " ", line.split("")));
|
|
279
|
+
}
|
|
280
|
+
function parseBlockScalarHeaderToken(token) {
|
|
281
|
+
let c;
|
|
282
|
+
if (isNullOrWhiteSpace(token)) {
|
|
283
|
+
return false;
|
|
284
|
+
} else {
|
|
285
|
+
const t = token.trim();
|
|
286
|
+
if (t.length === 0) {
|
|
287
|
+
return false;
|
|
288
|
+
} else {
|
|
289
|
+
const first = t[0];
|
|
290
|
+
if (first !== "|" && first !== ">") {
|
|
291
|
+
return false;
|
|
292
|
+
} else {
|
|
293
|
+
let valid = true;
|
|
294
|
+
let seenIndent = false;
|
|
295
|
+
let seenChomp = false;
|
|
296
|
+
let idx = 1;
|
|
297
|
+
while (idx < t.length && valid) {
|
|
298
|
+
const matchValue = t[idx];
|
|
299
|
+
let matchResult;
|
|
300
|
+
if (c = matchValue, c >= "1" && c <= "9") {
|
|
301
|
+
matchResult = 0;
|
|
302
|
+
} else {
|
|
303
|
+
switch (matchValue) {
|
|
304
|
+
case "+":
|
|
305
|
+
case "-": {
|
|
306
|
+
matchResult = 1;
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
default:
|
|
310
|
+
matchResult = 2;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
switch (matchResult) {
|
|
314
|
+
case 0: {
|
|
315
|
+
if (seenIndent) {
|
|
316
|
+
valid = false;
|
|
317
|
+
} else {
|
|
318
|
+
seenIndent = true;
|
|
319
|
+
}
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
case 1: {
|
|
323
|
+
if (seenChomp) {
|
|
324
|
+
valid = false;
|
|
325
|
+
} else {
|
|
326
|
+
seenChomp = true;
|
|
327
|
+
}
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
case 2: {
|
|
331
|
+
valid = false;
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
idx = idx + 1 | 0;
|
|
336
|
+
}
|
|
337
|
+
return valid;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
function tryDetectBlockScalarHeaderIndent(line) {
|
|
343
|
+
let loop, idx_3;
|
|
344
|
+
const trimmed = trimStart(line);
|
|
345
|
+
const afterDash = trimmed.startsWith("- ") ? trimStart(substring(trimmed, 2)) : trimmed;
|
|
346
|
+
const token = tryHead(split((loop = (current_mut) => {
|
|
347
|
+
loop:
|
|
348
|
+
while (true) {
|
|
349
|
+
const current = current_mut;
|
|
350
|
+
const c = trimStart(current);
|
|
351
|
+
if (c.startsWith("&")) {
|
|
352
|
+
const idx = c.indexOf(" ") | 0;
|
|
353
|
+
if (idx < 0) {
|
|
354
|
+
return "";
|
|
355
|
+
} else {
|
|
356
|
+
current_mut = substring(c, idx + 1);
|
|
357
|
+
continue loop;
|
|
358
|
+
}
|
|
359
|
+
} else if (c.startsWith("!<")) {
|
|
360
|
+
const idx_1 = c.indexOf(">") | 0;
|
|
361
|
+
if (idx_1 < 0) {
|
|
362
|
+
return c;
|
|
363
|
+
} else {
|
|
364
|
+
current_mut = substring(c, idx_1 + 1);
|
|
365
|
+
continue loop;
|
|
366
|
+
}
|
|
367
|
+
} else if (c.startsWith("!") && !c.startsWith("|") && !c.startsWith(">")) {
|
|
368
|
+
const idx_2 = c.indexOf(" ") | 0;
|
|
369
|
+
if (idx_2 < 0) {
|
|
370
|
+
return "";
|
|
371
|
+
} else {
|
|
372
|
+
current_mut = substring(c, idx_2 + 1);
|
|
373
|
+
continue loop;
|
|
374
|
+
}
|
|
375
|
+
} else {
|
|
376
|
+
return c;
|
|
377
|
+
}
|
|
378
|
+
break;
|
|
379
|
+
}
|
|
380
|
+
}, loop((idx_3 = afterDash.indexOf(":") | 0, idx_3 >= 0 ? trimStart(substring(afterDash, idx_3 + 1)) : afterDash))), [" ", " "], void 0, 1));
|
|
381
|
+
let matchResult, t_1;
|
|
382
|
+
if (token != null) {
|
|
383
|
+
if (parseBlockScalarHeaderToken(value(token))) {
|
|
384
|
+
matchResult = 0;
|
|
385
|
+
t_1 = value(token);
|
|
386
|
+
} else {
|
|
387
|
+
matchResult = 1;
|
|
388
|
+
}
|
|
389
|
+
} else {
|
|
390
|
+
matchResult = 1;
|
|
391
|
+
}
|
|
392
|
+
switch (matchResult) {
|
|
393
|
+
case 0:
|
|
394
|
+
return countLeadingSpaces(line);
|
|
395
|
+
default:
|
|
396
|
+
return void 0;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
function detectBlockScalarContentLines(yamlString) {
|
|
400
|
+
const lines = split(replace(replace(yamlString, "\r\n", "\n"), "\r", "\n"), ["\n"], void 0, 0);
|
|
401
|
+
const protectedLines = [];
|
|
402
|
+
let i = 0;
|
|
403
|
+
let openBlockIndent = void 0;
|
|
404
|
+
while (i < lines.length) {
|
|
405
|
+
if (openBlockIndent == null) {
|
|
406
|
+
const matchValue = tryDetectBlockScalarHeaderIndent(item(i, lines));
|
|
407
|
+
if (matchValue == null) {
|
|
408
|
+
i = i + 1 | 0;
|
|
409
|
+
} else {
|
|
410
|
+
const indent = value(matchValue) | 0;
|
|
411
|
+
openBlockIndent = indent;
|
|
412
|
+
i = i + 1 | 0;
|
|
413
|
+
}
|
|
414
|
+
} else {
|
|
415
|
+
const headerIndent = value(openBlockIndent) | 0;
|
|
416
|
+
const line = item(i, lines);
|
|
417
|
+
if (line.trim() === "" ? true : countLeadingSpaces(line) > headerIndent) {
|
|
418
|
+
const value = void protectedLines.push(i);
|
|
419
|
+
i = i + 1 | 0;
|
|
420
|
+
} else {
|
|
421
|
+
openBlockIndent = void 0;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
return ofList(toList(protectedLines), {
|
|
426
|
+
Compare: comparePrimitives
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
function stringCleanUpWithProtected(dict, protectedBlockScalarLines, s) {
|
|
430
|
+
return replaceQuotedStrings(QuotedStringKind_DoubleQuotedString(), dict, protectedBlockScalarLines, s);
|
|
431
|
+
}
|
|
432
|
+
function singleQuotedStringCleanUpWithProtected(dict, protectedBlockScalarLines, s) {
|
|
433
|
+
return replaceQuotedStrings(QuotedStringKind_SingleQuotedString(), dict, protectedBlockScalarLines, s);
|
|
434
|
+
}
|
|
435
|
+
function stringCleanUp(dict, s) {
|
|
436
|
+
return stringCleanUpWithProtected(dict, empty({
|
|
437
|
+
Compare: comparePrimitives
|
|
438
|
+
}), s);
|
|
439
|
+
}
|
|
440
|
+
function singleQuotedStringCleanUp(dict, s) {
|
|
441
|
+
return singleQuotedStringCleanUpWithProtected(dict, empty({
|
|
442
|
+
Compare: comparePrimitives
|
|
443
|
+
}), s);
|
|
444
|
+
}
|
|
445
|
+
function commentCleanUp(dict, s) {
|
|
446
|
+
let n = 0;
|
|
447
|
+
return replace$1(/#(?<comment>.*)/gu, s, (m) => {
|
|
448
|
+
const v = m.groups && m.groups.comment || "";
|
|
449
|
+
const currentN = n | 0;
|
|
450
|
+
n = n + 1 | 0;
|
|
451
|
+
addToDict(dict, currentN, v);
|
|
452
|
+
return toText(printf("<c f=%i/>"))(currentN);
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
function cut(yamlString) {
|
|
456
|
+
let matchValue;
|
|
457
|
+
const lines = ofArray(split(yamlString, ["\n"], void 0, 0));
|
|
458
|
+
const withoutLeading = !isEmpty(lines) ? head(lines) === "" ? tail(lines) : lines : lines;
|
|
459
|
+
return toArray((matchValue = reverse(withoutLeading), !isEmpty(matchValue) ? head(matchValue) === "" ? reverse(tail(matchValue)) : withoutLeading : withoutLeading));
|
|
460
|
+
}
|
|
461
|
+
function parseYAMLDirective(line) {
|
|
462
|
+
const m = match(/^%YAML\s+(\d+)\.(\d+)/gu, line.trim());
|
|
463
|
+
if (m != null) {
|
|
464
|
+
return new YAMLDirective(parse(m[1] || "", 511, false, 32), parse(m[2] || "", 511, false, 32));
|
|
465
|
+
} else {
|
|
466
|
+
return void 0;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
function parseTagDirective(line) {
|
|
470
|
+
const m = match(/^%TAG\s+(\S+)\s+(\S+)/gu, line.trim());
|
|
471
|
+
if (m != null) {
|
|
472
|
+
return [m[1] || "", m[2] || ""];
|
|
473
|
+
} else {
|
|
474
|
+
return void 0;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
function isDocumentMarker(marker, line) {
|
|
478
|
+
const trimmed = trimStart(line);
|
|
479
|
+
if (!trimmed.startsWith(marker)) {
|
|
480
|
+
return false;
|
|
481
|
+
} else if (trimmed.length === marker.length) {
|
|
482
|
+
return true;
|
|
483
|
+
} else {
|
|
484
|
+
return isWhiteSpace(trimmed[marker.length]);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
function tryInlineContentAfterStartMarker(line) {
|
|
488
|
+
const trimmed = trimStart(line);
|
|
489
|
+
if (!trimmed.startsWith("---")) {
|
|
490
|
+
return void 0;
|
|
491
|
+
} else {
|
|
492
|
+
const rest = trimStart(substring(trimmed, 3));
|
|
493
|
+
if (isNullOrWhiteSpace(rest) ? true : rest.startsWith("#")) {
|
|
494
|
+
return void 0;
|
|
495
|
+
} else {
|
|
496
|
+
return rest;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
function pipeline(yamlString) {
|
|
501
|
+
let matchValue_2;
|
|
502
|
+
const stringMap = /* @__PURE__ */ new Map([]);
|
|
503
|
+
const commentMap = /* @__PURE__ */ new Map([]);
|
|
504
|
+
const normalizedContent = encodingCleanUp(yamlString);
|
|
505
|
+
const protectedBlockScalarLines = detectBlockScalarContentLines(normalizedContent);
|
|
506
|
+
const lines = cut(commentCleanUp(commentMap, stringCleanUpWithProtected(stringMap, protectedBlockScalarLines, singleQuotedStringCleanUpWithProtected(stringMap, protectedBlockScalarLines, normalizedContent))));
|
|
507
|
+
let directivePreludeLength;
|
|
508
|
+
if (defaultArg(map((line) => trimStart(line).startsWith("%"), tryFind((l) => {
|
|
509
|
+
const t = l.trim();
|
|
510
|
+
if (t !== "") {
|
|
511
|
+
return !t.startsWith("#");
|
|
512
|
+
} else {
|
|
513
|
+
return false;
|
|
514
|
+
}
|
|
515
|
+
}, lines)), false)) {
|
|
516
|
+
const array_2 = takeWhile$1((l_1) => {
|
|
517
|
+
const t_1 = trimStart(l_1);
|
|
518
|
+
if (t_1.startsWith("%") ? true : t_1.startsWith("#")) {
|
|
519
|
+
return true;
|
|
520
|
+
} else {
|
|
521
|
+
return t_1.trim() === "";
|
|
522
|
+
}
|
|
523
|
+
}, lines);
|
|
524
|
+
directivePreludeLength = array_2.length;
|
|
525
|
+
} else {
|
|
526
|
+
directivePreludeLength = 0;
|
|
527
|
+
}
|
|
528
|
+
const directiveLines = take(directivePreludeLength, lines);
|
|
529
|
+
const contentLines = lines.slice(directivePreludeLength, lines.length);
|
|
530
|
+
let yamlVersion = void 0;
|
|
531
|
+
let tagHandles = add("!!", "tag:yaml.org,2002:", add("!", "!", empty$1({
|
|
532
|
+
Compare: comparePrimitives
|
|
533
|
+
})));
|
|
534
|
+
for (let idx = 0; idx <= directiveLines.length - 1; idx++) {
|
|
535
|
+
const line_1 = item(idx, directiveLines);
|
|
536
|
+
const matchValue = parseYAMLDirective(line_1);
|
|
537
|
+
if (matchValue == null) {
|
|
538
|
+
const matchValue_1 = parseTagDirective(line_1);
|
|
539
|
+
if (matchValue_1 == null) {
|
|
540
|
+
} else {
|
|
541
|
+
const t_2 = value(matchValue_1)[1];
|
|
542
|
+
const h = value(matchValue_1)[0];
|
|
543
|
+
tagHandles = add(h, t_2, tagHandles);
|
|
544
|
+
}
|
|
545
|
+
} else {
|
|
546
|
+
const v = value(matchValue);
|
|
547
|
+
if (yamlVersion != null) {
|
|
548
|
+
throw new Error("Duplicate YAML directive");
|
|
549
|
+
}
|
|
550
|
+
yamlVersion = v;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
return {
|
|
554
|
+
CommentMap: commentMap,
|
|
555
|
+
Lines: contentLines.length > 0 && isDocumentMarker("---", item(0, contentLines)) ? (matchValue_2 = tryInlineContentAfterStartMarker(item(0, contentLines)), matchValue_2 == null ? contentLines.slice(1, contentLines.length) : append([value(matchValue_2)], contentLines.slice(1, contentLines.length))) : contentLines,
|
|
556
|
+
StringMap: stringMap,
|
|
557
|
+
TagHandles: tagHandles,
|
|
558
|
+
YAMLVersion: unwrap(yamlVersion)
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
export { commentCleanUp, cut, encodingCleanUp, parseTagDirective, parseYAMLDirective, pipeline, singleQuotedStringCleanUp, stringCleanUp };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { length, takeWhile } from '../../../node_modules/@fable-org/fable-library-js/Seq.js';
|
|
2
|
+
import { trimStart, substring } from '../../../node_modules/@fable-org/fable-library-js/String.js';
|
|
3
|
+
import { isWhiteSpace } from '../../../node_modules/@fable-org/fable-library-js/Char.js';
|
|
2
4
|
import { Config_init_71136F3F, Config__get_WhitespaceString, Config, PreprocessorElement_Line, PreprocessorElement_Intendation, Preprocessor, PreprocessorElement_Level } from './YAMLiciousTypes.fs.js';
|
|
3
5
|
import { value } from '../../../node_modules/@fable-org/fable-library-js/Option.js';
|
|
4
|
-
import {
|
|
6
|
+
import { StringBuffer_$ctor, StringBuffer__AppendLine_Z721C83C5 } from './StringBuffer.fs.js';
|
|
5
7
|
import { getEnumerator, disposeSafe } from '../../../node_modules/@fable-org/fable-library-js/Util.js';
|
|
6
8
|
import { toString } from '../../../node_modules/@fable-org/fable-library-js/Types.js';
|
|
7
9
|
import { pipeline } from './Persil.fs.js';
|
|
@@ -10,11 +12,27 @@ import { isEmpty, tail, head, cons, takeWhile as takeWhile$1, skipWhile, reverse
|
|
|
10
12
|
function ReadHelpers_indentLevel(line) {
|
|
11
13
|
return length(takeWhile((c) => c === " ", line.split("")));
|
|
12
14
|
}
|
|
15
|
+
function isDocumentMarker(marker, line) {
|
|
16
|
+
const trimmed = trimStart(line);
|
|
17
|
+
if (!trimmed.startsWith(marker)) {
|
|
18
|
+
return false;
|
|
19
|
+
} else if (trimmed.length === marker.length) {
|
|
20
|
+
return true;
|
|
21
|
+
} else {
|
|
22
|
+
return isWhiteSpace(trimmed[marker.length]);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function isDocumentStart(line) {
|
|
26
|
+
return isDocumentMarker("---", line);
|
|
27
|
+
}
|
|
28
|
+
function isDocumentEnd(line) {
|
|
29
|
+
return isDocumentMarker("...", line);
|
|
30
|
+
}
|
|
13
31
|
function write(rootElement, fconfig) {
|
|
14
32
|
let config_1;
|
|
15
33
|
const config = Config_init_71136F3F();
|
|
16
34
|
config_1 = fconfig != null ? value(fconfig)(config) : config;
|
|
17
|
-
const sb =
|
|
35
|
+
const sb = StringBuffer_$ctor();
|
|
18
36
|
const loop = (current, sb_1, config_2) => {
|
|
19
37
|
switch (current.tag) {
|
|
20
38
|
case /* Intendation */
|
|
@@ -48,7 +66,7 @@ function write(rootElement, fconfig) {
|
|
|
48
66
|
}
|
|
49
67
|
default: {
|
|
50
68
|
const line = current.fields[0];
|
|
51
|
-
|
|
69
|
+
StringBuffer__AppendLine_Z721C83C5(sb_1, Config__get_WhitespaceString(config_2) + line);
|
|
52
70
|
}
|
|
53
71
|
}
|
|
54
72
|
};
|
|
@@ -57,25 +75,47 @@ function write(rootElement, fconfig) {
|
|
|
57
75
|
}
|
|
58
76
|
function read(yamlStr) {
|
|
59
77
|
const content = pipeline(yamlStr);
|
|
78
|
+
const stripIndent = (indent, line) => {
|
|
79
|
+
if (indent <= 0) {
|
|
80
|
+
return line;
|
|
81
|
+
} else if (line.length >= indent) {
|
|
82
|
+
return substring(line, indent);
|
|
83
|
+
} else {
|
|
84
|
+
return trimStart(line);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
60
87
|
const loop = (lines_mut, currentIntendation_mut, acc_mut) => {
|
|
61
88
|
loop:
|
|
62
89
|
while (true) {
|
|
63
90
|
const lines = lines_mut, currentIntendation = currentIntendation_mut, acc = acc_mut;
|
|
64
91
|
if (!isEmpty(lines)) {
|
|
65
92
|
const rest = tail(lines);
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
const nextIntendation = ReadHelpers_indentLevel(
|
|
93
|
+
const line_1 = head(lines);
|
|
94
|
+
const isEmptyLine = line_1.trim() === "";
|
|
95
|
+
const nextIntendation = (isEmptyLine ? currentIntendation : ReadHelpers_indentLevel(line_1)) | 0;
|
|
69
96
|
if (nextIntendation === currentIntendation) {
|
|
70
97
|
lines_mut = rest;
|
|
71
98
|
currentIntendation_mut = currentIntendation;
|
|
72
|
-
acc_mut = cons(PreprocessorElement_Line(
|
|
99
|
+
acc_mut = cons(PreprocessorElement_Line(isEmptyLine ? "" : stripIndent(currentIntendation, line_1)), acc);
|
|
73
100
|
continue loop;
|
|
74
101
|
} else {
|
|
75
|
-
const
|
|
76
|
-
|
|
102
|
+
const lineText_1 = isEmptyLine ? "" : stripIndent(nextIntendation, line_1);
|
|
103
|
+
const nextLevelLines = takeWhile$1((l) => {
|
|
104
|
+
if (l.trim() === "") {
|
|
105
|
+
return true;
|
|
106
|
+
} else {
|
|
107
|
+
return ReadHelpers_indentLevel(l) > currentIntendation;
|
|
108
|
+
}
|
|
109
|
+
}, rest);
|
|
110
|
+
lines_mut = skipWhile((l_1) => {
|
|
111
|
+
if (l_1.trim() === "") {
|
|
112
|
+
return true;
|
|
113
|
+
} else {
|
|
114
|
+
return ReadHelpers_indentLevel(l_1) > currentIntendation;
|
|
115
|
+
}
|
|
116
|
+
}, rest);
|
|
77
117
|
currentIntendation_mut = currentIntendation;
|
|
78
|
-
acc_mut = cons(PreprocessorElement_Intendation(cons(
|
|
118
|
+
acc_mut = cons(PreprocessorElement_Intendation(cons(PreprocessorElement_Line(lineText_1), reverse(loop(nextLevelLines, nextIntendation, empty())))), acc);
|
|
79
119
|
continue loop;
|
|
80
120
|
}
|
|
81
121
|
} else {
|
|
@@ -84,7 +124,7 @@ function read(yamlStr) {
|
|
|
84
124
|
break;
|
|
85
125
|
}
|
|
86
126
|
};
|
|
87
|
-
return new Preprocessor(PreprocessorElement_Level(reverse(loop(ofArray(content.Lines), 0, empty()))), content.StringMap, content.CommentMap);
|
|
127
|
+
return new Preprocessor(PreprocessorElement_Level(reverse(loop(ofArray(content.Lines), 0, empty()))), content.StringMap, content.CommentMap, content.YAMLVersion, content.TagHandles);
|
|
88
128
|
}
|
|
89
129
|
function mkLine(line) {
|
|
90
130
|
return PreprocessorElement_Line(line);
|
|
@@ -96,4 +136,4 @@ function mkIntendation(children) {
|
|
|
96
136
|
return PreprocessorElement_Intendation(ofSeq(children));
|
|
97
137
|
}
|
|
98
138
|
|
|
99
|
-
export { ReadHelpers_indentLevel, mkIntendation, mkLine, mklLevel, read, write };
|
|
139
|
+
export { ReadHelpers_indentLevel, isDocumentEnd, isDocumentStart, mkIntendation, mkLine, mklLevel, read, write };
|