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
Support SKF hashing over HTTP
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { createHash } from "node:crypto";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { sha256Hex } from "@/lib/projectAssets";
|
||||
|
||||
const utf8 = new TextEncoder();
|
||||
|
||||
describe("project asset hashing", () => {
|
||||
afterEach(() => vi.unstubAllGlobals());
|
||||
|
||||
it.each([
|
||||
["", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"],
|
||||
["abc", "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"],
|
||||
[
|
||||
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
|
||||
"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1",
|
||||
],
|
||||
])("computes SHA-256 without Web Crypto for %j", async (input, expected) => {
|
||||
vi.stubGlobal("crypto", {});
|
||||
await expect(sha256Hex(utf8.encode(input))).resolves.toBe(expected);
|
||||
});
|
||||
|
||||
it.each([55, 56, 63, 64, 65, 1024, 4097])("matches Node SHA-256 for %i binary bytes", async (length) => {
|
||||
const bytes = Uint8Array.from({ length }, (_value, index) => (index * 37 + 11) & 0xff);
|
||||
const expected = createHash("sha256").update(bytes).digest("hex");
|
||||
vi.stubGlobal("crypto", {});
|
||||
await expect(sha256Hex(bytes)).resolves.toBe(expected);
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { strFromU8, strToU8, unzipSync, zipSync } from "fflate";
|
||||
import { editorHistoryEntry } from "@/lib/editorHistory";
|
||||
import { projectAssetFromBytes } from "@/lib/projectAssets";
|
||||
@@ -69,6 +69,8 @@ function mutateProject(bytes: Uint8Array, mutate: (document: SkfProjectDocumentV
|
||||
}
|
||||
|
||||
describe("SketchForge .skf project packages", () => {
|
||||
afterEach(() => vi.unstubAllGlobals());
|
||||
|
||||
it("round-trips every supported native shape kind and editable properties", async () => {
|
||||
const nativeKinds: ShapeKind[] = [
|
||||
"box", "cylinder", "sphere", "sketch", "scribble", "cone", "pyramid", "roof", "text", "roundRoof",
|
||||
@@ -194,6 +196,30 @@ describe("SketchForge .skf project packages", () => {
|
||||
expect(importCalls).toBe(1);
|
||||
});
|
||||
|
||||
it("exports and imports source-backed projects without Web Crypto", async () => {
|
||||
const sourceBytes = strToU8("solid http source");
|
||||
const asset = await projectAssetFromBytes("http.stl", "stl", sourceBytes);
|
||||
const importedMesh: NonNullable<WorkplaneShape["importedMesh"]> = {
|
||||
positions: [0, 0, 0, 1, 0, 0, 0, 1, 0],
|
||||
baseWidth: 1,
|
||||
baseDepth: 1,
|
||||
baseHeight: 1,
|
||||
triangleCount: 1,
|
||||
sourceFormat: "stl",
|
||||
assetId: asset.id,
|
||||
};
|
||||
vi.stubGlobal("crypto", {});
|
||||
|
||||
const exported = await exportSkfProject(input([shape("mesh", "http-object", { importedMesh })], { assets: [asset] }));
|
||||
const restored = await importSkfProject(exported, {
|
||||
sourceImporter: async () => ({ ...importedMesh, assetId: undefined }),
|
||||
});
|
||||
|
||||
expect(packageDocument(exported).document.assets[0].sha256).toBe(asset.sha256);
|
||||
expect(restored.assets[0].sha256).toBe(asset.sha256);
|
||||
expect(restored.shapes[0].importedMesh?.assetId).toBe(restored.assets[0].id);
|
||||
});
|
||||
|
||||
it.each(["svg", "step"] as const)("stores and restores original %s sources", async (sourceFormat) => {
|
||||
const asset = await projectAssetFromBytes(`source.${sourceFormat}`, sourceFormat, strToU8(`${sourceFormat} source`));
|
||||
const importedMesh: NonNullable<WorkplaneShape["importedMesh"]> = {
|
||||
|
||||
Reference in New Issue
Block a user