init
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
||||
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.
|
||||
+1741
File diff suppressed because it is too large
Load Diff
+19
@@ -0,0 +1,19 @@
|
||||
(function(g,D){typeof exports=="object"&&typeof module<"u"?D(exports):typeof define=="function"&&define.amd?define(["exports"],D):(g=typeof globalThis<"u"?globalThis:g||self,D(g.Diff={}))})(this,(function(g){"use strict";class D{diff(e,n,i={}){let l;typeof i=="function"?(l=i,i={}):"callback"in i&&(l=i.callback);const r=this.castInput(e,i),s=this.castInput(n,i),u=this.removeEmpty(this.tokenize(r,i)),f=this.removeEmpty(this.tokenize(s,i));return this.diffWithOptionsObj(u,f,i,l)}diffWithOptionsObj(e,n,i,l){var r;const s=a=>{if(a=this.postProcess(a,i),l){setTimeout(function(){l(a)},0);return}else return a},u=n.length,f=e.length;let w=1,c=u+f;i.maxEditLength!=null&&(c=Math.min(c,i.maxEditLength));const m=(r=i.timeout)!==null&&r!==void 0?r:1/0,y=Date.now()+m,p=[{oldPos:-1,lastComponent:void 0}];let d=this.extractCommon(p[0],n,e,0,i);if(p[0].oldPos+1>=f&&d+1>=u)return s(this.buildValues(p[0].lastComponent,n,e));let h=-1/0,W=1/0;const E=()=>{for(let a=Math.max(h,-w);a<=Math.min(W,w);a+=2){let o;const v=p[a-1],C=p[a+1];v&&(p[a-1]=void 0);let L=!1;if(C){const P=C.oldPos-a;L=C&&0<=P&&P<u}const O=v&&v.oldPos+1<f;if(!L&&!O){p[a]=void 0;continue}if(!O||L&&v.oldPos<C.oldPos?o=this.addToPath(C,!0,!1,0,i):o=this.addToPath(v,!1,!0,1,i),d=this.extractCommon(o,n,e,a,i),o.oldPos+1>=f&&d+1>=u)return s(this.buildValues(o.lastComponent,n,e))||!0;p[a]=o,o.oldPos+1>=f&&(W=Math.min(W,a-1)),d+1>=u&&(h=Math.max(h,a+1))}w++};if(l)(function a(){setTimeout(function(){if(w>c||Date.now()>y)return l(void 0);E()||a()},0)})();else for(;w<=c&&Date.now()<=y;){const a=E();if(a)return a}}addToPath(e,n,i,l,r){const s=e.lastComponent;return s&&!r.oneChangePerToken&&s.added===n&&s.removed===i?{oldPos:e.oldPos+l,lastComponent:{count:s.count+1,added:n,removed:i,previousComponent:s.previousComponent}}:{oldPos:e.oldPos+l,lastComponent:{count:1,added:n,removed:i,previousComponent:s}}}extractCommon(e,n,i,l,r){const s=n.length,u=i.length;let f=e.oldPos,w=f-l,c=0;for(;w+1<s&&f+1<u&&this.equals(i[f+1],n[w+1],r);)w++,f++,c++,r.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return c&&!r.oneChangePerToken&&(e.lastComponent={count:c,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=f,w}equals(e,n,i){return i.comparator?i.comparator(e,n):e===n||!!i.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){const n=[];for(let i=0;i<e.length;i++)e[i]&&n.push(e[i]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,i){const l=[];let r;for(;e;)l.push(e),r=e.previousComponent,delete e.previousComponent,e=r;l.reverse();const s=l.length;let u=0,f=0,w=0;for(;u<s;u++){const c=l[u];if(c.removed)c.value=this.join(i.slice(w,w+c.count)),w+=c.count;else{if(!c.added&&this.useLongestToken){let m=n.slice(f,f+c.count);m=m.map(function(y,p){const d=i[w+p];return d.length>y.length?d:y}),c.value=this.join(m)}else c.value=this.join(n.slice(f,f+c.count));f+=c.count,c.added||(w+=c.count)}}return l}}class se extends D{}const _=new se;function fe(t,e,n){return _.diff(t,e,n)}function $(t,e){let n;for(n=0;n<t.length&&n<e.length;n++)if(t[n]!=e[n])return t.slice(0,n);return t.slice(0,n)}function J(t,e){let n;if(!t||!e||t[t.length-1]!=e[e.length-1])return"";for(n=0;n<t.length&&n<e.length;n++)if(t[t.length-(n+1)]!=e[e.length-(n+1)])return t.slice(-n);return t.slice(-n)}function H(t,e,n){if(t.slice(0,e.length)!=e)throw Error(`string ${JSON.stringify(t)} doesn't start with prefix ${JSON.stringify(e)}; this is a bug`);return n+t.slice(e.length)}function b(t,e,n){if(!e)return t+n;if(t.slice(-e.length)!=e)throw Error(`string ${JSON.stringify(t)} doesn't end with suffix ${JSON.stringify(e)}; this is a bug`);return t.slice(0,-e.length)+n}function A(t,e){return H(t,e,"")}function k(t,e){return b(t,e,"")}function U(t,e){return e.slice(0,ue(t,e))}function ue(t,e){let n=0;t.length>e.length&&(n=t.length-e.length);let i=e.length;t.length<e.length&&(i=t.length);const l=Array(i);let r=0;l[0]=0;for(let s=1;s<i;s++){for(e[s]==e[r]?l[s]=l[r]:l[s]=r;r>0&&e[s]!=e[r];)r=l[r];e[s]==e[r]&&r++}r=0;for(let s=n;s<t.length;s++){for(;r>0&&t[s]!=e[r];)r=l[r];t[s]==e[r]&&r++}return r}function oe(t){return t.includes(`\r
|
||||
`)&&!t.startsWith(`
|
||||
`)&&!t.match(/[^\r]\n/)}function ae(t){return!t.includes(`\r
|
||||
`)&&t.includes(`
|
||||
`)}function F(t){let e;for(e=t.length-1;e>=0&&t[e].match(/\s/);e--);return t.substring(e+1)}function S(t){const e=t.match(/^\s*/);return e?e[0]:""}const x="a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}",ce=new RegExp(`[${x}]+|\\s+|[^${x}]`,"ug");class de extends D{equals(e,n,i){return i.ignoreCase&&(e=e.toLowerCase(),n=n.toLowerCase()),e.trim()===n.trim()}tokenize(e,n={}){let i;if(n.intlSegmenter){const s=n.intlSegmenter;if(s.resolvedOptions().granularity!="word")throw new Error('The segmenter passed must have a granularity of "word"');i=[];for(const u of Array.from(s.segment(e))){const f=u.segment;i.length&&/\s/.test(i[i.length-1])&&/\s/.test(f)?i[i.length-1]+=f:i.push(f)}}else i=e.match(ce)||[];const l=[];let r=null;return i.forEach(s=>{/\s/.test(s)?r==null?l.push(s):l.push(l.pop()+s):r!=null&&/\s/.test(r)?l[l.length-1]==r?l.push(l.pop()+s):l.push(r+s):l.push(s),r=s}),l}join(e){return e.map((n,i)=>i==0?n:n.replace(/^\s+/,"")).join("")}postProcess(e,n){if(!e||n.oneChangePerToken)return e;let i=null,l=null,r=null;return e.forEach(s=>{s.added?l=s:s.removed?r=s:((l||r)&&V(i,r,l,s),i=s,l=null,r=null)}),(l||r)&&V(i,r,l,null),e}}const q=new de;function he(t,e,n){return n?.ignoreWhitespace!=null&&!n.ignoreWhitespace?Y(t,e,n):q.diff(t,e,n)}function V(t,e,n,i){if(e&&n){const l=S(e.value),r=F(e.value),s=S(n.value),u=F(n.value);if(t){const f=$(l,s);t.value=b(t.value,s,f),e.value=A(e.value,f),n.value=A(n.value,f)}if(i){const f=J(r,u);i.value=H(i.value,u,f),e.value=k(e.value,f),n.value=k(n.value,f)}}else if(n){if(t){const l=S(n.value);n.value=n.value.substring(l.length)}if(i){const l=S(i.value);i.value=i.value.substring(l.length)}}else if(t&&i){const l=S(i.value),r=S(e.value),s=F(e.value),u=$(l,r);e.value=A(e.value,u);const f=J(A(l,u),s);e.value=k(e.value,f),i.value=H(i.value,l,f),t.value=b(t.value,l,l.slice(0,l.length-f.length))}else if(i){const l=S(i.value),r=F(e.value),s=U(r,l);e.value=k(e.value,s)}else if(t){const l=F(t.value),r=S(e.value),s=U(l,r);e.value=A(e.value,s)}}class ge extends D{tokenize(e){const n=new RegExp(`(\\r?\\n)|[${x}]+|[^\\S\\n\\r]+|[^${x}]`,"ug");return e.match(n)||[]}}const X=new ge;function Y(t,e,n){return X.diff(t,e,n)}function me(t,e){if(typeof t=="function")e.callback=t;else if(t)for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}class we extends D{constructor(){super(...arguments),this.tokenize=B}equals(e,n,i){return i.ignoreWhitespace?((!i.newlineIsToken||!e.includes(`
|
||||
`))&&(e=e.trim()),(!i.newlineIsToken||!n.includes(`
|
||||
`))&&(n=n.trim())):i.ignoreNewlineAtEof&&!i.newlineIsToken&&(e.endsWith(`
|
||||
`)&&(e=e.slice(0,-1)),n.endsWith(`
|
||||
`)&&(n=n.slice(0,-1))),super.equals(e,n,i)}}const I=new we;function j(t,e,n){return I.diff(t,e,n)}function ve(t,e,n){return n=me(n,{ignoreWhitespace:!0}),I.diff(t,e,n)}function B(t,e){e.stripTrailingCr&&(t=t.replace(/\r\n/g,`
|
||||
`));const n=[],i=t.split(/(\n|\r\n)/);i[i.length-1]||i.pop();for(let l=0;l<i.length;l++){const r=i[l];l%2&&!e.newlineIsToken?n[n.length-1]+=r:n.push(r)}return n}function ye(t){return t=="."||t=="!"||t=="?"}class pe extends D{tokenize(e){var n;const i=[];let l=0;for(let r=0;r<e.length;r++){if(r==e.length-1){i.push(e.slice(l));break}if(ye(e[r])&&e[r+1].match(/\s/)){for(i.push(e.slice(l,r+1)),r=l=r+1;!((n=e[r+1])===null||n===void 0)&&n.match(/\s/);)r++;i.push(e.slice(l,r+1)),l=r+1}}return i}}const Z=new pe;function We(t,e,n){return Z.diff(t,e,n)}class Ce extends D{tokenize(e){return e.split(/([{}:;,]|\s+)/)}}const G=new Ce;function Ee(t,e,n){return G.diff(t,e,n)}class De extends D{constructor(){super(...arguments),this.tokenize=B}get useLongestToken(){return!0}castInput(e,n){const{undefinedReplacement:i,stringifyReplacer:l=(r,s)=>typeof s>"u"?i:s}=n;return typeof e=="string"?e:JSON.stringify(N(e,null,null,l),null," ")}equals(e,n,i){return super.equals(e.replace(/,([\r\n])/g,"$1"),n.replace(/,([\r\n])/g,"$1"),i)}}const Q=new De;function Oe(t,e,n){return Q.diff(t,e,n)}function N(t,e,n,i,l){e=e||[],n=n||[],i&&(t=i(l===void 0?"":l,t));let r;for(r=0;r<e.length;r+=1)if(e[r]===t)return n[r];let s;if(Object.prototype.toString.call(t)==="[object Array]"){for(e.push(t),s=new Array(t.length),n.push(s),r=0;r<t.length;r+=1)s[r]=N(t[r],e,n,i,String(r));return e.pop(),n.pop(),s}if(t&&t.toJSON&&(t=t.toJSON()),typeof t=="object"&&t!==null){e.push(t),s={},n.push(s);const u=[];let f;for(f in t)Object.prototype.hasOwnProperty.call(t,f)&&u.push(f);for(u.sort(),r=0;r<u.length;r+=1)f=u[r],s[f]=N(t[f],e,n,i,f);e.pop(),n.pop()}else s=t;return s}class Le extends D{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}}const K=new Le;function Se(t,e,n){return K.diff(t,e,n)}function ee(t){return Array.isArray(t)?t.map(e=>ee(e)):Object.assign(Object.assign({},t),{hunks:t.hunks.map(e=>Object.assign(Object.assign({},e),{lines:e.lines.map((n,i)=>{var l;return n.startsWith("\\")||n.endsWith("\r")||!((l=e.lines[i+1])===null||l===void 0)&&l.startsWith("\\")?n:n+"\r"})}))})}function ne(t){return Array.isArray(t)?t.map(e=>ne(e)):Object.assign(Object.assign({},t),{hunks:t.hunks.map(e=>Object.assign(Object.assign({},e),{lines:e.lines.map(n=>n.endsWith("\r")?n.substring(0,n.length-1):n)}))})}function Pe(t){return Array.isArray(t)||(t=[t]),!t.some(e=>e.hunks.some(n=>n.lines.some(i=>!i.startsWith("\\")&&i.endsWith("\r"))))}function Ae(t){return Array.isArray(t)||(t=[t]),t.some(e=>e.hunks.some(n=>n.lines.some(i=>i.endsWith("\r"))))&&t.every(e=>e.hunks.every(n=>n.lines.every((i,l)=>{var r;return i.startsWith("\\")||i.endsWith("\r")||((r=n.lines[l+1])===null||r===void 0?void 0:r.startsWith("\\"))})))}function z(t){const e=t.split(/\n/),n=[];let i=0;function l(){const u={};for(n.push(u);i<e.length;){const f=e[i];if(/^(---|\+\+\+|@@)\s/.test(f))break;const w=/^(?:Index:|diff(?: -r \w+)+)\s+/.exec(f);w&&(u.index=f.substring(w[0].length).trim()),i++}for(r(u),r(u),u.hunks=[];i<e.length;){const f=e[i];if(/^(Index:\s|diff\s|---\s|\+\+\+\s|===================================================================)/.test(f))break;if(/^@@/.test(f))u.hunks.push(s());else{if(f)throw new Error("Unknown line "+(i+1)+" "+JSON.stringify(f));i++}}}function r(u){const f=/^(---|\+\+\+)\s+/.exec(e[i]);if(f){const w=f[1],c=e[i].substring(3).trim().split(" ",2),m=(c[1]||"").trim();let y=c[0].replace(/\\\\/g,"\\");y.startsWith('"')&&y.endsWith('"')&&(y=y.substr(1,y.length-2)),w==="---"?(u.oldFileName=y,u.oldHeader=m):(u.newFileName=y,u.newHeader=m),i++}}function s(){var u;const f=i,w=e[i++],c=w.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/),m={oldStart:+c[1],oldLines:typeof c[2]>"u"?1:+c[2],newStart:+c[3],newLines:typeof c[4]>"u"?1:+c[4],lines:[]};m.oldLines===0&&(m.oldStart+=1),m.newLines===0&&(m.newStart+=1);let y=0,p=0;for(;i<e.length&&(p<m.oldLines||y<m.newLines||!((u=e[i])===null||u===void 0)&&u.startsWith("\\"));i++){const d=e[i].length==0&&i!=e.length-1?" ":e[i][0];if(d==="+"||d==="-"||d===" "||d==="\\")m.lines.push(e[i]),d==="+"?y++:d==="-"?p++:d===" "&&(y++,p++);else throw new Error(`Hunk at line ${f+1} contained invalid line ${e[i]}`)}if(!y&&m.newLines===1&&(m.newLines=0),!p&&m.oldLines===1&&(m.oldLines=0),y!==m.newLines)throw new Error("Added line count did not match for hunk at line "+(f+1));if(p!==m.oldLines)throw new Error("Removed line count did not match for hunk at line "+(f+1));return m}for(;i<e.length;)l();return n}function Fe(t,e,n){let i=!0,l=!1,r=!1,s=1;return function u(){if(i&&!r){if(l?s++:i=!1,t+s<=n)return t+s;r=!0}if(!l)return r||(i=!0),e<=t-s?t-s++:(l=!0,u())}}function te(t,e,n={}){let i;if(typeof e=="string"?i=z(e):Array.isArray(e)?i=e:i=[e],i.length>1)throw new Error("applyPatch only works with a single input.");return ke(t,i[0],n)}function ke(t,e,n={}){(n.autoConvertLineEndings||n.autoConvertLineEndings==null)&&(oe(t)&&Pe(e)?e=ee(e):ae(t)&&Ae(e)&&(e=ne(e)));const i=t.split(`
|
||||
`),l=e.hunks,r=n.compareLine||((d,h,W,E)=>h===E),s=n.fuzzFactor||0;let u=0;if(s<0||!Number.isInteger(s))throw new Error("fuzzFactor must be a non-negative integer");if(!l.length)return t;let f="",w=!1,c=!1;for(let d=0;d<l[l.length-1].lines.length;d++){const h=l[l.length-1].lines[d];h[0]=="\\"&&(f[0]=="+"?w=!0:f[0]=="-"&&(c=!0)),f=h}if(w){if(c){if(!s&&i[i.length-1]=="")return!1}else if(i[i.length-1]=="")i.pop();else if(!s)return!1}else if(c){if(i[i.length-1]!="")i.push("");else if(!s)return!1}function m(d,h,W,E=0,a=!0,o=[],v=0){let C=0,L=!1;for(;E<d.length;E++){const O=d[E],P=O.length>0?O[0]:" ",M=O.length>0?O.substr(1):O;if(P==="-")if(r(h+1,i[h],P,M))h++,C=0;else return!W||i[h]==null?null:(o[v]=i[h],m(d,h+1,W-1,E,!1,o,v+1));if(P==="+"){if(!a)return null;o[v]=M,v++,C=0,L=!0}if(P===" ")if(C++,o[v]=i[h],r(h+1,i[h],P,M))v++,a=!0,L=!1,h++;else return L||!W?null:i[h]&&(m(d,h+1,W-1,E+1,!1,o,v+1)||m(d,h+1,W-1,E,!1,o,v+1))||m(d,h,W-1,E+1,!1,o,v)}return v-=C,h-=C,o.length=v,{patchedLines:o,oldLineLastI:h-1}}const y=[];let p=0;for(let d=0;d<l.length;d++){const h=l[d];let W;const E=i.length-h.oldLines+s;let a;for(let o=0;o<=s;o++){a=h.oldStart+p-1;const v=Fe(a,u,E);for(;a!==void 0&&(W=m(h.lines,a,o),!W);a=v());if(W)break}if(!W)return!1;for(let o=u;o<a;o++)y.push(i[o]);for(let o=0;o<W.patchedLines.length;o++){const v=W.patchedLines[o];y.push(v)}u=W.oldLineLastI+1,p=a+1-h.oldStart}for(let d=u;d<i.length;d++)y.push(i[d]);return y.join(`
|
||||
`)}function xe(t,e){const n=typeof t=="string"?z(t):t;let i=0;function l(){const r=n[i++];if(!r)return e.complete();e.loadFile(r,function(s,u){if(s)return e.complete(s);const f=te(u,r,e);e.patched(r,f,function(w){if(w)return e.complete(w);l()})})}l()}function ie(t){return Array.isArray(t)?t.map(e=>ie(e)).reverse():Object.assign(Object.assign({},t),{oldFileName:t.newFileName,oldHeader:t.newHeader,newFileName:t.oldFileName,newHeader:t.oldHeader,hunks:t.hunks.map(e=>({oldLines:e.newLines,oldStart:e.newStart,newLines:e.oldLines,newStart:e.oldStart,lines:e.lines.map(n=>n.startsWith("-")?`+${n.slice(1)}`:n.startsWith("+")?`-${n.slice(1)}`:n)}))})}const le={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0},Ne={includeIndex:!1,includeUnderline:!1,includeFileHeaders:!0},Te={includeIndex:!1,includeUnderline:!1,includeFileHeaders:!1};function R(t,e,n,i,l,r,s){let u;s?typeof s=="function"?u={callback:s}:u=s:u={},typeof u.context>"u"&&(u.context=4);const f=u.context;if(u.newlineIsToken)throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(u.callback){const{callback:c}=u;j(n,i,Object.assign(Object.assign({},u),{callback:m=>{const y=w(m);c(y)}}))}else return w(j(n,i,u));function w(c){if(!c)return;c.push({value:"",lines:[]});function m(a){return a.map(function(o){return" "+o})}const y=[];let p=0,d=0,h=[],W=1,E=1;for(let a=0;a<c.length;a++){const o=c[a],v=o.lines||be(o.value);if(o.lines=v,o.added||o.removed){if(!p){const C=c[a-1];p=W,d=E,C&&(h=f>0?m(C.lines.slice(-f)):[],p-=h.length,d-=h.length)}for(const C of v)h.push((o.added?"+":"-")+C);o.added?E+=v.length:W+=v.length}else{if(p)if(v.length<=f*2&&a<c.length-2)for(const C of m(v))h.push(C);else{const C=Math.min(v.length,f);for(const O of m(v.slice(0,C)))h.push(O);const L={oldStart:p,oldLines:W-p+C,newStart:d,newLines:E-d+C,lines:h};y.push(L),p=0,d=0,h=[]}W+=v.length,E+=v.length}}for(const a of y)for(let o=0;o<a.lines.length;o++)a.lines[o].endsWith(`
|
||||
`)?a.lines[o]=a.lines[o].slice(0,-1):(a.lines.splice(o+1,0,"\\ No newline at end of file"),o++);return{oldFileName:t,newFileName:e,oldHeader:l,newHeader:r,hunks:y}}}function T(t,e){if(e||(e=le),Array.isArray(t)){if(t.length>1&&!e.includeFileHeaders)throw new Error("Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)");return t.map(i=>T(i,e)).join(`
|
||||
`)}const n=[];e.includeIndex&&t.oldFileName==t.newFileName&&n.push("Index: "+t.oldFileName),e.includeUnderline&&n.push("==================================================================="),e.includeFileHeaders&&(n.push("--- "+t.oldFileName+(typeof t.oldHeader>"u"?"":" "+t.oldHeader)),n.push("+++ "+t.newFileName+(typeof t.newHeader>"u"?"":" "+t.newHeader)));for(let i=0;i<t.hunks.length;i++){const l=t.hunks[i];l.oldLines===0&&(l.oldStart-=1),l.newLines===0&&(l.newStart-=1),n.push("@@ -"+l.oldStart+","+l.oldLines+" +"+l.newStart+","+l.newLines+" @@");for(const r of l.lines)n.push(r)}return n.join(`
|
||||
`)+`
|
||||
`}function re(t,e,n,i,l,r,s){if(typeof s=="function"&&(s={callback:s}),s?.callback){const{callback:u}=s;R(t,e,n,i,l,r,Object.assign(Object.assign({},s),{callback:f=>{u(f?T(f,s.headerOptions):void 0)}}))}else{const u=R(t,e,n,i,l,r,s);return u?T(u,s?.headerOptions):void 0}}function He(t,e,n,i,l,r){return re(t,t,e,n,i,l,r)}function be(t){const e=t.endsWith(`
|
||||
`),n=t.split(`
|
||||
`).map(i=>i+`
|
||||
`);return e?n.pop():n.push(n.pop().slice(0,-1)),n}function Ie(t){const e=[];let n,i;for(let l=0;l<t.length;l++)n=t[l],n.added?i=1:n.removed?i=-1:i=0,e.push([i,n.value]);return e}function je(t){const e=[];for(let n=0;n<t.length;n++){const i=t[n];i.added?e.push("<ins>"):i.removed&&e.push("<del>"),e.push(ze(i.value)),i.added?e.push("</ins>"):i.removed&&e.push("</del>")}return e.join("")}function ze(t){let e=t;return e=e.replace(/&/g,"&"),e=e.replace(/</g,"<"),e=e.replace(/>/g,">"),e=e.replace(/"/g,"""),e}g.Diff=D,g.FILE_HEADERS_ONLY=Ne,g.INCLUDE_HEADERS=le,g.OMIT_HEADERS=Te,g.applyPatch=te,g.applyPatches=xe,g.arrayDiff=K,g.canonicalize=N,g.characterDiff=_,g.convertChangesToDMP=Ie,g.convertChangesToXML=je,g.createPatch=He,g.createTwoFilesPatch=re,g.cssDiff=G,g.diffArrays=Se,g.diffChars=fe,g.diffCss=Ee,g.diffJson=Oe,g.diffLines=j,g.diffSentences=We,g.diffTrimmedLines=ve,g.diffWords=he,g.diffWordsWithSpace=Y,g.formatPatch=T,g.jsonDiff=Q,g.lineDiff=I,g.parsePatch=z,g.reversePatch=ie,g.sentenceDiff=Z,g.structuredPatch=R,g.wordDiff=q,g.wordsWithSpaceDiff=X}));
|
||||
BIN
Binary file not shown.
Reference in New Issue
Block a user