An agent skill for creating detailed, interactive isometric illustrations of real-world machines and complex systems. Generates polished SVGs with optional WebGL shaders and 3D effects.
fix(lines): inspect the selected SVG root
Rudy Celekli5cbddcfd8b02
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex bf7b18d..f48e95a 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -25,6 +25,9 @@ jobs:with:node-version: 22+ - name: Line check regressions+ run: node --test scripts/lines.test.mjs+- name: Dial indicatorrun: |node examples/dial-indicator/build.mjsdiff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8152ae2..cc05c85 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,8 @@ All notable changes to Anatomy are recorded here. The format follows [Keep a Cha### Fixed+- The line-end check now includes the selected element when `--select` names an SVG, rather than checking only SVGs inside it.+- `examples/test-rig/` drew its glass button dark in the light theme. `stretch.css` now has light values for its own colours.### Changeddiff --git a/scripts/line-ends.mjs b/scripts/line-ends.mjsindex 4f8a772..c9dfaf3 100644--- a/scripts/line-ends.mjs+++ b/scripts/line-ends.mjs@@ -5,7 +5,7 @@ function lineEnds({ select = null, tolerance = 1, root: rootSlack = 2, mark = 7,style.textContent = `${select || ".iso-plate"} *{pointer-events:none!important}${select || ".iso-plate"} svg,${select || ".iso-plate"} svg *{pointer-events:visiblePainted!important}`;document.head.append(style);const skipClass = ["iso-edge", "iso-bevel", "iso-crease", "tb-edge"];- const svgs = [...plate.querySelectorAll("svg")];+ const svgs = [...(plate.matches("svg") ? [plate] : []), ...plate.querySelectorAll("svg")];const shapes = svgs.flatMap((svg) => [...svg.querySelectorAll("path, line, polyline, polygon, circle, ellipse, rect")]).filter((el) => !el.closest("defs, clipPath, mask, pattern, marker, symbol"));const opacityOf = (el) => {let alpha = 1;diff --git a/scripts/lines.test.mjs b/scripts/lines.test.mjsnew file mode 100644index 0000000..934529d--- /dev/null+++ b/scripts/lines.test.mjs@@ -0,0 +1,38 @@+import assert from "node:assert/strict";+import { execFile } from "node:child_process";+import { mkdtemp, rm, writeFile } from "node:fs/promises";+import { tmpdir } from "node:os";+import { join } from "node:path";+import { promisify } from "node:util";+import { fileURLToPath } from "node:url";+import test from "node:test";++const execute = promisify(execFile);+const lines = fileURLToPath(new URL("lines.mjs", import.meta.url));++async function check(path) {+ const directory = await mkdtemp(join(tmpdir(), "anatomy-lines-"));+ try {+ const page = join(directory, "figure.html");+ await writeFile(page, `<!doctype html><svg id="figure" width="200" height="100" viewBox="0 0 200 100"><path class="iso-line" fill="none" stroke="black" d="${path}"/></svg>`);+ try {+ return { code: 0, ...await execute(process.execPath, [lines, page, "--select", "#figure", "--wait", "0"], { timeout: 30000 }) };+ } catch (error) {+ return { code: error.code, stdout: error.stdout, stderr: error.stderr };+ }+ } finally {+ await rm(directory, { recursive: true, force: true });+ }+}++test("a selected SVG checks its own floating lines", async () => {+ const result = await check("M20 20L180 20");+ assert.equal(result.code, 1);+ assert.match(result.stdout, /line ends: 2 of 2 ends on 1 lines float/);+});++test("a selected SVG preserves closed-path exemption", async () => {+ const result = await check("M20 20L180 20L180 80L20 80Z");+ assert.equal(result.code, 0);+ assert.match(result.stdout, /line ends: 0/);+});