yaml 2.0.0-0 → 2.0.0-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import './PlainValue-6b68dc0e.js';
2
- export { p as parse } from './parse-6e806192.js';
1
+ import './errors-2634d01a.js';
2
+ export { p as parse } from './parse-d1ba890f.js';
@@ -1,4 +1,4 @@
1
- import { j as _inherits, k as _createSuper, b as _classCallCheck, T as Type, a as _createClass, R as Range, N as Node, g as YAMLSemanticError, l as _get, m as _getPrototypeOf, Y as YAMLSyntaxError, C as Char, c as _defineProperty, P as PlainValue } from './PlainValue-6b68dc0e.js';
1
+ import { l as _inherits, m as _createSuper, b as _classCallCheck, T as Type, a as _createClass, R as Range, N as Node, Y as YAMLSemanticError, n as _get, o as _getPrototypeOf, i as YAMLSyntaxError, C as Char, c as _defineProperty } from './errors-2634d01a.js';
2
2
 
3
3
  var BlankLine = /*#__PURE__*/function (_Node) {
4
4
  _inherits(BlankLine, _Node);
@@ -1282,6 +1282,186 @@ var FlowCollection = /*#__PURE__*/function (_Node) {
1282
1282
  return FlowCollection;
1283
1283
  }(Node);
1284
1284
 
1285
+ var PlainValue = /*#__PURE__*/function (_Node) {
1286
+ _inherits(PlainValue, _Node);
1287
+
1288
+ var _super = _createSuper(PlainValue);
1289
+
1290
+ function PlainValue() {
1291
+ _classCallCheck(this, PlainValue);
1292
+
1293
+ return _super.apply(this, arguments);
1294
+ }
1295
+
1296
+ _createClass(PlainValue, [{
1297
+ key: "parseBlockValue",
1298
+ value: function parseBlockValue(start) {
1299
+ var _this$context = this.context,
1300
+ indent = _this$context.indent,
1301
+ inFlow = _this$context.inFlow,
1302
+ src = _this$context.src;
1303
+ var offset = start;
1304
+ var valueEnd = start;
1305
+
1306
+ for (var ch = src[offset]; ch === '\n'; ch = src[offset]) {
1307
+ if (Node.atDocumentBoundary(src, offset + 1)) break;
1308
+ var end = Node.endOfBlockIndent(src, indent, offset + 1);
1309
+ if (end === null || src[end] === '#') break;
1310
+
1311
+ if (src[end] === '\n') {
1312
+ offset = end;
1313
+ } else {
1314
+ valueEnd = PlainValue.endOfLine(src, end, inFlow);
1315
+ offset = valueEnd;
1316
+ }
1317
+ }
1318
+
1319
+ if (this.valueRange.isEmpty()) this.valueRange.start = start;
1320
+ this.valueRange.end = valueEnd;
1321
+ return valueEnd;
1322
+ }
1323
+ /**
1324
+ * Parses a plain value from the source
1325
+ *
1326
+ * Accepted forms are:
1327
+ * ```
1328
+ * #comment
1329
+ *
1330
+ * first line
1331
+ *
1332
+ * first line #comment
1333
+ *
1334
+ * first line
1335
+ * block
1336
+ * lines
1337
+ *
1338
+ * #comment
1339
+ * block
1340
+ * lines
1341
+ * ```
1342
+ * where block lines are empty or have an indent level greater than `indent`.
1343
+ *
1344
+ * @param {ParseContext} context
1345
+ * @param {number} start - Index of first character
1346
+ * @returns {number} - Index of the character after this scalar, may be `\n`
1347
+ */
1348
+
1349
+ }, {
1350
+ key: "parse",
1351
+ value: function parse(context, start) {
1352
+ this.context = context;
1353
+ var inFlow = context.inFlow,
1354
+ src = context.src;
1355
+ var offset = start;
1356
+ var ch = src[offset];
1357
+
1358
+ if (ch && ch !== '#' && ch !== '\n') {
1359
+ offset = PlainValue.endOfLine(src, start, inFlow);
1360
+ }
1361
+
1362
+ this.valueRange = new Range(start, offset);
1363
+ offset = Node.endOfWhiteSpace(src, offset);
1364
+ offset = this.parseComment(offset);
1365
+
1366
+ if (!this.hasComment || this.valueRange.isEmpty()) {
1367
+ offset = this.parseBlockValue(offset);
1368
+ }
1369
+
1370
+ return offset;
1371
+ }
1372
+ }, {
1373
+ key: "strValue",
1374
+ get: function get() {
1375
+ if (!this.valueRange || !this.context) return null;
1376
+ var _this$valueRange = this.valueRange,
1377
+ start = _this$valueRange.start,
1378
+ end = _this$valueRange.end;
1379
+ var src = this.context.src;
1380
+ var ch = src[end - 1];
1381
+
1382
+ while (start < end && (ch === '\n' || ch === '\t' || ch === ' ')) {
1383
+ ch = src[--end - 1];
1384
+ }
1385
+
1386
+ var str = '';
1387
+
1388
+ for (var i = start; i < end; ++i) {
1389
+ var _ch = src[i];
1390
+
1391
+ if (_ch === '\n') {
1392
+ var _Node$foldNewline = Node.foldNewline(src, i, -1),
1393
+ fold = _Node$foldNewline.fold,
1394
+ offset = _Node$foldNewline.offset;
1395
+
1396
+ str += fold;
1397
+ i = offset;
1398
+ } else if (_ch === ' ' || _ch === '\t') {
1399
+ // trim trailing whitespace
1400
+ var wsStart = i;
1401
+ var next = src[i + 1];
1402
+
1403
+ while (i < end && (next === ' ' || next === '\t')) {
1404
+ i += 1;
1405
+ next = src[i + 1];
1406
+ }
1407
+
1408
+ if (next !== '\n') str += i > wsStart ? src.slice(wsStart, i + 1) : _ch;
1409
+ } else {
1410
+ str += _ch;
1411
+ }
1412
+ }
1413
+
1414
+ var ch0 = src[start];
1415
+
1416
+ switch (ch0) {
1417
+ case '\t':
1418
+ {
1419
+ var msg = 'Plain value cannot start with a tab character';
1420
+ var errors = [new YAMLSemanticError(this, msg)];
1421
+ return {
1422
+ errors: errors,
1423
+ str: str
1424
+ };
1425
+ }
1426
+
1427
+ case '@':
1428
+ case '`':
1429
+ {
1430
+ var _msg = "Plain value cannot start with reserved character ".concat(ch0);
1431
+
1432
+ var _errors = [new YAMLSemanticError(this, _msg)];
1433
+ return {
1434
+ errors: _errors,
1435
+ str: str
1436
+ };
1437
+ }
1438
+
1439
+ default:
1440
+ return str;
1441
+ }
1442
+ }
1443
+ }], [{
1444
+ key: "endOfLine",
1445
+ value: function endOfLine(src, start, inFlow) {
1446
+ var ch = src[start];
1447
+ var offset = start;
1448
+
1449
+ while (ch && ch !== '\n') {
1450
+ if (inFlow && (ch === '[' || ch === ']' || ch === '{' || ch === '}' || ch === ',')) break;
1451
+ var next = src[offset + 1];
1452
+ if (ch === ':' && (!next || next === '\n' || next === '\t' || next === ' ' || inFlow && next === ',')) break;
1453
+ if ((ch === ' ' || ch === '\t') && next === '#') break;
1454
+ offset += 1;
1455
+ ch = next;
1456
+ }
1457
+
1458
+ return offset;
1459
+ }
1460
+ }]);
1461
+
1462
+ return PlainValue;
1463
+ }(Node);
1464
+
1285
1465
  var QuoteDouble = /*#__PURE__*/function (_Node) {
1286
1466
  _inherits(QuoteDouble, _Node);
1287
1467
 
@@ -1901,4 +2081,4 @@ function parse(src) {
1901
2081
  return documents;
1902
2082
  }
1903
2083
 
1904
- export { Document as D, parse as p };
2084
+ export { Document as D, PlainValue as P, parse as p };