antosdk-apps/GraphEditor/build/debug/main.js

41 lines
776 KiB
JavaScript
Raw Normal View History

2020-06-07 00:51:01 +02:00
var t,e;(function(){var t;(t=class t extends this.OS.application.BaseApplication{constructor(t){super("GraphEditor",t)}main(){return mermaid.initialize({theme:"forest"}),this.currfile=this.args&&this.args.length>0?this.args[0].path.asFileHandle():"Untitled".asFileHandle(),this.currfile.dirty=!1,this.datarea=this.find("datarea"),this.preview=this.find("preview"),this.btctn=this.find("btn-container"),ace.config.set("basePath","/scripts/ace"),this.editor=ace.edit(this.datarea),this.editor.setOptions({enableBasicAutocompletion:!0,enableLiveAutocompletion:!0,fontSize:"11pt"}),this.editor.getSession().setUseWrapMode(!0),this.editor.session.setMode("ace/mode/text"),this.editor.setTheme("ace/theme/monokai"),this.editor.on("input",()=>this.editormux?(this.editormux=!1,!1):this.currfile.dirty?void 0:this.currfile.dirty=!0),this.currfile.basename||(this.editormux=!0,this.editor.setValue(t.dummymermaid),this.renderSVG(!1)),this.editor.container.addEventListener("keydown",t=>{if(13===t.keyCode)return this.renderSVG(!0)},!0),this.bindKey("CTRL-R",()=>this.renderSVG(!1)),this.bindKey("ALT-G",()=>this.export("SVG")),this.bindKey("ALT-P",()=>this.export("PNG")),this.bindKey("ALT-N",()=>this.actionFile(this.name+"-New")),this.bindKey("ALT-O",()=>this.actionFile(this.name+"-Open")),this.bindKey("CTRL-S",()=>this.actionFile(this.name+"-Save")),this.bindKey("ALT-W",()=>this.actionFile(this.name+"-Saveas")),this.bindKey("CTRL-M",()=>this.svgToCanvas((function(){}))),this.on("hboxchange",()=>(this.editor.resize(),this.calibrate())),this.on("focus",()=>this.editor.focus()),this.find("btn-zoomin").onbtclick=t=>{if(this.pan)return this.pan.zoomIn()},this.find("btn-zoomout").onbtclick=t=>{if(this.pan)return this.pan.zoomOut()},this.find("btn-reset").onbtclick=t=>{if(this.pan)return this.pan.resetZoom()},this.open(this.currfile)}menu(){return[{text:"__(File)",nodes:[{text:"__(New)",dataid:this.name+"-New",shortcut:"A-N"},{text:"__(Open)",dataid:this.name+"-Open",shortcut:"A-O"},{text:"__(Save)",dataid:this.name+"-Save",shortcut:"C-S"},{text:"__(Save as)",dataid:this.name+"-Saveas",shortcut:"A-W"},{text:"__(Render)",dataid:this.name+"-Render",shortcut:"C-R"},{text:"__(Export as)",nodes:[{text:"SVG",shortcut:"A-G"},{text:"PNG",shortcut:"A-P"}],onchildselect:t=>this.export(t.data.item.data.text)}],onchildselect:t=>this.actionFile(t.data.item.data.dataid)}]}open(t){if("Untitled"!==t.path)return t.dirty=!1,t.read().then(e=>(this.currfile=t,this.editormux=!0,this.currfile.dirty=!1,this.editor.setValue(e),this.scheme.apptitle=""+this.currfile.basename,this.renderSVG(!1))).catch(t=>this.error(t.toString(),t))}save(t){return t.write("text/plain").then(e=>(t.dirty=!1,t.text=t.basename,this.scheme.apptitle=""+this.currfile.basename)).catch(t=>this.error(t.toString(),t))}actionFile(t){var e;switch(e=()=>this.openDialog("FileDialog",{title:__("Save as"),file:this.currfile}).then(t=>(this.currfile.setPath(`${t.file.path}/${t.name}`),this.save(this.currfile))).catch(t=>this.error(t.toString(),t)),t){case this.name+"-Open":return this.openDialog("FileDialog",{title:__("Open file")}).then((t,e)=>this.open(t.file.path.asFileHandle())).catch(t=>this.error(t.toString(),t));case this.name+"-Save":return this.currfile.cache=this.editor.getValue(),this.currfile.basename?this.save(this.currfile):e();case this.name+"-Saveas":return this.currfile.cache=this.editor.getValue(),e();case this.name+"-Render":return this.renderSVG(!1);case this.name+"-New":return this.currfile="Untitled".asFileHandle(),this.currfile.cache="",this.currfile.dirty=!1,this.editormux=!0,this.editor.setValue("")}}export(t){return this.openDialog("FileDialog",{title:__("Export as"),file:this.currfile}).then(e=>{var n,r;r=`${e.file.path}/${e.name}`.asFileHandle();try{switch(t){case"SVG":return r.cache=this.svgtext(),r.write("text/plain").then(t=>this.notify(__("File exported"))).catch(e=>this.error(__("Cannot export to {0}: {1}",t,e.toString()),e));case"PNG":return this.svgToCanvas(e=>{var n;try{return r.cache=e.toDataURL("image/png"),r.write("base64").then(t=>this.notify(__("File exported"))).catch(e=>
/**
* @license
* Copyright (c) 2012-2013 Chris Pettitt
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
t.exports={graphlib:n(282),dagre:n(136),intersect:n(339),render:n(341),util:n(10),version:n(353)}},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,n){"use strict";var r=n(3),i=n(12).Graph;function a(t,e,n,i){var a;do{a=r.uniqueId(i)}while(t.hasNode(a));return n.dummy=e,t.setNode(a,n),a}function o(t){return r.max(r.map(t.nodes(),(function(e){var n=t.node(e).rank;if(!r.isUndefined(n))return n})))}t.exports={addDummyNode:a,simplify:function(t){var e=(new i).setGraph(t.graph());return r.forEach(t.nodes(),(function(n){e.setNode(n,t.node(n))})),r.forEach(t.edges(),(function(n){var r=e.edge(n.v,n.w)||{weight:0,minlen:1},i=t.edge(n);e.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})})),e},asNonCompoundGraph:function(t){var e=new i({multigraph:t.isMultigraph()}).setGraph(t.graph());return r.forEach(t.nodes(),(function(n){t.children(n).length||e.setNode(n,t.node(n))})),r.forEach(t.edges(),(function(n){e.setEdge(n,t.edge(n))})),e},successorWeights:function(t){var e=r.map(t.nodes(),(function(e){var n={};return r.forEach(t.outEdges(e),(function(e){n[e.w]=(n[e.w]||0)+t.edge(e).weight})),n}));return r.zipObject(t.nodes(),e)},predecessorWeights:function(t){var e=r.map(t.nodes(),(function(e){var n={};return r.forEach(t.inEdges(e),(function(e){n[e.v]=(n[e.v]||0)+t.edge(e).weight})),n}));return r.zipObject(t.nodes(),e)},intersectRect:function(t,e){var n,r,i=t.x,a=t.y,o=e.x-i,s=e.y-a,u=t.width/2,c=t.height/2;if(!o&&!s)throw new Error("Not possible to find intersection inside of the rectangle");return Math.abs(s)*u>Math.abs(o)*c?(s<0&&(c=-c),n=c*o/s,r=c):(o<0&&(u=-u),n=u,r=u*s/o),{x:i+n,y:a+r}},buildLayerMatrix:function(t){var e=r.map(r.range(o(t)+1),(function(){return[]}));return r.forEach(t.nodes(),(function(n){var i=t.node(n),a=i.rank;r.isUndefined(a)||(e[a][i.order]=n)})),e},normalizeRanks:function(t){var e=r.min(r.map(t.nodes(),(function(e){return t.node(e).rank})));r.forEach(t.nodes(),(function(n){var i=t.node(n);r.has(i,"rank")&&(i.rank-=e)}))},removeEmptyRanks:function(t){var e=r.min(r.map(t.nodes(),(function(e){return t.node(e).rank}))),n=[];r.forEach(t.nodes(),(function(r){var i=t.node(r).rank-e;n[i]||(n[i]=[]),n[i].push(r)}));var i=0,a=t.graph().nodeRankFactor;r.forEach(n,(function(e,n){r.isUndefined(e)&&n%a!=0?--i:i&&r.forEach(e,(function(e){t.node(e).rank+=i}))}))},addBorderNode:function(t,e,n,r){var i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),a(t,"border",i,e)},maxRank:o,partition:function(t,e){var n={lhs:[],rhs:[]};return r.forEach(t,(function(t){e(t)?n.lhs.push(t):n.rhs.push(t)})),n},time:function(t,e){var n=r.now();try{return e()}finally{console.log(t+" time: "+(r.now()-n)+"ms")}},notime:function(t,e){return e()}}},function(t,e,n){var r;try{r={clone:n(170),constant:n(78),each:n(79),filter:n(111),has:n(85),isArray:n(4),isEmpty:n(247),isFunction:n(31),isUndefined:n(122),keys:n(25),map:n(123),reduce:n(125),size:n(250),transform:n(256),union:n(257),values:n(130)}}catch(t){}r||(r=window._),t.exports=r},function(t,e){t.exports=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}},function(t,e,n){var r=n(37);t.exports={isSubgraph:function(t,e){return!!t.children(e).length},edgeToId:function(t){return a(t.v)+":"+a(t.w)+":"+a(t.name)},applyStyle:function(t,e){e&&t.attr("style",e)},applyClass:function(t,e,n){e&&t.attr("class",e).attr("class",n+" "+t.attr("class"))},applyTransition:function(t,e){var n=e.graph();if(r.isPlainObject(n)){var i=n.transition;if(r.isFunction(i))return i(t)}return t}};var i=/:/g;function a(t){return t?String(t).replace(i,"\\:"):""}},function(t,e,n){var r=n(92),i="object"==typeof self&&self&&self.Object===Object&&self,a=r||i||Function("return this")();t.exports=a},function(t,e,n){var r;try{r=n(2)}catch(t){}r||(r=window.graphlib),t.exports=r},function(t,e){var n,r,i=t.export
/*!
* Escaper v2.5.3
* https://github.com/kobezzza/Escaper
*
* Released under the MIT license
* https://github.com/kobezzza/Escaper/blob/master/LICENSE
*
* Date: Tue, 23 Jan 2018 15:58:45 GMT
*/
!function(t){"use strict";var e,n="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},r=e={VERSION:[2,5,3],content:[],cache:{},snakeskinRgxp:null,symbols:null,replace:M,paste:C},i={'"':!0,"'":!0,"`":!0},a={"/":!0};for(var o in i){if(!i.hasOwnProperty(o))break;a[o]=!0}var s={"//":!0,"//*":!0,"//!":!0,"//#":!0,"//@":!0,"//$":!0},u={"/*":!0,"/**":!0,"/*!":!0,"/*#":!0,"/*@":!0,"/*$":!0},c=[],l={};for(var f in a){if(!a.hasOwnProperty(f))break;c.push(f),l[f]=!0}for(var h in s){if(!s.hasOwnProperty(h))break;c.push(h),l[h]=!0}for(var d in u){if(!u.hasOwnProperty(d))break;c.push(d),l[d]=!0}var p=[],y={g:!0,m:!0,i:!0,y:!0,u:!0};for(var g in y){if(!y.hasOwnProperty(g))break;p.push(g)}var m={"-":!0,"+":!0,"*":!0,"%":!0,"~":!0,">":!0,"<":!0,"^":!0,",":!0,";":!0,"=":!0,"|":!0,"&":!0,"!":!0,"?":!0,":":!0,"(":!0,"{":!0,"[":!0},v={return:!0,yield:!0,await:!0,typeof:!0,void:!0,instanceof:!0,delete:!0,in:!0,new:!0,of:!0};function b(t,e,n){for(var r in t){if(!t.hasOwnProperty(r))break;r in e==0&&(e[r]=n)}}var x=void 0,_=void 0,w=/[^\s/]/,k=/[a-z]/,E=/\s/,S=/[\r\n]/,A=/\${pos}/g,T={object:!0,function:!0};function M(t,r,o,f){x=x||e.symbols||"a-z",_=_||e.snakeskinRgxp||new RegExp("[!$"+x+"_]","i");var h=e.cache,d=e.content,g=Boolean(r&&T[void 0===r?"undefined":n(r)]),M=g?Object(r):{};function O(t){return M["@label"]?M["@label"].replace(A,t):"__ESCAPER_QUOT__"+t+"_"}var C=!1;"boolean"==typeof r&&(C=Boolean(r)),"@comments"in M&&(b(u,M,M["@comments"]),b(s,M,M["@comments"]),delete M["@comments"]),"@strings"in M&&(b(i,M,M["@strings"]),delete M["@strings"]),"@literals"in M&&(b(a,M,M["@literals"]),delete M["@literals"]),"@all"in M&&(b(l,M,M["@all"]),delete M["@all"]);for(var N="",D=-1;++D<c.length;){var L=c[D];u[L]||s[L]?M[L]=C||M[L]:M[L]=M[L]||!g,N+=M[L]+","}var F=t,P=o||d;if(P===d&&h[N]&&h[N][F])return h[N][F];for(var I=!1,R=!0,B=!1,j=!1,z=0,Y=!1,U=0,$=!1,V=void 0,G=void 0,W="",H="",q=-1;++q<t.length;){var Z=t.charAt(q),X=t.charAt(q+1),J=t.substr(q,2),Q=t.substr(q,3);if(j)(S.test(X)&&s[j]||u[Z+t.charAt(q-1)]&&q-z>2&&u[j])&&(M[j]&&(V=t.substring(z,q+1),-1===M[j]?G="":(G=O(P.length),P.push(V)),t=t.substring(0,z)+G+t.substring(q+1),q+=G.length-V.length),j=!1);else{if(!I){if("/"===Z&&((s[J]||u[J])&&(j=s[Q]||u[Q]?Q:J),j)){z=q;continue}m[Z]||v[H]?(R=!0,H=""):w.test(Z)&&(R=!1),k.test(Z)?W+=Z:(H=W,W="");var K=!1;f&&("|"===Z&&_.test(X)?($=!0,R=!1,K=!0):$&&E.test(Z)&&($=!1,R=!0,K=!0)),K||(m[Z]?R=!0:w.test(Z)&&(R=!1))}if("/"!==I||B||("["===Z?Y=!0:"]"===Z&&(Y=!1)),!I&&U&&("}"===Z?U--:"{"===Z&&U++,U||(Z="`")),"`"!==I||B||"${"!==J||(Z="`",q++,U++),!l[Z]||"/"===Z&&!R||I){if(I&&("\\"===Z||B))B=!B;else if(l[Z]&&I===Z&&!B&&("/"!==I||!Y)){if("/"===Z)for(var tt=-1;++tt<p.length;)y[t.charAt(q+1)]&&q++;I=!1,R=!1,M[Z]&&(V=t.substring(z,q+1),-1===M[Z]?G="":(G=O(P.length),P.push(V)),t=t.substring(0,z)+G+t.substring(q+1),q+=G.length-V.length)}}else I=Z,z=q}}return P===d&&(h[N]=h[N]||{},h[N][F]=t),t}var O=/__ESCAPER_QUOT__(\d+)_/g;function C(t,n,r){return t.replace(r||O,(function(t,r){return(n||e.content)[r]}))}t.default=r,t.replace=M,t.paste=C,Object.defineProperty(t,"__esModule",{value:!0})}(e)},function(t,e,n){"use strict";var r=n(157);t.exports=function(t,e){var n;t=t.toString();var i="",a="",o=!1,s=!(!1===(e=e||{}).preserve||!0===e.all),u="";"function"==typeof e.preserve?(s=!1,n=e.preserve):r(e.preserve)&&(s=!1,n=function(t){return e.preserve.test(t)});for(var c=0;c<t.length;c++)if(a=t[c],"\\"!==t[c-1]&&('"'!==a&&"'"!==a||(o===a?o=!1:o||(o=a))),o||"/"!==a||"*"!==t[c+1]||s&&"!"===t[c+2])u+=a;else{for(var l=c+2;l<t.length;l++){if("*"===t[l]&&"/"===t[l+1]){n&&(u=n(i)?u+"/*"+i+"*/":u,i="");break}n&&(i+=t[l])}c=l+1}return u}},function(t,e,n){"use strict";t.exports=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)}},function(t,e,n){var r={"./dark/index.scss":159,"./default/index.scss":161,"./forest/index.scss":163,"./neutral/index.scss":165};function i(t){var e=a(t);return n(e)}function a(t){if(!n.o(r,t)){
/*!
* Wait for document loaded before starting the execution
*/
window.addEventListener("load",(function(){ji()}),!1);var zi={startOnLoad:!0,htmlLabels:!0,mermaidAPI:Bi,parse:Bi.parse,render:Bi.render,init:function(){var t,e,n,r=Bi.getConfig();y.debug("Starting rendering diagrams"),arguments.length>=2?(
/*! sequence config was passed as #1 */
void 0!==arguments[0]&&(zi.sequenceConfig=arguments[0]),t=arguments[1]):t=arguments[0],"function"==typeof arguments[arguments.length-1]?(e=arguments[arguments.length-1],y.debug("Callback function found")):void 0!==r.mermaid&&("function"==typeof r.mermaid.callback?(e=r.mermaid.callback,y.debug("Callback function found")):y.debug("No Callback function found")),t=void 0===t?document.querySelectorAll(".mermaid"):"string"==typeof t?document.querySelectorAll(t):t instanceof window.Node?[t]:t,y.debug("Start On Load before: "+zi.startOnLoad),void 0!==zi.startOnLoad&&(y.debug("Start On Load inner: "+zi.startOnLoad),Bi.initialize({startOnLoad:zi.startOnLoad})),void 0!==zi.ganttConfig&&Bi.initialize({gantt:zi.ganttConfig});for(var a=function(r){var a=t[r];
/*! Check if previously processed */if(a.getAttribute("data-processed"))return"continue";a.setAttribute("data-processed",!0);var o="mermaid-".concat(Date.now());n=i(n=a.innerHTML).trim().replace(/<br\s*\/?>/gi,"<br/>"),Bi.render(o,n,(function(t,n){a.innerHTML=t,void 0!==e&&e(o),n&&n(a)}),a)},o=0;o<t.length;o++)a(o)},initialize:function(t){void 0!==t.mermaid&&(void 0!==t.mermaid.startOnLoad&&(zi.startOnLoad=t.mermaid.startOnLoad),void 0!==t.mermaid.htmlLabels&&(zi.htmlLabels=t.mermaid.htmlLabels)),Bi.initialize(t),y.debug("Initializing mermaid ")},contentLoaded:ji};e.default=zi}]).default},"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.mermaid=e():t.mermaid=e();