antosdk-apps/AceDiff/ace-diff.min.js

32 lines
35 KiB
JavaScript
Raw Normal View History

parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"k8CM":[function(require,module,exports) {
var t=function(){this.Diff_Timeout=1,this.Diff_EditCost=4,this.Match_Threshold=.5,this.Match_Distance=1e3,this.Patch_DeleteThreshold=.5,this.Patch_Margin=4,this.Match_MaxBits=32},e=-1,n=1,i=0;t.Diff=function(t,e){return[t,e]},t.prototype.diff_main=function(e,n,r,h){void 0===h&&(h=this.Diff_Timeout<=0?Number.MAX_VALUE:(new Date).getTime()+1e3*this.Diff_Timeout);var s=h;if(null==e||null==n)throw new Error("Null input. (diff_main)");if(e==n)return e?[new t.Diff(i,e)]:[];void 0===r&&(r=!0);var f=r,a=this.diff_commonPrefix(e,n),l=e.substring(0,a);e=e.substring(a),n=n.substring(a),a=this.diff_commonSuffix(e,n);var g=e.substring(e.length-a);e=e.substring(0,e.length-a),n=n.substring(0,n.length-a);var o=this.diff_compute_(e,n,f,s);return l&&o.unshift(new t.Diff(i,l)),g&&o.push(new t.Diff(i,g)),this.diff_cleanupMerge(o),o},t.prototype.diff_compute_=function(r,h,s,f){var a;if(!r)return[new t.Diff(n,h)];if(!h)return[new t.Diff(e,r)];var l=r.length>h.length?r:h,g=r.length>h.length?h:r,o=l.indexOf(g);if(-1!=o)return a=[new t.Diff(n,l.substring(0,o)),new t.Diff(i,g),new t.Diff(n,l.substring(o+g.length))],r.length>h.length&&(a[0][0]=a[2][0]=e),a;if(1==g.length)return[new t.Diff(e,r),new t.Diff(n,h)];var c=this.diff_halfMatch_(r,h);if(c){var u=c[0],p=c[1],d=c[2],_=c[3],b=c[4],v=this.diff_main(u,d,s,f),m=this.diff_main(p,_,s,f);return v.concat([new t.Diff(i,b)],m)}return s&&r.length>100&&h.length>100?this.diff_lineMode_(r,h,f):this.diff_bisect_(r,h,f)},t.prototype.diff_lineMode_=function(r,h,s){var f=this.diff_linesToChars_(r,h);r=f.chars1,h=f.chars2;var a=f.lineArray,l=this.diff_main(r,h,!1,s);this.diff_charsToLines_(l,a),this.diff_cleanupSemantic(l),l.push(new t.Diff(i,""));for(var g=0,o=0,c=0,u="",p="";g<l.length;){switch(l[g][0]){case n:c++,p+=l[g][1];break;case e:o++,u+=l[g][1];break;case i:if(o>=1&&c>=1){l.splice(g-o-c,o+c),g=g-o-c;for(var d=this.diff_main(u,p,!1,s),_=d.length-1;_>=0;_--)l.splice(g,0,d[_]);g+=d.length}c=0,o=0,u="",p=""}g++}return l.pop(),l},t.prototype.diff_bisect_=function(i,r,h){for(var s=i.length,f=r.length,a=Math.ceil((s+f)/2),l=a,g=2*a,o=new Array(g),c=new Array(g),u=0;u<g;u++)o[u]=-1,c[u]=-1;o[l+1]=0,c[l+1]=0;for(var p=s-f,d=p%2!=0,_=0,b=0,v=0,m=0,w=0;w<a&&!((new Date).getTime()>h);w++){for(var x=-w+_;x<=w-b;x+=2){for(var M=l+x,D=(I=x==-w||x!=w&&o[M-1]<o[M+1]?o[M+1]:o[M-1]+1)-x;I<s&&D<f&&i.charAt(I)==r.charAt(D);)I++,D++;if(o[M]=I,I>s)b+=2;else if(D>f)_+=2;else if(d){if((k=l+p-x)>=0&&k<g&&-1!=c[k])if(I>=(A=s-c[k]))return this.diff_bisectSplit_(i,r,I,D,h)}}for(var y=-w+v;y<=w-m;y+=2){for(var A,k=l+y,E=(A=y==-w||y!=w&&c[k-1]<c[k+1]?c[k+1]:c[k-1]+1)-y;A<s&&E<f&&i.charAt(s-A-1)==r.charAt(f-E-1);)A++,E++;if(c[k]=A,A>s)m+=2;else if(E>f)v+=2;else if(!d){if((M=l+p-y)>=0&&M<g&&-1!=o[M]){var I;D=l+(I=o[M])-M;if(I>=(A=s-A))return this.diff_bisectSplit_(i,r,I,D,h)}}}}return[new t.Diff(e,i),new t.Diff(n,r)]},t.prototype.diff_bisectSplit_=function(t,e,n,i,r){var h=t.substring(0,n),s=e.substring(0,i),f=t.substring(n),a=e.substring(i),l=this.diff_main(h,s,!1,r),g=this.diff_main(f,a,!1,r);return l.concat(g)},t.prototype.diff_linesToChars_=function(t,e){var n=[],i={};function r(t){for(var e="",r=0,s=-1,f=n.length;s<t.length-1;){-1==(s=t.indexOf("\n",r))&&(s=t.length-1);var a=t.substring(r,s+1);(i.hasOwnProperty?i.hasOwnProperty(a):void 0!==i[a])?e+=String.fromCharCode(i[a]):(f==h&&(a=t.substring(r),s=t.length),e+=String.fromCharCode(f),i[a]=f,n[f++]=a),r=s+1}return e}n[0]="";var h=4e4,s=r(t);return h=65535,{chars1:s,chars2:r(e),lineArray:n}},t.prototype.diff_charsToLines_=function(t,e){for(var n=0;n<t.length;n++){for(var i=t[n][1],r=[],h=0;h<i.length;h++)r[h]=e[i.charCodeAt(h)];t[n][1]=r.join("")}},t.prototype.diff_commonPrefix=function(t,e){if(!t||!e||t.charAt(0)!=e.charAt(0))return 0;for(var n=0,i=Math.min(t.length,e.length),r=i,h=0;n<r;)t.substring(h,r)==e.substring(h,r)?h=n=r:i=r,r=Math.floor((i-n)/2+n);return r},t.prototype.diff_commonSuffix=function(t,e){if(!t||!e||t.charAt(t.length-1)!=e.charAt(e.length-1))return 0;for(var n=0,i=Math.min(t.length,e.length),r=i,h=0;n<r;)t.substring(t.length-r,t.length-h)==e.substring(e.l
},{}],"iSlp":[function(require,module,exports) {
function t(t,o,n){return o in t?Object.defineProperty(t,o,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[o]=n,t}function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t){return t&&"object"===o(t)&&!Array.isArray(t)&&null!==t}module.exports=function o(e,r){return n(e)&&n(r)&&Object.keys(r).forEach(function(u){n(r[u])?(e[u]&&n(e[u])||(e[u]=r[u]),o(e[u],r[u])):Object.assign(e,t({},u,r[u]))}),e};
},{}],"Os6R":[function(require,module,exports) {
module.exports=function(n,t){var r=this,e=arguments.length>2&&void 0!==arguments[2]&&arguments[2],l=null,o=!0;return function(){for(var u=arguments.length,i=new Array(u),a=0;a<u;a++)i[a]=arguments[a];var f=function(){n.apply(r,i),l=null};e&&o&&(o=!1,f()),l||(l=setTimeout(f,t))}};
},{}],"gTec":[function(require,module,exports) {
module.exports=function(r,t){var e,n=this;return function(){for(var o=arguments.length,u=new Array(o),a=0;a<o;a++)u[a]=arguments[a];var i=n;clearTimeout(e),e=setTimeout(function(){return r.apply(i,u)},t)}};
},{}],"xRfK":[function(require,module,exports) {
module.exports=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").replace(/\r\n/g,"\n")};
},{}],"j8WE":[function(require,module,exports) {
module.exports=function(c,n,o,t){var a=c+(o-c)/2;return"M ".concat(c," ").concat(n," C ").concat(a,",").concat(n," ").concat(a,",").concat(t," ").concat(o,",").concat(t)};
},{}],"iJA9":[function(require,module,exports) {
module.exports={DIFF_EQUAL:0,DIFF_DELETE:-1,DIFF_INSERT:1,EDITOR_RIGHT:"right",EDITOR_LEFT:"left",RTL:"rtl",LTR:"ltr",SVG_NS:"http://www.w3.org/2000/svg",DIFF_GRANULARITY_SPECIFIC:"specific",DIFF_GRANULARITY_BROAD:"broad"};
},{}],"gWhB":[function(require,module,exports) {
var o=require("../constants");module.exports=function(t,e){var n=t.options.mode;return e===o.EDITOR_LEFT&&null!==t.options.left.mode&&(n=t.options.left.mode),e===o.EDITOR_RIGHT&&null!==t.options.right.mode&&(n=t.options.right.mode),n};
},{"../constants":"iJA9"}],"IRlp":[function(require,module,exports) {
var t=require("../constants");module.exports=function(e,o){var n=e.options.theme;return o===t.EDITOR_LEFT&&null!==e.options.left.theme&&(n=e.options.left.theme),o===t.EDITOR_RIGHT&&null!==e.options.right.theme&&(n=e.options.right.theme),n};
},{"../constants":"iJA9"}],"L8P8":[function(require,module,exports) {
module.exports=function(e,n){return e.ace.getSession().doc.getLine(n)};
},{}],"gpkQ":[function(require,module,exports) {
module.exports=function(e){return document.getElementById(e.options.left.id).offsetHeight};
},{}],"QEUm":[function(require,module,exports) {
module.exports=function(t){var e=document.createElement("div"),n={class:t.className,style:"top:".concat(t.topOffset,"px"),title:t.tooltip,"data-diff-index":t.diffIndex};for(var o in n)e.setAttribute(o,n[o]);return e.innerHTML=t.arrowContent,e};
},{}],"f1Db":[function(require,module,exports) {
module.exports=function(t,e){var r=Math.random().toString(36).substr(2,5),n="js-".concat(e,"-").concat(r),a=t.querySelector(".".concat(e));if(a)return a.id=a.id||n,a.id;var c=document.createElement("div");return t.appendChild(c),c.className=e,c.id=n,c.id};
},{}],"FPMV":[function(require,module,exports) {
function e(e,t,o,r){var n="document"===e?document:document.querySelector(e);n.addEventListener(t,function(e){for(var t=n.querySelectorAll(o),c=e.target,l=0,u=t.length;l<u;l+=1)for(var a=c,d=t[l];a&&a!==n;)a===d&&r.call(d,e),a=a.parentNode})}module.exports={on:e};
},{}],"Focm":[function(require,module,exports) {
var e,t=require("diff-match-patch"),n=require("./helpers/merge"),i=require("./helpers/throttle"),r=require("./helpers/debounce"),o=require("./helpers/normalizeContent"),s=require("./visuals/getCurve"),a=require("./visuals/getMode"),c=require("./visuals/getTheme"),l=require("./visuals/getLine"),d=require("./visuals/getEditorHeight"),f=require("./visuals/createArrow"),h=require("./dom/ensureElement"),g=require("./dom/query"),u=require("./constants");function p(e){if(e.Range)return e.Range;var t=e.acequire||e.require;return!!t&&t("ace/range")}function L(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!(this instanceof L))return new L(t);var i=this;i.options=n({ace:window?window.ace:void 0,mode:null,theme:null,element:null,diffGranularity:u.DIFF_GRANULARITY_BROAD,lockScrolling:!1,showDiffs:!0,showConnectors:!0,maxDiffs:5e3,left:{id:null,content:null,mode:null,theme:null,editable:!0,copyLinkEnabled:!0},right:{id:null,content:null,mode:null,theme:null,editable:!0,copyLinkEnabled:!0},classes:{gutterID:"acediff__gutter",diff:"acediff__diffLine",connector:"acediff__connector",newCodeConnectorLink:"acediff__newCodeConnector",newCodeConnectorLinkContent:"&#8594;",deletedCodeConnectorLink:"acediff__deletedCodeConnector",deletedCodeConnectorLinkContent:"&#8592;",copyRightContainer:"acediff__copy--right",copyLeftContainer:"acediff__copy--left"},connectorYOffset:0},t);var r=i.options.ace;if(!r){var s="No ace editor found nor supplied - `options.ace` or `window.ace` is missing";return console.error(s),new Error(s)}if(!(e=p(r))){var l="Could not require Range module for Ace. Depends on your bundling strategy, but it usually comes with Ace itself. See https://ace.c9.io/api/range.html, open an issue on GitHub ace-diff/ace-diff";return console.error(l),new Error(l)}if(null===i.options.element){var f="You need to specify an element for Ace-diff - `options.element` is missing";return console.error(f),new Error(f)}if(i.options.element instanceof HTMLElement?i.el=i.options.element:i.el=document.body.querySelector(i.options.element),!i.el){var g="Can't find the specified element ".concat(i.options.element);return console.error(g),new Error(g)}i.options.left.id=h(i.el,"acediff__left"),i.options.classes.gutterID=h(i.el,"acediff__gutter"),i.options.right.id=h(i.el,"acediff__right"),i.el.innerHTML='<div class="acediff__wrap">'.concat(i.el.innerHTML,"</div>"),i.editors={left:{ace:r.edit(i.options.left.id),markers:[],lineLengths:[]},right:{ace:r.edit(i.options.right.id),markers:[],lineLengths:[]},editorHeight:null},i.editors.left.ace.getSession().setMode(a(i,u.EDITOR_LEFT)),i.editors.right.ace.getSession().setMode(a(i,u.EDITOR_RIGHT)),i.editors.left.ace.setReadOnly(!i.options.left.editable),i.editors.right.ace.setReadOnly(!i.options.right.editable),i.editors.left.ace.setTheme(c(i,u.EDITOR_LEFT)),i.editors.right.ace.setTheme(c(i,u.EDITOR_RIGHT)),i.editors.left.ace.setValue(o(i.options.left.content),-1),i.editors.right.ace.setValue(o(i.options.right.content),-1),i.editors.editorHeight=d(i),setTimeout(function(){i.lineHeight=i.editors.left.ace.renderer.lineHeight,C(i),O(i),F(i),i.diff()},1)}L.prototype={setOptions:function(e){n(this.options,e),this.diff()},getNumDiffs:function(){return this.diffs.length},getEditors:function(){return{left:this.editors.left.ace,right:this.editors.right.ace}},diff:function(){var e=this,n=new t,i=this.editors.left.ace.getSession().getValue(),r=this.editors.right.ace.getSession().getValue(),o=n.diff_main(r,i);n.diff_cleanupSemantic(o),this.editors.left.lineLengths=S(this.editors.left),this.editors.right.lineLengths=S(this.editors.right);var s=[],a={left:0,right:0};o.forEach(function(t,n,i){var r=t[0],c=t[1];i[n+1]&&c.endsWith("\n")&&i[n+1][1].startsWith("\n")&&(c+="\n",o[n][1]=c,o[n+1][1]=o[n+1][1].replace(/^\n/,"")),0!==c.length&&(r===u.DIFF_EQUAL?(a.left+=c.length,a.right+=c.length):r===u.DIFF_DELETE?(s.push(R(e,u.DIFF_DELETE,a.left,a.right,c)),a.right+=c.length):r===u.DIFF_INSERT&&(s.push(R(e,u.DIFF_INSERT,a.left,a.right,c)),a.left+=c.length))},this),this.diffs=G(this,s),this.diffs.length>this.options
},{"diff-match-patch":"k8CM","./helpers/merge":"iSlp","./helpers/throttle":"Os6R","./helpers/debounce":"gTec","./helpers/normalizeContent":"xRfK","./visuals/getCurve":"j8WE","./visuals/getMode":"gWhB","./visuals/getTheme":"IRlp","./visuals/getLine":"L8P8","./visuals/getEditorHeight":"gpkQ","./visuals/createArrow":"QEUm","./dom/ensureElement":"f1Db","./dom/query":"FPMV","./constants":"iJA9"}]},{},["Focm"], "AceDiff")
//# sourceMappingURL=/ace-diff.min.js.map