ac6f1d84af
Extend CAD conversion to emit bounded semantic metadata (units, layers, blocks, entity types, labels, crop-indexed bounds) alongside the derived SVG, tag imported drawings as cad-vector nodes, and carry semanticContext through canvas nodes, snapshot normalization, and reference images. Agent Chat forwards this metadata as hidden cad-context reference parts. Add non-destructive vector cropping: cropping a vector/CAD node keeps the source SVG and spawns a transparent WebP sibling with crop-scoped semantic context, wired through the vectorized image toolbar and the workspace crop tool. Include node --test coverage for CAD semantics and vector crop. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
30 lines
1.1 KiB
JavaScript
30 lines
1.1 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import { isSvgSource, isVectorImageNode } from "../src/ui/lib/vectorImage.ts";
|
|
|
|
const imageNode = {
|
|
id: "node-1",
|
|
type: "image",
|
|
title: "image.png",
|
|
x: 0,
|
|
y: 0,
|
|
width: 100,
|
|
height: 100,
|
|
content: "/uploads/image.png"
|
|
};
|
|
|
|
test("recognizes uploaded and CAD-derived SVG image nodes", () => {
|
|
assert.equal(isVectorImageNode({ ...imageNode, title: "drawing (DWG).svg" }), true);
|
|
assert.equal(isVectorImageNode({ ...imageNode, content: "/uploads/plan.svg?version=2" }), true);
|
|
assert.equal(isVectorImageNode({ ...imageNode, content: "data:image/svg+xml,%3Csvg/%3E" }), true);
|
|
assert.equal(isVectorImageNode({ ...imageNode, layerRole: "vectorized-image" }), true);
|
|
assert.equal(isVectorImageNode({ ...imageNode, layerRole: "cad-vector" }), true);
|
|
assert.equal(isVectorImageNode(imageNode), false);
|
|
});
|
|
|
|
test("recognizes encoded SVG paths without treating raster paths as vector", () => {
|
|
assert.equal(isSvgSource("https://assets.example.com/%E5%9B%BE%E7%BA%B8.svg#preview"), true);
|
|
assert.equal(isSvgSource("https://assets.example.com/image.png?format=svg"), false);
|
|
});
|