@rnacanvas/draw.svg 3.8.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -50,7 +50,7 @@ p; // { x: 5, y: 0, length: 5 }
50
50
  A `precision` option can also be specified,
51
51
  which roughly controls the margin for error in the closest point calculation.
52
52
 
53
- (Lower precision improves the speed of calculation.)
53
+ (Higher margin for error improves the speed of calculation.)
54
54
 
55
55
  ```javascript
56
56
  // make the path a horizontal line
@@ -64,6 +64,29 @@ p; // { x: 40, y: 0, length: 40 }
64
64
 
65
65
  This method will throw if a precision of 0 or a negative precision is specified.
66
66
 
67
+ ## `class AbstractPath`
68
+
69
+ A way to do calculations related to SVG path elements
70
+ without having to worry about creating elements and/or adding them to the document body.
71
+
72
+ ```javascript
73
+ // a horizontal line
74
+ var path = new AbstractPath('M 0 0 L 100 0');
75
+
76
+ var p = path.closestPoint({ x: 33, y: -2 });
77
+
78
+ p.x; // 33
79
+ p.y; // 0
80
+ p.length; // 33
81
+ ```
82
+
83
+ ### `closestPoint()`
84
+
85
+ This method has the same interface as the `closestPoint()` method of the `Path` class [above](https://pzhaojohnson.github.io/rnacanvas.draw.svg/#class-path).
86
+
87
+ The main difference is that you don't have to worry about adding an abstract path to an SVG document (or the document body)
88
+ for closest point calculations to work.
89
+
67
90
  ## `setAttributes()`
68
91
 
69
92
  Set multiple attributes of a target SVG element at once.
@@ -0,0 +1,25 @@
1
+ /**
2
+ * A way to do calculations related to SVG path elements
3
+ * without having to worry about creating and adding elements to the document body (and so forth).
4
+ */
5
+ export declare class AbstractPath {
6
+ #private;
7
+ constructor(d: string);
8
+ /**
9
+ * Returns the closest point on the path to the specified point
10
+ * (as well as the length along the path that the closest point is at).
11
+ *
12
+ * This method is not guaranteed to return the true closest point (e.g., for particularly convoluted paths).
13
+ */
14
+ closestPoint(p: Point): {
15
+ x: number;
16
+ y: number;
17
+ length: number;
18
+ };
19
+ }
20
+ type Point = {
21
+ x: number;
22
+ y: number;
23
+ };
24
+ export {};
25
+ //# sourceMappingURL=AbstractPath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AbstractPath.d.ts","sourceRoot":"","sources":["../src/AbstractPath.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,qBAAa,YAAY;;gBAGX,CAAC,EAAE,MAAM;IAIrB;;;;;OAKG;IACH,YAAY,CAAC,CAAC,EAAE,KAAK;;;;;CAUtB;AAED,KAAK,KAAK,GAAG;IACX,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC"}
package/dist/Path.d.ts CHANGED
@@ -3,17 +3,11 @@ export declare class Path {
3
3
  constructor(domNode: SVGPathElement);
4
4
  /**
5
5
  * Returns the closest point along the path to the given point
6
- * (as well as the length along the path that the closest point is).
6
+ * (as well as the length along the path that the closest point is at).
7
7
  *
8
- * The precision option roughly corresponds to the margin for error in the closest point calculation.
9
- *
10
- * (Higher margin for error improves the speed of calculation.)
11
- *
12
- * This method will throw for non-positive precisions.
8
+ * This method is not guaranteed to return the true closest point (e.g., for particularly convoluted paths).
13
9
  */
14
- closestPoint(p: Point, options?: {
15
- precision?: number;
16
- }): {
10
+ closestPoint(p: Point): {
17
11
  x: number;
18
12
  y: number;
19
13
  length: number;
@@ -1 +1 @@
1
- {"version":3,"file":"Path.d.ts","sourceRoot":"","sources":["../src/Path.ts"],"names":[],"mappings":"AAEA,qBAAa,IAAI;IACH,QAAQ,CAAC,OAAO,EAAE,cAAc;gBAAvB,OAAO,EAAE,cAAc;IAE5C;;;;;;;;;OASG;IACH,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;CAuBxD;AAED,KAAK,KAAK,GAAG;IACX,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC"}
1
+ {"version":3,"file":"Path.d.ts","sourceRoot":"","sources":["../src/Path.ts"],"names":[],"mappings":"AAEA,qBAAa,IAAI;IACH,QAAQ,CAAC,OAAO,EAAE,cAAc;gBAAvB,OAAO,EAAE,cAAc;IAE5C;;;;;OAKG;IACH,YAAY,CAAC,CAAC,EAAE,KAAK;;;;;CAmDtB;AAED,KAAK,KAAK,GAAG;IACX,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { Path } from './Path';
2
2
  export { Path };
3
+ import { AbstractPath } from './AbstractPath';
4
+ export { AbstractPath };
3
5
  import { setAttributes } from './setAttributes';
4
6
  export { setAttributes };
5
7
  import { assignUUID } from './assignUUID';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,CAAC;AAEhB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,CAAC;AAEnB,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,CAAC;AAEnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAEhC,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,CAAC;AAEhB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,CAAC;AAEnB,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,CAAC;AAEnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAEhC,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["draw.svg"]=e():t["draw.svg"]=e()}(this,()=>(()=>{var t={725(t){t.exports=(()=>{var t={986:function(t){t.exports=(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function r(t){var e=0;return t.forEach(function(t){return e+=t}),e}function n(t){return r(t)/t.length}function i(t){t.sort(function(t,e){return t-e})}t.r(e),t.d(e,{areWithin:()=>f,average:()=>n,degrees:()=>m,isBetweenExclusive:()=>h,isBetweenInclusive:()=>l,max:()=>c,mean:()=>n,median:()=>s,min:()=>u,radians:()=>y,sortNumbers:()=>i,sortNumbersAscending:()=>i,sortNumbersDescending:()=>d,sortedNumbers:()=>a,sortedNumbersAscending:()=>a,sortedNumbersDescending:()=>g,sum:()=>r});var o=function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))};function a(t){var e=o([],t,!0);return i(e),e}function s(t){if(0==t.length)return NaN;var e=a(t);if(e.length%2!=0)return e[Math.floor(e.length/2)];var r=e.length/2,i=r-1;return n([e[r],e[i]])}function u(t){if(0==t.length)return 1/0;var e=t[0];return t.slice(1).forEach(function(t){e=Math.min(e,t)}),e}function c(t){if(0==t.length)return-1/0;var e=t[0];return t.slice(1).forEach(function(t){e=Math.max(e,t)}),e}function l(t,e,r){return t>=e&&t<=r}function h(t,e,r){return t>e&&t<r}function f(t,e,r){return Math.abs(t-e)<=r}function d(t){i(t),t.reverse()}function g(t){var e=a(t);return e.reverse(),e}function m(t){return t*(180/Math.PI)}function y(t){return t*(Math.PI/180)}return e})()},854:function(t){t.exports=(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function r(t){return"number"==typeof t}function n(t){return r(t)&&Number.isFinite(t)}function i(t){return r(t)&&!Number.isFinite(t)}function o(t){return n(t)&&t>0}function a(t){return n(t)&&t>=0}function s(t){return"string"==typeof t}function u(t){return null==t}function c(t){return"object"==typeof t&&null!==t}function l(t){return Array.isArray(t)}return t.r(e),t.d(e,{isArray:()=>l,isFiniteNumber:()=>n,isNonFiniteNumber:()=>i,isNonNegativeFiniteNumber:()=>a,isNonNullObject:()=>c,isNullish:()=>u,isNumber:()=>r,isPositiveFiniteNumber:()=>o,isString:()=>s}),e})()},30:function(t){t.exports=(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function r(t){return Math.pow(Math.pow(t.x,2)+Math.pow(t.y,2),.5)}function n(t){return Math.atan2(t.y,t.x)}return t.r(e),t.d(e,{direction:()=>n,magnitude:()=>r}),e})()}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,r),o.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n),r.d(n,{areWithin:()=>s,centroid:()=>d,deepCopy:()=>o,direction:()=>h,displaced:()=>c,displacement:()=>u,distance:()=>a,isFinitePoint:()=>i,isPoint:()=>e,midpoint:()=>g});var t=r(854);function e(e){return(0,t.isNonNullObject)(e)&&(0,t.isNumber)(e.x)&&(0,t.isNumber)(e.y)}function i(r){return e(r)&&(0,t.isFiniteNumber)(r.x)&&(0,t.isFiniteNumber)(r.y)}function o(t){return{x:t.x,y:t.y}}function a(t,e){var r=e.x-t.x,n=e.y-t.y;return Math.pow(Math.pow(r,2)+Math.pow(n,2),.5)}function s(t,e,r){return a(t,e)<=r}function u(t,e){return{x:e.x-t.x,y:e.y-t.y}}function c(t,e){return{x:t.x+e.x,y:t.y+e.y}}var l=r(30);function h(t,e){return(0,l.direction)(u(t,e))}var f=r(986);function d(t){return{x:(0,f.mean)(t.map(function(t){return t.x})),y:(0,f.mean)(t.map(function(t){return t.y}))}}function g(t,e){return d([t,e])}})(),n})()},854(t){t.exports=(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function r(t){return"number"==typeof t}function n(t){return r(t)&&Number.isFinite(t)}function i(t){return r(t)&&!Number.isFinite(t)}function o(t){return n(t)&&t>0}function a(t){return n(t)&&t>=0}function s(t){return"string"==typeof t}function u(t){return null==t}function c(t){return"object"==typeof t&&null!==t}function l(t){return Array.isArray(t)}function h(t){return l(t)&&0==t.length}function f(t){return l(t)&&t.length>0}function d(t){return l(t)&&t.every(r)}function g(t){return d(t)&&t.length>0}function m(t){return l(t)&&t.every(n)}function y(t){return l(t)&&t.every(i)}function p(t){return l(t)&&t.every(s)}function b(t){return p(t)&&t.length>0}return t.r(e),t.d(e,{isArray:()=>l,isEmptyArray:()=>h,isFiniteNumber:()=>n,isFiniteNumbersArray:()=>m,isNonEmptyArray:()=>f,isNonEmptyNumbersArray:()=>g,isNonEmptyStringsArray:()=>b,isNonFiniteNumber:()=>i,isNonFiniteNumbersArray:()=>y,isNonNegativeFiniteNumber:()=>a,isNonNullObject:()=>c,isNullish:()=>u,isNumber:()=>r,isNumbersArray:()=>d,isPositiveFiniteNumber:()=>o,isString:()=>s,isStringsArray:()=>p}),e})()}};const e={};function r(n){const i=e[n];if(void 0!==i)return i.exports;const o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,r),o.exports}r.d=(t,e)=>{if(Array.isArray(e))for(var n=0;n<e.length;){var i=e[n++],o=e[n++];r.o(t,i)?0===o&&n++:0===o?Object.defineProperty(t,i,{enumerable:!0,value:e[n++]}):Object.defineProperty(t,i,{enumerable:!0,get:o})}else for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};let n={};return(()=>{"use strict";r.r(n),r.d(n,{CoordinateSystem:()=>d,HorizontalClientScaling:()=>m,InnerXML:()=>S,OuterXML:()=>C,Path:()=>e,Scaling:()=>g,VerticalClientScaling:()=>y,assignUUID:()=>f,bringToFront:()=>p,drawOnCanvas:()=>M,isSVGGraphicsElement:()=>P,isSVGGraphicsElementsArray:()=>O,sendToBack:()=>b,setAttributes:()=>i});var t=r(725);class e{constructor(t){this.domNode=t}closestPoint(e,r){var n;let i=this.domNode.getPointAtLength(0),o={x:i.x,y:i.y,length:0},a=null!==(n=null==r?void 0:r.precision)&&void 0!==n?n:5;if(a<=0)throw new Error(`Precision must be positive: ${a}.`);let s=this.domNode.getTotalLength();for(let r=a;r<=s;r+=a){let n=this.domNode.getPointAtLength(r);(0,t.distance)(e,n)<(0,t.distance)(e,o)&&(o={x:n.x,y:n.y,length:r})}return o}}function i(t,e){for(let[r,n]of Object.entries(e))t.setAttribute(r,n)}const o={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};var a,s=new Uint8Array(16);function u(){if(!a&&!(a="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return a(s)}for(var c=[],l=0;l<256;++l)c.push((l+256).toString(16).slice(1));const h=function(t,e,r){if(o.randomUUID&&!e&&!t)return o.randomUUID();var n=(t=t||{}).random||(t.rng||u)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){r=r||0;for(var i=0;i<16;++i)e[r+i]=n[i];return e}return function(t,e=0){return(c[t[e+0]]+c[t[e+1]]+c[t[e+2]]+c[t[e+3]]+"-"+c[t[e+4]]+c[t[e+5]]+"-"+c[t[e+6]]+c[t[e+7]]+"-"+c[t[e+8]]+c[t[e+9]]+"-"+c[t[e+10]]+c[t[e+11]]+c[t[e+12]]+c[t[e+13]]+c[t[e+14]]+c[t[e+15]]).toLowerCase()}(n)};function f(t){t.id="uuid-"+h()}class d{constructor(t){this.targetSVGDoc=t}get width(){return this.targetSVGDoc.viewBox.baseVal.width}get height(){return this.targetSVGDoc.viewBox.baseVal.height}get minX(){return this.targetSVGDoc.viewBox.baseVal.x}get maxX(){return this.minX+this.width}get minY(){return this.targetSVGDoc.viewBox.baseVal.y}get maxY(){return this.minY+this.height}get horizontalScaling(){return this.targetSVGDoc.width.baseVal.value/this.width}get verticalScaling(){return this.targetSVGDoc.height.baseVal.value/this.height}setScaling(t){this.targetSVGDoc.setAttribute("width",""+t*this.width),this.targetSVGDoc.setAttribute("height",""+t*this.height)}get clientWidth(){return this.targetSVGDoc.getBoundingClientRect().width}get clientHeight(){return this.targetSVGDoc.getBoundingClientRect().height}get horizontalClientScaling(){return this.clientWidth/this.width}get verticalClientScaling(){return this.clientHeight/this.height}get minClientX(){return this.targetSVGDoc.getBoundingClientRect().x}get minClientY(){return this.targetSVGDoc.getBoundingClientRect().y}fromClientX(t){return this.minX+(t-this.minClientX)/this.horizontalClientScaling}fromClientY(t){return this.minY+(t-this.minClientY)/this.verticalClientScaling}fromClientCoordinates(t,e){return[this.fromClientX(t),this.fromClientY(e)]}fromClientPoint(t){return{x:this.fromClientX(t.x),y:this.fromClientY(t.y)}}toClientX(t){return this.minClientX+this.horizontalClientScaling*(t-this.minX)}toClientY(t){return this.minClientY+this.verticalClientScaling*(t-this.minY)}toClientCoordinates(t,e){return[this.toClientX(t),this.toClientY(e)]}toClientPoint(t){return{x:this.toClientX(t.x),y:this.toClientY(t.y)}}}class g{constructor(t){this.targetSVGDoc=t}set(t){let e=this.targetSVGDoc.viewBox.baseVal;this.targetSVGDoc.setAttribute("width",t*e.width+"px"),this.targetSVGDoc.setAttribute("height",t*e.height+"px")}}class m{constructor(t){this.targetSVGDoc=t}get(){let t=this.targetSVGDoc.getBoundingClientRect(),e=this.targetSVGDoc.viewBox.baseVal;return t.width/e.width}}class y{constructor(t){this.targetSVGDoc=t}get(){let t=this.targetSVGDoc.getBoundingClientRect(),e=this.targetSVGDoc.viewBox.baseVal;return t.height/e.height}}function p(t){let e=t.parentNode;e&&e.appendChild(t)}function b(t){let e=t.parentNode;e&&e.prepend(t)}var v,w=function(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)};class S{constructor(t){v.set(this,void 0),function(t,e,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===n?i.call(t,r):i?i.value=r:e.set(t,r)}(this,v,t,"f")}toString(){return w(this,v,"f").innerHTML}set(t){w(this,v,"f").innerHTML=t}}v=new WeakMap;var x,N=function(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)};class C{constructor(t){x.set(this,void 0),function(t,e,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===n?i.call(t,r):i?i.value=r:e.set(t,r)}(this,x,t,"f")}toString(){return N(this,x,"f").outerHTML}set(t){let e=document.createElementNS("http://www.w3.org/2000/svg","svg");if(e.style.height="0px",document.body.append(e),e.innerHTML=t,!e.firstElementChild)throw new Error("Outer XML must encode an SVG element.");if(e.childNodes.length>1)throw new Error("Outer XML cannot encode multiple DOM nodes.");if(e.firstElementChild.tagName.toLowerCase()!=N(this,x,"f").tagName.toLowerCase())throw new Error("Outer XML must specify an SVG element with the same tag name as the target SVG element.");[...N(this,x,"f").attributes].forEach(t=>N(this,x,"f").removeAttribute(t.name)),[...e.firstElementChild.attributes].forEach(t=>N(this,x,"f").setAttribute(t.name,t.value)),N(this,x,"f").innerHTML=e.firstElementChild.innerHTML,e.remove()}}function P(t){return t instanceof SVGGraphicsElement}x=new WeakMap;var V=r(854);function O(t){return(0,V.isArray)(t)&&t.every(P)}var j=function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function a(t){try{u(n.next(t))}catch(t){o(t)}}function s(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(a,s)}u((n=n.apply(t,e||[])).next())})};function M(t){return j(this,void 0,void 0,function*(){let e=document.createElement("canvas");e.style.position="fixed",e.style.display="none",e.style.pointerEvents="none",document.body.append(e),e.width=t.width.baseVal.value,e.height=t.height.baseVal.value;let r=e.getContext("2d");if(!r)throw new Error("Unable to get canvas context.");let n=(new XMLSerializer).serializeToString(t),i=new Image;return i.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(n),yield i.decode(),r.drawImage(i,0,0,t.width.baseVal.value,t.height.baseVal.value),e.remove(),e.style.position="",e.style.display="",e.style.pointerEvents="",e})}})(),n})());
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["draw.svg"]=e():t["draw.svg"]=e()}(this,()=>(()=>{var t={725(t){t.exports=(()=>{var t={986:function(t){t.exports=(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function r(t){var e=0;return t.forEach(function(t){return e+=t}),e}function n(t){return r(t)/t.length}function i(t){t.sort(function(t,e){return t-e})}t.r(e),t.d(e,{areWithin:()=>f,average:()=>n,degrees:()=>m,isBetweenExclusive:()=>h,isBetweenInclusive:()=>l,max:()=>c,mean:()=>n,median:()=>s,min:()=>u,radians:()=>p,sortNumbers:()=>i,sortNumbersAscending:()=>i,sortNumbersDescending:()=>d,sortedNumbers:()=>a,sortedNumbersAscending:()=>a,sortedNumbersDescending:()=>g,sum:()=>r});var o=function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))};function a(t){var e=o([],t,!0);return i(e),e}function s(t){if(0==t.length)return NaN;var e=a(t);if(e.length%2!=0)return e[Math.floor(e.length/2)];var r=e.length/2,i=r-1;return n([e[r],e[i]])}function u(t){if(0==t.length)return 1/0;var e=t[0];return t.slice(1).forEach(function(t){e=Math.min(e,t)}),e}function c(t){if(0==t.length)return-1/0;var e=t[0];return t.slice(1).forEach(function(t){e=Math.max(e,t)}),e}function l(t,e,r){return t>=e&&t<=r}function h(t,e,r){return t>e&&t<r}function f(t,e,r){return Math.abs(t-e)<=r}function d(t){i(t),t.reverse()}function g(t){var e=a(t);return e.reverse(),e}function m(t){return t*(180/Math.PI)}function p(t){return t*(Math.PI/180)}return e})()},854:function(t){t.exports=(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function r(t){return"number"==typeof t}function n(t){return r(t)&&Number.isFinite(t)}function i(t){return r(t)&&!Number.isFinite(t)}function o(t){return n(t)&&t>0}function a(t){return n(t)&&t>=0}function s(t){return"string"==typeof t}function u(t){return null==t}function c(t){return"object"==typeof t&&null!==t}function l(t){return Array.isArray(t)}return t.r(e),t.d(e,{isArray:()=>l,isFiniteNumber:()=>n,isNonFiniteNumber:()=>i,isNonNegativeFiniteNumber:()=>a,isNonNullObject:()=>c,isNullish:()=>u,isNumber:()=>r,isPositiveFiniteNumber:()=>o,isString:()=>s}),e})()},30:function(t){t.exports=(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function r(t){return Math.pow(Math.pow(t.x,2)+Math.pow(t.y,2),.5)}function n(t){return Math.atan2(t.y,t.x)}return t.r(e),t.d(e,{direction:()=>n,magnitude:()=>r}),e})()}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,r),o.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n),r.d(n,{areWithin:()=>s,centroid:()=>d,deepCopy:()=>o,direction:()=>h,displaced:()=>c,displacement:()=>u,distance:()=>a,isFinitePoint:()=>i,isPoint:()=>e,midpoint:()=>g});var t=r(854);function e(e){return(0,t.isNonNullObject)(e)&&(0,t.isNumber)(e.x)&&(0,t.isNumber)(e.y)}function i(r){return e(r)&&(0,t.isFiniteNumber)(r.x)&&(0,t.isFiniteNumber)(r.y)}function o(t){return{x:t.x,y:t.y}}function a(t,e){var r=e.x-t.x,n=e.y-t.y;return Math.pow(Math.pow(r,2)+Math.pow(n,2),.5)}function s(t,e,r){return a(t,e)<=r}function u(t,e){return{x:e.x-t.x,y:e.y-t.y}}function c(t,e){return{x:t.x+e.x,y:t.y+e.y}}var l=r(30);function h(t,e){return(0,l.direction)(u(t,e))}var f=r(986);function d(t){return{x:(0,f.mean)(t.map(function(t){return t.x})),y:(0,f.mean)(t.map(function(t){return t.y}))}}function g(t,e){return d([t,e])}})(),n})()},854(t){t.exports=(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function r(t){return"number"==typeof t}function n(t){return r(t)&&Number.isFinite(t)}function i(t){return r(t)&&!Number.isFinite(t)}function o(t){return n(t)&&t>0}function a(t){return n(t)&&t>=0}function s(t){return"string"==typeof t}function u(t){return""===t}function c(t){return s(t)&&!u(t)}function l(t){return!!s(t)&&0==t.trim().length}function h(t){if(!s(t))return!1;try{return JSON.parse(t),!0}catch{return!1}}function f(t){try{return JSON.stringify(t),!0}catch{return!1}}function d(t){return!!t}function g(t){return!t}function m(t){return null==t}function p(t){return"object"==typeof t&&null!==t}function y(t){return Array.isArray(t)}function b(t){return y(t)&&0==t.length}function w(t){return y(t)&&t.length>0}function v(t){return y(t)&&t.every(r)}function S(t){return v(t)&&t.length>0}function N(t){return y(t)&&t.every(n)}function x(t){return y(t)&&t.every(i)}function C(t){return y(t)&&t.every(s)}function P(t){return C(t)&&t.length>0}function E(t){return t instanceof SVGGraphicsElement}return t.r(e),t.d(e,{isArray:()=>y,isEmptyArray:()=>b,isEmptyString:()=>u,isFalsy:()=>g,isFiniteNumber:()=>n,isFiniteNumbersArray:()=>N,isJSON:()=>h,isJSONSerializable:()=>f,isNonEmptyArray:()=>w,isNonEmptyNumbersArray:()=>S,isNonEmptyString:()=>c,isNonEmptyStringsArray:()=>P,isNonFiniteNumber:()=>i,isNonFiniteNumbersArray:()=>x,isNonNegativeFiniteNumber:()=>a,isNonNullObject:()=>p,isNullish:()=>m,isNumber:()=>r,isNumbersArray:()=>v,isPositiveFiniteNumber:()=>o,isSVGGraphicsElement:()=>E,isString:()=>s,isStringsArray:()=>C,isTruthy:()=>d,isWhitespace:()=>l}),e})()}};const e={};function r(n){const i=e[n];if(void 0!==i)return i.exports;const o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,r),o.exports}r.d=(t,e)=>{if(Array.isArray(e))for(var n=0;n<e.length;){var i=e[n++],o=e[n++];r.o(t,i)?0===o&&n++:0===o?Object.defineProperty(t,i,{enumerable:!0,value:e[n++]}):Object.defineProperty(t,i,{enumerable:!0,get:o})}else for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};let n={};return(()=>{"use strict";r.r(n),r.d(n,{AbstractPath:()=>o,CoordinateSystem:()=>y,HorizontalClientScaling:()=>w,InnerXML:()=>P,OuterXML:()=>O,Path:()=>e,Scaling:()=>b,VerticalClientScaling:()=>v,assignUUID:()=>p,bringToFront:()=>S,drawOnCanvas:()=>T,isSVGGraphicsElement:()=>M,isSVGGraphicsElementsArray:()=>A,sendToBack:()=>N,setAttributes:()=>c});var t=r(725);class e{constructor(t){this.domNode=t}closestPoint(e){let r=this.domNode.getTotalLength(),n=[];for(let i=0;i<=16;i++){let o=i/16*r;n.push([o,(0,t.distance)(e,this.domNode.getPointAtLength(o))])}n.sort((t,e)=>t[1]-e[1]);let i=n[0],o=i[0]-r/16,a=i[0]+r/16;o=Math.max(0,o),a=Math.min(r,a);for(let r=0;r<20;r++){let r=(a-o)/3;(0,t.distance)(e,this.domNode.getPointAtLength(o))<(0,t.distance)(e,this.domNode.getPointAtLength(a))?a-=r:o+=r}let s=(o+a)/2,u=this.domNode.getPointAtLength(s);return{x:u.x,y:u.y,length:s}}}var i;class o{constructor(t){i.set(this,void 0),function(t,e,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===n?i.call(t,r):i?i.value=r:e.set(t,r)}(this,i,t,"f")}closestPoint(t){return document.body.contains(s)||document.body.append(s),u.setAttribute("d",function(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)}(this,i,"f")),new e(u).closestPoint(t)}}i=new WeakMap;const a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("viewBox","0 0 100 100"),a.setAttribute("width","100"),a.setAttribute("height","100");const s=document.createElement("div");s.append(a),s.style.height="0px",s.style.position="fixed",document.body.append(s);const u=document.createElementNS("http://www.w3.org/2000/svg","path");function c(t,e){for(let[r,n]of Object.entries(e))t.setAttribute(r,n)}u.setAttribute("stroke","black"),u.setAttribute("stroke-width","1"),a.append(u);const l={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let h;const f=new Uint8Array(16),d=[];for(let t=0;t<256;++t)d.push((t+256).toString(16).slice(1));function g(t,e,r){const n=(t=t||{}).random??t.rng?.()??function(){if(!h){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");h=crypto.getRandomValues.bind(crypto)}return h(f)}();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){if((r=r||0)<0||r+16>e.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let t=0;t<16;++t)e[r+t]=n[t];return e}return function(t,e=0){return(d[t[e+0]]+d[t[e+1]]+d[t[e+2]]+d[t[e+3]]+"-"+d[t[e+4]]+d[t[e+5]]+"-"+d[t[e+6]]+d[t[e+7]]+"-"+d[t[e+8]]+d[t[e+9]]+"-"+d[t[e+10]]+d[t[e+11]]+d[t[e+12]]+d[t[e+13]]+d[t[e+14]]+d[t[e+15]]).toLowerCase()}(n)}const m=function(t,e,r){return!l.randomUUID||e||t?g(t,e,r):l.randomUUID()};function p(t){t.id="uuid-"+m()}class y{constructor(t){this.targetSVGDoc=t}get width(){return this.targetSVGDoc.viewBox.baseVal.width}get height(){return this.targetSVGDoc.viewBox.baseVal.height}get minX(){return this.targetSVGDoc.viewBox.baseVal.x}get maxX(){return this.minX+this.width}get minY(){return this.targetSVGDoc.viewBox.baseVal.y}get maxY(){return this.minY+this.height}get horizontalScaling(){return this.targetSVGDoc.width.baseVal.value/this.width}get verticalScaling(){return this.targetSVGDoc.height.baseVal.value/this.height}setScaling(t){this.targetSVGDoc.setAttribute("width",""+t*this.width),this.targetSVGDoc.setAttribute("height",""+t*this.height)}get clientWidth(){return this.targetSVGDoc.getBoundingClientRect().width}get clientHeight(){return this.targetSVGDoc.getBoundingClientRect().height}get horizontalClientScaling(){return this.clientWidth/this.width}get verticalClientScaling(){return this.clientHeight/this.height}get minClientX(){return this.targetSVGDoc.getBoundingClientRect().x}get minClientY(){return this.targetSVGDoc.getBoundingClientRect().y}fromClientX(t){return this.minX+(t-this.minClientX)/this.horizontalClientScaling}fromClientY(t){return this.minY+(t-this.minClientY)/this.verticalClientScaling}fromClientCoordinates(t,e){return[this.fromClientX(t),this.fromClientY(e)]}fromClientPoint(t){return{x:this.fromClientX(t.x),y:this.fromClientY(t.y)}}toClientX(t){return this.minClientX+this.horizontalClientScaling*(t-this.minX)}toClientY(t){return this.minClientY+this.verticalClientScaling*(t-this.minY)}toClientCoordinates(t,e){return[this.toClientX(t),this.toClientY(e)]}toClientPoint(t){return{x:this.toClientX(t.x),y:this.toClientY(t.y)}}}class b{constructor(t){this.targetSVGDoc=t}set(t){let e=this.targetSVGDoc.viewBox.baseVal;this.targetSVGDoc.setAttribute("width",t*e.width+"px"),this.targetSVGDoc.setAttribute("height",t*e.height+"px")}}class w{constructor(t){this.targetSVGDoc=t}get(){let t=this.targetSVGDoc.getBoundingClientRect(),e=this.targetSVGDoc.viewBox.baseVal;return t.width/e.width}}class v{constructor(t){this.targetSVGDoc=t}get(){let t=this.targetSVGDoc.getBoundingClientRect(),e=this.targetSVGDoc.viewBox.baseVal;return t.height/e.height}}function S(t){let e=t.parentNode;e&&e.appendChild(t)}function N(t){let e=t.parentNode;e&&e.prepend(t)}var x,C=function(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)};class P{constructor(t){x.set(this,void 0),function(t,e,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===n?i.call(t,r):i?i.value=r:e.set(t,r)}(this,x,t,"f")}toString(){return C(this,x,"f").innerHTML}set(t){C(this,x,"f").innerHTML=t}}x=new WeakMap;var E,V=function(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)};class O{constructor(t){E.set(this,void 0),function(t,e,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===n?i.call(t,r):i?i.value=r:e.set(t,r)}(this,E,t,"f")}toString(){return V(this,E,"f").outerHTML}set(t){let e=document.createElementNS("http://www.w3.org/2000/svg","svg");if(e.style.height="0px",document.body.append(e),e.innerHTML=t,!e.firstElementChild)throw new Error("Outer XML must encode an SVG element.");if(e.childNodes.length>1)throw new Error("Outer XML cannot encode multiple DOM nodes.");if(e.firstElementChild.tagName.toLowerCase()!=V(this,E,"f").tagName.toLowerCase())throw new Error("Outer XML must specify an SVG element with the same tag name as the target SVG element.");[...V(this,E,"f").attributes].forEach(t=>V(this,E,"f").removeAttribute(t.name)),[...e.firstElementChild.attributes].forEach(t=>V(this,E,"f").setAttribute(t.name,t.value)),V(this,E,"f").innerHTML=e.firstElementChild.innerHTML,e.remove()}}function M(t){return t instanceof SVGGraphicsElement}E=new WeakMap;var j=r(854);function A(t){return(0,j.isArray)(t)&&t.every(M)}async function T(t){let e=document.createElement("canvas");e.style.position="fixed",e.style.display="none",e.style.pointerEvents="none",document.body.append(e),e.width=t.width.baseVal.value,e.height=t.height.baseVal.value;let r=e.getContext("2d");if(!r)throw new Error("Unable to get canvas context.");let n=(new XMLSerializer).serializeToString(t),i=new Image;return i.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(n),await i.decode(),r.drawImage(i,0,0,t.width.baseVal.value,t.height.baseVal.value),e.remove(),e.style.position="",e.style.display="",e.style.pointerEvents="",e}})(),n})());
package/jest.config.js ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @type { import('jest').Config }
3
+ */
4
+ const config = {
5
+ "moduleNameMapper": {
6
+ "\\.css$": "<rootDir>/__mocks__/styleMock.js",
7
+ },
8
+ "transformIgnorePatterns": [
9
+ "node_modules/(?!@ngrx|(?!deck.gl)|ng-dynamic)",
10
+ ],
11
+ };
12
+
13
+ module.exports = config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rnacanvas/draw.svg",
3
- "version": "3.8.1",
3
+ "version": "4.0.0",
4
4
  "description": "SVG drawing utilities",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,14 +23,14 @@
23
23
  "jest": "^30.1.3",
24
24
  "jest-environment-jsdom": "^30.1.2",
25
25
  "ts-loader": "^9.5.1",
26
- "typescript": "^5.3.3",
26
+ "typescript": "^6.0.3",
27
27
  "webpack": "^5.89.0",
28
- "webpack-cli": "^6.0.1"
28
+ "webpack-cli": "^7.2.2"
29
29
  },
30
30
  "dependencies": {
31
31
  "@rnacanvas/points": "^1.12.0",
32
- "@rnacanvas/value-check": "^1.14.1",
32
+ "@rnacanvas/value-check": "^2.7.0",
33
33
  "@svgdotjs/svg.js": "^3.2.0",
34
- "uuid": "^10.0.0"
34
+ "uuid": "^13.0.2"
35
35
  }
36
36
  }
package/tsconfig.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "strict": true,
4
+ "rootDir": "./src",
4
5
  "outDir": "./dist/",
5
6
  "sourceMap": true,
6
7
  "declaration": true,
7
8
  "declarationDir": "./dist/",
8
9
  "declarationMap": true,
9
10
  "module": "es6",
10
- "target": "es6",
11
- "moduleResolution": "node"
11
+ "target": "es2019",
12
+ "moduleResolution": "bundler"
12
13
  }
13
14
  }