From bb5a7eefa91cc7d49135aaeca1546c0a9bee05b1 Mon Sep 17 00:00:00 2001 From: Jan Dolejsi Date: Wed, 22 Nov 2023 12:42:27 +0100 Subject: [PATCH 1/2] prepack script, v1.7.1 --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fb64234..a3706e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "arrows-svg", - "version": "1.7.0", + "version": "1.7.1", "description": "SVG arrow between two HTML elements", "keywords": [ "arrow", @@ -16,7 +16,8 @@ "ts:watch": "tsc -p ./ --watch", "ts:build": "tsc -p ./", "test": "jest --coverage", - "lint": "eslint '*/**/*.{js,ts,tsx}' --fix" + "lint": "eslint '*/**/*.{js,ts,tsx}' --fix", + "prepack": "npm run build" }, "repository": { "type": "git", From 28c11a3a36dc7c734e9a305a2006e189e3600ad2 Mon Sep 17 00:00:00 2001 From: Jan Dolejsi Date: Wed, 22 Nov 2023 12:43:56 +0100 Subject: [PATCH 2/2] package and repo clean-up --- .npmignore | 4 +++- dist/main.js | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) delete mode 100644 dist/main.js diff --git a/.npmignore b/.npmignore index 209f16b..f94cc8d 100644 --- a/.npmignore +++ b/.npmignore @@ -11,4 +11,6 @@ tsconfig.json webpack.config.js /.vscode *.tgz -/out \ No newline at end of file +/out +/types/*.test.d.ts +/types/tests/ \ No newline at end of file diff --git a/dist/main.js b/dist/main.js deleted file mode 100644 index 4c85e8b..0000000 --- a/dist/main.js +++ /dev/null @@ -1 +0,0 @@ -!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(self,(()=>(()=>{"use strict";var e={400:(e,t,n)=>{n.r(t),n.d(t,{Component:()=>g,Fragment:()=>m,cloneElement:()=>U,createContext:()=>B,createElement:()=>p,createRef:()=>y,h:()=>p,hydrate:()=>F,isValidElement:()=>u,options:()=>o,render:()=>R,toChildArray:()=>A});var r,o,i,u,_,a,l,c={},f=[],s=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function d(e,t){for(var n in t)e[n]=t[n];return e}function h(e){var t=e.parentNode;t&&t.removeChild(e)}function p(e,t,n){var o,i,u,_={};for(u in t)"key"==u?o=t[u]:"ref"==u?i=t[u]:_[u]=t[u];if(arguments.length>2&&(_.children=arguments.length>3?r.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(u in e.defaultProps)void 0===_[u]&&(_[u]=e.defaultProps[u]);return v(e,_,o,i,null)}function v(e,t,n,r,u){var _={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==u?++i:u};return null==u&&null!=o.vnode&&o.vnode(_),_}function y(){return{current:null}}function m(e){return e.children}function g(e,t){this.props=e,this.context=t}function b(e,t){if(null==t)return e.__?b(e.__,e.__.__k.indexOf(e)+1):null;for(var n;t0?v(p.type,p.props,p.key,p.ref?p.ref:null,p.__v):p)){if(p.__=n,p.__b=n.__b+1,null===(h=x[s])||h&&p.key==h.key&&p.type===h.type)x[s]=void 0;else for(d=0;d2&&(_.children=arguments.length>3?r.call(arguments,2):n),v(e.type,_,o||e.key,i||e.ref,null)}function B(e,t){var n={__c:t="__cC"+l++,__:e,Consumer:function(e,t){return e.children(t)},Provider:function(e){var n,r;return this.getChildContext||(n=[],(r={})[t]=this,this.getChildContext=function(){return r},this.shouldComponentUpdate=function(e){this.props.value!==e.value&&n.some(x)},this.sub=function(e){n.push(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n.splice(n.indexOf(e),1),t&&t.call(e)}}),e.children}};return n.Provider.__=n.Consumer.contextType=n}r=f.slice,o={__e:function(e,t,n,r){for(var o,i,u;t=t.__;)if((o=t.__c)&&!o.__)try{if((i=o.constructor)&&null!=i.getDerivedStateFromError&&(o.setState(i.getDerivedStateFromError(e)),u=o.__d),null!=o.componentDidCatch&&(o.componentDidCatch(e,r||{}),u=o.__d),u)return o.__E=o}catch(t){e=t}throw e}},i=0,u=function(e){return null!=e&&void 0===e.constructor},g.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=d({},this.state),"function"==typeof e&&(e=e(d({},n),this.props)),e&&d(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),x(this))},g.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),x(this))},g.prototype.render=m,_=[],E.__r=0,l=0},396:(e,t,n)=>{n.r(t),n.d(t,{useCallback:()=>w,useContext:()=>O,useDebugValue:()=>A,useEffect:()=>g,useErrorBoundary:()=>P,useId:()=>M,useImperativeHandle:()=>x,useLayoutEffect:()=>b,useMemo:()=>E,useReducer:()=>m,useRef:()=>T,useState:()=>y});var r,o,i,u,_=n(400),a=0,l=[],c=[],f=_.options.__b,s=_.options.__r,d=_.options.diffed,h=_.options.__c,p=_.options.unmount;function v(e,t){_.options.__h&&_.options.__h(o,e,a||t),a=0;var n=o.__H||(o.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({__V:c}),n.__[e]}function y(e){return a=1,m(k,e)}function m(e,t,n){var i=v(r++,2);if(i.t=e,!i.__c&&(i.__=[n?n(t):k(void 0,t),function(e){var t=i.__N?i.__N[0]:i.__[0],n=i.t(t,e);t!==n&&(i.__N=[n,i.__[1]],i.__c.setState({}))}],i.__c=o,!o.u)){o.u=!0;var u=o.shouldComponentUpdate;o.shouldComponentUpdate=function(e,t,n){if(!i.__c.__H)return!0;var r=i.__c.__H.__.filter((function(e){return e.__c}));if(r.every((function(e){return!e.__N})))return!u||u.call(this,e,t,n);var o=!1;return r.forEach((function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}})),!(!o&&i.__c.props===e)&&(!u||u.call(this,e,t,n))}}return i.__N||i.__}function g(e,t){var n=v(r++,3);!_.options.__s&&S(n.__H,t)&&(n.__=e,n.i=t,o.__H.__h.push(n))}function b(e,t){var n=v(r++,4);!_.options.__s&&S(n.__H,t)&&(n.__=e,n.i=t,o.__h.push(n))}function T(e){return a=5,E((function(){return{current:e}}),[])}function x(e,t,n){a=6,b((function(){return"function"==typeof e?(e(t()),function(){return e(null)}):e?(e.current=t(),function(){return e.current=null}):void 0}),null==n?n:n.concat(e))}function E(e,t){var n=v(r++,7);return S(n.__H,t)?(n.__V=e(),n.i=t,n.__h=e,n.__V):n.__}function w(e,t){return a=8,E((function(){return e}),t)}function O(e){var t=o.context[e.__c],n=v(r++,9);return n.c=e,t?(null==n.__&&(n.__=!0,t.sub(o)),t.props.value):e.__}function A(e,t){_.options.useDebugValue&&_.options.useDebugValue(t?t(e):e)}function P(e){var t=v(r++,10),n=y();return t.__=e,o.componentDidCatch||(o.componentDidCatch=function(e,r){t.__&&t.__(e,r),n[1](e)}),[n[0],function(){n[1](void 0)}]}function M(){var e=v(r++,11);if(!e.__){for(var t=o.__v;null!==t&&!t.__m&&null!==t.__;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__="P"+n[0]+"-"+n[1]++}return e.__}function D(){for(var e;e=l.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(I),e.__H.__h.forEach(N),e.__H.__h=[]}catch(t){e.__H.__h=[],_.options.__e(t,e.__v)}}_.options.__b=function(e){o=null,f&&f(e)},_.options.__r=function(e){s&&s(e),r=0;var t=(o=e.__c).__H;t&&(i===o?(t.__h=[],o.__h=[],t.__.forEach((function(e){e.__N&&(e.__=e.__N),e.__V=c,e.__N=e.i=void 0}))):(t.__h.forEach(I),t.__h.forEach(N),t.__h=[])),i=o},_.options.diffed=function(e){d&&d(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==l.push(t)&&u===_.options.requestAnimationFrame||((u=_.options.requestAnimationFrame)||C)(D)),t.__H.__.forEach((function(e){e.i&&(e.__H=e.i),e.__V!==c&&(e.__=e.__V),e.i=void 0,e.__V=c}))),i=o=null},_.options.__c=function(e,t){t.some((function(e){try{e.__h.forEach(I),e.__h=e.__h.filter((function(e){return!e.__||N(e)}))}catch(n){t.some((function(e){e.__h&&(e.__h=[])})),t=[],_.options.__e(n,e.__v)}})),h&&h(e,t)},_.options.unmount=function(e){p&&p(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach((function(e){try{I(e)}catch(e){t=e}})),n.__H=void 0,t&&_.options.__e(t,n.__v))};var H="function"==typeof requestAnimationFrame;function C(e){var t,n=function(){clearTimeout(r),H&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,100);H&&(t=requestAnimationFrame(n))}function I(e){var t=o,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),o=t}function N(e){var t=o;e.__c=e.__(),o=t}function S(e,t){return!e||e.length!==t.length||t.some((function(t,n){return t!==e[n]}))}function k(e,t){return"function"==typeof t?t(e):t}},515:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;nMath.abs(e.y-n.y)?e.x ...}");if(!c)throw new Error("undefined to, try to pass it as to={() => ...}");return o.render(o.h(t.Arrow,{className:r,head:u,from:a.castToAnchor(_),to:a.castToAnchor(c),forwardRef:s,updateDelay:f}),d),{node:d,clear:function(){var e=s.current,t=e.parentNode;t&&t.removeChild(e)}}}},778:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});var r=n(515),o=n(240),i=n(981),u=n(945);t.default=function(e,t,n){var _=i.prepareHeads(n),a=i.calculateHeadsPadding(_),l=r.createAnchorWithPoint(e),c=r.createAnchorWithPoint(t),f=o.produceContainer(r.autoAnchorWithPoint(l,c),r.autoAnchorWithPoint(c,l),a),s=u.pathListBezier(f,a),d=i.assignPathToHeads(_,s),h=u.convertPathToSVG(s),p=function(e,t){var n=u.pathReducer(e,(function(e,t){return{x:Math.max(e.x,t.x),y:Math.max(e.y,t.y)}}));return{width:n.x+2*t.width,height:n.y+2*t.height}}(s,a),v=function(e,t,n){var r=function(t){return Math.min(e[0][t]-n.width,e[3][t]-n.height)};return{x:t.position.x-r("x")-n.width,y:t.position.y-r("y")-n.height}}(s,f,a);return{pathCommands:h,size:p,offset:v,heads:d}}},312:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DIRECTION=t.HEAD_DEFAULT_SIZE=void 0,t.HEAD_DEFAULT_SIZE=10,t.DIRECTION={TOP_LEFT:"top-left",TOP:"top",TOP_RIGHT:"top-right",RIGHT:"right",BOTTOM_LEFT:"bottom-left",BOTTOM:"bottom",BOTTOM_RIGHT:"bottom-right",LEFT:"left"}},240:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;nn.width&&(n.width=t.width),t.height>n.height&&(n.height=t.height),n}),{width:0,height:0})},t.assignPathToHeads=function(e,t){return e.map((function(e,n){return r(r(r({id:n},e),function(e,t){var n=e.distance,r=function(e){return Math.pow(1-n,2)*(t[1][e]-t[0][e])+2*n*(1-n)*(t[2][e]-t[1][e])+n*n*(t[3][e]-t[2][e])},o=r("x"),u=r("y"),_=i(-Math.atan2(o,u)+.5*Math.PI);return{degree:i(_*(180/Math.PI)),radius:_}}(e,t)),function(e,t){var n=e.distance,r=function(e){return Math.pow(1-n,3)*t[0][e]+3*n*Math.pow(1-n,2)*t[1][e]+3*n*n*(1-n)*t[2][e]+n*n*n*t[3][e]};return{x:r("x"),y:r("y")}}(e,t))}))},t.headTransformCSS=function(e){return"rotate("+e.degree+", "+e.x+", "+e.y+"), translate("+e.x+", "+e.y+")"}},981:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.HEAD=void 0,o(n(382),t);var i=n(740);Object.defineProperty(t,"HEAD",{enumerable:!0,get:function(){return i.default}})},380:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});var r=n(400),o=n(312);t.default=function(e){var t=e.size,n=void 0===t?o.HEAD_DEFAULT_SIZE:t;return{node:r.h("g",{transform:"translate(-"+n+", 0)"},r.h("path",{d:"M"+-n+" 0 L0 "+-n+" L"+n+" 0 L0 "+n+" Z"})),width:n,height:n}}},796:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});var r=n(400),o=n(312);t.default=function(e){var t=e.size,n=void 0===t?o.HEAD_DEFAULT_SIZE:t;return{node:r.h("g",{transform:"translate(-"+n+", 0)"},r.h("circle",{cx:0,cy:0,r:n})),width:n,height:n}}},591:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){var t=e.src,n=e.width,r=e.height;if(!t||!n||!r)throw new Error("image requires src, height, width");var o=document.createElementNS("http://www.w3.org/2000/svg","image");return o.setAttributeNS(null,"width",String(n)),o.setAttributeNS(null,"height",String(r)),o.setAttributeNS(null,"x",String(-n)),o.setAttributeNS(null,"y",String(-r/2)),o.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t),{node:o,width:n,height:r}}},740:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});var r=n(380),o=n(796),i=n(591),u=n(729),_=n(777),a=n(263),l=n(549),c=n(579),f={diamond:r.default,DIAMOND:r.default,dot:o.default,DOT:o.default,image:i.default,IMAGE:i.default,none:a.default,NONE:a.default,inv:u.default,INV:u.default,normal:_.default,NORMAL:_.default,thin:l.default,THIN:l.default,vee:c.default,VEE:c.default};t.default=f},729:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});var r=n(400),o=n(312);t.default=function(e){var t=e.size,n=void 0===t?o.HEAD_DEFAULT_SIZE:t;return{node:r.h("path",{d:"M"+-n+" 0 L0 "+-n+" L0 "+n+" Z"}),width:n,height:n}}},263:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});var r=n(312);t.default=function(){return{node:null,width:r.HEAD_DEFAULT_SIZE,height:r.HEAD_DEFAULT_SIZE}}},777:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});var r=n(400),o=n(312);t.default=function(e){var t=e.size,n=void 0===t?o.HEAD_DEFAULT_SIZE:t;return{node:r.h("path",{d:"M"+-n+" "+-n+" L0 0 L"+-n+" "+n+" Z"}),width:n,height:n}}},549:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});var r=n(400),o=n(312);t.default=function(e){var t=e.size,n=void 0===t?o.HEAD_DEFAULT_SIZE:t;return{node:r.h("g",null,r.h("line",{x1:-n,y1:-n,x2:0,y2:0}),r.h("line",{x1:0,y1:0,x2:-n,y2:n})),width:n,height:n}}},579:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});var r=n(400),o=n(312);t.default=function(e){var t=e.size,n=void 0===t?o.HEAD_DEFAULT_SIZE:t;return{node:r.h("g",{transform:"translate(-"+n+", 0)"},r.h("path",{d:"M"+-n+" "+-n+" L"+n+" 0 L"+-n+" "+n+" L0 0 Z"})),width:n,height:n}}},773:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){var t="function"==typeof e?e():e;return document.body.contains(t)?t:null}},202:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.assignArrowCreate=void 0;var r=n(940);t.assignArrowCreate=function(e){e&&(e.arrowCreate=r.default)}},296:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});var r=n(773),o=["x","y","width","height"],i={from:null,to:null},u=function(e,t){var n=t.getBoundingClientRect();return e?{equal:!o.some((function(t){return e[t]!==n[t]})),rect:n}:{equal:!1,rect:n}};t.default=function(e,t,n){var o,_=n.updateDelay,a=void 0===_?0:_,l=n.update,c=i,f=function(){var n=r.default(e.node),o=r.default(t.node);if(n&&o){var _=function(e,t,n){var r=u(e.from,t),o=u(e.to,n);return r.equal&&o.equal?null:{from:r.rect,to:o.rect}}(c,n,o);_&&(c!==i&&l(),c=_)}};if(a){var s=setInterval(f,a);return{clear:function(){return clearInterval(s)}}}var d=function(){f(),o=requestAnimationFrame(d)};return o=requestAnimationFrame(d),{clear:function(){return cancelAnimationFrame(o)}}}},945:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pathListBezier=t.pathReducer=t.convertPathToSVG=void 0;var r=n(134);t.convertPathToSVG=function(e){var t=["M"];return t.push(r.pointToArray(e[0])),t.push("C"),t.push(r.pointToArray(e[1])),t.push(","),t.push(r.pointToArray(e[2])),t.push(","),t.push(r.pointToArray(e[3])),t.flat().join(" ").replace(/ ,/g,",")},t.pathReducer=function(e,t){return e.reduce((function(e,n){return t(e,n)}))},t.pathListBezier=function(e,n){var o=[];return o.push(e.relativeFrom),o.push(r.pointBezier(e.relativeFrom,e.size)),o.push(r.pointBezier(e.relativeTo,e.size)),o.push(e.relativeTo),function(e,n){var r=t.pathReducer(e,(function(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y)}}));return e.map((function(e){return{x:e.x-r.x+n.width,y:e.y-r.y+n.height}}))}(o,n)}},134:function(e,t){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.HEAD=e.DIRECTION=e.arrowCreate=void 0;var t=n(202),o=n(940);e.arrowCreate=o.default,t.assignArrowCreate(window),e.default=o.default;var i=n(312);Object.defineProperty(e,"DIRECTION",{enumerable:!0,get:function(){return i.DIRECTION}});var u=n(981);Object.defineProperty(e,"HEAD",{enumerable:!0,get:function(){return u.HEAD}})})(),r})())); \ No newline at end of file