UNPKG

youzanyun-devtool-worker

Version:

- web - ws - proxy

13 lines 905 kB
!function(e){var n={};function r(t){if(n[t])return n[t].exports;var i=n[t]={i:t,l:!1,exports:{}};return e[t].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=e,r.c=n,r.d=function(e,n,t){r.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:t})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,n){if(1&n&&(e=r(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(r.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var i in e)r.d(t,i,function(n){return e[n]}.bind(null,i));return t},r.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(n,"a",n),n},r.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},r.p="/react-ui/",r(r.s="./node_modules/monaco-editor/esm/vs/language/json/json.worker.js")}({"./node_modules/monaco-editor/esm/vs/base/common/arrays.js": /*!*****************************************************************!*\ !*** ./node_modules/monaco-editor/esm/vs/base/common/arrays.js ***! \*****************************************************************/ /*! exports provided: tail, tail2, equals, binarySearch, findFirstInSorted, mergeSort, groupBy, coalesce, isFalsyOrEmpty, isNonEmptyArray, distinct, distinctES6, fromSet, firstIndex, first, firstOrDefault, flatten, range, arrayInsert, pushToStart, pushToEnd, find, asArray */function(module,__webpack_exports__,__webpack_require__){"use strict";eval('__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tail", function() { return tail; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tail2", function() { return tail2; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "binarySearch", function() { return binarySearch; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "findFirstInSorted", function() { return findFirstInSorted; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mergeSort", function() { return mergeSort; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "groupBy", function() { return groupBy; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "coalesce", function() { return coalesce; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isFalsyOrEmpty", function() { return isFalsyOrEmpty; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isNonEmptyArray", function() { return isNonEmptyArray; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "distinct", function() { return distinct; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "distinctES6", function() { return distinctES6; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromSet", function() { return fromSet; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "firstIndex", function() { return firstIndex; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "first", function() { return first; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "firstOrDefault", function() { return firstOrDefault; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "flatten", function() { return flatten; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "range", function() { return range; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "arrayInsert", function() { return arrayInsert; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pushToStart", function() { return pushToStart; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pushToEnd", function() { return pushToEnd; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "find", function() { return find; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "asArray", function() { return asArray; });\n/**\r\n * Returns the last element of an array.\r\n * @param array The array.\r\n * @param n Which element from the end (default is zero).\r\n */\r\nfunction tail(array, n) {\r\n if (n === void 0) { n = 0; }\r\n return array[array.length - (1 + n)];\r\n}\r\nfunction tail2(arr) {\r\n if (arr.length === 0) {\r\n throw new Error(\'Invalid tail call\');\r\n }\r\n return [arr.slice(0, arr.length - 1), arr[arr.length - 1]];\r\n}\r\nfunction equals(one, other, itemEquals) {\r\n if (itemEquals === void 0) { itemEquals = function (a, b) { return a === b; }; }\r\n if (one === other) {\r\n return true;\r\n }\r\n if (!one || !other) {\r\n return false;\r\n }\r\n if (one.length !== other.length) {\r\n return false;\r\n }\r\n for (var i = 0, len = one.length; i < len; i++) {\r\n if (!itemEquals(one[i], other[i])) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n}\r\nfunction binarySearch(array, key, comparator) {\r\n var low = 0, high = array.length - 1;\r\n while (low <= high) {\r\n var mid = ((low + high) / 2) | 0;\r\n var comp = comparator(array[mid], key);\r\n if (comp < 0) {\r\n low = mid + 1;\r\n }\r\n else if (comp > 0) {\r\n high = mid - 1;\r\n }\r\n else {\r\n return mid;\r\n }\r\n }\r\n return -(low + 1);\r\n}\r\n/**\r\n * Takes a sorted array and a function p. The array is sorted in such a way that all elements where p(x) is false\r\n * are located before all elements where p(x) is true.\r\n * @returns the least x for which p(x) is true or array.length if no element fullfills the given function.\r\n */\r\nfunction findFirstInSorted(array, p) {\r\n var low = 0, high = array.length;\r\n if (high === 0) {\r\n return 0; // no children\r\n }\r\n while (low < high) {\r\n var mid = Math.floor((low + high) / 2);\r\n if (p(array[mid])) {\r\n high = mid;\r\n }\r\n else {\r\n low = mid + 1;\r\n }\r\n }\r\n return low;\r\n}\r\n/**\r\n * Like `Array#sort` but always stable. Usually runs a little slower `than Array#sort`\r\n * so only use this when actually needing stable sort.\r\n */\r\nfunction mergeSort(data, compare) {\r\n _sort(data, compare, 0, data.length - 1, []);\r\n return data;\r\n}\r\nfunction _merge(a, compare, lo, mid, hi, aux) {\r\n var leftIdx = lo, rightIdx = mid + 1;\r\n for (var i = lo; i <= hi; i++) {\r\n aux[i] = a[i];\r\n }\r\n for (var i = lo; i <= hi; i++) {\r\n if (leftIdx > mid) {\r\n // left side consumed\r\n a[i] = aux[rightIdx++];\r\n }\r\n else if (rightIdx > hi) {\r\n // right side consumed\r\n a[i] = aux[leftIdx++];\r\n }\r\n else if (compare(aux[rightIdx], aux[leftIdx]) < 0) {\r\n // right element is less -> comes first\r\n a[i] = aux[rightIdx++];\r\n }\r\n else {\r\n // left element comes first (less or equal)\r\n a[i] = aux[leftIdx++];\r\n }\r\n }\r\n}\r\nfunction _sort(a, compare, lo, hi, aux) {\r\n if (hi <= lo) {\r\n return;\r\n }\r\n var mid = lo + ((hi - lo) / 2) | 0;\r\n _sort(a, compare, lo, mid, aux);\r\n _sort(a, compare, mid + 1, hi, aux);\r\n if (compare(a[mid], a[mid + 1]) <= 0) {\r\n // left and right are sorted and if the last-left element is less\r\n // or equals than the first-right element there is nothing else\r\n // to do\r\n return;\r\n }\r\n _merge(a, compare, lo, mid, hi, aux);\r\n}\r\nfunction groupBy(data, compare) {\r\n var result = [];\r\n var currentGroup = undefined;\r\n for (var _i = 0, _a = mergeSort(data.slice(0), compare); _i < _a.length; _i++) {\r\n var element = _a[_i];\r\n if (!currentGroup || compare(currentGroup[0], element) !== 0) {\r\n currentGroup = [element];\r\n result.push(currentGroup);\r\n }\r\n else {\r\n currentGroup.push(element);\r\n }\r\n }\r\n return result;\r\n}\r\n/**\r\n * @returns New array with all falsy values removed. The original array IS NOT modified.\r\n */\r\nfunction coalesce(array) {\r\n return array.filter(function (e) { return !!e; });\r\n}\r\n/**\r\n * @returns false if the provided object is an array and not empty.\r\n */\r\nfunction isFalsyOrEmpty(obj) {\r\n return !Array.isArray(obj) || obj.length === 0;\r\n}\r\nfunction isNonEmptyArray(obj) {\r\n return Array.isArray(obj) && obj.length > 0;\r\n}\r\n/**\r\n * Removes duplicates from the given array. The optional keyFn allows to specify\r\n * how elements are checked for equalness by returning a unique string for each.\r\n */\r\nfunction distinct(array, keyFn) {\r\n if (!keyFn) {\r\n return array.filter(function (element, position) {\r\n return array.indexOf(element) === position;\r\n });\r\n }\r\n var seen = Object.create(null);\r\n return array.filter(function (elem) {\r\n var key = keyFn(elem);\r\n if (seen[key]) {\r\n return false;\r\n }\r\n seen[key] = true;\r\n return true;\r\n });\r\n}\r\nfunction distinctES6(array) {\r\n var seen = new Set();\r\n return array.filter(function (element) {\r\n if (seen.has(element)) {\r\n return false;\r\n }\r\n seen.add(element);\r\n return true;\r\n });\r\n}\r\nfunction fromSet(set) {\r\n var result = [];\r\n set.forEach(function (o) { return result.push(o); });\r\n return result;\r\n}\r\nfunction firstIndex(array, fn) {\r\n for (var i = 0; i < array.length; i++) {\r\n var element = array[i];\r\n if (fn(element)) {\r\n return i;\r\n }\r\n }\r\n return -1;\r\n}\r\nfunction first(array, fn, notFoundValue) {\r\n if (notFoundValue === void 0) { notFoundValue = undefined; }\r\n var index = firstIndex(array, fn);\r\n return index < 0 ? notFoundValue : array[index];\r\n}\r\nfunction firstOrDefault(array, notFoundValue) {\r\n return array.length > 0 ? array[0] : notFoundValue;\r\n}\r\nfunction flatten(arr) {\r\n var _a;\r\n return (_a = []).concat.apply(_a, arr);\r\n}\r\nfunction range(arg, to) {\r\n var from = typeof to === \'number\' ? arg : 0;\r\n if (typeof to === \'number\') {\r\n from = arg;\r\n }\r\n else {\r\n from = 0;\r\n to = arg;\r\n }\r\n var result = [];\r\n if (from <= to) {\r\n for (var i = from; i < to; i++) {\r\n result.push(i);\r\n }\r\n }\r\n else {\r\n for (var i = from; i > to; i--) {\r\n result.push(i);\r\n }\r\n }\r\n return result;\r\n}\r\n/**\r\n * Insert `insertArr` inside `target` at `insertIndex`.\r\n * Please don\'t touch unless you understand https://jsperf.com/inserting-an-array-within-an-array\r\n */\r\nfunction arrayInsert(target, insertIndex, insertArr) {\r\n var before = target.slice(0, insertIndex);\r\n var after = target.slice(insertIndex);\r\n return before.concat(insertArr, after);\r\n}\r\n/**\r\n * Pushes an element to the start of the array, if found.\r\n */\r\nfunction pushToStart(arr, value) {\r\n var index = arr.indexOf(value);\r\n if (index > -1) {\r\n arr.splice(index, 1);\r\n arr.unshift(value);\r\n }\r\n}\r\n/**\r\n * Pushes an element to the end of the array, if found.\r\n */\r\nfunction pushToEnd(arr, value) {\r\n var index = arr.indexOf(value);\r\n if (index > -1) {\r\n arr.splice(index, 1);\r\n arr.push(value);\r\n }\r\n}\r\nfunction find(arr, predicate) {\r\n for (var i = 0; i < arr.length; i++) {\r\n var element = arr[i];\r\n if (predicate(element, i, arr)) {\r\n return element;\r\n }\r\n }\r\n return undefined;\r\n}\r\nfunction asArray(x) {\r\n return Array.isArray(x) ? x : [x];\r\n}\r\n\n\n//# sourceURL=webpack:///./node_modules/monaco-editor/esm/vs/base/common/arrays.js?')},"./node_modules/monaco-editor/esm/vs/base/common/cancellation.js": /*!***********************************************************************!*\ !*** ./node_modules/monaco-editor/esm/vs/base/common/cancellation.js ***! \***********************************************************************/ /*! exports provided: CancellationToken, CancellationTokenSource */function(module,__webpack_exports__,__webpack_require__){"use strict";eval('__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CancellationToken", function() { return CancellationToken; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CancellationTokenSource", function() { return CancellationTokenSource; });\n/* harmony import */ var _event_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./event.js */ "./node_modules/monaco-editor/esm/vs/base/common/event.js");\n/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License. See License.txt in the project root for license information.\r\n *--------------------------------------------------------------------------------------------*/\r\n\r\nvar shortcutEvent = Object.freeze(function (callback, context) {\r\n var handle = setTimeout(callback.bind(context), 0);\r\n return { dispose: function () { clearTimeout(handle); } };\r\n});\r\nvar CancellationToken;\r\n(function (CancellationToken) {\r\n function isCancellationToken(thing) {\r\n if (thing === CancellationToken.None || thing === CancellationToken.Cancelled) {\r\n return true;\r\n }\r\n if (thing instanceof MutableToken) {\r\n return true;\r\n }\r\n if (!thing || typeof thing !== \'object\') {\r\n return false;\r\n }\r\n return typeof thing.isCancellationRequested === \'boolean\'\r\n && typeof thing.onCancellationRequested === \'function\';\r\n }\r\n CancellationToken.isCancellationToken = isCancellationToken;\r\n CancellationToken.None = Object.freeze({\r\n isCancellationRequested: false,\r\n onCancellationRequested: _event_js__WEBPACK_IMPORTED_MODULE_0__["Event"].None\r\n });\r\n CancellationToken.Cancelled = Object.freeze({\r\n isCancellationRequested: true,\r\n onCancellationRequested: shortcutEvent\r\n });\r\n})(CancellationToken || (CancellationToken = {}));\r\nvar MutableToken = /** @class */ (function () {\r\n function MutableToken() {\r\n this._isCancelled = false;\r\n this._emitter = null;\r\n }\r\n MutableToken.prototype.cancel = function () {\r\n if (!this._isCancelled) {\r\n this._isCancelled = true;\r\n if (this._emitter) {\r\n this._emitter.fire(undefined);\r\n this.dispose();\r\n }\r\n }\r\n };\r\n Object.defineProperty(MutableToken.prototype, "isCancellationRequested", {\r\n get: function () {\r\n return this._isCancelled;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(MutableToken.prototype, "onCancellationRequested", {\r\n get: function () {\r\n if (this._isCancelled) {\r\n return shortcutEvent;\r\n }\r\n if (!this._emitter) {\r\n this._emitter = new _event_js__WEBPACK_IMPORTED_MODULE_0__["Emitter"]();\r\n }\r\n return this._emitter.event;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n MutableToken.prototype.dispose = function () {\r\n if (this._emitter) {\r\n this._emitter.dispose();\r\n this._emitter = null;\r\n }\r\n };\r\n return MutableToken;\r\n}());\r\nvar CancellationTokenSource = /** @class */ (function () {\r\n function CancellationTokenSource(parent) {\r\n this._token = undefined;\r\n this._parentListener = undefined;\r\n this._parentListener = parent && parent.onCancellationRequested(this.cancel, this);\r\n }\r\n Object.defineProperty(CancellationTokenSource.prototype, "token", {\r\n get: function () {\r\n if (!this._token) {\r\n // be lazy and create the token only when\r\n // actually needed\r\n this._token = new MutableToken();\r\n }\r\n return this._token;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n CancellationTokenSource.prototype.cancel = function () {\r\n if (!this._token) {\r\n // save an object by returning the default\r\n // cancelled token when cancellation happens\r\n // before someone asks for the token\r\n this._token = CancellationToken.Cancelled;\r\n }\r\n else if (this._token instanceof MutableToken) {\r\n // actually cancel\r\n this._token.cancel();\r\n }\r\n };\r\n CancellationTokenSource.prototype.dispose = function (cancel) {\r\n if (cancel === void 0) { cancel = false; }\r\n if (cancel) {\r\n this.cancel();\r\n }\r\n if (this._parentListener) {\r\n this._parentListener.dispose();\r\n }\r\n if (!this._token) {\r\n // ensure to initialize with an empty token if we had none\r\n this._token = CancellationToken.None;\r\n }\r\n else if (this._token instanceof MutableToken) {\r\n // actually dispose\r\n this._token.dispose();\r\n }\r\n };\r\n return CancellationTokenSource;\r\n}());\r\n\r\n\n\n//# sourceURL=webpack:///./node_modules/monaco-editor/esm/vs/base/common/cancellation.js?')},"./node_modules/monaco-editor/esm/vs/base/common/diff/diff.js": /*!********************************************************************!*\ !*** ./node_modules/monaco-editor/esm/vs/base/common/diff/diff.js ***! \********************************************************************/ /*! exports provided: StringDiffSequence, stringDiff, Debug, MyArray, LcsDiff */function(module,__webpack_exports__,__webpack_require__){"use strict";eval('__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringDiffSequence", function() { return StringDiffSequence; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stringDiff", function() { return stringDiff; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Debug", function() { return Debug; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MyArray", function() { return MyArray; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LcsDiff", function() { return LcsDiff; });\n/* harmony import */ var _diffChange_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./diffChange.js */ "./node_modules/monaco-editor/esm/vs/base/common/diff/diffChange.js");\n/* harmony import */ var _hash_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../hash.js */ "./node_modules/monaco-editor/esm/vs/base/common/hash.js");\n/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License. See License.txt in the project root for license information.\r\n *--------------------------------------------------------------------------------------------*/\r\n\r\n\r\nvar StringDiffSequence = /** @class */ (function () {\r\n function StringDiffSequence(source) {\r\n this.source = source;\r\n }\r\n StringDiffSequence.prototype.getElements = function () {\r\n var source = this.source;\r\n var characters = new Int32Array(source.length);\r\n for (var i = 0, len = source.length; i < len; i++) {\r\n characters[i] = source.charCodeAt(i);\r\n }\r\n return characters;\r\n };\r\n return StringDiffSequence;\r\n}());\r\n\r\nfunction stringDiff(original, modified, pretty) {\r\n return new LcsDiff(new StringDiffSequence(original), new StringDiffSequence(modified)).ComputeDiff(pretty).changes;\r\n}\r\n//\r\n// The code below has been ported from a C# implementation in VS\r\n//\r\nvar Debug = /** @class */ (function () {\r\n function Debug() {\r\n }\r\n Debug.Assert = function (condition, message) {\r\n if (!condition) {\r\n throw new Error(message);\r\n }\r\n };\r\n return Debug;\r\n}());\r\n\r\nvar MyArray = /** @class */ (function () {\r\n function MyArray() {\r\n }\r\n /**\r\n * Copies a range of elements from an Array starting at the specified source index and pastes\r\n * them to another Array starting at the specified destination index. The length and the indexes\r\n * are specified as 64-bit integers.\r\n * sourceArray:\r\n *\t\tThe Array that contains the data to copy.\r\n * sourceIndex:\r\n *\t\tA 64-bit integer that represents the index in the sourceArray at which copying begins.\r\n * destinationArray:\r\n *\t\tThe Array that receives the data.\r\n * destinationIndex:\r\n *\t\tA 64-bit integer that represents the index in the destinationArray at which storing begins.\r\n * length:\r\n *\t\tA 64-bit integer that represents the number of elements to copy.\r\n */\r\n MyArray.Copy = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) {\r\n for (var i = 0; i < length; i++) {\r\n destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i];\r\n }\r\n };\r\n MyArray.Copy2 = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) {\r\n for (var i = 0; i < length; i++) {\r\n destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i];\r\n }\r\n };\r\n return MyArray;\r\n}());\r\n\r\n/**\r\n * A utility class which helps to create the set of DiffChanges from\r\n * a difference operation. This class accepts original DiffElements and\r\n * modified DiffElements that are involved in a particular change. The\r\n * MarktNextChange() method can be called to mark the separation between\r\n * distinct changes. At the end, the Changes property can be called to retrieve\r\n * the constructed changes.\r\n */\r\nvar DiffChangeHelper = /** @class */ (function () {\r\n /**\r\n * Constructs a new DiffChangeHelper for the given DiffSequences.\r\n */\r\n function DiffChangeHelper() {\r\n this.m_changes = [];\r\n this.m_originalStart = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;\r\n this.m_modifiedStart = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;\r\n this.m_originalCount = 0;\r\n this.m_modifiedCount = 0;\r\n }\r\n /**\r\n * Marks the beginning of the next change in the set of differences.\r\n */\r\n DiffChangeHelper.prototype.MarkNextChange = function () {\r\n // Only add to the list if there is something to add\r\n if (this.m_originalCount > 0 || this.m_modifiedCount > 0) {\r\n // Add the new change to our list\r\n this.m_changes.push(new _diffChange_js__WEBPACK_IMPORTED_MODULE_0__["DiffChange"](this.m_originalStart, this.m_originalCount, this.m_modifiedStart, this.m_modifiedCount));\r\n }\r\n // Reset for the next change\r\n this.m_originalCount = 0;\r\n this.m_modifiedCount = 0;\r\n this.m_originalStart = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;\r\n this.m_modifiedStart = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;\r\n };\r\n /**\r\n * Adds the original element at the given position to the elements\r\n * affected by the current change. The modified index gives context\r\n * to the change position with respect to the original sequence.\r\n * @param originalIndex The index of the original element to add.\r\n * @param modifiedIndex The index of the modified element that provides corresponding position in the modified sequence.\r\n */\r\n DiffChangeHelper.prototype.AddOriginalElement = function (originalIndex, modifiedIndex) {\r\n // The \'true\' start index is the smallest of the ones we\'ve seen\r\n this.m_originalStart = Math.min(this.m_originalStart, originalIndex);\r\n this.m_modifiedStart = Math.min(this.m_modifiedStart, modifiedIndex);\r\n this.m_originalCount++;\r\n };\r\n /**\r\n * Adds the modified element at the given position to the elements\r\n * affected by the current change. The original index gives context\r\n * to the change position with respect to the modified sequence.\r\n * @param originalIndex The index of the original element that provides corresponding position in the original sequence.\r\n * @param modifiedIndex The index of the modified element to add.\r\n */\r\n DiffChangeHelper.prototype.AddModifiedElement = function (originalIndex, modifiedIndex) {\r\n // The \'true\' start index is the smallest of the ones we\'ve seen\r\n this.m_originalStart = Math.min(this.m_originalStart, originalIndex);\r\n this.m_modifiedStart = Math.min(this.m_modifiedStart, modifiedIndex);\r\n this.m_modifiedCount++;\r\n };\r\n /**\r\n * Retrieves all of the changes marked by the class.\r\n */\r\n DiffChangeHelper.prototype.getChanges = function () {\r\n if (this.m_originalCount > 0 || this.m_modifiedCount > 0) {\r\n // Finish up on whatever is left\r\n this.MarkNextChange();\r\n }\r\n return this.m_changes;\r\n };\r\n /**\r\n * Retrieves all of the changes marked by the class in the reverse order\r\n */\r\n DiffChangeHelper.prototype.getReverseChanges = function () {\r\n if (this.m_originalCount > 0 || this.m_modifiedCount > 0) {\r\n // Finish up on whatever is left\r\n this.MarkNextChange();\r\n }\r\n this.m_changes.reverse();\r\n return this.m_changes;\r\n };\r\n return DiffChangeHelper;\r\n}());\r\n/**\r\n * An implementation of the difference algorithm described in\r\n * "An O(ND) Difference Algorithm and its variations" by Eugene W. Myers\r\n */\r\nvar LcsDiff = /** @class */ (function () {\r\n /**\r\n * Constructs the DiffFinder\r\n */\r\n function LcsDiff(originalSequence, modifiedSequence, continueProcessingPredicate) {\r\n if (continueProcessingPredicate === void 0) { continueProcessingPredicate = null; }\r\n this.ContinueProcessingPredicate = continueProcessingPredicate;\r\n var _a = LcsDiff._getElements(originalSequence), originalStringElements = _a[0], originalElementsOrHash = _a[1], originalHasStrings = _a[2];\r\n var _b = LcsDiff._getElements(modifiedSequence), modifiedStringElements = _b[0], modifiedElementsOrHash = _b[1], modifiedHasStrings = _b[2];\r\n this._hasStrings = (originalHasStrings && modifiedHasStrings);\r\n this._originalStringElements = originalStringElements;\r\n this._originalElementsOrHash = originalElementsOrHash;\r\n this._modifiedStringElements = modifiedStringElements;\r\n this._modifiedElementsOrHash = modifiedElementsOrHash;\r\n this.m_forwardHistory = [];\r\n this.m_reverseHistory = [];\r\n }\r\n LcsDiff._isStringArray = function (arr) {\r\n return (arr.length > 0 && typeof arr[0] === \'string\');\r\n };\r\n LcsDiff._getElements = function (sequence) {\r\n var elements = sequence.getElements();\r\n if (LcsDiff._isStringArray(elements)) {\r\n var hashes = new Int32Array(elements.length);\r\n for (var i = 0, len = elements.length; i < len; i++) {\r\n hashes[i] = Object(_hash_js__WEBPACK_IMPORTED_MODULE_1__["stringHash"])(elements[i], 0);\r\n }\r\n return [elements, hashes, true];\r\n }\r\n if (elements instanceof Int32Array) {\r\n return [[], elements, false];\r\n }\r\n return [[], new Int32Array(elements), false];\r\n };\r\n LcsDiff.prototype.ElementsAreEqual = function (originalIndex, newIndex) {\r\n if (this._originalElementsOrHash[originalIndex] !== this._modifiedElementsOrHash[newIndex]) {\r\n return false;\r\n }\r\n return (this._hasStrings ? this._originalStringElements[originalIndex] === this._modifiedStringElements[newIndex] : true);\r\n };\r\n LcsDiff.prototype.OriginalElementsAreEqual = function (index1, index2) {\r\n if (this._originalElementsOrHash[index1] !== this._originalElementsOrHash[index2]) {\r\n return false;\r\n }\r\n return (this._hasStrings ? this._originalStringElements[index1] === this._originalStringElements[index2] : true);\r\n };\r\n LcsDiff.prototype.ModifiedElementsAreEqual = function (index1, index2) {\r\n if (this._modifiedElementsOrHash[index1] !== this._modifiedElementsOrHash[index2]) {\r\n return false;\r\n }\r\n return (this._hasStrings ? this._modifiedStringElements[index1] === this._modifiedStringElements[index2] : true);\r\n };\r\n LcsDiff.prototype.ComputeDiff = function (pretty) {\r\n return this._ComputeDiff(0, this._originalElementsOrHash.length - 1, 0, this._modifiedElementsOrHash.length - 1, pretty);\r\n };\r\n /**\r\n * Computes the differences between the original and modified input\r\n * sequences on the bounded range.\r\n * @returns An array of the differences between the two input sequences.\r\n */\r\n LcsDiff.prototype._ComputeDiff = function (originalStart, originalEnd, modifiedStart, modifiedEnd, pretty) {\r\n var quitEarlyArr = [false];\r\n var changes = this.ComputeDiffRecursive(originalStart, originalEnd, modifiedStart, modifiedEnd, quitEarlyArr);\r\n if (pretty) {\r\n // We have to clean up the computed diff to be more intuitive\r\n // but it turns out this cannot be done correctly until the entire set\r\n // of diffs have been computed\r\n changes = this.PrettifyChanges(changes);\r\n }\r\n return {\r\n quitEarly: quitEarlyArr[0],\r\n changes: changes\r\n };\r\n };\r\n /**\r\n * Private helper method which computes the differences on the bounded range\r\n * recursively.\r\n * @returns An array of the differences between the two input sequences.\r\n */\r\n LcsDiff.prototype.ComputeDiffRecursive = function (originalStart, originalEnd, modifiedStart, modifiedEnd, quitEarlyArr) {\r\n quitEarlyArr[0] = false;\r\n // Find the start of the differences\r\n while (originalStart <= originalEnd && modifiedStart <= modifiedEnd && this.ElementsAreEqual(originalStart, modifiedStart)) {\r\n originalStart++;\r\n modifiedStart++;\r\n }\r\n // Find the end of the differences\r\n while (originalEnd >= originalStart && modifiedEnd >= modifiedStart && this.ElementsAreEqual(originalEnd, modifiedEnd)) {\r\n originalEnd--;\r\n modifiedEnd--;\r\n }\r\n // In the special case where we either have all insertions or all deletions or the sequences are identical\r\n if (originalStart > originalEnd || modifiedStart > modifiedEnd) {\r\n var changes = void 0;\r\n if (modifiedStart <= modifiedEnd) {\r\n Debug.Assert(originalStart === originalEnd + 1, \'originalStart should only be one more than originalEnd\');\r\n // All insertions\r\n changes = [\r\n new _diffChange_js__WEBPACK_IMPORTED_MODULE_0__["DiffChange"](originalStart, 0, modifiedStart, modifiedEnd - modifiedStart + 1)\r\n ];\r\n }\r\n else if (originalStart <= originalEnd) {\r\n Debug.Assert(modifiedStart === modifiedEnd + 1, \'modifiedStart should only be one more than modifiedEnd\');\r\n // All deletions\r\n changes = [\r\n new _diffChange_js__WEBPACK_IMPORTED_MODULE_0__["DiffChange"](originalStart, originalEnd - originalStart + 1, modifiedStart, 0)\r\n ];\r\n }\r\n else {\r\n Debug.Assert(originalStart === originalEnd + 1, \'originalStart should only be one more than originalEnd\');\r\n Debug.Assert(modifiedStart === modifiedEnd + 1, \'modifiedStart should only be one more than modifiedEnd\');\r\n // Identical sequences - No differences\r\n changes = [];\r\n }\r\n return changes;\r\n }\r\n // This problem can be solved using the Divide-And-Conquer technique.\r\n var midOriginalArr = [0];\r\n var midModifiedArr = [0];\r\n var result = this.ComputeRecursionPoint(originalStart, originalEnd, modifiedStart, modifiedEnd, midOriginalArr, midModifiedArr, quitEarlyArr);\r\n var midOriginal = midOriginalArr[0];\r\n var midModified = midModifiedArr[0];\r\n if (result !== null) {\r\n // Result is not-null when there was enough memory to compute the changes while\r\n // searching for the recursion point\r\n return result;\r\n }\r\n else if (!quitEarlyArr[0]) {\r\n // We can break the problem down recursively by finding the changes in the\r\n // First Half: (originalStart, modifiedStart) to (midOriginal, midModified)\r\n // Second Half: (midOriginal + 1, minModified + 1) to (originalEnd, modifiedEnd)\r\n // NOTE: ComputeDiff() is inclusive, therefore the second range starts on the next point\r\n var leftChanges = this.ComputeDiffRecursive(originalStart, midOriginal, modifiedStart, midModified, quitEarlyArr);\r\n var rightChanges = [];\r\n if (!quitEarlyArr[0]) {\r\n rightChanges = this.ComputeDiffRecursive(midOriginal + 1, originalEnd, midModified + 1, modifiedEnd, quitEarlyArr);\r\n }\r\n else {\r\n // We did\'t have time to finish the first half, so we don\'t have time to compute this half.\r\n // Consider the entire rest of the sequence different.\r\n rightChanges = [\r\n new _diffChange_js__WEBPACK_IMPORTED_MODULE_0__["DiffChange"](midOriginal + 1, originalEnd - (midOriginal + 1) + 1, midModified + 1, modifiedEnd - (midModified + 1) + 1)\r\n ];\r\n }\r\n return this.ConcatenateChanges(leftChanges, rightChanges);\r\n }\r\n // If we hit here, we quit early, and so can\'t return anything meaningful\r\n return [\r\n new _diffChange_js__WEBPACK_IMPORTED_MODULE_0__["DiffChange"](originalStart, originalEnd - originalStart + 1, modifiedStart, modifiedEnd - modifiedStart + 1)\r\n ];\r\n };\r\n LcsDiff.prototype.WALKTRACE = function (diagonalForwardBase, diagonalForwardStart, diagonalForwardEnd, diagonalForwardOffset, diagonalReverseBase, diagonalReverseStart, diagonalReverseEnd, diagonalReverseOffset, forwardPoints, reversePoints, originalIndex, originalEnd, midOriginalArr, modifiedIndex, modifiedEnd, midModifiedArr, deltaIsEven, quitEarlyArr) {\r\n var forwardChanges = null;\r\n var reverseChanges = null;\r\n // First, walk backward through the forward diagonals history\r\n var changeHelper = new DiffChangeHelper();\r\n var diagonalMin = diagonalForwardStart;\r\n var diagonalMax = diagonalForwardEnd;\r\n var diagonalRelative = (midOriginalArr[0] - midModifiedArr[0]) - diagonalForwardOffset;\r\n var lastOriginalIndex = -1073741824 /* MIN_SAFE_SMALL_INTEGER */;\r\n var historyIndex = this.m_forwardHistory.length - 1;\r\n do {\r\n // Get the diagonal index from the relative diagonal number\r\n var diagonal = diagonalRelative + diagonalForwardBase;\r\n // Figure out where we came from\r\n if (diagonal === diagonalMin || (diagonal < diagonalMax && forwardPoints[diagonal - 1] < forwardPoints[diagonal + 1])) {\r\n // Vertical line (the element is an insert)\r\n originalIndex = forwardPoints[diagonal + 1];\r\n modifiedIndex = originalIndex - diagonalRelative - diagonalForwardOffset;\r\n if (originalIndex < lastOriginalIndex) {\r\n changeHelper.MarkNextChange();\r\n }\r\n lastOriginalIndex = originalIndex;\r\n changeHelper.AddModifiedElement(originalIndex + 1, modifiedIndex);\r\n diagonalRelative = (diagonal + 1) - diagonalForwardBase; //Setup for the next iteration\r\n }\r\n else {\r\n // Horizontal line (the element is a deletion)\r\n originalIndex = forwardPoints[diagonal - 1] + 1;\r\n modifiedIndex = originalIndex - diagonalRelative - diagonalForwardOffset;\r\n if (originalIndex < lastOriginalIndex) {\r\n changeHelper.MarkNextChange();\r\n }\r\n lastOriginalIndex = originalIndex - 1;\r\n changeHelper.AddOriginalElement(originalIndex, modifiedIndex + 1);\r\n diagonalRelative = (diagonal - 1) - diagonalForwardBase; //Setup for the next iteration\r\n }\r\n if (historyIndex >= 0) {\r\n forwardPoints = this.m_forwardHistory[historyIndex];\r\n diagonalForwardBase = forwardPoints[0]; //We stored this in the first spot\r\n diagonalMin = 1;\r\n diagonalMax = forwardPoints.length - 1;\r\n }\r\n } while (--historyIndex >= -1);\r\n // Ironically, we get the forward changes as the reverse of the\r\n // order we added them since we technically added them backwards\r\n forwardChanges = changeHelper.getReverseChanges();\r\n if (quitEarlyArr[0]) {\r\n // TODO: Calculate a partial from the reverse diagonals.\r\n // For now, just assume everything after the midOriginal/midModified point is a diff\r\n var originalStartPoint = midOriginalArr[0] + 1;\r\n var modifiedStartPoint = midModifiedArr[0] + 1;\r\n if (forwardChanges !== null && forwardChanges.length > 0) {\r\n var lastForwardChange = forwardChanges[forwardChanges.length - 1];\r\n originalStartPoint = Math.max(originalStartPoint, lastForwardChange.getOriginalEnd());\r\n modifiedStartPoint = Math.max(modifiedStartPoint, lastForwardChange.getModifiedEnd());\r\n }\r\n reverseChanges = [\r\n new _diffChange_js__WEBPACK_IMPORTED_MODULE_0__["DiffChange"](originalStartPoint, originalEnd - originalStartPoint + 1, modifiedStartPoint, modifiedEnd - modifiedStartPoint + 1)\r\n ];\r\n }\r\n else {\r\n // Now walk backward through the reverse diagonals history\r\n changeHelper = new DiffChangeHelper();\r\n diagonalMin = diagonalReverseStart;\r\n diagonalMax = diagonalReverseEnd;\r\n diagonalRelative = (midOriginalArr[0] - midModifiedArr[0]) - diagonalReverseOffset;\r\n lastOriginalIndex = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;\r\n historyIndex = (deltaIsEven) ? this.m_reverseHistory.length - 1 : this.m_reverseHistory.length - 2;\r\n do {\r\n // Get the diagonal index from the relative diagonal number\r\n var diagonal = diagonalRelative + diagonalReverseBase;\r\n // Figure out where we came from\r\n if (diagonal === diagonalMin || (diagonal < diagonalMax && reversePoints[diagonal - 1] >= reversePoints[diagonal + 1])) {\r\n // Horizontal line (the element is a deletion))\r\n originalIndex = reversePoints[diagonal + 1] - 1;\r\n modifiedIndex = originalIndex - diagonalRelative - diagonalReverseOffset;\r\n if (originalIndex > lastOriginalIndex) {\r\n changeHelper.MarkNextChange();\r\n }\r\n lastOriginalIndex = originalIndex + 1;\r\n changeHelper.AddOriginalElement(originalIndex + 1, modifiedIndex + 1);\r\n diagonalRelative = (diagonal + 1) - diagonalReverseBase; //Setup for the next iteration\r\n }\r\n else {\r\n // Vertical line (the element is an insertion)\r\n originalIndex = reversePoints[diagonal - 1];\r\n modifiedIndex = originalIndex - diagonalRelative - diagonalReverseOffset;\r\n if (originalIndex > lastOriginalIndex) {\r\n changeHelper.MarkNextChange();\r\n }\r\n lastOriginalIndex = originalIndex;\r\n changeHelper.AddModifiedElement(originalIndex + 1, modifiedIndex + 1);\r\n diagonalRelative = (diagonal - 1) - diagonalReverseBase; //Setup for the next iteration\r\n }\r\n if (historyIndex >= 0) {\r\n reversePoints = this.m_reverseHistory[historyIndex];\r\n diagonalReverseBase = reversePoints[0]; //We stored this in the first spot\r\n diagonalMin = 1;\r\n diagonalMax = reversePoints.length - 1;\r\n }\r\n } while (--historyIndex >= -1);\r\n // There are cases where the reverse history will find diffs that\r\n // are correct, but not intuitive, so we need shift them.\r\n reverseChanges = changeHelper.getChanges();\r\n }\r\n return this.ConcatenateChanges(forwardChanges, reverseChanges);\r\n };\r\n /**\r\n * Given the range to compute the diff on, this method finds the point:\r\n * (midOriginal, midModified)\r\n * that exists in the middle of the LCS of the two sequences and\r\n * is the point at which the LCS problem may be broken down recursively.\r\n * This method will try to keep the LCS trace in memory. If the LCS recursion\r\n * point is calculated and the full trace is available in memory, then this method\r\n * will return the change list.\r\n * @param originalStart The start bound of the original sequence range\r\n * @param originalEnd The end bound of the original sequence range\r\n * @param modifiedStart The start bound of the modified sequence range\r\n * @param modifiedEnd The end bound of the modified sequence range\r\n * @param midOriginal The middle point of the original sequence range\r\n * @param midModified The middle point of the modified sequence range\r\n * @returns The diff changes, if available, otherwise null\r\n */\r\n LcsDiff.prototype.ComputeRecursionPoint = function (originalStart, originalEnd, modifiedStart, modifiedEnd, midOriginalArr, midModifiedArr, quitEarlyArr) {\r\n var originalIndex = 0, modifiedIndex = 0;\r\n var diagonalForwardStart = 0, diagonalForwardEnd = 0;\r\n var diagonalReverseStart = 0, diagonalReverseEnd = 0;\r\n // To traverse the edit graph and produce the proper LCS, our actual\r\n // start position is just outside the given boundary\r\n originalStart--;\r\n modifiedStart--;\r\n // We set these up to make the compiler happy, but they will\r\n // be replaced before we return with the actual recursion point\r\n midOriginalArr[0] = 0;\r\n midModifiedArr[0] = 0;\r\n // Clear out the history\r\n this.m_forwardHistory = [];\r\n this.m_reverseHistory = [];\r\n // Each cell in the two arrays corresponds to a diagonal in the edit graph.\r\n // The integer value in the cell represents the originalIndex of the furthest\r\n // reaching point found so far that ends in that diagonal.\r\n // The modifiedIndex can be computed mathematically from the originalIndex and the diagonal number.\r\n var maxDifferences = (originalEnd - originalStart) + (modifiedEnd - modifiedStart);\r\n var numDiagonals = maxDifferences + 1;\r\n var forwardPoints = new Int32Array(numDiagonals);\r\n var reversePoints = new Int32Array(numDiagonals);\r\n // diagonalForwardBase: Index into forwardPoints of the diagonal which passes through (originalStart, modifiedStart)\r\n // diagonalReverseBase: Index into reversePoints of the diagonal which passes through (originalEnd, modifiedEnd)\r\n var diagonalForwardBase = (modifiedEnd - modifiedStart);\r\n var diagonalReverseBase = (originalEnd - originalStart);\r\n // diagonalForwardOffset: Geometric offset which allows modifiedIndex to be computed from originalIndex and the\r\n // diagonal number (relative to diagonalForwardBase)\r\n // diagonalReverseOffset: Geometric offset which allows modifiedIndex to be computed from originalIndex and the\r\n // diagonal number (relative to diagonalReverseBase)\r\n var diagonalForwardOffset = (originalStart - modifiedStart);\r\n var diagonalReverseOffset = (originalEnd - modifiedEnd);\r\n // delta: The difference between the end diagonal and the start diagonal. This is used to relate diagonal numbers\r\n // relative to the start diagonal with diagonal numbers relative to the end diagonal.\r\n // The Even/Oddn-ness of this delta is important for determining when we should check for overlap\r\n var delta = diagonalReverseBase - diagonalForwardBase;\r\n var deltaIsEven = (delta % 2 === 0);\r\n // Here we set up the start and end points as the furthest points found so far\r\n // in both the forward and reverse directions, respectively\r\n forwardPoints[diagonalForwardBase] = originalStart;\r\n reversePoints[diagonalReverseBase] = originalEnd;\r\n // Remember if we quit early, and thus need to do a best-effort result instead of a real result.\r\n quitEarlyArr[0] = false;\r\n // A couple of points:\r\n // --With this method, we iterate on the number of differences between the two sequences.\r\n // The more differences there actually are, the longer this will take.\r\n // --Also, as the number of differences increases, we have to search on diagonals further\r\n // away from the reference diagonal (which is diagonalForwardBase for forward, diagonalReverseBase for reverse).\r\n // --We extend on even diagonals (relative to the reference diagonal) only when numDifferences\r\n // is even and odd diagonals only when numDifferences is odd.\r\n for (var numDifferences = 1; numDifferences <= (maxDifferences / 2) + 1; numDifferences++) {\r\n var furthestOriginalIndex = 0;\r\n var furthestModifiedIndex = 0;\r\n // Run the algorithm in the forward direction\r\n diagonalForwardStart = this.ClipDiagonalBound(diagonalForwardBase - numDifferences, numDifferences, diagonalForwardBase, numDiagonals);\r\n diagonalForwardEnd = this.ClipDiagonalBound(diagonalForwardBase + numDifferences, numDifferences, diagonalForwardBase, numDiagonals);\r\n for (var diagonal = diagonalForwardStart; diagonal <= diagonalForwardEnd; diagonal += 2) {\r\n // STEP 1: We extend the furthest reaching point in the present diagonal\r\n // by looking at the diagonals above and below and picking the one whose point\r\n // is further away from the start point (originalStart, modifiedStart)\r\n if (diagonal === diagonalForwardStart || (diagonal < diagonalForwardEnd && forwardPoints[diagonal - 1] < forwardPoints[diagonal + 1])) {\r\n originalIndex = forwardPoints[diagonal + 1];\r\n }\r\n else {\r\n originalIndex = forwardPoints[diagonal - 1] + 1;\r\n }\r\n modifiedIndex = originalIndex - (diagonal - diagonalForwardBase) - diagonalForwardOffset;\r\n // Save the current originalIndex so we can test for false overlap in step 3\r\n var tempOriginalIndex = originalIndex;\r\n // STEP 2: We can continue to extend the furthest reaching point in the present diagonal\r\n // so long as the elements are equal.\r\n while (originalIndex < originalEnd && modifiedIndex < modifiedEnd && this.ElementsAreEqual(originalIndex + 1, modifiedIndex + 1)) {\r\n originalIndex++;\r\n modifiedIndex++;\r\n }\r\n forwardPoints[diagonal] = originalIndex;\r\n