release: SketchForge 1.0.7

This commit is contained in:
Formsmith746
2026-08-24 12:55:20 +03:00
parent aff1ca8f98
commit 2486b998c8
8 changed files with 70 additions and 12 deletions
+1 -1
View File
@@ -19,7 +19,7 @@
<a href="https://github.com/Formsmith746/SketchForge-3D/stargazers"><img alt="Star SketchForge on GitHub" src="https://img.shields.io/github/stars/Formsmith746/SketchForge-3D?style=flat&logo=github"></a> <a href="https://github.com/Formsmith746/SketchForge-3D/stargazers"><img alt="Star SketchForge on GitHub" src="https://img.shields.io/github/stars/Formsmith746/SketchForge-3D?style=flat&logo=github"></a>
<a href="https://github.com/sponsors/Formsmith746"><img alt="Sponsor SketchForge on GitHub" src="https://img.shields.io/badge/GitHub-Sponsor-ea4aaa?logo=githubsponsors&logoColor=white"></a> <a href="https://github.com/sponsors/Formsmith746"><img alt="Sponsor SketchForge on GitHub" src="https://img.shields.io/badge/GitHub-Sponsor-ea4aaa?logo=githubsponsors&logoColor=white"></a>
<img alt="Local first" src="https://img.shields.io/badge/local--first-no%20account-0ea5e9"> <img alt="Local first" src="https://img.shields.io/badge/local--first-no%20account-0ea5e9">
<img alt="Version v1.0.6" src="https://img.shields.io/badge/version-v1.0.6-2563eb"> <img alt="Version v1.0.7" src="https://img.shields.io/badge/version-v1.0.7-2563eb">
</p> </p>
</div> </div>
+3 -1
View File
@@ -918,6 +918,9 @@ export default function Home() {
)}:${project.placementElevation ?? 0}:${placementWorkplaneFingerprint(normalizePlacementWorkplane(project.placementWorkplane, project.placementElevation))}:${placementWorkplaneFingerprint(normalizePlacementWorkplane(project.sketchPlacementWorkplane))}`; )}:${project.placementElevation ?? 0}:${placementWorkplaneFingerprint(normalizePlacementWorkplane(project.placementWorkplane, project.placementElevation))}:${placementWorkplaneFingerprint(normalizePlacementWorkplane(project.sketchPlacementWorkplane))}`;
if (currentFingerprint === nextFingerprint) return project; if (currentFingerprint === nextFingerprint) return project;
changed = true; changed = true;
// `revision` tracks the IndexedDB shape snapshot. Advancing it for a
// workspace-only change can make the loader replace newer live shapes
// with an older persisted snapshot while autosave is still pending.
return { return {
...project, ...project,
workspace, workspace,
@@ -926,7 +929,6 @@ export default function Home() {
placementWorkplane, placementWorkplane,
sketchPlacementWorkplane, sketchPlacementWorkplane,
updatedAt: version, updatedAt: version,
revision: version,
}; };
}); });
if (!changed) return current; if (!changed) return current;
+17 -6
View File
@@ -12,13 +12,13 @@ import type { GridSize, ProjectAsset, ProjectAssetSourceFormat, SketchOperation,
export const SKF_SCHEMA_ID = "com.sketchforge.project"; export const SKF_SCHEMA_ID = "com.sketchforge.project";
export const SKF_FORMAT_VERSION = 1; export const SKF_FORMAT_VERSION = 1;
export const SKF_MINIMUM_READER_VERSION = 1; export const SKF_MINIMUM_READER_VERSION = 1;
export const SKF_CREATED_WITH_VERSION = "1.0.6"; export const SKF_CREATED_WITH_VERSION = "1.0.7";
export const SKF_MEDIA_TYPE = "application/vnd.sketchforge.project+zip"; export const SKF_MEDIA_TYPE = "application/vnd.sketchforge.project+zip";
export const SKF_LIMITS = { export const SKF_LIMITS = {
archiveBytes: 512 * 1024 * 1024, archiveBytes: 512 * 1024 * 1024,
expandedBytes: 1024 * 1024 * 1024, expandedBytes: 1024 * 1024 * 1024,
projectJsonBytes: 32 * 1024 * 1024, projectJsonBytes: 64 * 1024 * 1024,
assetBytes: 256 * 1024 * 1024, assetBytes: 256 * 1024 * 1024,
entries: 4096, entries: 4096,
states: 5001, states: 5001,
@@ -751,7 +751,11 @@ export async function exportSkfProject(input: SkfProjectExportInput) {
sketchPlacementWorkplane, sketchPlacementWorkplane,
}, },
}; };
builder.files["project.json"] = strToU8(`${JSON.stringify(document, null, 2)}\n`); const projectJson = strToU8(JSON.stringify(document));
if (projectJson.byteLength > SKF_LIMITS.projectJsonBytes) {
throw new Error("Project data exceeds the 64 MB .skf limit. Export with fewer history steps or simplify the project.");
}
builder.files["project.json"] = projectJson;
return zipAsync(Object.fromEntries(Object.entries(builder.files).sort(([a], [b]) => a.localeCompare(b))), input.compressionLevel); return zipAsync(Object.fromEntries(Object.entries(builder.files).sort(([a], [b]) => a.localeCompare(b))), input.compressionLevel);
} }
@@ -1064,6 +1068,7 @@ async function restoreShapeFromNode(
files: ArchiveFiles, files: ArchiveFiles,
runtimeAssetByArchiveId: Map<string, ProjectAsset>, runtimeAssetByArchiveId: Map<string, ProjectAsset>,
sourceMeshCache: Map<string, Promise<NonNullable<WorkplaneShape["importedMesh"]>>>, sourceMeshCache: Map<string, Promise<NonNullable<WorkplaneShape["importedMesh"]>>>,
derivedMeshCache: Map<string, ReturnType<typeof decodeMeshCache>>,
sourceImporter: SkfSourceImporter, sourceImporter: SkfSourceImporter,
restoring = new Set<string>(), restoring = new Set<string>(),
): Promise<WorkplaneShape> { ): Promise<WorkplaneShape> {
@@ -1106,7 +1111,11 @@ async function restoreShapeFromNode(
} else if (node.importedMesh?.meshAssetId) { } else if (node.importedMesh?.meshAssetId) {
const meshRecord = assetById.get(node.importedMesh.meshAssetId); const meshRecord = assetById.get(node.importedMesh.meshAssetId);
if (!meshRecord) throw new Error(`Object '${node.objectId}' is missing its derived mesh`); if (!meshRecord) throw new Error(`Object '${node.objectId}' is missing its derived mesh`);
const decoded = decodeMeshCache(files[meshRecord.path]); let decoded = derivedMeshCache.get(meshRecord.id);
if (!decoded) {
decoded = decodeMeshCache(files[meshRecord.path]);
derivedMeshCache.set(meshRecord.id, decoded);
}
const brepRecord = node.importedMesh.brepStepAssetId ? assetById.get(node.importedMesh.brepStepAssetId) : undefined; const brepRecord = node.importedMesh.brepStepAssetId ? assetById.get(node.importedMesh.brepStepAssetId) : undefined;
importedMesh = { importedMesh = {
...decoded, ...decoded,
@@ -1120,14 +1129,14 @@ async function restoreShapeFromNode(
} }
const groupedShapes = node.groupedShapeNodeIds?.length const groupedShapes = node.groupedShapeNodeIds?.length
? await Promise.all(node.groupedShapeNodeIds.map((childId) => restoreShapeFromNode(childId, nodeById, assetById, files, runtimeAssetByArchiveId, sourceMeshCache, sourceImporter, new Set(restoring)))) ? await Promise.all(node.groupedShapeNodeIds.map((childId) => restoreShapeFromNode(childId, nodeById, assetById, files, runtimeAssetByArchiveId, sourceMeshCache, derivedMeshCache, sourceImporter, new Set(restoring))))
: undefined; : undefined;
const edgeTreatmentHistory = node.edgeTreatmentHistory?.length const edgeTreatmentHistory = node.edgeTreatmentHistory?.length
? await Promise.all(node.edgeTreatmentHistory.map(async (entry) => ({ ? await Promise.all(node.edgeTreatmentHistory.map(async (entry) => ({
id: entry.id, id: entry.id,
createdAt: entry.createdAt, createdAt: entry.createdAt,
feature: entry.feature as NonNullable<WorkplaneShape["edgeTreatmentHistory"]>[number]["feature"], feature: entry.feature as NonNullable<WorkplaneShape["edgeTreatmentHistory"]>[number]["feature"],
before: await restoreShapeFromNode(entry.beforeNodeId, nodeById, assetById, files, runtimeAssetByArchiveId, sourceMeshCache, sourceImporter, new Set(restoring)), before: await restoreShapeFromNode(entry.beforeNodeId, nodeById, assetById, files, runtimeAssetByArchiveId, sourceMeshCache, derivedMeshCache, sourceImporter, new Set(restoring)),
...(entry.appliedFrame ? { appliedFrame: entry.appliedFrame as NonNullable<WorkplaneShape["edgeTreatmentHistory"]>[number]["appliedFrame"] } : {}), ...(entry.appliedFrame ? { appliedFrame: entry.appliedFrame as NonNullable<WorkplaneShape["edgeTreatmentHistory"]>[number]["appliedFrame"] } : {}),
}))) })))
: undefined; : undefined;
@@ -1158,6 +1167,7 @@ async function restoreV1(document: SkfProjectDocumentV1, assetById: Map<string,
runtimeAssetByArchiveId.set(record.id, asset); runtimeAssetByArchiveId.set(record.id, asset);
} }
const sourceMeshCache = new Map<string, Promise<NonNullable<WorkplaneShape["importedMesh"]>>>(); const sourceMeshCache = new Map<string, Promise<NonNullable<WorkplaneShape["importedMesh"]>>>();
const derivedMeshCache = new Map<string, ReturnType<typeof decodeMeshCache>>();
const sourceImporter = options.sourceImporter ?? defaultSourceImporter; const sourceImporter = options.sourceImporter ?? defaultSourceImporter;
const restoredStates = new Map<string, WorkplaneShape[]>(); const restoredStates = new Map<string, WorkplaneShape[]>();
for (const state of document.states) { for (const state of document.states) {
@@ -1169,6 +1179,7 @@ async function restoreV1(document: SkfProjectDocumentV1, assetById: Map<string,
files, files,
runtimeAssetByArchiveId, runtimeAssetByArchiveId,
sourceMeshCache, sourceMeshCache,
derivedMeshCache,
sourceImporter, sourceImporter,
))); )));
restoredStates.set(state.id, shapes); restoredStates.set(state.id, shapes);
+6
View File
@@ -1,5 +1,11 @@
# Changelog # Changelog
## 1.0.7
- Raised the supported `project.json` size in `.skf` packages from 32 MiB to 64 MiB and compacted new project exports without removing editable data.
- Reused decoded derived-mesh data across restored history states to reduce memory pressure when opening large `.skf` projects.
- Prevented workspace-only changes from advancing the persisted shape revision and replacing newer live objects with an older snapshot.
## 1.0.6 ## 1.0.6
- Fixed dense STL imports failing with `Invalid string length` while creating their initial undo-history fingerprint. - Fixed dense STL imports failing with `Invalid string length` while creating their initial undo-history fingerprint.
+1 -1
View File
@@ -55,7 +55,7 @@ SketchForge inspects ZIP metadata before expansion and validates the entire proj
Opening a valid `.skf` creates a new local project. It does not overwrite the project that is currently open. The imported project is then saved through the existing dashboard, thumbnail, IndexedDB, history, and editor lifecycle. Opening a valid `.skf` creates a new local project. It does not overwrite the project that is currently open. The imported project is then saved through the existing dashboard, thumbnail, IndexedDB, history, and editor lifecycle.
Current safety limits are 512 MB compressed, 1 GB expanded, 256 MB per asset, 32 MB for `project.json`, 4,096 archive entries, 100,000 object nodes per state, and 5,001 distinct states. The live editor retains at most 5,000 history entries and 64 MB of serialized history, so Unlimited means all history currently available inside those safety limits. Current safety limits are 512 MB compressed, 1 GB expanded, 256 MB per asset, 64 MB for `project.json`, 4,096 archive entries, 100,000 object nodes per state, and 5,001 distinct states. The live editor retains at most 5,000 history entries and 64 MB of serialized history, so Unlimited means all history currently available inside those safety limits.
## Compatibility and migrations ## Compatibility and migrations
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "sketchforge", "name": "sketchforge",
"version": "1.0.6", "version": "1.0.7",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "sketchforge", "name": "sketchforge",
"version": "1.0.6", "version": "1.0.7",
"license": "AGPL-3.0-only", "license": "AGPL-3.0-only",
"dependencies": { "dependencies": {
"@tailwindcss/postcss": "^4.1.8", "@tailwindcss/postcss": "^4.1.8",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "sketchforge", "name": "sketchforge",
"version": "1.0.6", "version": "1.0.7",
"private": true, "private": true,
"description": "A local-first 3D design editor.", "description": "A local-first 3D design editor.",
"author": { "author": {
+39
View File
@@ -9,6 +9,7 @@ import {
importSkfProject, importSkfProject,
inspectSkfProjectPackage, inspectSkfProjectPackage,
SKF_FORMAT_VERSION, SKF_FORMAT_VERSION,
SKF_LIMITS,
SKF_SCHEMA_ID, SKF_SCHEMA_ID,
type SkfProjectDocumentV1, type SkfProjectDocumentV1,
type SkfProjectExportInput, type SkfProjectExportInput,
@@ -330,6 +331,28 @@ describe("SketchForge .skf project packages", () => {
expect(restored.shapes[0].importedMesh?.assetId).toBe(restored.assets[0].id); expect(restored.shapes[0].importedMesh?.assetId).toBe(restored.assets[0].id);
}); });
it("shares decoded derived-mesh arrays across restored history states", async () => {
const importedMesh: NonNullable<WorkplaneShape["importedMesh"]> = {
positions: [0, 0, 0, 1, 0, 0, 0, 1, 0],
normals: [0, 0, 1, 0, 0, 1, 0, 0, 1],
baseWidth: 1,
baseDepth: 1,
baseHeight: 1,
triangleCount: 1,
sourceFormat: "json",
};
const before = shape("mesh", "derived-history", { importedMesh, x: 0 });
const after = { ...before, x: 20 };
const history = [editorHistoryEntry([before], []), editorHistoryEntry([after], [after.id])];
const restored = await importSkfProject(await exportSkfProject(input([after], { history, historyIndex: 1 })));
const firstPositions = restored.history[0].shapes[0].importedMesh?.positions;
const secondPositions = restored.history[1].shapes[0].importedMesh?.positions;
expect(firstPositions).toBe(secondPositions);
expect(restored.shapes[0].importedMesh?.positions).toBe(secondPositions);
});
it.each(["svg", "step"] as const)("stores and restores original %s sources", async (sourceFormat) => { 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 asset = await projectAssetFromBytes(`source.${sourceFormat}`, sourceFormat, strToU8(`${sourceFormat} source`));
const importedMesh: NonNullable<WorkplaneShape["importedMesh"]> = { const importedMesh: NonNullable<WorkplaneShape["importedMesh"]> = {
@@ -429,6 +452,22 @@ describe("SketchForge .skf project packages", () => {
} }
}); });
it("writes compact project data that stays compatible with the reader limit", async () => {
const exported = await exportSkfProject(input([shape("box")]));
const { files, document } = packageDocument(exported);
const projectJson = strFromU8(files["project.json"]);
expect(projectJson).toBe(JSON.stringify(document));
await expect(importSkfProject(exported)).resolves.toMatchObject({ projectName: "Round trip" });
});
it("refuses to create an .skf package that its reader cannot reopen", async () => {
const oversizedName = "x".repeat(SKF_LIMITS.projectJsonBytes);
await expect(exportSkfProject(input([shape("box")], { projectName: oversizedName })))
.rejects.toThrow("Project data exceeds the 64 MB .skf limit");
});
it("migrates the documented v0 JSON project without changing IDs", async () => { it("migrates the documented v0 JSON project without changing IDs", async () => {
const box = shape("box", "legacy-box"); const box = shape("box", "legacy-box");
const legacy = strToU8(JSON.stringify({ const legacy = strToU8(JSON.stringify({