svg-path-commander 2.2.1 → 2.2.3

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Project Overview
4
4
 
5
- SVGPathCommander v2.2.0 — TypeScript library for manipulating SVG `<path>` `d` attributes. Works in browser and Node.js.
5
+ SVGPathCommander v2.2.2 — TypeScript library for manipulating SVG `<path>` `d` attributes. Works in browser and Node.js.
6
6
 
7
7
  ## Commands
8
8
 
@@ -10,6 +10,7 @@ SVGPathCommander v2.2.0 — TypeScript library for manipulating SVG `<path>` `d`
10
10
  pnpm install # Install dependencies
11
11
  pnpm dev # Serve docs on localhost:3000
12
12
  pnpm test # Run all tests (vitest + happy-dom)
13
+ pnpm test:browser # Run browser tests (vitest + playwright chromium)
13
14
  pnpm test-ui # Run tests with UI
14
15
  pnpm test -- -t "Test name" # Run a single test by name
15
16
  pnpm test -- class.test.ts # Run a single test file
@@ -21,13 +22,25 @@ pnpm build # Build with tsdown
21
22
  pnpm check:ts # tsc --noEmit (type check only)
22
23
  ```
23
24
 
25
+ Deno equivalents (via `deno.json`):
26
+
27
+ ```bash
28
+ deno task test # vitest run
29
+ deno task lint # deno lint src
30
+ deno task check # deno check src (no --sloppy-imports needed)
31
+ deno task build # tsdown via node
32
+ deno publish # JSR dry run: deno publish --dry-run --allow-dirty
33
+ ```
34
+
24
35
  ## Tech Stack
25
36
 
26
37
  - **Language:** TypeScript (strict, ES2020 target, `allowImportingTsExtensions`)
27
- - **Package manager:** pnpm (v10.33.0)
38
+ - **Package manager:** pnpm (v11.x)
28
39
  - **Build:** tsdown (ESM + UMD outputs)
29
40
  - **Test:** Vitest + happy-dom (Istanbul coverage)
41
+ - **Browser Test:** Vitest + Playwright (real Chromium, `test/browser/`)
30
42
  - **Lint/Format:** Deno (`deno lint`, `deno fmt`)
43
+ - **JSR:** `deno.json` publishes as `@thednp/svg-path-commander` — `deno check src`, `deno lint src` and `deno publish --dry-run --allow-dirty` must all pass
31
44
  - **Dependency:** `@thednp/dommatrix` (DOMMatrix shim)
32
45
 
33
46
  ## Source Structure (`src/`)
@@ -88,9 +101,10 @@ pnpm check:ts # tsc --noEmit (type check only)
88
101
  - Instance options validated in constructor with fallback to `defaultOptions`
89
102
 
90
103
  ### Testing
91
- - Tests run with happy-dom (headless browser simulation)
104
+ - Tests run with happy-dom (headless browser simulation) via `pnpm test`
105
+ - Browser tests run with real Chromium (Playwright) via `pnpm test:browser`
92
106
  - Fixtures in `test/fixtures/`
93
- - Two test files: `test/class.test.ts` (instance API), `test/static.test.ts` (static methods)
107
+ - Test files: `test/class.test.ts` (instance API), `test/static.test.ts` (static methods), `test/browser/` (native browser APIs)
94
108
  - Tests render actual SVG and verify `d` attribute output
95
109
  - Use `vi.waitFor()` for async DOM queries (timeout: 200ms)
96
110
  - Use `expect().to.deep.equal()` for object comparison, `expect().to.equal()` for primitives
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.2.2] - 2026-08-03
4
+
5
+ ### Added
6
+ - `getBezierLengthAtT()` / `bezierLengthAtT()` — arc length up to a `t` ratio via Gauss-Legendre quadrature
7
+ - `arcLength()` / `arcLengthAtAngle()` / `arcLengthBetween()` — Gauss-Legendre ellipse arc length helpers
8
+ - Static-method cross-consistency tests (length/point lookup, conversions, transforms, geometry measurements, intersections)
9
+ - Native browser API parity tests — `getBBox()`, `getTotalLength()`, `getPointAtLength()` verified against real Chromium
10
+
11
+ ### Fixed
12
+ - `getPointAtLength()` returning the start of the next segment at interior distances on a `Z` (closing line) segment (#61)
13
+ - `getPointAtLength()` returning stale coordinates for distances beyond the path end
14
+ - Arc length accuracy for `getTotalLength()` and `getPointAtLength()` (Gauss-Legendre quadrature)
15
+ - Bezier / quad length accuracy for arc-length sampling in `cubicTools` and `quadTools`
16
+ - Deno minimum-dependency-age policy blocking fresh `@thednp/dommatrix` releases — `minimumDependencyAge` disabled in `deno.json` (mirrors the pnpm `minimumReleaseAgeExclude` in `pnpm-workspace.yaml`)
17
+
18
+ ### Changed
19
+ - Migrated tests to Vitest browser mode (Playwright Chromium) with Istanbul coverage — 100% line, branch, function and statement coverage
20
+ - Updated test fixtures and expected values to match the current implementation
21
+ - Rebuilt `dist` and `docs` bundles
22
+ - Full Deno / JSR compatibility — `deno.json` publishing as `@thednp/svg-path-commander`, `deno task` equivalents for test / check / lint / build, `.ts` extensions on all relative imports and explicit return types across the public API; `deno check src`, `deno lint src` and `deno publish --dry-run` all clean
23
+ - Upgraded `@thednp/dommatrix` to v3.0.6 and toolchain (tsdown, Vite, Vitest, pnpm 11)
24
+
25
+ ### Added
26
+ - `llms.txt` with an LLM-friendly project summary
27
+ - README installation section for JSR (`deno add jsr:@thednp/svg-path-commander`, raw TypeScript import) and JSR badge fix
28
+
29
+ ## [2.2.1] - 2026-04-06
30
+
31
+ ### Added
32
+ - Reorganized intersection tools into `src/intersect/` — `pathsIntersection()`, `boundingBoxIntersect()`, `isPointInsideBBox()`, `interHelper()`
33
+
34
+ ### Changed
35
+ - tsdown config and CI workflow versions, `.npmignore` cleanup, demo fixes
36
+
3
37
  ## [2.2.0] - 2026-04-06
4
38
 
5
39
  ### Added
package/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  [![Coverage Status](https://coveralls.io/repos/github/thednp/svg-path-commander/badge.svg)](https://coveralls.io/github/thednp/svg-path-commander)
4
4
  [![ci](https://github.com/thednp/svg-path-commander/actions/workflows/ci.yml/badge.svg)](https://github.com/thednp/svg-path-commander/actions/workflows/ci.yml)
5
5
  [![NPM Version](https://img.shields.io/npm/v/svg-path-commander.svg)](https://www.npmjs.com/package/svg-path-commander)
6
+ [![JSR Version](https://img.shields.io/jsr/v/@thednp/svg-path-commander.svg)](https://jsr.io/@thednp/svg-path-commander)
6
7
  [![NPM Downloads](https://img.shields.io/npm/dm/svg-path-commander.svg)](http://npm-stat.com/charts.html?svg-path-commander)
7
8
  [![jsDeliver](https://img.shields.io/jsdelivr/npm/hw/svg-path-commander)](https://www.jsdelivr.com/package/npm/svg-path-commander)
8
9
 
@@ -32,14 +33,24 @@ There are a couple of good reasons for this implementation:
32
33
  * we can actually apply a [3D transformation](https://github.com/ndebeiss/svg3d) matrix to SVG path commands, by calculating a 2D projection of the actual shape in 3D coordinates;
33
34
  * when most tools available will be rendered absolete, we are ready for new challenges.
34
35
 
35
- This library is available on [CDN](https://www.jsdelivr.com/package/npm/svg-path-commander) and [npm](https://www.npmjs.com/package/svg-path-commander).
36
+ This library is available on [CDN](https://www.jsdelivr.com/package/npm/svg-path-commander), [npm](https://www.npmjs.com/package/svg-path-commander) and [JSR](https://jsr.io/@thednp/svg-path-commander).
36
37
 
37
38
 
38
39
  # Install
39
40
 
40
- ```
41
+ ```sh
41
42
  npm install svg-path-commander
42
- # or pnpm/bun/deno add svg-path-commander
43
+ # or pnpm add svg-path-commander
44
+ # or bun add svg-path-commander
45
+ # or deno add npm:svg-path-commander
46
+ # or deno add jsr:@thednp/svg-path-commander
47
+ # or npx jsr add @thednp/svg-path-commander
48
+ ```
49
+
50
+ Install from [JSR](https://jsr.io/@thednp/svg-path-commander) and import the raw TypeScript source:
51
+
52
+ ```ts
53
+ import SVGPathCommander from "jsr:@thednp/svg-path-commander";
43
54
  ```
44
55
 
45
56
 
@@ -290,6 +301,7 @@ For developer guidelines, and a complete list of static methods, head over to th
290
301
  * all tools processing path segments will never round float values, however `pathToString`, `optimizePath` and especially `roundPath` will always round values to the default of 4 decimals; EG: 0.56676 => 0.567, 0.50 => 0.5; you can change the default option with `SVGPathCommander.options.round = 2` or remove the value rounding all together with `SVGPathCommander.options.round = false`; you can also control this feature via instance options;
291
302
  * the `getSVGMatrix` utility we developed will always compute the matrix by applying the transform functions in the following order: `translate`, `rotate`, `skew` and `scale`, which is the default composition/recomposition order specified in the W3C draft;
292
303
  * all 3d transformations as well as skews will convert `A` (arc) path commands to `C` (cubic bezier) due to the lack of resources;
304
+ * while converting `A` segments to `C` segments is the shipped behavior, a validated arc-preserving alternative exists: an affine-transformed elliptical arc is still an exact elliptical arc, so `A` segments can be transformed directly via the singular value decomposition of the transformed ellipse shape matrix (radii and rotation from the eigenvalues/eigenvectors of the Gram matrix, sweep flag flipped for negative-determinant matrices). This works for any 2D matrix, and even for 3D matrices whenever the projection is orthographic (default `origin: [0,0,0]` — the `z = 0` plane is untouched by the matrix's z rows/columns, so only the 2x2 submatrix matters); the conversion to `C` is only mathematically required for perspective projections (non-zero `origin` z value or a matrix with perspective), where the arc image is a general conic. See `experiments/transformArc-tested.ts` for the implementation and rationale;
293
305
  * most tools included with **SVGPathCommander** should work in your Node.js apps, but feel free to report any issue;
294
306
  * other path commands like `R` (catmulRomBezier), `O`, `U` (ellipse and shorthand ellipse) are not present in the current draft and are not supported;
295
307
  * normalization can mean many things to many people and our library is developed to convert path command values to absolute and shorthand to longhand commands to provide a solid foundation for the main processing tools of our library;