protvista-utils
Advanced tools
Comparing version 2.3.0 to 2.10.0
@@ -1,2 +0,2 @@ | ||
var ProtvistaUtils=function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function n(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}t.exports=function(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),t}},function(t,e,n){var i=n(4),r=n(5),o=n(6);t.exports=function(t,e){return i(t)||r(t,e)||o()}},function(t,e,n){t.exports=n(7)},function(t,e){t.exports=function(t){if(Array.isArray(t))return t}},function(t,e){t.exports=function(t,e){var n=[],i=!0,r=!1,o=void 0;try{for(var h,l=t[Symbol.iterator]();!(i=(h=l.next()).done)&&(n.push(h.value),!e||n.length!==e);i=!0);}catch(t){r=!0,o=t}finally{try{i||null==l.return||l.return()}finally{if(r)throw o}}return n}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(t,e,n){"use strict";n.r(e);var i=n(2),r=n.n(i),o=n(0),h=n.n(o),l=n(1),a=n.n(l),s=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.min,i=void 0===n?-1/0:n,r=e.max,o=void 0===r?1/0:r;h()(this,t),this.segments=[],this.max=o,this.min=i,this.regionString=null}return a()(t,[{key:"encode",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.segments.map(function(n){var i=n.start,r=n.end;if(e)return"".concat(i,":").concat(r);var o=i===t.min?"":i,h=r===t.max?"":r;return"".concat(o,":").concat(h)}).join(",")}},{key:"decode",value:function(t){var e=this;void 0!==t&&(this.regionString=t),this.regionString?this.segments=this.regionString.split(",").map(function(t){var n=t.split(":"),i=r()(n,3),o=i[0],h=i[1];if(void 0!==i[2])throw new Error("there should be at most 1 ':' per region. Region: ".concat(t));var l=o?Number(o):e.min,a=h?Number(h):e.max;if(l>a){var s=[a,l];l=s[0],a=s[1]}if(l<e.min&&(l=e.min),a>e.max&&(a=e.max),Number.isNaN(l))throw new Error("The parsed value of ".concat(o," is NaN. Region: ").concat(t));if(Number.isNaN(a))throw new Error("The parsed value of ".concat(h," is NaN. Region: ").concat(t));return{start:l,end:a}}):this.segments=[]}}]),t}(),u=function(t,e){return t?e?"".concat(t,",").concat(e):t:e},c=function(){function t(e){var n=e.element,i=e.min,r=e.max;h()(this,t),this.element=n,this.region=new s({min:i,max:r}),this.fixedHighlight=null}return a()(t,[{key:"setAttributesInElement",value:function(){this.region.decode(this.element.getAttribute("highlight")),0===this.region.segments.length&&(this.element._highlightstart=Number(this.element.getAttribute("highlightstart")),this.element._highlightend=Number(this.element.getAttribute("highlightend")),null!==this.element._highlightstart&&null!==this.element._highlightend&&"number"==typeof this.element._highlightstart&&"number"==typeof this.element._highlightend&&(this.element._highlight="".concat(this.element._highlightstart,":").concat(this.element._highlightend),this.region.decode(u(this.fixedHighlight,this.element._highlight))))}},{key:"setFloatAttribute",value:function(t,e){var n=parseFloat(e);this.element["_".concat(t)]=Number.isNaN(n)?e:n}},{key:"changedCallBack",value:function(t,e){switch(t){case"highlightstart":case"highlightend":this.setFloatAttribute(t,e),this.element._highlight=Number.isNaN(this.element._highlightstart)||Number.isNaN(this.element._highlightend)||void 0===this.element._highlightstart||void 0===this.element._highlightend||null===this.element._highlightstart||null===this.element._highlightend?"":"".concat(Math.max(this.region.min,this.element._highlightstart),":").concat(Math.min(this.region.max,this.element._highlightend));break;default:this.element._highlight=e}this.region.decode(u(this.fixedHighlight,this.element._highlight)),this.element.refresh()}},{key:"setFixedHighlight",value:function(t){this.fixedHighlight=t,this.region.decode(u(t,this.element._highlight)),this.element.refresh()}},{key:"appendHighlightTo",value:function(t){this.highlighted=t.append("g").attr("class","highlighted")}},{key:"updateHighlight",value:function(){var t=this,e=this.highlighted.selectAll("rect").data(this.region.segments);e.enter().append("rect").style("opacity",.5).attr("fill","rgba(255, 235, 59, 0.8)").style("pointer-events","none").merge(e).attr("height",this.element._height).attr("x",function(e){return t.element.getXFromSeqPosition(e.start)}).attr("width",function(e){return t.element.getSingleBaseWidth()*(e.end-e.start+1)}),e.exit().remove()}},{key:"max",set:function(t){this.region.max=t}}]),t}();function g(t){var e=document.createElement("div");return e.style.borderColor="",e.style.borderColor=t,""!==e.style.borderColor}var f=function(t){return t};n.d(e,"Region",function(){return m}),n.d(e,"TrackHighlighter",function(){return d}),n.d(e,"ColorScaleParser",function(){return v}),n.d(e,"String2Object",function(){return p});var m=s,d=c,v=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=[],n=[];if(null!==t&&"string"!=typeof t)throw new Error("The attribute text has to be of type string");if(t&&""!==t.trim()){var i=t.split(",").map(function(t){return t.split(":")});if(i.length<2)throw new Error("There should be at least 2 points to create a scale");e=i.map(function(t){var e=t[0].trim().toUpperCase();if(!g(e))throw new Error("The color '".concat(e," is not valid'"));return e}),n=i.map(function(t,e){var n=parseFloat(t[1]);if(Number.isNaN(n))throw new Error("The second part of every point should be a number. Error in point ".concat(e,": ").concat(t));return n})}return{range:e,domain:n}},p=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.keyFormatter,i=void 0===n?f:n,r=e.valueFormatter,o=void 0===r?f:r;if(null!==t&&"string"!=typeof t)throw new Error("The attribute text has to be of type string");if(t&&""!==t.trim()){var h=t.split(",").map(function(t){return t.split(":")}),l={};return h.forEach(function(t){if(2!==t.length)throw new Error("Bad block: ".concat(t.join(":"),"\n The blocks of the string should follow the format KEY:VALUE"));l[i(t[0])]=o(t[1])}),l}return{}}}]); | ||
var ProtvistaUtils=function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function n(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}t.exports=function(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),t}},function(t,e,n){var i=n(4),r=n(5),o=n(6);t.exports=function(t,e){return i(t)||r(t,e)||o()}},function(t,e,n){t.exports=n(7)},function(t,e){t.exports=function(t){if(Array.isArray(t))return t}},function(t,e){t.exports=function(t,e){var n=[],i=!0,r=!1,o=void 0;try{for(var l,h=t[Symbol.iterator]();!(i=(l=h.next()).done)&&(n.push(l.value),!e||n.length!==e);i=!0);}catch(t){r=!0,o=t}finally{try{i||null==h.return||h.return()}finally{if(r)throw o}}return n}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(t,e,n){"use strict";n.r(e);var i=n(2),r=n.n(i),o=n(0),l=n.n(o),h=n(1),a=n.n(h),s=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.min,i=void 0===n?-1/0:n,r=e.max,o=void 0===r?1/0:r;l()(this,t),this.segments=[],this.max=o,this.min=i,this.regionString=null}return a()(t,[{key:"encode",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.segments.map(function(n){var i=n.start,r=n.end;if(e)return"".concat(i,":").concat(r);var o=i===t.min?"":i,l=r===t.max?"":r;return"".concat(o,":").concat(l)}).join(",")}},{key:"decode",value:function(t){var e=this;void 0!==t&&(this.regionString=t),this.regionString?this.segments=this.regionString.split(",").map(function(t){var n=t.split(":"),i=r()(n,3),o=i[0],l=i[1];if(void 0!==i[2])throw new Error("there should be at most 1 ':' per region. Region: ".concat(t));var h=o?Number(o):e.min,a=l?Number(l):e.max;if(h>a){var s=[a,h];h=s[0],a=s[1]}if(h<e.min&&(h=e.min),a>e.max&&(a=e.max),Number.isNaN(h))throw new Error("The parsed value of ".concat(o," is NaN. Region: ").concat(t));if(Number.isNaN(a))throw new Error("The parsed value of ".concat(l," is NaN. Region: ").concat(t));return{start:h,end:a}}):this.segments=[]}}]),t}(),u=function(t,e){return t?e?"".concat(t,",").concat(e):t:e},c=function(){function t(e){var n=e.element,i=e.min,r=e.max;l()(this,t),this.element=n,this.region=new s({min:i,max:r}),this.fixedHighlight=null}return a()(t,[{key:"setAttributesInElement",value:function(){this.region.decode(this.element.getAttribute("highlight")),0===this.region.segments.length&&(this.element._highlightstart=Number(this.element.getAttribute("highlightstart")),this.element._highlightend=Number(this.element.getAttribute("highlightend")),null!==this.element._highlightstart&&null!==this.element._highlightend&&"number"==typeof this.element._highlightstart&&"number"==typeof this.element._highlightend&&(this.element._highlight="".concat(this.element._highlightstart,":").concat(this.element._highlightend),this.region.decode(u(this.fixedHighlight,this.element._highlight))))}},{key:"setFloatAttribute",value:function(t,e){var n=parseFloat(e);this.element["_".concat(t)]=Number.isNaN(n)?e:n}},{key:"changedCallBack",value:function(t,e){switch(t){case"highlightstart":case"highlightend":this.setFloatAttribute(t,e),this.element._highlight=Number.isNaN(this.element._highlightstart)||Number.isNaN(this.element._highlightend)||void 0===this.element._highlightstart||void 0===this.element._highlightend||null===this.element._highlightstart||null===this.element._highlightend?"":"".concat(Math.max(this.region.min,this.element._highlightstart),":").concat(Math.min(this.region.max,this.element._highlightend));break;default:this.element._highlight=e}this.region.decode(u(this.fixedHighlight,this.element._highlight)),this.element.refresh()}},{key:"setFixedHighlight",value:function(t){this.fixedHighlight=t,this.region.decode(u(t,this.element._highlight)),this.element.refresh()}},{key:"appendHighlightTo",value:function(t){this.highlighted=t.append("g").attr("class","highlighted")}},{key:"updateHighlight",value:function(){var t=this,e=this.highlighted.selectAll("rect").data(this.region.segments);e.enter().append("rect").style("opacity",.5).attr("fill","rgba(255, 235, 59, 0.8)").style("pointer-events","none").merge(e).attr("height",this.element._height).attr("x",function(e){return t.element.getXFromSeqPosition(e.start)}).attr("width",function(e){return t.element.getSingleBaseWidth()*(e.end-e.start+1)}),e.exit().remove()}},{key:"max",set:function(t){this.region.max=t}}]),t}();function g(t){var e=document.createElement("div");return e.style.borderColor="",e.style.borderColor=t,""!==e.style.borderColor}var m=function(t){return t},f=function(){function t(e){l()(this,t),this.element=e,this.timeStampWheelOutside=0,this.resetScrollableTimeout=null}return a()(t,[{key:"setElementScrollable",value:function(t){this.element.setAttribute("scrollable",t)}},{key:"startResetScrollableTimer",value:function(){var t=this;this.resetScrollableTimeout&&clearTimeout(this.resetScrollableTimeout),this.resetScrollableTimeout=setTimeout(function(){t.setElementScrollable(!0),t.resetScrollableTimeout=null},400)}},{key:"blockScroll",value:function(t){this.timeStampWheelOutside=t,this.setElementScrollable(!1),this.startResetScrollableTimer()}},{key:"isWheelEventInsideElement",value:function(t,e){var n=this.element.getBoundingClientRect(),i=n.height,r=n.width,o=n.x,l=n.y;return t>o&&e<o+r&&e>l&&e<l+i}},{key:"wheel",value:function(t){var e=t.x,n=t.y,i=t.timeStamp;this.isWheelEventInsideElement(e,n)?i<this.timeStampWheelOutside+400?this.blockScroll(i):this.setElementScrollable(!0):this.blockScroll(i)}}]),t}();n.d(e,"Region",function(){return d}),n.d(e,"TrackHighlighter",function(){return v}),n.d(e,"ColorScaleParser",function(){return p}),n.d(e,"String2Object",function(){return b}),n.d(e,"ScrollFilter",function(){return y});var d=s,v=c,p=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=[],n=[];if(null!==t&&"string"!=typeof t)throw new Error("The attribute text has to be of type string");if(t&&""!==t.trim()){var i=t.split(",").map(function(t){return t.split(":")});if(i.length<2)throw new Error("There should be at least 2 points to create a scale");e=i.map(function(t){var e=t[0].trim().toUpperCase();if(!g(e))throw new Error("The color '".concat(e," is not valid'"));return e}),n=i.map(function(t,e){var n=parseFloat(t[1]);if(Number.isNaN(n))throw new Error("The second part of every point should be a number. Error in point ".concat(e,": ").concat(t));return n})}return{range:e,domain:n}},b=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.keyFormatter,i=void 0===n?m:n,r=e.valueFormatter,o=void 0===r?m:r;if(null!==t&&"string"!=typeof t)throw new Error("The attribute text has to be of type string");if(t&&""!==t.trim()){var l=t.split(",").map(function(t){return t.split(":")}),h={};return l.forEach(function(t){if(2!==t.length)throw new Error("Bad block: ".concat(t.join(":"),"\n The blocks of the string should follow the format KEY:VALUE"));h[i(t[0])]=o(t[1])}),h}return{}},y=f}]); | ||
//# sourceMappingURL=protvista-utils.js.map |
{ | ||
"name": "protvista-utils", | ||
"version": "2.3.0", | ||
"version": "2.10.0", | ||
"description": "Collection of utilities for ProtVista components", | ||
@@ -29,3 +29,3 @@ "files": [ | ||
"license": "ISC", | ||
"gitHead": "fdde8de5638a363b75bddeb2309e84fd194b6ad4" | ||
"gitHead": "716f528deeaebcc4acb7f22c0328a1ac5c327bf7" | ||
} |
@@ -5,2 +5,3 @@ import _Region from "./Region"; | ||
import _s2o from "./String2Object"; | ||
import _sf from "./ScrollFilter"; | ||
@@ -11,1 +12,2 @@ export const Region = _Region; | ||
export const String2Object = _s2o; | ||
export const ScrollFilter = _sf; |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
52140
13
545
1