bgm-wiki-rev-diff

show diff between bgm.tv wiki versions

目前为 2020-04-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name bgm-wiki-rev-diff
  3. // @namespace https://trim21.me/
  4. // @version 0.0.4
  5. // @author Trim21 <i@trim21.me>
  6. // @source https://github.com/Trim21/bgm-wiki-rev-diff
  7. // @license MIT
  8. // @match https://bgm.tv/subject/*/edit
  9. // @match https://bangumi.tv/subject/*/edit
  10. // @require https://cdn.jsdelivr.net/npm/jquery@^3.5.0/dist/jquery.min.js
  11. // @grant GM_xmlhttpRequest
  12. // @connect bgm.tv
  13. // @run-at document-end
  14. // @description show diff between bgm.tv wiki versions
  15. // ==/UserScript==
  16.  
  17. /******/ (function(modules) { // webpackBootstrap
  18. /******/ // The module cache
  19. /******/ var installedModules = {};
  20. /******/
  21. /******/ // The require function
  22. /******/ function __webpack_require__(moduleId) {
  23. /******/
  24. /******/ // Check if module is in cache
  25. /******/ if(installedModules[moduleId]) {
  26. /******/ return installedModules[moduleId].exports;
  27. /******/ }
  28. /******/ // Create a new module (and put it into the cache)
  29. /******/ var module = installedModules[moduleId] = {
  30. /******/ i: moduleId,
  31. /******/ l: false,
  32. /******/ exports: {}
  33. /******/ };
  34. /******/
  35. /******/ // Execute the module function
  36. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  37. /******/
  38. /******/ // Flag the module as loaded
  39. /******/ module.l = true;
  40. /******/
  41. /******/ // Return the exports of the module
  42. /******/ return module.exports;
  43. /******/ }
  44. /******/
  45. /******/
  46. /******/ // expose the modules object (__webpack_modules__)
  47. /******/ __webpack_require__.m = modules;
  48. /******/
  49. /******/ // expose the module cache
  50. /******/ __webpack_require__.c = installedModules;
  51. /******/
  52. /******/ // define getter function for harmony exports
  53. /******/ __webpack_require__.d = function(exports, name, getter) {
  54. /******/ if(!__webpack_require__.o(exports, name)) {
  55. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  56. /******/ }
  57. /******/ };
  58. /******/
  59. /******/ // define __esModule on exports
  60. /******/ __webpack_require__.r = function(exports) {
  61. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  62. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  63. /******/ }
  64. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  65. /******/ };
  66. /******/
  67. /******/ // create a fake namespace object
  68. /******/ // mode & 1: value is a module id, require it
  69. /******/ // mode & 2: merge all properties of value into the ns
  70. /******/ // mode & 4: return value when already ns object
  71. /******/ // mode & 8|1: behave like require
  72. /******/ __webpack_require__.t = function(value, mode) {
  73. /******/ if(mode & 1) value = __webpack_require__(value);
  74. /******/ if(mode & 8) return value;
  75. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  76. /******/ var ns = Object.create(null);
  77. /******/ __webpack_require__.r(ns);
  78. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  79. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  80. /******/ return ns;
  81. /******/ };
  82. /******/
  83. /******/ // getDefaultExport function for compatibility with non-harmony modules
  84. /******/ __webpack_require__.n = function(module) {
  85. /******/ var getter = module && module.__esModule ?
  86. /******/ function getDefault() { return module['default']; } :
  87. /******/ function getModuleExports() { return module; };
  88. /******/ __webpack_require__.d(getter, 'a', getter);
  89. /******/ return getter;
  90. /******/ };
  91. /******/
  92. /******/ // Object.prototype.hasOwnProperty.call
  93. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  94. /******/
  95. /******/ // __webpack_public_path__
  96. /******/ __webpack_require__.p = "";
  97. /******/
  98. /******/
  99. /******/ // Load entry module and return exports
  100. /******/ return __webpack_require__(__webpack_require__.s = "e6Wu");
  101. /******/ })
  102. /************************************************************************/
  103. /******/ ({
  104.  
  105. /***/ "1gqn":
  106. /***/ (function(module, exports) {
  107.  
  108. module.exports = function isBuffer(arg) {
  109. return arg && typeof arg === 'object'
  110. && typeof arg.copy === 'function'
  111. && typeof arg.fill === 'function'
  112. && typeof arg.readUInt8 === 'function';
  113. }
  114.  
  115. /***/ }),
  116.  
  117. /***/ "7Mwc":
  118. /***/ (function(module, exports, __webpack_require__) {
  119.  
  120. module.exports = __webpack_require__("qVjC");
  121.  
  122.  
  123. /***/ }),
  124.  
  125. /***/ "8oxB":
  126. /***/ (function(module, exports) {
  127.  
  128. // shim for using process in browser
  129. var process = module.exports = {};
  130.  
  131. // cached from whatever global is present so that test runners that stub it
  132. // don't break things. But we need to wrap it in a try catch in case it is
  133. // wrapped in strict mode code which doesn't define any globals. It's inside a
  134. // function because try/catches deoptimize in certain engines.
  135.  
  136. var cachedSetTimeout;
  137. var cachedClearTimeout;
  138.  
  139. function defaultSetTimout() {
  140. throw new Error('setTimeout has not been defined');
  141. }
  142. function defaultClearTimeout () {
  143. throw new Error('clearTimeout has not been defined');
  144. }
  145. (function () {
  146. try {
  147. if (typeof setTimeout === 'function') {
  148. cachedSetTimeout = setTimeout;
  149. } else {
  150. cachedSetTimeout = defaultSetTimout;
  151. }
  152. } catch (e) {
  153. cachedSetTimeout = defaultSetTimout;
  154. }
  155. try {
  156. if (typeof clearTimeout === 'function') {
  157. cachedClearTimeout = clearTimeout;
  158. } else {
  159. cachedClearTimeout = defaultClearTimeout;
  160. }
  161. } catch (e) {
  162. cachedClearTimeout = defaultClearTimeout;
  163. }
  164. } ())
  165. function runTimeout(fun) {
  166. if (cachedSetTimeout === setTimeout) {
  167. //normal enviroments in sane situations
  168. return setTimeout(fun, 0);
  169. }
  170. // if setTimeout wasn't available but was latter defined
  171. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  172. cachedSetTimeout = setTimeout;
  173. return setTimeout(fun, 0);
  174. }
  175. try {
  176. // when when somebody has screwed with setTimeout but no I.E. maddness
  177. return cachedSetTimeout(fun, 0);
  178. } catch(e){
  179. try {
  180. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  181. return cachedSetTimeout.call(null, fun, 0);
  182. } catch(e){
  183. // 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
  184. return cachedSetTimeout.call(this, fun, 0);
  185. }
  186. }
  187.  
  188.  
  189. }
  190. function runClearTimeout(marker) {
  191. if (cachedClearTimeout === clearTimeout) {
  192. //normal enviroments in sane situations
  193. return clearTimeout(marker);
  194. }
  195. // if clearTimeout wasn't available but was latter defined
  196. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  197. cachedClearTimeout = clearTimeout;
  198. return clearTimeout(marker);
  199. }
  200. try {
  201. // when when somebody has screwed with setTimeout but no I.E. maddness
  202. return cachedClearTimeout(marker);
  203. } catch (e){
  204. try {
  205. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  206. return cachedClearTimeout.call(null, marker);
  207. } catch (e){
  208. // 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.
  209. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  210. return cachedClearTimeout.call(this, marker);
  211. }
  212. }
  213.  
  214.  
  215.  
  216. }
  217. var queue = [];
  218. var draining = false;
  219. var currentQueue;
  220. var queueIndex = -1;
  221.  
  222. function cleanUpNextTick() {
  223. if (!draining || !currentQueue) {
  224. return;
  225. }
  226. draining = false;
  227. if (currentQueue.length) {
  228. queue = currentQueue.concat(queue);
  229. } else {
  230. queueIndex = -1;
  231. }
  232. if (queue.length) {
  233. drainQueue();
  234. }
  235. }
  236.  
  237. function drainQueue() {
  238. if (draining) {
  239. return;
  240. }
  241. var timeout = runTimeout(cleanUpNextTick);
  242. draining = true;
  243.  
  244. var len = queue.length;
  245. while(len) {
  246. currentQueue = queue;
  247. queue = [];
  248. while (++queueIndex < len) {
  249. if (currentQueue) {
  250. currentQueue[queueIndex].run();
  251. }
  252. }
  253. queueIndex = -1;
  254. len = queue.length;
  255. }
  256. currentQueue = null;
  257. draining = false;
  258. runClearTimeout(timeout);
  259. }
  260.  
  261. process.nextTick = function (fun) {
  262. var args = new Array(arguments.length - 1);
  263. if (arguments.length > 1) {
  264. for (var i = 1; i < arguments.length; i++) {
  265. args[i - 1] = arguments[i];
  266. }
  267. }
  268. queue.push(new Item(fun, args));
  269. if (queue.length === 1 && !draining) {
  270. runTimeout(drainQueue);
  271. }
  272. };
  273.  
  274. // v8 likes predictible objects
  275. function Item(fun, array) {
  276. this.fun = fun;
  277. this.array = array;
  278. }
  279. Item.prototype.run = function () {
  280. this.fun.apply(null, this.array);
  281. };
  282. process.title = 'browser';
  283. process.browser = true;
  284. process.env = {};
  285. process.argv = [];
  286. process.version = ''; // empty string to avoid regexp issues
  287. process.versions = {};
  288.  
  289. function noop() {}
  290.  
  291. process.on = noop;
  292. process.addListener = noop;
  293. process.once = noop;
  294. process.off = noop;
  295. process.removeListener = noop;
  296. process.removeAllListeners = noop;
  297. process.emit = noop;
  298. process.prependListener = noop;
  299. process.prependOnceListener = noop;
  300.  
  301. process.listeners = function (name) { return [] }
  302.  
  303. process.binding = function (name) {
  304. throw new Error('process.binding is not supported');
  305. };
  306.  
  307. process.cwd = function () { return '/' };
  308. process.chdir = function (dir) {
  309. throw new Error('process.chdir is not supported');
  310. };
  311. process.umask = function() { return 0; };
  312.  
  313.  
  314. /***/ }),
  315.  
  316. /***/ "9lTW":
  317. /***/ (function(module, exports, __webpack_require__) {
  318.  
  319. "use strict";
  320. /* WEBPACK VAR INJECTION */(function(global) {
  321.  
  322. var objectAssign = __webpack_require__("MgzW");
  323.  
  324. // compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
  325. // original notice:
  326.  
  327. /*!
  328. * The buffer module from node.js, for the browser.
  329. *
  330. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  331. * @license MIT
  332. */
  333. function compare(a, b) {
  334. if (a === b) {
  335. return 0;
  336. }
  337.  
  338. var x = a.length;
  339. var y = b.length;
  340.  
  341. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  342. if (a[i] !== b[i]) {
  343. x = a[i];
  344. y = b[i];
  345. break;
  346. }
  347. }
  348.  
  349. if (x < y) {
  350. return -1;
  351. }
  352. if (y < x) {
  353. return 1;
  354. }
  355. return 0;
  356. }
  357. function isBuffer(b) {
  358. if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
  359. return global.Buffer.isBuffer(b);
  360. }
  361. return !!(b != null && b._isBuffer);
  362. }
  363.  
  364. // based on node assert, original notice:
  365. // NB: The URL to the CommonJS spec is kept just for tradition.
  366. // node-assert has evolved a lot since then, both in API and behavior.
  367.  
  368. // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
  369. //
  370. // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
  371. //
  372. // Originally from narwhal.js (http://narwhaljs.org)
  373. // Copyright (c) 2009 Thomas Robinson <280north.com>
  374. //
  375. // Permission is hereby granted, free of charge, to any person obtaining a copy
  376. // of this software and associated documentation files (the 'Software'), to
  377. // deal in the Software without restriction, including without limitation the
  378. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  379. // sell copies of the Software, and to permit persons to whom the Software is
  380. // furnished to do so, subject to the following conditions:
  381. //
  382. // The above copyright notice and this permission notice shall be included in
  383. // all copies or substantial portions of the Software.
  384. //
  385. // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  386. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  387. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  388. // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  389. // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  390. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  391.  
  392. var util = __webpack_require__("MCLT");
  393. var hasOwn = Object.prototype.hasOwnProperty;
  394. var pSlice = Array.prototype.slice;
  395. var functionsHaveNames = (function () {
  396. return function foo() {}.name === 'foo';
  397. }());
  398. function pToString (obj) {
  399. return Object.prototype.toString.call(obj);
  400. }
  401. function isView(arrbuf) {
  402. if (isBuffer(arrbuf)) {
  403. return false;
  404. }
  405. if (typeof global.ArrayBuffer !== 'function') {
  406. return false;
  407. }
  408. if (typeof ArrayBuffer.isView === 'function') {
  409. return ArrayBuffer.isView(arrbuf);
  410. }
  411. if (!arrbuf) {
  412. return false;
  413. }
  414. if (arrbuf instanceof DataView) {
  415. return true;
  416. }
  417. if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
  418. return true;
  419. }
  420. return false;
  421. }
  422. // 1. The assert module provides functions that throw
  423. // AssertionError's when particular conditions are not met. The
  424. // assert module must conform to the following interface.
  425.  
  426. var assert = module.exports = ok;
  427.  
  428. // 2. The AssertionError is defined in assert.
  429. // new assert.AssertionError({ message: message,
  430. // actual: actual,
  431. // expected: expected })
  432.  
  433. var regex = /\s*function\s+([^\(\s]*)\s*/;
  434. // based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
  435. function getName(func) {
  436. if (!util.isFunction(func)) {
  437. return;
  438. }
  439. if (functionsHaveNames) {
  440. return func.name;
  441. }
  442. var str = func.toString();
  443. var match = str.match(regex);
  444. return match && match[1];
  445. }
  446. assert.AssertionError = function AssertionError(options) {
  447. this.name = 'AssertionError';
  448. this.actual = options.actual;
  449. this.expected = options.expected;
  450. this.operator = options.operator;
  451. if (options.message) {
  452. this.message = options.message;
  453. this.generatedMessage = false;
  454. } else {
  455. this.message = getMessage(this);
  456. this.generatedMessage = true;
  457. }
  458. var stackStartFunction = options.stackStartFunction || fail;
  459. if (Error.captureStackTrace) {
  460. Error.captureStackTrace(this, stackStartFunction);
  461. } else {
  462. // non v8 browsers so we can have a stacktrace
  463. var err = new Error();
  464. if (err.stack) {
  465. var out = err.stack;
  466.  
  467. // try to strip useless frames
  468. var fn_name = getName(stackStartFunction);
  469. var idx = out.indexOf('\n' + fn_name);
  470. if (idx >= 0) {
  471. // once we have located the function frame
  472. // we need to strip out everything before it (and its line)
  473. var next_line = out.indexOf('\n', idx + 1);
  474. out = out.substring(next_line + 1);
  475. }
  476.  
  477. this.stack = out;
  478. }
  479. }
  480. };
  481.  
  482. // assert.AssertionError instanceof Error
  483. util.inherits(assert.AssertionError, Error);
  484.  
  485. function truncate(s, n) {
  486. if (typeof s === 'string') {
  487. return s.length < n ? s : s.slice(0, n);
  488. } else {
  489. return s;
  490. }
  491. }
  492. function inspect(something) {
  493. if (functionsHaveNames || !util.isFunction(something)) {
  494. return util.inspect(something);
  495. }
  496. var rawname = getName(something);
  497. var name = rawname ? ': ' + rawname : '';
  498. return '[Function' + name + ']';
  499. }
  500. function getMessage(self) {
  501. return truncate(inspect(self.actual), 128) + ' ' +
  502. self.operator + ' ' +
  503. truncate(inspect(self.expected), 128);
  504. }
  505.  
  506. // At present only the three keys mentioned above are used and
  507. // understood by the spec. Implementations or sub modules can pass
  508. // other keys to the AssertionError's constructor - they will be
  509. // ignored.
  510.  
  511. // 3. All of the following functions must throw an AssertionError
  512. // when a corresponding condition is not met, with a message that
  513. // may be undefined if not provided. All assertion methods provide
  514. // both the actual and expected values to the assertion error for
  515. // display purposes.
  516.  
  517. function fail(actual, expected, message, operator, stackStartFunction) {
  518. throw new assert.AssertionError({
  519. message: message,
  520. actual: actual,
  521. expected: expected,
  522. operator: operator,
  523. stackStartFunction: stackStartFunction
  524. });
  525. }
  526.  
  527. // EXTENSION! allows for well behaved errors defined elsewhere.
  528. assert.fail = fail;
  529.  
  530. // 4. Pure assertion tests whether a value is truthy, as determined
  531. // by !!guard.
  532. // assert.ok(guard, message_opt);
  533. // This statement is equivalent to assert.equal(true, !!guard,
  534. // message_opt);. To test strictly for the value true, use
  535. // assert.strictEqual(true, guard, message_opt);.
  536.  
  537. function ok(value, message) {
  538. if (!value) fail(value, true, message, '==', assert.ok);
  539. }
  540. assert.ok = ok;
  541.  
  542. // 5. The equality assertion tests shallow, coercive equality with
  543. // ==.
  544. // assert.equal(actual, expected, message_opt);
  545.  
  546. assert.equal = function equal(actual, expected, message) {
  547. if (actual != expected) fail(actual, expected, message, '==', assert.equal);
  548. };
  549.  
  550. // 6. The non-equality assertion tests for whether two objects are not equal
  551. // with != assert.notEqual(actual, expected, message_opt);
  552.  
  553. assert.notEqual = function notEqual(actual, expected, message) {
  554. if (actual == expected) {
  555. fail(actual, expected, message, '!=', assert.notEqual);
  556. }
  557. };
  558.  
  559. // 7. The equivalence assertion tests a deep equality relation.
  560. // assert.deepEqual(actual, expected, message_opt);
  561.  
  562. assert.deepEqual = function deepEqual(actual, expected, message) {
  563. if (!_deepEqual(actual, expected, false)) {
  564. fail(actual, expected, message, 'deepEqual', assert.deepEqual);
  565. }
  566. };
  567.  
  568. assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
  569. if (!_deepEqual(actual, expected, true)) {
  570. fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
  571. }
  572. };
  573.  
  574. function _deepEqual(actual, expected, strict, memos) {
  575. // 7.1. All identical values are equivalent, as determined by ===.
  576. if (actual === expected) {
  577. return true;
  578. } else if (isBuffer(actual) && isBuffer(expected)) {
  579. return compare(actual, expected) === 0;
  580.  
  581. // 7.2. If the expected value is a Date object, the actual value is
  582. // equivalent if it is also a Date object that refers to the same time.
  583. } else if (util.isDate(actual) && util.isDate(expected)) {
  584. return actual.getTime() === expected.getTime();
  585.  
  586. // 7.3 If the expected value is a RegExp object, the actual value is
  587. // equivalent if it is also a RegExp object with the same source and
  588. // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
  589. } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
  590. return actual.source === expected.source &&
  591. actual.global === expected.global &&
  592. actual.multiline === expected.multiline &&
  593. actual.lastIndex === expected.lastIndex &&
  594. actual.ignoreCase === expected.ignoreCase;
  595.  
  596. // 7.4. Other pairs that do not both pass typeof value == 'object',
  597. // equivalence is determined by ==.
  598. } else if ((actual === null || typeof actual !== 'object') &&
  599. (expected === null || typeof expected !== 'object')) {
  600. return strict ? actual === expected : actual == expected;
  601.  
  602. // If both values are instances of typed arrays, wrap their underlying
  603. // ArrayBuffers in a Buffer each to increase performance
  604. // This optimization requires the arrays to have the same type as checked by
  605. // Object.prototype.toString (aka pToString). Never perform binary
  606. // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
  607. // bit patterns are not identical.
  608. } else if (isView(actual) && isView(expected) &&
  609. pToString(actual) === pToString(expected) &&
  610. !(actual instanceof Float32Array ||
  611. actual instanceof Float64Array)) {
  612. return compare(new Uint8Array(actual.buffer),
  613. new Uint8Array(expected.buffer)) === 0;
  614.  
  615. // 7.5 For all other Object pairs, including Array objects, equivalence is
  616. // determined by having the same number of owned properties (as verified
  617. // with Object.prototype.hasOwnProperty.call), the same set of keys
  618. // (although not necessarily the same order), equivalent values for every
  619. // corresponding key, and an identical 'prototype' property. Note: this
  620. // accounts for both named and indexed properties on Arrays.
  621. } else if (isBuffer(actual) !== isBuffer(expected)) {
  622. return false;
  623. } else {
  624. memos = memos || {actual: [], expected: []};
  625.  
  626. var actualIndex = memos.actual.indexOf(actual);
  627. if (actualIndex !== -1) {
  628. if (actualIndex === memos.expected.indexOf(expected)) {
  629. return true;
  630. }
  631. }
  632.  
  633. memos.actual.push(actual);
  634. memos.expected.push(expected);
  635.  
  636. return objEquiv(actual, expected, strict, memos);
  637. }
  638. }
  639.  
  640. function isArguments(object) {
  641. return Object.prototype.toString.call(object) == '[object Arguments]';
  642. }
  643.  
  644. function objEquiv(a, b, strict, actualVisitedObjects) {
  645. if (a === null || a === undefined || b === null || b === undefined)
  646. return false;
  647. // if one is a primitive, the other must be same
  648. if (util.isPrimitive(a) || util.isPrimitive(b))
  649. return a === b;
  650. if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
  651. return false;
  652. var aIsArgs = isArguments(a);
  653. var bIsArgs = isArguments(b);
  654. if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
  655. return false;
  656. if (aIsArgs) {
  657. a = pSlice.call(a);
  658. b = pSlice.call(b);
  659. return _deepEqual(a, b, strict);
  660. }
  661. var ka = objectKeys(a);
  662. var kb = objectKeys(b);
  663. var key, i;
  664. // having the same number of owned properties (keys incorporates
  665. // hasOwnProperty)
  666. if (ka.length !== kb.length)
  667. return false;
  668. //the same set of keys (although not necessarily the same order),
  669. ka.sort();
  670. kb.sort();
  671. //~~~cheap key test
  672. for (i = ka.length - 1; i >= 0; i--) {
  673. if (ka[i] !== kb[i])
  674. return false;
  675. }
  676. //equivalent values for every corresponding key, and
  677. //~~~possibly expensive deep test
  678. for (i = ka.length - 1; i >= 0; i--) {
  679. key = ka[i];
  680. if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
  681. return false;
  682. }
  683. return true;
  684. }
  685.  
  686. // 8. The non-equivalence assertion tests for any deep inequality.
  687. // assert.notDeepEqual(actual, expected, message_opt);
  688.  
  689. assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
  690. if (_deepEqual(actual, expected, false)) {
  691. fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
  692. }
  693. };
  694.  
  695. assert.notDeepStrictEqual = notDeepStrictEqual;
  696. function notDeepStrictEqual(actual, expected, message) {
  697. if (_deepEqual(actual, expected, true)) {
  698. fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
  699. }
  700. }
  701.  
  702.  
  703. // 9. The strict equality assertion tests strict equality, as determined by ===.
  704. // assert.strictEqual(actual, expected, message_opt);
  705.  
  706. assert.strictEqual = function strictEqual(actual, expected, message) {
  707. if (actual !== expected) {
  708. fail(actual, expected, message, '===', assert.strictEqual);
  709. }
  710. };
  711.  
  712. // 10. The strict non-equality assertion tests for strict inequality, as
  713. // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
  714.  
  715. assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
  716. if (actual === expected) {
  717. fail(actual, expected, message, '!==', assert.notStrictEqual);
  718. }
  719. };
  720.  
  721. function expectedException(actual, expected) {
  722. if (!actual || !expected) {
  723. return false;
  724. }
  725.  
  726. if (Object.prototype.toString.call(expected) == '[object RegExp]') {
  727. return expected.test(actual);
  728. }
  729.  
  730. try {
  731. if (actual instanceof expected) {
  732. return true;
  733. }
  734. } catch (e) {
  735. // Ignore. The instanceof check doesn't work for arrow functions.
  736. }
  737.  
  738. if (Error.isPrototypeOf(expected)) {
  739. return false;
  740. }
  741.  
  742. return expected.call({}, actual) === true;
  743. }
  744.  
  745. function _tryBlock(block) {
  746. var error;
  747. try {
  748. block();
  749. } catch (e) {
  750. error = e;
  751. }
  752. return error;
  753. }
  754.  
  755. function _throws(shouldThrow, block, expected, message) {
  756. var actual;
  757.  
  758. if (typeof block !== 'function') {
  759. throw new TypeError('"block" argument must be a function');
  760. }
  761.  
  762. if (typeof expected === 'string') {
  763. message = expected;
  764. expected = null;
  765. }
  766.  
  767. actual = _tryBlock(block);
  768.  
  769. message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
  770. (message ? ' ' + message : '.');
  771.  
  772. if (shouldThrow && !actual) {
  773. fail(actual, expected, 'Missing expected exception' + message);
  774. }
  775.  
  776. var userProvidedMessage = typeof message === 'string';
  777. var isUnwantedException = !shouldThrow && util.isError(actual);
  778. var isUnexpectedException = !shouldThrow && actual && !expected;
  779.  
  780. if ((isUnwantedException &&
  781. userProvidedMessage &&
  782. expectedException(actual, expected)) ||
  783. isUnexpectedException) {
  784. fail(actual, expected, 'Got unwanted exception' + message);
  785. }
  786.  
  787. if ((shouldThrow && actual && expected &&
  788. !expectedException(actual, expected)) || (!shouldThrow && actual)) {
  789. throw actual;
  790. }
  791. }
  792.  
  793. // 11. Expected to throw an error:
  794. // assert.throws(block, Error_opt, message_opt);
  795.  
  796. assert.throws = function(block, /*optional*/error, /*optional*/message) {
  797. _throws(true, block, error, message);
  798. };
  799.  
  800. // EXTENSION! This is annoying to write outside this module.
  801. assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
  802. _throws(false, block, error, message);
  803. };
  804.  
  805. assert.ifError = function(err) { if (err) throw err; };
  806.  
  807. // Expose a strict only variant of assert
  808. function strict(value, message) {
  809. if (!value) fail(value, true, message, '==', strict);
  810. }
  811. assert.strict = objectAssign(strict, assert, {
  812. equal: assert.strictEqual,
  813. deepEqual: assert.deepStrictEqual,
  814. notEqual: assert.notStrictEqual,
  815. notDeepEqual: assert.notDeepStrictEqual
  816. });
  817. assert.strict.strict = assert.strict;
  818.  
  819. var objectKeys = Object.keys || function (obj) {
  820. var keys = [];
  821. for (var key in obj) {
  822. if (hasOwn.call(obj, key)) keys.push(key);
  823. }
  824. return keys;
  825. };
  826.  
  827. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__("yLpj")))
  828.  
  829. /***/ }),
  830.  
  831. /***/ "Ekho":
  832. /***/ (function(module, exports, __webpack_require__) {
  833.  
  834. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Generated by CoffeeScript 1.8.0
  835. (function() {
  836. var Heap, defaultCmp, floor, heapify, heappop, heappush, heappushpop, heapreplace, insort, min, nlargest, nsmallest, updateItem, _siftdown, _siftup;
  837.  
  838. floor = Math.floor, min = Math.min;
  839.  
  840.  
  841. /*
  842. Default comparison function to be used
  843. */
  844.  
  845. defaultCmp = function(x, y) {
  846. if (x < y) {
  847. return -1;
  848. }
  849. if (x > y) {
  850. return 1;
  851. }
  852. return 0;
  853. };
  854.  
  855.  
  856. /*
  857. Insert item x in list a, and keep it sorted assuming a is sorted.
  858. If x is already in a, insert it to the right of the rightmost x.
  859. Optional args lo (default 0) and hi (default a.length) bound the slice
  860. of a to be searched.
  861. */
  862.  
  863. insort = function(a, x, lo, hi, cmp) {
  864. var mid;
  865. if (lo == null) {
  866. lo = 0;
  867. }
  868. if (cmp == null) {
  869. cmp = defaultCmp;
  870. }
  871. if (lo < 0) {
  872. throw new Error('lo must be non-negative');
  873. }
  874. if (hi == null) {
  875. hi = a.length;
  876. }
  877. while (lo < hi) {
  878. mid = floor((lo + hi) / 2);
  879. if (cmp(x, a[mid]) < 0) {
  880. hi = mid;
  881. } else {
  882. lo = mid + 1;
  883. }
  884. }
  885. return ([].splice.apply(a, [lo, lo - lo].concat(x)), x);
  886. };
  887.  
  888.  
  889. /*
  890. Push item onto heap, maintaining the heap invariant.
  891. */
  892.  
  893. heappush = function(array, item, cmp) {
  894. if (cmp == null) {
  895. cmp = defaultCmp;
  896. }
  897. array.push(item);
  898. return _siftdown(array, 0, array.length - 1, cmp);
  899. };
  900.  
  901.  
  902. /*
  903. Pop the smallest item off the heap, maintaining the heap invariant.
  904. */
  905.  
  906. heappop = function(array, cmp) {
  907. var lastelt, returnitem;
  908. if (cmp == null) {
  909. cmp = defaultCmp;
  910. }
  911. lastelt = array.pop();
  912. if (array.length) {
  913. returnitem = array[0];
  914. array[0] = lastelt;
  915. _siftup(array, 0, cmp);
  916. } else {
  917. returnitem = lastelt;
  918. }
  919. return returnitem;
  920. };
  921.  
  922.  
  923. /*
  924. Pop and return the current smallest value, and add the new item.
  925. This is more efficient than heappop() followed by heappush(), and can be
  926. more appropriate when using a fixed size heap. Note that the value
  927. returned may be larger than item! That constrains reasonable use of
  928. this routine unless written as part of a conditional replacement:
  929. if item > array[0]
  930. item = heapreplace(array, item)
  931. */
  932.  
  933. heapreplace = function(array, item, cmp) {
  934. var returnitem;
  935. if (cmp == null) {
  936. cmp = defaultCmp;
  937. }
  938. returnitem = array[0];
  939. array[0] = item;
  940. _siftup(array, 0, cmp);
  941. return returnitem;
  942. };
  943.  
  944.  
  945. /*
  946. Fast version of a heappush followed by a heappop.
  947. */
  948.  
  949. heappushpop = function(array, item, cmp) {
  950. var _ref;
  951. if (cmp == null) {
  952. cmp = defaultCmp;
  953. }
  954. if (array.length && cmp(array[0], item) < 0) {
  955. _ref = [array[0], item], item = _ref[0], array[0] = _ref[1];
  956. _siftup(array, 0, cmp);
  957. }
  958. return item;
  959. };
  960.  
  961.  
  962. /*
  963. Transform list into a heap, in-place, in O(array.length) time.
  964. */
  965.  
  966. heapify = function(array, cmp) {
  967. var i, _i, _j, _len, _ref, _ref1, _results, _results1;
  968. if (cmp == null) {
  969. cmp = defaultCmp;
  970. }
  971. _ref1 = (function() {
  972. _results1 = [];
  973. for (var _j = 0, _ref = floor(array.length / 2); 0 <= _ref ? _j < _ref : _j > _ref; 0 <= _ref ? _j++ : _j--){ _results1.push(_j); }
  974. return _results1;
  975. }).apply(this).reverse();
  976. _results = [];
  977. for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
  978. i = _ref1[_i];
  979. _results.push(_siftup(array, i, cmp));
  980. }
  981. return _results;
  982. };
  983.  
  984.  
  985. /*
  986. Update the position of the given item in the heap.
  987. This function should be called every time the item is being modified.
  988. */
  989.  
  990. updateItem = function(array, item, cmp) {
  991. var pos;
  992. if (cmp == null) {
  993. cmp = defaultCmp;
  994. }
  995. pos = array.indexOf(item);
  996. if (pos === -1) {
  997. return;
  998. }
  999. _siftdown(array, 0, pos, cmp);
  1000. return _siftup(array, pos, cmp);
  1001. };
  1002.  
  1003.  
  1004. /*
  1005. Find the n largest elements in a dataset.
  1006. */
  1007.  
  1008. nlargest = function(array, n, cmp) {
  1009. var elem, result, _i, _len, _ref;
  1010. if (cmp == null) {
  1011. cmp = defaultCmp;
  1012. }
  1013. result = array.slice(0, n);
  1014. if (!result.length) {
  1015. return result;
  1016. }
  1017. heapify(result, cmp);
  1018. _ref = array.slice(n);
  1019. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  1020. elem = _ref[_i];
  1021. heappushpop(result, elem, cmp);
  1022. }
  1023. return result.sort(cmp).reverse();
  1024. };
  1025.  
  1026.  
  1027. /*
  1028. Find the n smallest elements in a dataset.
  1029. */
  1030.  
  1031. nsmallest = function(array, n, cmp) {
  1032. var elem, i, los, result, _i, _j, _len, _ref, _ref1, _results;
  1033. if (cmp == null) {
  1034. cmp = defaultCmp;
  1035. }
  1036. if (n * 10 <= array.length) {
  1037. result = array.slice(0, n).sort(cmp);
  1038. if (!result.length) {
  1039. return result;
  1040. }
  1041. los = result[result.length - 1];
  1042. _ref = array.slice(n);
  1043. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  1044. elem = _ref[_i];
  1045. if (cmp(elem, los) < 0) {
  1046. insort(result, elem, 0, null, cmp);
  1047. result.pop();
  1048. los = result[result.length - 1];
  1049. }
  1050. }
  1051. return result;
  1052. }
  1053. heapify(array, cmp);
  1054. _results = [];
  1055. for (i = _j = 0, _ref1 = min(n, array.length); 0 <= _ref1 ? _j < _ref1 : _j > _ref1; i = 0 <= _ref1 ? ++_j : --_j) {
  1056. _results.push(heappop(array, cmp));
  1057. }
  1058. return _results;
  1059. };
  1060.  
  1061. _siftdown = function(array, startpos, pos, cmp) {
  1062. var newitem, parent, parentpos;
  1063. if (cmp == null) {
  1064. cmp = defaultCmp;
  1065. }
  1066. newitem = array[pos];
  1067. while (pos > startpos) {
  1068. parentpos = (pos - 1) >> 1;
  1069. parent = array[parentpos];
  1070. if (cmp(newitem, parent) < 0) {
  1071. array[pos] = parent;
  1072. pos = parentpos;
  1073. continue;
  1074. }
  1075. break;
  1076. }
  1077. return array[pos] = newitem;
  1078. };
  1079.  
  1080. _siftup = function(array, pos, cmp) {
  1081. var childpos, endpos, newitem, rightpos, startpos;
  1082. if (cmp == null) {
  1083. cmp = defaultCmp;
  1084. }
  1085. endpos = array.length;
  1086. startpos = pos;
  1087. newitem = array[pos];
  1088. childpos = 2 * pos + 1;
  1089. while (childpos < endpos) {
  1090. rightpos = childpos + 1;
  1091. if (rightpos < endpos && !(cmp(array[childpos], array[rightpos]) < 0)) {
  1092. childpos = rightpos;
  1093. }
  1094. array[pos] = array[childpos];
  1095. pos = childpos;
  1096. childpos = 2 * pos + 1;
  1097. }
  1098. array[pos] = newitem;
  1099. return _siftdown(array, startpos, pos, cmp);
  1100. };
  1101.  
  1102. Heap = (function() {
  1103. Heap.push = heappush;
  1104.  
  1105. Heap.pop = heappop;
  1106.  
  1107. Heap.replace = heapreplace;
  1108.  
  1109. Heap.pushpop = heappushpop;
  1110.  
  1111. Heap.heapify = heapify;
  1112.  
  1113. Heap.updateItem = updateItem;
  1114.  
  1115. Heap.nlargest = nlargest;
  1116.  
  1117. Heap.nsmallest = nsmallest;
  1118.  
  1119. function Heap(cmp) {
  1120. this.cmp = cmp != null ? cmp : defaultCmp;
  1121. this.nodes = [];
  1122. }
  1123.  
  1124. Heap.prototype.push = function(x) {
  1125. return heappush(this.nodes, x, this.cmp);
  1126. };
  1127.  
  1128. Heap.prototype.pop = function() {
  1129. return heappop(this.nodes, this.cmp);
  1130. };
  1131.  
  1132. Heap.prototype.peek = function() {
  1133. return this.nodes[0];
  1134. };
  1135.  
  1136. Heap.prototype.contains = function(x) {
  1137. return this.nodes.indexOf(x) !== -1;
  1138. };
  1139.  
  1140. Heap.prototype.replace = function(x) {
  1141. return heapreplace(this.nodes, x, this.cmp);
  1142. };
  1143.  
  1144. Heap.prototype.pushpop = function(x) {
  1145. return heappushpop(this.nodes, x, this.cmp);
  1146. };
  1147.  
  1148. Heap.prototype.heapify = function() {
  1149. return heapify(this.nodes, this.cmp);
  1150. };
  1151.  
  1152. Heap.prototype.updateItem = function(x) {
  1153. return updateItem(this.nodes, x, this.cmp);
  1154. };
  1155.  
  1156. Heap.prototype.clear = function() {
  1157. return this.nodes = [];
  1158. };
  1159.  
  1160. Heap.prototype.empty = function() {
  1161. return this.nodes.length === 0;
  1162. };
  1163.  
  1164. Heap.prototype.size = function() {
  1165. return this.nodes.length;
  1166. };
  1167.  
  1168. Heap.prototype.clone = function() {
  1169. var heap;
  1170. heap = new Heap();
  1171. heap.nodes = this.nodes.slice(0);
  1172. return heap;
  1173. };
  1174.  
  1175. Heap.prototype.toArray = function() {
  1176. return this.nodes.slice(0);
  1177. };
  1178.  
  1179. Heap.prototype.insert = Heap.prototype.push;
  1180.  
  1181. Heap.prototype.top = Heap.prototype.peek;
  1182.  
  1183. Heap.prototype.front = Heap.prototype.peek;
  1184.  
  1185. Heap.prototype.has = Heap.prototype.contains;
  1186.  
  1187. Heap.prototype.copy = Heap.prototype.clone;
  1188.  
  1189. return Heap;
  1190.  
  1191. })();
  1192.  
  1193. (function(root, factory) {
  1194. if (true) {
  1195. return !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
  1196. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  1197. (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
  1198. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  1199. } else {}
  1200. })(this, function() {
  1201. return Heap;
  1202. });
  1203.  
  1204. }).call(this);
  1205.  
  1206.  
  1207. /***/ }),
  1208.  
  1209. /***/ "F1pL":
  1210. /***/ (function(module, exports, __webpack_require__) {
  1211.  
  1212. module.exports = __webpack_require__("Ekho");
  1213.  
  1214.  
  1215. /***/ }),
  1216.  
  1217. /***/ "KKCa":
  1218. /***/ (function(module, exports) {
  1219.  
  1220. if (typeof Object.create === 'function') {
  1221. // implementation from standard node.js 'util' module
  1222. module.exports = function inherits(ctor, superCtor) {
  1223. ctor.super_ = superCtor
  1224. ctor.prototype = Object.create(superCtor.prototype, {
  1225. constructor: {
  1226. value: ctor,
  1227. enumerable: false,
  1228. writable: true,
  1229. configurable: true
  1230. }
  1231. });
  1232. };
  1233. } else {
  1234. // old school shim for old browsers
  1235. module.exports = function inherits(ctor, superCtor) {
  1236. ctor.super_ = superCtor
  1237. var TempCtor = function () {}
  1238. TempCtor.prototype = superCtor.prototype
  1239. ctor.prototype = new TempCtor()
  1240. ctor.prototype.constructor = ctor
  1241. }
  1242. }
  1243.  
  1244.  
  1245. /***/ }),
  1246.  
  1247. /***/ "MCLT":
  1248. /***/ (function(module, exports, __webpack_require__) {
  1249.  
  1250. /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors.
  1251. //
  1252. // Permission is hereby granted, free of charge, to any person obtaining a
  1253. // copy of this software and associated documentation files (the
  1254. // "Software"), to deal in the Software without restriction, including
  1255. // without limitation the rights to use, copy, modify, merge, publish,
  1256. // distribute, sublicense, and/or sell copies of the Software, and to permit
  1257. // persons to whom the Software is furnished to do so, subject to the
  1258. // following conditions:
  1259. //
  1260. // The above copyright notice and this permission notice shall be included
  1261. // in all copies or substantial portions of the Software.
  1262. //
  1263. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  1264. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  1265. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  1266. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  1267. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  1268. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  1269. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  1270.  
  1271. var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors ||
  1272. function getOwnPropertyDescriptors(obj) {
  1273. var keys = Object.keys(obj);
  1274. var descriptors = {};
  1275. for (var i = 0; i < keys.length; i++) {
  1276. descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);
  1277. }
  1278. return descriptors;
  1279. };
  1280.  
  1281. var formatRegExp = /%[sdj%]/g;
  1282. exports.format = function(f) {
  1283. if (!isString(f)) {
  1284. var objects = [];
  1285. for (var i = 0; i < arguments.length; i++) {
  1286. objects.push(inspect(arguments[i]));
  1287. }
  1288. return objects.join(' ');
  1289. }
  1290.  
  1291. var i = 1;
  1292. var args = arguments;
  1293. var len = args.length;
  1294. var str = String(f).replace(formatRegExp, function(x) {
  1295. if (x === '%%') return '%';
  1296. if (i >= len) return x;
  1297. switch (x) {
  1298. case '%s': return String(args[i++]);
  1299. case '%d': return Number(args[i++]);
  1300. case '%j':
  1301. try {
  1302. return JSON.stringify(args[i++]);
  1303. } catch (_) {
  1304. return '[Circular]';
  1305. }
  1306. default:
  1307. return x;
  1308. }
  1309. });
  1310. for (var x = args[i]; i < len; x = args[++i]) {
  1311. if (isNull(x) || !isObject(x)) {
  1312. str += ' ' + x;
  1313. } else {
  1314. str += ' ' + inspect(x);
  1315. }
  1316. }
  1317. return str;
  1318. };
  1319.  
  1320.  
  1321. // Mark that a method should not be used.
  1322. // Returns a modified function which warns once by default.
  1323. // If --no-deprecation is set, then it is a no-op.
  1324. exports.deprecate = function(fn, msg) {
  1325. if (typeof process !== 'undefined' && process.noDeprecation === true) {
  1326. return fn;
  1327. }
  1328.  
  1329. // Allow for deprecating things in the process of starting up.
  1330. if (typeof process === 'undefined') {
  1331. return function() {
  1332. return exports.deprecate(fn, msg).apply(this, arguments);
  1333. };
  1334. }
  1335.  
  1336. var warned = false;
  1337. function deprecated() {
  1338. if (!warned) {
  1339. if (process.throwDeprecation) {
  1340. throw new Error(msg);
  1341. } else if (process.traceDeprecation) {
  1342. console.trace(msg);
  1343. } else {
  1344. console.error(msg);
  1345. }
  1346. warned = true;
  1347. }
  1348. return fn.apply(this, arguments);
  1349. }
  1350.  
  1351. return deprecated;
  1352. };
  1353.  
  1354.  
  1355. var debugs = {};
  1356. var debugEnviron;
  1357. exports.debuglog = function(set) {
  1358. if (isUndefined(debugEnviron))
  1359. debugEnviron = process.env.NODE_DEBUG || '';
  1360. set = set.toUpperCase();
  1361. if (!debugs[set]) {
  1362. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  1363. var pid = process.pid;
  1364. debugs[set] = function() {
  1365. var msg = exports.format.apply(exports, arguments);
  1366. console.error('%s %d: %s', set, pid, msg);
  1367. };
  1368. } else {
  1369. debugs[set] = function() {};
  1370. }
  1371. }
  1372. return debugs[set];
  1373. };
  1374.  
  1375.  
  1376. /**
  1377. * Echos the value of a value. Trys to print the value out
  1378. * in the best way possible given the different types.
  1379. *
  1380. * @param {Object} obj The object to print out.
  1381. * @param {Object} opts Optional options object that alters the output.
  1382. */
  1383. /* legacy: obj, showHidden, depth, colors*/
  1384. function inspect(obj, opts) {
  1385. // default options
  1386. var ctx = {
  1387. seen: [],
  1388. stylize: stylizeNoColor
  1389. };
  1390. // legacy...
  1391. if (arguments.length >= 3) ctx.depth = arguments[2];
  1392. if (arguments.length >= 4) ctx.colors = arguments[3];
  1393. if (isBoolean(opts)) {
  1394. // legacy...
  1395. ctx.showHidden = opts;
  1396. } else if (opts) {
  1397. // got an "options" object
  1398. exports._extend(ctx, opts);
  1399. }
  1400. // set default options
  1401. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  1402. if (isUndefined(ctx.depth)) ctx.depth = 2;
  1403. if (isUndefined(ctx.colors)) ctx.colors = false;
  1404. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  1405. if (ctx.colors) ctx.stylize = stylizeWithColor;
  1406. return formatValue(ctx, obj, ctx.depth);
  1407. }
  1408. exports.inspect = inspect;
  1409.  
  1410.  
  1411. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  1412. inspect.colors = {
  1413. 'bold' : [1, 22],
  1414. 'italic' : [3, 23],
  1415. 'underline' : [4, 24],
  1416. 'inverse' : [7, 27],
  1417. 'white' : [37, 39],
  1418. 'grey' : [90, 39],
  1419. 'black' : [30, 39],
  1420. 'blue' : [34, 39],
  1421. 'cyan' : [36, 39],
  1422. 'green' : [32, 39],
  1423. 'magenta' : [35, 39],
  1424. 'red' : [31, 39],
  1425. 'yellow' : [33, 39]
  1426. };
  1427.  
  1428. // Don't use 'blue' not visible on cmd.exe
  1429. inspect.styles = {
  1430. 'special': 'cyan',
  1431. 'number': 'yellow',
  1432. 'boolean': 'yellow',
  1433. 'undefined': 'grey',
  1434. 'null': 'bold',
  1435. 'string': 'green',
  1436. 'date': 'magenta',
  1437. // "name": intentionally not styling
  1438. 'regexp': 'red'
  1439. };
  1440.  
  1441.  
  1442. function stylizeWithColor(str, styleType) {
  1443. var style = inspect.styles[styleType];
  1444.  
  1445. if (style) {
  1446. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  1447. '\u001b[' + inspect.colors[style][1] + 'm';
  1448. } else {
  1449. return str;
  1450. }
  1451. }
  1452.  
  1453.  
  1454. function stylizeNoColor(str, styleType) {
  1455. return str;
  1456. }
  1457.  
  1458.  
  1459. function arrayToHash(array) {
  1460. var hash = {};
  1461.  
  1462. array.forEach(function(val, idx) {
  1463. hash[val] = true;
  1464. });
  1465.  
  1466. return hash;
  1467. }
  1468.  
  1469.  
  1470. function formatValue(ctx, value, recurseTimes) {
  1471. // Provide a hook for user-specified inspect functions.
  1472. // Check that value is an object with an inspect function on it
  1473. if (ctx.customInspect &&
  1474. value &&
  1475. isFunction(value.inspect) &&
  1476. // Filter out the util module, it's inspect function is special
  1477. value.inspect !== exports.inspect &&
  1478. // Also filter out any prototype objects using the circular check.
  1479. !(value.constructor && value.constructor.prototype === value)) {
  1480. var ret = value.inspect(recurseTimes, ctx);
  1481. if (!isString(ret)) {
  1482. ret = formatValue(ctx, ret, recurseTimes);
  1483. }
  1484. return ret;
  1485. }
  1486.  
  1487. // Primitive types cannot have properties
  1488. var primitive = formatPrimitive(ctx, value);
  1489. if (primitive) {
  1490. return primitive;
  1491. }
  1492.  
  1493. // Look up the keys of the object.
  1494. var keys = Object.keys(value);
  1495. var visibleKeys = arrayToHash(keys);
  1496.  
  1497. if (ctx.showHidden) {
  1498. keys = Object.getOwnPropertyNames(value);
  1499. }
  1500.  
  1501. // IE doesn't make error fields non-enumerable
  1502. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  1503. if (isError(value)
  1504. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  1505. return formatError(value);
  1506. }
  1507.  
  1508. // Some type of object without properties can be shortcutted.
  1509. if (keys.length === 0) {
  1510. if (isFunction(value)) {
  1511. var name = value.name ? ': ' + value.name : '';
  1512. return ctx.stylize('[Function' + name + ']', 'special');
  1513. }
  1514. if (isRegExp(value)) {
  1515. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  1516. }
  1517. if (isDate(value)) {
  1518. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  1519. }
  1520. if (isError(value)) {
  1521. return formatError(value);
  1522. }
  1523. }
  1524.  
  1525. var base = '', array = false, braces = ['{', '}'];
  1526.  
  1527. // Make Array say that they are Array
  1528. if (isArray(value)) {
  1529. array = true;
  1530. braces = ['[', ']'];
  1531. }
  1532.  
  1533. // Make functions say that they are functions
  1534. if (isFunction(value)) {
  1535. var n = value.name ? ': ' + value.name : '';
  1536. base = ' [Function' + n + ']';
  1537. }
  1538.  
  1539. // Make RegExps say that they are RegExps
  1540. if (isRegExp(value)) {
  1541. base = ' ' + RegExp.prototype.toString.call(value);
  1542. }
  1543.  
  1544. // Make dates with properties first say the date
  1545. if (isDate(value)) {
  1546. base = ' ' + Date.prototype.toUTCString.call(value);
  1547. }
  1548.  
  1549. // Make error with message first say the error
  1550. if (isError(value)) {
  1551. base = ' ' + formatError(value);
  1552. }
  1553.  
  1554. if (keys.length === 0 && (!array || value.length == 0)) {
  1555. return braces[0] + base + braces[1];
  1556. }
  1557.  
  1558. if (recurseTimes < 0) {
  1559. if (isRegExp(value)) {
  1560. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  1561. } else {
  1562. return ctx.stylize('[Object]', 'special');
  1563. }
  1564. }
  1565.  
  1566. ctx.seen.push(value);
  1567.  
  1568. var output;
  1569. if (array) {
  1570. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  1571. } else {
  1572. output = keys.map(function(key) {
  1573. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  1574. });
  1575. }
  1576.  
  1577. ctx.seen.pop();
  1578.  
  1579. return reduceToSingleString(output, base, braces);
  1580. }
  1581.  
  1582.  
  1583. function formatPrimitive(ctx, value) {
  1584. if (isUndefined(value))
  1585. return ctx.stylize('undefined', 'undefined');
  1586. if (isString(value)) {
  1587. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  1588. .replace(/'/g, "\\'")
  1589. .replace(/\\"/g, '"') + '\'';
  1590. return ctx.stylize(simple, 'string');
  1591. }
  1592. if (isNumber(value))
  1593. return ctx.stylize('' + value, 'number');
  1594. if (isBoolean(value))
  1595. return ctx.stylize('' + value, 'boolean');
  1596. // For some reason typeof null is "object", so special case here.
  1597. if (isNull(value))
  1598. return ctx.stylize('null', 'null');
  1599. }
  1600.  
  1601.  
  1602. function formatError(value) {
  1603. return '[' + Error.prototype.toString.call(value) + ']';
  1604. }
  1605.  
  1606.  
  1607. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  1608. var output = [];
  1609. for (var i = 0, l = value.length; i < l; ++i) {
  1610. if (hasOwnProperty(value, String(i))) {
  1611. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  1612. String(i), true));
  1613. } else {
  1614. output.push('');
  1615. }
  1616. }
  1617. keys.forEach(function(key) {
  1618. if (!key.match(/^\d+$/)) {
  1619. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  1620. key, true));
  1621. }
  1622. });
  1623. return output;
  1624. }
  1625.  
  1626.  
  1627. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  1628. var name, str, desc;
  1629. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  1630. if (desc.get) {
  1631. if (desc.set) {
  1632. str = ctx.stylize('[Getter/Setter]', 'special');
  1633. } else {
  1634. str = ctx.stylize('[Getter]', 'special');
  1635. }
  1636. } else {
  1637. if (desc.set) {
  1638. str = ctx.stylize('[Setter]', 'special');
  1639. }
  1640. }
  1641. if (!hasOwnProperty(visibleKeys, key)) {
  1642. name = '[' + key + ']';
  1643. }
  1644. if (!str) {
  1645. if (ctx.seen.indexOf(desc.value) < 0) {
  1646. if (isNull(recurseTimes)) {
  1647. str = formatValue(ctx, desc.value, null);
  1648. } else {
  1649. str = formatValue(ctx, desc.value, recurseTimes - 1);
  1650. }
  1651. if (str.indexOf('\n') > -1) {
  1652. if (array) {
  1653. str = str.split('\n').map(function(line) {
  1654. return ' ' + line;
  1655. }).join('\n').substr(2);
  1656. } else {
  1657. str = '\n' + str.split('\n').map(function(line) {
  1658. return ' ' + line;
  1659. }).join('\n');
  1660. }
  1661. }
  1662. } else {
  1663. str = ctx.stylize('[Circular]', 'special');
  1664. }
  1665. }
  1666. if (isUndefined(name)) {
  1667. if (array && key.match(/^\d+$/)) {
  1668. return str;
  1669. }
  1670. name = JSON.stringify('' + key);
  1671. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  1672. name = name.substr(1, name.length - 2);
  1673. name = ctx.stylize(name, 'name');
  1674. } else {
  1675. name = name.replace(/'/g, "\\'")
  1676. .replace(/\\"/g, '"')
  1677. .replace(/(^"|"$)/g, "'");
  1678. name = ctx.stylize(name, 'string');
  1679. }
  1680. }
  1681.  
  1682. return name + ': ' + str;
  1683. }
  1684.  
  1685.  
  1686. function reduceToSingleString(output, base, braces) {
  1687. var numLinesEst = 0;
  1688. var length = output.reduce(function(prev, cur) {
  1689. numLinesEst++;
  1690. if (cur.indexOf('\n') >= 0) numLinesEst++;
  1691. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  1692. }, 0);
  1693.  
  1694. if (length > 60) {
  1695. return braces[0] +
  1696. (base === '' ? '' : base + '\n ') +
  1697. ' ' +
  1698. output.join(',\n ') +
  1699. ' ' +
  1700. braces[1];
  1701. }
  1702.  
  1703. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  1704. }
  1705.  
  1706.  
  1707. // NOTE: These type checking functions intentionally don't use `instanceof`
  1708. // because it is fragile and can be easily faked with `Object.create()`.
  1709. function isArray(ar) {
  1710. return Array.isArray(ar);
  1711. }
  1712. exports.isArray = isArray;
  1713.  
  1714. function isBoolean(arg) {
  1715. return typeof arg === 'boolean';
  1716. }
  1717. exports.isBoolean = isBoolean;
  1718.  
  1719. function isNull(arg) {
  1720. return arg === null;
  1721. }
  1722. exports.isNull = isNull;
  1723.  
  1724. function isNullOrUndefined(arg) {
  1725. return arg == null;
  1726. }
  1727. exports.isNullOrUndefined = isNullOrUndefined;
  1728.  
  1729. function isNumber(arg) {
  1730. return typeof arg === 'number';
  1731. }
  1732. exports.isNumber = isNumber;
  1733.  
  1734. function isString(arg) {
  1735. return typeof arg === 'string';
  1736. }
  1737. exports.isString = isString;
  1738.  
  1739. function isSymbol(arg) {
  1740. return typeof arg === 'symbol';
  1741. }
  1742. exports.isSymbol = isSymbol;
  1743.  
  1744. function isUndefined(arg) {
  1745. return arg === void 0;
  1746. }
  1747. exports.isUndefined = isUndefined;
  1748.  
  1749. function isRegExp(re) {
  1750. return isObject(re) && objectToString(re) === '[object RegExp]';
  1751. }
  1752. exports.isRegExp = isRegExp;
  1753.  
  1754. function isObject(arg) {
  1755. return typeof arg === 'object' && arg !== null;
  1756. }
  1757. exports.isObject = isObject;
  1758.  
  1759. function isDate(d) {
  1760. return isObject(d) && objectToString(d) === '[object Date]';
  1761. }
  1762. exports.isDate = isDate;
  1763.  
  1764. function isError(e) {
  1765. return isObject(e) &&
  1766. (objectToString(e) === '[object Error]' || e instanceof Error);
  1767. }
  1768. exports.isError = isError;
  1769.  
  1770. function isFunction(arg) {
  1771. return typeof arg === 'function';
  1772. }
  1773. exports.isFunction = isFunction;
  1774.  
  1775. function isPrimitive(arg) {
  1776. return arg === null ||
  1777. typeof arg === 'boolean' ||
  1778. typeof arg === 'number' ||
  1779. typeof arg === 'string' ||
  1780. typeof arg === 'symbol' || // ES6 symbol
  1781. typeof arg === 'undefined';
  1782. }
  1783. exports.isPrimitive = isPrimitive;
  1784.  
  1785. exports.isBuffer = __webpack_require__("1gqn");
  1786.  
  1787. function objectToString(o) {
  1788. return Object.prototype.toString.call(o);
  1789. }
  1790.  
  1791.  
  1792. function pad(n) {
  1793. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  1794. }
  1795.  
  1796.  
  1797. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  1798. 'Oct', 'Nov', 'Dec'];
  1799.  
  1800. // 26 Feb 16:19:34
  1801. function timestamp() {
  1802. var d = new Date();
  1803. var time = [pad(d.getHours()),
  1804. pad(d.getMinutes()),
  1805. pad(d.getSeconds())].join(':');
  1806. return [d.getDate(), months[d.getMonth()], time].join(' ');
  1807. }
  1808.  
  1809.  
  1810. // log is just a thin wrapper to console.log that prepends a timestamp
  1811. exports.log = function() {
  1812. console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  1813. };
  1814.  
  1815.  
  1816. /**
  1817. * Inherit the prototype methods from one constructor into another.
  1818. *
  1819. * The Function.prototype.inherits from lang.js rewritten as a standalone
  1820. * function (not on Function.prototype). NOTE: If this file is to be loaded
  1821. * during bootstrapping this function needs to be rewritten using some native
  1822. * functions as prototype setup using normal JavaScript does not work as
  1823. * expected during bootstrapping (see mirror.js in r114903).
  1824. *
  1825. * @param {function} ctor Constructor function which needs to inherit the
  1826. * prototype.
  1827. * @param {function} superCtor Constructor function to inherit prototype from.
  1828. */
  1829. exports.inherits = __webpack_require__("KKCa");
  1830.  
  1831. exports._extend = function(origin, add) {
  1832. // Don't do anything if add isn't an object
  1833. if (!add || !isObject(add)) return origin;
  1834.  
  1835. var keys = Object.keys(add);
  1836. var i = keys.length;
  1837. while (i--) {
  1838. origin[keys[i]] = add[keys[i]];
  1839. }
  1840. return origin;
  1841. };
  1842.  
  1843. function hasOwnProperty(obj, prop) {
  1844. return Object.prototype.hasOwnProperty.call(obj, prop);
  1845. }
  1846.  
  1847. var kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined;
  1848.  
  1849. exports.promisify = function promisify(original) {
  1850. if (typeof original !== 'function')
  1851. throw new TypeError('The "original" argument must be of type Function');
  1852.  
  1853. if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
  1854. var fn = original[kCustomPromisifiedSymbol];
  1855. if (typeof fn !== 'function') {
  1856. throw new TypeError('The "util.promisify.custom" argument must be of type Function');
  1857. }
  1858. Object.defineProperty(fn, kCustomPromisifiedSymbol, {
  1859. value: fn, enumerable: false, writable: false, configurable: true
  1860. });
  1861. return fn;
  1862. }
  1863.  
  1864. function fn() {
  1865. var promiseResolve, promiseReject;
  1866. var promise = new Promise(function (resolve, reject) {
  1867. promiseResolve = resolve;
  1868. promiseReject = reject;
  1869. });
  1870.  
  1871. var args = [];
  1872. for (var i = 0; i < arguments.length; i++) {
  1873. args.push(arguments[i]);
  1874. }
  1875. args.push(function (err, value) {
  1876. if (err) {
  1877. promiseReject(err);
  1878. } else {
  1879. promiseResolve(value);
  1880. }
  1881. });
  1882.  
  1883. try {
  1884. original.apply(this, args);
  1885. } catch (err) {
  1886. promiseReject(err);
  1887. }
  1888.  
  1889. return promise;
  1890. }
  1891.  
  1892. Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
  1893.  
  1894. if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {
  1895. value: fn, enumerable: false, writable: false, configurable: true
  1896. });
  1897. return Object.defineProperties(
  1898. fn,
  1899. getOwnPropertyDescriptors(original)
  1900. );
  1901. }
  1902.  
  1903. exports.promisify.custom = kCustomPromisifiedSymbol
  1904.  
  1905. function callbackifyOnRejected(reason, cb) {
  1906. // `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M).
  1907. // Because `null` is a special error value in callbacks which means "no error
  1908. // occurred", we error-wrap so the callback consumer can distinguish between
  1909. // "the promise rejected with null" or "the promise fulfilled with undefined".
  1910. if (!reason) {
  1911. var newReason = new Error('Promise was rejected with a falsy value');
  1912. newReason.reason = reason;
  1913. reason = newReason;
  1914. }
  1915. return cb(reason);
  1916. }
  1917.  
  1918. function callbackify(original) {
  1919. if (typeof original !== 'function') {
  1920. throw new TypeError('The "original" argument must be of type Function');
  1921. }
  1922.  
  1923. // We DO NOT return the promise as it gives the user a false sense that
  1924. // the promise is actually somehow related to the callback's execution
  1925. // and that the callback throwing will reject the promise.
  1926. function callbackified() {
  1927. var args = [];
  1928. for (var i = 0; i < arguments.length; i++) {
  1929. args.push(arguments[i]);
  1930. }
  1931.  
  1932. var maybeCb = args.pop();
  1933. if (typeof maybeCb !== 'function') {
  1934. throw new TypeError('The last argument must be of type Function');
  1935. }
  1936. var self = this;
  1937. var cb = function() {
  1938. return maybeCb.apply(self, arguments);
  1939. };
  1940. // In true node style we process the callback on `nextTick` with all the
  1941. // implications (stack, `uncaughtException`, `async_hooks`)
  1942. original.apply(this, args)
  1943. .then(function(ret) { process.nextTick(cb, null, ret) },
  1944. function(rej) { process.nextTick(callbackifyOnRejected, rej, cb) });
  1945. }
  1946.  
  1947. Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original));
  1948. Object.defineProperties(callbackified,
  1949. getOwnPropertyDescriptors(original));
  1950. return callbackified;
  1951. }
  1952. exports.callbackify = callbackify;
  1953.  
  1954. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__("8oxB")))
  1955.  
  1956. /***/ }),
  1957.  
  1958. /***/ "MgzW":
  1959. /***/ (function(module, exports, __webpack_require__) {
  1960.  
  1961. "use strict";
  1962. /*
  1963. object-assign
  1964. (c) Sindre Sorhus
  1965. @license MIT
  1966. */
  1967.  
  1968.  
  1969. /* eslint-disable no-unused-vars */
  1970. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  1971. var hasOwnProperty = Object.prototype.hasOwnProperty;
  1972. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  1973.  
  1974. function toObject(val) {
  1975. if (val === null || val === undefined) {
  1976. throw new TypeError('Object.assign cannot be called with null or undefined');
  1977. }
  1978.  
  1979. return Object(val);
  1980. }
  1981.  
  1982. function shouldUseNative() {
  1983. try {
  1984. if (!Object.assign) {
  1985. return false;
  1986. }
  1987.  
  1988. // Detect buggy property enumeration order in older V8 versions.
  1989.  
  1990. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  1991. var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
  1992. test1[5] = 'de';
  1993. if (Object.getOwnPropertyNames(test1)[0] === '5') {
  1994. return false;
  1995. }
  1996.  
  1997. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  1998. var test2 = {};
  1999. for (var i = 0; i < 10; i++) {
  2000. test2['_' + String.fromCharCode(i)] = i;
  2001. }
  2002. var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
  2003. return test2[n];
  2004. });
  2005. if (order2.join('') !== '0123456789') {
  2006. return false;
  2007. }
  2008.  
  2009. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  2010. var test3 = {};
  2011. 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
  2012. test3[letter] = letter;
  2013. });
  2014. if (Object.keys(Object.assign({}, test3)).join('') !==
  2015. 'abcdefghijklmnopqrst') {
  2016. return false;
  2017. }
  2018.  
  2019. return true;
  2020. } catch (err) {
  2021. // We don't expect any of the above to throw, but better to be safe.
  2022. return false;
  2023. }
  2024. }
  2025.  
  2026. module.exports = shouldUseNative() ? Object.assign : function (target, source) {
  2027. var from;
  2028. var to = toObject(target);
  2029. var symbols;
  2030.  
  2031. for (var s = 1; s < arguments.length; s++) {
  2032. from = Object(arguments[s]);
  2033.  
  2034. for (var key in from) {
  2035. if (hasOwnProperty.call(from, key)) {
  2036. to[key] = from[key];
  2037. }
  2038. }
  2039.  
  2040. if (getOwnPropertySymbols) {
  2041. symbols = getOwnPropertySymbols(from);
  2042. for (var i = 0; i < symbols.length; i++) {
  2043. if (propIsEnumerable.call(from, symbols[i])) {
  2044. to[symbols[i]] = from[symbols[i]];
  2045. }
  2046. }
  2047. }
  2048. }
  2049.  
  2050. return to;
  2051. };
  2052.  
  2053.  
  2054. /***/ }),
  2055.  
  2056. /***/ "PKsF":
  2057. /***/ (function(module, exports, __webpack_require__) {
  2058.  
  2059. /*
  2060. * Copyright 2011 Twitter, Inc.
  2061. * Licensed under the Apache License, Version 2.0 (the "License");
  2062. * you may not use this file except in compliance with the License.
  2063. * You may obtain a copy of the License at
  2064. *
  2065. * http://www.apache.org/licenses/LICENSE-2.0
  2066. *
  2067. * Unless required by applicable law or agreed to in writing, software
  2068. * distributed under the License is distributed on an "AS IS" BASIS,
  2069. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  2070. * See the License for the specific language governing permissions and
  2071. * limitations under the License.
  2072. */
  2073.  
  2074. (function (Hogan) {
  2075. // Setup regex assignments
  2076. // remove whitespace according to Mustache spec
  2077. var rIsWhitespace = /\S/,
  2078. rQuot = /\"/g,
  2079. rNewline = /\n/g,
  2080. rCr = /\r/g,
  2081. rSlash = /\\/g,
  2082. rLineSep = /\u2028/,
  2083. rParagraphSep = /\u2029/;
  2084.  
  2085. Hogan.tags = {
  2086. '#': 1, '^': 2, '<': 3, '$': 4,
  2087. '/': 5, '!': 6, '>': 7, '=': 8, '_v': 9,
  2088. '{': 10, '&': 11, '_t': 12
  2089. };
  2090.  
  2091. Hogan.scan = function scan(text, delimiters) {
  2092. var len = text.length,
  2093. IN_TEXT = 0,
  2094. IN_TAG_TYPE = 1,
  2095. IN_TAG = 2,
  2096. state = IN_TEXT,
  2097. tagType = null,
  2098. tag = null,
  2099. buf = '',
  2100. tokens = [],
  2101. seenTag = false,
  2102. i = 0,
  2103. lineStart = 0,
  2104. otag = '{{',
  2105. ctag = '}}';
  2106.  
  2107. function addBuf() {
  2108. if (buf.length > 0) {
  2109. tokens.push({tag: '_t', text: new String(buf)});
  2110. buf = '';
  2111. }
  2112. }
  2113.  
  2114. function lineIsWhitespace() {
  2115. var isAllWhitespace = true;
  2116. for (var j = lineStart; j < tokens.length; j++) {
  2117. isAllWhitespace =
  2118. (Hogan.tags[tokens[j].tag] < Hogan.tags['_v']) ||
  2119. (tokens[j].tag == '_t' && tokens[j].text.match(rIsWhitespace) === null);
  2120. if (!isAllWhitespace) {
  2121. return false;
  2122. }
  2123. }
  2124.  
  2125. return isAllWhitespace;
  2126. }
  2127.  
  2128. function filterLine(haveSeenTag, noNewLine) {
  2129. addBuf();
  2130.  
  2131. if (haveSeenTag && lineIsWhitespace()) {
  2132. for (var j = lineStart, next; j < tokens.length; j++) {
  2133. if (tokens[j].text) {
  2134. if ((next = tokens[j+1]) && next.tag == '>') {
  2135. // set indent to token value
  2136. next.indent = tokens[j].text.toString()
  2137. }
  2138. tokens.splice(j, 1);
  2139. }
  2140. }
  2141. } else if (!noNewLine) {
  2142. tokens.push({tag:'\n'});
  2143. }
  2144.  
  2145. seenTag = false;
  2146. lineStart = tokens.length;
  2147. }
  2148.  
  2149. function changeDelimiters(text, index) {
  2150. var close = '=' + ctag,
  2151. closeIndex = text.indexOf(close, index),
  2152. delimiters = trim(
  2153. text.substring(text.indexOf('=', index) + 1, closeIndex)
  2154. ).split(' ');
  2155.  
  2156. otag = delimiters[0];
  2157. ctag = delimiters[delimiters.length - 1];
  2158.  
  2159. return closeIndex + close.length - 1;
  2160. }
  2161.  
  2162. if (delimiters) {
  2163. delimiters = delimiters.split(' ');
  2164. otag = delimiters[0];
  2165. ctag = delimiters[1];
  2166. }
  2167.  
  2168. for (i = 0; i < len; i++) {
  2169. if (state == IN_TEXT) {
  2170. if (tagChange(otag, text, i)) {
  2171. --i;
  2172. addBuf();
  2173. state = IN_TAG_TYPE;
  2174. } else {
  2175. if (text.charAt(i) == '\n') {
  2176. filterLine(seenTag);
  2177. } else {
  2178. buf += text.charAt(i);
  2179. }
  2180. }
  2181. } else if (state == IN_TAG_TYPE) {
  2182. i += otag.length - 1;
  2183. tag = Hogan.tags[text.charAt(i + 1)];
  2184. tagType = tag ? text.charAt(i + 1) : '_v';
  2185. if (tagType == '=') {
  2186. i = changeDelimiters(text, i);
  2187. state = IN_TEXT;
  2188. } else {
  2189. if (tag) {
  2190. i++;
  2191. }
  2192. state = IN_TAG;
  2193. }
  2194. seenTag = i;
  2195. } else {
  2196. if (tagChange(ctag, text, i)) {
  2197. tokens.push({tag: tagType, n: trim(buf), otag: otag, ctag: ctag,
  2198. i: (tagType == '/') ? seenTag - otag.length : i + ctag.length});
  2199. buf = '';
  2200. i += ctag.length - 1;
  2201. state = IN_TEXT;
  2202. if (tagType == '{') {
  2203. if (ctag == '}}') {
  2204. i++;
  2205. } else {
  2206. cleanTripleStache(tokens[tokens.length - 1]);
  2207. }
  2208. }
  2209. } else {
  2210. buf += text.charAt(i);
  2211. }
  2212. }
  2213. }
  2214.  
  2215. filterLine(seenTag, true);
  2216.  
  2217. return tokens;
  2218. }
  2219.  
  2220. function cleanTripleStache(token) {
  2221. if (token.n.substr(token.n.length - 1) === '}') {
  2222. token.n = token.n.substring(0, token.n.length - 1);
  2223. }
  2224. }
  2225.  
  2226. function trim(s) {
  2227. if (s.trim) {
  2228. return s.trim();
  2229. }
  2230.  
  2231. return s.replace(/^\s*|\s*$/g, '');
  2232. }
  2233.  
  2234. function tagChange(tag, text, index) {
  2235. if (text.charAt(index) != tag.charAt(0)) {
  2236. return false;
  2237. }
  2238.  
  2239. for (var i = 1, l = tag.length; i < l; i++) {
  2240. if (text.charAt(index + i) != tag.charAt(i)) {
  2241. return false;
  2242. }
  2243. }
  2244.  
  2245. return true;
  2246. }
  2247.  
  2248. // the tags allowed inside super templates
  2249. var allowedInSuper = {'_t': true, '\n': true, '$': true, '/': true};
  2250.  
  2251. function buildTree(tokens, kind, stack, customTags) {
  2252. var instructions = [],
  2253. opener = null,
  2254. tail = null,
  2255. token = null;
  2256.  
  2257. tail = stack[stack.length - 1];
  2258.  
  2259. while (tokens.length > 0) {
  2260. token = tokens.shift();
  2261.  
  2262. if (tail && tail.tag == '<' && !(token.tag in allowedInSuper)) {
  2263. throw new Error('Illegal content in < super tag.');
  2264. }
  2265.  
  2266. if (Hogan.tags[token.tag] <= Hogan.tags['$'] || isOpener(token, customTags)) {
  2267. stack.push(token);
  2268. token.nodes = buildTree(tokens, token.tag, stack, customTags);
  2269. } else if (token.tag == '/') {
  2270. if (stack.length === 0) {
  2271. throw new Error('Closing tag without opener: /' + token.n);
  2272. }
  2273. opener = stack.pop();
  2274. if (token.n != opener.n && !isCloser(token.n, opener.n, customTags)) {
  2275. throw new Error('Nesting error: ' + opener.n + ' vs. ' + token.n);
  2276. }
  2277. opener.end = token.i;
  2278. return instructions;
  2279. } else if (token.tag == '\n') {
  2280. token.last = (tokens.length == 0) || (tokens[0].tag == '\n');
  2281. }
  2282.  
  2283. instructions.push(token);
  2284. }
  2285.  
  2286. if (stack.length > 0) {
  2287. throw new Error('missing closing tag: ' + stack.pop().n);
  2288. }
  2289.  
  2290. return instructions;
  2291. }
  2292.  
  2293. function isOpener(token, tags) {
  2294. for (var i = 0, l = tags.length; i < l; i++) {
  2295. if (tags[i].o == token.n) {
  2296. token.tag = '#';
  2297. return true;
  2298. }
  2299. }
  2300. }
  2301.  
  2302. function isCloser(close, open, tags) {
  2303. for (var i = 0, l = tags.length; i < l; i++) {
  2304. if (tags[i].c == close && tags[i].o == open) {
  2305. return true;
  2306. }
  2307. }
  2308. }
  2309.  
  2310. function stringifySubstitutions(obj) {
  2311. var items = [];
  2312. for (var key in obj) {
  2313. items.push('"' + esc(key) + '": function(c,p,t,i) {' + obj[key] + '}');
  2314. }
  2315. return "{ " + items.join(",") + " }";
  2316. }
  2317.  
  2318. function stringifyPartials(codeObj) {
  2319. var partials = [];
  2320. for (var key in codeObj.partials) {
  2321. partials.push('"' + esc(key) + '":{name:"' + esc(codeObj.partials[key].name) + '", ' + stringifyPartials(codeObj.partials[key]) + "}");
  2322. }
  2323. return "partials: {" + partials.join(",") + "}, subs: " + stringifySubstitutions(codeObj.subs);
  2324. }
  2325.  
  2326. Hogan.stringify = function(codeObj, text, options) {
  2327. return "{code: function (c,p,i) { " + Hogan.wrapMain(codeObj.code) + " }," + stringifyPartials(codeObj) + "}";
  2328. }
  2329.  
  2330. var serialNo = 0;
  2331. Hogan.generate = function(tree, text, options) {
  2332. serialNo = 0;
  2333. var context = { code: '', subs: {}, partials: {} };
  2334. Hogan.walk(tree, context);
  2335.  
  2336. if (options.asString) {
  2337. return this.stringify(context, text, options);
  2338. }
  2339.  
  2340. return this.makeTemplate(context, text, options);
  2341. }
  2342.  
  2343. Hogan.wrapMain = function(code) {
  2344. return 'var t=this;t.b(i=i||"");' + code + 'return t.fl();';
  2345. }
  2346.  
  2347. Hogan.template = Hogan.Template;
  2348.  
  2349. Hogan.makeTemplate = function(codeObj, text, options) {
  2350. var template = this.makePartials(codeObj);
  2351. template.code = new Function('c', 'p', 'i', this.wrapMain(codeObj.code));
  2352. return new this.template(template, text, this, options);
  2353. }
  2354.  
  2355. Hogan.makePartials = function(codeObj) {
  2356. var key, template = {subs: {}, partials: codeObj.partials, name: codeObj.name};
  2357. for (key in template.partials) {
  2358. template.partials[key] = this.makePartials(template.partials[key]);
  2359. }
  2360. for (key in codeObj.subs) {
  2361. template.subs[key] = new Function('c', 'p', 't', 'i', codeObj.subs[key]);
  2362. }
  2363. return template;
  2364. }
  2365.  
  2366. function esc(s) {
  2367. return s.replace(rSlash, '\\\\')
  2368. .replace(rQuot, '\\\"')
  2369. .replace(rNewline, '\\n')
  2370. .replace(rCr, '\\r')
  2371. .replace(rLineSep, '\\u2028')
  2372. .replace(rParagraphSep, '\\u2029');
  2373. }
  2374.  
  2375. function chooseMethod(s) {
  2376. return (~s.indexOf('.')) ? 'd' : 'f';
  2377. }
  2378.  
  2379. function createPartial(node, context) {
  2380. var prefix = "<" + (context.prefix || "");
  2381. var sym = prefix + node.n + serialNo++;
  2382. context.partials[sym] = {name: node.n, partials: {}};
  2383. context.code += 't.b(t.rp("' + esc(sym) + '",c,p,"' + (node.indent || '') + '"));';
  2384. return sym;
  2385. }
  2386.  
  2387. Hogan.codegen = {
  2388. '#': function(node, context) {
  2389. context.code += 'if(t.s(t.' + chooseMethod(node.n) + '("' + esc(node.n) + '",c,p,1),' +
  2390. 'c,p,0,' + node.i + ',' + node.end + ',"' + node.otag + " " + node.ctag + '")){' +
  2391. 't.rs(c,p,' + 'function(c,p,t){';
  2392. Hogan.walk(node.nodes, context);
  2393. context.code += '});c.pop();}';
  2394. },
  2395.  
  2396. '^': function(node, context) {
  2397. context.code += 'if(!t.s(t.' + chooseMethod(node.n) + '("' + esc(node.n) + '",c,p,1),c,p,1,0,0,"")){';
  2398. Hogan.walk(node.nodes, context);
  2399. context.code += '};';
  2400. },
  2401.  
  2402. '>': createPartial,
  2403. '<': function(node, context) {
  2404. var ctx = {partials: {}, code: '', subs: {}, inPartial: true};
  2405. Hogan.walk(node.nodes, ctx);
  2406. var template = context.partials[createPartial(node, context)];
  2407. template.subs = ctx.subs;
  2408. template.partials = ctx.partials;
  2409. },
  2410.  
  2411. '$': function(node, context) {
  2412. var ctx = {subs: {}, code: '', partials: context.partials, prefix: node.n};
  2413. Hogan.walk(node.nodes, ctx);
  2414. context.subs[node.n] = ctx.code;
  2415. if (!context.inPartial) {
  2416. context.code += 't.sub("' + esc(node.n) + '",c,p,i);';
  2417. }
  2418. },
  2419.  
  2420. '\n': function(node, context) {
  2421. context.code += write('"\\n"' + (node.last ? '' : ' + i'));
  2422. },
  2423.  
  2424. '_v': function(node, context) {
  2425. context.code += 't.b(t.v(t.' + chooseMethod(node.n) + '("' + esc(node.n) + '",c,p,0)));';
  2426. },
  2427.  
  2428. '_t': function(node, context) {
  2429. context.code += write('"' + esc(node.text) + '"');
  2430. },
  2431.  
  2432. '{': tripleStache,
  2433.  
  2434. '&': tripleStache
  2435. }
  2436.  
  2437. function tripleStache(node, context) {
  2438. context.code += 't.b(t.t(t.' + chooseMethod(node.n) + '("' + esc(node.n) + '",c,p,0)));';
  2439. }
  2440.  
  2441. function write(s) {
  2442. return 't.b(' + s + ');';
  2443. }
  2444.  
  2445. Hogan.walk = function(nodelist, context) {
  2446. var func;
  2447. for (var i = 0, l = nodelist.length; i < l; i++) {
  2448. func = Hogan.codegen[nodelist[i].tag];
  2449. func && func(nodelist[i], context);
  2450. }
  2451. return context;
  2452. }
  2453.  
  2454. Hogan.parse = function(tokens, text, options) {
  2455. options = options || {};
  2456. return buildTree(tokens, '', [], options.sectionTags || []);
  2457. }
  2458.  
  2459. Hogan.cache = {};
  2460.  
  2461. Hogan.cacheKey = function(text, options) {
  2462. return [text, !!options.asString, !!options.disableLambda, options.delimiters, !!options.modelGet].join('||');
  2463. }
  2464.  
  2465. Hogan.compile = function(text, options) {
  2466. options = options || {};
  2467. var key = Hogan.cacheKey(text, options);
  2468. var template = this.cache[key];
  2469.  
  2470. if (template) {
  2471. var partials = template.partials;
  2472. for (var name in partials) {
  2473. delete partials[name].instance;
  2474. }
  2475. return template;
  2476. }
  2477.  
  2478. template = this.generate(this.parse(this.scan(text, options.delimiters), text, options), text, options);
  2479. return this.cache[key] = template;
  2480. }
  2481. })( true ? exports : undefined);
  2482.  
  2483.  
  2484. /***/ }),
  2485.  
  2486. /***/ "Ruv9":
  2487. /***/ (function(module, exports, __webpack_require__) {
  2488.  
  2489. /*
  2490. * Copyright 2011 Twitter, Inc.
  2491. * Licensed under the Apache License, Version 2.0 (the "License");
  2492. * you may not use this file except in compliance with the License.
  2493. * You may obtain a copy of the License at
  2494. *
  2495. * http://www.apache.org/licenses/LICENSE-2.0
  2496. *
  2497. * Unless required by applicable law or agreed to in writing, software
  2498. * distributed under the License is distributed on an "AS IS" BASIS,
  2499. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  2500. * See the License for the specific language governing permissions and
  2501. * limitations under the License.
  2502. */
  2503.  
  2504. // This file is for use with Node.js. See dist/ for browser files.
  2505.  
  2506. var Hogan = __webpack_require__("PKsF");
  2507. Hogan.Template = __webpack_require__("cK6b").Template;
  2508. Hogan.template = Hogan.Template;
  2509. module.exports = Hogan;
  2510.  
  2511.  
  2512. /***/ }),
  2513.  
  2514. /***/ "cK6b":
  2515. /***/ (function(module, exports, __webpack_require__) {
  2516.  
  2517. /*
  2518. * Copyright 2011 Twitter, Inc.
  2519. * Licensed under the Apache License, Version 2.0 (the "License");
  2520. * you may not use this file except in compliance with the License.
  2521. * You may obtain a copy of the License at
  2522. *
  2523. * http://www.apache.org/licenses/LICENSE-2.0
  2524. *
  2525. * Unless required by applicable law or agreed to in writing, software
  2526. * distributed under the License is distributed on an "AS IS" BASIS,
  2527. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  2528. * See the License for the specific language governing permissions and
  2529. * limitations under the License.
  2530. */
  2531.  
  2532. var Hogan = {};
  2533.  
  2534. (function (Hogan) {
  2535. Hogan.Template = function (codeObj, text, compiler, options) {
  2536. codeObj = codeObj || {};
  2537. this.r = codeObj.code || this.r;
  2538. this.c = compiler;
  2539. this.options = options || {};
  2540. this.text = text || '';
  2541. this.partials = codeObj.partials || {};
  2542. this.subs = codeObj.subs || {};
  2543. this.buf = '';
  2544. }
  2545.  
  2546. Hogan.Template.prototype = {
  2547. // render: replaced by generated code.
  2548. r: function (context, partials, indent) { return ''; },
  2549.  
  2550. // variable escaping
  2551. v: hoganEscape,
  2552.  
  2553. // triple stache
  2554. t: coerceToString,
  2555.  
  2556. render: function render(context, partials, indent) {
  2557. return this.ri([context], partials || {}, indent);
  2558. },
  2559.  
  2560. // render internal -- a hook for overrides that catches partials too
  2561. ri: function (context, partials, indent) {
  2562. return this.r(context, partials, indent);
  2563. },
  2564.  
  2565. // ensurePartial
  2566. ep: function(symbol, partials) {
  2567. var partial = this.partials[symbol];
  2568.  
  2569. // check to see that if we've instantiated this partial before
  2570. var template = partials[partial.name];
  2571. if (partial.instance && partial.base == template) {
  2572. return partial.instance;
  2573. }
  2574.  
  2575. if (typeof template == 'string') {
  2576. if (!this.c) {
  2577. throw new Error("No compiler available.");
  2578. }
  2579. template = this.c.compile(template, this.options);
  2580. }
  2581.  
  2582. if (!template) {
  2583. return null;
  2584. }
  2585.  
  2586. // We use this to check whether the partials dictionary has changed
  2587. this.partials[symbol].base = template;
  2588.  
  2589. if (partial.subs) {
  2590. // Make sure we consider parent template now
  2591. if (!partials.stackText) partials.stackText = {};
  2592. for (key in partial.subs) {
  2593. if (!partials.stackText[key]) {
  2594. partials.stackText[key] = (this.activeSub !== undefined && partials.stackText[this.activeSub]) ? partials.stackText[this.activeSub] : this.text;
  2595. }
  2596. }
  2597. template = createSpecializedPartial(template, partial.subs, partial.partials,
  2598. this.stackSubs, this.stackPartials, partials.stackText);
  2599. }
  2600. this.partials[symbol].instance = template;
  2601.  
  2602. return template;
  2603. },
  2604.  
  2605. // tries to find a partial in the current scope and render it
  2606. rp: function(symbol, context, partials, indent) {
  2607. var partial = this.ep(symbol, partials);
  2608. if (!partial) {
  2609. return '';
  2610. }
  2611.  
  2612. return partial.ri(context, partials, indent);
  2613. },
  2614.  
  2615. // render a section
  2616. rs: function(context, partials, section) {
  2617. var tail = context[context.length - 1];
  2618.  
  2619. if (!isArray(tail)) {
  2620. section(context, partials, this);
  2621. return;
  2622. }
  2623.  
  2624. for (var i = 0; i < tail.length; i++) {
  2625. context.push(tail[i]);
  2626. section(context, partials, this);
  2627. context.pop();
  2628. }
  2629. },
  2630.  
  2631. // maybe start a section
  2632. s: function(val, ctx, partials, inverted, start, end, tags) {
  2633. var pass;
  2634.  
  2635. if (isArray(val) && val.length === 0) {
  2636. return false;
  2637. }
  2638.  
  2639. if (typeof val == 'function') {
  2640. val = this.ms(val, ctx, partials, inverted, start, end, tags);
  2641. }
  2642.  
  2643. pass = !!val;
  2644.  
  2645. if (!inverted && pass && ctx) {
  2646. ctx.push((typeof val == 'object') ? val : ctx[ctx.length - 1]);
  2647. }
  2648.  
  2649. return pass;
  2650. },
  2651.  
  2652. // find values with dotted names
  2653. d: function(key, ctx, partials, returnFound) {
  2654. var found,
  2655. names = key.split('.'),
  2656. val = this.f(names[0], ctx, partials, returnFound),
  2657. doModelGet = this.options.modelGet,
  2658. cx = null;
  2659.  
  2660. if (key === '.' && isArray(ctx[ctx.length - 2])) {
  2661. val = ctx[ctx.length - 1];
  2662. } else {
  2663. for (var i = 1; i < names.length; i++) {
  2664. found = findInScope(names[i], val, doModelGet);
  2665. if (found !== undefined) {
  2666. cx = val;
  2667. val = found;
  2668. } else {
  2669. val = '';
  2670. }
  2671. }
  2672. }
  2673.  
  2674. if (returnFound && !val) {
  2675. return false;
  2676. }
  2677.  
  2678. if (!returnFound && typeof val == 'function') {
  2679. ctx.push(cx);
  2680. val = this.mv(val, ctx, partials);
  2681. ctx.pop();
  2682. }
  2683.  
  2684. return val;
  2685. },
  2686.  
  2687. // find values with normal names
  2688. f: function(key, ctx, partials, returnFound) {
  2689. var val = false,
  2690. v = null,
  2691. found = false,
  2692. doModelGet = this.options.modelGet;
  2693.  
  2694. for (var i = ctx.length - 1; i >= 0; i--) {
  2695. v = ctx[i];
  2696. val = findInScope(key, v, doModelGet);
  2697. if (val !== undefined) {
  2698. found = true;
  2699. break;
  2700. }
  2701. }
  2702.  
  2703. if (!found) {
  2704. return (returnFound) ? false : "";
  2705. }
  2706.  
  2707. if (!returnFound && typeof val == 'function') {
  2708. val = this.mv(val, ctx, partials);
  2709. }
  2710.  
  2711. return val;
  2712. },
  2713.  
  2714. // higher order templates
  2715. ls: function(func, cx, partials, text, tags) {
  2716. var oldTags = this.options.delimiters;
  2717.  
  2718. this.options.delimiters = tags;
  2719. this.b(this.ct(coerceToString(func.call(cx, text)), cx, partials));
  2720. this.options.delimiters = oldTags;
  2721.  
  2722. return false;
  2723. },
  2724.  
  2725. // compile text
  2726. ct: function(text, cx, partials) {
  2727. if (this.options.disableLambda) {
  2728. throw new Error('Lambda features disabled.');
  2729. }
  2730. return this.c.compile(text, this.options).render(cx, partials);
  2731. },
  2732.  
  2733. // template result buffering
  2734. b: function(s) { this.buf += s; },
  2735.  
  2736. fl: function() { var r = this.buf; this.buf = ''; return r; },
  2737.  
  2738. // method replace section
  2739. ms: function(func, ctx, partials, inverted, start, end, tags) {
  2740. var textSource,
  2741. cx = ctx[ctx.length - 1],
  2742. result = func.call(cx);
  2743.  
  2744. if (typeof result == 'function') {
  2745. if (inverted) {
  2746. return true;
  2747. } else {
  2748. textSource = (this.activeSub && this.subsText && this.subsText[this.activeSub]) ? this.subsText[this.activeSub] : this.text;
  2749. return this.ls(result, cx, partials, textSource.substring(start, end), tags);
  2750. }
  2751. }
  2752.  
  2753. return result;
  2754. },
  2755.  
  2756. // method replace variable
  2757. mv: function(func, ctx, partials) {
  2758. var cx = ctx[ctx.length - 1];
  2759. var result = func.call(cx);
  2760.  
  2761. if (typeof result == 'function') {
  2762. return this.ct(coerceToString(result.call(cx)), cx, partials);
  2763. }
  2764.  
  2765. return result;
  2766. },
  2767.  
  2768. sub: function(name, context, partials, indent) {
  2769. var f = this.subs[name];
  2770. if (f) {
  2771. this.activeSub = name;
  2772. f(context, partials, this, indent);
  2773. this.activeSub = false;
  2774. }
  2775. }
  2776.  
  2777. };
  2778.  
  2779. //Find a key in an object
  2780. function findInScope(key, scope, doModelGet) {
  2781. var val;
  2782.  
  2783. if (scope && typeof scope == 'object') {
  2784.  
  2785. if (scope[key] !== undefined) {
  2786. val = scope[key];
  2787.  
  2788. // try lookup with get for backbone or similar model data
  2789. } else if (doModelGet && scope.get && typeof scope.get == 'function') {
  2790. val = scope.get(key);
  2791. }
  2792. }
  2793.  
  2794. return val;
  2795. }
  2796.  
  2797. function createSpecializedPartial(instance, subs, partials, stackSubs, stackPartials, stackText) {
  2798. function PartialTemplate() {};
  2799. PartialTemplate.prototype = instance;
  2800. function Substitutions() {};
  2801. Substitutions.prototype = instance.subs;
  2802. var key;
  2803. var partial = new PartialTemplate();
  2804. partial.subs = new Substitutions();
  2805. partial.subsText = {}; //hehe. substext.
  2806. partial.buf = '';
  2807.  
  2808. stackSubs = stackSubs || {};
  2809. partial.stackSubs = stackSubs;
  2810. partial.subsText = stackText;
  2811. for (key in subs) {
  2812. if (!stackSubs[key]) stackSubs[key] = subs[key];
  2813. }
  2814. for (key in stackSubs) {
  2815. partial.subs[key] = stackSubs[key];
  2816. }
  2817.  
  2818. stackPartials = stackPartials || {};
  2819. partial.stackPartials = stackPartials;
  2820. for (key in partials) {
  2821. if (!stackPartials[key]) stackPartials[key] = partials[key];
  2822. }
  2823. for (key in stackPartials) {
  2824. partial.partials[key] = stackPartials[key];
  2825. }
  2826.  
  2827. return partial;
  2828. }
  2829.  
  2830. var rAmp = /&/g,
  2831. rLt = /</g,
  2832. rGt = />/g,
  2833. rApos = /\'/g,
  2834. rQuot = /\"/g,
  2835. hChars = /[&<>\"\']/;
  2836.  
  2837. function coerceToString(val) {
  2838. return String((val === null || val === undefined) ? '' : val);
  2839. }
  2840.  
  2841. function hoganEscape(str) {
  2842. str = coerceToString(str);
  2843. return hChars.test(str) ?
  2844. str
  2845. .replace(rAmp, '&amp;')
  2846. .replace(rLt, '&lt;')
  2847. .replace(rGt, '&gt;')
  2848. .replace(rApos, '&#39;')
  2849. .replace(rQuot, '&quot;') :
  2850. str;
  2851. }
  2852.  
  2853. var isArray = Array.isArray || function(a) {
  2854. return Object.prototype.toString.call(a) === '[object Array]';
  2855. };
  2856.  
  2857. })( true ? exports : undefined);
  2858.  
  2859.  
  2860. /***/ }),
  2861.  
  2862. /***/ "e6Wu":
  2863. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2864.  
  2865. "use strict";
  2866. // ESM COMPAT FLAG
  2867. __webpack_require__.r(__webpack_exports__);
  2868.  
  2869. // EXTERNAL MODULE: ./node_modules/difflib/index.js
  2870. var difflib = __webpack_require__("7Mwc");
  2871.  
  2872. // CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/types.js
  2873. var LineType;
  2874. (function (LineType) {
  2875. LineType["INSERT"] = "insert";
  2876. LineType["DELETE"] = "delete";
  2877. LineType["CONTEXT"] = "context";
  2878. })(LineType || (LineType = {}));
  2879. var OutputFormatType = {
  2880. LINE_BY_LINE: 'line-by-line',
  2881. SIDE_BY_SIDE: 'side-by-side',
  2882. };
  2883. var LineMatchingType = {
  2884. LINES: 'lines',
  2885. WORDS: 'words',
  2886. NONE: 'none',
  2887. };
  2888. var DiffStyleType = {
  2889. WORD: 'word',
  2890. CHAR: 'char',
  2891. };
  2892. //# sourceMappingURL=types.js.map
  2893. // CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/utils.js
  2894. var specials = [
  2895. '-',
  2896. '[',
  2897. ']',
  2898. '/',
  2899. '{',
  2900. '}',
  2901. '(',
  2902. ')',
  2903. '*',
  2904. '+',
  2905. '?',
  2906. '.',
  2907. '\\',
  2908. '^',
  2909. '$',
  2910. '|',
  2911. ];
  2912. var regex = RegExp('[' + specials.join('\\') + ']', 'g');
  2913. function escapeForRegExp(str) {
  2914. return str.replace(regex, '\\$&');
  2915. }
  2916. function unifyPath(path) {
  2917. return path ? path.replace(/\\/g, '/') : path;
  2918. }
  2919. function hashCode(text) {
  2920. var i, chr, len;
  2921. var hash = 0;
  2922. for (i = 0, len = text.length; i < len; i++) {
  2923. chr = text.charCodeAt(i);
  2924. hash = (hash << 5) - hash + chr;
  2925. hash |= 0;
  2926. }
  2927. return hash;
  2928. }
  2929. //# sourceMappingURL=utils.js.map
  2930. // CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/diff-parser.js
  2931. var __spreadArrays = (undefined && undefined.__spreadArrays) || function () {
  2932. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  2933. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  2934. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  2935. r[k] = a[j];
  2936. return r;
  2937. };
  2938.  
  2939.  
  2940. function getExtension(filename, language) {
  2941. var filenameParts = filename.split('.');
  2942. return filenameParts.length > 1 ? filenameParts[filenameParts.length - 1] : language;
  2943. }
  2944. function startsWithAny(str, prefixes) {
  2945. return prefixes.reduce(function (startsWith, prefix) { return startsWith || str.startsWith(prefix); }, false);
  2946. }
  2947. var baseDiffFilenamePrefixes = ['a/', 'b/', 'i/', 'w/', 'c/', 'o/'];
  2948. function getFilename(line, linePrefix, extraPrefix) {
  2949. var prefixes = extraPrefix !== undefined ? __spreadArrays(baseDiffFilenamePrefixes, [extraPrefix]) : baseDiffFilenamePrefixes;
  2950. var FilenameRegExp = linePrefix
  2951. ? new RegExp("^" + escapeForRegExp(linePrefix) + " \"?(.+?)\"?$")
  2952. : new RegExp('^"?(.+?)"?$');
  2953. var _a = FilenameRegExp.exec(line) || [], _b = _a[1], filename = _b === void 0 ? '' : _b;
  2954. var matchingPrefix = prefixes.find(function (p) { return filename.indexOf(p) === 0; });
  2955. var fnameWithoutPrefix = matchingPrefix ? filename.slice(matchingPrefix.length) : filename;
  2956. return fnameWithoutPrefix.replace(/\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?:\.\d+)? [+-]\d{4}.*$/, '');
  2957. }
  2958. function getSrcFilename(line, srcPrefix) {
  2959. return getFilename(line, '---', srcPrefix);
  2960. }
  2961. function getDstFilename(line, dstPrefix) {
  2962. return getFilename(line, '+++', dstPrefix);
  2963. }
  2964. function parse(diffInput, config) {
  2965. if (config === void 0) { config = {}; }
  2966. var files = [];
  2967. var currentFile = null;
  2968. var currentBlock = null;
  2969. var oldLine = null;
  2970. var oldLine2 = null;
  2971. var newLine = null;
  2972. var possibleOldName = null;
  2973. var possibleNewName = null;
  2974. var oldFileNameHeader = '--- ';
  2975. var newFileNameHeader = '+++ ';
  2976. var hunkHeaderPrefix = '@@';
  2977. var oldMode = /^old mode (\d{6})/;
  2978. var newMode = /^new mode (\d{6})/;
  2979. var deletedFileMode = /^deleted file mode (\d{6})/;
  2980. var newFileMode = /^new file mode (\d{6})/;
  2981. var copyFrom = /^copy from "?(.+)"?/;
  2982. var copyTo = /^copy to "?(.+)"?/;
  2983. var renameFrom = /^rename from "?(.+)"?/;
  2984. var renameTo = /^rename to "?(.+)"?/;
  2985. var similarityIndex = /^similarity index (\d+)%/;
  2986. var dissimilarityIndex = /^dissimilarity index (\d+)%/;
  2987. var index = /^index ([\da-z]+)\.\.([\da-z]+)\s*(\d{6})?/;
  2988. var binaryFiles = /^Binary files (.*) and (.*) differ/;
  2989. var binaryDiff = /^GIT binary patch/;
  2990. var combinedIndex = /^index ([\da-z]+),([\da-z]+)\.\.([\da-z]+)/;
  2991. var combinedMode = /^mode (\d{6}),(\d{6})\.\.(\d{6})/;
  2992. var combinedNewFile = /^new file mode (\d{6})/;
  2993. var combinedDeletedFile = /^deleted file mode (\d{6}),(\d{6})/;
  2994. var diffLines = diffInput
  2995. .replace(/\\ No newline at end of file/g, '')
  2996. .replace(/\r\n?/g, '\n')
  2997. .split('\n');
  2998. function saveBlock() {
  2999. if (currentBlock !== null && currentFile !== null) {
  3000. currentFile.blocks.push(currentBlock);
  3001. currentBlock = null;
  3002. }
  3003. }
  3004. function saveFile() {
  3005. if (currentFile !== null) {
  3006. if (!currentFile.oldName && possibleOldName !== null) {
  3007. currentFile.oldName = possibleOldName;
  3008. }
  3009. if (!currentFile.newName && possibleNewName !== null) {
  3010. currentFile.newName = possibleNewName;
  3011. }
  3012. if (currentFile.newName) {
  3013. files.push(currentFile);
  3014. currentFile = null;
  3015. }
  3016. }
  3017. possibleOldName = null;
  3018. possibleNewName = null;
  3019. }
  3020. function startFile() {
  3021. saveBlock();
  3022. saveFile();
  3023. currentFile = {
  3024. blocks: [],
  3025. deletedLines: 0,
  3026. addedLines: 0,
  3027. };
  3028. }
  3029. function startBlock(line) {
  3030. saveBlock();
  3031. var values;
  3032. if (currentFile !== null) {
  3033. if ((values = /^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@.*/.exec(line))) {
  3034. currentFile.isCombined = false;
  3035. oldLine = parseInt(values[1], 10);
  3036. newLine = parseInt(values[2], 10);
  3037. }
  3038. else if ((values = /^@@@ -(\d+)(?:,\d+)? -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@@.*/.exec(line))) {
  3039. currentFile.isCombined = true;
  3040. oldLine = parseInt(values[1], 10);
  3041. oldLine2 = parseInt(values[2], 10);
  3042. newLine = parseInt(values[3], 10);
  3043. }
  3044. else {
  3045. if (line.startsWith(hunkHeaderPrefix)) {
  3046. console.error('Failed to parse lines, starting in 0!');
  3047. }
  3048. oldLine = 0;
  3049. newLine = 0;
  3050. currentFile.isCombined = false;
  3051. }
  3052. }
  3053. currentBlock = {
  3054. lines: [],
  3055. oldStartLine: oldLine,
  3056. oldStartLine2: oldLine2,
  3057. newStartLine: newLine,
  3058. header: line,
  3059. };
  3060. }
  3061. function createLine(line) {
  3062. if (currentFile === null || currentBlock === null || oldLine === null || newLine === null)
  3063. return;
  3064. var currentLine = {
  3065. content: line,
  3066. };
  3067. var addedPrefixes = currentFile.isCombined ? ['+ ', ' +', '++'] : ['+'];
  3068. var deletedPrefixes = currentFile.isCombined ? ['- ', ' -', '--'] : ['-'];
  3069. if (startsWithAny(line, addedPrefixes)) {
  3070. currentFile.addedLines++;
  3071. currentLine.type = LineType.INSERT;
  3072. currentLine.oldNumber = undefined;
  3073. currentLine.newNumber = newLine++;
  3074. }
  3075. else if (startsWithAny(line, deletedPrefixes)) {
  3076. currentFile.deletedLines++;
  3077. currentLine.type = LineType.DELETE;
  3078. currentLine.oldNumber = oldLine++;
  3079. currentLine.newNumber = undefined;
  3080. }
  3081. else {
  3082. currentLine.type = LineType.CONTEXT;
  3083. currentLine.oldNumber = oldLine++;
  3084. currentLine.newNumber = newLine++;
  3085. }
  3086. currentBlock.lines.push(currentLine);
  3087. }
  3088. function existHunkHeader(line, lineIdx) {
  3089. var idx = lineIdx;
  3090. while (idx < diffLines.length - 3) {
  3091. if (line.startsWith('diff')) {
  3092. return false;
  3093. }
  3094. if (diffLines[idx].startsWith(oldFileNameHeader) &&
  3095. diffLines[idx + 1].startsWith(newFileNameHeader) &&
  3096. diffLines[idx + 2].startsWith(hunkHeaderPrefix)) {
  3097. return true;
  3098. }
  3099. idx++;
  3100. }
  3101. return false;
  3102. }
  3103. diffLines.forEach(function (line, lineIndex) {
  3104. if (!line || line.startsWith('*')) {
  3105. return;
  3106. }
  3107. var values;
  3108. var prevLine = diffLines[lineIndex - 1];
  3109. var nxtLine = diffLines[lineIndex + 1];
  3110. var afterNxtLine = diffLines[lineIndex + 2];
  3111. if (line.startsWith('diff')) {
  3112. startFile();
  3113. var gitDiffStart = /^diff --git "?(.+)"? "?(.+)"?/;
  3114. if ((values = gitDiffStart.exec(line))) {
  3115. possibleOldName = getFilename(values[1], undefined, config.dstPrefix);
  3116. possibleNewName = getFilename(values[2], undefined, config.srcPrefix);
  3117. }
  3118. if (currentFile === null) {
  3119. throw new Error('Where is my file !!!');
  3120. }
  3121. currentFile.isGitDiff = true;
  3122. return;
  3123. }
  3124. if (!currentFile ||
  3125. (!currentFile.isGitDiff &&
  3126. currentFile &&
  3127. line.startsWith(oldFileNameHeader) &&
  3128. nxtLine.startsWith(newFileNameHeader) &&
  3129. afterNxtLine.startsWith(hunkHeaderPrefix))) {
  3130. startFile();
  3131. }
  3132. if ((line.startsWith(oldFileNameHeader) && nxtLine.startsWith(newFileNameHeader)) ||
  3133. (line.startsWith(newFileNameHeader) && prevLine.startsWith(oldFileNameHeader))) {
  3134. if (currentFile &&
  3135. !currentFile.oldName &&
  3136. line.startsWith('--- ') &&
  3137. (values = getSrcFilename(line, config.srcPrefix))) {
  3138. currentFile.oldName = values;
  3139. currentFile.language = getExtension(currentFile.oldName, currentFile.language);
  3140. return;
  3141. }
  3142. if (currentFile &&
  3143. !currentFile.newName &&
  3144. line.startsWith('+++ ') &&
  3145. (values = getDstFilename(line, config.dstPrefix))) {
  3146. currentFile.newName = values;
  3147. currentFile.language = getExtension(currentFile.newName, currentFile.language);
  3148. return;
  3149. }
  3150. }
  3151. if (currentFile &&
  3152. (line.startsWith(hunkHeaderPrefix) ||
  3153. (currentFile.isGitDiff && currentFile.oldName && currentFile.newName && !currentBlock))) {
  3154. startBlock(line);
  3155. return;
  3156. }
  3157. if (currentBlock && (line.startsWith('+') || line.startsWith('-') || line.startsWith(' '))) {
  3158. createLine(line);
  3159. return;
  3160. }
  3161. var doesNotExistHunkHeader = !existHunkHeader(line, lineIndex);
  3162. if (currentFile === null) {
  3163. throw new Error('Where is my file !!!');
  3164. }
  3165. if ((values = oldMode.exec(line))) {
  3166. currentFile.oldMode = values[1];
  3167. }
  3168. else if ((values = newMode.exec(line))) {
  3169. currentFile.newMode = values[1];
  3170. }
  3171. else if ((values = deletedFileMode.exec(line))) {
  3172. currentFile.deletedFileMode = values[1];
  3173. currentFile.isDeleted = true;
  3174. }
  3175. else if ((values = newFileMode.exec(line))) {
  3176. currentFile.newFileMode = values[1];
  3177. currentFile.isNew = true;
  3178. }
  3179. else if ((values = copyFrom.exec(line))) {
  3180. if (doesNotExistHunkHeader) {
  3181. currentFile.oldName = values[1];
  3182. }
  3183. currentFile.isCopy = true;
  3184. }
  3185. else if ((values = copyTo.exec(line))) {
  3186. if (doesNotExistHunkHeader) {
  3187. currentFile.newName = values[1];
  3188. }
  3189. currentFile.isCopy = true;
  3190. }
  3191. else if ((values = renameFrom.exec(line))) {
  3192. if (doesNotExistHunkHeader) {
  3193. currentFile.oldName = values[1];
  3194. }
  3195. currentFile.isRename = true;
  3196. }
  3197. else if ((values = renameTo.exec(line))) {
  3198. if (doesNotExistHunkHeader) {
  3199. currentFile.newName = values[1];
  3200. }
  3201. currentFile.isRename = true;
  3202. }
  3203. else if ((values = binaryFiles.exec(line))) {
  3204. currentFile.isBinary = true;
  3205. currentFile.oldName = getFilename(values[1], undefined, config.srcPrefix);
  3206. currentFile.newName = getFilename(values[2], undefined, config.dstPrefix);
  3207. startBlock('Binary file');
  3208. }
  3209. else if (binaryDiff.test(line)) {
  3210. currentFile.isBinary = true;
  3211. startBlock(line);
  3212. }
  3213. else if ((values = similarityIndex.exec(line))) {
  3214. currentFile.unchangedPercentage = parseInt(values[1], 10);
  3215. }
  3216. else if ((values = dissimilarityIndex.exec(line))) {
  3217. currentFile.changedPercentage = parseInt(values[1], 10);
  3218. }
  3219. else if ((values = index.exec(line))) {
  3220. currentFile.checksumBefore = values[1];
  3221. currentFile.checksumAfter = values[2];
  3222. values[3] && (currentFile.mode = values[3]);
  3223. }
  3224. else if ((values = combinedIndex.exec(line))) {
  3225. currentFile.checksumBefore = [values[2], values[3]];
  3226. currentFile.checksumAfter = values[1];
  3227. }
  3228. else if ((values = combinedMode.exec(line))) {
  3229. currentFile.oldMode = [values[2], values[3]];
  3230. currentFile.newMode = values[1];
  3231. }
  3232. else if ((values = combinedNewFile.exec(line))) {
  3233. currentFile.newFileMode = values[1];
  3234. currentFile.isNew = true;
  3235. }
  3236. else if ((values = combinedDeletedFile.exec(line))) {
  3237. currentFile.deletedFileMode = values[1];
  3238. currentFile.isDeleted = true;
  3239. }
  3240. });
  3241. saveBlock();
  3242. saveFile();
  3243. return files;
  3244. }
  3245. //# sourceMappingURL=diff-parser.js.map
  3246. // EXTERNAL MODULE: ./node_modules/diff/dist/diff.js
  3247. var dist_diff = __webpack_require__("v2jn");
  3248.  
  3249. // CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/rematch.js
  3250. function levenshtein(a, b) {
  3251. if (a.length === 0) {
  3252. return b.length;
  3253. }
  3254. if (b.length === 0) {
  3255. return a.length;
  3256. }
  3257. var matrix = [];
  3258. var i;
  3259. for (i = 0; i <= b.length; i++) {
  3260. matrix[i] = [i];
  3261. }
  3262. var j;
  3263. for (j = 0; j <= a.length; j++) {
  3264. matrix[0][j] = j;
  3265. }
  3266. for (i = 1; i <= b.length; i++) {
  3267. for (j = 1; j <= a.length; j++) {
  3268. if (b.charAt(i - 1) === a.charAt(j - 1)) {
  3269. matrix[i][j] = matrix[i - 1][j - 1];
  3270. }
  3271. else {
  3272. matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, Math.min(matrix[i][j - 1] + 1, matrix[i - 1][j] + 1));
  3273. }
  3274. }
  3275. }
  3276. return matrix[b.length][a.length];
  3277. }
  3278. function newDistanceFn(str) {
  3279. return function (x, y) {
  3280. var xValue = str(x).trim();
  3281. var yValue = str(y).trim();
  3282. var lev = levenshtein(xValue, yValue);
  3283. return lev / (xValue.length + yValue.length);
  3284. };
  3285. }
  3286. function newMatcherFn(distance) {
  3287. function findBestMatch(a, b, cache) {
  3288. if (cache === void 0) { cache = new Map(); }
  3289. var bestMatchDist = Infinity;
  3290. var bestMatch;
  3291. for (var i = 0; i < a.length; ++i) {
  3292. for (var j = 0; j < b.length; ++j) {
  3293. var cacheKey = JSON.stringify([a[i], b[j]]);
  3294. var md = void 0;
  3295. if (!(cache.has(cacheKey) && (md = cache.get(cacheKey)))) {
  3296. md = distance(a[i], b[j]);
  3297. cache.set(cacheKey, md);
  3298. }
  3299. if (md < bestMatchDist) {
  3300. bestMatchDist = md;
  3301. bestMatch = { indexA: i, indexB: j, score: bestMatchDist };
  3302. }
  3303. }
  3304. }
  3305. return bestMatch;
  3306. }
  3307. function group(a, b, level, cache) {
  3308. if (level === void 0) { level = 0; }
  3309. if (cache === void 0) { cache = new Map(); }
  3310. var bm = findBestMatch(a, b, cache);
  3311. if (!bm || a.length + b.length < 3) {
  3312. return [[a, b]];
  3313. }
  3314. var a1 = a.slice(0, bm.indexA);
  3315. var b1 = b.slice(0, bm.indexB);
  3316. var aMatch = [a[bm.indexA]];
  3317. var bMatch = [b[bm.indexB]];
  3318. var tailA = bm.indexA + 1;
  3319. var tailB = bm.indexB + 1;
  3320. var a2 = a.slice(tailA);
  3321. var b2 = b.slice(tailB);
  3322. var group1 = group(a1, b1, level + 1, cache);
  3323. var groupMatch = group(aMatch, bMatch, level + 1, cache);
  3324. var group2 = group(a2, b2, level + 1, cache);
  3325. var result = groupMatch;
  3326. if (bm.indexA > 0 || bm.indexB > 0) {
  3327. result = group1.concat(result);
  3328. }
  3329. if (a.length > tailA || b.length > tailB) {
  3330. result = result.concat(group2);
  3331. }
  3332. return result;
  3333. }
  3334. return group;
  3335. }
  3336. //# sourceMappingURL=rematch.js.map
  3337. // CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/render-utils.js
  3338. var __assign = (undefined && undefined.__assign) || function () {
  3339. __assign = Object.assign || function(t) {
  3340. for (var s, i = 1, n = arguments.length; i < n; i++) {
  3341. s = arguments[i];
  3342. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  3343. t[p] = s[p];
  3344. }
  3345. return t;
  3346. };
  3347. return __assign.apply(this, arguments);
  3348. };
  3349.  
  3350.  
  3351.  
  3352.  
  3353. var CSSLineClass = {
  3354. INSERTS: 'd2h-ins',
  3355. DELETES: 'd2h-del',
  3356. CONTEXT: 'd2h-cntx',
  3357. INFO: 'd2h-info',
  3358. INSERT_CHANGES: 'd2h-ins d2h-change',
  3359. DELETE_CHANGES: 'd2h-del d2h-change',
  3360. };
  3361. var defaultRenderConfig = {
  3362. matching: LineMatchingType.NONE,
  3363. matchWordsThreshold: 0.25,
  3364. maxLineLengthHighlight: 10000,
  3365. diffStyle: DiffStyleType.WORD,
  3366. };
  3367. var separator = '/';
  3368. var distance = newDistanceFn(function (change) { return change.value; });
  3369. var render_utils_matcher = newMatcherFn(distance);
  3370. function isDevNullName(name) {
  3371. return name.indexOf('dev/null') !== -1;
  3372. }
  3373. function removeInsElements(line) {
  3374. return line.replace(/(<ins[^>]*>((.|\n)*?)<\/ins>)/g, '');
  3375. }
  3376. function removeDelElements(line) {
  3377. return line.replace(/(<del[^>]*>((.|\n)*?)<\/del>)/g, '');
  3378. }
  3379. function toCSSClass(lineType) {
  3380. switch (lineType) {
  3381. case LineType.CONTEXT:
  3382. return CSSLineClass.CONTEXT;
  3383. case LineType.INSERT:
  3384. return CSSLineClass.INSERTS;
  3385. case LineType.DELETE:
  3386. return CSSLineClass.DELETES;
  3387. }
  3388. }
  3389. function prefixLength(isCombined) {
  3390. return isCombined ? 2 : 1;
  3391. }
  3392. function escapeForHtml(str) {
  3393. return str
  3394. .slice(0)
  3395. .replace(/&/g, '&amp;')
  3396. .replace(/</g, '&lt;')
  3397. .replace(/>/g, '&gt;')
  3398. .replace(/"/g, '&quot;')
  3399. .replace(/'/g, '&#x27;')
  3400. .replace(/\//g, '&#x2F;');
  3401. }
  3402. function deconstructLine(line, isCombined, escape) {
  3403. if (escape === void 0) { escape = true; }
  3404. var indexToSplit = prefixLength(isCombined);
  3405. return {
  3406. prefix: line.substring(0, indexToSplit),
  3407. content: escape ? escapeForHtml(line.substring(indexToSplit)) : line.substring(indexToSplit),
  3408. };
  3409. }
  3410. function filenameDiff(file) {
  3411. var oldFilename = unifyPath(file.oldName);
  3412. var newFilename = unifyPath(file.newName);
  3413. if (oldFilename !== newFilename && !isDevNullName(oldFilename) && !isDevNullName(newFilename)) {
  3414. var prefixPaths = [];
  3415. var suffixPaths = [];
  3416. var oldFilenameParts = oldFilename.split(separator);
  3417. var newFilenameParts = newFilename.split(separator);
  3418. var oldFilenamePartsSize = oldFilenameParts.length;
  3419. var newFilenamePartsSize = newFilenameParts.length;
  3420. var i = 0;
  3421. var j = oldFilenamePartsSize - 1;
  3422. var k = newFilenamePartsSize - 1;
  3423. while (i < j && i < k) {
  3424. if (oldFilenameParts[i] === newFilenameParts[i]) {
  3425. prefixPaths.push(newFilenameParts[i]);
  3426. i += 1;
  3427. }
  3428. else {
  3429. break;
  3430. }
  3431. }
  3432. while (j > i && k > i) {
  3433. if (oldFilenameParts[j] === newFilenameParts[k]) {
  3434. suffixPaths.unshift(newFilenameParts[k]);
  3435. j -= 1;
  3436. k -= 1;
  3437. }
  3438. else {
  3439. break;
  3440. }
  3441. }
  3442. var finalPrefix = prefixPaths.join(separator);
  3443. var finalSuffix = suffixPaths.join(separator);
  3444. var oldRemainingPath = oldFilenameParts.slice(i, j + 1).join(separator);
  3445. var newRemainingPath = newFilenameParts.slice(i, k + 1).join(separator);
  3446. if (finalPrefix.length && finalSuffix.length) {
  3447. return (finalPrefix + separator + '{' + oldRemainingPath + ' → ' + newRemainingPath + '}' + separator + finalSuffix);
  3448. }
  3449. else if (finalPrefix.length) {
  3450. return finalPrefix + separator + '{' + oldRemainingPath + ' → ' + newRemainingPath + '}';
  3451. }
  3452. else if (finalSuffix.length) {
  3453. return '{' + oldRemainingPath + ' → ' + newRemainingPath + '}' + separator + finalSuffix;
  3454. }
  3455. return oldFilename + ' → ' + newFilename;
  3456. }
  3457. else if (!isDevNullName(newFilename)) {
  3458. return newFilename;
  3459. }
  3460. else {
  3461. return oldFilename;
  3462. }
  3463. }
  3464. function getHtmlId(file) {
  3465. return "d2h-" + hashCode(filenameDiff(file))
  3466. .toString()
  3467. .slice(-6);
  3468. }
  3469. function getFileIcon(file) {
  3470. var templateName = 'file-changed';
  3471. if (file.isRename) {
  3472. templateName = 'file-renamed';
  3473. }
  3474. else if (file.isCopy) {
  3475. templateName = 'file-renamed';
  3476. }
  3477. else if (file.isNew) {
  3478. templateName = 'file-added';
  3479. }
  3480. else if (file.isDeleted) {
  3481. templateName = 'file-deleted';
  3482. }
  3483. else if (file.newName !== file.oldName) {
  3484. templateName = 'file-renamed';
  3485. }
  3486. return templateName;
  3487. }
  3488. function diffHighlight(diffLine1, diffLine2, isCombined, config) {
  3489. if (config === void 0) { config = {}; }
  3490. var _a = __assign(__assign({}, defaultRenderConfig), config), matching = _a.matching, maxLineLengthHighlight = _a.maxLineLengthHighlight, matchWordsThreshold = _a.matchWordsThreshold, diffStyle = _a.diffStyle;
  3491. var line1 = deconstructLine(diffLine1, isCombined, false);
  3492. var line2 = deconstructLine(diffLine2, isCombined, false);
  3493. if (line1.content.length > maxLineLengthHighlight || line2.content.length > maxLineLengthHighlight) {
  3494. return {
  3495. oldLine: {
  3496. prefix: line1.prefix,
  3497. content: line1.content,
  3498. },
  3499. newLine: {
  3500. prefix: line2.prefix,
  3501. content: line2.content,
  3502. },
  3503. };
  3504. }
  3505. var diff = diffStyle === 'char'
  3506. ? dist_diff["diffChars"](line1.content, line2.content)
  3507. : dist_diff["diffWordsWithSpace"](line1.content, line2.content);
  3508. var changedWords = [];
  3509. if (diffStyle === 'word' && matching === 'words') {
  3510. var removed = diff.filter(function (element) { return element.removed; });
  3511. var added = diff.filter(function (element) { return element.added; });
  3512. var chunks = render_utils_matcher(added, removed);
  3513. chunks.forEach(function (chunk) {
  3514. if (chunk[0].length === 1 && chunk[1].length === 1) {
  3515. var dist = distance(chunk[0][0], chunk[1][0]);
  3516. if (dist < matchWordsThreshold) {
  3517. changedWords.push(chunk[0][0]);
  3518. changedWords.push(chunk[1][0]);
  3519. }
  3520. }
  3521. });
  3522. }
  3523. var highlightedLine = diff.reduce(function (highlightedLine, part) {
  3524. var elemType = part.added ? 'ins' : part.removed ? 'del' : null;
  3525. var addClass = changedWords.indexOf(part) > -1 ? ' class="d2h-change"' : '';
  3526. var escapedValue = escapeForHtml(part.value);
  3527. return elemType !== null
  3528. ? highlightedLine + "<" + elemType + addClass + ">" + escapedValue + "</" + elemType + ">"
  3529. : "" + highlightedLine + escapedValue;
  3530. }, '');
  3531. return {
  3532. oldLine: {
  3533. prefix: line1.prefix,
  3534. content: removeInsElements(highlightedLine),
  3535. },
  3536. newLine: {
  3537. prefix: line2.prefix,
  3538. content: removeDelElements(highlightedLine),
  3539. },
  3540. };
  3541. }
  3542. //# sourceMappingURL=render-utils.js.map
  3543. // CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/file-list-renderer.js
  3544.  
  3545. var baseTemplatesPath = 'file-summary';
  3546. var iconsBaseTemplatesPath = 'icon';
  3547. function render(diffFiles, hoganUtils) {
  3548. var files = diffFiles
  3549. .map(function (file) {
  3550. return hoganUtils.render(baseTemplatesPath, 'line', {
  3551. fileHtmlId: getHtmlId(file),
  3552. oldName: file.oldName,
  3553. newName: file.newName,
  3554. fileName: filenameDiff(file),
  3555. deletedLines: '-' + file.deletedLines,
  3556. addedLines: '+' + file.addedLines,
  3557. }, {
  3558. fileIcon: hoganUtils.template(iconsBaseTemplatesPath, getFileIcon(file)),
  3559. });
  3560. })
  3561. .join('\n');
  3562. return hoganUtils.render(baseTemplatesPath, 'wrapper', {
  3563. filesNumber: diffFiles.length,
  3564. files: files,
  3565. });
  3566. }
  3567. //# sourceMappingURL=file-list-renderer.js.map
  3568. // CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/line-by-line-renderer.js
  3569. var line_by_line_renderer_assign = (undefined && undefined.__assign) || function () {
  3570. line_by_line_renderer_assign = Object.assign || function(t) {
  3571. for (var s, i = 1, n = arguments.length; i < n; i++) {
  3572. s = arguments[i];
  3573. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  3574. t[p] = s[p];
  3575. }
  3576. return t;
  3577. };
  3578. return line_by_line_renderer_assign.apply(this, arguments);
  3579. };
  3580.  
  3581.  
  3582.  
  3583. var defaultLineByLineRendererConfig = line_by_line_renderer_assign(line_by_line_renderer_assign({}, defaultRenderConfig), { renderNothingWhenEmpty: false, matchingMaxComparisons: 2500, maxLineSizeInBlockForComparison: 200 });
  3584. var genericTemplatesPath = 'generic';
  3585. var line_by_line_renderer_baseTemplatesPath = 'line-by-line';
  3586. var line_by_line_renderer_iconsBaseTemplatesPath = 'icon';
  3587. var tagsBaseTemplatesPath = 'tag';
  3588. var line_by_line_renderer_LineByLineRenderer = (function () {
  3589. function LineByLineRenderer(hoganUtils, config) {
  3590. if (config === void 0) { config = {}; }
  3591. this.hoganUtils = hoganUtils;
  3592. this.config = line_by_line_renderer_assign(line_by_line_renderer_assign({}, defaultLineByLineRendererConfig), config);
  3593. }
  3594. LineByLineRenderer.prototype.render = function (diffFiles) {
  3595. var _this = this;
  3596. var diffsHtml = diffFiles
  3597. .map(function (file) {
  3598. var diffs;
  3599. if (file.blocks.length) {
  3600. diffs = _this.generateFileHtml(file);
  3601. }
  3602. else {
  3603. diffs = _this.generateEmptyDiff();
  3604. }
  3605. return _this.makeFileDiffHtml(file, diffs);
  3606. })
  3607. .join('\n');
  3608. return this.hoganUtils.render(genericTemplatesPath, 'wrapper', { content: diffsHtml });
  3609. };
  3610. LineByLineRenderer.prototype.makeFileDiffHtml = function (file, diffs) {
  3611. if (this.config.renderNothingWhenEmpty && Array.isArray(file.blocks) && file.blocks.length === 0)
  3612. return '';
  3613. var fileDiffTemplate = this.hoganUtils.template(line_by_line_renderer_baseTemplatesPath, 'file-diff');
  3614. var filePathTemplate = this.hoganUtils.template(genericTemplatesPath, 'file-path');
  3615. var fileIconTemplate = this.hoganUtils.template(line_by_line_renderer_iconsBaseTemplatesPath, 'file');
  3616. var fileTagTemplate = this.hoganUtils.template(tagsBaseTemplatesPath, getFileIcon(file));
  3617. return fileDiffTemplate.render({
  3618. file: file,
  3619. fileHtmlId: getHtmlId(file),
  3620. diffs: diffs,
  3621. filePath: filePathTemplate.render({
  3622. fileDiffName: filenameDiff(file),
  3623. }, {
  3624. fileIcon: fileIconTemplate,
  3625. fileTag: fileTagTemplate,
  3626. }),
  3627. });
  3628. };
  3629. LineByLineRenderer.prototype.generateEmptyDiff = function () {
  3630. return this.hoganUtils.render(genericTemplatesPath, 'empty-diff', {
  3631. contentClass: 'd2h-code-line',
  3632. CSSLineClass: CSSLineClass,
  3633. });
  3634. };
  3635. LineByLineRenderer.prototype.generateFileHtml = function (file) {
  3636. var _this = this;
  3637. var matcher = newMatcherFn(newDistanceFn(function (e) { return deconstructLine(e.content, file.isCombined).content; }));
  3638. return file.blocks
  3639. .map(function (block) {
  3640. var lines = _this.hoganUtils.render(genericTemplatesPath, 'block-header', {
  3641. CSSLineClass: CSSLineClass,
  3642. blockHeader: block.header,
  3643. lineClass: 'd2h-code-linenumber',
  3644. contentClass: 'd2h-code-line',
  3645. });
  3646. _this.applyLineGroupping(block).forEach(function (_a) {
  3647. var contextLines = _a[0], oldLines = _a[1], newLines = _a[2];
  3648. if (oldLines.length && newLines.length && !contextLines.length) {
  3649. _this.applyRematchMatching(oldLines, newLines, matcher).map(function (_a) {
  3650. var oldLines = _a[0], newLines = _a[1];
  3651. var _b = _this.processChangedLines(file.isCombined, oldLines, newLines), left = _b.left, right = _b.right;
  3652. lines += left;
  3653. lines += right;
  3654. });
  3655. }
  3656. else if (contextLines.length) {
  3657. contextLines.forEach(function (line) {
  3658. var _a = deconstructLine(line.content, file.isCombined), prefix = _a.prefix, content = _a.content;
  3659. lines += _this.generateSingleLineHtml({
  3660. type: CSSLineClass.CONTEXT,
  3661. prefix: prefix,
  3662. content: content,
  3663. oldNumber: line.oldNumber,
  3664. newNumber: line.newNumber,
  3665. });
  3666. });
  3667. }
  3668. else if (oldLines.length || newLines.length) {
  3669. var _b = _this.processChangedLines(file.isCombined, oldLines, newLines), left = _b.left, right = _b.right;
  3670. lines += left;
  3671. lines += right;
  3672. }
  3673. else {
  3674. console.error('Unknown state reached while processing groups of lines', contextLines, oldLines, newLines);
  3675. }
  3676. });
  3677. return lines;
  3678. })
  3679. .join('\n');
  3680. };
  3681. LineByLineRenderer.prototype.applyLineGroupping = function (block) {
  3682. var blockLinesGroups = [];
  3683. var oldLines = [];
  3684. var newLines = [];
  3685. for (var i = 0; i < block.lines.length; i++) {
  3686. var diffLine = block.lines[i];
  3687. if ((diffLine.type !== LineType.INSERT && newLines.length) ||
  3688. (diffLine.type === LineType.CONTEXT && oldLines.length > 0)) {
  3689. blockLinesGroups.push([[], oldLines, newLines]);
  3690. oldLines = [];
  3691. newLines = [];
  3692. }
  3693. if (diffLine.type === LineType.CONTEXT) {
  3694. blockLinesGroups.push([[diffLine], [], []]);
  3695. }
  3696. else if (diffLine.type === LineType.INSERT && oldLines.length === 0) {
  3697. blockLinesGroups.push([[], [], [diffLine]]);
  3698. }
  3699. else if (diffLine.type === LineType.INSERT && oldLines.length > 0) {
  3700. newLines.push(diffLine);
  3701. }
  3702. else if (diffLine.type === LineType.DELETE) {
  3703. oldLines.push(diffLine);
  3704. }
  3705. }
  3706. if (oldLines.length || newLines.length) {
  3707. blockLinesGroups.push([[], oldLines, newLines]);
  3708. oldLines = [];
  3709. newLines = [];
  3710. }
  3711. return blockLinesGroups;
  3712. };
  3713. LineByLineRenderer.prototype.applyRematchMatching = function (oldLines, newLines, matcher) {
  3714. var comparisons = oldLines.length * newLines.length;
  3715. var maxLineSizeInBlock = Math.max.apply(null, [0].concat(oldLines.concat(newLines).map(function (elem) { return elem.content.length; })));
  3716. var doMatching = comparisons < this.config.matchingMaxComparisons &&
  3717. maxLineSizeInBlock < this.config.maxLineSizeInBlockForComparison &&
  3718. (this.config.matching === 'lines' || this.config.matching === 'words');
  3719. return doMatching ? matcher(oldLines, newLines) : [[oldLines, newLines]];
  3720. };
  3721. LineByLineRenderer.prototype.processChangedLines = function (isCombined, oldLines, newLines) {
  3722. var fileHtml = {
  3723. right: '',
  3724. left: '',
  3725. };
  3726. var maxLinesNumber = Math.max(oldLines.length, newLines.length);
  3727. for (var i = 0; i < maxLinesNumber; i++) {
  3728. var oldLine = oldLines[i];
  3729. var newLine = newLines[i];
  3730. var diff = oldLine !== undefined && newLine !== undefined
  3731. ? diffHighlight(oldLine.content, newLine.content, isCombined, this.config)
  3732. : undefined;
  3733. var preparedOldLine = oldLine !== undefined && oldLine.oldNumber !== undefined
  3734. ? line_by_line_renderer_assign(line_by_line_renderer_assign({}, (diff !== undefined
  3735. ? {
  3736. prefix: diff.oldLine.prefix,
  3737. content: diff.oldLine.content,
  3738. type: CSSLineClass.DELETE_CHANGES,
  3739. }
  3740. : 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;
  3741. var preparedNewLine = newLine !== undefined && newLine.newNumber !== undefined
  3742. ? line_by_line_renderer_assign(line_by_line_renderer_assign({}, (diff !== undefined
  3743. ? {
  3744. prefix: diff.newLine.prefix,
  3745. content: diff.newLine.content,
  3746. type: CSSLineClass.INSERT_CHANGES,
  3747. }
  3748. : 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;
  3749. var _a = this.generateLineHtml(preparedOldLine, preparedNewLine), left = _a.left, right = _a.right;
  3750. fileHtml.left += left;
  3751. fileHtml.right += right;
  3752. }
  3753. return fileHtml;
  3754. };
  3755. LineByLineRenderer.prototype.generateLineHtml = function (oldLine, newLine) {
  3756. return {
  3757. left: this.generateSingleLineHtml(oldLine),
  3758. right: this.generateSingleLineHtml(newLine),
  3759. };
  3760. };
  3761. LineByLineRenderer.prototype.generateSingleLineHtml = function (line) {
  3762. if (line === undefined)
  3763. return '';
  3764. var lineNumberHtml = this.hoganUtils.render(line_by_line_renderer_baseTemplatesPath, 'numbers', {
  3765. oldNumber: line.oldNumber || '',
  3766. newNumber: line.newNumber || '',
  3767. });
  3768. return this.hoganUtils.render(genericTemplatesPath, 'line', {
  3769. type: line.type,
  3770. lineClass: 'd2h-code-linenumber',
  3771. contentClass: 'd2h-code-line',
  3772. prefix: line.prefix === ' ' ? '&nbsp;' : line.prefix,
  3773. content: line.content,
  3774. lineNumber: lineNumberHtml,
  3775. });
  3776. };
  3777. return LineByLineRenderer;
  3778. }());
  3779. /* harmony default export */ var line_by_line_renderer = (line_by_line_renderer_LineByLineRenderer);
  3780. //# sourceMappingURL=line-by-line-renderer.js.map
  3781. // CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/side-by-side-renderer.js
  3782. var side_by_side_renderer_assign = (undefined && undefined.__assign) || function () {
  3783. side_by_side_renderer_assign = Object.assign || function(t) {
  3784. for (var s, i = 1, n = arguments.length; i < n; i++) {
  3785. s = arguments[i];
  3786. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  3787. t[p] = s[p];
  3788. }
  3789. return t;
  3790. };
  3791. return side_by_side_renderer_assign.apply(this, arguments);
  3792. };
  3793.  
  3794.  
  3795.  
  3796. var defaultSideBySideRendererConfig = side_by_side_renderer_assign(side_by_side_renderer_assign({}, defaultRenderConfig), { renderNothingWhenEmpty: false, matchingMaxComparisons: 2500, maxLineSizeInBlockForComparison: 200 });
  3797. var side_by_side_renderer_genericTemplatesPath = 'generic';
  3798. var side_by_side_renderer_baseTemplatesPath = 'side-by-side';
  3799. var side_by_side_renderer_iconsBaseTemplatesPath = 'icon';
  3800. var side_by_side_renderer_tagsBaseTemplatesPath = 'tag';
  3801. var side_by_side_renderer_SideBySideRenderer = (function () {
  3802. function SideBySideRenderer(hoganUtils, config) {
  3803. if (config === void 0) { config = {}; }
  3804. this.hoganUtils = hoganUtils;
  3805. this.config = side_by_side_renderer_assign(side_by_side_renderer_assign({}, defaultSideBySideRendererConfig), config);
  3806. }
  3807. SideBySideRenderer.prototype.render = function (diffFiles) {
  3808. var _this = this;
  3809. var diffsHtml = diffFiles
  3810. .map(function (file) {
  3811. var diffs;
  3812. if (file.blocks.length) {
  3813. diffs = _this.generateFileHtml(file);
  3814. }
  3815. else {
  3816. diffs = _this.generateEmptyDiff();
  3817. }
  3818. return _this.makeFileDiffHtml(file, diffs);
  3819. })
  3820. .join('\n');
  3821. return this.hoganUtils.render(side_by_side_renderer_genericTemplatesPath, 'wrapper', { content: diffsHtml });
  3822. };
  3823. SideBySideRenderer.prototype.makeFileDiffHtml = function (file, diffs) {
  3824. if (this.config.renderNothingWhenEmpty && Array.isArray(file.blocks) && file.blocks.length === 0)
  3825. return '';
  3826. var fileDiffTemplate = this.hoganUtils.template(side_by_side_renderer_baseTemplatesPath, 'file-diff');
  3827. var filePathTemplate = this.hoganUtils.template(side_by_side_renderer_genericTemplatesPath, 'file-path');
  3828. var fileIconTemplate = this.hoganUtils.template(side_by_side_renderer_iconsBaseTemplatesPath, 'file');
  3829. var fileTagTemplate = this.hoganUtils.template(side_by_side_renderer_tagsBaseTemplatesPath, getFileIcon(file));
  3830. return fileDiffTemplate.render({
  3831. file: file,
  3832. fileHtmlId: getHtmlId(file),
  3833. diffs: diffs,
  3834. filePath: filePathTemplate.render({
  3835. fileDiffName: filenameDiff(file),
  3836. }, {
  3837. fileIcon: fileIconTemplate,
  3838. fileTag: fileTagTemplate,
  3839. }),
  3840. });
  3841. };
  3842. SideBySideRenderer.prototype.generateEmptyDiff = function () {
  3843. return {
  3844. right: '',
  3845. left: this.hoganUtils.render(side_by_side_renderer_genericTemplatesPath, 'empty-diff', {
  3846. contentClass: 'd2h-code-side-line',
  3847. CSSLineClass: CSSLineClass,
  3848. }),
  3849. };
  3850. };
  3851. SideBySideRenderer.prototype.generateFileHtml = function (file) {
  3852. var _this = this;
  3853. var matcher = newMatcherFn(newDistanceFn(function (e) { return deconstructLine(e.content, file.isCombined).content; }));
  3854. return file.blocks
  3855. .map(function (block) {
  3856. var fileHtml = {
  3857. left: _this.makeHeaderHtml(block.header),
  3858. right: _this.makeHeaderHtml(''),
  3859. };
  3860. _this.applyLineGroupping(block).forEach(function (_a) {
  3861. var contextLines = _a[0], oldLines = _a[1], newLines = _a[2];
  3862. if (oldLines.length && newLines.length && !contextLines.length) {
  3863. _this.applyRematchMatching(oldLines, newLines, matcher).map(function (_a) {
  3864. var oldLines = _a[0], newLines = _a[1];
  3865. var _b = _this.processChangedLines(file.isCombined, oldLines, newLines), left = _b.left, right = _b.right;
  3866. fileHtml.left += left;
  3867. fileHtml.right += right;
  3868. });
  3869. }
  3870. else if (contextLines.length) {
  3871. contextLines.forEach(function (line) {
  3872. var _a = deconstructLine(line.content, file.isCombined), prefix = _a.prefix, content = _a.content;
  3873. var _b = _this.generateLineHtml({
  3874. type: CSSLineClass.CONTEXT,
  3875. prefix: prefix,
  3876. content: content,
  3877. number: line.oldNumber,
  3878. }, {
  3879. type: CSSLineClass.CONTEXT,
  3880. prefix: prefix,
  3881. content: content,
  3882. number: line.newNumber,
  3883. }), left = _b.left, right = _b.right;
  3884. fileHtml.left += left;
  3885. fileHtml.right += right;
  3886. });
  3887. }
  3888. else if (oldLines.length || newLines.length) {
  3889. var _b = _this.processChangedLines(file.isCombined, oldLines, newLines), left = _b.left, right = _b.right;
  3890. fileHtml.left += left;
  3891. fileHtml.right += right;
  3892. }
  3893. else {
  3894. console.error('Unknown state reached while processing groups of lines', contextLines, oldLines, newLines);
  3895. }
  3896. });
  3897. return fileHtml;
  3898. })
  3899. .reduce(function (accomulated, html) {
  3900. return { left: accomulated.left + html.left, right: accomulated.right + html.right };
  3901. }, { left: '', right: '' });
  3902. };
  3903. SideBySideRenderer.prototype.applyLineGroupping = function (block) {
  3904. var blockLinesGroups = [];
  3905. var oldLines = [];
  3906. var newLines = [];
  3907. for (var i = 0; i < block.lines.length; i++) {
  3908. var diffLine = block.lines[i];
  3909. if ((diffLine.type !== LineType.INSERT && newLines.length) ||
  3910. (diffLine.type === LineType.CONTEXT && oldLines.length > 0)) {
  3911. blockLinesGroups.push([[], oldLines, newLines]);
  3912. oldLines = [];
  3913. newLines = [];
  3914. }
  3915. if (diffLine.type === LineType.CONTEXT) {
  3916. blockLinesGroups.push([[diffLine], [], []]);
  3917. }
  3918. else if (diffLine.type === LineType.INSERT && oldLines.length === 0) {
  3919. blockLinesGroups.push([[], [], [diffLine]]);
  3920. }
  3921. else if (diffLine.type === LineType.INSERT && oldLines.length > 0) {
  3922. newLines.push(diffLine);
  3923. }
  3924. else if (diffLine.type === LineType.DELETE) {
  3925. oldLines.push(diffLine);
  3926. }
  3927. }
  3928. if (oldLines.length || newLines.length) {
  3929. blockLinesGroups.push([[], oldLines, newLines]);
  3930. oldLines = [];
  3931. newLines = [];
  3932. }
  3933. return blockLinesGroups;
  3934. };
  3935. SideBySideRenderer.prototype.applyRematchMatching = function (oldLines, newLines, matcher) {
  3936. var comparisons = oldLines.length * newLines.length;
  3937. var maxLineSizeInBlock = Math.max.apply(null, [0].concat(oldLines.concat(newLines).map(function (elem) { return elem.content.length; })));
  3938. var doMatching = comparisons < this.config.matchingMaxComparisons &&
  3939. maxLineSizeInBlock < this.config.maxLineSizeInBlockForComparison &&
  3940. (this.config.matching === 'lines' || this.config.matching === 'words');
  3941. return doMatching ? matcher(oldLines, newLines) : [[oldLines, newLines]];
  3942. };
  3943. SideBySideRenderer.prototype.makeHeaderHtml = function (blockHeader) {
  3944. return this.hoganUtils.render(side_by_side_renderer_genericTemplatesPath, 'block-header', {
  3945. CSSLineClass: CSSLineClass,
  3946. blockHeader: blockHeader,
  3947. lineClass: 'd2h-code-side-linenumber',
  3948. contentClass: 'd2h-code-side-line',
  3949. });
  3950. };
  3951. SideBySideRenderer.prototype.processChangedLines = function (isCombined, oldLines, newLines) {
  3952. var fileHtml = {
  3953. right: '',
  3954. left: '',
  3955. };
  3956. var maxLinesNumber = Math.max(oldLines.length, newLines.length);
  3957. for (var i = 0; i < maxLinesNumber; i++) {
  3958. var oldLine = oldLines[i];
  3959. var newLine = newLines[i];
  3960. var diff = oldLine !== undefined && newLine !== undefined
  3961. ? diffHighlight(oldLine.content, newLine.content, isCombined, this.config)
  3962. : undefined;
  3963. var preparedOldLine = oldLine !== undefined && oldLine.oldNumber !== undefined
  3964. ? side_by_side_renderer_assign(side_by_side_renderer_assign({}, (diff !== undefined
  3965. ? {
  3966. prefix: diff.oldLine.prefix,
  3967. content: diff.oldLine.content,
  3968. type: CSSLineClass.DELETE_CHANGES,
  3969. }
  3970. : side_by_side_renderer_assign(side_by_side_renderer_assign({}, deconstructLine(oldLine.content, isCombined)), { type: toCSSClass(oldLine.type) }))), { number: oldLine.oldNumber }) : undefined;
  3971. var preparedNewLine = newLine !== undefined && newLine.newNumber !== undefined
  3972. ? side_by_side_renderer_assign(side_by_side_renderer_assign({}, (diff !== undefined
  3973. ? {
  3974. prefix: diff.newLine.prefix,
  3975. content: diff.newLine.content,
  3976. type: CSSLineClass.INSERT_CHANGES,
  3977. }
  3978. : side_by_side_renderer_assign(side_by_side_renderer_assign({}, deconstructLine(newLine.content, isCombined)), { type: toCSSClass(newLine.type) }))), { number: newLine.newNumber }) : undefined;
  3979. var _a = this.generateLineHtml(preparedOldLine, preparedNewLine), left = _a.left, right = _a.right;
  3980. fileHtml.left += left;
  3981. fileHtml.right += right;
  3982. }
  3983. return fileHtml;
  3984. };
  3985. SideBySideRenderer.prototype.generateLineHtml = function (oldLine, newLine) {
  3986. return {
  3987. left: this.generateSingleHtml(oldLine),
  3988. right: this.generateSingleHtml(newLine),
  3989. };
  3990. };
  3991. SideBySideRenderer.prototype.generateSingleHtml = function (line) {
  3992. var lineClass = 'd2h-code-side-linenumber';
  3993. var contentClass = 'd2h-code-side-line';
  3994. return this.hoganUtils.render(side_by_side_renderer_genericTemplatesPath, 'line', {
  3995. type: (line === null || line === void 0 ? void 0 : line.type) || CSSLineClass.CONTEXT + " d2h-emptyplaceholder",
  3996. lineClass: line !== undefined ? lineClass : lineClass + " d2h-code-side-emptyplaceholder",
  3997. contentClass: line !== undefined ? contentClass : contentClass + " d2h-code-side-emptyplaceholder",
  3998. prefix: (line === null || line === void 0 ? void 0 : line.prefix) === ' ' ? '&nbsp;' : line === null || line === void 0 ? void 0 : line.prefix,
  3999. content: line === null || line === void 0 ? void 0 : line.content,
  4000. lineNumber: line === null || line === void 0 ? void 0 : line.number,
  4001. });
  4002. };
  4003. return SideBySideRenderer;
  4004. }());
  4005. /* harmony default export */ var side_by_side_renderer = (side_by_side_renderer_SideBySideRenderer);
  4006. //# sourceMappingURL=side-by-side-renderer.js.map
  4007. // EXTERNAL MODULE: ./node_modules/hogan.js/lib/hogan.js
  4008. var hogan = __webpack_require__("Ruv9");
  4009.  
  4010. // CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/diff2html-templates.js
  4011.  
  4012. var defaultTemplates = {};
  4013. 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: {} });
  4014. 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: {} });
  4015. 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: {} });
  4016. 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: {} });
  4017. 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: {} });
  4018. 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, "{{ }}")) {
  4019. 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); });
  4020. c.pop();
  4021. } if (!t.s(t.f("prefix", c, p, 1), c, p, 1, 0, 0, "")) {
  4022. t.b(" <span class=\"d2h-code-line-prefix\">&nbsp;</span>");
  4023. t.b("\n" + i);
  4024. } ; if (t.s(t.f("content", c, p, 1), c, p, 0, 380, 454, "{{ }}")) {
  4025. 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); });
  4026. c.pop();
  4027. } if (!t.s(t.f("content", c, p, 1), c, p, 1, 0, 0, "")) {
  4028. t.b(" <span class=\"d2h-code-line-ctn\"><br></span>");
  4029. t.b("\n" + i);
  4030. } ; t.b(" </div>"); t.b("\n" + i); t.b(" </td>"); t.b("\n" + i); t.b("</tr>"); return t.fl(); }, partials: {}, subs: {} });
  4031. 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: {} });
  4032. 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: {} });
  4033. 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: {} });
  4034. 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: {} });
  4035. 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: {} });
  4036. 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: {} });
  4037. 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: {} });
  4038. 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: {} });
  4039. 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: {} });
  4040. 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: {} });
  4041. 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: {} });
  4042. 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: {} });
  4043. 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: {} });
  4044. //# sourceMappingURL=diff2html-templates.js.map
  4045. // CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/hoganjs-utils.js
  4046. var hoganjs_utils_assign = (undefined && undefined.__assign) || function () {
  4047. hoganjs_utils_assign = Object.assign || function(t) {
  4048. for (var s, i = 1, n = arguments.length; i < n; i++) {
  4049. s = arguments[i];
  4050. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  4051. t[p] = s[p];
  4052. }
  4053. return t;
  4054. };
  4055. return hoganjs_utils_assign.apply(this, arguments);
  4056. };
  4057.  
  4058.  
  4059. var hoganjs_utils_HoganJsUtils = (function () {
  4060. function HoganJsUtils(_a) {
  4061. var _b = _a.compiledTemplates, compiledTemplates = _b === void 0 ? {} : _b, _c = _a.rawTemplates, rawTemplates = _c === void 0 ? {} : _c;
  4062. var compiledRawTemplates = Object.entries(rawTemplates).reduce(function (previousTemplates, _a) {
  4063. var _b;
  4064. var name = _a[0], templateString = _a[1];
  4065. var compiledTemplate = hogan["compile"](templateString, { asString: false });
  4066. return hoganjs_utils_assign(hoganjs_utils_assign({}, previousTemplates), (_b = {}, _b[name] = compiledTemplate, _b));
  4067. }, {});
  4068. this.preCompiledTemplates = hoganjs_utils_assign(hoganjs_utils_assign(hoganjs_utils_assign({}, defaultTemplates), compiledTemplates), compiledRawTemplates);
  4069. }
  4070. HoganJsUtils.compile = function (templateString) {
  4071. return hogan["compile"](templateString, { asString: false });
  4072. };
  4073. HoganJsUtils.prototype.render = function (namespace, view, params, partials, indent) {
  4074. var templateKey = this.templateKey(namespace, view);
  4075. try {
  4076. var template = this.preCompiledTemplates[templateKey];
  4077. return template.render(params, partials, indent);
  4078. }
  4079. catch (e) {
  4080. throw new Error("Could not find template to render '" + templateKey + "'");
  4081. }
  4082. };
  4083. HoganJsUtils.prototype.template = function (namespace, view) {
  4084. return this.preCompiledTemplates[this.templateKey(namespace, view)];
  4085. };
  4086. HoganJsUtils.prototype.templateKey = function (namespace, view) {
  4087. return namespace + "-" + view;
  4088. };
  4089. return HoganJsUtils;
  4090. }());
  4091. /* harmony default export */ var hoganjs_utils = (hoganjs_utils_HoganJsUtils);
  4092. //# sourceMappingURL=hoganjs-utils.js.map
  4093. // CONCATENATED MODULE: ./node_modules/diff2html/lib-esm/diff2html.js
  4094. var diff2html_assign = (undefined && undefined.__assign) || function () {
  4095. diff2html_assign = Object.assign || function(t) {
  4096. for (var s, i = 1, n = arguments.length; i < n; i++) {
  4097. s = arguments[i];
  4098. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  4099. t[p] = s[p];
  4100. }
  4101. return t;
  4102. };
  4103. return diff2html_assign.apply(this, arguments);
  4104. };
  4105.  
  4106.  
  4107.  
  4108.  
  4109.  
  4110.  
  4111. var defaultDiff2HtmlConfig = diff2html_assign(diff2html_assign(diff2html_assign({}, defaultLineByLineRendererConfig), defaultSideBySideRendererConfig), { outputFormat: OutputFormatType.LINE_BY_LINE, drawFileList: true });
  4112. function diff2html_parse(diffInput, configuration) {
  4113. if (configuration === void 0) { configuration = {}; }
  4114. return parse(diffInput, diff2html_assign(diff2html_assign({}, defaultDiff2HtmlConfig), configuration));
  4115. }
  4116. function diff2html_html(diffInput, configuration) {
  4117. if (configuration === void 0) { configuration = {}; }
  4118. var config = diff2html_assign(diff2html_assign({}, defaultDiff2HtmlConfig), configuration);
  4119. var diffJson = typeof diffInput === 'string' ? parse(diffInput, config) : diffInput;
  4120. var hoganUtils = new hoganjs_utils(config);
  4121. var fileList = config.drawFileList ? render(diffJson, hoganUtils) : '';
  4122. var diffOutput = config.outputFormat === 'side-by-side'
  4123. ? new side_by_side_renderer(hoganUtils, config).render(diffJson)
  4124. : new line_by_line_renderer(hoganUtils, config).render(diffJson);
  4125. return fileList + diffOutput;
  4126. }
  4127. //# sourceMappingURL=diff2html.js.map
  4128. // EXTERNAL MODULE: external "$"
  4129. var external_$_ = __webpack_require__("xeH2");
  4130.  
  4131. // CONCATENATED MODULE: ./src/js/utils.js
  4132. function request (url) {
  4133. return new Promise((resolve, reject) => {
  4134. console.log('rew')
  4135. window.GM_xmlhttpRequest({
  4136. url,
  4137. onload: function ({ response, responseText, }) {
  4138. resolve({ response, responseText })
  4139. }
  4140. })
  4141. })
  4142. }
  4143.  
  4144.  
  4145.  
  4146. // CONCATENATED MODULE: ./src/js/index.js
  4147.  
  4148.  
  4149.  
  4150.  
  4151.  
  4152. function main () {
  4153. console.log('start bgm wiki rev diff UserScript')
  4154. initUI()
  4155. }
  4156.  
  4157. function initUI () {
  4158. external_$_('#pagehistory li').each(function () {
  4159. const el = external_$_(this)
  4160. const rev = parseRevEl(el)
  4161. el.prepend(`<input type="checkbox" class="rev-trim21-cn" name="rev" label="select to compare" value="${rev.id}">`)
  4162. })
  4163. external_$_('#columnInSubjectA span.text').append('<a href="#;" id="compare-trim21-cn" tar class="l"> > 比较选中的版本</a>')
  4164. external_$_('#compare-trim21-cn').click(function () {
  4165. const selectedRevs = getSelectedVersion()
  4166. compare(selectedRevs)
  4167. })
  4168. }
  4169.  
  4170. function getSelectedVersion () {
  4171. const selectedVersion = []
  4172. const selectedRev = external_$_('.rev-trim21-cn:checked')
  4173. if (selectedRev.length < 2) {
  4174. window.alert('请选中两个版本进行比较')
  4175. }
  4176. if (selectedRev.length > 2) {
  4177. window.alert('只能比较两个版本')
  4178. }
  4179. selectedRev.each(function () {
  4180. const el = external_$_(this)
  4181. selectedVersion.push(el.val())
  4182. })
  4183. selectedVersion.reverse()
  4184. return selectedVersion
  4185. }
  4186.  
  4187. function compare (revs) {
  4188. console.log('compare')
  4189. external_$_('head').append('<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/diff2html/bundles/css/diff2html.min.css" />')
  4190. const rev1 = getRevInfo(revs[0])
  4191. const rev2 = getRevInfo(revs[1])
  4192. const p1 = request(rev1.url)
  4193. const p2 = request(rev2.url)
  4194. Promise.all([p1, p2]).then(values => {
  4195. const contents = []
  4196. for (const page of values) {
  4197. const jq = external_$_(page.responseText)
  4198. contents.push(jq.find('#subject_infobox').val())
  4199. }
  4200. const d = difflib["unifiedDiff"](contents[0].split('\n'), contents[1].split('\n'), {
  4201. fromfile: rev1.comment,
  4202. tofile: rev2.comment,
  4203. fromfiledate: rev1.date,
  4204. tofiledate: rev2.date,
  4205. lineterm: ''
  4206. })
  4207. const rendered = js_render(d.join('\n'), {})
  4208. show(rendered)
  4209. })
  4210. }
  4211.  
  4212. function getRevs () {
  4213. const revs = []
  4214. external_$_('#pagehistory li').each(function () {
  4215. const el = external_$_(this)
  4216. revs.push(parseRevEl(el))
  4217. })
  4218. return revs
  4219. }
  4220.  
  4221. function parseRevEl (el) {
  4222. const date = el.find('a').first().html()
  4223. const revEL = el.find('a.l:contains("恢复")')
  4224. const revCommentEl = el.find('span.comment')
  4225. let comment = ''
  4226. if (revCommentEl.length) {
  4227. comment = revCommentEl.html()
  4228. comment = comment.substring(1, comment.length - 1)
  4229. }
  4230. const revHref = revEL.attr('href')
  4231. const revID = revHref.split('/').pop()
  4232. return {
  4233. id: revID,
  4234. comment,
  4235. date,
  4236. url: revHref,
  4237. }
  4238. }
  4239.  
  4240. function getRevInfo (revID) {
  4241. for (const rev of getRevs()) {
  4242. if (rev.id === revID) {
  4243. console.log(revID, rev)
  4244. return rev
  4245. }
  4246. }
  4247. }
  4248.  
  4249. function js_render (diff) {
  4250. return diff2html_html(diff)
  4251. }
  4252.  
  4253. function show (html) {
  4254. const el = external_$_('#show-trim21-cn')
  4255. if (el.length) {
  4256. el.html(html)
  4257. } else {
  4258. external_$_('#columnInSubjectA').prepend('<div id=show-trim21-cn></dev>')
  4259. show(html)
  4260. }
  4261. }
  4262.  
  4263. main()
  4264.  
  4265.  
  4266. /***/ }),
  4267.  
  4268. /***/ "qVjC":
  4269. /***/ (function(module, exports, __webpack_require__) {
  4270.  
  4271. // Generated by CoffeeScript 1.3.1
  4272.  
  4273. /*
  4274. Module difflib -- helpers for computing deltas between objects.
  4275.  
  4276. Function getCloseMatches(word, possibilities, n=3, cutoff=0.6):
  4277. Use SequenceMatcher to return list of the best "good enough" matches.
  4278.  
  4279. Function contextDiff(a, b):
  4280. For two lists of strings, return a delta in context diff format.
  4281.  
  4282. Function ndiff(a, b):
  4283. Return a delta: the difference between `a` and `b` (lists of strings).
  4284.  
  4285. Function restore(delta, which):
  4286. Return one of the two sequences that generated an ndiff delta.
  4287.  
  4288. Function unifiedDiff(a, b):
  4289. For two lists of strings, return a delta in unified diff format.
  4290.  
  4291. Class SequenceMatcher:
  4292. A flexible class for comparing pairs of sequences of any type.
  4293.  
  4294. Class Differ:
  4295. For producing human-readable deltas from sequences of lines of text.
  4296. */
  4297.  
  4298.  
  4299. (function() {
  4300. 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,
  4301. __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; };
  4302.  
  4303. floor = Math.floor, max = Math.max, min = Math.min;
  4304.  
  4305. Heap = __webpack_require__("F1pL");
  4306.  
  4307. assert = __webpack_require__("9lTW");
  4308.  
  4309. _calculateRatio = function(matches, length) {
  4310. if (length) {
  4311. return 2.0 * matches / length;
  4312. } else {
  4313. return 1.0;
  4314. }
  4315. };
  4316.  
  4317. _arrayCmp = function(a, b) {
  4318. var i, la, lb, _i, _ref, _ref1;
  4319. _ref = [a.length, b.length], la = _ref[0], lb = _ref[1];
  4320. for (i = _i = 0, _ref1 = min(la, lb); 0 <= _ref1 ? _i < _ref1 : _i > _ref1; i = 0 <= _ref1 ? ++_i : --_i) {
  4321. if (a[i] < b[i]) {
  4322. return -1;
  4323. }
  4324. if (a[i] > b[i]) {
  4325. return 1;
  4326. }
  4327. }
  4328. return la - lb;
  4329. };
  4330.  
  4331. _has = function(obj, key) {
  4332. return Object.prototype.hasOwnProperty.call(obj, key);
  4333. };
  4334.  
  4335. _any = function(items) {
  4336. var item, _i, _len;
  4337. for (_i = 0, _len = items.length; _i < _len; _i++) {
  4338. item = items[_i];
  4339. if (item) {
  4340. return true;
  4341. }
  4342. }
  4343. return false;
  4344. };
  4345.  
  4346. SequenceMatcher = (function() {
  4347.  
  4348. SequenceMatcher.name = 'SequenceMatcher';
  4349.  
  4350. /*
  4351. SequenceMatcher is a flexible class for comparing pairs of sequences of
  4352. any type, so long as the sequence elements are hashable. The basic
  4353. algorithm predates, and is a little fancier than, an algorithm
  4354. published in the late 1980's by Ratcliff and Obershelp under the
  4355. hyperbolic name "gestalt pattern matching". The basic idea is to find
  4356. the longest contiguous matching subsequence that contains no "junk"
  4357. elements (R-O doesn't address junk). The same idea is then applied
  4358. recursively to the pieces of the sequences to the left and to the right
  4359. of the matching subsequence. This does not yield minimal edit
  4360. sequences, but does tend to yield matches that "look right" to people.
  4361. SequenceMatcher tries to compute a "human-friendly diff" between two
  4362. sequences. Unlike e.g. UNIX(tm) diff, the fundamental notion is the
  4363. longest *contiguous* & junk-free matching subsequence. That's what
  4364. catches peoples' eyes. The Windows(tm) windiff has another interesting
  4365. notion, pairing up elements that appear uniquely in each sequence.
  4366. That, and the method here, appear to yield more intuitive difference
  4367. reports than does diff. This method appears to be the least vulnerable
  4368. to synching up on blocks of "junk lines", though (like blank lines in
  4369. ordinary text files, or maybe "<P>" lines in HTML files). That may be
  4370. because this is the only method of the 3 that has a *concept* of
  4371. "junk" <wink>.
  4372. Example, comparing two strings, and considering blanks to be "junk":
  4373. >>> isjunk = (c) -> c is ' '
  4374. >>> s = new SequenceMatcher(isjunk,
  4375. 'private Thread currentThread;',
  4376. 'private volatile Thread currentThread;')
  4377. .ratio() returns a float in [0, 1], measuring the "similarity" of the
  4378. sequences. As a rule of thumb, a .ratio() value over 0.6 means the
  4379. sequences are close matches:
  4380. >>> s.ratio().toPrecision(3)
  4381. '0.866'
  4382. If you're only interested in where the sequences match,
  4383. .getMatchingBlocks() is handy:
  4384. >>> for [a, b, size] in s.getMatchingBlocks()
  4385. ... console.log("a[#{a}] and b[#{b}] match for #{size} elements");
  4386. a[0] and b[0] match for 8 elements
  4387. a[8] and b[17] match for 21 elements
  4388. a[29] and b[38] match for 0 elements
  4389. Note that the last tuple returned by .get_matching_blocks() is always a
  4390. dummy, (len(a), len(b), 0), and this is the only case in which the last
  4391. tuple element (number of elements matched) is 0.
  4392. If you want to know how to change the first sequence into the second,
  4393. use .get_opcodes():
  4394. >>> for [op, a1, a2, b1, b2] in s.getOpcodes()
  4395. ... console.log "#{op} a[#{a1}:#{a2}] b[#{b1}:#{b2}]"
  4396. equal a[0:8] b[0:8]
  4397. insert a[8:8] b[8:17]
  4398. equal a[8:29] b[17:38]
  4399. See the Differ class for a fancy human-friendly file differencer, which
  4400. uses SequenceMatcher both to compare sequences of lines, and to compare
  4401. sequences of characters within similar (near-matching) lines.
  4402. See also function getCloseMatches() in this module, which shows how
  4403. simple code building on SequenceMatcher can be used to do useful work.
  4404. Timing: Basic R-O is cubic time worst case and quadratic time expected
  4405. case. SequenceMatcher is quadratic time for the worst case and has
  4406. expected-case behavior dependent in a complicated way on how many
  4407. elements the sequences have in common; best case time is linear.
  4408. Methods:
  4409. constructor(isjunk=null, a='', b='')
  4410. Construct a SequenceMatcher.
  4411. setSeqs(a, b)
  4412. Set the two sequences to be compared.
  4413. setSeq1(a)
  4414. Set the first sequence to be compared.
  4415. setSeq2(b)
  4416. Set the second sequence to be compared.
  4417. findLongestMatch(alo, ahi, blo, bhi)
  4418. Find longest matching block in a[alo:ahi] and b[blo:bhi].
  4419. getMatchingBlocks()
  4420. Return list of triples describing matching subsequences.
  4421. getOpcodes()
  4422. Return list of 5-tuples describing how to turn a into b.
  4423. ratio()
  4424. Return a measure of the sequences' similarity (float in [0,1]).
  4425. quickRatio()
  4426. Return an upper bound on .ratio() relatively quickly.
  4427. realQuickRatio()
  4428. Return an upper bound on ratio() very quickly.
  4429. */
  4430.  
  4431.  
  4432. function SequenceMatcher(isjunk, a, b, autojunk) {
  4433. this.isjunk = isjunk;
  4434. if (a == null) {
  4435. a = '';
  4436. }
  4437. if (b == null) {
  4438. b = '';
  4439. }
  4440. this.autojunk = autojunk != null ? autojunk : true;
  4441. /*
  4442. Construct a SequenceMatcher.
  4443. Optional arg isjunk is null (the default), or a one-argument
  4444. function that takes a sequence element and returns true iff the
  4445. element is junk. Null is equivalent to passing "(x) -> 0", i.e.
  4446. no elements are considered to be junk. For example, pass
  4447. (x) -> x in ' \t'
  4448. if you're comparing lines as sequences of characters, and don't
  4449. want to synch up on blanks or hard tabs.
  4450. Optional arg a is the first of two sequences to be compared. By
  4451. default, an empty string. The elements of a must be hashable. See
  4452. also .setSeqs() and .setSeq1().
  4453. Optional arg b is the second of two sequences to be compared. By
  4454. default, an empty string. The elements of b must be hashable. See
  4455. also .setSeqs() and .setSeq2().
  4456. Optional arg autojunk should be set to false to disable the
  4457. "automatic junk heuristic" that treats popular elements as junk
  4458. (see module documentation for more information).
  4459. */
  4460.  
  4461. this.a = this.b = null;
  4462. this.setSeqs(a, b);
  4463. }
  4464.  
  4465. SequenceMatcher.prototype.setSeqs = function(a, b) {
  4466. /*
  4467. Set the two sequences to be compared.
  4468. >>> s = new SequenceMatcher()
  4469. >>> s.setSeqs('abcd', 'bcde')
  4470. >>> s.ratio()
  4471. 0.75
  4472. */
  4473. this.setSeq1(a);
  4474. return this.setSeq2(b);
  4475. };
  4476.  
  4477. SequenceMatcher.prototype.setSeq1 = function(a) {
  4478. /*
  4479. Set the first sequence to be compared.
  4480. The second sequence to be compared is not changed.
  4481. >>> s = new SequenceMatcher(null, 'abcd', 'bcde')
  4482. >>> s.ratio()
  4483. 0.75
  4484. >>> s.setSeq1('bcde')
  4485. >>> s.ratio()
  4486. 1.0
  4487. SequenceMatcher computes and caches detailed information about the
  4488. second sequence, so if you want to compare one sequence S against
  4489. many sequences, use .setSeq2(S) once and call .setSeq1(x)
  4490. repeatedly for each of the other sequences.
  4491. See also setSeqs() and setSeq2().
  4492. */
  4493. if (a === this.a) {
  4494. return;
  4495. }
  4496. this.a = a;
  4497. return this.matchingBlocks = this.opcodes = null;
  4498. };
  4499.  
  4500. SequenceMatcher.prototype.setSeq2 = function(b) {
  4501. /*
  4502. Set the second sequence to be compared.
  4503. The first sequence to be compared is not changed.
  4504. >>> s = new SequenceMatcher(null, 'abcd', 'bcde')
  4505. >>> s.ratio()
  4506. 0.75
  4507. >>> s.setSeq2('abcd')
  4508. >>> s.ratio()
  4509. 1.0
  4510. SequenceMatcher computes and caches detailed information about the
  4511. second sequence, so if you want to compare one sequence S against
  4512. many sequences, use .setSeq2(S) once and call .setSeq1(x)
  4513. repeatedly for each of the other sequences.
  4514. See also setSeqs() and setSeq1().
  4515. */
  4516. if (b === this.b) {
  4517. return;
  4518. }
  4519. this.b = b;
  4520. this.matchingBlocks = this.opcodes = null;
  4521. this.fullbcount = null;
  4522. return this._chainB();
  4523. };
  4524.  
  4525. SequenceMatcher.prototype._chainB = function() {
  4526. var b, b2j, elt, i, idxs, indices, isjunk, junk, n, ntest, popular, _i, _j, _len, _len1, _ref;
  4527. b = this.b;
  4528. this.b2j = b2j = {};
  4529. for (i = _i = 0, _len = b.length; _i < _len; i = ++_i) {
  4530. elt = b[i];
  4531. indices = _has(b2j, elt) ? b2j[elt] : b2j[elt] = [];
  4532. indices.push(i);
  4533. }
  4534. junk = {};
  4535. isjunk = this.isjunk;
  4536. if (isjunk) {
  4537. _ref = Object.keys(b2j);
  4538. for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
  4539. elt = _ref[_j];
  4540. if (isjunk(elt)) {
  4541. junk[elt] = true;
  4542. delete b2j[elt];
  4543. }
  4544. }
  4545. }
  4546. popular = {};
  4547. n = b.length;
  4548. if (this.autojunk && n >= 200) {
  4549. ntest = floor(n / 100) + 1;
  4550. for (elt in b2j) {
  4551. idxs = b2j[elt];
  4552. if (idxs.length > ntest) {
  4553. popular[elt] = true;
  4554. delete b2j[elt];
  4555. }
  4556. }
  4557. }
  4558. this.isbjunk = function(b) {
  4559. return _has(junk, b);
  4560. };
  4561. return this.isbpopular = function(b) {
  4562. return _has(popular, b);
  4563. };
  4564. };
  4565.  
  4566. SequenceMatcher.prototype.findLongestMatch = function(alo, ahi, blo, bhi) {
  4567. /*
  4568. Find longest matching block in a[alo...ahi] and b[blo...bhi].
  4569. If isjunk is not defined:
  4570. Return [i,j,k] such that a[i...i+k] is equal to b[j...j+k], where
  4571. alo <= i <= i+k <= ahi
  4572. blo <= j <= j+k <= bhi
  4573. and for all [i',j',k'] meeting those conditions,
  4574. k >= k'
  4575. i <= i'
  4576. and if i == i', j <= j'
  4577. In other words, of all maximal matching blocks, return one that
  4578. starts earliest in a, and of all those maximal matching blocks that
  4579. start earliest in a, return the one that starts earliest in b.
  4580. >>> isjunk = (x) -> x is ' '
  4581. >>> s = new SequenceMatcher(isjunk, ' abcd', 'abcd abcd')
  4582. >>> s.findLongestMatch(0, 5, 0, 9)
  4583. [1, 0, 4]
  4584. >>> s = new SequenceMatcher(null, 'ab', 'c')
  4585. >>> s.findLongestMatch(0, 2, 0, 1)
  4586. [0, 0, 0]
  4587. */
  4588.  
  4589. var a, b, b2j, besti, bestj, bestsize, i, isbjunk, j, j2len, k, newj2len, _i, _j, _len, _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
  4590. _ref = [this.a, this.b, this.b2j, this.isbjunk], a = _ref[0], b = _ref[1], b2j = _ref[2], isbjunk = _ref[3];
  4591. _ref1 = [alo, blo, 0], besti = _ref1[0], bestj = _ref1[1], bestsize = _ref1[2];
  4592. j2len = {};
  4593. for (i = _i = alo; alo <= ahi ? _i < ahi : _i > ahi; i = alo <= ahi ? ++_i : --_i) {
  4594. newj2len = {};
  4595. _ref2 = (_has(b2j, a[i]) ? b2j[a[i]] : []);
  4596. for (_j = 0, _len = _ref2.length; _j < _len; _j++) {
  4597. j = _ref2[_j];
  4598. if (j < blo) {
  4599. continue;
  4600. }
  4601. if (j >= bhi) {
  4602. break;
  4603. }
  4604. k = newj2len[j] = (j2len[j - 1] || 0) + 1;
  4605. if (k > bestsize) {
  4606. _ref3 = [i - k + 1, j - k + 1, k], besti = _ref3[0], bestj = _ref3[1], bestsize = _ref3[2];
  4607. }
  4608. }
  4609. j2len = newj2len;
  4610. }
  4611. while (besti > alo && bestj > blo && !isbjunk(b[bestj - 1]) && a[besti - 1] === b[bestj - 1]) {
  4612. _ref4 = [besti - 1, bestj - 1, bestsize + 1], besti = _ref4[0], bestj = _ref4[1], bestsize = _ref4[2];
  4613. }
  4614. while (besti + bestsize < ahi && bestj + bestsize < bhi && !isbjunk(b[bestj + bestsize]) && a[besti + bestsize] === b[bestj + bestsize]) {
  4615. bestsize++;
  4616. }
  4617. while (besti > alo && bestj > blo && isbjunk(b[bestj - 1]) && a[besti - 1] === b[bestj - 1]) {
  4618. _ref5 = [besti - 1, bestj - 1, bestsize + 1], besti = _ref5[0], bestj = _ref5[1], bestsize = _ref5[2];
  4619. }
  4620. while (besti + bestsize < ahi && bestj + bestsize < bhi && isbjunk(b[bestj + bestsize]) && a[besti + bestsize] === b[bestj + bestsize]) {
  4621. bestsize++;
  4622. }
  4623. return [besti, bestj, bestsize];
  4624. };
  4625.  
  4626. SequenceMatcher.prototype.getMatchingBlocks = function() {
  4627. /*
  4628. Return list of triples describing matching subsequences.
  4629. Each triple is of the form [i, j, n], and means that
  4630. a[i...i+n] == b[j...j+n]. The triples are monotonically increasing in
  4631. i and in j. it's also guaranteed that if
  4632. [i, j, n] and [i', j', n'] are adjacent triples in the list, and
  4633. the second is not the last triple in the list, then i+n != i' or
  4634. j+n != j'. IOW, adjacent triples never describe adjacent equal
  4635. blocks.
  4636. The last triple is a dummy, [a.length, b.length, 0], and is the only
  4637. triple with n==0.
  4638. >>> s = new SequenceMatcher(null, 'abxcd', 'abcd')
  4639. >>> s.getMatchingBlocks()
  4640. [[0, 0, 2], [3, 2, 2], [5, 4, 0]]
  4641. */
  4642.  
  4643. 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;
  4644. if (this.matchingBlocks) {
  4645. return this.matchingBlocks;
  4646. }
  4647. _ref = [this.a.length, this.b.length], la = _ref[0], lb = _ref[1];
  4648. queue = [[0, la, 0, lb]];
  4649. matchingBlocks = [];
  4650. while (queue.length) {
  4651. _ref1 = queue.pop(), alo = _ref1[0], ahi = _ref1[1], blo = _ref1[2], bhi = _ref1[3];
  4652. _ref2 = x = this.findLongestMatch(alo, ahi, blo, bhi), i = _ref2[0], j = _ref2[1], k = _ref2[2];
  4653. if (k) {
  4654. matchingBlocks.push(x);
  4655. if (alo < i && blo < j) {
  4656. queue.push([alo, i, blo, j]);
  4657. }
  4658. if (i + k < ahi && j + k < bhi) {
  4659. queue.push([i + k, ahi, j + k, bhi]);
  4660. }
  4661. }
  4662. }
  4663. matchingBlocks.sort(_arrayCmp);
  4664. i1 = j1 = k1 = 0;
  4665. nonAdjacent = [];
  4666. for (_i = 0, _len = matchingBlocks.length; _i < _len; _i++) {
  4667. _ref3 = matchingBlocks[_i], i2 = _ref3[0], j2 = _ref3[1], k2 = _ref3[2];
  4668. if (i1 + k1 === i2 && j1 + k1 === j2) {
  4669. k1 += k2;
  4670. } else {
  4671. if (k1) {
  4672. nonAdjacent.push([i1, j1, k1]);
  4673. }
  4674. _ref4 = [i2, j2, k2], i1 = _ref4[0], j1 = _ref4[1], k1 = _ref4[2];
  4675. }
  4676. }
  4677. if (k1) {
  4678. nonAdjacent.push([i1, j1, k1]);
  4679. }
  4680. nonAdjacent.push([la, lb, 0]);
  4681. return this.matchingBlocks = nonAdjacent;
  4682. };
  4683.  
  4684. SequenceMatcher.prototype.getOpcodes = function() {
  4685. /*
  4686. Return list of 5-tuples describing how to turn a into b.
  4687. Each tuple is of the form [tag, i1, i2, j1, j2]. The first tuple
  4688. has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the
  4689. tuple preceding it, and likewise for j1 == the previous j2.
  4690. The tags are strings, with these meanings:
  4691. 'replace': a[i1...i2] should be replaced by b[j1...j2]
  4692. 'delete': a[i1...i2] should be deleted.
  4693. Note that j1==j2 in this case.
  4694. 'insert': b[j1...j2] should be inserted at a[i1...i1].
  4695. Note that i1==i2 in this case.
  4696. 'equal': a[i1...i2] == b[j1...j2]
  4697. >>> s = new SequenceMatcher(null, 'qabxcd', 'abycdf')
  4698. >>> s.getOpcodes()
  4699. [ [ 'delete' , 0 , 1 , 0 , 0 ] ,
  4700. [ 'equal' , 1 , 3 , 0 , 2 ] ,
  4701. [ 'replace' , 3 , 4 , 2 , 3 ] ,
  4702. [ 'equal' , 4 , 6 , 3 , 5 ] ,
  4703. [ 'insert' , 6 , 6 , 5 , 6 ] ]
  4704. */
  4705.  
  4706. var ai, answer, bj, i, j, size, tag, _i, _len, _ref, _ref1, _ref2;
  4707. if (this.opcodes) {
  4708. return this.opcodes;
  4709. }
  4710. i = j = 0;
  4711. this.opcodes = answer = [];
  4712. _ref = this.getMatchingBlocks();
  4713. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  4714. _ref1 = _ref[_i], ai = _ref1[0], bj = _ref1[1], size = _ref1[2];
  4715. tag = '';
  4716. if (i < ai && j < bj) {
  4717. tag = 'replace';
  4718. } else if (i < ai) {
  4719. tag = 'delete';
  4720. } else if (j < bj) {
  4721. tag = 'insert';
  4722. }
  4723. if (tag) {
  4724. answer.push([tag, i, ai, j, bj]);
  4725. }
  4726. _ref2 = [ai + size, bj + size], i = _ref2[0], j = _ref2[1];
  4727. if (size) {
  4728. answer.push(['equal', ai, i, bj, j]);
  4729. }
  4730. }
  4731. return answer;
  4732. };
  4733.  
  4734. SequenceMatcher.prototype.getGroupedOpcodes = function(n) {
  4735. var codes, group, groups, i1, i2, j1, j2, nn, tag, _i, _len, _ref, _ref1, _ref2, _ref3;
  4736. if (n == null) {
  4737. n = 3;
  4738. }
  4739. /*
  4740. Isolate change clusters by eliminating ranges with no changes.
  4741. Return a list groups with upto n lines of context.
  4742. Each group is in the same format as returned by get_opcodes().
  4743. >>> a = [1...40].map(String)
  4744. >>> b = a.slice()
  4745. >>> b[8...8] = 'i'
  4746. >>> b[20] += 'x'
  4747. >>> b[23...28] = []
  4748. >>> b[30] += 'y'
  4749. >>> s = new SequenceMatcher(null, a, b)
  4750. >>> s.getGroupedOpcodes()
  4751. [ [ [ 'equal' , 5 , 8 , 5 , 8 ],
  4752. [ 'insert' , 8 , 8 , 8 , 9 ],
  4753. [ 'equal' , 8 , 11 , 9 , 12 ] ],
  4754. [ [ 'equal' , 16 , 19 , 17 , 20 ],
  4755. [ 'replace' , 19 , 20 , 20 , 21 ],
  4756. [ 'equal' , 20 , 22 , 21 , 23 ],
  4757. [ 'delete' , 22 , 27 , 23 , 23 ],
  4758. [ 'equal' , 27 , 30 , 23 , 26 ] ],
  4759. [ [ 'equal' , 31 , 34 , 27 , 30 ],
  4760. [ 'replace' , 34 , 35 , 30 , 31 ],
  4761. [ 'equal' , 35 , 38 , 31 , 34 ] ] ]
  4762. */
  4763.  
  4764. codes = this.getOpcodes();
  4765. if (!codes.length) {
  4766. codes = [['equal', 0, 1, 0, 1]];
  4767. }
  4768. if (codes[0][0] === 'equal') {
  4769. _ref = codes[0], tag = _ref[0], i1 = _ref[1], i2 = _ref[2], j1 = _ref[3], j2 = _ref[4];
  4770. codes[0] = [tag, max(i1, i2 - n), i2, max(j1, j2 - n), j2];
  4771. }
  4772. if (codes[codes.length - 1][0] === 'equal') {
  4773. _ref1 = codes[codes.length - 1], tag = _ref1[0], i1 = _ref1[1], i2 = _ref1[2], j1 = _ref1[3], j2 = _ref1[4];
  4774. codes[codes.length - 1] = [tag, i1, min(i2, i1 + n), j1, min(j2, j1 + n)];
  4775. }
  4776. nn = n + n;
  4777. groups = [];
  4778. group = [];
  4779. for (_i = 0, _len = codes.length; _i < _len; _i++) {
  4780. _ref2 = codes[_i], tag = _ref2[0], i1 = _ref2[1], i2 = _ref2[2], j1 = _ref2[3], j2 = _ref2[4];
  4781. if (tag === 'equal' && i2 - i1 > nn) {
  4782. group.push([tag, i1, min(i2, i1 + n), j1, min(j2, j1 + n)]);
  4783. groups.push(group);
  4784. group = [];
  4785. _ref3 = [max(i1, i2 - n), max(j1, j2 - n)], i1 = _ref3[0], j1 = _ref3[1];
  4786. }
  4787. group.push([tag, i1, i2, j1, j2]);
  4788. }
  4789. if (group.length && !(group.length === 1 && group[0][0] === 'equal')) {
  4790. groups.push(group);
  4791. }
  4792. return groups;
  4793. };
  4794.  
  4795. SequenceMatcher.prototype.ratio = function() {
  4796. /*
  4797. Return a measure of the sequences' similarity (float in [0,1]).
  4798. Where T is the total number of elements in both sequences, and
  4799. M is the number of matches, this is 2.0*M / T.
  4800. Note that this is 1 if the sequences are identical, and 0 if
  4801. they have nothing in common.
  4802. .ratio() is expensive to compute if you haven't already computed
  4803. .getMatchingBlocks() or .getOpcodes(), in which case you may
  4804. want to try .quickRatio() or .realQuickRatio() first to get an
  4805. upper bound.
  4806. >>> s = new SequenceMatcher(null, 'abcd', 'bcde')
  4807. >>> s.ratio()
  4808. 0.75
  4809. >>> s.quickRatio()
  4810. 0.75
  4811. >>> s.realQuickRatio()
  4812. 1.0
  4813. */
  4814.  
  4815. var match, matches, _i, _len, _ref;
  4816. matches = 0;
  4817. _ref = this.getMatchingBlocks();
  4818. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  4819. match = _ref[_i];
  4820. matches += match[2];
  4821. }
  4822. return _calculateRatio(matches, this.a.length + this.b.length);
  4823. };
  4824.  
  4825. SequenceMatcher.prototype.quickRatio = function() {
  4826. /*
  4827. Return an upper bound on ratio() relatively quickly.
  4828. This isn't defined beyond that it is an upper bound on .ratio(), and
  4829. is faster to compute.
  4830. */
  4831.  
  4832. var avail, elt, fullbcount, matches, numb, _i, _j, _len, _len1, _ref, _ref1;
  4833. if (!this.fullbcount) {
  4834. this.fullbcount = fullbcount = {};
  4835. _ref = this.b;
  4836. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  4837. elt = _ref[_i];
  4838. fullbcount[elt] = (fullbcount[elt] || 0) + 1;
  4839. }
  4840. }
  4841. fullbcount = this.fullbcount;
  4842. avail = {};
  4843. matches = 0;
  4844. _ref1 = this.a;
  4845. for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
  4846. elt = _ref1[_j];
  4847. if (_has(avail, elt)) {
  4848. numb = avail[elt];
  4849. } else {
  4850. numb = fullbcount[elt] || 0;
  4851. }
  4852. avail[elt] = numb - 1;
  4853. if (numb > 0) {
  4854. matches++;
  4855. }
  4856. }
  4857. return _calculateRatio(matches, this.a.length + this.b.length);
  4858. };
  4859.  
  4860. SequenceMatcher.prototype.realQuickRatio = function() {
  4861. /*
  4862. Return an upper bound on ratio() very quickly.
  4863. This isn't defined beyond that it is an upper bound on .ratio(), and
  4864. is faster to compute than either .ratio() or .quickRatio().
  4865. */
  4866.  
  4867. var la, lb, _ref;
  4868. _ref = [this.a.length, this.b.length], la = _ref[0], lb = _ref[1];
  4869. return _calculateRatio(min(la, lb), la + lb);
  4870. };
  4871.  
  4872. return SequenceMatcher;
  4873.  
  4874. })();
  4875.  
  4876. getCloseMatches = function(word, possibilities, n, cutoff) {
  4877. var result, s, score, x, _i, _j, _len, _len1, _ref, _results;
  4878. if (n == null) {
  4879. n = 3;
  4880. }
  4881. if (cutoff == null) {
  4882. cutoff = 0.6;
  4883. }
  4884. /*
  4885. Use SequenceMatcher to return list of the best "good enough" matches.
  4886. word is a sequence for which close matches are desired (typically a
  4887. string).
  4888. possibilities is a list of sequences against which to match word
  4889. (typically a list of strings).
  4890. Optional arg n (default 3) is the maximum number of close matches to
  4891. return. n must be > 0.
  4892. Optional arg cutoff (default 0.6) is a float in [0, 1]. Possibilities
  4893. that don't score at least that similar to word are ignored.
  4894. The best (no more than n) matches among the possibilities are returned
  4895. in a list, sorted by similarity score, most similar first.
  4896. >>> getCloseMatches('appel', ['ape', 'apple', 'peach', 'puppy'])
  4897. ['apple', 'ape']
  4898. >>> KEYWORDS = require('coffee-script').RESERVED
  4899. >>> getCloseMatches('wheel', KEYWORDS)
  4900. ['when', 'while']
  4901. >>> getCloseMatches('accost', KEYWORDS)
  4902. ['const']
  4903. */
  4904.  
  4905. if (!(n > 0)) {
  4906. throw new Error("n must be > 0: (" + n + ")");
  4907. }
  4908. if (!((0.0 <= cutoff && cutoff <= 1.0))) {
  4909. throw new Error("cutoff must be in [0.0, 1.0]: (" + cutoff + ")");
  4910. }
  4911. result = [];
  4912. s = new SequenceMatcher();
  4913. s.setSeq2(word);
  4914. for (_i = 0, _len = possibilities.length; _i < _len; _i++) {
  4915. x = possibilities[_i];
  4916. s.setSeq1(x);
  4917. if (s.realQuickRatio() >= cutoff && s.quickRatio() >= cutoff && s.ratio() >= cutoff) {
  4918. result.push([s.ratio(), x]);
  4919. }
  4920. }
  4921. result = Heap.nlargest(result, n, _arrayCmp);
  4922. _results = [];
  4923. for (_j = 0, _len1 = result.length; _j < _len1; _j++) {
  4924. _ref = result[_j], score = _ref[0], x = _ref[1];
  4925. _results.push(x);
  4926. }
  4927. return _results;
  4928. };
  4929.  
  4930. _countLeading = function(line, ch) {
  4931. /*
  4932. Return number of `ch` characters at the start of `line`.
  4933. >>> _countLeading(' abc', ' ')
  4934. 3
  4935. */
  4936.  
  4937. var i, n, _ref;
  4938. _ref = [0, line.length], i = _ref[0], n = _ref[1];
  4939. while (i < n && line[i] === ch) {
  4940. i++;
  4941. }
  4942. return i;
  4943. };
  4944.  
  4945. Differ = (function() {
  4946.  
  4947. Differ.name = 'Differ';
  4948.  
  4949. /*
  4950. Differ is a class for comparing sequences of lines of text, and
  4951. producing human-readable differences or deltas. Differ uses
  4952. SequenceMatcher both to compare sequences of lines, and to compare
  4953. sequences of characters within similar (near-matching) lines.
  4954. Each line of a Differ delta begins with a two-letter code:
  4955. '- ' line unique to sequence 1
  4956. '+ ' line unique to sequence 2
  4957. ' ' line common to both sequences
  4958. '? ' line not present in either input sequence
  4959. Lines beginning with '? ' attempt to guide the eye to intraline
  4960. differences, and were not present in either input sequence. These lines
  4961. can be confusing if the sequences contain tab characters.
  4962. Note that Differ makes no claim to produce a *minimal* diff. To the
  4963. contrary, minimal diffs are often counter-intuitive, because they synch
  4964. up anywhere possible, sometimes accidental matches 100 pages apart.
  4965. Restricting synch points to contiguous matches preserves some notion of
  4966. locality, at the occasional cost of producing a longer diff.
  4967. Example: Comparing two texts.
  4968. >>> text1 = ['1. Beautiful is better than ugly.\n',
  4969. ... '2. Explicit is better than implicit.\n',
  4970. ... '3. Simple is better than complex.\n',
  4971. ... '4. Complex is better than complicated.\n']
  4972. >>> text1.length
  4973. 4
  4974. >>> text2 = ['1. Beautiful is better than ugly.\n',
  4975. ... '3. Simple is better than complex.\n',
  4976. ... '4. Complicated is better than complex.\n',
  4977. ... '5. Flat is better than nested.\n']
  4978. Next we instantiate a Differ object:
  4979. >>> d = new Differ()
  4980. Note that when instantiating a Differ object we may pass functions to
  4981. filter out line and character 'junk'.
  4982. Finally, we compare the two:
  4983. >>> result = d.compare(text1, text2)
  4984. [ ' 1. Beautiful is better than ugly.\n',
  4985. '- 2. Explicit is better than implicit.\n',
  4986. '- 3. Simple is better than complex.\n',
  4987. '+ 3. Simple is better than complex.\n',
  4988. '? ++\n',
  4989. '- 4. Complex is better than complicated.\n',
  4990. '? ^ ---- ^\n',
  4991. '+ 4. Complicated is better than complex.\n',
  4992. '? ++++ ^ ^\n',
  4993. '+ 5. Flat is better than nested.\n' ]
  4994. Methods:
  4995. constructor(linejunk=null, charjunk=null)
  4996. Construct a text differencer, with optional filters.
  4997. compare(a, b)
  4998. Compare two sequences of lines; generate the resulting delta.
  4999. */
  5000.  
  5001.  
  5002. function Differ(linejunk, charjunk) {
  5003. this.linejunk = linejunk;
  5004. this.charjunk = charjunk;
  5005. /*
  5006. Construct a text differencer, with optional filters.
  5007. The two optional keyword parameters are for filter functions:
  5008. - `linejunk`: A function that should accept a single string argument,
  5009. and return true iff the string is junk. The module-level function
  5010. `IS_LINE_JUNK` may be used to filter out lines without visible
  5011. characters, except for at most one splat ('#'). It is recommended
  5012. to leave linejunk null.
  5013. - `charjunk`: A function that should accept a string of length 1. The
  5014. module-level function `IS_CHARACTER_JUNK` may be used to filter out
  5015. whitespace characters (a blank or tab; **note**: bad idea to include
  5016. newline in this!). Use of IS_CHARACTER_JUNK is recommended.
  5017. */
  5018.  
  5019. }
  5020.  
  5021. Differ.prototype.compare = function(a, b) {
  5022. /*
  5023. Compare two sequences of lines; generate the resulting delta.
  5024. Each sequence must contain individual single-line strings ending with
  5025. newlines. Such sequences can be obtained from the `readlines()` method
  5026. of file-like objects. The delta generated also consists of newline-
  5027. terminated strings, ready to be printed as-is via the writeline()
  5028. method of a file-like object.
  5029. Example:
  5030. >>> d = new Differ
  5031. >>> d.compare(['one\n', 'two\n', 'three\n'],
  5032. ... ['ore\n', 'tree\n', 'emu\n'])
  5033. [ '- one\n',
  5034. '? ^\n',
  5035. '+ ore\n',
  5036. '? ^\n',
  5037. '- two\n',
  5038. '- three\n',
  5039. '? -\n',
  5040. '+ tree\n',
  5041. '+ emu\n' ]
  5042. */
  5043.  
  5044. var ahi, alo, bhi, blo, cruncher, g, line, lines, tag, _i, _j, _len, _len1, _ref, _ref1;
  5045. cruncher = new SequenceMatcher(this.linejunk, a, b);
  5046. lines = [];
  5047. _ref = cruncher.getOpcodes();
  5048. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  5049. _ref1 = _ref[_i], tag = _ref1[0], alo = _ref1[1], ahi = _ref1[2], blo = _ref1[3], bhi = _ref1[4];
  5050. switch (tag) {
  5051. case 'replace':
  5052. g = this._fancyReplace(a, alo, ahi, b, blo, bhi);
  5053. break;
  5054. case 'delete':
  5055. g = this._dump('-', a, alo, ahi);
  5056. break;
  5057. case 'insert':
  5058. g = this._dump('+', b, blo, bhi);
  5059. break;
  5060. case 'equal':
  5061. g = this._dump(' ', a, alo, ahi);
  5062. break;
  5063. default:
  5064. throw new Error("unknow tag (" + tag + ")");
  5065. }
  5066. for (_j = 0, _len1 = g.length; _j < _len1; _j++) {
  5067. line = g[_j];
  5068. lines.push(line);
  5069. }
  5070. }
  5071. return lines;
  5072. };
  5073.  
  5074. Differ.prototype._dump = function(tag, x, lo, hi) {
  5075. /*
  5076. Generate comparison results for a same-tagged range.
  5077. */
  5078.  
  5079. var i, _i, _results;
  5080. _results = [];
  5081. for (i = _i = lo; lo <= hi ? _i < hi : _i > hi; i = lo <= hi ? ++_i : --_i) {
  5082. _results.push("" + tag + " " + x[i]);
  5083. }
  5084. return _results;
  5085. };
  5086.  
  5087. Differ.prototype._plainReplace = function(a, alo, ahi, b, blo, bhi) {
  5088. var first, g, line, lines, second, _i, _j, _len, _len1, _ref;
  5089. assert(alo < ahi && blo < bhi);
  5090. if (bhi - blo < ahi - alo) {
  5091. first = this._dump('+', b, blo, bhi);
  5092. second = this._dump('-', a, alo, ahi);
  5093. } else {
  5094. first = this._dump('-', a, alo, ahi);
  5095. second = this._dump('+', b, blo, bhi);
  5096. }
  5097. lines = [];
  5098. _ref = [first, second];
  5099. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  5100. g = _ref[_i];
  5101. for (_j = 0, _len1 = g.length; _j < _len1; _j++) {
  5102. line = g[_j];
  5103. lines.push(line);
  5104. }
  5105. }
  5106. return lines;
  5107. };
  5108.  
  5109. Differ.prototype._fancyReplace = function(a, alo, ahi, b, blo, bhi) {
  5110. /*
  5111. When replacing one block of lines with another, search the blocks
  5112. for *similar* lines; the best-matching pair (if any) is used as a
  5113. synch point, and intraline difference marking is done on the
  5114. similar pair. Lots of work, but often worth it.
  5115. Example:
  5116. >>> d = new Differ
  5117. >>> d._fancyReplace(['abcDefghiJkl\n'], 0, 1,
  5118. ... ['abcdefGhijkl\n'], 0, 1)
  5119. [ '- abcDefghiJkl\n',
  5120. '? ^ ^ ^\n',
  5121. '+ abcdefGhijkl\n',
  5122. '? ^ ^ ^\n' ]
  5123. */
  5124.  
  5125. 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;
  5126. _ref = [0.74, 0.75], bestRatio = _ref[0], cutoff = _ref[1];
  5127. cruncher = new SequenceMatcher(this.charjunk);
  5128. _ref1 = [null, null], eqi = _ref1[0], eqj = _ref1[1];
  5129. lines = [];
  5130. for (j = _i = blo; blo <= bhi ? _i < bhi : _i > bhi; j = blo <= bhi ? ++_i : --_i) {
  5131. bj = b[j];
  5132. cruncher.setSeq2(bj);
  5133. for (i = _j = alo; alo <= ahi ? _j < ahi : _j > ahi; i = alo <= ahi ? ++_j : --_j) {
  5134. ai = a[i];
  5135. if (ai === bj) {
  5136. if (eqi === null) {
  5137. _ref2 = [i, j], eqi = _ref2[0], eqj = _ref2[1];
  5138. }
  5139. continue;
  5140. }
  5141. cruncher.setSeq1(ai);
  5142. if (cruncher.realQuickRatio() > bestRatio && cruncher.quickRatio() > bestRatio && cruncher.ratio() > bestRatio) {
  5143. _ref3 = [cruncher.ratio(), i, j], bestRatio = _ref3[0], besti = _ref3[1], bestj = _ref3[2];
  5144. }
  5145. }
  5146. }
  5147. if (bestRatio < cutoff) {
  5148. if (eqi === null) {
  5149. _ref4 = this._plainReplace(a, alo, ahi, b, blo, bhi);
  5150. for (_k = 0, _len = _ref4.length; _k < _len; _k++) {
  5151. line = _ref4[_k];
  5152. lines.push(line);
  5153. }
  5154. return lines;
  5155. }
  5156. _ref5 = [eqi, eqj, 1.0], besti = _ref5[0], bestj = _ref5[1], bestRatio = _ref5[2];
  5157. } else {
  5158. eqi = null;
  5159. }
  5160. _ref6 = this._fancyHelper(a, alo, besti, b, blo, bestj);
  5161. for (_l = 0, _len1 = _ref6.length; _l < _len1; _l++) {
  5162. line = _ref6[_l];
  5163. lines.push(line);
  5164. }
  5165. _ref7 = [a[besti], b[bestj]], aelt = _ref7[0], belt = _ref7[1];
  5166. if (eqi === null) {
  5167. atags = btags = '';
  5168. cruncher.setSeqs(aelt, belt);
  5169. _ref8 = cruncher.getOpcodes();
  5170. for (_m = 0, _len2 = _ref8.length; _m < _len2; _m++) {
  5171. _ref9 = _ref8[_m], tag = _ref9[0], ai1 = _ref9[1], ai2 = _ref9[2], bj1 = _ref9[3], bj2 = _ref9[4];
  5172. _ref10 = [ai2 - ai1, bj2 - bj1], la = _ref10[0], lb = _ref10[1];
  5173. switch (tag) {
  5174. case 'replace':
  5175. atags += Array(la + 1).join('^');
  5176. btags += Array(lb + 1).join('^');
  5177. break;
  5178. case 'delete':
  5179. atags += Array(la + 1).join('-');
  5180. break;
  5181. case 'insert':
  5182. btags += Array(lb + 1).join('+');
  5183. break;
  5184. case 'equal':
  5185. atags += Array(la + 1).join(' ');
  5186. btags += Array(lb + 1).join(' ');
  5187. break;
  5188. default:
  5189. throw new Error("unknow tag (" + tag + ")");
  5190. }
  5191. }
  5192. _ref11 = this._qformat(aelt, belt, atags, btags);
  5193. for (_n = 0, _len3 = _ref11.length; _n < _len3; _n++) {
  5194. line = _ref11[_n];
  5195. lines.push(line);
  5196. }
  5197. } else {
  5198. lines.push(' ' + aelt);
  5199. }
  5200. _ref12 = this._fancyHelper(a, besti + 1, ahi, b, bestj + 1, bhi);
  5201. for (_o = 0, _len4 = _ref12.length; _o < _len4; _o++) {
  5202. line = _ref12[_o];
  5203. lines.push(line);
  5204. }
  5205. return lines;
  5206. };
  5207.  
  5208. Differ.prototype._fancyHelper = function(a, alo, ahi, b, blo, bhi) {
  5209. var g;
  5210. g = [];
  5211. if (alo < ahi) {
  5212. if (blo < bhi) {
  5213. g = this._fancyReplace(a, alo, ahi, b, blo, bhi);
  5214. } else {
  5215. g = this._dump('-', a, alo, ahi);
  5216. }
  5217. } else if (blo < bhi) {
  5218. g = this._dump('+', b, blo, bhi);
  5219. }
  5220. return g;
  5221. };
  5222.  
  5223. Differ.prototype._qformat = function(aline, bline, atags, btags) {
  5224. /*
  5225. Format "?" output and deal with leading tabs.
  5226. Example:
  5227. >>> d = new Differ
  5228. >>> d._qformat('\tabcDefghiJkl\n', '\tabcdefGhijkl\n',
  5229. [ '- \tabcDefghiJkl\n',
  5230. '? \t ^ ^ ^\n',
  5231. '+ \tabcdefGhijkl\n',
  5232. '? \t ^ ^ ^\n' ]
  5233. */
  5234.  
  5235. var common, lines;
  5236. lines = [];
  5237. common = min(_countLeading(aline, '\t'), _countLeading(bline, '\t'));
  5238. common = min(common, _countLeading(atags.slice(0, common), ' '));
  5239. common = min(common, _countLeading(btags.slice(0, common), ' '));
  5240. atags = atags.slice(common).replace(/\s+$/, '');
  5241. btags = btags.slice(common).replace(/\s+$/, '');
  5242. lines.push('- ' + aline);
  5243. if (atags.length) {
  5244. lines.push("? " + (Array(common + 1).join('\t')) + atags + "\n");
  5245. }
  5246. lines.push('+ ' + bline);
  5247. if (btags.length) {
  5248. lines.push("? " + (Array(common + 1).join('\t')) + btags + "\n");
  5249. }
  5250. return lines;
  5251. };
  5252.  
  5253. return Differ;
  5254.  
  5255. })();
  5256.  
  5257. IS_LINE_JUNK = function(line, pat) {
  5258. if (pat == null) {
  5259. pat = /^\s*#?\s*$/;
  5260. }
  5261. /*
  5262. Return 1 for ignorable line: iff `line` is blank or contains a single '#'.
  5263. Examples:
  5264. >>> IS_LINE_JUNK('\n')
  5265. true
  5266. >>> IS_LINE_JUNK(' # \n')
  5267. true
  5268. >>> IS_LINE_JUNK('hello\n')
  5269. false
  5270. */
  5271.  
  5272. return pat.test(line);
  5273. };
  5274.  
  5275. IS_CHARACTER_JUNK = function(ch, ws) {
  5276. if (ws == null) {
  5277. ws = ' \t';
  5278. }
  5279. /*
  5280. Return 1 for ignorable character: iff `ch` is a space or tab.
  5281. Examples:
  5282. >>> IS_CHARACTER_JUNK(' ').should.be.true
  5283. true
  5284. >>> IS_CHARACTER_JUNK('\t').should.be.true
  5285. true
  5286. >>> IS_CHARACTER_JUNK('\n').should.be.false
  5287. false
  5288. >>> IS_CHARACTER_JUNK('x').should.be.false
  5289. false
  5290. */
  5291.  
  5292. return __indexOf.call(ws, ch) >= 0;
  5293. };
  5294.  
  5295. _formatRangeUnified = function(start, stop) {
  5296. /*
  5297. Convert range to the "ed" format'
  5298. */
  5299.  
  5300. var beginning, length;
  5301. beginning = start + 1;
  5302. length = stop - start;
  5303. if (length === 1) {
  5304. return "" + beginning;
  5305. }
  5306. if (!length) {
  5307. beginning--;
  5308. }
  5309. return "" + beginning + "," + length;
  5310. };
  5311.  
  5312. unifiedDiff = function(a, b, _arg) {
  5313. 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;
  5314. _ref = _arg != null ? _arg : {}, fromfile = _ref.fromfile, tofile = _ref.tofile, fromfiledate = _ref.fromfiledate, tofiledate = _ref.tofiledate, n = _ref.n, lineterm = _ref.lineterm;
  5315. /*
  5316. Compare two sequences of lines; generate the delta as a unified diff.
  5317. Unified diffs are a compact way of showing line changes and a few
  5318. lines of context. The number of context lines is set by 'n' which
  5319. defaults to three.
  5320. By default, the diff control lines (those with ---, +++, or @@) are
  5321. created with a trailing newline.
  5322. For inputs that do not have trailing newlines, set the lineterm
  5323. argument to "" so that the output will be uniformly newline free.
  5324. The unidiff format normally has a header for filenames and modification
  5325. times. Any or all of these may be specified using strings for
  5326. 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'.
  5327. The modification times are normally expressed in the ISO 8601 format.
  5328. Example:
  5329. >>> unifiedDiff('one two three four'.split(' '),
  5330. ... 'zero one tree four'.split(' '), {
  5331. ... fromfile: 'Original'
  5332. ... tofile: 'Current',
  5333. ... fromfiledate: '2005-01-26 23:30:50',
  5334. ... tofiledate: '2010-04-02 10:20:52',
  5335. ... lineterm: ''
  5336. ... })
  5337. [ '--- Original\t2005-01-26 23:30:50',
  5338. '+++ Current\t2010-04-02 10:20:52',
  5339. '@@ -1,4 +1,4 @@',
  5340. '+zero',
  5341. ' one',
  5342. '-two',
  5343. '-three',
  5344. '+tree',
  5345. ' four' ]
  5346. */
  5347.  
  5348. if (fromfile == null) {
  5349. fromfile = '';
  5350. }
  5351. if (tofile == null) {
  5352. tofile = '';
  5353. }
  5354. if (fromfiledate == null) {
  5355. fromfiledate = '';
  5356. }
  5357. if (tofiledate == null) {
  5358. tofiledate = '';
  5359. }
  5360. if (n == null) {
  5361. n = 3;
  5362. }
  5363. if (lineterm == null) {
  5364. lineterm = '\n';
  5365. }
  5366. lines = [];
  5367. started = false;
  5368. _ref1 = (new SequenceMatcher(null, a, b)).getGroupedOpcodes();
  5369. for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
  5370. group = _ref1[_i];
  5371. if (!started) {
  5372. started = true;
  5373. fromdate = fromfiledate ? "\t" + fromfiledate : '';
  5374. todate = tofiledate ? "\t" + tofiledate : '';
  5375. lines.push("--- " + fromfile + fromdate + lineterm);
  5376. lines.push("+++ " + tofile + todate + lineterm);
  5377. }
  5378. _ref2 = [group[0], group[group.length - 1]], first = _ref2[0], last = _ref2[1];
  5379. file1Range = _formatRangeUnified(first[1], last[2]);
  5380. file2Range = _formatRangeUnified(first[3], last[4]);
  5381. lines.push("@@ -" + file1Range + " +" + file2Range + " @@" + lineterm);
  5382. for (_j = 0, _len1 = group.length; _j < _len1; _j++) {
  5383. _ref3 = group[_j], tag = _ref3[0], i1 = _ref3[1], i2 = _ref3[2], j1 = _ref3[3], j2 = _ref3[4];
  5384. if (tag === 'equal') {
  5385. _ref4 = a.slice(i1, i2);
  5386. for (_k = 0, _len2 = _ref4.length; _k < _len2; _k++) {
  5387. line = _ref4[_k];
  5388. lines.push(' ' + line);
  5389. }
  5390. continue;
  5391. }
  5392. if (tag === 'replace' || tag === 'delete') {
  5393. _ref5 = a.slice(i1, i2);
  5394. for (_l = 0, _len3 = _ref5.length; _l < _len3; _l++) {
  5395. line = _ref5[_l];
  5396. lines.push('-' + line);
  5397. }
  5398. }
  5399. if (tag === 'replace' || tag === 'insert') {
  5400. _ref6 = b.slice(j1, j2);
  5401. for (_m = 0, _len4 = _ref6.length; _m < _len4; _m++) {
  5402. line = _ref6[_m];
  5403. lines.push('+' + line);
  5404. }
  5405. }
  5406. }
  5407. }
  5408. return lines;
  5409. };
  5410.  
  5411. _formatRangeContext = function(start, stop) {
  5412. /*
  5413. Convert range to the "ed" format'
  5414. */
  5415.  
  5416. var beginning, length;
  5417. beginning = start + 1;
  5418. length = stop - start;
  5419. if (!length) {
  5420. beginning--;
  5421. }
  5422. if (length <= 1) {
  5423. return "" + beginning;
  5424. }
  5425. return "" + beginning + "," + (beginning + length - 1);
  5426. };
  5427.  
  5428. contextDiff = function(a, b, _arg) {
  5429. 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;
  5430. _ref = _arg != null ? _arg : {}, fromfile = _ref.fromfile, tofile = _ref.tofile, fromfiledate = _ref.fromfiledate, tofiledate = _ref.tofiledate, n = _ref.n, lineterm = _ref.lineterm;
  5431. /*
  5432. Compare two sequences of lines; generate the delta as a context diff.
  5433. Context diffs are a compact way of showing line changes and a few
  5434. lines of context. The number of context lines is set by 'n' which
  5435. defaults to three.
  5436. By default, the diff control lines (those with *** or ---) are
  5437. created with a trailing newline. This is helpful so that inputs
  5438. created from file.readlines() result in diffs that are suitable for
  5439. file.writelines() since both the inputs and outputs have trailing
  5440. newlines.
  5441. For inputs that do not have trailing newlines, set the lineterm
  5442. argument to "" so that the output will be uniformly newline free.
  5443. The context diff format normally has a header for filenames and
  5444. modification times. Any or all of these may be specified using
  5445. strings for 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'.
  5446. The modification times are normally expressed in the ISO 8601 format.
  5447. If not specified, the strings default to blanks.
  5448. Example:
  5449. >>> a = ['one\n', 'two\n', 'three\n', 'four\n']
  5450. >>> b = ['zero\n', 'one\n', 'tree\n', 'four\n']
  5451. >>> contextDiff(a, b, {fromfile: 'Original', tofile: 'Current'})
  5452. [ '*** Original\n',
  5453. '--- Current\n',
  5454. '***************\n',
  5455. '*** 1,4 ****\n',
  5456. ' one\n',
  5457. '! two\n',
  5458. '! three\n',
  5459. ' four\n',
  5460. '--- 1,4 ----\n',
  5461. '+ zero\n',
  5462. ' one\n',
  5463. '! tree\n',
  5464. ' four\n' ]
  5465. */
  5466.  
  5467. if (fromfile == null) {
  5468. fromfile = '';
  5469. }
  5470. if (tofile == null) {
  5471. tofile = '';
  5472. }
  5473. if (fromfiledate == null) {
  5474. fromfiledate = '';
  5475. }
  5476. if (tofiledate == null) {
  5477. tofiledate = '';
  5478. }
  5479. if (n == null) {
  5480. n = 3;
  5481. }
  5482. if (lineterm == null) {
  5483. lineterm = '\n';
  5484. }
  5485. prefix = {
  5486. insert: '+ ',
  5487. "delete": '- ',
  5488. replace: '! ',
  5489. equal: ' '
  5490. };
  5491. started = false;
  5492. lines = [];
  5493. _ref1 = (new SequenceMatcher(null, a, b)).getGroupedOpcodes();
  5494. for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
  5495. group = _ref1[_i];
  5496. if (!started) {
  5497. started = true;
  5498. fromdate = fromfiledate ? "\t" + fromfiledate : '';
  5499. todate = tofiledate ? "\t" + tofiledate : '';
  5500. lines.push("*** " + fromfile + fromdate + lineterm);
  5501. lines.push("--- " + tofile + todate + lineterm);
  5502. _ref2 = [group[0], group[group.length - 1]], first = _ref2[0], last = _ref2[1];
  5503. lines.push('***************' + lineterm);
  5504. file1Range = _formatRangeContext(first[1], last[2]);
  5505. lines.push("*** " + file1Range + " ****" + lineterm);
  5506. if (_any((function() {
  5507. var _j, _len1, _ref3, _results;
  5508. _results = [];
  5509. for (_j = 0, _len1 = group.length; _j < _len1; _j++) {
  5510. _ref3 = group[_j], tag = _ref3[0], _ = _ref3[1], _ = _ref3[2], _ = _ref3[3], _ = _ref3[4];
  5511. _results.push(tag === 'replace' || tag === 'delete');
  5512. }
  5513. return _results;
  5514. })())) {
  5515. for (_j = 0, _len1 = group.length; _j < _len1; _j++) {
  5516. _ref3 = group[_j], tag = _ref3[0], i1 = _ref3[1], i2 = _ref3[2], _ = _ref3[3], _ = _ref3[4];
  5517. if (tag !== 'insert') {
  5518. _ref4 = a.slice(i1, i2);
  5519. for (_k = 0, _len2 = _ref4.length; _k < _len2; _k++) {
  5520. line = _ref4[_k];
  5521. lines.push(prefix[tag] + line);
  5522. }
  5523. }
  5524. }
  5525. }
  5526. file2Range = _formatRangeContext(first[3], last[4]);
  5527. lines.push("--- " + file2Range + " ----" + lineterm);
  5528. if (_any((function() {
  5529. var _l, _len3, _ref5, _results;
  5530. _results = [];
  5531. for (_l = 0, _len3 = group.length; _l < _len3; _l++) {
  5532. _ref5 = group[_l], tag = _ref5[0], _ = _ref5[1], _ = _ref5[2], _ = _ref5[3], _ = _ref5[4];
  5533. _results.push(tag === 'replace' || tag === 'insert');
  5534. }
  5535. return _results;
  5536. })())) {
  5537. for (_l = 0, _len3 = group.length; _l < _len3; _l++) {
  5538. _ref5 = group[_l], tag = _ref5[0], _ = _ref5[1], _ = _ref5[2], j1 = _ref5[3], j2 = _ref5[4];
  5539. if (tag !== 'delete') {
  5540. _ref6 = b.slice(j1, j2);
  5541. for (_m = 0, _len4 = _ref6.length; _m < _len4; _m++) {
  5542. line = _ref6[_m];
  5543. lines.push(prefix[tag] + line);
  5544. }
  5545. }
  5546. }
  5547. }
  5548. }
  5549. }
  5550. return lines;
  5551. };
  5552.  
  5553. ndiff = function(a, b, linejunk, charjunk) {
  5554. if (charjunk == null) {
  5555. charjunk = IS_CHARACTER_JUNK;
  5556. }
  5557. /*
  5558. Compare `a` and `b` (lists of strings); return a `Differ`-style delta.
  5559. Optional keyword parameters `linejunk` and `charjunk` are for filter
  5560. functions (or None):
  5561. - linejunk: A function that should accept a single string argument, and
  5562. return true iff the string is junk. The default is null, and is
  5563. recommended;
  5564. - charjunk: A function that should accept a string of length 1. The
  5565. default is module-level function IS_CHARACTER_JUNK, which filters out
  5566. whitespace characters (a blank or tab; note: bad idea to include newline
  5567. in this!).
  5568. Example:
  5569. >>> a = ['one\n', 'two\n', 'three\n']
  5570. >>> b = ['ore\n', 'tree\n', 'emu\n']
  5571. >>> ndiff(a, b)
  5572. [ '- one\n',
  5573. '? ^\n',
  5574. '+ ore\n',
  5575. '? ^\n',
  5576. '- two\n',
  5577. '- three\n',
  5578. '? -\n',
  5579. '+ tree\n',
  5580. '+ emu\n' ]
  5581. */
  5582.  
  5583. return (new Differ(linejunk, charjunk)).compare(a, b);
  5584. };
  5585.  
  5586. restore = function(delta, which) {
  5587. /*
  5588. Generate one of the two sequences that generated a delta.
  5589. Given a `delta` produced by `Differ.compare()` or `ndiff()`, extract
  5590. lines originating from file 1 or 2 (parameter `which`), stripping off line
  5591. prefixes.
  5592. Examples:
  5593. >>> a = ['one\n', 'two\n', 'three\n']
  5594. >>> b = ['ore\n', 'tree\n', 'emu\n']
  5595. >>> diff = ndiff(a, b)
  5596. >>> restore(diff, 1)
  5597. [ 'one\n',
  5598. 'two\n',
  5599. 'three\n' ]
  5600. >>> restore(diff, 2)
  5601. [ 'ore\n',
  5602. 'tree\n',
  5603. 'emu\n' ]
  5604. */
  5605.  
  5606. var line, lines, prefixes, tag, _i, _len, _ref;
  5607. tag = {
  5608. 1: '- ',
  5609. 2: '+ '
  5610. }[which];
  5611. if (!tag) {
  5612. throw new Error("unknow delta choice (must be 1 or 2): " + which);
  5613. }
  5614. prefixes = [' ', tag];
  5615. lines = [];
  5616. for (_i = 0, _len = delta.length; _i < _len; _i++) {
  5617. line = delta[_i];
  5618. if (_ref = line.slice(0, 2), __indexOf.call(prefixes, _ref) >= 0) {
  5619. lines.push(line.slice(2));
  5620. }
  5621. }
  5622. return lines;
  5623. };
  5624.  
  5625. exports._arrayCmp = _arrayCmp;
  5626.  
  5627. exports.SequenceMatcher = SequenceMatcher;
  5628.  
  5629. exports.getCloseMatches = getCloseMatches;
  5630.  
  5631. exports._countLeading = _countLeading;
  5632.  
  5633. exports.Differ = Differ;
  5634.  
  5635. exports.IS_LINE_JUNK = IS_LINE_JUNK;
  5636.  
  5637. exports.IS_CHARACTER_JUNK = IS_CHARACTER_JUNK;
  5638.  
  5639. exports._formatRangeUnified = _formatRangeUnified;
  5640.  
  5641. exports.unifiedDiff = unifiedDiff;
  5642.  
  5643. exports._formatRangeContext = _formatRangeContext;
  5644.  
  5645. exports.contextDiff = contextDiff;
  5646.  
  5647. exports.ndiff = ndiff;
  5648.  
  5649. exports.restore = restore;
  5650.  
  5651. }).call(this);
  5652.  
  5653.  
  5654. /***/ }),
  5655.  
  5656. /***/ "v2jn":
  5657. /***/ (function(module, exports, __webpack_require__) {
  5658.  
  5659. /*!
  5660.  
  5661. diff v4.0.1
  5662.  
  5663. Software License Agreement (BSD License)
  5664.  
  5665. Copyright (c) 2009-2015, Kevin Decker <kpdecker@gmail.com>
  5666.  
  5667. All rights reserved.
  5668.  
  5669. Redistribution and use of this software in source and binary forms, with or without modification,
  5670. are permitted provided that the following conditions are met:
  5671.  
  5672. * Redistributions of source code must retain the above
  5673. copyright notice, this list of conditions and the
  5674. following disclaimer.
  5675.  
  5676. * Redistributions in binary form must reproduce the above
  5677. copyright notice, this list of conditions and the
  5678. following disclaimer in the documentation and/or other
  5679. materials provided with the distribution.
  5680.  
  5681. * Neither the name of Kevin Decker nor the names of its
  5682. contributors may be used to endorse or promote products
  5683. derived from this software without specific prior
  5684. written permission.
  5685.  
  5686. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  5687. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  5688. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  5689. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  5690. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  5691. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  5692. IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  5693. OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5694. @license
  5695. */
  5696. (function (global, factory) {
  5697. true ? factory(exports) :
  5698. undefined;
  5699. }(this, function (exports) { 'use strict';
  5700.  
  5701. function Diff() {}
  5702. Diff.prototype = {
  5703. diff: function diff(oldString, newString) {
  5704. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  5705. var callback = options.callback;
  5706.  
  5707. if (typeof options === 'function') {
  5708. callback = options;
  5709. options = {};
  5710. }
  5711.  
  5712. this.options = options;
  5713. var self = this;
  5714.  
  5715. function done(value) {
  5716. if (callback) {
  5717. setTimeout(function () {
  5718. callback(undefined, value);
  5719. }, 0);
  5720. return true;
  5721. } else {
  5722. return value;
  5723. }
  5724. } // Allow subclasses to massage the input prior to running
  5725.  
  5726.  
  5727. oldString = this.castInput(oldString);
  5728. newString = this.castInput(newString);
  5729. oldString = this.removeEmpty(this.tokenize(oldString));
  5730. newString = this.removeEmpty(this.tokenize(newString));
  5731. var newLen = newString.length,
  5732. oldLen = oldString.length;
  5733. var editLength = 1;
  5734. var maxEditLength = newLen + oldLen;
  5735. var bestPath = [{
  5736. newPos: -1,
  5737. components: []
  5738. }]; // Seed editLength = 0, i.e. the content starts with the same values
  5739.  
  5740. var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
  5741.  
  5742. if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
  5743. // Identity per the equality and tokenizer
  5744. return done([{
  5745. value: this.join(newString),
  5746. count: newString.length
  5747. }]);
  5748. } // Main worker method. checks all permutations of a given edit length for acceptance.
  5749.  
  5750.  
  5751. function execEditLength() {
  5752. for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
  5753. var basePath = void 0;
  5754.  
  5755. var addPath = bestPath[diagonalPath - 1],
  5756. removePath = bestPath[diagonalPath + 1],
  5757. _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
  5758.  
  5759. if (addPath) {
  5760. // No one else is going to attempt to use this value, clear it
  5761. bestPath[diagonalPath - 1] = undefined;
  5762. }
  5763.  
  5764. var canAdd = addPath && addPath.newPos + 1 < newLen,
  5765. canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
  5766.  
  5767. if (!canAdd && !canRemove) {
  5768. // If this path is a terminal then prune
  5769. bestPath[diagonalPath] = undefined;
  5770. continue;
  5771. } // Select the diagonal that we want to branch from. We select the prior
  5772. // path whose position in the new string is the farthest from the origin
  5773. // and does not pass the bounds of the diff graph
  5774.  
  5775.  
  5776. if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
  5777. basePath = clonePath(removePath);
  5778. self.pushComponent(basePath.components, undefined, true);
  5779. } else {
  5780. basePath = addPath; // No need to clone, we've pulled it from the list
  5781.  
  5782. basePath.newPos++;
  5783. self.pushComponent(basePath.components, true, undefined);
  5784. }
  5785.  
  5786. _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done
  5787.  
  5788. if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
  5789. return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
  5790. } else {
  5791. // Otherwise track this path as a potential candidate and continue.
  5792. bestPath[diagonalPath] = basePath;
  5793. }
  5794. }
  5795.  
  5796. editLength++;
  5797. } // Performs the length of edit iteration. Is a bit fugly as this has to support the
  5798. // sync and async mode which is never fun. Loops over execEditLength until a value
  5799. // is produced.
  5800.  
  5801.  
  5802. if (callback) {
  5803. (function exec() {
  5804. setTimeout(function () {
  5805. // This should not happen, but we want to be safe.
  5806.  
  5807. /* istanbul ignore next */
  5808. if (editLength > maxEditLength) {
  5809. return callback();
  5810. }
  5811.  
  5812. if (!execEditLength()) {
  5813. exec();
  5814. }
  5815. }, 0);
  5816. })();
  5817. } else {
  5818. while (editLength <= maxEditLength) {
  5819. var ret = execEditLength();
  5820.  
  5821. if (ret) {
  5822. return ret;
  5823. }
  5824. }
  5825. }
  5826. },
  5827. pushComponent: function pushComponent(components, added, removed) {
  5828. var last = components[components.length - 1];
  5829.  
  5830. if (last && last.added === added && last.removed === removed) {
  5831. // We need to clone here as the component clone operation is just
  5832. // as shallow array clone
  5833. components[components.length - 1] = {
  5834. count: last.count + 1,
  5835. added: added,
  5836. removed: removed
  5837. };
  5838. } else {
  5839. components.push({
  5840. count: 1,
  5841. added: added,
  5842. removed: removed
  5843. });
  5844. }
  5845. },
  5846. extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
  5847. var newLen = newString.length,
  5848. oldLen = oldString.length,
  5849. newPos = basePath.newPos,
  5850. oldPos = newPos - diagonalPath,
  5851. commonCount = 0;
  5852.  
  5853. while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
  5854. newPos++;
  5855. oldPos++;
  5856. commonCount++;
  5857. }
  5858.  
  5859. if (commonCount) {
  5860. basePath.components.push({
  5861. count: commonCount
  5862. });
  5863. }
  5864.  
  5865. basePath.newPos = newPos;
  5866. return oldPos;
  5867. },
  5868. equals: function equals(left, right) {
  5869. if (this.options.comparator) {
  5870. return this.options.comparator(left, right);
  5871. } else {
  5872. return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
  5873. }
  5874. },
  5875. removeEmpty: function removeEmpty(array) {
  5876. var ret = [];
  5877.  
  5878. for (var i = 0; i < array.length; i++) {
  5879. if (array[i]) {
  5880. ret.push(array[i]);
  5881. }
  5882. }
  5883.  
  5884. return ret;
  5885. },
  5886. castInput: function castInput(value) {
  5887. return value;
  5888. },
  5889. tokenize: function tokenize(value) {
  5890. return value.split('');
  5891. },
  5892. join: function join(chars) {
  5893. return chars.join('');
  5894. }
  5895. };
  5896.  
  5897. function buildValues(diff, components, newString, oldString, useLongestToken) {
  5898. var componentPos = 0,
  5899. componentLen = components.length,
  5900. newPos = 0,
  5901. oldPos = 0;
  5902.  
  5903. for (; componentPos < componentLen; componentPos++) {
  5904. var component = components[componentPos];
  5905.  
  5906. if (!component.removed) {
  5907. if (!component.added && useLongestToken) {
  5908. var value = newString.slice(newPos, newPos + component.count);
  5909. value = value.map(function (value, i) {
  5910. var oldValue = oldString[oldPos + i];
  5911. return oldValue.length > value.length ? oldValue : value;
  5912. });
  5913. component.value = diff.join(value);
  5914. } else {
  5915. component.value = diff.join(newString.slice(newPos, newPos + component.count));
  5916. }
  5917.  
  5918. newPos += component.count; // Common case
  5919.  
  5920. if (!component.added) {
  5921. oldPos += component.count;
  5922. }
  5923. } else {
  5924. component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
  5925. oldPos += component.count; // Reverse add and remove so removes are output first to match common convention
  5926. // The diffing algorithm is tied to add then remove output and this is the simplest
  5927. // route to get the desired output with minimal overhead.
  5928.  
  5929. if (componentPos && components[componentPos - 1].added) {
  5930. var tmp = components[componentPos - 1];
  5931. components[componentPos - 1] = components[componentPos];
  5932. components[componentPos] = tmp;
  5933. }
  5934. }
  5935. } // Special case handle for when one terminal is ignored (i.e. whitespace).
  5936. // For this case we merge the terminal into the prior string and drop the change.
  5937. // This is only available for string mode.
  5938.  
  5939.  
  5940. var lastComponent = components[componentLen - 1];
  5941.  
  5942. if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
  5943. components[componentLen - 2].value += lastComponent.value;
  5944. components.pop();
  5945. }
  5946.  
  5947. return components;
  5948. }
  5949.  
  5950. function clonePath(path) {
  5951. return {
  5952. newPos: path.newPos,
  5953. components: path.components.slice(0)
  5954. };
  5955. }
  5956.  
  5957. var characterDiff = new Diff();
  5958. function diffChars(oldStr, newStr, options) {
  5959. return characterDiff.diff(oldStr, newStr, options);
  5960. }
  5961.  
  5962. function generateOptions(options, defaults) {
  5963. if (typeof options === 'function') {
  5964. defaults.callback = options;
  5965. } else if (options) {
  5966. for (var name in options) {
  5967. /* istanbul ignore else */
  5968. if (options.hasOwnProperty(name)) {
  5969. defaults[name] = options[name];
  5970. }
  5971. }
  5972. }
  5973.  
  5974. return defaults;
  5975. }
  5976.  
  5977. //
  5978. // Ranges and exceptions:
  5979. // Latin-1 Supplement, 0080–00FF
  5980. // - U+00D7 × Multiplication sign
  5981. // - U+00F7 ÷ Division sign
  5982. // Latin Extended-A, 0100–017F
  5983. // Latin Extended-B, 0180–024F
  5984. // IPA Extensions, 0250–02AF
  5985. // Spacing Modifier Letters, 02B0–02FF
  5986. // - U+02C7 ˇ &#711; Caron
  5987. // - U+02D8 ˘ &#728; Breve
  5988. // - U+02D9 ˙ &#729; Dot Above
  5989. // - U+02DA ˚ &#730; Ring Above
  5990. // - U+02DB ˛ &#731; Ogonek
  5991. // - U+02DC ˜ &#732; Small Tilde
  5992. // - U+02DD ˝ &#733; Double Acute Accent
  5993. // Latin Extended Additional, 1E00–1EFF
  5994.  
  5995. var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
  5996. var reWhitespace = /\S/;
  5997. var wordDiff = new Diff();
  5998.  
  5999. wordDiff.equals = function (left, right) {
  6000. if (this.options.ignoreCase) {
  6001. left = left.toLowerCase();
  6002. right = right.toLowerCase();
  6003. }
  6004.  
  6005. return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
  6006. };
  6007.  
  6008. wordDiff.tokenize = function (value) {
  6009. 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.
  6010.  
  6011. for (var i = 0; i < tokens.length - 1; i++) {
  6012. // If we have an empty string in the next field and we have only word chars before and after, merge
  6013. if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
  6014. tokens[i] += tokens[i + 2];
  6015. tokens.splice(i + 1, 2);
  6016. i--;
  6017. }
  6018. }
  6019.  
  6020. return tokens;
  6021. };
  6022.  
  6023. function diffWords(oldStr, newStr, options) {
  6024. options = generateOptions(options, {
  6025. ignoreWhitespace: true
  6026. });
  6027. return wordDiff.diff(oldStr, newStr, options);
  6028. }
  6029. function diffWordsWithSpace(oldStr, newStr, options) {
  6030. return wordDiff.diff(oldStr, newStr, options);
  6031. }
  6032.  
  6033. var lineDiff = new Diff();
  6034.  
  6035. lineDiff.tokenize = function (value) {
  6036. var retLines = [],
  6037. linesAndNewlines = value.split(/(\n|\r\n)/); // Ignore the final empty token that occurs if the string ends with a new line
  6038.  
  6039. if (!linesAndNewlines[linesAndNewlines.length - 1]) {
  6040. linesAndNewlines.pop();
  6041. } // Merge the content and line separators into single tokens
  6042.  
  6043.  
  6044. for (var i = 0; i < linesAndNewlines.length; i++) {
  6045. var line = linesAndNewlines[i];
  6046.  
  6047. if (i % 2 && !this.options.newlineIsToken) {
  6048. retLines[retLines.length - 1] += line;
  6049. } else {
  6050. if (this.options.ignoreWhitespace) {
  6051. line = line.trim();
  6052. }
  6053.  
  6054. retLines.push(line);
  6055. }
  6056. }
  6057.  
  6058. return retLines;
  6059. };
  6060.  
  6061. function diffLines(oldStr, newStr, callback) {
  6062. return lineDiff.diff(oldStr, newStr, callback);
  6063. }
  6064. function diffTrimmedLines(oldStr, newStr, callback) {
  6065. var options = generateOptions(callback, {
  6066. ignoreWhitespace: true
  6067. });
  6068. return lineDiff.diff(oldStr, newStr, options);
  6069. }
  6070.  
  6071. var sentenceDiff = new Diff();
  6072.  
  6073. sentenceDiff.tokenize = function (value) {
  6074. return value.split(/(\S.+?[.!?])(?=\s+|$)/);
  6075. };
  6076.  
  6077. function diffSentences(oldStr, newStr, callback) {
  6078. return sentenceDiff.diff(oldStr, newStr, callback);
  6079. }
  6080.  
  6081. var cssDiff = new Diff();
  6082.  
  6083. cssDiff.tokenize = function (value) {
  6084. return value.split(/([{}:;,]|\s+)/);
  6085. };
  6086.  
  6087. function diffCss(oldStr, newStr, callback) {
  6088. return cssDiff.diff(oldStr, newStr, callback);
  6089. }
  6090.  
  6091. function _typeof(obj) {
  6092. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  6093. _typeof = function (obj) {
  6094. return typeof obj;
  6095. };
  6096. } else {
  6097. _typeof = function (obj) {
  6098. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  6099. };
  6100. }
  6101.  
  6102. return _typeof(obj);
  6103. }
  6104.  
  6105. function _toConsumableArray(arr) {
  6106. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
  6107. }
  6108.  
  6109. function _arrayWithoutHoles(arr) {
  6110. if (Array.isArray(arr)) {
  6111. for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
  6112.  
  6113. return arr2;
  6114. }
  6115. }
  6116.  
  6117. function _iterableToArray(iter) {
  6118. if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
  6119. }
  6120.  
  6121. function _nonIterableSpread() {
  6122. throw new TypeError("Invalid attempt to spread non-iterable instance");
  6123. }
  6124.  
  6125. var objectPrototypeToString = Object.prototype.toString;
  6126. var jsonDiff = new Diff(); // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
  6127. // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
  6128.  
  6129. jsonDiff.useLongestToken = true;
  6130. jsonDiff.tokenize = lineDiff.tokenize;
  6131.  
  6132. jsonDiff.castInput = function (value) {
  6133. var _this$options = this.options,
  6134. undefinedReplacement = _this$options.undefinedReplacement,
  6135. _this$options$stringi = _this$options.stringifyReplacer,
  6136. stringifyReplacer = _this$options$stringi === void 0 ? function (k, v) {
  6137. return typeof v === 'undefined' ? undefinedReplacement : v;
  6138. } : _this$options$stringi;
  6139. return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' ');
  6140. };
  6141.  
  6142. jsonDiff.equals = function (left, right) {
  6143. return Diff.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'));
  6144. };
  6145.  
  6146. function diffJson(oldObj, newObj, options) {
  6147. return jsonDiff.diff(oldObj, newObj, options);
  6148. } // This function handles the presence of circular references by bailing out when encountering an
  6149. // object that is already on the "stack" of items being processed. Accepts an optional replacer
  6150.  
  6151. function canonicalize(obj, stack, replacementStack, replacer, key) {
  6152. stack = stack || [];
  6153. replacementStack = replacementStack || [];
  6154.  
  6155. if (replacer) {
  6156. obj = replacer(key, obj);
  6157. }
  6158.  
  6159. var i;
  6160.  
  6161. for (i = 0; i < stack.length; i += 1) {
  6162. if (stack[i] === obj) {
  6163. return replacementStack[i];
  6164. }
  6165. }
  6166.  
  6167. var canonicalizedObj;
  6168.  
  6169. if ('[object Array]' === objectPrototypeToString.call(obj)) {
  6170. stack.push(obj);
  6171. canonicalizedObj = new Array(obj.length);
  6172. replacementStack.push(canonicalizedObj);
  6173.  
  6174. for (i = 0; i < obj.length; i += 1) {
  6175. canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
  6176. }
  6177.  
  6178. stack.pop();
  6179. replacementStack.pop();
  6180. return canonicalizedObj;
  6181. }
  6182.  
  6183. if (obj && obj.toJSON) {
  6184. obj = obj.toJSON();
  6185. }
  6186.  
  6187. if (_typeof(obj) === 'object' && obj !== null) {
  6188. stack.push(obj);
  6189. canonicalizedObj = {};
  6190. replacementStack.push(canonicalizedObj);
  6191.  
  6192. var sortedKeys = [],
  6193. _key;
  6194.  
  6195. for (_key in obj) {
  6196. /* istanbul ignore else */
  6197. if (obj.hasOwnProperty(_key)) {
  6198. sortedKeys.push(_key);
  6199. }
  6200. }
  6201.  
  6202. sortedKeys.sort();
  6203.  
  6204. for (i = 0; i < sortedKeys.length; i += 1) {
  6205. _key = sortedKeys[i];
  6206. canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
  6207. }
  6208.  
  6209. stack.pop();
  6210. replacementStack.pop();
  6211. } else {
  6212. canonicalizedObj = obj;
  6213. }
  6214.  
  6215. return canonicalizedObj;
  6216. }
  6217.  
  6218. var arrayDiff = new Diff();
  6219.  
  6220. arrayDiff.tokenize = function (value) {
  6221. return value.slice();
  6222. };
  6223.  
  6224. arrayDiff.join = arrayDiff.removeEmpty = function (value) {
  6225. return value;
  6226. };
  6227.  
  6228. function diffArrays(oldArr, newArr, callback) {
  6229. return arrayDiff.diff(oldArr, newArr, callback);
  6230. }
  6231.  
  6232. function parsePatch(uniDiff) {
  6233. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  6234. var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/),
  6235. delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  6236. list = [],
  6237. i = 0;
  6238.  
  6239. function parseIndex() {
  6240. var index = {};
  6241. list.push(index); // Parse diff metadata
  6242.  
  6243. while (i < diffstr.length) {
  6244. var line = diffstr[i]; // File header found, end parsing diff metadata
  6245.  
  6246. if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
  6247. break;
  6248. } // Diff index
  6249.  
  6250.  
  6251. var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
  6252.  
  6253. if (header) {
  6254. index.index = header[1];
  6255. }
  6256.  
  6257. i++;
  6258. } // Parse file headers if they are defined. Unified diff requires them, but
  6259. // there's no technical issues to have an isolated hunk without file header
  6260.  
  6261.  
  6262. parseFileHeader(index);
  6263. parseFileHeader(index); // Parse hunks
  6264.  
  6265. index.hunks = [];
  6266.  
  6267. while (i < diffstr.length) {
  6268. var _line = diffstr[i];
  6269.  
  6270. if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
  6271. break;
  6272. } else if (/^@@/.test(_line)) {
  6273. index.hunks.push(parseHunk());
  6274. } else if (_line && options.strict) {
  6275. // Ignore unexpected content unless in strict mode
  6276. throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
  6277. } else {
  6278. i++;
  6279. }
  6280. }
  6281. } // Parses the --- and +++ headers, if none are found, no lines
  6282. // are consumed.
  6283.  
  6284.  
  6285. function parseFileHeader(index) {
  6286. var fileHeader = /^(---|\+\+\+)\s+(.*)$/.exec(diffstr[i]);
  6287.  
  6288. if (fileHeader) {
  6289. var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
  6290. var data = fileHeader[2].split('\t', 2);
  6291. var fileName = data[0].replace(/\\\\/g, '\\');
  6292.  
  6293. if (/^".*"$/.test(fileName)) {
  6294. fileName = fileName.substr(1, fileName.length - 2);
  6295. }
  6296.  
  6297. index[keyPrefix + 'FileName'] = fileName;
  6298. index[keyPrefix + 'Header'] = (data[1] || '').trim();
  6299. i++;
  6300. }
  6301. } // Parses a hunk
  6302. // This assumes that we are at the start of a hunk.
  6303.  
  6304.  
  6305. function parseHunk() {
  6306. var chunkHeaderIndex = i,
  6307. chunkHeaderLine = diffstr[i++],
  6308. chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
  6309. var hunk = {
  6310. oldStart: +chunkHeader[1],
  6311. oldLines: +chunkHeader[2] || 1,
  6312. newStart: +chunkHeader[3],
  6313. newLines: +chunkHeader[4] || 1,
  6314. lines: [],
  6315. linedelimiters: []
  6316. };
  6317. var addCount = 0,
  6318. removeCount = 0;
  6319.  
  6320. for (; i < diffstr.length; i++) {
  6321. // Lines starting with '---' could be mistaken for the "remove line" operation
  6322. // But they could be the header for the next file. Therefore prune such cases out.
  6323. if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
  6324. break;
  6325. }
  6326.  
  6327. var operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? ' ' : diffstr[i][0];
  6328.  
  6329. if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
  6330. hunk.lines.push(diffstr[i]);
  6331. hunk.linedelimiters.push(delimiters[i] || '\n');
  6332.  
  6333. if (operation === '+') {
  6334. addCount++;
  6335. } else if (operation === '-') {
  6336. removeCount++;
  6337. } else if (operation === ' ') {
  6338. addCount++;
  6339. removeCount++;
  6340. }
  6341. } else {
  6342. break;
  6343. }
  6344. } // Handle the empty block count case
  6345.  
  6346.  
  6347. if (!addCount && hunk.newLines === 1) {
  6348. hunk.newLines = 0;
  6349. }
  6350.  
  6351. if (!removeCount && hunk.oldLines === 1) {
  6352. hunk.oldLines = 0;
  6353. } // Perform optional sanity checking
  6354.  
  6355.  
  6356. if (options.strict) {
  6357. if (addCount !== hunk.newLines) {
  6358. throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  6359. }
  6360.  
  6361. if (removeCount !== hunk.oldLines) {
  6362. throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  6363. }
  6364. }
  6365.  
  6366. return hunk;
  6367. }
  6368.  
  6369. while (i < diffstr.length) {
  6370. parseIndex();
  6371. }
  6372.  
  6373. return list;
  6374. }
  6375.  
  6376. // Iterator that traverses in the range of [min, max], stepping
  6377. // by distance from a given start position. I.e. for [0, 4], with
  6378. // start of 2, this will iterate 2, 3, 1, 4, 0.
  6379. function distanceIterator (start, minLine, maxLine) {
  6380. var wantForward = true,
  6381. backwardExhausted = false,
  6382. forwardExhausted = false,
  6383. localOffset = 1;
  6384. return function iterator() {
  6385. if (wantForward && !forwardExhausted) {
  6386. if (backwardExhausted) {
  6387. localOffset++;
  6388. } else {
  6389. wantForward = false;
  6390. } // Check if trying to fit beyond text length, and if not, check it fits
  6391. // after offset location (or desired location on first iteration)
  6392.  
  6393.  
  6394. if (start + localOffset <= maxLine) {
  6395. return localOffset;
  6396. }
  6397.  
  6398. forwardExhausted = true;
  6399. }
  6400.  
  6401. if (!backwardExhausted) {
  6402. if (!forwardExhausted) {
  6403. wantForward = true;
  6404. } // Check if trying to fit before text beginning, and if not, check it fits
  6405. // before offset location
  6406.  
  6407.  
  6408. if (minLine <= start - localOffset) {
  6409. return -localOffset++;
  6410. }
  6411.  
  6412. backwardExhausted = true;
  6413. return iterator();
  6414. } // We tried to fit hunk before text beginning and beyond text length, then
  6415. // hunk can't fit on the text. Return undefined
  6416.  
  6417. };
  6418. }
  6419.  
  6420. function applyPatch(source, uniDiff) {
  6421. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  6422.  
  6423. if (typeof uniDiff === 'string') {
  6424. uniDiff = parsePatch(uniDiff);
  6425. }
  6426.  
  6427. if (Array.isArray(uniDiff)) {
  6428. if (uniDiff.length > 1) {
  6429. throw new Error('applyPatch only works with a single input.');
  6430. }
  6431.  
  6432. uniDiff = uniDiff[0];
  6433. } // Apply the diff to the input
  6434.  
  6435.  
  6436. var lines = source.split(/\r\n|[\n\v\f\r\x85]/),
  6437. delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  6438. hunks = uniDiff.hunks,
  6439. compareLine = options.compareLine || function (lineNumber, line, operation, patchContent) {
  6440. return line === patchContent;
  6441. },
  6442. errorCount = 0,
  6443. fuzzFactor = options.fuzzFactor || 0,
  6444. minLine = 0,
  6445. offset = 0,
  6446. removeEOFNL,
  6447. addEOFNL;
  6448. /**
  6449. * Checks if the hunk exactly fits on the provided location
  6450. */
  6451.  
  6452.  
  6453. function hunkFits(hunk, toPos) {
  6454. for (var j = 0; j < hunk.lines.length; j++) {
  6455. var line = hunk.lines[j],
  6456. operation = line.length > 0 ? line[0] : ' ',
  6457. content = line.length > 0 ? line.substr(1) : line;
  6458.  
  6459. if (operation === ' ' || operation === '-') {
  6460. // Context sanity check
  6461. if (!compareLine(toPos + 1, lines[toPos], operation, content)) {
  6462. errorCount++;
  6463.  
  6464. if (errorCount > fuzzFactor) {
  6465. return false;
  6466. }
  6467. }
  6468.  
  6469. toPos++;
  6470. }
  6471. }
  6472.  
  6473. return true;
  6474. } // Search best fit offsets for each hunk based on the previous ones
  6475.  
  6476.  
  6477. for (var i = 0; i < hunks.length; i++) {
  6478. var hunk = hunks[i],
  6479. maxLine = lines.length - hunk.oldLines,
  6480. localOffset = 0,
  6481. toPos = offset + hunk.oldStart - 1;
  6482. var iterator = distanceIterator(toPos, minLine, maxLine);
  6483.  
  6484. for (; localOffset !== undefined; localOffset = iterator()) {
  6485. if (hunkFits(hunk, toPos + localOffset)) {
  6486. hunk.offset = offset += localOffset;
  6487. break;
  6488. }
  6489. }
  6490.  
  6491. if (localOffset === undefined) {
  6492. return false;
  6493. } // Set lower text limit to end of the current hunk, so next ones don't try
  6494. // to fit over already patched text
  6495.  
  6496.  
  6497. minLine = hunk.offset + hunk.oldStart + hunk.oldLines;
  6498. } // Apply patch hunks
  6499.  
  6500.  
  6501. var diffOffset = 0;
  6502.  
  6503. for (var _i = 0; _i < hunks.length; _i++) {
  6504. var _hunk = hunks[_i],
  6505. _toPos = _hunk.oldStart + _hunk.offset + diffOffset - 1;
  6506.  
  6507. diffOffset += _hunk.newLines - _hunk.oldLines;
  6508.  
  6509. if (_toPos < 0) {
  6510. // Creating a new file
  6511. _toPos = 0;
  6512. }
  6513.  
  6514. for (var j = 0; j < _hunk.lines.length; j++) {
  6515. var line = _hunk.lines[j],
  6516. operation = line.length > 0 ? line[0] : ' ',
  6517. content = line.length > 0 ? line.substr(1) : line,
  6518. delimiter = _hunk.linedelimiters[j];
  6519.  
  6520. if (operation === ' ') {
  6521. _toPos++;
  6522. } else if (operation === '-') {
  6523. lines.splice(_toPos, 1);
  6524. delimiters.splice(_toPos, 1);
  6525. /* istanbul ignore else */
  6526. } else if (operation === '+') {
  6527. lines.splice(_toPos, 0, content);
  6528. delimiters.splice(_toPos, 0, delimiter);
  6529. _toPos++;
  6530. } else if (operation === '\\') {
  6531. var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null;
  6532.  
  6533. if (previousOperation === '+') {
  6534. removeEOFNL = true;
  6535. } else if (previousOperation === '-') {
  6536. addEOFNL = true;
  6537. }
  6538. }
  6539. }
  6540. } // Handle EOFNL insertion/removal
  6541.  
  6542.  
  6543. if (removeEOFNL) {
  6544. while (!lines[lines.length - 1]) {
  6545. lines.pop();
  6546. delimiters.pop();
  6547. }
  6548. } else if (addEOFNL) {
  6549. lines.push('');
  6550. delimiters.push('\n');
  6551. }
  6552.  
  6553. for (var _k = 0; _k < lines.length - 1; _k++) {
  6554. lines[_k] = lines[_k] + delimiters[_k];
  6555. }
  6556.  
  6557. return lines.join('');
  6558. } // Wrapper that supports multiple file patches via callbacks.
  6559.  
  6560. function applyPatches(uniDiff, options) {
  6561. if (typeof uniDiff === 'string') {
  6562. uniDiff = parsePatch(uniDiff);
  6563. }
  6564.  
  6565. var currentIndex = 0;
  6566.  
  6567. function processIndex() {
  6568. var index = uniDiff[currentIndex++];
  6569.  
  6570. if (!index) {
  6571. return options.complete();
  6572. }
  6573.  
  6574. options.loadFile(index, function (err, data) {
  6575. if (err) {
  6576. return options.complete(err);
  6577. }
  6578.  
  6579. var updatedContent = applyPatch(data, index, options);
  6580. options.patched(index, updatedContent, function (err) {
  6581. if (err) {
  6582. return options.complete(err);
  6583. }
  6584.  
  6585. processIndex();
  6586. });
  6587. });
  6588. }
  6589.  
  6590. processIndex();
  6591. }
  6592.  
  6593. function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  6594. if (!options) {
  6595. options = {};
  6596. }
  6597.  
  6598. if (typeof options.context === 'undefined') {
  6599. options.context = 4;
  6600. }
  6601.  
  6602. var diff = diffLines(oldStr, newStr, options);
  6603. diff.push({
  6604. value: '',
  6605. lines: []
  6606. }); // Append an empty value to make cleanup easier
  6607.  
  6608. function contextLines(lines) {
  6609. return lines.map(function (entry) {
  6610. return ' ' + entry;
  6611. });
  6612. }
  6613.  
  6614. var hunks = [];
  6615. var oldRangeStart = 0,
  6616. newRangeStart = 0,
  6617. curRange = [],
  6618. oldLine = 1,
  6619. newLine = 1;
  6620.  
  6621. var _loop = function _loop(i) {
  6622. var current = diff[i],
  6623. lines = current.lines || current.value.replace(/\n$/, '').split('\n');
  6624. current.lines = lines;
  6625.  
  6626. if (current.added || current.removed) {
  6627. var _curRange;
  6628.  
  6629. // If we have previous context, start with that
  6630. if (!oldRangeStart) {
  6631. var prev = diff[i - 1];
  6632. oldRangeStart = oldLine;
  6633. newRangeStart = newLine;
  6634.  
  6635. if (prev) {
  6636. curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
  6637. oldRangeStart -= curRange.length;
  6638. newRangeStart -= curRange.length;
  6639. }
  6640. } // Output our changes
  6641.  
  6642.  
  6643. (_curRange = curRange).push.apply(_curRange, _toConsumableArray(lines.map(function (entry) {
  6644. return (current.added ? '+' : '-') + entry;
  6645. }))); // Track the updated file position
  6646.  
  6647.  
  6648. if (current.added) {
  6649. newLine += lines.length;
  6650. } else {
  6651. oldLine += lines.length;
  6652. }
  6653. } else {
  6654. // Identical context lines. Track line changes
  6655. if (oldRangeStart) {
  6656. // Close out any changes that have been output (or join overlapping)
  6657. if (lines.length <= options.context * 2 && i < diff.length - 2) {
  6658. var _curRange2;
  6659.  
  6660. // Overlapping
  6661. (_curRange2 = curRange).push.apply(_curRange2, _toConsumableArray(contextLines(lines)));
  6662. } else {
  6663. var _curRange3;
  6664.  
  6665. // end the range and output
  6666. var contextSize = Math.min(lines.length, options.context);
  6667.  
  6668. (_curRange3 = curRange).push.apply(_curRange3, _toConsumableArray(contextLines(lines.slice(0, contextSize))));
  6669.  
  6670. var hunk = {
  6671. oldStart: oldRangeStart,
  6672. oldLines: oldLine - oldRangeStart + contextSize,
  6673. newStart: newRangeStart,
  6674. newLines: newLine - newRangeStart + contextSize,
  6675. lines: curRange
  6676. };
  6677.  
  6678. if (i >= diff.length - 2 && lines.length <= options.context) {
  6679. // EOF is inside this hunk
  6680. var oldEOFNewline = /\n$/.test(oldStr);
  6681. var newEOFNewline = /\n$/.test(newStr);
  6682. var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines;
  6683.  
  6684. if (!oldEOFNewline && noNlBeforeAdds) {
  6685. // special case: old has no eol and no trailing context; no-nl can end up before adds
  6686. curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
  6687. }
  6688.  
  6689. if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) {
  6690. curRange.push('\\ No newline at end of file');
  6691. }
  6692. }
  6693.  
  6694. hunks.push(hunk);
  6695. oldRangeStart = 0;
  6696. newRangeStart = 0;
  6697. curRange = [];
  6698. }
  6699. }
  6700.  
  6701. oldLine += lines.length;
  6702. newLine += lines.length;
  6703. }
  6704. };
  6705.  
  6706. for (var i = 0; i < diff.length; i++) {
  6707. _loop(i);
  6708. }
  6709.  
  6710. return {
  6711. oldFileName: oldFileName,
  6712. newFileName: newFileName,
  6713. oldHeader: oldHeader,
  6714. newHeader: newHeader,
  6715. hunks: hunks
  6716. };
  6717. }
  6718. function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  6719. var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
  6720. var ret = [];
  6721.  
  6722. if (oldFileName == newFileName) {
  6723. ret.push('Index: ' + oldFileName);
  6724. }
  6725.  
  6726. ret.push('===================================================================');
  6727. ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
  6728. ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
  6729.  
  6730. for (var i = 0; i < diff.hunks.length; i++) {
  6731. var hunk = diff.hunks[i];
  6732. ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
  6733. ret.push.apply(ret, hunk.lines);
  6734. }
  6735.  
  6736. return ret.join('\n') + '\n';
  6737. }
  6738. function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
  6739. return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
  6740. }
  6741.  
  6742. function arrayEqual(a, b) {
  6743. if (a.length !== b.length) {
  6744. return false;
  6745. }
  6746.  
  6747. return arrayStartsWith(a, b);
  6748. }
  6749. function arrayStartsWith(array, start) {
  6750. if (start.length > array.length) {
  6751. return false;
  6752. }
  6753.  
  6754. for (var i = 0; i < start.length; i++) {
  6755. if (start[i] !== array[i]) {
  6756. return false;
  6757. }
  6758. }
  6759.  
  6760. return true;
  6761. }
  6762.  
  6763. function calcLineCount(hunk) {
  6764. var _calcOldNewLineCount = calcOldNewLineCount(hunk.lines),
  6765. oldLines = _calcOldNewLineCount.oldLines,
  6766. newLines = _calcOldNewLineCount.newLines;
  6767.  
  6768. if (oldLines !== undefined) {
  6769. hunk.oldLines = oldLines;
  6770. } else {
  6771. delete hunk.oldLines;
  6772. }
  6773.  
  6774. if (newLines !== undefined) {
  6775. hunk.newLines = newLines;
  6776. } else {
  6777. delete hunk.newLines;
  6778. }
  6779. }
  6780. function merge(mine, theirs, base) {
  6781. mine = loadPatch(mine, base);
  6782. theirs = loadPatch(theirs, base);
  6783. var ret = {}; // For index we just let it pass through as it doesn't have any necessary meaning.
  6784. // Leaving sanity checks on this to the API consumer that may know more about the
  6785. // meaning in their own context.
  6786.  
  6787. if (mine.index || theirs.index) {
  6788. ret.index = mine.index || theirs.index;
  6789. }
  6790.  
  6791. if (mine.newFileName || theirs.newFileName) {
  6792. if (!fileNameChanged(mine)) {
  6793. // No header or no change in ours, use theirs (and ours if theirs does not exist)
  6794. ret.oldFileName = theirs.oldFileName || mine.oldFileName;
  6795. ret.newFileName = theirs.newFileName || mine.newFileName;
  6796. ret.oldHeader = theirs.oldHeader || mine.oldHeader;
  6797. ret.newHeader = theirs.newHeader || mine.newHeader;
  6798. } else if (!fileNameChanged(theirs)) {
  6799. // No header or no change in theirs, use ours
  6800. ret.oldFileName = mine.oldFileName;
  6801. ret.newFileName = mine.newFileName;
  6802. ret.oldHeader = mine.oldHeader;
  6803. ret.newHeader = mine.newHeader;
  6804. } else {
  6805. // Both changed... figure it out
  6806. ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName);
  6807. ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName);
  6808. ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader);
  6809. ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader);
  6810. }
  6811. }
  6812.  
  6813. ret.hunks = [];
  6814. var mineIndex = 0,
  6815. theirsIndex = 0,
  6816. mineOffset = 0,
  6817. theirsOffset = 0;
  6818.  
  6819. while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) {
  6820. var mineCurrent = mine.hunks[mineIndex] || {
  6821. oldStart: Infinity
  6822. },
  6823. theirsCurrent = theirs.hunks[theirsIndex] || {
  6824. oldStart: Infinity
  6825. };
  6826.  
  6827. if (hunkBefore(mineCurrent, theirsCurrent)) {
  6828. // This patch does not overlap with any of the others, yay.
  6829. ret.hunks.push(cloneHunk(mineCurrent, mineOffset));
  6830. mineIndex++;
  6831. theirsOffset += mineCurrent.newLines - mineCurrent.oldLines;
  6832. } else if (hunkBefore(theirsCurrent, mineCurrent)) {
  6833. // This patch does not overlap with any of the others, yay.
  6834. ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset));
  6835. theirsIndex++;
  6836. mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines;
  6837. } else {
  6838. // Overlap, merge as best we can
  6839. var mergedHunk = {
  6840. oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart),
  6841. oldLines: 0,
  6842. newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset),
  6843. newLines: 0,
  6844. lines: []
  6845. };
  6846. mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines);
  6847. theirsIndex++;
  6848. mineIndex++;
  6849. ret.hunks.push(mergedHunk);
  6850. }
  6851. }
  6852.  
  6853. return ret;
  6854. }
  6855.  
  6856. function loadPatch(param, base) {
  6857. if (typeof param === 'string') {
  6858. if (/^@@/m.test(param) || /^Index:/m.test(param)) {
  6859. return parsePatch(param)[0];
  6860. }
  6861.  
  6862. if (!base) {
  6863. throw new Error('Must provide a base reference or pass in a patch');
  6864. }
  6865.  
  6866. return structuredPatch(undefined, undefined, base, param);
  6867. }
  6868.  
  6869. return param;
  6870. }
  6871.  
  6872. function fileNameChanged(patch) {
  6873. return patch.newFileName && patch.newFileName !== patch.oldFileName;
  6874. }
  6875.  
  6876. function selectField(index, mine, theirs) {
  6877. if (mine === theirs) {
  6878. return mine;
  6879. } else {
  6880. index.conflict = true;
  6881. return {
  6882. mine: mine,
  6883. theirs: theirs
  6884. };
  6885. }
  6886. }
  6887.  
  6888. function hunkBefore(test, check) {
  6889. return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart;
  6890. }
  6891.  
  6892. function cloneHunk(hunk, offset) {
  6893. return {
  6894. oldStart: hunk.oldStart,
  6895. oldLines: hunk.oldLines,
  6896. newStart: hunk.newStart + offset,
  6897. newLines: hunk.newLines,
  6898. lines: hunk.lines
  6899. };
  6900. }
  6901.  
  6902. function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) {
  6903. // This will generally result in a conflicted hunk, but there are cases where the context
  6904. // is the only overlap where we can successfully merge the content here.
  6905. var mine = {
  6906. offset: mineOffset,
  6907. lines: mineLines,
  6908. index: 0
  6909. },
  6910. their = {
  6911. offset: theirOffset,
  6912. lines: theirLines,
  6913. index: 0
  6914. }; // Handle any leading content
  6915.  
  6916. insertLeading(hunk, mine, their);
  6917. insertLeading(hunk, their, mine); // Now in the overlap content. Scan through and select the best changes from each.
  6918.  
  6919. while (mine.index < mine.lines.length && their.index < their.lines.length) {
  6920. var mineCurrent = mine.lines[mine.index],
  6921. theirCurrent = their.lines[their.index];
  6922.  
  6923. if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) {
  6924. // Both modified ...
  6925. mutualChange(hunk, mine, their);
  6926. } else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') {
  6927. var _hunk$lines;
  6928.  
  6929. // Mine inserted
  6930. (_hunk$lines = hunk.lines).push.apply(_hunk$lines, _toConsumableArray(collectChange(mine)));
  6931. } else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') {
  6932. var _hunk$lines2;
  6933.  
  6934. // Theirs inserted
  6935. (_hunk$lines2 = hunk.lines).push.apply(_hunk$lines2, _toConsumableArray(collectChange(their)));
  6936. } else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') {
  6937. // Mine removed or edited
  6938. removal(hunk, mine, their);
  6939. } else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') {
  6940. // Their removed or edited
  6941. removal(hunk, their, mine, true);
  6942. } else if (mineCurrent === theirCurrent) {
  6943. // Context identity
  6944. hunk.lines.push(mineCurrent);
  6945. mine.index++;
  6946. their.index++;
  6947. } else {
  6948. // Context mismatch
  6949. conflict(hunk, collectChange(mine), collectChange(their));
  6950. }
  6951. } // Now push anything that may be remaining
  6952.  
  6953.  
  6954. insertTrailing(hunk, mine);
  6955. insertTrailing(hunk, their);
  6956. calcLineCount(hunk);
  6957. }
  6958.  
  6959. function mutualChange(hunk, mine, their) {
  6960. var myChanges = collectChange(mine),
  6961. theirChanges = collectChange(their);
  6962.  
  6963. if (allRemoves(myChanges) && allRemoves(theirChanges)) {
  6964. // Special case for remove changes that are supersets of one another
  6965. if (arrayStartsWith(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) {
  6966. var _hunk$lines3;
  6967.  
  6968. (_hunk$lines3 = hunk.lines).push.apply(_hunk$lines3, _toConsumableArray(myChanges));
  6969.  
  6970. return;
  6971. } else if (arrayStartsWith(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) {
  6972. var _hunk$lines4;
  6973.  
  6974. (_hunk$lines4 = hunk.lines).push.apply(_hunk$lines4, _toConsumableArray(theirChanges));
  6975.  
  6976. return;
  6977. }
  6978. } else if (arrayEqual(myChanges, theirChanges)) {
  6979. var _hunk$lines5;
  6980.  
  6981. (_hunk$lines5 = hunk.lines).push.apply(_hunk$lines5, _toConsumableArray(myChanges));
  6982.  
  6983. return;
  6984. }
  6985.  
  6986. conflict(hunk, myChanges, theirChanges);
  6987. }
  6988.  
  6989. function removal(hunk, mine, their, swap) {
  6990. var myChanges = collectChange(mine),
  6991. theirChanges = collectContext(their, myChanges);
  6992.  
  6993. if (theirChanges.merged) {
  6994. var _hunk$lines6;
  6995.  
  6996. (_hunk$lines6 = hunk.lines).push.apply(_hunk$lines6, _toConsumableArray(theirChanges.merged));
  6997. } else {
  6998. conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges);
  6999. }
  7000. }
  7001.  
  7002. function conflict(hunk, mine, their) {
  7003. hunk.conflict = true;
  7004. hunk.lines.push({
  7005. conflict: true,
  7006. mine: mine,
  7007. theirs: their
  7008. });
  7009. }
  7010.  
  7011. function insertLeading(hunk, insert, their) {
  7012. while (insert.offset < their.offset && insert.index < insert.lines.length) {
  7013. var line = insert.lines[insert.index++];
  7014. hunk.lines.push(line);
  7015. insert.offset++;
  7016. }
  7017. }
  7018.  
  7019. function insertTrailing(hunk, insert) {
  7020. while (insert.index < insert.lines.length) {
  7021. var line = insert.lines[insert.index++];
  7022. hunk.lines.push(line);
  7023. }
  7024. }
  7025.  
  7026. function collectChange(state) {
  7027. var ret = [],
  7028. operation = state.lines[state.index][0];
  7029.  
  7030. while (state.index < state.lines.length) {
  7031. var line = state.lines[state.index]; // Group additions that are immediately after subtractions and treat them as one "atomic" modify change.
  7032.  
  7033. if (operation === '-' && line[0] === '+') {
  7034. operation = '+';
  7035. }
  7036.  
  7037. if (operation === line[0]) {
  7038. ret.push(line);
  7039. state.index++;
  7040. } else {
  7041. break;
  7042. }
  7043. }
  7044.  
  7045. return ret;
  7046. }
  7047.  
  7048. function collectContext(state, matchChanges) {
  7049. var changes = [],
  7050. merged = [],
  7051. matchIndex = 0,
  7052. contextChanges = false,
  7053. conflicted = false;
  7054.  
  7055. while (matchIndex < matchChanges.length && state.index < state.lines.length) {
  7056. var change = state.lines[state.index],
  7057. match = matchChanges[matchIndex]; // Once we've hit our add, then we are done
  7058.  
  7059. if (match[0] === '+') {
  7060. break;
  7061. }
  7062.  
  7063. contextChanges = contextChanges || change[0] !== ' ';
  7064. merged.push(match);
  7065. matchIndex++; // Consume any additions in the other block as a conflict to attempt
  7066. // to pull in the remaining context after this
  7067.  
  7068. if (change[0] === '+') {
  7069. conflicted = true;
  7070.  
  7071. while (change[0] === '+') {
  7072. changes.push(change);
  7073. change = state.lines[++state.index];
  7074. }
  7075. }
  7076.  
  7077. if (match.substr(1) === change.substr(1)) {
  7078. changes.push(change);
  7079. state.index++;
  7080. } else {
  7081. conflicted = true;
  7082. }
  7083. }
  7084.  
  7085. if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) {
  7086. conflicted = true;
  7087. }
  7088.  
  7089. if (conflicted) {
  7090. return changes;
  7091. }
  7092.  
  7093. while (matchIndex < matchChanges.length) {
  7094. merged.push(matchChanges[matchIndex++]);
  7095. }
  7096.  
  7097. return {
  7098. merged: merged,
  7099. changes: changes
  7100. };
  7101. }
  7102.  
  7103. function allRemoves(changes) {
  7104. return changes.reduce(function (prev, change) {
  7105. return prev && change[0] === '-';
  7106. }, true);
  7107. }
  7108.  
  7109. function skipRemoveSuperset(state, removeChanges, delta) {
  7110. for (var i = 0; i < delta; i++) {
  7111. var changeContent = removeChanges[removeChanges.length - delta + i].substr(1);
  7112.  
  7113. if (state.lines[state.index + i] !== ' ' + changeContent) {
  7114. return false;
  7115. }
  7116. }
  7117.  
  7118. state.index += delta;
  7119. return true;
  7120. }
  7121.  
  7122. function calcOldNewLineCount(lines) {
  7123. var oldLines = 0;
  7124. var newLines = 0;
  7125. lines.forEach(function (line) {
  7126. if (typeof line !== 'string') {
  7127. var myCount = calcOldNewLineCount(line.mine);
  7128. var theirCount = calcOldNewLineCount(line.theirs);
  7129.  
  7130. if (oldLines !== undefined) {
  7131. if (myCount.oldLines === theirCount.oldLines) {
  7132. oldLines += myCount.oldLines;
  7133. } else {
  7134. oldLines = undefined;
  7135. }
  7136. }
  7137.  
  7138. if (newLines !== undefined) {
  7139. if (myCount.newLines === theirCount.newLines) {
  7140. newLines += myCount.newLines;
  7141. } else {
  7142. newLines = undefined;
  7143. }
  7144. }
  7145. } else {
  7146. if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) {
  7147. newLines++;
  7148. }
  7149.  
  7150. if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) {
  7151. oldLines++;
  7152. }
  7153. }
  7154. });
  7155. return {
  7156. oldLines: oldLines,
  7157. newLines: newLines
  7158. };
  7159. }
  7160.  
  7161. // See: http://code.google.com/p/google-diff-match-patch/wiki/API
  7162. function convertChangesToDMP(changes) {
  7163. var ret = [],
  7164. change,
  7165. operation;
  7166.  
  7167. for (var i = 0; i < changes.length; i++) {
  7168. change = changes[i];
  7169.  
  7170. if (change.added) {
  7171. operation = 1;
  7172. } else if (change.removed) {
  7173. operation = -1;
  7174. } else {
  7175. operation = 0;
  7176. }
  7177.  
  7178. ret.push([operation, change.value]);
  7179. }
  7180.  
  7181. return ret;
  7182. }
  7183.  
  7184. function convertChangesToXML(changes) {
  7185. var ret = [];
  7186.  
  7187. for (var i = 0; i < changes.length; i++) {
  7188. var change = changes[i];
  7189.  
  7190. if (change.added) {
  7191. ret.push('<ins>');
  7192. } else if (change.removed) {
  7193. ret.push('<del>');
  7194. }
  7195.  
  7196. ret.push(escapeHTML(change.value));
  7197.  
  7198. if (change.added) {
  7199. ret.push('</ins>');
  7200. } else if (change.removed) {
  7201. ret.push('</del>');
  7202. }
  7203. }
  7204.  
  7205. return ret.join('');
  7206. }
  7207.  
  7208. function escapeHTML(s) {
  7209. var n = s;
  7210. n = n.replace(/&/g, '&amp;');
  7211. n = n.replace(/</g, '&lt;');
  7212. n = n.replace(/>/g, '&gt;');
  7213. n = n.replace(/"/g, '&quot;');
  7214. return n;
  7215. }
  7216.  
  7217. /* See LICENSE file for terms of use */
  7218.  
  7219. exports.Diff = Diff;
  7220. exports.diffChars = diffChars;
  7221. exports.diffWords = diffWords;
  7222. exports.diffWordsWithSpace = diffWordsWithSpace;
  7223. exports.diffLines = diffLines;
  7224. exports.diffTrimmedLines = diffTrimmedLines;
  7225. exports.diffSentences = diffSentences;
  7226. exports.diffCss = diffCss;
  7227. exports.diffJson = diffJson;
  7228. exports.diffArrays = diffArrays;
  7229. exports.structuredPatch = structuredPatch;
  7230. exports.createTwoFilesPatch = createTwoFilesPatch;
  7231. exports.createPatch = createPatch;
  7232. exports.applyPatch = applyPatch;
  7233. exports.applyPatches = applyPatches;
  7234. exports.parsePatch = parsePatch;
  7235. exports.merge = merge;
  7236. exports.convertChangesToDMP = convertChangesToDMP;
  7237. exports.convertChangesToXML = convertChangesToXML;
  7238. exports.canonicalize = canonicalize;
  7239.  
  7240. Object.defineProperty(exports, '__esModule', { value: true });
  7241.  
  7242. }));
  7243.  
  7244.  
  7245. /***/ }),
  7246.  
  7247. /***/ "xeH2":
  7248. /***/ (function(module, exports) {
  7249.  
  7250. module.exports = $;
  7251.  
  7252. /***/ }),
  7253.  
  7254. /***/ "yLpj":
  7255. /***/ (function(module, exports) {
  7256.  
  7257. var g;
  7258.  
  7259. // This works in non-strict mode
  7260. g = (function() {
  7261. return this;
  7262. })();
  7263.  
  7264. try {
  7265. // This works if eval is allowed (see CSP)
  7266. g = g || new Function("return this")();
  7267. } catch (e) {
  7268. // This works if the window reference is available
  7269. if (typeof window === "object") g = window;
  7270. }
  7271.  
  7272. // g can still be undefined, but nothing to do about it...
  7273. // We return undefined, instead of nothing here, so it's
  7274. // easier to handle this case. if(!global) { ...}
  7275.  
  7276. module.exports = g;
  7277.  
  7278.  
  7279. /***/ })
  7280.  
  7281. /******/ });