/ cloudformation-templates / node_modules / aws-cdk / node_modules / yaml / browser / dist / warnings-df54cb69.js
warnings-df54cb69.js
1 import { o as YAMLReferenceError, T as Type, g as YAMLSemanticError, _ as _createForOfIteratorHelper, e as _defineProperty, j as _inherits, k as _createSuper, c as _classCallCheck, p as _assertThisInitialized, b as _createClass, a as _typeof, l as _get, m as _getPrototypeOf } from './PlainValue-b8036b75.js'; 2 import { j as resolveString, b as binaryOptions, c as stringifyString, h as resolveSeq, P as Pair, d as YAMLMap, Y as YAMLSeq, t as toJSON, S as Scalar, l as findPair, g as resolveMap, k as stringifyNumber } from './resolveSeq-492ab440.js'; 3 4 /* global atob, btoa, Buffer */ 5 var binary = { 6 identify: function identify(value) { 7 return value instanceof Uint8Array; 8 }, 9 // Buffer inherits from Uint8Array 10 default: false, 11 tag: 'tag:yaml.org,2002:binary', 12 13 /** 14 * Returns a Buffer in node and an Uint8Array in browsers 15 * 16 * To use the resulting buffer as an image, you'll want to do something like: 17 * 18 * const blob = new Blob([buffer], { type: 'image/jpeg' }) 19 * document.querySelector('#photo').src = URL.createObjectURL(blob) 20 */ 21 resolve: function resolve(doc, node) { 22 var src = resolveString(doc, node); 23 24 if (typeof Buffer === 'function') { 25 return Buffer.from(src, 'base64'); 26 } else if (typeof atob === 'function') { 27 // On IE 11, atob() can't handle newlines 28 var str = atob(src.replace(/[\n\r]/g, '')); 29 var buffer = new Uint8Array(str.length); 30 31 for (var i = 0; i < str.length; ++i) { 32 buffer[i] = str.charCodeAt(i); 33 } 34 35 return buffer; 36 } else { 37 var msg = 'This environment does not support reading binary tags; either Buffer or atob is required'; 38 doc.errors.push(new YAMLReferenceError(node, msg)); 39 return null; 40 } 41 }, 42 options: binaryOptions, 43 stringify: function stringify(_ref, ctx, onComment, onChompKeep) { 44 var comment = _ref.comment, 45 type = _ref.type, 46 value = _ref.value; 47 var src; 48 49 if (typeof Buffer === 'function') { 50 src = value instanceof Buffer ? value.toString('base64') : Buffer.from(value.buffer).toString('base64'); 51 } else if (typeof btoa === 'function') { 52 var s = ''; 53 54 for (var i = 0; i < value.length; ++i) { 55 s += String.fromCharCode(value[i]); 56 } 57 58 src = btoa(s); 59 } else { 60 throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required'); 61 } 62 63 if (!type) type = binaryOptions.defaultType; 64 65 if (type === Type.QUOTE_DOUBLE) { 66 value = src; 67 } else { 68 var lineWidth = binaryOptions.lineWidth; 69 var n = Math.ceil(src.length / lineWidth); 70 var lines = new Array(n); 71 72 for (var _i = 0, o = 0; _i < n; ++_i, o += lineWidth) { 73 lines[_i] = src.substr(o, lineWidth); 74 } 75 76 value = lines.join(type === Type.BLOCK_LITERAL ? '\n' : ' '); 77 } 78 79 return stringifyString({ 80 comment: comment, 81 type: type, 82 value: value 83 }, ctx, onComment, onChompKeep); 84 } 85 }; 86 87 function parsePairs(doc, cst) { 88 var seq = resolveSeq(doc, cst); 89 90 for (var i = 0; i < seq.items.length; ++i) { 91 var item = seq.items[i]; 92 if (item instanceof Pair) continue;else if (item instanceof YAMLMap) { 93 if (item.items.length > 1) { 94 var msg = 'Each pair must have its own sequence indicator'; 95 throw new YAMLSemanticError(cst, msg); 96 } 97 98 var pair = item.items[0] || new Pair(); 99 if (item.commentBefore) pair.commentBefore = pair.commentBefore ? "".concat(item.commentBefore, "\n").concat(pair.commentBefore) : item.commentBefore; 100 if (item.comment) pair.comment = pair.comment ? "".concat(item.comment, "\n").concat(pair.comment) : item.comment; 101 item = pair; 102 } 103 seq.items[i] = item instanceof Pair ? item : new Pair(item); 104 } 105 106 return seq; 107 } 108 function createPairs(schema, iterable, ctx) { 109 var pairs = new YAMLSeq(schema); 110 pairs.tag = 'tag:yaml.org,2002:pairs'; 111 112 var _iterator = _createForOfIteratorHelper(iterable), 113 _step; 114 115 try { 116 for (_iterator.s(); !(_step = _iterator.n()).done;) { 117 var it = _step.value; 118 var key = void 0, 119 value = void 0; 120 121 if (Array.isArray(it)) { 122 if (it.length === 2) { 123 key = it[0]; 124 value = it[1]; 125 } else throw new TypeError("Expected [key, value] tuple: ".concat(it)); 126 } else if (it && it instanceof Object) { 127 var keys = Object.keys(it); 128 129 if (keys.length === 1) { 130 key = keys[0]; 131 value = it[key]; 132 } else throw new TypeError("Expected { key: value } tuple: ".concat(it)); 133 } else { 134 key = it; 135 } 136 137 var pair = schema.createPair(key, value, ctx); 138 pairs.items.push(pair); 139 } 140 } catch (err) { 141 _iterator.e(err); 142 } finally { 143 _iterator.f(); 144 } 145 146 return pairs; 147 } 148 var pairs = { 149 default: false, 150 tag: 'tag:yaml.org,2002:pairs', 151 resolve: parsePairs, 152 createNode: createPairs 153 }; 154 155 var YAMLOMap = /*#__PURE__*/function (_YAMLSeq) { 156 _inherits(YAMLOMap, _YAMLSeq); 157 158 var _super = _createSuper(YAMLOMap); 159 160 function YAMLOMap() { 161 var _this; 162 163 _classCallCheck(this, YAMLOMap); 164 165 _this = _super.call(this); 166 167 _defineProperty(_assertThisInitialized(_this), "add", YAMLMap.prototype.add.bind(_assertThisInitialized(_this))); 168 169 _defineProperty(_assertThisInitialized(_this), "delete", YAMLMap.prototype.delete.bind(_assertThisInitialized(_this))); 170 171 _defineProperty(_assertThisInitialized(_this), "get", YAMLMap.prototype.get.bind(_assertThisInitialized(_this))); 172 173 _defineProperty(_assertThisInitialized(_this), "has", YAMLMap.prototype.has.bind(_assertThisInitialized(_this))); 174 175 _defineProperty(_assertThisInitialized(_this), "set", YAMLMap.prototype.set.bind(_assertThisInitialized(_this))); 176 177 _this.tag = YAMLOMap.tag; 178 return _this; 179 } 180 181 _createClass(YAMLOMap, [{ 182 key: "toJSON", 183 value: function toJSON$1(_, ctx) { 184 var map = new Map(); 185 if (ctx && ctx.onCreate) ctx.onCreate(map); 186 187 var _iterator = _createForOfIteratorHelper(this.items), 188 _step; 189 190 try { 191 for (_iterator.s(); !(_step = _iterator.n()).done;) { 192 var pair = _step.value; 193 var key = void 0, 194 value = void 0; 195 196 if (pair instanceof Pair) { 197 key = toJSON(pair.key, '', ctx); 198 value = toJSON(pair.value, key, ctx); 199 } else { 200 key = toJSON(pair, '', ctx); 201 } 202 203 if (map.has(key)) throw new Error('Ordered maps must not include duplicate keys'); 204 map.set(key, value); 205 } 206 } catch (err) { 207 _iterator.e(err); 208 } finally { 209 _iterator.f(); 210 } 211 212 return map; 213 } 214 }]); 215 216 return YAMLOMap; 217 }(YAMLSeq); 218 219 _defineProperty(YAMLOMap, "tag", 'tag:yaml.org,2002:omap'); 220 221 function parseOMap(doc, cst) { 222 var pairs = parsePairs(doc, cst); 223 var seenKeys = []; 224 225 var _iterator2 = _createForOfIteratorHelper(pairs.items), 226 _step2; 227 228 try { 229 for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { 230 var key = _step2.value.key; 231 232 if (key instanceof Scalar) { 233 if (seenKeys.includes(key.value)) { 234 var msg = 'Ordered maps must not include duplicate keys'; 235 throw new YAMLSemanticError(cst, msg); 236 } else { 237 seenKeys.push(key.value); 238 } 239 } 240 } 241 } catch (err) { 242 _iterator2.e(err); 243 } finally { 244 _iterator2.f(); 245 } 246 247 return Object.assign(new YAMLOMap(), pairs); 248 } 249 250 function createOMap(schema, iterable, ctx) { 251 var pairs = createPairs(schema, iterable, ctx); 252 var omap = new YAMLOMap(); 253 omap.items = pairs.items; 254 return omap; 255 } 256 257 var omap = { 258 identify: function identify(value) { 259 return value instanceof Map; 260 }, 261 nodeClass: YAMLOMap, 262 default: false, 263 tag: 'tag:yaml.org,2002:omap', 264 resolve: parseOMap, 265 createNode: createOMap 266 }; 267 268 var YAMLSet = /*#__PURE__*/function (_YAMLMap) { 269 _inherits(YAMLSet, _YAMLMap); 270 271 var _super = _createSuper(YAMLSet); 272 273 function YAMLSet() { 274 var _this; 275 276 _classCallCheck(this, YAMLSet); 277 278 _this = _super.call(this); 279 _this.tag = YAMLSet.tag; 280 return _this; 281 } 282 283 _createClass(YAMLSet, [{ 284 key: "add", 285 value: function add(key) { 286 var pair = key instanceof Pair ? key : new Pair(key); 287 var prev = findPair(this.items, pair.key); 288 if (!prev) this.items.push(pair); 289 } 290 }, { 291 key: "get", 292 value: function get(key, keepPair) { 293 var pair = findPair(this.items, key); 294 return !keepPair && pair instanceof Pair ? pair.key instanceof Scalar ? pair.key.value : pair.key : pair; 295 } 296 }, { 297 key: "set", 298 value: function set(key, value) { 299 if (typeof value !== 'boolean') throw new Error("Expected boolean value for set(key, value) in a YAML set, not ".concat(_typeof(value))); 300 var prev = findPair(this.items, key); 301 302 if (prev && !value) { 303 this.items.splice(this.items.indexOf(prev), 1); 304 } else if (!prev && value) { 305 this.items.push(new Pair(key)); 306 } 307 } 308 }, { 309 key: "toJSON", 310 value: function toJSON(_, ctx) { 311 return _get(_getPrototypeOf(YAMLSet.prototype), "toJSON", this).call(this, _, ctx, Set); 312 } 313 }, { 314 key: "toString", 315 value: function toString(ctx, onComment, onChompKeep) { 316 if (!ctx) return JSON.stringify(this); 317 if (this.hasAllNullValues()) return _get(_getPrototypeOf(YAMLSet.prototype), "toString", this).call(this, ctx, onComment, onChompKeep);else throw new Error('Set items must all have null values'); 318 } 319 }]); 320 321 return YAMLSet; 322 }(YAMLMap); 323 324 _defineProperty(YAMLSet, "tag", 'tag:yaml.org,2002:set'); 325 326 function parseSet(doc, cst) { 327 var map = resolveMap(doc, cst); 328 if (!map.hasAllNullValues()) throw new YAMLSemanticError(cst, 'Set items must all have null values'); 329 return Object.assign(new YAMLSet(), map); 330 } 331 332 function createSet(schema, iterable, ctx) { 333 var set = new YAMLSet(); 334 335 var _iterator = _createForOfIteratorHelper(iterable), 336 _step; 337 338 try { 339 for (_iterator.s(); !(_step = _iterator.n()).done;) { 340 var value = _step.value; 341 set.items.push(schema.createPair(value, null, ctx)); 342 } 343 } catch (err) { 344 _iterator.e(err); 345 } finally { 346 _iterator.f(); 347 } 348 349 return set; 350 } 351 352 var set = { 353 identify: function identify(value) { 354 return value instanceof Set; 355 }, 356 nodeClass: YAMLSet, 357 default: false, 358 tag: 'tag:yaml.org,2002:set', 359 resolve: parseSet, 360 createNode: createSet 361 }; 362 363 var parseSexagesimal = function parseSexagesimal(sign, parts) { 364 var n = parts.split(':').reduce(function (n, p) { 365 return n * 60 + Number(p); 366 }, 0); 367 return sign === '-' ? -n : n; 368 }; // hhhh:mm:ss.sss 369 370 371 var stringifySexagesimal = function stringifySexagesimal(_ref) { 372 var value = _ref.value; 373 if (isNaN(value) || !isFinite(value)) return stringifyNumber(value); 374 var sign = ''; 375 376 if (value < 0) { 377 sign = '-'; 378 value = Math.abs(value); 379 } 380 381 var parts = [value % 60]; // seconds, including ms 382 383 if (value < 60) { 384 parts.unshift(0); // at least one : is required 385 } else { 386 value = Math.round((value - parts[0]) / 60); 387 parts.unshift(value % 60); // minutes 388 389 if (value >= 60) { 390 value = Math.round((value - parts[0]) / 60); 391 parts.unshift(value); // hours 392 } 393 } 394 395 return sign + parts.map(function (n) { 396 return n < 10 ? '0' + String(n) : String(n); 397 }).join(':').replace(/000000\d*$/, '') // % 60 may introduce error 398 ; 399 }; 400 401 var intTime = { 402 identify: function identify(value) { 403 return typeof value === 'number'; 404 }, 405 default: true, 406 tag: 'tag:yaml.org,2002:int', 407 format: 'TIME', 408 test: /^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+)$/, 409 resolve: function resolve(str, sign, parts) { 410 return parseSexagesimal(sign, parts.replace(/_/g, '')); 411 }, 412 stringify: stringifySexagesimal 413 }; 414 var floatTime = { 415 identify: function identify(value) { 416 return typeof value === 'number'; 417 }, 418 default: true, 419 tag: 'tag:yaml.org,2002:float', 420 format: 'TIME', 421 test: /^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*)$/, 422 resolve: function resolve(str, sign, parts) { 423 return parseSexagesimal(sign, parts.replace(/_/g, '')); 424 }, 425 stringify: stringifySexagesimal 426 }; 427 var timestamp = { 428 identify: function identify(value) { 429 return value instanceof Date; 430 }, 431 default: true, 432 tag: 'tag:yaml.org,2002:timestamp', 433 // If the time zone is omitted, the timestamp is assumed to be specified in UTC. The time part 434 // may be omitted altogether, resulting in a date format. In such a case, the time part is 435 // assumed to be 00:00:00Z (start of day, UTC). 436 test: RegExp('^(?:' + '([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})' + // YYYY-Mm-Dd 437 '(?:(?:t|T|[ \\t]+)' + // t | T | whitespace 438 '([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)' + // Hh:Mm:Ss(.ss)? 439 '(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?' + // Z | +5 | -03:30 440 ')?' + ')$'), 441 resolve: function resolve(str, year, month, day, hour, minute, second, millisec, tz) { 442 if (millisec) millisec = (millisec + '00').substr(1, 3); 443 var date = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec || 0); 444 445 if (tz && tz !== 'Z') { 446 var d = parseSexagesimal(tz[0], tz.slice(1)); 447 if (Math.abs(d) < 30) d *= 60; 448 date -= 60000 * d; 449 } 450 451 return new Date(date); 452 }, 453 stringify: function stringify(_ref2) { 454 var value = _ref2.value; 455 return value.toISOString().replace(/((T00:00)?:00)?\.000Z$/, ''); 456 } 457 }; 458 459 /* global console, process, YAML_SILENCE_DEPRECATION_WARNINGS, YAML_SILENCE_WARNINGS */ 460 function shouldWarn(deprecation) { 461 var env = typeof process !== 'undefined' && process.env || {}; 462 463 if (deprecation) { 464 if (typeof YAML_SILENCE_DEPRECATION_WARNINGS !== 'undefined') return !YAML_SILENCE_DEPRECATION_WARNINGS; 465 return !env.YAML_SILENCE_DEPRECATION_WARNINGS; 466 } 467 468 if (typeof YAML_SILENCE_WARNINGS !== 'undefined') return !YAML_SILENCE_WARNINGS; 469 return !env.YAML_SILENCE_WARNINGS; 470 } 471 472 function warn(warning, type) { 473 if (shouldWarn(false)) { 474 var emit = typeof process !== 'undefined' && process.emitWarning; // This will throw in Jest if `warning` is an Error instance due to 475 // https://github.com/facebook/jest/issues/2549 476 477 if (emit) emit(warning, type);else { 478 // eslint-disable-next-line no-console 479 console.warn(type ? "".concat(type, ": ").concat(warning) : warning); 480 } 481 } 482 } 483 function warnFileDeprecation(filename) { 484 if (shouldWarn(true)) { 485 var path = filename.replace(/.*yaml[/\\]/i, '').replace(/\.js$/, '').replace(/\\/g, '/'); 486 warn("The endpoint 'yaml/".concat(path, "' will be removed in a future release."), 'DeprecationWarning'); 487 } 488 } 489 var warned = {}; 490 function warnOptionDeprecation(name, alternative) { 491 if (!warned[name] && shouldWarn(true)) { 492 warned[name] = true; 493 var msg = "The option '".concat(name, "' will be removed in a future release"); 494 msg += alternative ? ", use '".concat(alternative, "' instead.") : '.'; 495 warn(msg, 'DeprecationWarning'); 496 } 497 } 498 499 export { warnOptionDeprecation as a, binary as b, warnFileDeprecation as c, floatTime as f, intTime as i, omap as o, pairs as p, set as s, timestamp as t, warn as w };