- // ==UserScript==
- // @name bgm-wiki-rev-diff
- // @namespace https://trim21.me/
- // @version 0.0.1
- // @author Trim21 <i@trim21.me>
- // @source https://github.com/Trim21/bgm-wiki-rev-diff
- // @license MIT
- // @match https://bgm.tv/subject/*/edit*
- // @require https://cdn.jsdelivr.net/npm/jquery@^3.5.0/dist/jquery.min.js
- // @grant GM_xmlhttpRequest
- // @connect bgm.tv
- // @run-at document-end
- // @description show diff between bgm.tv wiki versions
- // ==/UserScript==
-
- /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId]) {
- /******/ return installedModules[moduleId].exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
- /******/ }
- /******/ };
- /******/
- /******/ // define __esModule on exports
- /******/ __webpack_require__.r = function(exports) {
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
- /******/ }
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
- /******/ };
- /******/
- /******/ // create a fake namespace object
- /******/ // mode & 1: value is a module id, require it
- /******/ // mode & 2: merge all properties of value into the ns
- /******/ // mode & 4: return value when already ns object
- /******/ // mode & 8|1: behave like require
- /******/ __webpack_require__.t = function(value, mode) {
- /******/ if(mode & 1) value = __webpack_require__(value);
- /******/ if(mode & 8) return value;
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
- /******/ var ns = Object.create(null);
- /******/ __webpack_require__.r(ns);
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
- /******/ return ns;
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "";
- /******/
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = "e6Wu");
- /******/ })
- /************************************************************************/
- /******/ ({
-
- /***/ "1gqn":
- /***/ (function(module, exports) {
-
- module.exports = function isBuffer(arg) {
- return arg && typeof arg === 'object'
- && typeof arg.copy === 'function'
- && typeof arg.fill === 'function'
- && typeof arg.readUInt8 === 'function';
- }
-
- /***/ }),
-
- /***/ "7Mwc":
- /***/ (function(module, exports, __webpack_require__) {
-
- module.exports = __webpack_require__("qVjC");
-
-
- /***/ }),
-
- /***/ "8oxB":
- /***/ (function(module, exports) {
-
- // shim for using process in browser
- var process = module.exports = {};
-
- // cached from whatever global is present so that test runners that stub it
- // don't break things. But we need to wrap it in a try catch in case it is
- // wrapped in strict mode code which doesn't define any globals. It's inside a
- // function because try/catches deoptimize in certain engines.
-
- var cachedSetTimeout;
- var cachedClearTimeout;
-
- function defaultSetTimout() {
- throw new Error('setTimeout has not been defined');
- }
- function defaultClearTimeout () {
- throw new Error('clearTimeout has not been defined');
- }
- (function () {
- try {
- if (typeof setTimeout === 'function') {
- cachedSetTimeout = setTimeout;
- } else {
- cachedSetTimeout = defaultSetTimout;
- }
- } catch (e) {
- cachedSetTimeout = defaultSetTimout;
- }
- try {
- if (typeof clearTimeout === 'function') {
- cachedClearTimeout = clearTimeout;
- } else {
- cachedClearTimeout = defaultClearTimeout;
- }
- } catch (e) {
- cachedClearTimeout = defaultClearTimeout;
- }
- } ())
- function runTimeout(fun) {
- if (cachedSetTimeout === setTimeout) {
- //normal enviroments in sane situations
- return setTimeout(fun, 0);
- }
- // if setTimeout wasn't available but was latter defined
- if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
- cachedSetTimeout = setTimeout;
- return setTimeout(fun, 0);
- }
- try {
- // when when somebody has screwed with setTimeout but no I.E. maddness
- return cachedSetTimeout(fun, 0);
- } catch(e){
- try {
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
- return cachedSetTimeout.call(null, fun, 0);
- } catch(e){
- // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
- return cachedSetTimeout.call(this, fun, 0);
- }
- }
-
-
- }
- function runClearTimeout(marker) {
- if (cachedClearTimeout === clearTimeout) {
- //normal enviroments in sane situations
- return clearTimeout(marker);
- }
- // if clearTimeout wasn't available but was latter defined
- if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
- cachedClearTimeout = clearTimeout;
- return clearTimeout(marker);
- }
- try {
- // when when somebody has screwed with setTimeout but no I.E. maddness
- return cachedClearTimeout(marker);
- } catch (e){
- try {
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
- return cachedClearTimeout.call(null, marker);
- } catch (e){
- // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
- // Some versions of I.E. have different rules for clearTimeout vs setTimeout
- return cachedClearTimeout.call(this, marker);
- }
- }
-
-
-
- }
- var queue = [];
- var draining = false;
- var currentQueue;
- var queueIndex = -1;
-
- function cleanUpNextTick() {
- if (!draining || !currentQueue) {
- return;
- }
- draining = false;
- if (currentQueue.length) {
- queue = currentQueue.concat(queue);
- } else {
- queueIndex = -1;
- }
- if (queue.length) {
- drainQueue();
- }
- }
-
- function drainQueue() {
- if (draining) {
- return;
- }
- var timeout = runTimeout(cleanUpNextTick);
- draining = true;
-
- var len = queue.length;
- while(len) {
- currentQueue = queue;
- queue = [];
- while (++queueIndex < len) {
- if (currentQueue) {
- currentQueue[queueIndex].run();
- }
- }
- queueIndex = -1;
- len = queue.length;
- }
- currentQueue = null;
- draining = false;
- runClearTimeout(timeout);
- }
-
- process.nextTick = function (fun) {
- var args = new Array(arguments.length - 1);
- if (arguments.length > 1) {
- for (var i = 1; i < arguments.length; i++) {
- args[i - 1] = arguments[i];
- }
- }
- queue.push(new Item(fun, args));
- if (queue.length === 1 && !draining) {
- runTimeout(drainQueue);
- }
- };
-
- // v8 likes predictible objects
- function Item(fun, array) {
- this.fun = fun;
- this.array = array;
- }
- Item.prototype.run = function () {
- this.fun.apply(null, this.array);
- };
- process.title = 'browser';
- process.browser = true;
- process.env = {};
- process.argv = [];
- process.version = ''; // empty string to avoid regexp issues
- process.versions = {};
-
- function noop() {}
-
- process.on = noop;
- process.addListener = noop;
- process.once = noop;
- process.off = noop;
- process.removeListener = noop;
- process.removeAllListeners = noop;
- process.emit = noop;
- process.prependListener = noop;
- process.prependOnceListener = noop;
-
- process.listeners = function (name) { return [] }
-
- process.binding = function (name) {
- throw new Error('process.binding is not supported');
- };
-
- process.cwd = function () { return '/' };
- process.chdir = function (dir) {
- throw new Error('process.chdir is not supported');
- };
- process.umask = function() { return 0; };
-
-
- /***/ }),
-
- /***/ "9lTW":
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /* WEBPACK VAR INJECTION */(function(global) {
-
- var objectAssign = __webpack_require__("MgzW");
-
- // compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
- // original notice:
-
- /*!
- * The buffer module from node.js, for the browser.
- *
- * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
- * @license MIT
- */
- function compare(a, b) {
- if (a === b) {
- return 0;
- }
-
- var x = a.length;
- var y = b.length;
-
- for (var i = 0, len = Math.min(x, y); i < len; ++i) {
- if (a[i] !== b[i]) {
- x = a[i];
- y = b[i];
- break;
- }
- }
-
- if (x < y) {
- return -1;
- }
- if (y < x) {
- return 1;
- }
- return 0;
- }
- function isBuffer(b) {
- if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
- return global.Buffer.isBuffer(b);
- }
- return !!(b != null && b._isBuffer);
- }
-
- // based on node assert, original notice:
- // NB: The URL to the CommonJS spec is kept just for tradition.
- // node-assert has evolved a lot since then, both in API and behavior.
-
- // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
- //
- // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
- //
- // Originally from narwhal.js (http://narwhaljs.org)
- // Copyright (c) 2009 Thomas Robinson <280north.com>
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the 'Software'), to
- // deal in the Software without restriction, including without limitation the
- // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- // sell copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- var util = __webpack_require__("MCLT");
- var hasOwn = Object.prototype.hasOwnProperty;
- var pSlice = Array.prototype.slice;
- var functionsHaveNames = (function () {
- return function foo() {}.name === 'foo';
- }());
- function pToString (obj) {
- return Object.prototype.toString.call(obj);
- }
- function isView(arrbuf) {
- if (isBuffer(arrbuf)) {
- return false;
- }
- if (typeof global.ArrayBuffer !== 'function') {
- return false;
- }
- if (typeof ArrayBuffer.isView === 'function') {
- return ArrayBuffer.isView(arrbuf);
- }
- if (!arrbuf) {
- return false;
- }
- if (arrbuf instanceof DataView) {
- return true;
- }
- if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
- return true;
- }
- return false;
- }
- // 1. The assert module provides functions that throw
- // AssertionError's when particular conditions are not met. The
- // assert module must conform to the following interface.
-
- var assert = module.exports = ok;
-
- // 2. The AssertionError is defined in assert.
- // new assert.AssertionError({ message: message,
- // actual: actual,
- // expected: expected })
-
- var regex = /\s*function\s+([^\(\s]*)\s*/;
- // based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
- function getName(func) {
- if (!util.isFunction(func)) {
- return;
- }
- if (functionsHaveNames) {
- return func.name;
- }
- var str = func.toString();
- var match = str.match(regex);
- return match && match[1];
- }
- assert.AssertionError = function AssertionError(options) {
- this.name = 'AssertionError';
- this.actual = options.actual;
- this.expected = options.expected;
- this.operator = options.operator;
- if (options.message) {
- this.message = options.message;
- this.generatedMessage = false;
- } else {
- this.message = getMessage(this);
- this.generatedMessage = true;
- }
- var stackStartFunction = options.stackStartFunction || fail;
- if (Error.captureStackTrace) {
- Error.captureStackTrace(this, stackStartFunction);
- } else {
- // non v8 browsers so we can have a stacktrace
- var err = new Error();
- if (err.stack) {
- var out = err.stack;
-
- // try to strip useless frames
- var fn_name = getName(stackStartFunction);
- var idx = out.indexOf('\n' + fn_name);
- if (idx >= 0) {
- // once we have located the function frame
- // we need to strip out everything before it (and its line)
- var next_line = out.indexOf('\n', idx + 1);
- out = out.substring(next_line + 1);
- }
-
- this.stack = out;
- }
- }
- };
-
- // assert.AssertionError instanceof Error
- util.inherits(assert.AssertionError, Error);
-
- function truncate(s, n) {
- if (typeof s === 'string') {
- return s.length < n ? s : s.slice(0, n);
- } else {
- return s;
- }
- }
- function inspect(something) {
- if (functionsHaveNames || !util.isFunction(something)) {
- return util.inspect(something);
- }
- var rawname = getName(something);
- var name = rawname ? ': ' + rawname : '';
- return '[Function' + name + ']';
- }
- function getMessage(self) {
- return truncate(inspect(self.actual), 128) + ' ' +
- self.operator + ' ' +
- truncate(inspect(self.expected), 128);
- }
-
- // At present only the three keys mentioned above are used and
- // understood by the spec. Implementations or sub modules can pass
- // other keys to the AssertionError's constructor - they will be
- // ignored.
-
- // 3. All of the following functions must throw an AssertionError
- // when a corresponding condition is not met, with a message that
- // may be undefined if not provided. All assertion methods provide
- // both the actual and expected values to the assertion error for
- // display purposes.
-
- function fail(actual, expected, message, operator, stackStartFunction) {
- throw new assert.AssertionError({
- message: message,
- actual: actual,
- expected: expected,
- operator: operator,
- stackStartFunction: stackStartFunction
- });
- }
-
- // EXTENSION! allows for well behaved errors defined elsewhere.
- assert.fail = fail;
-
- // 4. Pure assertion tests whether a value is truthy, as determined
- // by !!guard.
- // assert.ok(guard, message_opt);
- // This statement is equivalent to assert.equal(true, !!guard,
- // message_opt);. To test strictly for the value true, use
- // assert.strictEqual(true, guard, message_opt);.
-
- function ok(value, message) {
- if (!value) fail(value, true, message, '==', assert.ok);
- }
- assert.ok = ok;
-
- // 5. The equality assertion tests shallow, coercive equality with
- // ==.
- // assert.equal(actual, expected, message_opt);
-
- assert.equal = function equal(actual, expected, message) {
- if (actual != expected) fail(actual, expected, message, '==', assert.equal);
- };
-
- // 6. The non-equality assertion tests for whether two objects are not equal
- // with != assert.notEqual(actual, expected, message_opt);
-
- assert.notEqual = function notEqual(actual, expected, message) {
- if (actual == expected) {
- fail(actual, expected, message, '!=', assert.notEqual);
- }
- };
-
- // 7. The equivalence assertion tests a deep equality relation.
- // assert.deepEqual(actual, expected, message_opt);
-
- assert.deepEqual = function deepEqual(actual, expected, message) {
- if (!_deepEqual(actual, expected, false)) {
- fail(actual, expected, message, 'deepEqual', assert.deepEqual);
- }
- };
-
- assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
- if (!_deepEqual(actual, expected, true)) {
- fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
- }
- };
-
- function _deepEqual(actual, expected, strict, memos) {
- // 7.1. All identical values are equivalent, as determined by ===.
- if (actual === expected) {
- return true;
- } else if (isBuffer(actual) && isBuffer(expected)) {
- return compare(actual, expected) === 0;
-
- // 7.2. If the expected value is a Date object, the actual value is
- // equivalent if it is also a Date object that refers to the same time.
- } else if (util.isDate(actual) && util.isDate(expected)) {
- return actual.getTime() === expected.getTime();
-
- // 7.3 If the expected value is a RegExp object, the actual value is
- // equivalent if it is also a RegExp object with the same source and
- // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
- } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
- return actual.source === expected.source &&
- actual.global === expected.global &&
- actual.multiline === expected.multiline &&
- actual.lastIndex === expected.lastIndex &&
- actual.ignoreCase === expected.ignoreCase;
-
- // 7.4. Other pairs that do not both pass typeof value == 'object',
- // equivalence is determined by ==.
- } else if ((actual === null || typeof actual !== 'object') &&
- (expected === null || typeof expected !== 'object')) {
- return strict ? actual === expected : actual == expected;
-
- // If both values are instances of typed arrays, wrap their underlying
- // ArrayBuffers in a Buffer each to increase performance
- // This optimization requires the arrays to have the same type as checked by
- // Object.prototype.toString (aka pToString). Never perform binary
- // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
- // bit patterns are not identical.
- } else if (isView(actual) && isView(expected) &&
- pToString(actual) === pToString(expected) &&
- !(actual instanceof Float32Array ||
- actual instanceof Float64Array)) {
- return compare(new Uint8Array(actual.buffer),
- new Uint8Array(expected.buffer)) === 0;
-
- // 7.5 For all other Object pairs, including Array objects, equivalence is
- // determined by having the same number of owned properties (as verified
- // with Object.prototype.hasOwnProperty.call), the same set of keys
- // (although not necessarily the same order), equivalent values for every
- // corresponding key, and an identical 'prototype' property. Note: this
- // accounts for both named and indexed properties on Arrays.
- } else if (isBuffer(actual) !== isBuffer(expected)) {
- return false;
- } else {
- memos = memos || {actual: [], expected: []};
-
- var actualIndex = memos.actual.indexOf(actual);
- if (actualIndex !== -1) {
- if (actualIndex === memos.expected.indexOf(expected)) {
- return true;
- }
- }
-
- memos.actual.push(actual);
- memos.expected.push(expected);
-
- return objEquiv(actual, expected, strict, memos);
- }
- }
-
- function isArguments(object) {
- return Object.prototype.toString.call(object) == '[object Arguments]';
- }
-
- function objEquiv(a, b, strict, actualVisitedObjects) {
- if (a === null || a === undefined || b === null || b === undefined)
- return false;
- // if one is a primitive, the other must be same
- if (util.isPrimitive(a) || util.isPrimitive(b))
- return a === b;
- if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
- return false;
- var aIsArgs = isArguments(a);
- var bIsArgs = isArguments(b);
- if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
- return false;
- if (aIsArgs) {
- a = pSlice.call(a);
- b = pSlice.call(b);
- return _deepEqual(a, b, strict);
- }
- var ka = objectKeys(a);
- var kb = objectKeys(b);
- var key, i;
- // having the same number of owned properties (keys incorporates
- // hasOwnProperty)
- if (ka.length !== kb.length)
- return false;
- //the same set of keys (although not necessarily the same order),
- ka.sort();
- kb.sort();
- //~~~cheap key test
- for (i = ka.length - 1; i >= 0; i--) {
- if (ka[i] !== kb[i])
- return false;
- }
- //equivalent values for every corresponding key, and
- //~~~possibly expensive deep test
- for (i = ka.length - 1; i >= 0; i--) {
- key = ka[i];
- if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
- return false;
- }
- return true;
- }
-
- // 8. The non-equivalence assertion tests for any deep inequality.
- // assert.notDeepEqual(actual, expected, message_opt);
-
- assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
- if (_deepEqual(actual, expected, false)) {
- fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
- }
- };
-
- assert.notDeepStrictEqual = notDeepStrictEqual;
- function notDeepStrictEqual(actual, expected, message) {
- if (_deepEqual(actual, expected, true)) {
- fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
- }
- }
-
-
- // 9. The strict equality assertion tests strict equality, as determined by ===.
- // assert.strictEqual(actual, expected, message_opt);
-
- assert.strictEqual = function strictEqual(actual, expected, message) {
- if (actual !== expected) {
- fail(actual, expected, message, '===', assert.strictEqual);
- }
- };
-
- // 10. The strict non-equality assertion tests for strict inequality, as
- // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
-
- assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
- if (actual === expected) {
- fail(actual, expected, message, '!==', assert.notStrictEqual);
- }
- };
-
- function expectedException(actual, expected) {
- if (!actual || !expected) {
- return false;
- }
-
- if (Object.prototype.toString.call(expected) == '[object RegExp]') {
- return expected.test(actual);
- }
-
- try {
- if (actual instanceof expected) {
- return true;
- }
- } catch (e) {
- // Ignore. The instanceof check doesn't work for arrow functions.
- }
-
- if (Error.isPrototypeOf(expected)) {
- return false;
- }
-
- return expected.call({}, actual) === true;
- }
-
- function _tryBlock(block) {
- var error;
- try {
- block();
- } catch (e) {
- error = e;
- }
- return error;
- }
-
- function _throws(shouldThrow, block, expected, message) {
- var actual;
-
- if (typeof block !== 'function') {
- throw new TypeError('"block" argument must be a function');
- }
-
- if (typeof expected === 'string') {
- message = expected;
- expected = null;
- }
-
- actual = _tryBlock(block);
-
- message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
- (message ? ' ' + message : '.');
-
- if (shouldThrow && !actual) {
- fail(actual, expected, 'Missing expected exception' + message);
- }
-
- var userProvidedMessage = typeof message === 'string';
- var isUnwantedException = !shouldThrow && util.isError(actual);
- var isUnexpectedException = !shouldThrow && actual && !expected;
-
- if ((isUnwantedException &&
- userProvidedMessage &&
- expectedException(actual, expected)) ||
- isUnexpectedException) {
- fail(actual, expected, 'Got unwanted exception' + message);
- }
-
- if ((shouldThrow && actual && expected &&
- !expectedException(actual, expected)) || (!shouldThrow && actual)) {
- throw actual;
- }
- }
-
- // 11. Expected to throw an error:
- // assert.throws(block, Error_opt, message_opt);
-
- assert.throws = function(block, /*optional*/error, /*optional*/message) {
- _throws(true, block, error, message);
- };
-
- // EXTENSION! This is annoying to write outside this module.
- assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
- _throws(false, block, error, message);
- };
-
- assert.ifError = function(err) { if (err) throw err; };
-
- // Expose a strict only variant of assert
- function strict(value, message) {
- if (!value) fail(value, true, message, '==', strict);
- }
- assert.strict = objectAssign(strict, assert, {
- equal: assert.strictEqual,
- deepEqual: assert.deepStrictEqual,
- notEqual: assert.notStrictEqual,
- notDeepEqual: assert.notDeepStrictEqual
- });
- assert.strict.strict = assert.strict;
-
- var objectKeys = Object.keys || function (obj) {
- var keys = [];
- for (var key in obj) {
- if (hasOwn.call(obj, key)) keys.push(key);
- }
- return keys;
- };
-
- /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__("yLpj")))
-
- /***/ }),
-
- /***/ "Ekho":
- /***/ (function(module, exports, __webpack_require__) {
-
- var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Generated by CoffeeScript 1.8.0
- (function() {
- var Heap, defaultCmp, floor, heapify, heappop, heappush, heappushpop, heapreplace, insort, min, nlargest, nsmallest, updateItem, _siftdown, _siftup;
-
- floor = Math.floor, min = Math.min;
-
-
- /*
- Default comparison function to be used
- */
-
- defaultCmp = function(x, y) {
- if (x < y) {
- return -1;
- }
- if (x > y) {
- return 1;
- }
- return 0;
- };
-
-
- /*
- Insert item x in list a, and keep it sorted assuming a is sorted.
-
- If x is already in a, insert it to the right of the rightmost x.
-
- Optional args lo (default 0) and hi (default a.length) bound the slice
- of a to be searched.
- */
-
- insort = function(a, x, lo, hi, cmp) {
- var mid;
- if (lo == null) {
- lo = 0;
- }
- if (cmp == null) {
- cmp = defaultCmp;
- }
- if (lo < 0) {
- throw new Error('lo must be non-negative');
- }
- if (hi == null) {
- hi = a.length;
- }
- while (lo < hi) {
- mid = floor((lo + hi) / 2);
- if (cmp(x, a[mid]) < 0) {
- hi = mid;
- } else {
- lo = mid + 1;
- }
- }
- return ([].splice.apply(a, [lo, lo - lo].concat(x)), x);
- };
-
-
- /*
- Push item onto heap, maintaining the heap invariant.
- */
-
- heappush = function(array, item, cmp) {
- if (cmp == null) {
- cmp = defaultCmp;
- }
- array.push(item);
- return _siftdown(array, 0, array.length - 1, cmp);
- };
-
-
- /*
- Pop the smallest item off the heap, maintaining the heap invariant.
- */
-
- heappop = function(array, cmp) {
- var lastelt, returnitem;
- if (cmp == null) {
- cmp = defaultCmp;
- }
- lastelt = array.pop();
- if (array.length) {
- returnitem = array[0];
- array[0] = lastelt;
- _siftup(array, 0, cmp);
- } else {
- returnitem = lastelt;
- }
- return returnitem;
- };
-
-
- /*
- Pop and return the current smallest value, and add the new item.
-
- This is more efficient than heappop() followed by heappush(), and can be
- more appropriate when using a fixed size heap. Note that the value
- returned may be larger than item! That constrains reasonable use of
- this routine unless written as part of a conditional replacement:
- if item > array[0]
- item = heapreplace(array, item)
- */
-
- heapreplace = function(array, item, cmp) {
- var returnitem;
- if (cmp == null) {
- cmp = defaultCmp;
- }
- returnitem = array[0];
- array[0] = item;
- _siftup(array, 0, cmp);
- return returnitem;
- };
-
-
- /*
- Fast version of a heappush followed by a heappop.
- */
-
- heappushpop = function(array, item, cmp) {
- var _ref;
- if (cmp == null) {
- cmp = defaultCmp;
- }
- if (array.length && cmp(array[0], item) < 0) {
- _ref = [array[0], item], item = _ref[0], array[0] = _ref[1];
- _siftup(array, 0, cmp);
- }
- return item;
- };
-
-
- /*
- Transform list into a heap, in-place, in O(array.length) time.
- */
-
- heapify = function(array, cmp) {
- var i, _i, _j, _len, _ref, _ref1, _results, _results1;
- if (cmp == null) {
- cmp = defaultCmp;
- }
- _ref1 = (function() {
- _results1 = [];
- for (var _j = 0, _ref = floor(array.length / 2); 0 <= _ref ? _j < _ref : _j > _ref; 0 <= _ref ? _j++ : _j--){ _results1.push(_j); }
- return _results1;
- }).apply(this).reverse();
- _results = [];
- for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
- i = _ref1[_i];
- _results.push(_siftup(array, i, cmp));
- }
- return _results;
- };
-
-
- /*
- Update the position of the given item in the heap.
- This function should be called every time the item is being modified.
- */
-
- updateItem = function(array, item, cmp) {
- var pos;
- if (cmp == null) {
- cmp = defaultCmp;
- }
- pos = array.indexOf(item);
- if (pos === -1) {
- return;
- }
- _siftdown(array, 0, pos, cmp);
- return _siftup(array, pos, cmp);
- };
-
-
- /*
- Find the n largest elements in a dataset.
- */
-
- nlargest = function(array, n, cmp) {
- var elem, result, _i, _len, _ref;
- if (cmp == null) {
- cmp = defaultCmp;
- }
- result = array.slice(0, n);
- if (!result.length) {
- return result;
- }
- heapify(result, cmp);
- _ref = array.slice(n);
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- elem = _ref[_i];
- heappushpop(result, elem, cmp);
- }
- return result.sort(cmp).reverse();
- };
-
-
- /*
- Find the n smallest elements in a dataset.
- */
-
- nsmallest = function(array, n, cmp) {
- var elem, i, los, result, _i, _j, _len, _ref, _ref1, _results;
- if (cmp == null) {
- cmp = defaultCmp;
- }
- if (n * 10 <= array.length) {
- result = array.slice(0, n).sort(cmp);
- if (!result.length) {
- return result;
- }
- los = result[result.length - 1];
- _ref = array.slice(n);
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- elem = _ref[_i];
- if (cmp(elem, los) < 0) {
- insort(result, elem, 0, null, cmp);
- result.pop();
- los = result[result.length - 1];
- }
- }
- return result;
- }
- heapify(array, cmp);
- _results = [];
- for (i = _j = 0, _ref1 = min(n, array.length); 0 <= _ref1 ? _j < _ref1 : _j > _ref1; i = 0 <= _ref1 ? ++_j : --_j) {
- _results.push(heappop(array, cmp));
- }
- return _results;
- };
-
- _siftdown = function(array, startpos, pos, cmp) {
- var newitem, parent, parentpos;
- if (cmp == null) {
- cmp = defaultCmp;
- }
- newitem = array[pos];
- while (pos > startpos) {
- parentpos = (pos - 1) >> 1;
- parent = array[parentpos];
- if (cmp(newitem, parent) < 0) {
- array[pos] = parent;
- pos = parentpos;
- continue;
- }
- break;
- }
- return array[pos] = newitem;
- };
-
- _siftup = function(array, pos, cmp) {
- var childpos, endpos, newitem, rightpos, startpos;
- if (cmp == null) {
- cmp = defaultCmp;
- }
- endpos = array.length;
- startpos = pos;
- newitem = array[pos];
- childpos = 2 * pos + 1;
- while (childpos < endpos) {
- rightpos = childpos + 1;
- if (rightpos < endpos && !(cmp(array[childpos], array[rightpos]) < 0)) {
- childpos = rightpos;
- }
- array[pos] = array[childpos];
- pos = childpos;
- childpos = 2 * pos + 1;
- }
- array[pos] = newitem;
- return _siftdown(array, startpos, pos, cmp);
- };
-
- Heap = (function() {
- Heap.push = heappush;
-
- Heap.pop = heappop;
-
- Heap.replace = heapreplace;
-
- Heap.pushpop = heappushpop;
-
- Heap.heapify = heapify;
-
- Heap.updateItem = updateItem;
-
- Heap.nlargest = nlargest;
-
- Heap.nsmallest = nsmallest;
-
- function Heap(cmp) {
- this.cmp = cmp != null ? cmp : defaultCmp;
- this.nodes = [];
- }
-
- Heap.prototype.push = function(x) {
- return heappush(this.nodes, x, this.cmp);
- };
-
- Heap.prototype.pop = function() {
- return heappop(this.nodes, this.cmp);
- };
-
- Heap.prototype.peek = function() {
- return this.nodes[0];
- };
-
- Heap.prototype.contains = function(x) {
- return this.nodes.indexOf(x) !== -1;
- };
-
- Heap.prototype.replace = function(x) {
- return heapreplace(this.nodes, x, this.cmp);
- };
-
- Heap.prototype.pushpop = function(x) {
- return heappushpop(this.nodes, x, this.cmp);
- };
-
- Heap.prototype.heapify = function() {
- return heapify(this.nodes, this.cmp);
- };
-
- Heap.prototype.updateItem = function(x) {
- return updateItem(this.nodes, x, this.cmp);
- };
-
- Heap.prototype.clear = function() {
- return this.nodes = [];
- };
-
- Heap.prototype.empty = function() {
- return this.nodes.length === 0;
- };
-
- Heap.prototype.size = function() {
- return this.nodes.length;
- };
-
- Heap.prototype.clone = function() {
- var heap;
- heap = new Heap();
- heap.nodes = this.nodes.slice(0);
- return heap;
- };
-
- Heap.prototype.toArray = function() {
- return this.nodes.slice(0);
- };
-
- Heap.prototype.insert = Heap.prototype.push;
-
- Heap.prototype.top = Heap.prototype.peek;
-
- Heap.prototype.front = Heap.prototype.peek;
-
- Heap.prototype.has = Heap.prototype.contains;
-
- Heap.prototype.copy = Heap.prototype.clone;
-
- return Heap;
-
- })();
-
- (function(root, factory) {
- if (true) {
- return !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
- __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
- (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
- } else {}
- })(this, function() {
- return Heap;
- });
-
- }).call(this);
-
-
- /***/ }),
-
- /***/ "F1pL":
- /***/ (function(module, exports, __webpack_require__) {
-
- module.exports = __webpack_require__("Ekho");
-
-
- /***/ }),
-
- /***/ "KKCa":
- /***/ (function(module, exports) {
-
- if (typeof Object.create === 'function') {
- // implementation from standard node.js 'util' module
- module.exports = function inherits(ctor, superCtor) {
- ctor.super_ = superCtor
- ctor.prototype = Object.create(superCtor.prototype, {
- constructor: {
- value: ctor,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
- };
- } else {
- // old school shim for old browsers
- module.exports = function inherits(ctor, superCtor) {
- ctor.super_ = superCtor
- var TempCtor = function () {}
- TempCtor.prototype = superCtor.prototype
- ctor.prototype = new TempCtor()
- ctor.prototype.constructor = ctor
- }
- }
-
-
- /***/ }),
-
- /***/ "MCLT":
- /***/ (function(module, exports, __webpack_require__) {
-
- /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors ||
- function getOwnPropertyDescriptors(obj) {
- var keys = Object.keys(obj);
- var descriptors = {};
- for (var i = 0; i < keys.length; i++) {
- descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);
- }
- return descriptors;
- };
-
- var formatRegExp = /%[sdj%]/g;
- exports.format = function(f) {
- if (!isString(f)) {
- var objects = [];
- for (var i = 0; i < arguments.length; i++) {
- objects.push(inspect(arguments[i]));
- }
- return objects.join(' ');
- }
-
- var i = 1;
- var args = arguments;
- var len = args.length;
- var str = String(f).replace(formatRegExp, function(x) {
- if (x === '%%') return '%';
- if (i >= len) return x;
- switch (x) {
- case '%s': return String(args[i++]);
- case '%d': return Number(args[i++]);
- case '%j':
- try {
- return JSON.stringify(args[i++]);
- } catch (_) {
- return '[Circular]';
- }
- default:
- return x;
- }
- });
- for (var x = args[i]; i < len; x = args[++i]) {
- if (isNull(x) || !isObject(x)) {
- str += ' ' + x;
- } else {
- str += ' ' + inspect(x);
- }
- }
- return str;
- };
-
-
- // Mark that a method should not be used.
- // Returns a modified function which warns once by default.
- // If --no-deprecation is set, then it is a no-op.
- exports.deprecate = function(fn, msg) {
- if (typeof process !== 'undefined' && process.noDeprecation === true) {
- return fn;
- }
-
- // Allow for deprecating things in the process of starting up.
- if (typeof process === 'undefined') {
- return function() {
- return exports.deprecate(fn, msg).apply(this, arguments);
- };
- }
-
- var warned = false;
- function deprecated() {
- if (!warned) {
- if (process.throwDeprecation) {
- throw new Error(msg);
- } else if (process.traceDeprecation) {
- console.trace(msg);
- } else {
- console.error(msg);
- }
- warned = true;
- }
- return fn.apply(this, arguments);
- }
-
- return deprecated;
- };
-
-
- var debugs = {};
- var debugEnviron;
- exports.debuglog = function(set) {
- if (isUndefined(debugEnviron))
- debugEnviron = process.env.NODE_DEBUG || '';
- set = set.toUpperCase();
- if (!debugs[set]) {
- if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
- var pid = process.pid;
- debugs[set] = function() {
- var msg = exports.format.apply(exports, arguments);
- console.error('%s %d: %s', set, pid, msg);
- };
- } else {
- debugs[set] = function() {};
- }
- }
- return debugs[set];
- };
-
-
- /**
- * Echos the value of a value. Trys to print the value out
- * in the best way possible given the different types.
- *
- * @param {Object} obj The object to print out.
- * @param {Object} opts Optional options object that alters the output.
- */
- /* legacy: obj, showHidden, depth, colors*/
- function inspect(obj, opts) {
- // default options
- var ctx = {
- seen: [],
- stylize: stylizeNoColor
- };
- // legacy...
- if (arguments.length >= 3) ctx.depth = arguments[2];
- if (arguments.length >= 4) ctx.colors = arguments[3];
- if (isBoolean(opts)) {
- // legacy...
- ctx.showHidden = opts;
- } else if (opts) {
- // got an "options" object
- exports._extend(ctx, opts);
- }
- // set default options
- if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
- if (isUndefined(ctx.depth)) ctx.depth = 2;
- if (isUndefined(ctx.colors)) ctx.colors = false;
- if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
- if (ctx.colors) ctx.stylize = stylizeWithColor;
- return formatValue(ctx, obj, ctx.depth);
- }
- exports.inspect = inspect;
-
-
- // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
- inspect.colors = {
- 'bold' : [1, 22],
- 'italic' : [3, 23],
- 'underline' : [4, 24],
- 'inverse' : [7, 27],
- 'white' : [37, 39],
- 'grey' : [90, 39],
- 'black' : [30, 39],
- 'blue' : [34, 39],
- 'cyan' : [36, 39],
- 'green' : [32, 39],
- 'magenta' : [35, 39],
- 'red' : [31, 39],
- 'yellow' : [33, 39]
- };
-
- // Don't use 'blue' not visible on cmd.exe
- inspect.styles = {
- 'special': 'cyan',
- 'number': 'yellow',
- 'boolean': 'yellow',
- 'undefined': 'grey',
- 'null': 'bold',
- 'string': 'green',
- 'date': 'magenta',
- // "name": intentionally not styling
- 'regexp': 'red'
- };
-
-
- function stylizeWithColor(str, styleType) {
- var style = inspect.styles[styleType];
-
- if (style) {
- return '\u001b[' + inspect.colors[style][0] + 'm' + str +
- '\u001b[' + inspect.colors[style][1] + 'm';
- } else {
- return str;
- }
- }
-
-
- function stylizeNoColor(str, styleType) {
- return str;
- }
-
-
- function arrayToHash(array) {
- var hash = {};
-
- array.forEach(function(val, idx) {
- hash[val] = true;
- });
-
- return hash;
- }
-
-
- function formatValue(ctx, value, recurseTimes) {
- // Provide a hook for user-specified inspect functions.
- // Check that value is an object with an inspect function on it
- if (ctx.customInspect &&
- value &&
- isFunction(value.inspect) &&
- // Filter out the util module, it's inspect function is special
- value.inspect !== exports.inspect &&
- // Also filter out any prototype objects using the circular check.
- !(value.constructor && value.constructor.prototype === value)) {
- var ret = value.inspect(recurseTimes, ctx);
- if (!isString(ret)) {
- ret = formatValue(ctx, ret, recurseTimes);
- }
- return ret;
- }
-
- // Primitive types cannot have properties
- var primitive = formatPrimitive(ctx, value);
- if (primitive) {
- return primitive;
- }
-
- // Look up the keys of the object.
- var keys = Object.keys(value);
- var visibleKeys = arrayToHash(keys);
-
- if (ctx.showHidden) {
- keys = Object.getOwnPropertyNames(value);
- }
-
- // IE doesn't make error fields non-enumerable
- // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
- if (isError(value)
- && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
- return formatError(value);
- }
-
- // Some type of object without properties can be shortcutted.
- if (keys.length === 0) {
- if (isFunction(value)) {
- var name = value.name ? ': ' + value.name : '';
- return ctx.stylize('[Function' + name + ']', 'special');
- }
- if (isRegExp(value)) {
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
- }
- if (isDate(value)) {
- return ctx.stylize(Date.prototype.toString.call(value), 'date');
- }
- if (isError(value)) {
- return formatError(value);
- }
- }
-
- var base = '', array = false, braces = ['{', '}'];
-
- // Make Array say that they are Array
- if (isArray(value)) {
- array = true;
- braces = ['[', ']'];
- }
-
- // Make functions say that they are functions
- if (isFunction(value)) {
- var n = value.name ? ': ' + value.name : '';
- base = ' [Function' + n + ']';
- }
-
- // Make RegExps say that they are RegExps
- if (isRegExp(value)) {
- base = ' ' + RegExp.prototype.toString.call(value);
- }
-
- // Make dates with properties first say the date
- if (isDate(value)) {
- base = ' ' + Date.prototype.toUTCString.call(value);
- }
-
- // Make error with message first say the error
- if (isError(value)) {
- base = ' ' + formatError(value);
- }
-
- if (keys.length === 0 && (!array || value.length == 0)) {
- return braces[0] + base + braces[1];
- }
-
- if (recurseTimes < 0) {
- if (isRegExp(value)) {
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
- } else {
- return ctx.stylize('[Object]', 'special');
- }
- }
-
- ctx.seen.push(value);
-
- var output;
- if (array) {
- output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
- } else {
- output = keys.map(function(key) {
- return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
- });
- }
-
- ctx.seen.pop();
-
- return reduceToSingleString(output, base, braces);
- }
-
-
- function formatPrimitive(ctx, value) {
- if (isUndefined(value))
- return ctx.stylize('undefined', 'undefined');
- if (isString(value)) {
- var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
- .replace(/'/g, "\\'")
- .replace(/\\"/g, '"') + '\'';
- return ctx.stylize(simple, 'string');
- }
- if (isNumber(value))
- return ctx.stylize('' + value, 'number');
- if (isBoolean(value))
- return ctx.stylize('' + value, 'boolean');
- // For some reason typeof null is "object", so special case here.
- if (isNull(value))
- return ctx.stylize('null', 'null');
- }
-
-
- function formatError(value) {
- return '[' + Error.prototype.toString.call(value) + ']';
- }
-
-
- function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
- var output = [];
- for (var i = 0, l = value.length; i < l; ++i) {
- if (hasOwnProperty(value, String(i))) {
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
- String(i), true));
- } else {
- output.push('');
- }
- }
- keys.forEach(function(key) {
- if (!key.match(/^\d+$/)) {
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
- key, true));
- }
- });
- return output;
- }
-
-
- function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
- var name, str, desc;
- desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
- if (desc.get) {
- if (desc.set) {
- str = ctx.stylize('[Getter/Setter]', 'special');
- } else {
- str = ctx.stylize('[Getter]', 'special');
- }
- } else {
- if (desc.set) {
- str = ctx.stylize('[Setter]', 'special');
- }
- }
- if (!hasOwnProperty(visibleKeys, key)) {
- name = '[' + key + ']';
- }
- if (!str) {
- if (ctx.seen.indexOf(desc.value) < 0) {
- if (isNull(recurseTimes)) {
- str = formatValue(ctx, desc.value, null);
- } else {
- str = formatValue(ctx, desc.value, recurseTimes - 1);
- }
- if (str.indexOf('\n') > -1) {
- if (array) {
- str = str.split('\n').map(function(line) {
- return ' ' + line;
- }).join('\n').substr(2);
- } else {
- str = '\n' + str.split('\n').map(function(line) {
- return ' ' + line;
- }).join('\n');
- }
- }
- } else {
- str = ctx.stylize('[Circular]', 'special');
- }
- }
- if (isUndefined(name)) {
- if (array && key.match(/^\d+$/)) {
- return str;
- }
- name = JSON.stringify('' + key);
- if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
- name = name.substr(1, name.length - 2);
- name = ctx.stylize(name, 'name');
- } else {
- name = name.replace(/'/g, "\\'")
- .replace(/\\"/g, '"')
- .replace(/(^"|"$)/g, "'");
- name = ctx.stylize(name, 'string');
- }
- }
-
- return name + ': ' + str;
- }
-
-
- function reduceToSingleString(output, base, braces) {
- var numLinesEst = 0;
- var length = output.reduce(function(prev, cur) {
- numLinesEst++;
- if (cur.indexOf('\n') >= 0) numLinesEst++;
- return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
- }, 0);
-
- if (length > 60) {
- return braces[0] +
- (base === '' ? '' : base + '\n ') +
- ' ' +
- output.join(',\n ') +
- ' ' +
- braces[1];
- }
-
- return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
- }
-
-
- // NOTE: These type checking functions intentionally don't use `instanceof`
- // because it is fragile and can be easily faked with `Object.create()`.
- function isArray(ar) {
- return Array.isArray(ar);
- }
- exports.isArray = isArray;
-
- function isBoolean(arg) {
- return typeof arg === 'boolean';
- }
- exports.isBoolean = isBoolean;
-
- function isNull(arg) {
- return arg === null;
- }
- exports.isNull = isNull;
-
- function isNullOrUndefined(arg) {
- return arg == null;
- }
- exports.isNullOrUndefined = isNullOrUndefined;
-
- function isNumber(arg) {
- return typeof arg === 'number';
- }
- exports.isNumber = isNumber;
-
- function isString(arg) {
- return typeof arg === 'string';
- }
- exports.isString = isString;
-
- function isSymbol(arg) {
- return typeof arg === 'symbol';
- }
- exports.isSymbol = isSymbol;
-
- function isUndefined(arg) {
- return arg === void 0;
- }
- exports.isUndefined = isUndefined;
-
- function isRegExp(re) {
- return isObject(re) && objectToString(re) === '[object RegExp]';
- }
- exports.isRegExp = isRegExp;
-
- function isObject(arg) {
- return typeof arg === 'object' && arg !== null;
- }
- exports.isObject = isObject;
-
- function isDate(d) {
- return isObject(d) && objectToString(d) === '[object Date]';
- }
- exports.isDate = isDate;
-
- function isError(e) {
- return isObject(e) &&
- (objectToString(e) === '[object Error]' || e instanceof Error);
- }
- exports.isError = isError;
-
- function isFunction(arg) {
- return typeof arg === 'function';
- }
- exports.isFunction = isFunction;
-
- function isPrimitive(arg) {
- return arg === null ||
- typeof arg === 'boolean' ||
- typeof arg === 'number' ||
- typeof arg === 'string' ||
- typeof arg === 'symbol' || // ES6 symbol
- typeof arg === 'undefined';
- }
- exports.isPrimitive = isPrimitive;
-
- exports.isBuffer = __webpack_require__("1gqn");
-
- function objectToString(o) {
- return Object.prototype.toString.call(o);
- }
-
-
- function pad(n) {
- return n < 10 ? '0' + n.toString(10) : n.toString(10);
- }
-
-
- var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
- 'Oct', 'Nov', 'Dec'];
-
- // 26 Feb 16:19:34
- function timestamp() {
- var d = new Date();
- var time = [pad(d.getHours()),
- pad(d.getMinutes()),
- pad(d.getSeconds())].join(':');
- return [d.getDate(), months[d.getMonth()], time].join(' ');
- }
-
-
- // log is just a thin wrapper to console.log that prepends a timestamp
- exports.log = function() {
- console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
- };
-
-
- /**
- * Inherit the prototype methods from one constructor into another.
- *
- * The Function.prototype.inherits from lang.js rewritten as a standalone
- * function (not on Function.prototype). NOTE: If this file is to be loaded
- * during bootstrapping this function needs to be rewritten using some native
- * functions as prototype setup using normal JavaScript does not work as
- * expected during bootstrapping (see mirror.js in r114903).
- *
- * @param {function} ctor Constructor function which needs to inherit the
- * prototype.
- * @param {function} superCtor Constructor function to inherit prototype from.
- */
- exports.inherits = __webpack_require__("KKCa");
-
- exports._extend = function(origin, add) {
- // Don't do anything if add isn't an object
- if (!add || !isObject(add)) return origin;
-
- var keys = Object.keys(add);
- var i = keys.length;
- while (i--) {
- origin[keys[i]] = add[keys[i]];
- }
- return origin;
- };
-
- function hasOwnProperty(obj, prop) {
- return Object.prototype.hasOwnProperty.call(obj, prop);
- }
-
- var kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined;
-
- exports.promisify = function promisify(original) {
- if (typeof original !== 'function')
- throw new TypeError('The "original" argument must be of type Function');
-
- if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
- var fn = original[kCustomPromisifiedSymbol];
- if (typeof fn !== 'function') {
- throw new TypeError('The "util.promisify.custom" argument must be of type Function');
- }
- Object.defineProperty(fn, kCustomPromisifiedSymbol, {
- value: fn, enumerable: false, writable: false, configurable: true
- });
- return fn;
- }
-
- function fn() {
- var promiseResolve, promiseReject;
- var promise = new Promise(function (resolve, reject) {
- promiseResolve = resolve;
- promiseReject = reject;
- });
-
- var args = [];
- for (var i = 0; i < arguments.length; i++) {
- args.push(arguments[i]);
- }
- args.push(function (err, value) {
- if (err) {
- promiseReject(err);
- } else {
- promiseResolve(value);
- }
- });
-
- try {
- original.apply(this, args);
- } catch (err) {
- promiseReject(err);
- }
-
- return promise;
- }
-
- Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
-
- if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {
- value: fn, enumerable: false, writable: false, configurable: true
- });
- return Object.defineProperties(
- fn,
- getOwnPropertyDescriptors(original)
- );
- }
-
- exports.promisify.custom = kCustomPromisifiedSymbol
-
- function callbackifyOnRejected(reason, cb) {
- // `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M).
- // Because `null` is a special error value in callbacks which means "no error
- // occurred", we error-wrap so the callback consumer can distinguish between
- // "the promise rejected with null" or "the promise fulfilled with undefined".
- if (!reason) {
- var newReason = new Error('Promise was rejected with a falsy value');
- newReason.reason = reason;
- reason = newReason;
- }
- return cb(reason);
- }
-
- function callbackify(original) {
- if (typeof original !== 'function') {
- throw new TypeError('The "original" argument must be of type Function');
- }
-
- // We DO NOT return the promise as it gives the user a false sense that
- // the promise is actually somehow related to the callback's execution
- // and that the callback throwing will reject the promise.
- function callbackified() {
- var args = [];
- for (var i = 0; i < arguments.length; i++) {
- args.push(arguments[i]);
- }
-
- var maybeCb = args.pop();
- if (typeof maybeCb !== 'function') {
- throw new TypeError('The last argument must be of type Function');
- }
- var self = this;
- var cb = function() {
- return maybeCb.apply(self, arguments);
- };
- // In true node style we process the callback on `nextTick` with all the
- // implications (stack, `uncaughtException`, `async_hooks`)
- original.apply(this, args)
- .then(function(ret) { process.nextTick(cb, null, ret) },
- function(rej) { process.nextTick(callbackifyOnRejected, rej, cb) });
- }
-
- Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original));
- Object.defineProperties(callbackified,
- getOwnPropertyDescriptors(original));
- return callbackified;
- }
- exports.callbackify = callbackify;
-
- /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__("8oxB")))
-
- /***/ }),
-
- /***/ "MgzW":
- /***/ (function(module, exports, __webpack_require__) {
-
- "use strict";
- /*
- object-assign
- (c) Sindre Sorhus
- @license MIT
- */
-
-
- /* eslint-disable no-unused-vars */
- var getOwnPropertySymbols = Object.getOwnPropertySymbols;
- var hasOwnProperty = Object.prototype.hasOwnProperty;
- var propIsEnumerable = Object.prototype.propertyIsEnumerable;
-
- function toObject(val) {
- if (val === null || val === undefined) {
- throw new TypeError('Object.assign cannot be called with null or undefined');
- }
-
- return Object(val);
- }
-
- function shouldUseNative() {
- try {
- if (!Object.assign) {
- return false;
- }
-
- // Detect buggy property enumeration order in older V8 versions.
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=4118
- var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
- test1[5] = 'de';
- if (Object.getOwnPropertyNames(test1)[0] === '5') {
- return false;
- }
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
- var test2 = {};
- for (var i = 0; i < 10; i++) {
- test2['_' + String.fromCharCode(i)] = i;
- }
- var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
- return test2[n];
- });
- if (order2.join('') !== '0123456789') {
- return false;
- }
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
- var test3 = {};
- 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
- test3[letter] = letter;
- });
- if (Object.keys(Object.assign({}, test3)).join('') !==
- 'abcdefghijklmnopqrst') {
- return false;
- }
-
- return true;
- } catch (err) {
- // We don't expect any of the above to throw, but better to be safe.
- return false;
- }
- }
-
- module.exports = shouldUseNative() ? Object.assign : function (target, source) {
- var from;
- var to = toObject(target);
- var symbols;
-
- for (var s = 1; s < arguments.length; s++) {
- from = Object(arguments[s]);
-
- for (var key in from) {
- if (hasOwnProperty.call(from, key)) {
- to[key] = from[key];
- }
- }
-
- if (getOwnPropertySymbols) {
- symbols = getOwnPropertySymbols(from);
- for (var i = 0; i < symbols.length; i++) {
- if (propIsEnumerable.call(from, symbols[i])) {
- to[symbols[i]] = from[symbols[i]];
- }
- }
- }
- }
-
- return to;
- };
-
-
- /***/ }),
-
- /***/ "PKsF":
- /***/ (function(module, exports, __webpack_require__) {
-
- /*
- * Copyright 2011 Twitter, Inc.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
- (function (Hogan) {
- // Setup regex assignments
- // remove whitespace according to Mustache spec
- var rIsWhitespace = /\S/,
- rQuot = /\"/g,
- rNewline = /\n/g,
- rCr = /\r/g,
- rSlash = /\\/g,
- rLineSep = /\u2028/,
- rParagraphSep = /\u2029/;
-
- Hogan.tags = {
- '#': 1, '^': 2, '<': 3, '$': 4,
- '/': 5, '!': 6, '>': 7, '=': 8, '_v': 9,
- '{': 10, '&': 11, '_t': 12
- };
-
- Hogan.scan = function scan(text, delimiters) {
- var len = text.length,
- IN_TEXT = 0,
- IN_TAG_TYPE = 1,
- IN_TAG = 2,
- state = IN_TEXT,
- tagType = null,
- tag = null,
- buf = '',
- tokens = [],
- seenTag = false,
- i = 0,
- lineStart = 0,
- otag = '{{',
- ctag = '}}';
-
- function addBuf() {
- if (buf.length > 0) {
- tokens.push({tag: '_t', text: new String(buf)});
- buf = '';
- }
- }
-
- function lineIsWhitespace() {
- var isAllWhitespace = true;
- for (var j = lineStart; j < tokens.length; j++) {
- isAllWhitespace =
- (Hogan.tags[tokens[j].tag] < Hogan.tags['_v']) ||
- (tokens[j].tag == '_t' && tokens[j].text.match(rIsWhitespace) === null);
- if (!isAllWhitespace) {
- return false;
- }
- }
-
- return isAllWhitespace;
- }
-
- function filterLine(haveSeenTag, noNewLine) {
- addBuf();
-
- if (haveSeenTag && lineIsWhitespace()) {
- for (var j = lineStart, next; j < tokens.length; j++) {
- if (tokens[j].text) {
- if ((next = tokens[j+1]) && next.tag == '>') {
- // set indent to token value
- next.indent = tokens[j].text.toString()
- }
- tokens.splice(j, 1);
- }
- }
- } else if (!noNewLine) {
- tokens.push({tag:'\n'});
- }
-
- seenTag = false;
- lineStart = tokens.length;
- }
-
- function changeDelimiters(text, index) {
- var close = '=' + ctag,
- closeIndex = text.indexOf(close, index),
- delimiters = trim(
- text.substring(text.indexOf('=', index) + 1, closeIndex)
- ).split(' ');
-
- otag = delimiters[0];
- ctag = delimiters[delimiters.length - 1];
-
- return closeIndex + close.length - 1;
- }
-
- if (delimiters) {
- delimiters = delimiters.split(' ');
- otag = delimiters[0];
- ctag = delimiters[1];
- }
-
- for (i = 0; i < len; i++) {
- if (state == IN_TEXT) {
- if (tagChange(otag, text, i)) {
- --i;
- addBuf();
- state = IN_TAG_TYPE;
- } else {
- if (text.charAt(i) == '\n') {
- filterLine(seenTag);
- } else {
- buf += text.charAt(i);
- }
- }
- } else if (state == IN_TAG_TYPE) {
- i += otag.length - 1;
- tag = Hogan.tags[text.charAt(i + 1)];
- tagType = tag ? text.charAt(i + 1) : '_v';
- if (tagType == '=') {
- i = changeDelimiters(text, i);
- state = IN_TEXT;
- } else {
- if (tag) {
- i++;
- }
- state = IN_TAG;
- }
- seenTag = i;
- } else {
- if (tagChange(ctag, text, i)) {
- tokens.push({tag: tagType, n: trim(buf), otag: otag, ctag: ctag,
- i: (tagType == '/') ? seenTag - otag.length : i + ctag.length});
- buf = '';
- i += ctag.length - 1;
- state = IN_TEXT;
- if (tagType == '{') {
- if (ctag == '}}') {
- i++;
- } else {
- cleanTripleStache(tokens[tokens.length - 1]);
- }
- }
- } else {
- buf += text.charAt(i);
- }
- }
- }
-
- filterLine(seenTag, true);
-
- return tokens;
- }
-
- function cleanTripleStache(token) {
- if (token.n.substr(token.n.length - 1) === '}') {
- token.n = token.n.substring(0, token.n.length - 1);
- }
- }
-
- function trim(s) {
- if (s.trim) {
- return s.trim();
- }
-
- return s.replace(/^\s*|\s*$/g, '');
- }
-
- function tagChange(tag, text, index) {
- if (text.charAt(index) != tag.charAt(0)) {
- return false;
- }
-
- for (var i = 1, l = tag.length; i < l; i++) {
- if (text.charAt(index + i) != tag.charAt(i)) {
- return false;
- }
- }
-
- return true;
- }
-
- // the tags allowed inside super templates
- var allowedInSuper = {'_t': true, '\n': true, '$': true, '/': true};
-
- function buildTree(tokens, kind, stack, customTags) {
- var instructions = [],
- opener = null,
- tail = null,
- token = null;
-
- tail = stack[stack.length - 1];
-
- while (tokens.length > 0) {
- token = tokens.shift();
-
- if (tail && tail.tag == '<' && !(token.tag in allowedInSuper)) {
- throw new Error('Illegal content in < super tag.');
- }
-
- if (Hogan.tags[token.tag] <= Hogan.tags['$'] || isOpener(token, customTags)) {
- stack.push(token);
- token.nodes = buildTree(tokens, token.tag, stack, customTags);
- } else if (token.tag == '/') {
- if (stack.length === 0) {
- throw new Error('Closing tag without opener: /' + token.n);
- }
- opener = stack.pop();
- if (token.n != opener.n && !isCloser(token.n, opener.n, customTags)) {
- throw new Error('Nesting error: ' + opener.n + ' vs. ' + token.n);
- }
- opener.end = token.i;
- return instructions;
- } else if (token.tag == '\n') {
- token.last = (tokens.length == 0) || (tokens[0].tag == '\n');
- }
-
- instructions.push(token);
- }
-
- if (stack.length > 0) {
- throw new Error('missing closing tag: ' + stack.pop().n);
- }
-
- return instructions;
- }
-
- function isOpener(token, tags) {
- for (var i = 0, l = tags.length; i < l; i++) {
- if (tags[i].o == token.n) {
- token.tag = '#';
- return true;
- }
- }
- }
-
- function isCloser(close, open, tags) {
- for (var i = 0, l = tags.length; i < l; i++) {
- if (tags[i].c == close && tags[i].o == open) {
- return true;
- }
- }
- }
-
- function stringifySubstitutions(obj) {
- var items = [];
- for (var key in obj) {
- items.push('"' + esc(key) + '": function(c,p,t,i) {' + obj[key] + '}');
- }
- return "{ " + items.join(",") + " }";
- }
-
- function stringifyPartials(codeObj) {
- var partials = [];
- for (var key in codeObj.partials) {
- partials.push('"' + esc(key) + '":{name:"' + esc(codeObj.partials[key].name) + '", ' + stringifyPartials(codeObj.partials[key]) + "}");
- }
- return "partials: {" + partials.join(",") + "}, subs: " + stringifySubstitutions(codeObj.subs);
- }
-
- Hogan.stringify = function(codeObj, text, options) {
- return "{code: function (c,p,i) { " + Hogan.wrapMain(codeObj.code) + " }," + stringifyPartials(codeObj) + "}";
- }
-
- var serialNo = 0;
- Hogan.generate = function(tree, text, options) {
- serialNo = 0;
- var context = { code: '', subs: {}, partials: {} };
- Hogan.walk(tree, context);
-
- if (options.asString) {
- return this.stringify(context, text, options);
- }
-
- return this.makeTemplate(context, text, options);
- }
-
- Hogan.wrapMain = function(code) {
- return 'var t=this;t.b(i=i||"");' + code + 'return t.fl();';
- }
-
- Hogan.template = Hogan.Template;
-
- Hogan.makeTemplate = function(codeObj, text, options) {
- var template = this.makePartials(codeObj);
- template.code = new Function('c', 'p', 'i', this.wrapMain(codeObj.code));
- return new this.template(template, text, this, options);
- }
-
- Hogan.makePartials = function(codeObj) {
- var key, template = {subs: {}, partials: codeObj.partials, name: codeObj.name};
- for (key in template.partials) {
- template.partials[key] = this.makePartials(template.partials[key]);
- }
- for (key in codeObj.subs) {
- template.subs[key] = new Function('c', 'p', 't', 'i', codeObj.subs[key]);
- }
- return template;
- }
-
- function esc(s) {
- return s.replace(rSlash, '\\\\')
- .replace(rQuot, '\\\"')
- .replace(rNewline, '\\n')
- .replace(rCr, '\\r')
- .replace(rLineSep, '\\u2028')
- .replace(rParagraphSep, '\\u2029');
- }
-
- function chooseMethod(s) {
- return (~s.indexOf('.')) ? 'd' : 'f';
- }
-
- function createPartial(node, context) {
- var prefix = "<" + (context.prefix || "");
- var sym = prefix + node.n + serialNo++;
- context.partials[sym] = {name: node.n, partials: {}};
- context.code += 't.b(t.rp("' + esc(sym) + '",c,p,"' + (node.indent || '') + '"));';
- return sym;
- }
-
- Hogan.codegen = {
- '#': function(node, context) {
- context.code += 'if(t.s(t.' + chooseMethod(node.n) + '("' + esc(node.n) + '",c,p,1),' +
- 'c,p,0,' + node.i + ',' + node.end + ',"' + node.otag + " " + node.ctag + '")){' +
- 't.rs(c,p,' + 'function(c,p,t){';
- Hogan.walk(node.nodes, context);
- context.code += '});c.pop();}';
- },
-
- '^': function(node, context) {
- context.code += 'if(!t.s(t.' + chooseMethod(node.n) + '("' + esc(node.n) + '",c,p,1),c,p,1,0,0,"")){';
- Hogan.walk(node.nodes, context);
- context.code += '};';
- },
-
- '>': createPartial,
- '<': function(node, context) {
- var ctx = {partials: {}, code: '', subs: {}, inPartial: true};
- Hogan.walk(node.nodes, ctx);
- var template = context.partials[createPartial(node, context)];
- template.subs = ctx.subs;
- template.partials = ctx.partials;
- },
-
- '$': function(node, context) {
- var ctx = {subs: {}, code: '', partials: context.partials, prefix: node.n};
- Hogan.walk(node.nodes, ctx);
- context.subs[node.n] = ctx.code;
- if (!context.inPartial) {
- context.code += 't.sub("' + esc(node.n) + '",c,p,i);';
- }
- },
-
- '\n': function(node, context) {
- context.code += write('"\\n"' + (node.last ? '' : ' + i'));
- },
-
- '_v': function(node, context) {
- context.code += 't.b(t.v(t.' + chooseMethod(node.n) + '("' + esc(node.n) + '",c,p,0)));';
- },
-
- '_t': function(node, context) {
- context.code += write('"' + esc(node.text) + '"');
- },
-
- '{': tripleStache,
-
- '&': tripleStache
- }
-
- function tripleStache(node, context) {
- context.code += 't.b(t.t(t.' + chooseMethod(node.n) + '("' + esc(node.n) + '",c,p,0)));';
- }
-
- function write(s) {
- return 't.b(' + s + ');';
- }
-
- Hogan.walk = function(nodelist, context) {
- var func;
- for (var i = 0, l = nodelist.length; i < l; i++) {
- func = Hogan.codegen[nodelist[i].tag];
- func && func(nodelist[i], context);
- }
- return context;
- }
-
- Hogan.parse = function(tokens, text, options) {
- options = options || {};
- return buildTree(tokens, '', [], options.sectionTags || []);
- }
-
- Hogan.cache = {};
-
- Hogan.cacheKey = function(text, options) {
- return [text, !!options.asString, !!options.disableLambda, options.delimiters, !!options.modelGet].join('||');
- }
-
- Hogan.compile = function(text, options) {
- options = options || {};
- var key = Hogan.cacheKey(text, options);
- var template = this.cache[key];
-
- if (template) {
- var partials = template.partials;
- for (var name in partials) {
- delete partials[name].instance;
- }
- return template;
- }
-
- template = this.generate(this.parse(this.scan(text, options.delimiters), text, options), text, options);
- return this.cache[key] = template;
- }
- })( true ? exports : undefined);
-
-
- /***/ }),
-
- /***/ "Ruv9":
- /***/ (function(module, exports, __webpack_require__) {
-
- /*
- * Copyright 2011 Twitter, Inc.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
- // This file is for use with Node.js. See dist/ for browser files.
-
- var Hogan = __webpack_require__("PKsF");
- Hogan.Template = __webpack_require__("cK6b").Template;
- Hogan.template = Hogan.Template;
- module.exports = Hogan;
-
-
- /***/ }),
-
- /***/ "cK6b":
- /***/ (function(module, exports, __webpack_require__) {
-
- /*
- * Copyright 2011 Twitter, Inc.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
- var Hogan = {};
-
- (function (Hogan) {
- Hogan.Template = function (codeObj, text, compiler, options) {
- codeObj = codeObj || {};
- this.r = codeObj.code || this.r;
- this.c = compiler;
- this.options = options || {};
- this.text = text || '';
- this.partials = codeObj.partials || {};
- this.subs = codeObj.subs || {};
- this.buf = '';
- }
-
- Hogan.Template.prototype = {
- // render: replaced by generated code.
- r: function (context, partials, indent) { return ''; },
-
- // variable escaping
- v: hoganEscape,
-
- // triple stache
- t: coerceToString,
-
- render: function render(context, partials, indent) {
- return this.ri([context], partials || {}, indent);
- },
-
- // render internal -- a hook for overrides that catches partials too
- ri: function (context, partials, indent) {
- return this.r(context, partials, indent);
- },
-
- // ensurePartial
- ep: function(symbol, partials) {
- var partial = this.partials[symbol];
-
- // check to see that if we've instantiated this partial before
- var template = partials[partial.name];
- if (partial.instance && partial.base == template) {
- return partial.instance;
- }
-
- if (typeof template == 'string') {
- if (!this.c) {
- throw new Error("No compiler available.");
- }
- template = this.c.compile(template, this.options);
- }
-
- if (!template) {
- return null;
- }
-
- // We use this to check whether the partials dictionary has changed
- this.partials[symbol].base = template;
-
- if (partial.subs) {
- // Make sure we consider parent template now
- if (!partials.stackText) partials.stackText = {};
- for (key in partial.subs) {
- if (!partials.stackText[key]) {
- partials.stackText[key] = (this.activeSub !== undefined && partials.stackText[this.activeSub]) ? partials.stackText[this.activeSub] : this.text;
- }
- }
- template = createSpecializedPartial(template, partial.subs, partial.partials,
- this.stackSubs, this.stackPartials, partials.stackText);
- }
- this.partials[symbol].instance = template;
-
- return template;
- },
-
- // tries to find a partial in the current scope and render it
- rp: function(symbol, context, partials, indent) {
- var partial = this.ep(symbol, partials);
- if (!partial) {
- return '';
- }
-
- return partial.ri(context, partials, indent);
- },
-
- // render a section
- rs: function(context, partials, section) {
- var tail = context[context.length - 1];
-
- if (!isArray(tail)) {
- section(context, partials, this);
- return;
- }
-
- for (var i = 0; i < tail.length; i++) {
- context.push(tail[i]);
- section(context, partials, this);
- context.pop();
- }
- },
-
- // maybe start a section
- s: function(val, ctx, partials, inverted, start, end, tags) {
- var pass;
-
- if (isArray(val) && val.length === 0) {
- return false;
- }
-
- if (typeof val == 'function') {
- val = this.ms(val, ctx, partials, inverted, start, end, tags);
- }
-
- pass = !!val;
-
- if (!inverted && pass && ctx) {
- ctx.push((typeof val == 'object') ? val : ctx[ctx.length - 1]);
- }
-
- return pass;
- },
-
- // find values with dotted names
- d: function(key, ctx, partials, returnFound) {
- var found,
- names = key.split('.'),
- val = this.f(names[0], ctx, partials, returnFound),
- doModelGet = this.options.modelGet,
- cx = null;
-
- if (key === '.' && isArray(ctx[ctx.length - 2])) {
- val = ctx[ctx.length - 1];
- } else {
- for (var i = 1; i < names.length; i++) {
- found = findInScope(names[i], val, doModelGet);
- if (found !== undefined) {
- cx = val;
- val = found;
- } else {
- val = '';
- }
- }
- }
-
- if (returnFound && !val) {
- return false;
- }
-
- if (!returnFound && typeof val == 'function') {
- ctx.push(cx);
- val = this.mv(val, ctx, partials);
- ctx.pop();
- }
-
- return val;
- },
-
- // find values with normal names
- f: function(key, ctx, partials, returnFound) {
- var val = false,
- v = null,
- found = false,
- doModelGet = this.options.modelGet;
-
- for (var i = ctx.length - 1; i >= 0; i--) {
- v = ctx[i];
- val = findInScope(key, v, doModelGet);
- if (val !== undefined) {
- found = true;
- break;
- }
- }
-
- if (!found) {
- return (returnFound) ? false : "";
- }
-
- if (!returnFound && typeof val == 'function') {
- val = this.mv(val, ctx, partials);
- }
-
- return val;
- },
-
- // higher order templates
- ls: function(func, cx, partials, text, tags) {
- var oldTags = this.options.delimiters;
-
- this.options.delimiters = tags;
- this.b(this.ct(coerceToString(func.call(cx, text)), cx, partials));
- this.options.delimiters = oldTags;
-
- return false;
- },
-
- // compile text
- ct: function(text, cx, partials) {
- if (this.options.disableLambda) {
- throw new Error('Lambda features disabled.');
- }
- return this.c.compile(text, this.options).render(cx, partials);
- },
-
- // template result buffering
- b: function(s) { this.buf += s; },
-
- fl: function() { var r = this.buf; this.buf = ''; return r; },
-
- // method replace section
- ms: function(func, ctx, partials, inverted, start, end, tags) {
- var textSource,
- cx = ctx[ctx.length - 1],
- result = func.call(cx);
-
- if (typeof result == 'function') {
- if (inverted) {
- return true;
- } else {
- textSource = (this.activeSub && this.subsText && this.subsText[this.activeSub]) ? this.subsText[this.activeSub] : this.text;
- return this.ls(result, cx, partials, textSource.substring(start, end), tags);
- }
- }
-
- return result;
- },
-
- // method replace variable
- mv: function(func, ctx, partials) {
- var cx = ctx[ctx.length - 1];
- var result = func.call(cx);
-
- if (typeof result == 'function') {
- return this.ct(coerceToString(result.call(cx)), cx, partials);
- }
-
- return result;
- },
-
- sub: function(name, context, partials, indent) {
- var f = this.subs[name];
- if (f) {
- this.activeSub = name;
- f(context, partials, this, indent);
- this.activeSub = false;
- }
- }
-
- };
-
- //Find a key in an object
- function findInScope(key, scope, doModelGet) {
- var val;
-
- if (scope && typeof scope == 'object') {
-
- if (scope[key] !== undefined) {
- val = scope[key];
-
- // try lookup with get for backbone or similar model data
- } else if (doModelGet && scope.get && typeof scope.get == 'function') {
- val = scope.get(key);
- }
- }
-
- return val;
- }
-
- function createSpecializedPartial(instance, subs, partials, stackSubs, stackPartials, stackText) {
- function PartialTemplate() {};
- PartialTemplate.prototype = instance;
- function Substitutions() {};
- Substitutions.prototype = instance.subs;
- var key;
- var partial = new PartialTemplate();
- partial.subs = new Substitutions();
- partial.subsText = {}; //hehe. substext.
- partial.buf = '';
-
- stackSubs = stackSubs || {};
- partial.stackSubs = stackSubs;
- partial.subsText = stackText;
- for (key in subs) {
- if (!stackSubs[key]) stackSubs[key] = subs[key];
- }
- for (key in stackSubs) {
- partial.subs[key] = stackSubs[key];
- }
-
- stackPartials = stackPartials || {};
- partial.stackPartials = stackPartials;
- for (key in partials) {
- if (!stackPartials[key]) stackPartials[key] = partials[key];
- }
- for (key in stackPartials) {
- partial.partials[key] = stackPartials[key];
- }
-
- return partial;
- }
-
- var rAmp = /&/g,
- rLt = /</g,
- rGt = />/g,
- rApos = /\'/g,
- rQuot = /\"/g,
- hChars = /[&<>\"\']/;
-
- function coerceToString(val) {
- return String((val === null || val === undefined) ? '' : val);
- }
-
- function hoganEscape(str) {
- str = coerceToString(str);
- return hChars.test(str) ?
- str
- .replace(rAmp, '&')
- .replace(rLt, '<')
- .replace(rGt, '>')
- .replace(rApos, ''')
- .replace(rQuot, '"') :
- str;
- }
-
- var isArray = Array.isArray || function(a) {
- return Object.prototype.toString.call(a) === '[object Array]';
- };
-
- })( true ? exports : undefined);
-
-
- /***/ }),
-
- /***/ "e6Wu":
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
-
- "use strict";
- // ESM COMPAT FLAG
- __webpack_require__.r(__webpack_exports__);
-
- // EXTERNAL MODULE: ./node_modules/difflib/index.js
- var difflib = __webpack_require__("7Mwc");
-
- // CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/types.js
- var LineType;
- (function (LineType) {
- LineType["INSERT"] = "insert";
- LineType["DELETE"] = "delete";
- LineType["CONTEXT"] = "context";
- })(LineType || (LineType = {}));
- var OutputFormatType = {
- LINE_BY_LINE: 'line-by-line',
- SIDE_BY_SIDE: 'side-by-side',
- };
- var LineMatchingType = {
- LINES: 'lines',
- WORDS: 'words',
- NONE: 'none',
- };
- var DiffStyleType = {
- WORD: 'word',
- CHAR: 'char',
- };
- //# sourceMappingURL=types.js.map
- // CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/utils.js
- var specials = [
- '-',
- '[',
- ']',
- '/',
- '{',
- '}',
- '(',
- ')',
- '*',
- '+',
- '?',
- '.',
- '\\',
- '^',
- '$',
- '|',
- ];
- var regex = RegExp('[' + specials.join('\\') + ']', 'g');
- function escapeForRegExp(str) {
- return str.replace(regex, '\\$&');
- }
- function unifyPath(path) {
- return path ? path.replace(/\\/g, '/') : path;
- }
- function hashCode(text) {
- var i, chr, len;
- var hash = 0;
- for (i = 0, len = text.length; i < len; i++) {
- chr = text.charCodeAt(i);
- hash = (hash << 5) - hash + chr;
- hash |= 0;
- }
- return hash;
- }
- //# sourceMappingURL=utils.js.map
- // CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/diff-parser.js
- var __spreadArrays = (undefined && undefined.__spreadArrays) || function () {
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
- r[k] = a[j];
- return r;
- };
-
-
- function getExtension(filename, language) {
- var filenameParts = filename.split('.');
- return filenameParts.length > 1 ? filenameParts[filenameParts.length - 1] : language;
- }
- function startsWithAny(str, prefixes) {
- return prefixes.reduce(function (startsWith, prefix) { return startsWith || str.startsWith(prefix); }, false);
- }
- var baseDiffFilenamePrefixes = ['a/', 'b/', 'i/', 'w/', 'c/', 'o/'];
- function getFilename(line, linePrefix, extraPrefix) {
- var prefixes = extraPrefix !== undefined ? __spreadArrays(baseDiffFilenamePrefixes, [extraPrefix]) : baseDiffFilenamePrefixes;
- var FilenameRegExp = linePrefix
- ? new RegExp("^" + escapeForRegExp(linePrefix) + " \"?(.+?)\"?$")
- : new RegExp('^"?(.+?)"?$');
- var _a = FilenameRegExp.exec(line) || [], _b = _a[1], filename = _b === void 0 ? '' : _b;
- var matchingPrefix = prefixes.find(function (p) { return filename.indexOf(p) === 0; });
- var fnameWithoutPrefix = matchingPrefix ? filename.slice(matchingPrefix.length) : filename;
- return fnameWithoutPrefix.replace(/\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?:\.\d+)? [+-]\d{4}.*$/, '');
- }
- function getSrcFilename(line, srcPrefix) {
- return getFilename(line, '---', srcPrefix);
- }
- function getDstFilename(line, dstPrefix) {
- return getFilename(line, '+++', dstPrefix);
- }
- function parse(diffInput, config) {
- if (config === void 0) { config = {}; }
- var files = [];
- var currentFile = null;
- var currentBlock = null;
- var oldLine = null;
- var oldLine2 = null;
- var newLine = null;
- var possibleOldName = null;
- var possibleNewName = null;
- var oldFileNameHeader = '--- ';
- var newFileNameHeader = '+++ ';
- var hunkHeaderPrefix = '@@';
- var oldMode = /^old mode (\d{6})/;
- var newMode = /^new mode (\d{6})/;
- var deletedFileMode = /^deleted file mode (\d{6})/;
- var newFileMode = /^new file mode (\d{6})/;
- var copyFrom = /^copy from "?(.+)"?/;
- var copyTo = /^copy to "?(.+)"?/;
- var renameFrom = /^rename from "?(.+)"?/;
- var renameTo = /^rename to "?(.+)"?/;
- var similarityIndex = /^similarity index (\d+)%/;
- var dissimilarityIndex = /^dissimilarity index (\d+)%/;
- var index = /^index ([\da-z]+)\.\.([\da-z]+)\s*(\d{6})?/;
- var binaryFiles = /^Binary files (.*) and (.*) differ/;
- var binaryDiff = /^GIT binary patch/;
- var combinedIndex = /^index ([\da-z]+),([\da-z]+)\.\.([\da-z]+)/;
- var combinedMode = /^mode (\d{6}),(\d{6})\.\.(\d{6})/;
- var combinedNewFile = /^new file mode (\d{6})/;
- var combinedDeletedFile = /^deleted file mode (\d{6}),(\d{6})/;
- var diffLines = diffInput
- .replace(/\\ No newline at end of file/g, '')
- .replace(/\r\n?/g, '\n')
- .split('\n');
- function saveBlock() {
- if (currentBlock !== null && currentFile !== null) {
- currentFile.blocks.push(currentBlock);
- currentBlock = null;
- }
- }
- function saveFile() {
- if (currentFile !== null) {
- if (!currentFile.oldName && possibleOldName !== null) {
- currentFile.oldName = possibleOldName;
- }
- if (!currentFile.newName && possibleNewName !== null) {
- currentFile.newName = possibleNewName;
- }
- if (currentFile.newName) {
- files.push(currentFile);
- currentFile = null;
- }
- }
- possibleOldName = null;
- possibleNewName = null;
- }
- function startFile() {
- saveBlock();
- saveFile();
- currentFile = {
- blocks: [],
- deletedLines: 0,
- addedLines: 0,
- };
- }
- function startBlock(line) {
- saveBlock();
- var values;
- if (currentFile !== null) {
- if ((values = /^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@.*/.exec(line))) {
- currentFile.isCombined = false;
- oldLine = parseInt(values[1], 10);
- newLine = parseInt(values[2], 10);
- }
- else if ((values = /^@@@ -(\d+)(?:,\d+)? -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@@.*/.exec(line))) {
- currentFile.isCombined = true;
- oldLine = parseInt(values[1], 10);
- oldLine2 = parseInt(values[2], 10);
- newLine = parseInt(values[3], 10);
- }
- else {
- if (line.startsWith(hunkHeaderPrefix)) {
- console.error('Failed to parse lines, starting in 0!');
- }
- oldLine = 0;
- newLine = 0;
- currentFile.isCombined = false;
- }
- }
- currentBlock = {
- lines: [],
- oldStartLine: oldLine,
- oldStartLine2: oldLine2,
- newStartLine: newLine,
- header: line,
- };
- }
- function createLine(line) {
- if (currentFile === null || currentBlock === null || oldLine === null || newLine === null)
- return;
- var currentLine = {
- content: line,
- };
- var addedPrefixes = currentFile.isCombined ? ['+ ', ' +', '++'] : ['+'];
- var deletedPrefixes = currentFile.isCombined ? ['- ', ' -', '--'] : ['-'];
- if (startsWithAny(line, addedPrefixes)) {
- currentFile.addedLines++;
- currentLine.type = LineType.INSERT;
- currentLine.oldNumber = undefined;
- currentLine.newNumber = newLine++;
- }
- else if (startsWithAny(line, deletedPrefixes)) {
- currentFile.deletedLines++;
- currentLine.type = LineType.DELETE;
- currentLine.oldNumber = oldLine++;
- currentLine.newNumber = undefined;
- }
- else {
- currentLine.type = LineType.CONTEXT;
- currentLine.oldNumber = oldLine++;
- currentLine.newNumber = newLine++;
- }
- currentBlock.lines.push(currentLine);
- }
- function existHunkHeader(line, lineIdx) {
- var idx = lineIdx;
- while (idx < diffLines.length - 3) {
- if (line.startsWith('diff')) {
- return false;
- }
- if (diffLines[idx].startsWith(oldFileNameHeader) &&
- diffLines[idx + 1].startsWith(newFileNameHeader) &&
- diffLines[idx + 2].startsWith(hunkHeaderPrefix)) {
- return true;
- }
- idx++;
- }
- return false;
- }
- diffLines.forEach(function (line, lineIndex) {
- if (!line || line.startsWith('*')) {
- return;
- }
- var values;
- var prevLine = diffLines[lineIndex - 1];
- var nxtLine = diffLines[lineIndex + 1];
- var afterNxtLine = diffLines[lineIndex + 2];
- if (line.startsWith('diff')) {
- startFile();
- var gitDiffStart = /^diff --git "?(.+)"? "?(.+)"?/;
- if ((values = gitDiffStart.exec(line))) {
- possibleOldName = getFilename(values[1], undefined, config.dstPrefix);
- possibleNewName = getFilename(values[2], undefined, config.srcPrefix);
- }
- if (currentFile === null) {
- throw new Error('Where is my file !!!');
- }
- currentFile.isGitDiff = true;
- return;
- }
- if (!currentFile ||
- (!currentFile.isGitDiff &&
- currentFile &&
- line.startsWith(oldFileNameHeader) &&
- nxtLine.startsWith(newFileNameHeader) &&
- afterNxtLine.startsWith(hunkHeaderPrefix))) {
- startFile();
- }
- if ((line.startsWith(oldFileNameHeader) && nxtLine.startsWith(newFileNameHeader)) ||
- (line.startsWith(newFileNameHeader) && prevLine.startsWith(oldFileNameHeader))) {
- if (currentFile &&
- !currentFile.oldName &&
- line.startsWith('--- ') &&
- (values = getSrcFilename(line, config.srcPrefix))) {
- currentFile.oldName = values;
- currentFile.language = getExtension(currentFile.oldName, currentFile.language);
- return;
- }
- if (currentFile &&
- !currentFile.newName &&
- line.startsWith('+++ ') &&
- (values = getDstFilename(line, config.dstPrefix))) {
- currentFile.newName = values;
- currentFile.language = getExtension(currentFile.newName, currentFile.language);
- return;
- }
- }
- if (currentFile &&
- (line.startsWith(hunkHeaderPrefix) ||
- (currentFile.isGitDiff && currentFile.oldName && currentFile.newName && !currentBlock))) {
- startBlock(line);
- return;
- }
- if (currentBlock && (line.startsWith('+') || line.startsWith('-') || line.startsWith(' '))) {
- createLine(line);
- return;
- }
- var doesNotExistHunkHeader = !existHunkHeader(line, lineIndex);
- if (currentFile === null) {
- throw new Error('Where is my file !!!');
- }
- if ((values = oldMode.exec(line))) {
- currentFile.oldMode = values[1];
- }
- else if ((values = newMode.exec(line))) {
- currentFile.newMode = values[1];
- }
- else if ((values = deletedFileMode.exec(line))) {
- currentFile.deletedFileMode = values[1];
- currentFile.isDeleted = true;
- }
- else if ((values = newFileMode.exec(line))) {
- currentFile.newFileMode = values[1];
- currentFile.isNew = true;
- }
- else if ((values = copyFrom.exec(line))) {
- if (doesNotExistHunkHeader) {
- currentFile.oldName = values[1];
- }
- currentFile.isCopy = true;
- }
- else if ((values = copyTo.exec(line))) {
- if (doesNotExistHunkHeader) {
- currentFile.newName = values[1];
- }
- currentFile.isCopy = true;
- }
- else if ((values = renameFrom.exec(line))) {
- if (doesNotExistHunkHeader) {
- currentFile.oldName = values[1];
- }
- currentFile.isRename = true;
- }
- else if ((values = renameTo.exec(line))) {
- if (doesNotExistHunkHeader) {
- currentFile.newName = values[1];
- }
- currentFile.isRename = true;
- }
- else if ((values = binaryFiles.exec(line))) {
- currentFile.isBinary = true;
- currentFile.oldName = getFilename(values[1], undefined, config.srcPrefix);
- currentFile.newName = getFilename(values[2], undefined, config.dstPrefix);
- startBlock('Binary file');
- }
- else if (binaryDiff.test(line)) {
- currentFile.isBinary = true;
- startBlock(line);
- }
- else if ((values = similarityIndex.exec(line))) {
- currentFile.unchangedPercentage = parseInt(values[1], 10);
- }
- else if ((values = dissimilarityIndex.exec(line))) {
- currentFile.changedPercentage = parseInt(values[1], 10);
- }
- else if ((values = index.exec(line))) {
- currentFile.checksumBefore = values[1];
- currentFile.checksumAfter = values[2];
- values[3] && (currentFile.mode = values[3]);
- }
- else if ((values = combinedIndex.exec(line))) {
- currentFile.checksumBefore = [values[2], values[3]];
- currentFile.checksumAfter = values[1];
- }
- else if ((values = combinedMode.exec(line))) {
- currentFile.oldMode = [values[2], values[3]];
- currentFile.newMode = values[1];
- }
- else if ((values = combinedNewFile.exec(line))) {
- currentFile.newFileMode = values[1];
- currentFile.isNew = true;
- }
- else if ((values = combinedDeletedFile.exec(line))) {
- currentFile.deletedFileMode = values[1];
- currentFile.isDeleted = true;
- }
- });
- saveBlock();
- saveFile();
- return files;
- }
- //# sourceMappingURL=diff-parser.js.map
- // EXTERNAL MODULE: ./node_modules/diff/dist/diff.js
- var dist_diff = __webpack_require__("v2jn");
-
- // CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/rematch.js
- function levenshtein(a, b) {
- if (a.length === 0) {
- return b.length;
- }
- if (b.length === 0) {
- return a.length;
- }
- var matrix = [];
- var i;
- for (i = 0; i <= b.length; i++) {
- matrix[i] = [i];
- }
- var j;
- for (j = 0; j <= a.length; j++) {
- matrix[0][j] = j;
- }
- for (i = 1; i <= b.length; i++) {
- for (j = 1; j <= a.length; j++) {
- if (b.charAt(i - 1) === a.charAt(j - 1)) {
- matrix[i][j] = matrix[i - 1][j - 1];
- }
- else {
- matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, Math.min(matrix[i][j - 1] + 1, matrix[i - 1][j] + 1));
- }
- }
- }
- return matrix[b.length][a.length];
- }
- function newDistanceFn(str) {
- return function (x, y) {
- var xValue = str(x).trim();
- var yValue = str(y).trim();
- var lev = levenshtein(xValue, yValue);
- return lev / (xValue.length + yValue.length);
- };
- }
- function newMatcherFn(distance) {
- function findBestMatch(a, b, cache) {
- if (cache === void 0) { cache = new Map(); }
- var bestMatchDist = Infinity;
- var bestMatch;
- for (var i = 0; i < a.length; ++i) {
- for (var j = 0; j < b.length; ++j) {
- var cacheKey = JSON.stringify([a[i], b[j]]);
- var md = void 0;
- if (!(cache.has(cacheKey) && (md = cache.get(cacheKey)))) {
- md = distance(a[i], b[j]);
- cache.set(cacheKey, md);
- }
- if (md < bestMatchDist) {
- bestMatchDist = md;
- bestMatch = { indexA: i, indexB: j, score: bestMatchDist };
- }
- }
- }
- return bestMatch;
- }
- function group(a, b, level, cache) {
- if (level === void 0) { level = 0; }
- if (cache === void 0) { cache = new Map(); }
- var bm = findBestMatch(a, b, cache);
- if (!bm || a.length + b.length < 3) {
- return [[a, b]];
- }
- var a1 = a.slice(0, bm.indexA);
- var b1 = b.slice(0, bm.indexB);
- var aMatch = [a[bm.indexA]];
- var bMatch = [b[bm.indexB]];
- var tailA = bm.indexA + 1;
- var tailB = bm.indexB + 1;
- var a2 = a.slice(tailA);
- var b2 = b.slice(tailB);
- var group1 = group(a1, b1, level + 1, cache);
- var groupMatch = group(aMatch, bMatch, level + 1, cache);
- var group2 = group(a2, b2, level + 1, cache);
- var result = groupMatch;
- if (bm.indexA > 0 || bm.indexB > 0) {
- result = group1.concat(result);
- }
- if (a.length > tailA || b.length > tailB) {
- result = result.concat(group2);
- }
- return result;
- }
- return group;
- }
- //# sourceMappingURL=rematch.js.map
- // CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/render-utils.js
- var __assign = (undefined && undefined.__assign) || function () {
- __assign = Object.assign || function(t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
- t[p] = s[p];
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
-
-
-
-
- var CSSLineClass = {
- INSERTS: 'd2h-ins',
- DELETES: 'd2h-del',
- CONTEXT: 'd2h-cntx',
- INFO: 'd2h-info',
- INSERT_CHANGES: 'd2h-ins d2h-change',
- DELETE_CHANGES: 'd2h-del d2h-change',
- };
- var defaultRenderConfig = {
- matching: LineMatchingType.NONE,
- matchWordsThreshold: 0.25,
- maxLineLengthHighlight: 10000,
- diffStyle: DiffStyleType.WORD,
- };
- var separator = '/';
- var distance = newDistanceFn(function (change) { return change.value; });
- var render_utils_matcher = newMatcherFn(distance);
- function isDevNullName(name) {
- return name.indexOf('dev/null') !== -1;
- }
- function removeInsElements(line) {
- return line.replace(/(<ins[^>]*>((.|\n)*?)<\/ins>)/g, '');
- }
- function removeDelElements(line) {
- return line.replace(/(<del[^>]*>((.|\n)*?)<\/del>)/g, '');
- }
- function toCSSClass(lineType) {
- switch (lineType) {
- case LineType.CONTEXT:
- return CSSLineClass.CONTEXT;
- case LineType.INSERT:
- return CSSLineClass.INSERTS;
- case LineType.DELETE:
- return CSSLineClass.DELETES;
- }
- }
- function prefixLength(isCombined) {
- return isCombined ? 2 : 1;
- }
- function escapeForHtml(str) {
- return str
- .slice(0)
- .replace(/&/g, '&')
- .replace(/</g, '<')
- .replace(/>/g, '>')
- .replace(/"/g, '"')
- .replace(/'/g, ''')
- .replace(/\//g, '/');
- }
- function deconstructLine(line, isCombined, escape) {
- if (escape === void 0) { escape = true; }
- var indexToSplit = prefixLength(isCombined);
- return {
- prefix: line.substring(0, indexToSplit),
- content: escape ? escapeForHtml(line.substring(indexToSplit)) : line.substring(indexToSplit),
- };
- }
- function filenameDiff(file) {
- var oldFilename = unifyPath(file.oldName);
- var newFilename = unifyPath(file.newName);
- if (oldFilename !== newFilename && !isDevNullName(oldFilename) && !isDevNullName(newFilename)) {
- var prefixPaths = [];
- var suffixPaths = [];
- var oldFilenameParts = oldFilename.split(separator);
- var newFilenameParts = newFilename.split(separator);
- var oldFilenamePartsSize = oldFilenameParts.length;
- var newFilenamePartsSize = newFilenameParts.length;
- var i = 0;
- var j = oldFilenamePartsSize - 1;
- var k = newFilenamePartsSize - 1;
- while (i < j && i < k) {
- if (oldFilenameParts[i] === newFilenameParts[i]) {
- prefixPaths.push(newFilenameParts[i]);
- i += 1;
- }
- else {
- break;
- }
- }
- while (j > i && k > i) {
- if (oldFilenameParts[j] === newFilenameParts[k]) {
- suffixPaths.unshift(newFilenameParts[k]);
- j -= 1;
- k -= 1;
- }
- else {
- break;
- }
- }
- var finalPrefix = prefixPaths.join(separator);
- var finalSuffix = suffixPaths.join(separator);
- var oldRemainingPath = oldFilenameParts.slice(i, j + 1).join(separator);
- var newRemainingPath = newFilenameParts.slice(i, k + 1).join(separator);
- if (finalPrefix.length && finalSuffix.length) {
- return (finalPrefix + separator + '{' + oldRemainingPath + ' → ' + newRemainingPath + '}' + separator + finalSuffix);
- }
- else if (finalPrefix.length) {
- return finalPrefix + separator + '{' + oldRemainingPath + ' → ' + newRemainingPath + '}';
- }
- else if (finalSuffix.length) {
- return '{' + oldRemainingPath + ' → ' + newRemainingPath + '}' + separator + finalSuffix;
- }
- return oldFilename + ' → ' + newFilename;
- }
- else if (!isDevNullName(newFilename)) {
- return newFilename;
- }
- else {
- return oldFilename;
- }
- }
- function getHtmlId(file) {
- return "d2h-" + hashCode(filenameDiff(file))
- .toString()
- .slice(-6);
- }
- function getFileIcon(file) {
- var templateName = 'file-changed';
- if (file.isRename) {
- templateName = 'file-renamed';
- }
- else if (file.isCopy) {
- templateName = 'file-renamed';
- }
- else if (file.isNew) {
- templateName = 'file-added';
- }
- else if (file.isDeleted) {
- templateName = 'file-deleted';
- }
- else if (file.newName !== file.oldName) {
- templateName = 'file-renamed';
- }
- return templateName;
- }
- function diffHighlight(diffLine1, diffLine2, isCombined, config) {
- if (config === void 0) { config = {}; }
- var _a = __assign(__assign({}, defaultRenderConfig), config), matching = _a.matching, maxLineLengthHighlight = _a.maxLineLengthHighlight, matchWordsThreshold = _a.matchWordsThreshold, diffStyle = _a.diffStyle;
- var line1 = deconstructLine(diffLine1, isCombined, false);
- var line2 = deconstructLine(diffLine2, isCombined, false);
- if (line1.content.length > maxLineLengthHighlight || line2.content.length > maxLineLengthHighlight) {
- return {
- oldLine: {
- prefix: line1.prefix,
- content: line1.content,
- },
- newLine: {
- prefix: line2.prefix,
- content: line2.content,
- },
- };
- }
- var diff = diffStyle === 'char'
- ? dist_diff["diffChars"](line1.content, line2.content)
- : dist_diff["diffWordsWithSpace"](line1.content, line2.content);
- var changedWords = [];
- if (diffStyle === 'word' && matching === 'words') {
- var removed = diff.filter(function (element) { return element.removed; });
- var added = diff.filter(function (element) { return element.added; });
- var chunks = render_utils_matcher(added, removed);
- chunks.forEach(function (chunk) {
- if (chunk[0].length === 1 && chunk[1].length === 1) {
- var dist = distance(chunk[0][0], chunk[1][0]);
- if (dist < matchWordsThreshold) {
- changedWords.push(chunk[0][0]);
- changedWords.push(chunk[1][0]);
- }
- }
- });
- }
- var highlightedLine = diff.reduce(function (highlightedLine, part) {
- var elemType = part.added ? 'ins' : part.removed ? 'del' : null;
- var addClass = changedWords.indexOf(part) > -1 ? ' class="d2h-change"' : '';
- var escapedValue = escapeForHtml(part.value);
- return elemType !== null
- ? highlightedLine + "<" + elemType + addClass + ">" + escapedValue + "</" + elemType + ">"
- : "" + highlightedLine + escapedValue;
- }, '');
- return {
- oldLine: {
- prefix: line1.prefix,
- content: removeInsElements(highlightedLine),
- },
- newLine: {
- prefix: line2.prefix,
- content: removeDelElements(highlightedLine),
- },
- };
- }
- //# sourceMappingURL=render-utils.js.map
- // CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/file-list-renderer.js
-
- var baseTemplatesPath = 'file-summary';
- var iconsBaseTemplatesPath = 'icon';
- function render(diffFiles, hoganUtils) {
- var files = diffFiles
- .map(function (file) {
- return hoganUtils.render(baseTemplatesPath, 'line', {
- fileHtmlId: getHtmlId(file),
- oldName: file.oldName,
- newName: file.newName,
- fileName: filenameDiff(file),
- deletedLines: '-' + file.deletedLines,
- addedLines: '+' + file.addedLines,
- }, {
- fileIcon: hoganUtils.template(iconsBaseTemplatesPath, getFileIcon(file)),
- });
- })
- .join('\n');
- return hoganUtils.render(baseTemplatesPath, 'wrapper', {
- filesNumber: diffFiles.length,
- files: files,
- });
- }
- //# sourceMappingURL=file-list-renderer.js.map
- // CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/line-by-line-renderer.js
- var line_by_line_renderer_assign = (undefined && undefined.__assign) || function () {
- line_by_line_renderer_assign = Object.assign || function(t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
- t[p] = s[p];
- }
- return t;
- };
- return line_by_line_renderer_assign.apply(this, arguments);
- };
-
-
-
- var defaultLineByLineRendererConfig = line_by_line_renderer_assign(line_by_line_renderer_assign({}, defaultRenderConfig), { renderNothingWhenEmpty: false, matchingMaxComparisons: 2500, maxLineSizeInBlockForComparison: 200 });
- var genericTemplatesPath = 'generic';
- var line_by_line_renderer_baseTemplatesPath = 'line-by-line';
- var line_by_line_renderer_iconsBaseTemplatesPath = 'icon';
- var tagsBaseTemplatesPath = 'tag';
- var line_by_line_renderer_LineByLineRenderer = (function () {
- function LineByLineRenderer(hoganUtils, config) {
- if (config === void 0) { config = {}; }
- this.hoganUtils = hoganUtils;
- this.config = line_by_line_renderer_assign(line_by_line_renderer_assign({}, defaultLineByLineRendererConfig), config);
- }
- LineByLineRenderer.prototype.render = function (diffFiles) {
- var _this = this;
- var diffsHtml = diffFiles
- .map(function (file) {
- var diffs;
- if (file.blocks.length) {
- diffs = _this.generateFileHtml(file);
- }
- else {
- diffs = _this.generateEmptyDiff();
- }
- return _this.makeFileDiffHtml(file, diffs);
- })
- .join('\n');
- return this.hoganUtils.render(genericTemplatesPath, 'wrapper', { content: diffsHtml });
- };
- LineByLineRenderer.prototype.makeFileDiffHtml = function (file, diffs) {
- if (this.config.renderNothingWhenEmpty && Array.isArray(file.blocks) && file.blocks.length === 0)
- return '';
- var fileDiffTemplate = this.hoganUtils.template(line_by_line_renderer_baseTemplatesPath, 'file-diff');
- var filePathTemplate = this.hoganUtils.template(genericTemplatesPath, 'file-path');
- var fileIconTemplate = this.hoganUtils.template(line_by_line_renderer_iconsBaseTemplatesPath, 'file');
- var fileTagTemplate = this.hoganUtils.template(tagsBaseTemplatesPath, getFileIcon(file));
- return fileDiffTemplate.render({
- file: file,
- fileHtmlId: getHtmlId(file),
- diffs: diffs,
- filePath: filePathTemplate.render({
- fileDiffName: filenameDiff(file),
- }, {
- fileIcon: fileIconTemplate,
- fileTag: fileTagTemplate,
- }),
- });
- };
- LineByLineRenderer.prototype.generateEmptyDiff = function () {
- return this.hoganUtils.render(genericTemplatesPath, 'empty-diff', {
- contentClass: 'd2h-code-line',
- CSSLineClass: CSSLineClass,
- });
- };
- LineByLineRenderer.prototype.generateFileHtml = function (file) {
- var _this = this;
- var matcher = newMatcherFn(newDistanceFn(function (e) { return deconstructLine(e.content, file.isCombined).content; }));
- return file.blocks
- .map(function (block) {
- var lines = _this.hoganUtils.render(genericTemplatesPath, 'block-header', {
- CSSLineClass: CSSLineClass,
- blockHeader: block.header,
- lineClass: 'd2h-code-linenumber',
- contentClass: 'd2h-code-line',
- });
- _this.applyLineGroupping(block).forEach(function (_a) {
- var contextLines = _a[0], oldLines = _a[1], newLines = _a[2];
- if (oldLines.length && newLines.length && !contextLines.length) {
- _this.applyRematchMatching(oldLines, newLines, matcher).map(function (_a) {
- var oldLines = _a[0], newLines = _a[1];
- var _b = _this.processChangedLines(file.isCombined, oldLines, newLines), left = _b.left, right = _b.right;
- lines += left;
- lines += right;
- });
- }
- else if (contextLines.length) {
- contextLines.forEach(function (line) {
- var _a = deconstructLine(line.content, file.isCombined), prefix = _a.prefix, content = _a.content;
- lines += _this.generateSingleLineHtml({
- type: CSSLineClass.CONTEXT,
- prefix: prefix,
- content: content,
- oldNumber: line.oldNumber,
- newNumber: line.newNumber,
- });
- });
- }
- else if (oldLines.length || newLines.length) {
- var _b = _this.processChangedLines(file.isCombined, oldLines, newLines), left = _b.left, right = _b.right;
- lines += left;
- lines += right;
- }
- else {
- console.error('Unknown state reached while processing groups of lines', contextLines, oldLines, newLines);
- }
- });
- return lines;
- })
- .join('\n');
- };
- LineByLineRenderer.prototype.applyLineGroupping = function (block) {
- var blockLinesGroups = [];
- var oldLines = [];
- var newLines = [];
- for (var i = 0; i < block.lines.length; i++) {
- var diffLine = block.lines[i];
- if ((diffLine.type !== LineType.INSERT && newLines.length) ||
- (diffLine.type === LineType.CONTEXT && oldLines.length > 0)) {
- blockLinesGroups.push([[], oldLines, newLines]);
- oldLines = [];
- newLines = [];
- }
- if (diffLine.type === LineType.CONTEXT) {
- blockLinesGroups.push([[diffLine], [], []]);
- }
- else if (diffLine.type === LineType.INSERT && oldLines.length === 0) {
- blockLinesGroups.push([[], [], [diffLine]]);
- }
- else if (diffLine.type === LineType.INSERT && oldLines.length > 0) {
- newLines.push(diffLine);
- }
- else if (diffLine.type === LineType.DELETE) {
- oldLines.push(diffLine);
- }
- }
- if (oldLines.length || newLines.length) {
- blockLinesGroups.push([[], oldLines, newLines]);
- oldLines = [];
- newLines = [];
- }
- return blockLinesGroups;
- };
- LineByLineRenderer.prototype.applyRematchMatching = function (oldLines, newLines, matcher) {
- var comparisons = oldLines.length * newLines.length;
- var maxLineSizeInBlock = Math.max.apply(null, [0].concat(oldLines.concat(newLines).map(function (elem) { return elem.content.length; })));
- var doMatching = comparisons < this.config.matchingMaxComparisons &&
- maxLineSizeInBlock < this.config.maxLineSizeInBlockForComparison &&
- (this.config.matching === 'lines' || this.config.matching === 'words');
- return doMatching ? matcher(oldLines, newLines) : [[oldLines, newLines]];
- };
- LineByLineRenderer.prototype.processChangedLines = function (isCombined, oldLines, newLines) {
- var fileHtml = {
- right: '',
- left: '',
- };
- var maxLinesNumber = Math.max(oldLines.length, newLines.length);
- for (var i = 0; i < maxLinesNumber; i++) {
- var oldLine = oldLines[i];
- var newLine = newLines[i];
- var diff = oldLine !== undefined && newLine !== undefined
- ? diffHighlight(oldLine.content, newLine.content, isCombined, this.config)
- : undefined;
- var preparedOldLine = oldLine !== undefined && oldLine.oldNumber !== undefined
- ? line_by_line_renderer_assign(line_by_line_renderer_assign({}, (diff !== undefined
- ? {
- prefix: diff.oldLine.prefix,
- content: diff.oldLine.content,
- type: CSSLineClass.DELETE_CHANGES,
- }
- : line_by_line_renderer_assign(line_by_line_renderer_assign({}, deconstructLine(oldLine.content, isCombined)), { type: toCSSClass(oldLine.type) }))), { oldNumber: oldLine.oldNumber, newNumber: oldLine.newNumber }) : undefined;
- var preparedNewLine = newLine !== undefined && newLine.newNumber !== undefined
- ? line_by_line_renderer_assign(line_by_line_renderer_assign({}, (diff !== undefined
- ? {
- prefix: diff.newLine.prefix,
- content: diff.newLine.content,
- type: CSSLineClass.INSERT_CHANGES,
- }
- : line_by_line_renderer_assign(line_by_line_renderer_assign({}, deconstructLine(newLine.content, isCombined)), { type: toCSSClass(newLine.type) }))), { oldNumber: newLine.oldNumber, newNumber: newLine.newNumber }) : undefined;
- var _a = this.generateLineHtml(preparedOldLine, preparedNewLine), left = _a.left, right = _a.right;
- fileHtml.left += left;
- fileHtml.right += right;
- }
- return fileHtml;
- };
- LineByLineRenderer.prototype.generateLineHtml = function (oldLine, newLine) {
- return {
- left: this.generateSingleLineHtml(oldLine),
- right: this.generateSingleLineHtml(newLine),
- };
- };
- LineByLineRenderer.prototype.generateSingleLineHtml = function (line) {
- if (line === undefined)
- return '';
- var lineNumberHtml = this.hoganUtils.render(line_by_line_renderer_baseTemplatesPath, 'numbers', {
- oldNumber: line.oldNumber || '',
- newNumber: line.newNumber || '',
- });
- return this.hoganUtils.render(genericTemplatesPath, 'line', {
- type: line.type,
- lineClass: 'd2h-code-linenumber',
- contentClass: 'd2h-code-line',
- prefix: line.prefix === ' ' ? ' ' : line.prefix,
- content: line.content,
- lineNumber: lineNumberHtml,
- });
- };
- return LineByLineRenderer;
- }());
- /* harmony default export */ var line_by_line_renderer = (line_by_line_renderer_LineByLineRenderer);
- //# sourceMappingURL=line-by-line-renderer.js.map
- // CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/side-by-side-renderer.js
- var side_by_side_renderer_assign = (undefined && undefined.__assign) || function () {
- side_by_side_renderer_assign = Object.assign || function(t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
- t[p] = s[p];
- }
- return t;
- };
- return side_by_side_renderer_assign.apply(this, arguments);
- };
-
-
-
- var defaultSideBySideRendererConfig = side_by_side_renderer_assign(side_by_side_renderer_assign({}, defaultRenderConfig), { renderNothingWhenEmpty: false, matchingMaxComparisons: 2500, maxLineSizeInBlockForComparison: 200 });
- var side_by_side_renderer_genericTemplatesPath = 'generic';
- var side_by_side_renderer_baseTemplatesPath = 'side-by-side';
- var side_by_side_renderer_iconsBaseTemplatesPath = 'icon';
- var side_by_side_renderer_tagsBaseTemplatesPath = 'tag';
- var side_by_side_renderer_SideBySideRenderer = (function () {
- function SideBySideRenderer(hoganUtils, config) {
- if (config === void 0) { config = {}; }
- this.hoganUtils = hoganUtils;
- this.config = side_by_side_renderer_assign(side_by_side_renderer_assign({}, defaultSideBySideRendererConfig), config);
- }
- SideBySideRenderer.prototype.render = function (diffFiles) {
- var _this = this;
- var diffsHtml = diffFiles
- .map(function (file) {
- var diffs;
- if (file.blocks.length) {
- diffs = _this.generateFileHtml(file);
- }
- else {
- diffs = _this.generateEmptyDiff();
- }
- return _this.makeFileDiffHtml(file, diffs);
- })
- .join('\n');
- return this.hoganUtils.render(side_by_side_renderer_genericTemplatesPath, 'wrapper', { content: diffsHtml });
- };
- SideBySideRenderer.prototype.makeFileDiffHtml = function (file, diffs) {
- if (this.config.renderNothingWhenEmpty && Array.isArray(file.blocks) && file.blocks.length === 0)
- return '';
- var fileDiffTemplate = this.hoganUtils.template(side_by_side_renderer_baseTemplatesPath, 'file-diff');
- var filePathTemplate = this.hoganUtils.template(side_by_side_renderer_genericTemplatesPath, 'file-path');
- var fileIconTemplate = this.hoganUtils.template(side_by_side_renderer_iconsBaseTemplatesPath, 'file');
- var fileTagTemplate = this.hoganUtils.template(side_by_side_renderer_tagsBaseTemplatesPath, getFileIcon(file));
- return fileDiffTemplate.render({
- file: file,
- fileHtmlId: getHtmlId(file),
- diffs: diffs,
- filePath: filePathTemplate.render({
- fileDiffName: filenameDiff(file),
- }, {
- fileIcon: fileIconTemplate,
- fileTag: fileTagTemplate,
- }),
- });
- };
- SideBySideRenderer.prototype.generateEmptyDiff = function () {
- return {
- right: '',
- left: this.hoganUtils.render(side_by_side_renderer_genericTemplatesPath, 'empty-diff', {
- contentClass: 'd2h-code-side-line',
- CSSLineClass: CSSLineClass,
- }),
- };
- };
- SideBySideRenderer.prototype.generateFileHtml = function (file) {
- var _this = this;
- var matcher = newMatcherFn(newDistanceFn(function (e) { return deconstructLine(e.content, file.isCombined).content; }));
- return file.blocks
- .map(function (block) {
- var fileHtml = {
- left: _this.makeHeaderHtml(block.header),
- right: _this.makeHeaderHtml(''),
- };
- _this.applyLineGroupping(block).forEach(function (_a) {
- var contextLines = _a[0], oldLines = _a[1], newLines = _a[2];
- if (oldLines.length && newLines.length && !contextLines.length) {
- _this.applyRematchMatching(oldLines, newLines, matcher).map(function (_a) {
- var oldLines = _a[0], newLines = _a[1];
- var _b = _this.processChangedLines(file.isCombined, oldLines, newLines), left = _b.left, right = _b.right;
- fileHtml.left += left;
- fileHtml.right += right;
- });
- }
- else if (contextLines.length) {
- contextLines.forEach(function (line) {
- var _a = deconstructLine(line.content, file.isCombined), prefix = _a.prefix, content = _a.content;
- var _b = _this.generateLineHtml({
- type: CSSLineClass.CONTEXT,
- prefix: prefix,
- content: content,
- number: line.oldNumber,
- }, {
- type: CSSLineClass.CONTEXT,
- prefix: prefix,
- content: content,
- number: line.newNumber,
- }), left = _b.left, right = _b.right;
- fileHtml.left += left;
- fileHtml.right += right;
- });
- }
- else if (oldLines.length || newLines.length) {
- var _b = _this.processChangedLines(file.isCombined, oldLines, newLines), left = _b.left, right = _b.right;
- fileHtml.left += left;
- fileHtml.right += right;
- }
- else {
- console.error('Unknown state reached while processing groups of lines', contextLines, oldLines, newLines);
- }
- });
- return fileHtml;
- })
- .reduce(function (accomulated, html) {
- return { left: accomulated.left + html.left, right: accomulated.right + html.right };
- }, { left: '', right: '' });
- };
- SideBySideRenderer.prototype.applyLineGroupping = function (block) {
- var blockLinesGroups = [];
- var oldLines = [];
- var newLines = [];
- for (var i = 0; i < block.lines.length; i++) {
- var diffLine = block.lines[i];
- if ((diffLine.type !== LineType.INSERT && newLines.length) ||
- (diffLine.type === LineType.CONTEXT && oldLines.length > 0)) {
- blockLinesGroups.push([[], oldLines, newLines]);
- oldLines = [];
- newLines = [];
- }
- if (diffLine.type === LineType.CONTEXT) {
- blockLinesGroups.push([[diffLine], [], []]);
- }
- else if (diffLine.type === LineType.INSERT && oldLines.length === 0) {
- blockLinesGroups.push([[], [], [diffLine]]);
- }
- else if (diffLine.type === LineType.INSERT && oldLines.length > 0) {
- newLines.push(diffLine);
- }
- else if (diffLine.type === LineType.DELETE) {
- oldLines.push(diffLine);
- }
- }
- if (oldLines.length || newLines.length) {
- blockLinesGroups.push([[], oldLines, newLines]);
- oldLines = [];
- newLines = [];
- }
- return blockLinesGroups;
- };
- SideBySideRenderer.prototype.applyRematchMatching = function (oldLines, newLines, matcher) {
- var comparisons = oldLines.length * newLines.length;
- var maxLineSizeInBlock = Math.max.apply(null, [0].concat(oldLines.concat(newLines).map(function (elem) { return elem.content.length; })));
- var doMatching = comparisons < this.config.matchingMaxComparisons &&
- maxLineSizeInBlock < this.config.maxLineSizeInBlockForComparison &&
- (this.config.matching === 'lines' || this.config.matching === 'words');
- return doMatching ? matcher(oldLines, newLines) : [[oldLines, newLines]];
- };
- SideBySideRenderer.prototype.makeHeaderHtml = function (blockHeader) {
- return this.hoganUtils.render(side_by_side_renderer_genericTemplatesPath, 'block-header', {
- CSSLineClass: CSSLineClass,
- blockHeader: blockHeader,
- lineClass: 'd2h-code-side-linenumber',
- contentClass: 'd2h-code-side-line',
- });
- };
- SideBySideRenderer.prototype.processChangedLines = function (isCombined, oldLines, newLines) {
- var fileHtml = {
- right: '',
- left: '',
- };
- var maxLinesNumber = Math.max(oldLines.length, newLines.length);
- for (var i = 0; i < maxLinesNumber; i++) {
- var oldLine = oldLines[i];
- var newLine = newLines[i];
- var diff = oldLine !== undefined && newLine !== undefined
- ? diffHighlight(oldLine.content, newLine.content, isCombined, this.config)
- : undefined;
- var preparedOldLine = oldLine !== undefined && oldLine.oldNumber !== undefined
- ? side_by_side_renderer_assign(side_by_side_renderer_assign({}, (diff !== undefined
- ? {
- prefix: diff.oldLine.prefix,
- content: diff.oldLine.content,
- type: CSSLineClass.DELETE_CHANGES,
- }
- : side_by_side_renderer_assign(side_by_side_renderer_assign({}, deconstructLine(oldLine.content, isCombined)), { type: toCSSClass(oldLine.type) }))), { number: oldLine.oldNumber }) : undefined;
- var preparedNewLine = newLine !== undefined && newLine.newNumber !== undefined
- ? side_by_side_renderer_assign(side_by_side_renderer_assign({}, (diff !== undefined
- ? {
- prefix: diff.newLine.prefix,
- content: diff.newLine.content,
- type: CSSLineClass.INSERT_CHANGES,
- }
- : side_by_side_renderer_assign(side_by_side_renderer_assign({}, deconstructLine(newLine.content, isCombined)), { type: toCSSClass(newLine.type) }))), { number: newLine.newNumber }) : undefined;
- var _a = this.generateLineHtml(preparedOldLine, preparedNewLine), left = _a.left, right = _a.right;
- fileHtml.left += left;
- fileHtml.right += right;
- }
- return fileHtml;
- };
- SideBySideRenderer.prototype.generateLineHtml = function (oldLine, newLine) {
- return {
- left: this.generateSingleHtml(oldLine),
- right: this.generateSingleHtml(newLine),
- };
- };
- SideBySideRenderer.prototype.generateSingleHtml = function (line) {
- var lineClass = 'd2h-code-side-linenumber';
- var contentClass = 'd2h-code-side-line';
- return this.hoganUtils.render(side_by_side_renderer_genericTemplatesPath, 'line', {
- type: (line === null || line === void 0 ? void 0 : line.type) || CSSLineClass.CONTEXT + " d2h-emptyplaceholder",
- lineClass: line !== undefined ? lineClass : lineClass + " d2h-code-side-emptyplaceholder",
- contentClass: line !== undefined ? contentClass : contentClass + " d2h-code-side-emptyplaceholder",
- prefix: (line === null || line === void 0 ? void 0 : line.prefix) === ' ' ? ' ' : line === null || line === void 0 ? void 0 : line.prefix,
- content: line === null || line === void 0 ? void 0 : line.content,
- lineNumber: line === null || line === void 0 ? void 0 : line.number,
- });
- };
- return SideBySideRenderer;
- }());
- /* harmony default export */ var side_by_side_renderer = (side_by_side_renderer_SideBySideRenderer);
- //# sourceMappingURL=side-by-side-renderer.js.map
- // EXTERNAL MODULE: ./node_modules/hogan.js/lib/hogan.js
- var hogan = __webpack_require__("Ruv9");
-
- // CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/diff2html-templates.js
-
- var defaultTemplates = {};
- defaultTemplates["file-summary-line"] = new hogan["Template"]({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<li class=\"d2h-file-list-line\">"); t.b("\n" + i); t.b(" <span class=\"d2h-file-name-wrapper\">"); t.b("\n" + i); t.b(t.rp("<fileIcon0", c, p, " ")); t.b(" <a href=\"#"); t.b(t.v(t.f("fileHtmlId", c, p, 0))); t.b("\" class=\"d2h-file-name\">"); t.b(t.v(t.f("fileName", c, p, 0))); t.b("</a>"); t.b("\n" + i); t.b(" <span class=\"d2h-file-stats\">"); t.b("\n" + i); t.b(" <span class=\"d2h-lines-added\">"); t.b(t.v(t.f("addedLines", c, p, 0))); t.b("</span>"); t.b("\n" + i); t.b(" <span class=\"d2h-lines-deleted\">"); t.b(t.v(t.f("deletedLines", c, p, 0))); t.b("</span>"); t.b("\n" + i); t.b(" </span>"); t.b("\n" + i); t.b(" </span>"); t.b("\n" + i); t.b("</li>"); return t.fl(); }, partials: { "<fileIcon0": { name: "fileIcon", partials: {}, subs: {} } }, subs: {} });
- defaultTemplates["file-summary-wrapper"] = new hogan["Template"]({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<div class=\"d2h-file-list-wrapper\">"); t.b("\n" + i); t.b(" <div class=\"d2h-file-list-header\">"); t.b("\n" + i); t.b(" <span class=\"d2h-file-list-title\">Files changed ("); t.b(t.v(t.f("filesNumber", c, p, 0))); t.b(")</span>"); t.b("\n" + i); t.b(" <a class=\"d2h-file-switch d2h-hide\">hide</a>"); t.b("\n" + i); t.b(" <a class=\"d2h-file-switch d2h-show\">show</a>"); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b(" <ol class=\"d2h-file-list\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.f("files", c, p, 0))); t.b("\n" + i); t.b(" </ol>"); t.b("\n" + i); t.b("</div>"); return t.fl(); }, partials: {}, subs: {} });
- defaultTemplates["generic-block-header"] = new hogan["Template"]({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<tr>"); t.b("\n" + i); t.b(" <td class=\""); t.b(t.v(t.f("lineClass", c, p, 0))); t.b(" "); t.b(t.v(t.d("CSSLineClass.INFO", c, p, 0))); t.b("\"></td>"); t.b("\n" + i); t.b(" <td class=\""); t.b(t.v(t.d("CSSLineClass.INFO", c, p, 0))); t.b("\">"); t.b("\n" + i); t.b(" <div class=\""); t.b(t.v(t.f("contentClass", c, p, 0))); t.b(" "); t.b(t.v(t.d("CSSLineClass.INFO", c, p, 0))); t.b("\">"); t.b(t.t(t.f("blockHeader", c, p, 0))); t.b("</div>"); t.b("\n" + i); t.b(" </td>"); t.b("\n" + i); t.b("</tr>"); return t.fl(); }, partials: {}, subs: {} });
- defaultTemplates["generic-empty-diff"] = new hogan["Template"]({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<tr>"); t.b("\n" + i); t.b(" <td class=\""); t.b(t.v(t.d("CSSLineClass.INFO", c, p, 0))); t.b("\">"); t.b("\n" + i); t.b(" <div class=\""); t.b(t.v(t.f("contentClass", c, p, 0))); t.b(" "); t.b(t.v(t.d("CSSLineClass.INFO", c, p, 0))); t.b("\">"); t.b("\n" + i); t.b(" File without changes"); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b(" </td>"); t.b("\n" + i); t.b("</tr>"); return t.fl(); }, partials: {}, subs: {} });
- defaultTemplates["generic-file-path"] = new hogan["Template"]({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<span class=\"d2h-file-name-wrapper\">"); t.b("\n" + i); t.b(t.rp("<fileIcon0", c, p, " ")); t.b(" <span class=\"d2h-file-name\">"); t.b(t.v(t.f("fileDiffName", c, p, 0))); t.b("</span>"); t.b("\n" + i); t.b(t.rp("<fileTag1", c, p, " ")); t.b("</span>"); return t.fl(); }, partials: { "<fileIcon0": { name: "fileIcon", partials: {}, subs: {} }, "<fileTag1": { name: "fileTag", partials: {}, subs: {} } }, subs: {} });
- defaultTemplates["generic-line"] = new hogan["Template"]({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<tr>"); t.b("\n" + i); t.b(" <td class=\""); t.b(t.v(t.f("lineClass", c, p, 0))); t.b(" "); t.b(t.v(t.f("type", c, p, 0))); t.b("\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.f("lineNumber", c, p, 0))); t.b("\n" + i); t.b(" </td>"); t.b("\n" + i); t.b(" <td class=\""); t.b(t.v(t.f("type", c, p, 0))); t.b("\">"); t.b("\n" + i); t.b(" <div class=\""); t.b(t.v(t.f("contentClass", c, p, 0))); t.b(" "); t.b(t.v(t.f("type", c, p, 0))); t.b("\">"); t.b("\n" + i); if (t.s(t.f("prefix", c, p, 1), c, p, 0, 171, 247, "{{ }}")) {
- t.rs(c, p, function (c, p, t) { t.b(" <span class=\"d2h-code-line-prefix\">"); t.b(t.t(t.f("prefix", c, p, 0))); t.b("</span>"); t.b("\n" + i); });
- c.pop();
- } if (!t.s(t.f("prefix", c, p, 1), c, p, 1, 0, 0, "")) {
- t.b(" <span class=\"d2h-code-line-prefix\"> </span>");
- t.b("\n" + i);
- } ; if (t.s(t.f("content", c, p, 1), c, p, 0, 380, 454, "{{ }}")) {
- t.rs(c, p, function (c, p, t) { t.b(" <span class=\"d2h-code-line-ctn\">"); t.b(t.t(t.f("content", c, p, 0))); t.b("</span>"); t.b("\n" + i); });
- c.pop();
- } if (!t.s(t.f("content", c, p, 1), c, p, 1, 0, 0, "")) {
- t.b(" <span class=\"d2h-code-line-ctn\"><br></span>");
- t.b("\n" + i);
- } ; t.b(" </div>"); t.b("\n" + i); t.b(" </td>"); t.b("\n" + i); t.b("</tr>"); return t.fl(); }, partials: {}, subs: {} });
- defaultTemplates["generic-wrapper"] = new hogan["Template"]({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<div class=\"d2h-wrapper\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.f("content", c, p, 0))); t.b("\n" + i); t.b("</div>"); return t.fl(); }, partials: {}, subs: {} });
- defaultTemplates["icon-file-added"] = new hogan["Template"]({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<svg aria-hidden=\"true\" class=\"d2h-icon d2h-added\" height=\"16\" title=\"added\" version=\"1.1\" viewBox=\"0 0 14 16\""); t.b("\n" + i); t.b(" width=\"14\">"); t.b("\n" + i); t.b(" <path d=\"M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM6 9H3V7h3V4h2v3h3v2H8v3H6V9z\"></path>"); t.b("\n" + i); t.b("</svg>"); return t.fl(); }, partials: {}, subs: {} });
- defaultTemplates["icon-file-changed"] = new hogan["Template"]({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<svg aria-hidden=\"true\" class=\"d2h-icon d2h-changed\" height=\"16\" title=\"modified\" version=\"1.1\""); t.b("\n" + i); t.b(" viewBox=\"0 0 14 16\" width=\"14\">"); t.b("\n" + i); t.b(" <path d=\"M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM4 8c0-1.66 1.34-3 3-3s3 1.34 3 3-1.34 3-3 3-3-1.34-3-3z\"></path>"); t.b("\n" + i); t.b("</svg>"); return t.fl(); }, partials: {}, subs: {} });
- defaultTemplates["icon-file-deleted"] = new hogan["Template"]({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<svg aria-hidden=\"true\" class=\"d2h-icon d2h-deleted\" height=\"16\" title=\"removed\" version=\"1.1\""); t.b("\n" + i); t.b(" viewBox=\"0 0 14 16\" width=\"14\">"); t.b("\n" + i); t.b(" <path d=\"M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM11 9H3V7h8v2z\"></path>"); t.b("\n" + i); t.b("</svg>"); return t.fl(); }, partials: {}, subs: {} });
- defaultTemplates["icon-file-renamed"] = new hogan["Template"]({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<svg aria-hidden=\"true\" class=\"d2h-icon d2h-moved\" height=\"16\" title=\"renamed\" version=\"1.1\""); t.b("\n" + i); t.b(" viewBox=\"0 0 14 16\" width=\"14\">"); t.b("\n" + i); t.b(" <path d=\"M6 9H3V7h3V4l5 4-5 4V9z m8-7v12c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h12c0.55 0 1 0.45 1 1z m-1 0H1v12h12V2z\"></path>"); t.b("\n" + i); t.b("</svg>"); return t.fl(); }, partials: {}, subs: {} });
- defaultTemplates["icon-file"] = new hogan["Template"]({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<svg aria-hidden=\"true\" class=\"d2h-icon\" height=\"16\" version=\"1.1\" viewBox=\"0 0 12 16\" width=\"12\">"); t.b("\n" + i); t.b(" <path d=\"M6 5H2v-1h4v1zM2 8h7v-1H2v1z m0 2h7v-1H2v1z m0 2h7v-1H2v1z m10-7.5v9.5c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h7.5l3.5 3.5z m-1 0.5L8 2H1v12h10V5z\"></path>"); t.b("\n" + i); t.b("</svg>"); return t.fl(); }, partials: {}, subs: {} });
- defaultTemplates["line-by-line-file-diff"] = new hogan["Template"]({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<div id=\""); t.b(t.v(t.f("fileHtmlId", c, p, 0))); t.b("\" class=\"d2h-file-wrapper\" data-lang=\""); t.b(t.v(t.d("file.language", c, p, 0))); t.b("\">"); t.b("\n" + i); t.b(" <div class=\"d2h-file-header\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.f("filePath", c, p, 0))); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b(" <div class=\"d2h-file-diff\">"); t.b("\n" + i); t.b(" <div class=\"d2h-code-wrapper\">"); t.b("\n" + i); t.b(" <table class=\"d2h-diff-table\">"); t.b("\n" + i); t.b(" <tbody class=\"d2h-diff-tbody\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.f("diffs", c, p, 0))); t.b("\n" + i); t.b(" </tbody>"); t.b("\n" + i); t.b(" </table>"); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b("</div>"); return t.fl(); }, partials: {}, subs: {} });
- defaultTemplates["line-by-line-numbers"] = new hogan["Template"]({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<div class=\"line-num1\">"); t.b(t.v(t.f("oldNumber", c, p, 0))); t.b("</div>"); t.b("\n" + i); t.b("<div class=\"line-num2\">"); t.b(t.v(t.f("newNumber", c, p, 0))); t.b("</div>"); return t.fl(); }, partials: {}, subs: {} });
- defaultTemplates["side-by-side-file-diff"] = new hogan["Template"]({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<div id=\""); t.b(t.v(t.f("fileHtmlId", c, p, 0))); t.b("\" class=\"d2h-file-wrapper\" data-lang=\""); t.b(t.v(t.d("file.language", c, p, 0))); t.b("\">"); t.b("\n" + i); t.b(" <div class=\"d2h-file-header\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.f("filePath", c, p, 0))); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b(" <div class=\"d2h-files-diff\">"); t.b("\n" + i); t.b(" <div class=\"d2h-file-side-diff\">"); t.b("\n" + i); t.b(" <div class=\"d2h-code-wrapper\">"); t.b("\n" + i); t.b(" <table class=\"d2h-diff-table\">"); t.b("\n" + i); t.b(" <tbody class=\"d2h-diff-tbody\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.d("diffs.left", c, p, 0))); t.b("\n" + i); t.b(" </tbody>"); t.b("\n" + i); t.b(" </table>"); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b(" <div class=\"d2h-file-side-diff\">"); t.b("\n" + i); t.b(" <div class=\"d2h-code-wrapper\">"); t.b("\n" + i); t.b(" <table class=\"d2h-diff-table\">"); t.b("\n" + i); t.b(" <tbody class=\"d2h-diff-tbody\">"); t.b("\n" + i); t.b(" "); t.b(t.t(t.d("diffs.right", c, p, 0))); t.b("\n" + i); t.b(" </tbody>"); t.b("\n" + i); t.b(" </table>"); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b(" </div>"); t.b("\n" + i); t.b("</div>"); return t.fl(); }, partials: {}, subs: {} });
- defaultTemplates["tag-file-added"] = new hogan["Template"]({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<span class=\"d2h-tag d2h-added d2h-added-tag\">ADDED</span>"); return t.fl(); }, partials: {}, subs: {} });
- defaultTemplates["tag-file-changed"] = new hogan["Template"]({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<span class=\"d2h-tag d2h-changed d2h-changed-tag\">CHANGED</span>"); return t.fl(); }, partials: {}, subs: {} });
- defaultTemplates["tag-file-deleted"] = new hogan["Template"]({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<span class=\"d2h-tag d2h-deleted d2h-deleted-tag\">DELETED</span>"); return t.fl(); }, partials: {}, subs: {} });
- defaultTemplates["tag-file-renamed"] = new hogan["Template"]({ code: function (c, p, i) { var t = this; t.b(i = i || ""); t.b("<span class=\"d2h-tag d2h-moved d2h-moved-tag\">RENAMED</span>"); return t.fl(); }, partials: {}, subs: {} });
- //# sourceMappingURL=diff2html-templates.js.map
- // CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/hoganjs-utils.js
- var hoganjs_utils_assign = (undefined && undefined.__assign) || function () {
- hoganjs_utils_assign = Object.assign || function(t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
- t[p] = s[p];
- }
- return t;
- };
- return hoganjs_utils_assign.apply(this, arguments);
- };
-
-
- var hoganjs_utils_HoganJsUtils = (function () {
- function HoganJsUtils(_a) {
- var _b = _a.compiledTemplates, compiledTemplates = _b === void 0 ? {} : _b, _c = _a.rawTemplates, rawTemplates = _c === void 0 ? {} : _c;
- var compiledRawTemplates = Object.entries(rawTemplates).reduce(function (previousTemplates, _a) {
- var _b;
- var name = _a[0], templateString = _a[1];
- var compiledTemplate = hogan["compile"](templateString, { asString: false });
- return hoganjs_utils_assign(hoganjs_utils_assign({}, previousTemplates), (_b = {}, _b[name] = compiledTemplate, _b));
- }, {});
- this.preCompiledTemplates = hoganjs_utils_assign(hoganjs_utils_assign(hoganjs_utils_assign({}, defaultTemplates), compiledTemplates), compiledRawTemplates);
- }
- HoganJsUtils.compile = function (templateString) {
- return hogan["compile"](templateString, { asString: false });
- };
- HoganJsUtils.prototype.render = function (namespace, view, params, partials, indent) {
- var templateKey = this.templateKey(namespace, view);
- try {
- var template = this.preCompiledTemplates[templateKey];
- return template.render(params, partials, indent);
- }
- catch (e) {
- throw new Error("Could not find template to render '" + templateKey + "'");
- }
- };
- HoganJsUtils.prototype.template = function (namespace, view) {
- return this.preCompiledTemplates[this.templateKey(namespace, view)];
- };
- HoganJsUtils.prototype.templateKey = function (namespace, view) {
- return namespace + "-" + view;
- };
- return HoganJsUtils;
- }());
- /* harmony default export */ var hoganjs_utils = (hoganjs_utils_HoganJsUtils);
- //# sourceMappingURL=hoganjs-utils.js.map
- // CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/diff2html.js
- var diff2html_assign = (undefined && undefined.__assign) || function () {
- diff2html_assign = Object.assign || function(t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
- t[p] = s[p];
- }
- return t;
- };
- return diff2html_assign.apply(this, arguments);
- };
-
-
-
-
-
-
- var defaultDiff2HtmlConfig = diff2html_assign(diff2html_assign(diff2html_assign({}, defaultLineByLineRendererConfig), defaultSideBySideRendererConfig), { outputFormat: OutputFormatType.LINE_BY_LINE, drawFileList: true });
- function diff2html_parse(diffInput, configuration) {
- if (configuration === void 0) { configuration = {}; }
- return parse(diffInput, diff2html_assign(diff2html_assign({}, defaultDiff2HtmlConfig), configuration));
- }
- function html(diffInput, configuration) {
- if (configuration === void 0) { configuration = {}; }
- var config = diff2html_assign(diff2html_assign({}, defaultDiff2HtmlConfig), configuration);
- var diffJson = typeof diffInput === 'string' ? parse(diffInput, config) : diffInput;
- var hoganUtils = new hoganjs_utils(config);
- var fileList = config.drawFileList ? render(diffJson, hoganUtils) : '';
- var diffOutput = config.outputFormat === 'side-by-side'
- ? new side_by_side_renderer(hoganUtils, config).render(diffJson)
- : new line_by_line_renderer(hoganUtils, config).render(diffJson);
- return fileList + diffOutput;
- }
- //# sourceMappingURL=diff2html.js.map
- // EXTERNAL MODULE: external "$"
- var external_$_ = __webpack_require__("xeH2");
-
- // CONCATENATED MODULE: ./src/js/utils.js
- function request (url) {
- return new Promise((resolve, reject) => {
- window.GM_xmlhttpRequest({
- url,
- onload: function ({ response, responseText, }) {
- resolve({ response, responseText })
- }
- })
- })
- }
-
-
-
- // CONCATENATED MODULE: ./src/js/index.js
-
-
-
-
-
- function main () {
- console.log('start bgm wiki rev diff UserScript')
- initUI()
- }
-
- function initUI () {
- external_$_('#pagehistory li').each(function () {
- const el = external_$_(this)
- const rev = parseRevEl(el)
- el.prepend(`<input type="checkbox" class="rev-trim21-cn" name="rev" label="select to compare" value="${rev.id}">`)
- })
- external_$_('#columnInSubjectA span.text').append('<a href="#;" id="compare-trim21-cn" tar class="l"> > 比较选中的版本</a>')
- external_$_('#compare-trim21-cn').click(function () {
- const selectedRevs = getSelectedVersion()
- compare(selectedRevs)
- })
- }
-
- function getSelectedVersion () {
- const selectedVersion = []
- const selectedRev = external_$_('.rev-trim21-cn:checked')
- if (selectedRev.length < 2) {
- window.alert('请选中两个版本进行比较')
- }
- if (selectedRev.length > 2) {
- window.alert('只能比较两个版本')
- }
- selectedRev.each(function () {
- const el = external_$_(this)
- selectedVersion.push(el.val())
- })
- selectedVersion.reverse()
- return selectedVersion
- }
-
- function compare (revs) {
- console.log('compare')
- external_$_('head').append('<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/diff2html/bundles/css/diff2html.min.css" />')
- const rev1 = getRevInfo(revs[0])
- const rev2 = getRevInfo(revs[1])
- const p1 = request(rev1.url)
- const p2 = request(rev2.url)
- Promise.all([p1, p2]).then(values => {
- const contents = []
- for (const page of values) {
- const jq = external_$_(page.responseText)
- contents.push(jq.find('#subject_infobox').val())
- }
- const d = difflib["unifiedDiff"](contents[0].split('\n'), contents[1].split('\n'), {
- fromfile: rev1.comment,
- tofile: rev2.comment,
- fromfiledate: rev1.date,
- tofiledate: rev2.date,
- lineterm: ''
- })
- const rendered = js_render(d.join('\n'), {})
- external_$_('#columnInSubjectA').prepend(rendered)
- })
- }
-
- function getRevs () {
- const revs = []
- external_$_('#pagehistory li').each(function () {
- const el = external_$_(this)
- revs.push(parseRevEl(el))
- })
- return revs
- }
-
- function parseRevEl (el) {
- const date = el.find('a').first().html()
- const revEL = el.find('a.l:contains("恢复")')
- const revCommentEl = el.find('span.comment')
- let comment = ''
- if (revCommentEl.length) {
- comment = revCommentEl.html()
- comment = comment.substring(1, comment.length - 1)
- }
- const revHref = revEL.attr('href')
- const revID = revHref.split('/').pop()
- return {
- id: revID,
- comment,
- date,
- url: revHref,
- }
- }
-
- function getRevInfo (revID) {
- for (const rev of getRevs()) {
- if (rev.id === revID) {
- console.log(revID, rev)
- return rev
- }
- }
- }
-
- function js_render (diff) {
- return html(diff)
- }
-
- main()
-
-
- /***/ }),
-
- /***/ "qVjC":
- /***/ (function(module, exports, __webpack_require__) {
-
- // Generated by CoffeeScript 1.3.1
-
- /*
- Module difflib -- helpers for computing deltas between objects.
-
- Function getCloseMatches(word, possibilities, n=3, cutoff=0.6):
- Use SequenceMatcher to return list of the best "good enough" matches.
-
- Function contextDiff(a, b):
- For two lists of strings, return a delta in context diff format.
-
- Function ndiff(a, b):
- Return a delta: the difference between `a` and `b` (lists of strings).
-
- Function restore(delta, which):
- Return one of the two sequences that generated an ndiff delta.
-
- Function unifiedDiff(a, b):
- For two lists of strings, return a delta in unified diff format.
-
- Class SequenceMatcher:
- A flexible class for comparing pairs of sequences of any type.
-
- Class Differ:
- For producing human-readable deltas from sequences of lines of text.
- */
-
-
- (function() {
- var Differ, Heap, IS_CHARACTER_JUNK, IS_LINE_JUNK, SequenceMatcher, assert, contextDiff, floor, getCloseMatches, max, min, ndiff, restore, unifiedDiff, _any, _arrayCmp, _calculateRatio, _countLeading, _formatRangeContext, _formatRangeUnified, _has,
- __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
-
- floor = Math.floor, max = Math.max, min = Math.min;
-
- Heap = __webpack_require__("F1pL");
-
- assert = __webpack_require__("9lTW");
-
- _calculateRatio = function(matches, length) {
- if (length) {
- return 2.0 * matches / length;
- } else {
- return 1.0;
- }
- };
-
- _arrayCmp = function(a, b) {
- var i, la, lb, _i, _ref, _ref1;
- _ref = [a.length, b.length], la = _ref[0], lb = _ref[1];
- for (i = _i = 0, _ref1 = min(la, lb); 0 <= _ref1 ? _i < _ref1 : _i > _ref1; i = 0 <= _ref1 ? ++_i : --_i) {
- if (a[i] < b[i]) {
- return -1;
- }
- if (a[i] > b[i]) {
- return 1;
- }
- }
- return la - lb;
- };
-
- _has = function(obj, key) {
- return Object.prototype.hasOwnProperty.call(obj, key);
- };
-
- _any = function(items) {
- var item, _i, _len;
- for (_i = 0, _len = items.length; _i < _len; _i++) {
- item = items[_i];
- if (item) {
- return true;
- }
- }
- return false;
- };
-
- SequenceMatcher = (function() {
-
- SequenceMatcher.name = 'SequenceMatcher';
-
- /*
- SequenceMatcher is a flexible class for comparing pairs of sequences of
- any type, so long as the sequence elements are hashable. The basic
- algorithm predates, and is a little fancier than, an algorithm
- published in the late 1980's by Ratcliff and Obershelp under the
- hyperbolic name "gestalt pattern matching". The basic idea is to find
- the longest contiguous matching subsequence that contains no "junk"
- elements (R-O doesn't address junk). The same idea is then applied
- recursively to the pieces of the sequences to the left and to the right
- of the matching subsequence. This does not yield minimal edit
- sequences, but does tend to yield matches that "look right" to people.
-
- SequenceMatcher tries to compute a "human-friendly diff" between two
- sequences. Unlike e.g. UNIX(tm) diff, the fundamental notion is the
- longest *contiguous* & junk-free matching subsequence. That's what
- catches peoples' eyes. The Windows(tm) windiff has another interesting
- notion, pairing up elements that appear uniquely in each sequence.
- That, and the method here, appear to yield more intuitive difference
- reports than does diff. This method appears to be the least vulnerable
- to synching up on blocks of "junk lines", though (like blank lines in
- ordinary text files, or maybe "<P>" lines in HTML files). That may be
- because this is the only method of the 3 that has a *concept* of
- "junk" <wink>.
-
- Example, comparing two strings, and considering blanks to be "junk":
-
- >>> isjunk = (c) -> c is ' '
- >>> s = new SequenceMatcher(isjunk,
- 'private Thread currentThread;',
- 'private volatile Thread currentThread;')
-
- .ratio() returns a float in [0, 1], measuring the "similarity" of the
- sequences. As a rule of thumb, a .ratio() value over 0.6 means the
- sequences are close matches:
-
- >>> s.ratio().toPrecision(3)
- '0.866'
-
- If you're only interested in where the sequences match,
- .getMatchingBlocks() is handy:
-
- >>> for [a, b, size] in s.getMatchingBlocks()
- ... console.log("a[#{a}] and b[#{b}] match for #{size} elements");
- a[0] and b[0] match for 8 elements
- a[8] and b[17] match for 21 elements
- a[29] and b[38] match for 0 elements
-
- Note that the last tuple returned by .get_matching_blocks() is always a
- dummy, (len(a), len(b), 0), and this is the only case in which the last
- tuple element (number of elements matched) is 0.
-
- If you want to know how to change the first sequence into the second,
- use .get_opcodes():
-
- >>> for [op, a1, a2, b1, b2] in s.getOpcodes()
- ... console.log "#{op} a[#{a1}:#{a2}] b[#{b1}:#{b2}]"
- equal a[0:8] b[0:8]
- insert a[8:8] b[8:17]
- equal a[8:29] b[17:38]
-
- See the Differ class for a fancy human-friendly file differencer, which
- uses SequenceMatcher both to compare sequences of lines, and to compare
- sequences of characters within similar (near-matching) lines.
-
- See also function getCloseMatches() in this module, which shows how
- simple code building on SequenceMatcher can be used to do useful work.
-
- Timing: Basic R-O is cubic time worst case and quadratic time expected
- case. SequenceMatcher is quadratic time for the worst case and has
- expected-case behavior dependent in a complicated way on how many
- elements the sequences have in common; best case time is linear.
-
- Methods:
-
- constructor(isjunk=null, a='', b='')
- Construct a SequenceMatcher.
-
- setSeqs(a, b)
- Set the two sequences to be compared.
-
- setSeq1(a)
- Set the first sequence to be compared.
-
- setSeq2(b)
- Set the second sequence to be compared.
-
- findLongestMatch(alo, ahi, blo, bhi)
- Find longest matching block in a[alo:ahi] and b[blo:bhi].
-
- getMatchingBlocks()
- Return list of triples describing matching subsequences.
-
- getOpcodes()
- Return list of 5-tuples describing how to turn a into b.
-
- ratio()
- Return a measure of the sequences' similarity (float in [0,1]).
-
- quickRatio()
- Return an upper bound on .ratio() relatively quickly.
-
- realQuickRatio()
- Return an upper bound on ratio() very quickly.
- */
-
-
- function SequenceMatcher(isjunk, a, b, autojunk) {
- this.isjunk = isjunk;
- if (a == null) {
- a = '';
- }
- if (b == null) {
- b = '';
- }
- this.autojunk = autojunk != null ? autojunk : true;
- /*
- Construct a SequenceMatcher.
-
- Optional arg isjunk is null (the default), or a one-argument
- function that takes a sequence element and returns true iff the
- element is junk. Null is equivalent to passing "(x) -> 0", i.e.
- no elements are considered to be junk. For example, pass
- (x) -> x in ' \t'
- if you're comparing lines as sequences of characters, and don't
- want to synch up on blanks or hard tabs.
-
- Optional arg a is the first of two sequences to be compared. By
- default, an empty string. The elements of a must be hashable. See
- also .setSeqs() and .setSeq1().
-
- Optional arg b is the second of two sequences to be compared. By
- default, an empty string. The elements of b must be hashable. See
- also .setSeqs() and .setSeq2().
-
- Optional arg autojunk should be set to false to disable the
- "automatic junk heuristic" that treats popular elements as junk
- (see module documentation for more information).
- */
-
- this.a = this.b = null;
- this.setSeqs(a, b);
- }
-
- SequenceMatcher.prototype.setSeqs = function(a, b) {
- /*
- Set the two sequences to be compared.
-
- >>> s = new SequenceMatcher()
- >>> s.setSeqs('abcd', 'bcde')
- >>> s.ratio()
- 0.75
- */
- this.setSeq1(a);
- return this.setSeq2(b);
- };
-
- SequenceMatcher.prototype.setSeq1 = function(a) {
- /*
- Set the first sequence to be compared.
-
- The second sequence to be compared is not changed.
-
- >>> s = new SequenceMatcher(null, 'abcd', 'bcde')
- >>> s.ratio()
- 0.75
- >>> s.setSeq1('bcde')
- >>> s.ratio()
- 1.0
-
- SequenceMatcher computes and caches detailed information about the
- second sequence, so if you want to compare one sequence S against
- many sequences, use .setSeq2(S) once and call .setSeq1(x)
- repeatedly for each of the other sequences.
-
- See also setSeqs() and setSeq2().
- */
- if (a === this.a) {
- return;
- }
- this.a = a;
- return this.matchingBlocks = this.opcodes = null;
- };
-
- SequenceMatcher.prototype.setSeq2 = function(b) {
- /*
- Set the second sequence to be compared.
-
- The first sequence to be compared is not changed.
-
- >>> s = new SequenceMatcher(null, 'abcd', 'bcde')
- >>> s.ratio()
- 0.75
- >>> s.setSeq2('abcd')
- >>> s.ratio()
- 1.0
-
- SequenceMatcher computes and caches detailed information about the
- second sequence, so if you want to compare one sequence S against
- many sequences, use .setSeq2(S) once and call .setSeq1(x)
- repeatedly for each of the other sequences.
-
- See also setSeqs() and setSeq1().
- */
- if (b === this.b) {
- return;
- }
- this.b = b;
- this.matchingBlocks = this.opcodes = null;
- this.fullbcount = null;
- return this._chainB();
- };
-
- SequenceMatcher.prototype._chainB = function() {
- var b, b2j, elt, i, idxs, indices, isjunk, junk, n, ntest, popular, _i, _j, _len, _len1, _ref;
- b = this.b;
- this.b2j = b2j = {};
- for (i = _i = 0, _len = b.length; _i < _len; i = ++_i) {
- elt = b[i];
- indices = _has(b2j, elt) ? b2j[elt] : b2j[elt] = [];
- indices.push(i);
- }
- junk = {};
- isjunk = this.isjunk;
- if (isjunk) {
- _ref = Object.keys(b2j);
- for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
- elt = _ref[_j];
- if (isjunk(elt)) {
- junk[elt] = true;
- delete b2j[elt];
- }
- }
- }
- popular = {};
- n = b.length;
- if (this.autojunk && n >= 200) {
- ntest = floor(n / 100) + 1;
- for (elt in b2j) {
- idxs = b2j[elt];
- if (idxs.length > ntest) {
- popular[elt] = true;
- delete b2j[elt];
- }
- }
- }
- this.isbjunk = function(b) {
- return _has(junk, b);
- };
- return this.isbpopular = function(b) {
- return _has(popular, b);
- };
- };
-
- SequenceMatcher.prototype.findLongestMatch = function(alo, ahi, blo, bhi) {
- /*
- Find longest matching block in a[alo...ahi] and b[blo...bhi].
-
- If isjunk is not defined:
-
- Return [i,j,k] such that a[i...i+k] is equal to b[j...j+k], where
- alo <= i <= i+k <= ahi
- blo <= j <= j+k <= bhi
- and for all [i',j',k'] meeting those conditions,
- k >= k'
- i <= i'
- and if i == i', j <= j'
-
- In other words, of all maximal matching blocks, return one that
- starts earliest in a, and of all those maximal matching blocks that
- start earliest in a, return the one that starts earliest in b.
-
- >>> isjunk = (x) -> x is ' '
- >>> s = new SequenceMatcher(isjunk, ' abcd', 'abcd abcd')
- >>> s.findLongestMatch(0, 5, 0, 9)
- [1, 0, 4]
-
- >>> s = new SequenceMatcher(null, 'ab', 'c')
- >>> s.findLongestMatch(0, 2, 0, 1)
- [0, 0, 0]
- */
-
- var a, b, b2j, besti, bestj, bestsize, i, isbjunk, j, j2len, k, newj2len, _i, _j, _len, _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
- _ref = [this.a, this.b, this.b2j, this.isbjunk], a = _ref[0], b = _ref[1], b2j = _ref[2], isbjunk = _ref[3];
- _ref1 = [alo, blo, 0], besti = _ref1[0], bestj = _ref1[1], bestsize = _ref1[2];
- j2len = {};
- for (i = _i = alo; alo <= ahi ? _i < ahi : _i > ahi; i = alo <= ahi ? ++_i : --_i) {
- newj2len = {};
- _ref2 = (_has(b2j, a[i]) ? b2j[a[i]] : []);
- for (_j = 0, _len = _ref2.length; _j < _len; _j++) {
- j = _ref2[_j];
- if (j < blo) {
- continue;
- }
- if (j >= bhi) {
- break;
- }
- k = newj2len[j] = (j2len[j - 1] || 0) + 1;
- if (k > bestsize) {
- _ref3 = [i - k + 1, j - k + 1, k], besti = _ref3[0], bestj = _ref3[1], bestsize = _ref3[2];
- }
- }
- j2len = newj2len;
- }
- while (besti > alo && bestj > blo && !isbjunk(b[bestj - 1]) && a[besti - 1] === b[bestj - 1]) {
- _ref4 = [besti - 1, bestj - 1, bestsize + 1], besti = _ref4[0], bestj = _ref4[1], bestsize = _ref4[2];
- }
- while (besti + bestsize < ahi && bestj + bestsize < bhi && !isbjunk(b[bestj + bestsize]) && a[besti + bestsize] === b[bestj + bestsize]) {
- bestsize++;
- }
- while (besti > alo && bestj > blo && isbjunk(b[bestj - 1]) && a[besti - 1] === b[bestj - 1]) {
- _ref5 = [besti - 1, bestj - 1, bestsize + 1], besti = _ref5[0], bestj = _ref5[1], bestsize = _ref5[2];
- }
- while (besti + bestsize < ahi && bestj + bestsize < bhi && isbjunk(b[bestj + bestsize]) && a[besti + bestsize] === b[bestj + bestsize]) {
- bestsize++;
- }
- return [besti, bestj, bestsize];
- };
-
- SequenceMatcher.prototype.getMatchingBlocks = function() {
- /*
- Return list of triples describing matching subsequences.
-
- Each triple is of the form [i, j, n], and means that
- a[i...i+n] == b[j...j+n]. The triples are monotonically increasing in
- i and in j. it's also guaranteed that if
- [i, j, n] and [i', j', n'] are adjacent triples in the list, and
- the second is not the last triple in the list, then i+n != i' or
- j+n != j'. IOW, adjacent triples never describe adjacent equal
- blocks.
-
- The last triple is a dummy, [a.length, b.length, 0], and is the only
- triple with n==0.
-
- >>> s = new SequenceMatcher(null, 'abxcd', 'abcd')
- >>> s.getMatchingBlocks()
- [[0, 0, 2], [3, 2, 2], [5, 4, 0]]
- */
-
- var ahi, alo, bhi, blo, i, i1, i2, j, j1, j2, k, k1, k2, la, lb, matchingBlocks, nonAdjacent, queue, x, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4;
- if (this.matchingBlocks) {
- return this.matchingBlocks;
- }
- _ref = [this.a.length, this.b.length], la = _ref[0], lb = _ref[1];
- queue = [[0, la, 0, lb]];
- matchingBlocks = [];
- while (queue.length) {
- _ref1 = queue.pop(), alo = _ref1[0], ahi = _ref1[1], blo = _ref1[2], bhi = _ref1[3];
- _ref2 = x = this.findLongestMatch(alo, ahi, blo, bhi), i = _ref2[0], j = _ref2[1], k = _ref2[2];
- if (k) {
- matchingBlocks.push(x);
- if (alo < i && blo < j) {
- queue.push([alo, i, blo, j]);
- }
- if (i + k < ahi && j + k < bhi) {
- queue.push([i + k, ahi, j + k, bhi]);
- }
- }
- }
- matchingBlocks.sort(_arrayCmp);
- i1 = j1 = k1 = 0;
- nonAdjacent = [];
- for (_i = 0, _len = matchingBlocks.length; _i < _len; _i++) {
- _ref3 = matchingBlocks[_i], i2 = _ref3[0], j2 = _ref3[1], k2 = _ref3[2];
- if (i1 + k1 === i2 && j1 + k1 === j2) {
- k1 += k2;
- } else {
- if (k1) {
- nonAdjacent.push([i1, j1, k1]);
- }
- _ref4 = [i2, j2, k2], i1 = _ref4[0], j1 = _ref4[1], k1 = _ref4[2];
- }
- }
- if (k1) {
- nonAdjacent.push([i1, j1, k1]);
- }
- nonAdjacent.push([la, lb, 0]);
- return this.matchingBlocks = nonAdjacent;
- };
-
- SequenceMatcher.prototype.getOpcodes = function() {
- /*
- Return list of 5-tuples describing how to turn a into b.
-
- Each tuple is of the form [tag, i1, i2, j1, j2]. The first tuple
- has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the
- tuple preceding it, and likewise for j1 == the previous j2.
-
- The tags are strings, with these meanings:
-
- 'replace': a[i1...i2] should be replaced by b[j1...j2]
- 'delete': a[i1...i2] should be deleted.
- Note that j1==j2 in this case.
- 'insert': b[j1...j2] should be inserted at a[i1...i1].
- Note that i1==i2 in this case.
- 'equal': a[i1...i2] == b[j1...j2]
-
- >>> s = new SequenceMatcher(null, 'qabxcd', 'abycdf')
- >>> s.getOpcodes()
- [ [ 'delete' , 0 , 1 , 0 , 0 ] ,
- [ 'equal' , 1 , 3 , 0 , 2 ] ,
- [ 'replace' , 3 , 4 , 2 , 3 ] ,
- [ 'equal' , 4 , 6 , 3 , 5 ] ,
- [ 'insert' , 6 , 6 , 5 , 6 ] ]
- */
-
- var ai, answer, bj, i, j, size, tag, _i, _len, _ref, _ref1, _ref2;
- if (this.opcodes) {
- return this.opcodes;
- }
- i = j = 0;
- this.opcodes = answer = [];
- _ref = this.getMatchingBlocks();
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- _ref1 = _ref[_i], ai = _ref1[0], bj = _ref1[1], size = _ref1[2];
- tag = '';
- if (i < ai && j < bj) {
- tag = 'replace';
- } else if (i < ai) {
- tag = 'delete';
- } else if (j < bj) {
- tag = 'insert';
- }
- if (tag) {
- answer.push([tag, i, ai, j, bj]);
- }
- _ref2 = [ai + size, bj + size], i = _ref2[0], j = _ref2[1];
- if (size) {
- answer.push(['equal', ai, i, bj, j]);
- }
- }
- return answer;
- };
-
- SequenceMatcher.prototype.getGroupedOpcodes = function(n) {
- var codes, group, groups, i1, i2, j1, j2, nn, tag, _i, _len, _ref, _ref1, _ref2, _ref3;
- if (n == null) {
- n = 3;
- }
- /*
- Isolate change clusters by eliminating ranges with no changes.
-
- Return a list groups with upto n lines of context.
- Each group is in the same format as returned by get_opcodes().
-
- >>> a = [1...40].map(String)
- >>> b = a.slice()
- >>> b[8...8] = 'i'
- >>> b[20] += 'x'
- >>> b[23...28] = []
- >>> b[30] += 'y'
- >>> s = new SequenceMatcher(null, a, b)
- >>> s.getGroupedOpcodes()
- [ [ [ 'equal' , 5 , 8 , 5 , 8 ],
- [ 'insert' , 8 , 8 , 8 , 9 ],
- [ 'equal' , 8 , 11 , 9 , 12 ] ],
- [ [ 'equal' , 16 , 19 , 17 , 20 ],
- [ 'replace' , 19 , 20 , 20 , 21 ],
- [ 'equal' , 20 , 22 , 21 , 23 ],
- [ 'delete' , 22 , 27 , 23 , 23 ],
- [ 'equal' , 27 , 30 , 23 , 26 ] ],
- [ [ 'equal' , 31 , 34 , 27 , 30 ],
- [ 'replace' , 34 , 35 , 30 , 31 ],
- [ 'equal' , 35 , 38 , 31 , 34 ] ] ]
- */
-
- codes = this.getOpcodes();
- if (!codes.length) {
- codes = [['equal', 0, 1, 0, 1]];
- }
- if (codes[0][0] === 'equal') {
- _ref = codes[0], tag = _ref[0], i1 = _ref[1], i2 = _ref[2], j1 = _ref[3], j2 = _ref[4];
- codes[0] = [tag, max(i1, i2 - n), i2, max(j1, j2 - n), j2];
- }
- if (codes[codes.length - 1][0] === 'equal') {
- _ref1 = codes[codes.length - 1], tag = _ref1[0], i1 = _ref1[1], i2 = _ref1[2], j1 = _ref1[3], j2 = _ref1[4];
- codes[codes.length - 1] = [tag, i1, min(i2, i1 + n), j1, min(j2, j1 + n)];
- }
- nn = n + n;
- groups = [];
- group = [];
- for (_i = 0, _len = codes.length; _i < _len; _i++) {
- _ref2 = codes[_i], tag = _ref2[0], i1 = _ref2[1], i2 = _ref2[2], j1 = _ref2[3], j2 = _ref2[4];
- if (tag === 'equal' && i2 - i1 > nn) {
- group.push([tag, i1, min(i2, i1 + n), j1, min(j2, j1 + n)]);
- groups.push(group);
- group = [];
- _ref3 = [max(i1, i2 - n), max(j1, j2 - n)], i1 = _ref3[0], j1 = _ref3[1];
- }
- group.push([tag, i1, i2, j1, j2]);
- }
- if (group.length && !(group.length === 1 && group[0][0] === 'equal')) {
- groups.push(group);
- }
- return groups;
- };
-
- SequenceMatcher.prototype.ratio = function() {
- /*
- Return a measure of the sequences' similarity (float in [0,1]).
-
- Where T is the total number of elements in both sequences, and
- M is the number of matches, this is 2.0*M / T.
- Note that this is 1 if the sequences are identical, and 0 if
- they have nothing in common.
-
- .ratio() is expensive to compute if you haven't already computed
- .getMatchingBlocks() or .getOpcodes(), in which case you may
- want to try .quickRatio() or .realQuickRatio() first to get an
- upper bound.
-
- >>> s = new SequenceMatcher(null, 'abcd', 'bcde')
- >>> s.ratio()
- 0.75
- >>> s.quickRatio()
- 0.75
- >>> s.realQuickRatio()
- 1.0
- */
-
- var match, matches, _i, _len, _ref;
- matches = 0;
- _ref = this.getMatchingBlocks();
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- match = _ref[_i];
- matches += match[2];
- }
- return _calculateRatio(matches, this.a.length + this.b.length);
- };
-
- SequenceMatcher.prototype.quickRatio = function() {
- /*
- Return an upper bound on ratio() relatively quickly.
-
- This isn't defined beyond that it is an upper bound on .ratio(), and
- is faster to compute.
- */
-
- var avail, elt, fullbcount, matches, numb, _i, _j, _len, _len1, _ref, _ref1;
- if (!this.fullbcount) {
- this.fullbcount = fullbcount = {};
- _ref = this.b;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- elt = _ref[_i];
- fullbcount[elt] = (fullbcount[elt] || 0) + 1;
- }
- }
- fullbcount = this.fullbcount;
- avail = {};
- matches = 0;
- _ref1 = this.a;
- for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
- elt = _ref1[_j];
- if (_has(avail, elt)) {
- numb = avail[elt];
- } else {
- numb = fullbcount[elt] || 0;
- }
- avail[elt] = numb - 1;
- if (numb > 0) {
- matches++;
- }
- }
- return _calculateRatio(matches, this.a.length + this.b.length);
- };
-
- SequenceMatcher.prototype.realQuickRatio = function() {
- /*
- Return an upper bound on ratio() very quickly.
-
- This isn't defined beyond that it is an upper bound on .ratio(), and
- is faster to compute than either .ratio() or .quickRatio().
- */
-
- var la, lb, _ref;
- _ref = [this.a.length, this.b.length], la = _ref[0], lb = _ref[1];
- return _calculateRatio(min(la, lb), la + lb);
- };
-
- return SequenceMatcher;
-
- })();
-
- getCloseMatches = function(word, possibilities, n, cutoff) {
- var result, s, score, x, _i, _j, _len, _len1, _ref, _results;
- if (n == null) {
- n = 3;
- }
- if (cutoff == null) {
- cutoff = 0.6;
- }
- /*
- Use SequenceMatcher to return list of the best "good enough" matches.
-
- word is a sequence for which close matches are desired (typically a
- string).
-
- possibilities is a list of sequences against which to match word
- (typically a list of strings).
-
- Optional arg n (default 3) is the maximum number of close matches to
- return. n must be > 0.
-
- Optional arg cutoff (default 0.6) is a float in [0, 1]. Possibilities
- that don't score at least that similar to word are ignored.
-
- The best (no more than n) matches among the possibilities are returned
- in a list, sorted by similarity score, most similar first.
-
- >>> getCloseMatches('appel', ['ape', 'apple', 'peach', 'puppy'])
- ['apple', 'ape']
- >>> KEYWORDS = require('coffee-script').RESERVED
- >>> getCloseMatches('wheel', KEYWORDS)
- ['when', 'while']
- >>> getCloseMatches('accost', KEYWORDS)
- ['const']
- */
-
- if (!(n > 0)) {
- throw new Error("n must be > 0: (" + n + ")");
- }
- if (!((0.0 <= cutoff && cutoff <= 1.0))) {
- throw new Error("cutoff must be in [0.0, 1.0]: (" + cutoff + ")");
- }
- result = [];
- s = new SequenceMatcher();
- s.setSeq2(word);
- for (_i = 0, _len = possibilities.length; _i < _len; _i++) {
- x = possibilities[_i];
- s.setSeq1(x);
- if (s.realQuickRatio() >= cutoff && s.quickRatio() >= cutoff && s.ratio() >= cutoff) {
- result.push([s.ratio(), x]);
- }
- }
- result = Heap.nlargest(result, n, _arrayCmp);
- _results = [];
- for (_j = 0, _len1 = result.length; _j < _len1; _j++) {
- _ref = result[_j], score = _ref[0], x = _ref[1];
- _results.push(x);
- }
- return _results;
- };
-
- _countLeading = function(line, ch) {
- /*
- Return number of `ch` characters at the start of `line`.
-
- >>> _countLeading(' abc', ' ')
- 3
- */
-
- var i, n, _ref;
- _ref = [0, line.length], i = _ref[0], n = _ref[1];
- while (i < n && line[i] === ch) {
- i++;
- }
- return i;
- };
-
- Differ = (function() {
-
- Differ.name = 'Differ';
-
- /*
- Differ is a class for comparing sequences of lines of text, and
- producing human-readable differences or deltas. Differ uses
- SequenceMatcher both to compare sequences of lines, and to compare
- sequences of characters within similar (near-matching) lines.
-
- Each line of a Differ delta begins with a two-letter code:
-
- '- ' line unique to sequence 1
- '+ ' line unique to sequence 2
- ' ' line common to both sequences
- '? ' line not present in either input sequence
-
- Lines beginning with '? ' attempt to guide the eye to intraline
- differences, and were not present in either input sequence. These lines
- can be confusing if the sequences contain tab characters.
-
- Note that Differ makes no claim to produce a *minimal* diff. To the
- contrary, minimal diffs are often counter-intuitive, because they synch
- up anywhere possible, sometimes accidental matches 100 pages apart.
- Restricting synch points to contiguous matches preserves some notion of
- locality, at the occasional cost of producing a longer diff.
-
- Example: Comparing two texts.
-
- >>> text1 = ['1. Beautiful is better than ugly.\n',
- ... '2. Explicit is better than implicit.\n',
- ... '3. Simple is better than complex.\n',
- ... '4. Complex is better than complicated.\n']
- >>> text1.length
- 4
- >>> text2 = ['1. Beautiful is better than ugly.\n',
- ... '3. Simple is better than complex.\n',
- ... '4. Complicated is better than complex.\n',
- ... '5. Flat is better than nested.\n']
-
- Next we instantiate a Differ object:
-
- >>> d = new Differ()
-
- Note that when instantiating a Differ object we may pass functions to
- filter out line and character 'junk'.
-
- Finally, we compare the two:
-
- >>> result = d.compare(text1, text2)
- [ ' 1. Beautiful is better than ugly.\n',
- '- 2. Explicit is better than implicit.\n',
- '- 3. Simple is better than complex.\n',
- '+ 3. Simple is better than complex.\n',
- '? ++\n',
- '- 4. Complex is better than complicated.\n',
- '? ^ ---- ^\n',
- '+ 4. Complicated is better than complex.\n',
- '? ++++ ^ ^\n',
- '+ 5. Flat is better than nested.\n' ]
-
- Methods:
-
- constructor(linejunk=null, charjunk=null)
- Construct a text differencer, with optional filters.
- compare(a, b)
- Compare two sequences of lines; generate the resulting delta.
- */
-
-
- function Differ(linejunk, charjunk) {
- this.linejunk = linejunk;
- this.charjunk = charjunk;
- /*
- Construct a text differencer, with optional filters.
-
- The two optional keyword parameters are for filter functions:
-
- - `linejunk`: A function that should accept a single string argument,
- and return true iff the string is junk. The module-level function
- `IS_LINE_JUNK` may be used to filter out lines without visible
- characters, except for at most one splat ('#'). It is recommended
- to leave linejunk null.
-
- - `charjunk`: A function that should accept a string of length 1. The
- module-level function `IS_CHARACTER_JUNK` may be used to filter out
- whitespace characters (a blank or tab; **note**: bad idea to include
- newline in this!). Use of IS_CHARACTER_JUNK is recommended.
- */
-
- }
-
- Differ.prototype.compare = function(a, b) {
- /*
- Compare two sequences of lines; generate the resulting delta.
-
- Each sequence must contain individual single-line strings ending with
- newlines. Such sequences can be obtained from the `readlines()` method
- of file-like objects. The delta generated also consists of newline-
- terminated strings, ready to be printed as-is via the writeline()
- method of a file-like object.
-
- Example:
-
- >>> d = new Differ
- >>> d.compare(['one\n', 'two\n', 'three\n'],
- ... ['ore\n', 'tree\n', 'emu\n'])
- [ '- one\n',
- '? ^\n',
- '+ ore\n',
- '? ^\n',
- '- two\n',
- '- three\n',
- '? -\n',
- '+ tree\n',
- '+ emu\n' ]
- */
-
- var ahi, alo, bhi, blo, cruncher, g, line, lines, tag, _i, _j, _len, _len1, _ref, _ref1;
- cruncher = new SequenceMatcher(this.linejunk, a, b);
- lines = [];
- _ref = cruncher.getOpcodes();
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- _ref1 = _ref[_i], tag = _ref1[0], alo = _ref1[1], ahi = _ref1[2], blo = _ref1[3], bhi = _ref1[4];
- switch (tag) {
- case 'replace':
- g = this._fancyReplace(a, alo, ahi, b, blo, bhi);
- break;
- case 'delete':
- g = this._dump('-', a, alo, ahi);
- break;
- case 'insert':
- g = this._dump('+', b, blo, bhi);
- break;
- case 'equal':
- g = this._dump(' ', a, alo, ahi);
- break;
- default:
- throw new Error("unknow tag (" + tag + ")");
- }
- for (_j = 0, _len1 = g.length; _j < _len1; _j++) {
- line = g[_j];
- lines.push(line);
- }
- }
- return lines;
- };
-
- Differ.prototype._dump = function(tag, x, lo, hi) {
- /*
- Generate comparison results for a same-tagged range.
- */
-
- var i, _i, _results;
- _results = [];
- for (i = _i = lo; lo <= hi ? _i < hi : _i > hi; i = lo <= hi ? ++_i : --_i) {
- _results.push("" + tag + " " + x[i]);
- }
- return _results;
- };
-
- Differ.prototype._plainReplace = function(a, alo, ahi, b, blo, bhi) {
- var first, g, line, lines, second, _i, _j, _len, _len1, _ref;
- assert(alo < ahi && blo < bhi);
- if (bhi - blo < ahi - alo) {
- first = this._dump('+', b, blo, bhi);
- second = this._dump('-', a, alo, ahi);
- } else {
- first = this._dump('-', a, alo, ahi);
- second = this._dump('+', b, blo, bhi);
- }
- lines = [];
- _ref = [first, second];
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- g = _ref[_i];
- for (_j = 0, _len1 = g.length; _j < _len1; _j++) {
- line = g[_j];
- lines.push(line);
- }
- }
- return lines;
- };
-
- Differ.prototype._fancyReplace = function(a, alo, ahi, b, blo, bhi) {
- /*
- When replacing one block of lines with another, search the blocks
- for *similar* lines; the best-matching pair (if any) is used as a
- synch point, and intraline difference marking is done on the
- similar pair. Lots of work, but often worth it.
-
- Example:
- >>> d = new Differ
- >>> d._fancyReplace(['abcDefghiJkl\n'], 0, 1,
- ... ['abcdefGhijkl\n'], 0, 1)
- [ '- abcDefghiJkl\n',
- '? ^ ^ ^\n',
- '+ abcdefGhijkl\n',
- '? ^ ^ ^\n' ]
- */
-
- var aelt, ai, ai1, ai2, atags, belt, bestRatio, besti, bestj, bj, bj1, bj2, btags, cruncher, cutoff, eqi, eqj, i, j, la, lb, line, lines, tag, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _n, _o, _ref, _ref1, _ref10, _ref11, _ref12, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
- _ref = [0.74, 0.75], bestRatio = _ref[0], cutoff = _ref[1];
- cruncher = new SequenceMatcher(this.charjunk);
- _ref1 = [null, null], eqi = _ref1[0], eqj = _ref1[1];
- lines = [];
- for (j = _i = blo; blo <= bhi ? _i < bhi : _i > bhi; j = blo <= bhi ? ++_i : --_i) {
- bj = b[j];
- cruncher.setSeq2(bj);
- for (i = _j = alo; alo <= ahi ? _j < ahi : _j > ahi; i = alo <= ahi ? ++_j : --_j) {
- ai = a[i];
- if (ai === bj) {
- if (eqi === null) {
- _ref2 = [i, j], eqi = _ref2[0], eqj = _ref2[1];
- }
- continue;
- }
- cruncher.setSeq1(ai);
- if (cruncher.realQuickRatio() > bestRatio && cruncher.quickRatio() > bestRatio && cruncher.ratio() > bestRatio) {
- _ref3 = [cruncher.ratio(), i, j], bestRatio = _ref3[0], besti = _ref3[1], bestj = _ref3[2];
- }
- }
- }
- if (bestRatio < cutoff) {
- if (eqi === null) {
- _ref4 = this._plainReplace(a, alo, ahi, b, blo, bhi);
- for (_k = 0, _len = _ref4.length; _k < _len; _k++) {
- line = _ref4[_k];
- lines.push(line);
- }
- return lines;
- }
- _ref5 = [eqi, eqj, 1.0], besti = _ref5[0], bestj = _ref5[1], bestRatio = _ref5[2];
- } else {
- eqi = null;
- }
- _ref6 = this._fancyHelper(a, alo, besti, b, blo, bestj);
- for (_l = 0, _len1 = _ref6.length; _l < _len1; _l++) {
- line = _ref6[_l];
- lines.push(line);
- }
- _ref7 = [a[besti], b[bestj]], aelt = _ref7[0], belt = _ref7[1];
- if (eqi === null) {
- atags = btags = '';
- cruncher.setSeqs(aelt, belt);
- _ref8 = cruncher.getOpcodes();
- for (_m = 0, _len2 = _ref8.length; _m < _len2; _m++) {
- _ref9 = _ref8[_m], tag = _ref9[0], ai1 = _ref9[1], ai2 = _ref9[2], bj1 = _ref9[3], bj2 = _ref9[4];
- _ref10 = [ai2 - ai1, bj2 - bj1], la = _ref10[0], lb = _ref10[1];
- switch (tag) {
- case 'replace':
- atags += Array(la + 1).join('^');
- btags += Array(lb + 1).join('^');
- break;
- case 'delete':
- atags += Array(la + 1).join('-');
- break;
- case 'insert':
- btags += Array(lb + 1).join('+');
- break;
- case 'equal':
- atags += Array(la + 1).join(' ');
- btags += Array(lb + 1).join(' ');
- break;
- default:
- throw new Error("unknow tag (" + tag + ")");
- }
- }
- _ref11 = this._qformat(aelt, belt, atags, btags);
- for (_n = 0, _len3 = _ref11.length; _n < _len3; _n++) {
- line = _ref11[_n];
- lines.push(line);
- }
- } else {
- lines.push(' ' + aelt);
- }
- _ref12 = this._fancyHelper(a, besti + 1, ahi, b, bestj + 1, bhi);
- for (_o = 0, _len4 = _ref12.length; _o < _len4; _o++) {
- line = _ref12[_o];
- lines.push(line);
- }
- return lines;
- };
-
- Differ.prototype._fancyHelper = function(a, alo, ahi, b, blo, bhi) {
- var g;
- g = [];
- if (alo < ahi) {
- if (blo < bhi) {
- g = this._fancyReplace(a, alo, ahi, b, blo, bhi);
- } else {
- g = this._dump('-', a, alo, ahi);
- }
- } else if (blo < bhi) {
- g = this._dump('+', b, blo, bhi);
- }
- return g;
- };
-
- Differ.prototype._qformat = function(aline, bline, atags, btags) {
- /*
- Format "?" output and deal with leading tabs.
-
- Example:
-
- >>> d = new Differ
- >>> d._qformat('\tabcDefghiJkl\n', '\tabcdefGhijkl\n',
- [ '- \tabcDefghiJkl\n',
- '? \t ^ ^ ^\n',
- '+ \tabcdefGhijkl\n',
- '? \t ^ ^ ^\n' ]
- */
-
- var common, lines;
- lines = [];
- common = min(_countLeading(aline, '\t'), _countLeading(bline, '\t'));
- common = min(common, _countLeading(atags.slice(0, common), ' '));
- common = min(common, _countLeading(btags.slice(0, common), ' '));
- atags = atags.slice(common).replace(/\s+$/, '');
- btags = btags.slice(common).replace(/\s+$/, '');
- lines.push('- ' + aline);
- if (atags.length) {
- lines.push("? " + (Array(common + 1).join('\t')) + atags + "\n");
- }
- lines.push('+ ' + bline);
- if (btags.length) {
- lines.push("? " + (Array(common + 1).join('\t')) + btags + "\n");
- }
- return lines;
- };
-
- return Differ;
-
- })();
-
- IS_LINE_JUNK = function(line, pat) {
- if (pat == null) {
- pat = /^\s*#?\s*$/;
- }
- /*
- Return 1 for ignorable line: iff `line` is blank or contains a single '#'.
-
- Examples:
-
- >>> IS_LINE_JUNK('\n')
- true
- >>> IS_LINE_JUNK(' # \n')
- true
- >>> IS_LINE_JUNK('hello\n')
- false
- */
-
- return pat.test(line);
- };
-
- IS_CHARACTER_JUNK = function(ch, ws) {
- if (ws == null) {
- ws = ' \t';
- }
- /*
- Return 1 for ignorable character: iff `ch` is a space or tab.
-
- Examples:
- >>> IS_CHARACTER_JUNK(' ').should.be.true
- true
- >>> IS_CHARACTER_JUNK('\t').should.be.true
- true
- >>> IS_CHARACTER_JUNK('\n').should.be.false
- false
- >>> IS_CHARACTER_JUNK('x').should.be.false
- false
- */
-
- return __indexOf.call(ws, ch) >= 0;
- };
-
- _formatRangeUnified = function(start, stop) {
- /*
- Convert range to the "ed" format'
- */
-
- var beginning, length;
- beginning = start + 1;
- length = stop - start;
- if (length === 1) {
- return "" + beginning;
- }
- if (!length) {
- beginning--;
- }
- return "" + beginning + "," + length;
- };
-
- unifiedDiff = function(a, b, _arg) {
- var file1Range, file2Range, first, fromdate, fromfile, fromfiledate, group, i1, i2, j1, j2, last, line, lines, lineterm, n, started, tag, todate, tofile, tofiledate, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6;
- _ref = _arg != null ? _arg : {}, fromfile = _ref.fromfile, tofile = _ref.tofile, fromfiledate = _ref.fromfiledate, tofiledate = _ref.tofiledate, n = _ref.n, lineterm = _ref.lineterm;
- /*
- Compare two sequences of lines; generate the delta as a unified diff.
-
- Unified diffs are a compact way of showing line changes and a few
- lines of context. The number of context lines is set by 'n' which
- defaults to three.
-
- By default, the diff control lines (those with ---, +++, or @@) are
- created with a trailing newline.
-
- For inputs that do not have trailing newlines, set the lineterm
- argument to "" so that the output will be uniformly newline free.
-
- The unidiff format normally has a header for filenames and modification
- times. Any or all of these may be specified using strings for
- 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'.
- The modification times are normally expressed in the ISO 8601 format.
-
- Example:
-
- >>> unifiedDiff('one two three four'.split(' '),
- ... 'zero one tree four'.split(' '), {
- ... fromfile: 'Original'
- ... tofile: 'Current',
- ... fromfiledate: '2005-01-26 23:30:50',
- ... tofiledate: '2010-04-02 10:20:52',
- ... lineterm: ''
- ... })
- [ '--- Original\t2005-01-26 23:30:50',
- '+++ Current\t2010-04-02 10:20:52',
- '@@ -1,4 +1,4 @@',
- '+zero',
- ' one',
- '-two',
- '-three',
- '+tree',
- ' four' ]
- */
-
- if (fromfile == null) {
- fromfile = '';
- }
- if (tofile == null) {
- tofile = '';
- }
- if (fromfiledate == null) {
- fromfiledate = '';
- }
- if (tofiledate == null) {
- tofiledate = '';
- }
- if (n == null) {
- n = 3;
- }
- if (lineterm == null) {
- lineterm = '\n';
- }
- lines = [];
- started = false;
- _ref1 = (new SequenceMatcher(null, a, b)).getGroupedOpcodes();
- for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
- group = _ref1[_i];
- if (!started) {
- started = true;
- fromdate = fromfiledate ? "\t" + fromfiledate : '';
- todate = tofiledate ? "\t" + tofiledate : '';
- lines.push("--- " + fromfile + fromdate + lineterm);
- lines.push("+++ " + tofile + todate + lineterm);
- }
- _ref2 = [group[0], group[group.length - 1]], first = _ref2[0], last = _ref2[1];
- file1Range = _formatRangeUnified(first[1], last[2]);
- file2Range = _formatRangeUnified(first[3], last[4]);
- lines.push("@@ -" + file1Range + " +" + file2Range + " @@" + lineterm);
- for (_j = 0, _len1 = group.length; _j < _len1; _j++) {
- _ref3 = group[_j], tag = _ref3[0], i1 = _ref3[1], i2 = _ref3[2], j1 = _ref3[3], j2 = _ref3[4];
- if (tag === 'equal') {
- _ref4 = a.slice(i1, i2);
- for (_k = 0, _len2 = _ref4.length; _k < _len2; _k++) {
- line = _ref4[_k];
- lines.push(' ' + line);
- }
- continue;
- }
- if (tag === 'replace' || tag === 'delete') {
- _ref5 = a.slice(i1, i2);
- for (_l = 0, _len3 = _ref5.length; _l < _len3; _l++) {
- line = _ref5[_l];
- lines.push('-' + line);
- }
- }
- if (tag === 'replace' || tag === 'insert') {
- _ref6 = b.slice(j1, j2);
- for (_m = 0, _len4 = _ref6.length; _m < _len4; _m++) {
- line = _ref6[_m];
- lines.push('+' + line);
- }
- }
- }
- }
- return lines;
- };
-
- _formatRangeContext = function(start, stop) {
- /*
- Convert range to the "ed" format'
- */
-
- var beginning, length;
- beginning = start + 1;
- length = stop - start;
- if (!length) {
- beginning--;
- }
- if (length <= 1) {
- return "" + beginning;
- }
- return "" + beginning + "," + (beginning + length - 1);
- };
-
- contextDiff = function(a, b, _arg) {
- var file1Range, file2Range, first, fromdate, fromfile, fromfiledate, group, i1, i2, j1, j2, last, line, lines, lineterm, n, prefix, started, tag, todate, tofile, tofiledate, _, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6;
- _ref = _arg != null ? _arg : {}, fromfile = _ref.fromfile, tofile = _ref.tofile, fromfiledate = _ref.fromfiledate, tofiledate = _ref.tofiledate, n = _ref.n, lineterm = _ref.lineterm;
- /*
- Compare two sequences of lines; generate the delta as a context diff.
-
- Context diffs are a compact way of showing line changes and a few
- lines of context. The number of context lines is set by 'n' which
- defaults to three.
-
- By default, the diff control lines (those with *** or ---) are
- created with a trailing newline. This is helpful so that inputs
- created from file.readlines() result in diffs that are suitable for
- file.writelines() since both the inputs and outputs have trailing
- newlines.
-
- For inputs that do not have trailing newlines, set the lineterm
- argument to "" so that the output will be uniformly newline free.
-
- The context diff format normally has a header for filenames and
- modification times. Any or all of these may be specified using
- strings for 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'.
- The modification times are normally expressed in the ISO 8601 format.
- If not specified, the strings default to blanks.
-
- Example:
- >>> a = ['one\n', 'two\n', 'three\n', 'four\n']
- >>> b = ['zero\n', 'one\n', 'tree\n', 'four\n']
- >>> contextDiff(a, b, {fromfile: 'Original', tofile: 'Current'})
- [ '*** Original\n',
- '--- Current\n',
- '***************\n',
- '*** 1,4 ****\n',
- ' one\n',
- '! two\n',
- '! three\n',
- ' four\n',
- '--- 1,4 ----\n',
- '+ zero\n',
- ' one\n',
- '! tree\n',
- ' four\n' ]
- */
-
- if (fromfile == null) {
- fromfile = '';
- }
- if (tofile == null) {
- tofile = '';
- }
- if (fromfiledate == null) {
- fromfiledate = '';
- }
- if (tofiledate == null) {
- tofiledate = '';
- }
- if (n == null) {
- n = 3;
- }
- if (lineterm == null) {
- lineterm = '\n';
- }
- prefix = {
- insert: '+ ',
- "delete": '- ',
- replace: '! ',
- equal: ' '
- };
- started = false;
- lines = [];
- _ref1 = (new SequenceMatcher(null, a, b)).getGroupedOpcodes();
- for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
- group = _ref1[_i];
- if (!started) {
- started = true;
- fromdate = fromfiledate ? "\t" + fromfiledate : '';
- todate = tofiledate ? "\t" + tofiledate : '';
- lines.push("*** " + fromfile + fromdate + lineterm);
- lines.push("--- " + tofile + todate + lineterm);
- _ref2 = [group[0], group[group.length - 1]], first = _ref2[0], last = _ref2[1];
- lines.push('***************' + lineterm);
- file1Range = _formatRangeContext(first[1], last[2]);
- lines.push("*** " + file1Range + " ****" + lineterm);
- if (_any((function() {
- var _j, _len1, _ref3, _results;
- _results = [];
- for (_j = 0, _len1 = group.length; _j < _len1; _j++) {
- _ref3 = group[_j], tag = _ref3[0], _ = _ref3[1], _ = _ref3[2], _ = _ref3[3], _ = _ref3[4];
- _results.push(tag === 'replace' || tag === 'delete');
- }
- return _results;
- })())) {
- for (_j = 0, _len1 = group.length; _j < _len1; _j++) {
- _ref3 = group[_j], tag = _ref3[0], i1 = _ref3[1], i2 = _ref3[2], _ = _ref3[3], _ = _ref3[4];
- if (tag !== 'insert') {
- _ref4 = a.slice(i1, i2);
- for (_k = 0, _len2 = _ref4.length; _k < _len2; _k++) {
- line = _ref4[_k];
- lines.push(prefix[tag] + line);
- }
- }
- }
- }
- file2Range = _formatRangeContext(first[3], last[4]);
- lines.push("--- " + file2Range + " ----" + lineterm);
- if (_any((function() {
- var _l, _len3, _ref5, _results;
- _results = [];
- for (_l = 0, _len3 = group.length; _l < _len3; _l++) {
- _ref5 = group[_l], tag = _ref5[0], _ = _ref5[1], _ = _ref5[2], _ = _ref5[3], _ = _ref5[4];
- _results.push(tag === 'replace' || tag === 'insert');
- }
- return _results;
- })())) {
- for (_l = 0, _len3 = group.length; _l < _len3; _l++) {
- _ref5 = group[_l], tag = _ref5[0], _ = _ref5[1], _ = _ref5[2], j1 = _ref5[3], j2 = _ref5[4];
- if (tag !== 'delete') {
- _ref6 = b.slice(j1, j2);
- for (_m = 0, _len4 = _ref6.length; _m < _len4; _m++) {
- line = _ref6[_m];
- lines.push(prefix[tag] + line);
- }
- }
- }
- }
- }
- }
- return lines;
- };
-
- ndiff = function(a, b, linejunk, charjunk) {
- if (charjunk == null) {
- charjunk = IS_CHARACTER_JUNK;
- }
- /*
- Compare `a` and `b` (lists of strings); return a `Differ`-style delta.
-
- Optional keyword parameters `linejunk` and `charjunk` are for filter
- functions (or None):
-
- - linejunk: A function that should accept a single string argument, and
- return true iff the string is junk. The default is null, and is
- recommended;
-
- - charjunk: A function that should accept a string of length 1. The
- default is module-level function IS_CHARACTER_JUNK, which filters out
- whitespace characters (a blank or tab; note: bad idea to include newline
- in this!).
-
- Example:
- >>> a = ['one\n', 'two\n', 'three\n']
- >>> b = ['ore\n', 'tree\n', 'emu\n']
- >>> ndiff(a, b)
- [ '- one\n',
- '? ^\n',
- '+ ore\n',
- '? ^\n',
- '- two\n',
- '- three\n',
- '? -\n',
- '+ tree\n',
- '+ emu\n' ]
- */
-
- return (new Differ(linejunk, charjunk)).compare(a, b);
- };
-
- restore = function(delta, which) {
- /*
- Generate one of the two sequences that generated a delta.
-
- Given a `delta` produced by `Differ.compare()` or `ndiff()`, extract
- lines originating from file 1 or 2 (parameter `which`), stripping off line
- prefixes.
-
- Examples:
- >>> a = ['one\n', 'two\n', 'three\n']
- >>> b = ['ore\n', 'tree\n', 'emu\n']
- >>> diff = ndiff(a, b)
- >>> restore(diff, 1)
- [ 'one\n',
- 'two\n',
- 'three\n' ]
- >>> restore(diff, 2)
- [ 'ore\n',
- 'tree\n',
- 'emu\n' ]
- */
-
- var line, lines, prefixes, tag, _i, _len, _ref;
- tag = {
- 1: '- ',
- 2: '+ '
- }[which];
- if (!tag) {
- throw new Error("unknow delta choice (must be 1 or 2): " + which);
- }
- prefixes = [' ', tag];
- lines = [];
- for (_i = 0, _len = delta.length; _i < _len; _i++) {
- line = delta[_i];
- if (_ref = line.slice(0, 2), __indexOf.call(prefixes, _ref) >= 0) {
- lines.push(line.slice(2));
- }
- }
- return lines;
- };
-
- exports._arrayCmp = _arrayCmp;
-
- exports.SequenceMatcher = SequenceMatcher;
-
- exports.getCloseMatches = getCloseMatches;
-
- exports._countLeading = _countLeading;
-
- exports.Differ = Differ;
-
- exports.IS_LINE_JUNK = IS_LINE_JUNK;
-
- exports.IS_CHARACTER_JUNK = IS_CHARACTER_JUNK;
-
- exports._formatRangeUnified = _formatRangeUnified;
-
- exports.unifiedDiff = unifiedDiff;
-
- exports._formatRangeContext = _formatRangeContext;
-
- exports.contextDiff = contextDiff;
-
- exports.ndiff = ndiff;
-
- exports.restore = restore;
-
- }).call(this);
-
-
- /***/ }),
-
- /***/ "v2jn":
- /***/ (function(module, exports, __webpack_require__) {
-
- /*!
-
- diff v4.0.1
-
- Software License Agreement (BSD License)
-
- Copyright (c) 2009-2015, Kevin Decker <kpdecker@gmail.com>
-
- All rights reserved.
-
- Redistribution and use of this software in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above
- copyright notice, this list of conditions and the
- following disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the
- following disclaimer in the documentation and/or other
- materials provided with the distribution.
-
- * Neither the name of Kevin Decker nor the names of its
- contributors may be used to endorse or promote products
- derived from this software without specific prior
- written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
- IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- @license
- */
- (function (global, factory) {
- true ? factory(exports) :
- undefined;
- }(this, function (exports) { 'use strict';
-
- function Diff() {}
- Diff.prototype = {
- diff: function diff(oldString, newString) {
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
- var callback = options.callback;
-
- if (typeof options === 'function') {
- callback = options;
- options = {};
- }
-
- this.options = options;
- var self = this;
-
- function done(value) {
- if (callback) {
- setTimeout(function () {
- callback(undefined, value);
- }, 0);
- return true;
- } else {
- return value;
- }
- } // Allow subclasses to massage the input prior to running
-
-
- oldString = this.castInput(oldString);
- newString = this.castInput(newString);
- oldString = this.removeEmpty(this.tokenize(oldString));
- newString = this.removeEmpty(this.tokenize(newString));
- var newLen = newString.length,
- oldLen = oldString.length;
- var editLength = 1;
- var maxEditLength = newLen + oldLen;
- var bestPath = [{
- newPos: -1,
- components: []
- }]; // Seed editLength = 0, i.e. the content starts with the same values
-
- var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
-
- if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
- // Identity per the equality and tokenizer
- return done([{
- value: this.join(newString),
- count: newString.length
- }]);
- } // Main worker method. checks all permutations of a given edit length for acceptance.
-
-
- function execEditLength() {
- for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
- var basePath = void 0;
-
- var addPath = bestPath[diagonalPath - 1],
- removePath = bestPath[diagonalPath + 1],
- _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
-
- if (addPath) {
- // No one else is going to attempt to use this value, clear it
- bestPath[diagonalPath - 1] = undefined;
- }
-
- var canAdd = addPath && addPath.newPos + 1 < newLen,
- canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
-
- if (!canAdd && !canRemove) {
- // If this path is a terminal then prune
- bestPath[diagonalPath] = undefined;
- continue;
- } // Select the diagonal that we want to branch from. We select the prior
- // path whose position in the new string is the farthest from the origin
- // and does not pass the bounds of the diff graph
-
-
- if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
- basePath = clonePath(removePath);
- self.pushComponent(basePath.components, undefined, true);
- } else {
- basePath = addPath; // No need to clone, we've pulled it from the list
-
- basePath.newPos++;
- self.pushComponent(basePath.components, true, undefined);
- }
-
- _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done
-
- if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
- return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
- } else {
- // Otherwise track this path as a potential candidate and continue.
- bestPath[diagonalPath] = basePath;
- }
- }
-
- editLength++;
- } // Performs the length of edit iteration. Is a bit fugly as this has to support the
- // sync and async mode which is never fun. Loops over execEditLength until a value
- // is produced.
-
-
- if (callback) {
- (function exec() {
- setTimeout(function () {
- // This should not happen, but we want to be safe.
-
- /* istanbul ignore next */
- if (editLength > maxEditLength) {
- return callback();
- }
-
- if (!execEditLength()) {
- exec();
- }
- }, 0);
- })();
- } else {
- while (editLength <= maxEditLength) {
- var ret = execEditLength();
-
- if (ret) {
- return ret;
- }
- }
- }
- },
- pushComponent: function pushComponent(components, added, removed) {
- var last = components[components.length - 1];
-
- if (last && last.added === added && last.removed === removed) {
- // We need to clone here as the component clone operation is just
- // as shallow array clone
- components[components.length - 1] = {
- count: last.count + 1,
- added: added,
- removed: removed
- };
- } else {
- components.push({
- count: 1,
- added: added,
- removed: removed
- });
- }
- },
- extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
- var newLen = newString.length,
- oldLen = oldString.length,
- newPos = basePath.newPos,
- oldPos = newPos - diagonalPath,
- commonCount = 0;
-
- while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
- newPos++;
- oldPos++;
- commonCount++;
- }
-
- if (commonCount) {
- basePath.components.push({
- count: commonCount
- });
- }
-
- basePath.newPos = newPos;
- return oldPos;
- },
- equals: function equals(left, right) {
- if (this.options.comparator) {
- return this.options.comparator(left, right);
- } else {
- return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
- }
- },
- removeEmpty: function removeEmpty(array) {
- var ret = [];
-
- for (var i = 0; i < array.length; i++) {
- if (array[i]) {
- ret.push(array[i]);
- }
- }
-
- return ret;
- },
- castInput: function castInput(value) {
- return value;
- },
- tokenize: function tokenize(value) {
- return value.split('');
- },
- join: function join(chars) {
- return chars.join('');
- }
- };
-
- function buildValues(diff, components, newString, oldString, useLongestToken) {
- var componentPos = 0,
- componentLen = components.length,
- newPos = 0,
- oldPos = 0;
-
- for (; componentPos < componentLen; componentPos++) {
- var component = components[componentPos];
-
- if (!component.removed) {
- if (!component.added && useLongestToken) {
- var value = newString.slice(newPos, newPos + component.count);
- value = value.map(function (value, i) {
- var oldValue = oldString[oldPos + i];
- return oldValue.length > value.length ? oldValue : value;
- });
- component.value = diff.join(value);
- } else {
- component.value = diff.join(newString.slice(newPos, newPos + component.count));
- }
-
- newPos += component.count; // Common case
-
- if (!component.added) {
- oldPos += component.count;
- }
- } else {
- component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
- oldPos += component.count; // Reverse add and remove so removes are output first to match common convention
- // The diffing algorithm is tied to add then remove output and this is the simplest
- // route to get the desired output with minimal overhead.
-
- if (componentPos && components[componentPos - 1].added) {
- var tmp = components[componentPos - 1];
- components[componentPos - 1] = components[componentPos];
- components[componentPos] = tmp;
- }
- }
- } // Special case handle for when one terminal is ignored (i.e. whitespace).
- // For this case we merge the terminal into the prior string and drop the change.
- // This is only available for string mode.
-
-
- var lastComponent = components[componentLen - 1];
-
- if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
- components[componentLen - 2].value += lastComponent.value;
- components.pop();
- }
-
- return components;
- }
-
- function clonePath(path) {
- return {
- newPos: path.newPos,
- components: path.components.slice(0)
- };
- }
-
- var characterDiff = new Diff();
- function diffChars(oldStr, newStr, options) {
- return characterDiff.diff(oldStr, newStr, options);
- }
-
- function generateOptions(options, defaults) {
- if (typeof options === 'function') {
- defaults.callback = options;
- } else if (options) {
- for (var name in options) {
- /* istanbul ignore else */
- if (options.hasOwnProperty(name)) {
- defaults[name] = options[name];
- }
- }
- }
-
- return defaults;
- }
-
- //
- // Ranges and exceptions:
- // Latin-1 Supplement, 0080–00FF
- // - U+00D7 × Multiplication sign
- // - U+00F7 ÷ Division sign
- // Latin Extended-A, 0100–017F
- // Latin Extended-B, 0180–024F
- // IPA Extensions, 0250–02AF
- // Spacing Modifier Letters, 02B0–02FF
- // - U+02C7 ˇ ˇ Caron
- // - U+02D8 ˘ ˘ Breve
- // - U+02D9 ˙ ˙ Dot Above
- // - U+02DA ˚ ˚ Ring Above
- // - U+02DB ˛ ˛ Ogonek
- // - U+02DC ˜ ˜ Small Tilde
- // - U+02DD ˝ ˝ Double Acute Accent
- // Latin Extended Additional, 1E00–1EFF
-
- var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
- var reWhitespace = /\S/;
- var wordDiff = new Diff();
-
- wordDiff.equals = function (left, right) {
- if (this.options.ignoreCase) {
- left = left.toLowerCase();
- right = right.toLowerCase();
- }
-
- return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
- };
-
- wordDiff.tokenize = function (value) {
- var tokens = value.split(/(\s+|[()[\]{}'"]|\b)/); // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set.
-
- for (var i = 0; i < tokens.length - 1; i++) {
- // If we have an empty string in the next field and we have only word chars before and after, merge
- if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
- tokens[i] += tokens[i + 2];
- tokens.splice(i + 1, 2);
- i--;
- }
- }
-
- return tokens;
- };
-
- function diffWords(oldStr, newStr, options) {
- options = generateOptions(options, {
- ignoreWhitespace: true
- });
- return wordDiff.diff(oldStr, newStr, options);
- }
- function diffWordsWithSpace(oldStr, newStr, options) {
- return wordDiff.diff(oldStr, newStr, options);
- }
-
- var lineDiff = new Diff();
-
- lineDiff.tokenize = function (value) {
- var retLines = [],
- linesAndNewlines = value.split(/(\n|\r\n)/); // Ignore the final empty token that occurs if the string ends with a new line
-
- if (!linesAndNewlines[linesAndNewlines.length - 1]) {
- linesAndNewlines.pop();
- } // Merge the content and line separators into single tokens
-
-
- for (var i = 0; i < linesAndNewlines.length; i++) {
- var line = linesAndNewlines[i];
-
- if (i % 2 && !this.options.newlineIsToken) {
- retLines[retLines.length - 1] += line;
- } else {
- if (this.options.ignoreWhitespace) {
- line = line.trim();
- }
-
- retLines.push(line);
- }
- }
-
- return retLines;
- };
-
- function diffLines(oldStr, newStr, callback) {
- return lineDiff.diff(oldStr, newStr, callback);
- }
- function diffTrimmedLines(oldStr, newStr, callback) {
- var options = generateOptions(callback, {
- ignoreWhitespace: true
- });
- return lineDiff.diff(oldStr, newStr, options);
- }
-
- var sentenceDiff = new Diff();
-
- sentenceDiff.tokenize = function (value) {
- return value.split(/(\S.+?[.!?])(?=\s+|$)/);
- };
-
- function diffSentences(oldStr, newStr, callback) {
- return sentenceDiff.diff(oldStr, newStr, callback);
- }
-
- var cssDiff = new Diff();
-
- cssDiff.tokenize = function (value) {
- return value.split(/([{}:;,]|\s+)/);
- };
-
- function diffCss(oldStr, newStr, callback) {
- return cssDiff.diff(oldStr, newStr, callback);
- }
-
- function _typeof(obj) {
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
- _typeof = function (obj) {
- return typeof obj;
- };
- } else {
- _typeof = function (obj) {
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
- };
- }
-
- return _typeof(obj);
- }
-
- function _toConsumableArray(arr) {
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
- }
-
- function _arrayWithoutHoles(arr) {
- if (Array.isArray(arr)) {
- for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
-
- return arr2;
- }
- }
-
- function _iterableToArray(iter) {
- if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
- }
-
- function _nonIterableSpread() {
- throw new TypeError("Invalid attempt to spread non-iterable instance");
- }
-
- var objectPrototypeToString = Object.prototype.toString;
- var jsonDiff = new Diff(); // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
- // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
-
- jsonDiff.useLongestToken = true;
- jsonDiff.tokenize = lineDiff.tokenize;
-
- jsonDiff.castInput = function (value) {
- var _this$options = this.options,
- undefinedReplacement = _this$options.undefinedReplacement,
- _this$options$stringi = _this$options.stringifyReplacer,
- stringifyReplacer = _this$options$stringi === void 0 ? function (k, v) {
- return typeof v === 'undefined' ? undefinedReplacement : v;
- } : _this$options$stringi;
- return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' ');
- };
-
- jsonDiff.equals = function (left, right) {
- return Diff.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'));
- };
-
- function diffJson(oldObj, newObj, options) {
- return jsonDiff.diff(oldObj, newObj, options);
- } // This function handles the presence of circular references by bailing out when encountering an
- // object that is already on the "stack" of items being processed. Accepts an optional replacer
-
- function canonicalize(obj, stack, replacementStack, replacer, key) {
- stack = stack || [];
- replacementStack = replacementStack || [];
-
- if (replacer) {
- obj = replacer(key, obj);
- }
-
- var i;
-
- for (i = 0; i < stack.length; i += 1) {
- if (stack[i] === obj) {
- return replacementStack[i];
- }
- }
-
- var canonicalizedObj;
-
- if ('[object Array]' === objectPrototypeToString.call(obj)) {
- stack.push(obj);
- canonicalizedObj = new Array(obj.length);
- replacementStack.push(canonicalizedObj);
-
- for (i = 0; i < obj.length; i += 1) {
- canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
- }
-
- stack.pop();
- replacementStack.pop();
- return canonicalizedObj;
- }
-
- if (obj && obj.toJSON) {
- obj = obj.toJSON();
- }
-
- if (_typeof(obj) === 'object' && obj !== null) {
- stack.push(obj);
- canonicalizedObj = {};
- replacementStack.push(canonicalizedObj);
-
- var sortedKeys = [],
- _key;
-
- for (_key in obj) {
- /* istanbul ignore else */
- if (obj.hasOwnProperty(_key)) {
- sortedKeys.push(_key);
- }
- }
-
- sortedKeys.sort();
-
- for (i = 0; i < sortedKeys.length; i += 1) {
- _key = sortedKeys[i];
- canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
- }
-
- stack.pop();
- replacementStack.pop();
- } else {
- canonicalizedObj = obj;
- }
-
- return canonicalizedObj;
- }
-
- var arrayDiff = new Diff();
-
- arrayDiff.tokenize = function (value) {
- return value.slice();
- };
-
- arrayDiff.join = arrayDiff.removeEmpty = function (value) {
- return value;
- };
-
- function diffArrays(oldArr, newArr, callback) {
- return arrayDiff.diff(oldArr, newArr, callback);
- }
-
- function parsePatch(uniDiff) {
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/),
- delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [],
- list = [],
- i = 0;
-
- function parseIndex() {
- var index = {};
- list.push(index); // Parse diff metadata
-
- while (i < diffstr.length) {
- var line = diffstr[i]; // File header found, end parsing diff metadata
-
- if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
- break;
- } // Diff index
-
-
- var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
-
- if (header) {
- index.index = header[1];
- }
-
- i++;
- } // Parse file headers if they are defined. Unified diff requires them, but
- // there's no technical issues to have an isolated hunk without file header
-
-
- parseFileHeader(index);
- parseFileHeader(index); // Parse hunks
-
- index.hunks = [];
-
- while (i < diffstr.length) {
- var _line = diffstr[i];
-
- if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
- break;
- } else if (/^@@/.test(_line)) {
- index.hunks.push(parseHunk());
- } else if (_line && options.strict) {
- // Ignore unexpected content unless in strict mode
- throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
- } else {
- i++;
- }
- }
- } // Parses the --- and +++ headers, if none are found, no lines
- // are consumed.
-
-
- function parseFileHeader(index) {
- var fileHeader = /^(---|\+\+\+)\s+(.*)$/.exec(diffstr[i]);
-
- if (fileHeader) {
- var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
- var data = fileHeader[2].split('\t', 2);
- var fileName = data[0].replace(/\\\\/g, '\\');
-
- if (/^".*"$/.test(fileName)) {
- fileName = fileName.substr(1, fileName.length - 2);
- }
-
- index[keyPrefix + 'FileName'] = fileName;
- index[keyPrefix + 'Header'] = (data[1] || '').trim();
- i++;
- }
- } // Parses a hunk
- // This assumes that we are at the start of a hunk.
-
-
- function parseHunk() {
- var chunkHeaderIndex = i,
- chunkHeaderLine = diffstr[i++],
- chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
- var hunk = {
- oldStart: +chunkHeader[1],
- oldLines: +chunkHeader[2] || 1,
- newStart: +chunkHeader[3],
- newLines: +chunkHeader[4] || 1,
- lines: [],
- linedelimiters: []
- };
- var addCount = 0,
- removeCount = 0;
-
- for (; i < diffstr.length; i++) {
- // Lines starting with '---' could be mistaken for the "remove line" operation
- // But they could be the header for the next file. Therefore prune such cases out.
- if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
- break;
- }
-
- var operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? ' ' : diffstr[i][0];
-
- if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
- hunk.lines.push(diffstr[i]);
- hunk.linedelimiters.push(delimiters[i] || '\n');
-
- if (operation === '+') {
- addCount++;
- } else if (operation === '-') {
- removeCount++;
- } else if (operation === ' ') {
- addCount++;
- removeCount++;
- }
- } else {
- break;
- }
- } // Handle the empty block count case
-
-
- if (!addCount && hunk.newLines === 1) {
- hunk.newLines = 0;
- }
-
- if (!removeCount && hunk.oldLines === 1) {
- hunk.oldLines = 0;
- } // Perform optional sanity checking
-
-
- if (options.strict) {
- if (addCount !== hunk.newLines) {
- throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
- }
-
- if (removeCount !== hunk.oldLines) {
- throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
- }
- }
-
- return hunk;
- }
-
- while (i < diffstr.length) {
- parseIndex();
- }
-
- return list;
- }
-
- // Iterator that traverses in the range of [min, max], stepping
- // by distance from a given start position. I.e. for [0, 4], with
- // start of 2, this will iterate 2, 3, 1, 4, 0.
- function distanceIterator (start, minLine, maxLine) {
- var wantForward = true,
- backwardExhausted = false,
- forwardExhausted = false,
- localOffset = 1;
- return function iterator() {
- if (wantForward && !forwardExhausted) {
- if (backwardExhausted) {
- localOffset++;
- } else {
- wantForward = false;
- } // Check if trying to fit beyond text length, and if not, check it fits
- // after offset location (or desired location on first iteration)
-
-
- if (start + localOffset <= maxLine) {
- return localOffset;
- }
-
- forwardExhausted = true;
- }
-
- if (!backwardExhausted) {
- if (!forwardExhausted) {
- wantForward = true;
- } // Check if trying to fit before text beginning, and if not, check it fits
- // before offset location
-
-
- if (minLine <= start - localOffset) {
- return -localOffset++;
- }
-
- backwardExhausted = true;
- return iterator();
- } // We tried to fit hunk before text beginning and beyond text length, then
- // hunk can't fit on the text. Return undefined
-
- };
- }
-
- function applyPatch(source, uniDiff) {
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
-
- if (typeof uniDiff === 'string') {
- uniDiff = parsePatch(uniDiff);
- }
-
- if (Array.isArray(uniDiff)) {
- if (uniDiff.length > 1) {
- throw new Error('applyPatch only works with a single input.');
- }
-
- uniDiff = uniDiff[0];
- } // Apply the diff to the input
-
-
- var lines = source.split(/\r\n|[\n\v\f\r\x85]/),
- delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [],
- hunks = uniDiff.hunks,
- compareLine = options.compareLine || function (lineNumber, line, operation, patchContent) {
- return line === patchContent;
- },
- errorCount = 0,
- fuzzFactor = options.fuzzFactor || 0,
- minLine = 0,
- offset = 0,
- removeEOFNL,
- addEOFNL;
- /**
- * Checks if the hunk exactly fits on the provided location
- */
-
-
- function hunkFits(hunk, toPos) {
- for (var j = 0; j < hunk.lines.length; j++) {
- var line = hunk.lines[j],
- operation = line.length > 0 ? line[0] : ' ',
- content = line.length > 0 ? line.substr(1) : line;
-
- if (operation === ' ' || operation === '-') {
- // Context sanity check
- if (!compareLine(toPos + 1, lines[toPos], operation, content)) {
- errorCount++;
-
- if (errorCount > fuzzFactor) {
- return false;
- }
- }
-
- toPos++;
- }
- }
-
- return true;
- } // Search best fit offsets for each hunk based on the previous ones
-
-
- for (var i = 0; i < hunks.length; i++) {
- var hunk = hunks[i],
- maxLine = lines.length - hunk.oldLines,
- localOffset = 0,
- toPos = offset + hunk.oldStart - 1;
- var iterator = distanceIterator(toPos, minLine, maxLine);
-
- for (; localOffset !== undefined; localOffset = iterator()) {
- if (hunkFits(hunk, toPos + localOffset)) {
- hunk.offset = offset += localOffset;
- break;
- }
- }
-
- if (localOffset === undefined) {
- return false;
- } // Set lower text limit to end of the current hunk, so next ones don't try
- // to fit over already patched text
-
-
- minLine = hunk.offset + hunk.oldStart + hunk.oldLines;
- } // Apply patch hunks
-
-
- var diffOffset = 0;
-
- for (var _i = 0; _i < hunks.length; _i++) {
- var _hunk = hunks[_i],
- _toPos = _hunk.oldStart + _hunk.offset + diffOffset - 1;
-
- diffOffset += _hunk.newLines - _hunk.oldLines;
-
- if (_toPos < 0) {
- // Creating a new file
- _toPos = 0;
- }
-
- for (var j = 0; j < _hunk.lines.length; j++) {
- var line = _hunk.lines[j],
- operation = line.length > 0 ? line[0] : ' ',
- content = line.length > 0 ? line.substr(1) : line,
- delimiter = _hunk.linedelimiters[j];
-
- if (operation === ' ') {
- _toPos++;
- } else if (operation === '-') {
- lines.splice(_toPos, 1);
- delimiters.splice(_toPos, 1);
- /* istanbul ignore else */
- } else if (operation === '+') {
- lines.splice(_toPos, 0, content);
- delimiters.splice(_toPos, 0, delimiter);
- _toPos++;
- } else if (operation === '\\') {
- var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null;
-
- if (previousOperation === '+') {
- removeEOFNL = true;
- } else if (previousOperation === '-') {
- addEOFNL = true;
- }
- }
- }
- } // Handle EOFNL insertion/removal
-
-
- if (removeEOFNL) {
- while (!lines[lines.length - 1]) {
- lines.pop();
- delimiters.pop();
- }
- } else if (addEOFNL) {
- lines.push('');
- delimiters.push('\n');
- }
-
- for (var _k = 0; _k < lines.length - 1; _k++) {
- lines[_k] = lines[_k] + delimiters[_k];
- }
-
- return lines.join('');
- } // Wrapper that supports multiple file patches via callbacks.
-
- function applyPatches(uniDiff, options) {
- if (typeof uniDiff === 'string') {
- uniDiff = parsePatch(uniDiff);
- }
-
- var currentIndex = 0;
-
- function processIndex() {
- var index = uniDiff[currentIndex++];
-
- if (!index) {
- return options.complete();
- }
-
- options.loadFile(index, function (err, data) {
- if (err) {
- return options.complete(err);
- }
-
- var updatedContent = applyPatch(data, index, options);
- options.patched(index, updatedContent, function (err) {
- if (err) {
- return options.complete(err);
- }
-
- processIndex();
- });
- });
- }
-
- processIndex();
- }
-
- function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
- if (!options) {
- options = {};
- }
-
- if (typeof options.context === 'undefined') {
- options.context = 4;
- }
-
- var diff = diffLines(oldStr, newStr, options);
- diff.push({
- value: '',
- lines: []
- }); // Append an empty value to make cleanup easier
-
- function contextLines(lines) {
- return lines.map(function (entry) {
- return ' ' + entry;
- });
- }
-
- var hunks = [];
- var oldRangeStart = 0,
- newRangeStart = 0,
- curRange = [],
- oldLine = 1,
- newLine = 1;
-
- var _loop = function _loop(i) {
- var current = diff[i],
- lines = current.lines || current.value.replace(/\n$/, '').split('\n');
- current.lines = lines;
-
- if (current.added || current.removed) {
- var _curRange;
-
- // If we have previous context, start with that
- if (!oldRangeStart) {
- var prev = diff[i - 1];
- oldRangeStart = oldLine;
- newRangeStart = newLine;
-
- if (prev) {
- curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
- oldRangeStart -= curRange.length;
- newRangeStart -= curRange.length;
- }
- } // Output our changes
-
-
- (_curRange = curRange).push.apply(_curRange, _toConsumableArray(lines.map(function (entry) {
- return (current.added ? '+' : '-') + entry;
- }))); // Track the updated file position
-
-
- if (current.added) {
- newLine += lines.length;
- } else {
- oldLine += lines.length;
- }
- } else {
- // Identical context lines. Track line changes
- if (oldRangeStart) {
- // Close out any changes that have been output (or join overlapping)
- if (lines.length <= options.context * 2 && i < diff.length - 2) {
- var _curRange2;
-
- // Overlapping
- (_curRange2 = curRange).push.apply(_curRange2, _toConsumableArray(contextLines(lines)));
- } else {
- var _curRange3;
-
- // end the range and output
- var contextSize = Math.min(lines.length, options.context);
-
- (_curRange3 = curRange).push.apply(_curRange3, _toConsumableArray(contextLines(lines.slice(0, contextSize))));
-
- var hunk = {
- oldStart: oldRangeStart,
- oldLines: oldLine - oldRangeStart + contextSize,
- newStart: newRangeStart,
- newLines: newLine - newRangeStart + contextSize,
- lines: curRange
- };
-
- if (i >= diff.length - 2 && lines.length <= options.context) {
- // EOF is inside this hunk
- var oldEOFNewline = /\n$/.test(oldStr);
- var newEOFNewline = /\n$/.test(newStr);
- var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines;
-
- if (!oldEOFNewline && noNlBeforeAdds) {
- // special case: old has no eol and no trailing context; no-nl can end up before adds
- curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
- }
-
- if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) {
- curRange.push('\\ No newline at end of file');
- }
- }
-
- hunks.push(hunk);
- oldRangeStart = 0;
- newRangeStart = 0;
- curRange = [];
- }
- }
-
- oldLine += lines.length;
- newLine += lines.length;
- }
- };
-
- for (var i = 0; i < diff.length; i++) {
- _loop(i);
- }
-
- return {
- oldFileName: oldFileName,
- newFileName: newFileName,
- oldHeader: oldHeader,
- newHeader: newHeader,
- hunks: hunks
- };
- }
- function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
- var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
- var ret = [];
-
- if (oldFileName == newFileName) {
- ret.push('Index: ' + oldFileName);
- }
-
- ret.push('===================================================================');
- ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
- ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
-
- for (var i = 0; i < diff.hunks.length; i++) {
- var hunk = diff.hunks[i];
- ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
- ret.push.apply(ret, hunk.lines);
- }
-
- return ret.join('\n') + '\n';
- }
- function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
- return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
- }
-
- function arrayEqual(a, b) {
- if (a.length !== b.length) {
- return false;
- }
-
- return arrayStartsWith(a, b);
- }
- function arrayStartsWith(array, start) {
- if (start.length > array.length) {
- return false;
- }
-
- for (var i = 0; i < start.length; i++) {
- if (start[i] !== array[i]) {
- return false;
- }
- }
-
- return true;
- }
-
- function calcLineCount(hunk) {
- var _calcOldNewLineCount = calcOldNewLineCount(hunk.lines),
- oldLines = _calcOldNewLineCount.oldLines,
- newLines = _calcOldNewLineCount.newLines;
-
- if (oldLines !== undefined) {
- hunk.oldLines = oldLines;
- } else {
- delete hunk.oldLines;
- }
-
- if (newLines !== undefined) {
- hunk.newLines = newLines;
- } else {
- delete hunk.newLines;
- }
- }
- function merge(mine, theirs, base) {
- mine = loadPatch(mine, base);
- theirs = loadPatch(theirs, base);
- var ret = {}; // For index we just let it pass through as it doesn't have any necessary meaning.
- // Leaving sanity checks on this to the API consumer that may know more about the
- // meaning in their own context.
-
- if (mine.index || theirs.index) {
- ret.index = mine.index || theirs.index;
- }
-
- if (mine.newFileName || theirs.newFileName) {
- if (!fileNameChanged(mine)) {
- // No header or no change in ours, use theirs (and ours if theirs does not exist)
- ret.oldFileName = theirs.oldFileName || mine.oldFileName;
- ret.newFileName = theirs.newFileName || mine.newFileName;
- ret.oldHeader = theirs.oldHeader || mine.oldHeader;
- ret.newHeader = theirs.newHeader || mine.newHeader;
- } else if (!fileNameChanged(theirs)) {
- // No header or no change in theirs, use ours
- ret.oldFileName = mine.oldFileName;
- ret.newFileName = mine.newFileName;
- ret.oldHeader = mine.oldHeader;
- ret.newHeader = mine.newHeader;
- } else {
- // Both changed... figure it out
- ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName);
- ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName);
- ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader);
- ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader);
- }
- }
-
- ret.hunks = [];
- var mineIndex = 0,
- theirsIndex = 0,
- mineOffset = 0,
- theirsOffset = 0;
-
- while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) {
- var mineCurrent = mine.hunks[mineIndex] || {
- oldStart: Infinity
- },
- theirsCurrent = theirs.hunks[theirsIndex] || {
- oldStart: Infinity
- };
-
- if (hunkBefore(mineCurrent, theirsCurrent)) {
- // This patch does not overlap with any of the others, yay.
- ret.hunks.push(cloneHunk(mineCurrent, mineOffset));
- mineIndex++;
- theirsOffset += mineCurrent.newLines - mineCurrent.oldLines;
- } else if (hunkBefore(theirsCurrent, mineCurrent)) {
- // This patch does not overlap with any of the others, yay.
- ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset));
- theirsIndex++;
- mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines;
- } else {
- // Overlap, merge as best we can
- var mergedHunk = {
- oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart),
- oldLines: 0,
- newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset),
- newLines: 0,
- lines: []
- };
- mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines);
- theirsIndex++;
- mineIndex++;
- ret.hunks.push(mergedHunk);
- }
- }
-
- return ret;
- }
-
- function loadPatch(param, base) {
- if (typeof param === 'string') {
- if (/^@@/m.test(param) || /^Index:/m.test(param)) {
- return parsePatch(param)[0];
- }
-
- if (!base) {
- throw new Error('Must provide a base reference or pass in a patch');
- }
-
- return structuredPatch(undefined, undefined, base, param);
- }
-
- return param;
- }
-
- function fileNameChanged(patch) {
- return patch.newFileName && patch.newFileName !== patch.oldFileName;
- }
-
- function selectField(index, mine, theirs) {
- if (mine === theirs) {
- return mine;
- } else {
- index.conflict = true;
- return {
- mine: mine,
- theirs: theirs
- };
- }
- }
-
- function hunkBefore(test, check) {
- return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart;
- }
-
- function cloneHunk(hunk, offset) {
- return {
- oldStart: hunk.oldStart,
- oldLines: hunk.oldLines,
- newStart: hunk.newStart + offset,
- newLines: hunk.newLines,
- lines: hunk.lines
- };
- }
-
- function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) {
- // This will generally result in a conflicted hunk, but there are cases where the context
- // is the only overlap where we can successfully merge the content here.
- var mine = {
- offset: mineOffset,
- lines: mineLines,
- index: 0
- },
- their = {
- offset: theirOffset,
- lines: theirLines,
- index: 0
- }; // Handle any leading content
-
- insertLeading(hunk, mine, their);
- insertLeading(hunk, their, mine); // Now in the overlap content. Scan through and select the best changes from each.
-
- while (mine.index < mine.lines.length && their.index < their.lines.length) {
- var mineCurrent = mine.lines[mine.index],
- theirCurrent = their.lines[their.index];
-
- if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) {
- // Both modified ...
- mutualChange(hunk, mine, their);
- } else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') {
- var _hunk$lines;
-
- // Mine inserted
- (_hunk$lines = hunk.lines).push.apply(_hunk$lines, _toConsumableArray(collectChange(mine)));
- } else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') {
- var _hunk$lines2;
-
- // Theirs inserted
- (_hunk$lines2 = hunk.lines).push.apply(_hunk$lines2, _toConsumableArray(collectChange(their)));
- } else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') {
- // Mine removed or edited
- removal(hunk, mine, their);
- } else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') {
- // Their removed or edited
- removal(hunk, their, mine, true);
- } else if (mineCurrent === theirCurrent) {
- // Context identity
- hunk.lines.push(mineCurrent);
- mine.index++;
- their.index++;
- } else {
- // Context mismatch
- conflict(hunk, collectChange(mine), collectChange(their));
- }
- } // Now push anything that may be remaining
-
-
- insertTrailing(hunk, mine);
- insertTrailing(hunk, their);
- calcLineCount(hunk);
- }
-
- function mutualChange(hunk, mine, their) {
- var myChanges = collectChange(mine),
- theirChanges = collectChange(their);
-
- if (allRemoves(myChanges) && allRemoves(theirChanges)) {
- // Special case for remove changes that are supersets of one another
- if (arrayStartsWith(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) {
- var _hunk$lines3;
-
- (_hunk$lines3 = hunk.lines).push.apply(_hunk$lines3, _toConsumableArray(myChanges));
-
- return;
- } else if (arrayStartsWith(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) {
- var _hunk$lines4;
-
- (_hunk$lines4 = hunk.lines).push.apply(_hunk$lines4, _toConsumableArray(theirChanges));
-
- return;
- }
- } else if (arrayEqual(myChanges, theirChanges)) {
- var _hunk$lines5;
-
- (_hunk$lines5 = hunk.lines).push.apply(_hunk$lines5, _toConsumableArray(myChanges));
-
- return;
- }
-
- conflict(hunk, myChanges, theirChanges);
- }
-
- function removal(hunk, mine, their, swap) {
- var myChanges = collectChange(mine),
- theirChanges = collectContext(their, myChanges);
-
- if (theirChanges.merged) {
- var _hunk$lines6;
-
- (_hunk$lines6 = hunk.lines).push.apply(_hunk$lines6, _toConsumableArray(theirChanges.merged));
- } else {
- conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges);
- }
- }
-
- function conflict(hunk, mine, their) {
- hunk.conflict = true;
- hunk.lines.push({
- conflict: true,
- mine: mine,
- theirs: their
- });
- }
-
- function insertLeading(hunk, insert, their) {
- while (insert.offset < their.offset && insert.index < insert.lines.length) {
- var line = insert.lines[insert.index++];
- hunk.lines.push(line);
- insert.offset++;
- }
- }
-
- function insertTrailing(hunk, insert) {
- while (insert.index < insert.lines.length) {
- var line = insert.lines[insert.index++];
- hunk.lines.push(line);
- }
- }
-
- function collectChange(state) {
- var ret = [],
- operation = state.lines[state.index][0];
-
- while (state.index < state.lines.length) {
- var line = state.lines[state.index]; // Group additions that are immediately after subtractions and treat them as one "atomic" modify change.
-
- if (operation === '-' && line[0] === '+') {
- operation = '+';
- }
-
- if (operation === line[0]) {
- ret.push(line);
- state.index++;
- } else {
- break;
- }
- }
-
- return ret;
- }
-
- function collectContext(state, matchChanges) {
- var changes = [],
- merged = [],
- matchIndex = 0,
- contextChanges = false,
- conflicted = false;
-
- while (matchIndex < matchChanges.length && state.index < state.lines.length) {
- var change = state.lines[state.index],
- match = matchChanges[matchIndex]; // Once we've hit our add, then we are done
-
- if (match[0] === '+') {
- break;
- }
-
- contextChanges = contextChanges || change[0] !== ' ';
- merged.push(match);
- matchIndex++; // Consume any additions in the other block as a conflict to attempt
- // to pull in the remaining context after this
-
- if (change[0] === '+') {
- conflicted = true;
-
- while (change[0] === '+') {
- changes.push(change);
- change = state.lines[++state.index];
- }
- }
-
- if (match.substr(1) === change.substr(1)) {
- changes.push(change);
- state.index++;
- } else {
- conflicted = true;
- }
- }
-
- if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) {
- conflicted = true;
- }
-
- if (conflicted) {
- return changes;
- }
-
- while (matchIndex < matchChanges.length) {
- merged.push(matchChanges[matchIndex++]);
- }
-
- return {
- merged: merged,
- changes: changes
- };
- }
-
- function allRemoves(changes) {
- return changes.reduce(function (prev, change) {
- return prev && change[0] === '-';
- }, true);
- }
-
- function skipRemoveSuperset(state, removeChanges, delta) {
- for (var i = 0; i < delta; i++) {
- var changeContent = removeChanges[removeChanges.length - delta + i].substr(1);
-
- if (state.lines[state.index + i] !== ' ' + changeContent) {
- return false;
- }
- }
-
- state.index += delta;
- return true;
- }
-
- function calcOldNewLineCount(lines) {
- var oldLines = 0;
- var newLines = 0;
- lines.forEach(function (line) {
- if (typeof line !== 'string') {
- var myCount = calcOldNewLineCount(line.mine);
- var theirCount = calcOldNewLineCount(line.theirs);
-
- if (oldLines !== undefined) {
- if (myCount.oldLines === theirCount.oldLines) {
- oldLines += myCount.oldLines;
- } else {
- oldLines = undefined;
- }
- }
-
- if (newLines !== undefined) {
- if (myCount.newLines === theirCount.newLines) {
- newLines += myCount.newLines;
- } else {
- newLines = undefined;
- }
- }
- } else {
- if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) {
- newLines++;
- }
-
- if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) {
- oldLines++;
- }
- }
- });
- return {
- oldLines: oldLines,
- newLines: newLines
- };
- }
-
- // See: http://code.google.com/p/google-diff-match-patch/wiki/API
- function convertChangesToDMP(changes) {
- var ret = [],
- change,
- operation;
-
- for (var i = 0; i < changes.length; i++) {
- change = changes[i];
-
- if (change.added) {
- operation = 1;
- } else if (change.removed) {
- operation = -1;
- } else {
- operation = 0;
- }
-
- ret.push([operation, change.value]);
- }
-
- return ret;
- }
-
- function convertChangesToXML(changes) {
- var ret = [];
-
- for (var i = 0; i < changes.length; i++) {
- var change = changes[i];
-
- if (change.added) {
- ret.push('<ins>');
- } else if (change.removed) {
- ret.push('<del>');
- }
-
- ret.push(escapeHTML(change.value));
-
- if (change.added) {
- ret.push('</ins>');
- } else if (change.removed) {
- ret.push('</del>');
- }
- }
-
- return ret.join('');
- }
-
- function escapeHTML(s) {
- var n = s;
- n = n.replace(/&/g, '&');
- n = n.replace(/</g, '<');
- n = n.replace(/>/g, '>');
- n = n.replace(/"/g, '"');
- return n;
- }
-
- /* See LICENSE file for terms of use */
-
- exports.Diff = Diff;
- exports.diffChars = diffChars;
- exports.diffWords = diffWords;
- exports.diffWordsWithSpace = diffWordsWithSpace;
- exports.diffLines = diffLines;
- exports.diffTrimmedLines = diffTrimmedLines;
- exports.diffSentences = diffSentences;
- exports.diffCss = diffCss;
- exports.diffJson = diffJson;
- exports.diffArrays = diffArrays;
- exports.structuredPatch = structuredPatch;
- exports.createTwoFilesPatch = createTwoFilesPatch;
- exports.createPatch = createPatch;
- exports.applyPatch = applyPatch;
- exports.applyPatches = applyPatches;
- exports.parsePatch = parsePatch;
- exports.merge = merge;
- exports.convertChangesToDMP = convertChangesToDMP;
- exports.convertChangesToXML = convertChangesToXML;
- exports.canonicalize = canonicalize;
-
- Object.defineProperty(exports, '__esModule', { value: true });
-
- }));
-
-
- /***/ }),
-
- /***/ "xeH2":
- /***/ (function(module, exports) {
-
- module.exports = $;
-
- /***/ }),
-
- /***/ "yLpj":
- /***/ (function(module, exports) {
-
- var g;
-
- // This works in non-strict mode
- g = (function() {
- return this;
- })();
-
- try {
- // This works if eval is allowed (see CSP)
- g = g || new Function("return this")();
- } catch (e) {
- // This works if the window reference is available
- if (typeof window === "object") g = window;
- }
-
- // g can still be undefined, but nothing to do about it...
- // We return undefined, instead of nothing here, so it's
- // easier to handle this case. if(!global) { ...}
-
- module.exports = g;
-
-
- /***/ })
-
- /******/ });