diff --git a/README.md b/README.md index 5c75fd3..b291f47 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,11 @@ Chrome devtools extension intended to display result of deep in-memory object comparisons with the help of dedicated console commands. +### Features +* compare objects from multiple tabs and/or between page reloads +* function code included in comparison result in form of a string, may help to see if it was altered +* document, dom-elements and other non-serializable objects are filtered-out from the results +* self recurring references displayed only once, the rest of occurrences are filtered-out ### API ```javascript @@ -13,24 +18,28 @@ console.diffRight(right); // update object on the right side only console.diffPush(next); // shifts sides, right becomes left, next becomes right ``` - ### Usage basics -Historicly, left side represents the old state and right side the new state. -Things that are present on the left side but missing on the right side are colour-coded as red (old). -Things that are missing on the left side but present on the right side are colour-coded as green (new). -To track changes of the same variable in timed manner you can push it with `diffPush` command, +Historically, left side represents the old state and right side the new state. +* Things that are present on the left side but missing on the right side are colour-coded as red (old). +* Things that are missing on the left side but present on the right side are colour-coded as green (new). + +To track changes of the same variable in timed manner you can push it with `diffPush` or `diff` +with a single argument, that will shift objects from right to left, showing differences with previous push state. -You can compare objects from different tabs (sites). +### How it works +* `jsdiff-devtools` registers devtools panel + * injects console commands that send data to `jsdiff-proxy` + * injects `jsdiff-proxy` to farther communicate objects to the extension's `jsdiff-background` +* when `console.diff` command invoked + * argument/s are cloned in a suitable form for sending between different window contexts and sent to `jsdiff-proxy` + * `jsdiff-proxy` catches the data and sends it to the `jsdiff-background` where it is stored for future consuming +* when `jsdiff-panel` is mounted (visible in devtools) it listens to data expected to come from the `jsdiff-background` +and displays it ### Screenshot ![screenshot](./src/img/screenshot-01.png) - -### Gotcha -Comparred objects shouldn't contain functions or self-recurrent references, like DOM elements or view instances have. - - ### Based on - [jsondiffpatch](https://github.com/benjamine/jsondiffpatch) by Benjamín Eidelman - [vuejs](https://github.com/vuejs) by Evan You diff --git a/manifest.json b/manifest.json index 060c1b8..727fa7e 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "console.diff(...)", "description": "Deep compare complex in-memory objects inside browser devtools panel with console.diff command.", - "version": "1.1", + "version": "2.0", "manifest_version": 2, "minimum_chrome_version": "64.0", "devtools_page": "src/jsdiff-devtools.html", @@ -21,7 +21,6 @@ "http://*/*", "https://*/*", "file:///*", - "clipboardWrite", - "tabs" + "clipboardWrite" ] } diff --git a/package.json b/package.json index fff870c..fad0319 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jsdiff", - "version": "1.1.0", + "version": "2.0.0", "description": "![jsdiff](./src/img/panel-icon64.png) --- Chrome devtools extension intended to display result of in-memory object comparisons with the help of dedicated commands invoked via console.", "private": true, "directories": { @@ -30,7 +30,7 @@ "clean-webpack-plugin": "~1.0.1", "css-loader": "~2.1.0", "file-loader": "^3.0.1", - "node-sass": "~4.11.0", + "node-sass": "~4.14.1", "sass-loader": "~7.1.0", "style-loader": "~0.23.1", "vue-loader": "~15.6.2", @@ -39,8 +39,8 @@ "webpack-cli": "~3.2.1" }, "dependencies": { - "jsondiffpatch": "~0.3.11", - "moment": "~2.24.0", - "vue": "~2.6.6" + "jsondiffpatch": "~0.4.1", + "moment": "~2.29.0", + "vue": "~2.6.12" } } diff --git a/src/js/bundle/jsdiff-panel.js b/src/js/bundle/jsdiff-panel.js index 71a9239..56bb318 100644 --- a/src/js/bundle/jsdiff-panel.js +++ b/src/js/bundle/jsdiff-panel.js @@ -1,7 +1,9 @@ -!function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=9)}([function(t,e,n){"use strict";var r=n(1),i=n.n(r);e.default=i.a},function(t,e,n){const r=n(10),i=r.formatters;n(12);const o=n(15).default,a=n(19);t.exports=o.extend({name:"jsdiff-panel",data:()=>({git:{self:"https://github.com/zendive/jsdiff",diffApi:"https://github.com/benjamine/jsondiffpatch"},showUnchanged:!0,compare:{timestamp:null,left:null,right:null},now:Date.now(),timer:null}),mounted(){chrome.runtime.onMessage.addListener((t,e,n)=>{console.log("$_onRuntimeMessage",t),"jsdiff-devtools-extension-api"===t.source&&this.$_onDiffRequest(t.payload)}),chrome.runtime.sendMessage({type:"jsdiff-devtools-panel-shown"},t=>{null!==t&&this.$_onDiffRequest(t.payload)}),window.vm=this},computed:{lastUpdated(){return a(this.compare.timestamp).fromNow()},hasBothSides(){return this.$_hasData(this.compare.left)&&this.$_hasData(this.compare.right)},exactMatch(){return!this.deltaHtml},deltaHtml(){try{return this.$_adjustArrows(),i.html.format(r.diff(this.compare.left,this.compare.right),this.compare.left)}catch(t){return JSON.stringify(t)}}},methods:{onToggleUnchanged(t){this.showUnchanged=!this.showUnchanged,i.html.showUnchanged(this.showUnchanged,this.$refs.delta),this.$_adjustArrows()},onCopyDelta(){const t=r.diff(this.compare.left,this.compare.right),e=JSON.stringify(t,null,2);document.oncopy=function(t){t.clipboardData.setData("text",e),t.preventDefault()},document.execCommand("copy",!1,null)},$_restartLastUpdated(){this.compare.timestamp=Date.now(),this.timer=clearInterval(this.timer),this.timer=setInterval(()=>{this.now=Date.now()},5e3)},$_hasData:t=>null!=t,$_onDiffRequest({left:t,right:e,push:n}){n?(this.compare.left=this.compare.right,this.compare.right=n):(t&&(this.compare.left=t),e&&(this.compare.right=e)),this.$_restartLastUpdated()},$_adjustArrows(){this.$nextTick(()=>{const t=document.body;!function(t,e,n){for(var r=t.querySelectorAll(e),i=0,o=r.length;o>i;i++)n(r[i])}(t,".jsondiffpatch-arrow",function(t){var e=t.parentNode,n=t.children[0],r=n.children[1];n.style.display="none";var i,o=function(t){return t.textContent||t.innerText}(e.querySelector(".jsondiffpatch-moved-destination"));if(function(t,e){for(var n=0,r=t.children.length;r>n;n++)e(t.children[n],n)}(e.parentNode,function(t){t.getAttribute("data-key")===o&&(i=t)}),i)try{var a=i.offsetTop-e.offsetTop;n.setAttribute("height",Math.abs(a)+6),t.style.top=-8+(a>0?0:a)+"px";var s=a>0?"M30,0 Q-10,"+Math.round(a/2)+" 26,"+(a-4):"M30,"+-a+" Q-10,"+Math.round(-a/2)+" 26,4";r.setAttribute("d",s),n.style.display=""}catch(t){return}})})}}})},function(t,e,n){var r=n(22);"string"==typeof r&&(r=[[t.i,r,""]]);var i={hmr:!0,transform:void 0,insertInto:void 0};n(6)(r,i);r.locals&&(t.exports=r.locals)},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";var r=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("section",{attrs:{id:"app"}},[t.hasBothSides?n("section",{staticClass:"-header"},[n("div",{staticClass:"-toolbox"},[t.hasBothSides?n("button",{staticClass:"btn",attrs:{title:"Hide/Show unchanged properties"},on:{click:t.onToggleUnchanged}},[t._v("Toggle Unchanged")]):t._e(),t._v(" "),t.hasBothSides?n("button",{staticClass:"btn",attrs:{title:"Copy delta as json object"},on:{click:t.onCopyDelta}},[t._v("Copy")]):t._e()]),t._v(" "),n("div",{staticClass:"-last-updated"},[n("span",[t._v("Last updated")]),t._v(" "),n("span",{staticClass:"-value",domProps:{textContent:t._s(t.lastUpdated)}})])]):t._e(),t._v(" "),n("a",{staticClass:"-icon",attrs:{href:t.git.self,target:"_blank",title:t.git.self}},[n("img",{attrs:{src:"/src/img/panel-icon64.png",alt:"JSDiff"}})]),t._v(" "),t.hasBothSides&&t.exactMatch?n("section",{staticClass:"-match"},[n("code",{ref:"delta",staticClass:"-center"},[t._v("match")])]):t.hasBothSides&&!t.exactMatch?n("section",[n("code",{ref:"delta",staticClass:"-delta",domProps:{innerHTML:t._s(t.deltaHtml)}})]):t._e(),t._v(" "),t.hasBothSides?t._e():n("section",{staticClass:"-empty"},[n("div",{staticClass:"-center"},[n("code",[t._v("console.diff({a:1,b:1,c:3}, {a:1,b:2,d:3});")]),t._v(" "),n("div",{staticClass:"-links"},[n("a",{attrs:{href:t.git.diffApi,target:"_blank"}},[t._v("benjamine/jsondiffpatch")]),t._v(" "),n("a",{attrs:{href:t.git.self,target:"_blank"}},[t._v("zendive/jsdiff")])])])])])},i=[];n.d(e,"a",function(){return r}),n.d(e,"b",function(){return i})},function(t,e,n){"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var n=function(t,e){var n=t[1]||"",r=t[3];if(!r)return n;if(e&&"function"==typeof btoa){var i=(a=r,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(a))))+" */"),o=r.sources.map(function(t){return"/*# sourceURL="+r.sourceRoot+t+" */"});return[n].concat(o).concat([i]).join("\n")}var a;return[n].join("\n")}(e,t);return e[2]?"@media "+e[2]+"{"+n+"}":n}).join("")},e.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var r={},i=0;i=0&&f.splice(e,1)}function m(t){var e=document.createElement("style");if(void 0===t.attrs.type&&(t.attrs.type="text/css"),void 0===t.attrs.nonce){var r=function(){0;return n.nc}();r&&(t.attrs.nonce=r)}return g(e,t.attrs),p(t,e),e}function g(t,e){Object.keys(e).forEach(function(n){t.setAttribute(n,e[n])})}function y(t,e){var n,r,i,o;if(e.transform&&t.css){if(!(o="function"==typeof e.transform?e.transform(t.css):e.transform.default(t.css)))return function(){};t.css=o}if(e.singleton){var a=u++;n=l||(l=m(e)),r=w.bind(null,n,a,!1),i=w.bind(null,n,a,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=function(t){var e=document.createElement("link");return void 0===t.attrs.type&&(t.attrs.type="text/css"),t.attrs.rel="stylesheet",g(e,t.attrs),p(t,e),e}(e),r=function(t,e,n){var r=n.css,i=n.sourceMap,o=void 0===e.convertToAbsoluteUrls&&i;(e.convertToAbsoluteUrls||o)&&(r=c(r));i&&(r+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(i))))+" */");var a=new Blob([r],{type:"text/css"}),s=t.href;t.href=URL.createObjectURL(a),s&&URL.revokeObjectURL(s)}.bind(null,n,e),i=function(){v(n),n.href&&URL.revokeObjectURL(n.href)}):(n=m(e),r=function(t,e){var n=e.css,r=e.media;r&&t.setAttribute("media",r);if(t.styleSheet)t.styleSheet.cssText=n;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(n))}}.bind(null,n),i=function(){v(n)});return r(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;r(t=e)}else i()}}t.exports=function(t,e){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(e=e||{}).attrs="object"==typeof e.attrs?e.attrs:{},e.singleton||"boolean"==typeof e.singleton||(e.singleton=a()),e.insertInto||(e.insertInto="head"),e.insertAt||(e.insertAt="bottom");var n=h(t,e);return d(n,e),function(t){for(var r=[],i=0;ie[i-1][o]?t(e,n,r,i,o-1,a):t(e,n,r,i-1,o,a)}(o,t,e,t.length,e.length,i);return"string"==typeof t&&"string"==typeof e&&(a.sequence=a.sequence.join("")),a}},T="function"==typeof Array.isArray?Array.isArray:function(t){return t instanceof Array},A="function"==typeof Array.prototype.indexOf?function(t,e){return t.indexOf(e)}:function(t,e){for(var n=t.length,r=0;r0&&f>0&&!e.objectHash&&"boolean"!=typeof e.matchByPosition&&(e.matchByPosition=!function(t,e,n,r){for(var i=0;i0)for(var k=0;k=0;e--){n=o[e];var l=r["_"+n],u=i.splice(n,1)[0];3===l[2]&&a.push({index:l[1],value:u})}var f=(a=a.sort(Y.numericallyBy("index"))).length;for(e=0;e0)for(e=0;er?r++:a>=r&&se.length?t:e,a=t.length>e.length?e:t,s=o.indexOf(a);if(-1!=s)return i=[[1,o.substring(0,s)],[0,a],[1,o.substring(s+a.length)]],t.length>e.length&&(i[0][0]=i[2][0]=-1),i;if(1==a.length)return[[-1,t],[1,e]];var l=this.diff_halfMatch_(t,e);if(l){var u=l[0],f=l[1],c=l[2],d=l[3],h=l[4],p=this.diff_main(u,c,n,r),v=this.diff_main(f,d,n,r);return p.concat([[0,h]],v)}return n&&t.length>100&&e.length>100?this.diff_lineMode_(t,e,r):this.diff_bisect_(t,e,r)},e.prototype.diff_lineMode_=function(t,e,n){var r=this.diff_linesToChars_(t,e);t=r.chars1,e=r.chars2;var i=r.lineArray,o=this.diff_main(t,e,!1,n);this.diff_charsToLines_(o,i),this.diff_cleanupSemantic(o),o.push([0,""]);for(var a=0,s=0,l=0,u="",f="";a=1&&l>=1){o.splice(a-s-l,s+l),a=a-s-l;for(var r=this.diff_main(u,f,!1,n),c=r.length-1;c>=0;c--)o.splice(a,0,r[c]);a+=r.length}l=0,s=0,u="",f=""}a++}return o.pop(),o},e.prototype.diff_bisect_=function(t,e,n){for(var r=t.length,i=e.length,o=Math.ceil((r+i)/2),a=o,s=2*o,l=new Array(s),u=new Array(s),f=0;fn);g++){for(var y=-g+h;y<=g-p;y+=2){for(var _=a+y,b=(M=y==-g||y!=g&&l[_-1]r)p+=2;else if(b>i)h+=2;else if(d){var w=a+c-y;if(w>=0&&w=x)return this.diff_bisectSplit_(t,e,M,b,n)}}}for(var k=-g+v;k<=g-m;k+=2){for(var w=a+k,S=(x=k==-g||k!=g&&u[w-1]r)m+=2;else if(S>i)v+=2;else if(!d){var _=a+c-k;if(_>=0&&_=(x=r-x))return this.diff_bisectSplit_(t,e,M,b,n)}}}}return[[-1,t],[1,e]]},e.prototype.diff_bisectSplit_=function(t,e,n,r,i){var o=t.substring(0,n),a=e.substring(0,r),s=t.substring(n),l=e.substring(r),u=this.diff_main(o,a,!1,i),f=this.diff_main(s,l,!1,i);return u.concat(f)},e.prototype.diff_linesToChars_=function(t,e){var n=[],r={};function i(t){for(var e="",i=0,o=-1,a=n.length;or?t=t.substring(n-r):ne.length?t:e,r=t.length>e.length?e:t;if(n.length<4||2*r.length=t.length?[r,o,a,s,f]:null}var a,s,l,u,f,c=o(n,r,Math.ceil(n.length/4)),d=o(n,r,Math.ceil(n.length/2));if(!c&&!d)return null;a=d?c&&c[4].length>d[4].length?c:d:c,t.length>e.length?(s=a[0],l=a[1],u=a[2],f=a[3]):(u=a[0],f=a[1],s=a[2],l=a[3]);var h=a[4];return[s,l,u,f,h]},e.prototype.diff_cleanupSemantic=function(t){for(var e=!1,n=[],r=0,i=null,o=0,a=0,s=0,l=0,u=0;o0?n[r-1]:-1,a=0,s=0,l=0,u=0,i=null,e=!0)),o++;for(e&&this.diff_cleanupMerge(t),this.diff_cleanupSemanticLossless(t),o=1;o=h?(d>=f.length/2||d>=c.length/2)&&(t.splice(o,0,[0,c.substring(0,d)]),t[o-1][1]=f.substring(0,f.length-d),t[o+1][1]=c.substring(d),o++):(h>=f.length/2||h>=c.length/2)&&(t.splice(o,0,[0,f.substring(0,h)]),t[o-1][0]=1,t[o-1][1]=c.substring(0,c.length-h),t[o+1][0]=-1,t[o+1][1]=f.substring(h),o++),o++}o++}},e.prototype.diff_cleanupSemanticLossless=function(t){function n(t,n){if(!t||!n)return 6;var r=t.charAt(t.length-1),i=n.charAt(0),o=r.match(e.nonAlphaNumericRegex_),a=i.match(e.nonAlphaNumericRegex_),s=o&&r.match(e.whitespaceRegex_),l=a&&i.match(e.whitespaceRegex_),u=s&&r.match(e.linebreakRegex_),f=l&&i.match(e.linebreakRegex_),c=u&&t.match(e.blanklineEndRegex_),d=f&&n.match(e.blanklineStartRegex_);return c||d?5:u||f?4:o&&!s&&l?3:s||l?2:o||a?1:0}for(var r=1;r=d&&(d=h,u=i,f=o,c=a)}t[r-1][1]!=u&&(u?t[r-1][1]=u:(t.splice(r-1,1),r--),t[r][1]=f,c?t[r+1][1]=c:(t.splice(r+1,1),r--))}r++}},e.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/,e.whitespaceRegex_=/\s/,e.linebreakRegex_=/[\r\n]/,e.blanklineEndRegex_=/\n\r?\n$/,e.blanklineStartRegex_=/^\r?\n\r?\n/,e.prototype.diff_cleanupEfficiency=function(t){for(var e=!1,n=[],r=0,i=null,o=0,a=!1,s=!1,l=!1,u=!1;o0?n[r-1]:-1,l=u=!1),e=!0)),o++;e&&this.diff_cleanupMerge(t)},e.prototype.diff_cleanupMerge=function(t){t.push([0,""]);for(var e,n=0,r=0,i=0,o="",a="";n1?(0!==r&&0!==i&&(0!==(e=this.diff_commonPrefix(a,o))&&(n-r-i>0&&0==t[n-r-i-1][0]?t[n-r-i-1][1]+=a.substring(0,e):(t.splice(0,0,[0,a.substring(0,e)]),n++),a=a.substring(e),o=o.substring(e)),0!==(e=this.diff_commonSuffix(a,o))&&(t[n][1]=a.substring(a.length-e)+t[n][1],a=a.substring(0,a.length-e),o=o.substring(0,o.length-e))),0===r?t.splice(n-i,r+i,[1,a]):0===i?t.splice(n-r,r+i,[-1,o]):t.splice(n-r-i,r+i,[-1,o],[1,a]),n=n-r-i+(r?1:0)+(i?1:0)+1):0!==n&&0==t[n-1][0]?(t[n-1][1]+=t[n][1],t.splice(n,1)):n++,i=0,r=0,o="",a=""}""===t[t.length-1][1]&&t.pop();var s=!1;for(n=1;ne));n++)o=r,a=i;return t.length!=n&&-1===t[n][0]?a:a+(e-o)},e.prototype.diff_prettyHtml=function(t){for(var e=[],n=/&/g,r=//g,o=/\n/g,a=0;a");switch(s){case 1:e[a]=''+u+"";break;case-1:e[a]=''+u+"";break;case 0:e[a]=""+u+""}}return e.join("")},e.prototype.diff_text1=function(t){for(var e=[],n=0;nthis.Match_MaxBits)throw new Error("Pattern too long for this browser.");var r=this.match_alphabet_(e),i=this;function o(t,r){var o=t/e.length,a=Math.abs(n-r);return i.Match_Distance?o+a/i.Match_Distance:a?1:o}var a=this.Match_Threshold,s=t.indexOf(e,n);-1!=s&&(a=Math.min(o(0,s),a),-1!=(s=t.lastIndexOf(e,n+e.length))&&(a=Math.min(o(0,s),a)));var l,u,f=1<=p;g--){var y=r[t.charAt(g-1)];if(m[g]=0===h?(m[g+1]<<1|1)&y:(m[g+1]<<1|1)&y|(c[g+1]|c[g])<<1|1|c[g+1],m[g]&f){var _=o(h,g-1);if(_<=a){if(a=_,!((s=g-1)>n))break;p=Math.max(1,2*n-s)}}}if(o(h+1,n)>a)break;c=m}return s},e.prototype.match_alphabet_=function(t){for(var e={},n=0;n2&&(this.diff_cleanupSemantic(o),this.diff_cleanupEfficiency(o));else if(t&&"object"==typeof t&&void 0===n&&void 0===r)o=t,i=this.diff_text1(o);else if("string"==typeof t&&n&&"object"==typeof n&&void 0===r)i=t,o=n;else{if("string"!=typeof t||"string"!=typeof n||!r||"object"!=typeof r)throw new Error("Unknown call format to patch_make.");i=t,o=r}if(0===o.length)return[];for(var a=[],s=new e.patch_obj,l=0,u=0,f=0,c=i,d=i,h=0;h=2*this.Patch_Margin&&l&&(this.patch_addContext_(s,c),a.push(s),s=new e.patch_obj,l=0,c=d,u=f)}1!==p&&(u+=v.length),-1!==p&&(f+=v.length)}return l&&(this.patch_addContext_(s,c),a.push(s)),a},e.prototype.patch_deepCopy=function(t){for(var n=[],r=0;rthis.Match_MaxBits?-1!=(a=this.match_main(e,u.substring(0,this.Match_MaxBits),l))&&(-1==(f=this.match_main(e,u.substring(u.length-this.Match_MaxBits),l+u.length-this.Match_MaxBits))||a>=f)&&(a=-1):a=this.match_main(e,u,l),-1==a)i[o]=!1,r-=t[o].length2-t[o].length1;else if(i[o]=!0,r=a-l,s=-1==f?e.substring(a,a+u.length):e.substring(a,f+this.Match_MaxBits),u==s)e=e.substring(0,a)+this.diff_text2(t[o].diffs)+e.substring(a+u.length);else{var c=this.diff_main(u,s,!1);if(u.length>this.Match_MaxBits&&this.diff_levenshtein(c)/u.length>this.Patch_DeleteThreshold)i[o]=!1;else{this.diff_cleanupSemanticLossless(c);for(var d,h=0,p=0;po[0][1].length){var a=e-o[0][1].length;o[0][1]=n.substring(o[0][1].length)+o[0][1],i.start1-=a,i.start2-=a,i.length1+=a,i.length2+=a}if(i=t[t.length-1],0==(o=i.diffs).length||0!=o[o.length-1][0])o.push([0,n]),i.length1+=e,i.length2+=e;else if(e>o[o.length-1][1].length){var a=e-o[o.length-1][1].length;o[o.length-1][1]+=n.substring(0,a),i.length1+=a,i.length2+=a}return n},e.prototype.patch_splitMax=function(t){for(var n=this.Match_MaxBits,r=0;r2*n?(l.length1+=c.length,o+=c.length,u=!1,l.diffs.push([f,c]),i.diffs.shift()):(c=c.substring(0,n-l.length1-this.Patch_Margin),l.length1+=c.length,o+=c.length,0===f?(l.length2+=c.length,a+=c.length):u=!1,l.diffs.push([f,c]),c==i.diffs[0][1]?i.diffs.shift():i.diffs[0][1]=i.diffs[0][1].substring(c.length))}s=(s=this.diff_text2(l.diffs)).substring(s.length-this.Patch_Margin);var d=this.diff_text1(i.diffs).substring(0,this.Patch_Margin);""!==d&&(l.length1+=d.length,l.length2+=d.length,0!==l.diffs.length&&0===l.diffs[l.diffs.length-1][0]?l.diffs[l.diffs.length-1][1]+=d:l.diffs.push([0,d])),u||t.splice(++r,0,l)}}},e.prototype.patch_toText=function(t){for(var e=[],n=0;n'+e+"")}},{key:"formatValue",value:function(t,e){t.out("
"+rt(JSON.stringify(e,null,2))+"
")}},{key:"formatTextDiffString",value:function(t,e){var n=this.parseTextDiff(e);t.out('
    ');for(var r=0,i=n.length;r
    '+o.location.line+''+o.location.chr+'
    ');for(var a=o.pieces,s=0,l=a.length;s'+rt(decodeURI(u.text))+"")}t.out("
    ")}t.out("
")}},{key:"rootBegin",value:function(t,e,n){var r="jsondiffpatch-"+e+(n?" jsondiffpatch-child-node-type-"+n:"");t.out('
')}},{key:"rootEnd",value:function(t){t.out("
"+(t.hasArrows?'