rete-area-plugin
Advanced tools
Comparing version 0.1.3 to 0.1.4
/*! | ||
* rete-area-plugin v0.1.3 | ||
* rete-area-plugin v0.1.4 | ||
* (c) 2018 License | ||
* Released under the ISC license. | ||
*/ | ||
!function(t){"use strict";var u,r=Object.prototype,h=r.hasOwnProperty,e="function"==typeof Symbol?Symbol:{},o=e.iterator||"@@iterator",n=e.asyncIterator||"@@asyncIterator",i=e.toStringTag||"@@toStringTag",a="object"==typeof module,c=t.regeneratorRuntime;if(c)a&&(module.exports=c);else{(c=t.regeneratorRuntime=a?module.exports:{}).wrap=w;var l="suspendedStart",s="suspendedYield",p="executing",y="completed",d={},f={};f[o]=function(){return this};var m=Object.getPrototypeOf,v=m&&m(m(N([])));v&&v!==r&&h.call(v,o)&&(f=v);var g=b.prototype=E.prototype=Object.create(f);L.prototype=g.constructor=b,b.constructor=L,b[i]=L.displayName="GeneratorFunction",c.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===L||"GeneratorFunction"===(r.displayName||r.name))},c.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,i in t||(t[i]="GeneratorFunction")),t.prototype=Object.create(g),t},c.awrap=function(t){return{__await:t}},_(j.prototype),j.prototype[n]=function(){return this},c.AsyncIterator=j,c.async=function(t,r,e,n){var o=new j(w(t,r,e,n));return c.isGeneratorFunction(r)?o:o.next().then(function(t){return t.done?t.value:o.next()})},_(g),g[i]="Generator",g[o]=function(){return this},g.toString=function(){return"[object Generator]"},c.keys=function(e){var n=[];for(var t in e)n.push(t);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},c.values=N,G.prototype={constructor:G,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=u,this.done=!1,this.delegate=null,this.method="next",this.arg=u,this.tryEntries.forEach(k),!t)for(var r in this)"t"===r.charAt(0)&&h.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=u)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function t(t,r){return i.type="throw",i.arg=e,n.next=t,r&&(n.method="next",n.arg=u),!!r}for(var r=this.tryEntries.length-1;0<=r;--r){var o=this.tryEntries[r],i=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var a=h.call(o,"catchLoc"),c=h.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;0<=e;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&h.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=r&&r<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=r,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(i)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),d},finish:function(t){for(var r=this.tryEntries.length-1;0<=r;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),k(e),d}},catch:function(t){for(var r=this.tryEntries.length-1;0<=r;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;k(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:N(t),resultName:r,nextLoc:e},"next"===this.method&&(this.arg=u),d}}}function w(t,r,e,n){var i,a,c,u,o=r&&r.prototype instanceof E?r:E,h=Object.create(o.prototype),f=new G(n||[]);return h._invoke=(i=t,a=e,c=f,u=l,function(t,r){if(u===p)throw new Error("Generator is already running");if(u===y){if("throw"===t)throw r;return P()}for(c.method=t,c.arg=r;;){var e=c.delegate;if(e){var n=O(e,c);if(n){if(n===d)continue;return n}}if("next"===c.method)c.sent=c._sent=c.arg;else if("throw"===c.method){if(u===l)throw u=y,c.arg;c.dispatchException(c.arg)}else"return"===c.method&&c.abrupt("return",c.arg);u=p;var o=x(i,a,c);if("normal"===o.type){if(u=c.done?y:s,o.arg===d)continue;return{value:o.arg,done:c.done}}"throw"===o.type&&(u=y,c.method="throw",c.arg=o.arg)}}),h}function x(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}function E(){}function L(){}function b(){}function _(t){["next","throw","return"].forEach(function(r){t[r]=function(t){return this._invoke(r,t)}})}function j(u){var r;this._invoke=function(e,n){function t(){return new Promise(function(t,r){!function r(t,e,n,o){var i=x(u[t],u,e);if("throw"!==i.type){var a=i.arg,c=a.value;return c&&"object"==typeof c&&h.call(c,"__await")?Promise.resolve(c.__await).then(function(t){r("next",t,n,o)},function(t){r("throw",t,n,o)}):Promise.resolve(c).then(function(t){a.value=t,n(a)},o)}o(i.arg)}(e,n,t,r)})}return r=r?r.then(t,t):t()}}function O(t,r){var e=t.iterator[r.method];if(e===u){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=u,O(t,r),"throw"===r.method))return d;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var n=x(e,t.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,d;var o=n.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=u),r.delegate=null,d):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function A(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function k(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function G(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function N(r){if(r){var t=r[o];if(t)return t.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var e=-1,n=function t(){for(;++e<r.length;)if(h.call(r,e))return t.value=r[e],t.done=!1,t;return t.value=u,t.done=!0,t};return n.next=n}}return{next:P}}function P(){return{value:u,done:!0}}}(function(){return this}()||Function("return this")()),function(t,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):t.AreaPlugin=r()}(this,function(){"use strict";var x=function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,r){var e=[],n=!0,o=!1,i=void 0;try{for(var a,c=t[Symbol.iterator]();!(n=(a=c.next()).done)&&(e.push(a.value),!r||e.length!==r);n=!0);}catch(t){o=!0,i=t}finally{try{!n&&c.return&&c.return()}finally{if(o)throw i}}return e}(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")},r=function(t){if(Array.isArray(t)){for(var r=0,e=Array(t.length);r<t.length;r++)e[r]=t[r];return e}return Array.from(t)},E=function(t){return Math.min.apply(Math,r(t))},L=function(t){return Math.max.apply(Math,r(t))};return{install:function(c,u){u.scaleExtent=u.scaleExtent||{min:.1,max:1},u.translateExtent=u.translateExtent||{width:2e3,height:1e3},c.on("zoom",function(t){var r=u.scaleExtent;t.transform,t.zoom<r.min?t.zoom=r.min:t.zoom>r.max&&(t.zoom=r.max)}),c.on("translate",function(t){var r=u.translateExtent,e=t.transform.k,n=r.width*e,o=r.height*e,i=c.view.container.clientWidth/2,a=c.view.container.clientHeight/2;t.x-=i,t.y-=a,t.x>n?t.x=n:t.x<-n&&(t.x=-n),t.y>o?t.y=o:t.y<-o&&(t.y=-o),t.x+=i,t.y+=a})},zoomAt:function(t){var r,e,n,o,i,a,c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t.nodes,u=(r=t,n=E((e=c).map(function(t){return t.position[0]})),o=E(e.map(function(t){return t.position[1]})),i=L(e.map(function(t){return t.position[0]+r.view.nodes.get(t).el.clientWidth})),a=L(e.map(function(t){return t.position[1]+r.view.nodes.get(t).el.clientHeight})),{left:n,right:i,top:o,bottom:a,width:Math.abs(n-i),height:Math.abs(o-a),getCenter:function(){return[(n+i)/2,(o+a)/2]}}),h=u.getCenter(),f=x(h,2),l=f[0],s=f[1],p=[t.view.container.clientWidth,t.view.container.clientHeight],y=p[0],d=p[1],m=t.view.area,v=y/u.width,g=d/u.height,w=Math.min(.9*g,.9*v,1);m.transform.x=m.container.clientWidth/2-l*w,m.transform.y=m.container.clientHeight/2-s*w,m.zoom(w,0,0),m.update()}}}); | ||
!function(t){"use strict";var u,e=Object.prototype,s=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",r=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag",a="object"==typeof module,c=t.regeneratorRuntime;if(c)a&&(module.exports=c);else{(c=t.regeneratorRuntime=a?module.exports:{}).wrap=w;var l="suspendedStart",f="suspendedYield",p="executing",d="completed",y={},h={};h[o]=function(){return this};var v=Object.getPrototypeOf,m=v&&v(v(A([])));m&&m!==e&&s.call(m,o)&&(h=m);var g=L.prototype=b.prototype=Object.create(h);E.prototype=g.constructor=L,L.constructor=E,L[i]=E.displayName="GeneratorFunction",c.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===E||"GeneratorFunction"===(e.displayName||e.name))},c.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,L):(t.__proto__=L,i in t||(t[i]="GeneratorFunction")),t.prototype=Object.create(g),t},c.awrap=function(t){return{__await:t}},k(j.prototype),j.prototype[r]=function(){return this},c.AsyncIterator=j,c.async=function(t,e,n,r){var o=new j(w(t,e,n,r));return c.isGeneratorFunction(e)?o:o.next().then(function(t){return t.done?t.value:o.next()})},k(g),g[i]="Generator",g[o]=function(){return this},g.toString=function(){return"[object Generator]"},c.keys=function(n){var r=[];for(var t in n)r.push(t);return r.reverse(),function t(){for(;r.length;){var e=r.pop();if(e in n)return t.value=e,t.done=!1,t}return t.done=!0,t}},c.values=A,T.prototype={constructor:T,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=u,this.done=!1,this.delegate=null,this.method="next",this.arg=u,this.tryEntries.forEach(O),!t)for(var e in this)"t"===e.charAt(0)&&s.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=u)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var r=this;function t(t,e){return i.type="throw",i.arg=n,r.next=t,e&&(r.method="next",r.arg=u),!!e}for(var e=this.tryEntries.length-1;0<=e;--e){var o=this.tryEntries[e],i=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var a=s.call(o,"catchLoc"),c=s.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;0<=n;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&s.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,y):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y},finish:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),O(n),y}},catch:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;O(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:A(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=u),y}}}function w(t,e,n,r){var i,a,c,u,o=e&&e.prototype instanceof b?e:b,s=Object.create(o.prototype),h=new T(r||[]);return s._invoke=(i=t,a=n,c=h,u=l,function(t,e){if(u===p)throw new Error("Generator is already running");if(u===d){if("throw"===t)throw e;return M()}for(c.method=t,c.arg=e;;){var n=c.delegate;if(n){var r=_(n,c);if(r){if(r===y)continue;return r}}if("next"===c.method)c.sent=c._sent=c.arg;else if("throw"===c.method){if(u===l)throw u=d,c.arg;c.dispatchException(c.arg)}else"return"===c.method&&c.abrupt("return",c.arg);u=p;var o=x(i,a,c);if("normal"===o.type){if(u=c.done?d:f,o.arg===y)continue;return{value:o.arg,done:c.done}}"throw"===o.type&&(u=d,c.method="throw",c.arg=o.arg)}}),s}function x(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}function b(){}function E(){}function L(){}function k(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function j(u){var e;this._invoke=function(n,r){function t(){return new Promise(function(t,e){!function e(t,n,r,o){var i=x(u[t],u,n);if("throw"!==i.type){var a=i.arg,c=a.value;return c&&"object"==typeof c&&s.call(c,"__await")?Promise.resolve(c.__await).then(function(t){e("next",t,r,o)},function(t){e("throw",t,r,o)}):Promise.resolve(c).then(function(t){a.value=t,r(a)},o)}o(i.arg)}(n,r,t,e)})}return e=e?e.then(t,t):t()}}function _(t,e){var n=t.iterator[e.method];if(n===u){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=u,_(t,e),"throw"===e.method))return y;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return y}var r=x(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,y;var o=r.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=u),e.delegate=null,y):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,y)}function z(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(z,this),this.reset(!0)}function A(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n<e.length;)if(s.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=u,t.done=!0,t};return r.next=r}}return{next:M}}function M(){return{value:u,done:!0}}}(function(){return this}()||Function("return this")()),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.AreaPlugin=e()}(this,function(){"use strict";!function(t){if(t&&"undefined"!=typeof window){var e=document.createElement("style");e.setAttribute("type","text/css"),e.innerHTML=t,document.head.appendChild(e)}}(".node-editor .background {\n display: table;\n z-index: -1;\n position: absolute;\n top: -32000px;\n left: -32000px;\n width: 64000px;\n height: 64000px;\n background-size: 32px 32px;\n background-image: linear-gradient(to right, #ccc 1px, transparent 1px), linear-gradient(to bottom, #ccc 1px, transparent 1px);\n}");var u=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t=function(){function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}}(),x=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var a,c=t[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{!r&&c.return&&c.return()}finally{if(o)throw i}}return n}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")},e=function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)},n=function(){function n(t,e){u(this,n),this.editor=t,e&&this.init()}return t(n,[{key:"init",value:function(){var t=document.createElement("div");t.innerHTML="hjk",t.className="background",this.editor.view.area.appendChild(t)}}]),n}(),r=function(){function r(t,e,n){u(this,r),this.editor=t,this.scaleExtent=e,this.translateExtent=n,t.on("zoom",this.restrictZoom.bind(this)),t.on("translate",this.restrictTranslate.bind(this))}return t(r,[{key:"restrictZoom",value:function(t){var e=this.scaleExtent;t.transform;t.zoom<e.min?t.zoom=e.min:t.zoom>e.max&&(t.zoom=e.max)}},{key:"restrictTranslate",value:function(t){var e=this.translateExtent,n=this.editor.view.container,r=t.transform.k,o=e.width*r,i=e.height*r,a=n.clientWidth/2,c=n.clientHeight/2;t.x-=a,t.y-=c,t.x>o?t.x=o:t.x<-o&&(t.x=-o),t.y>i?t.y=i:t.y<-i&&(t.y=-i),t.x+=a,t.y+=c}}]),r}(),o=function(){function c(t,e){var r=this,n=e.size,o=void 0===n?16:n,i=e.dynamic,a=void 0===i||i;u(this,c),this.editor=t,this.size=o,a?this.editor.on("nodetranslate",this.onTranslate.bind(this)):this.editor.on("rendernode",function(t){var e=t.node,n=t.el;n.addEventListener("mouseup",r.onDrag.bind(r,e)),n.addEventListener("touchend",r.onDrag.bind(r,e)),n.addEventListener("touchcancel",r.onDrag.bind(r,e))})}return t(c,[{key:"onTranslate",value:function(t){var e=t.x,n=t.y;t.x=this.snap(e),t.y=this.snap(n)}},{key:"onDrag",value:function(t){var e=x(t.position,2),n=e[0],r=e[1];t.position[0]=this.snap(n),t.position[1]=this.snap(r),console.log(this,n,r,t.position),this.editor.view.nodes.get(t).update(),this.editor.view.updateConnections({node:t})}},{key:"snap",value:function(t){return Math.round(t/this.size)*this.size}}]),c}(),b=function(t){return Math.min.apply(Math,e(t))},E=function(t){return Math.max.apply(Math,e(t))};return{install:function(t,e){e.background=e.background||!1,e.snap=e.snap||{size:16,dynamic:!0},e.scaleExtent=e.scaleExtent||{min:.1,max:1},e.translateExtent=e.translateExtent||{width:2e3,height:1e3},new n(t,e.background),new r(t,e.scaleExtent,e.translateExtent),new o(t,e.snap)},zoomAt:function(t){var e,n,r,o,i,a,c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t.nodes,u=(e=t,r=b((n=c).map(function(t){return t.position[0]})),o=b(n.map(function(t){return t.position[1]})),i=E(n.map(function(t){return t.position[0]+e.view.nodes.get(t).el.clientWidth})),a=E(n.map(function(t){return t.position[1]+e.view.nodes.get(t).el.clientHeight})),{left:r,right:i,top:o,bottom:a,width:Math.abs(r-i),height:Math.abs(o-a),getCenter:function(){return[(r+i)/2,(o+a)/2]}}),s=u.getCenter(),h=x(s,2),l=h[0],f=h[1],p=[t.view.container.clientWidth,t.view.container.clientHeight],d=p[0],y=p[1],v=t.view.area,m=d/u.width,g=y/u.height,w=Math.min(.9*g,.9*m,1);v.transform.x=v.container.clientWidth/2-l*w,v.transform.y=v.container.clientHeight/2-f*w,v.zoom(w,0,0),v.update()}}}); | ||
//# sourceMappingURL=area-plugin.min.js.map |
{ | ||
"name": "rete-area-plugin", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "", | ||
@@ -13,3 +13,5 @@ "main": "build/area-plugin.min.js", | ||
"license": "ISC", | ||
"dependencies": {}, | ||
"dependencies": { | ||
"rollup-plugin-sass": "^0.9.2" | ||
}, | ||
"devDependencies": { | ||
@@ -16,0 +18,0 @@ "rete-cli": "^0.1.0" |
@@ -0,4 +1,12 @@ | ||
import sass from 'rollup-plugin-sass'; | ||
export default { | ||
input: 'src/index.js', | ||
name: 'AreaPlugin' | ||
name: 'AreaPlugin', | ||
plugins: [ | ||
sass({ | ||
insert: true | ||
}) | ||
] | ||
} |
@@ -1,80 +0,16 @@ | ||
const min = (arr) => Math.min(...arr); | ||
const max = (arr) => Math.max(...arr); | ||
import './style.sass'; | ||
import { Background } from './background'; | ||
import { Restrictor } from './restrictor'; | ||
import { SnapGrid } from './snap'; | ||
import { zoomAt } from './zoom-at'; | ||
function nodesBBox(editor, nodes) { | ||
const left = min(nodes.map(node => node.position[0])); | ||
const top = min(nodes.map(node => node.position[1])); | ||
const right = max(nodes.map(node => node.position[0] + editor.view.nodes.get(node).el.clientWidth)); | ||
const bottom = max(nodes.map(node => node.position[1] + editor.view.nodes.get(node).el.clientHeight)); | ||
return { | ||
left, | ||
right, | ||
top, | ||
bottom, | ||
width: Math.abs(left - right), | ||
height: Math.abs(top - bottom), | ||
getCenter: () => { | ||
return [ | ||
(left + right) / 2, | ||
(top + bottom) / 2 | ||
]; | ||
} | ||
}; | ||
} | ||
function zoomAt(editor, nodes = editor.nodes) { | ||
const bbox = nodesBBox(editor, nodes); | ||
const [x, y] = bbox.getCenter(); | ||
const [w, h] = [editor.view.container.clientWidth, editor.view.container.clientHeight]; | ||
const { area } = editor.view; | ||
var [kw, kh] = [w / bbox.width, h / bbox.height] | ||
var k = Math.min(kh * 0.9, kw * 0.9, 1); | ||
area.transform.x = area.container.clientWidth / 2 - x * k; | ||
area.transform.y = area.container.clientHeight / 2 - y * k; | ||
area.zoom(k, 0, 0); | ||
area.update(); | ||
} | ||
function install(editor, params) { | ||
params.background = params.background || false; | ||
params.snap = params.snap || { size: 16, dynamic: true }; | ||
params.scaleExtent = params.scaleExtent || { min: 0.1, max: 1 }; | ||
params.translateExtent = params.translateExtent || { width: 2000, height: 1000 }; | ||
editor.on('zoom', data => { | ||
const se = params.scaleExtent; | ||
const tr = data.transform; | ||
if (data.zoom < se.min) | ||
data.zoom = se.min; | ||
else if (data.zoom > se.max) | ||
data.zoom = se.max; | ||
}); | ||
editor.on('translate', data => { | ||
const te = params.translateExtent; | ||
const k = data.transform.k; | ||
const kw = te.width * k; | ||
const kh = te.height * k; | ||
const cx = editor.view.container.clientWidth / 2; | ||
const cy = editor.view.container.clientHeight / 2; | ||
data.x -= cx; | ||
data.y -= cy; | ||
if (data.x > kw) | ||
data.x = kw; | ||
else if (data.x < - kw) | ||
data.x = - kw; | ||
if (data.y > kh) | ||
data.y = kh; | ||
else if (data.y < - kh) | ||
data.y = - kh; | ||
data.x += cx; | ||
data.y += cy; | ||
}); | ||
const background = new Background(editor, params.background); | ||
const restrictor = new Restrictor(editor, params.scaleExtent, params.translateExtent) | ||
const snap = new SnapGrid(editor, params.snap); | ||
} | ||
@@ -81,0 +17,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24976
13
184
1
1
+ Addedrollup-plugin-sass@^0.9.2
+ Addedanymatch@2.0.0(transitive)
+ Addedarr-diff@4.0.0(transitive)
+ Addedarr-flatten@1.1.0(transitive)
+ Addedarr-union@3.1.0(transitive)
+ Addedarray-unique@0.3.2(transitive)
+ Addedassign-symbols@1.0.0(transitive)
+ Addedasync-each@1.0.6(transitive)
+ Addedatob@2.1.2(transitive)
+ Addedbabel-runtime@6.26.0(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbase@0.11.2(transitive)
+ Addedbinary-extensions@1.13.1(transitive)
+ Addedbindings@1.5.0(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedbraces@2.3.2(transitive)
+ Addedcache-base@1.0.1(transitive)
+ Addedchokidar@2.1.8(transitive)
+ Addedclass-utils@0.3.6(transitive)
+ Addedcollection-visit@1.0.0(transitive)
+ Addedcomponent-emitter@1.3.1(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedcopy-descriptor@0.1.1(transitive)
+ Addedcore-js@2.6.12(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddecode-uri-component@0.2.2(transitive)
+ Addeddefine-property@0.2.51.0.02.0.2(transitive)
+ Addedestree-walker@0.6.1(transitive)
+ Addedexpand-brackets@2.1.4(transitive)
+ Addedextend-shallow@2.0.13.0.2(transitive)
+ Addedextglob@2.0.4(transitive)
+ Addedfile-uri-to-path@1.0.0(transitive)
+ Addedfill-range@4.0.0(transitive)
+ Addedfor-in@1.0.2(transitive)
+ Addedfragment-cache@0.2.1(transitive)
+ Addedfs-extra@0.30.0(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedfsevents@1.2.13(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-value@2.0.6(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedglob-parent@3.1.0(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhas-value@0.3.11.0.0(transitive)
+ Addedhas-values@0.1.41.0.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-accessor-descriptor@1.0.1(transitive)
+ Addedis-binary-path@1.0.1(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedis-core-module@2.16.0(transitive)
+ Addedis-data-descriptor@1.0.1(transitive)
+ Addedis-descriptor@0.1.71.0.3(transitive)
+ Addedis-extendable@0.1.11.0.1(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-glob@3.1.04.0.3(transitive)
+ Addedis-number@3.0.0(transitive)
+ Addedis-plain-object@2.0.4(transitive)
+ Addedis-windows@1.0.2(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedisobject@2.1.03.0.1(transitive)
+ Addedjsonfile@2.4.0(transitive)
+ Addedkind-of@3.2.24.0.06.0.3(transitive)
+ Addedklaw@1.3.1(transitive)
+ Addedmap-cache@0.2.2(transitive)
+ Addedmap-visit@1.0.0(transitive)
+ Addedmicromatch@3.1.10(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedmixin-deep@1.3.2(transitive)
+ Addedms@2.0.0(transitive)
+ Addednan@2.22.0(transitive)
+ Addednanomatch@1.2.13(transitive)
+ Addednormalize-path@2.1.13.0.0(transitive)
+ Addedobject-copy@0.1.0(transitive)
+ Addedobject-visit@1.0.1(transitive)
+ Addedobject.pick@1.3.0(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpascalcase@0.1.1(transitive)
+ Addedpath-dirname@1.0.2(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedpath-parse@1.0.7(transitive)
+ Addedpify@3.0.0(transitive)
+ Addedposix-character-classes@0.1.1(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedreaddirp@2.2.1(transitive)
+ Addedregenerator-runtime@0.11.1(transitive)
+ Addedregex-not@1.0.2(transitive)
+ Addedremove-trailing-separator@1.1.0(transitive)
+ Addedrepeat-element@1.1.4(transitive)
+ Addedrepeat-string@1.6.1(transitive)
+ Addedresolve@1.22.9(transitive)
+ Addedresolve-url@0.2.1(transitive)
+ Addedret@0.1.15(transitive)
+ Addedrimraf@2.7.1(transitive)
+ Addedrollup-plugin-sass@0.9.3(transitive)
+ Addedrollup-pluginutils@2.8.2(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedsafe-regex@1.1.0(transitive)
+ Addedsass@1.7.2(transitive)
+ Addedset-value@2.0.1(transitive)
+ Addedsnapdragon@0.8.2(transitive)
+ Addedsnapdragon-node@2.1.1(transitive)
+ Addedsnapdragon-util@3.0.1(transitive)
+ Addedsource-map@0.5.7(transitive)
+ Addedsource-map-resolve@0.5.3(transitive)
+ Addedsource-map-url@0.4.1(transitive)
+ Addedsplit-string@3.1.0(transitive)
+ Addedstatic-extend@0.1.2(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedsupports-preserve-symlinks-flag@1.0.0(transitive)
+ Addedto-object-path@0.3.0(transitive)
+ Addedto-regex@3.0.2(transitive)
+ Addedto-regex-range@2.1.1(transitive)
+ Addedunion-value@1.0.1(transitive)
+ Addedunset-value@1.0.0(transitive)
+ Addedupath@1.2.0(transitive)
+ Addedurix@0.1.0(transitive)
+ Addeduse@3.1.1(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedwrappy@1.0.2(transitive)