trusty-cms 4.1.2 → 4.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -3
  3. data/Gemfile.lock +104 -104
  4. data/README.md +1 -1
  5. data/Rakefile +7 -7
  6. data/app/assets/javascripts/admin/assets.js +1 -1
  7. data/app/assets/javascripts/rad_social/rad_ajax_form.js +3 -0
  8. data/app/assets/javascripts/rad_social/rad_email.js +0 -1
  9. data/app/assets/javascripts/rad_social/rad_email_form.js +2 -7
  10. data/app/assets/stylesheets/admin/partials/_content.scss +1 -2
  11. data/app/assets/stylesheets/rad_social/rad_screen.scss +0 -4
  12. data/app/controllers/admin/assets_controller.rb +22 -21
  13. data/app/controllers/admin/configuration_controller.rb +9 -11
  14. data/app/controllers/admin/extensions_controller.rb +3 -3
  15. data/app/controllers/admin/layouts_controller.rb +3 -4
  16. data/app/controllers/admin/page_attachments_controller.rb +5 -5
  17. data/app/controllers/admin/page_fields_controller.rb +3 -4
  18. data/app/controllers/admin/page_parts_controller.rb +4 -5
  19. data/app/controllers/admin/pages_controller.rb +55 -56
  20. data/app/controllers/admin/references_controller.rb +1 -1
  21. data/app/controllers/admin/resource_controller.rb +132 -130
  22. data/app/controllers/admin/sites_controller.rb +4 -4
  23. data/app/controllers/admin/snippets_controller.rb +3 -4
  24. data/app/controllers/admin/users_controller.rb +16 -16
  25. data/app/controllers/application_controller.rb +47 -48
  26. data/app/controllers/site_controller.rb +51 -48
  27. data/app/controllers/social_mailer_controller.rb +12 -22
  28. data/app/helpers/admin/configuration_helper.rb +19 -20
  29. data/app/helpers/admin/layouts_helper.rb +0 -1
  30. data/app/helpers/admin/node_helper.rb +27 -24
  31. data/app/helpers/admin/pages_helper.rb +2 -2
  32. data/app/helpers/admin/preferences_helper.rb +0 -1
  33. data/app/helpers/admin/references_helper.rb +9 -10
  34. data/app/helpers/admin/regions_helper.rb +3 -3
  35. data/app/helpers/application_helper.rb +32 -33
  36. data/app/helpers/rad_social_helper.rb +8 -11
  37. data/app/helpers/scoped_helper.rb +1 -3
  38. data/app/helpers/sites_helper.rb +4 -4
  39. data/app/mailers/devise_mailer.rb +3 -4
  40. data/app/mailers/rad_social_mailer.rb +8 -8
  41. data/app/models/asset.rb +62 -63
  42. data/app/models/asset_type.rb +38 -39
  43. data/app/models/deprecated_tags.rb +3 -4
  44. data/app/models/file_not_found_page.rb +1 -3
  45. data/app/models/haml_filter.rb +1 -1
  46. data/app/models/layout.rb +4 -5
  47. data/app/models/legacy_user.rb +2 -2
  48. data/app/models/menu_renderer.rb +16 -18
  49. data/app/models/page.rb +96 -93
  50. data/app/models/page_attachment.rb +1 -2
  51. data/app/models/page_context.rb +11 -12
  52. data/app/models/page_part.rb +3 -4
  53. data/app/models/rails_page.rb +10 -12
  54. data/app/models/site.rb +22 -21
  55. data/app/models/snippet.rb +6 -8
  56. data/app/models/snippet_finder.rb +3 -3
  57. data/app/models/snippet_tags.rb +4 -4
  58. data/app/models/standard_tags.rb +258 -252
  59. data/app/models/status.rb +8 -8
  60. data/app/models/trusty_cms/config.rb +25 -25
  61. data/app/models/trusty_cms/page_response_cache_director.rb +2 -3
  62. data/app/models/user.rb +15 -14
  63. data/app/models/user_action_observer.rb +3 -3
  64. data/app/views/admin/assets/edit.html.haml +3 -0
  65. data/app/views/rad_social_mailer/social_mail_form.html.haml +1 -3
  66. data/app/views/widget/_email_form.html.haml +0 -5
  67. data/bin/rails +4 -4
  68. data/bin/trusty_cms +3 -5
  69. data/config.ru +1 -1
  70. data/config/application.rb +14 -15
  71. data/config/boot.rb +1 -2
  72. data/config/environment.rb +1 -1
  73. data/config/environments/production.rb +0 -1
  74. data/config/environments/test.rb +1 -2
  75. data/config/initializers/devise.rb +1 -1
  76. data/config/initializers/kraken.rb +2 -2
  77. data/config/initializers/tmp.rb +1 -1
  78. data/config/initializers/trusty_cms_config.rb +48 -48
  79. data/config/locales/en.yml +1 -0
  80. data/config/routes.rb +6 -6
  81. data/lib/active_record_extensions/active_record_extensions.rb +1 -2
  82. data/lib/annotatable.rb +3 -5
  83. data/lib/configuration_extensions/configuration_extensions.rb +1 -1
  84. data/lib/inheritable_class_attributes.rb +13 -9
  85. data/lib/login_system.rb +73 -73
  86. data/lib/method_observer.rb +13 -12
  87. data/lib/ostruct.rb +7 -10
  88. data/lib/simpleton.rb +0 -4
  89. data/lib/string_extensions/string_extensions.rb +3 -3
  90. data/lib/symbol_extensions/symbol_extensions.rb +1 -1
  91. data/lib/tasks/database.rake +28 -28
  92. data/lib/tasks/extensions.rake +18 -18
  93. data/lib/tasks/framework.rake +68 -68
  94. data/lib/tasks/radiant_config.rake +4 -4
  95. data/lib/tasks/snippets_extension_tasks.rake +11 -11
  96. data/lib/tasks/translate.rake +14 -14
  97. data/lib/tasks/upgrade_to_devise.rake +1 -1
  98. data/lib/translation_support.rb +22 -22
  99. data/lib/trusty_cms.rb +2 -2
  100. data/lib/trusty_cms/admin_ui.rb +19 -16
  101. data/lib/trusty_cms/admin_ui/region_partials.rb +4 -3
  102. data/lib/trusty_cms/admin_ui/region_set.rb +4 -5
  103. data/lib/trusty_cms/available_locales.rb +2 -4
  104. data/lib/trusty_cms/config/definition.rb +11 -8
  105. data/lib/trusty_cms/engine.rb +13 -14
  106. data/lib/trusty_cms/extension.rb +14 -16
  107. data/lib/trusty_cms/extension_loader.rb +6 -6
  108. data/lib/trusty_cms/extension_migrator.rb +42 -41
  109. data/lib/trusty_cms/extension_path.rb +20 -19
  110. data/lib/trusty_cms/initializer.rb +5 -8
  111. data/lib/trusty_cms/pagination/controller.rb +7 -10
  112. data/lib/trusty_cms/pagination/link_renderer.rb +2 -2
  113. data/lib/trusty_cms/resource_responses.rb +3 -3
  114. data/lib/trusty_cms/setup.rb +130 -132
  115. data/lib/trusty_cms/taggable.rb +19 -22
  116. data/lib/trusty_cms/task_support.rb +9 -6
  117. data/public/dispatch.fcgi +1 -1
  118. data/public/dispatch.rb +2 -2
  119. data/script/extension +1 -1
  120. data/script/rails +2 -2
  121. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/core.js +126 -0
  122. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/index.js +4 -0
  123. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/map.js +56 -0
  124. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/seq.js +43 -0
  125. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/string.js +28 -0
  126. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/index.js +36 -0
  127. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/json.js +76 -0
  128. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/options.js +23 -0
  129. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/binary.js +87 -0
  130. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/index.js +157 -0
  131. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/omap.js +142 -0
  132. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/pairs.js +81 -0
  133. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/set.js +114 -0
  134. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/timestamp.js +97 -0
  135. data/spec/spec/dummy/node_modules/yaml/dist/tags/core.js +114 -0
  136. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/index.js +17 -0
  137. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/map.js +37 -0
  138. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/seq.js +34 -0
  139. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/string.js +40 -0
  140. data/spec/spec/dummy/node_modules/yaml/dist/tags/index.js +62 -0
  141. data/spec/spec/dummy/node_modules/yaml/dist/tags/json.js +60 -0
  142. data/spec/spec/dummy/node_modules/yaml/dist/tags/options.js +35 -0
  143. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/binary.js +97 -0
  144. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/index.js +131 -0
  145. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/omap.js +105 -0
  146. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/pairs.js +80 -0
  147. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/set.js +91 -0
  148. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/timestamp.js +93 -0
  149. data/trusty_cms.gemspec +24 -24
  150. data/yarn.lock +3 -3
  151. metadata +7602 -103
  152. 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
+ };