feat: SnapCAD Studio'yu YakHub deposuna taşı
Build and Push Docker Images / build (push) Canceled after 0s
CI / Typecheck and unit tests (push) Canceled after 0s

- DWG/DXF içe aktarma ve .skf yeniden açma düzeltmeleri

- YakNet Bulut eşitlemede boş/eski kopya koruması ve yerel-only proje bildirimi

- Panelden içe aktarma duyuruları ve erişilebilir Türkçe hata mesajları

- AGPL-3.0 lisansı, README ve YakHub bağlantıları
This commit is contained in:
Enes Yakıştır
2026-10-25 18:20:21 +03:00
parent e9cb8e8681
commit 33b0940012
149 changed files with 46978 additions and 1273 deletions
+125 -1
View File
@@ -1,8 +1,9 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { strFromU8, strToU8, unzipSync, zipSync } from "fflate";
import { importedShapeFromDxf } from "@/lib/dxfImport";
import { editorHistoryEntry } from "@/lib/editorHistory";
import { placementWorkplaneFromSurface } from "@/lib/placementWorkplane";
import { projectAssetFromBytes } from "@/lib/projectAssets";
import { attachProjectAsset, projectAssetFromBytes } from "@/lib/projectAssets";
import * as projectAssets from "@/lib/projectAssets";
import { canonicalizeShape } from "@/lib/workplaneShapes";
import {
@@ -18,6 +19,21 @@ import {
import { DEFAULT_SNAP_GRID, DEFAULT_WORKPLANE_WORKSPACE } from "@/lib/workplaneSettings";
import type { ShapeKind, WorkplaneShape } from "@/types/sketchforge";
// DWG tarayıcı çekirdeği testte gerçek WASM çalıştırmaz; kaynak varlık yolunun
// doğru içe aktarıcıya yönlendirildiğini doğrulamak için sabit bir mesh döner.
vi.mock("@/lib/dwgKernel", () => ({
importedShapeFromDwg: vi.fn(async () => ({
importedMesh: {
positions: [0, 0, 0, 1, 0, 0, 0, 1, 0],
baseWidth: 4321,
baseDepth: 21,
baseHeight: 3,
triangleCount: 1,
sourceFormat: "dwg",
},
})),
}));
function shape(kind: ShapeKind, id = `${kind}-1`, overrides: Partial<WorkplaneShape> = {}): WorkplaneShape {
return {
id,
@@ -635,3 +651,111 @@ describe("SketchForge .skf project packages", () => {
await expect(importSkfProject(zipSync(files))).rejects.toThrow("integrity check");
});
});
function rectangleDxf(width: number, height: number) {
return `0
SECTION
2
ENTITIES
0
LWPOLYLINE
8
0
90
4
70
1
10
0.0
20
0.0
10
${width}
20
0.0
10
${width}
20
${height}
10
0.0
20
${height}
0
ENDSEC
0
EOF`;
}
describe("Imported CAD source assets survive .skf round trips", () => {
it("reconstructs a DXF source asset when a project is reopened", async () => {
const dxf = rectangleDxf(40, 20);
const original = importedShapeFromDxf("plan.dxf", dxf);
const asset = await projectAssetFromBytes("plan.dxf", "dxf", strToU8(dxf));
const packaged = await exportSkfProject(input([attachProjectAsset(original, asset.id)], { assets: [asset] }));
// DXF kaynak dosyası yeniden üretilebildiği için paket yalnızca kaynağı taşır.
const { document } = packageDocument(packaged);
expect(document.assets.filter((entry) => entry.kind === "source").map((entry) => entry.sourceFormat)).toEqual(["dxf"]);
expect(document.assets.some((entry) => entry.kind === "derived-mesh")).toBe(false);
const restored = await importSkfProject(packaged);
expect(restored.shapes).toHaveLength(1);
expect(restored.shapes[0].kind).toBe("mesh");
expect(restored.shapes[0].importedMesh?.sourceFormat).toBe("dxf");
expect(restored.shapes[0].importedMesh?.triangleCount).toBe(original.importedMesh?.triangleCount);
expect(restored.shapes[0].width).toBeCloseTo(40, 0);
expect(restored.shapes[0].depth).toBeCloseTo(20, 0);
});
it("accepts a DWG source asset and reuses the stored derived mesh", async () => {
// Gerçek bir DWG içe aktarımı, kaynak varlığını "dwg" biçiminde saklar ama
// şeklin mesh'i DXF'ten üretildiği için sourceFormat "dxf" olarak kalır.
// Bu birleşim daha önce "unknown source format" hatasıyla projeyi boş açıyordu.
const importedMesh = {
positions: [0, 0, 0, 10, 0, 0, 0, 10, 0],
baseWidth: 270,
baseDepth: 280,
baseHeight: 4,
triangleCount: 1,
sourceFormat: "dxf" as const,
};
const dwgShape = shape("mesh", "dwg-mesh", { importedMesh });
const dwgBytes = strToU8("AC1032");
const asset = await projectAssetFromBytes("plan.dwg", "dwg", dwgBytes);
const packaged = await exportSkfProject(input([attachProjectAsset(dwgShape, asset.id)], { assets: [asset] }));
const { document } = packageDocument(packaged);
expect(document.assets.map((entry) => [entry.kind, entry.sourceFormat])).toContainEqual(["source", "dwg"]);
expect(document.assets.some((entry) => entry.kind === "derived-mesh")).toBe(true);
// Kaynak DWG dönüştürülmeden, paketteki hazır mesh ile açılmalı.
const restored = await importSkfProject(packaged);
expect(restored.shapes).toHaveLength(1);
expect(restored.shapes[0].importedMesh?.triangleCount).toBe(1);
expect(restored.shapes[0].importedMesh?.baseWidth).toBe(270);
});
it("routes a DWG source asset to the DWG importer when no derived mesh is stored", async () => {
const dwgShape = shape("mesh", "dwg-source-only", {
importedMesh: {
positions: [0, 0, 0, 1, 0, 0, 0, 1, 0],
baseWidth: 1,
baseDepth: 1,
baseHeight: 1,
triangleCount: 1,
sourceFormat: "dwg",
},
});
const asset = await projectAssetFromBytes("source-only.dwg", "dwg", strToU8("AC1032"));
const packaged = await exportSkfProject(input([attachProjectAsset(dwgShape, asset.id)], { assets: [asset] }));
const { document } = packageDocument(packaged);
expect(document.assets.some((entry) => entry.kind === "derived-mesh")).toBe(false);
const restored = await importSkfProject(packaged);
expect(restored.shapes).toHaveLength(1);
expect(restored.shapes[0].importedMesh?.baseWidth).toBe(4321);
expect(restored.shapes[0].importedMesh?.sourceFormat).toBe("dwg");
});
});