Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
feat: SnapCAD Studio'yu YakHub deposuna taşı
- 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:
@@ -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");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user