| 1 |
"no use strict"; |
| 2 |
!(function(window) { |
| 3 |
if (typeof window.window != "undefined" && window.document) |
| 4 |
return; |
| 5 |
if (window.require && window.define) |
| 6 |
return; |
| 7 |
|
| 8 |
if (!window.console) { |
| 9 |
window.console = function() { |
| 10 |
var msgs = Array.prototype.slice.call(arguments, 0); |
| 11 |
postMessage({type: "log", data: msgs}); |
| 12 |
}; |
| 13 |
window.console.error = |
| 14 |
window.console.warn = |
| 15 |
window.console.log = |
| 16 |
window.console.trace = window.console; |
| 17 |
} |
| 18 |
window.window = window; |
| 19 |
window.ace = window; |
| 20 |
|
| 21 |
window.onerror = function(message, file, line, col, err) { |
| 22 |
postMessage({type: "error", data: { |
| 23 |
message: message, |
| 24 |
data: err && err.data, |
| 25 |
file: file, |
| 26 |
line: line, |
| 27 |
col: col, |
| 28 |
stack: err && err.stack |
| 29 |
}}); |
| 30 |
}; |
| 31 |
|
| 32 |
window.normalizeModule = function(parentId, moduleName) { |
| 33 |
|
| 34 |
if (moduleName.indexOf("!") !== -1) { |
| 35 |
var chunks = moduleName.split("!"); |
| 36 |
return window.normalizeModule(parentId, chunks[0]) + "!" + window.normalizeModule(parentId, chunks[1]); |
| 37 |
} |
| 38 |
|
| 39 |
if (moduleName.charAt(0) == ".") { |
| 40 |
var base = parentId.split("/").slice(0, -1).join("/"); |
| 41 |
moduleName = (base ? base + "/" : "") + moduleName; |
| 42 |
|
| 43 |
while (moduleName.indexOf(".") !== -1 && previous != moduleName) { |
| 44 |
var previous = moduleName; |
| 45 |
moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, ""); |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
return moduleName; |
| 50 |
}; |
| 51 |
|
| 52 |
window.require = function require(parentId, id) { |
| 53 |
if (!id) { |
| 54 |
id = parentId; |
| 55 |
parentId = null; |
| 56 |
} |
| 57 |
if (!id.charAt) |
| 58 |
throw new Error("worker.js require() accepts only (parentId, id) as arguments"); |
| 59 |
|
| 60 |
id = window.normalizeModule(parentId, id); |
| 61 |
|
| 62 |
var module = window.require.modules[id]; |
| 63 |
if (module) { |
| 64 |
if (!module.initialized) { |
| 65 |
module.initialized = true; |
| 66 |
module.exports = module.factory().exports; |
| 67 |
} |
| 68 |
return module.exports; |
| 69 |
} |
| 70 |
|
| 71 |
if (!window.require.tlns) |
| 72 |
return console.log("unable to load " + id); |
| 73 |
|
| 74 |
var path = resolveModuleId(id, window.require.tlns); |
| 75 |
if (path.slice(-3) != ".js") path += ".js"; |
| 76 |
|
| 77 |
window.require.id = id; |
| 78 |
window.require.modules[id] = {}; |
| 79 |
importScripts(path); |
| 80 |
return window.require(parentId, id); |
| 81 |
}; |
| 82 |
function resolveModuleId(id, paths) { |
| 83 |
var testPath = id, tail = ""; |
| 84 |
while (testPath) { |
| 85 |
var alias = paths[testPath]; |
| 86 |
if (typeof alias == "string") { |
| 87 |
return alias + tail; |
| 88 |
} else if (alias) { |
| 89 |
return alias.location.replace(/\/*$/, "/") + (tail || alias.main || alias.name); |
| 90 |
} else if (alias === false) { |
| 91 |
return ""; |
| 92 |
} |
| 93 |
var i = testPath.lastIndexOf("/"); |
| 94 |
if (i === -1) break; |
| 95 |
tail = testPath.substr(i) + tail; |
| 96 |
testPath = testPath.slice(0, i); |
| 97 |
} |
| 98 |
return id; |
| 99 |
} |
| 100 |
window.require.modules = {}; |
| 101 |
window.require.tlns = {}; |
| 102 |
|
| 103 |
window.define = function(id, deps, factory) { |
| 104 |
if (arguments.length == 2) { |
| 105 |
factory = deps; |
| 106 |
if (typeof id != "string") { |
| 107 |
deps = id; |
| 108 |
id = window.require.id; |
| 109 |
} |
| 110 |
} else if (arguments.length == 1) { |
| 111 |
factory = id; |
| 112 |
deps = []; |
| 113 |
id = window.require.id; |
| 114 |
} |
| 115 |
|
| 116 |
if (typeof factory != "function") { |
| 117 |
window.require.modules[id] = { |
| 118 |
exports: factory, |
| 119 |
initialized: true |
| 120 |
}; |
| 121 |
return; |
| 122 |
} |
| 123 |
|
| 124 |
if (!deps.length) |
| 125 |
|
| 126 |
|
| 127 |
deps = ["require", "exports", "module"]; |
| 128 |
|
| 129 |
var req = function(childId) { |
| 130 |
return window.require(id, childId); |
| 131 |
}; |
| 132 |
|
| 133 |
window.require.modules[id] = { |
| 134 |
exports: {}, |
| 135 |
factory: function() { |
| 136 |
var module = this; |
| 137 |
var returnExports = factory.apply(this, deps.slice(0, factory.length).map(function(dep) { |
| 138 |
switch (dep) { |
| 139 |
|
| 140 |
|
| 141 |
case "require": return req; |
| 142 |
case "exports": return module.exports; |
| 143 |
case "module": return module; |
| 144 |
|
| 145 |
|
| 146 |
default: return req(dep); |
| 147 |
} |
| 148 |
})); |
| 149 |
if (returnExports) |
| 150 |
module.exports = returnExports; |
| 151 |
return module; |
| 152 |
} |
| 153 |
}; |
| 154 |
}; |
| 155 |
window.define.amd = {}; |
| 156 |
window.require.tlns = {}; |
| 157 |
window.initBaseUrls = function initBaseUrls(topLevelNamespaces) { |
| 158 |
for (var i in topLevelNamespaces) |
| 159 |
this.require.tlns[i] = topLevelNamespaces[i]; |
| 160 |
}; |
| 161 |
|
| 162 |
window.initSender = function initSender() { |
| 163 |
|
| 164 |
var EventEmitter = window.require("ace/lib/event_emitter").EventEmitter; |
| 165 |
var oop = window.require("ace/lib/oop"); |
| 166 |
|
| 167 |
var Sender = function() {}; |
| 168 |
|
| 169 |
(function() { |
| 170 |
|
| 171 |
oop.implement(this, EventEmitter); |
| 172 |
|
| 173 |
this.callback = function(data, callbackId) { |
| 174 |
postMessage({ |
| 175 |
type: "call", |
| 176 |
id: callbackId, |
| 177 |
data: data |
| 178 |
}); |
| 179 |
}; |
| 180 |
|
| 181 |
this.emit = function(name, data) { |
| 182 |
postMessage({ |
| 183 |
type: "event", |
| 184 |
name: name, |
| 185 |
data: data |
| 186 |
}); |
| 187 |
}; |
| 188 |
|
| 189 |
}).call(Sender.prototype); |
| 190 |
|
| 191 |
return new Sender(); |
| 192 |
}; |
| 193 |
|
| 194 |
var main = window.main = null; |
| 195 |
var sender = window.sender = null; |
| 196 |
|
| 197 |
window.onmessage = function(e) { |
| 198 |
var msg = e.data; |
| 199 |
if (msg.event && sender) { |
| 200 |
sender._signal(msg.event, msg.data); |
| 201 |
} |
| 202 |
else if (msg.command) { |
| 203 |
if (main[msg.command]) |
| 204 |
main[msg.command].apply(main, msg.args); |
| 205 |
else if (window[msg.command]) |
| 206 |
window[msg.command].apply(window, msg.args); |
| 207 |
else |
| 208 |
throw new Error("Unknown command:" + msg.command); |
| 209 |
} |
| 210 |
else if (msg.init) { |
| 211 |
window.initBaseUrls(msg.tlns); |
| 212 |
sender = window.sender = window.initSender(); |
| 213 |
var clazz = this.require(msg.module)[msg.classname]; |
| 214 |
main = window.main = new clazz(sender); |
| 215 |
} |
| 216 |
}; |
| 217 |
})(this); |
| 218 |
|
| 219 |
ace.define("ace/lib/oop",[], function(require, exports, module){"use strict"; |
| 220 |
exports.inherits = function (ctor, superCtor) { |
| 221 |
ctor.super_ = superCtor; |
| 222 |
ctor.prototype = Object.create(superCtor.prototype, { |
| 223 |
constructor: { |
| 224 |
value: ctor, |
| 225 |
enumerable: false, |
| 226 |
writable: true, |
| 227 |
configurable: true |
| 228 |
} |
| 229 |
}); |
| 230 |
}; |
| 231 |
exports.mixin = function (obj, mixin) { |
| 232 |
for (var key in mixin) { |
| 233 |
obj[key] = mixin[key]; |
| 234 |
} |
| 235 |
return obj; |
| 236 |
}; |
| 237 |
exports.implement = function (proto, mixin) { |
| 238 |
exports.mixin(proto, mixin); |
| 239 |
}; |
| 240 |
|
| 241 |
}); |
| 242 |
|
| 243 |
ace.define("ace/apply_delta",[], function(require, exports, module){"use strict"; |
| 244 |
function throwDeltaError(delta, errorText) { |
| 245 |
console.log("Invalid Delta:", delta); |
| 246 |
throw "Invalid Delta: " + errorText; |
| 247 |
} |
| 248 |
function positionInDocument(docLines, position) { |
| 249 |
return position.row >= 0 && position.row < docLines.length && |
| 250 |
position.column >= 0 && position.column <= docLines[position.row].length; |
| 251 |
} |
| 252 |
function validateDelta(docLines, delta) { |
| 253 |
if (delta.action != "insert" && delta.action != "remove") |
| 254 |
throwDeltaError(delta, "delta.action must be 'insert' or 'remove'"); |
| 255 |
if (!(delta.lines instanceof Array)) |
| 256 |
throwDeltaError(delta, "delta.lines must be an Array"); |
| 257 |
if (!delta.start || !delta.end) |
| 258 |
throwDeltaError(delta, "delta.start/end must be an present"); |
| 259 |
var start = delta.start; |
| 260 |
if (!positionInDocument(docLines, delta.start)) |
| 261 |
throwDeltaError(delta, "delta.start must be contained in document"); |
| 262 |
var end = delta.end; |
| 263 |
if (delta.action == "remove" && !positionInDocument(docLines, end)) |
| 264 |
throwDeltaError(delta, "delta.end must contained in document for 'remove' actions"); |
| 265 |
var numRangeRows = end.row - start.row; |
| 266 |
var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0)); |
| 267 |
if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars) |
| 268 |
throwDeltaError(delta, "delta.range must match delta lines"); |
| 269 |
} |
| 270 |
exports.applyDelta = function (docLines, delta, doNotValidate) { |
| 271 |
var row = delta.start.row; |
| 272 |
var startColumn = delta.start.column; |
| 273 |
var line = docLines[row] || ""; |
| 274 |
switch (delta.action) { |
| 275 |
case "insert": |
| 276 |
var lines = delta.lines; |
| 277 |
if (lines.length === 1) { |
| 278 |
docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn); |
| 279 |
} |
| 280 |
else { |
| 281 |
var args = [row, 1].concat(delta.lines); |
| 282 |
docLines.splice.apply(docLines, args); |
| 283 |
docLines[row] = line.substring(0, startColumn) + docLines[row]; |
| 284 |
docLines[row + delta.lines.length - 1] += line.substring(startColumn); |
| 285 |
} |
| 286 |
break; |
| 287 |
case "remove": |
| 288 |
var endColumn = delta.end.column; |
| 289 |
var endRow = delta.end.row; |
| 290 |
if (row === endRow) { |
| 291 |
docLines[row] = line.substring(0, startColumn) + line.substring(endColumn); |
| 292 |
} |
| 293 |
else { |
| 294 |
docLines.splice(row, endRow - row + 1, line.substring(0, startColumn) + docLines[endRow].substring(endColumn)); |
| 295 |
} |
| 296 |
break; |
| 297 |
} |
| 298 |
}; |
| 299 |
|
| 300 |
}); |
| 301 |
|
| 302 |
ace.define("ace/lib/event_emitter",[], function(require, exports, module){"use strict"; |
| 303 |
var EventEmitter = {}; |
| 304 |
var stopPropagation = function () { this.propagationStopped = true; }; |
| 305 |
var preventDefault = function () { this.defaultPrevented = true; }; |
| 306 |
EventEmitter._emit = |
| 307 |
EventEmitter._dispatchEvent = function (eventName, e) { |
| 308 |
this._eventRegistry || (this._eventRegistry = {}); |
| 309 |
this._defaultHandlers || (this._defaultHandlers = {}); |
| 310 |
var listeners = this._eventRegistry[eventName] || []; |
| 311 |
var defaultHandler = this._defaultHandlers[eventName]; |
| 312 |
if (!listeners.length && !defaultHandler) |
| 313 |
return; |
| 314 |
if (typeof e != "object" || !e) |
| 315 |
e = {}; |
| 316 |
if (!e.type) |
| 317 |
e.type = eventName; |
| 318 |
if (!e.stopPropagation) |
| 319 |
e.stopPropagation = stopPropagation; |
| 320 |
if (!e.preventDefault) |
| 321 |
e.preventDefault = preventDefault; |
| 322 |
listeners = listeners.slice(); |
| 323 |
for (var i = 0; i < listeners.length; i++) { |
| 324 |
listeners[i](e, this); |
| 325 |
if (e.propagationStopped) |
| 326 |
break; |
| 327 |
} |
| 328 |
if (defaultHandler && !e.defaultPrevented) |
| 329 |
return defaultHandler(e, this); |
| 330 |
}; |
| 331 |
EventEmitter._signal = function (eventName, e) { |
| 332 |
var listeners = (this._eventRegistry || {})[eventName]; |
| 333 |
if (!listeners) |
| 334 |
return; |
| 335 |
listeners = listeners.slice(); |
| 336 |
for (var i = 0; i < listeners.length; i++) |
| 337 |
listeners[i](e, this); |
| 338 |
}; |
| 339 |
EventEmitter.once = function (eventName, callback) { |
| 340 |
var _self = this; |
| 341 |
this.on(eventName, function newCallback() { |
| 342 |
_self.off(eventName, newCallback); |
| 343 |
callback.apply(null, arguments); |
| 344 |
}); |
| 345 |
if (!callback) { |
| 346 |
return new Promise(function (resolve) { |
| 347 |
callback = resolve; |
| 348 |
}); |
| 349 |
} |
| 350 |
}; |
| 351 |
EventEmitter.setDefaultHandler = function (eventName, callback) { |
| 352 |
var handlers = this._defaultHandlers; |
| 353 |
if (!handlers) |
| 354 |
handlers = this._defaultHandlers = { _disabled_: {} }; |
| 355 |
if (handlers[eventName]) { |
| 356 |
var old = handlers[eventName]; |
| 357 |
var disabled = handlers._disabled_[eventName]; |
| 358 |
if (!disabled) |
| 359 |
handlers._disabled_[eventName] = disabled = []; |
| 360 |
disabled.push(old); |
| 361 |
var i = disabled.indexOf(callback); |
| 362 |
if (i != -1) |
| 363 |
disabled.splice(i, 1); |
| 364 |
} |
| 365 |
handlers[eventName] = callback; |
| 366 |
}; |
| 367 |
EventEmitter.removeDefaultHandler = function (eventName, callback) { |
| 368 |
var handlers = this._defaultHandlers; |
| 369 |
if (!handlers) |
| 370 |
return; |
| 371 |
var disabled = handlers._disabled_[eventName]; |
| 372 |
if (handlers[eventName] == callback) { |
| 373 |
if (disabled) |
| 374 |
this.setDefaultHandler(eventName, disabled.pop()); |
| 375 |
} |
| 376 |
else if (disabled) { |
| 377 |
var i = disabled.indexOf(callback); |
| 378 |
if (i != -1) |
| 379 |
disabled.splice(i, 1); |
| 380 |
} |
| 381 |
}; |
| 382 |
EventEmitter.on = |
| 383 |
EventEmitter.addEventListener = function (eventName, callback, capturing) { |
| 384 |
this._eventRegistry = this._eventRegistry || {}; |
| 385 |
var listeners = this._eventRegistry[eventName]; |
| 386 |
if (!listeners) |
| 387 |
listeners = this._eventRegistry[eventName] = []; |
| 388 |
if (listeners.indexOf(callback) == -1) |
| 389 |
listeners[capturing ? "unshift" : "push"](callback); |
| 390 |
return callback; |
| 391 |
}; |
| 392 |
EventEmitter.off = |
| 393 |
EventEmitter.removeListener = |
| 394 |
EventEmitter.removeEventListener = function (eventName, callback) { |
| 395 |
this._eventRegistry = this._eventRegistry || {}; |
| 396 |
var listeners = this._eventRegistry[eventName]; |
| 397 |
if (!listeners) |
| 398 |
return; |
| 399 |
var index = listeners.indexOf(callback); |
| 400 |
if (index !== -1) |
| 401 |
listeners.splice(index, 1); |
| 402 |
}; |
| 403 |
EventEmitter.removeAllListeners = function (eventName) { |
| 404 |
if (!eventName) |
| 405 |
this._eventRegistry = this._defaultHandlers = undefined; |
| 406 |
if (this._eventRegistry) |
| 407 |
this._eventRegistry[eventName] = undefined; |
| 408 |
if (this._defaultHandlers) |
| 409 |
this._defaultHandlers[eventName] = undefined; |
| 410 |
}; |
| 411 |
exports.EventEmitter = EventEmitter; |
| 412 |
|
| 413 |
}); |
| 414 |
|
| 415 |
ace.define("ace/range",[], function(require, exports, module){"use strict"; |
| 416 |
var Range = (function () { |
| 417 |
function Range(startRow, startColumn, endRow, endColumn) { |
| 418 |
this.start = { |
| 419 |
row: startRow, |
| 420 |
column: startColumn |
| 421 |
}; |
| 422 |
this.end = { |
| 423 |
row: endRow, |
| 424 |
column: endColumn |
| 425 |
}; |
| 426 |
} |
| 427 |
Range.prototype.isEqual = function (range) { |
| 428 |
return this.start.row === range.start.row && |
| 429 |
this.end.row === range.end.row && |
| 430 |
this.start.column === range.start.column && |
| 431 |
this.end.column === range.end.column; |
| 432 |
}; |
| 433 |
Range.prototype.toString = function () { |
| 434 |
return ("Range: [" + this.start.row + "/" + this.start.column + |
| 435 |
"] -> [" + this.end.row + "/" + this.end.column + "]"); |
| 436 |
}; |
| 437 |
Range.prototype.contains = function (row, column) { |
| 438 |
return this.compare(row, column) == 0; |
| 439 |
}; |
| 440 |
Range.prototype.compareRange = function (range) { |
| 441 |
var cmp, end = range.end, start = range.start; |
| 442 |
cmp = this.compare(end.row, end.column); |
| 443 |
if (cmp == 1) { |
| 444 |
cmp = this.compare(start.row, start.column); |
| 445 |
if (cmp == 1) { |
| 446 |
return 2; |
| 447 |
} |
| 448 |
else if (cmp == 0) { |
| 449 |
return 1; |
| 450 |
} |
| 451 |
else { |
| 452 |
return 0; |
| 453 |
} |
| 454 |
} |
| 455 |
else if (cmp == -1) { |
| 456 |
return -2; |
| 457 |
} |
| 458 |
else { |
| 459 |
cmp = this.compare(start.row, start.column); |
| 460 |
if (cmp == -1) { |
| 461 |
return -1; |
| 462 |
} |
| 463 |
else if (cmp == 1) { |
| 464 |
return 42; |
| 465 |
} |
| 466 |
else { |
| 467 |
return 0; |
| 468 |
} |
| 469 |
} |
| 470 |
}; |
| 471 |
Range.prototype.comparePoint = function (p) { |
| 472 |
return this.compare(p.row, p.column); |
| 473 |
}; |
| 474 |
Range.prototype.containsRange = function (range) { |
| 475 |
return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0; |
| 476 |
}; |
| 477 |
Range.prototype.intersects = function (range) { |
| 478 |
var cmp = this.compareRange(range); |
| 479 |
return (cmp == -1 || cmp == 0 || cmp == 1); |
| 480 |
}; |
| 481 |
Range.prototype.isEnd = function (row, column) { |
| 482 |
return this.end.row == row && this.end.column == column; |
| 483 |
}; |
| 484 |
Range.prototype.isStart = function (row, column) { |
| 485 |
return this.start.row == row && this.start.column == column; |
| 486 |
}; |
| 487 |
Range.prototype.setStart = function (row, column) { |
| 488 |
if (typeof row == "object") { |
| 489 |
this.start.column = row.column; |
| 490 |
this.start.row = row.row; |
| 491 |
} |
| 492 |
else { |
| 493 |
this.start.row = row; |
| 494 |
this.start.column = column; |
| 495 |
} |
| 496 |
}; |
| 497 |
Range.prototype.setEnd = function (row, column) { |
| 498 |
if (typeof row == "object") { |
| 499 |
this.end.column = row.column; |
| 500 |
this.end.row = row.row; |
| 501 |
} |
| 502 |
else { |
| 503 |
this.end.row = row; |
| 504 |
this.end.column = column; |
| 505 |
} |
| 506 |
}; |
| 507 |
Range.prototype.inside = function (row, column) { |
| 508 |
if (this.compare(row, column) == 0) { |
| 509 |
if (this.isEnd(row, column) || this.isStart(row, column)) { |
| 510 |
return false; |
| 511 |
} |
| 512 |
else { |
| 513 |
return true; |
| 514 |
} |
| 515 |
} |
| 516 |
return false; |
| 517 |
}; |
| 518 |
Range.prototype.insideStart = function (row, column) { |
| 519 |
if (this.compare(row, column) == 0) { |
| 520 |
if (this.isEnd(row, column)) { |
| 521 |
return false; |
| 522 |
} |
| 523 |
else { |
| 524 |
return true; |
| 525 |
} |
| 526 |
} |
| 527 |
return false; |
| 528 |
}; |
| 529 |
Range.prototype.insideEnd = function (row, column) { |
| 530 |
if (this.compare(row, column) == 0) { |
| 531 |
if (this.isStart(row, column)) { |
| 532 |
return false; |
| 533 |
} |
| 534 |
else { |
| 535 |
return true; |
| 536 |
} |
| 537 |
} |
| 538 |
return false; |
| 539 |
}; |
| 540 |
Range.prototype.compare = function (row, column) { |
| 541 |
if (!this.isMultiLine()) { |
| 542 |
if (row === this.start.row) { |
| 543 |
return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0); |
| 544 |
} |
| 545 |
} |
| 546 |
if (row < this.start.row) |
| 547 |
return -1; |
| 548 |
if (row > this.end.row) |
| 549 |
return 1; |
| 550 |
if (this.start.row === row) |
| 551 |
return column >= this.start.column ? 0 : -1; |
| 552 |
if (this.end.row === row) |
| 553 |
return column <= this.end.column ? 0 : 1; |
| 554 |
return 0; |
| 555 |
}; |
| 556 |
Range.prototype.compareStart = function (row, column) { |
| 557 |
if (this.start.row == row && this.start.column == column) { |
| 558 |
return -1; |
| 559 |
} |
| 560 |
else { |
| 561 |
return this.compare(row, column); |
| 562 |
} |
| 563 |
}; |
| 564 |
Range.prototype.compareEnd = function (row, column) { |
| 565 |
if (this.end.row == row && this.end.column == column) { |
| 566 |
return 1; |
| 567 |
} |
| 568 |
else { |
| 569 |
return this.compare(row, column); |
| 570 |
} |
| 571 |
}; |
| 572 |
Range.prototype.compareInside = function (row, column) { |
| 573 |
if (this.end.row == row && this.end.column == column) { |
| 574 |
return 1; |
| 575 |
} |
| 576 |
else if (this.start.row == row && this.start.column == column) { |
| 577 |
return -1; |
| 578 |
} |
| 579 |
else { |
| 580 |
return this.compare(row, column); |
| 581 |
} |
| 582 |
}; |
| 583 |
Range.prototype.clipRows = function (firstRow, lastRow) { |
| 584 |
if (this.end.row > lastRow) |
| 585 |
var end = { row: lastRow + 1, column: 0 }; |
| 586 |
else if (this.end.row < firstRow) |
| 587 |
var end = { row: firstRow, column: 0 }; |
| 588 |
if (this.start.row > lastRow) |
| 589 |
var start = { row: lastRow + 1, column: 0 }; |
| 590 |
else if (this.start.row < firstRow) |
| 591 |
var start = { row: firstRow, column: 0 }; |
| 592 |
return Range.fromPoints(start || this.start, end || this.end); |
| 593 |
}; |
| 594 |
Range.prototype.extend = function (row, column) { |
| 595 |
var cmp = this.compare(row, column); |
| 596 |
if (cmp == 0) |
| 597 |
return this; |
| 598 |
else if (cmp == -1) |
| 599 |
var start = { row: row, column: column }; |
| 600 |
else |
| 601 |
var end = { row: row, column: column }; |
| 602 |
return Range.fromPoints(start || this.start, end || this.end); |
| 603 |
}; |
| 604 |
Range.prototype.isEmpty = function () { |
| 605 |
return (this.start.row === this.end.row && this.start.column === this.end.column); |
| 606 |
}; |
| 607 |
Range.prototype.isMultiLine = function () { |
| 608 |
return (this.start.row !== this.end.row); |
| 609 |
}; |
| 610 |
Range.prototype.clone = function () { |
| 611 |
return Range.fromPoints(this.start, this.end); |
| 612 |
}; |
| 613 |
Range.prototype.collapseRows = function () { |
| 614 |
if (this.end.column == 0) |
| 615 |
return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row - 1), 0); |
| 616 |
else |
| 617 |
return new Range(this.start.row, 0, this.end.row, 0); |
| 618 |
}; |
| 619 |
Range.prototype.toScreenRange = function (session) { |
| 620 |
var screenPosStart = session.documentToScreenPosition(this.start); |
| 621 |
var screenPosEnd = session.documentToScreenPosition(this.end); |
| 622 |
return new Range(screenPosStart.row, screenPosStart.column, screenPosEnd.row, screenPosEnd.column); |
| 623 |
}; |
| 624 |
Range.prototype.moveBy = function (row, column) { |
| 625 |
this.start.row += row; |
| 626 |
this.start.column += column; |
| 627 |
this.end.row += row; |
| 628 |
this.end.column += column; |
| 629 |
}; |
| 630 |
return Range; |
| 631 |
}()); |
| 632 |
Range.fromPoints = function (start, end) { |
| 633 |
return new Range(start.row, start.column, end.row, end.column); |
| 634 |
}; |
| 635 |
Range.comparePoints = function (p1, p2) { |
| 636 |
return p1.row - p2.row || p1.column - p2.column; |
| 637 |
}; |
| 638 |
exports.Range = Range; |
| 639 |
|
| 640 |
}); |
| 641 |
|
| 642 |
ace.define("ace/anchor",[], function(require, exports, module){"use strict"; |
| 643 |
var oop = require("./lib/oop"); |
| 644 |
var EventEmitter = require("./lib/event_emitter").EventEmitter; |
| 645 |
var Anchor = (function () { |
| 646 |
function Anchor(doc, row, column) { |
| 647 |
this.$onChange = this.onChange.bind(this); |
| 648 |
this.attach(doc); |
| 649 |
if (typeof row != "number") |
| 650 |
this.setPosition(row.row, row.column); |
| 651 |
else |
| 652 |
this.setPosition(row, column); |
| 653 |
} |
| 654 |
Anchor.prototype.getPosition = function () { |
| 655 |
return this.$clipPositionToDocument(this.row, this.column); |
| 656 |
}; |
| 657 |
Anchor.prototype.getDocument = function () { |
| 658 |
return this.document; |
| 659 |
}; |
| 660 |
Anchor.prototype.onChange = function (delta) { |
| 661 |
if (delta.start.row == delta.end.row && delta.start.row != this.row) |
| 662 |
return; |
| 663 |
if (delta.start.row > this.row) |
| 664 |
return; |
| 665 |
var point = $getTransformedPoint(delta, { row: this.row, column: this.column }, this.$insertRight); |
| 666 |
this.setPosition(point.row, point.column, true); |
| 667 |
}; |
| 668 |
Anchor.prototype.setPosition = function (row, column, noClip) { |
| 669 |
var pos; |
| 670 |
if (noClip) { |
| 671 |
pos = { |
| 672 |
row: row, |
| 673 |
column: column |
| 674 |
}; |
| 675 |
} |
| 676 |
else { |
| 677 |
pos = this.$clipPositionToDocument(row, column); |
| 678 |
} |
| 679 |
if (this.row == pos.row && this.column == pos.column) |
| 680 |
return; |
| 681 |
var old = { |
| 682 |
row: this.row, |
| 683 |
column: this.column |
| 684 |
}; |
| 685 |
this.row = pos.row; |
| 686 |
this.column = pos.column; |
| 687 |
this._signal("change", { |
| 688 |
old: old, |
| 689 |
value: pos |
| 690 |
}); |
| 691 |
}; |
| 692 |
Anchor.prototype.detach = function () { |
| 693 |
this.document.off("change", this.$onChange); |
| 694 |
}; |
| 695 |
Anchor.prototype.attach = function (doc) { |
| 696 |
this.document = doc || this.document; |
| 697 |
this.document.on("change", this.$onChange); |
| 698 |
}; |
| 699 |
Anchor.prototype.$clipPositionToDocument = function (row, column) { |
| 700 |
var pos = {}; |
| 701 |
if (row >= this.document.getLength()) { |
| 702 |
pos.row = Math.max(0, this.document.getLength() - 1); |
| 703 |
pos.column = this.document.getLine(pos.row).length; |
| 704 |
} |
| 705 |
else if (row < 0) { |
| 706 |
pos.row = 0; |
| 707 |
pos.column = 0; |
| 708 |
} |
| 709 |
else { |
| 710 |
pos.row = row; |
| 711 |
pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column)); |
| 712 |
} |
| 713 |
if (column < 0) |
| 714 |
pos.column = 0; |
| 715 |
return pos; |
| 716 |
}; |
| 717 |
return Anchor; |
| 718 |
}()); |
| 719 |
Anchor.prototype.$insertRight = false; |
| 720 |
oop.implement(Anchor.prototype, EventEmitter); |
| 721 |
function $pointsInOrder(point1, point2, equalPointsInOrder) { |
| 722 |
var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column; |
| 723 |
return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter); |
| 724 |
} |
| 725 |
function $getTransformedPoint(delta, point, moveIfEqual) { |
| 726 |
var deltaIsInsert = delta.action == "insert"; |
| 727 |
var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row); |
| 728 |
var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column); |
| 729 |
var deltaStart = delta.start; |
| 730 |
var deltaEnd = deltaIsInsert ? deltaStart : delta.end; |
| 731 |
if ($pointsInOrder(point, deltaStart, moveIfEqual)) { |
| 732 |
return { |
| 733 |
row: point.row, |
| 734 |
column: point.column |
| 735 |
}; |
| 736 |
} |
| 737 |
if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) { |
| 738 |
return { |
| 739 |
row: point.row + deltaRowShift, |
| 740 |
column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0) |
| 741 |
}; |
| 742 |
} |
| 743 |
return { |
| 744 |
row: deltaStart.row, |
| 745 |
column: deltaStart.column |
| 746 |
}; |
| 747 |
} |
| 748 |
exports.Anchor = Anchor; |
| 749 |
|
| 750 |
}); |
| 751 |
|
| 752 |
ace.define("ace/document",[], function(require, exports, module){"use strict"; |
| 753 |
var oop = require("./lib/oop"); |
| 754 |
var applyDelta = require("./apply_delta").applyDelta; |
| 755 |
var EventEmitter = require("./lib/event_emitter").EventEmitter; |
| 756 |
var Range = require("./range").Range; |
| 757 |
var Anchor = require("./anchor").Anchor; |
| 758 |
var Document = (function () { |
| 759 |
function Document(textOrLines) { |
| 760 |
this.$lines = [""]; |
| 761 |
if (textOrLines.length === 0) { |
| 762 |
this.$lines = [""]; |
| 763 |
} |
| 764 |
else if (Array.isArray(textOrLines)) { |
| 765 |
this.insertMergedLines({ row: 0, column: 0 }, textOrLines); |
| 766 |
} |
| 767 |
else { |
| 768 |
this.insert({ row: 0, column: 0 }, textOrLines); |
| 769 |
} |
| 770 |
} |
| 771 |
Document.prototype.setValue = function (text) { |
| 772 |
var len = this.getLength() - 1; |
| 773 |
this.remove(new Range(0, 0, len, this.getLine(len).length)); |
| 774 |
this.insert({ row: 0, column: 0 }, text || ""); |
| 775 |
}; |
| 776 |
Document.prototype.getValue = function () { |
| 777 |
return this.getAllLines().join(this.getNewLineCharacter()); |
| 778 |
}; |
| 779 |
Document.prototype.createAnchor = function (row, column) { |
| 780 |
return new Anchor(this, row, column); |
| 781 |
}; |
| 782 |
Document.prototype.$detectNewLine = function (text) { |
| 783 |
var match = text.match(/^.*?(\r\n|\r|\n)/m); |
| 784 |
this.$autoNewLine = match ? match[1] : "\n"; |
| 785 |
this._signal("changeNewLineMode"); |
| 786 |
}; |
| 787 |
Document.prototype.getNewLineCharacter = function () { |
| 788 |
switch (this.$newLineMode) { |
| 789 |
case "windows": |
| 790 |
return "\r\n"; |
| 791 |
case "unix": |
| 792 |
return "\n"; |
| 793 |
default: |
| 794 |
return this.$autoNewLine || "\n"; |
| 795 |
} |
| 796 |
}; |
| 797 |
Document.prototype.setNewLineMode = function (newLineMode) { |
| 798 |
if (this.$newLineMode === newLineMode) |
| 799 |
return; |
| 800 |
this.$newLineMode = newLineMode; |
| 801 |
this._signal("changeNewLineMode"); |
| 802 |
}; |
| 803 |
Document.prototype.getNewLineMode = function () { |
| 804 |
return this.$newLineMode; |
| 805 |
}; |
| 806 |
Document.prototype.isNewLine = function (text) { |
| 807 |
return (text == "\r\n" || text == "\r" || text == "\n"); |
| 808 |
}; |
| 809 |
Document.prototype.getLine = function (row) { |
| 810 |
return this.$lines[row] || ""; |
| 811 |
}; |
| 812 |
Document.prototype.getLines = function (firstRow, lastRow) { |
| 813 |
return this.$lines.slice(firstRow, lastRow + 1); |
| 814 |
}; |
| 815 |
Document.prototype.getAllLines = function () { |
| 816 |
return this.getLines(0, this.getLength()); |
| 817 |
}; |
| 818 |
Document.prototype.getLength = function () { |
| 819 |
return this.$lines.length; |
| 820 |
}; |
| 821 |
Document.prototype.getTextRange = function (range) { |
| 822 |
return this.getLinesForRange(range).join(this.getNewLineCharacter()); |
| 823 |
}; |
| 824 |
Document.prototype.getLinesForRange = function (range) { |
| 825 |
var lines; |
| 826 |
if (range.start.row === range.end.row) { |
| 827 |
lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)]; |
| 828 |
} |
| 829 |
else { |
| 830 |
lines = this.getLines(range.start.row, range.end.row); |
| 831 |
lines[0] = (lines[0] || "").substring(range.start.column); |
| 832 |
var l = lines.length - 1; |
| 833 |
if (range.end.row - range.start.row == l) |
| 834 |
lines[l] = lines[l].substring(0, range.end.column); |
| 835 |
} |
| 836 |
return lines; |
| 837 |
}; |
| 838 |
Document.prototype.insertLines = function (row, lines) { |
| 839 |
console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead."); |
| 840 |
return this.insertFullLines(row, lines); |
| 841 |
}; |
| 842 |
Document.prototype.removeLines = function (firstRow, lastRow) { |
| 843 |
console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead."); |
| 844 |
return this.removeFullLines(firstRow, lastRow); |
| 845 |
}; |
| 846 |
Document.prototype.insertNewLine = function (position) { |
| 847 |
console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead."); |
| 848 |
return this.insertMergedLines(position, ["", ""]); |
| 849 |
}; |
| 850 |
Document.prototype.insert = function (position, text) { |
| 851 |
if (this.getLength() <= 1) |
| 852 |
this.$detectNewLine(text); |
| 853 |
return this.insertMergedLines(position, this.$split(text)); |
| 854 |
}; |
| 855 |
Document.prototype.insertInLine = function (position, text) { |
| 856 |
var start = this.clippedPos(position.row, position.column); |
| 857 |
var end = this.pos(position.row, position.column + text.length); |
| 858 |
this.applyDelta({ |
| 859 |
start: start, |
| 860 |
end: end, |
| 861 |
action: "insert", |
| 862 |
lines: [text] |
| 863 |
}, true); |
| 864 |
return this.clonePos(end); |
| 865 |
}; |
| 866 |
Document.prototype.clippedPos = function (row, column) { |
| 867 |
var length = this.getLength(); |
| 868 |
if (row === undefined) { |
| 869 |
row = length; |
| 870 |
} |
| 871 |
else if (row < 0) { |
| 872 |
row = 0; |
| 873 |
} |
| 874 |
else if (row >= length) { |
| 875 |
row = length - 1; |
| 876 |
column = undefined; |
| 877 |
} |
| 878 |
var line = this.getLine(row); |
| 879 |
if (column == undefined) |
| 880 |
column = line.length; |
| 881 |
column = Math.min(Math.max(column, 0), line.length); |
| 882 |
return { row: row, column: column }; |
| 883 |
}; |
| 884 |
Document.prototype.clonePos = function (pos) { |
| 885 |
return { row: pos.row, column: pos.column }; |
| 886 |
}; |
| 887 |
Document.prototype.pos = function (row, column) { |
| 888 |
return { row: row, column: column }; |
| 889 |
}; |
| 890 |
Document.prototype.$clipPosition = function (position) { |
| 891 |
var length = this.getLength(); |
| 892 |
if (position.row >= length) { |
| 893 |
position.row = Math.max(0, length - 1); |
| 894 |
position.column = this.getLine(length - 1).length; |
| 895 |
} |
| 896 |
else { |
| 897 |
position.row = Math.max(0, position.row); |
| 898 |
position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length); |
| 899 |
} |
| 900 |
return position; |
| 901 |
}; |
| 902 |
Document.prototype.insertFullLines = function (row, lines) { |
| 903 |
row = Math.min(Math.max(row, 0), this.getLength()); |
| 904 |
var column = 0; |
| 905 |
if (row < this.getLength()) { |
| 906 |
lines = lines.concat([""]); |
| 907 |
column = 0; |
| 908 |
} |
| 909 |
else { |
| 910 |
lines = [""].concat(lines); |
| 911 |
row--; |
| 912 |
column = this.$lines[row].length; |
| 913 |
} |
| 914 |
this.insertMergedLines({ row: row, column: column }, lines); |
| 915 |
}; |
| 916 |
Document.prototype.insertMergedLines = function (position, lines) { |
| 917 |
var start = this.clippedPos(position.row, position.column); |
| 918 |
var end = { |
| 919 |
row: start.row + lines.length - 1, |
| 920 |
column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length |
| 921 |
}; |
| 922 |
this.applyDelta({ |
| 923 |
start: start, |
| 924 |
end: end, |
| 925 |
action: "insert", |
| 926 |
lines: lines |
| 927 |
}); |
| 928 |
return this.clonePos(end); |
| 929 |
}; |
| 930 |
Document.prototype.remove = function (range) { |
| 931 |
var start = this.clippedPos(range.start.row, range.start.column); |
| 932 |
var end = this.clippedPos(range.end.row, range.end.column); |
| 933 |
this.applyDelta({ |
| 934 |
start: start, |
| 935 |
end: end, |
| 936 |
action: "remove", |
| 937 |
lines: this.getLinesForRange({ start: start, end: end }) |
| 938 |
}); |
| 939 |
return this.clonePos(start); |
| 940 |
}; |
| 941 |
Document.prototype.removeInLine = function (row, startColumn, endColumn) { |
| 942 |
var start = this.clippedPos(row, startColumn); |
| 943 |
var end = this.clippedPos(row, endColumn); |
| 944 |
this.applyDelta({ |
| 945 |
start: start, |
| 946 |
end: end, |
| 947 |
action: "remove", |
| 948 |
lines: this.getLinesForRange({ start: start, end: end }) |
| 949 |
}, true); |
| 950 |
return this.clonePos(start); |
| 951 |
}; |
| 952 |
Document.prototype.removeFullLines = function (firstRow, lastRow) { |
| 953 |
firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1); |
| 954 |
lastRow = Math.min(Math.max(0, lastRow), this.getLength() - 1); |
| 955 |
var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0; |
| 956 |
var deleteLastNewLine = lastRow < this.getLength() - 1; |
| 957 |
var startRow = (deleteFirstNewLine ? firstRow - 1 : firstRow); |
| 958 |
var startCol = (deleteFirstNewLine ? this.getLine(startRow).length : 0); |
| 959 |
var endRow = (deleteLastNewLine ? lastRow + 1 : lastRow); |
| 960 |
var endCol = (deleteLastNewLine ? 0 : this.getLine(endRow).length); |
| 961 |
var range = new Range(startRow, startCol, endRow, endCol); |
| 962 |
var deletedLines = this.$lines.slice(firstRow, lastRow + 1); |
| 963 |
this.applyDelta({ |
| 964 |
start: range.start, |
| 965 |
end: range.end, |
| 966 |
action: "remove", |
| 967 |
lines: this.getLinesForRange(range) |
| 968 |
}); |
| 969 |
return deletedLines; |
| 970 |
}; |
| 971 |
Document.prototype.removeNewLine = function (row) { |
| 972 |
if (row < this.getLength() - 1 && row >= 0) { |
| 973 |
this.applyDelta({ |
| 974 |
start: this.pos(row, this.getLine(row).length), |
| 975 |
end: this.pos(row + 1, 0), |
| 976 |
action: "remove", |
| 977 |
lines: ["", ""] |
| 978 |
}); |
| 979 |
} |
| 980 |
}; |
| 981 |
Document.prototype.replace = function (range, text) { |
| 982 |
if (!(range instanceof Range)) |
| 983 |
range = Range.fromPoints(range.start, range.end); |
| 984 |
if (text.length === 0 && range.isEmpty()) |
| 985 |
return range.start; |
| 986 |
if (text == this.getTextRange(range)) |
| 987 |
return range.end; |
| 988 |
this.remove(range); |
| 989 |
var end; |
| 990 |
if (text) { |
| 991 |
end = this.insert(range.start, text); |
| 992 |
} |
| 993 |
else { |
| 994 |
end = range.start; |
| 995 |
} |
| 996 |
return end; |
| 997 |
}; |
| 998 |
Document.prototype.applyDeltas = function (deltas) { |
| 999 |
for (var i = 0; i < deltas.length; i++) { |
| 1000 |
this.applyDelta(deltas[i]); |
| 1001 |
} |
| 1002 |
}; |
| 1003 |
Document.prototype.revertDeltas = function (deltas) { |
| 1004 |
for (var i = deltas.length - 1; i >= 0; i--) { |
| 1005 |
this.revertDelta(deltas[i]); |
| 1006 |
} |
| 1007 |
}; |
| 1008 |
Document.prototype.applyDelta = function (delta, doNotValidate) { |
| 1009 |
var isInsert = delta.action == "insert"; |
| 1010 |
if (isInsert ? delta.lines.length <= 1 && !delta.lines[0] |
| 1011 |
: !Range.comparePoints(delta.start, delta.end)) { |
| 1012 |
return; |
| 1013 |
} |
| 1014 |
if (isInsert && delta.lines.length > 20000) { |
| 1015 |
this.$splitAndapplyLargeDelta(delta, 20000); |
| 1016 |
} |
| 1017 |
else { |
| 1018 |
applyDelta(this.$lines, delta, doNotValidate); |
| 1019 |
this._signal("change", delta); |
| 1020 |
} |
| 1021 |
}; |
| 1022 |
Document.prototype.$safeApplyDelta = function (delta) { |
| 1023 |
var docLength = this.$lines.length; |
| 1024 |
if (delta.action == "remove" && delta.start.row < docLength && delta.end.row < docLength |
| 1025 |
|| delta.action == "insert" && delta.start.row <= docLength) { |
| 1026 |
this.applyDelta(delta); |
| 1027 |
} |
| 1028 |
}; |
| 1029 |
Document.prototype.$splitAndapplyLargeDelta = function (delta, MAX) { |
| 1030 |
var lines = delta.lines; |
| 1031 |
var l = lines.length - MAX + 1; |
| 1032 |
var row = delta.start.row; |
| 1033 |
var column = delta.start.column; |
| 1034 |
for (var from = 0, to = 0; from < l; from = to) { |
| 1035 |
to += MAX - 1; |
| 1036 |
var chunk = lines.slice(from, to); |
| 1037 |
chunk.push(""); |
| 1038 |
this.applyDelta({ |
| 1039 |
start: this.pos(row + from, column), |
| 1040 |
end: this.pos(row + to, column = 0), |
| 1041 |
action: delta.action, |
| 1042 |
lines: chunk |
| 1043 |
}, true); |
| 1044 |
} |
| 1045 |
delta.lines = lines.slice(from); |
| 1046 |
delta.start.row = row + from; |
| 1047 |
delta.start.column = column; |
| 1048 |
this.applyDelta(delta, true); |
| 1049 |
}; |
| 1050 |
Document.prototype.revertDelta = function (delta) { |
| 1051 |
this.$safeApplyDelta({ |
| 1052 |
start: this.clonePos(delta.start), |
| 1053 |
end: this.clonePos(delta.end), |
| 1054 |
action: (delta.action == "insert" ? "remove" : "insert"), |
| 1055 |
lines: delta.lines.slice() |
| 1056 |
}); |
| 1057 |
}; |
| 1058 |
Document.prototype.indexToPosition = function (index, startRow) { |
| 1059 |
var lines = this.$lines || this.getAllLines(); |
| 1060 |
var newlineLength = this.getNewLineCharacter().length; |
| 1061 |
for (var i = startRow || 0, l = lines.length; i < l; i++) { |
| 1062 |
index -= lines[i].length + newlineLength; |
| 1063 |
if (index < 0) |
| 1064 |
return { row: i, column: index + lines[i].length + newlineLength }; |
| 1065 |
} |
| 1066 |
return { row: l - 1, column: index + lines[l - 1].length + newlineLength }; |
| 1067 |
}; |
| 1068 |
Document.prototype.positionToIndex = function (pos, startRow) { |
| 1069 |
var lines = this.$lines || this.getAllLines(); |
| 1070 |
var newlineLength = this.getNewLineCharacter().length; |
| 1071 |
var index = 0; |
| 1072 |
var row = Math.min(pos.row, lines.length); |
| 1073 |
for (var i = startRow || 0; i < row; ++i) |
| 1074 |
index += lines[i].length + newlineLength; |
| 1075 |
return index + pos.column; |
| 1076 |
}; |
| 1077 |
Document.prototype.$split = function (text) { |
| 1078 |
return text.split(/\r\n|\r|\n/); |
| 1079 |
}; |
| 1080 |
return Document; |
| 1081 |
}()); |
| 1082 |
Document.prototype.$autoNewLine = ""; |
| 1083 |
Document.prototype.$newLineMode = "auto"; |
| 1084 |
oop.implement(Document.prototype, EventEmitter); |
| 1085 |
exports.Document = Document; |
| 1086 |
|
| 1087 |
}); |
| 1088 |
|
| 1089 |
ace.define("ace/lib/deep_copy",[], function(require, exports, module){exports.deepCopy = function deepCopy(obj) { |
| 1090 |
if (typeof obj !== "object" || !obj) |
| 1091 |
return obj; |
| 1092 |
var copy; |
| 1093 |
if (Array.isArray(obj)) { |
| 1094 |
copy = []; |
| 1095 |
for (var key = 0; key < obj.length; key++) { |
| 1096 |
copy[key] = deepCopy(obj[key]); |
| 1097 |
} |
| 1098 |
return copy; |
| 1099 |
} |
| 1100 |
if (Object.prototype.toString.call(obj) !== "[object Object]") |
| 1101 |
return obj; |
| 1102 |
copy = {}; |
| 1103 |
for (var key in obj) |
| 1104 |
copy[key] = deepCopy(obj[key]); |
| 1105 |
return copy; |
| 1106 |
}; |
| 1107 |
|
| 1108 |
}); |
| 1109 |
|
| 1110 |
ace.define("ace/lib/lang",[], function(require, exports, module){"use strict"; |
| 1111 |
exports.last = function (a) { |
| 1112 |
return a[a.length - 1]; |
| 1113 |
}; |
| 1114 |
exports.stringReverse = function (string) { |
| 1115 |
return string.split("").reverse().join(""); |
| 1116 |
}; |
| 1117 |
exports.stringRepeat = function (string, count) { |
| 1118 |
var result = ''; |
| 1119 |
while (count > 0) { |
| 1120 |
if (count & 1) |
| 1121 |
result += string; |
| 1122 |
if (count >>= 1) |
| 1123 |
string += string; |
| 1124 |
} |
| 1125 |
return result; |
| 1126 |
}; |
| 1127 |
var trimBeginRegexp = /^\s\s*/; |
| 1128 |
var trimEndRegexp = /\s\s*$/; |
| 1129 |
exports.stringTrimLeft = function (string) { |
| 1130 |
return string.replace(trimBeginRegexp, ''); |
| 1131 |
}; |
| 1132 |
exports.stringTrimRight = function (string) { |
| 1133 |
return string.replace(trimEndRegexp, ''); |
| 1134 |
}; |
| 1135 |
exports.copyObject = function (obj) { |
| 1136 |
var copy = {}; |
| 1137 |
for (var key in obj) { |
| 1138 |
copy[key] = obj[key]; |
| 1139 |
} |
| 1140 |
return copy; |
| 1141 |
}; |
| 1142 |
exports.copyArray = function (array) { |
| 1143 |
var copy = []; |
| 1144 |
for (var i = 0, l = array.length; i < l; i++) { |
| 1145 |
if (array[i] && typeof array[i] == "object") |
| 1146 |
copy[i] = this.copyObject(array[i]); |
| 1147 |
else |
| 1148 |
copy[i] = array[i]; |
| 1149 |
} |
| 1150 |
return copy; |
| 1151 |
}; |
| 1152 |
exports.deepCopy = require("./deep_copy").deepCopy; |
| 1153 |
exports.arrayToMap = function (arr) { |
| 1154 |
var map = {}; |
| 1155 |
for (var i = 0; i < arr.length; i++) { |
| 1156 |
map[arr[i]] = 1; |
| 1157 |
} |
| 1158 |
return map; |
| 1159 |
}; |
| 1160 |
exports.createMap = function (props) { |
| 1161 |
var map = Object.create(null); |
| 1162 |
for (var i in props) { |
| 1163 |
map[i] = props[i]; |
| 1164 |
} |
| 1165 |
return map; |
| 1166 |
}; |
| 1167 |
exports.arrayRemove = function (array, value) { |
| 1168 |
for (var i = 0; i <= array.length; i++) { |
| 1169 |
if (value === array[i]) { |
| 1170 |
array.splice(i, 1); |
| 1171 |
} |
| 1172 |
} |
| 1173 |
}; |
| 1174 |
exports.escapeRegExp = function (str) { |
| 1175 |
return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1'); |
| 1176 |
}; |
| 1177 |
exports.escapeHTML = function (str) { |
| 1178 |
return ("" + str).replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<"); |
| 1179 |
}; |
| 1180 |
exports.getMatchOffsets = function (string, regExp) { |
| 1181 |
var matches = []; |
| 1182 |
string.replace(regExp, function (str) { |
| 1183 |
matches.push({ |
| 1184 |
offset: arguments[arguments.length - 2], |
| 1185 |
length: str.length |
| 1186 |
}); |
| 1187 |
}); |
| 1188 |
return matches; |
| 1189 |
}; |
| 1190 |
exports.deferredCall = function (fcn) { |
| 1191 |
var timer = null; |
| 1192 |
var callback = function () { |
| 1193 |
timer = null; |
| 1194 |
fcn(); |
| 1195 |
}; |
| 1196 |
var deferred = function (timeout) { |
| 1197 |
deferred.cancel(); |
| 1198 |
timer = setTimeout(callback, timeout || 0); |
| 1199 |
return deferred; |
| 1200 |
}; |
| 1201 |
deferred.schedule = deferred; |
| 1202 |
deferred.call = function () { |
| 1203 |
this.cancel(); |
| 1204 |
fcn(); |
| 1205 |
return deferred; |
| 1206 |
}; |
| 1207 |
deferred.cancel = function () { |
| 1208 |
clearTimeout(timer); |
| 1209 |
timer = null; |
| 1210 |
return deferred; |
| 1211 |
}; |
| 1212 |
deferred.isPending = function () { |
| 1213 |
return timer; |
| 1214 |
}; |
| 1215 |
return deferred; |
| 1216 |
}; |
| 1217 |
exports.delayedCall = function (fcn, defaultTimeout) { |
| 1218 |
var timer = null; |
| 1219 |
var callback = function () { |
| 1220 |
timer = null; |
| 1221 |
fcn(); |
| 1222 |
}; |
| 1223 |
var _self = function (timeout) { |
| 1224 |
if (timer == null) |
| 1225 |
timer = setTimeout(callback, timeout || defaultTimeout); |
| 1226 |
}; |
| 1227 |
_self.delay = function (timeout) { |
| 1228 |
timer && clearTimeout(timer); |
| 1229 |
timer = setTimeout(callback, timeout || defaultTimeout); |
| 1230 |
}; |
| 1231 |
_self.schedule = _self; |
| 1232 |
_self.call = function () { |
| 1233 |
this.cancel(); |
| 1234 |
fcn(); |
| 1235 |
}; |
| 1236 |
_self.cancel = function () { |
| 1237 |
timer && clearTimeout(timer); |
| 1238 |
timer = null; |
| 1239 |
}; |
| 1240 |
_self.isPending = function () { |
| 1241 |
return timer; |
| 1242 |
}; |
| 1243 |
return _self; |
| 1244 |
}; |
| 1245 |
exports.supportsLookbehind = function () { |
| 1246 |
try { |
| 1247 |
new RegExp('(?<=.)'); |
| 1248 |
} |
| 1249 |
catch (e) { |
| 1250 |
return false; |
| 1251 |
} |
| 1252 |
return true; |
| 1253 |
}; |
| 1254 |
exports.skipEmptyMatch = function (line, last, supportsUnicodeFlag) { |
| 1255 |
return supportsUnicodeFlag && line.codePointAt(last) > 0xffff ? 2 : 1; |
| 1256 |
}; |
| 1257 |
|
| 1258 |
}); |
| 1259 |
|
| 1260 |
ace.define("ace/worker/mirror",[], function(require, exports, module) { |
| 1261 |
"use strict"; |
| 1262 |
|
| 1263 |
var Document = require("../document").Document; |
| 1264 |
var lang = require("../lib/lang"); |
| 1265 |
|
| 1266 |
var Mirror = exports.Mirror = function(sender) { |
| 1267 |
this.sender = sender; |
| 1268 |
var doc = this.doc = new Document(""); |
| 1269 |
|
| 1270 |
var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this)); |
| 1271 |
|
| 1272 |
var _self = this; |
| 1273 |
sender.on("change", function(e) { |
| 1274 |
var data = e.data; |
| 1275 |
if (data[0].start) { |
| 1276 |
doc.applyDeltas(data); |
| 1277 |
} else { |
| 1278 |
for (var i = 0; i < data.length; i += 2) { |
| 1279 |
var d, err; |
| 1280 |
if (Array.isArray(data[i+1])) { |
| 1281 |
d = {action: "insert", start: data[i], lines: data[i+1]}; |
| 1282 |
} else { |
| 1283 |
d = {action: "remove", start: data[i], end: data[i+1]}; |
| 1284 |
} |
| 1285 |
|
| 1286 |
if ((d.action == "insert" ? d.start : d.end).row >= doc.$lines.length) { |
| 1287 |
err = new Error("Invalid delta"); |
| 1288 |
err.data = { |
| 1289 |
path: _self.$path, |
| 1290 |
linesLength: doc.$lines.length, |
| 1291 |
start: d.start, |
| 1292 |
end: d.end |
| 1293 |
}; |
| 1294 |
throw err; |
| 1295 |
} |
| 1296 |
|
| 1297 |
doc.applyDelta(d, true); |
| 1298 |
} |
| 1299 |
} |
| 1300 |
if (_self.$timeout) |
| 1301 |
return deferredUpdate.schedule(_self.$timeout); |
| 1302 |
_self.onUpdate(); |
| 1303 |
}); |
| 1304 |
}; |
| 1305 |
|
| 1306 |
(function() { |
| 1307 |
|
| 1308 |
this.$timeout = 500; |
| 1309 |
|
| 1310 |
this.setTimeout = function(timeout) { |
| 1311 |
this.$timeout = timeout; |
| 1312 |
}; |
| 1313 |
|
| 1314 |
this.setValue = function(value) { |
| 1315 |
this.doc.setValue(value); |
| 1316 |
this.deferredUpdate.schedule(this.$timeout); |
| 1317 |
}; |
| 1318 |
|
| 1319 |
this.getValue = function(callbackId) { |
| 1320 |
this.sender.callback(this.doc.getValue(), callbackId); |
| 1321 |
}; |
| 1322 |
|
| 1323 |
this.onUpdate = function() { |
| 1324 |
}; |
| 1325 |
|
| 1326 |
this.isPending = function() { |
| 1327 |
return this.deferredUpdate.isPending(); |
| 1328 |
}; |
| 1329 |
|
| 1330 |
}).call(Mirror.prototype); |
| 1331 |
|
| 1332 |
}); |
| 1333 |
|
| 1334 |
ace.define("ace/mode/yaml/yaml-lint",[], function(require, exports, module) { |
| 1335 |
var $build_deps$ = {require: require, exports: exports, module: module}; |
| 1336 |
exports = undefined; module = undefined; |
| 1337 |
function define(name, deps, m) { |
| 1338 |
if (typeof name == "function") { |
| 1339 |
m = name; deps = ["require", "exports", "module"]; name = $build_deps$.module.id |
| 1340 |
} |
| 1341 |
if (typeof name !== "string") { |
| 1342 |
m = deps; deps = name; name = $build_deps$.module.id |
| 1343 |
} |
| 1344 |
if (!m) { |
| 1345 |
m = deps; deps = []; |
| 1346 |
} |
| 1347 |
var ret = typeof m == "function" ? |
| 1348 |
m.apply($build_deps$.module, deps.map(function(n){return $build_deps$[n] || require(n)})) : m |
| 1349 |
if (ret != undefined) $build_deps$.module.exports = ret; |
| 1350 |
} |
| 1351 |
define.amd = true;(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f();}else if(typeof define==="function"&&define.amd){define([],f);}else{var g;if(typeof window!=="undefined"){g=window;}else if(typeof global!=="undefined"){g=global;}else if(typeof self!=="undefined"){g=self;}else{g=this;}g.lint = f();}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c=typeof require=="function"&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a;}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r);},p,p.exports,r,e,n,t);}return n[i].exports;}for(var u=typeof require=="function"&&require,i=0;i<t.length;i++)o(t[i]);return o;}return r;})()({1:[function(require,module,exports){ |
| 1352 |
|
| 1353 |
},{}],2:[function(require,module,exports){ |
| 1354 |
var fs = require('fs'); |
| 1355 |
var merge = require('lodash.merge'); |
| 1356 |
var yaml = require('js-yaml'); |
| 1357 |
|
| 1358 |
var DEFAULT_LINT_OPTION = { |
| 1359 |
schema: 'DEFAULT_SAFE_SCHEMA' |
| 1360 |
}; |
| 1361 |
|
| 1362 |
function lint(content, opts, cb) { |
| 1363 |
|
| 1364 |
var options = merge({}, DEFAULT_LINT_OPTION, opts); |
| 1365 |
try { |
| 1366 |
yaml.safeLoad(content, { |
| 1367 |
schema: yaml[options.schema] |
| 1368 |
}); |
| 1369 |
cb(); |
| 1370 |
} catch (e) { |
| 1371 |
cb(e); |
| 1372 |
} |
| 1373 |
} |
| 1374 |
|
| 1375 |
module.exports = { |
| 1376 |
lint: lint |
| 1377 |
}; |
| 1378 |
|
| 1379 |
},{"fs":1,"js-yaml":3,"lodash.merge":33}],3:[function(require,module,exports){ |
| 1380 |
'use strict'; |
| 1381 |
|
| 1382 |
|
| 1383 |
var yaml = require('./lib/js-yaml.js'); |
| 1384 |
|
| 1385 |
|
| 1386 |
module.exports = yaml; |
| 1387 |
|
| 1388 |
},{"./lib/js-yaml.js":4}],4:[function(require,module,exports){ |
| 1389 |
'use strict'; |
| 1390 |
|
| 1391 |
|
| 1392 |
var loader = require('./js-yaml/loader'); |
| 1393 |
var dumper = require('./js-yaml/dumper'); |
| 1394 |
|
| 1395 |
|
| 1396 |
function deprecated(name) { |
| 1397 |
return function () { |
| 1398 |
throw new Error('Function ' + name + ' is deprecated and cannot be used.'); |
| 1399 |
}; |
| 1400 |
} |
| 1401 |
|
| 1402 |
|
| 1403 |
module.exports.Type = require('./js-yaml/type'); |
| 1404 |
module.exports.Schema = require('./js-yaml/schema'); |
| 1405 |
module.exports.FAILSAFE_SCHEMA = require('./js-yaml/schema/failsafe'); |
| 1406 |
module.exports.JSON_SCHEMA = require('./js-yaml/schema/json'); |
| 1407 |
module.exports.CORE_SCHEMA = require('./js-yaml/schema/core'); |
| 1408 |
module.exports.DEFAULT_SAFE_SCHEMA = require('./js-yaml/schema/default_safe'); |
| 1409 |
module.exports.DEFAULT_FULL_SCHEMA = require('./js-yaml/schema/default_full'); |
| 1410 |
module.exports.load = loader.load; |
| 1411 |
module.exports.loadAll = loader.loadAll; |
| 1412 |
module.exports.safeLoad = loader.safeLoad; |
| 1413 |
module.exports.safeLoadAll = loader.safeLoadAll; |
| 1414 |
module.exports.dump = dumper.dump; |
| 1415 |
module.exports.safeDump = dumper.safeDump; |
| 1416 |
module.exports.YAMLException = require('./js-yaml/exception'); |
| 1417 |
module.exports.MINIMAL_SCHEMA = require('./js-yaml/schema/failsafe'); |
| 1418 |
module.exports.SAFE_SCHEMA = require('./js-yaml/schema/default_safe'); |
| 1419 |
module.exports.DEFAULT_SCHEMA = require('./js-yaml/schema/default_full'); |
| 1420 |
module.exports.scan = deprecated('scan'); |
| 1421 |
module.exports.parse = deprecated('parse'); |
| 1422 |
module.exports.compose = deprecated('compose'); |
| 1423 |
module.exports.addConstructor = deprecated('addConstructor'); |
| 1424 |
|
| 1425 |
},{"./js-yaml/dumper":6,"./js-yaml/exception":7,"./js-yaml/loader":8,"./js-yaml/schema":10,"./js-yaml/schema/core":11,"./js-yaml/schema/default_full":12,"./js-yaml/schema/default_safe":13,"./js-yaml/schema/failsafe":14,"./js-yaml/schema/json":15,"./js-yaml/type":16}],5:[function(require,module,exports){ |
| 1426 |
'use strict'; |
| 1427 |
|
| 1428 |
|
| 1429 |
function isNothing(subject) { |
| 1430 |
return (typeof subject === 'undefined') || (subject === null); |
| 1431 |
} |
| 1432 |
|
| 1433 |
|
| 1434 |
function isObject(subject) { |
| 1435 |
return (typeof subject === 'object') && (subject !== null); |
| 1436 |
} |
| 1437 |
|
| 1438 |
|
| 1439 |
function toArray(sequence) { |
| 1440 |
if (Array.isArray(sequence)) return sequence; |
| 1441 |
else if (isNothing(sequence)) return []; |
| 1442 |
|
| 1443 |
return [ sequence ]; |
| 1444 |
} |
| 1445 |
|
| 1446 |
|
| 1447 |
function extend(target, source) { |
| 1448 |
var index, length, key, sourceKeys; |
| 1449 |
|
| 1450 |
if (source) { |
| 1451 |
sourceKeys = Object.keys(source); |
| 1452 |
|
| 1453 |
for (index = 0, length = sourceKeys.length; index < length; index += 1) { |
| 1454 |
key = sourceKeys[index]; |
| 1455 |
target[key] = source[key]; |
| 1456 |
} |
| 1457 |
} |
| 1458 |
|
| 1459 |
return target; |
| 1460 |
} |
| 1461 |
|
| 1462 |
|
| 1463 |
function repeat(string, count) { |
| 1464 |
var result = '', cycle; |
| 1465 |
|
| 1466 |
for (cycle = 0; cycle < count; cycle += 1) { |
| 1467 |
result += string; |
| 1468 |
} |
| 1469 |
|
| 1470 |
return result; |
| 1471 |
} |
| 1472 |
|
| 1473 |
|
| 1474 |
function isNegativeZero(number) { |
| 1475 |
return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number); |
| 1476 |
} |
| 1477 |
|
| 1478 |
|
| 1479 |
module.exports.isNothing = isNothing; |
| 1480 |
module.exports.isObject = isObject; |
| 1481 |
module.exports.toArray = toArray; |
| 1482 |
module.exports.repeat = repeat; |
| 1483 |
module.exports.isNegativeZero = isNegativeZero; |
| 1484 |
module.exports.extend = extend; |
| 1485 |
|
| 1486 |
},{}],6:[function(require,module,exports){ |
| 1487 |
'use strict'; |
| 1488 |
|
| 1489 |
var common = require('./common'); |
| 1490 |
var YAMLException = require('./exception'); |
| 1491 |
var DEFAULT_FULL_SCHEMA = require('./schema/default_full'); |
| 1492 |
var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe'); |
| 1493 |
|
| 1494 |
var _toString = Object.prototype.toString; |
| 1495 |
var _hasOwnProperty = Object.prototype.hasOwnProperty; |
| 1496 |
|
| 1497 |
var CHAR_TAB = 0x09; |
| 1498 |
var CHAR_LINE_FEED = 0x0A; |
| 1499 |
var CHAR_SPACE = 0x20; |
| 1500 |
var CHAR_EXCLAMATION = 0x21; |
| 1501 |
var CHAR_DOUBLE_QUOTE = 0x22; |
| 1502 |
var CHAR_SHARP = 0x23; |
| 1503 |
var CHAR_PERCENT = 0x25; |
| 1504 |
var CHAR_AMPERSAND = 0x26; |
| 1505 |
var CHAR_SINGLE_QUOTE = 0x27; |
| 1506 |
var CHAR_ASTERISK = 0x2A; |
| 1507 |
var CHAR_COMMA = 0x2C; |
| 1508 |
var CHAR_MINUS = 0x2D; |
| 1509 |
var CHAR_COLON = 0x3A; |
| 1510 |
var CHAR_GREATER_THAN = 0x3E; |
| 1511 |
var CHAR_QUESTION = 0x3F; |
| 1512 |
var CHAR_COMMERCIAL_AT = 0x40; |
| 1513 |
var CHAR_LEFT_SQUARE_BRACKET = 0x5B; |
| 1514 |
var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; |
| 1515 |
var CHAR_GRAVE_ACCENT = 0x60; |
| 1516 |
var CHAR_LEFT_CURLY_BRACKET = 0x7B; |
| 1517 |
var CHAR_VERTICAL_LINE = 0x7C; |
| 1518 |
var CHAR_RIGHT_CURLY_BRACKET = 0x7D; |
| 1519 |
|
| 1520 |
var ESCAPE_SEQUENCES = {}; |
| 1521 |
|
| 1522 |
ESCAPE_SEQUENCES[0x00] = '\\0'; |
| 1523 |
ESCAPE_SEQUENCES[0x07] = '\\a'; |
| 1524 |
ESCAPE_SEQUENCES[0x08] = '\\b'; |
| 1525 |
ESCAPE_SEQUENCES[0x09] = '\\t'; |
| 1526 |
ESCAPE_SEQUENCES[0x0A] = '\\n'; |
| 1527 |
ESCAPE_SEQUENCES[0x0B] = '\\v'; |
| 1528 |
ESCAPE_SEQUENCES[0x0C] = '\\f'; |
| 1529 |
ESCAPE_SEQUENCES[0x0D] = '\\r'; |
| 1530 |
ESCAPE_SEQUENCES[0x1B] = '\\e'; |
| 1531 |
ESCAPE_SEQUENCES[0x22] = '\\"'; |
| 1532 |
ESCAPE_SEQUENCES[0x5C] = '\\\\'; |
| 1533 |
ESCAPE_SEQUENCES[0x85] = '\\N'; |
| 1534 |
ESCAPE_SEQUENCES[0xA0] = '\\_'; |
| 1535 |
ESCAPE_SEQUENCES[0x2028] = '\\L'; |
| 1536 |
ESCAPE_SEQUENCES[0x2029] = '\\P'; |
| 1537 |
|
| 1538 |
var DEPRECATED_BOOLEANS_SYNTAX = [ |
| 1539 |
'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', |
| 1540 |
'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' |
| 1541 |
]; |
| 1542 |
|
| 1543 |
function compileStyleMap(schema, map) { |
| 1544 |
var result, keys, index, length, tag, style, type; |
| 1545 |
|
| 1546 |
if (map === null) return {}; |
| 1547 |
|
| 1548 |
result = {}; |
| 1549 |
keys = Object.keys(map); |
| 1550 |
|
| 1551 |
for (index = 0, length = keys.length; index < length; index += 1) { |
| 1552 |
tag = keys[index]; |
| 1553 |
style = String(map[tag]); |
| 1554 |
|
| 1555 |
if (tag.slice(0, 2) === '!!') { |
| 1556 |
tag = 'tag:yaml.org,2002:' + tag.slice(2); |
| 1557 |
} |
| 1558 |
type = schema.compiledTypeMap['fallback'][tag]; |
| 1559 |
|
| 1560 |
if (type && _hasOwnProperty.call(type.styleAliases, style)) { |
| 1561 |
style = type.styleAliases[style]; |
| 1562 |
} |
| 1563 |
|
| 1564 |
result[tag] = style; |
| 1565 |
} |
| 1566 |
|
| 1567 |
return result; |
| 1568 |
} |
| 1569 |
|
| 1570 |
function encodeHex(character) { |
| 1571 |
var string, handle, length; |
| 1572 |
|
| 1573 |
string = character.toString(16).toUpperCase(); |
| 1574 |
|
| 1575 |
if (character <= 0xFF) { |
| 1576 |
handle = 'x'; |
| 1577 |
length = 2; |
| 1578 |
} else if (character <= 0xFFFF) { |
| 1579 |
handle = 'u'; |
| 1580 |
length = 4; |
| 1581 |
} else if (character <= 0xFFFFFFFF) { |
| 1582 |
handle = 'U'; |
| 1583 |
length = 8; |
| 1584 |
} else { |
| 1585 |
throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF'); |
| 1586 |
} |
| 1587 |
|
| 1588 |
return '\\' + handle + common.repeat('0', length - string.length) + string; |
| 1589 |
} |
| 1590 |
|
| 1591 |
function State(options) { |
| 1592 |
this.schema = options['schema'] || DEFAULT_FULL_SCHEMA; |
| 1593 |
this.indent = Math.max(1, (options['indent'] || 2)); |
| 1594 |
this.noArrayIndent = options['noArrayIndent'] || false; |
| 1595 |
this.skipInvalid = options['skipInvalid'] || false; |
| 1596 |
this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']); |
| 1597 |
this.styleMap = compileStyleMap(this.schema, options['styles'] || null); |
| 1598 |
this.sortKeys = options['sortKeys'] || false; |
| 1599 |
this.lineWidth = options['lineWidth'] || 80; |
| 1600 |
this.noRefs = options['noRefs'] || false; |
| 1601 |
this.noCompatMode = options['noCompatMode'] || false; |
| 1602 |
this.condenseFlow = options['condenseFlow'] || false; |
| 1603 |
|
| 1604 |
this.implicitTypes = this.schema.compiledImplicit; |
| 1605 |
this.explicitTypes = this.schema.compiledExplicit; |
| 1606 |
|
| 1607 |
this.tag = null; |
| 1608 |
this.result = ''; |
| 1609 |
|
| 1610 |
this.duplicates = []; |
| 1611 |
this.usedDuplicates = null; |
| 1612 |
} |
| 1613 |
function indentString(string, spaces) { |
| 1614 |
var ind = common.repeat(' ', spaces), |
| 1615 |
position = 0, |
| 1616 |
next = -1, |
| 1617 |
result = '', |
| 1618 |
line, |
| 1619 |
length = string.length; |
| 1620 |
|
| 1621 |
while (position < length) { |
| 1622 |
next = string.indexOf('\n', position); |
| 1623 |
if (next === -1) { |
| 1624 |
line = string.slice(position); |
| 1625 |
position = length; |
| 1626 |
} else { |
| 1627 |
line = string.slice(position, next + 1); |
| 1628 |
position = next + 1; |
| 1629 |
} |
| 1630 |
|
| 1631 |
if (line.length && line !== '\n') result += ind; |
| 1632 |
|
| 1633 |
result += line; |
| 1634 |
} |
| 1635 |
|
| 1636 |
return result; |
| 1637 |
} |
| 1638 |
|
| 1639 |
function generateNextLine(state, level) { |
| 1640 |
return '\n' + common.repeat(' ', state.indent * level); |
| 1641 |
} |
| 1642 |
|
| 1643 |
function testImplicitResolving(state, str) { |
| 1644 |
var index, length, type; |
| 1645 |
|
| 1646 |
for (index = 0, length = state.implicitTypes.length; index < length; index += 1) { |
| 1647 |
type = state.implicitTypes[index]; |
| 1648 |
|
| 1649 |
if (type.resolve(str)) { |
| 1650 |
return true; |
| 1651 |
} |
| 1652 |
} |
| 1653 |
|
| 1654 |
return false; |
| 1655 |
} |
| 1656 |
function isWhitespace(c) { |
| 1657 |
return c === CHAR_SPACE || c === CHAR_TAB; |
| 1658 |
} |
| 1659 |
function isPrintable(c) { |
| 1660 |
return (c >= 0x00020 && c <= 0x00007E) |
| 1661 |
|| ((c >= 0x000A1 && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029) |
| 1662 |
|| ((c >= 0x0E000 && c <= 0x00FFFD) && c !== 0xFEFF ) |
| 1663 |
|| (c >= 0x10000 && c <= 0x10FFFF); |
| 1664 |
} |
| 1665 |
function isPlainSafe(c) { |
| 1666 |
return isPrintable(c) && c !== 0xFEFF |
| 1667 |
&& c !== CHAR_COMMA |
| 1668 |
&& c !== CHAR_LEFT_SQUARE_BRACKET |
| 1669 |
&& c !== CHAR_RIGHT_SQUARE_BRACKET |
| 1670 |
&& c !== CHAR_LEFT_CURLY_BRACKET |
| 1671 |
&& c !== CHAR_RIGHT_CURLY_BRACKET |
| 1672 |
&& c !== CHAR_COLON |
| 1673 |
&& c !== CHAR_SHARP; |
| 1674 |
} |
| 1675 |
function isPlainSafeFirst(c) { |
| 1676 |
return isPrintable(c) && c !== 0xFEFF |
| 1677 |
&& !isWhitespace(c) |
| 1678 |
&& c !== CHAR_MINUS |
| 1679 |
&& c !== CHAR_QUESTION |
| 1680 |
&& c !== CHAR_COLON |
| 1681 |
&& c !== CHAR_COMMA |
| 1682 |
&& c !== CHAR_LEFT_SQUARE_BRACKET |
| 1683 |
&& c !== CHAR_RIGHT_SQUARE_BRACKET |
| 1684 |
&& c !== CHAR_LEFT_CURLY_BRACKET |
| 1685 |
&& c !== CHAR_RIGHT_CURLY_BRACKET |
| 1686 |
&& c !== CHAR_SHARP |
| 1687 |
&& c !== CHAR_AMPERSAND |
| 1688 |
&& c !== CHAR_ASTERISK |
| 1689 |
&& c !== CHAR_EXCLAMATION |
| 1690 |
&& c !== CHAR_VERTICAL_LINE |
| 1691 |
&& c !== CHAR_GREATER_THAN |
| 1692 |
&& c !== CHAR_SINGLE_QUOTE |
| 1693 |
&& c !== CHAR_DOUBLE_QUOTE |
| 1694 |
&& c !== CHAR_PERCENT |
| 1695 |
&& c !== CHAR_COMMERCIAL_AT |
| 1696 |
&& c !== CHAR_GRAVE_ACCENT; |
| 1697 |
} |
| 1698 |
function needIndentIndicator(string) { |
| 1699 |
var leadingSpaceRe = /^\n* /; |
| 1700 |
return leadingSpaceRe.test(string); |
| 1701 |
} |
| 1702 |
|
| 1703 |
var STYLE_PLAIN = 1, |
| 1704 |
STYLE_SINGLE = 2, |
| 1705 |
STYLE_LITERAL = 3, |
| 1706 |
STYLE_FOLDED = 4, |
| 1707 |
STYLE_DOUBLE = 5; |
| 1708 |
function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) { |
| 1709 |
var i; |
| 1710 |
var char; |
| 1711 |
var hasLineBreak = false; |
| 1712 |
var hasFoldableLine = false; |
| 1713 |
var shouldTrackWidth = lineWidth !== -1; |
| 1714 |
var previousLineBreak = -1; |
| 1715 |
var plain = isPlainSafeFirst(string.charCodeAt(0)) |
| 1716 |
&& !isWhitespace(string.charCodeAt(string.length - 1)); |
| 1717 |
|
| 1718 |
if (singleLineOnly) { |
| 1719 |
for (i = 0; i < string.length; i++) { |
| 1720 |
char = string.charCodeAt(i); |
| 1721 |
if (!isPrintable(char)) { |
| 1722 |
return STYLE_DOUBLE; |
| 1723 |
} |
| 1724 |
plain = plain && isPlainSafe(char); |
| 1725 |
} |
| 1726 |
} else { |
| 1727 |
for (i = 0; i < string.length; i++) { |
| 1728 |
char = string.charCodeAt(i); |
| 1729 |
if (char === CHAR_LINE_FEED) { |
| 1730 |
hasLineBreak = true; |
| 1731 |
if (shouldTrackWidth) { |
| 1732 |
hasFoldableLine = hasFoldableLine || |
| 1733 |
(i - previousLineBreak - 1 > lineWidth && |
| 1734 |
string[previousLineBreak + 1] !== ' '); |
| 1735 |
previousLineBreak = i; |
| 1736 |
} |
| 1737 |
} else if (!isPrintable(char)) { |
| 1738 |
return STYLE_DOUBLE; |
| 1739 |
} |
| 1740 |
plain = plain && isPlainSafe(char); |
| 1741 |
} |
| 1742 |
hasFoldableLine = hasFoldableLine || (shouldTrackWidth && |
| 1743 |
(i - previousLineBreak - 1 > lineWidth && |
| 1744 |
string[previousLineBreak + 1] !== ' ')); |
| 1745 |
} |
| 1746 |
if (!hasLineBreak && !hasFoldableLine) { |
| 1747 |
return plain && !testAmbiguousType(string) |
| 1748 |
? STYLE_PLAIN : STYLE_SINGLE; |
| 1749 |
} |
| 1750 |
if (indentPerLevel > 9 && needIndentIndicator(string)) { |
| 1751 |
return STYLE_DOUBLE; |
| 1752 |
} |
| 1753 |
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL; |
| 1754 |
} |
| 1755 |
function writeScalar(state, string, level, iskey) { |
| 1756 |
state.dump = (function () { |
| 1757 |
if (string.length === 0) { |
| 1758 |
return "''"; |
| 1759 |
} |
| 1760 |
if (!state.noCompatMode && |
| 1761 |
DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) { |
| 1762 |
return "'" + string + "'"; |
| 1763 |
} |
| 1764 |
|
| 1765 |
var indent = state.indent * Math.max(1, level); |
| 1766 |
var lineWidth = state.lineWidth === -1 |
| 1767 |
? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent); |
| 1768 |
var singleLineOnly = iskey |
| 1769 |
|| (state.flowLevel > -1 && level >= state.flowLevel); |
| 1770 |
function testAmbiguity(string) { |
| 1771 |
return testImplicitResolving(state, string); |
| 1772 |
} |
| 1773 |
|
| 1774 |
switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) { |
| 1775 |
case STYLE_PLAIN: |
| 1776 |
return string; |
| 1777 |
case STYLE_SINGLE: |
| 1778 |
return "'" + string.replace(/'/g, "''") + "'"; |
| 1779 |
case STYLE_LITERAL: |
| 1780 |
return '|' + blockHeader(string, state.indent) |
| 1781 |
+ dropEndingNewline(indentString(string, indent)); |
| 1782 |
case STYLE_FOLDED: |
| 1783 |
return '>' + blockHeader(string, state.indent) |
| 1784 |
+ dropEndingNewline(indentString(foldString(string, lineWidth), indent)); |
| 1785 |
case STYLE_DOUBLE: |
| 1786 |
return '"' + escapeString(string, lineWidth) + '"'; |
| 1787 |
default: |
| 1788 |
throw new YAMLException('impossible error: invalid scalar style'); |
| 1789 |
} |
| 1790 |
}()); |
| 1791 |
} |
| 1792 |
function blockHeader(string, indentPerLevel) { |
| 1793 |
var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : ''; |
| 1794 |
var clip = string[string.length - 1] === '\n'; |
| 1795 |
var keep = clip && (string[string.length - 2] === '\n' || string === '\n'); |
| 1796 |
var chomp = keep ? '+' : (clip ? '' : '-'); |
| 1797 |
|
| 1798 |
return indentIndicator + chomp + '\n'; |
| 1799 |
} |
| 1800 |
function dropEndingNewline(string) { |
| 1801 |
return string[string.length - 1] === '\n' ? string.slice(0, -1) : string; |
| 1802 |
} |
| 1803 |
function foldString(string, width) { |
| 1804 |
var lineRe = /(\n+)([^\n]*)/g; |
| 1805 |
var result = (function () { |
| 1806 |
var nextLF = string.indexOf('\n'); |
| 1807 |
nextLF = nextLF !== -1 ? nextLF : string.length; |
| 1808 |
lineRe.lastIndex = nextLF; |
| 1809 |
return foldLine(string.slice(0, nextLF), width); |
| 1810 |
}()); |
| 1811 |
var prevMoreIndented = string[0] === '\n' || string[0] === ' '; |
| 1812 |
var moreIndented; |
| 1813 |
var match; |
| 1814 |
while ((match = lineRe.exec(string))) { |
| 1815 |
var prefix = match[1], line = match[2]; |
| 1816 |
moreIndented = (line[0] === ' '); |
| 1817 |
result += prefix |
| 1818 |
+ (!prevMoreIndented && !moreIndented && line !== '' |
| 1819 |
? '\n' : '') |
| 1820 |
+ foldLine(line, width); |
| 1821 |
prevMoreIndented = moreIndented; |
| 1822 |
} |
| 1823 |
|
| 1824 |
return result; |
| 1825 |
} |
| 1826 |
function foldLine(line, width) { |
| 1827 |
if (line === '' || line[0] === ' ') return line; |
| 1828 |
var breakRe = / [^ ]/g; |
| 1829 |
var match; |
| 1830 |
var start = 0, end, curr = 0, next = 0; |
| 1831 |
var result = ''; |
| 1832 |
while ((match = breakRe.exec(line))) { |
| 1833 |
next = match.index; |
| 1834 |
if (next - start > width) { |
| 1835 |
end = (curr > start) ? curr : next; |
| 1836 |
result += '\n' + line.slice(start, end); |
| 1837 |
start = end + 1; |
| 1838 |
} |
| 1839 |
curr = next; |
| 1840 |
} |
| 1841 |
result += '\n'; |
| 1842 |
if (line.length - start > width && curr > start) { |
| 1843 |
result += line.slice(start, curr) + '\n' + line.slice(curr + 1); |
| 1844 |
} else { |
| 1845 |
result += line.slice(start); |
| 1846 |
} |
| 1847 |
|
| 1848 |
return result.slice(1); |
| 1849 |
} |
| 1850 |
function escapeString(string) { |
| 1851 |
var result = ''; |
| 1852 |
var char, nextChar; |
| 1853 |
var escapeSeq; |
| 1854 |
|
| 1855 |
for (var i = 0; i < string.length; i++) { |
| 1856 |
char = string.charCodeAt(i); |
| 1857 |
if (char >= 0xD800 && char <= 0xDBFF) { |
| 1858 |
nextChar = string.charCodeAt(i + 1); |
| 1859 |
if (nextChar >= 0xDC00 && nextChar <= 0xDFFF) { |
| 1860 |
result += encodeHex((char - 0xD800) * 0x400 + nextChar - 0xDC00 + 0x10000); |
| 1861 |
i++; continue; |
| 1862 |
} |
| 1863 |
} |
| 1864 |
escapeSeq = ESCAPE_SEQUENCES[char]; |
| 1865 |
result += !escapeSeq && isPrintable(char) |
| 1866 |
? string[i] |
| 1867 |
: escapeSeq || encodeHex(char); |
| 1868 |
} |
| 1869 |
|
| 1870 |
return result; |
| 1871 |
} |
| 1872 |
|
| 1873 |
function writeFlowSequence(state, level, object) { |
| 1874 |
var _result = '', |
| 1875 |
_tag = state.tag, |
| 1876 |
index, |
| 1877 |
length; |
| 1878 |
|
| 1879 |
for (index = 0, length = object.length; index < length; index += 1) { |
| 1880 |
if (writeNode(state, level, object[index], false, false)) { |
| 1881 |
if (index !== 0) _result += ',' + (!state.condenseFlow ? ' ' : ''); |
| 1882 |
_result += state.dump; |
| 1883 |
} |
| 1884 |
} |
| 1885 |
|
| 1886 |
state.tag = _tag; |
| 1887 |
state.dump = '[' + _result + ']'; |
| 1888 |
} |
| 1889 |
|
| 1890 |
function writeBlockSequence(state, level, object, compact) { |
| 1891 |
var _result = '', |
| 1892 |
_tag = state.tag, |
| 1893 |
index, |
| 1894 |
length; |
| 1895 |
|
| 1896 |
for (index = 0, length = object.length; index < length; index += 1) { |
| 1897 |
if (writeNode(state, level + 1, object[index], true, true)) { |
| 1898 |
if (!compact || index !== 0) { |
| 1899 |
_result += generateNextLine(state, level); |
| 1900 |
} |
| 1901 |
|
| 1902 |
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { |
| 1903 |
_result += '-'; |
| 1904 |
} else { |
| 1905 |
_result += '- '; |
| 1906 |
} |
| 1907 |
|
| 1908 |
_result += state.dump; |
| 1909 |
} |
| 1910 |
} |
| 1911 |
|
| 1912 |
state.tag = _tag; |
| 1913 |
state.dump = _result || '[]'; |
| 1914 |
} |
| 1915 |
|
| 1916 |
function writeFlowMapping(state, level, object) { |
| 1917 |
var _result = '', |
| 1918 |
_tag = state.tag, |
| 1919 |
objectKeyList = Object.keys(object), |
| 1920 |
index, |
| 1921 |
length, |
| 1922 |
objectKey, |
| 1923 |
objectValue, |
| 1924 |
pairBuffer; |
| 1925 |
|
| 1926 |
for (index = 0, length = objectKeyList.length; index < length; index += 1) { |
| 1927 |
pairBuffer = state.condenseFlow ? '"' : ''; |
| 1928 |
|
| 1929 |
if (index !== 0) pairBuffer += ', '; |
| 1930 |
|
| 1931 |
objectKey = objectKeyList[index]; |
| 1932 |
objectValue = object[objectKey]; |
| 1933 |
|
| 1934 |
if (!writeNode(state, level, objectKey, false, false)) { |
| 1935 |
continue; |
| 1936 |
} |
| 1937 |
|
| 1938 |
if (state.dump.length > 1024) pairBuffer += '? '; |
| 1939 |
|
| 1940 |
pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' '); |
| 1941 |
|
| 1942 |
if (!writeNode(state, level, objectValue, false, false)) { |
| 1943 |
continue; |
| 1944 |
} |
| 1945 |
|
| 1946 |
pairBuffer += state.dump; |
| 1947 |
_result += pairBuffer; |
| 1948 |
} |
| 1949 |
|
| 1950 |
state.tag = _tag; |
| 1951 |
state.dump = '{' + _result + '}'; |
| 1952 |
} |
| 1953 |
|
| 1954 |
function writeBlockMapping(state, level, object, compact) { |
| 1955 |
var _result = '', |
| 1956 |
_tag = state.tag, |
| 1957 |
objectKeyList = Object.keys(object), |
| 1958 |
index, |
| 1959 |
length, |
| 1960 |
objectKey, |
| 1961 |
objectValue, |
| 1962 |
explicitPair, |
| 1963 |
pairBuffer; |
| 1964 |
if (state.sortKeys === true) { |
| 1965 |
objectKeyList.sort(); |
| 1966 |
} else if (typeof state.sortKeys === 'function') { |
| 1967 |
objectKeyList.sort(state.sortKeys); |
| 1968 |
} else if (state.sortKeys) { |
| 1969 |
throw new YAMLException('sortKeys must be a boolean or a function'); |
| 1970 |
} |
| 1971 |
|
| 1972 |
for (index = 0, length = objectKeyList.length; index < length; index += 1) { |
| 1973 |
pairBuffer = ''; |
| 1974 |
|
| 1975 |
if (!compact || index !== 0) { |
| 1976 |
pairBuffer += generateNextLine(state, level); |
| 1977 |
} |
| 1978 |
|
| 1979 |
objectKey = objectKeyList[index]; |
| 1980 |
objectValue = object[objectKey]; |
| 1981 |
|
| 1982 |
if (!writeNode(state, level + 1, objectKey, true, true, true)) { |
| 1983 |
continue; |
| 1984 |
} |
| 1985 |
|
| 1986 |
explicitPair = (state.tag !== null && state.tag !== '?') || |
| 1987 |
(state.dump && state.dump.length > 1024); |
| 1988 |
|
| 1989 |
if (explicitPair) { |
| 1990 |
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { |
| 1991 |
pairBuffer += '?'; |
| 1992 |
} else { |
| 1993 |
pairBuffer += '? '; |
| 1994 |
} |
| 1995 |
} |
| 1996 |
|
| 1997 |
pairBuffer += state.dump; |
| 1998 |
|
| 1999 |
if (explicitPair) { |
| 2000 |
pairBuffer += generateNextLine(state, level); |
| 2001 |
} |
| 2002 |
|
| 2003 |
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) { |
| 2004 |
continue; |
| 2005 |
} |
| 2006 |
|
| 2007 |
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { |
| 2008 |
pairBuffer += ':'; |
| 2009 |
} else { |
| 2010 |
pairBuffer += ': '; |
| 2011 |
} |
| 2012 |
|
| 2013 |
pairBuffer += state.dump; |
| 2014 |
_result += pairBuffer; |
| 2015 |
} |
| 2016 |
|
| 2017 |
state.tag = _tag; |
| 2018 |
state.dump = _result || '{}'; |
| 2019 |
} |
| 2020 |
|
| 2021 |
function detectType(state, object, explicit) { |
| 2022 |
var _result, typeList, index, length, type, style; |
| 2023 |
|
| 2024 |
typeList = explicit ? state.explicitTypes : state.implicitTypes; |
| 2025 |
|
| 2026 |
for (index = 0, length = typeList.length; index < length; index += 1) { |
| 2027 |
type = typeList[index]; |
| 2028 |
|
| 2029 |
if ((type.instanceOf || type.predicate) && |
| 2030 |
(!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) && |
| 2031 |
(!type.predicate || type.predicate(object))) { |
| 2032 |
|
| 2033 |
state.tag = explicit ? type.tag : '?'; |
| 2034 |
|
| 2035 |
if (type.represent) { |
| 2036 |
style = state.styleMap[type.tag] || type.defaultStyle; |
| 2037 |
|
| 2038 |
if (_toString.call(type.represent) === '[object Function]') { |
| 2039 |
_result = type.represent(object, style); |
| 2040 |
} else if (_hasOwnProperty.call(type.represent, style)) { |
| 2041 |
_result = type.represent[style](object, style); |
| 2042 |
} else { |
| 2043 |
throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style'); |
| 2044 |
} |
| 2045 |
|
| 2046 |
state.dump = _result; |
| 2047 |
} |
| 2048 |
|
| 2049 |
return true; |
| 2050 |
} |
| 2051 |
} |
| 2052 |
|
| 2053 |
return false; |
| 2054 |
} |
| 2055 |
function writeNode(state, level, object, block, compact, iskey) { |
| 2056 |
state.tag = null; |
| 2057 |
state.dump = object; |
| 2058 |
|
| 2059 |
if (!detectType(state, object, false)) { |
| 2060 |
detectType(state, object, true); |
| 2061 |
} |
| 2062 |
|
| 2063 |
var type = _toString.call(state.dump); |
| 2064 |
|
| 2065 |
if (block) { |
| 2066 |
block = (state.flowLevel < 0 || state.flowLevel > level); |
| 2067 |
} |
| 2068 |
|
| 2069 |
var objectOrArray = type === '[object Object]' || type === '[object Array]', |
| 2070 |
duplicateIndex, |
| 2071 |
duplicate; |
| 2072 |
|
| 2073 |
if (objectOrArray) { |
| 2074 |
duplicateIndex = state.duplicates.indexOf(object); |
| 2075 |
duplicate = duplicateIndex !== -1; |
| 2076 |
} |
| 2077 |
|
| 2078 |
if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) { |
| 2079 |
compact = false; |
| 2080 |
} |
| 2081 |
|
| 2082 |
if (duplicate && state.usedDuplicates[duplicateIndex]) { |
| 2083 |
state.dump = '*ref_' + duplicateIndex; |
| 2084 |
} else { |
| 2085 |
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) { |
| 2086 |
state.usedDuplicates[duplicateIndex] = true; |
| 2087 |
} |
| 2088 |
if (type === '[object Object]') { |
| 2089 |
if (block && (Object.keys(state.dump).length !== 0)) { |
| 2090 |
writeBlockMapping(state, level, state.dump, compact); |
| 2091 |
if (duplicate) { |
| 2092 |
state.dump = '&ref_' + duplicateIndex + state.dump; |
| 2093 |
} |
| 2094 |
} else { |
| 2095 |
writeFlowMapping(state, level, state.dump); |
| 2096 |
if (duplicate) { |
| 2097 |
state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; |
| 2098 |
} |
| 2099 |
} |
| 2100 |
} else if (type === '[object Array]') { |
| 2101 |
var arrayLevel = (state.noArrayIndent && (level > 0)) ? level - 1 : level; |
| 2102 |
if (block && (state.dump.length !== 0)) { |
| 2103 |
writeBlockSequence(state, arrayLevel, state.dump, compact); |
| 2104 |
if (duplicate) { |
| 2105 |
state.dump = '&ref_' + duplicateIndex + state.dump; |
| 2106 |
} |
| 2107 |
} else { |
| 2108 |
writeFlowSequence(state, arrayLevel, state.dump); |
| 2109 |
if (duplicate) { |
| 2110 |
state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; |
| 2111 |
} |
| 2112 |
} |
| 2113 |
} else if (type === '[object String]') { |
| 2114 |
if (state.tag !== '?') { |
| 2115 |
writeScalar(state, state.dump, level, iskey); |
| 2116 |
} |
| 2117 |
} else { |
| 2118 |
if (state.skipInvalid) return false; |
| 2119 |
throw new YAMLException('unacceptable kind of an object to dump ' + type); |
| 2120 |
} |
| 2121 |
|
| 2122 |
if (state.tag !== null && state.tag !== '?') { |
| 2123 |
state.dump = '!<' + state.tag + '> ' + state.dump; |
| 2124 |
} |
| 2125 |
} |
| 2126 |
|
| 2127 |
return true; |
| 2128 |
} |
| 2129 |
|
| 2130 |
function getDuplicateReferences(object, state) { |
| 2131 |
var objects = [], |
| 2132 |
duplicatesIndexes = [], |
| 2133 |
index, |
| 2134 |
length; |
| 2135 |
|
| 2136 |
inspectNode(object, objects, duplicatesIndexes); |
| 2137 |
|
| 2138 |
for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) { |
| 2139 |
state.duplicates.push(objects[duplicatesIndexes[index]]); |
| 2140 |
} |
| 2141 |
state.usedDuplicates = new Array(length); |
| 2142 |
} |
| 2143 |
|
| 2144 |
function inspectNode(object, objects, duplicatesIndexes) { |
| 2145 |
var objectKeyList, |
| 2146 |
index, |
| 2147 |
length; |
| 2148 |
|
| 2149 |
if (object !== null && typeof object === 'object') { |
| 2150 |
index = objects.indexOf(object); |
| 2151 |
if (index !== -1) { |
| 2152 |
if (duplicatesIndexes.indexOf(index) === -1) { |
| 2153 |
duplicatesIndexes.push(index); |
| 2154 |
} |
| 2155 |
} else { |
| 2156 |
objects.push(object); |
| 2157 |
|
| 2158 |
if (Array.isArray(object)) { |
| 2159 |
for (index = 0, length = object.length; index < length; index += 1) { |
| 2160 |
inspectNode(object[index], objects, duplicatesIndexes); |
| 2161 |
} |
| 2162 |
} else { |
| 2163 |
objectKeyList = Object.keys(object); |
| 2164 |
|
| 2165 |
for (index = 0, length = objectKeyList.length; index < length; index += 1) { |
| 2166 |
inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes); |
| 2167 |
} |
| 2168 |
} |
| 2169 |
} |
| 2170 |
} |
| 2171 |
} |
| 2172 |
|
| 2173 |
function dump(input, options) { |
| 2174 |
options = options || {}; |
| 2175 |
|
| 2176 |
var state = new State(options); |
| 2177 |
|
| 2178 |
if (!state.noRefs) getDuplicateReferences(input, state); |
| 2179 |
|
| 2180 |
if (writeNode(state, 0, input, true, true)) return state.dump + '\n'; |
| 2181 |
|
| 2182 |
return ''; |
| 2183 |
} |
| 2184 |
|
| 2185 |
function safeDump(input, options) { |
| 2186 |
return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); |
| 2187 |
} |
| 2188 |
|
| 2189 |
module.exports.dump = dump; |
| 2190 |
module.exports.safeDump = safeDump; |
| 2191 |
|
| 2192 |
},{"./common":5,"./exception":7,"./schema/default_full":12,"./schema/default_safe":13}],7:[function(require,module,exports){ |
| 2193 |
'use strict'; |
| 2194 |
|
| 2195 |
function YAMLException(reason, mark) { |
| 2196 |
Error.call(this); |
| 2197 |
|
| 2198 |
this.name = 'YAMLException'; |
| 2199 |
this.reason = reason; |
| 2200 |
this.mark = mark; |
| 2201 |
this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : ''); |
| 2202 |
if (Error.captureStackTrace) { |
| 2203 |
Error.captureStackTrace(this, this.constructor); |
| 2204 |
} else { |
| 2205 |
this.stack = (new Error()).stack || ''; |
| 2206 |
} |
| 2207 |
} |
| 2208 |
YAMLException.prototype = Object.create(Error.prototype); |
| 2209 |
YAMLException.prototype.constructor = YAMLException; |
| 2210 |
|
| 2211 |
|
| 2212 |
YAMLException.prototype.toString = function toString(compact) { |
| 2213 |
var result = this.name + ': '; |
| 2214 |
|
| 2215 |
result += this.reason || '(unknown reason)'; |
| 2216 |
|
| 2217 |
if (!compact && this.mark) { |
| 2218 |
result += ' ' + this.mark.toString(); |
| 2219 |
} |
| 2220 |
|
| 2221 |
return result; |
| 2222 |
}; |
| 2223 |
|
| 2224 |
|
| 2225 |
module.exports = YAMLException; |
| 2226 |
|
| 2227 |
},{}],8:[function(require,module,exports){ |
| 2228 |
'use strict'; |
| 2229 |
|
| 2230 |
var common = require('./common'); |
| 2231 |
var YAMLException = require('./exception'); |
| 2232 |
var Mark = require('./mark'); |
| 2233 |
var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe'); |
| 2234 |
var DEFAULT_FULL_SCHEMA = require('./schema/default_full'); |
| 2235 |
|
| 2236 |
|
| 2237 |
var _hasOwnProperty = Object.prototype.hasOwnProperty; |
| 2238 |
|
| 2239 |
|
| 2240 |
var CONTEXT_FLOW_IN = 1; |
| 2241 |
var CONTEXT_FLOW_OUT = 2; |
| 2242 |
var CONTEXT_BLOCK_IN = 3; |
| 2243 |
var CONTEXT_BLOCK_OUT = 4; |
| 2244 |
|
| 2245 |
|
| 2246 |
var CHOMPING_CLIP = 1; |
| 2247 |
var CHOMPING_STRIP = 2; |
| 2248 |
var CHOMPING_KEEP = 3; |
| 2249 |
|
| 2250 |
|
| 2251 |
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; |
| 2252 |
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; |
| 2253 |
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; |
| 2254 |
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; |
| 2255 |
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; |
| 2256 |
|
| 2257 |
|
| 2258 |
function is_EOL(c) { |
| 2259 |
return (c === 0x0A) || (c === 0x0D); |
| 2260 |
} |
| 2261 |
|
| 2262 |
function is_WHITE_SPACE(c) { |
| 2263 |
return (c === 0x09) || (c === 0x20); |
| 2264 |
} |
| 2265 |
|
| 2266 |
function is_WS_OR_EOL(c) { |
| 2267 |
return (c === 0x09) || |
| 2268 |
(c === 0x20) || |
| 2269 |
(c === 0x0A) || |
| 2270 |
(c === 0x0D); |
| 2271 |
} |
| 2272 |
|
| 2273 |
function is_FLOW_INDICATOR(c) { |
| 2274 |
return c === 0x2C || |
| 2275 |
c === 0x5B || |
| 2276 |
c === 0x5D || |
| 2277 |
c === 0x7B || |
| 2278 |
c === 0x7D; |
| 2279 |
} |
| 2280 |
|
| 2281 |
function fromHexCode(c) { |
| 2282 |
var lc; |
| 2283 |
|
| 2284 |
if ((c >= 0x30) && (c <= 0x39)) { |
| 2285 |
return c - 0x30; |
| 2286 |
} |
| 2287 |
lc = c | 0x20; |
| 2288 |
|
| 2289 |
if ((lc >= 0x61) && (lc <= 0x66)) { |
| 2290 |
return lc - 0x61 + 10; |
| 2291 |
} |
| 2292 |
|
| 2293 |
return -1; |
| 2294 |
} |
| 2295 |
|
| 2296 |
function escapedHexLen(c) { |
| 2297 |
if (c === 0x78) { return 2; } |
| 2298 |
if (c === 0x75) { return 4; } |
| 2299 |
if (c === 0x55) { return 8; } |
| 2300 |
return 0; |
| 2301 |
} |
| 2302 |
|
| 2303 |
function fromDecimalCode(c) { |
| 2304 |
if ((c >= 0x30) && (c <= 0x39)) { |
| 2305 |
return c - 0x30; |
| 2306 |
} |
| 2307 |
|
| 2308 |
return -1; |
| 2309 |
} |
| 2310 |
|
| 2311 |
function simpleEscapeSequence(c) { |
| 2312 |
return (c === 0x30) ? '\x00' : |
| 2313 |
(c === 0x61) ? '\x07' : |
| 2314 |
(c === 0x62) ? '\x08' : |
| 2315 |
(c === 0x74) ? '\x09' : |
| 2316 |
(c === 0x09) ? '\x09' : |
| 2317 |
(c === 0x6E) ? '\x0A' : |
| 2318 |
(c === 0x76) ? '\x0B' : |
| 2319 |
(c === 0x66) ? '\x0C' : |
| 2320 |
(c === 0x72) ? '\x0D' : |
| 2321 |
(c === 0x65) ? '\x1B' : |
| 2322 |
(c === 0x20) ? ' ' : |
| 2323 |
(c === 0x22) ? '\x22' : |
| 2324 |
(c === 0x2F) ? '/' : |
| 2325 |
(c === 0x5C) ? '\x5C' : |
| 2326 |
(c === 0x4E) ? '\x85' : |
| 2327 |
(c === 0x5F) ? '\xA0' : |
| 2328 |
(c === 0x4C) ? '\u2028' : |
| 2329 |
(c === 0x50) ? '\u2029' : ''; |
| 2330 |
} |
| 2331 |
|
| 2332 |
function charFromCodepoint(c) { |
| 2333 |
if (c <= 0xFFFF) { |
| 2334 |
return String.fromCharCode(c); |
| 2335 |
} |
| 2336 |
return String.fromCharCode( |
| 2337 |
((c - 0x010000) >> 10) + 0xD800, |
| 2338 |
((c - 0x010000) & 0x03FF) + 0xDC00 |
| 2339 |
); |
| 2340 |
} |
| 2341 |
|
| 2342 |
var simpleEscapeCheck = new Array(256); |
| 2343 |
var simpleEscapeMap = new Array(256); |
| 2344 |
for (var i = 0; i < 256; i++) { |
| 2345 |
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0; |
| 2346 |
simpleEscapeMap[i] = simpleEscapeSequence(i); |
| 2347 |
} |
| 2348 |
|
| 2349 |
|
| 2350 |
function State(input, options) { |
| 2351 |
this.input = input; |
| 2352 |
|
| 2353 |
this.filename = options['filename'] || null; |
| 2354 |
this.schema = options['schema'] || DEFAULT_FULL_SCHEMA; |
| 2355 |
this.onWarning = options['onWarning'] || null; |
| 2356 |
this.legacy = options['legacy'] || false; |
| 2357 |
this.json = options['json'] || false; |
| 2358 |
this.listener = options['listener'] || null; |
| 2359 |
|
| 2360 |
this.implicitTypes = this.schema.compiledImplicit; |
| 2361 |
this.typeMap = this.schema.compiledTypeMap; |
| 2362 |
|
| 2363 |
this.length = input.length; |
| 2364 |
this.position = 0; |
| 2365 |
this.line = 0; |
| 2366 |
this.lineStart = 0; |
| 2367 |
this.lineIndent = 0; |
| 2368 |
|
| 2369 |
this.documents = []; |
| 2370 |
|
| 2371 |
} |
| 2372 |
|
| 2373 |
|
| 2374 |
function generateError(state, message) { |
| 2375 |
return new YAMLException( |
| 2376 |
message, |
| 2377 |
new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart))); |
| 2378 |
} |
| 2379 |
|
| 2380 |
function throwError(state, message) { |
| 2381 |
throw generateError(state, message); |
| 2382 |
} |
| 2383 |
|
| 2384 |
function throwWarning(state, message) { |
| 2385 |
if (state.onWarning) { |
| 2386 |
state.onWarning.call(null, generateError(state, message)); |
| 2387 |
} |
| 2388 |
} |
| 2389 |
|
| 2390 |
|
| 2391 |
var directiveHandlers = { |
| 2392 |
|
| 2393 |
YAML: function handleYamlDirective(state, name, args) { |
| 2394 |
|
| 2395 |
var match, major, minor; |
| 2396 |
|
| 2397 |
if (state.version !== null) { |
| 2398 |
throwError(state, 'duplication of %YAML directive'); |
| 2399 |
} |
| 2400 |
|
| 2401 |
if (args.length !== 1) { |
| 2402 |
throwError(state, 'YAML directive accepts exactly one argument'); |
| 2403 |
} |
| 2404 |
|
| 2405 |
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); |
| 2406 |
|
| 2407 |
if (match === null) { |
| 2408 |
throwError(state, 'ill-formed argument of the YAML directive'); |
| 2409 |
} |
| 2410 |
|
| 2411 |
major = parseInt(match[1], 10); |
| 2412 |
minor = parseInt(match[2], 10); |
| 2413 |
|
| 2414 |
if (major !== 1) { |
| 2415 |
throwError(state, 'unacceptable YAML version of the document'); |
| 2416 |
} |
| 2417 |
|
| 2418 |
state.version = args[0]; |
| 2419 |
state.checkLineBreaks = (minor < 2); |
| 2420 |
|
| 2421 |
if (minor !== 1 && minor !== 2) { |
| 2422 |
throwWarning(state, 'unsupported YAML version of the document'); |
| 2423 |
} |
| 2424 |
}, |
| 2425 |
|
| 2426 |
TAG: function handleTagDirective(state, name, args) { |
| 2427 |
|
| 2428 |
var handle, prefix; |
| 2429 |
|
| 2430 |
if (args.length !== 2) { |
| 2431 |
throwError(state, 'TAG directive accepts exactly two arguments'); |
| 2432 |
} |
| 2433 |
|
| 2434 |
handle = args[0]; |
| 2435 |
prefix = args[1]; |
| 2436 |
|
| 2437 |
if (!PATTERN_TAG_HANDLE.test(handle)) { |
| 2438 |
throwError(state, 'ill-formed tag handle (first argument) of the TAG directive'); |
| 2439 |
} |
| 2440 |
|
| 2441 |
if (_hasOwnProperty.call(state.tagMap, handle)) { |
| 2442 |
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle'); |
| 2443 |
} |
| 2444 |
|
| 2445 |
if (!PATTERN_TAG_URI.test(prefix)) { |
| 2446 |
throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive'); |
| 2447 |
} |
| 2448 |
|
| 2449 |
state.tagMap[handle] = prefix; |
| 2450 |
} |
| 2451 |
}; |
| 2452 |
|
| 2453 |
|
| 2454 |
function captureSegment(state, start, end, checkJson) { |
| 2455 |
var _position, _length, _character, _result; |
| 2456 |
|
| 2457 |
if (start < end) { |
| 2458 |
_result = state.input.slice(start, end); |
| 2459 |
|
| 2460 |
if (checkJson) { |
| 2461 |
for (_position = 0, _length = _result.length; _position < _length; _position += 1) { |
| 2462 |
_character = _result.charCodeAt(_position); |
| 2463 |
if (!(_character === 0x09 || |
| 2464 |
(_character >= 0x20 && _character <= 0x10FFFF))) { |
| 2465 |
throwError(state, 'expected valid JSON character'); |
| 2466 |
} |
| 2467 |
} |
| 2468 |
} else if (PATTERN_NON_PRINTABLE.test(_result)) { |
| 2469 |
throwError(state, 'the stream contains non-printable characters'); |
| 2470 |
} |
| 2471 |
|
| 2472 |
state.result += _result; |
| 2473 |
} |
| 2474 |
} |
| 2475 |
|
| 2476 |
function mergeMappings(state, destination, source, overridableKeys) { |
| 2477 |
var sourceKeys, key, index, quantity; |
| 2478 |
|
| 2479 |
if (!common.isObject(source)) { |
| 2480 |
throwError(state, 'cannot merge mappings; the provided source object is unacceptable'); |
| 2481 |
} |
| 2482 |
|
| 2483 |
sourceKeys = Object.keys(source); |
| 2484 |
|
| 2485 |
for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { |
| 2486 |
key = sourceKeys[index]; |
| 2487 |
|
| 2488 |
if (!_hasOwnProperty.call(destination, key)) { |
| 2489 |
destination[key] = source[key]; |
| 2490 |
overridableKeys[key] = true; |
| 2491 |
} |
| 2492 |
} |
| 2493 |
} |
| 2494 |
|
| 2495 |
function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) { |
| 2496 |
var index, quantity; |
| 2497 |
|
| 2498 |
keyNode = String(keyNode); |
| 2499 |
|
| 2500 |
if (_result === null) { |
| 2501 |
_result = {}; |
| 2502 |
} |
| 2503 |
|
| 2504 |
if (keyTag === 'tag:yaml.org,2002:merge') { |
| 2505 |
if (Array.isArray(valueNode)) { |
| 2506 |
for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { |
| 2507 |
mergeMappings(state, _result, valueNode[index], overridableKeys); |
| 2508 |
} |
| 2509 |
} else { |
| 2510 |
mergeMappings(state, _result, valueNode, overridableKeys); |
| 2511 |
} |
| 2512 |
} else { |
| 2513 |
if (!state.json && |
| 2514 |
!_hasOwnProperty.call(overridableKeys, keyNode) && |
| 2515 |
_hasOwnProperty.call(_result, keyNode)) { |
| 2516 |
state.line = startLine || state.line; |
| 2517 |
state.position = startPos || state.position; |
| 2518 |
throwError(state, 'duplicated mapping key'); |
| 2519 |
} |
| 2520 |
_result[keyNode] = valueNode; |
| 2521 |
delete overridableKeys[keyNode]; |
| 2522 |
} |
| 2523 |
|
| 2524 |
return _result; |
| 2525 |
} |
| 2526 |
|
| 2527 |
function readLineBreak(state) { |
| 2528 |
var ch; |
| 2529 |
|
| 2530 |
ch = state.input.charCodeAt(state.position); |
| 2531 |
|
| 2532 |
if (ch === 0x0A) { |
| 2533 |
state.position++; |
| 2534 |
} else if (ch === 0x0D) { |
| 2535 |
state.position++; |
| 2536 |
if (state.input.charCodeAt(state.position) === 0x0A) { |
| 2537 |
state.position++; |
| 2538 |
} |
| 2539 |
} else { |
| 2540 |
throwError(state, 'a line break is expected'); |
| 2541 |
} |
| 2542 |
|
| 2543 |
state.line += 1; |
| 2544 |
state.lineStart = state.position; |
| 2545 |
} |
| 2546 |
|
| 2547 |
function skipSeparationSpace(state, allowComments, checkIndent) { |
| 2548 |
var lineBreaks = 0, |
| 2549 |
ch = state.input.charCodeAt(state.position); |
| 2550 |
|
| 2551 |
while (ch !== 0) { |
| 2552 |
while (is_WHITE_SPACE(ch)) { |
| 2553 |
ch = state.input.charCodeAt(++state.position); |
| 2554 |
} |
| 2555 |
|
| 2556 |
if (allowComments && ch === 0x23) { |
| 2557 |
do { |
| 2558 |
ch = state.input.charCodeAt(++state.position); |
| 2559 |
} while (ch !== 0x0A && ch !== 0x0D && ch !== 0); |
| 2560 |
} |
| 2561 |
|
| 2562 |
if (is_EOL(ch)) { |
| 2563 |
readLineBreak(state); |
| 2564 |
|
| 2565 |
ch = state.input.charCodeAt(state.position); |
| 2566 |
lineBreaks++; |
| 2567 |
state.lineIndent = 0; |
| 2568 |
|
| 2569 |
while (ch === 0x20) { |
| 2570 |
state.lineIndent++; |
| 2571 |
ch = state.input.charCodeAt(++state.position); |
| 2572 |
} |
| 2573 |
} else { |
| 2574 |
break; |
| 2575 |
} |
| 2576 |
} |
| 2577 |
|
| 2578 |
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) { |
| 2579 |
throwWarning(state, 'deficient indentation'); |
| 2580 |
} |
| 2581 |
|
| 2582 |
return lineBreaks; |
| 2583 |
} |
| 2584 |
|
| 2585 |
function testDocumentSeparator(state) { |
| 2586 |
var _position = state.position, |
| 2587 |
ch; |
| 2588 |
|
| 2589 |
ch = state.input.charCodeAt(_position); |
| 2590 |
if ((ch === 0x2D || ch === 0x2E) && |
| 2591 |
ch === state.input.charCodeAt(_position + 1) && |
| 2592 |
ch === state.input.charCodeAt(_position + 2)) { |
| 2593 |
|
| 2594 |
_position += 3; |
| 2595 |
|
| 2596 |
ch = state.input.charCodeAt(_position); |
| 2597 |
|
| 2598 |
if (ch === 0 || is_WS_OR_EOL(ch)) { |
| 2599 |
return true; |
| 2600 |
} |
| 2601 |
} |
| 2602 |
|
| 2603 |
return false; |
| 2604 |
} |
| 2605 |
|
| 2606 |
function writeFoldedLines(state, count) { |
| 2607 |
if (count === 1) { |
| 2608 |
state.result += ' '; |
| 2609 |
} else if (count > 1) { |
| 2610 |
state.result += common.repeat('\n', count - 1); |
| 2611 |
} |
| 2612 |
} |
| 2613 |
|
| 2614 |
|
| 2615 |
function readPlainScalar(state, nodeIndent, withinFlowCollection) { |
| 2616 |
var preceding, |
| 2617 |
following, |
| 2618 |
captureStart, |
| 2619 |
captureEnd, |
| 2620 |
hasPendingContent, |
| 2621 |
_line, |
| 2622 |
_lineStart, |
| 2623 |
_lineIndent, |
| 2624 |
_kind = state.kind, |
| 2625 |
_result = state.result, |
| 2626 |
ch; |
| 2627 |
|
| 2628 |
ch = state.input.charCodeAt(state.position); |
| 2629 |
|
| 2630 |
if (is_WS_OR_EOL(ch) || |
| 2631 |
is_FLOW_INDICATOR(ch) || |
| 2632 |
ch === 0x23 || |
| 2633 |
ch === 0x26 || |
| 2634 |
ch === 0x2A || |
| 2635 |
ch === 0x21 || |
| 2636 |
ch === 0x7C || |
| 2637 |
ch === 0x3E || |
| 2638 |
ch === 0x27 || |
| 2639 |
ch === 0x22 || |
| 2640 |
ch === 0x25 || |
| 2641 |
ch === 0x40 || |
| 2642 |
ch === 0x60) { |
| 2643 |
return false; |
| 2644 |
} |
| 2645 |
|
| 2646 |
if (ch === 0x3F || ch === 0x2D) { |
| 2647 |
following = state.input.charCodeAt(state.position + 1); |
| 2648 |
|
| 2649 |
if (is_WS_OR_EOL(following) || |
| 2650 |
withinFlowCollection && is_FLOW_INDICATOR(following)) { |
| 2651 |
return false; |
| 2652 |
} |
| 2653 |
} |
| 2654 |
|
| 2655 |
state.kind = 'scalar'; |
| 2656 |
state.result = ''; |
| 2657 |
captureStart = captureEnd = state.position; |
| 2658 |
hasPendingContent = false; |
| 2659 |
|
| 2660 |
while (ch !== 0) { |
| 2661 |
if (ch === 0x3A) { |
| 2662 |
following = state.input.charCodeAt(state.position + 1); |
| 2663 |
|
| 2664 |
if (is_WS_OR_EOL(following) || |
| 2665 |
withinFlowCollection && is_FLOW_INDICATOR(following)) { |
| 2666 |
break; |
| 2667 |
} |
| 2668 |
|
| 2669 |
} else if (ch === 0x23) { |
| 2670 |
preceding = state.input.charCodeAt(state.position - 1); |
| 2671 |
|
| 2672 |
if (is_WS_OR_EOL(preceding)) { |
| 2673 |
break; |
| 2674 |
} |
| 2675 |
|
| 2676 |
} else if ((state.position === state.lineStart && testDocumentSeparator(state)) || |
| 2677 |
withinFlowCollection && is_FLOW_INDICATOR(ch)) { |
| 2678 |
break; |
| 2679 |
|
| 2680 |
} else if (is_EOL(ch)) { |
| 2681 |
_line = state.line; |
| 2682 |
_lineStart = state.lineStart; |
| 2683 |
_lineIndent = state.lineIndent; |
| 2684 |
skipSeparationSpace(state, false, -1); |
| 2685 |
|
| 2686 |
if (state.lineIndent >= nodeIndent) { |
| 2687 |
hasPendingContent = true; |
| 2688 |
ch = state.input.charCodeAt(state.position); |
| 2689 |
continue; |
| 2690 |
} else { |
| 2691 |
state.position = captureEnd; |
| 2692 |
state.line = _line; |
| 2693 |
state.lineStart = _lineStart; |
| 2694 |
state.lineIndent = _lineIndent; |
| 2695 |
break; |
| 2696 |
} |
| 2697 |
} |
| 2698 |
|
| 2699 |
if (hasPendingContent) { |
| 2700 |
captureSegment(state, captureStart, captureEnd, false); |
| 2701 |
writeFoldedLines(state, state.line - _line); |
| 2702 |
captureStart = captureEnd = state.position; |
| 2703 |
hasPendingContent = false; |
| 2704 |
} |
| 2705 |
|
| 2706 |
if (!is_WHITE_SPACE(ch)) { |
| 2707 |
captureEnd = state.position + 1; |
| 2708 |
} |
| 2709 |
|
| 2710 |
ch = state.input.charCodeAt(++state.position); |
| 2711 |
} |
| 2712 |
|
| 2713 |
captureSegment(state, captureStart, captureEnd, false); |
| 2714 |
|
| 2715 |
if (state.result) { |
| 2716 |
return true; |
| 2717 |
} |
| 2718 |
|
| 2719 |
state.kind = _kind; |
| 2720 |
state.result = _result; |
| 2721 |
return false; |
| 2722 |
} |
| 2723 |
|
| 2724 |
function readSingleQuotedScalar(state, nodeIndent) { |
| 2725 |
var ch, |
| 2726 |
captureStart, captureEnd; |
| 2727 |
|
| 2728 |
ch = state.input.charCodeAt(state.position); |
| 2729 |
|
| 2730 |
if (ch !== 0x27) { |
| 2731 |
return false; |
| 2732 |
} |
| 2733 |
|
| 2734 |
state.kind = 'scalar'; |
| 2735 |
state.result = ''; |
| 2736 |
state.position++; |
| 2737 |
captureStart = captureEnd = state.position; |
| 2738 |
|
| 2739 |
while ((ch = state.input.charCodeAt(state.position)) !== 0) { |
| 2740 |
if (ch === 0x27) { |
| 2741 |
captureSegment(state, captureStart, state.position, true); |
| 2742 |
ch = state.input.charCodeAt(++state.position); |
| 2743 |
|
| 2744 |
if (ch === 0x27) { |
| 2745 |
captureStart = state.position; |
| 2746 |
state.position++; |
| 2747 |
captureEnd = state.position; |
| 2748 |
} else { |
| 2749 |
return true; |
| 2750 |
} |
| 2751 |
|
| 2752 |
} else if (is_EOL(ch)) { |
| 2753 |
captureSegment(state, captureStart, captureEnd, true); |
| 2754 |
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); |
| 2755 |
captureStart = captureEnd = state.position; |
| 2756 |
|
| 2757 |
} else if (state.position === state.lineStart && testDocumentSeparator(state)) { |
| 2758 |
throwError(state, 'unexpected end of the document within a single quoted scalar'); |
| 2759 |
|
| 2760 |
} else { |
| 2761 |
state.position++; |
| 2762 |
captureEnd = state.position; |
| 2763 |
} |
| 2764 |
} |
| 2765 |
|
| 2766 |
throwError(state, 'unexpected end of the stream within a single quoted scalar'); |
| 2767 |
} |
| 2768 |
|
| 2769 |
function readDoubleQuotedScalar(state, nodeIndent) { |
| 2770 |
var captureStart, |
| 2771 |
captureEnd, |
| 2772 |
hexLength, |
| 2773 |
hexResult, |
| 2774 |
tmp, |
| 2775 |
ch; |
| 2776 |
|
| 2777 |
ch = state.input.charCodeAt(state.position); |
| 2778 |
|
| 2779 |
if (ch !== 0x22) { |
| 2780 |
return false; |
| 2781 |
} |
| 2782 |
|
| 2783 |
state.kind = 'scalar'; |
| 2784 |
state.result = ''; |
| 2785 |
state.position++; |
| 2786 |
captureStart = captureEnd = state.position; |
| 2787 |
|
| 2788 |
while ((ch = state.input.charCodeAt(state.position)) !== 0) { |
| 2789 |
if (ch === 0x22) { |
| 2790 |
captureSegment(state, captureStart, state.position, true); |
| 2791 |
state.position++; |
| 2792 |
return true; |
| 2793 |
|
| 2794 |
} else if (ch === 0x5C) { |
| 2795 |
captureSegment(state, captureStart, state.position, true); |
| 2796 |
ch = state.input.charCodeAt(++state.position); |
| 2797 |
|
| 2798 |
if (is_EOL(ch)) { |
| 2799 |
skipSeparationSpace(state, false, nodeIndent); |
| 2800 |
} else if (ch < 256 && simpleEscapeCheck[ch]) { |
| 2801 |
state.result += simpleEscapeMap[ch]; |
| 2802 |
state.position++; |
| 2803 |
|
| 2804 |
} else if ((tmp = escapedHexLen(ch)) > 0) { |
| 2805 |
hexLength = tmp; |
| 2806 |
hexResult = 0; |
| 2807 |
|
| 2808 |
for (; hexLength > 0; hexLength--) { |
| 2809 |
ch = state.input.charCodeAt(++state.position); |
| 2810 |
|
| 2811 |
if ((tmp = fromHexCode(ch)) >= 0) { |
| 2812 |
hexResult = (hexResult << 4) + tmp; |
| 2813 |
|
| 2814 |
} else { |
| 2815 |
throwError(state, 'expected hexadecimal character'); |
| 2816 |
} |
| 2817 |
} |
| 2818 |
|
| 2819 |
state.result += charFromCodepoint(hexResult); |
| 2820 |
|
| 2821 |
state.position++; |
| 2822 |
|
| 2823 |
} else { |
| 2824 |
throwError(state, 'unknown escape sequence'); |
| 2825 |
} |
| 2826 |
|
| 2827 |
captureStart = captureEnd = state.position; |
| 2828 |
|
| 2829 |
} else if (is_EOL(ch)) { |
| 2830 |
captureSegment(state, captureStart, captureEnd, true); |
| 2831 |
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); |
| 2832 |
captureStart = captureEnd = state.position; |
| 2833 |
|
| 2834 |
} else if (state.position === state.lineStart && testDocumentSeparator(state)) { |
| 2835 |
throwError(state, 'unexpected end of the document within a double quoted scalar'); |
| 2836 |
|
| 2837 |
} else { |
| 2838 |
state.position++; |
| 2839 |
captureEnd = state.position; |
| 2840 |
} |
| 2841 |
} |
| 2842 |
|
| 2843 |
throwError(state, 'unexpected end of the stream within a double quoted scalar'); |
| 2844 |
} |
| 2845 |
|
| 2846 |
function readFlowCollection(state, nodeIndent) { |
| 2847 |
var readNext = true, |
| 2848 |
_line, |
| 2849 |
_tag = state.tag, |
| 2850 |
_result, |
| 2851 |
_anchor = state.anchor, |
| 2852 |
following, |
| 2853 |
terminator, |
| 2854 |
isPair, |
| 2855 |
isExplicitPair, |
| 2856 |
isMapping, |
| 2857 |
overridableKeys = {}, |
| 2858 |
keyNode, |
| 2859 |
keyTag, |
| 2860 |
valueNode, |
| 2861 |
ch; |
| 2862 |
|
| 2863 |
ch = state.input.charCodeAt(state.position); |
| 2864 |
|
| 2865 |
if (ch === 0x5B) { |
| 2866 |
terminator = 0x5D; |
| 2867 |
isMapping = false; |
| 2868 |
_result = []; |
| 2869 |
} else if (ch === 0x7B) { |
| 2870 |
terminator = 0x7D; |
| 2871 |
isMapping = true; |
| 2872 |
_result = {}; |
| 2873 |
} else { |
| 2874 |
return false; |
| 2875 |
} |
| 2876 |
|
| 2877 |
if (state.anchor !== null) { |
| 2878 |
state.anchorMap[state.anchor] = _result; |
| 2879 |
} |
| 2880 |
|
| 2881 |
ch = state.input.charCodeAt(++state.position); |
| 2882 |
|
| 2883 |
while (ch !== 0) { |
| 2884 |
skipSeparationSpace(state, true, nodeIndent); |
| 2885 |
|
| 2886 |
ch = state.input.charCodeAt(state.position); |
| 2887 |
|
| 2888 |
if (ch === terminator) { |
| 2889 |
state.position++; |
| 2890 |
state.tag = _tag; |
| 2891 |
state.anchor = _anchor; |
| 2892 |
state.kind = isMapping ? 'mapping' : 'sequence'; |
| 2893 |
state.result = _result; |
| 2894 |
return true; |
| 2895 |
} else if (!readNext) { |
| 2896 |
throwError(state, 'missed comma between flow collection entries'); |
| 2897 |
} |
| 2898 |
|
| 2899 |
keyTag = keyNode = valueNode = null; |
| 2900 |
isPair = isExplicitPair = false; |
| 2901 |
|
| 2902 |
if (ch === 0x3F) { |
| 2903 |
following = state.input.charCodeAt(state.position + 1); |
| 2904 |
|
| 2905 |
if (is_WS_OR_EOL(following)) { |
| 2906 |
isPair = isExplicitPair = true; |
| 2907 |
state.position++; |
| 2908 |
skipSeparationSpace(state, true, nodeIndent); |
| 2909 |
} |
| 2910 |
} |
| 2911 |
|
| 2912 |
_line = state.line; |
| 2913 |
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); |
| 2914 |
keyTag = state.tag; |
| 2915 |
keyNode = state.result; |
| 2916 |
skipSeparationSpace(state, true, nodeIndent); |
| 2917 |
|
| 2918 |
ch = state.input.charCodeAt(state.position); |
| 2919 |
|
| 2920 |
if ((isExplicitPair || state.line === _line) && ch === 0x3A) { |
| 2921 |
isPair = true; |
| 2922 |
ch = state.input.charCodeAt(++state.position); |
| 2923 |
skipSeparationSpace(state, true, nodeIndent); |
| 2924 |
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); |
| 2925 |
valueNode = state.result; |
| 2926 |
} |
| 2927 |
|
| 2928 |
if (isMapping) { |
| 2929 |
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode); |
| 2930 |
} else if (isPair) { |
| 2931 |
_result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode)); |
| 2932 |
} else { |
| 2933 |
_result.push(keyNode); |
| 2934 |
} |
| 2935 |
|
| 2936 |
skipSeparationSpace(state, true, nodeIndent); |
| 2937 |
|
| 2938 |
ch = state.input.charCodeAt(state.position); |
| 2939 |
|
| 2940 |
if (ch === 0x2C) { |
| 2941 |
readNext = true; |
| 2942 |
ch = state.input.charCodeAt(++state.position); |
| 2943 |
} else { |
| 2944 |
readNext = false; |
| 2945 |
} |
| 2946 |
} |
| 2947 |
|
| 2948 |
throwError(state, 'unexpected end of the stream within a flow collection'); |
| 2949 |
} |
| 2950 |
|
| 2951 |
function readBlockScalar(state, nodeIndent) { |
| 2952 |
var captureStart, |
| 2953 |
folding, |
| 2954 |
chomping = CHOMPING_CLIP, |
| 2955 |
didReadContent = false, |
| 2956 |
detectedIndent = false, |
| 2957 |
textIndent = nodeIndent, |
| 2958 |
emptyLines = 0, |
| 2959 |
atMoreIndented = false, |
| 2960 |
tmp, |
| 2961 |
ch; |
| 2962 |
|
| 2963 |
ch = state.input.charCodeAt(state.position); |
| 2964 |
|
| 2965 |
if (ch === 0x7C) { |
| 2966 |
folding = false; |
| 2967 |
} else if (ch === 0x3E) { |
| 2968 |
folding = true; |
| 2969 |
} else { |
| 2970 |
return false; |
| 2971 |
} |
| 2972 |
|
| 2973 |
state.kind = 'scalar'; |
| 2974 |
state.result = ''; |
| 2975 |
|
| 2976 |
while (ch !== 0) { |
| 2977 |
ch = state.input.charCodeAt(++state.position); |
| 2978 |
|
| 2979 |
if (ch === 0x2B || ch === 0x2D) { |
| 2980 |
if (CHOMPING_CLIP === chomping) { |
| 2981 |
chomping = (ch === 0x2B) ? CHOMPING_KEEP : CHOMPING_STRIP; |
| 2982 |
} else { |
| 2983 |
throwError(state, 'repeat of a chomping mode identifier'); |
| 2984 |
} |
| 2985 |
|
| 2986 |
} else if ((tmp = fromDecimalCode(ch)) >= 0) { |
| 2987 |
if (tmp === 0) { |
| 2988 |
throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one'); |
| 2989 |
} else if (!detectedIndent) { |
| 2990 |
textIndent = nodeIndent + tmp - 1; |
| 2991 |
detectedIndent = true; |
| 2992 |
} else { |
| 2993 |
throwError(state, 'repeat of an indentation width identifier'); |
| 2994 |
} |
| 2995 |
|
| 2996 |
} else { |
| 2997 |
break; |
| 2998 |
} |
| 2999 |
} |
| 3000 |
|
| 3001 |
if (is_WHITE_SPACE(ch)) { |
| 3002 |
do { ch = state.input.charCodeAt(++state.position); } |
| 3003 |
while (is_WHITE_SPACE(ch)); |
| 3004 |
|
| 3005 |
if (ch === 0x23) { |
| 3006 |
do { ch = state.input.charCodeAt(++state.position); } |
| 3007 |
while (!is_EOL(ch) && (ch !== 0)); |
| 3008 |
} |
| 3009 |
} |
| 3010 |
|
| 3011 |
while (ch !== 0) { |
| 3012 |
readLineBreak(state); |
| 3013 |
state.lineIndent = 0; |
| 3014 |
|
| 3015 |
ch = state.input.charCodeAt(state.position); |
| 3016 |
|
| 3017 |
while ((!detectedIndent || state.lineIndent < textIndent) && |
| 3018 |
(ch === 0x20)) { |
| 3019 |
state.lineIndent++; |
| 3020 |
ch = state.input.charCodeAt(++state.position); |
| 3021 |
} |
| 3022 |
|
| 3023 |
if (!detectedIndent && state.lineIndent > textIndent) { |
| 3024 |
textIndent = state.lineIndent; |
| 3025 |
} |
| 3026 |
|
| 3027 |
if (is_EOL(ch)) { |
| 3028 |
emptyLines++; |
| 3029 |
continue; |
| 3030 |
} |
| 3031 |
if (state.lineIndent < textIndent) { |
| 3032 |
if (chomping === CHOMPING_KEEP) { |
| 3033 |
state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); |
| 3034 |
} else if (chomping === CHOMPING_CLIP) { |
| 3035 |
if (didReadContent) { |
| 3036 |
state.result += '\n'; |
| 3037 |
} |
| 3038 |
} |
| 3039 |
break; |
| 3040 |
} |
| 3041 |
if (folding) { |
| 3042 |
if (is_WHITE_SPACE(ch)) { |
| 3043 |
atMoreIndented = true; |
| 3044 |
state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); |
| 3045 |
} else if (atMoreIndented) { |
| 3046 |
atMoreIndented = false; |
| 3047 |
state.result += common.repeat('\n', emptyLines + 1); |
| 3048 |
} else if (emptyLines === 0) { |
| 3049 |
if (didReadContent) { |
| 3050 |
state.result += ' '; |
| 3051 |
} |
| 3052 |
} else { |
| 3053 |
state.result += common.repeat('\n', emptyLines); |
| 3054 |
} |
| 3055 |
} else { |
| 3056 |
state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); |
| 3057 |
} |
| 3058 |
|
| 3059 |
didReadContent = true; |
| 3060 |
detectedIndent = true; |
| 3061 |
emptyLines = 0; |
| 3062 |
captureStart = state.position; |
| 3063 |
|
| 3064 |
while (!is_EOL(ch) && (ch !== 0)) { |
| 3065 |
ch = state.input.charCodeAt(++state.position); |
| 3066 |
} |
| 3067 |
|
| 3068 |
captureSegment(state, captureStart, state.position, false); |
| 3069 |
} |
| 3070 |
|
| 3071 |
return true; |
| 3072 |
} |
| 3073 |
|
| 3074 |
function readBlockSequence(state, nodeIndent) { |
| 3075 |
var _line, |
| 3076 |
_tag = state.tag, |
| 3077 |
_anchor = state.anchor, |
| 3078 |
_result = [], |
| 3079 |
following, |
| 3080 |
detected = false, |
| 3081 |
ch; |
| 3082 |
|
| 3083 |
if (state.anchor !== null) { |
| 3084 |
state.anchorMap[state.anchor] = _result; |
| 3085 |
} |
| 3086 |
|
| 3087 |
ch = state.input.charCodeAt(state.position); |
| 3088 |
|
| 3089 |
while (ch !== 0) { |
| 3090 |
|
| 3091 |
if (ch !== 0x2D) { |
| 3092 |
break; |
| 3093 |
} |
| 3094 |
|
| 3095 |
following = state.input.charCodeAt(state.position + 1); |
| 3096 |
|
| 3097 |
if (!is_WS_OR_EOL(following)) { |
| 3098 |
break; |
| 3099 |
} |
| 3100 |
|
| 3101 |
detected = true; |
| 3102 |
state.position++; |
| 3103 |
|
| 3104 |
if (skipSeparationSpace(state, true, -1)) { |
| 3105 |
if (state.lineIndent <= nodeIndent) { |
| 3106 |
_result.push(null); |
| 3107 |
ch = state.input.charCodeAt(state.position); |
| 3108 |
continue; |
| 3109 |
} |
| 3110 |
} |
| 3111 |
|
| 3112 |
_line = state.line; |
| 3113 |
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true); |
| 3114 |
_result.push(state.result); |
| 3115 |
skipSeparationSpace(state, true, -1); |
| 3116 |
|
| 3117 |
ch = state.input.charCodeAt(state.position); |
| 3118 |
|
| 3119 |
if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { |
| 3120 |
throwError(state, 'bad indentation of a sequence entry'); |
| 3121 |
} else if (state.lineIndent < nodeIndent) { |
| 3122 |
break; |
| 3123 |
} |
| 3124 |
} |
| 3125 |
|
| 3126 |
if (detected) { |
| 3127 |
state.tag = _tag; |
| 3128 |
state.anchor = _anchor; |
| 3129 |
state.kind = 'sequence'; |
| 3130 |
state.result = _result; |
| 3131 |
return true; |
| 3132 |
} |
| 3133 |
return false; |
| 3134 |
} |
| 3135 |
|
| 3136 |
function readBlockMapping(state, nodeIndent, flowIndent) { |
| 3137 |
var following, |
| 3138 |
allowCompact, |
| 3139 |
_line, |
| 3140 |
_pos, |
| 3141 |
_tag = state.tag, |
| 3142 |
_anchor = state.anchor, |
| 3143 |
_result = {}, |
| 3144 |
overridableKeys = {}, |
| 3145 |
keyTag = null, |
| 3146 |
keyNode = null, |
| 3147 |
valueNode = null, |
| 3148 |
atExplicitKey = false, |
| 3149 |
detected = false, |
| 3150 |
ch; |
| 3151 |
|
| 3152 |
if (state.anchor !== null) { |
| 3153 |
state.anchorMap[state.anchor] = _result; |
| 3154 |
} |
| 3155 |
|
| 3156 |
ch = state.input.charCodeAt(state.position); |
| 3157 |
|
| 3158 |
while (ch !== 0) { |
| 3159 |
following = state.input.charCodeAt(state.position + 1); |
| 3160 |
_line = state.line; |
| 3161 |
_pos = state.position; |
| 3162 |
if ((ch === 0x3F || ch === 0x3A) && is_WS_OR_EOL(following)) { |
| 3163 |
|
| 3164 |
if (ch === 0x3F) { |
| 3165 |
if (atExplicitKey) { |
| 3166 |
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null); |
| 3167 |
keyTag = keyNode = valueNode = null; |
| 3168 |
} |
| 3169 |
|
| 3170 |
detected = true; |
| 3171 |
atExplicitKey = true; |
| 3172 |
allowCompact = true; |
| 3173 |
|
| 3174 |
} else if (atExplicitKey) { |
| 3175 |
atExplicitKey = false; |
| 3176 |
allowCompact = true; |
| 3177 |
|
| 3178 |
} else { |
| 3179 |
throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line'); |
| 3180 |
} |
| 3181 |
|
| 3182 |
state.position += 1; |
| 3183 |
ch = following; |
| 3184 |
} else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) { |
| 3185 |
|
| 3186 |
if (state.line === _line) { |
| 3187 |
ch = state.input.charCodeAt(state.position); |
| 3188 |
|
| 3189 |
while (is_WHITE_SPACE(ch)) { |
| 3190 |
ch = state.input.charCodeAt(++state.position); |
| 3191 |
} |
| 3192 |
|
| 3193 |
if (ch === 0x3A) { |
| 3194 |
ch = state.input.charCodeAt(++state.position); |
| 3195 |
|
| 3196 |
if (!is_WS_OR_EOL(ch)) { |
| 3197 |
throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping'); |
| 3198 |
} |
| 3199 |
|
| 3200 |
if (atExplicitKey) { |
| 3201 |
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null); |
| 3202 |
keyTag = keyNode = valueNode = null; |
| 3203 |
} |
| 3204 |
|
| 3205 |
detected = true; |
| 3206 |
atExplicitKey = false; |
| 3207 |
allowCompact = false; |
| 3208 |
keyTag = state.tag; |
| 3209 |
keyNode = state.result; |
| 3210 |
|
| 3211 |
} else if (detected) { |
| 3212 |
throwError(state, 'can not read an implicit mapping pair; a colon is missed'); |
| 3213 |
|
| 3214 |
} else { |
| 3215 |
state.tag = _tag; |
| 3216 |
state.anchor = _anchor; |
| 3217 |
return true; |
| 3218 |
} |
| 3219 |
|
| 3220 |
} else if (detected) { |
| 3221 |
throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key'); |
| 3222 |
|
| 3223 |
} else { |
| 3224 |
state.tag = _tag; |
| 3225 |
state.anchor = _anchor; |
| 3226 |
return true; |
| 3227 |
} |
| 3228 |
|
| 3229 |
} else { |
| 3230 |
break; |
| 3231 |
} |
| 3232 |
if (state.line === _line || state.lineIndent > nodeIndent) { |
| 3233 |
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { |
| 3234 |
if (atExplicitKey) { |
| 3235 |
keyNode = state.result; |
| 3236 |
} else { |
| 3237 |
valueNode = state.result; |
| 3238 |
} |
| 3239 |
} |
| 3240 |
|
| 3241 |
if (!atExplicitKey) { |
| 3242 |
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _pos); |
| 3243 |
keyTag = keyNode = valueNode = null; |
| 3244 |
} |
| 3245 |
|
| 3246 |
skipSeparationSpace(state, true, -1); |
| 3247 |
ch = state.input.charCodeAt(state.position); |
| 3248 |
} |
| 3249 |
|
| 3250 |
if (state.lineIndent > nodeIndent && (ch !== 0)) { |
| 3251 |
throwError(state, 'bad indentation of a mapping entry'); |
| 3252 |
} else if (state.lineIndent < nodeIndent) { |
| 3253 |
break; |
| 3254 |
} |
| 3255 |
} |
| 3256 |
if (atExplicitKey) { |
| 3257 |
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null); |
| 3258 |
} |
| 3259 |
if (detected) { |
| 3260 |
state.tag = _tag; |
| 3261 |
state.anchor = _anchor; |
| 3262 |
state.kind = 'mapping'; |
| 3263 |
state.result = _result; |
| 3264 |
} |
| 3265 |
|
| 3266 |
return detected; |
| 3267 |
} |
| 3268 |
|
| 3269 |
function readTagProperty(state) { |
| 3270 |
var _position, |
| 3271 |
isVerbatim = false, |
| 3272 |
isNamed = false, |
| 3273 |
tagHandle, |
| 3274 |
tagName, |
| 3275 |
ch; |
| 3276 |
|
| 3277 |
ch = state.input.charCodeAt(state.position); |
| 3278 |
|
| 3279 |
if (ch !== 0x21) return false; |
| 3280 |
|
| 3281 |
if (state.tag !== null) { |
| 3282 |
throwError(state, 'duplication of a tag property'); |
| 3283 |
} |
| 3284 |
|
| 3285 |
ch = state.input.charCodeAt(++state.position); |
| 3286 |
|
| 3287 |
if (ch === 0x3C) { |
| 3288 |
isVerbatim = true; |
| 3289 |
ch = state.input.charCodeAt(++state.position); |
| 3290 |
|
| 3291 |
} else if (ch === 0x21) { |
| 3292 |
isNamed = true; |
| 3293 |
tagHandle = '!!'; |
| 3294 |
ch = state.input.charCodeAt(++state.position); |
| 3295 |
|
| 3296 |
} else { |
| 3297 |
tagHandle = '!'; |
| 3298 |
} |
| 3299 |
|
| 3300 |
_position = state.position; |
| 3301 |
|
| 3302 |
if (isVerbatim) { |
| 3303 |
do { ch = state.input.charCodeAt(++state.position); } |
| 3304 |
while (ch !== 0 && ch !== 0x3E); |
| 3305 |
|
| 3306 |
if (state.position < state.length) { |
| 3307 |
tagName = state.input.slice(_position, state.position); |
| 3308 |
ch = state.input.charCodeAt(++state.position); |
| 3309 |
} else { |
| 3310 |
throwError(state, 'unexpected end of the stream within a verbatim tag'); |
| 3311 |
} |
| 3312 |
} else { |
| 3313 |
while (ch !== 0 && !is_WS_OR_EOL(ch)) { |
| 3314 |
|
| 3315 |
if (ch === 0x21) { |
| 3316 |
if (!isNamed) { |
| 3317 |
tagHandle = state.input.slice(_position - 1, state.position + 1); |
| 3318 |
|
| 3319 |
if (!PATTERN_TAG_HANDLE.test(tagHandle)) { |
| 3320 |
throwError(state, 'named tag handle cannot contain such characters'); |
| 3321 |
} |
| 3322 |
|
| 3323 |
isNamed = true; |
| 3324 |
_position = state.position + 1; |
| 3325 |
} else { |
| 3326 |
throwError(state, 'tag suffix cannot contain exclamation marks'); |
| 3327 |
} |
| 3328 |
} |
| 3329 |
|
| 3330 |
ch = state.input.charCodeAt(++state.position); |
| 3331 |
} |
| 3332 |
|
| 3333 |
tagName = state.input.slice(_position, state.position); |
| 3334 |
|
| 3335 |
if (PATTERN_FLOW_INDICATORS.test(tagName)) { |
| 3336 |
throwError(state, 'tag suffix cannot contain flow indicator characters'); |
| 3337 |
} |
| 3338 |
} |
| 3339 |
|
| 3340 |
if (tagName && !PATTERN_TAG_URI.test(tagName)) { |
| 3341 |
throwError(state, 'tag name cannot contain such characters: ' + tagName); |
| 3342 |
} |
| 3343 |
|
| 3344 |
if (isVerbatim) { |
| 3345 |
state.tag = tagName; |
| 3346 |
|
| 3347 |
} else if (_hasOwnProperty.call(state.tagMap, tagHandle)) { |
| 3348 |
state.tag = state.tagMap[tagHandle] + tagName; |
| 3349 |
|
| 3350 |
} else if (tagHandle === '!') { |
| 3351 |
state.tag = '!' + tagName; |
| 3352 |
|
| 3353 |
} else if (tagHandle === '!!') { |
| 3354 |
state.tag = 'tag:yaml.org,2002:' + tagName; |
| 3355 |
|
| 3356 |
} else { |
| 3357 |
throwError(state, 'undeclared tag handle "' + tagHandle + '"'); |
| 3358 |
} |
| 3359 |
|
| 3360 |
return true; |
| 3361 |
} |
| 3362 |
|
| 3363 |
function readAnchorProperty(state) { |
| 3364 |
var _position, |
| 3365 |
ch; |
| 3366 |
|
| 3367 |
ch = state.input.charCodeAt(state.position); |
| 3368 |
|
| 3369 |
if (ch !== 0x26) return false; |
| 3370 |
|
| 3371 |
if (state.anchor !== null) { |
| 3372 |
throwError(state, 'duplication of an anchor property'); |
| 3373 |
} |
| 3374 |
|
| 3375 |
ch = state.input.charCodeAt(++state.position); |
| 3376 |
_position = state.position; |
| 3377 |
|
| 3378 |
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { |
| 3379 |
ch = state.input.charCodeAt(++state.position); |
| 3380 |
} |
| 3381 |
|
| 3382 |
if (state.position === _position) { |
| 3383 |
throwError(state, 'name of an anchor node must contain at least one character'); |
| 3384 |
} |
| 3385 |
|
| 3386 |
state.anchor = state.input.slice(_position, state.position); |
| 3387 |
return true; |
| 3388 |
} |
| 3389 |
|
| 3390 |
function readAlias(state) { |
| 3391 |
var _position, alias, |
| 3392 |
ch; |
| 3393 |
|
| 3394 |
ch = state.input.charCodeAt(state.position); |
| 3395 |
|
| 3396 |
if (ch !== 0x2A) return false; |
| 3397 |
|
| 3398 |
ch = state.input.charCodeAt(++state.position); |
| 3399 |
_position = state.position; |
| 3400 |
|
| 3401 |
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { |
| 3402 |
ch = state.input.charCodeAt(++state.position); |
| 3403 |
} |
| 3404 |
|
| 3405 |
if (state.position === _position) { |
| 3406 |
throwError(state, 'name of an alias node must contain at least one character'); |
| 3407 |
} |
| 3408 |
|
| 3409 |
alias = state.input.slice(_position, state.position); |
| 3410 |
|
| 3411 |
if (!state.anchorMap.hasOwnProperty(alias)) { |
| 3412 |
throwError(state, 'unidentified alias "' + alias + '"'); |
| 3413 |
} |
| 3414 |
|
| 3415 |
state.result = state.anchorMap[alias]; |
| 3416 |
skipSeparationSpace(state, true, -1); |
| 3417 |
return true; |
| 3418 |
} |
| 3419 |
|
| 3420 |
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) { |
| 3421 |
var allowBlockStyles, |
| 3422 |
allowBlockScalars, |
| 3423 |
allowBlockCollections, |
| 3424 |
indentStatus = 1, |
| 3425 |
atNewLine = false, |
| 3426 |
hasContent = false, |
| 3427 |
typeIndex, |
| 3428 |
typeQuantity, |
| 3429 |
type, |
| 3430 |
flowIndent, |
| 3431 |
blockIndent; |
| 3432 |
|
| 3433 |
if (state.listener !== null) { |
| 3434 |
state.listener('open', state); |
| 3435 |
} |
| 3436 |
|
| 3437 |
state.tag = null; |
| 3438 |
state.anchor = null; |
| 3439 |
state.kind = null; |
| 3440 |
state.result = null; |
| 3441 |
|
| 3442 |
allowBlockStyles = allowBlockScalars = allowBlockCollections = |
| 3443 |
CONTEXT_BLOCK_OUT === nodeContext || |
| 3444 |
CONTEXT_BLOCK_IN === nodeContext; |
| 3445 |
|
| 3446 |
if (allowToSeek) { |
| 3447 |
if (skipSeparationSpace(state, true, -1)) { |
| 3448 |
atNewLine = true; |
| 3449 |
|
| 3450 |
if (state.lineIndent > parentIndent) { |
| 3451 |
indentStatus = 1; |
| 3452 |
} else if (state.lineIndent === parentIndent) { |
| 3453 |
indentStatus = 0; |
| 3454 |
} else if (state.lineIndent < parentIndent) { |
| 3455 |
indentStatus = -1; |
| 3456 |
} |
| 3457 |
} |
| 3458 |
} |
| 3459 |
|
| 3460 |
if (indentStatus === 1) { |
| 3461 |
while (readTagProperty(state) || readAnchorProperty(state)) { |
| 3462 |
if (skipSeparationSpace(state, true, -1)) { |
| 3463 |
atNewLine = true; |
| 3464 |
allowBlockCollections = allowBlockStyles; |
| 3465 |
|
| 3466 |
if (state.lineIndent > parentIndent) { |
| 3467 |
indentStatus = 1; |
| 3468 |
} else if (state.lineIndent === parentIndent) { |
| 3469 |
indentStatus = 0; |
| 3470 |
} else if (state.lineIndent < parentIndent) { |
| 3471 |
indentStatus = -1; |
| 3472 |
} |
| 3473 |
} else { |
| 3474 |
allowBlockCollections = false; |
| 3475 |
} |
| 3476 |
} |
| 3477 |
} |
| 3478 |
|
| 3479 |
if (allowBlockCollections) { |
| 3480 |
allowBlockCollections = atNewLine || allowCompact; |
| 3481 |
} |
| 3482 |
|
| 3483 |
if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { |
| 3484 |
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { |
| 3485 |
flowIndent = parentIndent; |
| 3486 |
} else { |
| 3487 |
flowIndent = parentIndent + 1; |
| 3488 |
} |
| 3489 |
|
| 3490 |
blockIndent = state.position - state.lineStart; |
| 3491 |
|
| 3492 |
if (indentStatus === 1) { |
| 3493 |
if (allowBlockCollections && |
| 3494 |
(readBlockSequence(state, blockIndent) || |
| 3495 |
readBlockMapping(state, blockIndent, flowIndent)) || |
| 3496 |
readFlowCollection(state, flowIndent)) { |
| 3497 |
hasContent = true; |
| 3498 |
} else { |
| 3499 |
if ((allowBlockScalars && readBlockScalar(state, flowIndent)) || |
| 3500 |
readSingleQuotedScalar(state, flowIndent) || |
| 3501 |
readDoubleQuotedScalar(state, flowIndent)) { |
| 3502 |
hasContent = true; |
| 3503 |
|
| 3504 |
} else if (readAlias(state)) { |
| 3505 |
hasContent = true; |
| 3506 |
|
| 3507 |
if (state.tag !== null || state.anchor !== null) { |
| 3508 |
throwError(state, 'alias node should not have any properties'); |
| 3509 |
} |
| 3510 |
|
| 3511 |
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { |
| 3512 |
hasContent = true; |
| 3513 |
|
| 3514 |
if (state.tag === null) { |
| 3515 |
state.tag = '?'; |
| 3516 |
} |
| 3517 |
} |
| 3518 |
|
| 3519 |
if (state.anchor !== null) { |
| 3520 |
state.anchorMap[state.anchor] = state.result; |
| 3521 |
} |
| 3522 |
} |
| 3523 |
} else if (indentStatus === 0) { |
| 3524 |
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent); |
| 3525 |
} |
| 3526 |
} |
| 3527 |
|
| 3528 |
if (state.tag !== null && state.tag !== '!') { |
| 3529 |
if (state.tag === '?') { |
| 3530 |
for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { |
| 3531 |
type = state.implicitTypes[typeIndex]; |
| 3532 |
|
| 3533 |
if (type.resolve(state.result)) { |
| 3534 |
state.result = type.construct(state.result); |
| 3535 |
state.tag = type.tag; |
| 3536 |
if (state.anchor !== null) { |
| 3537 |
state.anchorMap[state.anchor] = state.result; |
| 3538 |
} |
| 3539 |
break; |
| 3540 |
} |
| 3541 |
} |
| 3542 |
} else if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) { |
| 3543 |
type = state.typeMap[state.kind || 'fallback'][state.tag]; |
| 3544 |
|
| 3545 |
if (state.result !== null && type.kind !== state.kind) { |
| 3546 |
throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"'); |
| 3547 |
} |
| 3548 |
|
| 3549 |
if (!type.resolve(state.result)) { |
| 3550 |
throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag'); |
| 3551 |
} else { |
| 3552 |
state.result = type.construct(state.result); |
| 3553 |
if (state.anchor !== null) { |
| 3554 |
state.anchorMap[state.anchor] = state.result; |
| 3555 |
} |
| 3556 |
} |
| 3557 |
} else { |
| 3558 |
throwError(state, 'unknown tag !<' + state.tag + '>'); |
| 3559 |
} |
| 3560 |
} |
| 3561 |
|
| 3562 |
if (state.listener !== null) { |
| 3563 |
state.listener('close', state); |
| 3564 |
} |
| 3565 |
return state.tag !== null || state.anchor !== null || hasContent; |
| 3566 |
} |
| 3567 |
|
| 3568 |
function readDocument(state) { |
| 3569 |
var documentStart = state.position, |
| 3570 |
_position, |
| 3571 |
directiveName, |
| 3572 |
directiveArgs, |
| 3573 |
hasDirectives = false, |
| 3574 |
ch; |
| 3575 |
|
| 3576 |
state.version = null; |
| 3577 |
state.checkLineBreaks = state.legacy; |
| 3578 |
state.tagMap = {}; |
| 3579 |
state.anchorMap = {}; |
| 3580 |
|
| 3581 |
while ((ch = state.input.charCodeAt(state.position)) !== 0) { |
| 3582 |
skipSeparationSpace(state, true, -1); |
| 3583 |
|
| 3584 |
ch = state.input.charCodeAt(state.position); |
| 3585 |
|
| 3586 |
if (state.lineIndent > 0 || ch !== 0x25) { |
| 3587 |
break; |
| 3588 |
} |
| 3589 |
|
| 3590 |
hasDirectives = true; |
| 3591 |
ch = state.input.charCodeAt(++state.position); |
| 3592 |
_position = state.position; |
| 3593 |
|
| 3594 |
while (ch !== 0 && !is_WS_OR_EOL(ch)) { |
| 3595 |
ch = state.input.charCodeAt(++state.position); |
| 3596 |
} |
| 3597 |
|
| 3598 |
directiveName = state.input.slice(_position, state.position); |
| 3599 |
directiveArgs = []; |
| 3600 |
|
| 3601 |
if (directiveName.length < 1) { |
| 3602 |
throwError(state, 'directive name must not be less than one character in length'); |
| 3603 |
} |
| 3604 |
|
| 3605 |
while (ch !== 0) { |
| 3606 |
while (is_WHITE_SPACE(ch)) { |
| 3607 |
ch = state.input.charCodeAt(++state.position); |
| 3608 |
} |
| 3609 |
|
| 3610 |
if (ch === 0x23) { |
| 3611 |
do { ch = state.input.charCodeAt(++state.position); } |
| 3612 |
while (ch !== 0 && !is_EOL(ch)); |
| 3613 |
break; |
| 3614 |
} |
| 3615 |
|
| 3616 |
if (is_EOL(ch)) break; |
| 3617 |
|
| 3618 |
_position = state.position; |
| 3619 |
|
| 3620 |
while (ch !== 0 && !is_WS_OR_EOL(ch)) { |
| 3621 |
ch = state.input.charCodeAt(++state.position); |
| 3622 |
} |
| 3623 |
|
| 3624 |
directiveArgs.push(state.input.slice(_position, state.position)); |
| 3625 |
} |
| 3626 |
|
| 3627 |
if (ch !== 0) readLineBreak(state); |
| 3628 |
|
| 3629 |
if (_hasOwnProperty.call(directiveHandlers, directiveName)) { |
| 3630 |
directiveHandlers[directiveName](state, directiveName, directiveArgs); |
| 3631 |
} else { |
| 3632 |
throwWarning(state, 'unknown document directive "' + directiveName + '"'); |
| 3633 |
} |
| 3634 |
} |
| 3635 |
|
| 3636 |
skipSeparationSpace(state, true, -1); |
| 3637 |
|
| 3638 |
if (state.lineIndent === 0 && |
| 3639 |
state.input.charCodeAt(state.position) === 0x2D && |
| 3640 |
state.input.charCodeAt(state.position + 1) === 0x2D && |
| 3641 |
state.input.charCodeAt(state.position + 2) === 0x2D) { |
| 3642 |
state.position += 3; |
| 3643 |
skipSeparationSpace(state, true, -1); |
| 3644 |
|
| 3645 |
} else if (hasDirectives) { |
| 3646 |
throwError(state, 'directives end mark is expected'); |
| 3647 |
} |
| 3648 |
|
| 3649 |
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); |
| 3650 |
skipSeparationSpace(state, true, -1); |
| 3651 |
|
| 3652 |
if (state.checkLineBreaks && |
| 3653 |
PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) { |
| 3654 |
throwWarning(state, 'non-ASCII line breaks are interpreted as content'); |
| 3655 |
} |
| 3656 |
|
| 3657 |
state.documents.push(state.result); |
| 3658 |
|
| 3659 |
if (state.position === state.lineStart && testDocumentSeparator(state)) { |
| 3660 |
|
| 3661 |
if (state.input.charCodeAt(state.position) === 0x2E) { |
| 3662 |
state.position += 3; |
| 3663 |
skipSeparationSpace(state, true, -1); |
| 3664 |
} |
| 3665 |
return; |
| 3666 |
} |
| 3667 |
|
| 3668 |
if (state.position < (state.length - 1)) { |
| 3669 |
throwError(state, 'end of the stream or a document separator is expected'); |
| 3670 |
} else { |
| 3671 |
return; |
| 3672 |
} |
| 3673 |
} |
| 3674 |
|
| 3675 |
|
| 3676 |
function loadDocuments(input, options) { |
| 3677 |
input = String(input); |
| 3678 |
options = options || {}; |
| 3679 |
|
| 3680 |
if (input.length !== 0) { |
| 3681 |
if (input.charCodeAt(input.length - 1) !== 0x0A && |
| 3682 |
input.charCodeAt(input.length - 1) !== 0x0D) { |
| 3683 |
input += '\n'; |
| 3684 |
} |
| 3685 |
if (input.charCodeAt(0) === 0xFEFF) { |
| 3686 |
input = input.slice(1); |
| 3687 |
} |
| 3688 |
} |
| 3689 |
|
| 3690 |
var state = new State(input, options); |
| 3691 |
state.input += '\0'; |
| 3692 |
|
| 3693 |
while (state.input.charCodeAt(state.position) === 0x20) { |
| 3694 |
state.lineIndent += 1; |
| 3695 |
state.position += 1; |
| 3696 |
} |
| 3697 |
|
| 3698 |
while (state.position < (state.length - 1)) { |
| 3699 |
readDocument(state); |
| 3700 |
} |
| 3701 |
|
| 3702 |
return state.documents; |
| 3703 |
} |
| 3704 |
|
| 3705 |
|
| 3706 |
function loadAll(input, iterator, options) { |
| 3707 |
var documents = loadDocuments(input, options), index, length; |
| 3708 |
|
| 3709 |
if (typeof iterator !== 'function') { |
| 3710 |
return documents; |
| 3711 |
} |
| 3712 |
|
| 3713 |
for (index = 0, length = documents.length; index < length; index += 1) { |
| 3714 |
iterator(documents[index]); |
| 3715 |
} |
| 3716 |
} |
| 3717 |
|
| 3718 |
|
| 3719 |
function load(input, options) { |
| 3720 |
var documents = loadDocuments(input, options); |
| 3721 |
|
| 3722 |
if (documents.length === 0) { |
| 3723 |
return undefined; |
| 3724 |
} else if (documents.length === 1) { |
| 3725 |
return documents[0]; |
| 3726 |
} |
| 3727 |
throw new YAMLException('expected a single document in the stream, but found more'); |
| 3728 |
} |
| 3729 |
|
| 3730 |
|
| 3731 |
function safeLoadAll(input, output, options) { |
| 3732 |
if (typeof output === 'function') { |
| 3733 |
loadAll(input, output, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); |
| 3734 |
} else { |
| 3735 |
return loadAll(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); |
| 3736 |
} |
| 3737 |
} |
| 3738 |
|
| 3739 |
|
| 3740 |
function safeLoad(input, options) { |
| 3741 |
return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); |
| 3742 |
} |
| 3743 |
|
| 3744 |
|
| 3745 |
module.exports.loadAll = loadAll; |
| 3746 |
module.exports.load = load; |
| 3747 |
module.exports.safeLoadAll = safeLoadAll; |
| 3748 |
module.exports.safeLoad = safeLoad; |
| 3749 |
|
| 3750 |
},{"./common":5,"./exception":7,"./mark":9,"./schema/default_full":12,"./schema/default_safe":13}],9:[function(require,module,exports){ |
| 3751 |
'use strict'; |
| 3752 |
|
| 3753 |
|
| 3754 |
var common = require('./common'); |
| 3755 |
|
| 3756 |
|
| 3757 |
function Mark(name, buffer, position, line, column) { |
| 3758 |
this.name = name; |
| 3759 |
this.buffer = buffer; |
| 3760 |
this.position = position; |
| 3761 |
this.line = line; |
| 3762 |
this.column = column; |
| 3763 |
} |
| 3764 |
|
| 3765 |
|
| 3766 |
Mark.prototype.getSnippet = function getSnippet(indent, maxLength) { |
| 3767 |
var head, start, tail, end, snippet; |
| 3768 |
|
| 3769 |
if (!this.buffer) return null; |
| 3770 |
|
| 3771 |
indent = indent || 4; |
| 3772 |
maxLength = maxLength || 75; |
| 3773 |
|
| 3774 |
head = ''; |
| 3775 |
start = this.position; |
| 3776 |
|
| 3777 |
while (start > 0 && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1)) === -1) { |
| 3778 |
start -= 1; |
| 3779 |
if (this.position - start > (maxLength / 2 - 1)) { |
| 3780 |
head = ' ... '; |
| 3781 |
start += 5; |
| 3782 |
break; |
| 3783 |
} |
| 3784 |
} |
| 3785 |
|
| 3786 |
tail = ''; |
| 3787 |
end = this.position; |
| 3788 |
|
| 3789 |
while (end < this.buffer.length && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end)) === -1) { |
| 3790 |
end += 1; |
| 3791 |
if (end - this.position > (maxLength / 2 - 1)) { |
| 3792 |
tail = ' ... '; |
| 3793 |
end -= 5; |
| 3794 |
break; |
| 3795 |
} |
| 3796 |
} |
| 3797 |
|
| 3798 |
snippet = this.buffer.slice(start, end); |
| 3799 |
|
| 3800 |
return common.repeat(' ', indent) + head + snippet + tail + '\n' + |
| 3801 |
common.repeat(' ', indent + this.position - start + head.length) + '^'; |
| 3802 |
}; |
| 3803 |
|
| 3804 |
|
| 3805 |
Mark.prototype.toString = function toString(compact) { |
| 3806 |
var snippet, where = ''; |
| 3807 |
|
| 3808 |
if (this.name) { |
| 3809 |
where += 'in "' + this.name + '" '; |
| 3810 |
} |
| 3811 |
|
| 3812 |
where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1); |
| 3813 |
|
| 3814 |
if (!compact) { |
| 3815 |
snippet = this.getSnippet(); |
| 3816 |
|
| 3817 |
if (snippet) { |
| 3818 |
where += ':\n' + snippet; |
| 3819 |
} |
| 3820 |
} |
| 3821 |
|
| 3822 |
return where; |
| 3823 |
}; |
| 3824 |
|
| 3825 |
|
| 3826 |
module.exports = Mark; |
| 3827 |
|
| 3828 |
},{"./common":5}],10:[function(require,module,exports){ |
| 3829 |
'use strict'; |
| 3830 |
|
| 3831 |
var common = require('./common'); |
| 3832 |
var YAMLException = require('./exception'); |
| 3833 |
var Type = require('./type'); |
| 3834 |
|
| 3835 |
|
| 3836 |
function compileList(schema, name, result) { |
| 3837 |
var exclude = []; |
| 3838 |
|
| 3839 |
schema.include.forEach(function (includedSchema) { |
| 3840 |
result = compileList(includedSchema, name, result); |
| 3841 |
}); |
| 3842 |
|
| 3843 |
schema[name].forEach(function (currentType) { |
| 3844 |
result.forEach(function (previousType, previousIndex) { |
| 3845 |
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) { |
| 3846 |
exclude.push(previousIndex); |
| 3847 |
} |
| 3848 |
}); |
| 3849 |
|
| 3850 |
result.push(currentType); |
| 3851 |
}); |
| 3852 |
|
| 3853 |
return result.filter(function (type, index) { |
| 3854 |
return exclude.indexOf(index) === -1; |
| 3855 |
}); |
| 3856 |
} |
| 3857 |
|
| 3858 |
|
| 3859 |
function compileMap() { |
| 3860 |
var result = { |
| 3861 |
scalar: {}, |
| 3862 |
sequence: {}, |
| 3863 |
mapping: {}, |
| 3864 |
fallback: {} |
| 3865 |
}, index, length; |
| 3866 |
|
| 3867 |
function collectType(type) { |
| 3868 |
result[type.kind][type.tag] = result['fallback'][type.tag] = type; |
| 3869 |
} |
| 3870 |
|
| 3871 |
for (index = 0, length = arguments.length; index < length; index += 1) { |
| 3872 |
arguments[index].forEach(collectType); |
| 3873 |
} |
| 3874 |
return result; |
| 3875 |
} |
| 3876 |
|
| 3877 |
|
| 3878 |
function Schema(definition) { |
| 3879 |
this.include = definition.include || []; |
| 3880 |
this.implicit = definition.implicit || []; |
| 3881 |
this.explicit = definition.explicit || []; |
| 3882 |
|
| 3883 |
this.implicit.forEach(function (type) { |
| 3884 |
if (type.loadKind && type.loadKind !== 'scalar') { |
| 3885 |
throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.'); |
| 3886 |
} |
| 3887 |
}); |
| 3888 |
|
| 3889 |
this.compiledImplicit = compileList(this, 'implicit', []); |
| 3890 |
this.compiledExplicit = compileList(this, 'explicit', []); |
| 3891 |
this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit); |
| 3892 |
} |
| 3893 |
|
| 3894 |
|
| 3895 |
Schema.DEFAULT = null; |
| 3896 |
|
| 3897 |
|
| 3898 |
Schema.create = function createSchema() { |
| 3899 |
var schemas, types; |
| 3900 |
|
| 3901 |
switch (arguments.length) { |
| 3902 |
case 1: |
| 3903 |
schemas = Schema.DEFAULT; |
| 3904 |
types = arguments[0]; |
| 3905 |
break; |
| 3906 |
|
| 3907 |
case 2: |
| 3908 |
schemas = arguments[0]; |
| 3909 |
types = arguments[1]; |
| 3910 |
break; |
| 3911 |
|
| 3912 |
default: |
| 3913 |
throw new YAMLException('Wrong number of arguments for Schema.create function'); |
| 3914 |
} |
| 3915 |
|
| 3916 |
schemas = common.toArray(schemas); |
| 3917 |
types = common.toArray(types); |
| 3918 |
|
| 3919 |
if (!schemas.every(function (schema) { return schema instanceof Schema; })) { |
| 3920 |
throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.'); |
| 3921 |
} |
| 3922 |
|
| 3923 |
if (!types.every(function (type) { return type instanceof Type; })) { |
| 3924 |
throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.'); |
| 3925 |
} |
| 3926 |
|
| 3927 |
return new Schema({ |
| 3928 |
include: schemas, |
| 3929 |
explicit: types |
| 3930 |
}); |
| 3931 |
}; |
| 3932 |
|
| 3933 |
|
| 3934 |
module.exports = Schema; |
| 3935 |
|
| 3936 |
},{"./common":5,"./exception":7,"./type":16}],11:[function(require,module,exports){ |
| 3937 |
|
| 3938 |
|
| 3939 |
'use strict'; |
| 3940 |
|
| 3941 |
|
| 3942 |
var Schema = require('../schema'); |
| 3943 |
|
| 3944 |
|
| 3945 |
module.exports = new Schema({ |
| 3946 |
include: [ |
| 3947 |
require('./json') |
| 3948 |
] |
| 3949 |
}); |
| 3950 |
|
| 3951 |
},{"../schema":10,"./json":15}],12:[function(require,module,exports){ |
| 3952 |
|
| 3953 |
|
| 3954 |
'use strict'; |
| 3955 |
|
| 3956 |
|
| 3957 |
var Schema = require('../schema'); |
| 3958 |
|
| 3959 |
|
| 3960 |
module.exports = Schema.DEFAULT = new Schema({ |
| 3961 |
include: [ |
| 3962 |
require('./default_safe') |
| 3963 |
], |
| 3964 |
explicit: [ |
| 3965 |
require('../type/js/undefined'), |
| 3966 |
require('../type/js/regexp'), |
| 3967 |
require('../type/js/function') |
| 3968 |
] |
| 3969 |
}); |
| 3970 |
|
| 3971 |
},{"../schema":10,"../type/js/function":21,"../type/js/regexp":22,"../type/js/undefined":23,"./default_safe":13}],13:[function(require,module,exports){ |
| 3972 |
|
| 3973 |
|
| 3974 |
'use strict'; |
| 3975 |
|
| 3976 |
|
| 3977 |
var Schema = require('../schema'); |
| 3978 |
|
| 3979 |
|
| 3980 |
module.exports = new Schema({ |
| 3981 |
include: [ |
| 3982 |
require('./core') |
| 3983 |
], |
| 3984 |
implicit: [ |
| 3985 |
require('../type/timestamp'), |
| 3986 |
require('../type/merge') |
| 3987 |
], |
| 3988 |
explicit: [ |
| 3989 |
require('../type/binary'), |
| 3990 |
require('../type/omap'), |
| 3991 |
require('../type/pairs'), |
| 3992 |
require('../type/set') |
| 3993 |
] |
| 3994 |
}); |
| 3995 |
|
| 3996 |
},{"../schema":10,"../type/binary":17,"../type/merge":25,"../type/omap":27,"../type/pairs":28,"../type/set":30,"../type/timestamp":32,"./core":11}],14:[function(require,module,exports){ |
| 3997 |
|
| 3998 |
|
| 3999 |
'use strict'; |
| 4000 |
|
| 4001 |
|
| 4002 |
var Schema = require('../schema'); |
| 4003 |
|
| 4004 |
|
| 4005 |
module.exports = new Schema({ |
| 4006 |
explicit: [ |
| 4007 |
require('../type/str'), |
| 4008 |
require('../type/seq'), |
| 4009 |
require('../type/map') |
| 4010 |
] |
| 4011 |
}); |
| 4012 |
|
| 4013 |
},{"../schema":10,"../type/map":24,"../type/seq":29,"../type/str":31}],15:[function(require,module,exports){ |
| 4014 |
|
| 4015 |
|
| 4016 |
'use strict'; |
| 4017 |
|
| 4018 |
|
| 4019 |
var Schema = require('../schema'); |
| 4020 |
|
| 4021 |
|
| 4022 |
module.exports = new Schema({ |
| 4023 |
include: [ |
| 4024 |
require('./failsafe') |
| 4025 |
], |
| 4026 |
implicit: [ |
| 4027 |
require('../type/null'), |
| 4028 |
require('../type/bool'), |
| 4029 |
require('../type/int'), |
| 4030 |
require('../type/float') |
| 4031 |
] |
| 4032 |
}); |
| 4033 |
|
| 4034 |
},{"../schema":10,"../type/bool":18,"../type/float":19,"../type/int":20,"../type/null":26,"./failsafe":14}],16:[function(require,module,exports){ |
| 4035 |
'use strict'; |
| 4036 |
|
| 4037 |
var YAMLException = require('./exception'); |
| 4038 |
|
| 4039 |
var TYPE_CONSTRUCTOR_OPTIONS = [ |
| 4040 |
'kind', |
| 4041 |
'resolve', |
| 4042 |
'construct', |
| 4043 |
'instanceOf', |
| 4044 |
'predicate', |
| 4045 |
'represent', |
| 4046 |
'defaultStyle', |
| 4047 |
'styleAliases' |
| 4048 |
]; |
| 4049 |
|
| 4050 |
var YAML_NODE_KINDS = [ |
| 4051 |
'scalar', |
| 4052 |
'sequence', |
| 4053 |
'mapping' |
| 4054 |
]; |
| 4055 |
|
| 4056 |
function compileStyleAliases(map) { |
| 4057 |
var result = {}; |
| 4058 |
|
| 4059 |
if (map !== null) { |
| 4060 |
Object.keys(map).forEach(function (style) { |
| 4061 |
map[style].forEach(function (alias) { |
| 4062 |
result[String(alias)] = style; |
| 4063 |
}); |
| 4064 |
}); |
| 4065 |
} |
| 4066 |
|
| 4067 |
return result; |
| 4068 |
} |
| 4069 |
|
| 4070 |
function Type(tag, options) { |
| 4071 |
options = options || {}; |
| 4072 |
|
| 4073 |
Object.keys(options).forEach(function (name) { |
| 4074 |
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { |
| 4075 |
throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); |
| 4076 |
} |
| 4077 |
}); |
| 4078 |
this.tag = tag; |
| 4079 |
this.kind = options['kind'] || null; |
| 4080 |
this.resolve = options['resolve'] || function () { return true; }; |
| 4081 |
this.construct = options['construct'] || function (data) { return data; }; |
| 4082 |
this.instanceOf = options['instanceOf'] || null; |
| 4083 |
this.predicate = options['predicate'] || null; |
| 4084 |
this.represent = options['represent'] || null; |
| 4085 |
this.defaultStyle = options['defaultStyle'] || null; |
| 4086 |
this.styleAliases = compileStyleAliases(options['styleAliases'] || null); |
| 4087 |
|
| 4088 |
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { |
| 4089 |
throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); |
| 4090 |
} |
| 4091 |
} |
| 4092 |
|
| 4093 |
module.exports = Type; |
| 4094 |
|
| 4095 |
},{"./exception":7}],17:[function(require,module,exports){ |
| 4096 |
'use strict'; |
| 4097 |
|
| 4098 |
var NodeBuffer; |
| 4099 |
|
| 4100 |
try { |
| 4101 |
var _require = require; |
| 4102 |
NodeBuffer = _require('buffer').Buffer; |
| 4103 |
} catch (__) {} |
| 4104 |
|
| 4105 |
var Type = require('../type'); |
| 4106 |
var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r'; |
| 4107 |
|
| 4108 |
|
| 4109 |
function resolveYamlBinary(data) { |
| 4110 |
if (data === null) return false; |
| 4111 |
|
| 4112 |
var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP; |
| 4113 |
for (idx = 0; idx < max; idx++) { |
| 4114 |
code = map.indexOf(data.charAt(idx)); |
| 4115 |
if (code > 64) continue; |
| 4116 |
if (code < 0) return false; |
| 4117 |
|
| 4118 |
bitlen += 6; |
| 4119 |
} |
| 4120 |
return (bitlen % 8) === 0; |
| 4121 |
} |
| 4122 |
|
| 4123 |
function constructYamlBinary(data) { |
| 4124 |
var idx, tailbits, |
| 4125 |
input = data.replace(/[\r\n=]/g, ''), |
| 4126 |
max = input.length, |
| 4127 |
map = BASE64_MAP, |
| 4128 |
bits = 0, |
| 4129 |
result = []; |
| 4130 |
|
| 4131 |
for (idx = 0; idx < max; idx++) { |
| 4132 |
if ((idx % 4 === 0) && idx) { |
| 4133 |
result.push((bits >> 16) & 0xFF); |
| 4134 |
result.push((bits >> 8) & 0xFF); |
| 4135 |
result.push(bits & 0xFF); |
| 4136 |
} |
| 4137 |
|
| 4138 |
bits = (bits << 6) | map.indexOf(input.charAt(idx)); |
| 4139 |
} |
| 4140 |
|
| 4141 |
tailbits = (max % 4) * 6; |
| 4142 |
|
| 4143 |
if (tailbits === 0) { |
| 4144 |
result.push((bits >> 16) & 0xFF); |
| 4145 |
result.push((bits >> 8) & 0xFF); |
| 4146 |
result.push(bits & 0xFF); |
| 4147 |
} else if (tailbits === 18) { |
| 4148 |
result.push((bits >> 10) & 0xFF); |
| 4149 |
result.push((bits >> 2) & 0xFF); |
| 4150 |
} else if (tailbits === 12) { |
| 4151 |
result.push((bits >> 4) & 0xFF); |
| 4152 |
} |
| 4153 |
if (NodeBuffer) { |
| 4154 |
return NodeBuffer.from ? NodeBuffer.from(result) : new NodeBuffer(result); |
| 4155 |
} |
| 4156 |
|
| 4157 |
return result; |
| 4158 |
} |
| 4159 |
|
| 4160 |
function representYamlBinary(object ) { |
| 4161 |
var result = '', bits = 0, idx, tail, |
| 4162 |
max = object.length, |
| 4163 |
map = BASE64_MAP; |
| 4164 |
|
| 4165 |
for (idx = 0; idx < max; idx++) { |
| 4166 |
if ((idx % 3 === 0) && idx) { |
| 4167 |
result += map[(bits >> 18) & 0x3F]; |
| 4168 |
result += map[(bits >> 12) & 0x3F]; |
| 4169 |
result += map[(bits >> 6) & 0x3F]; |
| 4170 |
result += map[bits & 0x3F]; |
| 4171 |
} |
| 4172 |
|
| 4173 |
bits = (bits << 8) + object[idx]; |
| 4174 |
} |
| 4175 |
|
| 4176 |
tail = max % 3; |
| 4177 |
|
| 4178 |
if (tail === 0) { |
| 4179 |
result += map[(bits >> 18) & 0x3F]; |
| 4180 |
result += map[(bits >> 12) & 0x3F]; |
| 4181 |
result += map[(bits >> 6) & 0x3F]; |
| 4182 |
result += map[bits & 0x3F]; |
| 4183 |
} else if (tail === 2) { |
| 4184 |
result += map[(bits >> 10) & 0x3F]; |
| 4185 |
result += map[(bits >> 4) & 0x3F]; |
| 4186 |
result += map[(bits << 2) & 0x3F]; |
| 4187 |
result += map[64]; |
| 4188 |
} else if (tail === 1) { |
| 4189 |
result += map[(bits >> 2) & 0x3F]; |
| 4190 |
result += map[(bits << 4) & 0x3F]; |
| 4191 |
result += map[64]; |
| 4192 |
result += map[64]; |
| 4193 |
} |
| 4194 |
|
| 4195 |
return result; |
| 4196 |
} |
| 4197 |
|
| 4198 |
function isBinary(object) { |
| 4199 |
return NodeBuffer && NodeBuffer.isBuffer(object); |
| 4200 |
} |
| 4201 |
|
| 4202 |
module.exports = new Type('tag:yaml.org,2002:binary', { |
| 4203 |
kind: 'scalar', |
| 4204 |
resolve: resolveYamlBinary, |
| 4205 |
construct: constructYamlBinary, |
| 4206 |
predicate: isBinary, |
| 4207 |
represent: representYamlBinary |
| 4208 |
}); |
| 4209 |
|
| 4210 |
},{"../type":16}],18:[function(require,module,exports){ |
| 4211 |
'use strict'; |
| 4212 |
|
| 4213 |
var Type = require('../type'); |
| 4214 |
|
| 4215 |
function resolveYamlBoolean(data) { |
| 4216 |
if (data === null) return false; |
| 4217 |
|
| 4218 |
var max = data.length; |
| 4219 |
|
| 4220 |
return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) || |
| 4221 |
(max === 5 && (data === 'false' || data === 'False' || data === 'FALSE')); |
| 4222 |
} |
| 4223 |
|
| 4224 |
function constructYamlBoolean(data) { |
| 4225 |
return data === 'true' || |
| 4226 |
data === 'True' || |
| 4227 |
data === 'TRUE'; |
| 4228 |
} |
| 4229 |
|
| 4230 |
function isBoolean(object) { |
| 4231 |
return Object.prototype.toString.call(object) === '[object Boolean]'; |
| 4232 |
} |
| 4233 |
|
| 4234 |
module.exports = new Type('tag:yaml.org,2002:bool', { |
| 4235 |
kind: 'scalar', |
| 4236 |
resolve: resolveYamlBoolean, |
| 4237 |
construct: constructYamlBoolean, |
| 4238 |
predicate: isBoolean, |
| 4239 |
represent: { |
| 4240 |
lowercase: function (object) { return object ? 'true' : 'false'; }, |
| 4241 |
uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; }, |
| 4242 |
camelcase: function (object) { return object ? 'True' : 'False'; } |
| 4243 |
}, |
| 4244 |
defaultStyle: 'lowercase' |
| 4245 |
}); |
| 4246 |
|
| 4247 |
},{"../type":16}],19:[function(require,module,exports){ |
| 4248 |
'use strict'; |
| 4249 |
|
| 4250 |
var common = require('../common'); |
| 4251 |
var Type = require('../type'); |
| 4252 |
|
| 4253 |
var YAML_FLOAT_PATTERN = new RegExp( |
| 4254 |
'^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' + |
| 4255 |
'|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' + |
| 4256 |
'|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' + |
| 4257 |
'|[-+]?\\.(?:inf|Inf|INF)' + |
| 4258 |
'|\\.(?:nan|NaN|NAN))$'); |
| 4259 |
|
| 4260 |
function resolveYamlFloat(data) { |
| 4261 |
if (data === null) return false; |
| 4262 |
|
| 4263 |
if (!YAML_FLOAT_PATTERN.test(data) || |
| 4264 |
data[data.length - 1] === '_') { |
| 4265 |
return false; |
| 4266 |
} |
| 4267 |
|
| 4268 |
return true; |
| 4269 |
} |
| 4270 |
|
| 4271 |
function constructYamlFloat(data) { |
| 4272 |
var value, sign, base, digits; |
| 4273 |
|
| 4274 |
value = data.replace(/_/g, '').toLowerCase(); |
| 4275 |
sign = value[0] === '-' ? -1 : 1; |
| 4276 |
digits = []; |
| 4277 |
|
| 4278 |
if ('+-'.indexOf(value[0]) >= 0) { |
| 4279 |
value = value.slice(1); |
| 4280 |
} |
| 4281 |
|
| 4282 |
if (value === '.inf') { |
| 4283 |
return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; |
| 4284 |
|
| 4285 |
} else if (value === '.nan') { |
| 4286 |
return NaN; |
| 4287 |
|
| 4288 |
} else if (value.indexOf(':') >= 0) { |
| 4289 |
value.split(':').forEach(function (v) { |
| 4290 |
digits.unshift(parseFloat(v, 10)); |
| 4291 |
}); |
| 4292 |
|
| 4293 |
value = 0.0; |
| 4294 |
base = 1; |
| 4295 |
|
| 4296 |
digits.forEach(function (d) { |
| 4297 |
value += d * base; |
| 4298 |
base *= 60; |
| 4299 |
}); |
| 4300 |
|
| 4301 |
return sign * value; |
| 4302 |
|
| 4303 |
} |
| 4304 |
return sign * parseFloat(value, 10); |
| 4305 |
} |
| 4306 |
|
| 4307 |
|
| 4308 |
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; |
| 4309 |
|
| 4310 |
function representYamlFloat(object, style) { |
| 4311 |
var res; |
| 4312 |
|
| 4313 |
if (isNaN(object)) { |
| 4314 |
switch (style) { |
| 4315 |
case 'lowercase': return '.nan'; |
| 4316 |
case 'uppercase': return '.NAN'; |
| 4317 |
case 'camelcase': return '.NaN'; |
| 4318 |
} |
| 4319 |
} else if (Number.POSITIVE_INFINITY === object) { |
| 4320 |
switch (style) { |
| 4321 |
case 'lowercase': return '.inf'; |
| 4322 |
case 'uppercase': return '.INF'; |
| 4323 |
case 'camelcase': return '.Inf'; |
| 4324 |
} |
| 4325 |
} else if (Number.NEGATIVE_INFINITY === object) { |
| 4326 |
switch (style) { |
| 4327 |
case 'lowercase': return '-.inf'; |
| 4328 |
case 'uppercase': return '-.INF'; |
| 4329 |
case 'camelcase': return '-.Inf'; |
| 4330 |
} |
| 4331 |
} else if (common.isNegativeZero(object)) { |
| 4332 |
return '-0.0'; |
| 4333 |
} |
| 4334 |
|
| 4335 |
res = object.toString(10); |
| 4336 |
|
| 4337 |
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res; |
| 4338 |
} |
| 4339 |
|
| 4340 |
function isFloat(object) { |
| 4341 |
return (Object.prototype.toString.call(object) === '[object Number]') && |
| 4342 |
(object % 1 !== 0 || common.isNegativeZero(object)); |
| 4343 |
} |
| 4344 |
|
| 4345 |
module.exports = new Type('tag:yaml.org,2002:float', { |
| 4346 |
kind: 'scalar', |
| 4347 |
resolve: resolveYamlFloat, |
| 4348 |
construct: constructYamlFloat, |
| 4349 |
predicate: isFloat, |
| 4350 |
represent: representYamlFloat, |
| 4351 |
defaultStyle: 'lowercase' |
| 4352 |
}); |
| 4353 |
|
| 4354 |
},{"../common":5,"../type":16}],20:[function(require,module,exports){ |
| 4355 |
'use strict'; |
| 4356 |
|
| 4357 |
var common = require('../common'); |
| 4358 |
var Type = require('../type'); |
| 4359 |
|
| 4360 |
function isHexCode(c) { |
| 4361 |
return ((c >= 0x30) && (c <= 0x39)) || |
| 4362 |
((c >= 0x41) && (c <= 0x46)) || |
| 4363 |
((c >= 0x61) && (c <= 0x66)); |
| 4364 |
} |
| 4365 |
|
| 4366 |
function isOctCode(c) { |
| 4367 |
return ((c >= 0x30) && (c <= 0x37)); |
| 4368 |
} |
| 4369 |
|
| 4370 |
function isDecCode(c) { |
| 4371 |
return ((c >= 0x30) && (c <= 0x39)); |
| 4372 |
} |
| 4373 |
|
| 4374 |
function resolveYamlInteger(data) { |
| 4375 |
if (data === null) return false; |
| 4376 |
|
| 4377 |
var max = data.length, |
| 4378 |
index = 0, |
| 4379 |
hasDigits = false, |
| 4380 |
ch; |
| 4381 |
|
| 4382 |
if (!max) return false; |
| 4383 |
|
| 4384 |
ch = data[index]; |
| 4385 |
if (ch === '-' || ch === '+') { |
| 4386 |
ch = data[++index]; |
| 4387 |
} |
| 4388 |
|
| 4389 |
if (ch === '0') { |
| 4390 |
if (index + 1 === max) return true; |
| 4391 |
ch = data[++index]; |
| 4392 |
|
| 4393 |
if (ch === 'b') { |
| 4394 |
index++; |
| 4395 |
|
| 4396 |
for (; index < max; index++) { |
| 4397 |
ch = data[index]; |
| 4398 |
if (ch === '_') continue; |
| 4399 |
if (ch !== '0' && ch !== '1') return false; |
| 4400 |
hasDigits = true; |
| 4401 |
} |
| 4402 |
return hasDigits && ch !== '_'; |
| 4403 |
} |
| 4404 |
|
| 4405 |
|
| 4406 |
if (ch === 'x') { |
| 4407 |
index++; |
| 4408 |
|
| 4409 |
for (; index < max; index++) { |
| 4410 |
ch = data[index]; |
| 4411 |
if (ch === '_') continue; |
| 4412 |
if (!isHexCode(data.charCodeAt(index))) return false; |
| 4413 |
hasDigits = true; |
| 4414 |
} |
| 4415 |
return hasDigits && ch !== '_'; |
| 4416 |
} |
| 4417 |
for (; index < max; index++) { |
| 4418 |
ch = data[index]; |
| 4419 |
if (ch === '_') continue; |
| 4420 |
if (!isOctCode(data.charCodeAt(index))) return false; |
| 4421 |
hasDigits = true; |
| 4422 |
} |
| 4423 |
return hasDigits && ch !== '_'; |
| 4424 |
} |
| 4425 |
if (ch === '_') return false; |
| 4426 |
|
| 4427 |
for (; index < max; index++) { |
| 4428 |
ch = data[index]; |
| 4429 |
if (ch === '_') continue; |
| 4430 |
if (ch === ':') break; |
| 4431 |
if (!isDecCode(data.charCodeAt(index))) { |
| 4432 |
return false; |
| 4433 |
} |
| 4434 |
hasDigits = true; |
| 4435 |
} |
| 4436 |
if (!hasDigits || ch === '_') return false; |
| 4437 |
if (ch !== ':') return true; |
| 4438 |
return /^(:[0-5]?[0-9])+$/.test(data.slice(index)); |
| 4439 |
} |
| 4440 |
|
| 4441 |
function constructYamlInteger(data) { |
| 4442 |
var value = data, sign = 1, ch, base, digits = []; |
| 4443 |
|
| 4444 |
if (value.indexOf('_') !== -1) { |
| 4445 |
value = value.replace(/_/g, ''); |
| 4446 |
} |
| 4447 |
|
| 4448 |
ch = value[0]; |
| 4449 |
|
| 4450 |
if (ch === '-' || ch === '+') { |
| 4451 |
if (ch === '-') sign = -1; |
| 4452 |
value = value.slice(1); |
| 4453 |
ch = value[0]; |
| 4454 |
} |
| 4455 |
|
| 4456 |
if (value === '0') return 0; |
| 4457 |
|
| 4458 |
if (ch === '0') { |
| 4459 |
if (value[1] === 'b') return sign * parseInt(value.slice(2), 2); |
| 4460 |
if (value[1] === 'x') return sign * parseInt(value, 16); |
| 4461 |
return sign * parseInt(value, 8); |
| 4462 |
} |
| 4463 |
|
| 4464 |
if (value.indexOf(':') !== -1) { |
| 4465 |
value.split(':').forEach(function (v) { |
| 4466 |
digits.unshift(parseInt(v, 10)); |
| 4467 |
}); |
| 4468 |
|
| 4469 |
value = 0; |
| 4470 |
base = 1; |
| 4471 |
|
| 4472 |
digits.forEach(function (d) { |
| 4473 |
value += (d * base); |
| 4474 |
base *= 60; |
| 4475 |
}); |
| 4476 |
|
| 4477 |
return sign * value; |
| 4478 |
|
| 4479 |
} |
| 4480 |
|
| 4481 |
return sign * parseInt(value, 10); |
| 4482 |
} |
| 4483 |
|
| 4484 |
function isInteger(object) { |
| 4485 |
return (Object.prototype.toString.call(object)) === '[object Number]' && |
| 4486 |
(object % 1 === 0 && !common.isNegativeZero(object)); |
| 4487 |
} |
| 4488 |
|
| 4489 |
module.exports = new Type('tag:yaml.org,2002:int', { |
| 4490 |
kind: 'scalar', |
| 4491 |
resolve: resolveYamlInteger, |
| 4492 |
construct: constructYamlInteger, |
| 4493 |
predicate: isInteger, |
| 4494 |
represent: { |
| 4495 |
binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); }, |
| 4496 |
octal: function (obj) { return obj >= 0 ? '0' + obj.toString(8) : '-0' + obj.toString(8).slice(1); }, |
| 4497 |
decimal: function (obj) { return obj.toString(10); }, |
| 4498 |
hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); } |
| 4499 |
}, |
| 4500 |
defaultStyle: 'decimal', |
| 4501 |
styleAliases: { |
| 4502 |
binary: [ 2, 'bin' ], |
| 4503 |
octal: [ 8, 'oct' ], |
| 4504 |
decimal: [ 10, 'dec' ], |
| 4505 |
hexadecimal: [ 16, 'hex' ] |
| 4506 |
} |
| 4507 |
}); |
| 4508 |
|
| 4509 |
},{"../common":5,"../type":16}],21:[function(require,module,exports){ |
| 4510 |
'use strict'; |
| 4511 |
|
| 4512 |
var esprima; |
| 4513 |
try { |
| 4514 |
var _require = require; |
| 4515 |
esprima = _require('esprima'); |
| 4516 |
} catch (_) { |
| 4517 |
if (typeof window !== 'undefined') esprima = window.esprima; |
| 4518 |
} |
| 4519 |
|
| 4520 |
var Type = require('../../type'); |
| 4521 |
|
| 4522 |
function resolveJavascriptFunction(data) { |
| 4523 |
if (data === null) return false; |
| 4524 |
|
| 4525 |
try { |
| 4526 |
var source = '(' + data + ')', |
| 4527 |
ast = esprima.parse(source, { range: true }); |
| 4528 |
|
| 4529 |
if (ast.type !== 'Program' || |
| 4530 |
ast.body.length !== 1 || |
| 4531 |
ast.body[0].type !== 'ExpressionStatement' || |
| 4532 |
(ast.body[0].expression.type !== 'ArrowFunctionExpression' && |
| 4533 |
ast.body[0].expression.type !== 'FunctionExpression')) { |
| 4534 |
return false; |
| 4535 |
} |
| 4536 |
|
| 4537 |
return true; |
| 4538 |
} catch (err) { |
| 4539 |
return false; |
| 4540 |
} |
| 4541 |
} |
| 4542 |
|
| 4543 |
function constructJavascriptFunction(data) { |
| 4544 |
|
| 4545 |
var source = '(' + data + ')', |
| 4546 |
ast = esprima.parse(source, { range: true }), |
| 4547 |
params = [], |
| 4548 |
body; |
| 4549 |
|
| 4550 |
if (ast.type !== 'Program' || |
| 4551 |
ast.body.length !== 1 || |
| 4552 |
ast.body[0].type !== 'ExpressionStatement' || |
| 4553 |
(ast.body[0].expression.type !== 'ArrowFunctionExpression' && |
| 4554 |
ast.body[0].expression.type !== 'FunctionExpression')) { |
| 4555 |
throw new Error('Failed to resolve function'); |
| 4556 |
} |
| 4557 |
|
| 4558 |
ast.body[0].expression.params.forEach(function (param) { |
| 4559 |
params.push(param.name); |
| 4560 |
}); |
| 4561 |
|
| 4562 |
body = ast.body[0].expression.body.range; |
| 4563 |
if (ast.body[0].expression.body.type === 'BlockStatement') { |
| 4564 |
return new Function(params, source.slice(body[0] + 1, body[1] - 1)); |
| 4565 |
} |
| 4566 |
return new Function(params, 'return ' + source.slice(body[0], body[1])); |
| 4567 |
} |
| 4568 |
|
| 4569 |
function representJavascriptFunction(object ) { |
| 4570 |
return object.toString(); |
| 4571 |
} |
| 4572 |
|
| 4573 |
function isFunction(object) { |
| 4574 |
return Object.prototype.toString.call(object) === '[object Function]'; |
| 4575 |
} |
| 4576 |
|
| 4577 |
module.exports = new Type('tag:yaml.org,2002:js/function', { |
| 4578 |
kind: 'scalar', |
| 4579 |
resolve: resolveJavascriptFunction, |
| 4580 |
construct: constructJavascriptFunction, |
| 4581 |
predicate: isFunction, |
| 4582 |
represent: representJavascriptFunction |
| 4583 |
}); |
| 4584 |
|
| 4585 |
},{"../../type":16}],22:[function(require,module,exports){ |
| 4586 |
'use strict'; |
| 4587 |
|
| 4588 |
var Type = require('../../type'); |
| 4589 |
|
| 4590 |
function resolveJavascriptRegExp(data) { |
| 4591 |
if (data === null) return false; |
| 4592 |
if (data.length === 0) return false; |
| 4593 |
|
| 4594 |
var regexp = data, |
| 4595 |
tail = /\/([gim]*)$/.exec(data), |
| 4596 |
modifiers = ''; |
| 4597 |
if (regexp[0] === '/') { |
| 4598 |
if (tail) modifiers = tail[1]; |
| 4599 |
|
| 4600 |
if (modifiers.length > 3) return false; |
| 4601 |
if (regexp[regexp.length - modifiers.length - 1] !== '/') return false; |
| 4602 |
} |
| 4603 |
|
| 4604 |
return true; |
| 4605 |
} |
| 4606 |
|
| 4607 |
function constructJavascriptRegExp(data) { |
| 4608 |
var regexp = data, |
| 4609 |
tail = /\/([gim]*)$/.exec(data), |
| 4610 |
modifiers = ''; |
| 4611 |
if (regexp[0] === '/') { |
| 4612 |
if (tail) modifiers = tail[1]; |
| 4613 |
regexp = regexp.slice(1, regexp.length - modifiers.length - 1); |
| 4614 |
} |
| 4615 |
|
| 4616 |
return new RegExp(regexp, modifiers); |
| 4617 |
} |
| 4618 |
|
| 4619 |
function representJavascriptRegExp(object ) { |
| 4620 |
var result = '/' + object.source + '/'; |
| 4621 |
|
| 4622 |
if (object.global) result += 'g'; |
| 4623 |
if (object.multiline) result += 'm'; |
| 4624 |
if (object.ignoreCase) result += 'i'; |
| 4625 |
|
| 4626 |
return result; |
| 4627 |
} |
| 4628 |
|
| 4629 |
function isRegExp(object) { |
| 4630 |
return Object.prototype.toString.call(object) === '[object RegExp]'; |
| 4631 |
} |
| 4632 |
|
| 4633 |
module.exports = new Type('tag:yaml.org,2002:js/regexp', { |
| 4634 |
kind: 'scalar', |
| 4635 |
resolve: resolveJavascriptRegExp, |
| 4636 |
construct: constructJavascriptRegExp, |
| 4637 |
predicate: isRegExp, |
| 4638 |
represent: representJavascriptRegExp |
| 4639 |
}); |
| 4640 |
|
| 4641 |
},{"../../type":16}],23:[function(require,module,exports){ |
| 4642 |
'use strict'; |
| 4643 |
|
| 4644 |
var Type = require('../../type'); |
| 4645 |
|
| 4646 |
function resolveJavascriptUndefined() { |
| 4647 |
return true; |
| 4648 |
} |
| 4649 |
|
| 4650 |
function constructJavascriptUndefined() { |
| 4651 |
return undefined; |
| 4652 |
} |
| 4653 |
|
| 4654 |
function representJavascriptUndefined() { |
| 4655 |
return ''; |
| 4656 |
} |
| 4657 |
|
| 4658 |
function isUndefined(object) { |
| 4659 |
return typeof object === 'undefined'; |
| 4660 |
} |
| 4661 |
|
| 4662 |
module.exports = new Type('tag:yaml.org,2002:js/undefined', { |
| 4663 |
kind: 'scalar', |
| 4664 |
resolve: resolveJavascriptUndefined, |
| 4665 |
construct: constructJavascriptUndefined, |
| 4666 |
predicate: isUndefined, |
| 4667 |
represent: representJavascriptUndefined |
| 4668 |
}); |
| 4669 |
|
| 4670 |
},{"../../type":16}],24:[function(require,module,exports){ |
| 4671 |
'use strict'; |
| 4672 |
|
| 4673 |
var Type = require('../type'); |
| 4674 |
|
| 4675 |
module.exports = new Type('tag:yaml.org,2002:map', { |
| 4676 |
kind: 'mapping', |
| 4677 |
construct: function (data) { return data !== null ? data : {}; } |
| 4678 |
}); |
| 4679 |
|
| 4680 |
},{"../type":16}],25:[function(require,module,exports){ |
| 4681 |
'use strict'; |
| 4682 |
|
| 4683 |
var Type = require('../type'); |
| 4684 |
|
| 4685 |
function resolveYamlMerge(data) { |
| 4686 |
return data === '<<' || data === null; |
| 4687 |
} |
| 4688 |
|
| 4689 |
module.exports = new Type('tag:yaml.org,2002:merge', { |
| 4690 |
kind: 'scalar', |
| 4691 |
resolve: resolveYamlMerge |
| 4692 |
}); |
| 4693 |
|
| 4694 |
},{"../type":16}],26:[function(require,module,exports){ |
| 4695 |
'use strict'; |
| 4696 |
|
| 4697 |
var Type = require('../type'); |
| 4698 |
|
| 4699 |
function resolveYamlNull(data) { |
| 4700 |
if (data === null) return true; |
| 4701 |
|
| 4702 |
var max = data.length; |
| 4703 |
|
| 4704 |
return (max === 1 && data === '~') || |
| 4705 |
(max === 4 && (data === 'null' || data === 'Null' || data === 'NULL')); |
| 4706 |
} |
| 4707 |
|
| 4708 |
function constructYamlNull() { |
| 4709 |
return null; |
| 4710 |
} |
| 4711 |
|
| 4712 |
function isNull(object) { |
| 4713 |
return object === null; |
| 4714 |
} |
| 4715 |
|
| 4716 |
module.exports = new Type('tag:yaml.org,2002:null', { |
| 4717 |
kind: 'scalar', |
| 4718 |
resolve: resolveYamlNull, |
| 4719 |
construct: constructYamlNull, |
| 4720 |
predicate: isNull, |
| 4721 |
represent: { |
| 4722 |
canonical: function () { return '~'; }, |
| 4723 |
lowercase: function () { return 'null'; }, |
| 4724 |
uppercase: function () { return 'NULL'; }, |
| 4725 |
camelcase: function () { return 'Null'; } |
| 4726 |
}, |
| 4727 |
defaultStyle: 'lowercase' |
| 4728 |
}); |
| 4729 |
|
| 4730 |
},{"../type":16}],27:[function(require,module,exports){ |
| 4731 |
'use strict'; |
| 4732 |
|
| 4733 |
var Type = require('../type'); |
| 4734 |
|
| 4735 |
var _hasOwnProperty = Object.prototype.hasOwnProperty; |
| 4736 |
var _toString = Object.prototype.toString; |
| 4737 |
|
| 4738 |
function resolveYamlOmap(data) { |
| 4739 |
if (data === null) return true; |
| 4740 |
|
| 4741 |
var objectKeys = [], index, length, pair, pairKey, pairHasKey, |
| 4742 |
object = data; |
| 4743 |
|
| 4744 |
for (index = 0, length = object.length; index < length; index += 1) { |
| 4745 |
pair = object[index]; |
| 4746 |
pairHasKey = false; |
| 4747 |
|
| 4748 |
if (_toString.call(pair) !== '[object Object]') return false; |
| 4749 |
|
| 4750 |
for (pairKey in pair) { |
| 4751 |
if (_hasOwnProperty.call(pair, pairKey)) { |
| 4752 |
if (!pairHasKey) pairHasKey = true; |
| 4753 |
else return false; |
| 4754 |
} |
| 4755 |
} |
| 4756 |
|
| 4757 |
if (!pairHasKey) return false; |
| 4758 |
|
| 4759 |
if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey); |
| 4760 |
else return false; |
| 4761 |
} |
| 4762 |
|
| 4763 |
return true; |
| 4764 |
} |
| 4765 |
|
| 4766 |
function constructYamlOmap(data) { |
| 4767 |
return data !== null ? data : []; |
| 4768 |
} |
| 4769 |
|
| 4770 |
module.exports = new Type('tag:yaml.org,2002:omap', { |
| 4771 |
kind: 'sequence', |
| 4772 |
resolve: resolveYamlOmap, |
| 4773 |
construct: constructYamlOmap |
| 4774 |
}); |
| 4775 |
|
| 4776 |
},{"../type":16}],28:[function(require,module,exports){ |
| 4777 |
'use strict'; |
| 4778 |
|
| 4779 |
var Type = require('../type'); |
| 4780 |
|
| 4781 |
var _toString = Object.prototype.toString; |
| 4782 |
|
| 4783 |
function resolveYamlPairs(data) { |
| 4784 |
if (data === null) return true; |
| 4785 |
|
| 4786 |
var index, length, pair, keys, result, |
| 4787 |
object = data; |
| 4788 |
|
| 4789 |
result = new Array(object.length); |
| 4790 |
|
| 4791 |
for (index = 0, length = object.length; index < length; index += 1) { |
| 4792 |
pair = object[index]; |
| 4793 |
|
| 4794 |
if (_toString.call(pair) !== '[object Object]') return false; |
| 4795 |
|
| 4796 |
keys = Object.keys(pair); |
| 4797 |
|
| 4798 |
if (keys.length !== 1) return false; |
| 4799 |
|
| 4800 |
result[index] = [ keys[0], pair[keys[0]] ]; |
| 4801 |
} |
| 4802 |
|
| 4803 |
return true; |
| 4804 |
} |
| 4805 |
|
| 4806 |
function constructYamlPairs(data) { |
| 4807 |
if (data === null) return []; |
| 4808 |
|
| 4809 |
var index, length, pair, keys, result, |
| 4810 |
object = data; |
| 4811 |
|
| 4812 |
result = new Array(object.length); |
| 4813 |
|
| 4814 |
for (index = 0, length = object.length; index < length; index += 1) { |
| 4815 |
pair = object[index]; |
| 4816 |
|
| 4817 |
keys = Object.keys(pair); |
| 4818 |
|
| 4819 |
result[index] = [ keys[0], pair[keys[0]] ]; |
| 4820 |
} |
| 4821 |
|
| 4822 |
return result; |
| 4823 |
} |
| 4824 |
|
| 4825 |
module.exports = new Type('tag:yaml.org,2002:pairs', { |
| 4826 |
kind: 'sequence', |
| 4827 |
resolve: resolveYamlPairs, |
| 4828 |
construct: constructYamlPairs |
| 4829 |
}); |
| 4830 |
|
| 4831 |
},{"../type":16}],29:[function(require,module,exports){ |
| 4832 |
'use strict'; |
| 4833 |
|
| 4834 |
var Type = require('../type'); |
| 4835 |
|
| 4836 |
module.exports = new Type('tag:yaml.org,2002:seq', { |
| 4837 |
kind: 'sequence', |
| 4838 |
construct: function (data) { return data !== null ? data : []; } |
| 4839 |
}); |
| 4840 |
|
| 4841 |
},{"../type":16}],30:[function(require,module,exports){ |
| 4842 |
'use strict'; |
| 4843 |
|
| 4844 |
var Type = require('../type'); |
| 4845 |
|
| 4846 |
var _hasOwnProperty = Object.prototype.hasOwnProperty; |
| 4847 |
|
| 4848 |
function resolveYamlSet(data) { |
| 4849 |
if (data === null) return true; |
| 4850 |
|
| 4851 |
var key, object = data; |
| 4852 |
|
| 4853 |
for (key in object) { |
| 4854 |
if (_hasOwnProperty.call(object, key)) { |
| 4855 |
if (object[key] !== null) return false; |
| 4856 |
} |
| 4857 |
} |
| 4858 |
|
| 4859 |
return true; |
| 4860 |
} |
| 4861 |
|
| 4862 |
function constructYamlSet(data) { |
| 4863 |
return data !== null ? data : {}; |
| 4864 |
} |
| 4865 |
|
| 4866 |
module.exports = new Type('tag:yaml.org,2002:set', { |
| 4867 |
kind: 'mapping', |
| 4868 |
resolve: resolveYamlSet, |
| 4869 |
construct: constructYamlSet |
| 4870 |
}); |
| 4871 |
|
| 4872 |
},{"../type":16}],31:[function(require,module,exports){ |
| 4873 |
'use strict'; |
| 4874 |
|
| 4875 |
var Type = require('../type'); |
| 4876 |
|
| 4877 |
module.exports = new Type('tag:yaml.org,2002:str', { |
| 4878 |
kind: 'scalar', |
| 4879 |
construct: function (data) { return data !== null ? data : ''; } |
| 4880 |
}); |
| 4881 |
|
| 4882 |
},{"../type":16}],32:[function(require,module,exports){ |
| 4883 |
'use strict'; |
| 4884 |
|
| 4885 |
var Type = require('../type'); |
| 4886 |
|
| 4887 |
var YAML_DATE_REGEXP = new RegExp( |
| 4888 |
'^([0-9][0-9][0-9][0-9])' + |
| 4889 |
'-([0-9][0-9])' + |
| 4890 |
'-([0-9][0-9])$'); |
| 4891 |
|
| 4892 |
var YAML_TIMESTAMP_REGEXP = new RegExp( |
| 4893 |
'^([0-9][0-9][0-9][0-9])' + |
| 4894 |
'-([0-9][0-9]?)' + |
| 4895 |
'-([0-9][0-9]?)' + |
| 4896 |
'(?:[Tt]|[ \\t]+)' + |
| 4897 |
'([0-9][0-9]?)' + |
| 4898 |
':([0-9][0-9])' + |
| 4899 |
':([0-9][0-9])' + |
| 4900 |
'(?:\\.([0-9]*))?' + |
| 4901 |
'(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + |
| 4902 |
'(?::([0-9][0-9]))?))?$'); |
| 4903 |
|
| 4904 |
function resolveYamlTimestamp(data) { |
| 4905 |
if (data === null) return false; |
| 4906 |
if (YAML_DATE_REGEXP.exec(data) !== null) return true; |
| 4907 |
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true; |
| 4908 |
return false; |
| 4909 |
} |
| 4910 |
|
| 4911 |
function constructYamlTimestamp(data) { |
| 4912 |
var match, year, month, day, hour, minute, second, fraction = 0, |
| 4913 |
delta = null, tz_hour, tz_minute, date; |
| 4914 |
|
| 4915 |
match = YAML_DATE_REGEXP.exec(data); |
| 4916 |
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data); |
| 4917 |
|
| 4918 |
if (match === null) throw new Error('Date resolve error'); |
| 4919 |
|
| 4920 |
year = +(match[1]); |
| 4921 |
month = +(match[2]) - 1; |
| 4922 |
day = +(match[3]); |
| 4923 |
|
| 4924 |
if (!match[4]) { |
| 4925 |
return new Date(Date.UTC(year, month, day)); |
| 4926 |
} |
| 4927 |
|
| 4928 |
hour = +(match[4]); |
| 4929 |
minute = +(match[5]); |
| 4930 |
second = +(match[6]); |
| 4931 |
|
| 4932 |
if (match[7]) { |
| 4933 |
fraction = match[7].slice(0, 3); |
| 4934 |
while (fraction.length < 3) { |
| 4935 |
fraction += '0'; |
| 4936 |
} |
| 4937 |
fraction = +fraction; |
| 4938 |
} |
| 4939 |
|
| 4940 |
if (match[9]) { |
| 4941 |
tz_hour = +(match[10]); |
| 4942 |
tz_minute = +(match[11] || 0); |
| 4943 |
delta = (tz_hour * 60 + tz_minute) * 60000; |
| 4944 |
if (match[9] === '-') delta = -delta; |
| 4945 |
} |
| 4946 |
|
| 4947 |
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); |
| 4948 |
|
| 4949 |
if (delta) date.setTime(date.getTime() - delta); |
| 4950 |
|
| 4951 |
return date; |
| 4952 |
} |
| 4953 |
|
| 4954 |
function representYamlTimestamp(object ) { |
| 4955 |
return object.toISOString(); |
| 4956 |
} |
| 4957 |
|
| 4958 |
module.exports = new Type('tag:yaml.org,2002:timestamp', { |
| 4959 |
kind: 'scalar', |
| 4960 |
resolve: resolveYamlTimestamp, |
| 4961 |
construct: constructYamlTimestamp, |
| 4962 |
instanceOf: Date, |
| 4963 |
represent: representYamlTimestamp |
| 4964 |
}); |
| 4965 |
|
| 4966 |
},{"../type":16}],33:[function(require,module,exports){ |
| 4967 |
(function (global){ |
| 4968 |
var LARGE_ARRAY_SIZE = 200; |
| 4969 |
var HASH_UNDEFINED = '__lodash_hash_undefined__'; |
| 4970 |
var HOT_COUNT = 800, |
| 4971 |
HOT_SPAN = 16; |
| 4972 |
var MAX_SAFE_INTEGER = 9007199254740991; |
| 4973 |
var argsTag = '[object Arguments]', |
| 4974 |
arrayTag = '[object Array]', |
| 4975 |
asyncTag = '[object AsyncFunction]', |
| 4976 |
boolTag = '[object Boolean]', |
| 4977 |
dateTag = '[object Date]', |
| 4978 |
errorTag = '[object Error]', |
| 4979 |
funcTag = '[object Function]', |
| 4980 |
genTag = '[object GeneratorFunction]', |
| 4981 |
mapTag = '[object Map]', |
| 4982 |
numberTag = '[object Number]', |
| 4983 |
nullTag = '[object Null]', |
| 4984 |
objectTag = '[object Object]', |
| 4985 |
proxyTag = '[object Proxy]', |
| 4986 |
regexpTag = '[object RegExp]', |
| 4987 |
setTag = '[object Set]', |
| 4988 |
stringTag = '[object String]', |
| 4989 |
undefinedTag = '[object Undefined]', |
| 4990 |
weakMapTag = '[object WeakMap]'; |
| 4991 |
|
| 4992 |
var arrayBufferTag = '[object ArrayBuffer]', |
| 4993 |
dataViewTag = '[object DataView]', |
| 4994 |
float32Tag = '[object Float32Array]', |
| 4995 |
float64Tag = '[object Float64Array]', |
| 4996 |
int8Tag = '[object Int8Array]', |
| 4997 |
int16Tag = '[object Int16Array]', |
| 4998 |
int32Tag = '[object Int32Array]', |
| 4999 |
uint8Tag = '[object Uint8Array]', |
| 5000 |
uint8ClampedTag = '[object Uint8ClampedArray]', |
| 5001 |
uint16Tag = '[object Uint16Array]', |
| 5002 |
uint32Tag = '[object Uint32Array]'; |
| 5003 |
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; |
| 5004 |
var reIsHostCtor = /^\[object .+?Constructor\]$/; |
| 5005 |
var reIsUint = /^(?:0|[1-9]\d*)$/; |
| 5006 |
var typedArrayTags = {}; |
| 5007 |
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = |
| 5008 |
typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = |
| 5009 |
typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = |
| 5010 |
typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = |
| 5011 |
typedArrayTags[uint32Tag] = true; |
| 5012 |
typedArrayTags[argsTag] = typedArrayTags[arrayTag] = |
| 5013 |
typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = |
| 5014 |
typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = |
| 5015 |
typedArrayTags[errorTag] = typedArrayTags[funcTag] = |
| 5016 |
typedArrayTags[mapTag] = typedArrayTags[numberTag] = |
| 5017 |
typedArrayTags[objectTag] = typedArrayTags[regexpTag] = |
| 5018 |
typedArrayTags[setTag] = typedArrayTags[stringTag] = |
| 5019 |
typedArrayTags[weakMapTag] = false; |
| 5020 |
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; |
| 5021 |
var freeSelf = typeof self == 'object' && self && self.Object === Object && self; |
| 5022 |
var root = freeGlobal || freeSelf || Function('return this')(); |
| 5023 |
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; |
| 5024 |
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; |
| 5025 |
var moduleExports = freeModule && freeModule.exports === freeExports; |
| 5026 |
var freeProcess = moduleExports && freeGlobal.process; |
| 5027 |
var nodeUtil = (function() { |
| 5028 |
try { |
| 5029 |
return freeProcess && freeProcess.binding && freeProcess.binding('util'); |
| 5030 |
} catch (e) {} |
| 5031 |
}()); |
| 5032 |
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; |
| 5033 |
function apply(func, thisArg, args) { |
| 5034 |
switch (args.length) { |
| 5035 |
case 0: return func.call(thisArg); |
| 5036 |
case 1: return func.call(thisArg, args[0]); |
| 5037 |
case 2: return func.call(thisArg, args[0], args[1]); |
| 5038 |
case 3: return func.call(thisArg, args[0], args[1], args[2]); |
| 5039 |
} |
| 5040 |
return func.apply(thisArg, args); |
| 5041 |
} |
| 5042 |
function baseTimes(n, iteratee) { |
| 5043 |
var index = -1, |
| 5044 |
result = Array(n); |
| 5045 |
|
| 5046 |
while (++index < n) { |
| 5047 |
result[index] = iteratee(index); |
| 5048 |
} |
| 5049 |
return result; |
| 5050 |
} |
| 5051 |
function baseUnary(func) { |
| 5052 |
return function(value) { |
| 5053 |
return func(value); |
| 5054 |
}; |
| 5055 |
} |
| 5056 |
function getValue(object, key) { |
| 5057 |
return object == null ? undefined : object[key]; |
| 5058 |
} |
| 5059 |
function overArg(func, transform) { |
| 5060 |
return function(arg) { |
| 5061 |
return func(transform(arg)); |
| 5062 |
}; |
| 5063 |
} |
| 5064 |
function safeGet(object, key) { |
| 5065 |
return key == '__proto__' |
| 5066 |
? undefined |
| 5067 |
: object[key]; |
| 5068 |
} |
| 5069 |
var arrayProto = Array.prototype, |
| 5070 |
funcProto = Function.prototype, |
| 5071 |
objectProto = Object.prototype; |
| 5072 |
var coreJsData = root['__core-js_shared__']; |
| 5073 |
var funcToString = funcProto.toString; |
| 5074 |
var hasOwnProperty = objectProto.hasOwnProperty; |
| 5075 |
var maskSrcKey = (function() { |
| 5076 |
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); |
| 5077 |
return uid ? ('Symbol(src)_1.' + uid) : ''; |
| 5078 |
}()); |
| 5079 |
var nativeObjectToString = objectProto.toString; |
| 5080 |
var objectCtorString = funcToString.call(Object); |
| 5081 |
var reIsNative = RegExp('^' + |
| 5082 |
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') |
| 5083 |
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' |
| 5084 |
); |
| 5085 |
var Buffer = moduleExports ? root.Buffer : undefined, |
| 5086 |
Symbol = root.Symbol, |
| 5087 |
Uint8Array = root.Uint8Array, |
| 5088 |
allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined, |
| 5089 |
getPrototype = overArg(Object.getPrototypeOf, Object), |
| 5090 |
objectCreate = Object.create, |
| 5091 |
propertyIsEnumerable = objectProto.propertyIsEnumerable, |
| 5092 |
splice = arrayProto.splice, |
| 5093 |
symToStringTag = Symbol ? Symbol.toStringTag : undefined; |
| 5094 |
|
| 5095 |
var defineProperty = (function() { |
| 5096 |
try { |
| 5097 |
var func = getNative(Object, 'defineProperty'); |
| 5098 |
func({}, '', {}); |
| 5099 |
return func; |
| 5100 |
} catch (e) {} |
| 5101 |
}()); |
| 5102 |
var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, |
| 5103 |
nativeMax = Math.max, |
| 5104 |
nativeNow = Date.now; |
| 5105 |
var Map = getNative(root, 'Map'), |
| 5106 |
nativeCreate = getNative(Object, 'create'); |
| 5107 |
var baseCreate = (function() { |
| 5108 |
function object() {} |
| 5109 |
return function(proto) { |
| 5110 |
if (!isObject(proto)) { |
| 5111 |
return {}; |
| 5112 |
} |
| 5113 |
if (objectCreate) { |
| 5114 |
return objectCreate(proto); |
| 5115 |
} |
| 5116 |
object.prototype = proto; |
| 5117 |
var result = new object; |
| 5118 |
object.prototype = undefined; |
| 5119 |
return result; |
| 5120 |
}; |
| 5121 |
}()); |
| 5122 |
function Hash(entries) { |
| 5123 |
var index = -1, |
| 5124 |
length = entries == null ? 0 : entries.length; |
| 5125 |
|
| 5126 |
this.clear(); |
| 5127 |
while (++index < length) { |
| 5128 |
var entry = entries[index]; |
| 5129 |
this.set(entry[0], entry[1]); |
| 5130 |
} |
| 5131 |
} |
| 5132 |
function hashClear() { |
| 5133 |
this.__data__ = nativeCreate ? nativeCreate(null) : {}; |
| 5134 |
this.size = 0; |
| 5135 |
} |
| 5136 |
function hashDelete(key) { |
| 5137 |
var result = this.has(key) && delete this.__data__[key]; |
| 5138 |
this.size -= result ? 1 : 0; |
| 5139 |
return result; |
| 5140 |
} |
| 5141 |
function hashGet(key) { |
| 5142 |
var data = this.__data__; |
| 5143 |
if (nativeCreate) { |
| 5144 |
var result = data[key]; |
| 5145 |
return result === HASH_UNDEFINED ? undefined : result; |
| 5146 |
} |
| 5147 |
return hasOwnProperty.call(data, key) ? data[key] : undefined; |
| 5148 |
} |
| 5149 |
function hashHas(key) { |
| 5150 |
var data = this.__data__; |
| 5151 |
return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); |
| 5152 |
} |
| 5153 |
function hashSet(key, value) { |
| 5154 |
var data = this.__data__; |
| 5155 |
this.size += this.has(key) ? 0 : 1; |
| 5156 |
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; |
| 5157 |
return this; |
| 5158 |
} |
| 5159 |
Hash.prototype.clear = hashClear; |
| 5160 |
Hash.prototype['delete'] = hashDelete; |
| 5161 |
Hash.prototype.get = hashGet; |
| 5162 |
Hash.prototype.has = hashHas; |
| 5163 |
Hash.prototype.set = hashSet; |
| 5164 |
function ListCache(entries) { |
| 5165 |
var index = -1, |
| 5166 |
length = entries == null ? 0 : entries.length; |
| 5167 |
|
| 5168 |
this.clear(); |
| 5169 |
while (++index < length) { |
| 5170 |
var entry = entries[index]; |
| 5171 |
this.set(entry[0], entry[1]); |
| 5172 |
} |
| 5173 |
} |
| 5174 |
function listCacheClear() { |
| 5175 |
this.__data__ = []; |
| 5176 |
this.size = 0; |
| 5177 |
} |
| 5178 |
function listCacheDelete(key) { |
| 5179 |
var data = this.__data__, |
| 5180 |
index = assocIndexOf(data, key); |
| 5181 |
|
| 5182 |
if (index < 0) { |
| 5183 |
return false; |
| 5184 |
} |
| 5185 |
var lastIndex = data.length - 1; |
| 5186 |
if (index == lastIndex) { |
| 5187 |
data.pop(); |
| 5188 |
} else { |
| 5189 |
splice.call(data, index, 1); |
| 5190 |
} |
| 5191 |
--this.size; |
| 5192 |
return true; |
| 5193 |
} |
| 5194 |
function listCacheGet(key) { |
| 5195 |
var data = this.__data__, |
| 5196 |
index = assocIndexOf(data, key); |
| 5197 |
|
| 5198 |
return index < 0 ? undefined : data[index][1]; |
| 5199 |
} |
| 5200 |
function listCacheHas(key) { |
| 5201 |
return assocIndexOf(this.__data__, key) > -1; |
| 5202 |
} |
| 5203 |
function listCacheSet(key, value) { |
| 5204 |
var data = this.__data__, |
| 5205 |
index = assocIndexOf(data, key); |
| 5206 |
|
| 5207 |
if (index < 0) { |
| 5208 |
++this.size; |
| 5209 |
data.push([key, value]); |
| 5210 |
} else { |
| 5211 |
data[index][1] = value; |
| 5212 |
} |
| 5213 |
return this; |
| 5214 |
} |
| 5215 |
ListCache.prototype.clear = listCacheClear; |
| 5216 |
ListCache.prototype['delete'] = listCacheDelete; |
| 5217 |
ListCache.prototype.get = listCacheGet; |
| 5218 |
ListCache.prototype.has = listCacheHas; |
| 5219 |
ListCache.prototype.set = listCacheSet; |
| 5220 |
function MapCache(entries) { |
| 5221 |
var index = -1, |
| 5222 |
length = entries == null ? 0 : entries.length; |
| 5223 |
|
| 5224 |
this.clear(); |
| 5225 |
while (++index < length) { |
| 5226 |
var entry = entries[index]; |
| 5227 |
this.set(entry[0], entry[1]); |
| 5228 |
} |
| 5229 |
} |
| 5230 |
function mapCacheClear() { |
| 5231 |
this.size = 0; |
| 5232 |
this.__data__ = { |
| 5233 |
'hash': new Hash, |
| 5234 |
'map': new (Map || ListCache), |
| 5235 |
'string': new Hash |
| 5236 |
}; |
| 5237 |
} |
| 5238 |
function mapCacheDelete(key) { |
| 5239 |
var result = getMapData(this, key)['delete'](key); |
| 5240 |
this.size -= result ? 1 : 0; |
| 5241 |
return result; |
| 5242 |
} |
| 5243 |
function mapCacheGet(key) { |
| 5244 |
return getMapData(this, key).get(key); |
| 5245 |
} |
| 5246 |
function mapCacheHas(key) { |
| 5247 |
return getMapData(this, key).has(key); |
| 5248 |
} |
| 5249 |
function mapCacheSet(key, value) { |
| 5250 |
var data = getMapData(this, key), |
| 5251 |
size = data.size; |
| 5252 |
|
| 5253 |
data.set(key, value); |
| 5254 |
this.size += data.size == size ? 0 : 1; |
| 5255 |
return this; |
| 5256 |
} |
| 5257 |
MapCache.prototype.clear = mapCacheClear; |
| 5258 |
MapCache.prototype['delete'] = mapCacheDelete; |
| 5259 |
MapCache.prototype.get = mapCacheGet; |
| 5260 |
MapCache.prototype.has = mapCacheHas; |
| 5261 |
MapCache.prototype.set = mapCacheSet; |
| 5262 |
function Stack(entries) { |
| 5263 |
var data = this.__data__ = new ListCache(entries); |
| 5264 |
this.size = data.size; |
| 5265 |
} |
| 5266 |
function stackClear() { |
| 5267 |
this.__data__ = new ListCache; |
| 5268 |
this.size = 0; |
| 5269 |
} |
| 5270 |
function stackDelete(key) { |
| 5271 |
var data = this.__data__, |
| 5272 |
result = data['delete'](key); |
| 5273 |
|
| 5274 |
this.size = data.size; |
| 5275 |
return result; |
| 5276 |
} |
| 5277 |
function stackGet(key) { |
| 5278 |
return this.__data__.get(key); |
| 5279 |
} |
| 5280 |
function stackHas(key) { |
| 5281 |
return this.__data__.has(key); |
| 5282 |
} |
| 5283 |
function stackSet(key, value) { |
| 5284 |
var data = this.__data__; |
| 5285 |
if (data instanceof ListCache) { |
| 5286 |
var pairs = data.__data__; |
| 5287 |
if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { |
| 5288 |
pairs.push([key, value]); |
| 5289 |
this.size = ++data.size; |
| 5290 |
return this; |
| 5291 |
} |
| 5292 |
data = this.__data__ = new MapCache(pairs); |
| 5293 |
} |
| 5294 |
data.set(key, value); |
| 5295 |
this.size = data.size; |
| 5296 |
return this; |
| 5297 |
} |
| 5298 |
Stack.prototype.clear = stackClear; |
| 5299 |
Stack.prototype['delete'] = stackDelete; |
| 5300 |
Stack.prototype.get = stackGet; |
| 5301 |
Stack.prototype.has = stackHas; |
| 5302 |
Stack.prototype.set = stackSet; |
| 5303 |
function arrayLikeKeys(value, inherited) { |
| 5304 |
var isArr = isArray(value), |
| 5305 |
isArg = !isArr && isArguments(value), |
| 5306 |
isBuff = !isArr && !isArg && isBuffer(value), |
| 5307 |
isType = !isArr && !isArg && !isBuff && isTypedArray(value), |
| 5308 |
skipIndexes = isArr || isArg || isBuff || isType, |
| 5309 |
result = skipIndexes ? baseTimes(value.length, String) : [], |
| 5310 |
length = result.length; |
| 5311 |
|
| 5312 |
for (var key in value) { |
| 5313 |
if ((inherited || hasOwnProperty.call(value, key)) && |
| 5314 |
!(skipIndexes && ( |
| 5315 |
key == 'length' || |
| 5316 |
(isBuff && (key == 'offset' || key == 'parent')) || |
| 5317 |
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || |
| 5318 |
isIndex(key, length) |
| 5319 |
))) { |
| 5320 |
result.push(key); |
| 5321 |
} |
| 5322 |
} |
| 5323 |
return result; |
| 5324 |
} |
| 5325 |
function assignMergeValue(object, key, value) { |
| 5326 |
if ((value !== undefined && !eq(object[key], value)) || |
| 5327 |
(value === undefined && !(key in object))) { |
| 5328 |
baseAssignValue(object, key, value); |
| 5329 |
} |
| 5330 |
} |
| 5331 |
function assignValue(object, key, value) { |
| 5332 |
var objValue = object[key]; |
| 5333 |
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || |
| 5334 |
(value === undefined && !(key in object))) { |
| 5335 |
baseAssignValue(object, key, value); |
| 5336 |
} |
| 5337 |
} |
| 5338 |
function assocIndexOf(array, key) { |
| 5339 |
var length = array.length; |
| 5340 |
while (length--) { |
| 5341 |
if (eq(array[length][0], key)) { |
| 5342 |
return length; |
| 5343 |
} |
| 5344 |
} |
| 5345 |
return -1; |
| 5346 |
} |
| 5347 |
function baseAssignValue(object, key, value) { |
| 5348 |
if (key == '__proto__' && defineProperty) { |
| 5349 |
defineProperty(object, key, { |
| 5350 |
'configurable': true, |
| 5351 |
'enumerable': true, |
| 5352 |
'value': value, |
| 5353 |
'writable': true |
| 5354 |
}); |
| 5355 |
} else { |
| 5356 |
object[key] = value; |
| 5357 |
} |
| 5358 |
} |
| 5359 |
var baseFor = createBaseFor(); |
| 5360 |
function baseGetTag(value) { |
| 5361 |
if (value == null) { |
| 5362 |
return value === undefined ? undefinedTag : nullTag; |
| 5363 |
} |
| 5364 |
return (symToStringTag && symToStringTag in Object(value)) |
| 5365 |
? getRawTag(value) |
| 5366 |
: objectToString(value); |
| 5367 |
} |
| 5368 |
function baseIsArguments(value) { |
| 5369 |
return isObjectLike(value) && baseGetTag(value) == argsTag; |
| 5370 |
} |
| 5371 |
function baseIsNative(value) { |
| 5372 |
if (!isObject(value) || isMasked(value)) { |
| 5373 |
return false; |
| 5374 |
} |
| 5375 |
var pattern = isFunction(value) ? reIsNative : reIsHostCtor; |
| 5376 |
return pattern.test(toSource(value)); |
| 5377 |
} |
| 5378 |
function baseIsTypedArray(value) { |
| 5379 |
return isObjectLike(value) && |
| 5380 |
isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; |
| 5381 |
} |
| 5382 |
function baseKeysIn(object) { |
| 5383 |
if (!isObject(object)) { |
| 5384 |
return nativeKeysIn(object); |
| 5385 |
} |
| 5386 |
var isProto = isPrototype(object), |
| 5387 |
result = []; |
| 5388 |
|
| 5389 |
for (var key in object) { |
| 5390 |
if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { |
| 5391 |
result.push(key); |
| 5392 |
} |
| 5393 |
} |
| 5394 |
return result; |
| 5395 |
} |
| 5396 |
function baseMerge(object, source, srcIndex, customizer, stack) { |
| 5397 |
if (object === source) { |
| 5398 |
return; |
| 5399 |
} |
| 5400 |
baseFor(source, function(srcValue, key) { |
| 5401 |
if (isObject(srcValue)) { |
| 5402 |
stack || (stack = new Stack); |
| 5403 |
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); |
| 5404 |
} |
| 5405 |
else { |
| 5406 |
var newValue = customizer |
| 5407 |
? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) |
| 5408 |
: undefined; |
| 5409 |
|
| 5410 |
if (newValue === undefined) { |
| 5411 |
newValue = srcValue; |
| 5412 |
} |
| 5413 |
assignMergeValue(object, key, newValue); |
| 5414 |
} |
| 5415 |
}, keysIn); |
| 5416 |
} |
| 5417 |
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { |
| 5418 |
var objValue = safeGet(object, key), |
| 5419 |
srcValue = safeGet(source, key), |
| 5420 |
stacked = stack.get(srcValue); |
| 5421 |
|
| 5422 |
if (stacked) { |
| 5423 |
assignMergeValue(object, key, stacked); |
| 5424 |
return; |
| 5425 |
} |
| 5426 |
var newValue = customizer |
| 5427 |
? customizer(objValue, srcValue, (key + ''), object, source, stack) |
| 5428 |
: undefined; |
| 5429 |
|
| 5430 |
var isCommon = newValue === undefined; |
| 5431 |
|
| 5432 |
if (isCommon) { |
| 5433 |
var isArr = isArray(srcValue), |
| 5434 |
isBuff = !isArr && isBuffer(srcValue), |
| 5435 |
isTyped = !isArr && !isBuff && isTypedArray(srcValue); |
| 5436 |
|
| 5437 |
newValue = srcValue; |
| 5438 |
if (isArr || isBuff || isTyped) { |
| 5439 |
if (isArray(objValue)) { |
| 5440 |
newValue = objValue; |
| 5441 |
} |
| 5442 |
else if (isArrayLikeObject(objValue)) { |
| 5443 |
newValue = copyArray(objValue); |
| 5444 |
} |
| 5445 |
else if (isBuff) { |
| 5446 |
isCommon = false; |
| 5447 |
newValue = cloneBuffer(srcValue, true); |
| 5448 |
} |
| 5449 |
else if (isTyped) { |
| 5450 |
isCommon = false; |
| 5451 |
newValue = cloneTypedArray(srcValue, true); |
| 5452 |
} |
| 5453 |
else { |
| 5454 |
newValue = []; |
| 5455 |
} |
| 5456 |
} |
| 5457 |
else if (isPlainObject(srcValue) || isArguments(srcValue)) { |
| 5458 |
newValue = objValue; |
| 5459 |
if (isArguments(objValue)) { |
| 5460 |
newValue = toPlainObject(objValue); |
| 5461 |
} |
| 5462 |
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) { |
| 5463 |
newValue = initCloneObject(srcValue); |
| 5464 |
} |
| 5465 |
} |
| 5466 |
else { |
| 5467 |
isCommon = false; |
| 5468 |
} |
| 5469 |
} |
| 5470 |
if (isCommon) { |
| 5471 |
stack.set(srcValue, newValue); |
| 5472 |
mergeFunc(newValue, srcValue, srcIndex, customizer, stack); |
| 5473 |
stack['delete'](srcValue); |
| 5474 |
} |
| 5475 |
assignMergeValue(object, key, newValue); |
| 5476 |
} |
| 5477 |
function baseRest(func, start) { |
| 5478 |
return setToString(overRest(func, start, identity), func + ''); |
| 5479 |
} |
| 5480 |
var baseSetToString = !defineProperty ? identity : function(func, string) { |
| 5481 |
return defineProperty(func, 'toString', { |
| 5482 |
'configurable': true, |
| 5483 |
'enumerable': false, |
| 5484 |
'value': constant(string), |
| 5485 |
'writable': true |
| 5486 |
}); |
| 5487 |
}; |
| 5488 |
function cloneBuffer(buffer, isDeep) { |
| 5489 |
if (isDeep) { |
| 5490 |
return buffer.slice(); |
| 5491 |
} |
| 5492 |
var length = buffer.length, |
| 5493 |
result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); |
| 5494 |
|
| 5495 |
buffer.copy(result); |
| 5496 |
return result; |
| 5497 |
} |
| 5498 |
function cloneArrayBuffer(arrayBuffer) { |
| 5499 |
var result = new arrayBuffer.constructor(arrayBuffer.byteLength); |
| 5500 |
new Uint8Array(result).set(new Uint8Array(arrayBuffer)); |
| 5501 |
return result; |
| 5502 |
} |
| 5503 |
function cloneTypedArray(typedArray, isDeep) { |
| 5504 |
var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; |
| 5505 |
return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); |
| 5506 |
} |
| 5507 |
function copyArray(source, array) { |
| 5508 |
var index = -1, |
| 5509 |
length = source.length; |
| 5510 |
|
| 5511 |
array || (array = Array(length)); |
| 5512 |
while (++index < length) { |
| 5513 |
array[index] = source[index]; |
| 5514 |
} |
| 5515 |
return array; |
| 5516 |
} |
| 5517 |
function copyObject(source, props, object, customizer) { |
| 5518 |
var isNew = !object; |
| 5519 |
object || (object = {}); |
| 5520 |
|
| 5521 |
var index = -1, |
| 5522 |
length = props.length; |
| 5523 |
|
| 5524 |
while (++index < length) { |
| 5525 |
var key = props[index]; |
| 5526 |
|
| 5527 |
var newValue = customizer |
| 5528 |
? customizer(object[key], source[key], key, object, source) |
| 5529 |
: undefined; |
| 5530 |
|
| 5531 |
if (newValue === undefined) { |
| 5532 |
newValue = source[key]; |
| 5533 |
} |
| 5534 |
if (isNew) { |
| 5535 |
baseAssignValue(object, key, newValue); |
| 5536 |
} else { |
| 5537 |
assignValue(object, key, newValue); |
| 5538 |
} |
| 5539 |
} |
| 5540 |
return object; |
| 5541 |
} |
| 5542 |
function createAssigner(assigner) { |
| 5543 |
return baseRest(function(object, sources) { |
| 5544 |
var index = -1, |
| 5545 |
length = sources.length, |
| 5546 |
customizer = length > 1 ? sources[length - 1] : undefined, |
| 5547 |
guard = length > 2 ? sources[2] : undefined; |
| 5548 |
|
| 5549 |
customizer = (assigner.length > 3 && typeof customizer == 'function') |
| 5550 |
? (length--, customizer) |
| 5551 |
: undefined; |
| 5552 |
|
| 5553 |
if (guard && isIterateeCall(sources[0], sources[1], guard)) { |
| 5554 |
customizer = length < 3 ? undefined : customizer; |
| 5555 |
length = 1; |
| 5556 |
} |
| 5557 |
object = Object(object); |
| 5558 |
while (++index < length) { |
| 5559 |
var source = sources[index]; |
| 5560 |
if (source) { |
| 5561 |
assigner(object, source, index, customizer); |
| 5562 |
} |
| 5563 |
} |
| 5564 |
return object; |
| 5565 |
}); |
| 5566 |
} |
| 5567 |
function createBaseFor(fromRight) { |
| 5568 |
return function(object, iteratee, keysFunc) { |
| 5569 |
var index = -1, |
| 5570 |
iterable = Object(object), |
| 5571 |
props = keysFunc(object), |
| 5572 |
length = props.length; |
| 5573 |
|
| 5574 |
while (length--) { |
| 5575 |
var key = props[fromRight ? length : ++index]; |
| 5576 |
if (iteratee(iterable[key], key, iterable) === false) { |
| 5577 |
break; |
| 5578 |
} |
| 5579 |
} |
| 5580 |
return object; |
| 5581 |
}; |
| 5582 |
} |
| 5583 |
function getMapData(map, key) { |
| 5584 |
var data = map.__data__; |
| 5585 |
return isKeyable(key) |
| 5586 |
? data[typeof key == 'string' ? 'string' : 'hash'] |
| 5587 |
: data.map; |
| 5588 |
} |
| 5589 |
function getNative(object, key) { |
| 5590 |
var value = getValue(object, key); |
| 5591 |
return baseIsNative(value) ? value : undefined; |
| 5592 |
} |
| 5593 |
function getRawTag(value) { |
| 5594 |
var isOwn = hasOwnProperty.call(value, symToStringTag), |
| 5595 |
tag = value[symToStringTag]; |
| 5596 |
|
| 5597 |
try { |
| 5598 |
value[symToStringTag] = undefined; |
| 5599 |
var unmasked = true; |
| 5600 |
} catch (e) {} |
| 5601 |
|
| 5602 |
var result = nativeObjectToString.call(value); |
| 5603 |
if (unmasked) { |
| 5604 |
if (isOwn) { |
| 5605 |
value[symToStringTag] = tag; |
| 5606 |
} else { |
| 5607 |
delete value[symToStringTag]; |
| 5608 |
} |
| 5609 |
} |
| 5610 |
return result; |
| 5611 |
} |
| 5612 |
function initCloneObject(object) { |
| 5613 |
return (typeof object.constructor == 'function' && !isPrototype(object)) |
| 5614 |
? baseCreate(getPrototype(object)) |
| 5615 |
: {}; |
| 5616 |
} |
| 5617 |
function isIndex(value, length) { |
| 5618 |
var type = typeof value; |
| 5619 |
length = length == null ? MAX_SAFE_INTEGER : length; |
| 5620 |
|
| 5621 |
return !!length && |
| 5622 |
(type == 'number' || |
| 5623 |
(type != 'symbol' && reIsUint.test(value))) && |
| 5624 |
(value > -1 && value % 1 == 0 && value < length); |
| 5625 |
} |
| 5626 |
function isIterateeCall(value, index, object) { |
| 5627 |
if (!isObject(object)) { |
| 5628 |
return false; |
| 5629 |
} |
| 5630 |
var type = typeof index; |
| 5631 |
if (type == 'number' |
| 5632 |
? (isArrayLike(object) && isIndex(index, object.length)) |
| 5633 |
: (type == 'string' && index in object) |
| 5634 |
) { |
| 5635 |
return eq(object[index], value); |
| 5636 |
} |
| 5637 |
return false; |
| 5638 |
} |
| 5639 |
function isKeyable(value) { |
| 5640 |
var type = typeof value; |
| 5641 |
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') |
| 5642 |
? (value !== '__proto__') |
| 5643 |
: (value === null); |
| 5644 |
} |
| 5645 |
function isMasked(func) { |
| 5646 |
return !!maskSrcKey && (maskSrcKey in func); |
| 5647 |
} |
| 5648 |
function isPrototype(value) { |
| 5649 |
var Ctor = value && value.constructor, |
| 5650 |
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; |
| 5651 |
|
| 5652 |
return value === proto; |
| 5653 |
} |
| 5654 |
function nativeKeysIn(object) { |
| 5655 |
var result = []; |
| 5656 |
if (object != null) { |
| 5657 |
for (var key in Object(object)) { |
| 5658 |
result.push(key); |
| 5659 |
} |
| 5660 |
} |
| 5661 |
return result; |
| 5662 |
} |
| 5663 |
function objectToString(value) { |
| 5664 |
return nativeObjectToString.call(value); |
| 5665 |
} |
| 5666 |
function overRest(func, start, transform) { |
| 5667 |
start = nativeMax(start === undefined ? (func.length - 1) : start, 0); |
| 5668 |
return function() { |
| 5669 |
var args = arguments, |
| 5670 |
index = -1, |
| 5671 |
length = nativeMax(args.length - start, 0), |
| 5672 |
array = Array(length); |
| 5673 |
|
| 5674 |
while (++index < length) { |
| 5675 |
array[index] = args[start + index]; |
| 5676 |
} |
| 5677 |
index = -1; |
| 5678 |
var otherArgs = Array(start + 1); |
| 5679 |
while (++index < start) { |
| 5680 |
otherArgs[index] = args[index]; |
| 5681 |
} |
| 5682 |
otherArgs[start] = transform(array); |
| 5683 |
return apply(func, this, otherArgs); |
| 5684 |
}; |
| 5685 |
} |
| 5686 |
var setToString = shortOut(baseSetToString); |
| 5687 |
function shortOut(func) { |
| 5688 |
var count = 0, |
| 5689 |
lastCalled = 0; |
| 5690 |
|
| 5691 |
return function() { |
| 5692 |
var stamp = nativeNow(), |
| 5693 |
remaining = HOT_SPAN - (stamp - lastCalled); |
| 5694 |
|
| 5695 |
lastCalled = stamp; |
| 5696 |
if (remaining > 0) { |
| 5697 |
if (++count >= HOT_COUNT) { |
| 5698 |
return arguments[0]; |
| 5699 |
} |
| 5700 |
} else { |
| 5701 |
count = 0; |
| 5702 |
} |
| 5703 |
return func.apply(undefined, arguments); |
| 5704 |
}; |
| 5705 |
} |
| 5706 |
function toSource(func) { |
| 5707 |
if (func != null) { |
| 5708 |
try { |
| 5709 |
return funcToString.call(func); |
| 5710 |
} catch (e) {} |
| 5711 |
try { |
| 5712 |
return (func + ''); |
| 5713 |
} catch (e) {} |
| 5714 |
} |
| 5715 |
return ''; |
| 5716 |
} |
| 5717 |
function eq(value, other) { |
| 5718 |
return value === other || (value !== value && other !== other); |
| 5719 |
} |
| 5720 |
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { |
| 5721 |
return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && |
| 5722 |
!propertyIsEnumerable.call(value, 'callee'); |
| 5723 |
}; |
| 5724 |
var isArray = Array.isArray; |
| 5725 |
function isArrayLike(value) { |
| 5726 |
return value != null && isLength(value.length) && !isFunction(value); |
| 5727 |
} |
| 5728 |
function isArrayLikeObject(value) { |
| 5729 |
return isObjectLike(value) && isArrayLike(value); |
| 5730 |
} |
| 5731 |
var isBuffer = nativeIsBuffer || stubFalse; |
| 5732 |
function isFunction(value) { |
| 5733 |
if (!isObject(value)) { |
| 5734 |
return false; |
| 5735 |
} |
| 5736 |
var tag = baseGetTag(value); |
| 5737 |
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; |
| 5738 |
} |
| 5739 |
function isLength(value) { |
| 5740 |
return typeof value == 'number' && |
| 5741 |
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; |
| 5742 |
} |
| 5743 |
function isObject(value) { |
| 5744 |
var type = typeof value; |
| 5745 |
return value != null && (type == 'object' || type == 'function'); |
| 5746 |
} |
| 5747 |
function isObjectLike(value) { |
| 5748 |
return value != null && typeof value == 'object'; |
| 5749 |
} |
| 5750 |
function isPlainObject(value) { |
| 5751 |
if (!isObjectLike(value) || baseGetTag(value) != objectTag) { |
| 5752 |
return false; |
| 5753 |
} |
| 5754 |
var proto = getPrototype(value); |
| 5755 |
if (proto === null) { |
| 5756 |
return true; |
| 5757 |
} |
| 5758 |
var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; |
| 5759 |
return typeof Ctor == 'function' && Ctor instanceof Ctor && |
| 5760 |
funcToString.call(Ctor) == objectCtorString; |
| 5761 |
} |
| 5762 |
var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; |
| 5763 |
function toPlainObject(value) { |
| 5764 |
return copyObject(value, keysIn(value)); |
| 5765 |
} |
| 5766 |
function keysIn(object) { |
| 5767 |
return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); |
| 5768 |
} |
| 5769 |
var merge = createAssigner(function(object, source, srcIndex) { |
| 5770 |
baseMerge(object, source, srcIndex); |
| 5771 |
}); |
| 5772 |
function constant(value) { |
| 5773 |
return function() { |
| 5774 |
return value; |
| 5775 |
}; |
| 5776 |
} |
| 5777 |
function identity(value) { |
| 5778 |
return value; |
| 5779 |
} |
| 5780 |
function stubFalse() { |
| 5781 |
return false; |
| 5782 |
} |
| 5783 |
|
| 5784 |
module.exports = merge; |
| 5785 |
|
| 5786 |
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}); |
| 5787 |
},{}]},{},[2])(2); |
| 5788 |
}); |
| 5789 |
}); |
| 5790 |
|
| 5791 |
ace.define("ace/mode/yaml_worker",[], function(require, exports) { |
| 5792 |
"use strict"; |
| 5793 |
|
| 5794 |
var oop = require("../lib/oop"); |
| 5795 |
var Mirror = require("../worker/mirror").Mirror; |
| 5796 |
var lint = require("./yaml/yaml-lint").lint; |
| 5797 |
|
| 5798 |
var YamlWorker = exports.YamlWorker = function(sender) { |
| 5799 |
Mirror.call(this, sender); |
| 5800 |
this.setTimeout(500); |
| 5801 |
this.setOptions(); |
| 5802 |
}; |
| 5803 |
|
| 5804 |
oop.inherits(YamlWorker, Mirror); |
| 5805 |
|
| 5806 |
(function() { |
| 5807 |
this.setOptions = function() { |
| 5808 |
this.doc.getValue() && this.deferredUpdate.schedule(100); |
| 5809 |
}; |
| 5810 |
|
| 5811 |
this.changeOptions = function(newOptions) { |
| 5812 |
oop.mixin(this.options, newOptions); |
| 5813 |
this.doc.getValue() && this.deferredUpdate.schedule(100); |
| 5814 |
}; |
| 5815 |
|
| 5816 |
this.onUpdate = function() { |
| 5817 |
var _this = this; |
| 5818 |
var value = this.doc.getValue(); |
| 5819 |
var errors = []; |
| 5820 |
|
| 5821 |
lint(value, {}, function(error) { |
| 5822 |
if (!error) { |
| 5823 |
_this.sender.emit("annotate", errors); |
| 5824 |
return; |
| 5825 |
} |
| 5826 |
var markDefined = !!error.mark; |
| 5827 |
errors.push({ |
| 5828 |
row: markDefined ? error.mark.line : 0, |
| 5829 |
column: markDefined ? error.mark.column : 0, |
| 5830 |
text: error.reason, |
| 5831 |
type: 'error', |
| 5832 |
raw: error |
| 5833 |
}); |
| 5834 |
|
| 5835 |
_this.sender.emit("annotate", errors); |
| 5836 |
}); |
| 5837 |
}; |
| 5838 |
|
| 5839 |
}).call(YamlWorker.prototype); |
| 5840 |
|
| 5841 |
}); |