svg-path-commander 2.0.10 → 2.1.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/.eslintrc.cjs +1 -0
- package/README.md +64 -8
- package/dist/svg-path-commander.cjs +1 -1
- package/dist/svg-path-commander.cjs.map +1 -1
- package/dist/svg-path-commander.d.ts +236 -43
- package/dist/svg-path-commander.js +1 -1
- package/dist/svg-path-commander.js.map +1 -1
- package/dist/svg-path-commander.mjs +790 -650
- package/dist/svg-path-commander.mjs.map +1 -1
- package/package.json +20 -22
- package/src/convert/pathToAbsolute.ts +16 -70
- package/src/convert/pathToCurve.ts +36 -28
- package/src/convert/pathToRelative.ts +33 -62
- package/src/index.ts +37 -39
- package/src/interface.ts +33 -33
- package/src/math/arcTools.ts +394 -0
- package/src/math/bezier.ts +253 -0
- package/src/math/cubicTools.ts +122 -0
- package/src/math/distanceSquareRoot.ts +3 -1
- package/src/math/lineTools.ts +67 -0
- package/src/math/midPoint.ts +3 -1
- package/src/math/polygonArea.ts +3 -1
- package/src/math/polygonLength.ts +2 -1
- package/src/math/quadTools.ts +98 -0
- package/src/parser/isMoveCommand.ts +17 -0
- package/src/parser/parsePathString.ts +5 -5
- package/src/parser/scanSegment.ts +12 -3
- package/src/process/absolutizeSegment.ts +58 -0
- package/src/process/iterate.ts +33 -0
- package/src/process/normalizePath.ts +34 -28
- package/src/process/normalizeSegment.ts +8 -9
- package/src/process/projection2d.ts +2 -1
- package/src/process/relativizeSegment.ts +61 -0
- package/src/process/reversePath.ts +1 -1
- package/src/process/roundPath.ts +8 -10
- package/src/process/segmentToCubic.ts +1 -1
- package/src/process/shortenSegment.ts +3 -3
- package/src/process/splitCubic.ts +8 -7
- package/src/process/splitPath.ts +39 -5
- package/src/process/transformPath.ts +81 -94
- package/src/types.ts +40 -1
- package/src/util/distanceEpsilon.ts +3 -0
- package/src/util/getClosestPoint.ts +1 -1
- package/src/util/getPathArea.ts +3 -3
- package/src/util/getPathBBox.ts +86 -18
- package/src/util/getPointAtLength.ts +98 -4
- package/src/util/getPropertiesAtLength.ts +4 -3
- package/src/util/getPropertiesAtPoint.ts +4 -1
- package/src/util/getTotalLength.ts +71 -4
- package/src/util/isPointInStroke.ts +2 -1
- package/src/util/shapeToPathArray.ts +8 -4
- package/test/class.test.ts +502 -0
- package/test/fixtures/getMarkup.ts +17 -0
- package/{cypress → test}/fixtures/shapes.js +39 -39
- package/test/fixtures/simpleShapes.js +75 -0
- package/test/static.test.ts +324 -0
- package/tsconfig.json +9 -4
- package/{vite.config.ts → vite.config.mts} +10 -1
- package/vitest.config-ui.mts +26 -0
- package/vitest.config.mts +26 -0
- package/cypress/e2e/svg-path-commander.spec.ts +0 -868
- package/cypress/fixtures/simpleShapes.js +0 -75
- package/cypress/plugins/esbuild-istanbul.ts +0 -50
- package/cypress/plugins/tsCompile.ts +0 -34
- package/cypress/support/commands.ts +0 -37
- package/cypress/support/e2e.ts +0 -21
- package/cypress/test.html +0 -36
- package/cypress.config.ts +0 -29
- package/src/process/fixArc.ts +0 -23
- package/src/util/pathLengthFactory.ts +0 -114
- package/src/util/segmentArcFactory.ts +0 -219
- package/src/util/segmentCubicFactory.ts +0 -114
- package/src/util/segmentLineFactory.ts +0 -45
- package/src/util/segmentQuadFactory.ts +0 -109
- /package/{cypress/fixtures/shapeObjects.js → test/fixtures/shapeObjects.ts} +0 -0
package/tsconfig.json
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// https://janessagarrow.com/blog/typescript-and-esbuild/
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"lib": ["DOM", "ESNext", "DOM.Iterable"],
|
|
5
|
-
// "types": ["vite", "vite/client", "
|
|
6
|
-
|
|
5
|
+
// "types": ["vite", "vite/client", "vitest", "node", "@thednp/dommatrix"],
|
|
6
|
+
// "types": ["@thednp/dommatrix"],
|
|
7
7
|
"rootDir": "./",
|
|
8
8
|
"baseUrl": "./",
|
|
9
9
|
"module": "ESNext",
|
|
10
10
|
"target": "ESNext",
|
|
11
|
-
"moduleResolution": "
|
|
11
|
+
"moduleResolution": "Bundler",
|
|
12
12
|
"allowJs": true,
|
|
13
13
|
"forceConsistentCasingInFileNames": true,
|
|
14
14
|
"useDefineForClassFields": true,
|
|
@@ -23,7 +23,12 @@
|
|
|
23
23
|
"removeComments": false,
|
|
24
24
|
"allowSyntheticDefaultImports": true,
|
|
25
25
|
"noEmit": true,
|
|
26
|
+
"paths": {
|
|
27
|
+
"~/*": [
|
|
28
|
+
"src"
|
|
29
|
+
],
|
|
30
|
+
}
|
|
26
31
|
},
|
|
27
|
-
"include": ["src/*", "
|
|
32
|
+
"include": ["src/*", "test/**/*"],
|
|
28
33
|
"exclude": ["node_modules", "experiments", "coverage", "dist"],
|
|
29
34
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
import {resolve} from 'path';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
3
|
import { defineConfig } from 'vite';
|
|
4
4
|
import { name } from './package.json';
|
|
5
5
|
|
|
@@ -17,6 +17,11 @@ const fileName = {
|
|
|
17
17
|
|
|
18
18
|
export default defineConfig({
|
|
19
19
|
base: './',
|
|
20
|
+
resolve: {
|
|
21
|
+
alias: {
|
|
22
|
+
"~": resolve(__dirname, "src"),
|
|
23
|
+
},
|
|
24
|
+
},
|
|
20
25
|
build: {
|
|
21
26
|
emptyOutDir: true,
|
|
22
27
|
outDir: 'dist',
|
|
@@ -27,6 +32,10 @@ export default defineConfig({
|
|
|
27
32
|
fileName: (format: string) => fileName[format],
|
|
28
33
|
},
|
|
29
34
|
sourcemap: true,
|
|
35
|
+
reportCompressedSize: true,
|
|
36
|
+
},
|
|
37
|
+
esbuild: {
|
|
38
|
+
legalComments: 'none'
|
|
30
39
|
}
|
|
31
40
|
});
|
|
32
41
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
resolve: {
|
|
6
|
+
alias: {
|
|
7
|
+
"~": resolve(__dirname, "src"),
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
test: {
|
|
11
|
+
css: true,
|
|
12
|
+
globals: true,
|
|
13
|
+
coverage: {
|
|
14
|
+
provider: "istanbul",
|
|
15
|
+
reporter: ["html", "text", "lcov"],
|
|
16
|
+
enabled: true,
|
|
17
|
+
include: ["src/**/*.{ts,tsx}"],
|
|
18
|
+
},
|
|
19
|
+
browser: {
|
|
20
|
+
// provider: 'webdriverio', // or 'webdriverio'
|
|
21
|
+
enabled: true,
|
|
22
|
+
headless: false,
|
|
23
|
+
name: 'chromium', // browser name is required
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
resolve: {
|
|
6
|
+
alias: {
|
|
7
|
+
"~": resolve(__dirname, "src"),
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
test: {
|
|
11
|
+
css: true,
|
|
12
|
+
globals: true,
|
|
13
|
+
coverage: {
|
|
14
|
+
provider: "istanbul",
|
|
15
|
+
reporter: ["html", "text", "lcov"],
|
|
16
|
+
enabled: true,
|
|
17
|
+
include: ["src/**/*.{ts,tsx}"],
|
|
18
|
+
},
|
|
19
|
+
browser: {
|
|
20
|
+
provider: 'playwright', // or 'webdriverio'
|
|
21
|
+
enabled: true,
|
|
22
|
+
headless: true,
|
|
23
|
+
name: 'chromium', // browser name is required
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
});
|