plotboilerplate 1.20.0 → 1.20.1
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 +1 -0
- package/package.json +1 -1
- package/src/cjs/utils/parsers/svg/parseSVGPathData.d.ts +2 -1
- package/src/cjs/utils/parsers/svg/parseSVGPathData.js +228 -205
- package/src/cjs/utils/parsers/svg/parseSVGPathData.js.map +1 -1
- package/src/cjs/utils/parsers/svg/splitSVGPathData.js +6 -2
- package/src/cjs/utils/parsers/svg/splitSVGPathData.js.map +1 -1
- package/src/cjs/utils/parsers/svg/types.d.ts +29 -9
- package/src/cjs/utils/parsers/svg/types.js +4 -3
- package/src/cjs/utils/parsers/svg/types.js.map +1 -1
- package/src/esm/utils/parsers/svg/parseSVGPathData.d.ts +2 -1
- package/src/esm/utils/parsers/svg/parseSVGPathData.js +228 -205
- package/src/esm/utils/parsers/svg/parseSVGPathData.js.map +1 -1
- package/src/esm/utils/parsers/svg/splitSVGPathData.js +6 -2
- package/src/esm/utils/parsers/svg/splitSVGPathData.js.map +1 -1
- package/src/esm/utils/parsers/svg/types.d.ts +29 -9
- package/src/esm/utils/parsers/svg/types.js +4 -3
- package/src/esm/utils/parsers/svg/types.js.map +1 -1
- package/src/ts/utils/parsers/svg/parseSVGPathData.ts +271 -212
- package/src/ts/utils/parsers/svg/splitSVGPathData.ts +6 -2
- package/src/ts/utils/parsers/svg/types.ts +29 -9
|
@@ -17,11 +17,15 @@
|
|
|
17
17
|
* @param {string} dataString - The SVG path data to split. This should be some string
|
|
18
18
|
**/
|
|
19
19
|
export const splitSVGPathData = (dataString) => {
|
|
20
|
+
// I used a modified version of this Josh Frank's SVG path data RexEx.
|
|
20
21
|
// Source
|
|
21
22
|
// https://javascript.plainenglish.io/june-3-parsing-and-validating-svg-paths-with-regex-7bd0e245115
|
|
22
|
-
const validCommand =
|
|
23
|
+
// const validCommand =
|
|
24
|
+
// /([ml](\s?-?((\d+(\.\d+)?)|(\.\d+)))[,\s]?(-?((\d+(\.\d+)?)|(\.\d+))))|([hv](\s?-?((\d+(\.\d+)?)|(\.\d+))))|(c(\s?-?((\d+(\.\d+)?)|(\.\d+)))([,\s]?(-?((\d+(\.\d+)?)|(\.\d+)))){5})|(q(\s?-?((\d+(\.\d+)?)|(\.\d+)))([,\s]?(-?((\d+(\.\d+)?)|(\.\d+)))){3}(\s?t?(\s?-?((\d+(\.\d+)?)|(\.\d+)))[,\s]?(-?((\d+(\.\d+)?)|(\.\d+))))*)|(a(\s?-?((\d+(\.\d+)?)|(\.\d+)))([,\s]?(-?((\d+(\.\d+)?)|(\.\d+)))){2}[,\s]?[01][,\s]+[01][,\s]+([,\s]?(-?((\d+(\.\d+)?)|(\.\d+)))){2})|(s(\s?-?((\d+(\.\d+)?)|(\.\d+)))([,\s]?(-?((\d+(\.\d+)?)|(\.\d+)))){3})|z/gi;
|
|
25
|
+
//
|
|
26
|
+
// My Version allows multiple param sets, too, like 'm|M (x y)+' or 'q|Q (x1 y1 x y)+'. Look at the plus.
|
|
27
|
+
const validCommand = /([ml]((\s?-?((\d+(\.\d+)?)|(\.\d+)))[,\s]?(-?((\d+(\.\d+)?)|(\.\d+))))+)|([hv]((\s?-?((\d+(\.\d+)?)|(\.\d+))))+)|(c((\s?-?((\d+(\.\d+)?)|(\.\d+)))([,\s]?(-?((\d+(\.\d+)?)|(\.\d+)))){5})+)|(q((\s?-?((\d+(\.\d+)?)|(\.\d+)))([,\s]?(-?((\d+(\.\d+)?)|(\.\d+)))){3})+(\s?(t?(\s?-?((\d+(\.\d+)?)|(\.\d+)))[,\s]?(-?((\d+(\.\d+)?)|(\.\d+))))*)+)|(a((\s?-?((\d+(\.\d+)?)|(\.\d+)))([,\s]?(-?((\d+(\.\d+)?)|(\.\d+)))){2}[,\s]?[01][,\s]+[01][,\s]+([,\s]?(-?((\d+(\.\d+)?)|(\.\d+)))){2})+)|(s(\s?-?((\d+(\.\d+)?)|(\.\d+)))([,\s]?(-?((\d+(\.\d+)?)|(\.\d+)))){3})|z/gi;
|
|
23
28
|
const dataElements = dataString.match(validCommand);
|
|
24
|
-
// console.log("Splitted: ", dataElements);
|
|
25
29
|
if (!dataElements) {
|
|
26
30
|
return null;
|
|
27
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"splitSVGPathData.js","sourceRoot":"","sources":["../../../../ts/utils/parsers/svg/splitSVGPathData.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH;;;;IAII;AACJ,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,UAAkB,EAAgC,EAAE;IACnF,SAAS;IACT,uGAAuG;IACvG,MAAM,YAAY,GAChB,
|
|
1
|
+
{"version":3,"file":"splitSVGPathData.js","sourceRoot":"","sources":["../../../../ts/utils/parsers/svg/splitSVGPathData.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH;;;;IAII;AACJ,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,UAAkB,EAAgC,EAAE;IACnF,sEAAsE;IACtE,SAAS;IACT,uGAAuG;IACvG,uBAAuB;IACvB,2hBAA2hB;IAC3hB,EAAE;IACF,yGAAyG;IACzG,MAAM,YAAY,GAChB,yiBAAyiB,CAAC;IAE5iB,MAAM,YAAY,GAAG,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACpD,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO,IAAI,CAAC;KACb;IAED,MAAM,MAAM,GAA0B,EAAE,CAAC;IAEzC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE;QAC9B,MAAM,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QAC9B,0CAA0C;QAC1C,sHAAsH;QACtH,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;QACvD,IAAI,OAAO,EAAE;YACX,MAAM,CAAC,IAAI,CAAC,OAAyB,CAAC,CAAC;SACxC;aAAM;YACL,eAAe;SAChB;QACD,CAAC,EAAE,CAAC;KACL;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC,CAAC,uBAAuB"}
|
|
@@ -7,17 +7,28 @@
|
|
|
7
7
|
* https://www.w3.org/TR/SVG/paths.html
|
|
8
8
|
*
|
|
9
9
|
*
|
|
10
|
-
* @author
|
|
11
|
-
* @date
|
|
12
|
-
* @
|
|
10
|
+
* @author Ikaros Kappler
|
|
11
|
+
* @date 2022-12-21 (winter solstice night – yes the days & nights are dark and I have nothing else to do)
|
|
12
|
+
* @modified 2023-01-17 Added multiple parameter sets.
|
|
13
|
+
* @version 0.0.2-alpha
|
|
13
14
|
*/
|
|
14
15
|
export declare type NumericString = `${number}`;
|
|
15
16
|
export declare type BooleanString = "0" | "1" | `${boolean}`;
|
|
16
17
|
export declare type SVGPathMoveToCommand = ["M" | "m", NumericString, NumericString];
|
|
17
|
-
export declare type SVGPathLineToCommand = ["L" | "l", NumericString, NumericString];
|
|
18
|
+
export declare type SVGPathLineToCommand = ["L" | "l", NumericString, NumericString, ...Array<NumericString>];
|
|
18
19
|
export declare type SVGPathVerticalLineToCommand = ["V" | "v", NumericString];
|
|
19
20
|
export declare type SVGPathHorizontalLineToCommand = ["H" | "h", NumericString];
|
|
20
|
-
export declare type SVGPathQuadraticCurveToCommand = ["Q" | "q", NumericString, NumericString, NumericString, NumericString] | [
|
|
21
|
+
export declare type SVGPathQuadraticCurveToCommand = ["Q" | "q", NumericString, NumericString, NumericString, NumericString] | [
|
|
22
|
+
"Q" | "q",
|
|
23
|
+
NumericString,
|
|
24
|
+
NumericString,
|
|
25
|
+
NumericString,
|
|
26
|
+
NumericString,
|
|
27
|
+
"T" | "t",
|
|
28
|
+
NumericString,
|
|
29
|
+
NumericString,
|
|
30
|
+
...Array<NumericString>
|
|
31
|
+
];
|
|
21
32
|
export declare type SVGPathCubicCurveToCommand = [
|
|
22
33
|
"C" | "c",
|
|
23
34
|
NumericString,
|
|
@@ -25,9 +36,17 @@ export declare type SVGPathCubicCurveToCommand = [
|
|
|
25
36
|
NumericString,
|
|
26
37
|
NumericString,
|
|
27
38
|
NumericString,
|
|
28
|
-
NumericString
|
|
39
|
+
NumericString,
|
|
40
|
+
...Array<NumericString>
|
|
41
|
+
];
|
|
42
|
+
export declare type SVGPathShorthandCubicCurveToCommand = [
|
|
43
|
+
"S" | "s",
|
|
44
|
+
NumericString,
|
|
45
|
+
NumericString,
|
|
46
|
+
NumericString,
|
|
47
|
+
NumericString,
|
|
48
|
+
...Array<NumericString>
|
|
29
49
|
];
|
|
30
|
-
export declare type SVGPathShorthandCubicCurveToCommand = ["S" | "s", NumericString, NumericString, NumericString, NumericString];
|
|
31
50
|
export declare type SVGPathArcToCommand = [
|
|
32
51
|
"A" | "a",
|
|
33
52
|
NumericString,
|
|
@@ -36,8 +55,9 @@ export declare type SVGPathArcToCommand = [
|
|
|
36
55
|
BooleanString,
|
|
37
56
|
BooleanString,
|
|
38
57
|
NumericString,
|
|
39
|
-
NumericString
|
|
58
|
+
NumericString,
|
|
59
|
+
...Array<NumericString>
|
|
40
60
|
];
|
|
41
61
|
export declare type SVGPathCloseCommand = ["Z" | "z"];
|
|
42
|
-
export declare type SVGPathShorthandQuadraticCurveToCommand = ["T" | "t", NumericString, NumericString];
|
|
62
|
+
export declare type SVGPathShorthandQuadraticCurveToCommand = ["T" | "t", NumericString, NumericString, ...Array<NumericString>];
|
|
43
63
|
export declare type SVGPathCommand = SVGPathMoveToCommand | SVGPathLineToCommand | SVGPathVerticalLineToCommand | SVGPathHorizontalLineToCommand | SVGPathQuadraticCurveToCommand | SVGPathCubicCurveToCommand | SVGPathShorthandCubicCurveToCommand | SVGPathArcToCommand | SVGPathCloseCommand;
|
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
* https://www.w3.org/TR/SVG/paths.html
|
|
8
8
|
*
|
|
9
9
|
*
|
|
10
|
-
* @author
|
|
11
|
-
* @date
|
|
12
|
-
* @
|
|
10
|
+
* @author Ikaros Kappler
|
|
11
|
+
* @date 2022-12-21 (winter solstice night – yes the days & nights are dark and I have nothing else to do)
|
|
12
|
+
* @modified 2023-01-17 Added multiple parameter sets.
|
|
13
|
+
* @version 0.0.2-alpha
|
|
13
14
|
*/
|
|
14
15
|
export {};
|
|
15
16
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../ts/utils/parsers/svg/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../ts/utils/parsers/svg/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
|