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
fix: keep imported STL objects after import
Release local/web v1.0.4. Fixes #65
This commit is contained in:
@@ -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.3" src="https://img.shields.io/badge/version-v1.0.3-2563eb">
|
<img alt="Version v1.0.4" src="https://img.shields.io/badge/version-v1.0.4-2563eb">
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
+31
-13
@@ -16,7 +16,7 @@ import {
|
|||||||
type PlacementWorkplane,
|
type PlacementWorkplane,
|
||||||
} from "@/lib/placementWorkplane";
|
} from "@/lib/placementWorkplane";
|
||||||
import { attachProjectAsset, dedupeProjectAssets, projectAssetFromBytes, sourceFormatForFileName } from "@/lib/projectAssets";
|
import { attachProjectAsset, dedupeProjectAssets, projectAssetFromBytes, sourceFormatForFileName } from "@/lib/projectAssets";
|
||||||
import { hydrateProjectShapeState, type ImportedMeshResource } from "@/lib/projectShapePersistence";
|
import { hydrateProjectShapeState, reconcileLoadedProjectShapeCacheEntry, type ImportedMeshResource } from "@/lib/projectShapePersistence";
|
||||||
import { exportSkfProject, importSkfProject, SKF_CREATED_WITH_VERSION } from "@/lib/skfProject";
|
import { exportSkfProject, importSkfProject, SKF_CREATED_WITH_VERSION } from "@/lib/skfProject";
|
||||||
import { importExtensionSupported } from "@/lib/importExtensions";
|
import { importExtensionSupported } from "@/lib/importExtensions";
|
||||||
import { DEFAULT_SNAP_GRID, DEFAULT_WORKPLANE_WORKSPACE, normalizeSnapGrid, normalizeWorkspaceSettings, workplaneSettingsFingerprint } from "@/lib/workplaneSettings";
|
import { DEFAULT_SNAP_GRID, DEFAULT_WORKPLANE_WORKSPACE, normalizeSnapGrid, normalizeWorkspaceSettings, workplaneSettingsFingerprint } from "@/lib/workplaneSettings";
|
||||||
@@ -659,14 +659,27 @@ export default function Home() {
|
|||||||
void loadProjectShapes(activeProjectId)
|
void loadProjectShapes(activeProjectId)
|
||||||
.then((record) => {
|
.then((record) => {
|
||||||
if (canceled) return;
|
if (canceled) return;
|
||||||
const revision = activeProject.revision ?? record?.revision ?? Date.now();
|
const loadedRevision = record?.revision ?? 0;
|
||||||
const entry = projectShapeCacheEntry(revision, record?.shapes ?? [], record?.history, record?.historyIndex, record?.assets);
|
const revision = Math.max(activeProject.revision ?? 0, loadedRevision, 1);
|
||||||
setProjectShapesById((current) => ({
|
const loadedEntry = projectShapeCacheEntry(Math.max(loadedRevision, 1), record?.shapes ?? [], record?.history, record?.historyIndex, record?.assets);
|
||||||
...current,
|
const entry = loadedEntry.revision === revision ? loadedEntry : { ...loadedEntry, revision };
|
||||||
[activeProjectId]: entry,
|
setProjectShapesById((current) => {
|
||||||
}));
|
// IndexedDB reads are asynchronous. A local edit/import can update the live
|
||||||
if (record && !record.skfPackage) {
|
// cache while this older read is still in flight; never let that stale read
|
||||||
void saveProjectShapesWhenIdle(activeProjectId, entry, projectShapeSaveContext(activeProject)).catch(() => {
|
// replace newer in-memory shapes. Bump the preserved entry to the requested
|
||||||
|
// project revision so this effect does not immediately retry the same load.
|
||||||
|
const existing = current[activeProjectId];
|
||||||
|
const reconciled = reconcileLoadedProjectShapeCacheEntry(existing, entry, loadedRevision);
|
||||||
|
if (reconciled === existing) return current;
|
||||||
|
return {
|
||||||
|
...current,
|
||||||
|
[activeProjectId]: reconciled,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
if (record && !record.skfPackage && loadedRevision > 0) {
|
||||||
|
// Migrate the data at the revision it was actually read from disk. Using the
|
||||||
|
// newer project metadata revision here can let stale shapes outrank a live edit.
|
||||||
|
void saveProjectShapesWhenIdle(activeProjectId, loadedEntry, projectShapeSaveContext(activeProject)).catch(() => {
|
||||||
// The legacy record remains readable and migration can retry on the next load.
|
// The legacy record remains readable and migration can retry on the next load.
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -674,10 +687,15 @@ export default function Home() {
|
|||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
if (!canceled) {
|
if (!canceled) {
|
||||||
setDashboardNotice(error instanceof Error ? error.message : "Could not load project shapes");
|
setDashboardNotice(error instanceof Error ? error.message : "Could not load project shapes");
|
||||||
setProjectShapesById((current) => ({
|
setProjectShapesById((current) => {
|
||||||
...current,
|
// A failed background read must not erase a project that has already
|
||||||
[activeProjectId]: projectShapeCacheEntry(activeProject.revision ?? Date.now(), []),
|
// received live editor changes while the read was pending.
|
||||||
}));
|
if (current[activeProjectId]) return current;
|
||||||
|
return {
|
||||||
|
...current,
|
||||||
|
[activeProjectId]: projectShapeCacheEntry(activeProject.revision ?? Date.now(), []),
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return () => {
|
return () => {
|
||||||
|
|||||||
@@ -3,6 +3,20 @@ import type { WorkplaneShape } from "@/types/sketchforge";
|
|||||||
|
|
||||||
export type ImportedMeshResource = NonNullable<WorkplaneShape["importedMesh"]>;
|
export type ImportedMeshResource = NonNullable<WorkplaneShape["importedMesh"]>;
|
||||||
|
|
||||||
|
export function reconcileLoadedProjectShapeCacheEntry<T extends { revision: number }>(
|
||||||
|
existing: T | undefined,
|
||||||
|
loaded: T,
|
||||||
|
persistedRevision: number,
|
||||||
|
): T {
|
||||||
|
if (!existing || existing.revision <= persistedRevision) {
|
||||||
|
return loaded;
|
||||||
|
}
|
||||||
|
if (existing.revision >= loaded.revision) {
|
||||||
|
return existing;
|
||||||
|
}
|
||||||
|
return { ...existing, revision: loaded.revision };
|
||||||
|
}
|
||||||
|
|
||||||
type CompactProjectShapeState = {
|
type CompactProjectShapeState = {
|
||||||
shapes: WorkplaneShape[];
|
shapes: WorkplaneShape[];
|
||||||
history: EditorHistoryEntry[];
|
history: EditorHistoryEntry[];
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ 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.2";
|
export const SKF_CREATED_WITH_VERSION = "1.0.4";
|
||||||
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 = {
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 1.0.4
|
||||||
|
|
||||||
|
- Fixed imported STL objects briefly appearing and then vanishing when a stale IndexedDB project read completed after the import.
|
||||||
|
- Prevented older persisted project data from overwriting newer live editor state during asynchronous project hydration.
|
||||||
|
|
||||||
## 0.1.0
|
## 0.1.0
|
||||||
|
|
||||||
- Initial open-source alpha.
|
- Initial open-source alpha.
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "sketchforge",
|
"name": "sketchforge",
|
||||||
"version": "1.0.3",
|
"version": "1.0.4",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "sketchforge",
|
"name": "sketchforge",
|
||||||
"version": "1.0.3",
|
"version": "1.0.4",
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tailwindcss/postcss": "^4.1.8",
|
"@tailwindcss/postcss": "^4.1.8",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sketchforge",
|
"name": "sketchforge",
|
||||||
"version": "1.0.3",
|
"version": "1.0.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"main": "apps/desktop/main.cjs",
|
"main": "apps/desktop/main.cjs",
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import { editorHistoryEntry } from "@/lib/editorHistory";
|
import { editorHistoryEntry } from "@/lib/editorHistory";
|
||||||
import { compactProjectShapeState, hydrateProjectShapeState } from "@/lib/projectShapePersistence";
|
import { compactProjectShapeState, hydrateProjectShapeState, reconcileLoadedProjectShapeCacheEntry } from "@/lib/projectShapePersistence";
|
||||||
import type { WorkplaneShape } from "@/types/sketchforge";
|
import type { WorkplaneShape } from "@/types/sketchforge";
|
||||||
|
|
||||||
function importedShape(): WorkplaneShape {
|
function importedShape(): WorkplaneShape {
|
||||||
@@ -30,6 +30,27 @@ function importedShape(): WorkplaneShape {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe("project shape persistence resources", () => {
|
describe("project shape persistence resources", () => {
|
||||||
|
it("preserves a newer live cache entry when an older IndexedDB read finishes late", () => {
|
||||||
|
const live = { revision: 20, shapes: [importedShape()] };
|
||||||
|
const staleLoaded = { revision: 30, shapes: [] as WorkplaneShape[] };
|
||||||
|
|
||||||
|
const reconciled = reconcileLoadedProjectShapeCacheEntry(live, staleLoaded, 10);
|
||||||
|
|
||||||
|
expect(reconciled.revision).toBe(30);
|
||||||
|
expect(reconciled.shapes).toHaveLength(1);
|
||||||
|
expect(reconciled.shapes[0]?.id).toBe("mesh-1");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("accepts persisted shapes when the IndexedDB record is newer than the live cache", () => {
|
||||||
|
const live = { revision: 20, shapes: [] as WorkplaneShape[] };
|
||||||
|
const loaded = { revision: 40, shapes: [importedShape()] };
|
||||||
|
|
||||||
|
const reconciled = reconcileLoadedProjectShapeCacheEntry(live, loaded, 40);
|
||||||
|
|
||||||
|
expect(reconciled).toBe(loaded);
|
||||||
|
expect(reconciled.shapes[0]?.id).toBe("mesh-1");
|
||||||
|
});
|
||||||
|
|
||||||
it("stores one immutable mesh resource across current shapes and history", () => {
|
it("stores one immutable mesh resource across current shapes and history", () => {
|
||||||
const mesh = importedShape();
|
const mesh = importedShape();
|
||||||
const group: WorkplaneShape = {
|
const group: WorkplaneShape = {
|
||||||
|
|||||||
Reference in New Issue
Block a user