Unreferenced path definitions become filled output geometry in getSvgBRepShapes. Reproduced on v0.0.10, commit 81a79bc.
An SVG containing only <defs><path id="unused" d="M1 1H2V2H1Z"/></defs> should produce no visible shapes. It currently returns one BRep square (bounds x=-4..-3, y=3..4 with a 10x10 viewBox/output). An unreferenced symbol produces the same result. Adding a separate visible path results in two output shapes instead of one, including when the definition is nested in a group.
The SVG 2 defs and symbol rules specify that these contents are not directly rendered. There is no use element or other reference in this reproduction, so reference expansion is not required to establish the expected output.
Reproduction test (Bun, from repository root):
import { expect, test } from "bun:test"
import { identity } from "transformation-matrix"
import { getSvgBRepShapes } from "../lib/svg-to-brep-shapes"
const convert = (body: string) => getSvgBRepShapes({
svg: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10">${body}</svg>`,
width: 10, height: 10, transform: identity(),
})
const definition = '<path id="unused" d="M1 1H2V2H1Z"/>'
const visible = '<path d="M7 7H8V8H7Z"/>'
for (const container of ["defs", "symbol"]) {
test(`unreferenced ${container} content produces no filled shapes`, () => {
const actual = convert(`<${container}>${definition}</${container}>`)
console.log(JSON.stringify({container, actual}))
expect(actual).toEqual([])
})
test(`unreferenced ${container} does not add geometry beside a visible path`, () => {
const expected = convert(visible)
expect(expected).toHaveLength(1)
expect(convert(`<${container}><g>${definition}</g></${container}>${visible}`))
.toEqual(expected)
})
}
Run bun test tests/unreferenced-definitions.test.ts. All four regressions fail on the current implementation; the visible-only controls each return one shape.
The path extraction scans every path tag without distinguishing definition content from directly rendered paths. #29/#30 address transform attributes; this report concerns whether the path should contribute any visible geometry. A fix should exclude unreferenced definition content while preserving ordinary visible paths, with referenced definitions handled separately as appropriate.
Investigated with Codex (Astra) assistance; reproduction verified locally.
Unreferenced path definitions become filled output geometry in
getSvgBRepShapes. Reproduced on v0.0.10, commit 81a79bc.An SVG containing only
<defs><path id="unused" d="M1 1H2V2H1Z"/></defs>should produce no visible shapes. It currently returns one BRep square (bounds x=-4..-3, y=3..4 with a 10x10 viewBox/output). An unreferencedsymbolproduces the same result. Adding a separate visible path results in two output shapes instead of one, including when the definition is nested in a group.The SVG 2 defs and symbol rules specify that these contents are not directly rendered. There is no
useelement or other reference in this reproduction, so reference expansion is not required to establish the expected output.Reproduction test (Bun, from repository root):
Run
bun test tests/unreferenced-definitions.test.ts. All four regressions fail on the current implementation; the visible-only controls each return one shape.The path extraction scans every path tag without distinguishing definition content from directly rendered paths. #29/#30 address transform attributes; this report concerns whether the path should contribute any visible geometry. A fix should exclude unreferenced definition content while preserving ordinary visible paths, with referenced definitions handled separately as appropriate.
Investigated with Codex (Astra) assistance; reproduction verified locally.