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.
Files changed (75) hide show
  1. package/.eslintrc.cjs +1 -0
  2. package/README.md +64 -8
  3. package/dist/svg-path-commander.cjs +1 -1
  4. package/dist/svg-path-commander.cjs.map +1 -1
  5. package/dist/svg-path-commander.d.ts +236 -43
  6. package/dist/svg-path-commander.js +1 -1
  7. package/dist/svg-path-commander.js.map +1 -1
  8. package/dist/svg-path-commander.mjs +790 -650
  9. package/dist/svg-path-commander.mjs.map +1 -1
  10. package/package.json +20 -22
  11. package/src/convert/pathToAbsolute.ts +16 -70
  12. package/src/convert/pathToCurve.ts +36 -28
  13. package/src/convert/pathToRelative.ts +33 -62
  14. package/src/index.ts +37 -39
  15. package/src/interface.ts +33 -33
  16. package/src/math/arcTools.ts +394 -0
  17. package/src/math/bezier.ts +253 -0
  18. package/src/math/cubicTools.ts +122 -0
  19. package/src/math/distanceSquareRoot.ts +3 -1
  20. package/src/math/lineTools.ts +67 -0
  21. package/src/math/midPoint.ts +3 -1
  22. package/src/math/polygonArea.ts +3 -1
  23. package/src/math/polygonLength.ts +2 -1
  24. package/src/math/quadTools.ts +98 -0
  25. package/src/parser/isMoveCommand.ts +17 -0
  26. package/src/parser/parsePathString.ts +5 -5
  27. package/src/parser/scanSegment.ts +12 -3
  28. package/src/process/absolutizeSegment.ts +58 -0
  29. package/src/process/iterate.ts +33 -0
  30. package/src/process/normalizePath.ts +34 -28
  31. package/src/process/normalizeSegment.ts +8 -9
  32. package/src/process/projection2d.ts +2 -1
  33. package/src/process/relativizeSegment.ts +61 -0
  34. package/src/process/reversePath.ts +1 -1
  35. package/src/process/roundPath.ts +8 -10
  36. package/src/process/segmentToCubic.ts +1 -1
  37. package/src/process/shortenSegment.ts +3 -3
  38. package/src/process/splitCubic.ts +8 -7
  39. package/src/process/splitPath.ts +39 -5
  40. package/src/process/transformPath.ts +81 -94
  41. package/src/types.ts +40 -1
  42. package/src/util/distanceEpsilon.ts +3 -0
  43. package/src/util/getClosestPoint.ts +1 -1
  44. package/src/util/getPathArea.ts +3 -3
  45. package/src/util/getPathBBox.ts +86 -18
  46. package/src/util/getPointAtLength.ts +98 -4
  47. package/src/util/getPropertiesAtLength.ts +4 -3
  48. package/src/util/getPropertiesAtPoint.ts +4 -1
  49. package/src/util/getTotalLength.ts +71 -4
  50. package/src/util/isPointInStroke.ts +2 -1
  51. package/src/util/shapeToPathArray.ts +8 -4
  52. package/test/class.test.ts +502 -0
  53. package/test/fixtures/getMarkup.ts +17 -0
  54. package/{cypress → test}/fixtures/shapes.js +39 -39
  55. package/test/fixtures/simpleShapes.js +75 -0
  56. package/test/static.test.ts +324 -0
  57. package/tsconfig.json +9 -4
  58. package/{vite.config.ts → vite.config.mts} +10 -1
  59. package/vitest.config-ui.mts +26 -0
  60. package/vitest.config.mts +26 -0
  61. package/cypress/e2e/svg-path-commander.spec.ts +0 -868
  62. package/cypress/fixtures/simpleShapes.js +0 -75
  63. package/cypress/plugins/esbuild-istanbul.ts +0 -50
  64. package/cypress/plugins/tsCompile.ts +0 -34
  65. package/cypress/support/commands.ts +0 -37
  66. package/cypress/support/e2e.ts +0 -21
  67. package/cypress/test.html +0 -36
  68. package/cypress.config.ts +0 -29
  69. package/src/process/fixArc.ts +0 -23
  70. package/src/util/pathLengthFactory.ts +0 -114
  71. package/src/util/segmentArcFactory.ts +0 -219
  72. package/src/util/segmentCubicFactory.ts +0 -114
  73. package/src/util/segmentLineFactory.ts +0 -45
  74. package/src/util/segmentQuadFactory.ts +0 -109
  75. /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", "cypress", "@thednp/dommatrix"],
6
- "types": ["@thednp/dommatrix"],
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": "Node",
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/*", "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
+ });