078b0bee32
Accept DWG and DXF files (up to 24 MB) through the canvas asset picker and drag-and-drop. Conversion runs locally in a browser worker via acad-ts, uploads a sanitized derived SVG, and leaves the source file untouched. DXF covers ASCII and binary drawings; DWG covers AutoCAD R14 through 2018. Rename the image-only upload input/handler to a generic canvas asset flow, add vector-image node detection, tag imported SVGs as vector-image nodes, localize CAD import status/error messages, and switch the Next build to the webpack compiler so the worker bundles correctly. Add a node --test suite covering CAD conversion and vector image helpers. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
29 lines
1.1 KiB
JavaScript
29 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), 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);
|
|
});
|