@remotion/paths 3.3.51 → 3.3.52
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/dist/helpers/parse.d.ts +2 -0
- package/dist/helpers/parse.js +51 -0
- package/package.json +2 -2
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copied from: https://github.com/rveciana/svg-path-properties
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.parsePath = void 0;
|
|
5
|
+
const length = {
|
|
6
|
+
a: 7,
|
|
7
|
+
c: 6,
|
|
8
|
+
h: 1,
|
|
9
|
+
l: 2,
|
|
10
|
+
m: 2,
|
|
11
|
+
q: 4,
|
|
12
|
+
s: 4,
|
|
13
|
+
t: 2,
|
|
14
|
+
v: 1,
|
|
15
|
+
z: 0,
|
|
16
|
+
};
|
|
17
|
+
const segmentRegExp = /([astvzqmhlc])([^astvzqmhlc]*)/gi;
|
|
18
|
+
const numberRegExp = /-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;
|
|
19
|
+
const parsePath = (path) => {
|
|
20
|
+
const segments = (path && path.length > 0 ? path : 'M0,0').match(segmentRegExp);
|
|
21
|
+
if (!segments) {
|
|
22
|
+
throw new Error(`No path elements found in string ${path}`);
|
|
23
|
+
}
|
|
24
|
+
return segments.reduce((segmentsArray, segmentString) => {
|
|
25
|
+
let command = segmentString.charAt(0);
|
|
26
|
+
let type = command.toLowerCase();
|
|
27
|
+
const args = parseValues(segmentString.substr(1));
|
|
28
|
+
// overloaded moveTo
|
|
29
|
+
if (type === 'm' && args.length > 2) {
|
|
30
|
+
segmentsArray.push([command, ...args.splice(0, 2)]);
|
|
31
|
+
type = 'l';
|
|
32
|
+
command = command === 'm' ? 'l' : 'L';
|
|
33
|
+
}
|
|
34
|
+
while (args.length >= 0) {
|
|
35
|
+
if (args.length === length[type]) {
|
|
36
|
+
segmentsArray.push([command, ...args.splice(0, length[type])]);
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
if (args.length < length[type]) {
|
|
40
|
+
throw new Error(`Malformed path data: "${command}" must have ${length[type]} elements and has ${args.length}: ${segmentString}`);
|
|
41
|
+
}
|
|
42
|
+
segmentsArray.push([command, ...args.splice(0, length[type])]);
|
|
43
|
+
}
|
|
44
|
+
return segmentsArray;
|
|
45
|
+
}, []);
|
|
46
|
+
};
|
|
47
|
+
exports.parsePath = parsePath;
|
|
48
|
+
const parseValues = (args) => {
|
|
49
|
+
const numbers = args.match(numberRegExp);
|
|
50
|
+
return numbers ? numbers.map(Number) : [];
|
|
51
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/paths",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.52",
|
|
4
4
|
"description": "Utility functions for SVG paths",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "b48dff6c96081c924ae3bbc37f2f00bdd53e6e1f"
|
|
39
39
|
}
|