svg-toolbox 1.1.5 → 1.1.7
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 +151 -21
- package/es/applyRemoveNanCoordinates.js +7 -3
- package/es/applyRemoveNanCoordinates.js.map +1 -1
- package/es/{utils.d.ts → common.d.ts} +3 -5
- package/es/{utils.js → common.js} +4 -6
- package/es/common.js.map +1 -0
- package/es/index.d.ts +9 -3
- package/es/index.js +9 -3
- package/es/index.js.map +1 -1
- package/lib/applyRemoveNanCoordinates.js +7 -3
- package/lib/applyRemoveNanCoordinates.js.map +1 -1
- package/lib/{utils.d.ts → common.d.ts} +3 -5
- package/lib/{utils.js → common.js} +4 -6
- package/lib/common.js.map +1 -0
- package/lib/index.d.ts +9 -3
- package/lib/index.js +10 -8
- package/lib/index.js.map +1 -1
- package/package.json +3 -2
- package/es/utils.js.map +0 -1
- package/lib/utils.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
This
|
|
1
|
+
# SVG Utility Functions
|
|
2
|
+
This module provides utility functions for working with SVG elements and files, including creating, cloning, merging, converting SVG to Base64, comparing SVG images, normalizing path data, and converting SVG to PNG format.
|
|
3
3
|
|
|
4
4
|
[](https://www.npmjs.com/package/svg-toolbox)
|
|
5
5
|
[](https://www.npmjs.com/package/svg-toolbox)
|
|
@@ -9,34 +9,164 @@ This library provides some SVG-related tools
|
|
|
9
9
|
```bash
|
|
10
10
|
npm install svg-toolbox
|
|
11
11
|
```
|
|
12
|
+
|
|
13
|
+
## Table of Contents
|
|
14
|
+
|
|
15
|
+
- [SVG Utility Functions](#svg-utility-functions)
|
|
16
|
+
- [Installation](#installation)
|
|
17
|
+
- [Table of Contents](#table-of-contents)
|
|
18
|
+
- [Usage](#usage)
|
|
19
|
+
- [createSVGElement](#createsvgelement)
|
|
20
|
+
- [cloneSVGElement](#clonesvgelement)
|
|
21
|
+
- [mergeSVGElements](#mergesvgelements)
|
|
22
|
+
- [convertSVGToBase64](#convertsvgtobase64)
|
|
23
|
+
- [convertBase64ToSVG](#convertbase64tosvg)
|
|
24
|
+
- [diffSvg](#diffsvg)
|
|
25
|
+
- [removeNanCoordinates](#removenancoordinates)
|
|
26
|
+
- [svg2png](#svg2png)
|
|
27
|
+
- [License](#license)
|
|
28
|
+
|
|
12
29
|
## Usage
|
|
30
|
+
|
|
31
|
+
### createSVGElement
|
|
32
|
+
|
|
33
|
+
Creates an SVG element from a given SVG content string.
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { createSVGElement } from 'svg-toolbox';
|
|
37
|
+
|
|
38
|
+
const svgContent = `<circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />`;
|
|
39
|
+
const svgElement = createSVGElement(svgContent);
|
|
40
|
+
console.log(svgElement);
|
|
41
|
+
```
|
|
42
|
+
### cloneSVGElement
|
|
43
|
+
|
|
44
|
+
Clones an SVG element deeply.
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { cloneSVGElement } from 'svg-toolbox';
|
|
48
|
+
import { JSDOM } from 'jsdom';
|
|
49
|
+
|
|
50
|
+
const dom = new JSDOM(`<!DOCTYPE html><html><body></body></html>`);
|
|
51
|
+
const { document } = dom.window;
|
|
52
|
+
|
|
53
|
+
const originalElement = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
|
|
54
|
+
originalElement.setAttribute('cx', '50');
|
|
55
|
+
originalElement.setAttribute('cy', '50');
|
|
56
|
+
originalElement.setAttribute('r', '40');
|
|
57
|
+
originalElement.setAttribute('stroke', 'black');
|
|
58
|
+
originalElement.setAttribute('stroke-width', '3');
|
|
59
|
+
originalElement.setAttribute('fill', 'red');
|
|
60
|
+
|
|
61
|
+
const clonedElement = cloneSVGElement(originalElement);
|
|
62
|
+
console.log(clonedElement);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### mergeSVGElements
|
|
66
|
+
Merges multiple SVG elements into a single SVG element.
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { mergeSVGElements } from 'svg-toolbox';
|
|
70
|
+
import { JSDOM } from 'jsdom';
|
|
71
|
+
|
|
72
|
+
const dom = new JSDOM(`<!DOCTYPE html><html><body></body></html>`);
|
|
73
|
+
const { document } = dom.window;
|
|
74
|
+
|
|
75
|
+
const svgElement1 = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
|
|
76
|
+
svgElement1.setAttribute('cx', '50');
|
|
77
|
+
svgElement1.setAttribute('cy', '50');
|
|
78
|
+
svgElement1.setAttribute('r', '40');
|
|
79
|
+
svgElement1.setAttribute('stroke', 'black');
|
|
80
|
+
svgElement1.setAttribute('stroke-width', '3');
|
|
81
|
+
svgElement1.setAttribute('fill', 'red');
|
|
82
|
+
|
|
83
|
+
const svgElement2 = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
|
|
84
|
+
svgElement2.setAttribute('x', '10');
|
|
85
|
+
svgElement2.setAttribute('y', '10');
|
|
86
|
+
svgElement2.setAttribute('width', '100');
|
|
87
|
+
svgElement2.setAttribute('height', '100');
|
|
88
|
+
svgElement2.setAttribute('fill', 'blue');
|
|
89
|
+
|
|
90
|
+
const mergedElement = mergeSVGElements([svgElement1, svgElement2]);
|
|
91
|
+
console.log(mergedElement);
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### convertSVGToBase64
|
|
95
|
+
Converts an SVG element to a Base64-encoded string.
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
import { convertSVGToBase64 } from 'svg-toolbox';
|
|
99
|
+
import { JSDOM } from 'jsdom';
|
|
100
|
+
|
|
101
|
+
const dom = new JSDOM(`<!DOCTYPE html><html><body></body></html>`);
|
|
102
|
+
const { document } = dom.window;
|
|
103
|
+
|
|
104
|
+
const svgElement = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
|
|
105
|
+
svgElement.setAttribute('cx', '50');
|
|
106
|
+
svgElement.setAttribute('cy', '50');
|
|
107
|
+
svgElement.setAttribute('r', '40');
|
|
108
|
+
svgElement.setAttribute('stroke', 'black');
|
|
109
|
+
svgElement.setAttribute('stroke-width', '3');
|
|
110
|
+
svgElement.setAttribute('fill', 'red');
|
|
111
|
+
|
|
112
|
+
const base64String = convertSVGToBase64(svgElement);
|
|
113
|
+
console.log(base64String);
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### convertBase64ToSVG
|
|
117
|
+
Converts a Base64-encoded string back to an SVG string.
|
|
118
|
+
|
|
13
119
|
```typescript
|
|
14
|
-
|
|
120
|
+
import { convertBase64ToSVG } from 'svg-toolbox';
|
|
15
121
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
122
|
+
const base64String = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxjaXJjbGUgY3g9IjUwIiBjeT0iNTAiIHI9IjQwIiBzdHJva2U9ImJsYWNrIiBzdHJva2Utd2lkdGg9IjMiIGZpbGw9InJlZCIgLz48L3N2Zz4=';
|
|
123
|
+
const svgString = convertBase64ToSVG(base64String);
|
|
124
|
+
console.log(svgString);
|
|
19
125
|
```
|
|
20
126
|
|
|
127
|
+
### diffSvg
|
|
128
|
+
Compares two PNG images and generates a diff image.
|
|
129
|
+
|
|
21
130
|
```typescript
|
|
22
|
-
|
|
131
|
+
import { diffSvg } from 'svg-toolbox';
|
|
132
|
+
|
|
133
|
+
const pathA = 'path/to/first/image.png';
|
|
134
|
+
const pathB = 'path/to/second/image.png';
|
|
135
|
+
const diffFilePath = 'path/to/save/diff/image.png';
|
|
23
136
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
} | void> = await diffSvg(svgPath1, svgPath2, diffResultSavePath)
|
|
32
|
-
const diffPngBase64 = `data:image/png;base64,${diffPngBuffer.toString('base64')}`;
|
|
33
|
-
...
|
|
137
|
+
diffSvg(pathA, pathB, diffFilePath)
|
|
138
|
+
.then(({ diffPngBuffer, numDiffPixels }) => {
|
|
139
|
+
console.log(`Number of different pixels: ${numDiffPixels}`);
|
|
140
|
+
})
|
|
141
|
+
.catch(error => {
|
|
142
|
+
console.error('Error generating diff image:', error);
|
|
143
|
+
});
|
|
34
144
|
```
|
|
35
145
|
|
|
146
|
+
### removeNanCoordinates
|
|
147
|
+
Parses and normalizes the d attribute of all path elements in an SVG content.
|
|
148
|
+
|
|
36
149
|
```typescript
|
|
37
|
-
|
|
150
|
+
import { removeNanCoordinates } from 'svg-toolbox';
|
|
151
|
+
|
|
152
|
+
const svgContent = `<svg><path d="M 10,20 nan L 30,40 -nan Z" /></svg>`;
|
|
153
|
+
const normalizedSvgContent = removeNanCoordinates(svgContent);
|
|
154
|
+
console.log(normalizedSvgContent);
|
|
38
155
|
|
|
39
|
-
...
|
|
40
|
-
const modifiedSvgContent: string = removeEmptyCoordinates(svgContent)
|
|
41
|
-
...
|
|
42
156
|
```
|
|
157
|
+
|
|
158
|
+
### svg2png
|
|
159
|
+
Converts an SVG file to PNG format.
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
import { svg2Png } from 'svg-toolbox';
|
|
163
|
+
|
|
164
|
+
const svgPath = 'path/to/input/image.svg';
|
|
165
|
+
const pngPath = 'path/to/output/image.png';
|
|
166
|
+
const scale = 2; // Scaling factor
|
|
167
|
+
|
|
168
|
+
svg2Png(svgPath, pngPath, scale);
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## License
|
|
172
|
+
MIT License
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* @author pipi
|
|
7
7
|
*/
|
|
8
8
|
import { JSDOM } from 'jsdom';
|
|
9
|
+
// Define the types of path commands that do not have parameters
|
|
10
|
+
const ignoreTypes = ['z', 'Z'];
|
|
9
11
|
/**
|
|
10
12
|
* Parses and normalizes the 'd' attribute of all path elements in an SVG content.
|
|
11
13
|
* @param {*} svgContent
|
|
@@ -41,11 +43,13 @@ export default function (svgContent) {
|
|
|
41
43
|
// Split each command into type and parameters
|
|
42
44
|
const type = command[0];
|
|
43
45
|
// If the command is not 'z' or 'Z', then it has parameters.
|
|
44
|
-
|
|
46
|
+
const ignoreType = ignoreTypes.includes(type);
|
|
47
|
+
if (!ignoreType) {
|
|
45
48
|
// Split parameters by spaces or commas, filter out empty values, and convert to numbers
|
|
46
49
|
const params = command.slice(1).split(/[\s,]+/);
|
|
47
50
|
// Filter out non-numeric values
|
|
48
|
-
|
|
51
|
+
const pickCommand = params.every(Number);
|
|
52
|
+
if (pickCommand) {
|
|
49
53
|
return { type, params };
|
|
50
54
|
}
|
|
51
55
|
}
|
|
@@ -57,7 +61,7 @@ export default function (svgContent) {
|
|
|
57
61
|
.filter((item) => item !== void 0)
|
|
58
62
|
// Filter out commands with no parameters, or commands with only 'z' or 'Z'. 'Zz' means close the path.
|
|
59
63
|
// -> https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/d#closepath
|
|
60
|
-
.filter((command) => (
|
|
64
|
+
.filter((command) => (ignoreTypes.includes(command.type) || command.params.length > 0));
|
|
61
65
|
// Reconstruct the 'd' attribute
|
|
62
66
|
const modifiedD = commands.map((command) => {
|
|
63
67
|
return command.type + command.params.join(' ');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyRemoveNanCoordinates.js","sourceRoot":"","sources":["../src/applyRemoveNanCoordinates.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B;;;;GAIG;AACH,MAAM,CAAC,OAAO,WAAW,UAAkB;IACzC,oCAAoC;IACpC,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,UAAU,EAAE;QAChC,WAAW,EAAE,eAAe,CAAC,0BAA0B;KACxD,CAAC,CAAC;IACH,mCAAmC;IACnC,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC;IACrC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M,EAAE,CAAC;gBAC1B,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;YAC9B,CAAC;QACH,CAAC,CAAC;YACF,8BAA8B;aAC7B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC;YAClC,wGAAwG;YACxG,4EAA4E;aAC3E,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;QAC1F,gCAAgC;QAChC,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YACzC,OAAO,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACZ,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,iCAAiC;IACtE,CAAC,CAAC,CAAC;IAEH,0BAA0B;IAC1B,MAAM,aAAa,GAAG,UAAU,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;IAClD,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -91,13 +91,11 @@ export declare function convertSVGToBase64(svgElement: Element): string;
|
|
|
91
91
|
* @returns {string} - The SVG string representation of the Base64-encoded string.
|
|
92
92
|
*
|
|
93
93
|
* @example
|
|
94
|
-
*
|
|
95
|
-
* @param {string} base64String - The Base64-encoded string to convert.
|
|
96
|
-
* @returns {string} - The SVG string representation of the Base64-encoded string.
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
94
|
* const base64String = 'data:image/svg+xml;base64, * const base64String = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3
|
|
100
95
|
* const svgString = convertBase64ToSVG(base64String);
|
|
101
96
|
* console.log(svgString);
|
|
97
|
+
*
|
|
98
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser - DOMParser documentation
|
|
99
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Buffer - Buffer documentation
|
|
102
100
|
*/
|
|
103
101
|
export declare function convertBase64ToSVG(base64String: string): string;
|
|
@@ -114,17 +114,15 @@ export function convertSVGToBase64(svgElement) {
|
|
|
114
114
|
* @returns {string} - The SVG string representation of the Base64-encoded string.
|
|
115
115
|
*
|
|
116
116
|
* @example
|
|
117
|
-
*
|
|
118
|
-
* @param {string} base64String - The Base64-encoded string to convert.
|
|
119
|
-
* @returns {string} - The SVG string representation of the Base64-encoded string.
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
117
|
* const base64String = 'data:image/svg+xml;base64, * const base64String = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3
|
|
123
118
|
* const svgString = convertBase64ToSVG(base64String);
|
|
124
119
|
* console.log(svgString);
|
|
120
|
+
*
|
|
121
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser - DOMParser documentation
|
|
122
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Buffer - Buffer documentation
|
|
125
123
|
*/
|
|
126
124
|
export function convertBase64ToSVG(base64String) {
|
|
127
125
|
const svgString = Buffer.from(base64String.split(',')[1], 'base64').toString('utf-8');
|
|
128
126
|
return svgString;
|
|
129
127
|
}
|
|
130
|
-
//# sourceMappingURL=
|
|
128
|
+
//# sourceMappingURL=common.js.map
|
package/es/common.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,mCAAmC;AACnC,MAAM,GAAG,GA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MAAM,SAAS,GAAG,UAAU,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAC3D,OAAO,6BAA6B,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;AAClF,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,kBAAkB,CAAC,YAAoB;IACrD,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACtF,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/es/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import svg2Png from './applySvg2Png';
|
|
2
2
|
import diffSvg from './applyDiffSvg';
|
|
3
|
-
import
|
|
4
|
-
import { createSVGElement, cloneSVGElement, mergeSVGElements, convertSVGToBase64, convertBase64ToSVG } from './
|
|
5
|
-
|
|
3
|
+
import removeNanCoordinates from './applyRemoveNanCoordinates';
|
|
4
|
+
import { createSVGElement, cloneSVGElement, mergeSVGElements, convertSVGToBase64, convertBase64ToSVG } from './common';
|
|
5
|
+
declare const removeEmptyCoordinates: typeof removeNanCoordinates;
|
|
6
|
+
export { svg2Png, diffSvg,
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated
|
|
9
|
+
* @see removeNanCoordinates
|
|
10
|
+
*/
|
|
11
|
+
removeEmptyCoordinates, removeNanCoordinates, createSVGElement, cloneSVGElement, mergeSVGElements, convertSVGToBase64, convertBase64ToSVG };
|
package/es/index.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import svg2Png from './applySvg2Png';
|
|
2
2
|
import diffSvg from './applyDiffSvg';
|
|
3
|
-
import
|
|
4
|
-
import { createSVGElement, cloneSVGElement, mergeSVGElements, convertSVGToBase64, convertBase64ToSVG } from './
|
|
5
|
-
|
|
3
|
+
import removeNanCoordinates from './applyRemoveNanCoordinates';
|
|
4
|
+
import { createSVGElement, cloneSVGElement, mergeSVGElements, convertSVGToBase64, convertBase64ToSVG } from './common';
|
|
5
|
+
const removeEmptyCoordinates = removeNanCoordinates;
|
|
6
|
+
export { svg2Png, diffSvg,
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated
|
|
9
|
+
* @see removeNanCoordinates
|
|
10
|
+
*/
|
|
11
|
+
removeEmptyCoordinates, removeNanCoordinates, createSVGElement, cloneSVGElement, mergeSVGElements, convertSVGToBase64, convertBase64ToSVG };
|
|
6
12
|
//# sourceMappingURL=index.js.map
|
package/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,oBAAoB,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAEtH,MAAM,sBAAsB,GAAG,oBAAoB,CAAA;AAEnD,OAAO,EACL,OAAO,EACP,OAAO;AACP;;;GAGG;AACH,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,kBAAkB,EAC5F,CAAC"}
|
|
@@ -9,6 +9,8 @@ exports.default = default_1;
|
|
|
9
9
|
* @author pipi
|
|
10
10
|
*/
|
|
11
11
|
var jsdom_1 = require("jsdom");
|
|
12
|
+
// Define the types of path commands that do not have parameters
|
|
13
|
+
var ignoreTypes = ['z', 'Z'];
|
|
12
14
|
/**
|
|
13
15
|
* Parses and normalizes the 'd' attribute of all path elements in an SVG content.
|
|
14
16
|
* @param {*} svgContent
|
|
@@ -44,11 +46,13 @@ function default_1(svgContent) {
|
|
|
44
46
|
// Split each command into type and parameters
|
|
45
47
|
var type = command[0];
|
|
46
48
|
// If the command is not 'z' or 'Z', then it has parameters.
|
|
47
|
-
|
|
49
|
+
var ignoreType = ignoreTypes.includes(type);
|
|
50
|
+
if (!ignoreType) {
|
|
48
51
|
// Split parameters by spaces or commas, filter out empty values, and convert to numbers
|
|
49
52
|
var params = command.slice(1).split(/[\s,]+/);
|
|
50
53
|
// Filter out non-numeric values
|
|
51
|
-
|
|
54
|
+
var pickCommand = params.every(Number);
|
|
55
|
+
if (pickCommand) {
|
|
52
56
|
return { type: type, params: params };
|
|
53
57
|
}
|
|
54
58
|
}
|
|
@@ -60,7 +64,7 @@ function default_1(svgContent) {
|
|
|
60
64
|
.filter(function (item) { return item !== void 0; })
|
|
61
65
|
// Filter out commands with no parameters, or commands with only 'z' or 'Z'. 'Zz' means close the path.
|
|
62
66
|
// -> https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/d#closepath
|
|
63
|
-
.filter(function (command) { return (
|
|
67
|
+
.filter(function (command) { return (ignoreTypes.includes(command.type) || command.params.length > 0); });
|
|
64
68
|
// Reconstruct the 'd' attribute
|
|
65
69
|
var modifiedD = commands.map(function (command) {
|
|
66
70
|
return command.type + command.params.join(' ');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyRemoveNanCoordinates.js","sourceRoot":"","sources":["../src/applyRemoveNanCoordinates.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"applyRemoveNanCoordinates.js","sourceRoot":"","sources":["../src/applyRemoveNanCoordinates.ts"],"names":[],"mappings":";;AAiBA,4BA4DC;AA7ED;;;;;;GAMG;AACH,+BAA8B;AAE9B,gEAAgE;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C,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;gBAC/C,gCAAgC;gBAChC,IAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;gBACxC,IAAI,WAAW,EAAE,CAAC;oBAChB,OAAO,EAAE,IAAI,MAAA,EAAE,MAAM,QAAA,EAAE,CAAC;gBAC1B,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,OAAO,EAAE,IAAI,MAAA,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;YAC9B,CAAC;QACH,CAAC,CAAC;YACF,8BAA8B;aAC7B,MAAM,CAAC,UAAC,IAAI,IAAK,OAAA,IAAI,KAAK,KAAK,CAAC,EAAf,CAAe,CAAC;YAClC,wGAAwG;YACxG,4EAA4E;aAC3E,MAAM,CAAC,UAAC,OAAO,IAAK,OAAA,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,EAAjE,CAAiE,CAAC,CAAC;QAC1F,gCAAgC;QAChC,IAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,UAAC,OAAO;YACrC,OAAO,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACZ,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,iCAAiC;IACtE,CAAC,CAAC,CAAC;IAEH,0BAA0B;IAC1B,IAAM,aAAa,GAAG,UAAU,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;IAClD,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -91,13 +91,11 @@ export declare function convertSVGToBase64(svgElement: Element): string;
|
|
|
91
91
|
* @returns {string} - The SVG string representation of the Base64-encoded string.
|
|
92
92
|
*
|
|
93
93
|
* @example
|
|
94
|
-
*
|
|
95
|
-
* @param {string} base64String - The Base64-encoded string to convert.
|
|
96
|
-
* @returns {string} - The SVG string representation of the Base64-encoded string.
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
94
|
* const base64String = 'data:image/svg+xml;base64, * const base64String = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3
|
|
100
95
|
* const svgString = convertBase64ToSVG(base64String);
|
|
101
96
|
* console.log(svgString);
|
|
97
|
+
*
|
|
98
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser - DOMParser documentation
|
|
99
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Buffer - Buffer documentation
|
|
102
100
|
*/
|
|
103
101
|
export declare function convertBase64ToSVG(base64String: string): string;
|
|
@@ -121,17 +121,15 @@ function convertSVGToBase64(svgElement) {
|
|
|
121
121
|
* @returns {string} - The SVG string representation of the Base64-encoded string.
|
|
122
122
|
*
|
|
123
123
|
* @example
|
|
124
|
-
*
|
|
125
|
-
* @param {string} base64String - The Base64-encoded string to convert.
|
|
126
|
-
* @returns {string} - The SVG string representation of the Base64-encoded string.
|
|
127
|
-
*
|
|
128
|
-
* @example
|
|
129
124
|
* const base64String = 'data:image/svg+xml;base64, * const base64String = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3
|
|
130
125
|
* const svgString = convertBase64ToSVG(base64String);
|
|
131
126
|
* console.log(svgString);
|
|
127
|
+
*
|
|
128
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser - DOMParser documentation
|
|
129
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Buffer - Buffer documentation
|
|
132
130
|
*/
|
|
133
131
|
function convertBase64ToSVG(base64String) {
|
|
134
132
|
var svgString = Buffer.from(base64String.split(',')[1], 'base64').toString('utf-8');
|
|
135
133
|
return svgString;
|
|
136
134
|
}
|
|
137
|
-
//# sourceMappingURL=
|
|
135
|
+
//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CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,kBAAkB,CAAC,UAAmB;IACpD,IAAM,UAAU,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;IAClD,IAAM,SAAS,GAAG,UAAU,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAC3D,OAAO,oCAA6B,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAE,CAAC;AAClF,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,kBAAkB,CAAC,YAAoB;IACrD,IAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACtF,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import svg2Png from './applySvg2Png';
|
|
2
2
|
import diffSvg from './applyDiffSvg';
|
|
3
|
-
import
|
|
4
|
-
import { createSVGElement, cloneSVGElement, mergeSVGElements, convertSVGToBase64, convertBase64ToSVG } from './
|
|
5
|
-
|
|
3
|
+
import removeNanCoordinates from './applyRemoveNanCoordinates';
|
|
4
|
+
import { createSVGElement, cloneSVGElement, mergeSVGElements, convertSVGToBase64, convertBase64ToSVG } from './common';
|
|
5
|
+
declare const removeEmptyCoordinates: typeof removeNanCoordinates;
|
|
6
|
+
export { svg2Png, diffSvg,
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated
|
|
9
|
+
* @see removeNanCoordinates
|
|
10
|
+
*/
|
|
11
|
+
removeEmptyCoordinates, removeNanCoordinates, createSVGElement, cloneSVGElement, mergeSVGElements, convertSVGToBase64, convertBase64ToSVG };
|
package/lib/index.js
CHANGED
|
@@ -3,17 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.convertBase64ToSVG = exports.convertSVGToBase64 = exports.mergeSVGElements = exports.cloneSVGElement = exports.createSVGElement = exports.removeEmptyCoordinates = exports.diffSvg = exports.svg2Png = void 0;
|
|
6
|
+
exports.convertBase64ToSVG = exports.convertSVGToBase64 = exports.mergeSVGElements = exports.cloneSVGElement = exports.createSVGElement = exports.removeNanCoordinates = exports.removeEmptyCoordinates = exports.diffSvg = exports.svg2Png = void 0;
|
|
7
7
|
var applySvg2Png_1 = __importDefault(require("./applySvg2Png"));
|
|
8
8
|
exports.svg2Png = applySvg2Png_1.default;
|
|
9
9
|
var applyDiffSvg_1 = __importDefault(require("./applyDiffSvg"));
|
|
10
10
|
exports.diffSvg = applyDiffSvg_1.default;
|
|
11
11
|
var applyRemoveNanCoordinates_1 = __importDefault(require("./applyRemoveNanCoordinates"));
|
|
12
|
-
exports.
|
|
13
|
-
var
|
|
14
|
-
Object.defineProperty(exports, "createSVGElement", { enumerable: true, get: function () { return
|
|
15
|
-
Object.defineProperty(exports, "cloneSVGElement", { enumerable: true, get: function () { return
|
|
16
|
-
Object.defineProperty(exports, "mergeSVGElements", { enumerable: true, get: function () { return
|
|
17
|
-
Object.defineProperty(exports, "convertSVGToBase64", { enumerable: true, get: function () { return
|
|
18
|
-
Object.defineProperty(exports, "convertBase64ToSVG", { enumerable: true, get: function () { return
|
|
12
|
+
exports.removeNanCoordinates = applyRemoveNanCoordinates_1.default;
|
|
13
|
+
var common_1 = require("./common");
|
|
14
|
+
Object.defineProperty(exports, "createSVGElement", { enumerable: true, get: function () { return common_1.createSVGElement; } });
|
|
15
|
+
Object.defineProperty(exports, "cloneSVGElement", { enumerable: true, get: function () { return common_1.cloneSVGElement; } });
|
|
16
|
+
Object.defineProperty(exports, "mergeSVGElements", { enumerable: true, get: function () { return common_1.mergeSVGElements; } });
|
|
17
|
+
Object.defineProperty(exports, "convertSVGToBase64", { enumerable: true, get: function () { return common_1.convertSVGToBase64; } });
|
|
18
|
+
Object.defineProperty(exports, "convertBase64ToSVG", { enumerable: true, get: function () { return common_1.convertBase64ToSVG; } });
|
|
19
|
+
var removeEmptyCoordinates = applyRemoveNanCoordinates_1.default;
|
|
20
|
+
exports.removeEmptyCoordinates = removeEmptyCoordinates;
|
|
19
21
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAQnC,kBARK,sBAAO,CAQL;AAPT,gEAAqC;AAQnC,kBARK,sBAAO,CAQL;AAPT,0FAA+D;AAa7D,+BAbK,mCAAoB,CAaL;AAZtB,mCAAsH;AAapH,iGAbO,yBAAgB,OAaP;AAAE,gGAbO,wBAAe,OAaP;AAAE,iGAbO,yBAAgB,OAaP;AAAE,mGAbO,2BAAkB,OAaP;AAAE,mGAbO,2BAAkB,OAaP;AAX7F,IAAM,sBAAsB,GAAG,mCAAoB,CAAA;AASjD,wDAAsB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svg-toolbox",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"description": "This library provides some SVG-related tools",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build:es": "tsc -p tsconfig.json",
|
|
17
17
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
18
|
-
"build": "npm run build:es && npm run build:cjs"
|
|
18
|
+
"build": "npm run build:es && npm run build:cjs",
|
|
19
|
+
"prepublishOnly": "npm run build"
|
|
19
20
|
},
|
|
20
21
|
"keywords": [
|
|
21
22
|
"svg"
|
package/es/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,mCAAmC;AACnC,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;AACnE,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAkB;IACjD,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,eAAe,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC,eAAe,CAAC;IAC3G,OAAO,UAAU,CAAA;AACnB,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC9C,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;IAClD,MAAM,UAAU,GAAG,UAAU,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;IAC1C,MAAM,GAAG,GAAG,MAAM,CAAC,eAAe,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;IAChE,OAAO,GAAG,CAAC,eAAgB,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAmB;IAClD,M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