svg-path-commander 0.1.25 → 0.2.0-alpha3

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.
Files changed (71) hide show
  1. package/README.md +5 -3
  2. package/dist/svg-path-commander.es5.js +3948 -0
  3. package/dist/svg-path-commander.es5.min.js +2 -0
  4. package/dist/svg-path-commander.esm.js +425 -404
  5. package/dist/svg-path-commander.esm.min.js +2 -2
  6. package/dist/svg-path-commander.js +1432 -1513
  7. package/dist/svg-path-commander.min.js +2 -2
  8. package/package.json +28 -12
  9. package/src/convert/pathToAbsolute.js +4 -4
  10. package/src/convert/pathToCurve.js +2 -2
  11. package/src/convert/pathToRelative.js +4 -4
  12. package/src/convert/pathToString.js +2 -2
  13. package/src/math/polygonLength.js +1 -2
  14. package/src/options/options.js +1 -1
  15. package/src/parser/error.js +2 -0
  16. package/src/parser/finalizeSegment.js +1 -1
  17. package/src/parser/paramsParser.js +1 -1
  18. package/src/parser/parsePathString.js +6 -11
  19. package/src/parser/pathParser.js +1 -1
  20. package/src/parser/scanFlag.js +3 -3
  21. package/src/parser/scanParam.js +7 -6
  22. package/src/parser/scanSegment.js +3 -2
  23. package/src/parser/skipSpaces.js +1 -1
  24. package/src/process/clonePath.js +1 -1
  25. package/src/process/fixArc.js +1 -1
  26. package/src/process/fixPath.js +2 -2
  27. package/src/process/getSVGMatrix.js +3 -2
  28. package/src/process/normalizePath.js +3 -3
  29. package/src/process/normalizeSegment.js +2 -2
  30. package/src/process/optimizePath.js +2 -2
  31. package/src/process/projection2d.js +2 -2
  32. package/src/process/reverseCurve.js +3 -3
  33. package/src/process/reversePath.js +4 -5
  34. package/src/process/roundPath.js +7 -6
  35. package/src/process/segmentToCubic.js +3 -3
  36. package/src/process/shortenSegment.js +3 -3
  37. package/src/process/splitCubic.js +1 -1
  38. package/src/process/splitPath.js +1 -1
  39. package/src/process/transformPath.js +8 -7
  40. package/src/svg-path-commander.js +60 -20
  41. package/src/util/getClosestPoint.js +1 -1
  42. package/src/util/getCubicSize.js +1 -1
  43. package/src/util/getDrawDirection.js +1 -1
  44. package/src/util/getPathArea.js +1 -1
  45. package/src/util/getPathBBox.js +2 -2
  46. package/src/util/getPathLength.js +1 -1
  47. package/src/util/getPointAtLength.js +1 -1
  48. package/src/util/getPropertiesAtLength.js +3 -3
  49. package/src/util/getPropertiesAtPoint.js +2 -2
  50. package/src/util/getSegmentAtLength.js +2 -2
  51. package/src/util/getSegmentOfPoint.js +2 -2
  52. package/src/util/getTotalLength.js +1 -1
  53. package/src/util/isAbsoluteArray.js +1 -1
  54. package/src/util/isCurveArray.js +1 -1
  55. package/src/util/isNormalizedArray.js +1 -1
  56. package/src/util/isPathArray.js +1 -1
  57. package/src/util/isPointInStroke.js +2 -2
  58. package/src/util/isRelativeArray.js +1 -1
  59. package/src/util/pathLengthFactory.js +3 -2
  60. package/src/util/segmentArcFactory.js +1 -1
  61. package/src/util/segmentCubicFactory.js +1 -1
  62. package/src/util/segmentLineFactory.js +1 -1
  63. package/src/util/segmentQuadFactory.js +1 -1
  64. package/src/util/shapeToPath.js +13 -13
  65. package/src/util/util.js +0 -2
  66. package/types/index.d.ts +1 -3
  67. package/types/more/modules.ts +0 -3
  68. package/types/more/svg.d.ts +11 -10
  69. package/types/svg-path-commander.d.ts +214 -226
  70. package/src/util/createPath.js +0 -17
  71. package/src/util/getPointAtPathLength.js +0 -15
