v-code-diff 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/v2/index.cjs.js +1 -1
- package/dist/v2/index.es.js +84 -84
- package/dist/v2.7/index.cjs.js +1 -1
- package/dist/v2.7/index.es.js +1 -1
- package/package.json +1 -1
- package/src/CodeDiff.vue +1 -1
- package/src/split/SplitLine.vue +2 -2
- package/src/types.ts +4 -4
- package/src/unified/UnifiedLine.vue +2 -2
- package/src/unified/UnifiedViewer.vue +2 -2
- package/src/utils.ts +3 -3
package/dist/v2/index.cjs.js
CHANGED
|
@@ -11,6 +11,6 @@ https://github.com/highlightjs/highlight.js/issues/2277`),x=b,k=M),C===void 0&&(
|
|
|
11
11
|
`);if(v===void 0){for(const S of m){let N=t(),I=t();const R=Z(a,S);E===D.EQUAL&&(s++,o++,N=r(D.EQUAL,s,R),I=r(D.EQUAL,o,R)),E===D.DELETE&&(s++,N=r(D.DELETE,s,R),I=t()),E===D.ADD&&(o++,N=t(),I=r(D.ADD,o,R)),c.push({left:N,right:I})}break}if(E===D.EQUAL)for(const S of m){s++,o++;const N=Z(a,S);c.push({left:r(D.EQUAL,s,N),right:r(D.EQUAL,o,N)})}const T=v.value.replace(/\n$/,"").split(`
|
|
12
12
|
`);if(E===D.DELETE){if(w===D.EQUAL)for(const S of m)s++,c.push({left:r(D.DELETE,s,Z(a,S)),right:t()});if(w===D.ADD){l=!0;const S=Math.max(_.count,v.count);for(let N=0;N<S;N++){N<_.count&&s++,N<v.count&&o++;const[I,R]=[m[N],T[N]],F=m.length===T.length?De(R,I,u):I,U=m.length===T.length?De(I,R,u):R,$=N<_.count?r(D.DELETE,s,Z(a,F)):t(),H=N<v.count?r(D.ADD,o,Z(a,U)):t();c.push({left:$,right:H})}}}if(E===D.ADD)for(const S of m)o++,c.push({left:t(),right:r(D.ADD,o,Z(a,S))})}if(e===n){for(let d=0;d<c.length;d++)c[d].fold=!1;return f}for(let d=0;d<c.length;d++){const _=c[d];if(_.left.type===D.DELETE||_.right.type===D.ADD){const[v,E]=[Math.max(d-h,0),Math.min(d+h+1,c.length)];for(let w=v;w<E;w++)c[w].fold=!1}_.fold===void 0&&(_.fold=!0)}const g=[];for(let d=0;d<c.length;d++){const _=c[d];if(_.fold===!1){g.push(_);continue}_.fold===!0&&((p=g[g.length-1])==null?void 0:p.fold)!==!0&&g.push(_)}return f.changes=g,f}function sr(e,n,a="plaintext",u="word",h=10){var f;const t=Dn(e,n);let r=0,i=0,s=!1;const o=[],l={changes:o,stat:Rn(t)};for(let g=0;g<t.length;g++){if(s){s=!1;continue}const[p,d]=[t[g],t[g+1]],[_,v]=[le(p),le(d)],E=p.value.replace(/\n$/,"").split(`
|
|
13
13
|
`);if(d===void 0){for(const m of E){_===D.EQUAL&&(r++,i++),_===D.DELETE&&r++,_===D.ADD&&i++;const T=Z(a,m);o.push({type:_,code:T,addNum:_===D.DELETE?void 0:i,delNum:_===D.ADD?void 0:r})}break}if(_===D.EQUAL)for(const m of E){r++,i++;const T=Z(a,m);o.push({type:D.EQUAL,code:T,delNum:r,addNum:i})}const w=d.value.replace(/\n$/,"").split(`
|
|
14
|
-
`);if(_===D.DELETE)if(v===D.ADD&&E.length===w.length){for(let m=0;m<E.length;m++){const T=E[m],S=w[m];r++;const N=Z(a,De(S,T,u));o.push({type:D.DELETE,code:N,delNum:r})}for(let m=0;m<w.length;m++){const T=E[m],S=w[m];i++;const N=Z(a,De(T,S,u));o.push({type:D.ADD,code:N,addNum:i})}s=!0}else for(const m of E){r++;const T=Z(a,m);o.push({type:D.DELETE,code:T,delNum:r})}if(_===D.ADD)for(const m of E){i++;const T=Z(a,m);o.push({type:D.ADD,code:T,addNum:i})}}for(let g=0;g<o.length;g++){const p=o[g];if(p.type===D.DELETE||p.type===D.ADD){const[d,_]=[Math.max(g-h,0),Math.min(g+h+1,o.length)];for(let v=d;v<_;v++)o[v].fold=!1}p.fold===void 0&&(p.fold=!0)}if(e===n){for(let g=0;g<o.length;g++)o[g].fold=!1;return l}const c=[];for(let g=0;g<o.length;g++){const p=o[g];if(p.fold===!1){c.push(p);continue}p.fold===!0&&(g===0||((f=c[c.length-1])==null?void 0:f.fold)!==!0)&&c.push(p)}return l.changes=c,l}const Ke={};Ke.props={line:{key:"line",required:!0,type:null}};Ke.setup=(e,n)=>({DiffType:D,getCodeMarker:u=>u===D.DELETE?"-":u===D.ADD?"+":""});var ar=function(){var e=this,n=e.$createElement,a=e._self._c||n;return e.line.fold?a("tr",[a("td",{staticClass:"blob-num blob-num-hunk"},[e._v(" > ")]),a("td",{staticClass:"blob-num blob-num-hunk"},[e._v(" > ")]),a("td",{staticClass:"blob-code blob-code-hunk",attrs:{align:"left"}},[e._v(" ⋯ ")])]):a("tr",[a("td",{staticClass:"blob-num",class:{"blob-num-deletion":e.line.type===e.DiffType.DELETE,"blob-num-addition":e.line.type===e.DiffType.ADD,"blob-num-context":e.line.type===e.DiffType.EQUAL}},[e._v(" "+e._s(e.line.delNum)+" ")]),a("td",{staticClass:"blob-num",class:{"blob-num-deletion":e.line.type===e.DiffType.DELETE,"blob-num-addition":e.line.type===e.DiffType.ADD,"blob-num-context":e.line.type===e.DiffType.EQUAL}},[e._v(" "+e._s(e.line.addNum)+" ")]),a("td",{staticClass:"blob-code",class:{"blob-code-deletion":e.line.type===e.DiffType.DELETE,"blob-code-addition":e.line.type===e.DiffType.ADD,"blob-code-context":e.line.type===e.DiffType.EQUAL}},[a("span",{staticClass:"blob-code-inner blob-code-marker",attrs:{"data-code-marker":e.getCodeMarker(e.line.type)},domProps:{innerHTML:e._s(e.line.code)}})])])},or=[];function ve(e,n,a,u,h,t,r,i){var s=typeof e=="function"?e.options:e;n&&(s.render=n,s.staticRenderFns=a,s._compiled=!0),u&&(s.functional=!0),t&&(s._scopeId="data-v-"+t);var o;if(r?(o=function(f){f=f||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!f&&typeof __VUE_SSR_CONTEXT__<"u"&&(f=__VUE_SSR_CONTEXT__),h&&h.call(this,f),f&&f._registeredComponents&&f._registeredComponents.add(r)},s._ssrRegister=o):h&&(o=i?function(){h.call(this,(s.functional?this.parent:this).$root.$options.shadowRoot)}:h),o)if(s.functional){s._injectStyles=o;var l=s.render;s.render=function(g,p){return o.call(p),l(g,p)}}else{var c=s.beforeCreate;s.beforeCreate=c?[].concat(c,o):[o]}return{exports:e,options:s}}const ln={};var lr=ve(Ke,ar,or,!1,cr,null,null,null);function cr(e){for(let n in ln)this[n]=ln[n]}const ur=function(){return lr.exports}(),pe={};pe.props={diffChange:{key:"diffChange",required:!0,type:
|
|
14
|
+
`);if(_===D.DELETE)if(v===D.ADD&&E.length===w.length){for(let m=0;m<E.length;m++){const T=E[m],S=w[m];r++;const N=Z(a,De(S,T,u));o.push({type:D.DELETE,code:N,delNum:r})}for(let m=0;m<w.length;m++){const T=E[m],S=w[m];i++;const N=Z(a,De(T,S,u));o.push({type:D.ADD,code:N,addNum:i})}s=!0}else for(const m of E){r++;const T=Z(a,m);o.push({type:D.DELETE,code:T,delNum:r})}if(_===D.ADD)for(const m of E){i++;const T=Z(a,m);o.push({type:D.ADD,code:T,addNum:i})}}for(let g=0;g<o.length;g++){const p=o[g];if(p.type===D.DELETE||p.type===D.ADD){const[d,_]=[Math.max(g-h,0),Math.min(g+h+1,o.length)];for(let v=d;v<_;v++)o[v].fold=!1}p.fold===void 0&&(p.fold=!0)}if(e===n){for(let g=0;g<o.length;g++)o[g].fold=!1;return l}const c=[];for(let g=0;g<o.length;g++){const p=o[g];if(p.fold===!1){c.push(p);continue}p.fold===!0&&(g===0||((f=c[c.length-1])==null?void 0:f.fold)!==!0)&&c.push(p)}return l.changes=c,l}const Ke={};Ke.props={line:{key:"line",required:!0,type:null}};Ke.setup=(e,n)=>({DiffType:D,getCodeMarker:u=>u===D.DELETE?"-":u===D.ADD?"+":""});var ar=function(){var e=this,n=e.$createElement,a=e._self._c||n;return e.line.fold?a("tr",[a("td",{staticClass:"blob-num blob-num-hunk"},[e._v(" > ")]),a("td",{staticClass:"blob-num blob-num-hunk"},[e._v(" > ")]),a("td",{staticClass:"blob-code blob-code-hunk",attrs:{align:"left"}},[e._v(" ⋯ ")])]):a("tr",[a("td",{staticClass:"blob-num",class:{"blob-num-deletion":e.line.type===e.DiffType.DELETE,"blob-num-addition":e.line.type===e.DiffType.ADD,"blob-num-context":e.line.type===e.DiffType.EQUAL}},[e._v(" "+e._s(e.line.delNum)+" ")]),a("td",{staticClass:"blob-num",class:{"blob-num-deletion":e.line.type===e.DiffType.DELETE,"blob-num-addition":e.line.type===e.DiffType.ADD,"blob-num-context":e.line.type===e.DiffType.EQUAL}},[e._v(" "+e._s(e.line.addNum)+" ")]),a("td",{staticClass:"blob-code",class:{"blob-code-deletion":e.line.type===e.DiffType.DELETE,"blob-code-addition":e.line.type===e.DiffType.ADD,"blob-code-context":e.line.type===e.DiffType.EQUAL}},[a("span",{staticClass:"blob-code-inner blob-code-marker",attrs:{"data-code-marker":e.getCodeMarker(e.line.type)},domProps:{innerHTML:e._s(e.line.code)}})])])},or=[];function ve(e,n,a,u,h,t,r,i){var s=typeof e=="function"?e.options:e;n&&(s.render=n,s.staticRenderFns=a,s._compiled=!0),u&&(s.functional=!0),t&&(s._scopeId="data-v-"+t);var o;if(r?(o=function(f){f=f||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!f&&typeof __VUE_SSR_CONTEXT__<"u"&&(f=__VUE_SSR_CONTEXT__),h&&h.call(this,f),f&&f._registeredComponents&&f._registeredComponents.add(r)},s._ssrRegister=o):h&&(o=i?function(){h.call(this,(s.functional?this.parent:this).$root.$options.shadowRoot)}:h),o)if(s.functional){s._injectStyles=o;var l=s.render;s.render=function(g,p){return o.call(p),l(g,p)}}else{var c=s.beforeCreate;s.beforeCreate=c?[].concat(c,o):[o]}return{exports:e,options:s}}const ln={};var lr=ve(Ke,ar,or,!1,cr,null,null,null);function cr(e){for(let n in ln)this[n]=ln[n]}const ur=function(){return lr.exports}(),pe={};pe.props={diffChange:{key:"diffChange",required:!0,type:Array}};pe.setup=(e,n)=>({});pe.components=Object.assign({UnifiedLine:ur},pe.components);var fr=function(){var e=this,n=e.$createElement,a=e._self._c||n;return a("table",{staticClass:"diff-table"},[a("tbody",e._l(e.diffChange,function(u,h){return a("UnifiedLine",{key:h,attrs:{line:u}})}),1)])},gr=[];const cn={};var hr=ve(pe,fr,gr,!1,dr,null,null,null);function dr(e){for(let n in cn)this[n]=cn[n]}const pr=function(){return hr.exports}(),We={};We.props={splitLine:{key:"splitLine",required:!0,type:null}};We.setup=(e,n)=>({DiffType:D,getCodeMarker:u=>u===D.DELETE?"-":u===D.ADD?"+":""});var _r=function(){var e=this,n=e.$createElement,a=e._self._c||n;return e.splitLine.fold?a("tr",[a("td",{staticClass:"blob-num blob-num-hunk",attrs:{colspan:"1"}},[e._v(" > ")]),a("td",{staticClass:"blob-code blob-code-inner blob-code-hunk",attrs:{colspan:"3",align:"left"}},[e._v(" ⋯ ")])]):a("tr",[e._l([e.splitLine.left,e.splitLine.right],function(u){return[u.type===e.DiffType.EMPTY?[a("td",{staticClass:"blob-num blob-num-empty empty-cell"}),a("td",{staticClass:"blob-code blob-code-empty empty-cell"})]:[a("td",{staticClass:"blob-num",class:{"blob-num-deletion":u.type===e.DiffType.DELETE,"blob-num-addition":u.type===e.DiffType.ADD,"blob-num-context":u.type===e.DiffType.EQUAL}},[e._v(" "+e._s(u.num)+" ")]),a("td",{staticClass:"blob-code",class:{"blob-code-deletion":u.type===e.DiffType.DELETE,"blob-code-addition":u.type===e.DiffType.ADD,"blob-code-context":u.type===e.DiffType.EQUAL}},[a("span",{staticClass:"blob-code-inner blob-code-marker",attrs:{"data-code-marker":e.getCodeMarker(u.type)},domProps:{innerHTML:e._s(u.code)}})])]]})],2)},br=[];const un={};var vr=ve(We,_r,br,!1,Er,null,null,null);function Er(e){for(let n in un)this[n]=un[n]}const mr=function(){return vr.exports}(),_e={};_e.props={diffChange:{key:"diffChange",required:!0,type:null}};_e.setup=(e,n)=>({});_e.components=Object.assign({SplitLine:mr},_e.components);var yr=function(){var e=this,n=e.$createElement,a=e._self._c||n;return a("table",{staticClass:"file-diff-split diff-table"},[e._m(0),a("tbody",e._l(e.diffChange,function(u,h){return a("SplitLine",{key:h,attrs:{"split-line":u}})}),1)])},wr=[function(){var e=this,n=e.$createElement,a=e._self._c||n;return a("colgroup",[a("col",{attrs:{width:"44"}}),a("col"),a("col",{attrs:{width:"44"}}),a("col")])}];const fn={};var Mr=ve(_e,yr,wr,!1,Nr,null,null,null);function Nr(e){for(let n in fn)this[n]=fn[n]}const Ar=function(){return Mr.exports}();const be={};be.props={newString:{key:"newString",required:!0,type:String},oldString:{key:"oldString",required:!0,type:String},language:{key:"language",required:!1,type:String,default:"plaintext"},context:{key:"context",required:!1,type:Number,default:10},diffStyle:{key:"diffStyle",required:!1,type:String,default:"word"},outputFormat:{key:"outputFormat",required:!1,type:String,default:"line-by-line"},trim:{key:"trim",required:!1,type:Boolean,default:!1},noDiffLineFeed:{key:"noDiffLineFeed",required:!1,type:Boolean,default:!1},maxHeight:{key:"maxHeight",required:!1,type:String,default:void 0},filename:{key:"filename",required:!1,type:String,default:void 0}};be.setup=(e,n)=>{const a=e,u=ce.computed(()=>a.outputFormat==="line-by-line"),h=ce.computed(()=>{const i=a.trim?a.oldString.trim():a.oldString;return a.noDiffLineFeed?i.replace(/(\r\n)/g,`
|
|
15
15
|
`):i}),t=ce.computed(()=>{const i=a.trim?a.newString.trim():a.newString;return a.noDiffLineFeed?i.replace(/(\r\n)/g,`
|
|
16
16
|
`):i}),r=ce.computed(()=>u.value?sr(h.value,t.value,a.language,a.diffStyle,a.context):ir(h.value,t.value,a.language,a.diffStyle,a.context));return{isUnifiedViewer:u,diffChange:r}};be.components=Object.assign({UnifiedViewer:pr,SplitViewer:Ar},be.components);var Tr=function(){var e=this,n=e.$createElement,a=e._self._c||n;return a("div",{staticClass:"code-diff-view",style:{maxHeight:e.maxHeight}},[a("div",{staticClass:"file-header"},[a("div",{staticClass:"file-info"},[a("span",{staticClass:"filename"},[e._v(e._s(e.filename))]),a("span",{staticClass:"diff-stat"},[a("span",{staticClass:"diff-stat-added"},[e._v("+"+e._s(e.diffChange.stat.additionsNum)+" additions")]),a("span",{staticClass:"diff-stat-deleted",staticStyle:{"margin-left":"8px"}},[e._v("-"+e._s(e.diffChange.stat.deletionsNum)+" deletions")])])])]),e.isUnifiedViewer?a("UnifiedViewer",{attrs:{"diff-change":e.diffChange.changes}}):a("SplitViewer",{attrs:{"diff-change":e.diffChange.changes}})],1)},Sr=[];const gn={};var Dr=ve(be,Tr,Sr,!1,Rr,null,null,null);function Rr(e){for(let n in gn)this[n]=gn[n]}const On=function(){return Dr.exports}(),Or=e=>{e.component("CodeDiff",On)},Cr={install:Or,hljs:Y};exports.CodeDiff=On;exports.default=Cr;
|
package/dist/v2/index.es.js
CHANGED
|
@@ -311,10 +311,10 @@ var ce = {}, Yn = {
|
|
|
311
311
|
for (var s = t.length, o = r.length, l = Math.ceil((s + o) / 2), c = l, f = 2 * l, g = new Array(f), p = new Array(f), d = 0; d < f; d++)
|
|
312
312
|
g[d] = -1, p[d] = -1;
|
|
313
313
|
g[c + 1] = 0, p[c + 1] = 0;
|
|
314
|
-
for (var _ = s - o, v = _ % 2 != 0, E = 0, w = 0, m = 0, T = 0,
|
|
315
|
-
for (var N = -
|
|
314
|
+
for (var _ = s - o, v = _ % 2 != 0, E = 0, w = 0, m = 0, T = 0, S = 0; S < l && !(new Date().getTime() > i); S++) {
|
|
315
|
+
for (var N = -S + E; N <= S - w; N += 2) {
|
|
316
316
|
var I = c + N, R;
|
|
317
|
-
N == -
|
|
317
|
+
N == -S || N != S && g[I - 1] < g[I + 1] ? R = g[I + 1] : R = g[I - 1] + 1;
|
|
318
318
|
for (var F = R - N; R < s && F < o && t.charAt(R) == r.charAt(F); )
|
|
319
319
|
R++, F++;
|
|
320
320
|
if (g[I] = R, R > s)
|
|
@@ -330,9 +330,9 @@ var ce = {}, Yn = {
|
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
|
-
for (var H = -
|
|
333
|
+
for (var H = -S + m; H <= S - T; H += 2) {
|
|
334
334
|
var U = c + H, $;
|
|
335
|
-
H == -
|
|
335
|
+
H == -S || H != S && p[U - 1] < p[U + 1] ? $ = p[U + 1] : $ = p[U - 1] + 1;
|
|
336
336
|
for (var G = $ - H; $ < s && G < o && t.charAt(s - $ - 1) == r.charAt(o - G - 1); )
|
|
337
337
|
$++, G++;
|
|
338
338
|
if (p[U] = $, $ > s)
|
|
@@ -412,7 +412,7 @@ var ce = {}, Yn = {
|
|
|
412
412
|
return null;
|
|
413
413
|
var o = this;
|
|
414
414
|
function l(w, m, T) {
|
|
415
|
-
for (var
|
|
415
|
+
for (var S = w.substring(T, T + Math.floor(w.length / 4)), N = -1, I = "", R, F, U, $; (N = m.indexOf(S, N + 1)) != -1; ) {
|
|
416
416
|
var H = o.diff_commonPrefix(
|
|
417
417
|
w.substring(T),
|
|
418
418
|
m.substring(N)
|
|
@@ -473,8 +473,8 @@ var ce = {}, Yn = {
|
|
|
473
473
|
function r(E, w) {
|
|
474
474
|
if (!E || !w)
|
|
475
475
|
return 6;
|
|
476
|
-
var m = E.charAt(E.length - 1), T = w.charAt(0),
|
|
477
|
-
return $ || H ? 5 : F || U ? 4 :
|
|
476
|
+
var m = E.charAt(E.length - 1), T = w.charAt(0), S = m.match(n.nonAlphaNumericRegex_), N = T.match(n.nonAlphaNumericRegex_), I = S && m.match(n.whitespaceRegex_), R = N && T.match(n.whitespaceRegex_), F = I && m.match(n.linebreakRegex_), U = R && T.match(n.linebreakRegex_), $ = F && E.match(n.blanklineEndRegex_), H = U && w.match(n.blanklineStartRegex_);
|
|
477
|
+
return $ || H ? 5 : F || U ? 4 : S && !I && R ? 3 : I || R ? 2 : S || N ? 1 : 0;
|
|
478
478
|
}
|
|
479
479
|
for (var i = 1; i < t.length - 1; ) {
|
|
480
480
|
if (t[i - 1][0] == h && t[i + 1][0] == h) {
|
|
@@ -638,12 +638,12 @@ var ce = {}, Yn = {
|
|
|
638
638
|
_ = d;
|
|
639
639
|
var w = Math.max(1, i - d + 1), m = Math.min(i + d, t.length) + r.length, T = Array(m + 2);
|
|
640
640
|
T[m + 1] = (1 << E) - 1;
|
|
641
|
-
for (var
|
|
642
|
-
var N = s[t.charAt(
|
|
643
|
-
if (E === 0 ? T[
|
|
644
|
-
var I = l(E,
|
|
641
|
+
for (var S = m; S >= w; S--) {
|
|
642
|
+
var N = s[t.charAt(S - 1)];
|
|
643
|
+
if (E === 0 ? T[S] = (T[S + 1] << 1 | 1) & N : T[S] = (T[S + 1] << 1 | 1) & N | ((v[S + 1] | v[S]) << 1 | 1) | v[S + 1], T[S] & g) {
|
|
644
|
+
var I = l(E, S - 1);
|
|
645
645
|
if (I <= c)
|
|
646
|
-
if (c = I, f =
|
|
646
|
+
if (c = I, f = S - 1, f > i)
|
|
647
647
|
w = Math.max(1, 2 * i - f);
|
|
648
648
|
else
|
|
649
649
|
break;
|
|
@@ -1314,7 +1314,7 @@ function At(e, n) {
|
|
|
1314
1314
|
function Tt(e, n) {
|
|
1315
1315
|
e.relevance === void 0 && (e.relevance = 1);
|
|
1316
1316
|
}
|
|
1317
|
-
const
|
|
1317
|
+
const St = (e, n) => {
|
|
1318
1318
|
if (!e.beforeMatch)
|
|
1319
1319
|
return;
|
|
1320
1320
|
if (e.starts)
|
|
@@ -1328,7 +1328,7 @@ const Dt = (e, n) => {
|
|
|
1328
1328
|
Object.assign(a, { endsParent: !0 })
|
|
1329
1329
|
]
|
|
1330
1330
|
}, e.relevance = 0, delete a.beforeMatch;
|
|
1331
|
-
},
|
|
1331
|
+
}, Dt = [
|
|
1332
1332
|
"of",
|
|
1333
1333
|
"and",
|
|
1334
1334
|
"for",
|
|
@@ -1363,7 +1363,7 @@ function Ot(e, n) {
|
|
|
1363
1363
|
return n ? Number(n) : Ct(e) ? 0 : 1;
|
|
1364
1364
|
}
|
|
1365
1365
|
function Ct(e) {
|
|
1366
|
-
return
|
|
1366
|
+
return Dt.includes(e.toLowerCase());
|
|
1367
1367
|
}
|
|
1368
1368
|
const nn = {}, ie = (e) => {
|
|
1369
1369
|
console.error(e);
|
|
@@ -1371,7 +1371,7 @@ const nn = {}, ie = (e) => {
|
|
|
1371
1371
|
console.log(`WARN: ${e}`, ...n);
|
|
1372
1372
|
}, ae = (e, n) => {
|
|
1373
1373
|
nn[`${e}/${n}`] || (console.log(`Deprecated as of ${e}. ${n}`), nn[`${e}/${n}`] = !0);
|
|
1374
|
-
},
|
|
1374
|
+
}, Se = new Error();
|
|
1375
1375
|
function wn(e, n, { key: a }) {
|
|
1376
1376
|
let u = 0;
|
|
1377
1377
|
const h = e[a], t = {}, r = {};
|
|
@@ -1382,18 +1382,18 @@ function wn(e, n, { key: a }) {
|
|
|
1382
1382
|
function Lt(e) {
|
|
1383
1383
|
if (Array.isArray(e.begin)) {
|
|
1384
1384
|
if (e.skip || e.excludeBegin || e.returnBegin)
|
|
1385
|
-
throw ie("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),
|
|
1385
|
+
throw ie("skip, excludeBegin, returnBegin not compatible with beginScope: {}"), Se;
|
|
1386
1386
|
if (typeof e.beginScope != "object" || e.beginScope === null)
|
|
1387
|
-
throw ie("beginScope must be object"),
|
|
1387
|
+
throw ie("beginScope must be object"), Se;
|
|
1388
1388
|
wn(e, e.begin, { key: "beginScope" }), e.begin = ze(e.begin, { joinWith: "" });
|
|
1389
1389
|
}
|
|
1390
1390
|
}
|
|
1391
1391
|
function It(e) {
|
|
1392
1392
|
if (Array.isArray(e.end)) {
|
|
1393
1393
|
if (e.skip || e.excludeEnd || e.returnEnd)
|
|
1394
|
-
throw ie("skip, excludeEnd, returnEnd not compatible with endScope: {}"),
|
|
1394
|
+
throw ie("skip, excludeEnd, returnEnd not compatible with endScope: {}"), Se;
|
|
1395
1395
|
if (typeof e.endScope != "object" || e.endScope === null)
|
|
1396
|
-
throw ie("endScope must be object"),
|
|
1396
|
+
throw ie("endScope must be object"), Se;
|
|
1397
1397
|
wn(e, e.end, { key: "endScope" }), e.end = ze(e.end, { joinWith: "" });
|
|
1398
1398
|
}
|
|
1399
1399
|
}
|
|
@@ -1483,7 +1483,7 @@ function $t(e) {
|
|
|
1483
1483
|
// the distinction between match/begin
|
|
1484
1484
|
At,
|
|
1485
1485
|
Bt,
|
|
1486
|
-
|
|
1486
|
+
St
|
|
1487
1487
|
].forEach((l) => l(r, i)), e.compilerExtensions.forEach((l) => l(r, i)), r.__beforeBegin = null, [
|
|
1488
1488
|
Mt,
|
|
1489
1489
|
// do this later so compiler extensions that come earlier have access to the
|
|
@@ -1835,7 +1835,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`), x = b, k = M), C ===
|
|
|
1835
1835
|
w && m();
|
|
1836
1836
|
}
|
|
1837
1837
|
typeof window < "u" && window.addEventListener && window.addEventListener("DOMContentLoaded", T, !1);
|
|
1838
|
-
function
|
|
1838
|
+
function S(b, M) {
|
|
1839
1839
|
let C = null;
|
|
1840
1840
|
try {
|
|
1841
1841
|
C = M(e);
|
|
@@ -1901,7 +1901,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`), x = b, k = M), C ===
|
|
|
1901
1901
|
configure: _,
|
|
1902
1902
|
initHighlighting: v,
|
|
1903
1903
|
initHighlightingOnLoad: E,
|
|
1904
|
-
registerLanguage:
|
|
1904
|
+
registerLanguage: S,
|
|
1905
1905
|
unregisterLanguage: N,
|
|
1906
1906
|
listLanguages: I,
|
|
1907
1907
|
getLanguage: R,
|
|
@@ -2472,7 +2472,7 @@ function Yt(e) {
|
|
|
2472
2472
|
excludeEnd: !0,
|
|
2473
2473
|
keywords: i,
|
|
2474
2474
|
contains: m
|
|
2475
|
-
},
|
|
2475
|
+
}, S = {
|
|
2476
2476
|
variants: [
|
|
2477
2477
|
// class Car extends vehicle
|
|
2478
2478
|
{
|
|
@@ -2771,7 +2771,7 @@ function Yt(e) {
|
|
|
2771
2771
|
},
|
|
2772
2772
|
$,
|
|
2773
2773
|
F,
|
|
2774
|
-
|
|
2774
|
+
S,
|
|
2775
2775
|
G,
|
|
2776
2776
|
{
|
|
2777
2777
|
match: /\$[(.]/
|
|
@@ -3405,11 +3405,11 @@ var oe = "[0-9](_*[0-9])*", Ne = `\\.(${oe})`, Ae = "[0-9a-fA-F](_*[0-9a-fA-F])*
|
|
|
3405
3405
|
],
|
|
3406
3406
|
relevance: 0
|
|
3407
3407
|
};
|
|
3408
|
-
function
|
|
3409
|
-
return a === -1 ? "" : e.replace(n, (u) =>
|
|
3408
|
+
function Sn(e, n, a) {
|
|
3409
|
+
return a === -1 ? "" : e.replace(n, (u) => Sn(e, n, a - 1));
|
|
3410
3410
|
}
|
|
3411
3411
|
function Jt(e) {
|
|
3412
|
-
const n = e.regex, a = "[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*", u = a +
|
|
3412
|
+
const n = e.regex, a = "[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*", u = a + Sn("(?:<" + a + "~~~(?:\\s*,\\s*" + a + "~~~)*>)?", /~~~/g, 2), s = {
|
|
3413
3413
|
keyword: [
|
|
3414
3414
|
"synchronized",
|
|
3415
3415
|
"abstract",
|
|
@@ -4538,8 +4538,8 @@ function nr(e) {
|
|
|
4538
4538
|
exceptions: m,
|
|
4539
4539
|
when: T
|
|
4540
4540
|
} = {}) {
|
|
4541
|
-
const
|
|
4542
|
-
return m = m || [], w.map((N) => N.match(/\|\d+$/) || m.includes(N) ? N :
|
|
4541
|
+
const S = T;
|
|
4542
|
+
return m = m || [], w.map((N) => N.match(/\|\d+$/) || m.includes(N) ? N : S(N) ? `${N}|0` : N);
|
|
4543
4543
|
}
|
|
4544
4544
|
return {
|
|
4545
4545
|
name: "SQL",
|
|
@@ -4588,11 +4588,11 @@ Y.registerLanguage("python", qt);
|
|
|
4588
4588
|
Y.registerLanguage("java", Jt);
|
|
4589
4589
|
Y.registerLanguage("bash", er);
|
|
4590
4590
|
Y.registerLanguage("sql", nr);
|
|
4591
|
-
var
|
|
4592
|
-
const j = "<code-diff-modified>", q = "</code-diff-modified>", tr = j.replace("<", "<").replace(">", ">"), rr = q.replace("<", "<").replace(">", ">"), le = (e) => e === void 0 ?
|
|
4593
|
-
(h) => le(h) ===
|
|
4591
|
+
var D = /* @__PURE__ */ ((e) => (e.EQUAL = "equal", e.DELETE = "removed", e.ADD = "added", e.EMPTY = "empty", e))(D || {});
|
|
4592
|
+
const j = "<code-diff-modified>", q = "</code-diff-modified>", tr = j.replace("<", "<").replace(">", ">"), rr = q.replace("<", "<").replace(">", ">"), le = (e) => e === void 0 ? D.EQUAL : e.added ? D.ADD : e.removed ? D.DELETE : D.EQUAL, De = (e, n, a = "word") => typeof e > "u" ? n : typeof n > "u" ? e : (a === "char" ? zn : Kn)(e, n).filter((h) => le(h) !== D.DELETE).map(
|
|
4593
|
+
(h) => le(h) === D.ADD ? `${j}${h.value}${q}` : h.value
|
|
4594
4594
|
).join("");
|
|
4595
|
-
function
|
|
4595
|
+
function Dn(e, n) {
|
|
4596
4596
|
const a = new ce.diff_match_patch(), u = a.diff_linesToChars_(e, n), h = u.chars1, t = u.chars2, r = u.lineArray, i = a.diff_main(h, t, !1);
|
|
4597
4597
|
return a.diff_charsToLines_(i, r), i.map((s) => {
|
|
4598
4598
|
const [o, l] = s;
|
|
@@ -4647,7 +4647,7 @@ function Rn(e) {
|
|
|
4647
4647
|
}
|
|
4648
4648
|
function ir(e, n, a = "plaintext", u = "word", h = 10) {
|
|
4649
4649
|
var p;
|
|
4650
|
-
const t = () => ({ type:
|
|
4650
|
+
const t = () => ({ type: D.EMPTY }), r = (d, _, v) => ({ type: d, num: _, code: v }), i = Dn(e, n);
|
|
4651
4651
|
let s = 0, o = 0, l = !1;
|
|
4652
4652
|
const c = [], f = {
|
|
4653
4653
|
changes: c,
|
|
@@ -4661,46 +4661,46 @@ function ir(e, n, a = "plaintext", u = "word", h = 10) {
|
|
|
4661
4661
|
const [_, v] = [i[d], i[d + 1]], [E, w] = [le(_), le(v)], m = _.value.replace(/\n$/, "").split(`
|
|
4662
4662
|
`);
|
|
4663
4663
|
if (v === void 0) {
|
|
4664
|
-
for (const
|
|
4664
|
+
for (const S of m) {
|
|
4665
4665
|
let N = t(), I = t();
|
|
4666
|
-
const R = Z(a,
|
|
4667
|
-
E ===
|
|
4666
|
+
const R = Z(a, S);
|
|
4667
|
+
E === D.EQUAL && (s++, o++, N = r(D.EQUAL, s, R), I = r(D.EQUAL, o, R)), E === D.DELETE && (s++, N = r(D.DELETE, s, R), I = t()), E === D.ADD && (o++, N = t(), I = r(D.ADD, o, R)), c.push({ left: N, right: I });
|
|
4668
4668
|
}
|
|
4669
4669
|
break;
|
|
4670
4670
|
}
|
|
4671
|
-
if (E ===
|
|
4672
|
-
for (const
|
|
4671
|
+
if (E === D.EQUAL)
|
|
4672
|
+
for (const S of m) {
|
|
4673
4673
|
s++, o++;
|
|
4674
|
-
const N = Z(a,
|
|
4674
|
+
const N = Z(a, S);
|
|
4675
4675
|
c.push({
|
|
4676
|
-
left: r(
|
|
4677
|
-
right: r(
|
|
4676
|
+
left: r(D.EQUAL, s, N),
|
|
4677
|
+
right: r(D.EQUAL, o, N)
|
|
4678
4678
|
});
|
|
4679
4679
|
}
|
|
4680
4680
|
const T = v.value.replace(/\n$/, "").split(`
|
|
4681
4681
|
`);
|
|
4682
|
-
if (E ===
|
|
4683
|
-
if (w ===
|
|
4684
|
-
for (const
|
|
4682
|
+
if (E === D.DELETE) {
|
|
4683
|
+
if (w === D.EQUAL)
|
|
4684
|
+
for (const S of m)
|
|
4685
4685
|
s++, c.push({
|
|
4686
|
-
left: r(
|
|
4686
|
+
left: r(D.DELETE, s, Z(a, S)),
|
|
4687
4687
|
right: t()
|
|
4688
4688
|
});
|
|
4689
|
-
if (w ===
|
|
4689
|
+
if (w === D.ADD) {
|
|
4690
4690
|
l = !0;
|
|
4691
|
-
const
|
|
4692
|
-
for (let N = 0; N <
|
|
4691
|
+
const S = Math.max(_.count, v.count);
|
|
4692
|
+
for (let N = 0; N < S; N++) {
|
|
4693
4693
|
N < _.count && s++, N < v.count && o++;
|
|
4694
|
-
const [I, R] = [m[N], T[N]], F = m.length === T.length ?
|
|
4694
|
+
const [I, R] = [m[N], T[N]], F = m.length === T.length ? De(R, I, u) : I, U = m.length === T.length ? De(I, R, u) : R, $ = N < _.count ? r(D.DELETE, s, Z(a, F)) : t(), H = N < v.count ? r(D.ADD, o, Z(a, U)) : t();
|
|
4695
4695
|
c.push({ left: $, right: H });
|
|
4696
4696
|
}
|
|
4697
4697
|
}
|
|
4698
4698
|
}
|
|
4699
|
-
if (E ===
|
|
4700
|
-
for (const
|
|
4699
|
+
if (E === D.ADD)
|
|
4700
|
+
for (const S of m)
|
|
4701
4701
|
o++, c.push({
|
|
4702
4702
|
left: t(),
|
|
4703
|
-
right: r(
|
|
4703
|
+
right: r(D.ADD, o, Z(a, S))
|
|
4704
4704
|
});
|
|
4705
4705
|
}
|
|
4706
4706
|
if (e === n) {
|
|
@@ -4710,7 +4710,7 @@ function ir(e, n, a = "plaintext", u = "word", h = 10) {
|
|
|
4710
4710
|
}
|
|
4711
4711
|
for (let d = 0; d < c.length; d++) {
|
|
4712
4712
|
const _ = c[d];
|
|
4713
|
-
if (_.left.type ===
|
|
4713
|
+
if (_.left.type === D.DELETE || _.right.type === D.ADD) {
|
|
4714
4714
|
const [v, E] = [Math.max(d - h, 0), Math.min(d + h + 1, c.length)];
|
|
4715
4715
|
for (let w = v; w < E; w++)
|
|
4716
4716
|
c[w].fold = !1;
|
|
@@ -4730,7 +4730,7 @@ function ir(e, n, a = "plaintext", u = "word", h = 10) {
|
|
|
4730
4730
|
}
|
|
4731
4731
|
function sr(e, n, a = "plaintext", u = "word", h = 10) {
|
|
4732
4732
|
var f;
|
|
4733
|
-
const t =
|
|
4733
|
+
const t = Dn(e, n);
|
|
4734
4734
|
let r = 0, i = 0, s = !1;
|
|
4735
4735
|
const o = [], l = {
|
|
4736
4736
|
changes: o,
|
|
@@ -4745,56 +4745,56 @@ function sr(e, n, a = "plaintext", u = "word", h = 10) {
|
|
|
4745
4745
|
`);
|
|
4746
4746
|
if (d === void 0) {
|
|
4747
4747
|
for (const m of E) {
|
|
4748
|
-
_ ===
|
|
4748
|
+
_ === D.EQUAL && (r++, i++), _ === D.DELETE && r++, _ === D.ADD && i++;
|
|
4749
4749
|
const T = Z(a, m);
|
|
4750
4750
|
o.push({
|
|
4751
4751
|
type: _,
|
|
4752
4752
|
code: T,
|
|
4753
|
-
addNum: _ ===
|
|
4754
|
-
delNum: _ ===
|
|
4753
|
+
addNum: _ === D.DELETE ? void 0 : i,
|
|
4754
|
+
delNum: _ === D.ADD ? void 0 : r
|
|
4755
4755
|
});
|
|
4756
4756
|
}
|
|
4757
4757
|
break;
|
|
4758
4758
|
}
|
|
4759
|
-
if (_ ===
|
|
4759
|
+
if (_ === D.EQUAL)
|
|
4760
4760
|
for (const m of E) {
|
|
4761
4761
|
r++, i++;
|
|
4762
4762
|
const T = Z(a, m);
|
|
4763
|
-
o.push({ type:
|
|
4763
|
+
o.push({ type: D.EQUAL, code: T, delNum: r, addNum: i });
|
|
4764
4764
|
}
|
|
4765
4765
|
const w = d.value.replace(/\n$/, "").split(`
|
|
4766
4766
|
`);
|
|
4767
|
-
if (_ ===
|
|
4768
|
-
if (v ===
|
|
4767
|
+
if (_ === D.DELETE)
|
|
4768
|
+
if (v === D.ADD && E.length === w.length) {
|
|
4769
4769
|
for (let m = 0; m < E.length; m++) {
|
|
4770
|
-
const T = E[m],
|
|
4770
|
+
const T = E[m], S = w[m];
|
|
4771
4771
|
r++;
|
|
4772
|
-
const N = Z(a,
|
|
4773
|
-
o.push({ type:
|
|
4772
|
+
const N = Z(a, De(S, T, u));
|
|
4773
|
+
o.push({ type: D.DELETE, code: N, delNum: r });
|
|
4774
4774
|
}
|
|
4775
4775
|
for (let m = 0; m < w.length; m++) {
|
|
4776
|
-
const T = E[m],
|
|
4776
|
+
const T = E[m], S = w[m];
|
|
4777
4777
|
i++;
|
|
4778
|
-
const N = Z(a,
|
|
4779
|
-
o.push({ type:
|
|
4778
|
+
const N = Z(a, De(T, S, u));
|
|
4779
|
+
o.push({ type: D.ADD, code: N, addNum: i });
|
|
4780
4780
|
}
|
|
4781
4781
|
s = !0;
|
|
4782
4782
|
} else
|
|
4783
4783
|
for (const m of E) {
|
|
4784
4784
|
r++;
|
|
4785
4785
|
const T = Z(a, m);
|
|
4786
|
-
o.push({ type:
|
|
4786
|
+
o.push({ type: D.DELETE, code: T, delNum: r });
|
|
4787
4787
|
}
|
|
4788
|
-
if (_ ===
|
|
4788
|
+
if (_ === D.ADD)
|
|
4789
4789
|
for (const m of E) {
|
|
4790
4790
|
i++;
|
|
4791
4791
|
const T = Z(a, m);
|
|
4792
|
-
o.push({ type:
|
|
4792
|
+
o.push({ type: D.ADD, code: T, addNum: i });
|
|
4793
4793
|
}
|
|
4794
4794
|
}
|
|
4795
4795
|
for (let g = 0; g < o.length; g++) {
|
|
4796
4796
|
const p = o[g];
|
|
4797
|
-
if (p.type ===
|
|
4797
|
+
if (p.type === D.DELETE || p.type === D.ADD) {
|
|
4798
4798
|
const [d, _] = [Math.max(g - h, 0), Math.min(g + h + 1, o.length)];
|
|
4799
4799
|
for (let v = d; v < _; v++)
|
|
4800
4800
|
o[v].fold = !1;
|
|
@@ -4826,8 +4826,8 @@ Ke.props = {
|
|
|
4826
4826
|
}
|
|
4827
4827
|
};
|
|
4828
4828
|
Ke.setup = (e, n) => ({
|
|
4829
|
-
DiffType:
|
|
4830
|
-
getCodeMarker: (u) => u ===
|
|
4829
|
+
DiffType: D,
|
|
4830
|
+
getCodeMarker: (u) => u === D.DELETE ? "-" : u === D.ADD ? "+" : ""
|
|
4831
4831
|
});
|
|
4832
4832
|
var ar = function() {
|
|
4833
4833
|
var e = this, n = e.$createElement, a = e._self._c || n;
|
|
@@ -4922,7 +4922,7 @@ de.props = {
|
|
|
4922
4922
|
diffChange: {
|
|
4923
4923
|
key: "diffChange",
|
|
4924
4924
|
required: !0,
|
|
4925
|
-
type:
|
|
4925
|
+
type: Array
|
|
4926
4926
|
}
|
|
4927
4927
|
};
|
|
4928
4928
|
de.setup = (e, n) => ({});
|
|
@@ -4968,8 +4968,8 @@ We.props = {
|
|
|
4968
4968
|
}
|
|
4969
4969
|
};
|
|
4970
4970
|
We.setup = (e, n) => ({
|
|
4971
|
-
DiffType:
|
|
4972
|
-
getCodeMarker: (u) => u ===
|
|
4971
|
+
DiffType: D,
|
|
4972
|
+
getCodeMarker: (u) => u === D.DELETE ? "-" : u === D.ADD ? "+" : ""
|
|
4973
4973
|
});
|
|
4974
4974
|
var _r = function() {
|
|
4975
4975
|
var e = this, n = e.$createElement, a = e._self._c || n;
|
|
@@ -5136,7 +5136,7 @@ _e.props = {
|
|
|
5136
5136
|
maxHeight: {
|
|
5137
5137
|
key: "maxHeight",
|
|
5138
5138
|
required: !1,
|
|
5139
|
-
type:
|
|
5139
|
+
type: String,
|
|
5140
5140
|
default: void 0
|
|
5141
5141
|
},
|
|
5142
5142
|
filename: {
|
|
@@ -5196,12 +5196,12 @@ var Tr = function() {
|
|
|
5196
5196
|
"diff-change": e.diffChange.changes
|
|
5197
5197
|
}
|
|
5198
5198
|
})], 1);
|
|
5199
|
-
},
|
|
5199
|
+
}, Sr = [];
|
|
5200
5200
|
const gn = {};
|
|
5201
|
-
var
|
|
5201
|
+
var Dr = /* @__PURE__ */ be(
|
|
5202
5202
|
_e,
|
|
5203
5203
|
Tr,
|
|
5204
|
-
|
|
5204
|
+
Sr,
|
|
5205
5205
|
!1,
|
|
5206
5206
|
Rr,
|
|
5207
5207
|
null,
|
|
@@ -5213,7 +5213,7 @@ function Rr(e) {
|
|
|
5213
5213
|
this[n] = gn[n];
|
|
5214
5214
|
}
|
|
5215
5215
|
const Or = /* @__PURE__ */ function() {
|
|
5216
|
-
return
|
|
5216
|
+
return Dr.exports;
|
|
5217
5217
|
}(), Cr = (e) => {
|
|
5218
5218
|
e.component("CodeDiff", Or);
|
|
5219
5219
|
}, kr = {
|
package/dist/v2.7/index.cjs.js
CHANGED
|
@@ -11,6 +11,6 @@ https://github.com/highlightjs/highlight.js/issues/2277`),x=b,k=M),O===void 0&&(
|
|
|
11
11
|
`);if(v===void 0){for(const D of m){let N=t(),I=t();const R=V(o,D);E===S.EQUAL&&(s++,a++,N=r(S.EQUAL,s,R),I=r(S.EQUAL,a,R)),E===S.DELETE&&(s++,N=r(S.DELETE,s,R),I=t()),E===S.ADD&&(a++,N=t(),I=r(S.ADD,a,R)),c.push({left:N,right:I})}break}if(E===S.EQUAL)for(const D of m){s++,a++;const N=V(o,D);c.push({left:r(S.EQUAL,s,N),right:r(S.EQUAL,a,N)})}const T=v.value.replace(/\n$/,"").split(`
|
|
12
12
|
`);if(E===S.DELETE){if(w===S.EQUAL)for(const D of m)s++,c.push({left:r(S.DELETE,s,V(o,D)),right:t()});if(w===S.ADD){l=!0;const D=Math.max(p.count,v.count);for(let N=0;N<D;N++){N<p.count&&s++,N<v.count&&a++;const[I,R]=[m[N],T[N]],F=m.length===T.length?Ae(R,I,u):I,U=m.length===T.length?Ae(I,R,u):R,$=N<p.count?r(S.DELETE,s,V(o,F)):t(),H=N<v.count?r(S.ADD,a,V(o,U)):t();c.push({left:$,right:H})}}}if(E===S.ADD)for(const D of m)a++,c.push({left:t(),right:r(S.ADD,a,V(o,D))})}if(n===e){for(let d=0;d<c.length;d++)c[d].fold=!1;return f}for(let d=0;d<c.length;d++){const p=c[d];if(p.left.type===S.DELETE||p.right.type===S.ADD){const[v,E]=[Math.max(d-h,0),Math.min(d+h+1,c.length)];for(let w=v;w<E;w++)c[w].fold=!1}p.fold===void 0&&(p.fold=!0)}const g=[];for(let d=0;d<c.length;d++){const p=c[d];if(p.fold===!1){g.push(p);continue}p.fold===!0&&((_=g[g.length-1])==null?void 0:_.fold)!==!0&&g.push(p)}return f.changes=g,f}function Vt(n,e,o="plaintext",u="word",h=10){var f;const t=bn(n,e);let r=0,i=0,s=!1;const a=[],l={changes:a,stat:vn(t)};for(let g=0;g<t.length;g++){if(s){s=!1;continue}const[_,d]=[t[g],t[g+1]],[p,v]=[ce(_),ce(d)],E=_.value.replace(/\n$/,"").split(`
|
|
13
13
|
`);if(d===void 0){for(const m of E){p===S.EQUAL&&(r++,i++),p===S.DELETE&&r++,p===S.ADD&&i++;const T=V(o,m);a.push({type:p,code:T,addNum:p===S.DELETE?void 0:i,delNum:p===S.ADD?void 0:r})}break}if(p===S.EQUAL)for(const m of E){r++,i++;const T=V(o,m);a.push({type:S.EQUAL,code:T,delNum:r,addNum:i})}const w=d.value.replace(/\n$/,"").split(`
|
|
14
|
-
`);if(p===S.DELETE)if(v===S.ADD&&E.length===w.length){for(let m=0;m<E.length;m++){const T=E[m],D=w[m];r++;const N=V(o,Ae(D,T,u));a.push({type:S.DELETE,code:N,delNum:r})}for(let m=0;m<w.length;m++){const T=E[m],D=w[m];i++;const N=V(o,Ae(T,D,u));a.push({type:S.ADD,code:N,addNum:i})}s=!0}else for(const m of E){r++;const T=V(o,m);a.push({type:S.DELETE,code:T,delNum:r})}if(p===S.ADD)for(const m of E){i++;const T=V(o,m);a.push({type:S.ADD,code:T,addNum:i})}}for(let g=0;g<a.length;g++){const _=a[g];if(_.type===S.DELETE||_.type===S.ADD){const[d,p]=[Math.max(g-h,0),Math.min(g+h+1,a.length)];for(let v=d;v<p;v++)a[v].fold=!1}_.fold===void 0&&(_.fold=!0)}if(n===e){for(let g=0;g<a.length;g++)a[g].fold=!1;return l}const c=[];for(let g=0;g<a.length;g++){const _=a[g];if(_.fold===!1){c.push(_);continue}_.fold===!0&&(g===0||((f=c[c.length-1])==null?void 0:f.fold)!==!0)&&c.push(_)}return l.changes=c,l}const Zt=X.defineComponent({__name:"UnifiedLine",props:{line:null},setup(n){return{__sfc:!0,props:n,getCodeMarker:u=>u===S.DELETE?"-":u===S.ADD?"+":"",DiffType:S}}});function _e(n,e,o,u,h,t,r,i){var s=typeof n=="function"?n.options:n;e&&(s.render=e,s.staticRenderFns=o,s._compiled=!0),u&&(s.functional=!0),t&&(s._scopeId="data-v-"+t);var a;if(r?(a=function(f){f=f||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!f&&typeof __VUE_SSR_CONTEXT__<"u"&&(f=__VUE_SSR_CONTEXT__),h&&h.call(this,f),f&&f._registeredComponents&&f._registeredComponents.add(r)},s._ssrRegister=a):h&&(a=i?function(){h.call(this,(s.functional?this.parent:this).$root.$options.shadowRoot)}:h),a)if(s.functional){s._injectStyles=a;var l=s.render;s.render=function(g,_){return a.call(_),l(g,_)}}else{var c=s.beforeCreate;s.beforeCreate=c?[].concat(c,a):[a]}return{exports:n,options:s}}var Yt=function(){var e=this,o=e._self._c,u=e._self._setupProxy;return e.line.fold?o("tr",[o("td",{staticClass:"blob-num blob-num-hunk"},[e._v(" > ")]),o("td",{staticClass:"blob-num blob-num-hunk"},[e._v(" > ")]),o("td",{staticClass:"blob-code blob-code-hunk",attrs:{align:"left"}},[e._v(" ⋯ ")])]):o("tr",[o("td",{staticClass:"blob-num",class:{"blob-num-deletion":e.line.type===u.DiffType.DELETE,"blob-num-addition":e.line.type===u.DiffType.ADD,"blob-num-context":e.line.type===u.DiffType.EQUAL}},[e._v(" "+e._s(e.line.delNum)+" ")]),o("td",{staticClass:"blob-num",class:{"blob-num-deletion":e.line.type===u.DiffType.DELETE,"blob-num-addition":e.line.type===u.DiffType.ADD,"blob-num-context":e.line.type===u.DiffType.EQUAL}},[e._v(" "+e._s(e.line.addNum)+" ")]),o("td",{staticClass:"blob-code",class:{"blob-code-deletion":e.line.type===u.DiffType.DELETE,"blob-code-addition":e.line.type===u.DiffType.ADD,"blob-code-context":e.line.type===u.DiffType.EQUAL}},[o("span",{staticClass:"blob-code-inner blob-code-marker",attrs:{"data-code-marker":u.getCodeMarker(e.line.type)},domProps:{innerHTML:e._s(e.line.code)}})])])},Xt=[],jt=_e(Zt,Yt,Xt,!1,null,null,null,null);const Jt=jt.exports,qt=X.defineComponent({__name:"UnifiedViewer",props:{diffChange:null},setup(n){return{__sfc:!0,props:n,UnifiedLine:Jt}}});var er=function(){var e=this,o=e._self._c,u=e._self._setupProxy;return o("table",{staticClass:"diff-table"},[o("tbody",e._l(e.diffChange,function(h,t){return o(u.UnifiedLine,{key:t,attrs:{line:h}})}),1)])},nr=[],tr=_e(qt,er,nr,!1,null,"
|
|
14
|
+
`);if(p===S.DELETE)if(v===S.ADD&&E.length===w.length){for(let m=0;m<E.length;m++){const T=E[m],D=w[m];r++;const N=V(o,Ae(D,T,u));a.push({type:S.DELETE,code:N,delNum:r})}for(let m=0;m<w.length;m++){const T=E[m],D=w[m];i++;const N=V(o,Ae(T,D,u));a.push({type:S.ADD,code:N,addNum:i})}s=!0}else for(const m of E){r++;const T=V(o,m);a.push({type:S.DELETE,code:T,delNum:r})}if(p===S.ADD)for(const m of E){i++;const T=V(o,m);a.push({type:S.ADD,code:T,addNum:i})}}for(let g=0;g<a.length;g++){const _=a[g];if(_.type===S.DELETE||_.type===S.ADD){const[d,p]=[Math.max(g-h,0),Math.min(g+h+1,a.length)];for(let v=d;v<p;v++)a[v].fold=!1}_.fold===void 0&&(_.fold=!0)}if(n===e){for(let g=0;g<a.length;g++)a[g].fold=!1;return l}const c=[];for(let g=0;g<a.length;g++){const _=a[g];if(_.fold===!1){c.push(_);continue}_.fold===!0&&(g===0||((f=c[c.length-1])==null?void 0:f.fold)!==!0)&&c.push(_)}return l.changes=c,l}const Zt=X.defineComponent({__name:"UnifiedLine",props:{line:null},setup(n){return{__sfc:!0,props:n,getCodeMarker:u=>u===S.DELETE?"-":u===S.ADD?"+":"",DiffType:S}}});function _e(n,e,o,u,h,t,r,i){var s=typeof n=="function"?n.options:n;e&&(s.render=e,s.staticRenderFns=o,s._compiled=!0),u&&(s.functional=!0),t&&(s._scopeId="data-v-"+t);var a;if(r?(a=function(f){f=f||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!f&&typeof __VUE_SSR_CONTEXT__<"u"&&(f=__VUE_SSR_CONTEXT__),h&&h.call(this,f),f&&f._registeredComponents&&f._registeredComponents.add(r)},s._ssrRegister=a):h&&(a=i?function(){h.call(this,(s.functional?this.parent:this).$root.$options.shadowRoot)}:h),a)if(s.functional){s._injectStyles=a;var l=s.render;s.render=function(g,_){return a.call(_),l(g,_)}}else{var c=s.beforeCreate;s.beforeCreate=c?[].concat(c,a):[a]}return{exports:n,options:s}}var Yt=function(){var e=this,o=e._self._c,u=e._self._setupProxy;return e.line.fold?o("tr",[o("td",{staticClass:"blob-num blob-num-hunk"},[e._v(" > ")]),o("td",{staticClass:"blob-num blob-num-hunk"},[e._v(" > ")]),o("td",{staticClass:"blob-code blob-code-hunk",attrs:{align:"left"}},[e._v(" ⋯ ")])]):o("tr",[o("td",{staticClass:"blob-num",class:{"blob-num-deletion":e.line.type===u.DiffType.DELETE,"blob-num-addition":e.line.type===u.DiffType.ADD,"blob-num-context":e.line.type===u.DiffType.EQUAL}},[e._v(" "+e._s(e.line.delNum)+" ")]),o("td",{staticClass:"blob-num",class:{"blob-num-deletion":e.line.type===u.DiffType.DELETE,"blob-num-addition":e.line.type===u.DiffType.ADD,"blob-num-context":e.line.type===u.DiffType.EQUAL}},[e._v(" "+e._s(e.line.addNum)+" ")]),o("td",{staticClass:"blob-code",class:{"blob-code-deletion":e.line.type===u.DiffType.DELETE,"blob-code-addition":e.line.type===u.DiffType.ADD,"blob-code-context":e.line.type===u.DiffType.EQUAL}},[o("span",{staticClass:"blob-code-inner blob-code-marker",attrs:{"data-code-marker":u.getCodeMarker(e.line.type)},domProps:{innerHTML:e._s(e.line.code)}})])])},Xt=[],jt=_e(Zt,Yt,Xt,!1,null,null,null,null);const Jt=jt.exports,qt=X.defineComponent({__name:"UnifiedViewer",props:{diffChange:null},setup(n){return{__sfc:!0,props:n,UnifiedLine:Jt}}});var er=function(){var e=this,o=e._self._c,u=e._self._setupProxy;return o("table",{staticClass:"diff-table"},[o("tbody",e._l(e.diffChange,function(h,t){return o(u.UnifiedLine,{key:t,attrs:{line:h}})}),1)])},nr=[],tr=_e(qt,er,nr,!1,null,"64611e2c",null,null);const rr=tr.exports,ir=X.defineComponent({__name:"SplitLine",props:{splitLine:null},setup(n){return{__sfc:!0,props:n,getCodeMarker:u=>u===S.DELETE?"-":u===S.ADD?"+":"",DiffType:S}}});var sr=function(){var e=this,o=e._self._c,u=e._self._setupProxy;return e.splitLine.fold?o("tr",[o("td",{staticClass:"blob-num blob-num-hunk",attrs:{colspan:"1"}},[e._v(" > ")]),o("td",{staticClass:"blob-code blob-code-inner blob-code-hunk",attrs:{colspan:"3",align:"left"}},[e._v(" ⋯ ")])]):o("tr",[e._l([e.splitLine.left,e.splitLine.right],function(h){return[h.type===u.DiffType.EMPTY?[o("td",{staticClass:"blob-num blob-num-empty empty-cell"}),o("td",{staticClass:"blob-code blob-code-empty empty-cell"})]:[o("td",{staticClass:"blob-num",class:{"blob-num-deletion":h.type===u.DiffType.DELETE,"blob-num-addition":h.type===u.DiffType.ADD,"blob-num-context":h.type===u.DiffType.EQUAL}},[e._v(" "+e._s(h.num)+" ")]),o("td",{staticClass:"blob-code",class:{"blob-code-deletion":h.type===u.DiffType.DELETE,"blob-code-addition":h.type===u.DiffType.ADD,"blob-code-context":h.type===u.DiffType.EQUAL}},[o("span",{staticClass:"blob-code-inner blob-code-marker",attrs:{"data-code-marker":u.getCodeMarker(h.type)},domProps:{innerHTML:e._s(h.code)}})])]]})],2)},ar=[],or=_e(ir,sr,ar,!1,null,null,null,null);const lr=or.exports,cr=X.defineComponent({__name:"SplitViewer",props:{diffChange:null},setup(n){return{__sfc:!0,props:n,SplitLine:lr}}});var ur=function(){var e=this,o=e._self._c,u=e._self._setupProxy;return o("table",{staticClass:"file-diff-split diff-table"},[e._m(0),o("tbody",e._l(e.diffChange,function(h,t){return o(u.SplitLine,{key:t,attrs:{"split-line":h}})}),1)])},fr=[function(){var n=this,e=n._self._c;return n._self._setupProxy,e("colgroup",[e("col",{attrs:{width:"44"}}),e("col"),e("col",{attrs:{width:"44"}}),e("col")])}],gr=_e(cr,ur,fr,!1,null,"0c23c064",null,null);const hr=gr.exports;const dr=X.defineComponent({__name:"CodeDiff",props:{newString:null,oldString:null,language:{default:"plaintext"},context:{default:10},diffStyle:{default:"word"},outputFormat:{default:"line-by-line"},trim:{type:Boolean,default:!1},noDiffLineFeed:{type:Boolean,default:!1},maxHeight:{default:void 0},filename:{default:void 0}},setup(n){const e=n,o=X.computed(()=>e.outputFormat==="line-by-line"),u=X.computed(()=>{const r=e.trim?e.oldString.trim():e.oldString;return e.noDiffLineFeed?r.replace(/(\r\n)/g,`
|
|
15
15
|
`):r}),h=X.computed(()=>{const r=e.trim?e.newString.trim():e.newString;return e.noDiffLineFeed?r.replace(/(\r\n)/g,`
|
|
16
16
|
`):r}),t=X.computed(()=>o.value?Vt(u.value,h.value,e.language,e.diffStyle,e.context):Qt(u.value,h.value,e.language,e.diffStyle,e.context));return{__sfc:!0,props:e,isUnifiedViewer:o,oldString:u,newString:h,diffChange:t,UnifiedViewer:rr,SplitViewer:hr}}});var _r=function(){var e=this,o=e._self._c,u=e._self._setupProxy;return o("div",{staticClass:"code-diff-view",style:{maxHeight:e.maxHeight}},[o("div",{staticClass:"file-header"},[o("div",{staticClass:"file-info"},[o("span",{staticClass:"filename"},[e._v(e._s(e.filename))]),o("span",{staticClass:"diff-stat"},[o("span",{staticClass:"diff-stat-added"},[e._v("+"+e._s(u.diffChange.stat.additionsNum)+" additions")]),o("span",{staticClass:"diff-stat-deleted",staticStyle:{"margin-left":"8px"}},[e._v("-"+e._s(u.diffChange.stat.deletionsNum)+" deletions")])])])]),u.isUnifiedViewer?o(u.UnifiedViewer,{attrs:{"diff-change":u.diffChange.changes}}):o(u.SplitViewer,{attrs:{"diff-change":u.diffChange.changes}})],1)},pr=[],br=_e(dr,_r,pr,!1,null,null,null,null);const En=br.exports,vr=n=>{n.component("CodeDiff",En)},Er={install:vr,hljs:Z};exports.CodeDiff=En;exports.default=Er;
|
package/dist/v2.7/index.es.js
CHANGED
package/package.json
CHANGED
package/src/CodeDiff.vue
CHANGED
package/src/split/SplitLine.vue
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { DiffType } from '../types'
|
|
3
|
-
import type {
|
|
3
|
+
import type { SplitLineChange } from '../types'
|
|
4
4
|
|
|
5
5
|
const props = defineProps<{
|
|
6
|
-
splitLine:
|
|
6
|
+
splitLine: SplitLineChange
|
|
7
7
|
}>()
|
|
8
8
|
|
|
9
9
|
const getCodeMarker = (type: DiffType) => {
|
package/src/types.ts
CHANGED
|
@@ -11,13 +11,13 @@ export interface DiffLine {
|
|
|
11
11
|
num?: number
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export interface
|
|
14
|
+
export interface SplitLineChange {
|
|
15
15
|
fold?: boolean
|
|
16
16
|
left: DiffLine
|
|
17
17
|
right: DiffLine
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export interface
|
|
20
|
+
export interface UnifiedLineChange {
|
|
21
21
|
fold?: boolean
|
|
22
22
|
type: DiffType
|
|
23
23
|
code: string
|
|
@@ -30,11 +30,11 @@ export interface DiffStat {
|
|
|
30
30
|
deletionsNum: number
|
|
31
31
|
}
|
|
32
32
|
export interface SplitViewerChange {
|
|
33
|
-
changes:
|
|
33
|
+
changes: SplitLineChange[]
|
|
34
34
|
stat: DiffStat
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export interface UnifiedViewerChange {
|
|
38
|
-
changes:
|
|
38
|
+
changes: UnifiedLineChange[]
|
|
39
39
|
stat: DiffStat
|
|
40
40
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import type {
|
|
2
|
+
import type { UnifiedLineChange } from '../types'
|
|
3
3
|
import { DiffType } from '../types'
|
|
4
4
|
|
|
5
5
|
const props = defineProps<{
|
|
6
|
-
line:
|
|
6
|
+
line: UnifiedLineChange
|
|
7
7
|
}>()
|
|
8
8
|
|
|
9
9
|
const getCodeMarker = (type: DiffType) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { UnifiedLineChange } from '../types'
|
|
3
3
|
import UnifiedLine from './UnifiedLine.vue'
|
|
4
4
|
|
|
5
5
|
const props = defineProps<{
|
|
6
|
-
diffChange:
|
|
6
|
+
diffChange: UnifiedLineChange[]
|
|
7
7
|
}>()
|
|
8
8
|
</script>
|
|
9
9
|
|
package/src/utils.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Change } from 'diff'
|
|
|
3
3
|
import { DIFF_DELETE, DIFF_INSERT, diff_match_patch as DiffMatchPatch } from 'diff-match-patch'
|
|
4
4
|
import hljs from './highlight'
|
|
5
5
|
import { DiffType } from './types'
|
|
6
|
-
import type { DiffLine, DiffStat,
|
|
6
|
+
import type { DiffLine, DiffStat, SplitLineChange, SplitViewerChange, UnifiedLineChange, UnifiedViewerChange } from './types'
|
|
7
7
|
|
|
8
8
|
const MODIFIED_START_TAG = '<code-diff-modified>'
|
|
9
9
|
const MODIFIED_CLOSE_TAG = '</code-diff-modified>'
|
|
@@ -165,7 +165,7 @@ export function createSplitDiff(
|
|
|
165
165
|
let addNum = 0
|
|
166
166
|
let skip = false
|
|
167
167
|
|
|
168
|
-
const rawChanges:
|
|
168
|
+
const rawChanges: SplitLineChange[] = []
|
|
169
169
|
const result: SplitViewerChange = {
|
|
170
170
|
changes: rawChanges,
|
|
171
171
|
stat: calcDiffStat(changes),
|
|
@@ -330,7 +330,7 @@ export function createUnifiedDiff(
|
|
|
330
330
|
let addNum = 0
|
|
331
331
|
let skip = false
|
|
332
332
|
|
|
333
|
-
const rawChanges:
|
|
333
|
+
const rawChanges: UnifiedLineChange[] = []
|
|
334
334
|
const result: UnifiedViewerChange = {
|
|
335
335
|
changes: rawChanges,
|
|
336
336
|
stat: calcDiffStat(changes),
|