fix: reduce autosave work and batch keyboard movement history

This commit is contained in:
Formsmith746
2026-09-18 12:12:41 +03:00
parent 6b3e0e642d
commit e9cb8e8681
12 changed files with 770 additions and 120 deletions
+6 -3
View File
@@ -8,7 +8,7 @@ SketchForge uses a packaged container (format option B). A `.skf` file is a ZIP
This was selected over pure JSON because imported STL/STEP data and exact B-Rep can be large, Base64 would add size and parsing overhead, and an archive lets SketchForge validate and hash each asset independently. The editable model is still JSON and can be inspected by opening `project.json` from the package.
## Version 1 layout
## Version 2 layout
```text
project.skf
@@ -17,7 +17,8 @@ project.skf
├── source/ Original imported STL, SVG, or STEP files
├── derived-mesh/ Exact caches for baked operations or legacy imports
├── brep/ Exact STEP/B-Rep payloads
└── image/ Deduplicated sketch/reference images
├── image/ Deduplicated sketch/reference images
└── display-edges/ Shared CAD display-edge arrays (JSON)
```
`project.json` contains these top-level sections:
@@ -36,6 +37,8 @@ project.skf
Object nodes keep stable SketchForge object IDs. Groups refer to child node IDs instead of array positions. Fillet/chamfer history refers to explicit “before” nodes. Feature dependencies are explicit and checked for cycles.
Nodes reference display edges through `cadDisplayEdgesAssetId`; the edge version remains in the shape definition. Each distinct edge array is stored once, including references from groups and reversible edge-treatment history. Mesh coordinate arrays, B-Rep strings, and image data URLs are encoded and hashed once per immutable resource. Weak caches and a bounded text cache reuse this work on subsequent saves. Import restores shared mesh and edge objects across undo states. Long node traversals yield to the event loop between batches.
## What is preserved
- All current native shape kinds and their editable parameters
@@ -59,7 +62,7 @@ Current safety limits are 512 MB compressed, 1 GB expanded, 256 MB per asset, 64
## Compatibility and migrations
The current format is version 1. Readers refuse a higher `formatVersion` or `minimumReaderVersion` instead of partially loading it. The importer also contains an explicit migration for the documented version 0 pure-JSON prototype and preserves its object IDs and valid history.
New saves use format version 2 and minimum reader version 2. Older applications reject these files rather than dropping shared display edges. The current reader accepts version 1 packages with inline display edges, interns those resources on import, and writes version 2 on the next save. The importer also contains an explicit migration for the documented version 0 pure-JSON prototype and preserves its object IDs and valid history.
Future schema changes should add a version-to-version migration, run validation after every migration, and never mutate the user's original file.