@@ -17,8 +17,8 @@ const shapeParams = {
17
17
  /**
18
18
  * Returns a new `pathArray` from line attributes.
19
19
  *
20
- * @param {SVGPathCommander.lineAttr} attr shape configuration
21
- * @returns {SVGPathCommander.pathArray} a new line `pathArray`
20
+ * @param {SVGPath.lineAttr} attr shape configuration
21
+ * @returns {SVGPath.pathArray} a new line `pathArray`
22
22
  */
23
23
  export function getLinePath(attr) {
24
24
  const {
@@ -30,11 +30,11 @@ export function getLinePath(attr) {
30
30
  /**
31
31
  * Returns a new `pathArray` like from polyline/polygon attributes.
32
32
  *
33
- * @param {SVGPathCommander.polyAttr} attr shape configuration
34
- * @return {SVGPathCommander.pathArray} a new polygon/polyline `pathArray`
33
+ * @param {SVGPath.polyAttr} attr shape configuration
34
+ * @return {SVGPath.pathArray} a new polygon/polyline `pathArray`
35
35
  */
36
36
  export function getPolyPath(attr) {
37
- /** @type {SVGPathCommander.pathArray} */
37
+ /** @type {SVGPath.pathArray} */
38
38
  // @ts-ignore -- it's an empty `pathArray`
39
39
  const pathArray = [];
40
40
  const points = attr.points.trim().split(/[\s|,]/).map(Number);
@@ -51,8 +51,8 @@ export function getPolyPath(attr) {
51
51
  /**
52
52
  * Returns a new `pathArray` from circle attributes.
53
53
  *
54
- * @param {SVGPathCommander.circleAttr} attr shape configuration
55
- * @return {SVGPathCommander.pathArray} a circle `pathArray`
54
+ * @param {SVGPath.circleAttr} attr shape configuration
55
+ * @return {SVGPath.pathArray} a circle `pathArray`
56
56
  */
57
57
  export function getCirclePath(attr) {
58
58
  const {
@@ -69,8 +69,8 @@ export function getCirclePath(attr) {
69
69
  /**
70
70
  * Returns a new `pathArray` from ellipse attributes.
71
71
  *
72
- * @param {SVGPathCommander.ellipseAttr} attr shape configuration
73
- * @return {SVGPathCommander.pathArray} an ellipse `pathArray`
72
+ * @param {SVGPath.ellipseAttr} attr shape configuration
73
+ * @return {SVGPath.pathArray} an ellipse `pathArray`
74
74
  */
75
75
  export function getEllipsePath(attr) {
76
76
  const {
@@ -87,8 +87,8 @@ export function getEllipsePath(attr) {
87
87
  /**
88
88
  * Returns a new `pathArray` like from rect attributes.
89
89
  *
90
- * @param {SVGPathCommander.rectAttr} attr object with properties above
91
- * @return {SVGPathCommander.pathArray} a new `pathArray` from `<rect>` attributes
90
+ * @param {SVGPath.rectAttr} attr object with properties above
91
+ * @return {SVGPath.pathArray} a new `pathArray` from `<rect>` attributes
92
92
  */
93
93
  export function getRectanglePath(attr) {
94
94
  const x = +attr.x || 0;
@@ -134,12 +134,12 @@ export function getRectanglePath(attr) {
134
134
  * is `true`, it will replace the target.
135
135
  *
136
136
  * It can also work with an options object,
137
- * @see SVGPathCommander.shapeOps
137
+ * @see SVGPath.shapeOps
138
138
  *
139
139
  * The newly created `<path>` element keeps all non-specific
140
140
  * attributes like `class`, `fill`, etc.
141
141
  *
142
- * @param {SVGPathCommander.shapeTypes | SVGPathCommander.shapeOps} element target shape
142
+ * @param {SVGPath.shapeTypes | SVGPath.shapeOps} element target shape
143
143
  * @param {boolean=} replace option to replace target
144
144
  * @return {SVGPathElement | boolean} the newly created `<path>` element
145
145
  */
package/src/util/util.js CHANGED
@@ -6,7 +6,6 @@ import getPathLength from './getPathLength';
6
6
  import getTotalLength from './getTotalLength';
7
7
  import getDrawDirection from './getDrawDirection';
8
8
  import getPointAtLength from './getPointAtLength';
9
- import getPointAtPathLength from './getPointAtPathLength';
10
9
 
11
10
  import getPropertiesAtLength from './getPropertiesAtLength';
12
11
  import getPropertiesAtPoint from './getPropertiesAtPoint';
@@ -61,7 +60,6 @@ const Util = {
61
60
  getTotalLength,
62
61
  getPathLength,
63
62
  getPointAtLength,
64
- getPointAtPathLength,
65
63
  getClosestPoint,
66
64
  getSegmentOfPoint,
67
65
  getPropertiesAtPoint,
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export as namespace SVGPathCommander;
1
+ export as namespace SVGPath;
2
2
  export default SVGPathCommander;
3
3
 
4
4
  // modules
@@ -51,7 +51,6 @@ export { default as splitCubic } from "svg-path-commander/src/process/splitCubic
51
51
  export { default as splitPath } from "svg-path-commander/src/process/splitPath";
52
52
  export { default as transformEllipse } from "svg-path-commander/src/process/transformEllipse";
53
53
  export { default as transformPath } from "svg-path-commander/src/process/transformPath";
54
- export { default as createPath } from "svg-path-commander/src/util/createPath";
55
54
  export { default as getCubicSize } from "svg-path-commander/src/util/getCubicSize";
56
55
  export { default as getDrawDirection } from "svg-path-commander/src/util/getDrawDirection";
57
56
  export { default as getPathArea } from "svg-path-commander/src/util/getPathArea";
@@ -63,7 +62,6 @@ export { default as segmentArcFactory } from "svg-path-commander/src/util/segmen
63
62
  export { default as segmentCubicFactory } from "svg-path-commander/src/util/segmentCubicFactory";
64
63
  export { default as segmentQuadFactory } from "svg-path-commander/src/util/segmentQuadFactory";
65
64
  export { default as getPointAtLength } from "svg-path-commander/src/util/getPointAtLength";
66
- export { default as getPointAtPathLength } from "svg-path-commander/src/util/getPointAtPathLength";
67
65
  export { default as getPropertiesAtPoint } from "svg-path-commander/src/util/getPropertiesAtPoint";
68
66
  export { default as getPropertiesAtLength } from "svg-path-commander/src/util/getPropertiesAtLength";
69
67
  export { default as getClosestPoint } from "svg-path-commander/src/util/getClosestPoint";
@@ -51,7 +51,6 @@ export { default as splitPath } from '../../src/process/splitPath';
51
51
  export { default as transformEllipse } from '../../src/process/transformEllipse';
52
52
  export { default as transformPath } from '../../src/process/transformPath';
53
53
 
54
- export { default as createPath } from '../../src/util/createPath';
55
54
  export { default as getCubicSize } from '../../src/util/getCubicSize';
56
55
  export { default as getDrawDirection } from '../../src/util/getDrawDirection';
57
56
  export { default as getPathArea } from '../../src/util/getPathArea';
@@ -66,8 +65,6 @@ export { default as segmentCubicFactory } from '../../src/util/segmentCubicFacto
66
65
  export { default as segmentQuadFactory } from '../../src/util/segmentQuadFactory';
67
66
 
68
67
  export { default as getPointAtLength } from '../../src/util/getPointAtLength';
69
- export { default as getPointAtPathLength } from '../../src/util/getPointAtPathLength';
70
-
71
68
  export { default as getPropertiesAtPoint } from '../../src/util/getPropertiesAtPoint';
72
69
  export { default as getPropertiesAtLength } from '../../src/util/getPropertiesAtLength';
73
70
  export { default as getClosestPoint } from '../../src/util/getClosestPoint';
@@ -106,7 +106,7 @@ export type polylineArray = [MSegment, ...LSegment[]];
106
106
 
107
107
  export interface options {
108
108
  /** @default 4 */
109
- round: boolean | number;
109
+ round: false | number;
110
110
  /** @default [0,0,0] */
111
111
  origin: number[];
112
112
  }
@@ -123,15 +123,16 @@ export interface pathTransformList {
123
123
  }
124
124
 
125
125
  export interface transformObject {
126
- // translate?: number | [number, number, number];
127
- // rotate?: number | [number, number, number];
128
- // scale?: number | [number, number, number];
129
- // skew?: number | [number, number];
130
- translate?: number | number[];
131
- rotate?: number | number[];
132
- scale?: number | number[];
133
- skew?: number | number[];
134
- origin: number[];
126
+ translate?: number | [number, number, number];
127
+ rotate?: number | [number, number, number];
128
+ scale?: number | [number, number, number];
129
+ skew?: number | [number, number];
130
+ origin?: [number, number, number?];
131
+ // translate?: number | number[];
132
+ // rotate?: number | number[];
133
+ // scale?: number | number[];
134
+ // skew?: number | number[];
135
+ // origin?: number[];
135
136
  }
136
137
 
137
138
  export type shapeTypes = SVGPolylineElement | SVGPolygonElement | SVGLineElement | SVGEllipseElement | SVGCircleElement | SVGRectElement;