trusty-cms 4.1.3 → 4.1.8
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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +127 -120
- data/README.md +1 -1
- data/app/assets/javascripts/admin/assets.js +1 -1
- data/app/assets/javascripts/rad_social/rad_ajax_form.js +3 -0
- data/app/assets/javascripts/rad_social/rad_email.js +0 -1
- data/app/assets/javascripts/rad_social/rad_email_form.js +2 -7
- data/app/assets/stylesheets/rad_social/rad_screen.scss +0 -4
- data/app/controllers/social_mailer_controller.rb +0 -7
- data/app/views/admin/assets/edit.html.haml +3 -0
- data/app/views/rad_social_mailer/social_mail_form.html.haml +1 -3
- data/app/views/widget/_email_form.html.haml +0 -5
- data/config/locales/en.yml +1 -0
- data/lib/trusty_cms.rb +1 -1
- data/lib/trusty_cms/engine.rb +0 -1
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/core.js +126 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/index.js +4 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/map.js +56 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/seq.js +43 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/string.js +28 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/index.js +36 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/json.js +76 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/options.js +23 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/binary.js +87 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/index.js +157 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/omap.js +142 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/pairs.js +81 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/set.js +114 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/timestamp.js +97 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/core.js +114 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/index.js +17 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/map.js +37 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/seq.js +34 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/string.js +40 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/index.js +62 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/json.js +60 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/options.js +35 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/binary.js +97 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/index.js +131 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/omap.js +105 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/pairs.js +80 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/set.js +91 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/timestamp.js +93 -0
- data/trusty_cms.gemspec +4 -4
- data/yarn.lock +6 -6
- metadata +7574 -75
- data/app/assets/javascripts/rad_social/captcha.js +0 -42
@@ -0,0 +1,23 @@
|
|
1
|
+
import { Type } from '../constants';
|
2
|
+
export var binaryOptions = {
|
3
|
+
defaultType: Type.BLOCK_LITERAL,
|
4
|
+
lineWidth: 76
|
5
|
+
};
|
6
|
+
export var boolOptions = {
|
7
|
+
trueStr: 'true',
|
8
|
+
falseStr: 'false'
|
9
|
+
};
|
10
|
+
export var nullOptions = {
|
11
|
+
nullStr: 'null'
|
12
|
+
};
|
13
|
+
export var strOptions = {
|
14
|
+
defaultType: Type.PLAIN,
|
15
|
+
doubleQuoted: {
|
16
|
+
jsonEncoding: false,
|
17
|
+
minMultiLineLength: 40
|
18
|
+
},
|
19
|
+
fold: {
|
20
|
+
lineWidth: 80,
|
21
|
+
minContentWidth: 20
|
22
|
+
}
|
23
|
+
};
|
@@ -0,0 +1,87 @@
|
|
1
|
+
/* global atob, btoa, Buffer */
|
2
|
+
import { Type } from '../../constants';
|
3
|
+
import { YAMLReferenceError } from '../../errors';
|
4
|
+
import { stringifyString } from '../../stringify';
|
5
|
+
import { resolveString } from '../failsafe/string';
|
6
|
+
import { binaryOptions as options } from '../options';
|
7
|
+
export default {
|
8
|
+
identify: function identify(value) {
|
9
|
+
return value instanceof Uint8Array;
|
10
|
+
},
|
11
|
+
// Buffer inherits from Uint8Array
|
12
|
+
default: false,
|
13
|
+
tag: 'tag:yaml.org,2002:binary',
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Returns a Buffer in node and an Uint8Array in browsers
|
17
|
+
*
|
18
|
+
* To use the resulting buffer as an image, you'll want to do something like:
|
19
|
+
*
|
20
|
+
* const blob = new Blob([buffer], { type: 'image/jpeg' })
|
21
|
+
* document.querySelector('#photo').src = URL.createObjectURL(blob)
|
22
|
+
*/
|
23
|
+
resolve: function resolve(doc, node) {
|
24
|
+
var src = resolveString(doc, node);
|
25
|
+
|
26
|
+
if (typeof Buffer === 'function') {
|
27
|
+
return Buffer.from(src, 'base64');
|
28
|
+
} else if (typeof atob === 'function') {
|
29
|
+
// On IE 11, atob() can't handle newlines
|
30
|
+
var str = atob(src.replace(/[\n\r]/g, ''));
|
31
|
+
var buffer = new Uint8Array(str.length);
|
32
|
+
|
33
|
+
for (var i = 0; i < str.length; ++i) {
|
34
|
+
buffer[i] = str.charCodeAt(i);
|
35
|
+
}
|
36
|
+
|
37
|
+
return buffer;
|
38
|
+
} else {
|
39
|
+
var msg = 'This environment does not support reading binary tags; either Buffer or atob is required';
|
40
|
+
doc.errors.push(new YAMLReferenceError(node, msg));
|
41
|
+
return null;
|
42
|
+
}
|
43
|
+
},
|
44
|
+
options: options,
|
45
|
+
stringify: function stringify(_ref, ctx, onComment, onChompKeep) {
|
46
|
+
var comment = _ref.comment,
|
47
|
+
type = _ref.type,
|
48
|
+
value = _ref.value;
|
49
|
+
var src;
|
50
|
+
|
51
|
+
if (typeof Buffer === 'function') {
|
52
|
+
src = value instanceof Buffer ? value.toString('base64') : Buffer.from(value.buffer).toString('base64');
|
53
|
+
} else if (typeof btoa === 'function') {
|
54
|
+
var s = '';
|
55
|
+
|
56
|
+
for (var i = 0; i < value.length; ++i) {
|
57
|
+
s += String.fromCharCode(value[i]);
|
58
|
+
}
|
59
|
+
|
60
|
+
src = btoa(s);
|
61
|
+
} else {
|
62
|
+
throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required');
|
63
|
+
}
|
64
|
+
|
65
|
+
if (!type) type = options.defaultType;
|
66
|
+
|
67
|
+
if (type === Type.QUOTE_DOUBLE) {
|
68
|
+
value = src;
|
69
|
+
} else {
|
70
|
+
var lineWidth = options.lineWidth;
|
71
|
+
var n = Math.ceil(src.length / lineWidth);
|
72
|
+
var lines = new Array(n);
|
73
|
+
|
74
|
+
for (var _i = 0, o = 0; _i < n; ++_i, o += lineWidth) {
|
75
|
+
lines[_i] = src.substr(o, lineWidth);
|
76
|
+
}
|
77
|
+
|
78
|
+
value = lines.join(type === Type.BLOCK_LITERAL ? '\n' : ' ');
|
79
|
+
}
|
80
|
+
|
81
|
+
return stringifyString({
|
82
|
+
comment: comment,
|
83
|
+
type: type,
|
84
|
+
value: value
|
85
|
+
}, ctx, onComment, onChompKeep);
|
86
|
+
}
|
87
|
+
};
|
@@ -0,0 +1,157 @@
|
|
1
|
+
import Scalar from '../../schema/Scalar';
|
2
|
+
import { stringifyNumber } from '../../stringify';
|
3
|
+
import failsafe from '../failsafe';
|
4
|
+
import { boolOptions, nullOptions } from '../options';
|
5
|
+
import binary from './binary';
|
6
|
+
import omap from './omap';
|
7
|
+
import pairs from './pairs';
|
8
|
+
import set from './set';
|
9
|
+
import { intTime, floatTime, timestamp } from './timestamp';
|
10
|
+
|
11
|
+
var boolStringify = function boolStringify(_ref) {
|
12
|
+
var value = _ref.value;
|
13
|
+
return value ? boolOptions.trueStr : boolOptions.falseStr;
|
14
|
+
};
|
15
|
+
|
16
|
+
export default failsafe.concat([{
|
17
|
+
identify: function identify(value) {
|
18
|
+
return value == null;
|
19
|
+
},
|
20
|
+
createNode: function createNode(schema, value, ctx) {
|
21
|
+
return ctx.wrapScalars ? new Scalar(null) : null;
|
22
|
+
},
|
23
|
+
default: true,
|
24
|
+
tag: 'tag:yaml.org,2002:null',
|
25
|
+
test: /^(?:~|[Nn]ull|NULL)?$/,
|
26
|
+
resolve: function resolve() {
|
27
|
+
return null;
|
28
|
+
},
|
29
|
+
options: nullOptions,
|
30
|
+
stringify: function stringify() {
|
31
|
+
return nullOptions.nullStr;
|
32
|
+
}
|
33
|
+
}, {
|
34
|
+
identify: function identify(value) {
|
35
|
+
return typeof value === 'boolean';
|
36
|
+
},
|
37
|
+
default: true,
|
38
|
+
tag: 'tag:yaml.org,2002:bool',
|
39
|
+
test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
|
40
|
+
resolve: function resolve() {
|
41
|
+
return true;
|
42
|
+
},
|
43
|
+
options: boolOptions,
|
44
|
+
stringify: boolStringify
|
45
|
+
}, {
|
46
|
+
identify: function identify(value) {
|
47
|
+
return typeof value === 'boolean';
|
48
|
+
},
|
49
|
+
default: true,
|
50
|
+
tag: 'tag:yaml.org,2002:bool',
|
51
|
+
test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/i,
|
52
|
+
resolve: function resolve() {
|
53
|
+
return false;
|
54
|
+
},
|
55
|
+
options: boolOptions,
|
56
|
+
stringify: boolStringify
|
57
|
+
}, {
|
58
|
+
identify: function identify(value) {
|
59
|
+
return typeof value === 'number';
|
60
|
+
},
|
61
|
+
default: true,
|
62
|
+
tag: 'tag:yaml.org,2002:int',
|
63
|
+
format: 'BIN',
|
64
|
+
test: /^0b([0-1_]+)$/,
|
65
|
+
resolve: function resolve(str, bin) {
|
66
|
+
return parseInt(bin.replace(/_/g, ''), 2);
|
67
|
+
},
|
68
|
+
stringify: function stringify(_ref2) {
|
69
|
+
var value = _ref2.value;
|
70
|
+
return '0b' + value.toString(2);
|
71
|
+
}
|
72
|
+
}, {
|
73
|
+
identify: function identify(value) {
|
74
|
+
return typeof value === 'number';
|
75
|
+
},
|
76
|
+
default: true,
|
77
|
+
tag: 'tag:yaml.org,2002:int',
|
78
|
+
format: 'OCT',
|
79
|
+
test: /^[-+]?0([0-7_]+)$/,
|
80
|
+
resolve: function resolve(str, oct) {
|
81
|
+
return parseInt(oct.replace(/_/g, ''), 8);
|
82
|
+
},
|
83
|
+
stringify: function stringify(_ref3) {
|
84
|
+
var value = _ref3.value;
|
85
|
+
return (value < 0 ? '-0' : '0') + value.toString(8);
|
86
|
+
}
|
87
|
+
}, {
|
88
|
+
identify: function identify(value) {
|
89
|
+
return typeof value === 'number';
|
90
|
+
},
|
91
|
+
default: true,
|
92
|
+
tag: 'tag:yaml.org,2002:int',
|
93
|
+
test: /^[-+]?[0-9][0-9_]*$/,
|
94
|
+
resolve: function resolve(str) {
|
95
|
+
return parseInt(str.replace(/_/g, ''), 10);
|
96
|
+
},
|
97
|
+
stringify: stringifyNumber
|
98
|
+
}, {
|
99
|
+
identify: function identify(value) {
|
100
|
+
return typeof value === 'number';
|
101
|
+
},
|
102
|
+
default: true,
|
103
|
+
tag: 'tag:yaml.org,2002:int',
|
104
|
+
format: 'HEX',
|
105
|
+
test: /^0x([0-9a-fA-F_]+)$/,
|
106
|
+
resolve: function resolve(str, hex) {
|
107
|
+
return parseInt(hex.replace(/_/g, ''), 16);
|
108
|
+
},
|
109
|
+
stringify: function stringify(_ref4) {
|
110
|
+
var value = _ref4.value;
|
111
|
+
return (value < 0 ? '-0x' : '0x') + value.toString(16);
|
112
|
+
}
|
113
|
+
}, {
|
114
|
+
identify: function identify(value) {
|
115
|
+
return typeof value === 'number';
|
116
|
+
},
|
117
|
+
default: true,
|
118
|
+
tag: 'tag:yaml.org,2002:float',
|
119
|
+
test: /^(?:[-+]?\.inf|(\.nan))$/i,
|
120
|
+
resolve: function resolve(str, nan) {
|
121
|
+
return nan ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY;
|
122
|
+
},
|
123
|
+
stringify: stringifyNumber
|
124
|
+
}, {
|
125
|
+
identify: function identify(value) {
|
126
|
+
return typeof value === 'number';
|
127
|
+
},
|
128
|
+
default: true,
|
129
|
+
tag: 'tag:yaml.org,2002:float',
|
130
|
+
format: 'EXP',
|
131
|
+
test: /^[-+]?([0-9][0-9_]*)?(\.[0-9_]*)?[eE][-+]?[0-9]+$/,
|
132
|
+
resolve: function resolve(str) {
|
133
|
+
return parseFloat(str.replace(/_/g, ''));
|
134
|
+
},
|
135
|
+
stringify: function stringify(_ref5) {
|
136
|
+
var value = _ref5.value;
|
137
|
+
return Number(value).toExponential();
|
138
|
+
}
|
139
|
+
}, {
|
140
|
+
identify: function identify(value) {
|
141
|
+
return typeof value === 'number';
|
142
|
+
},
|
143
|
+
default: true,
|
144
|
+
tag: 'tag:yaml.org,2002:float',
|
145
|
+
test: /^[-+]?(?:[0-9][0-9_]*)?\.([0-9_]*)$/,
|
146
|
+
resolve: function resolve(str, frac) {
|
147
|
+
var node = new Scalar(parseFloat(str.replace(/_/g, '')));
|
148
|
+
|
149
|
+
if (frac) {
|
150
|
+
var f = frac.replace(/_/g, '');
|
151
|
+
if (f[f.length - 1] === '0') node.minFractionDigits = f.length;
|
152
|
+
}
|
153
|
+
|
154
|
+
return node;
|
155
|
+
},
|
156
|
+
stringify: stringifyNumber
|
157
|
+
}], binary, omap, pairs, set, intTime, floatTime, timestamp);
|
@@ -0,0 +1,142 @@
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
3
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
4
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
5
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
6
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
8
|
+
import { YAMLSemanticError } from '../../errors';
|
9
|
+
import _toJSON from '../../toJSON';
|
10
|
+
import YAMLMap from '../../schema/Map';
|
11
|
+
import Pair from '../../schema/Pair';
|
12
|
+
import Scalar from '../../schema/Scalar';
|
13
|
+
import YAMLSeq from '../../schema/Seq';
|
14
|
+
import { createPairs, parsePairs } from './pairs';
|
15
|
+
export var YAMLOMap = /*#__PURE__*/function (_YAMLSeq) {
|
16
|
+
_inherits(YAMLOMap, _YAMLSeq);
|
17
|
+
|
18
|
+
function YAMLOMap() {
|
19
|
+
var _this;
|
20
|
+
|
21
|
+
_classCallCheck(this, YAMLOMap);
|
22
|
+
|
23
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(YAMLOMap).call(this));
|
24
|
+
|
25
|
+
_defineProperty(_assertThisInitialized(_this), "add", YAMLMap.prototype.add.bind(_assertThisInitialized(_this)));
|
26
|
+
|
27
|
+
_defineProperty(_assertThisInitialized(_this), "delete", YAMLMap.prototype.delete.bind(_assertThisInitialized(_this)));
|
28
|
+
|
29
|
+
_defineProperty(_assertThisInitialized(_this), "get", YAMLMap.prototype.get.bind(_assertThisInitialized(_this)));
|
30
|
+
|
31
|
+
_defineProperty(_assertThisInitialized(_this), "has", YAMLMap.prototype.has.bind(_assertThisInitialized(_this)));
|
32
|
+
|
33
|
+
_defineProperty(_assertThisInitialized(_this), "set", YAMLMap.prototype.set.bind(_assertThisInitialized(_this)));
|
34
|
+
|
35
|
+
_this.tag = YAMLOMap.tag;
|
36
|
+
return _this;
|
37
|
+
}
|
38
|
+
|
39
|
+
_createClass(YAMLOMap, [{
|
40
|
+
key: "toJSON",
|
41
|
+
value: function toJSON(_, ctx) {
|
42
|
+
var map = new Map();
|
43
|
+
if (ctx && ctx.onCreate) ctx.onCreate(map);
|
44
|
+
var _iteratorNormalCompletion = true;
|
45
|
+
var _didIteratorError = false;
|
46
|
+
var _iteratorError = undefined;
|
47
|
+
|
48
|
+
try {
|
49
|
+
for (var _iterator = this.items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
50
|
+
var pair = _step.value;
|
51
|
+
var key = void 0,
|
52
|
+
value = void 0;
|
53
|
+
|
54
|
+
if (pair instanceof Pair) {
|
55
|
+
key = _toJSON(pair.key, '', ctx);
|
56
|
+
value = _toJSON(pair.value, key, ctx);
|
57
|
+
} else {
|
58
|
+
key = _toJSON(pair, '', ctx);
|
59
|
+
}
|
60
|
+
|
61
|
+
if (map.has(key)) throw new Error('Ordered maps must not include duplicate keys');
|
62
|
+
map.set(key, value);
|
63
|
+
}
|
64
|
+
} catch (err) {
|
65
|
+
_didIteratorError = true;
|
66
|
+
_iteratorError = err;
|
67
|
+
} finally {
|
68
|
+
try {
|
69
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
70
|
+
_iterator.return();
|
71
|
+
}
|
72
|
+
} finally {
|
73
|
+
if (_didIteratorError) {
|
74
|
+
throw _iteratorError;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
return map;
|
80
|
+
}
|
81
|
+
}]);
|
82
|
+
|
83
|
+
return YAMLOMap;
|
84
|
+
}(YAMLSeq);
|
85
|
+
|
86
|
+
_defineProperty(YAMLOMap, "tag", 'tag:yaml.org,2002:omap');
|
87
|
+
|
88
|
+
function parseOMap(doc, cst) {
|
89
|
+
var pairs = parsePairs(doc, cst);
|
90
|
+
var seenKeys = [];
|
91
|
+
var _iteratorNormalCompletion2 = true;
|
92
|
+
var _didIteratorError2 = false;
|
93
|
+
var _iteratorError2 = undefined;
|
94
|
+
|
95
|
+
try {
|
96
|
+
for (var _iterator2 = pairs.items[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
97
|
+
var key = _step2.value.key;
|
98
|
+
|
99
|
+
if (key instanceof Scalar) {
|
100
|
+
if (seenKeys.includes(key.value)) {
|
101
|
+
var msg = 'Ordered maps must not include duplicate keys';
|
102
|
+
throw new YAMLSemanticError(cst, msg);
|
103
|
+
} else {
|
104
|
+
seenKeys.push(key.value);
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}
|
108
|
+
} catch (err) {
|
109
|
+
_didIteratorError2 = true;
|
110
|
+
_iteratorError2 = err;
|
111
|
+
} finally {
|
112
|
+
try {
|
113
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
114
|
+
_iterator2.return();
|
115
|
+
}
|
116
|
+
} finally {
|
117
|
+
if (_didIteratorError2) {
|
118
|
+
throw _iteratorError2;
|
119
|
+
}
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
return Object.assign(new YAMLOMap(), pairs);
|
124
|
+
}
|
125
|
+
|
126
|
+
function createOMap(schema, iterable, ctx) {
|
127
|
+
var pairs = createPairs(schema, iterable, ctx);
|
128
|
+
var omap = new YAMLOMap();
|
129
|
+
omap.items = pairs.items;
|
130
|
+
return omap;
|
131
|
+
}
|
132
|
+
|
133
|
+
export default {
|
134
|
+
identify: function identify(value) {
|
135
|
+
return value instanceof Map;
|
136
|
+
},
|
137
|
+
nodeClass: YAMLOMap,
|
138
|
+
default: false,
|
139
|
+
tag: 'tag:yaml.org,2002:omap',
|
140
|
+
resolve: parseOMap,
|
141
|
+
createNode: createOMap
|
142
|
+
};
|
@@ -0,0 +1,81 @@
|
|
1
|
+
import { YAMLSemanticError } from '../../errors';
|
2
|
+
import YAMLMap from '../../schema/Map';
|
3
|
+
import Pair from '../../schema/Pair';
|
4
|
+
import parseSeq from '../../schema/parseSeq';
|
5
|
+
import YAMLSeq from '../../schema/Seq';
|
6
|
+
export function parsePairs(doc, cst) {
|
7
|
+
var seq = parseSeq(doc, cst);
|
8
|
+
|
9
|
+
for (var i = 0; i < seq.items.length; ++i) {
|
10
|
+
var item = seq.items[i];
|
11
|
+
if (item instanceof Pair) continue;else if (item instanceof YAMLMap) {
|
12
|
+
if (item.items.length > 1) {
|
13
|
+
var msg = 'Each pair must have its own sequence indicator';
|
14
|
+
throw new YAMLSemanticError(cst, msg);
|
15
|
+
}
|
16
|
+
|
17
|
+
var pair = item.items[0] || new Pair();
|
18
|
+
if (item.commentBefore) pair.commentBefore = pair.commentBefore ? "".concat(item.commentBefore, "\n").concat(pair.commentBefore) : item.commentBefore;
|
19
|
+
if (item.comment) pair.comment = pair.comment ? "".concat(item.comment, "\n").concat(pair.comment) : item.comment;
|
20
|
+
item = pair;
|
21
|
+
}
|
22
|
+
seq.items[i] = item instanceof Pair ? item : new Pair(item);
|
23
|
+
}
|
24
|
+
|
25
|
+
return seq;
|
26
|
+
}
|
27
|
+
export function createPairs(schema, iterable, ctx) {
|
28
|
+
var pairs = new YAMLSeq(schema);
|
29
|
+
pairs.tag = 'tag:yaml.org,2002:pairs';
|
30
|
+
var _iteratorNormalCompletion = true;
|
31
|
+
var _didIteratorError = false;
|
32
|
+
var _iteratorError = undefined;
|
33
|
+
|
34
|
+
try {
|
35
|
+
for (var _iterator = iterable[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
36
|
+
var it = _step.value;
|
37
|
+
var key = void 0,
|
38
|
+
value = void 0;
|
39
|
+
|
40
|
+
if (Array.isArray(it)) {
|
41
|
+
if (it.length === 2) {
|
42
|
+
key = it[0];
|
43
|
+
value = it[1];
|
44
|
+
} else throw new TypeError("Expected [key, value] tuple: ".concat(it));
|
45
|
+
} else if (it && it instanceof Object) {
|
46
|
+
var keys = Object.keys(it);
|
47
|
+
|
48
|
+
if (keys.length === 1) {
|
49
|
+
key = keys[0];
|
50
|
+
value = it[key];
|
51
|
+
} else throw new TypeError("Expected { key: value } tuple: ".concat(it));
|
52
|
+
} else {
|
53
|
+
key = it;
|
54
|
+
}
|
55
|
+
|
56
|
+
var pair = schema.createPair(key, value, ctx);
|
57
|
+
pairs.items.push(pair);
|
58
|
+
}
|
59
|
+
} catch (err) {
|
60
|
+
_didIteratorError = true;
|
61
|
+
_iteratorError = err;
|
62
|
+
} finally {
|
63
|
+
try {
|
64
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
65
|
+
_iterator.return();
|
66
|
+
}
|
67
|
+
} finally {
|
68
|
+
if (_didIteratorError) {
|
69
|
+
throw _iteratorError;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
return pairs;
|
75
|
+
}
|
76
|
+
export default {
|
77
|
+
default: false,
|
78
|
+
tag: 'tag:yaml.org,2002:pairs',
|
79
|
+
resolve: parsePairs,
|
80
|
+
createNode: createPairs
|
81
|
+
};
|