svg-path-commander 2.3.4 → 2.3.5
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/AGENTS.md +16 -1
- package/CHANGELOG.md +18 -3
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -12
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -4
- package/dist/index.min.js.map +1 -1
- package/dist/util.d.ts +5 -1
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +36 -11
- package/dist/util.js.map +1 -1
- package/package.json +4 -6
package/AGENTS.md
CHANGED
|
@@ -10,7 +10,8 @@ SVGPathCommander v2.3.4 — TypeScript library for manipulating SVG `<path>` `d`
|
|
|
10
10
|
vp install # Install dependencies
|
|
11
11
|
vpr dev # Serve docs on localhost:3000
|
|
12
12
|
vpr test # Run all tests (Vitest + Istanbul coverage)
|
|
13
|
-
vpr test
|
|
13
|
+
vpr test:ui # Run tests with UI and --watch option
|
|
14
|
+
vpr test:watch # Run tests with --watch option
|
|
14
15
|
vpr test -- class.test.ts # Run a single test file
|
|
15
16
|
vpr test -- -t "Test name" # Run a single test by name
|
|
16
17
|
vpr bench # Benchmark vs svgpath (results embedded in README)
|
|
@@ -165,3 +166,17 @@ release. Add a tool name to select part of the graph. For example, run
|
|
|
165
166
|
- [ ] If setup, runtime, or package-manager behavior looks wrong, run `vp env doctor` and include its output when asking for help.
|
|
166
167
|
|
|
167
168
|
<!--VITE PLUS END-->
|
|
169
|
+
|
|
170
|
+
## Workflow notes
|
|
171
|
+
- **Harness folders**: dev repro/harness scaffolding (debugging the Vite plugin,
|
|
172
|
+
a compiler, or the browser) goes in `TMP/`; fixtures imported by vitest suites
|
|
173
|
+
go in `tests/fixtures/` — **never** in the root or in OS temp dirs. Root-level
|
|
174
|
+
harness files break `tsdown`/`vitest` path resolution, and temp dirs outside
|
|
175
|
+
the project get swept by OS cleaners and leave stale `node_modules`/`.vite`
|
|
176
|
+
state that corrupts the next run. (`tests/fixtures/` is covered by
|
|
177
|
+
`vp lint` + `tsc` like the rest of `tests/` — keep fixtures valid;
|
|
178
|
+
intentionally-broken inputs don't belong there.)
|
|
179
|
+
- **Never delete files**: do not `rm` source/test files. If a file must be
|
|
180
|
+
removed from the tree, **rename it to `<name>-bak.<ext>`** (e.g. `foo.ts` →
|
|
181
|
+
`foo-bak.ts`) and leave it in place. The `-bak` suffix is the only sanctioned
|
|
182
|
+
way to retire a file; the repo may be scanned for history or references later.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [2.3.
|
|
3
|
+
## [2.3.5] - 2026-11-16
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- `reversePath()` no longer loses the `Z` of a sub-path ([#65](https://github.com/thednp/svg-path-commander/issues/65)) — the reversal was applied to the whole path as a single shape, so the `M`/`Z` pairs of the sub-paths were mixed up and the closing command was dropped; e.g. `reversePath("M0 0L10 0L10 10Zm4 4")` returned `M4 4M0 0M10 10L10 0L0 0` instead of `M10 10L10 0L0 0ZM4 4`; every sub-path is now reversed on its own and the sub-paths keep their original order, so the static method returns the same result as the `reverse()` instance method (this was still broken in 2.3.4)
|
|
8
|
+
- `reversePath()` no longer throws for an empty path — it returns an empty array, like the other static methods
|
|
9
|
+
- No `dist` bundle contains `istanbul` comments anymore (except for the source maps) — the bundled `@thednp/dommatrix` shipped its coverage hints with the `@preserve` suffix, which the bundlers treat as a legal-comment marker, so the comment survived the minification of the UMD bundle
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- The `istanbul` coverage hints no longer carry the `@preserve` suffix — the suffix is a legal-comment marker for the bundlers, not a coverage hint
|
|
14
|
+
- Removed dependencies: `vite-plugin-strip-comments` — the comments are now stripped by the bundler itself through `outputOptions.comments`; the `vite` and `tsdown` packages are no longer direct dev dependencies (`vite-plus` provides them), and the browser provider comes from `vite-plus/test/browser-playwright`
|
|
15
|
+
- Updated dependencies: `@thednp/dommatrix` `^3.1.4` — the dependency is now published with its comments stripped, so the `dist` bundles no longer carry its `istanbul` comments
|
|
16
|
+
- Rebuilt `dist` and `docs` bundles
|
|
17
|
+
|
|
18
|
+
## [2.3.4] - 2026-11-15
|
|
4
19
|
|
|
5
20
|
### Fixed
|
|
6
21
|
|
|
@@ -14,10 +29,10 @@
|
|
|
14
29
|
|
|
15
30
|
- `ParserParams.x2` / `ParserParams.y2` are now `number | null`, `null` marks a previous segment without a reflectable control point (the same sentinel used by `ParserParams.qx` / `ParserParams.qy`)
|
|
16
31
|
- `normalizeSegment()` accepts the command of the previous segment as an optional third argument, required to tell a reflectable control point from a missing one
|
|
17
|
-
- Migrated the toolchain from pnpm to Vite+ (`vp`) — the `package.json` scripts now run through `vp` / `vpr` (`vp test`, `vp pack`, `vp lint src`, `vp fmt src`), the shared dependencies are pinned through the `catalog:` in `pnpm-workspace.yaml` and the GitHub Actions workflows are driven by the `voidzero-dev/setup-vp` action (`vpr lint`, `vpr build`, `vpr test`, `vp pm publish`)
|
|
32
|
+
- Migrated the toolchain from pnpm to Vite+ (`vp`) — the `package.json` scripts now run through `vp` / `vpr` (`vp test`, `vp pack`, `vp lint src`, `vp fmt src`), the docs are served with `vp dev docs --port 3000`, the shared dependencies are pinned through the `catalog:` in `pnpm-workspace.yaml` and the GitHub Actions workflows are driven by the `voidzero-dev/setup-vp` action (`vpr lint`, `vpr build`, `vpr test`, `vp pm publish`)
|
|
18
33
|
- The source is now formatted with oxfmt (`vp fmt src`) instead of `deno fmt src`, and linted with oxlint (`vp lint src`) instead of `deno lint src`; `deno lint` / `deno check` still gate the JSR publish
|
|
19
34
|
- The `lint` script now runs the type check as well (`vpr lint:ts && vpr check:ts`), so `vpr lint` covers both oxlint and `tsc --noEmit`
|
|
20
|
-
- Updated dev dependencies: `vitest` / `@vitest/*`
|
|
35
|
+
- Updated dev dependencies: `vitest` / `@vitest/*` `5.1.0`, `vite-plus` `1.6.0`, `happy-dom` `^21.0.4`, `playwright` `^1.65.1`, `@types/node` `^26.6.6` — `tsdown` is no longer a direct dev dependency, `vite-plus` provides it, and the browser provider comes from `vite-plus/test/browser-playwright`
|
|
21
36
|
- Updated dependencies: `@thednp/dommatrix` `^3.1.3`
|
|
22
37
|
- Rebuilt `dist` and `docs` bundles
|
|
23
38
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* SVGPathCommander v2.3.
|
|
2
|
+
* SVGPathCommander ESM v2.3.5 (http://thednp.github.io/svg-path-commander)
|
|
3
3
|
* Copyright 2026 © thednp
|
|
4
4
|
* Licensed under MIT (https://github.com/thednp/svg-path-commander/blob/master/LICENSE)
|
|
5
5
|
*/
|
|
@@ -1013,6 +1013,10 @@ declare const optimizePath: <T extends string | PathArray>(pathInput: T, roundOp
|
|
|
1013
1013
|
* Reverses all segments of a PathArray and returns a new PathArray
|
|
1014
1014
|
* with absolute values.
|
|
1015
1015
|
*
|
|
1016
|
+
* Every sub-path is reversed on its own, so the `M` and the `Z` of a
|
|
1017
|
+
* sub-path are swapped with each other and the sub-paths keep their
|
|
1018
|
+
* original order.
|
|
1019
|
+
*
|
|
1016
1020
|
* @param pathInput - The source PathArray
|
|
1017
1021
|
* @returns The reversed PathArray
|
|
1018
1022
|
*
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["_$__types_ts0.Point","_$__interface_ts0.ParserParams","_$__interface_ts0.ShapeParams"],"sources":["../src/interface.ts","../src/types.ts","../src/math/distanceSquareRoot.ts","../src/math/midPoint.ts","../src/math/rotateVector.ts","../src/math/roundTo.ts","../src/convert/pathToAbsolute.ts","../src/convert/pathToRelative.ts","../src/convert/pathToCurve.ts","../src/convert/pathToString.ts","../src/parser/parsePathString.ts","../src/parser/pathParser.ts","../src/parser/finalizeSegment.ts","../src/parser/isArcCommand.ts","../src/parser/isDigit.ts","../src/parser/isDigitStart.ts","../src/parser/isMoveCommand.ts","../src/parser/isPathCommand.ts","../src/parser/isSpace.ts","../src/parser/scanFlag.ts","../src/parser/scanParam.ts","../src/parser/scanSegment.ts","../src/parser/skipSpaces.ts","../src/util/getPathBBox.ts","../src/util/getTotalLength.ts","../src/util/getClosestPoint.ts","../src/util/getDrawDirection.ts","../src/util/getPathArea.ts","../src/util/getPointAtLength.ts","../src/util/getPropertiesAtLength.ts","../src/util/getPropertiesAtPoint.ts","../src/util/getSegmentAtLength.ts","../src/util/getSegmentOfPoint.ts","../src/util/isAbsoluteArray.ts","../src/util/isPolygonArray.ts","../src/util/isCurveArray.ts","../src/util/isNormalizedArray.ts","../src/util/isPathArray.ts","../src/util/isPointInStroke.ts","../src/util/isRelativeArray.ts","../src/util/isValidPath.ts","../src/morph/samplePolygon.ts","../src/util/shapeToPath.ts","../src/util/shapeToPathArray.ts","../src/util/isMultiPath.ts","../src/util/isPolylineArray.ts","../src/util/isClosedPath.ts","../src/process/normalizePath.ts","../src/process/optimizePath.ts","../src/process/reversePath.ts","../src/process/splitPath.ts","../src/process/transformPath.ts","../src/process/absolutizeSegment.ts","../src/process/arcToCubic.ts","../src/process/getSVGMatrix.ts","../src/process/iterate.ts","../src/process/lineToCubic.ts","../src/process/normalizeSegment.ts","../src/process/projection2d.ts","../src/process/quadToCubic.ts","../src/process/relativizeSegment.ts","../src/process/reverseCurve.ts","../src/process/roundPath.ts","../src/process/roundSegment.ts","../src/process/segmentToCubic.ts","../src/process/shortenSegment.ts","../src/morph/fixPath.ts","../src/morph/splitCubicSegment.ts","../src/morph/equalizeSegments.ts","../src/morph/equalizePaths.ts","../src/intersect/pathIntersection.ts","../src/intersect/boundingBoxIntersect.ts","../src/intersect/isPointInsideBBox.ts","../src/main.ts"],"mappings":";;;;;;;YAGY;;EAEV,SAAS;;EAET;;EAEA;;EAEA;;;YAIU;;EAEV;;IAEE;;IAEA;;;E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AAiB;;;;;;iBCHhD,gBAAgB,MAAM,YAAY,QAAQ;;;;;;cCA7C,eAAgB,UAAU,WAAS,MAAQ;;;;;;;;;;;;;;;cCa3C,gBAAiB,mBAAmB,WAAS,WAAa,MAAI;;;;;;;;;;;;;;;;cCI9D,eAAgB,mBAAmB,WAAS,WAC5C,GAAC,yBAEX
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["_$__types_ts0.Point","_$__interface_ts0.ParserParams","_$__interface_ts0.ShapeParams"],"sources":["../src/interface.ts","../src/types.ts","../src/math/distanceSquareRoot.ts","../src/math/midPoint.ts","../src/math/rotateVector.ts","../src/math/roundTo.ts","../src/convert/pathToAbsolute.ts","../src/convert/pathToRelative.ts","../src/convert/pathToCurve.ts","../src/convert/pathToString.ts","../src/parser/parsePathString.ts","../src/parser/pathParser.ts","../src/parser/finalizeSegment.ts","../src/parser/isArcCommand.ts","../src/parser/isDigit.ts","../src/parser/isDigitStart.ts","../src/parser/isMoveCommand.ts","../src/parser/isPathCommand.ts","../src/parser/isSpace.ts","../src/parser/scanFlag.ts","../src/parser/scanParam.ts","../src/parser/scanSegment.ts","../src/parser/skipSpaces.ts","../src/util/getPathBBox.ts","../src/util/getTotalLength.ts","../src/util/getClosestPoint.ts","../src/util/getDrawDirection.ts","../src/util/getPathArea.ts","../src/util/getPointAtLength.ts","../src/util/getPropertiesAtLength.ts","../src/util/getPropertiesAtPoint.ts","../src/util/getSegmentAtLength.ts","../src/util/getSegmentOfPoint.ts","../src/util/isAbsoluteArray.ts","../src/util/isPolygonArray.ts","../src/util/isCurveArray.ts","../src/util/isNormalizedArray.ts","../src/util/isPathArray.ts","../src/util/isPointInStroke.ts","../src/util/isRelativeArray.ts","../src/util/isValidPath.ts","../src/morph/samplePolygon.ts","../src/util/shapeToPath.ts","../src/util/shapeToPathArray.ts","../src/util/isMultiPath.ts","../src/util/isPolylineArray.ts","../src/util/isClosedPath.ts","../src/process/normalizePath.ts","../src/process/optimizePath.ts","../src/process/reversePath.ts","../src/process/splitPath.ts","../src/process/transformPath.ts","../src/process/absolutizeSegment.ts","../src/process/arcToCubic.ts","../src/process/getSVGMatrix.ts","../src/process/iterate.ts","../src/process/lineToCubic.ts","../src/process/normalizeSegment.ts","../src/process/projection2d.ts","../src/process/quadToCubic.ts","../src/process/relativizeSegment.ts","../src/process/reverseCurve.ts","../src/process/roundPath.ts","../src/process/roundSegment.ts","../src/process/segmentToCubic.ts","../src/process/shortenSegment.ts","../src/morph/fixPath.ts","../src/morph/splitCubicSegment.ts","../src/morph/equalizeSegments.ts","../src/morph/equalizePaths.ts","../src/intersect/pathIntersection.ts","../src/intersect/boundingBoxIntersect.ts","../src/intersect/isPointInsideBBox.ts","../src/main.ts"],"mappings":";;;;;;;YAGY;;EAEV,SAAS;;EAET;;EAEA;;EAEA;;;YAIU;;EAEV;;IAEE;;IAEA;;;EAGF;;EAEA,UAAU;;;YAIA;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;GACC;;;YAGS;;EAEV;;EAEA;GACC;;;YAGS;;EAEV;;EAEA;;EAEA;;EAEA;GACC;;;YAGS;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;GACC;;;YAGS;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;GACC;;;YAGS;;EAEV;;EAEA;GACC;;;YAIS;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;YAIU;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;YAGU;;EAEV;;IAEE;;IAEA;;;EAGF;;IAEE;;IAEA;;;;YAKQ;;EAEV;;EAEA;;EAEA;;EAEA;;;;;EAKA;;;;;EAKA;;EAEA;;EAEA;;EAEA;;EAEA;;;YAIU;;EAEV;;EAEA;;IAEE;;IAEA;;;EAGF;;IAEE;;IAEA;;;EAGF;;IAEE;;IAEA;;;;YAKQ;;EAEV;;EAEA;;;YAIU;;EAEV,GAAG;;EAEH;;EAEA;;E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;;SAEX,sBAAa;;SAEb,yBAAgB;;SAEhB,qBAAY;;SAEZ,qBAAY;;SAEZ,oBAAW;;SAEX,0BAAiB;;SAEjB,qBAAY;;SAEZ,oBAAW;;SAEX,kBAAS;;SAET,qBAAY;;SAEZ,uBAAc;;SAEd,uBAAc;;SAEd,kBAAS;;SAET,sBAAa;;SAEb,yBAAgB;;SAEhB,0BAAiB;;SAEjB,sBAAa;;SAEb,0BAAiB;;SAEjB,0BAAiB;;SAEjB,6BAAoB;;SAEpB,oBAAW;;SAEX,qBAAY;;SAEZ,wBAAe;;SAEf"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* SVGPathCommander v2.3.
|
|
2
|
+
* SVGPathCommander ESM v2.3.5 (http://thednp.github.io/svg-path-commander)
|
|
3
3
|
* Copyright 2026 © thednp
|
|
4
4
|
* Licensed under MIT (https://github.com/thednp/svg-path-commander/blob/master/LICENSE)
|
|
5
5
|
*/
|
|
6
6
|
import CSSMatrix from "@thednp/dommatrix";
|
|
7
7
|
// package.json
|
|
8
|
-
var version = "2.3.
|
|
8
|
+
var version = "2.3.5";
|
|
9
9
|
// src/math/midPoint.ts
|
|
10
10
|
/**
|
|
11
11
|
* Returns the coordinates of a specified distance
|
|
@@ -3192,20 +3192,13 @@ const optimizePath = (pathInput, roundOption) => {
|
|
|
3192
3192
|
};
|
|
3193
3193
|
// src/process/reversePath.ts
|
|
3194
3194
|
/**
|
|
3195
|
-
* Reverses
|
|
3195
|
+
* Reverses the segments of a single sub-path and returns a new PathArray
|
|
3196
3196
|
* with absolute values.
|
|
3197
3197
|
*
|
|
3198
|
-
* @param
|
|
3198
|
+
* @param absolutePath - The absolute PathArray of a single sub-path
|
|
3199
3199
|
* @returns The reversed PathArray
|
|
3200
|
-
*
|
|
3201
|
-
* @example
|
|
3202
|
-
* ```ts
|
|
3203
|
-
* reversePath([['M', 0, 0], ['L', 100, 0], ['L', 100, 100], ['L', 0, 100], ['Z']])
|
|
3204
|
-
* // => [['M', 0, 100], ['L', 0, 0], ['L', 100, 0], ['L', 100, 100], ['Z']]
|
|
3205
|
-
* ```
|
|
3206
3200
|
*/
|
|
3207
|
-
const
|
|
3208
|
-
const absolutePath = pathToAbsolute(pathInput);
|
|
3201
|
+
const reverseSubPath = (absolutePath) => {
|
|
3209
3202
|
const normalizedPath = normalizePath(absolutePath);
|
|
3210
3203
|
const pLen = absolutePath.length;
|
|
3211
3204
|
const isClosed = absolutePath[pLen - 1][0] === "Z";
|
|
@@ -3341,6 +3334,38 @@ const reversePath = (pathInput) => {
|
|
|
3341
3334
|
});
|
|
3342
3335
|
return isClosed ? reversedPath.reverse() : [reversedPath[0]].concat(reversedPath.slice(1).reverse());
|
|
3343
3336
|
};
|
|
3337
|
+
/**
|
|
3338
|
+
* Reverses all segments of a PathArray and returns a new PathArray
|
|
3339
|
+
* with absolute values.
|
|
3340
|
+
*
|
|
3341
|
+
* Every sub-path is reversed on its own, so the `M` and the `Z` of a
|
|
3342
|
+
* sub-path are swapped with each other and the sub-paths keep their
|
|
3343
|
+
* original order.
|
|
3344
|
+
*
|
|
3345
|
+
* @param pathInput - The source PathArray
|
|
3346
|
+
* @returns The reversed PathArray
|
|
3347
|
+
*
|
|
3348
|
+
* @example
|
|
3349
|
+
* ```ts
|
|
3350
|
+
* reversePath([['M', 0, 0], ['L', 100, 0], ['L', 100, 100], ['L', 0, 100], ['Z']])
|
|
3351
|
+
* // => [['M', 0, 100], ['L', 0, 0], ['L', 100, 0], ['L', 100, 100], ['Z']]
|
|
3352
|
+
* ```
|
|
3353
|
+
*/
|
|
3354
|
+
const reversePath = (pathInput) => {
|
|
3355
|
+
const absolutePath = pathToAbsolute(pathInput);
|
|
3356
|
+
const subPaths = [];
|
|
3357
|
+
let subPath = [];
|
|
3358
|
+
for (const segment of absolutePath) {
|
|
3359
|
+
if (segment[0] === "M" && subPath.length) {
|
|
3360
|
+
subPaths.push(subPath);
|
|
3361
|
+
subPath = [];
|
|
3362
|
+
}
|
|
3363
|
+
subPath.push(segment);
|
|
3364
|
+
}
|
|
3365
|
+
if (subPath.length) subPaths.push(subPath);
|
|
3366
|
+
const reversed = subPaths.map((path) => reverseSubPath(path));
|
|
3367
|
+
return reversed.length === 1 ? reversed[0] : reversed.flat();
|
|
3368
|
+
};
|
|
3344
3369
|
// src/process/splitPath.ts
|
|
3345
3370
|
/**
|
|
3346
3371
|
* Split a path string or PathArray into an array of sub-paths.
|