foreman_acd 0.9.7 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/foreman_acd/version.rb +1 -1
- data/package.json +5 -3
- data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +210 -121
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +79 -91
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +30 -15
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +15 -15
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +96 -63
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +22 -11
- data/webpack/components/ApplicationDefinition/__fixtures__/{applicationDefinitionConfData_1.fixtures.js → applicationDefinitionConfData1.fixtures.js} +77 -105
- data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionReducer.fixtures.js +49 -29
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +4 -4
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionHelper.test.js +16 -0
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionReducer.test.js +0 -5
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +25 -25
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +9 -1
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +11 -11
- data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +30 -25
- data/webpack/components/ApplicationDefinition/components/__tests__/AnsiblePlaybookSelector.test.js +3 -3
- data/webpack/components/ApplicationDefinition/index.js +0 -1
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.js +91 -105
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportActions.js +59 -84
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportConstants.js +12 -6
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportReducer.js +21 -27
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportSelectors.js +14 -7
- data/webpack/components/ApplicationDefinitionImport/__fixtures__/{applicationDefinitionImportConfData_1.fixtures.js → applicationDefinitionImportConfData1.fixtures.js} +32 -40
- data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportReducer.fixtures.js +14 -16
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js +38 -8
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportReducer.test.js +0 -2
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportSelectors.test.js +9 -9
- data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap +116 -2
- data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportSelectors.test.js.snap +3 -3
- data/webpack/components/ApplicationInstance/ApplicationInstance.js +344 -193
- data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +92 -105
- data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +34 -17
- data/webpack/components/ApplicationInstance/ApplicationInstanceHelper.js +4 -7
- data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +114 -74
- data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +18 -9
- data/webpack/components/ApplicationInstance/__fixtures__/{applicationInstanceConfData_1.fixtures.js → applicationInstanceConfData1.fixtures.js} +68 -86
- data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +24 -32
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +75 -10
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +0 -8
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +27 -27
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +606 -2
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +12 -12
- data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +32 -25
- data/webpack/components/ApplicationInstance/components/Service.js +7 -18
- data/webpack/components/ApplicationInstance/components/ServiceCounter.js +25 -18
- data/webpack/components/ApplicationInstance/index.js +0 -1
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +167 -110
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +20 -25
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +10 -5
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +9 -12
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +12 -6
- data/webpack/components/ApplicationInstanceReport/__fixtures__/{applicationInstanceReportData_1.fixtures.js → applicationInstanceReportData1.fixtures.js} +154 -101
- data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportReducer.fixtures.js +3 -10
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReport.test.js +28 -22
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportSelectors.test.js +5 -7
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportReducer.test.js.snap +0 -1
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportSelectors.test.js.snap +2 -2
- data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +9 -5
- data/webpack/components/ApplicationInstanceReport/components/__tests__/ReportViewer.test.js +1 -3
- data/webpack/components/ExistingHostSelection/ExistingHostSelection.js +35 -56
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionActions.js +21 -28
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionConstants.js +6 -3
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionReducer.js +16 -19
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionSelectors.js +8 -4
- data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData1.fixtures.js +187 -0
- data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionReducer.fixtures.js +13 -24
- data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelection.test.js +3 -2
- data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionSelectors.test.js +11 -14
- data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionSelectors.test.js.snap +5 -5
- data/webpack/components/ExistingHostSelection/components/ServiceSelector.js +31 -25
- data/webpack/components/ExistingHostSelection/components/__tests__/ServiceSelector.test.js +3 -9
- data/webpack/components/ParameterSelection/ParameterSelection.js +258 -174
- data/webpack/components/ParameterSelection/ParameterSelectionActions.js +110 -100
- data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +22 -11
- data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +13 -11
- data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +63 -49
- data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +10 -5
- data/webpack/components/ParameterSelection/__fixtures__/{parameterSelectionData_1.fixtures.js → parameterSelectionData1.fixtures.js} +67 -104
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +22 -26
- data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +50 -36
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionHelper.test.js +76 -0
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +0 -2
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +23 -25
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +100 -0
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +99 -112
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +18 -19
- data/webpack/components/ParameterSelection/index.js +1 -4
- data/webpack/components/SyncGitRepo/SyncGitRepo.js +124 -117
- data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +64 -74
- data/webpack/components/SyncGitRepo/SyncGitRepoReducer.js +17 -17
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData1.fixtures.js +7 -0
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoReducer.fixtures.js +10 -18
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepo.test.js +80 -6
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoSelectors.test.js +9 -11
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +192 -1
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoSelectors.test.js.snap +4 -4
- data/webpack/components/SyncGitRepo/components/FormTextInput.js +26 -21
- data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +29 -24
- data/webpack/components/SyncGitRepo/index.js +2 -5
- data/webpack/components/common/AddTableEntry.js +3 -10
- data/webpack/components/common/DeleteTableEntry.js +7 -15
- data/webpack/components/common/EditTableEntry.js +7 -7
- data/webpack/components/common/ExtSelect.js +12 -8
- data/webpack/components/common/ExtTextInput.js +12 -7
- data/webpack/components/common/LockTableEntry.js +6 -6
- data/webpack/components/common/RailsData.js +6 -16
- data/webpack/components/common/__tests__/ExtSelect.test.js +2 -2
- data/webpack/components/common/__tests__/RailsData.test.js +0 -2
- data/webpack/global_test_setup.js +11 -0
- data/webpack/helper.js +10 -21
- data/webpack/helper.test.js +17 -29
- data/webpack/index.js +25 -7
- data/webpack/js-yaml.js +1563 -1135
- data/webpack/reducer.js +52 -27
- metadata +13 -11
- data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData_1.fixtures.js +0 -191
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelection.fixtures.js +0 -153
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData_1.fixtures.js +0 -7
data/webpack/js-yaml.js
CHANGED
@@ -1,31 +1,33 @@
|
|
1
|
-
|
2
1
|
/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
|
3
|
-
(function
|
4
|
-
typeof exports === 'object' && typeof module !== 'undefined'
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
(function(global, factory) {
|
3
|
+
typeof exports === 'object' && typeof module !== 'undefined'
|
4
|
+
? factory(exports)
|
5
|
+
: typeof define === 'function' && define.amd
|
6
|
+
? define(['exports'], factory)
|
7
|
+
: ((global =
|
8
|
+
typeof globalThis !== 'undefined' ? globalThis : global || self),
|
9
|
+
factory((global.jsyaml = {})));
|
10
|
+
})(this, exports => {
|
9
11
|
function isNothing(subject) {
|
10
|
-
return
|
12
|
+
return typeof subject === 'undefined' || subject === null;
|
11
13
|
}
|
12
14
|
|
13
|
-
|
14
15
|
function isObject(subject) {
|
15
|
-
return
|
16
|
+
return typeof subject === 'object' && subject !== null;
|
16
17
|
}
|
17
18
|
|
18
|
-
|
19
19
|
function toArray(sequence) {
|
20
20
|
if (Array.isArray(sequence)) return sequence;
|
21
21
|
else if (isNothing(sequence)) return [];
|
22
22
|
|
23
|
-
return [
|
23
|
+
return [sequence];
|
24
24
|
}
|
25
25
|
|
26
|
-
|
27
26
|
function extend(target, source) {
|
28
|
-
|
27
|
+
let index;
|
28
|
+
let length;
|
29
|
+
let key;
|
30
|
+
let sourceKeys;
|
29
31
|
|
30
32
|
if (source) {
|
31
33
|
sourceKeys = Object.keys(source);
|
@@ -39,9 +41,9 @@
|
|
39
41
|
return target;
|
40
42
|
}
|
41
43
|
|
42
|
-
|
43
44
|
function repeat(string, count) {
|
44
|
-
|
45
|
+
let result = '';
|
46
|
+
let cycle;
|
45
47
|
|
46
48
|
for (cycle = 0; cycle < count; cycle += 1) {
|
47
49
|
result += string;
|
@@ -50,50 +52,47 @@
|
|
50
52
|
return result;
|
51
53
|
}
|
52
54
|
|
53
|
-
|
54
55
|
function isNegativeZero(number) {
|
55
|
-
return
|
56
|
+
return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
|
56
57
|
}
|
57
58
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
extend: extend_1
|
59
|
+
const isNothing_1 = isNothing;
|
60
|
+
const isObject_1 = isObject;
|
61
|
+
const toArray_1 = toArray;
|
62
|
+
const repeat_1 = repeat;
|
63
|
+
const isNegativeZero_1 = isNegativeZero;
|
64
|
+
const extend_1 = extend;
|
65
|
+
|
66
|
+
const common = {
|
67
|
+
isNothing: isNothing_1,
|
68
|
+
isObject: isObject_1,
|
69
|
+
toArray: toArray_1,
|
70
|
+
repeat: repeat_1,
|
71
|
+
isNegativeZero: isNegativeZero_1,
|
72
|
+
extend: extend_1,
|
73
73
|
};
|
74
74
|
|
75
75
|
// YAML error class. http://stackoverflow.com/questions/8458984
|
76
76
|
|
77
|
-
|
78
77
|
function formatError(exception, compact) {
|
79
|
-
|
78
|
+
let where = '';
|
79
|
+
const message = exception.reason || '(unknown reason)';
|
80
80
|
|
81
81
|
if (!exception.mark) return message;
|
82
82
|
|
83
83
|
if (exception.mark.name) {
|
84
|
-
where +=
|
84
|
+
where += `in "${exception.mark.name}" `;
|
85
85
|
}
|
86
86
|
|
87
|
-
where +=
|
87
|
+
where += `(${exception.mark.line + 1}:${exception.mark.column + 1})`;
|
88
88
|
|
89
89
|
if (!compact && exception.mark.snippet) {
|
90
|
-
where +=
|
90
|
+
where += `\n\n${exception.mark.snippet}`;
|
91
91
|
}
|
92
92
|
|
93
|
-
return message
|
93
|
+
return `${message} ${where}`;
|
94
94
|
}
|
95
95
|
|
96
|
-
|
97
96
|
function YAMLException$1(reason, mark) {
|
98
97
|
// Super constructor
|
99
98
|
Error.call(this);
|
@@ -109,28 +108,25 @@
|
|
109
108
|
Error.captureStackTrace(this, this.constructor);
|
110
109
|
} else {
|
111
110
|
// FF, IE 10+ and Safari 6+. Fallback for others
|
112
|
-
this.stack =
|
111
|
+
this.stack = new Error().stack || '';
|
113
112
|
}
|
114
113
|
}
|
115
114
|
|
116
|
-
|
117
115
|
// Inherit from Error
|
118
116
|
YAMLException$1.prototype = Object.create(Error.prototype);
|
119
117
|
YAMLException$1.prototype.constructor = YAMLException$1;
|
120
118
|
|
121
|
-
|
122
119
|
YAMLException$1.prototype.toString = function toString(compact) {
|
123
|
-
return this.name
|
120
|
+
return `${this.name}: ${formatError(this, compact)}`;
|
124
121
|
};
|
125
122
|
|
126
|
-
|
127
|
-
var exception = YAMLException$1;
|
123
|
+
const exception = YAMLException$1;
|
128
124
|
|
129
125
|
// get snippet for a single line, respecting maxLength
|
130
126
|
function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
|
131
|
-
|
132
|
-
|
133
|
-
|
127
|
+
let head = '';
|
128
|
+
let tail = '';
|
129
|
+
const maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
134
130
|
|
135
131
|
if (position - lineStart > maxHalfLength) {
|
136
132
|
head = ' ... ';
|
@@ -144,31 +140,29 @@
|
|
144
140
|
|
145
141
|
return {
|
146
142
|
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, '→') + tail,
|
147
|
-
pos: position - lineStart + head.length // relative position
|
143
|
+
pos: position - lineStart + head.length, // relative position
|
148
144
|
};
|
149
145
|
}
|
150
146
|
|
151
|
-
|
152
147
|
function padStart(string, max) {
|
153
148
|
return common.repeat(' ', max - string.length) + string;
|
154
149
|
}
|
155
150
|
|
156
|
-
|
157
151
|
function makeSnippet(mark, options) {
|
158
152
|
options = Object.create(options || null);
|
159
153
|
|
160
154
|
if (!mark.buffer) return null;
|
161
155
|
|
162
156
|
if (!options.maxLength) options.maxLength = 79;
|
163
|
-
if (typeof options.indent
|
157
|
+
if (typeof options.indent !== 'number') options.indent = 1;
|
164
158
|
if (typeof options.linesBefore !== 'number') options.linesBefore = 3;
|
165
|
-
if (typeof options.linesAfter
|
159
|
+
if (typeof options.linesAfter !== 'number') options.linesAfter = 2;
|
166
160
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
161
|
+
const re = /\r?\n|\r|\0/g;
|
162
|
+
const lineStarts = [0];
|
163
|
+
const lineEnds = [];
|
164
|
+
let match;
|
165
|
+
let foundLineNo = -1;
|
172
166
|
|
173
167
|
while ((match = re.exec(mark.buffer))) {
|
174
168
|
lineEnds.push(match.index);
|
@@ -181,9 +175,15 @@
|
|
181
175
|
|
182
176
|
if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
|
183
177
|
|
184
|
-
|
185
|
-
|
186
|
-
|
178
|
+
let result = '';
|
179
|
+
let i;
|
180
|
+
let line;
|
181
|
+
const lineNoLength = Math.min(
|
182
|
+
mark.line + options.linesAfter,
|
183
|
+
lineEnds.length
|
184
|
+
).toString().length;
|
185
|
+
const maxLineLength =
|
186
|
+
options.maxLength - (options.indent + lineNoLength + 3);
|
187
187
|
|
188
188
|
for (i = 1; i <= options.linesBefore; i++) {
|
189
189
|
if (foundLineNo - i < 0) break;
|
@@ -194,14 +194,24 @@
|
|
194
194
|
mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]),
|
195
195
|
maxLineLength
|
196
196
|
);
|
197
|
-
result = common.repeat(' ', options.indent) +
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
197
|
+
result = `${common.repeat(' ', options.indent) +
|
198
|
+
padStart((mark.line - i + 1).toString(), lineNoLength)} | ${
|
199
|
+
line.str
|
200
|
+
}\n${result}`;
|
201
|
+
}
|
202
|
+
|
203
|
+
line = getLine(
|
204
|
+
mark.buffer,
|
205
|
+
lineStarts[foundLineNo],
|
206
|
+
lineEnds[foundLineNo],
|
207
|
+
mark.position,
|
208
|
+
maxLineLength
|
209
|
+
);
|
210
|
+
result += `${common.repeat(' ', options.indent) +
|
211
|
+
padStart((mark.line + 1).toString(), lineNoLength)} | ${line.str}\n`;
|
212
|
+
result +=
|
213
|
+
`${common.repeat('-', options.indent + lineNoLength + 3 + line.pos)}^` +
|
214
|
+
`\n`;
|
205
215
|
|
206
216
|
for (i = 1; i <= options.linesAfter; i++) {
|
207
217
|
if (foundLineNo + i >= lineEnds.length) break;
|
@@ -212,17 +222,18 @@
|
|
212
222
|
mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]),
|
213
223
|
maxLineLength
|
214
224
|
);
|
215
|
-
result += common.repeat(' ', options.indent) +
|
216
|
-
|
225
|
+
result += `${common.repeat(' ', options.indent) +
|
226
|
+
padStart((mark.line + i + 1).toString(), lineNoLength)} | ${
|
227
|
+
line.str
|
228
|
+
}\n`;
|
217
229
|
}
|
218
230
|
|
219
231
|
return result.replace(/\n$/, '');
|
220
232
|
}
|
221
233
|
|
234
|
+
const snippet = makeSnippet;
|
222
235
|
|
223
|
-
|
224
|
-
|
225
|
-
var TYPE_CONSTRUCTOR_OPTIONS = [
|
236
|
+
const TYPE_CONSTRUCTOR_OPTIONS = [
|
226
237
|
'kind',
|
227
238
|
'multi',
|
228
239
|
'resolve',
|
@@ -232,21 +243,17 @@
|
|
232
243
|
'represent',
|
233
244
|
'representName',
|
234
245
|
'defaultStyle',
|
235
|
-
'styleAliases'
|
246
|
+
'styleAliases',
|
236
247
|
];
|
237
248
|
|
238
|
-
|
239
|
-
'scalar',
|
240
|
-
'sequence',
|
241
|
-
'mapping'
|
242
|
-
];
|
249
|
+
const YAML_NODE_KINDS = ['scalar', 'sequence', 'mapping'];
|
243
250
|
|
244
251
|
function compileStyleAliases(map) {
|
245
|
-
|
252
|
+
const result = {};
|
246
253
|
|
247
254
|
if (map !== null) {
|
248
|
-
Object.keys(map).forEach(
|
249
|
-
map[style].forEach(
|
255
|
+
Object.keys(map).forEach(style => {
|
256
|
+
map[style].forEach(alias => {
|
250
257
|
result[String(alias)] = style;
|
251
258
|
});
|
252
259
|
});
|
@@ -258,50 +265,59 @@
|
|
258
265
|
function Type$1(tag, options) {
|
259
266
|
options = options || {};
|
260
267
|
|
261
|
-
Object.keys(options).forEach(
|
268
|
+
Object.keys(options).forEach(name => {
|
262
269
|
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
|
263
|
-
throw new exception(
|
270
|
+
throw new exception(
|
271
|
+
`Unknown option "${name}" is met in definition of "${tag}" YAML type.`
|
272
|
+
);
|
264
273
|
}
|
265
274
|
});
|
266
275
|
|
267
276
|
// TODO: Add tag format check.
|
268
|
-
this.options
|
269
|
-
this.tag
|
270
|
-
this.kind
|
271
|
-
this.resolve
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
this.
|
277
|
-
|
278
|
-
|
279
|
-
|
277
|
+
this.options = options; // keep original options in case user wants to extend this type later
|
278
|
+
this.tag = tag;
|
279
|
+
this.kind = options.kind || null;
|
280
|
+
this.resolve =
|
281
|
+
options.resolve ||
|
282
|
+
function() {
|
283
|
+
return true;
|
284
|
+
};
|
285
|
+
this.construct =
|
286
|
+
options.construct ||
|
287
|
+
function(data) {
|
288
|
+
return data;
|
289
|
+
};
|
290
|
+
this.instanceOf = options.instanceOf || null;
|
291
|
+
this.predicate = options.predicate || null;
|
292
|
+
this.represent = options.represent || null;
|
293
|
+
this.representName = options.representName || null;
|
294
|
+
this.defaultStyle = options.defaultStyle || null;
|
295
|
+
this.multi = options.multi || false;
|
296
|
+
this.styleAliases = compileStyleAliases(options.styleAliases || null);
|
280
297
|
|
281
298
|
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
282
|
-
throw new exception(
|
299
|
+
throw new exception(
|
300
|
+
`Unknown kind "${this.kind}" is specified for "${tag}" YAML type.`
|
301
|
+
);
|
283
302
|
}
|
284
303
|
}
|
285
304
|
|
286
|
-
|
287
|
-
|
288
|
-
/*eslint-disable max-len*/
|
289
|
-
|
290
|
-
|
291
|
-
|
305
|
+
const type = Type$1;
|
292
306
|
|
307
|
+
/* eslint-disable max-len */
|
293
308
|
|
294
309
|
function compileList(schema, name) {
|
295
|
-
|
296
|
-
|
297
|
-
schema[name].forEach(function (currentType) {
|
298
|
-
var newIndex = result.length;
|
310
|
+
const result = [];
|
299
311
|
|
300
|
-
|
301
|
-
|
302
|
-
previousType.kind === currentType.kind &&
|
303
|
-
previousType.multi === currentType.multi) {
|
312
|
+
schema[name].forEach(currentType => {
|
313
|
+
let newIndex = result.length;
|
304
314
|
|
315
|
+
result.forEach((previousType, previousIndex) => {
|
316
|
+
if (
|
317
|
+
previousType.tag === currentType.tag &&
|
318
|
+
previousType.kind === currentType.kind &&
|
319
|
+
previousType.multi === currentType.multi
|
320
|
+
) {
|
305
321
|
newIndex = previousIndex;
|
306
322
|
}
|
307
323
|
});
|
@@ -312,27 +328,28 @@
|
|
312
328
|
return result;
|
313
329
|
}
|
314
330
|
|
315
|
-
|
316
331
|
function compileMap(/* lists... */) {
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
332
|
+
const result = {
|
333
|
+
scalar: {},
|
334
|
+
sequence: {},
|
335
|
+
mapping: {},
|
336
|
+
fallback: {},
|
337
|
+
multi: {
|
338
|
+
scalar: [],
|
339
|
+
sequence: [],
|
340
|
+
mapping: [],
|
341
|
+
fallback: [],
|
342
|
+
},
|
343
|
+
};
|
344
|
+
let index;
|
345
|
+
let length;
|
329
346
|
|
330
347
|
function collectType(type) {
|
331
348
|
if (type.multi) {
|
332
349
|
result.multi[type.kind].push(type);
|
333
|
-
result.multi
|
350
|
+
result.multi.fallback.push(type);
|
334
351
|
} else {
|
335
|
-
result[type.kind][type.tag] = result
|
352
|
+
result[type.kind][type.tag] = result.fallback[type.tag] = type;
|
336
353
|
}
|
337
354
|
}
|
338
355
|
|
@@ -342,99 +359,113 @@
|
|
342
359
|
return result;
|
343
360
|
}
|
344
361
|
|
345
|
-
|
346
362
|
function Schema$1(definition) {
|
347
363
|
return this.extend(definition);
|
348
364
|
}
|
349
365
|
|
350
|
-
|
351
366
|
Schema$1.prototype.extend = function extend(definition) {
|
352
|
-
|
353
|
-
|
367
|
+
let implicit = [];
|
368
|
+
let explicit = [];
|
354
369
|
|
355
370
|
if (definition instanceof type) {
|
356
371
|
// Schema.extend(type)
|
357
372
|
explicit.push(definition);
|
358
|
-
|
359
373
|
} else if (Array.isArray(definition)) {
|
360
374
|
// Schema.extend([ type1, type2, ... ])
|
361
375
|
explicit = explicit.concat(definition);
|
362
|
-
|
363
|
-
|
376
|
+
} else if (
|
377
|
+
definition &&
|
378
|
+
(Array.isArray(definition.implicit) || Array.isArray(definition.explicit))
|
379
|
+
) {
|
364
380
|
// Schema.extend({ explicit: [ type1, type2, ... ], implicit: [ type1, type2, ... ] })
|
365
381
|
if (definition.implicit) implicit = implicit.concat(definition.implicit);
|
366
382
|
if (definition.explicit) explicit = explicit.concat(definition.explicit);
|
367
|
-
|
368
383
|
} else {
|
369
|
-
throw new exception(
|
370
|
-
'
|
384
|
+
throw new exception(
|
385
|
+
'Schema.extend argument should be a Type, [ Type ], ' +
|
386
|
+
'or a schema definition ({ implicit: [...], explicit: [...] })'
|
387
|
+
);
|
371
388
|
}
|
372
389
|
|
373
|
-
implicit.forEach(
|
390
|
+
implicit.forEach(type$1 => {
|
374
391
|
if (!(type$1 instanceof type)) {
|
375
|
-
throw new exception(
|
392
|
+
throw new exception(
|
393
|
+
'Specified list of YAML types (or a single Type object) contains a non-Type object.'
|
394
|
+
);
|
376
395
|
}
|
377
396
|
|
378
397
|
if (type$1.loadKind && type$1.loadKind !== 'scalar') {
|
379
|
-
throw new exception(
|
398
|
+
throw new exception(
|
399
|
+
'There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.'
|
400
|
+
);
|
380
401
|
}
|
381
402
|
|
382
403
|
if (type$1.multi) {
|
383
|
-
throw new exception(
|
404
|
+
throw new exception(
|
405
|
+
'There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.'
|
406
|
+
);
|
384
407
|
}
|
385
408
|
});
|
386
409
|
|
387
|
-
explicit.forEach(
|
410
|
+
explicit.forEach(type$1 => {
|
388
411
|
if (!(type$1 instanceof type)) {
|
389
|
-
throw new exception(
|
412
|
+
throw new exception(
|
413
|
+
'Specified list of YAML types (or a single Type object) contains a non-Type object.'
|
414
|
+
);
|
390
415
|
}
|
391
416
|
});
|
392
417
|
|
393
|
-
|
418
|
+
const result = Object.create(Schema$1.prototype);
|
394
419
|
|
395
420
|
result.implicit = (this.implicit || []).concat(implicit);
|
396
421
|
result.explicit = (this.explicit || []).concat(explicit);
|
397
422
|
|
398
423
|
result.compiledImplicit = compileList(result, 'implicit');
|
399
424
|
result.compiledExplicit = compileList(result, 'explicit');
|
400
|
-
result.compiledTypeMap
|
425
|
+
result.compiledTypeMap = compileMap(
|
426
|
+
result.compiledImplicit,
|
427
|
+
result.compiledExplicit
|
428
|
+
);
|
401
429
|
|
402
430
|
return result;
|
403
431
|
};
|
404
432
|
|
433
|
+
const schema = Schema$1;
|
405
434
|
|
406
|
-
|
407
|
-
|
408
|
-
var str = new type('tag:yaml.org,2002:str', {
|
435
|
+
const str = new type('tag:yaml.org,2002:str', {
|
409
436
|
kind: 'scalar',
|
410
|
-
construct
|
437
|
+
construct(data) {
|
438
|
+
return data !== null ? data : '';
|
439
|
+
},
|
411
440
|
});
|
412
441
|
|
413
|
-
|
442
|
+
const seq = new type('tag:yaml.org,2002:seq', {
|
414
443
|
kind: 'sequence',
|
415
|
-
construct
|
444
|
+
construct(data) {
|
445
|
+
return data !== null ? data : [];
|
446
|
+
},
|
416
447
|
});
|
417
448
|
|
418
|
-
|
449
|
+
const map = new type('tag:yaml.org,2002:map', {
|
419
450
|
kind: 'mapping',
|
420
|
-
construct
|
451
|
+
construct(data) {
|
452
|
+
return data !== null ? data : {};
|
453
|
+
},
|
421
454
|
});
|
422
455
|
|
423
|
-
|
424
|
-
explicit: [
|
425
|
-
str,
|
426
|
-
seq,
|
427
|
-
map
|
428
|
-
]
|
456
|
+
const failsafe = new schema({
|
457
|
+
explicit: [str, seq, map],
|
429
458
|
});
|
430
459
|
|
431
460
|
function resolveYamlNull(data) {
|
432
461
|
if (data === null) return true;
|
433
462
|
|
434
|
-
|
463
|
+
const max = data.length;
|
435
464
|
|
436
|
-
return (
|
437
|
-
|
465
|
+
return (
|
466
|
+
(max === 1 && data === '~') ||
|
467
|
+
(max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'))
|
468
|
+
);
|
438
469
|
}
|
439
470
|
|
440
471
|
function constructYamlNull() {
|
@@ -445,74 +476,92 @@
|
|
445
476
|
return object === null;
|
446
477
|
}
|
447
478
|
|
448
|
-
|
479
|
+
const _null = new type('tag:yaml.org,2002:null', {
|
449
480
|
kind: 'scalar',
|
450
481
|
resolve: resolveYamlNull,
|
451
482
|
construct: constructYamlNull,
|
452
483
|
predicate: isNull,
|
453
484
|
represent: {
|
454
|
-
canonical
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
485
|
+
canonical() {
|
486
|
+
return '~';
|
487
|
+
},
|
488
|
+
lowercase() {
|
489
|
+
return 'null';
|
490
|
+
},
|
491
|
+
uppercase() {
|
492
|
+
return 'NULL';
|
493
|
+
},
|
494
|
+
camelcase() {
|
495
|
+
return 'Null';
|
496
|
+
},
|
497
|
+
empty() {
|
498
|
+
return '';
|
499
|
+
},
|
459
500
|
},
|
460
|
-
defaultStyle: 'lowercase'
|
501
|
+
defaultStyle: 'lowercase',
|
461
502
|
});
|
462
503
|
|
463
504
|
function resolveYamlBoolean(data) {
|
464
505
|
if (data === null) return false;
|
465
506
|
|
466
|
-
|
507
|
+
const max = data.length;
|
467
508
|
|
468
|
-
return (
|
469
|
-
|
509
|
+
return (
|
510
|
+
(max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
|
511
|
+
(max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'))
|
512
|
+
);
|
470
513
|
}
|
471
514
|
|
472
515
|
function constructYamlBoolean(data) {
|
473
|
-
return data === 'true' ||
|
474
|
-
data === 'True' ||
|
475
|
-
data === 'TRUE';
|
516
|
+
return data === 'true' || data === 'True' || data === 'TRUE';
|
476
517
|
}
|
477
518
|
|
478
519
|
function isBoolean(object) {
|
479
520
|
return Object.prototype.toString.call(object) === '[object Boolean]';
|
480
521
|
}
|
481
522
|
|
482
|
-
|
523
|
+
const bool = new type('tag:yaml.org,2002:bool', {
|
483
524
|
kind: 'scalar',
|
484
525
|
resolve: resolveYamlBoolean,
|
485
526
|
construct: constructYamlBoolean,
|
486
527
|
predicate: isBoolean,
|
487
528
|
represent: {
|
488
|
-
lowercase
|
489
|
-
|
490
|
-
|
529
|
+
lowercase(object) {
|
530
|
+
return object ? 'true' : 'false';
|
531
|
+
},
|
532
|
+
uppercase(object) {
|
533
|
+
return object ? 'TRUE' : 'FALSE';
|
534
|
+
},
|
535
|
+
camelcase(object) {
|
536
|
+
return object ? 'True' : 'False';
|
537
|
+
},
|
491
538
|
},
|
492
|
-
defaultStyle: 'lowercase'
|
539
|
+
defaultStyle: 'lowercase',
|
493
540
|
});
|
494
541
|
|
495
542
|
function isHexCode(c) {
|
496
|
-
return (
|
497
|
-
|
498
|
-
|
543
|
+
return (
|
544
|
+
(c /* 0 */ >= 0x30 && c <= 0x39) /* 9 */ ||
|
545
|
+
(c /* A */ >= 0x41 && c <= 0x46) /* F */ ||
|
546
|
+
(c /* a */ >= 0x61 && c <= 0x66) /* f */
|
547
|
+
);
|
499
548
|
}
|
500
549
|
|
501
550
|
function isOctCode(c) {
|
502
|
-
return
|
551
|
+
return c /* 0 */ >= 0x30 && c <= 0x37 /* 7 */;
|
503
552
|
}
|
504
553
|
|
505
554
|
function isDecCode(c) {
|
506
|
-
return
|
555
|
+
return c /* 0 */ >= 0x30 && c <= 0x39 /* 9 */;
|
507
556
|
}
|
508
557
|
|
509
558
|
function resolveYamlInteger(data) {
|
510
559
|
if (data === null) return false;
|
511
560
|
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
561
|
+
const max = data.length;
|
562
|
+
let index = 0;
|
563
|
+
let hasDigits = false;
|
564
|
+
let ch;
|
516
565
|
|
517
566
|
if (!max) return false;
|
518
567
|
|
@@ -543,7 +592,6 @@
|
|
543
592
|
return hasDigits && ch !== '_';
|
544
593
|
}
|
545
594
|
|
546
|
-
|
547
595
|
if (ch === 'x') {
|
548
596
|
// base 16
|
549
597
|
index++;
|
@@ -557,7 +605,6 @@
|
|
557
605
|
return hasDigits && ch !== '_';
|
558
606
|
}
|
559
607
|
|
560
|
-
|
561
608
|
if (ch === 'o') {
|
562
609
|
// base 8
|
563
610
|
index++;
|
@@ -593,7 +640,9 @@
|
|
593
640
|
}
|
594
641
|
|
595
642
|
function constructYamlInteger(data) {
|
596
|
-
|
643
|
+
let value = data;
|
644
|
+
let sign = 1;
|
645
|
+
let ch;
|
597
646
|
|
598
647
|
if (value.indexOf('_') !== -1) {
|
599
648
|
value = value.replace(/_/g, '');
|
@@ -619,49 +668,72 @@
|
|
619
668
|
}
|
620
669
|
|
621
670
|
function isInteger(object) {
|
622
|
-
return (
|
623
|
-
|
671
|
+
return (
|
672
|
+
Object.prototype.toString.call(object) === '[object Number]' &&
|
673
|
+
object % 1 === 0 &&
|
674
|
+
!common.isNegativeZero(object)
|
675
|
+
);
|
624
676
|
}
|
625
677
|
|
626
|
-
|
678
|
+
const int = new type('tag:yaml.org,2002:int', {
|
627
679
|
kind: 'scalar',
|
628
680
|
resolve: resolveYamlInteger,
|
629
681
|
construct: constructYamlInteger,
|
630
682
|
predicate: isInteger,
|
631
683
|
represent: {
|
632
|
-
binary
|
633
|
-
|
634
|
-
|
684
|
+
binary(obj) {
|
685
|
+
return obj >= 0
|
686
|
+
? `0b${obj.toString(2)}`
|
687
|
+
: `-0b${obj.toString(2).slice(1)}`;
|
688
|
+
},
|
689
|
+
octal(obj) {
|
690
|
+
return obj >= 0
|
691
|
+
? `0o${obj.toString(8)}`
|
692
|
+
: `-0o${obj.toString(8).slice(1)}`;
|
693
|
+
},
|
694
|
+
decimal(obj) {
|
695
|
+
return obj.toString(10);
|
696
|
+
},
|
635
697
|
/* eslint-disable max-len */
|
636
|
-
hexadecimal
|
698
|
+
hexadecimal(obj) {
|
699
|
+
return obj >= 0
|
700
|
+
? `0x${obj.toString(16).toUpperCase()}`
|
701
|
+
: `-0x${obj
|
702
|
+
.toString(16)
|
703
|
+
.toUpperCase()
|
704
|
+
.slice(1)}`;
|
705
|
+
},
|
637
706
|
},
|
638
707
|
defaultStyle: 'decimal',
|
639
708
|
styleAliases: {
|
640
|
-
binary:
|
641
|
-
octal:
|
642
|
-
decimal:
|
643
|
-
hexadecimal: [
|
644
|
-
}
|
709
|
+
binary: [2, 'bin'],
|
710
|
+
octal: [8, 'oct'],
|
711
|
+
decimal: [10, 'dec'],
|
712
|
+
hexadecimal: [16, 'hex'],
|
713
|
+
},
|
645
714
|
});
|
646
715
|
|
647
|
-
|
716
|
+
const YAML_FLOAT_PATTERN = new RegExp(
|
648
717
|
// 2.5e4, 2.5 and integers
|
649
718
|
'^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' +
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
719
|
+
// .2e4, .2
|
720
|
+
// special case, seems not from spec
|
721
|
+
'|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' +
|
722
|
+
// .inf
|
723
|
+
'|[-+]?\\.(?:inf|Inf|INF)' +
|
724
|
+
// .nan
|
725
|
+
'|\\.(?:nan|NaN|NAN))$'
|
726
|
+
);
|
657
727
|
|
658
728
|
function resolveYamlFloat(data) {
|
659
729
|
if (data === null) return false;
|
660
730
|
|
661
|
-
if (
|
662
|
-
|
663
|
-
|
664
|
-
|
731
|
+
if (
|
732
|
+
!YAML_FLOAT_PATTERN.test(data) ||
|
733
|
+
// Quick hack to not allow integers end with `_`
|
734
|
+
// Probably should update regexp & check speed
|
735
|
+
data[data.length - 1] === '_'
|
736
|
+
) {
|
665
737
|
return false;
|
666
738
|
}
|
667
739
|
|
@@ -669,47 +741,55 @@
|
|
669
741
|
}
|
670
742
|
|
671
743
|
function constructYamlFloat(data) {
|
672
|
-
|
744
|
+
let value;
|
745
|
+
let sign;
|
673
746
|
|
674
|
-
value
|
675
|
-
sign
|
747
|
+
value = data.replace(/_/g, '').toLowerCase();
|
748
|
+
sign = value[0] === '-' ? -1 : 1;
|
676
749
|
|
677
750
|
if ('+-'.indexOf(value[0]) >= 0) {
|
678
751
|
value = value.slice(1);
|
679
752
|
}
|
680
753
|
|
681
754
|
if (value === '.inf') {
|
682
|
-
return
|
683
|
-
|
755
|
+
return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
684
756
|
} else if (value === '.nan') {
|
685
757
|
return NaN;
|
686
758
|
}
|
687
759
|
return sign * parseFloat(value, 10);
|
688
760
|
}
|
689
761
|
|
690
|
-
|
691
|
-
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
762
|
+
const SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
692
763
|
|
693
764
|
function representYamlFloat(object, style) {
|
694
|
-
|
765
|
+
let res;
|
695
766
|
|
696
767
|
if (isNaN(object)) {
|
697
768
|
switch (style) {
|
698
|
-
case 'lowercase':
|
699
|
-
|
700
|
-
case '
|
769
|
+
case 'lowercase':
|
770
|
+
return '.nan';
|
771
|
+
case 'uppercase':
|
772
|
+
return '.NAN';
|
773
|
+
case 'camelcase':
|
774
|
+
return '.NaN';
|
701
775
|
}
|
702
776
|
} else if (Number.POSITIVE_INFINITY === object) {
|
703
777
|
switch (style) {
|
704
|
-
case 'lowercase':
|
705
|
-
|
706
|
-
case '
|
778
|
+
case 'lowercase':
|
779
|
+
return '.inf';
|
780
|
+
case 'uppercase':
|
781
|
+
return '.INF';
|
782
|
+
case 'camelcase':
|
783
|
+
return '.Inf';
|
707
784
|
}
|
708
785
|
} else if (Number.NEGATIVE_INFINITY === object) {
|
709
786
|
switch (style) {
|
710
|
-
case 'lowercase':
|
711
|
-
|
712
|
-
case '
|
787
|
+
case 'lowercase':
|
788
|
+
return '-.inf';
|
789
|
+
case 'uppercase':
|
790
|
+
return '-.INF';
|
791
|
+
case 'camelcase':
|
792
|
+
return '-.Inf';
|
713
793
|
}
|
714
794
|
} else if (common.isNegativeZero(object)) {
|
715
795
|
return '-0.0';
|
@@ -724,46 +804,45 @@
|
|
724
804
|
}
|
725
805
|
|
726
806
|
function isFloat(object) {
|
727
|
-
return (
|
728
|
-
|
807
|
+
return (
|
808
|
+
Object.prototype.toString.call(object) === '[object Number]' &&
|
809
|
+
(object % 1 !== 0 || common.isNegativeZero(object))
|
810
|
+
);
|
729
811
|
}
|
730
812
|
|
731
|
-
|
813
|
+
const float = new type('tag:yaml.org,2002:float', {
|
732
814
|
kind: 'scalar',
|
733
815
|
resolve: resolveYamlFloat,
|
734
816
|
construct: constructYamlFloat,
|
735
817
|
predicate: isFloat,
|
736
818
|
represent: representYamlFloat,
|
737
|
-
defaultStyle: 'lowercase'
|
819
|
+
defaultStyle: 'lowercase',
|
738
820
|
});
|
739
821
|
|
740
|
-
|
741
|
-
implicit: [
|
742
|
-
_null,
|
743
|
-
bool,
|
744
|
-
int,
|
745
|
-
float
|
746
|
-
]
|
822
|
+
const json = failsafe.extend({
|
823
|
+
implicit: [_null, bool, int, float],
|
747
824
|
});
|
748
825
|
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
'^([0-9][0-9][0-9][0-9])'
|
753
|
-
'-([0-9][0-9])'
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
'
|
759
|
-
'-([0-9][0-9]?)'
|
760
|
-
'(
|
761
|
-
'([
|
762
|
-
'
|
763
|
-
':([0-9][0-9])'
|
764
|
-
'(
|
826
|
+
const core = json;
|
827
|
+
|
828
|
+
const YAML_DATE_REGEXP = new RegExp(
|
829
|
+
'^([0-9][0-9][0-9][0-9])' + // [1] year
|
830
|
+
'-([0-9][0-9])' + // [2] month
|
831
|
+
'-([0-9][0-9])$'
|
832
|
+
); // [3] day
|
833
|
+
|
834
|
+
const YAML_TIMESTAMP_REGEXP = new RegExp(
|
835
|
+
'^([0-9][0-9][0-9][0-9])' + // [1] year
|
836
|
+
'-([0-9][0-9]?)' + // [2] month
|
837
|
+
'-([0-9][0-9]?)' + // [3] day
|
838
|
+
'(?:[Tt]|[ \\t]+)' + // ...
|
839
|
+
'([0-9][0-9]?)' + // [4] hour
|
840
|
+
':([0-9][0-9])' + // [5] minute
|
841
|
+
':([0-9][0-9])' + // [6] second
|
842
|
+
'(?:\\.([0-9]*))?' + // [7] fraction
|
765
843
|
'(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
|
766
|
-
|
844
|
+
'(?::([0-9][0-9]))?))?$'
|
845
|
+
); // [11] tz_minute
|
767
846
|
|
768
847
|
function resolveYamlTimestamp(data) {
|
769
848
|
if (data === null) return false;
|
@@ -773,8 +852,18 @@
|
|
773
852
|
}
|
774
853
|
|
775
854
|
function constructYamlTimestamp(data) {
|
776
|
-
|
777
|
-
|
855
|
+
let match;
|
856
|
+
let year;
|
857
|
+
let month;
|
858
|
+
let day;
|
859
|
+
let hour;
|
860
|
+
let minute;
|
861
|
+
let second;
|
862
|
+
let fraction = 0;
|
863
|
+
let delta = null;
|
864
|
+
let tz_hour;
|
865
|
+
let tz_minute;
|
866
|
+
let date;
|
778
867
|
|
779
868
|
match = YAML_DATE_REGEXP.exec(data);
|
780
869
|
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
|
@@ -783,23 +872,25 @@
|
|
783
872
|
|
784
873
|
// match: [1] year [2] month [3] day
|
785
874
|
|
786
|
-
year = +
|
787
|
-
month = +
|
788
|
-
day = +
|
875
|
+
year = +match[1];
|
876
|
+
month = +match[2] - 1; // JS month starts with 0
|
877
|
+
day = +match[3];
|
789
878
|
|
790
|
-
if (!match[4]) {
|
879
|
+
if (!match[4]) {
|
880
|
+
// no hour
|
791
881
|
return new Date(Date.UTC(year, month, day));
|
792
882
|
}
|
793
883
|
|
794
884
|
// match: [4] hour [5] minute [6] second [7] fraction
|
795
885
|
|
796
|
-
hour = +
|
797
|
-
minute = +
|
798
|
-
second = +
|
886
|
+
hour = +match[4];
|
887
|
+
minute = +match[5];
|
888
|
+
second = +match[6];
|
799
889
|
|
800
890
|
if (match[7]) {
|
801
891
|
fraction = match[7].slice(0, 3);
|
802
|
-
while (fraction.length < 3) {
|
892
|
+
while (fraction.length < 3) {
|
893
|
+
// milli-seconds
|
803
894
|
fraction += '0';
|
804
895
|
}
|
805
896
|
fraction = +fraction;
|
@@ -808,7 +899,7 @@
|
|
808
899
|
// match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
|
809
900
|
|
810
901
|
if (match[9]) {
|
811
|
-
tz_hour = +
|
902
|
+
tz_hour = +match[10];
|
812
903
|
tz_minute = +(match[11] || 0);
|
813
904
|
delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
|
814
905
|
if (match[9] === '-') delta = -delta;
|
@@ -821,41 +912,41 @@
|
|
821
912
|
return date;
|
822
913
|
}
|
823
914
|
|
824
|
-
function representYamlTimestamp(object
|
915
|
+
function representYamlTimestamp(object /* , style */) {
|
825
916
|
return object.toISOString();
|
826
917
|
}
|
827
918
|
|
828
|
-
|
919
|
+
const timestamp = new type('tag:yaml.org,2002:timestamp', {
|
829
920
|
kind: 'scalar',
|
830
921
|
resolve: resolveYamlTimestamp,
|
831
922
|
construct: constructYamlTimestamp,
|
832
923
|
instanceOf: Date,
|
833
|
-
represent: representYamlTimestamp
|
924
|
+
represent: representYamlTimestamp,
|
834
925
|
});
|
835
926
|
|
836
927
|
function resolveYamlMerge(data) {
|
837
928
|
return data === '<<' || data === null;
|
838
929
|
}
|
839
930
|
|
840
|
-
|
931
|
+
const merge = new type('tag:yaml.org,2002:merge', {
|
841
932
|
kind: 'scalar',
|
842
|
-
resolve: resolveYamlMerge
|
933
|
+
resolve: resolveYamlMerge,
|
843
934
|
});
|
844
935
|
|
845
|
-
/*eslint-disable no-bitwise*/
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
936
|
+
/* eslint-disable no-bitwise */
|
850
937
|
|
851
938
|
// [ 64, 65, 66 ] -> [ padding, CR, LF ]
|
852
|
-
|
853
|
-
|
939
|
+
const BASE64_MAP =
|
940
|
+
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
|
854
941
|
|
855
942
|
function resolveYamlBinary(data) {
|
856
943
|
if (data === null) return false;
|
857
944
|
|
858
|
-
|
945
|
+
let code;
|
946
|
+
let idx;
|
947
|
+
let bitlen = 0;
|
948
|
+
const max = data.length;
|
949
|
+
const map = BASE64_MAP;
|
859
950
|
|
860
951
|
// Convert one by one.
|
861
952
|
for (idx = 0; idx < max; idx++) {
|
@@ -871,24 +962,25 @@
|
|
871
962
|
}
|
872
963
|
|
873
964
|
// If there are any bits left, source was corrupted
|
874
|
-
return
|
965
|
+
return bitlen % 8 === 0;
|
875
966
|
}
|
876
967
|
|
877
968
|
function constructYamlBinary(data) {
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
969
|
+
let idx;
|
970
|
+
let tailbits;
|
971
|
+
const input = data.replace(/[\r\n=]/g, ''); // remove CR/LF & padding to simplify scan
|
972
|
+
const max = input.length;
|
973
|
+
const map = BASE64_MAP;
|
974
|
+
let bits = 0;
|
975
|
+
const result = [];
|
884
976
|
|
885
977
|
// Collect by 6*4 bits (3 bytes)
|
886
978
|
|
887
979
|
for (idx = 0; idx < max; idx++) {
|
888
|
-
if (
|
889
|
-
result.push((bits >> 16) &
|
890
|
-
result.push((bits >> 8) &
|
891
|
-
result.push(bits &
|
980
|
+
if (idx % 4 === 0 && idx) {
|
981
|
+
result.push((bits >> 16) & 0xff);
|
982
|
+
result.push((bits >> 8) & 0xff);
|
983
|
+
result.push(bits & 0xff);
|
892
984
|
}
|
893
985
|
|
894
986
|
bits = (bits << 6) | map.indexOf(input.charAt(idx));
|
@@ -899,32 +991,35 @@
|
|
899
991
|
tailbits = (max % 4) * 6;
|
900
992
|
|
901
993
|
if (tailbits === 0) {
|
902
|
-
result.push((bits >> 16) &
|
903
|
-
result.push((bits >> 8) &
|
904
|
-
result.push(bits &
|
994
|
+
result.push((bits >> 16) & 0xff);
|
995
|
+
result.push((bits >> 8) & 0xff);
|
996
|
+
result.push(bits & 0xff);
|
905
997
|
} else if (tailbits === 18) {
|
906
|
-
result.push((bits >> 10) &
|
907
|
-
result.push((bits >> 2) &
|
998
|
+
result.push((bits >> 10) & 0xff);
|
999
|
+
result.push((bits >> 2) & 0xff);
|
908
1000
|
} else if (tailbits === 12) {
|
909
|
-
result.push((bits >> 4) &
|
1001
|
+
result.push((bits >> 4) & 0xff);
|
910
1002
|
}
|
911
1003
|
|
912
1004
|
return new Uint8Array(result);
|
913
1005
|
}
|
914
1006
|
|
915
|
-
function representYamlBinary(object
|
916
|
-
|
917
|
-
|
918
|
-
|
1007
|
+
function representYamlBinary(object /* , style */) {
|
1008
|
+
let result = '';
|
1009
|
+
let bits = 0;
|
1010
|
+
let idx;
|
1011
|
+
let tail;
|
1012
|
+
const max = object.length;
|
1013
|
+
const map = BASE64_MAP;
|
919
1014
|
|
920
1015
|
// Convert every three bytes to 4 ASCII characters.
|
921
1016
|
|
922
1017
|
for (idx = 0; idx < max; idx++) {
|
923
|
-
if (
|
924
|
-
result += map[(bits >> 18) &
|
925
|
-
result += map[(bits >> 12) &
|
926
|
-
result += map[(bits >> 6) &
|
927
|
-
result += map[bits &
|
1018
|
+
if (idx % 3 === 0 && idx) {
|
1019
|
+
result += map[(bits >> 18) & 0x3f];
|
1020
|
+
result += map[(bits >> 12) & 0x3f];
|
1021
|
+
result += map[(bits >> 6) & 0x3f];
|
1022
|
+
result += map[bits & 0x3f];
|
928
1023
|
}
|
929
1024
|
|
930
1025
|
bits = (bits << 8) + object[idx];
|
@@ -935,18 +1030,18 @@
|
|
935
1030
|
tail = max % 3;
|
936
1031
|
|
937
1032
|
if (tail === 0) {
|
938
|
-
result += map[(bits >> 18) &
|
939
|
-
result += map[(bits >> 12) &
|
940
|
-
result += map[(bits >> 6) &
|
941
|
-
result += map[bits &
|
1033
|
+
result += map[(bits >> 18) & 0x3f];
|
1034
|
+
result += map[(bits >> 12) & 0x3f];
|
1035
|
+
result += map[(bits >> 6) & 0x3f];
|
1036
|
+
result += map[bits & 0x3f];
|
942
1037
|
} else if (tail === 2) {
|
943
|
-
result += map[(bits >> 10) &
|
944
|
-
result += map[(bits >> 4) &
|
945
|
-
result += map[(bits << 2) &
|
1038
|
+
result += map[(bits >> 10) & 0x3f];
|
1039
|
+
result += map[(bits >> 4) & 0x3f];
|
1040
|
+
result += map[(bits << 2) & 0x3f];
|
946
1041
|
result += map[64];
|
947
1042
|
} else if (tail === 1) {
|
948
|
-
result += map[(bits >> 2) &
|
949
|
-
result += map[(bits << 4) &
|
1043
|
+
result += map[(bits >> 2) & 0x3f];
|
1044
|
+
result += map[(bits << 4) & 0x3f];
|
950
1045
|
result += map[64];
|
951
1046
|
result += map[64];
|
952
1047
|
}
|
@@ -955,25 +1050,30 @@
|
|
955
1050
|
}
|
956
1051
|
|
957
1052
|
function isBinary(obj) {
|
958
|
-
return Object.prototype.toString.call(obj) ===
|
1053
|
+
return Object.prototype.toString.call(obj) === '[object Uint8Array]';
|
959
1054
|
}
|
960
1055
|
|
961
|
-
|
1056
|
+
const binary = new type('tag:yaml.org,2002:binary', {
|
962
1057
|
kind: 'scalar',
|
963
1058
|
resolve: resolveYamlBinary,
|
964
1059
|
construct: constructYamlBinary,
|
965
1060
|
predicate: isBinary,
|
966
|
-
represent: representYamlBinary
|
1061
|
+
represent: representYamlBinary,
|
967
1062
|
});
|
968
1063
|
|
969
|
-
|
970
|
-
|
1064
|
+
const _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
1065
|
+
const _toString$2 = Object.prototype.toString;
|
971
1066
|
|
972
1067
|
function resolveYamlOmap(data) {
|
973
1068
|
if (data === null) return true;
|
974
1069
|
|
975
|
-
|
976
|
-
|
1070
|
+
const objectKeys = [];
|
1071
|
+
let index;
|
1072
|
+
let length;
|
1073
|
+
let pair;
|
1074
|
+
let pairKey;
|
1075
|
+
let pairHasKey;
|
1076
|
+
const object = data;
|
977
1077
|
|
978
1078
|
for (index = 0, length = object.length; index < length; index += 1) {
|
979
1079
|
pair = object[index];
|
@@ -1001,19 +1101,23 @@
|
|
1001
1101
|
return data !== null ? data : [];
|
1002
1102
|
}
|
1003
1103
|
|
1004
|
-
|
1104
|
+
const omap = new type('tag:yaml.org,2002:omap', {
|
1005
1105
|
kind: 'sequence',
|
1006
1106
|
resolve: resolveYamlOmap,
|
1007
|
-
construct: constructYamlOmap
|
1107
|
+
construct: constructYamlOmap,
|
1008
1108
|
});
|
1009
1109
|
|
1010
|
-
|
1110
|
+
const _toString$1 = Object.prototype.toString;
|
1011
1111
|
|
1012
1112
|
function resolveYamlPairs(data) {
|
1013
1113
|
if (data === null) return true;
|
1014
1114
|
|
1015
|
-
|
1016
|
-
|
1115
|
+
let index;
|
1116
|
+
let length;
|
1117
|
+
let pair;
|
1118
|
+
let keys;
|
1119
|
+
let result;
|
1120
|
+
const object = data;
|
1017
1121
|
|
1018
1122
|
result = new Array(object.length);
|
1019
1123
|
|
@@ -1026,7 +1130,7 @@
|
|
1026
1130
|
|
1027
1131
|
if (keys.length !== 1) return false;
|
1028
1132
|
|
1029
|
-
result[index] = [
|
1133
|
+
result[index] = [keys[0], pair[keys[0]]];
|
1030
1134
|
}
|
1031
1135
|
|
1032
1136
|
return true;
|
@@ -1035,8 +1139,12 @@
|
|
1035
1139
|
function constructYamlPairs(data) {
|
1036
1140
|
if (data === null) return [];
|
1037
1141
|
|
1038
|
-
|
1039
|
-
|
1142
|
+
let index;
|
1143
|
+
let length;
|
1144
|
+
let pair;
|
1145
|
+
let keys;
|
1146
|
+
let result;
|
1147
|
+
const object = data;
|
1040
1148
|
|
1041
1149
|
result = new Array(object.length);
|
1042
1150
|
|
@@ -1045,24 +1153,25 @@
|
|
1045
1153
|
|
1046
1154
|
keys = Object.keys(pair);
|
1047
1155
|
|
1048
|
-
result[index] = [
|
1156
|
+
result[index] = [keys[0], pair[keys[0]]];
|
1049
1157
|
}
|
1050
1158
|
|
1051
1159
|
return result;
|
1052
1160
|
}
|
1053
1161
|
|
1054
|
-
|
1162
|
+
const pairs = new type('tag:yaml.org,2002:pairs', {
|
1055
1163
|
kind: 'sequence',
|
1056
1164
|
resolve: resolveYamlPairs,
|
1057
|
-
construct: constructYamlPairs
|
1165
|
+
construct: constructYamlPairs,
|
1058
1166
|
});
|
1059
1167
|
|
1060
|
-
|
1168
|
+
const _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
1061
1169
|
|
1062
1170
|
function resolveYamlSet(data) {
|
1063
1171
|
if (data === null) return true;
|
1064
1172
|
|
1065
|
-
|
1173
|
+
let key;
|
1174
|
+
const object = data;
|
1066
1175
|
|
1067
1176
|
for (key in object) {
|
1068
1177
|
if (_hasOwnProperty$2.call(object, key)) {
|
@@ -1077,90 +1186,78 @@
|
|
1077
1186
|
return data !== null ? data : {};
|
1078
1187
|
}
|
1079
1188
|
|
1080
|
-
|
1189
|
+
const set = new type('tag:yaml.org,2002:set', {
|
1081
1190
|
kind: 'mapping',
|
1082
1191
|
resolve: resolveYamlSet,
|
1083
|
-
construct: constructYamlSet
|
1192
|
+
construct: constructYamlSet,
|
1084
1193
|
});
|
1085
1194
|
|
1086
|
-
|
1087
|
-
implicit: [
|
1088
|
-
|
1089
|
-
merge
|
1090
|
-
],
|
1091
|
-
explicit: [
|
1092
|
-
binary,
|
1093
|
-
omap,
|
1094
|
-
pairs,
|
1095
|
-
set
|
1096
|
-
]
|
1195
|
+
const _default = core.extend({
|
1196
|
+
implicit: [timestamp, merge],
|
1197
|
+
explicit: [binary, omap, pairs, set],
|
1097
1198
|
});
|
1098
1199
|
|
1099
|
-
/*eslint-disable max-len,no-use-before-define*/
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1200
|
+
/* eslint-disable max-len,no-use-before-define */
|
1106
1201
|
|
1107
|
-
|
1202
|
+
const _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
1108
1203
|
|
1204
|
+
const CONTEXT_FLOW_IN = 1;
|
1205
|
+
const CONTEXT_FLOW_OUT = 2;
|
1206
|
+
const CONTEXT_BLOCK_IN = 3;
|
1207
|
+
const CONTEXT_BLOCK_OUT = 4;
|
1109
1208
|
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
var CONTEXT_BLOCK_OUT = 4;
|
1209
|
+
const CHOMPING_CLIP = 1;
|
1210
|
+
const CHOMPING_STRIP = 2;
|
1211
|
+
const CHOMPING_KEEP = 3;
|
1114
1212
|
|
1213
|
+
const PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
1214
|
+
const PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
1215
|
+
const PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
1216
|
+
const PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
1217
|
+
const PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
1115
1218
|
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
1122
|
-
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
1123
|
-
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
1124
|
-
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
1125
|
-
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
1126
|
-
|
1127
|
-
|
1128
|
-
function _class(obj) { return Object.prototype.toString.call(obj); }
|
1219
|
+
function _class(obj) {
|
1220
|
+
return Object.prototype.toString.call(obj);
|
1221
|
+
}
|
1129
1222
|
|
1130
1223
|
function is_EOL(c) {
|
1131
|
-
return
|
1224
|
+
return c === 0x0a /* LF */ || c === 0x0d /* CR */;
|
1132
1225
|
}
|
1133
1226
|
|
1134
1227
|
function is_WHITE_SPACE(c) {
|
1135
|
-
return
|
1228
|
+
return c === 0x09 /* Tab */ || c === 0x20 /* Space */;
|
1136
1229
|
}
|
1137
1230
|
|
1138
1231
|
function is_WS_OR_EOL(c) {
|
1139
|
-
return (
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1232
|
+
return (
|
1233
|
+
c === 0x09 /* Tab */ ||
|
1234
|
+
c === 0x20 /* Space */ ||
|
1235
|
+
c === 0x0a /* LF */ ||
|
1236
|
+
c === 0x0d /* CR */
|
1237
|
+
);
|
1143
1238
|
}
|
1144
1239
|
|
1145
1240
|
function is_FLOW_INDICATOR(c) {
|
1146
|
-
return
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1241
|
+
return (
|
1242
|
+
c === 0x2c /* , */ ||
|
1243
|
+
c === 0x5b /* [ */ ||
|
1244
|
+
c === 0x5d /* ] */ ||
|
1245
|
+
c === 0x7b /* { */ ||
|
1246
|
+
c === 0x7d /* } */
|
1247
|
+
);
|
1151
1248
|
}
|
1152
1249
|
|
1153
1250
|
function fromHexCode(c) {
|
1154
|
-
|
1251
|
+
let lc;
|
1155
1252
|
|
1156
|
-
if (
|
1253
|
+
if (c /* 0 */ >= 0x30 && c <= 0x39 /* 9 */) {
|
1157
1254
|
return c - 0x30;
|
1158
1255
|
}
|
1159
1256
|
|
1160
|
-
/*eslint-disable no-bitwise*/
|
1257
|
+
/* eslint-disable no-bitwise */
|
1161
1258
|
lc = c | 0x20;
|
1162
1259
|
|
1163
|
-
if (
|
1260
|
+
if (lc /* a */ >= 0x61 && lc <= 0x66 /* f */) {
|
1164
1261
|
return lc - 0x61 + 10;
|
1165
1262
|
}
|
1166
1263
|
|
@@ -1168,14 +1265,20 @@
|
|
1168
1265
|
}
|
1169
1266
|
|
1170
1267
|
function escapedHexLen(c) {
|
1171
|
-
if (c === 0x78/* x */) {
|
1172
|
-
|
1173
|
-
|
1268
|
+
if (c === 0x78 /* x */) {
|
1269
|
+
return 2;
|
1270
|
+
}
|
1271
|
+
if (c === 0x75 /* u */) {
|
1272
|
+
return 4;
|
1273
|
+
}
|
1274
|
+
if (c === 0x55 /* U */) {
|
1275
|
+
return 8;
|
1276
|
+
}
|
1174
1277
|
return 0;
|
1175
1278
|
}
|
1176
1279
|
|
1177
1280
|
function fromDecimalCode(c) {
|
1178
|
-
if (
|
1281
|
+
if (c /* 0 */ >= 0x30 && c <= 0x39 /* 9 */) {
|
1179
1282
|
return c - 0x30;
|
1180
1283
|
}
|
1181
1284
|
|
@@ -1184,66 +1287,84 @@
|
|
1184
1287
|
|
1185
1288
|
function simpleEscapeSequence(c) {
|
1186
1289
|
/* eslint-disable indent */
|
1187
|
-
return
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1290
|
+
return c === 0x30 /* 0 */
|
1291
|
+
? '\x00'
|
1292
|
+
: c === 0x61 /* a */
|
1293
|
+
? '\x07'
|
1294
|
+
: c === 0x62 /* b */
|
1295
|
+
? '\x08'
|
1296
|
+
: c === 0x74 /* t */
|
1297
|
+
? '\x09'
|
1298
|
+
: c === 0x09 /* Tab */
|
1299
|
+
? '\x09'
|
1300
|
+
: c === 0x6e /* n */
|
1301
|
+
? '\x0A'
|
1302
|
+
: c === 0x76 /* v */
|
1303
|
+
? '\x0B'
|
1304
|
+
: c === 0x66 /* f */
|
1305
|
+
? '\x0C'
|
1306
|
+
: c === 0x72 /* r */
|
1307
|
+
? '\x0D'
|
1308
|
+
: c === 0x65 /* e */
|
1309
|
+
? '\x1B'
|
1310
|
+
: c === 0x20 /* Space */
|
1311
|
+
? ' '
|
1312
|
+
: c === 0x22 /* " */
|
1313
|
+
? '\x22'
|
1314
|
+
: c === 0x2f /* / */
|
1315
|
+
? '/'
|
1316
|
+
: c === 0x5c /* \ */
|
1317
|
+
? '\x5C'
|
1318
|
+
: c === 0x4e /* N */
|
1319
|
+
? '\x85'
|
1320
|
+
: c === 0x5f /* _ */
|
1321
|
+
? '\xA0'
|
1322
|
+
: c === 0x4c /* L */
|
1323
|
+
? '\u2028'
|
1324
|
+
: c === 0x50 /* P */
|
1325
|
+
? '\u2029'
|
1326
|
+
: '';
|
1205
1327
|
}
|
1206
1328
|
|
1207
1329
|
function charFromCodepoint(c) {
|
1208
|
-
if (c <=
|
1330
|
+
if (c <= 0xffff) {
|
1209
1331
|
return String.fromCharCode(c);
|
1210
1332
|
}
|
1211
1333
|
// Encode UTF-16 surrogate pair
|
1212
1334
|
// https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
|
1213
1335
|
return String.fromCharCode(
|
1214
|
-
((c - 0x010000) >> 10) +
|
1215
|
-
((c - 0x010000) &
|
1336
|
+
((c - 0x010000) >> 10) + 0xd800,
|
1337
|
+
((c - 0x010000) & 0x03ff) + 0xdc00
|
1216
1338
|
);
|
1217
1339
|
}
|
1218
1340
|
|
1219
|
-
|
1220
|
-
|
1221
|
-
for (
|
1341
|
+
const simpleEscapeCheck = new Array(256); // integer, for fast access
|
1342
|
+
const simpleEscapeMap = new Array(256);
|
1343
|
+
for (let i = 0; i < 256; i++) {
|
1222
1344
|
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
1223
1345
|
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
1224
1346
|
}
|
1225
1347
|
|
1226
|
-
|
1227
1348
|
function State$1(input, options) {
|
1228
1349
|
this.input = input;
|
1229
1350
|
|
1230
|
-
this.filename
|
1231
|
-
this.schema
|
1232
|
-
this.onWarning = options
|
1351
|
+
this.filename = options.filename || null;
|
1352
|
+
this.schema = options.schema || _default;
|
1353
|
+
this.onWarning = options.onWarning || null;
|
1233
1354
|
// (Hidden) Remove? makes the loader to expect YAML 1.1 documents
|
1234
1355
|
// if such documents have no explicit %YAML directive
|
1235
|
-
this.legacy
|
1356
|
+
this.legacy = options.legacy || false;
|
1236
1357
|
|
1237
|
-
this.json
|
1238
|
-
this.listener
|
1358
|
+
this.json = options.json || false;
|
1359
|
+
this.listener = options.listener || null;
|
1239
1360
|
|
1240
1361
|
this.implicitTypes = this.schema.compiledImplicit;
|
1241
|
-
this.typeMap
|
1362
|
+
this.typeMap = this.schema.compiledTypeMap;
|
1242
1363
|
|
1243
|
-
this.length
|
1244
|
-
this.position
|
1245
|
-
this.line
|
1246
|
-
this.lineStart
|
1364
|
+
this.length = input.length;
|
1365
|
+
this.position = 0;
|
1366
|
+
this.line = 0;
|
1367
|
+
this.lineStart = 0;
|
1247
1368
|
this.lineIndent = 0;
|
1248
1369
|
|
1249
1370
|
// position of first leading tab in the current line,
|
@@ -1260,18 +1381,16 @@
|
|
1260
1381
|
this.tag;
|
1261
1382
|
this.anchor;
|
1262
1383
|
this.kind;
|
1263
|
-
this.result
|
1264
|
-
|
1384
|
+
this.result; */
|
1265
1385
|
}
|
1266
1386
|
|
1267
|
-
|
1268
1387
|
function generateError(state, message) {
|
1269
|
-
|
1270
|
-
name:
|
1271
|
-
buffer:
|
1388
|
+
const mark = {
|
1389
|
+
name: state.filename,
|
1390
|
+
buffer: state.input.slice(0, -1), // omit trailing \0
|
1272
1391
|
position: state.position,
|
1273
|
-
line:
|
1274
|
-
column:
|
1392
|
+
line: state.line,
|
1393
|
+
column: state.position - state.lineStart,
|
1275
1394
|
};
|
1276
1395
|
|
1277
1396
|
mark.snippet = snippet(mark);
|
@@ -1289,12 +1408,11 @@
|
|
1289
1408
|
}
|
1290
1409
|
}
|
1291
1410
|
|
1292
|
-
|
1293
|
-
var directiveHandlers = {
|
1294
|
-
|
1411
|
+
const directiveHandlers = {
|
1295
1412
|
YAML: function handleYamlDirective(state, name, args) {
|
1296
|
-
|
1297
|
-
|
1413
|
+
let match;
|
1414
|
+
let major;
|
1415
|
+
let minor;
|
1298
1416
|
|
1299
1417
|
if (state.version !== null) {
|
1300
1418
|
throwError(state, 'duplication of %YAML directive');
|
@@ -1318,7 +1436,7 @@
|
|
1318
1436
|
}
|
1319
1437
|
|
1320
1438
|
state.version = args[0];
|
1321
|
-
state.checkLineBreaks =
|
1439
|
+
state.checkLineBreaks = minor < 2;
|
1322
1440
|
|
1323
1441
|
if (minor !== 1 && minor !== 2) {
|
1324
1442
|
throwWarning(state, 'unsupported YAML version of the document');
|
@@ -1326,8 +1444,8 @@
|
|
1326
1444
|
},
|
1327
1445
|
|
1328
1446
|
TAG: function handleTagDirective(state, name, args) {
|
1329
|
-
|
1330
|
-
|
1447
|
+
let handle;
|
1448
|
+
let prefix;
|
1331
1449
|
|
1332
1450
|
if (args.length !== 2) {
|
1333
1451
|
throwError(state, 'TAG directive accepts exactly two arguments');
|
@@ -1337,39 +1455,58 @@
|
|
1337
1455
|
prefix = args[1];
|
1338
1456
|
|
1339
1457
|
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
1340
|
-
throwError(
|
1458
|
+
throwError(
|
1459
|
+
state,
|
1460
|
+
'ill-formed tag handle (first argument) of the TAG directive'
|
1461
|
+
);
|
1341
1462
|
}
|
1342
1463
|
|
1343
1464
|
if (_hasOwnProperty$1.call(state.tagMap, handle)) {
|
1344
|
-
throwError(
|
1465
|
+
throwError(
|
1466
|
+
state,
|
1467
|
+
`there is a previously declared suffix for "${handle}" tag handle`
|
1468
|
+
);
|
1345
1469
|
}
|
1346
1470
|
|
1347
1471
|
if (!PATTERN_TAG_URI.test(prefix)) {
|
1348
|
-
throwError(
|
1472
|
+
throwError(
|
1473
|
+
state,
|
1474
|
+
'ill-formed tag prefix (second argument) of the TAG directive'
|
1475
|
+
);
|
1349
1476
|
}
|
1350
1477
|
|
1351
1478
|
try {
|
1352
1479
|
prefix = decodeURIComponent(prefix);
|
1353
1480
|
} catch (err) {
|
1354
|
-
throwError(state,
|
1481
|
+
throwError(state, `tag prefix is malformed: ${prefix}`);
|
1355
1482
|
}
|
1356
1483
|
|
1357
1484
|
state.tagMap[handle] = prefix;
|
1358
|
-
}
|
1485
|
+
},
|
1359
1486
|
};
|
1360
1487
|
|
1361
|
-
|
1362
1488
|
function captureSegment(state, start, end, checkJson) {
|
1363
|
-
|
1489
|
+
let _position;
|
1490
|
+
let _length;
|
1491
|
+
let _character;
|
1492
|
+
let _result;
|
1364
1493
|
|
1365
1494
|
if (start < end) {
|
1366
1495
|
_result = state.input.slice(start, end);
|
1367
1496
|
|
1368
1497
|
if (checkJson) {
|
1369
|
-
for (
|
1498
|
+
for (
|
1499
|
+
_position = 0, _length = _result.length;
|
1500
|
+
_position < _length;
|
1501
|
+
_position += 1
|
1502
|
+
) {
|
1370
1503
|
_character = _result.charCodeAt(_position);
|
1371
|
-
if (
|
1372
|
-
|
1504
|
+
if (
|
1505
|
+
!(
|
1506
|
+
_character === 0x09 ||
|
1507
|
+
(_character >= 0x20 && _character <= 0x10ffff)
|
1508
|
+
)
|
1509
|
+
) {
|
1373
1510
|
throwError(state, 'expected valid JSON character');
|
1374
1511
|
}
|
1375
1512
|
}
|
@@ -1382,15 +1519,25 @@
|
|
1382
1519
|
}
|
1383
1520
|
|
1384
1521
|
function mergeMappings(state, destination, source, overridableKeys) {
|
1385
|
-
|
1522
|
+
let sourceKeys;
|
1523
|
+
let key;
|
1524
|
+
let index;
|
1525
|
+
let quantity;
|
1386
1526
|
|
1387
1527
|
if (!common.isObject(source)) {
|
1388
|
-
throwError(
|
1528
|
+
throwError(
|
1529
|
+
state,
|
1530
|
+
'cannot merge mappings; the provided source object is unacceptable'
|
1531
|
+
);
|
1389
1532
|
}
|
1390
1533
|
|
1391
1534
|
sourceKeys = Object.keys(source);
|
1392
1535
|
|
1393
|
-
for (
|
1536
|
+
for (
|
1537
|
+
index = 0, quantity = sourceKeys.length;
|
1538
|
+
index < quantity;
|
1539
|
+
index += 1
|
1540
|
+
) {
|
1394
1541
|
key = sourceKeys[index];
|
1395
1542
|
|
1396
1543
|
if (!_hasOwnProperty$1.call(destination, key)) {
|
@@ -1400,10 +1547,19 @@
|
|
1400
1547
|
}
|
1401
1548
|
}
|
1402
1549
|
|
1403
|
-
function storeMappingPair(
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1550
|
+
function storeMappingPair(
|
1551
|
+
state,
|
1552
|
+
_result,
|
1553
|
+
overridableKeys,
|
1554
|
+
keyTag,
|
1555
|
+
keyNode,
|
1556
|
+
valueNode,
|
1557
|
+
startLine,
|
1558
|
+
startLineStart,
|
1559
|
+
startPos
|
1560
|
+
) {
|
1561
|
+
let index;
|
1562
|
+
let quantity;
|
1407
1563
|
|
1408
1564
|
// The output is a plain object here, so keys can only be strings.
|
1409
1565
|
// We need to convert keyNode to a string, but doing so can hang the process
|
@@ -1416,7 +1572,10 @@
|
|
1416
1572
|
throwError(state, 'nested arrays are not supported inside keys');
|
1417
1573
|
}
|
1418
1574
|
|
1419
|
-
if (
|
1575
|
+
if (
|
1576
|
+
typeof keyNode === 'object' &&
|
1577
|
+
_class(keyNode[index]) === '[object Object]'
|
1578
|
+
) {
|
1420
1579
|
keyNode[index] = '[object Object]';
|
1421
1580
|
}
|
1422
1581
|
}
|
@@ -1429,7 +1588,6 @@
|
|
1429
1588
|
keyNode = '[object Object]';
|
1430
1589
|
}
|
1431
1590
|
|
1432
|
-
|
1433
1591
|
keyNode = String(keyNode);
|
1434
1592
|
|
1435
1593
|
if (_result === null) {
|
@@ -1438,16 +1596,22 @@
|
|
1438
1596
|
|
1439
1597
|
if (keyTag === 'tag:yaml.org,2002:merge') {
|
1440
1598
|
if (Array.isArray(valueNode)) {
|
1441
|
-
for (
|
1599
|
+
for (
|
1600
|
+
index = 0, quantity = valueNode.length;
|
1601
|
+
index < quantity;
|
1602
|
+
index += 1
|
1603
|
+
) {
|
1442
1604
|
mergeMappings(state, _result, valueNode[index], overridableKeys);
|
1443
1605
|
}
|
1444
1606
|
} else {
|
1445
1607
|
mergeMappings(state, _result, valueNode, overridableKeys);
|
1446
1608
|
}
|
1447
1609
|
} else {
|
1448
|
-
if (
|
1449
|
-
|
1450
|
-
|
1610
|
+
if (
|
1611
|
+
!state.json &&
|
1612
|
+
!_hasOwnProperty$1.call(overridableKeys, keyNode) &&
|
1613
|
+
_hasOwnProperty$1.call(_result, keyNode)
|
1614
|
+
) {
|
1451
1615
|
state.line = startLine || state.line;
|
1452
1616
|
state.lineStart = startLineStart || state.lineStart;
|
1453
1617
|
state.position = startPos || state.position;
|
@@ -1460,7 +1624,7 @@
|
|
1460
1624
|
configurable: true,
|
1461
1625
|
enumerable: true,
|
1462
1626
|
writable: true,
|
1463
|
-
value: valueNode
|
1627
|
+
value: valueNode,
|
1464
1628
|
});
|
1465
1629
|
} else {
|
1466
1630
|
_result[keyNode] = valueNode;
|
@@ -1472,15 +1636,15 @@
|
|
1472
1636
|
}
|
1473
1637
|
|
1474
1638
|
function readLineBreak(state) {
|
1475
|
-
|
1639
|
+
let ch;
|
1476
1640
|
|
1477
1641
|
ch = state.input.charCodeAt(state.position);
|
1478
1642
|
|
1479
|
-
if (ch ===
|
1643
|
+
if (ch === 0x0a /* LF */) {
|
1480
1644
|
state.position++;
|
1481
|
-
} else if (ch ===
|
1645
|
+
} else if (ch === 0x0d /* CR */) {
|
1482
1646
|
state.position++;
|
1483
|
-
if (state.input.charCodeAt(state.position) ===
|
1647
|
+
if (state.input.charCodeAt(state.position) === 0x0a /* LF */) {
|
1484
1648
|
state.position++;
|
1485
1649
|
}
|
1486
1650
|
} else {
|
@@ -1493,21 +1657,21 @@
|
|
1493
1657
|
}
|
1494
1658
|
|
1495
1659
|
function skipSeparationSpace(state, allowComments, checkIndent) {
|
1496
|
-
|
1497
|
-
|
1660
|
+
let lineBreaks = 0;
|
1661
|
+
let ch = state.input.charCodeAt(state.position);
|
1498
1662
|
|
1499
1663
|
while (ch !== 0) {
|
1500
1664
|
while (is_WHITE_SPACE(ch)) {
|
1501
|
-
if (ch === 0x09/* Tab */ && state.firstTabInLine === -1) {
|
1665
|
+
if (ch === 0x09 /* Tab */ && state.firstTabInLine === -1) {
|
1502
1666
|
state.firstTabInLine = state.position;
|
1503
1667
|
}
|
1504
1668
|
ch = state.input.charCodeAt(++state.position);
|
1505
1669
|
}
|
1506
1670
|
|
1507
|
-
if (allowComments && ch === 0x23/* # */) {
|
1671
|
+
if (allowComments && ch === 0x23 /* # */) {
|
1508
1672
|
do {
|
1509
1673
|
ch = state.input.charCodeAt(++state.position);
|
1510
|
-
} while (ch !==
|
1674
|
+
} while (ch !== 0x0a /* LF */ && ch !== 0x0d /* CR */ && ch !== 0);
|
1511
1675
|
}
|
1512
1676
|
|
1513
1677
|
if (is_EOL(ch)) {
|
@@ -1517,7 +1681,7 @@
|
|
1517
1681
|
lineBreaks++;
|
1518
1682
|
state.lineIndent = 0;
|
1519
1683
|
|
1520
|
-
while (ch === 0x20/* Space */) {
|
1684
|
+
while (ch === 0x20 /* Space */) {
|
1521
1685
|
state.lineIndent++;
|
1522
1686
|
ch = state.input.charCodeAt(++state.position);
|
1523
1687
|
}
|
@@ -1526,7 +1690,11 @@
|
|
1526
1690
|
}
|
1527
1691
|
}
|
1528
1692
|
|
1529
|
-
if (
|
1693
|
+
if (
|
1694
|
+
checkIndent !== -1 &&
|
1695
|
+
lineBreaks !== 0 &&
|
1696
|
+
state.lineIndent < checkIndent
|
1697
|
+
) {
|
1530
1698
|
throwWarning(state, 'deficient indentation');
|
1531
1699
|
}
|
1532
1700
|
|
@@ -1534,17 +1702,18 @@
|
|
1534
1702
|
}
|
1535
1703
|
|
1536
1704
|
function testDocumentSeparator(state) {
|
1537
|
-
|
1538
|
-
|
1705
|
+
let _position = state.position;
|
1706
|
+
let ch;
|
1539
1707
|
|
1540
1708
|
ch = state.input.charCodeAt(_position);
|
1541
1709
|
|
1542
1710
|
// Condition state.position === state.lineStart is tested
|
1543
1711
|
// in parent on each call, for efficiency. No needs to test here again.
|
1544
|
-
if (
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1712
|
+
if (
|
1713
|
+
(ch === 0x2d /* - */ || ch === 0x2e) /* . */ &&
|
1714
|
+
ch === state.input.charCodeAt(_position + 1) &&
|
1715
|
+
ch === state.input.charCodeAt(_position + 2)
|
1716
|
+
) {
|
1548
1717
|
_position += 3;
|
1549
1718
|
|
1550
1719
|
ch = state.input.charCodeAt(_position);
|
@@ -1565,43 +1734,46 @@
|
|
1565
1734
|
}
|
1566
1735
|
}
|
1567
1736
|
|
1568
|
-
|
1569
1737
|
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1738
|
+
let preceding;
|
1739
|
+
let following;
|
1740
|
+
let captureStart;
|
1741
|
+
let captureEnd;
|
1742
|
+
let hasPendingContent;
|
1743
|
+
let _line;
|
1744
|
+
let _lineStart;
|
1745
|
+
let _lineIndent;
|
1746
|
+
const _kind = state.kind;
|
1747
|
+
const _result = state.result;
|
1748
|
+
let ch;
|
1581
1749
|
|
1582
1750
|
ch = state.input.charCodeAt(state.position);
|
1583
1751
|
|
1584
|
-
if (
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1752
|
+
if (
|
1753
|
+
is_WS_OR_EOL(ch) ||
|
1754
|
+
is_FLOW_INDICATOR(ch) ||
|
1755
|
+
ch === 0x23 /* # */ ||
|
1756
|
+
ch === 0x26 /* & */ ||
|
1757
|
+
ch === 0x2a /* * */ ||
|
1758
|
+
ch === 0x21 /* ! */ ||
|
1759
|
+
ch === 0x7c /* | */ ||
|
1760
|
+
ch === 0x3e /* > */ ||
|
1761
|
+
ch === 0x27 /* ' */ ||
|
1762
|
+
ch === 0x22 /* " */ ||
|
1763
|
+
ch === 0x25 /* % */ ||
|
1764
|
+
ch === 0x40 /* @ */ ||
|
1765
|
+
ch === 0x60 /* ` */
|
1766
|
+
) {
|
1597
1767
|
return false;
|
1598
1768
|
}
|
1599
1769
|
|
1600
|
-
if (ch ===
|
1770
|
+
if (ch === 0x3f /* ? */ || ch === 0x2d /* - */) {
|
1601
1771
|
following = state.input.charCodeAt(state.position + 1);
|
1602
1772
|
|
1603
|
-
if (
|
1604
|
-
|
1773
|
+
if (
|
1774
|
+
is_WS_OR_EOL(following) ||
|
1775
|
+
(withinFlowCollection && is_FLOW_INDICATOR(following))
|
1776
|
+
) {
|
1605
1777
|
return false;
|
1606
1778
|
}
|
1607
1779
|
}
|
@@ -1612,25 +1784,26 @@
|
|
1612
1784
|
hasPendingContent = false;
|
1613
1785
|
|
1614
1786
|
while (ch !== 0) {
|
1615
|
-
if (ch ===
|
1787
|
+
if (ch === 0x3a /* : */) {
|
1616
1788
|
following = state.input.charCodeAt(state.position + 1);
|
1617
1789
|
|
1618
|
-
if (
|
1619
|
-
|
1790
|
+
if (
|
1791
|
+
is_WS_OR_EOL(following) ||
|
1792
|
+
(withinFlowCollection && is_FLOW_INDICATOR(following))
|
1793
|
+
) {
|
1620
1794
|
break;
|
1621
1795
|
}
|
1622
|
-
|
1623
|
-
} else if (ch === 0x23/* # */) {
|
1796
|
+
} else if (ch === 0x23 /* # */) {
|
1624
1797
|
preceding = state.input.charCodeAt(state.position - 1);
|
1625
1798
|
|
1626
1799
|
if (is_WS_OR_EOL(preceding)) {
|
1627
1800
|
break;
|
1628
1801
|
}
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1802
|
+
} else if (
|
1803
|
+
(state.position === state.lineStart && testDocumentSeparator(state)) ||
|
1804
|
+
(withinFlowCollection && is_FLOW_INDICATOR(ch))
|
1805
|
+
) {
|
1632
1806
|
break;
|
1633
|
-
|
1634
1807
|
} else if (is_EOL(ch)) {
|
1635
1808
|
_line = state.line;
|
1636
1809
|
_lineStart = state.lineStart;
|
@@ -1676,12 +1849,13 @@
|
|
1676
1849
|
}
|
1677
1850
|
|
1678
1851
|
function readSingleQuotedScalar(state, nodeIndent) {
|
1679
|
-
|
1680
|
-
|
1852
|
+
let ch;
|
1853
|
+
let captureStart;
|
1854
|
+
let captureEnd;
|
1681
1855
|
|
1682
1856
|
ch = state.input.charCodeAt(state.position);
|
1683
1857
|
|
1684
|
-
if (ch !== 0x27/* ' */) {
|
1858
|
+
if (ch !== 0x27 /* ' */) {
|
1685
1859
|
return false;
|
1686
1860
|
}
|
1687
1861
|
|
@@ -1691,46 +1865,52 @@
|
|
1691
1865
|
captureStart = captureEnd = state.position;
|
1692
1866
|
|
1693
1867
|
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
1694
|
-
if (ch === 0x27/* ' */) {
|
1868
|
+
if (ch === 0x27 /* ' */) {
|
1695
1869
|
captureSegment(state, captureStart, state.position, true);
|
1696
1870
|
ch = state.input.charCodeAt(++state.position);
|
1697
1871
|
|
1698
|
-
if (ch === 0x27/* ' */) {
|
1872
|
+
if (ch === 0x27 /* ' */) {
|
1699
1873
|
captureStart = state.position;
|
1700
1874
|
state.position++;
|
1701
1875
|
captureEnd = state.position;
|
1702
1876
|
} else {
|
1703
1877
|
return true;
|
1704
1878
|
}
|
1705
|
-
|
1706
1879
|
} else if (is_EOL(ch)) {
|
1707
1880
|
captureSegment(state, captureStart, captureEnd, true);
|
1708
1881
|
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
1709
1882
|
captureStart = captureEnd = state.position;
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1883
|
+
} else if (
|
1884
|
+
state.position === state.lineStart &&
|
1885
|
+
testDocumentSeparator(state)
|
1886
|
+
) {
|
1887
|
+
throwError(
|
1888
|
+
state,
|
1889
|
+
'unexpected end of the document within a single quoted scalar'
|
1890
|
+
);
|
1714
1891
|
} else {
|
1715
1892
|
state.position++;
|
1716
1893
|
captureEnd = state.position;
|
1717
1894
|
}
|
1718
1895
|
}
|
1719
1896
|
|
1720
|
-
throwError(
|
1897
|
+
throwError(
|
1898
|
+
state,
|
1899
|
+
'unexpected end of the stream within a single quoted scalar'
|
1900
|
+
);
|
1721
1901
|
}
|
1722
1902
|
|
1723
1903
|
function readDoubleQuotedScalar(state, nodeIndent) {
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1904
|
+
let captureStart;
|
1905
|
+
let captureEnd;
|
1906
|
+
let hexLength;
|
1907
|
+
let hexResult;
|
1908
|
+
let tmp;
|
1909
|
+
let ch;
|
1730
1910
|
|
1731
1911
|
ch = state.input.charCodeAt(state.position);
|
1732
1912
|
|
1733
|
-
if (ch !== 0x22/* " */) {
|
1913
|
+
if (ch !== 0x22 /* " */) {
|
1734
1914
|
return false;
|
1735
1915
|
}
|
1736
1916
|
|
@@ -1740,12 +1920,11 @@
|
|
1740
1920
|
captureStart = captureEnd = state.position;
|
1741
1921
|
|
1742
1922
|
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
1743
|
-
if (ch === 0x22/* " */) {
|
1923
|
+
if (ch === 0x22 /* " */) {
|
1744
1924
|
captureSegment(state, captureStart, state.position, true);
|
1745
1925
|
state.position++;
|
1746
1926
|
return true;
|
1747
|
-
|
1748
|
-
} else if (ch === 0x5C/* \ */) {
|
1927
|
+
} else if (ch === 0x5c /* \ */) {
|
1749
1928
|
captureSegment(state, captureStart, state.position, true);
|
1750
1929
|
ch = state.input.charCodeAt(++state.position);
|
1751
1930
|
|
@@ -1756,7 +1935,6 @@
|
|
1756
1935
|
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
1757
1936
|
state.result += simpleEscapeMap[ch];
|
1758
1937
|
state.position++;
|
1759
|
-
|
1760
1938
|
} else if ((tmp = escapedHexLen(ch)) > 0) {
|
1761
1939
|
hexLength = tmp;
|
1762
1940
|
hexResult = 0;
|
@@ -1766,7 +1944,6 @@
|
|
1766
1944
|
|
1767
1945
|
if ((tmp = fromHexCode(ch)) >= 0) {
|
1768
1946
|
hexResult = (hexResult << 4) + tmp;
|
1769
|
-
|
1770
1947
|
} else {
|
1771
1948
|
throwError(state, 'expected hexadecimal character');
|
1772
1949
|
}
|
@@ -1775,57 +1952,62 @@
|
|
1775
1952
|
state.result += charFromCodepoint(hexResult);
|
1776
1953
|
|
1777
1954
|
state.position++;
|
1778
|
-
|
1779
1955
|
} else {
|
1780
1956
|
throwError(state, 'unknown escape sequence');
|
1781
1957
|
}
|
1782
1958
|
|
1783
1959
|
captureStart = captureEnd = state.position;
|
1784
|
-
|
1785
1960
|
} else if (is_EOL(ch)) {
|
1786
1961
|
captureSegment(state, captureStart, captureEnd, true);
|
1787
1962
|
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
1788
1963
|
captureStart = captureEnd = state.position;
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1964
|
+
} else if (
|
1965
|
+
state.position === state.lineStart &&
|
1966
|
+
testDocumentSeparator(state)
|
1967
|
+
) {
|
1968
|
+
throwError(
|
1969
|
+
state,
|
1970
|
+
'unexpected end of the document within a double quoted scalar'
|
1971
|
+
);
|
1793
1972
|
} else {
|
1794
1973
|
state.position++;
|
1795
1974
|
captureEnd = state.position;
|
1796
1975
|
}
|
1797
1976
|
}
|
1798
1977
|
|
1799
|
-
throwError(
|
1978
|
+
throwError(
|
1979
|
+
state,
|
1980
|
+
'unexpected end of the stream within a double quoted scalar'
|
1981
|
+
);
|
1800
1982
|
}
|
1801
1983
|
|
1802
1984
|
function readFlowCollection(state, nodeIndent) {
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1815
|
-
|
1816
|
-
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1985
|
+
let readNext = true;
|
1986
|
+
let _line;
|
1987
|
+
let _lineStart;
|
1988
|
+
let _pos;
|
1989
|
+
const _tag = state.tag;
|
1990
|
+
let _result;
|
1991
|
+
const _anchor = state.anchor;
|
1992
|
+
let following;
|
1993
|
+
let terminator;
|
1994
|
+
let isPair;
|
1995
|
+
let isExplicitPair;
|
1996
|
+
let isMapping;
|
1997
|
+
const overridableKeys = Object.create(null);
|
1998
|
+
let keyNode;
|
1999
|
+
let keyTag;
|
2000
|
+
let valueNode;
|
2001
|
+
let ch;
|
1820
2002
|
|
1821
2003
|
ch = state.input.charCodeAt(state.position);
|
1822
2004
|
|
1823
|
-
if (ch ===
|
1824
|
-
terminator =
|
2005
|
+
if (ch === 0x5b /* [ */) {
|
2006
|
+
terminator = 0x5d; /* ] */
|
1825
2007
|
isMapping = false;
|
1826
2008
|
_result = [];
|
1827
|
-
} else if (ch ===
|
1828
|
-
terminator =
|
2009
|
+
} else if (ch === 0x7b /* { */) {
|
2010
|
+
terminator = 0x7d; /* } */
|
1829
2011
|
isMapping = true;
|
1830
2012
|
_result = {};
|
1831
2013
|
} else {
|
@@ -1852,7 +2034,7 @@
|
|
1852
2034
|
return true;
|
1853
2035
|
} else if (!readNext) {
|
1854
2036
|
throwError(state, 'missed comma between flow collection entries');
|
1855
|
-
} else if (ch ===
|
2037
|
+
} else if (ch === 0x2c /* , */) {
|
1856
2038
|
// "flow collection entries can never be completely empty", as per YAML 1.2, section 7.4
|
1857
2039
|
throwError(state, "expected the node content, but found ','");
|
1858
2040
|
}
|
@@ -1860,7 +2042,7 @@
|
|
1860
2042
|
keyTag = keyNode = valueNode = null;
|
1861
2043
|
isPair = isExplicitPair = false;
|
1862
2044
|
|
1863
|
-
if (ch ===
|
2045
|
+
if (ch === 0x3f /* ? */) {
|
1864
2046
|
following = state.input.charCodeAt(state.position + 1);
|
1865
2047
|
|
1866
2048
|
if (is_WS_OR_EOL(following)) {
|
@@ -1880,7 +2062,7 @@
|
|
1880
2062
|
|
1881
2063
|
ch = state.input.charCodeAt(state.position);
|
1882
2064
|
|
1883
|
-
if ((isExplicitPair || state.line === _line) && ch ===
|
2065
|
+
if ((isExplicitPair || state.line === _line) && ch === 0x3a /* : */) {
|
1884
2066
|
isPair = true;
|
1885
2067
|
ch = state.input.charCodeAt(++state.position);
|
1886
2068
|
skipSeparationSpace(state, true, nodeIndent);
|
@@ -1889,9 +2071,31 @@
|
|
1889
2071
|
}
|
1890
2072
|
|
1891
2073
|
if (isMapping) {
|
1892
|
-
storeMappingPair(
|
2074
|
+
storeMappingPair(
|
2075
|
+
state,
|
2076
|
+
_result,
|
2077
|
+
overridableKeys,
|
2078
|
+
keyTag,
|
2079
|
+
keyNode,
|
2080
|
+
valueNode,
|
2081
|
+
_line,
|
2082
|
+
_lineStart,
|
2083
|
+
_pos
|
2084
|
+
);
|
1893
2085
|
} else if (isPair) {
|
1894
|
-
_result.push(
|
2086
|
+
_result.push(
|
2087
|
+
storeMappingPair(
|
2088
|
+
state,
|
2089
|
+
null,
|
2090
|
+
overridableKeys,
|
2091
|
+
keyTag,
|
2092
|
+
keyNode,
|
2093
|
+
valueNode,
|
2094
|
+
_line,
|
2095
|
+
_lineStart,
|
2096
|
+
_pos
|
2097
|
+
)
|
2098
|
+
);
|
1895
2099
|
} else {
|
1896
2100
|
_result.push(keyNode);
|
1897
2101
|
}
|
@@ -1900,7 +2104,7 @@
|
|
1900
2104
|
|
1901
2105
|
ch = state.input.charCodeAt(state.position);
|
1902
2106
|
|
1903
|
-
if (ch ===
|
2107
|
+
if (ch === 0x2c /* , */) {
|
1904
2108
|
readNext = true;
|
1905
2109
|
ch = state.input.charCodeAt(++state.position);
|
1906
2110
|
} else {
|
@@ -1912,22 +2116,22 @@
|
|
1912
2116
|
}
|
1913
2117
|
|
1914
2118
|
function readBlockScalar(state, nodeIndent) {
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
2119
|
+
let captureStart;
|
2120
|
+
let folding;
|
2121
|
+
let chomping = CHOMPING_CLIP;
|
2122
|
+
let didReadContent = false;
|
2123
|
+
let detectedIndent = false;
|
2124
|
+
let textIndent = nodeIndent;
|
2125
|
+
let emptyLines = 0;
|
2126
|
+
let atMoreIndented = false;
|
2127
|
+
let tmp;
|
2128
|
+
let ch;
|
1925
2129
|
|
1926
2130
|
ch = state.input.charCodeAt(state.position);
|
1927
2131
|
|
1928
|
-
if (ch ===
|
2132
|
+
if (ch === 0x7c /* | */) {
|
1929
2133
|
folding = false;
|
1930
|
-
} else if (ch ===
|
2134
|
+
} else if (ch === 0x3e /* > */) {
|
1931
2135
|
folding = true;
|
1932
2136
|
} else {
|
1933
2137
|
return false;
|
@@ -1939,35 +2143,38 @@
|
|
1939
2143
|
while (ch !== 0) {
|
1940
2144
|
ch = state.input.charCodeAt(++state.position);
|
1941
2145
|
|
1942
|
-
if (ch ===
|
2146
|
+
if (ch === 0x2b /* + */ || ch === 0x2d /* - */) {
|
1943
2147
|
if (CHOMPING_CLIP === chomping) {
|
1944
|
-
chomping =
|
2148
|
+
chomping = ch === 0x2b /* + */ ? CHOMPING_KEEP : CHOMPING_STRIP;
|
1945
2149
|
} else {
|
1946
2150
|
throwError(state, 'repeat of a chomping mode identifier');
|
1947
2151
|
}
|
1948
|
-
|
1949
2152
|
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
1950
2153
|
if (tmp === 0) {
|
1951
|
-
throwError(
|
2154
|
+
throwError(
|
2155
|
+
state,
|
2156
|
+
'bad explicit indentation width of a block scalar; it cannot be less than one'
|
2157
|
+
);
|
1952
2158
|
} else if (!detectedIndent) {
|
1953
2159
|
textIndent = nodeIndent + tmp - 1;
|
1954
2160
|
detectedIndent = true;
|
1955
2161
|
} else {
|
1956
2162
|
throwError(state, 'repeat of an indentation width identifier');
|
1957
2163
|
}
|
1958
|
-
|
1959
2164
|
} else {
|
1960
2165
|
break;
|
1961
2166
|
}
|
1962
2167
|
}
|
1963
2168
|
|
1964
2169
|
if (is_WHITE_SPACE(ch)) {
|
1965
|
-
do {
|
1966
|
-
|
2170
|
+
do {
|
2171
|
+
ch = state.input.charCodeAt(++state.position);
|
2172
|
+
} while (is_WHITE_SPACE(ch));
|
1967
2173
|
|
1968
|
-
if (ch === 0x23/* # */) {
|
1969
|
-
do {
|
1970
|
-
|
2174
|
+
if (ch === 0x23 /* # */) {
|
2175
|
+
do {
|
2176
|
+
ch = state.input.charCodeAt(++state.position);
|
2177
|
+
} while (!is_EOL(ch) && ch !== 0);
|
1971
2178
|
}
|
1972
2179
|
}
|
1973
2180
|
|
@@ -1977,8 +2184,10 @@
|
|
1977
2184
|
|
1978
2185
|
ch = state.input.charCodeAt(state.position);
|
1979
2186
|
|
1980
|
-
while (
|
1981
|
-
|
2187
|
+
while (
|
2188
|
+
(!detectedIndent || state.lineIndent < textIndent) &&
|
2189
|
+
ch === 0x20 /* Space */
|
2190
|
+
) {
|
1982
2191
|
state.lineIndent++;
|
1983
2192
|
ch = state.input.charCodeAt(++state.position);
|
1984
2193
|
}
|
@@ -1994,12 +2203,15 @@
|
|
1994
2203
|
|
1995
2204
|
// End of the scalar.
|
1996
2205
|
if (state.lineIndent < textIndent) {
|
1997
|
-
|
1998
2206
|
// Perform the chomping.
|
1999
2207
|
if (chomping === CHOMPING_KEEP) {
|
2000
|
-
state.result += common.repeat(
|
2208
|
+
state.result += common.repeat(
|
2209
|
+
'\n',
|
2210
|
+
didReadContent ? 1 + emptyLines : emptyLines
|
2211
|
+
);
|
2001
2212
|
} else if (chomping === CHOMPING_CLIP) {
|
2002
|
-
if (didReadContent) {
|
2213
|
+
if (didReadContent) {
|
2214
|
+
// i.e. only if the scalar is not empty.
|
2003
2215
|
state.result += '\n';
|
2004
2216
|
}
|
2005
2217
|
}
|
@@ -2010,33 +2222,39 @@
|
|
2010
2222
|
|
2011
2223
|
// Folded style: use fancy rules to handle line breaks.
|
2012
2224
|
if (folding) {
|
2013
|
-
|
2014
2225
|
// Lines starting with white space characters (more-indented lines) are not folded.
|
2015
2226
|
if (is_WHITE_SPACE(ch)) {
|
2016
2227
|
atMoreIndented = true;
|
2017
2228
|
// except for the first content line (cf. Example 8.1)
|
2018
|
-
state.result += common.repeat(
|
2229
|
+
state.result += common.repeat(
|
2230
|
+
'\n',
|
2231
|
+
didReadContent ? 1 + emptyLines : emptyLines
|
2232
|
+
);
|
2019
2233
|
|
2020
|
-
|
2234
|
+
// End of more-indented block.
|
2021
2235
|
} else if (atMoreIndented) {
|
2022
2236
|
atMoreIndented = false;
|
2023
2237
|
state.result += common.repeat('\n', emptyLines + 1);
|
2024
2238
|
|
2025
|
-
|
2239
|
+
// Just one line break - perceive as the same line.
|
2026
2240
|
} else if (emptyLines === 0) {
|
2027
|
-
if (didReadContent) {
|
2241
|
+
if (didReadContent) {
|
2242
|
+
// i.e. only if we have already read some scalar content.
|
2028
2243
|
state.result += ' ';
|
2029
2244
|
}
|
2030
2245
|
|
2031
|
-
|
2246
|
+
// Several line breaks - perceive as different lines.
|
2032
2247
|
} else {
|
2033
2248
|
state.result += common.repeat('\n', emptyLines);
|
2034
2249
|
}
|
2035
2250
|
|
2036
|
-
|
2251
|
+
// Literal style: just add exact number of line breaks between content lines.
|
2037
2252
|
} else {
|
2038
2253
|
// Keep all line breaks except the header line break.
|
2039
|
-
state.result += common.repeat(
|
2254
|
+
state.result += common.repeat(
|
2255
|
+
'\n',
|
2256
|
+
didReadContent ? 1 + emptyLines : emptyLines
|
2257
|
+
);
|
2040
2258
|
}
|
2041
2259
|
|
2042
2260
|
didReadContent = true;
|
@@ -2044,7 +2262,7 @@
|
|
2044
2262
|
emptyLines = 0;
|
2045
2263
|
captureStart = state.position;
|
2046
2264
|
|
2047
|
-
while (!is_EOL(ch) &&
|
2265
|
+
while (!is_EOL(ch) && ch !== 0) {
|
2048
2266
|
ch = state.input.charCodeAt(++state.position);
|
2049
2267
|
}
|
2050
2268
|
|
@@ -2055,13 +2273,13 @@
|
|
2055
2273
|
}
|
2056
2274
|
|
2057
2275
|
function readBlockSequence(state, nodeIndent) {
|
2058
|
-
|
2059
|
-
|
2060
|
-
|
2061
|
-
|
2062
|
-
|
2063
|
-
|
2064
|
-
|
2276
|
+
let _line;
|
2277
|
+
const _tag = state.tag;
|
2278
|
+
const _anchor = state.anchor;
|
2279
|
+
const _result = [];
|
2280
|
+
let following;
|
2281
|
+
let detected = false;
|
2282
|
+
let ch;
|
2065
2283
|
|
2066
2284
|
// there is a leading tab before this token, so it can't be a block sequence/mapping;
|
2067
2285
|
// it can still be flow sequence/mapping or a scalar
|
@@ -2079,7 +2297,7 @@
|
|
2079
2297
|
throwError(state, 'tab characters must not be used in indentation');
|
2080
2298
|
}
|
2081
2299
|
|
2082
|
-
if (ch !==
|
2300
|
+
if (ch !== 0x2d /* - */) {
|
2083
2301
|
break;
|
2084
2302
|
}
|
2085
2303
|
|
@@ -2107,7 +2325,7 @@
|
|
2107
2325
|
|
2108
2326
|
ch = state.input.charCodeAt(state.position);
|
2109
2327
|
|
2110
|
-
if ((state.line === _line || state.lineIndent > nodeIndent) &&
|
2328
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
2111
2329
|
throwError(state, 'bad indentation of a sequence entry');
|
2112
2330
|
} else if (state.lineIndent < nodeIndent) {
|
2113
2331
|
break;
|
@@ -2125,22 +2343,22 @@
|
|
2125
2343
|
}
|
2126
2344
|
|
2127
2345
|
function readBlockMapping(state, nodeIndent, flowIndent) {
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2134
|
-
|
2135
|
-
|
2136
|
-
|
2137
|
-
|
2138
|
-
|
2139
|
-
|
2140
|
-
|
2141
|
-
|
2142
|
-
|
2143
|
-
|
2346
|
+
let following;
|
2347
|
+
let allowCompact;
|
2348
|
+
let _line;
|
2349
|
+
let _keyLine;
|
2350
|
+
let _keyLineStart;
|
2351
|
+
let _keyPos;
|
2352
|
+
const _tag = state.tag;
|
2353
|
+
const _anchor = state.anchor;
|
2354
|
+
const _result = {};
|
2355
|
+
const overridableKeys = Object.create(null);
|
2356
|
+
let keyTag = null;
|
2357
|
+
let keyNode = null;
|
2358
|
+
let valueNode = null;
|
2359
|
+
let atExplicitKey = false;
|
2360
|
+
let detected = false;
|
2361
|
+
let ch;
|
2144
2362
|
|
2145
2363
|
// there is a leading tab before this token, so it can't be a block sequence/mapping;
|
2146
2364
|
// it can still be flow sequence/mapping or a scalar
|
@@ -2165,33 +2383,46 @@
|
|
2165
2383
|
// Explicit notation case. There are two separate blocks:
|
2166
2384
|
// first for the key (denoted by "?") and second for the value (denoted by ":")
|
2167
2385
|
//
|
2168
|
-
if (
|
2169
|
-
|
2170
|
-
|
2386
|
+
if (
|
2387
|
+
(ch === 0x3f /* ? */ || ch === 0x3a /*: */) &&
|
2388
|
+
is_WS_OR_EOL(following)
|
2389
|
+
) {
|
2390
|
+
if (ch === 0x3f /* ? */) {
|
2171
2391
|
if (atExplicitKey) {
|
2172
|
-
storeMappingPair(
|
2392
|
+
storeMappingPair(
|
2393
|
+
state,
|
2394
|
+
_result,
|
2395
|
+
overridableKeys,
|
2396
|
+
keyTag,
|
2397
|
+
keyNode,
|
2398
|
+
null,
|
2399
|
+
_keyLine,
|
2400
|
+
_keyLineStart,
|
2401
|
+
_keyPos
|
2402
|
+
);
|
2173
2403
|
keyTag = keyNode = valueNode = null;
|
2174
2404
|
}
|
2175
2405
|
|
2176
2406
|
detected = true;
|
2177
2407
|
atExplicitKey = true;
|
2178
2408
|
allowCompact = true;
|
2179
|
-
|
2180
2409
|
} else if (atExplicitKey) {
|
2181
2410
|
// i.e. 0x3A/* : */ === character after the explicit key.
|
2182
2411
|
atExplicitKey = false;
|
2183
2412
|
allowCompact = true;
|
2184
|
-
|
2185
2413
|
} else {
|
2186
|
-
throwError(
|
2414
|
+
throwError(
|
2415
|
+
state,
|
2416
|
+
'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line'
|
2417
|
+
);
|
2187
2418
|
}
|
2188
2419
|
|
2189
2420
|
state.position += 1;
|
2190
2421
|
ch = following;
|
2191
2422
|
|
2192
|
-
|
2193
|
-
|
2194
|
-
|
2423
|
+
//
|
2424
|
+
// Implicit notation case. Flow-style node as the key first, then ":", and the value.
|
2425
|
+
//
|
2195
2426
|
} else {
|
2196
2427
|
_keyLine = state.line;
|
2197
2428
|
_keyLineStart = state.lineStart;
|
@@ -2210,15 +2441,28 @@
|
|
2210
2441
|
ch = state.input.charCodeAt(++state.position);
|
2211
2442
|
}
|
2212
2443
|
|
2213
|
-
if (ch ===
|
2444
|
+
if (ch === 0x3a /* : */) {
|
2214
2445
|
ch = state.input.charCodeAt(++state.position);
|
2215
2446
|
|
2216
2447
|
if (!is_WS_OR_EOL(ch)) {
|
2217
|
-
throwError(
|
2448
|
+
throwError(
|
2449
|
+
state,
|
2450
|
+
'a whitespace character is expected after the key-value separator within a block mapping'
|
2451
|
+
);
|
2218
2452
|
}
|
2219
2453
|
|
2220
2454
|
if (atExplicitKey) {
|
2221
|
-
storeMappingPair(
|
2455
|
+
storeMappingPair(
|
2456
|
+
state,
|
2457
|
+
_result,
|
2458
|
+
overridableKeys,
|
2459
|
+
keyTag,
|
2460
|
+
keyNode,
|
2461
|
+
null,
|
2462
|
+
_keyLine,
|
2463
|
+
_keyLineStart,
|
2464
|
+
_keyPos
|
2465
|
+
);
|
2222
2466
|
keyTag = keyNode = valueNode = null;
|
2223
2467
|
}
|
2224
2468
|
|
@@ -2227,19 +2471,21 @@
|
|
2227
2471
|
allowCompact = false;
|
2228
2472
|
keyTag = state.tag;
|
2229
2473
|
keyNode = state.result;
|
2230
|
-
|
2231
2474
|
} else if (detected) {
|
2232
|
-
throwError(
|
2233
|
-
|
2475
|
+
throwError(
|
2476
|
+
state,
|
2477
|
+
'can not read an implicit mapping pair; a colon is missed'
|
2478
|
+
);
|
2234
2479
|
} else {
|
2235
2480
|
state.tag = _tag;
|
2236
2481
|
state.anchor = _anchor;
|
2237
2482
|
return true; // Keep the result of `composeNode`.
|
2238
2483
|
}
|
2239
|
-
|
2240
2484
|
} else if (detected) {
|
2241
|
-
throwError(
|
2242
|
-
|
2485
|
+
throwError(
|
2486
|
+
state,
|
2487
|
+
'can not read a block mapping entry; a multiline key may not be an implicit key'
|
2488
|
+
);
|
2243
2489
|
} else {
|
2244
2490
|
state.tag = _tag;
|
2245
2491
|
state.anchor = _anchor;
|
@@ -2257,7 +2503,9 @@
|
|
2257
2503
|
_keyPos = state.position;
|
2258
2504
|
}
|
2259
2505
|
|
2260
|
-
if (
|
2506
|
+
if (
|
2507
|
+
composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)
|
2508
|
+
) {
|
2261
2509
|
if (atExplicitKey) {
|
2262
2510
|
keyNode = state.result;
|
2263
2511
|
} else {
|
@@ -2266,7 +2514,17 @@
|
|
2266
2514
|
}
|
2267
2515
|
|
2268
2516
|
if (!atExplicitKey) {
|
2269
|
-
storeMappingPair(
|
2517
|
+
storeMappingPair(
|
2518
|
+
state,
|
2519
|
+
_result,
|
2520
|
+
overridableKeys,
|
2521
|
+
keyTag,
|
2522
|
+
keyNode,
|
2523
|
+
valueNode,
|
2524
|
+
_keyLine,
|
2525
|
+
_keyLineStart,
|
2526
|
+
_keyPos
|
2527
|
+
);
|
2270
2528
|
keyTag = keyNode = valueNode = null;
|
2271
2529
|
}
|
2272
2530
|
|
@@ -2274,7 +2532,7 @@
|
|
2274
2532
|
ch = state.input.charCodeAt(state.position);
|
2275
2533
|
}
|
2276
2534
|
|
2277
|
-
if ((state.line === _line || state.lineIndent > nodeIndent) &&
|
2535
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
2278
2536
|
throwError(state, 'bad indentation of a mapping entry');
|
2279
2537
|
} else if (state.lineIndent < nodeIndent) {
|
2280
2538
|
break;
|
@@ -2287,7 +2545,17 @@
|
|
2287
2545
|
|
2288
2546
|
// Special case: last mapping's node contains only the key in explicit notation.
|
2289
2547
|
if (atExplicitKey) {
|
2290
|
-
storeMappingPair(
|
2548
|
+
storeMappingPair(
|
2549
|
+
state,
|
2550
|
+
_result,
|
2551
|
+
overridableKeys,
|
2552
|
+
keyTag,
|
2553
|
+
keyNode,
|
2554
|
+
null,
|
2555
|
+
_keyLine,
|
2556
|
+
_keyLineStart,
|
2557
|
+
_keyPos
|
2558
|
+
);
|
2291
2559
|
}
|
2292
2560
|
|
2293
2561
|
// Expose the resulting mapping.
|
@@ -2302,16 +2570,16 @@
|
|
2302
2570
|
}
|
2303
2571
|
|
2304
2572
|
function readTagProperty(state) {
|
2305
|
-
|
2306
|
-
|
2307
|
-
|
2308
|
-
|
2309
|
-
|
2310
|
-
|
2573
|
+
let _position;
|
2574
|
+
let isVerbatim = false;
|
2575
|
+
let isNamed = false;
|
2576
|
+
let tagHandle;
|
2577
|
+
let tagName;
|
2578
|
+
let ch;
|
2311
2579
|
|
2312
2580
|
ch = state.input.charCodeAt(state.position);
|
2313
2581
|
|
2314
|
-
if (ch !== 0x21/* ! */) return false;
|
2582
|
+
if (ch !== 0x21 /* ! */) return false;
|
2315
2583
|
|
2316
2584
|
if (state.tag !== null) {
|
2317
2585
|
throwError(state, 'duplication of a tag property');
|
@@ -2319,15 +2587,13 @@
|
|
2319
2587
|
|
2320
2588
|
ch = state.input.charCodeAt(++state.position);
|
2321
2589
|
|
2322
|
-
if (ch ===
|
2590
|
+
if (ch === 0x3c /* < */) {
|
2323
2591
|
isVerbatim = true;
|
2324
2592
|
ch = state.input.charCodeAt(++state.position);
|
2325
|
-
|
2326
|
-
} else if (ch === 0x21/* ! */) {
|
2593
|
+
} else if (ch === 0x21 /* ! */) {
|
2327
2594
|
isNamed = true;
|
2328
2595
|
tagHandle = '!!';
|
2329
2596
|
ch = state.input.charCodeAt(++state.position);
|
2330
|
-
|
2331
2597
|
} else {
|
2332
2598
|
tagHandle = '!';
|
2333
2599
|
}
|
@@ -2335,8 +2601,9 @@
|
|
2335
2601
|
_position = state.position;
|
2336
2602
|
|
2337
2603
|
if (isVerbatim) {
|
2338
|
-
do {
|
2339
|
-
|
2604
|
+
do {
|
2605
|
+
ch = state.input.charCodeAt(++state.position);
|
2606
|
+
} while (ch !== 0 && ch !== 0x3e /* > */);
|
2340
2607
|
|
2341
2608
|
if (state.position < state.length) {
|
2342
2609
|
tagName = state.input.slice(_position, state.position);
|
@@ -2346,13 +2613,15 @@
|
|
2346
2613
|
}
|
2347
2614
|
} else {
|
2348
2615
|
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
2349
|
-
|
2350
|
-
if (ch === 0x21/* ! */) {
|
2616
|
+
if (ch === 0x21 /* ! */) {
|
2351
2617
|
if (!isNamed) {
|
2352
2618
|
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
2353
2619
|
|
2354
2620
|
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
2355
|
-
throwError(
|
2621
|
+
throwError(
|
2622
|
+
state,
|
2623
|
+
'named tag handle cannot contain such characters'
|
2624
|
+
);
|
2356
2625
|
}
|
2357
2626
|
|
2358
2627
|
isNamed = true;
|
@@ -2368,46 +2637,45 @@
|
|
2368
2637
|
tagName = state.input.slice(_position, state.position);
|
2369
2638
|
|
2370
2639
|
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
2371
|
-
throwError(
|
2640
|
+
throwError(
|
2641
|
+
state,
|
2642
|
+
'tag suffix cannot contain flow indicator characters'
|
2643
|
+
);
|
2372
2644
|
}
|
2373
2645
|
}
|
2374
2646
|
|
2375
2647
|
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
2376
|
-
throwError(state,
|
2648
|
+
throwError(state, `tag name cannot contain such characters: ${tagName}`);
|
2377
2649
|
}
|
2378
2650
|
|
2379
2651
|
try {
|
2380
2652
|
tagName = decodeURIComponent(tagName);
|
2381
2653
|
} catch (err) {
|
2382
|
-
throwError(state,
|
2654
|
+
throwError(state, `tag name is malformed: ${tagName}`);
|
2383
2655
|
}
|
2384
2656
|
|
2385
2657
|
if (isVerbatim) {
|
2386
2658
|
state.tag = tagName;
|
2387
|
-
|
2388
2659
|
} else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
|
2389
2660
|
state.tag = state.tagMap[tagHandle] + tagName;
|
2390
|
-
|
2391
2661
|
} else if (tagHandle === '!') {
|
2392
|
-
state.tag =
|
2393
|
-
|
2662
|
+
state.tag = `!${tagName}`;
|
2394
2663
|
} else if (tagHandle === '!!') {
|
2395
|
-
state.tag =
|
2396
|
-
|
2664
|
+
state.tag = `tag:yaml.org,2002:${tagName}`;
|
2397
2665
|
} else {
|
2398
|
-
throwError(state,
|
2666
|
+
throwError(state, `undeclared tag handle "${tagHandle}"`);
|
2399
2667
|
}
|
2400
2668
|
|
2401
2669
|
return true;
|
2402
2670
|
}
|
2403
2671
|
|
2404
2672
|
function readAnchorProperty(state) {
|
2405
|
-
|
2406
|
-
|
2673
|
+
let _position;
|
2674
|
+
let ch;
|
2407
2675
|
|
2408
2676
|
ch = state.input.charCodeAt(state.position);
|
2409
2677
|
|
2410
|
-
if (ch !== 0x26/* & */) return false;
|
2678
|
+
if (ch !== 0x26 /* & */) return false;
|
2411
2679
|
|
2412
2680
|
if (state.anchor !== null) {
|
2413
2681
|
throwError(state, 'duplication of an anchor property');
|
@@ -2421,7 +2689,10 @@
|
|
2421
2689
|
}
|
2422
2690
|
|
2423
2691
|
if (state.position === _position) {
|
2424
|
-
throwError(
|
2692
|
+
throwError(
|
2693
|
+
state,
|
2694
|
+
'name of an anchor node must contain at least one character'
|
2695
|
+
);
|
2425
2696
|
}
|
2426
2697
|
|
2427
2698
|
state.anchor = state.input.slice(_position, state.position);
|
@@ -2429,12 +2700,13 @@
|
|
2429
2700
|
}
|
2430
2701
|
|
2431
2702
|
function readAlias(state) {
|
2432
|
-
|
2433
|
-
|
2703
|
+
let _position;
|
2704
|
+
let alias;
|
2705
|
+
let ch;
|
2434
2706
|
|
2435
2707
|
ch = state.input.charCodeAt(state.position);
|
2436
2708
|
|
2437
|
-
if (ch !==
|
2709
|
+
if (ch !== 0x2a /* * */) return false;
|
2438
2710
|
|
2439
2711
|
ch = state.input.charCodeAt(++state.position);
|
2440
2712
|
_position = state.position;
|
@@ -2444,13 +2716,16 @@
|
|
2444
2716
|
}
|
2445
2717
|
|
2446
2718
|
if (state.position === _position) {
|
2447
|
-
throwError(
|
2719
|
+
throwError(
|
2720
|
+
state,
|
2721
|
+
'name of an alias node must contain at least one character'
|
2722
|
+
);
|
2448
2723
|
}
|
2449
2724
|
|
2450
2725
|
alias = state.input.slice(_position, state.position);
|
2451
2726
|
|
2452
2727
|
if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
|
2453
|
-
throwError(state,
|
2728
|
+
throwError(state, `unidentified alias "${alias}"`);
|
2454
2729
|
}
|
2455
2730
|
|
2456
2731
|
state.result = state.anchorMap[alias];
|
@@ -2458,32 +2733,37 @@
|
|
2458
2733
|
return true;
|
2459
2734
|
}
|
2460
2735
|
|
2461
|
-
function composeNode(
|
2462
|
-
|
2463
|
-
|
2464
|
-
|
2465
|
-
|
2466
|
-
|
2467
|
-
|
2468
|
-
|
2469
|
-
|
2470
|
-
|
2471
|
-
|
2472
|
-
|
2473
|
-
|
2736
|
+
function composeNode(
|
2737
|
+
state,
|
2738
|
+
parentIndent,
|
2739
|
+
nodeContext,
|
2740
|
+
allowToSeek,
|
2741
|
+
allowCompact
|
2742
|
+
) {
|
2743
|
+
let allowBlockStyles;
|
2744
|
+
let allowBlockScalars;
|
2745
|
+
let allowBlockCollections;
|
2746
|
+
let indentStatus = 1; // 1: this>parent, 0: this=parent, -1: this<parent
|
2747
|
+
let atNewLine = false;
|
2748
|
+
let hasContent = false;
|
2749
|
+
let typeIndex;
|
2750
|
+
let typeQuantity;
|
2751
|
+
let typeList;
|
2752
|
+
let type;
|
2753
|
+
let flowIndent;
|
2754
|
+
let blockIndent;
|
2474
2755
|
|
2475
2756
|
if (state.listener !== null) {
|
2476
2757
|
state.listener('open', state);
|
2477
2758
|
}
|
2478
2759
|
|
2479
|
-
state.tag
|
2760
|
+
state.tag = null;
|
2480
2761
|
state.anchor = null;
|
2481
|
-
state.kind
|
2762
|
+
state.kind = null;
|
2482
2763
|
state.result = null;
|
2483
2764
|
|
2484
2765
|
allowBlockStyles = allowBlockScalars = allowBlockCollections =
|
2485
|
-
CONTEXT_BLOCK_OUT === nodeContext ||
|
2486
|
-
CONTEXT_BLOCK_IN === nodeContext;
|
2766
|
+
CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
|
2487
2767
|
|
2488
2768
|
if (allowToSeek) {
|
2489
2769
|
if (skipSeparationSpace(state, true, -1)) {
|
@@ -2532,25 +2812,29 @@
|
|
2532
2812
|
blockIndent = state.position - state.lineStart;
|
2533
2813
|
|
2534
2814
|
if (indentStatus === 1) {
|
2535
|
-
if (
|
2815
|
+
if (
|
2816
|
+
(allowBlockCollections &&
|
2536
2817
|
(readBlockSequence(state, blockIndent) ||
|
2537
|
-
|
2538
|
-
|
2818
|
+
readBlockMapping(state, blockIndent, flowIndent))) ||
|
2819
|
+
readFlowCollection(state, flowIndent)
|
2820
|
+
) {
|
2539
2821
|
hasContent = true;
|
2540
2822
|
} else {
|
2541
|
-
if (
|
2542
|
-
|
2543
|
-
|
2823
|
+
if (
|
2824
|
+
(allowBlockScalars && readBlockScalar(state, flowIndent)) ||
|
2825
|
+
readSingleQuotedScalar(state, flowIndent) ||
|
2826
|
+
readDoubleQuotedScalar(state, flowIndent)
|
2827
|
+
) {
|
2544
2828
|
hasContent = true;
|
2545
|
-
|
2546
2829
|
} else if (readAlias(state)) {
|
2547
2830
|
hasContent = true;
|
2548
2831
|
|
2549
2832
|
if (state.tag !== null || state.anchor !== null) {
|
2550
2833
|
throwError(state, 'alias node should not have any properties');
|
2551
2834
|
}
|
2552
|
-
|
2553
|
-
|
2835
|
+
} else if (
|
2836
|
+
readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)
|
2837
|
+
) {
|
2554
2838
|
hasContent = true;
|
2555
2839
|
|
2556
2840
|
if (state.tag === null) {
|
@@ -2565,7 +2849,8 @@
|
|
2565
2849
|
} else if (indentStatus === 0) {
|
2566
2850
|
// Special case: block sequences are allowed to have same indentation level as the parent.
|
2567
2851
|
// http://www.yaml.org/spec/1.2/spec.html#id2799784
|
2568
|
-
hasContent =
|
2852
|
+
hasContent =
|
2853
|
+
allowBlockCollections && readBlockSequence(state, blockIndent);
|
2569
2854
|
}
|
2570
2855
|
}
|
2571
2856
|
|
@@ -2573,7 +2858,6 @@
|
|
2573
2858
|
if (state.anchor !== null) {
|
2574
2859
|
state.anchorMap[state.anchor] = state.result;
|
2575
2860
|
}
|
2576
|
-
|
2577
2861
|
} else if (state.tag === '?') {
|
2578
2862
|
// Implicit resolving is not allowed for non-scalar types, and '?'
|
2579
2863
|
// non-specific tag is only automatically assigned to plain scalars.
|
@@ -2582,13 +2866,21 @@
|
|
2582
2866
|
// tag, for example like this: "!<?> [0]"
|
2583
2867
|
//
|
2584
2868
|
if (state.result !== null && state.kind !== 'scalar') {
|
2585
|
-
throwError(
|
2869
|
+
throwError(
|
2870
|
+
state,
|
2871
|
+
`unacceptable node kind for !<?> tag; it should be "scalar", not "${state.kind}"`
|
2872
|
+
);
|
2586
2873
|
}
|
2587
2874
|
|
2588
|
-
for (
|
2875
|
+
for (
|
2876
|
+
typeIndex = 0, typeQuantity = state.implicitTypes.length;
|
2877
|
+
typeIndex < typeQuantity;
|
2878
|
+
typeIndex += 1
|
2879
|
+
) {
|
2589
2880
|
type = state.implicitTypes[typeIndex];
|
2590
2881
|
|
2591
|
-
if (type.resolve(state.result)) {
|
2882
|
+
if (type.resolve(state.result)) {
|
2883
|
+
// `state.result` updated in resolver if matched
|
2592
2884
|
state.result = type.construct(state.result);
|
2593
2885
|
state.tag = type.tag;
|
2594
2886
|
if (state.anchor !== null) {
|
@@ -2598,15 +2890,27 @@
|
|
2598
2890
|
}
|
2599
2891
|
}
|
2600
2892
|
} else if (state.tag !== '!') {
|
2601
|
-
if (
|
2893
|
+
if (
|
2894
|
+
_hasOwnProperty$1.call(
|
2895
|
+
state.typeMap[state.kind || 'fallback'],
|
2896
|
+
state.tag
|
2897
|
+
)
|
2898
|
+
) {
|
2602
2899
|
type = state.typeMap[state.kind || 'fallback'][state.tag];
|
2603
2900
|
} else {
|
2604
2901
|
// looking for multi type
|
2605
2902
|
type = null;
|
2606
2903
|
typeList = state.typeMap.multi[state.kind || 'fallback'];
|
2607
2904
|
|
2608
|
-
for (
|
2609
|
-
|
2905
|
+
for (
|
2906
|
+
typeIndex = 0, typeQuantity = typeList.length;
|
2907
|
+
typeIndex < typeQuantity;
|
2908
|
+
typeIndex += 1
|
2909
|
+
) {
|
2910
|
+
if (
|
2911
|
+
state.tag.slice(0, typeList[typeIndex].tag.length) ===
|
2912
|
+
typeList[typeIndex].tag
|
2913
|
+
) {
|
2610
2914
|
type = typeList[typeIndex];
|
2611
2915
|
break;
|
2612
2916
|
}
|
@@ -2614,15 +2918,22 @@
|
|
2614
2918
|
}
|
2615
2919
|
|
2616
2920
|
if (!type) {
|
2617
|
-
throwError(state,
|
2921
|
+
throwError(state, `unknown tag !<${state.tag}>`);
|
2618
2922
|
}
|
2619
2923
|
|
2620
2924
|
if (state.result !== null && type.kind !== state.kind) {
|
2621
|
-
throwError(
|
2925
|
+
throwError(
|
2926
|
+
state,
|
2927
|
+
`unacceptable node kind for !<${state.tag}> tag; it should be "${type.kind}", not "${state.kind}"`
|
2928
|
+
);
|
2622
2929
|
}
|
2623
2930
|
|
2624
|
-
if (!type.resolve(state.result, state.tag)) {
|
2625
|
-
|
2931
|
+
if (!type.resolve(state.result, state.tag)) {
|
2932
|
+
// `state.result` updated in resolver if matched
|
2933
|
+
throwError(
|
2934
|
+
state,
|
2935
|
+
`cannot resolve a node with !<${state.tag}> explicit tag`
|
2936
|
+
);
|
2626
2937
|
} else {
|
2627
2938
|
state.result = type.construct(state.result, state.tag);
|
2628
2939
|
if (state.anchor !== null) {
|
@@ -2634,16 +2945,16 @@
|
|
2634
2945
|
if (state.listener !== null) {
|
2635
2946
|
state.listener('close', state);
|
2636
2947
|
}
|
2637
|
-
return state.tag !== null ||
|
2948
|
+
return state.tag !== null || state.anchor !== null || hasContent;
|
2638
2949
|
}
|
2639
2950
|
|
2640
2951
|
function readDocument(state) {
|
2641
|
-
|
2642
|
-
|
2643
|
-
|
2644
|
-
|
2645
|
-
|
2646
|
-
|
2952
|
+
const documentStart = state.position;
|
2953
|
+
let _position;
|
2954
|
+
let directiveName;
|
2955
|
+
let directiveArgs;
|
2956
|
+
let hasDirectives = false;
|
2957
|
+
let ch;
|
2647
2958
|
|
2648
2959
|
state.version = null;
|
2649
2960
|
state.checkLineBreaks = state.legacy;
|
@@ -2655,7 +2966,7 @@
|
|
2655
2966
|
|
2656
2967
|
ch = state.input.charCodeAt(state.position);
|
2657
2968
|
|
2658
|
-
if (state.lineIndent > 0 || ch !== 0x25/* % */) {
|
2969
|
+
if (state.lineIndent > 0 || ch !== 0x25 /* % */) {
|
2659
2970
|
break;
|
2660
2971
|
}
|
2661
2972
|
|
@@ -2671,7 +2982,10 @@
|
|
2671
2982
|
directiveArgs = [];
|
2672
2983
|
|
2673
2984
|
if (directiveName.length < 1) {
|
2674
|
-
throwError(
|
2985
|
+
throwError(
|
2986
|
+
state,
|
2987
|
+
'directive name must not be less than one character in length'
|
2988
|
+
);
|
2675
2989
|
}
|
2676
2990
|
|
2677
2991
|
while (ch !== 0) {
|
@@ -2679,9 +2993,10 @@
|
|
2679
2993
|
ch = state.input.charCodeAt(++state.position);
|
2680
2994
|
}
|
2681
2995
|
|
2682
|
-
if (ch === 0x23/* # */) {
|
2683
|
-
do {
|
2684
|
-
|
2996
|
+
if (ch === 0x23 /* # */) {
|
2997
|
+
do {
|
2998
|
+
ch = state.input.charCodeAt(++state.position);
|
2999
|
+
} while (ch !== 0 && !is_EOL(ch));
|
2685
3000
|
break;
|
2686
3001
|
}
|
2687
3002
|
|
@@ -2701,19 +3016,20 @@
|
|
2701
3016
|
if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
|
2702
3017
|
directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
2703
3018
|
} else {
|
2704
|
-
throwWarning(state,
|
3019
|
+
throwWarning(state, `unknown document directive "${directiveName}"`);
|
2705
3020
|
}
|
2706
3021
|
}
|
2707
3022
|
|
2708
3023
|
skipSeparationSpace(state, true, -1);
|
2709
3024
|
|
2710
|
-
if (
|
2711
|
-
|
2712
|
-
|
2713
|
-
|
3025
|
+
if (
|
3026
|
+
state.lineIndent === 0 &&
|
3027
|
+
state.input.charCodeAt(state.position) === 0x2d /* - */ &&
|
3028
|
+
state.input.charCodeAt(state.position + 1) === 0x2d /* - */ &&
|
3029
|
+
state.input.charCodeAt(state.position + 2) === 0x2d /* - */
|
3030
|
+
) {
|
2714
3031
|
state.position += 3;
|
2715
3032
|
skipSeparationSpace(state, true, -1);
|
2716
|
-
|
2717
3033
|
} else if (hasDirectives) {
|
2718
3034
|
throwError(state, 'directives end mark is expected');
|
2719
3035
|
}
|
@@ -2721,51 +3037,56 @@
|
|
2721
3037
|
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
2722
3038
|
skipSeparationSpace(state, true, -1);
|
2723
3039
|
|
2724
|
-
if (
|
2725
|
-
|
3040
|
+
if (
|
3041
|
+
state.checkLineBreaks &&
|
3042
|
+
PATTERN_NON_ASCII_LINE_BREAKS.test(
|
3043
|
+
state.input.slice(documentStart, state.position)
|
3044
|
+
)
|
3045
|
+
) {
|
2726
3046
|
throwWarning(state, 'non-ASCII line breaks are interpreted as content');
|
2727
3047
|
}
|
2728
3048
|
|
2729
3049
|
state.documents.push(state.result);
|
2730
3050
|
|
2731
3051
|
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
2732
|
-
|
2733
|
-
if (state.input.charCodeAt(state.position) === 0x2E/* . */) {
|
3052
|
+
if (state.input.charCodeAt(state.position) === 0x2e /* . */) {
|
2734
3053
|
state.position += 3;
|
2735
3054
|
skipSeparationSpace(state, true, -1);
|
2736
3055
|
}
|
2737
3056
|
return;
|
2738
3057
|
}
|
2739
3058
|
|
2740
|
-
if (state.position <
|
2741
|
-
throwError(
|
3059
|
+
if (state.position < state.length - 1) {
|
3060
|
+
throwError(
|
3061
|
+
state,
|
3062
|
+
'end of the stream or a document separator is expected'
|
3063
|
+
);
|
2742
3064
|
} else {
|
2743
|
-
return;
|
2744
3065
|
}
|
2745
3066
|
}
|
2746
3067
|
|
2747
|
-
|
2748
3068
|
function loadDocuments(input, options) {
|
2749
3069
|
input = String(input);
|
2750
3070
|
options = options || {};
|
2751
3071
|
|
2752
3072
|
if (input.length !== 0) {
|
2753
|
-
|
2754
3073
|
// Add tailing `\n` if not exists
|
2755
|
-
if (
|
2756
|
-
|
3074
|
+
if (
|
3075
|
+
input.charCodeAt(input.length - 1) !== 0x0a /* LF */ &&
|
3076
|
+
input.charCodeAt(input.length - 1) !== 0x0d /* CR */
|
3077
|
+
) {
|
2757
3078
|
input += '\n';
|
2758
3079
|
}
|
2759
3080
|
|
2760
3081
|
// Strip BOM
|
2761
|
-
if (input.charCodeAt(0) ===
|
3082
|
+
if (input.charCodeAt(0) === 0xfeff) {
|
2762
3083
|
input = input.slice(1);
|
2763
3084
|
}
|
2764
3085
|
}
|
2765
3086
|
|
2766
|
-
|
3087
|
+
const state = new State$1(input, options);
|
2767
3088
|
|
2768
|
-
|
3089
|
+
const nullpos = input.indexOf('\0');
|
2769
3090
|
|
2770
3091
|
if (nullpos !== -1) {
|
2771
3092
|
state.position = nullpos;
|
@@ -2775,120 +3096,139 @@
|
|
2775
3096
|
// Use 0 as string terminator. That significantly simplifies bounds check.
|
2776
3097
|
state.input += '\0';
|
2777
3098
|
|
2778
|
-
while (state.input.charCodeAt(state.position) === 0x20/* Space */) {
|
3099
|
+
while (state.input.charCodeAt(state.position) === 0x20 /* Space */) {
|
2779
3100
|
state.lineIndent += 1;
|
2780
3101
|
state.position += 1;
|
2781
3102
|
}
|
2782
3103
|
|
2783
|
-
while (state.position <
|
3104
|
+
while (state.position < state.length - 1) {
|
2784
3105
|
readDocument(state);
|
2785
3106
|
}
|
2786
3107
|
|
2787
3108
|
return state.documents;
|
2788
3109
|
}
|
2789
3110
|
|
2790
|
-
|
2791
3111
|
function loadAll$1(input, iterator, options) {
|
2792
|
-
if (
|
3112
|
+
if (
|
3113
|
+
iterator !== null &&
|
3114
|
+
typeof iterator === 'object' &&
|
3115
|
+
typeof options === 'undefined'
|
3116
|
+
) {
|
2793
3117
|
options = iterator;
|
2794
3118
|
iterator = null;
|
2795
3119
|
}
|
2796
3120
|
|
2797
|
-
|
3121
|
+
const documents = loadDocuments(input, options);
|
2798
3122
|
|
2799
3123
|
if (typeof iterator !== 'function') {
|
2800
3124
|
return documents;
|
2801
3125
|
}
|
2802
3126
|
|
2803
|
-
for (
|
3127
|
+
for (let index = 0, { length } = documents; index < length; index += 1) {
|
2804
3128
|
iterator(documents[index]);
|
2805
3129
|
}
|
2806
3130
|
}
|
2807
3131
|
|
2808
|
-
|
2809
3132
|
function load$1(input, options) {
|
2810
|
-
|
3133
|
+
const documents = loadDocuments(input, options);
|
2811
3134
|
|
2812
3135
|
if (documents.length === 0) {
|
2813
|
-
/*eslint-disable no-undefined*/
|
3136
|
+
/* eslint-disable no-undefined */
|
2814
3137
|
return undefined;
|
2815
3138
|
} else if (documents.length === 1) {
|
2816
3139
|
return documents[0];
|
2817
3140
|
}
|
2818
|
-
throw new exception(
|
3141
|
+
throw new exception(
|
3142
|
+
'expected a single document in the stream, but found more'
|
3143
|
+
);
|
2819
3144
|
}
|
2820
3145
|
|
3146
|
+
const loadAll_1 = loadAll$1;
|
3147
|
+
const load_1 = load$1;
|
2821
3148
|
|
2822
|
-
|
2823
|
-
|
2824
|
-
|
2825
|
-
var loader = {
|
2826
|
-
loadAll: loadAll_1,
|
2827
|
-
load: load_1
|
3149
|
+
const loader = {
|
3150
|
+
loadAll: loadAll_1,
|
3151
|
+
load: load_1,
|
2828
3152
|
};
|
2829
3153
|
|
2830
|
-
/*eslint-disable no-use-before-define*/
|
2831
|
-
|
2832
|
-
|
2833
|
-
|
2834
|
-
|
2835
|
-
|
2836
|
-
|
2837
|
-
|
2838
|
-
|
2839
|
-
|
2840
|
-
|
2841
|
-
|
2842
|
-
|
2843
|
-
|
2844
|
-
|
2845
|
-
|
2846
|
-
|
2847
|
-
|
2848
|
-
|
2849
|
-
|
2850
|
-
|
2851
|
-
|
2852
|
-
|
2853
|
-
|
2854
|
-
|
2855
|
-
|
2856
|
-
|
2857
|
-
|
2858
|
-
|
2859
|
-
|
2860
|
-
|
2861
|
-
|
2862
|
-
|
2863
|
-
|
2864
|
-
|
2865
|
-
|
2866
|
-
|
2867
|
-
ESCAPE_SEQUENCES[
|
2868
|
-
ESCAPE_SEQUENCES[
|
2869
|
-
ESCAPE_SEQUENCES[
|
2870
|
-
ESCAPE_SEQUENCES[
|
2871
|
-
ESCAPE_SEQUENCES[
|
2872
|
-
ESCAPE_SEQUENCES[
|
2873
|
-
ESCAPE_SEQUENCES[
|
2874
|
-
ESCAPE_SEQUENCES[
|
2875
|
-
ESCAPE_SEQUENCES[
|
2876
|
-
ESCAPE_SEQUENCES[0x22] = '\\"';
|
2877
|
-
ESCAPE_SEQUENCES[0x5C] = '\\\\';
|
2878
|
-
ESCAPE_SEQUENCES[0x85] = '\\N';
|
2879
|
-
ESCAPE_SEQUENCES[0xA0] = '\\_';
|
3154
|
+
/* eslint-disable no-use-before-define */
|
3155
|
+
|
3156
|
+
const _toString = Object.prototype.toString;
|
3157
|
+
const _hasOwnProperty = Object.prototype.hasOwnProperty;
|
3158
|
+
|
3159
|
+
const CHAR_BOM = 0xfeff;
|
3160
|
+
const CHAR_TAB = 0x09; /* Tab */
|
3161
|
+
const CHAR_LINE_FEED = 0x0a; /* LF */
|
3162
|
+
const CHAR_CARRIAGE_RETURN = 0x0d; /* CR */
|
3163
|
+
const CHAR_SPACE = 0x20; /* Space */
|
3164
|
+
const CHAR_EXCLAMATION = 0x21; /* ! */
|
3165
|
+
const CHAR_DOUBLE_QUOTE = 0x22; /* " */
|
3166
|
+
const CHAR_SHARP = 0x23; /* # */
|
3167
|
+
const CHAR_PERCENT = 0x25; /* % */
|
3168
|
+
const CHAR_AMPERSAND = 0x26; /* & */
|
3169
|
+
const CHAR_SINGLE_QUOTE = 0x27; /* ' */
|
3170
|
+
const CHAR_ASTERISK = 0x2a; /* * */
|
3171
|
+
const CHAR_COMMA = 0x2c; /* , */
|
3172
|
+
const CHAR_MINUS = 0x2d; /* - */
|
3173
|
+
const CHAR_COLON = 0x3a; /* : */
|
3174
|
+
const CHAR_EQUALS = 0x3d; /* = */
|
3175
|
+
const CHAR_GREATER_THAN = 0x3e; /* > */
|
3176
|
+
const CHAR_QUESTION = 0x3f; /* ? */
|
3177
|
+
const CHAR_COMMERCIAL_AT = 0x40; /* @ */
|
3178
|
+
const CHAR_LEFT_SQUARE_BRACKET = 0x5b; /* [ */
|
3179
|
+
const CHAR_RIGHT_SQUARE_BRACKET = 0x5d; /* ] */
|
3180
|
+
const CHAR_GRAVE_ACCENT = 0x60; /* ` */
|
3181
|
+
const CHAR_LEFT_CURLY_BRACKET = 0x7b; /* { */
|
3182
|
+
const CHAR_VERTICAL_LINE = 0x7c; /* | */
|
3183
|
+
const CHAR_RIGHT_CURLY_BRACKET = 0x7d; /* } */
|
3184
|
+
|
3185
|
+
const ESCAPE_SEQUENCES = {};
|
3186
|
+
|
3187
|
+
ESCAPE_SEQUENCES[0x00] = '\\0';
|
3188
|
+
ESCAPE_SEQUENCES[0x07] = '\\a';
|
3189
|
+
ESCAPE_SEQUENCES[0x08] = '\\b';
|
3190
|
+
ESCAPE_SEQUENCES[0x09] = '\\t';
|
3191
|
+
ESCAPE_SEQUENCES[0x0a] = '\\n';
|
3192
|
+
ESCAPE_SEQUENCES[0x0b] = '\\v';
|
3193
|
+
ESCAPE_SEQUENCES[0x0c] = '\\f';
|
3194
|
+
ESCAPE_SEQUENCES[0x0d] = '\\r';
|
3195
|
+
ESCAPE_SEQUENCES[0x1b] = '\\e';
|
3196
|
+
ESCAPE_SEQUENCES[0x22] = '\\"';
|
3197
|
+
ESCAPE_SEQUENCES[0x5c] = '\\\\';
|
3198
|
+
ESCAPE_SEQUENCES[0x85] = '\\N';
|
3199
|
+
ESCAPE_SEQUENCES[0xa0] = '\\_';
|
2880
3200
|
ESCAPE_SEQUENCES[0x2028] = '\\L';
|
2881
3201
|
ESCAPE_SEQUENCES[0x2029] = '\\P';
|
2882
3202
|
|
2883
|
-
|
2884
|
-
'y',
|
2885
|
-
'
|
3203
|
+
const DEPRECATED_BOOLEANS_SYNTAX = [
|
3204
|
+
'y',
|
3205
|
+
'Y',
|
3206
|
+
'yes',
|
3207
|
+
'Yes',
|
3208
|
+
'YES',
|
3209
|
+
'on',
|
3210
|
+
'On',
|
3211
|
+
'ON',
|
3212
|
+
'n',
|
3213
|
+
'N',
|
3214
|
+
'no',
|
3215
|
+
'No',
|
3216
|
+
'NO',
|
3217
|
+
'off',
|
3218
|
+
'Off',
|
3219
|
+
'OFF',
|
2886
3220
|
];
|
2887
3221
|
|
2888
|
-
|
3222
|
+
const DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
|
2889
3223
|
|
2890
3224
|
function compileStyleMap(schema, map) {
|
2891
|
-
|
3225
|
+
let result;
|
3226
|
+
let keys;
|
3227
|
+
let index;
|
3228
|
+
let length;
|
3229
|
+
let tag;
|
3230
|
+
let style;
|
3231
|
+
let type;
|
2892
3232
|
|
2893
3233
|
if (map === null) return {};
|
2894
3234
|
|
@@ -2900,9 +3240,9 @@
|
|
2900
3240
|
style = String(map[tag]);
|
2901
3241
|
|
2902
3242
|
if (tag.slice(0, 2) === '!!') {
|
2903
|
-
tag =
|
3243
|
+
tag = `tag:yaml.org,2002:${tag.slice(2)}`;
|
2904
3244
|
}
|
2905
|
-
type = schema.compiledTypeMap
|
3245
|
+
type = schema.compiledTypeMap.fallback[tag];
|
2906
3246
|
|
2907
3247
|
if (type && _hasOwnProperty.call(type.styleAliases, style)) {
|
2908
3248
|
style = type.styleAliases[style];
|
@@ -2915,45 +3255,52 @@
|
|
2915
3255
|
}
|
2916
3256
|
|
2917
3257
|
function encodeHex(character) {
|
2918
|
-
|
3258
|
+
let string;
|
3259
|
+
let handle;
|
3260
|
+
let length;
|
2919
3261
|
|
2920
3262
|
string = character.toString(16).toUpperCase();
|
2921
3263
|
|
2922
|
-
if (character <=
|
3264
|
+
if (character <= 0xff) {
|
2923
3265
|
handle = 'x';
|
2924
3266
|
length = 2;
|
2925
|
-
} else if (character <=
|
3267
|
+
} else if (character <= 0xffff) {
|
2926
3268
|
handle = 'u';
|
2927
3269
|
length = 4;
|
2928
|
-
} else if (character <=
|
3270
|
+
} else if (character <= 0xffffffff) {
|
2929
3271
|
handle = 'U';
|
2930
3272
|
length = 8;
|
2931
3273
|
} else {
|
2932
|
-
throw new exception(
|
3274
|
+
throw new exception(
|
3275
|
+
'code point within a string may not be greater than 0xFFFFFFFF'
|
3276
|
+
);
|
2933
3277
|
}
|
2934
3278
|
|
2935
|
-
return
|
3279
|
+
return `\\${handle}${common.repeat('0', length - string.length)}${string}`;
|
2936
3280
|
}
|
2937
3281
|
|
2938
|
-
|
2939
|
-
|
2940
|
-
QUOTING_TYPE_DOUBLE = 2;
|
3282
|
+
const QUOTING_TYPE_SINGLE = 1;
|
3283
|
+
const QUOTING_TYPE_DOUBLE = 2;
|
2941
3284
|
|
2942
3285
|
function State(options) {
|
2943
|
-
this.schema
|
2944
|
-
this.indent
|
2945
|
-
this.noArrayIndent = options
|
2946
|
-
this.skipInvalid
|
2947
|
-
this.flowLevel
|
2948
|
-
|
2949
|
-
|
2950
|
-
this.
|
2951
|
-
this.
|
2952
|
-
this.
|
2953
|
-
this.
|
2954
|
-
this.
|
2955
|
-
this.
|
2956
|
-
this.
|
3286
|
+
this.schema = options.schema || _default;
|
3287
|
+
this.indent = Math.max(1, options.indent || 2);
|
3288
|
+
this.noArrayIndent = options.noArrayIndent || false;
|
3289
|
+
this.skipInvalid = options.skipInvalid || false;
|
3290
|
+
this.flowLevel = common.isNothing(options.flowLevel)
|
3291
|
+
? -1
|
3292
|
+
: options.flowLevel;
|
3293
|
+
this.styleMap = compileStyleMap(this.schema, options.styles || null);
|
3294
|
+
this.sortKeys = options.sortKeys || false;
|
3295
|
+
this.lineWidth = options.lineWidth || 80;
|
3296
|
+
this.noRefs = options.noRefs || false;
|
3297
|
+
this.noCompatMode = options.noCompatMode || false;
|
3298
|
+
this.condenseFlow = options.condenseFlow || false;
|
3299
|
+
this.quotingType =
|
3300
|
+
options.quotingType === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
|
3301
|
+
this.forceQuotes = options.forceQuotes || false;
|
3302
|
+
this.replacer =
|
3303
|
+
typeof options.replacer === 'function' ? options.replacer : null;
|
2957
3304
|
|
2958
3305
|
this.implicitTypes = this.schema.compiledImplicit;
|
2959
3306
|
this.explicitTypes = this.schema.compiledExplicit;
|
@@ -2967,12 +3314,12 @@
|
|
2967
3314
|
|
2968
3315
|
// Indents every line in a string. Empty lines (\n only) are not indented.
|
2969
3316
|
function indentString(string, spaces) {
|
2970
|
-
|
2971
|
-
|
2972
|
-
|
2973
|
-
|
2974
|
-
|
2975
|
-
|
3317
|
+
const ind = common.repeat(' ', spaces);
|
3318
|
+
let position = 0;
|
3319
|
+
let next = -1;
|
3320
|
+
let result = '';
|
3321
|
+
let line;
|
3322
|
+
const { length } = string;
|
2976
3323
|
|
2977
3324
|
while (position < length) {
|
2978
3325
|
next = string.indexOf('\n', position);
|
@@ -2993,13 +3340,19 @@
|
|
2993
3340
|
}
|
2994
3341
|
|
2995
3342
|
function generateNextLine(state, level) {
|
2996
|
-
return
|
3343
|
+
return `\n${common.repeat(' ', state.indent * level)}`;
|
2997
3344
|
}
|
2998
3345
|
|
2999
3346
|
function testImplicitResolving(state, str) {
|
3000
|
-
|
3001
|
-
|
3002
|
-
|
3347
|
+
let index;
|
3348
|
+
let length;
|
3349
|
+
let type;
|
3350
|
+
|
3351
|
+
for (
|
3352
|
+
index = 0, length = state.implicitTypes.length;
|
3353
|
+
index < length;
|
3354
|
+
index += 1
|
3355
|
+
) {
|
3003
3356
|
type = state.implicitTypes[index];
|
3004
3357
|
|
3005
3358
|
if (type.resolve(str)) {
|
@@ -3020,10 +3373,12 @@
|
|
3020
3373
|
// should also be escaped. [However,] This isn’t mandatory"
|
3021
3374
|
// Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029.
|
3022
3375
|
function isPrintable(c) {
|
3023
|
-
return
|
3024
|
-
|
3025
|
-
|
3026
|
-
|
3376
|
+
return (
|
3377
|
+
(c >= 0x00020 && c <= 0x00007e) ||
|
3378
|
+
(c >= 0x000a1 && c <= 0x00d7ff && c !== 0x2028 && c !== 0x2029) ||
|
3379
|
+
(c >= 0x0e000 && c <= 0x00fffd && c !== CHAR_BOM) ||
|
3380
|
+
(c >= 0x10000 && c <= 0x10ffff)
|
3381
|
+
);
|
3027
3382
|
}
|
3028
3383
|
|
3029
3384
|
// [34] ns-char ::= nb-char - s-white
|
@@ -3032,11 +3387,13 @@
|
|
3032
3387
|
// Including s-white (for some reason, examples doesn't match specs in this aspect)
|
3033
3388
|
// ns-char ::= c-printable - b-line-feed - b-carriage-return - c-byte-order-mark
|
3034
3389
|
function isNsCharOrWhitespace(c) {
|
3035
|
-
return
|
3036
|
-
|
3390
|
+
return (
|
3391
|
+
isPrintable(c) &&
|
3392
|
+
c !== CHAR_BOM &&
|
3037
3393
|
// - b-char
|
3038
|
-
|
3039
|
-
|
3394
|
+
c !== CHAR_CARRIAGE_RETURN &&
|
3395
|
+
c !== CHAR_LINE_FEED
|
3396
|
+
);
|
3040
3397
|
}
|
3041
3398
|
|
3042
3399
|
// [127] ns-plain-safe(c) ::= c = flow-out ⇒ ns-plain-safe-out
|
@@ -3049,25 +3406,25 @@
|
|
3049
3406
|
// | ( /* An ns-char preceding */ “#” )
|
3050
3407
|
// | ( “:” /* Followed by an ns-plain-safe(c) */ )
|
3051
3408
|
function isPlainSafe(c, prev, inblock) {
|
3052
|
-
|
3053
|
-
|
3409
|
+
const cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
|
3410
|
+
const cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
|
3054
3411
|
return (
|
3055
3412
|
// ns-plain-safe
|
3056
|
-
inblock
|
3057
|
-
cIsNsCharOrWhitespace
|
3058
|
-
: cIsNsCharOrWhitespace
|
3413
|
+
((inblock // c = flow-in
|
3414
|
+
? cIsNsCharOrWhitespace
|
3415
|
+
: cIsNsCharOrWhitespace &&
|
3059
3416
|
// - c-flow-indicator
|
3060
|
-
|
3061
|
-
|
3062
|
-
|
3063
|
-
|
3064
|
-
|
3065
|
-
)
|
3417
|
+
c !== CHAR_COMMA &&
|
3418
|
+
c !== CHAR_LEFT_SQUARE_BRACKET &&
|
3419
|
+
c !== CHAR_RIGHT_SQUARE_BRACKET &&
|
3420
|
+
c !== CHAR_LEFT_CURLY_BRACKET &&
|
3421
|
+
c !== CHAR_RIGHT_CURLY_BRACKET) &&
|
3066
3422
|
// ns-plain-char
|
3067
|
-
|
3068
|
-
|
3069
|
-
|
3070
|
-
|
3423
|
+
c !== CHAR_SHARP && // false on '#'
|
3424
|
+
!(prev === CHAR_COLON && !cIsNsChar)) || // false on ': '
|
3425
|
+
(isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP) || // change to true on '[^ ]#'
|
3426
|
+
(prev === CHAR_COLON && cIsNsChar)
|
3427
|
+
); // change to true on ':[^ ]'
|
3071
3428
|
}
|
3072
3429
|
|
3073
3430
|
// Simplified test for values allowed as the first character in plain style.
|
@@ -3075,32 +3432,35 @@
|
|
3075
3432
|
// Uses a subset of ns-char - c-indicator
|
3076
3433
|
// where ns-char = nb-char - s-white.
|
3077
3434
|
// No support of ( ( “?” | “:” | “-” ) /* Followed by an ns-plain-safe(c)) */ ) part
|
3078
|
-
return
|
3079
|
-
|
3435
|
+
return (
|
3436
|
+
isPrintable(c) &&
|
3437
|
+
c !== CHAR_BOM &&
|
3438
|
+
!isWhitespace(c) && // - s-white
|
3080
3439
|
// - (c-indicator ::=
|
3081
3440
|
// “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}”
|
3082
|
-
|
3083
|
-
|
3084
|
-
|
3085
|
-
|
3086
|
-
|
3087
|
-
|
3088
|
-
|
3089
|
-
|
3441
|
+
c !== CHAR_MINUS &&
|
3442
|
+
c !== CHAR_QUESTION &&
|
3443
|
+
c !== CHAR_COLON &&
|
3444
|
+
c !== CHAR_COMMA &&
|
3445
|
+
c !== CHAR_LEFT_SQUARE_BRACKET &&
|
3446
|
+
c !== CHAR_RIGHT_SQUARE_BRACKET &&
|
3447
|
+
c !== CHAR_LEFT_CURLY_BRACKET &&
|
3448
|
+
c !== CHAR_RIGHT_CURLY_BRACKET &&
|
3090
3449
|
// | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"”
|
3091
|
-
|
3092
|
-
|
3093
|
-
|
3094
|
-
|
3095
|
-
|
3096
|
-
|
3097
|
-
|
3098
|
-
|
3099
|
-
|
3450
|
+
c !== CHAR_SHARP &&
|
3451
|
+
c !== CHAR_AMPERSAND &&
|
3452
|
+
c !== CHAR_ASTERISK &&
|
3453
|
+
c !== CHAR_EXCLAMATION &&
|
3454
|
+
c !== CHAR_VERTICAL_LINE &&
|
3455
|
+
c !== CHAR_EQUALS &&
|
3456
|
+
c !== CHAR_GREATER_THAN &&
|
3457
|
+
c !== CHAR_SINGLE_QUOTE &&
|
3458
|
+
c !== CHAR_DOUBLE_QUOTE &&
|
3100
3459
|
// | “%” | “@” | “`”)
|
3101
|
-
|
3102
|
-
|
3103
|
-
|
3460
|
+
c !== CHAR_PERCENT &&
|
3461
|
+
c !== CHAR_COMMERCIAL_AT &&
|
3462
|
+
c !== CHAR_GRAVE_ACCENT
|
3463
|
+
);
|
3104
3464
|
}
|
3105
3465
|
|
3106
3466
|
// Simplified test for values allowed as the last character in plain style.
|
@@ -3111,12 +3471,13 @@
|
|
3111
3471
|
|
3112
3472
|
// Same as 'string'.codePointAt(pos), but works in older browsers.
|
3113
3473
|
function codePointAt(string, pos) {
|
3114
|
-
|
3115
|
-
|
3474
|
+
const first = string.charCodeAt(pos);
|
3475
|
+
let second;
|
3476
|
+
if (first >= 0xd800 && first <= 0xdbff && pos + 1 < string.length) {
|
3116
3477
|
second = string.charCodeAt(pos + 1);
|
3117
|
-
if (second >=
|
3478
|
+
if (second >= 0xdc00 && second <= 0xdfff) {
|
3118
3479
|
// https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
|
3119
|
-
return (first -
|
3480
|
+
return (first - 0xd800) * 0x400 + second - 0xdc00 + 0x10000;
|
3120
3481
|
}
|
3121
3482
|
}
|
3122
3483
|
return first;
|
@@ -3124,15 +3485,15 @@
|
|
3124
3485
|
|
3125
3486
|
// Determines whether block indentation indicator is required.
|
3126
3487
|
function needIndentIndicator(string) {
|
3127
|
-
|
3488
|
+
const leadingSpaceRe = /^\n* /;
|
3128
3489
|
return leadingSpaceRe.test(string);
|
3129
3490
|
}
|
3130
3491
|
|
3131
|
-
|
3132
|
-
|
3133
|
-
|
3134
|
-
|
3135
|
-
|
3492
|
+
const STYLE_PLAIN = 1;
|
3493
|
+
const STYLE_SINGLE = 2;
|
3494
|
+
const STYLE_LITERAL = 3;
|
3495
|
+
const STYLE_FOLDED = 4;
|
3496
|
+
const STYLE_DOUBLE = 5;
|
3136
3497
|
|
3137
3498
|
// Determines which scalar styles are possible and returns the preferred style.
|
3138
3499
|
// lineWidth = -1 => no limit.
|
@@ -3141,23 +3502,31 @@
|
|
3141
3502
|
// STYLE_PLAIN or STYLE_SINGLE => no \n are in the string.
|
3142
3503
|
// STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1).
|
3143
3504
|
// STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1).
|
3144
|
-
function chooseScalarStyle(
|
3145
|
-
|
3146
|
-
|
3147
|
-
|
3148
|
-
|
3149
|
-
|
3150
|
-
|
3151
|
-
|
3152
|
-
|
3153
|
-
|
3154
|
-
|
3155
|
-
|
3505
|
+
function chooseScalarStyle(
|
3506
|
+
string,
|
3507
|
+
singleLineOnly,
|
3508
|
+
indentPerLevel,
|
3509
|
+
lineWidth,
|
3510
|
+
testAmbiguousType,
|
3511
|
+
quotingType,
|
3512
|
+
forceQuotes,
|
3513
|
+
inblock
|
3514
|
+
) {
|
3515
|
+
let i;
|
3516
|
+
let char = 0;
|
3517
|
+
let prevChar = null;
|
3518
|
+
let hasLineBreak = false;
|
3519
|
+
let hasFoldableLine = false; // only checked if shouldTrackWidth
|
3520
|
+
const shouldTrackWidth = lineWidth !== -1;
|
3521
|
+
let previousLineBreak = -1; // count the first line correctly
|
3522
|
+
let plain =
|
3523
|
+
isPlainSafeFirst(codePointAt(string, 0)) &&
|
3524
|
+
isPlainSafeLast(codePointAt(string, string.length - 1));
|
3156
3525
|
|
3157
3526
|
if (singleLineOnly || forceQuotes) {
|
3158
3527
|
// Case: no block styles.
|
3159
3528
|
// Check for disallowed characters to rule out plain and single.
|
3160
|
-
for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) {
|
3529
|
+
for (i = 0; i < string.length; char >= 0x10000 ? (i += 2) : i++) {
|
3161
3530
|
char = codePointAt(string, i);
|
3162
3531
|
if (!isPrintable(char)) {
|
3163
3532
|
return STYLE_DOUBLE;
|
@@ -3167,16 +3536,17 @@
|
|
3167
3536
|
}
|
3168
3537
|
} else {
|
3169
3538
|
// Case: block styles permitted.
|
3170
|
-
for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) {
|
3539
|
+
for (i = 0; i < string.length; char >= 0x10000 ? (i += 2) : i++) {
|
3171
3540
|
char = codePointAt(string, i);
|
3172
3541
|
if (char === CHAR_LINE_FEED) {
|
3173
3542
|
hasLineBreak = true;
|
3174
3543
|
// Check if any line can be folded.
|
3175
3544
|
if (shouldTrackWidth) {
|
3176
|
-
hasFoldableLine =
|
3545
|
+
hasFoldableLine =
|
3546
|
+
hasFoldableLine ||
|
3177
3547
|
// Foldable line = too long, and not more-indented.
|
3178
3548
|
(i - previousLineBreak - 1 > lineWidth &&
|
3179
|
-
|
3549
|
+
string[previousLineBreak + 1] !== ' ');
|
3180
3550
|
previousLineBreak = i;
|
3181
3551
|
}
|
3182
3552
|
} else if (!isPrintable(char)) {
|
@@ -3186,9 +3556,11 @@
|
|
3186
3556
|
prevChar = char;
|
3187
3557
|
}
|
3188
3558
|
// in case the end is missing a \n
|
3189
|
-
hasFoldableLine =
|
3190
|
-
|
3191
|
-
|
3559
|
+
hasFoldableLine =
|
3560
|
+
hasFoldableLine ||
|
3561
|
+
(shouldTrackWidth &&
|
3562
|
+
i - previousLineBreak - 1 > lineWidth &&
|
3563
|
+
string[previousLineBreak + 1] !== ' ');
|
3192
3564
|
}
|
3193
3565
|
// Although every style can represent \n without escaping, prefer block styles
|
3194
3566
|
// for multiline, since they're more readable and they don't add empty lines.
|
@@ -3220,17 +3592,22 @@
|
|
3220
3592
|
// • Ending newline => removed then restored.
|
3221
3593
|
// Importantly, this keeps the "+" chomp indicator from gaining an extra line.
|
3222
3594
|
function writeScalar(state, string, level, iskey, inblock) {
|
3223
|
-
state.dump = (function
|
3595
|
+
state.dump = (function() {
|
3224
3596
|
if (string.length === 0) {
|
3225
3597
|
return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
|
3226
3598
|
}
|
3227
3599
|
if (!state.noCompatMode) {
|
3228
|
-
if (
|
3229
|
-
|
3600
|
+
if (
|
3601
|
+
DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 ||
|
3602
|
+
DEPRECATED_BASE60_SYNTAX.test(string)
|
3603
|
+
) {
|
3604
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE
|
3605
|
+
? `"${string}"`
|
3606
|
+
: `'${string}'`;
|
3230
3607
|
}
|
3231
3608
|
}
|
3232
3609
|
|
3233
|
-
|
3610
|
+
const indent = state.indent * Math.max(1, level); // no 0-indent scalars
|
3234
3611
|
// As indentation gets deeper, let the width decrease monotonically
|
3235
3612
|
// to the lower bound min(state.lineWidth, 40).
|
3236
3613
|
// Note that this implies
|
@@ -3238,48 +3615,65 @@
|
|
3238
3615
|
// state.lineWidth > 40 + state.indent: width decreases until the lower bound.
|
3239
3616
|
// This behaves better than a constant minimum width which disallows narrower options,
|
3240
3617
|
// or an indent threshold which causes the width to suddenly increase.
|
3241
|
-
|
3242
|
-
|
3618
|
+
const lineWidth =
|
3619
|
+
state.lineWidth === -1
|
3620
|
+
? -1
|
3621
|
+
: Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
3243
3622
|
|
3244
3623
|
// Without knowing if keys are implicit/explicit, assume implicit for safety.
|
3245
|
-
|
3624
|
+
const singleLineOnly =
|
3625
|
+
iskey ||
|
3246
3626
|
// No block styles in flow mode.
|
3247
|
-
|
3627
|
+
(state.flowLevel > -1 && level >= state.flowLevel);
|
3248
3628
|
function testAmbiguity(string) {
|
3249
3629
|
return testImplicitResolving(state, string);
|
3250
3630
|
}
|
3251
3631
|
|
3252
|
-
switch (
|
3253
|
-
|
3254
|
-
|
3632
|
+
switch (
|
3633
|
+
chooseScalarStyle(
|
3634
|
+
string,
|
3635
|
+
singleLineOnly,
|
3636
|
+
state.indent,
|
3637
|
+
lineWidth,
|
3638
|
+
testAmbiguity,
|
3639
|
+
state.quotingType,
|
3640
|
+
state.forceQuotes && !iskey,
|
3641
|
+
inblock
|
3642
|
+
)
|
3643
|
+
) {
|
3255
3644
|
case STYLE_PLAIN:
|
3256
3645
|
return string;
|
3257
3646
|
case STYLE_SINGLE:
|
3258
|
-
return
|
3647
|
+
return `'${string.replace(/'/g, "''")}'`;
|
3259
3648
|
case STYLE_LITERAL:
|
3260
|
-
return
|
3261
|
-
|
3649
|
+
return `|${blockHeader(string, state.indent)}${dropEndingNewline(
|
3650
|
+
indentString(string, indent)
|
3651
|
+
)}`;
|
3262
3652
|
case STYLE_FOLDED:
|
3263
|
-
return
|
3264
|
-
|
3653
|
+
return `>${blockHeader(string, state.indent)}${dropEndingNewline(
|
3654
|
+
indentString(foldString(string, lineWidth), indent)
|
3655
|
+
)}`;
|
3265
3656
|
case STYLE_DOUBLE:
|
3266
|
-
return
|
3657
|
+
return `"${escapeString(string)}"`;
|
3267
3658
|
default:
|
3268
3659
|
throw new exception('impossible error: invalid scalar style');
|
3269
3660
|
}
|
3270
|
-
}()
|
3661
|
+
})();
|
3271
3662
|
}
|
3272
3663
|
|
3273
3664
|
// Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9.
|
3274
3665
|
function blockHeader(string, indentPerLevel) {
|
3275
|
-
|
3666
|
+
const indentIndicator = needIndentIndicator(string)
|
3667
|
+
? String(indentPerLevel)
|
3668
|
+
: '';
|
3276
3669
|
|
3277
3670
|
// note the special case: the string '\n' counts as a "trailing" empty line.
|
3278
|
-
|
3279
|
-
|
3280
|
-
|
3671
|
+
const clip = string[string.length - 1] === '\n';
|
3672
|
+
const keep =
|
3673
|
+
clip && (string[string.length - 2] === '\n' || string === '\n');
|
3674
|
+
const chomp = keep ? '+' : clip ? '' : '-';
|
3281
3675
|
|
3282
|
-
return indentIndicator + chomp
|
3676
|
+
return `${indentIndicator + chomp}\n`;
|
3283
3677
|
}
|
3284
3678
|
|
3285
3679
|
// (See the note for writeScalar.)
|
@@ -3294,28 +3688,29 @@
|
|
3294
3688
|
// unless they're before or after a more-indented line, or at the very
|
3295
3689
|
// beginning or end, in which case $k$ maps to $k$.
|
3296
3690
|
// Therefore, parse each chunk as newline(s) followed by a content line.
|
3297
|
-
|
3691
|
+
const lineRe = /(\n+)([^\n]*)/g;
|
3298
3692
|
|
3299
3693
|
// first line (possibly an empty line)
|
3300
|
-
|
3301
|
-
|
3694
|
+
let result = (function() {
|
3695
|
+
let nextLF = string.indexOf('\n');
|
3302
3696
|
nextLF = nextLF !== -1 ? nextLF : string.length;
|
3303
3697
|
lineRe.lastIndex = nextLF;
|
3304
3698
|
return foldLine(string.slice(0, nextLF), width);
|
3305
|
-
}()
|
3699
|
+
})();
|
3306
3700
|
// If we haven't reached the first content line yet, don't add an extra \n.
|
3307
|
-
|
3308
|
-
|
3701
|
+
let prevMoreIndented = string[0] === '\n' || string[0] === ' ';
|
3702
|
+
let moreIndented;
|
3309
3703
|
|
3310
3704
|
// rest of the lines
|
3311
|
-
|
3705
|
+
let match;
|
3312
3706
|
while ((match = lineRe.exec(string))) {
|
3313
|
-
|
3314
|
-
|
3315
|
-
|
3316
|
-
|
3317
|
-
|
3318
|
-
|
3707
|
+
const prefix = match[1];
|
3708
|
+
const line = match[2];
|
3709
|
+
moreIndented = line[0] === ' ';
|
3710
|
+
result +=
|
3711
|
+
prefix +
|
3712
|
+
(!prevMoreIndented && !moreIndented && line !== '' ? '\n' : '') +
|
3713
|
+
foldLine(line, width);
|
3319
3714
|
prevMoreIndented = moreIndented;
|
3320
3715
|
}
|
3321
3716
|
|
@@ -3330,11 +3725,14 @@
|
|
3330
3725
|
if (line === '' || line[0] === ' ') return line;
|
3331
3726
|
|
3332
3727
|
// Since a more-indented line adds a \n, breaks can't be followed by a space.
|
3333
|
-
|
3334
|
-
|
3728
|
+
const breakRe = / [^ ]/g; // note: the match index will always be <= length-2.
|
3729
|
+
let match;
|
3335
3730
|
// start is an inclusive index. end, curr, and next are exclusive.
|
3336
|
-
|
3337
|
-
|
3731
|
+
let start = 0;
|
3732
|
+
let end;
|
3733
|
+
let curr = 0;
|
3734
|
+
let next = 0;
|
3735
|
+
let result = '';
|
3338
3736
|
|
3339
3737
|
// Invariants: 0 <= start <= length-1.
|
3340
3738
|
// 0 <= curr <= next <= max(0, length-2). curr - start <= width.
|
@@ -3344,10 +3742,10 @@
|
|
3344
3742
|
next = match.index;
|
3345
3743
|
// maintain invariant: curr - start <= width
|
3346
3744
|
if (next - start > width) {
|
3347
|
-
end =
|
3348
|
-
result +=
|
3745
|
+
end = curr > start ? curr : next; // derive end <= length-2
|
3746
|
+
result += `\n${line.slice(start, end)}`;
|
3349
3747
|
// skip the space that was output as \n
|
3350
|
-
start = end + 1;
|
3748
|
+
start = end + 1; // derive start <= length-1
|
3351
3749
|
}
|
3352
3750
|
curr = next;
|
3353
3751
|
}
|
@@ -3357,7 +3755,7 @@
|
|
3357
3755
|
result += '\n';
|
3358
3756
|
// Insert a break if the remainder is too long and there is a break available.
|
3359
3757
|
if (line.length - start > width && curr > start) {
|
3360
|
-
result += line.slice(start, curr)
|
3758
|
+
result += `${line.slice(start, curr)}\n${line.slice(curr + 1)}`;
|
3361
3759
|
} else {
|
3362
3760
|
result += line.slice(start);
|
3363
3761
|
}
|
@@ -3367,11 +3765,11 @@
|
|
3367
3765
|
|
3368
3766
|
// Escapes a double-quoted string.
|
3369
3767
|
function escapeString(string) {
|
3370
|
-
|
3371
|
-
|
3372
|
-
|
3768
|
+
let result = '';
|
3769
|
+
let char = 0;
|
3770
|
+
let escapeSeq;
|
3373
3771
|
|
3374
|
-
for (
|
3772
|
+
for (let i = 0; i < string.length; char >= 0x10000 ? (i += 2) : i++) {
|
3375
3773
|
char = codePointAt(string, i);
|
3376
3774
|
escapeSeq = ESCAPE_SEQUENCES[char];
|
3377
3775
|
|
@@ -3387,11 +3785,11 @@
|
|
3387
3785
|
}
|
3388
3786
|
|
3389
3787
|
function writeFlowSequence(state, level, object) {
|
3390
|
-
|
3391
|
-
|
3392
|
-
|
3393
|
-
|
3394
|
-
|
3788
|
+
let _result = '';
|
3789
|
+
const _tag = state.tag;
|
3790
|
+
let index;
|
3791
|
+
let length;
|
3792
|
+
let value;
|
3395
3793
|
|
3396
3794
|
for (index = 0, length = object.length; index < length; index += 1) {
|
3397
3795
|
value = object[index];
|
@@ -3401,25 +3799,26 @@
|
|
3401
3799
|
}
|
3402
3800
|
|
3403
3801
|
// Write only valid elements, put null instead of invalid elements.
|
3404
|
-
if (
|
3405
|
-
|
3406
|
-
|
3407
|
-
|
3408
|
-
|
3802
|
+
if (
|
3803
|
+
writeNode(state, level, value, false, false) ||
|
3804
|
+
(typeof value === 'undefined' &&
|
3805
|
+
writeNode(state, level, null, false, false))
|
3806
|
+
) {
|
3807
|
+
if (_result !== '') _result += `,${!state.condenseFlow ? ' ' : ''}`;
|
3409
3808
|
_result += state.dump;
|
3410
3809
|
}
|
3411
3810
|
}
|
3412
3811
|
|
3413
3812
|
state.tag = _tag;
|
3414
|
-
state.dump =
|
3813
|
+
state.dump = `[${_result}]`;
|
3415
3814
|
}
|
3416
3815
|
|
3417
3816
|
function writeBlockSequence(state, level, object, compact) {
|
3418
|
-
|
3419
|
-
|
3420
|
-
|
3421
|
-
|
3422
|
-
|
3817
|
+
let _result = '';
|
3818
|
+
const _tag = state.tag;
|
3819
|
+
let index;
|
3820
|
+
let length;
|
3821
|
+
let value;
|
3423
3822
|
|
3424
3823
|
for (index = 0, length = object.length; index < length; index += 1) {
|
3425
3824
|
value = object[index];
|
@@ -3429,10 +3828,11 @@
|
|
3429
3828
|
}
|
3430
3829
|
|
3431
3830
|
// Write only valid elements, put null instead of invalid elements.
|
3432
|
-
if (
|
3433
|
-
|
3434
|
-
|
3435
|
-
|
3831
|
+
if (
|
3832
|
+
writeNode(state, level + 1, value, true, true, false, true) ||
|
3833
|
+
(typeof value === 'undefined' &&
|
3834
|
+
writeNode(state, level + 1, null, true, true, false, true))
|
3835
|
+
) {
|
3436
3836
|
if (!compact || _result !== '') {
|
3437
3837
|
_result += generateNextLine(state, level);
|
3438
3838
|
}
|
@@ -3452,17 +3852,16 @@
|
|
3452
3852
|
}
|
3453
3853
|
|
3454
3854
|
function writeFlowMapping(state, level, object) {
|
3455
|
-
|
3456
|
-
|
3457
|
-
|
3458
|
-
|
3459
|
-
|
3460
|
-
|
3461
|
-
|
3462
|
-
|
3855
|
+
let _result = '';
|
3856
|
+
const _tag = state.tag;
|
3857
|
+
const objectKeyList = Object.keys(object);
|
3858
|
+
let index;
|
3859
|
+
let length;
|
3860
|
+
let objectKey;
|
3861
|
+
let objectValue;
|
3862
|
+
let pairBuffer;
|
3463
3863
|
|
3464
3864
|
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
3465
|
-
|
3466
3865
|
pairBuffer = '';
|
3467
3866
|
if (_result !== '') pairBuffer += ', ';
|
3468
3867
|
|
@@ -3481,7 +3880,9 @@
|
|
3481
3880
|
|
3482
3881
|
if (state.dump.length > 1024) pairBuffer += '? ';
|
3483
3882
|
|
3484
|
-
pairBuffer += state.dump + (state.condenseFlow ? '"' : '')
|
3883
|
+
pairBuffer += `${state.dump + (state.condenseFlow ? '"' : '')}:${
|
3884
|
+
state.condenseFlow ? '' : ' '
|
3885
|
+
}`;
|
3485
3886
|
|
3486
3887
|
if (!writeNode(state, level, objectValue, false, false)) {
|
3487
3888
|
continue; // Skip this pair because of invalid value.
|
@@ -3494,19 +3895,19 @@
|
|
3494
3895
|
}
|
3495
3896
|
|
3496
3897
|
state.tag = _tag;
|
3497
|
-
state.dump =
|
3898
|
+
state.dump = `{${_result}}`;
|
3498
3899
|
}
|
3499
3900
|
|
3500
3901
|
function writeBlockMapping(state, level, object, compact) {
|
3501
|
-
|
3502
|
-
|
3503
|
-
|
3504
|
-
|
3505
|
-
|
3506
|
-
|
3507
|
-
|
3508
|
-
|
3509
|
-
|
3902
|
+
let _result = '';
|
3903
|
+
const _tag = state.tag;
|
3904
|
+
const objectKeyList = Object.keys(object);
|
3905
|
+
let index;
|
3906
|
+
let length;
|
3907
|
+
let objectKey;
|
3908
|
+
let objectValue;
|
3909
|
+
let explicitPair;
|
3910
|
+
let pairBuffer;
|
3510
3911
|
|
3511
3912
|
// Allow sorting keys so that the output file is deterministic
|
3512
3913
|
if (state.sortKeys === true) {
|
@@ -3538,8 +3939,9 @@
|
|
3538
3939
|
continue; // Skip this pair because of invalid key.
|
3539
3940
|
}
|
3540
3941
|
|
3541
|
-
explicitPair =
|
3542
|
-
|
3942
|
+
explicitPair =
|
3943
|
+
(state.tag !== null && state.tag !== '?') ||
|
3944
|
+
(state.dump && state.dump.length > 1024);
|
3543
3945
|
|
3544
3946
|
if (explicitPair) {
|
3545
3947
|
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
@@ -3576,17 +3978,24 @@
|
|
3576
3978
|
}
|
3577
3979
|
|
3578
3980
|
function detectType(state, object, explicit) {
|
3579
|
-
|
3981
|
+
let _result;
|
3982
|
+
let typeList;
|
3983
|
+
let index;
|
3984
|
+
let length;
|
3985
|
+
let type;
|
3986
|
+
let style;
|
3580
3987
|
|
3581
3988
|
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
3582
3989
|
|
3583
3990
|
for (index = 0, length = typeList.length; index < length; index += 1) {
|
3584
3991
|
type = typeList[index];
|
3585
3992
|
|
3586
|
-
if (
|
3587
|
-
|
3588
|
-
|
3589
|
-
|
3993
|
+
if (
|
3994
|
+
(type.instanceOf || type.predicate) &&
|
3995
|
+
(!type.instanceOf ||
|
3996
|
+
(typeof object === 'object' && object instanceof type.instanceOf)) &&
|
3997
|
+
(!type.predicate || type.predicate(object))
|
3998
|
+
) {
|
3590
3999
|
if (explicit) {
|
3591
4000
|
if (type.multi && type.representName) {
|
3592
4001
|
state.tag = type.representName(object);
|
@@ -3605,7 +4014,9 @@
|
|
3605
4014
|
} else if (_hasOwnProperty.call(type.represent, style)) {
|
3606
4015
|
_result = type.represent[style](object, style);
|
3607
4016
|
} else {
|
3608
|
-
throw new exception(
|
4017
|
+
throw new exception(
|
4018
|
+
`!<${type.tag}> tag resolver accepts not "${style}" style`
|
4019
|
+
);
|
3609
4020
|
}
|
3610
4021
|
|
3611
4022
|
state.dump = _result;
|
@@ -3629,59 +4040,64 @@
|
|
3629
4040
|
detectType(state, object, true);
|
3630
4041
|
}
|
3631
4042
|
|
3632
|
-
|
3633
|
-
|
3634
|
-
|
4043
|
+
const type = _toString.call(state.dump);
|
4044
|
+
const inblock = block;
|
4045
|
+
let tagStr;
|
3635
4046
|
|
3636
4047
|
if (block) {
|
3637
|
-
block =
|
4048
|
+
block = state.flowLevel < 0 || state.flowLevel > level;
|
3638
4049
|
}
|
3639
4050
|
|
3640
|
-
|
3641
|
-
|
3642
|
-
|
4051
|
+
const objectOrArray =
|
4052
|
+
type === '[object Object]' || type === '[object Array]';
|
4053
|
+
let duplicateIndex;
|
4054
|
+
let duplicate;
|
3643
4055
|
|
3644
4056
|
if (objectOrArray) {
|
3645
4057
|
duplicateIndex = state.duplicates.indexOf(object);
|
3646
4058
|
duplicate = duplicateIndex !== -1;
|
3647
4059
|
}
|
3648
4060
|
|
3649
|
-
if (
|
4061
|
+
if (
|
4062
|
+
(state.tag !== null && state.tag !== '?') ||
|
4063
|
+
duplicate ||
|
4064
|
+
(state.indent !== 2 && level > 0)
|
4065
|
+
) {
|
3650
4066
|
compact = false;
|
3651
4067
|
}
|
3652
4068
|
|
3653
4069
|
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
3654
|
-
state.dump =
|
4070
|
+
state.dump = `*ref_${duplicateIndex}`;
|
3655
4071
|
} else {
|
3656
4072
|
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
3657
4073
|
state.usedDuplicates[duplicateIndex] = true;
|
3658
4074
|
}
|
3659
4075
|
if (type === '[object Object]') {
|
3660
|
-
if (block &&
|
4076
|
+
if (block && Object.keys(state.dump).length !== 0) {
|
3661
4077
|
writeBlockMapping(state, level, state.dump, compact);
|
3662
4078
|
if (duplicate) {
|
3663
|
-
state.dump =
|
4079
|
+
state.dump = `&ref_${duplicateIndex}${state.dump}`;
|
3664
4080
|
}
|
3665
4081
|
} else {
|
3666
4082
|
writeFlowMapping(state, level, state.dump);
|
3667
4083
|
if (duplicate) {
|
3668
|
-
state.dump =
|
4084
|
+
state.dump = `&ref_${duplicateIndex} ${state.dump}`;
|
3669
4085
|
}
|
3670
4086
|
}
|
3671
4087
|
} else if (type === '[object Array]') {
|
3672
|
-
if (block &&
|
4088
|
+
if (block && state.dump.length !== 0) {
|
3673
4089
|
if (state.noArrayIndent && !isblockseq && level > 0) {
|
3674
4090
|
writeBlockSequence(state, level - 1, state.dump, compact);
|
3675
4091
|
} else {
|
3676
4092
|
writeBlockSequence(state, level, state.dump, compact);
|
3677
4093
|
}
|
3678
4094
|
if (duplicate) {
|
3679
|
-
state.dump =
|
4095
|
+
state.dump = `&ref_${duplicateIndex}${state.dump}`;
|
3680
4096
|
}
|
3681
4097
|
} else {
|
3682
4098
|
writeFlowSequence(state, level, state.dump);
|
3683
4099
|
if (duplicate) {
|
3684
|
-
state.dump =
|
4100
|
+
state.dump = `&ref_${duplicateIndex} ${state.dump}`;
|
3685
4101
|
}
|
3686
4102
|
}
|
3687
4103
|
} else if (type === '[object String]') {
|
@@ -3692,7 +4108,7 @@
|
|
3692
4108
|
return false;
|
3693
4109
|
} else {
|
3694
4110
|
if (state.skipInvalid) return false;
|
3695
|
-
throw new exception(
|
4111
|
+
throw new exception(`unacceptable kind of an object to dump ${type}`);
|
3696
4112
|
}
|
3697
4113
|
|
3698
4114
|
if (state.tag !== null && state.tag !== '?') {
|
@@ -3714,14 +4130,14 @@
|
|
3714
4130
|
).replace(/!/g, '%21');
|
3715
4131
|
|
3716
4132
|
if (state.tag[0] === '!') {
|
3717
|
-
tagStr =
|
4133
|
+
tagStr = `!${tagStr}`;
|
3718
4134
|
} else if (tagStr.slice(0, 18) === 'tag:yaml.org,2002:') {
|
3719
|
-
tagStr =
|
4135
|
+
tagStr = `!!${tagStr.slice(18)}`;
|
3720
4136
|
} else {
|
3721
|
-
tagStr =
|
4137
|
+
tagStr = `!<${tagStr}>`;
|
3722
4138
|
}
|
3723
4139
|
|
3724
|
-
state.dump = tagStr
|
4140
|
+
state.dump = `${tagStr} ${state.dump}`;
|
3725
4141
|
}
|
3726
4142
|
}
|
3727
4143
|
|
@@ -3729,23 +4145,27 @@
|
|
3729
4145
|
}
|
3730
4146
|
|
3731
4147
|
function getDuplicateReferences(object, state) {
|
3732
|
-
|
3733
|
-
|
3734
|
-
|
3735
|
-
|
4148
|
+
const objects = [];
|
4149
|
+
const duplicatesIndexes = [];
|
4150
|
+
let index;
|
4151
|
+
let length;
|
3736
4152
|
|
3737
4153
|
inspectNode(object, objects, duplicatesIndexes);
|
3738
4154
|
|
3739
|
-
for (
|
4155
|
+
for (
|
4156
|
+
index = 0, length = duplicatesIndexes.length;
|
4157
|
+
index < length;
|
4158
|
+
index += 1
|
4159
|
+
) {
|
3740
4160
|
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
3741
4161
|
}
|
3742
4162
|
state.usedDuplicates = new Array(length);
|
3743
4163
|
}
|
3744
4164
|
|
3745
4165
|
function inspectNode(object, objects, duplicatesIndexes) {
|
3746
|
-
|
3747
|
-
|
3748
|
-
|
4166
|
+
let objectKeyList;
|
4167
|
+
let index;
|
4168
|
+
let length;
|
3749
4169
|
|
3750
4170
|
if (object !== null && typeof object === 'object') {
|
3751
4171
|
index = objects.indexOf(object);
|
@@ -3763,8 +4183,16 @@
|
|
3763
4183
|
} else {
|
3764
4184
|
objectKeyList = Object.keys(object);
|
3765
4185
|
|
3766
|
-
for (
|
3767
|
-
|
4186
|
+
for (
|
4187
|
+
index = 0, length = objectKeyList.length;
|
4188
|
+
index < length;
|
4189
|
+
index += 1
|
4190
|
+
) {
|
4191
|
+
inspectNode(
|
4192
|
+
object[objectKeyList[index]],
|
4193
|
+
objects,
|
4194
|
+
duplicatesIndexes
|
4195
|
+
);
|
3768
4196
|
}
|
3769
4197
|
}
|
3770
4198
|
}
|
@@ -3774,83 +4202,84 @@
|
|
3774
4202
|
function dump$1(input, options) {
|
3775
4203
|
options = options || {};
|
3776
4204
|
|
3777
|
-
|
4205
|
+
const state = new State(options);
|
3778
4206
|
|
3779
4207
|
if (!state.noRefs) getDuplicateReferences(input, state);
|
3780
4208
|
|
3781
|
-
|
4209
|
+
let value = input;
|
3782
4210
|
|
3783
4211
|
if (state.replacer) {
|
3784
4212
|
value = state.replacer.call({ '': value }, '', value);
|
3785
4213
|
}
|
3786
4214
|
|
3787
|
-
if (writeNode(state, 0, value, true, true)) return state.dump
|
4215
|
+
if (writeNode(state, 0, value, true, true)) return `${state.dump}\n`;
|
3788
4216
|
|
3789
4217
|
return '';
|
3790
4218
|
}
|
3791
4219
|
|
3792
|
-
|
4220
|
+
const dump_1 = dump$1;
|
3793
4221
|
|
3794
|
-
|
3795
|
-
|
4222
|
+
const dumper = {
|
4223
|
+
dump: dump_1,
|
3796
4224
|
};
|
3797
4225
|
|
3798
4226
|
function renamed(from, to) {
|
3799
|
-
return function
|
3800
|
-
throw new Error(
|
3801
|
-
|
4227
|
+
return function() {
|
4228
|
+
throw new Error(
|
4229
|
+
`Function yaml.${from} is removed in js-yaml 4. ` +
|
4230
|
+
`Use yaml.${to} instead, which is now safe by default.`
|
4231
|
+
);
|
3802
4232
|
};
|
3803
4233
|
}
|
3804
4234
|
|
3805
|
-
|
3806
|
-
|
3807
|
-
|
3808
|
-
|
3809
|
-
|
3810
|
-
|
3811
|
-
|
3812
|
-
|
3813
|
-
|
3814
|
-
|
3815
|
-
var YAMLException = exception;
|
4235
|
+
const Type = type;
|
4236
|
+
const Schema = schema;
|
4237
|
+
const FAILSAFE_SCHEMA = failsafe;
|
4238
|
+
const JSON_SCHEMA = json;
|
4239
|
+
const CORE_SCHEMA = core;
|
4240
|
+
const DEFAULT_SCHEMA = _default;
|
4241
|
+
const { load } = loader;
|
4242
|
+
const { loadAll } = loader;
|
4243
|
+
const { dump } = dumper;
|
4244
|
+
const YAMLException = exception;
|
3816
4245
|
|
3817
4246
|
// Re-export all types in case user wants to create custom schema
|
3818
|
-
|
3819
|
-
binary
|
3820
|
-
float
|
3821
|
-
map
|
3822
|
-
null:
|
3823
|
-
pairs
|
3824
|
-
set
|
3825
|
-
timestamp
|
3826
|
-
bool
|
3827
|
-
int
|
3828
|
-
merge
|
3829
|
-
omap
|
3830
|
-
seq
|
3831
|
-
str
|
4247
|
+
const types = {
|
4248
|
+
binary,
|
4249
|
+
float,
|
4250
|
+
map,
|
4251
|
+
null: _null,
|
4252
|
+
pairs,
|
4253
|
+
set,
|
4254
|
+
timestamp,
|
4255
|
+
bool,
|
4256
|
+
int,
|
4257
|
+
merge,
|
4258
|
+
omap,
|
4259
|
+
seq,
|
4260
|
+
str,
|
3832
4261
|
};
|
3833
4262
|
|
3834
4263
|
// Removed functions from JS-YAML 3.0.x
|
3835
|
-
|
3836
|
-
|
3837
|
-
|
3838
|
-
|
3839
|
-
|
3840
|
-
|
3841
|
-
|
3842
|
-
|
3843
|
-
|
3844
|
-
|
3845
|
-
|
3846
|
-
|
3847
|
-
|
3848
|
-
|
3849
|
-
|
3850
|
-
|
3851
|
-
|
3852
|
-
|
3853
|
-
|
4264
|
+
const safeLoad = renamed('safeLoad', 'load');
|
4265
|
+
const safeLoadAll = renamed('safeLoadAll', 'loadAll');
|
4266
|
+
const safeDump = renamed('safeDump', 'dump');
|
4267
|
+
|
4268
|
+
const jsYaml = {
|
4269
|
+
Type,
|
4270
|
+
Schema,
|
4271
|
+
FAILSAFE_SCHEMA,
|
4272
|
+
JSON_SCHEMA,
|
4273
|
+
CORE_SCHEMA,
|
4274
|
+
DEFAULT_SCHEMA,
|
4275
|
+
load,
|
4276
|
+
loadAll,
|
4277
|
+
dump,
|
4278
|
+
YAMLException,
|
4279
|
+
types,
|
4280
|
+
safeLoad,
|
4281
|
+
safeLoadAll,
|
4282
|
+
safeDump,
|
3854
4283
|
};
|
3855
4284
|
|
3856
4285
|
exports.CORE_SCHEMA = CORE_SCHEMA;
|
@@ -3870,5 +4299,4 @@
|
|
3870
4299
|
exports.types = types;
|
3871
4300
|
|
3872
4301
|
Object.defineProperty(exports, '__esModule', { value: true });
|
3873
|
-
|
3874
|
-
})));
|
4302
|
+
});
|