Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rete-area-plugin

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rete-area-plugin - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

src/background.js

4

build/area-plugin.min.js
/*!
* 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc