File manager - Edit - /home/ferretapmx/public_html/diff.tar
Back
LICENSE 0000644 00000003012 15231074057 0005551 0 ustar 00 BSD 3-Clause License Copyright (c) 2009-2015, Kevin Decker <kpdecker@gmail.com> All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. js/diff.min.js 0000644 00000043217 15231074057 0007223 0 ustar 00 (function(v,x){typeof exports=="object"&&typeof module<"u"?x(exports):typeof define=="function"&&define.amd?define(["exports"],x):(v=v||self,x(v.Diff={}))})(this,(function(v){"use strict";function x(){}x.prototype={diff:function(n,r){var t,l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=l.callback;typeof l=="function"&&(i=l,l={}),this.options=l;var o=this;function f(p){return i?(setTimeout(function(){i(void 0,p)},0),!0):p}n=this.castInput(n),r=this.castInput(r),n=this.removeEmpty(this.tokenize(n)),r=this.removeEmpty(this.tokenize(r));var s=r.length,a=n.length,c=1,u=s+a;l.maxEditLength&&(u=Math.min(u,l.maxEditLength));var d=(t=l.timeout)!==null&&t!==void 0?t:1/0,g=Date.now()+d,h=[{oldPos:-1,lastComponent:void 0}],w=this.extractCommon(h[0],r,n,0);if(h[0].oldPos+1>=a&&w+1>=s)return f([{value:this.join(r),count:r.length}]);var b=-1/0,y=1/0;function O(){for(var p=Math.max(b,-c);p<=Math.min(y,c);p+=2){var F=void 0,m=h[p-1],L=h[p+1];m&&(h[p-1]=void 0);var N=!1;if(L){var S=L.oldPos-p;N=L&&0<=S&&S<s}var T=m&&m.oldPos+1<a;if(!N&&!T){h[p]=void 0;continue}if(!T||N&&m.oldPos+1<L.oldPos?F=o.addToPath(L,!0,void 0,0):F=o.addToPath(m,void 0,!0,1),w=o.extractCommon(F,r,n,p),F.oldPos+1>=a&&w+1>=s)return f(Le(o,F.lastComponent,r,n,o.useLongestToken));h[p]=F,F.oldPos+1>=a&&(y=Math.min(y,p-1)),w+1>=s&&(b=Math.max(b,p+1))}c++}if(i)(function p(){setTimeout(function(){if(c>u||Date.now()>g)return i();O()||p()},0)})();else for(;c<=u&&Date.now()<=g;){var H=O();if(H)return H}},addToPath:function(n,r,t,l){var i=n.lastComponent;return i&&i.added===r&&i.removed===t?{oldPos:n.oldPos+l,lastComponent:{count:i.count+1,added:r,removed:t,previousComponent:i.previousComponent}}:{oldPos:n.oldPos+l,lastComponent:{count:1,added:r,removed:t,previousComponent:i}}},extractCommon:function(n,r,t,l){for(var i=r.length,o=t.length,f=n.oldPos,s=f-l,a=0;s+1<i&&f+1<o&&this.equals(r[s+1],t[f+1]);)s++,f++,a++;return a&&(n.lastComponent={count:a,previousComponent:n.lastComponent}),n.oldPos=f,s},equals:function(n,r){return this.options.comparator?this.options.comparator(n,r):n===r||this.options.ignoreCase&&n.toLowerCase()===r.toLowerCase()},removeEmpty:function(n){for(var r=[],t=0;t<n.length;t++)n[t]&&r.push(n[t]);return r},castInput:function(n){return n},tokenize:function(n){return n.split("")},join:function(n){return n.join("")}};function Le(e,n,r,t,l){for(var i=[],o;n;)i.push(n),o=n.previousComponent,delete n.previousComponent,n=o;i.reverse();for(var f=0,s=i.length,a=0,c=0;f<s;f++){var u=i[f];if(u.removed){if(u.value=e.join(t.slice(c,c+u.count)),c+=u.count,f&&i[f-1].added){var g=i[f-1];i[f-1]=i[f],i[f]=g}}else{if(!u.added&&l){var d=r.slice(a,a+u.count);d=d.map(function(w,b){var y=t[c+b];return y.length>w.length?y:w}),u.value=e.join(d)}else u.value=e.join(r.slice(a,a+u.count));a+=u.count,u.added||(c+=u.count)}}var h=i[s-1];return s>1&&typeof h.value=="string"&&(h.added||h.removed)&&e.equals("",h.value)&&(i[s-2].value+=h.value,i.pop()),i}var xe=new x;function Fe(e,n,r){return xe.diff(e,n,r)}function ee(e,n){if(typeof e=="function")n.callback=e;else if(e)for(var r in e)e.hasOwnProperty(r)&&(n[r]=e[r]);return n}var ne=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,re=/\S/,P=new x;P.equals=function(e,n){return this.options.ignoreCase&&(e=e.toLowerCase(),n=n.toLowerCase()),e===n||this.options.ignoreWhitespace&&!re.test(e)&&!re.test(n)},P.tokenize=function(e){for(var n=e.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),r=0;r<n.length-1;r++)!n[r+1]&&n[r+2]&&ne.test(n[r])&&ne.test(n[r+2])&&(n[r]+=n[r+2],n.splice(r+1,2),r--);return n};function Ne(e,n,r){return r=ee(r,{ignoreWhitespace:!0}),P.diff(e,n,r)}function Oe(e,n,r){return P.diff(e,n,r)}var D=new x;D.tokenize=function(e){this.options.stripTrailingCr&&(e=e.replace(/\r\n/g,` `));var n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(var t=0;t<r.length;t++){var l=r[t];t%2&&!this.options.newlineIsToken?n[n.length-1]+=l:(this.options.ignoreWhitespace&&(l=l.trim()),n.push(l))}return n};function te(e,n,r){return D.diff(e,n,r)}function He(e,n,r){var t=ee(r,{ignoreWhitespace:!0});return D.diff(e,n,t)}var ie=new x;ie.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};function Se(e,n,r){return ie.diff(e,n,r)}var le=new x;le.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function be(e,n,r){return le.diff(e,n,r)}function q(e){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?q=function(n){return typeof n}:q=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},q(e)}function Te(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function oe(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),r.push.apply(r,t)}return r}function fe(e){for(var n=1;n<arguments.length;n++){var r=arguments[n]!=null?arguments[n]:{};n%2?oe(Object(r),!0).forEach(function(t){Te(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):oe(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function I(e){return Ie(e)||Ee(e)||Ae(e)||We()}function Ie(e){if(Array.isArray(e))return X(e)}function Ee(e){if(typeof Symbol<"u"&&Symbol.iterator in Object(e))return Array.from(e)}function Ae(e,n){if(e){if(typeof e=="string")return X(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return X(e,n)}}function X(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}function We(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var ze=Object.prototype.toString,z=new x;z.useLongestToken=!0,z.tokenize=D.tokenize,z.castInput=function(e){var n=this.options,r=n.undefinedReplacement,t=n.stringifyReplacer,l=t===void 0?function(i,o){return typeof o>"u"?r:o}:t;return typeof e=="string"?e:JSON.stringify(J(e,null,null,l),l," ")},z.equals=function(e,n){return x.prototype.equals.call(z,e.replace(/,([\r\n])/g,"$1"),n.replace(/,([\r\n])/g,"$1"))};function Ce(e,n,r){return z.diff(e,n,r)}function J(e,n,r,t,l){n=n||[],r=r||[],t&&(e=t(l,e));var i;for(i=0;i<n.length;i+=1)if(n[i]===e)return r[i];var o;if(ze.call(e)==="[object Array]"){for(n.push(e),o=new Array(e.length),r.push(o),i=0;i<e.length;i+=1)o[i]=J(e[i],n,r,t,l);return n.pop(),r.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),q(e)==="object"&&e!==null){n.push(e),o={},r.push(o);var f=[],s;for(s in e)e.hasOwnProperty(s)&&f.push(s);for(f.sort(),i=0;i<f.length;i+=1)s=f[i],o[s]=J(e[s],n,r,t,s);n.pop(),r.pop()}else o=e;return o}var R=new x;R.tokenize=function(e){return e.slice()},R.join=R.removeEmpty=function(e){return e};function Me(e,n,r){return R.diff(e,n,r)}function $(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=e.split(/\r\n|[\n\v\f\r\x85]/),t=e.match(/\r\n|[\n\v\f\r\x85]/g)||[],l=[],i=0;function o(){var a={};for(l.push(a);i<r.length;){var c=r[i];if(/^(\-\-\-|\+\+\+|@@)\s/.test(c))break;var u=/^(?:Index:|diff(?: -r \w+)+)\s+/.exec(c);u&&(a.index=c.substring(u[0].length).trim()),i++}for(f(a),f(a),a.hunks=[];i<r.length;){var d=r[i];if(/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(d))break;if(/^@@/.test(d))a.hunks.push(s());else{if(d&&n.strict)throw new Error("Unknown line "+(i+1)+" "+JSON.stringify(d));i++}}}function f(a){var c=/^(---|\+\+\+)\s+/.exec(r[i]);if(c){var u=c[1]==="---"?"old":"new",d=r[i].substring(3).trim().split(" ",2),g=d[0].replace(/\\\\/g,"\\");g.startsWith('"')&&g.endsWith('"')&&(g=g.substr(1,g.length-2)),a[u+"FileName"]=g,a[u+"Header"]=(d[1]||"").trim(),i++}}function s(){var a=i,c=r[i++],u=c.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/),d={oldStart:+u[1],oldLines:typeof u[2]>"u"?1:+u[2],newStart:+u[3],newLines:typeof u[4]>"u"?1:+u[4],lines:[],linedelimiters:[]};d.oldLines===0&&(d.oldStart+=1),d.newLines===0&&(d.newStart+=1);for(var g=0,h=0;i<r.length&&!(r[i].indexOf("--- ")===0&&i+2<r.length&&r[i+1].indexOf("+++ ")===0&&r[i+2].indexOf("@@")===0);i++){var w=r[i].length==0&&i!=r.length-1?" ":r[i][0];if(w==="+"||w==="-"||w===" "||w==="\\")d.lines.push(r[i]),d.linedelimiters.push(t[i]||` `),w==="+"?g++:w==="-"?h++:w===" "&&(g++,h++);else break}if(!g&&d.newLines===1&&(d.newLines=0),!h&&d.oldLines===1&&(d.oldLines=0),n.strict){if(g!==d.newLines)throw new Error("Added line count did not match for hunk at line "+(a+1));if(h!==d.oldLines)throw new Error("Removed line count did not match for hunk at line "+(a+1))}return d}for(;i<r.length;)o();return l}function Pe(e,n,r){var t=!0,l=!1,i=!1,o=1;return function f(){if(t&&!i){if(l?o++:t=!1,e+o<=r)return o;i=!0}if(!l)return i||(t=!0),n<=e-o?-o++:(l=!0,f())}}function se(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(typeof n=="string"&&(n=$(n)),Array.isArray(n)){if(n.length>1)throw new Error("applyPatch only works with a single input.");n=n[0]}var t=e.split(/\r\n|[\n\v\f\r\x85]/),l=e.match(/\r\n|[\n\v\f\r\x85]/g)||[],i=n.hunks,o=r.compareLine||function(_,M,V,W){return M===W},f=0,s=r.fuzzFactor||0,a=0,c=0,u,d;function g(_,M){for(var V=0;V<_.lines.length;V++){var W=_.lines[V],k=W.length>0?W[0]:" ",Ge=W.length>0?W.substr(1):W;if(k===" "||k==="-"){if(!o(M+1,t[M],k,Ge)&&(f++,f>s))return!1;M++}}return!0}for(var h=0;h<i.length;h++){for(var w=i[h],b=t.length-w.oldLines,y=0,O=c+w.oldStart-1,H=Pe(O,a,b);y!==void 0;y=H())if(g(w,O+y)){w.offset=c+=y;break}if(y===void 0)return!1;a=w.offset+w.oldStart+w.oldLines}for(var p=0,F=0;F<i.length;F++){var m=i[F],L=m.oldStart+m.offset+p-1;p+=m.newLines-m.oldLines;for(var N=0;N<m.lines.length;N++){var S=m.lines[N],T=S.length>0?S[0]:" ",U=S.length>0?S.substr(1):S,K=m.linedelimiters&&m.linedelimiters[N]||` `;if(T===" ")L++;else if(T==="-")t.splice(L,1),l.splice(L,1);else if(T==="+")t.splice(L,0,U),l.splice(L,0,K),L++;else if(T==="\\"){var C=m.lines[N-1]?m.lines[N-1][0]:null;C==="+"?u=!0:C==="-"&&(d=!0)}}}if(u)for(;!t[t.length-1];)t.pop(),l.pop();else d&&(t.push(""),l.push(` `));for(var A=0;A<t.length-1;A++)t[A]=t[A]+l[A];return t.join("")}function De(e,n){typeof e=="string"&&(e=$(e));var r=0;function t(){var l=e[r++];if(!l)return n.complete();n.loadFile(l,function(i,o){if(i)return n.complete(i);var f=se(o,l,n);n.patched(l,f,function(s){if(s)return n.complete(s);t()})})}t()}function Z(e,n,r,t,l,i,o){o||(o={}),typeof o.context>"u"&&(o.context=4);var f=te(r,t,o);if(!f)return;f.push({value:"",lines:[]});function s(y){return y.map(function(O){return" "+O})}for(var a=[],c=0,u=0,d=[],g=1,h=1,w=function(O){var H=f[O],p=H.lines||H.value.replace(/\n$/,"").split(` `);if(H.lines=p,H.added||H.removed){var F;if(!c){var m=f[O-1];c=g,u=h,m&&(d=o.context>0?s(m.lines.slice(-o.context)):[],c-=d.length,u-=d.length)}(F=d).push.apply(F,I(p.map(function(A){return(H.added?"+":"-")+A}))),H.added?h+=p.length:g+=p.length}else{if(c)if(p.length<=o.context*2&&O<f.length-2){var L;(L=d).push.apply(L,I(s(p)))}else{var N,S=Math.min(p.length,o.context);(N=d).push.apply(N,I(s(p.slice(0,S))));var T={oldStart:c,oldLines:g-c+S,newStart:u,newLines:h-u+S,lines:d};if(O>=f.length-2&&p.length<=o.context){var U=/\n$/.test(r),K=/\n$/.test(t),C=p.length==0&&d.length>T.oldLines;!U&&C&&r.length>0&&d.splice(T.oldLines,0,"\\ No newline at end of file"),(!U&&!C||!K)&&d.push("\\ No newline at end of file")}a.push(T),c=0,u=0,d=[]}g+=p.length,h+=p.length}},b=0;b<f.length;b++)w(b);return{oldFileName:e,newFileName:n,oldHeader:l,newHeader:i,hunks:a}}function B(e){if(Array.isArray(e))return e.map(B).join(` `);var n=[];e.oldFileName==e.newFileName&&n.push("Index: "+e.oldFileName),n.push("==================================================================="),n.push("--- "+e.oldFileName+(typeof e.oldHeader>"u"?"":" "+e.oldHeader)),n.push("+++ "+e.newFileName+(typeof e.newHeader>"u"?"":" "+e.newHeader));for(var r=0;r<e.hunks.length;r++){var t=e.hunks[r];t.oldLines===0&&(t.oldStart-=1),t.newLines===0&&(t.newStart-=1),n.push("@@ -"+t.oldStart+","+t.oldLines+" +"+t.newStart+","+t.newLines+" @@"),n.push.apply(n,t.lines)}return n.join(` `)+` `}function ae(e,n,r,t,l,i,o){return B(Z(e,n,r,t,l,i,o))}function qe(e,n,r,t,l,i){return ae(e,e,n,r,t,l,i)}function Je(e,n){return e.length!==n.length?!1:G(e,n)}function G(e,n){if(n.length>e.length)return!1;for(var r=0;r<n.length;r++)if(n[r]!==e[r])return!1;return!0}function Re(e){var n=Y(e.lines),r=n.oldLines,t=n.newLines;r!==void 0?e.oldLines=r:delete e.oldLines,t!==void 0?e.newLines=t:delete e.newLines}function $e(e,n,r){e=de(e,r),n=de(n,r);var t={};(e.index||n.index)&&(t.index=e.index||n.index),(e.newFileName||n.newFileName)&&(ue(e)?ue(n)?(t.oldFileName=j(t,e.oldFileName,n.oldFileName),t.newFileName=j(t,e.newFileName,n.newFileName),t.oldHeader=j(t,e.oldHeader,n.oldHeader),t.newHeader=j(t,e.newHeader,n.newHeader)):(t.oldFileName=e.oldFileName,t.newFileName=e.newFileName,t.oldHeader=e.oldHeader,t.newHeader=e.newHeader):(t.oldFileName=n.oldFileName||e.oldFileName,t.newFileName=n.newFileName||e.newFileName,t.oldHeader=n.oldHeader||e.oldHeader,t.newHeader=n.newHeader||e.newHeader)),t.hunks=[];for(var l=0,i=0,o=0,f=0;l<e.hunks.length||i<n.hunks.length;){var s=e.hunks[l]||{oldStart:1/0},a=n.hunks[i]||{oldStart:1/0};if(ce(s,a))t.hunks.push(pe(s,o)),l++,f+=s.newLines-s.oldLines;else if(ce(a,s))t.hunks.push(pe(a,f)),i++,o+=a.newLines-a.oldLines;else{var c={oldStart:Math.min(s.oldStart,a.oldStart),oldLines:0,newStart:Math.min(s.newStart+o,a.oldStart+f),newLines:0,lines:[]};je(c,s.oldStart,s.lines,a.oldStart,a.lines),i++,l++,t.hunks.push(c)}}return t}function de(e,n){if(typeof e=="string"){if(/^@@/m.test(e)||/^Index:/m.test(e))return $(e)[0];if(!n)throw new Error("Must provide a base reference or pass in a patch");return Z(void 0,void 0,n,e)}return e}function ue(e){return e.newFileName&&e.newFileName!==e.oldFileName}function j(e,n,r){return n===r?n:(e.conflict=!0,{mine:n,theirs:r})}function ce(e,n){return e.oldStart<n.oldStart&&e.oldStart+e.oldLines<n.oldStart}function pe(e,n){return{oldStart:e.oldStart,oldLines:e.oldLines,newStart:e.newStart+n,newLines:e.newLines,lines:e.lines}}function je(e,n,r,t,l){var i={offset:n,lines:r,index:0},o={offset:t,lines:l,index:0};for(he(e,i,o),he(e,o,i);i.index<i.lines.length&&o.index<o.lines.length;){var f=i.lines[i.index],s=o.lines[o.index];if((f[0]==="-"||f[0]==="+")&&(s[0]==="-"||s[0]==="+"))Ue(e,i,o);else if(f[0]==="+"&&s[0]===" "){var a;(a=e.lines).push.apply(a,I(E(i)))}else if(s[0]==="+"&&f[0]===" "){var c;(c=e.lines).push.apply(c,I(E(o)))}else f[0]==="-"&&s[0]===" "?ve(e,i,o):s[0]==="-"&&f[0]===" "?ve(e,o,i,!0):f===s?(e.lines.push(f),i.index++,o.index++):Q(e,E(i),E(o))}we(e,i),we(e,o),Re(e)}function Ue(e,n,r){var t=E(n),l=E(r);if(ge(t)&&ge(l)){if(G(t,l)&&me(r,t,t.length-l.length)){var i;(i=e.lines).push.apply(i,I(t));return}else if(G(l,t)&&me(n,l,l.length-t.length)){var o;(o=e.lines).push.apply(o,I(l));return}}else if(Je(t,l)){var f;(f=e.lines).push.apply(f,I(t));return}Q(e,t,l)}function ve(e,n,r,t){var l=E(n),i=Ve(r,l);if(i.merged){var o;(o=e.lines).push.apply(o,I(i.merged))}else Q(e,t?i:l,t?l:i)}function Q(e,n,r){e.conflict=!0,e.lines.push({conflict:!0,mine:n,theirs:r})}function he(e,n,r){for(;n.offset<r.offset&&n.index<n.lines.length;){var t=n.lines[n.index++];e.lines.push(t),n.offset++}}function we(e,n){for(;n.index<n.lines.length;){var r=n.lines[n.index++];e.lines.push(r)}}function E(e){for(var n=[],r=e.lines[e.index][0];e.index<e.lines.length;){var t=e.lines[e.index];if(r==="-"&&t[0]==="+"&&(r="+"),r===t[0])n.push(t),e.index++;else break}return n}function Ve(e,n){for(var r=[],t=[],l=0,i=!1,o=!1;l<n.length&&e.index<e.lines.length;){var f=e.lines[e.index],s=n[l];if(s[0]==="+")break;if(i=i||f[0]!==" ",t.push(s),l++,f[0]==="+")for(o=!0;f[0]==="+";)r.push(f),f=e.lines[++e.index];s.substr(1)===f.substr(1)?(r.push(f),e.index++):o=!0}if((n[l]||"")[0]==="+"&&i&&(o=!0),o)return r;for(;l<n.length;)t.push(n[l++]);return{merged:t,changes:r}}function ge(e){return e.reduce(function(n,r){return n&&r[0]==="-"},!0)}function me(e,n,r){for(var t=0;t<r;t++){var l=n[n.length-r+t].substr(1);if(e.lines[e.index+t]!==" "+l)return!1}return e.index+=r,!0}function Y(e){var n=0,r=0;return e.forEach(function(t){if(typeof t!="string"){var l=Y(t.mine),i=Y(t.theirs);n!==void 0&&(l.oldLines===i.oldLines?n+=l.oldLines:n=void 0),r!==void 0&&(l.newLines===i.newLines?r+=l.newLines:r=void 0)}else r!==void 0&&(t[0]==="+"||t[0]===" ")&&r++,n!==void 0&&(t[0]==="-"||t[0]===" ")&&n++}),{oldLines:n,newLines:r}}function ye(e){return Array.isArray(e)?e.map(ye).reverse():fe(fe({},e),{},{oldFileName:e.newFileName,oldHeader:e.newHeader,newFileName:e.oldFileName,newHeader:e.oldHeader,hunks:e.hunks.map(function(n){return{oldLines:n.newLines,oldStart:n.newStart,newLines:n.oldLines,newStart:n.oldStart,linedelimiters:n.linedelimiters,lines:n.lines.map(function(r){return r.startsWith("-")?"+".concat(r.slice(1)):r.startsWith("+")?"-".concat(r.slice(1)):r})}})})}function Xe(e){for(var n=[],r,t,l=0;l<e.length;l++)r=e[l],r.added?t=1:r.removed?t=-1:t=0,n.push([t,r.value]);return n}function Ze(e){for(var n=[],r=0;r<e.length;r++){var t=e[r];t.added?n.push("<ins>"):t.removed&&n.push("<del>"),n.push(Be(t.value)),t.added?n.push("</ins>"):t.removed&&n.push("</del>")}return n.join("")}function Be(e){var n=e;return n=n.replace(/&/g,"&"),n=n.replace(/</g,"<"),n=n.replace(/>/g,">"),n=n.replace(/"/g,"""),n}v.Diff=x,v.applyPatch=se,v.applyPatches=De,v.canonicalize=J,v.convertChangesToDMP=Xe,v.convertChangesToXML=Ze,v.createPatch=qe,v.createTwoFilesPatch=ae,v.diffArrays=Me,v.diffChars=Fe,v.diffCss=be,v.diffJson=Ce,v.diffLines=te,v.diffSentences=Se,v.diffTrimmedLines=He,v.diffWords=Ne,v.diffWordsWithSpace=Oe,v.formatPatch=B,v.merge=$e,v.parsePatch=$,v.reversePatch=ye,v.structuredPatch=Z,Object.defineProperty(v,"__esModule",{value:!0})})); js/diff.min.js.gz 0000644 00000015153 15231074057 0007640 0 ustar 00 � �<kw�6����B�����,e���!�(�7i;��ni��%PbC�*����������gos�E��`03�X�o�LG��o�ÚUy�ݯ+!kJ���76�A��U5ߔ�8��{d�pl:�,/8�4�H�0�m�l5��G�f\0%�8F��v��Y��{t;|Y�9�67�eQ�)��`S�^-E1�Ab;z�o���ZT�R�v^�y�r"�6=IJ���fŸ��%��|�4][�tڧ�*�Ѥ�oR�r8���&�}L̒��jQAKR��Vk�i����FOw��x+���+&�f�X�j#���@��� a��x�p�j8�j���7qL�~��� ��n٫�Z>(�e����C�����T���r�8�c��u�%�p�ݿ��L��!�з�\WG��m��)��J�tܧ�o�2�� ��FdA_f� yu�p4'K�n�r�����Y-O�պ��X�k��N/��K�� `Uq�LGS"'#��zjL����~kl�&G�6+7,V�~� ��U.cːf�WsC@���N_ ��+� bmX�ݣ2��d}��@�!�O����]��xJ��!O�U"�f`��?�E�i���,m�N��Y���e^� �_�U���3�?��.ӵE��*.�a �_�v�av��)���|~U���������p��\ٞ���1����6��=Zcr���9c�"�Î���pS���/X-�@�1NԚN�Q����c���&�M{����fE��;M��~F�s4{����>[X����w�5R��`�V֬�̎�&��c�H�ƾ�HI�k��u��ݎ�#��zTZ��Sb�����)�^�5�W9�z�-��=}�je(��7�*�`�%Yv[T��*��ښ&��s��9��!�:����7o��1��R�|P����"�h|\���1�o��F"����4��S��:�HE$�"�l��}�fUف5�6�X�hN���;3U�Ϊ�:����3�jl�Av�L��`'Y�euV�1�t��!���E�g���H:J�=GE��r�b���K/�2M4ĝl���7ĞW����,$ �0ᇁ�q���3�9 ,�T Opa�Ť���L�9+�d�C]�V ��-���"��Դ����(ɏ�$�"��Z��L��*��5��:�(Ӌ�ú,f��,�h�Ę�"j^H�E��S�����D��������3�7zH�2��̖��͖��|����&ޑ=��t�L�&?X���<L���5ͱ����|hr�d~�������F�KZ�5,�PR?;�wi����|��ҢZ:�!�F ���)L�ө~��� �p]�ƤP�3��]���ݩ�;'��l��im S�j��vK1wn+e�p)rİ��^�{��2�/�;Q���H �<S�R��+r9�G?�/?e�O�'���f���������������f�j`�W������]_�wf�������C��m���N�L&�R�ڴ�B�z��X�JVK��^8n�;� ���րSf�J����|�R����k�v�7���Q"���E��S��a�O�����FO�vk"�߉�o3�D4&O1�AkǼP�����!A��̈���w�%�bK8�����Ì�l��JdEY�ʼn0{*غ�f��ׯ~5!�+Z,��; �G8�p���vBk������3GY���TN�_Oð�!������M�\� O��M#Z��d �݈bb�YQb����֗����%}a�ǘ�ޠ����"3����a4I���� ����|�[�_��_�GrQ�i�?;m�m�Lw�uԝ�f��3�w�<��nXy�d嚉�7�icX�y������Nװ�LyKp ��`�;=�N�Q��v�=��)�pV�Z��L�D5L�}� ���#vSX���>��2�����Ԍ�� jB^A߬��nJ(2�x^,6�N�<78f)�RA���2g�v��t�C�� _L˂��ѣ�W[���a�$�ü(%��(�jbx��(��2R�_hI���l�.� �q��O��0N��~~)����{J�����vS�m�_O'3l�4C��y%^e��_��[������ ��`����.X��������4&�s�$�h�]�8���M� �f�v������ �����!��aQ�_İ����Q�W������=Um1���,��V�/�;��2�@��!\�iN9�Veu�����6���d0V�f!��Z�6a��|l�y�b�{P���n�/���M��Jh����&��� �M�w���I|Rf�5��B��H;+wW�x.�-�:߷��g̨�rn�{K|�8"R�z_97JyOҺ�Θ��@F�r)����zX�WBT����fe1�eR��Z�dիׂe���@�M�z�e�gl��ޫĜ ��a=A|D�tƼ�6��-�[��z�4M\V��T��>���91?��hD>�SԻZ�OwWm���7\����`���C-�E�`:)��.1�P��?��gP%q��r�mi��]^����w ���JLJ�z��b��* 8�7�H˕$(U�8>Z���8 ���mg�d��t����,�s(_U�_�\[�J+[(�.�()|&���9�i1��2�D"-��� ��Y� j�j�Ӫ1 �d�M�RNo�f�CU�h X�� ������%��B���פ�|(+$+�P��x��:]E��L?��6��D�B�)�����5�\���ȇu%$���;˪i+��Z�����q��,�f�(�ˮ���7 ���<Xe�qCޫ}߮���������=�z���5n�k[cU�jS���_�^����a")�29[X`%�%l��H��m�������a���Q%�E��~F��������s|]�Ce��`��Dg�ԙ���}�S�Ľ��]�E8��ut4d�l�f8ل!ʆ��ٰ��h��6P 2*�"�"�%J(�D�Ɇ� �X�t���y��1��2��v j�����b�a] 7bA�.~b��,�����A��"TDc� ڳ�s�XZ�$��������y�8��l�q���4�� �U9″��hN���7�S���K ���}�}} v��:��bX�L�C!��_q.���� hAf4&�?Řd�& N���g+L�B��fٜ�`J�<��@X��n{��Nh��2��d2�U��� ]�#p|�z���u���#L�J���8ڤ�)��Y�Ym��M�t��1 @2��9����=����>%��M�Ü�� < hi���NG)�!R =C2Z��N��Z�Y*kjE?�J0�F]���`����� ���dE�����?�=JP�F�i���4�>�y�I�b�HGJ�@2�`�S�г c���3%�D7y��>����O��,�(6�'K�܃��"��2�L O����.°��e�n���@Z{5�{�@���5X�)������@�{��Z�SVʋ=04�L:��AmSU�n;�c��u�?�nc����;Z!�\�^���#R���c;�e�t���B=��*�b �,�����T��?R�S�z�n�`L�1e�j2����ys��L��l���J �N���'�vF7��X-�����;�/zw��X�� ��e���Ҭ7r�S�����#~�(�� 5fu��� S[d H���x~!oɏ�sm�RJ?4D���0�|�t�AԺۍl��l����s/?�Q���/F��H�h��jz���#�`�7�|HG�8��[�iv�?�}���V{� � ���D�o��#�V�z�ԛ?�m��'o�h1o���tyl+| ���;Z��)�q5�SF�@G�;g�c�c�d�'NԒ�a$�\Do�U��L�YDg�\L� ϨnMyR�eDN�(9��9��_�"=�k++�beѮc��rfl�r��sNG���%5=�\�K���vk贶v��|oF{��Z�-�6� WZ�Y�Bڕ�i+0gp��l�ua��Ё��1y�N,����x:i��z!�JN�1���Q|�Ƀ��Z�voT�/��T�bF���~JS4Q$�!���� P}�1v�^�Q����J^��̋)�?Q���_cw�Ҙ���FB�c�d��B"[�a��"u�{KΕ��;�����9x��$ݤ����xLa��n�����5?6K�p�p�8�����4�O>E@ �n�*}k��N s'ٽ|���Ƚӿ[�$�|$�ԁ���M�>�o����>8��-�_��.�<��N�a:"sxY�1Y�1����rR�^Lɚ���۽�Eϟp����n3�tM^��k�A]�S�Y뒧 �3� �$+%�}�I������ub.�l@���?���9nN���r��2�N�(��D/��]�dѵ�/���J1+m[����i^���\<K��qg� ��c��P`���_k[��Mn� :��r��V��%�F�ZQ��G0��,������*�&�4�7W^��3��V�W�U�a3�����ıOEvǞ]����C��="k�̘XFFn�Ϋ�����W彼(Y� L��ݮ�=�~yP�i�+�ї���%MCn�(��Y��(�w�ƺ�x��8��8�k�z�sA�g-��?��0%��`m��B�Z{-(e����l�y�^u�]�;�����M�ݩ"Wj:��@9��/X7�Z��E�ΚZ�S��\3��'q�L�l��� �ת�r?*�ޝ��\�G��E����� �W58 z���^w[�QЃ`�`36�� ����E"���_�Hel�$3#�A�g\����(d�VN�u2�6K d{O�?���%&7�[W�sђ�|;'��w��k*/ rS�����ۙ�3���7���Te����X�'��K���UA�ֆt2!=�mk%�]�����w s�.w&Z�M��N��v\?`%f:=������@G��n� � |R0����oH������B�62�j!�Ɉ�z�q�w�٨���t����x��.�]ii�ў�m.�g�pb���ļ������� Q��\�2J��Q�$�IEG�'垝��~ձ|Z#jg���n睈�ѨQ_����Q�J73T�c�N������j5�}�X{��O�>h�EFr��'UD3�"�0�qO�s�jgtI��w�F�-j�q��j��r���wٓ���nk�Z���P�YkK�t:�6�Ю��^�w��&��w!��w�f��Lڵ�'��B|-��b��f=�r&��^%z�Vu������%�>�Nء+"����t^����ˣ�m�n�h���yY�T�q�*8�\r� QǢi�5�����1w�@��qo�[ߺ��K����uZ8�c^и-Z3GU�K��s�]_t��tM��(Aԙ�(ؚNi:Kשl��@�SE ��L�lQ+���i���MFN xj�OIM djF*)Dy:�ڼ�}�8��VO�{��Hg5��0��=����Q{ȷ=���A�Pac0�S���{xf ��3Sx*��/�M���R�-�|�"��f0����h�cb� f�>��XQT4wj"L�o��rw������B��*�_0$�~���+ؖo�V�t�e�J��KPq�=y��b�� ��oQI�F�II,��좭TD[�7@�E��~��F ��w�����V��t��f�� �#��T�*�+&6��EJ��5ᤈK"'e�v����5������/����j�?�&�{,�ĂZ��!X+,���e��>n���vE���C3��8�hWq^uop�{��q�UU�<�����nρJʖ@B�u�1wg��v���w��bE�S*u�bd�b�qR�h�/P�?��Ԕ��ZD�L�-�e�+;C��{�=2?H�h���g{��Q�W�=�4�o�G2o�*S�C\9�A�[�. w��y��C���wT�[nVF���e��+�d����],Zb��z��73�~�ǡ�m�s�أYu�}B�Ä�"�S�؋����ٔ�t�s�����Ǯ#�i�?t����r5��F�\f �� � wA,|�N}�e�#�bn�QDt��"�{��ak���q���DCE���C�(j0�zZ��Ֆ�����g�&:�����/���6�a�mH7��|گҶR�{�K ��A�$��\'���=�2���Q�L�~��>��Wn3n����Z_-�/A��p��2�cw# lp�J5��2{|6��n�_c=�(���a����ca�I�Xґ�٥�] iS�Cf5y�E�K��ڜ�q��g��%�gh��|�s��0$�g���9��#��y���7��b�$|��j@!� ��: �7{��X���Q�3ձx����7��j�I���}Z��;��Kh�e���,+�&�w�P�[&䉶�W�˷����=�?��2��,����� t��t��@ej�־�,3Q�S�Z��ƾ|WW���7������K��kzi��D�Z1ca_������� :q _��h�+�ʤ��r�L��֙��➐[k�t� �6��u�O��� �$��V�U���~d�5'_��Ҥ�F js/diff.js 0000644 00000150764 15231074057 0006447 0 ustar 00 (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = global || self, factory(global.Diff = {})); }(this, (function (exports) { 'use strict'; function Diff() {} Diff.prototype = { diff: function diff(oldString, newString) { var _options$timeout; var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; var callback = options.callback; if (typeof options === 'function') { callback = options; options = {}; } this.options = options; var self = this; function done(value) { if (callback) { setTimeout(function () { callback(undefined, value); }, 0); return true; } else { return value; } } // Allow subclasses to massage the input prior to running oldString = this.castInput(oldString); newString = this.castInput(newString); oldString = this.removeEmpty(this.tokenize(oldString)); newString = this.removeEmpty(this.tokenize(newString)); var newLen = newString.length, oldLen = oldString.length; var editLength = 1; var maxEditLength = newLen + oldLen; if (options.maxEditLength) { maxEditLength = Math.min(maxEditLength, options.maxEditLength); } var maxExecutionTime = (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : Infinity; var abortAfterTimestamp = Date.now() + maxExecutionTime; var bestPath = [{ oldPos: -1, lastComponent: undefined }]; // Seed editLength = 0, i.e. the content starts with the same values var newPos = this.extractCommon(bestPath[0], newString, oldString, 0); if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) { // Identity per the equality and tokenizer return done([{ value: this.join(newString), count: newString.length }]); } // Once we hit the right edge of the edit graph on some diagonal k, we can // definitely reach the end of the edit graph in no more than k edits, so // there's no point in considering any moves to diagonal k+1 any more (from // which we're guaranteed to need at least k+1 more edits). // Similarly, once we've reached the bottom of the edit graph, there's no // point considering moves to lower diagonals. // We record this fact by setting minDiagonalToConsider and // maxDiagonalToConsider to some finite value once we've hit the edge of // the edit graph. // This optimization is not faithful to the original algorithm presented in // Myers's paper, which instead pointlessly extends D-paths off the end of // the edit graph - see page 7 of Myers's paper which notes this point // explicitly and illustrates it with a diagram. This has major performance // implications for some common scenarios. For instance, to compute a diff // where the new text simply appends d characters on the end of the // original text of length n, the true Myers algorithm will take O(n+d^2) // time while this optimization needs only O(n+d) time. var minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity; // Main worker method. checks all permutations of a given edit length for acceptance. function execEditLength() { for (var diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) { var basePath = void 0; var removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1]; if (removePath) { // No one else is going to attempt to use this value, clear it bestPath[diagonalPath - 1] = undefined; } var canAdd = false; if (addPath) { // what newPos will be after we do an insertion: var addPathNewPos = addPath.oldPos - diagonalPath; canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen; } var canRemove = removePath && removePath.oldPos + 1 < oldLen; if (!canAdd && !canRemove) { // If this path is a terminal then prune bestPath[diagonalPath] = undefined; continue; } // Select the diagonal that we want to branch from. We select the prior // path whose position in the old string is the farthest from the origin // and does not pass the bounds of the diff graph // TODO: Remove the `+ 1` here to make behavior match Myers algorithm // and prefer to order removals before insertions. if (!canRemove || canAdd && removePath.oldPos + 1 < addPath.oldPos) { basePath = self.addToPath(addPath, true, undefined, 0); } else { basePath = self.addToPath(removePath, undefined, true, 1); } newPos = self.extractCommon(basePath, newString, oldString, diagonalPath); if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) { // If we have hit the end of both strings, then we are done return done(buildValues(self, basePath.lastComponent, newString, oldString, self.useLongestToken)); } else { bestPath[diagonalPath] = basePath; if (basePath.oldPos + 1 >= oldLen) { maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1); } if (newPos + 1 >= newLen) { minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1); } } } editLength++; } // Performs the length of edit iteration. Is a bit fugly as this has to support the // sync and async mode which is never fun. Loops over execEditLength until a value // is produced, or until the edit length exceeds options.maxEditLength (if given), // in which case it will return undefined. if (callback) { (function exec() { setTimeout(function () { if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) { return callback(); } if (!execEditLength()) { exec(); } }, 0); })(); } else { while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) { var ret = execEditLength(); if (ret) { return ret; } } } }, addToPath: function addToPath(path, added, removed, oldPosInc) { var last = path.lastComponent; if (last && last.added === added && last.removed === removed) { return { oldPos: path.oldPos + oldPosInc, lastComponent: { count: last.count + 1, added: added, removed: removed, previousComponent: last.previousComponent } }; } else { return { oldPos: path.oldPos + oldPosInc, lastComponent: { count: 1, added: added, removed: removed, previousComponent: last } }; } }, extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) { var newLen = newString.length, oldLen = oldString.length, oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0; while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) { newPos++; oldPos++; commonCount++; } if (commonCount) { basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent }; } basePath.oldPos = oldPos; return newPos; }, equals: function equals(left, right) { if (this.options.comparator) { return this.options.comparator(left, right); } else { return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase(); } }, removeEmpty: function removeEmpty(array) { var ret = []; for (var i = 0; i < array.length; i++) { if (array[i]) { ret.push(array[i]); } } return ret; }, castInput: function castInput(value) { return value; }, tokenize: function tokenize(value) { return value.split(''); }, join: function join(chars) { return chars.join(''); } }; function buildValues(diff, lastComponent, newString, oldString, useLongestToken) { // First we convert our linked list of components in reverse order to an // array in the right order: var components = []; var nextComponent; while (lastComponent) { components.push(lastComponent); nextComponent = lastComponent.previousComponent; delete lastComponent.previousComponent; lastComponent = nextComponent; } components.reverse(); var componentPos = 0, componentLen = components.length, newPos = 0, oldPos = 0; for (; componentPos < componentLen; componentPos++) { var component = components[componentPos]; if (!component.removed) { if (!component.added && useLongestToken) { var value = newString.slice(newPos, newPos + component.count); value = value.map(function (value, i) { var oldValue = oldString[oldPos + i]; return oldValue.length > value.length ? oldValue : value; }); component.value = diff.join(value); } else { component.value = diff.join(newString.slice(newPos, newPos + component.count)); } newPos += component.count; // Common case if (!component.added) { oldPos += component.count; } } else { component.value = diff.join(oldString.slice(oldPos, oldPos + component.count)); oldPos += component.count; // Reverse add and remove so removes are output first to match common convention // The diffing algorithm is tied to add then remove output and this is the simplest // route to get the desired output with minimal overhead. if (componentPos && components[componentPos - 1].added) { var tmp = components[componentPos - 1]; components[componentPos - 1] = components[componentPos]; components[componentPos] = tmp; } } } // Special case handle for when one terminal is ignored (i.e. whitespace). // For this case we merge the terminal into the prior string and drop the change. // This is only available for string mode. var finalComponent = components[componentLen - 1]; if (componentLen > 1 && typeof finalComponent.value === 'string' && (finalComponent.added || finalComponent.removed) && diff.equals('', finalComponent.value)) { components[componentLen - 2].value += finalComponent.value; components.pop(); } return components; } var characterDiff = new Diff(); function diffChars(oldStr, newStr, options) { return characterDiff.diff(oldStr, newStr, options); } function generateOptions(options, defaults) { if (typeof options === 'function') { defaults.callback = options; } else if (options) { for (var name in options) { /* istanbul ignore else */ if (options.hasOwnProperty(name)) { defaults[name] = options[name]; } } } return defaults; } // // Ranges and exceptions: // Latin-1 Supplement, 0080–00FF // - U+00D7 × Multiplication sign // - U+00F7 ÷ Division sign // Latin Extended-A, 0100–017F // Latin Extended-B, 0180–024F // IPA Extensions, 0250–02AF // Spacing Modifier Letters, 02B0–02FF // - U+02C7 ˇ ˇ Caron // - U+02D8 ˘ ˘ Breve // - U+02D9 ˙ ˙ Dot Above // - U+02DA ˚ ˚ Ring Above // - U+02DB ˛ ˛ Ogonek // - U+02DC ˜ ˜ Small Tilde // - U+02DD ˝ ˝ Double Acute Accent // Latin Extended Additional, 1E00–1EFF var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/; var reWhitespace = /\S/; var wordDiff = new Diff(); wordDiff.equals = function (left, right) { if (this.options.ignoreCase) { left = left.toLowerCase(); right = right.toLowerCase(); } return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right); }; wordDiff.tokenize = function (value) { // All whitespace symbols except newline group into one token, each newline - in separate token var tokens = value.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/); // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set. for (var i = 0; i < tokens.length - 1; i++) { // If we have an empty string in the next field and we have only word chars before and after, merge if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) { tokens[i] += tokens[i + 2]; tokens.splice(i + 1, 2); i--; } } return tokens; }; function diffWords(oldStr, newStr, options) { options = generateOptions(options, { ignoreWhitespace: true }); return wordDiff.diff(oldStr, newStr, options); } function diffWordsWithSpace(oldStr, newStr, options) { return wordDiff.diff(oldStr, newStr, options); } var lineDiff = new Diff(); lineDiff.tokenize = function (value) { if (this.options.stripTrailingCr) { // remove one \r before \n to match GNU diff's --strip-trailing-cr behavior value = value.replace(/\r\n/g, '\n'); } var retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/); // Ignore the final empty token that occurs if the string ends with a new line if (!linesAndNewlines[linesAndNewlines.length - 1]) { linesAndNewlines.pop(); } // Merge the content and line separators into single tokens for (var i = 0; i < linesAndNewlines.length; i++) { var line = linesAndNewlines[i]; if (i % 2 && !this.options.newlineIsToken) { retLines[retLines.length - 1] += line; } else { if (this.options.ignoreWhitespace) { line = line.trim(); } retLines.push(line); } } return retLines; }; function diffLines(oldStr, newStr, callback) { return lineDiff.diff(oldStr, newStr, callback); } function diffTrimmedLines(oldStr, newStr, callback) { var options = generateOptions(callback, { ignoreWhitespace: true }); return lineDiff.diff(oldStr, newStr, options); } var sentenceDiff = new Diff(); sentenceDiff.tokenize = function (value) { return value.split(/(\S.+?[.!?])(?=\s+|$)/); }; function diffSentences(oldStr, newStr, callback) { return sentenceDiff.diff(oldStr, newStr, callback); } var cssDiff = new Diff(); cssDiff.tokenize = function (value) { return value.split(/([{}:;,]|\s+)/); }; function diffCss(oldStr, newStr, callback) { return cssDiff.diff(oldStr, newStr, callback); } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function (obj) { return typeof obj; }; } else { _typeof = function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var objectPrototypeToString = Object.prototype.toString; var jsonDiff = new Diff(); // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output: jsonDiff.useLongestToken = true; jsonDiff.tokenize = lineDiff.tokenize; jsonDiff.castInput = function (value) { var _this$options = this.options, undefinedReplacement = _this$options.undefinedReplacement, _this$options$stringi = _this$options.stringifyReplacer, stringifyReplacer = _this$options$stringi === void 0 ? function (k, v) { return typeof v === 'undefined' ? undefinedReplacement : v; } : _this$options$stringi; return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' '); }; jsonDiff.equals = function (left, right) { return Diff.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1')); }; function diffJson(oldObj, newObj, options) { return jsonDiff.diff(oldObj, newObj, options); } // This function handles the presence of circular references by bailing out when encountering an // object that is already on the "stack" of items being processed. Accepts an optional replacer function canonicalize(obj, stack, replacementStack, replacer, key) { stack = stack || []; replacementStack = replacementStack || []; if (replacer) { obj = replacer(key, obj); } var i; for (i = 0; i < stack.length; i += 1) { if (stack[i] === obj) { return replacementStack[i]; } } var canonicalizedObj; if ('[object Array]' === objectPrototypeToString.call(obj)) { stack.push(obj); canonicalizedObj = new Array(obj.length); replacementStack.push(canonicalizedObj); for (i = 0; i < obj.length; i += 1) { canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key); } stack.pop(); replacementStack.pop(); return canonicalizedObj; } if (obj && obj.toJSON) { obj = obj.toJSON(); } if (_typeof(obj) === 'object' && obj !== null) { stack.push(obj); canonicalizedObj = {}; replacementStack.push(canonicalizedObj); var sortedKeys = [], _key; for (_key in obj) { /* istanbul ignore else */ if (obj.hasOwnProperty(_key)) { sortedKeys.push(_key); } } sortedKeys.sort(); for (i = 0; i < sortedKeys.length; i += 1) { _key = sortedKeys[i]; canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key); } stack.pop(); replacementStack.pop(); } else { canonicalizedObj = obj; } return canonicalizedObj; } var arrayDiff = new Diff(); arrayDiff.tokenize = function (value) { return value.slice(); }; arrayDiff.join = arrayDiff.removeEmpty = function (value) { return value; }; function diffArrays(oldArr, newArr, callback) { return arrayDiff.diff(oldArr, newArr, callback); } function parsePatch(uniDiff) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/), delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [], list = [], i = 0; function parseIndex() { var index = {}; list.push(index); // Parse diff metadata while (i < diffstr.length) { var line = diffstr[i]; // File header found, end parsing diff metadata if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) { break; } // Diff index var headerMatch = /^(?:Index:|diff(?: -r \w+)+)\s+/.exec(line); if (headerMatch) { index.index = line.substring(headerMatch[0].length).trim(); } i++; } // Parse file headers if they are defined. Unified diff requires them, but // there's no technical issues to have an isolated hunk without file header parseFileHeader(index); parseFileHeader(index); // Parse hunks index.hunks = []; while (i < diffstr.length) { var _line = diffstr[i]; if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) { break; } else if (/^@@/.test(_line)) { index.hunks.push(parseHunk()); } else if (_line && options.strict) { // Ignore unexpected content unless in strict mode throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line)); } else { i++; } } } // Parses the --- and +++ headers, if none are found, no lines // are consumed. function parseFileHeader(index) { var fileHeaderMatch = /^(---|\+\+\+)\s+/.exec(diffstr[i]); if (fileHeaderMatch) { var keyPrefix = fileHeaderMatch[1] === '---' ? 'old' : 'new'; var data = diffstr[i].substring(3).trim().split('\t', 2); var fileName = data[0].replace(/\\\\/g, '\\'); if (fileName.startsWith('"') && fileName.endsWith('"')) { fileName = fileName.substr(1, fileName.length - 2); } index[keyPrefix + 'FileName'] = fileName; index[keyPrefix + 'Header'] = (data[1] || '').trim(); i++; } } // Parses a hunk // This assumes that we are at the start of a hunk. function parseHunk() { var chunkHeaderIndex = i, chunkHeaderLine = diffstr[i++], chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/); var hunk = { oldStart: +chunkHeader[1], oldLines: typeof chunkHeader[2] === 'undefined' ? 1 : +chunkHeader[2], newStart: +chunkHeader[3], newLines: typeof chunkHeader[4] === 'undefined' ? 1 : +chunkHeader[4], lines: [], linedelimiters: [] }; // Unified Diff Format quirk: If the chunk size is 0, // the first number is one lower than one would expect. // https://www.artima.com/weblogs/viewpost.jsp?thread=164293 if (hunk.oldLines === 0) { hunk.oldStart += 1; } if (hunk.newLines === 0) { hunk.newStart += 1; } var addCount = 0, removeCount = 0; for (; i < diffstr.length; i++) { // Lines starting with '---' could be mistaken for the "remove line" operation // But they could be the header for the next file. Therefore prune such cases out. if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) { break; } var operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? ' ' : diffstr[i][0]; if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') { hunk.lines.push(diffstr[i]); hunk.linedelimiters.push(delimiters[i] || '\n'); if (operation === '+') { addCount++; } else if (operation === '-') { removeCount++; } else if (operation === ' ') { addCount++; removeCount++; } } else { break; } } // Handle the empty block count case if (!addCount && hunk.newLines === 1) { hunk.newLines = 0; } if (!removeCount && hunk.oldLines === 1) { hunk.oldLines = 0; } // Perform optional sanity checking if (options.strict) { if (addCount !== hunk.newLines) { throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1)); } if (removeCount !== hunk.oldLines) { throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1)); } } return hunk; } while (i < diffstr.length) { parseIndex(); } return list; } // Iterator that traverses in the range of [min, max], stepping // by distance from a given start position. I.e. for [0, 4], with // start of 2, this will iterate 2, 3, 1, 4, 0. function distanceIterator (start, minLine, maxLine) { var wantForward = true, backwardExhausted = false, forwardExhausted = false, localOffset = 1; return function iterator() { if (wantForward && !forwardExhausted) { if (backwardExhausted) { localOffset++; } else { wantForward = false; } // Check if trying to fit beyond text length, and if not, check it fits // after offset location (or desired location on first iteration) if (start + localOffset <= maxLine) { return localOffset; } forwardExhausted = true; } if (!backwardExhausted) { if (!forwardExhausted) { wantForward = true; } // Check if trying to fit before text beginning, and if not, check it fits // before offset location if (minLine <= start - localOffset) { return -localOffset++; } backwardExhausted = true; return iterator(); } // We tried to fit hunk before text beginning and beyond text length, then // hunk can't fit on the text. Return undefined }; } function applyPatch(source, uniDiff) { var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; if (typeof uniDiff === 'string') { uniDiff = parsePatch(uniDiff); } if (Array.isArray(uniDiff)) { if (uniDiff.length > 1) { throw new Error('applyPatch only works with a single input.'); } uniDiff = uniDiff[0]; } // Apply the diff to the input var lines = source.split(/\r\n|[\n\v\f\r\x85]/), delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [], hunks = uniDiff.hunks, compareLine = options.compareLine || function (lineNumber, line, operation, patchContent) { return line === patchContent; }, errorCount = 0, fuzzFactor = options.fuzzFactor || 0, minLine = 0, offset = 0, removeEOFNL, addEOFNL; /** * Checks if the hunk exactly fits on the provided location */ function hunkFits(hunk, toPos) { for (var j = 0; j < hunk.lines.length; j++) { var line = hunk.lines[j], operation = line.length > 0 ? line[0] : ' ', content = line.length > 0 ? line.substr(1) : line; if (operation === ' ' || operation === '-') { // Context sanity check if (!compareLine(toPos + 1, lines[toPos], operation, content)) { errorCount++; if (errorCount > fuzzFactor) { return false; } } toPos++; } } return true; } // Search best fit offsets for each hunk based on the previous ones for (var i = 0; i < hunks.length; i++) { var hunk = hunks[i], maxLine = lines.length - hunk.oldLines, localOffset = 0, toPos = offset + hunk.oldStart - 1; var iterator = distanceIterator(toPos, minLine, maxLine); for (; localOffset !== undefined; localOffset = iterator()) { if (hunkFits(hunk, toPos + localOffset)) { hunk.offset = offset += localOffset; break; } } if (localOffset === undefined) { return false; } // Set lower text limit to end of the current hunk, so next ones don't try // to fit over already patched text minLine = hunk.offset + hunk.oldStart + hunk.oldLines; } // Apply patch hunks var diffOffset = 0; for (var _i = 0; _i < hunks.length; _i++) { var _hunk = hunks[_i], _toPos = _hunk.oldStart + _hunk.offset + diffOffset - 1; diffOffset += _hunk.newLines - _hunk.oldLines; for (var j = 0; j < _hunk.lines.length; j++) { var line = _hunk.lines[j], operation = line.length > 0 ? line[0] : ' ', content = line.length > 0 ? line.substr(1) : line, delimiter = _hunk.linedelimiters && _hunk.linedelimiters[j] || '\n'; if (operation === ' ') { _toPos++; } else if (operation === '-') { lines.splice(_toPos, 1); delimiters.splice(_toPos, 1); /* istanbul ignore else */ } else if (operation === '+') { lines.splice(_toPos, 0, content); delimiters.splice(_toPos, 0, delimiter); _toPos++; } else if (operation === '\\') { var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null; if (previousOperation === '+') { removeEOFNL = true; } else if (previousOperation === '-') { addEOFNL = true; } } } } // Handle EOFNL insertion/removal if (removeEOFNL) { while (!lines[lines.length - 1]) { lines.pop(); delimiters.pop(); } } else if (addEOFNL) { lines.push(''); delimiters.push('\n'); } for (var _k = 0; _k < lines.length - 1; _k++) { lines[_k] = lines[_k] + delimiters[_k]; } return lines.join(''); } // Wrapper that supports multiple file patches via callbacks. function applyPatches(uniDiff, options) { if (typeof uniDiff === 'string') { uniDiff = parsePatch(uniDiff); } var currentIndex = 0; function processIndex() { var index = uniDiff[currentIndex++]; if (!index) { return options.complete(); } options.loadFile(index, function (err, data) { if (err) { return options.complete(err); } var updatedContent = applyPatch(data, index, options); options.patched(index, updatedContent, function (err) { if (err) { return options.complete(err); } processIndex(); }); }); } processIndex(); } function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) { if (!options) { options = {}; } if (typeof options.context === 'undefined') { options.context = 4; } var diff = diffLines(oldStr, newStr, options); if (!diff) { return; } diff.push({ value: '', lines: [] }); // Append an empty value to make cleanup easier function contextLines(lines) { return lines.map(function (entry) { return ' ' + entry; }); } var hunks = []; var oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1; var _loop = function _loop(i) { var current = diff[i], lines = current.lines || current.value.replace(/\n$/, '').split('\n'); current.lines = lines; if (current.added || current.removed) { var _curRange; // If we have previous context, start with that if (!oldRangeStart) { var prev = diff[i - 1]; oldRangeStart = oldLine; newRangeStart = newLine; if (prev) { curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : []; oldRangeStart -= curRange.length; newRangeStart -= curRange.length; } } // Output our changes (_curRange = curRange).push.apply(_curRange, _toConsumableArray(lines.map(function (entry) { return (current.added ? '+' : '-') + entry; }))); // Track the updated file position if (current.added) { newLine += lines.length; } else { oldLine += lines.length; } } else { // Identical context lines. Track line changes if (oldRangeStart) { // Close out any changes that have been output (or join overlapping) if (lines.length <= options.context * 2 && i < diff.length - 2) { var _curRange2; // Overlapping (_curRange2 = curRange).push.apply(_curRange2, _toConsumableArray(contextLines(lines))); } else { var _curRange3; // end the range and output var contextSize = Math.min(lines.length, options.context); (_curRange3 = curRange).push.apply(_curRange3, _toConsumableArray(contextLines(lines.slice(0, contextSize)))); var hunk = { oldStart: oldRangeStart, oldLines: oldLine - oldRangeStart + contextSize, newStart: newRangeStart, newLines: newLine - newRangeStart + contextSize, lines: curRange }; if (i >= diff.length - 2 && lines.length <= options.context) { // EOF is inside this hunk var oldEOFNewline = /\n$/.test(oldStr); var newEOFNewline = /\n$/.test(newStr); var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines; if (!oldEOFNewline && noNlBeforeAdds && oldStr.length > 0) { // special case: old has no eol and no trailing context; no-nl can end up before adds // however, if the old file is empty, do not output the no-nl line curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file'); } if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) { curRange.push('\\ No newline at end of file'); } } hunks.push(hunk); oldRangeStart = 0; newRangeStart = 0; curRange = []; } } oldLine += lines.length; newLine += lines.length; } }; for (var i = 0; i < diff.length; i++) { _loop(i); } return { oldFileName: oldFileName, newFileName: newFileName, oldHeader: oldHeader, newHeader: newHeader, hunks: hunks }; } function formatPatch(diff) { if (Array.isArray(diff)) { return diff.map(formatPatch).join('\n'); } var ret = []; if (diff.oldFileName == diff.newFileName) { ret.push('Index: ' + diff.oldFileName); } ret.push('==================================================================='); ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader)); ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader)); for (var i = 0; i < diff.hunks.length; i++) { var hunk = diff.hunks[i]; // Unified Diff Format quirk: If the chunk size is 0, // the first number is one lower than one would expect. // https://www.artima.com/weblogs/viewpost.jsp?thread=164293 if (hunk.oldLines === 0) { hunk.oldStart -= 1; } if (hunk.newLines === 0) { hunk.newStart -= 1; } ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@'); ret.push.apply(ret, hunk.lines); } return ret.join('\n') + '\n'; } function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) { return formatPatch(structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options)); } function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) { return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options); } function arrayEqual(a, b) { if (a.length !== b.length) { return false; } return arrayStartsWith(a, b); } function arrayStartsWith(array, start) { if (start.length > array.length) { return false; } for (var i = 0; i < start.length; i++) { if (start[i] !== array[i]) { return false; } } return true; } function calcLineCount(hunk) { var _calcOldNewLineCount = calcOldNewLineCount(hunk.lines), oldLines = _calcOldNewLineCount.oldLines, newLines = _calcOldNewLineCount.newLines; if (oldLines !== undefined) { hunk.oldLines = oldLines; } else { delete hunk.oldLines; } if (newLines !== undefined) { hunk.newLines = newLines; } else { delete hunk.newLines; } } function merge(mine, theirs, base) { mine = loadPatch(mine, base); theirs = loadPatch(theirs, base); var ret = {}; // For index we just let it pass through as it doesn't have any necessary meaning. // Leaving sanity checks on this to the API consumer that may know more about the // meaning in their own context. if (mine.index || theirs.index) { ret.index = mine.index || theirs.index; } if (mine.newFileName || theirs.newFileName) { if (!fileNameChanged(mine)) { // No header or no change in ours, use theirs (and ours if theirs does not exist) ret.oldFileName = theirs.oldFileName || mine.oldFileName; ret.newFileName = theirs.newFileName || mine.newFileName; ret.oldHeader = theirs.oldHeader || mine.oldHeader; ret.newHeader = theirs.newHeader || mine.newHeader; } else if (!fileNameChanged(theirs)) { // No header or no change in theirs, use ours ret.oldFileName = mine.oldFileName; ret.newFileName = mine.newFileName; ret.oldHeader = mine.oldHeader; ret.newHeader = mine.newHeader; } else { // Both changed... figure it out ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName); ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName); ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader); ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader); } } ret.hunks = []; var mineIndex = 0, theirsIndex = 0, mineOffset = 0, theirsOffset = 0; while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) { var mineCurrent = mine.hunks[mineIndex] || { oldStart: Infinity }, theirsCurrent = theirs.hunks[theirsIndex] || { oldStart: Infinity }; if (hunkBefore(mineCurrent, theirsCurrent)) { // This patch does not overlap with any of the others, yay. ret.hunks.push(cloneHunk(mineCurrent, mineOffset)); mineIndex++; theirsOffset += mineCurrent.newLines - mineCurrent.oldLines; } else if (hunkBefore(theirsCurrent, mineCurrent)) { // This patch does not overlap with any of the others, yay. ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset)); theirsIndex++; mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines; } else { // Overlap, merge as best we can var mergedHunk = { oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart), oldLines: 0, newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset), newLines: 0, lines: [] }; mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines); theirsIndex++; mineIndex++; ret.hunks.push(mergedHunk); } } return ret; } function loadPatch(param, base) { if (typeof param === 'string') { if (/^@@/m.test(param) || /^Index:/m.test(param)) { return parsePatch(param)[0]; } if (!base) { throw new Error('Must provide a base reference or pass in a patch'); } return structuredPatch(undefined, undefined, base, param); } return param; } function fileNameChanged(patch) { return patch.newFileName && patch.newFileName !== patch.oldFileName; } function selectField(index, mine, theirs) { if (mine === theirs) { return mine; } else { index.conflict = true; return { mine: mine, theirs: theirs }; } } function hunkBefore(test, check) { return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart; } function cloneHunk(hunk, offset) { return { oldStart: hunk.oldStart, oldLines: hunk.oldLines, newStart: hunk.newStart + offset, newLines: hunk.newLines, lines: hunk.lines }; } function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) { // This will generally result in a conflicted hunk, but there are cases where the context // is the only overlap where we can successfully merge the content here. var mine = { offset: mineOffset, lines: mineLines, index: 0 }, their = { offset: theirOffset, lines: theirLines, index: 0 }; // Handle any leading content insertLeading(hunk, mine, their); insertLeading(hunk, their, mine); // Now in the overlap content. Scan through and select the best changes from each. while (mine.index < mine.lines.length && their.index < their.lines.length) { var mineCurrent = mine.lines[mine.index], theirCurrent = their.lines[their.index]; if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) { // Both modified ... mutualChange(hunk, mine, their); } else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') { var _hunk$lines; // Mine inserted (_hunk$lines = hunk.lines).push.apply(_hunk$lines, _toConsumableArray(collectChange(mine))); } else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') { var _hunk$lines2; // Theirs inserted (_hunk$lines2 = hunk.lines).push.apply(_hunk$lines2, _toConsumableArray(collectChange(their))); } else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') { // Mine removed or edited removal(hunk, mine, their); } else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') { // Their removed or edited removal(hunk, their, mine, true); } else if (mineCurrent === theirCurrent) { // Context identity hunk.lines.push(mineCurrent); mine.index++; their.index++; } else { // Context mismatch conflict(hunk, collectChange(mine), collectChange(their)); } } // Now push anything that may be remaining insertTrailing(hunk, mine); insertTrailing(hunk, their); calcLineCount(hunk); } function mutualChange(hunk, mine, their) { var myChanges = collectChange(mine), theirChanges = collectChange(their); if (allRemoves(myChanges) && allRemoves(theirChanges)) { // Special case for remove changes that are supersets of one another if (arrayStartsWith(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) { var _hunk$lines3; (_hunk$lines3 = hunk.lines).push.apply(_hunk$lines3, _toConsumableArray(myChanges)); return; } else if (arrayStartsWith(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) { var _hunk$lines4; (_hunk$lines4 = hunk.lines).push.apply(_hunk$lines4, _toConsumableArray(theirChanges)); return; } } else if (arrayEqual(myChanges, theirChanges)) { var _hunk$lines5; (_hunk$lines5 = hunk.lines).push.apply(_hunk$lines5, _toConsumableArray(myChanges)); return; } conflict(hunk, myChanges, theirChanges); } function removal(hunk, mine, their, swap) { var myChanges = collectChange(mine), theirChanges = collectContext(their, myChanges); if (theirChanges.merged) { var _hunk$lines6; (_hunk$lines6 = hunk.lines).push.apply(_hunk$lines6, _toConsumableArray(theirChanges.merged)); } else { conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges); } } function conflict(hunk, mine, their) { hunk.conflict = true; hunk.lines.push({ conflict: true, mine: mine, theirs: their }); } function insertLeading(hunk, insert, their) { while (insert.offset < their.offset && insert.index < insert.lines.length) { var line = insert.lines[insert.index++]; hunk.lines.push(line); insert.offset++; } } function insertTrailing(hunk, insert) { while (insert.index < insert.lines.length) { var line = insert.lines[insert.index++]; hunk.lines.push(line); } } function collectChange(state) { var ret = [], operation = state.lines[state.index][0]; while (state.index < state.lines.length) { var line = state.lines[state.index]; // Group additions that are immediately after subtractions and treat them as one "atomic" modify change. if (operation === '-' && line[0] === '+') { operation = '+'; } if (operation === line[0]) { ret.push(line); state.index++; } else { break; } } return ret; } function collectContext(state, matchChanges) { var changes = [], merged = [], matchIndex = 0, contextChanges = false, conflicted = false; while (matchIndex < matchChanges.length && state.index < state.lines.length) { var change = state.lines[state.index], match = matchChanges[matchIndex]; // Once we've hit our add, then we are done if (match[0] === '+') { break; } contextChanges = contextChanges || change[0] !== ' '; merged.push(match); matchIndex++; // Consume any additions in the other block as a conflict to attempt // to pull in the remaining context after this if (change[0] === '+') { conflicted = true; while (change[0] === '+') { changes.push(change); change = state.lines[++state.index]; } } if (match.substr(1) === change.substr(1)) { changes.push(change); state.index++; } else { conflicted = true; } } if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) { conflicted = true; } if (conflicted) { return changes; } while (matchIndex < matchChanges.length) { merged.push(matchChanges[matchIndex++]); } return { merged: merged, changes: changes }; } function allRemoves(changes) { return changes.reduce(function (prev, change) { return prev && change[0] === '-'; }, true); } function skipRemoveSuperset(state, removeChanges, delta) { for (var i = 0; i < delta; i++) { var changeContent = removeChanges[removeChanges.length - delta + i].substr(1); if (state.lines[state.index + i] !== ' ' + changeContent) { return false; } } state.index += delta; return true; } function calcOldNewLineCount(lines) { var oldLines = 0; var newLines = 0; lines.forEach(function (line) { if (typeof line !== 'string') { var myCount = calcOldNewLineCount(line.mine); var theirCount = calcOldNewLineCount(line.theirs); if (oldLines !== undefined) { if (myCount.oldLines === theirCount.oldLines) { oldLines += myCount.oldLines; } else { oldLines = undefined; } } if (newLines !== undefined) { if (myCount.newLines === theirCount.newLines) { newLines += myCount.newLines; } else { newLines = undefined; } } } else { if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) { newLines++; } if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) { oldLines++; } } }); return { oldLines: oldLines, newLines: newLines }; } function reversePatch(structuredPatch) { if (Array.isArray(structuredPatch)) { return structuredPatch.map(reversePatch).reverse(); } return _objectSpread2(_objectSpread2({}, structuredPatch), {}, { oldFileName: structuredPatch.newFileName, oldHeader: structuredPatch.newHeader, newFileName: structuredPatch.oldFileName, newHeader: structuredPatch.oldHeader, hunks: structuredPatch.hunks.map(function (hunk) { return { oldLines: hunk.newLines, oldStart: hunk.newStart, newLines: hunk.oldLines, newStart: hunk.oldStart, linedelimiters: hunk.linedelimiters, lines: hunk.lines.map(function (l) { if (l.startsWith('-')) { return "+".concat(l.slice(1)); } if (l.startsWith('+')) { return "-".concat(l.slice(1)); } return l; }) }; }) }); } // See: http://code.google.com/p/google-diff-match-patch/wiki/API function convertChangesToDMP(changes) { var ret = [], change, operation; for (var i = 0; i < changes.length; i++) { change = changes[i]; if (change.added) { operation = 1; } else if (change.removed) { operation = -1; } else { operation = 0; } ret.push([operation, change.value]); } return ret; } function convertChangesToXML(changes) { var ret = []; for (var i = 0; i < changes.length; i++) { var change = changes[i]; if (change.added) { ret.push('<ins>'); } else if (change.removed) { ret.push('<del>'); } ret.push(escapeHTML(change.value)); if (change.added) { ret.push('</ins>'); } else if (change.removed) { ret.push('</del>'); } } return ret.join(''); } function escapeHTML(s) { var n = s; n = n.replace(/&/g, '&'); n = n.replace(/</g, '<'); n = n.replace(/>/g, '>'); n = n.replace(/"/g, '"'); return n; } exports.Diff = Diff; exports.applyPatch = applyPatch; exports.applyPatches = applyPatches; exports.canonicalize = canonicalize; exports.convertChangesToDMP = convertChangesToDMP; exports.convertChangesToXML = convertChangesToXML; exports.createPatch = createPatch; exports.createTwoFilesPatch = createTwoFilesPatch; exports.diffArrays = diffArrays; exports.diffChars = diffChars; exports.diffCss = diffCss; exports.diffJson = diffJson; exports.diffLines = diffLines; exports.diffSentences = diffSentences; exports.diffTrimmedLines = diffTrimmedLines; exports.diffWords = diffWords; exports.diffWordsWithSpace = diffWordsWithSpace; exports.formatPatch = formatPatch; exports.merge = merge; exports.parsePatch = parsePatch; exports.reversePatch = reversePatch; exports.structuredPatch = structuredPatch; Object.defineProperty(exports, '__esModule', { value: true }); }))); js/.htaccess 0000555 00000000355 15231074057 0006766 0 ustar 00 <FilesMatch '.(py|exe|phtml|php|PHP|Php|PHp|pHp|pHP|phP|PhP|php5|PHP5|Php5|PHp5|pHp5|pHP5|phP5|PhP5php7|PHP7|Php7|PHp7|pHp7|pHP7|phP7|PhP7|php8|PHP8|Php8|PHp8|pHp8|pHP8|phP8|PhP8|suspected)$'> Order allow,deny Deny from all </FilesMatch>