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
Improve editor history, CAD tools, and ruler workflows
This commit is contained in:
@@ -2837,6 +2837,11 @@ button {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.workplane-wrap.ruler-move-mode .three-workplane-host,
|
||||
.workplane-wrap.ruler-move-mode .three-workplane-host:active {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.workplane-wrap.modifier-edge-pick .three-workplane-host,
|
||||
.workplane-wrap.modifier-edge-pick .three-workplane-host:active {
|
||||
cursor: crosshair;
|
||||
@@ -2901,6 +2906,16 @@ button {
|
||||
transition: fill 120ms ease, stroke 120ms ease, filter 120ms ease;
|
||||
}
|
||||
|
||||
.ruler-overlay.move-mode .ruler-point {
|
||||
cursor: grab;
|
||||
}
|
||||
|
||||
.ruler-overlay.move-mode .ruler-point:active {
|
||||
cursor: grabbing;
|
||||
fill: #dff7ff;
|
||||
filter: drop-shadow(0 0 4px rgba(0, 143, 190, 0.4));
|
||||
}
|
||||
|
||||
.ruler-overlay.delete-mode .ruler-segment-group:hover .ruler-segment {
|
||||
stroke: #dc3f36;
|
||||
stroke-width: 3;
|
||||
@@ -2925,6 +2940,17 @@ button {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.ruler-hover-edge {
|
||||
fill: none;
|
||||
stroke: #00aeea;
|
||||
stroke-width: 4;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
vector-effect: non-scaling-stroke;
|
||||
filter: drop-shadow(0 0 3px rgba(0, 174, 234, 0.48));
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.ruler-label {
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
|
||||
+47
-21
@@ -3,6 +3,7 @@
|
||||
import { Clock3, EllipsisVertical, FileUp, Grid3X3, HomeIcon, List, Pencil, Plus, Search, Settings, SlidersHorizontal, Trash2, X } from "lucide-react";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { SketchForgeEditor, importedShapeFromStl, importedShapeFromSvg } from "@/components/SketchForgeEditor";
|
||||
import { hydrateEditorHistoryState, type EditorHistoryEntry } from "@/lib/editorHistory";
|
||||
import { createLocalId } from "@/lib/localIds";
|
||||
import { importExtensionSupported } from "@/lib/stlImport";
|
||||
import { DEFAULT_SNAP_GRID, DEFAULT_WORKPLANE_WORKSPACE, normalizeSnapGrid, normalizeWorkspaceSettings, workplaneSettingsFingerprint } from "@/lib/workplaneSettings";
|
||||
@@ -34,10 +35,16 @@ type StoredDashboardProject = Partial<DashboardProject> & {
|
||||
type ProjectShapeCacheEntry = {
|
||||
revision: number;
|
||||
shapes: WorkplaneShape[];
|
||||
history: EditorHistoryEntry[];
|
||||
historyIndex: number;
|
||||
};
|
||||
|
||||
type ProjectShapeRecord = ProjectShapeCacheEntry & {
|
||||
type ProjectShapeRecord = {
|
||||
id: string;
|
||||
revision: number;
|
||||
shapes: WorkplaneShape[];
|
||||
history?: EditorHistoryEntry[];
|
||||
historyIndex?: number;
|
||||
updatedAt: number;
|
||||
};
|
||||
|
||||
@@ -57,6 +64,21 @@ function formatUpdated(timestamp: number) {
|
||||
return new Intl.DateTimeFormat(undefined, { month: "short", day: "numeric" }).format(new Date(timestamp));
|
||||
}
|
||||
|
||||
function projectShapeCacheEntry(
|
||||
revision: number,
|
||||
shapes: WorkplaneShape[],
|
||||
history?: EditorHistoryEntry[],
|
||||
historyIndex?: number,
|
||||
): ProjectShapeCacheEntry {
|
||||
const hydrated = hydrateEditorHistoryState(shapes, history, historyIndex);
|
||||
return {
|
||||
revision,
|
||||
shapes: hydrated.entries[hydrated.index]?.shapes ?? shapes,
|
||||
history: hydrated.entries,
|
||||
historyIndex: hydrated.index,
|
||||
};
|
||||
}
|
||||
|
||||
function openProjectShapesDb() {
|
||||
return new Promise<IDBDatabase>((resolve, reject) => {
|
||||
if (typeof window === "undefined" || !window.indexedDB) {
|
||||
@@ -91,7 +113,7 @@ async function loadProjectShapes(projectId: string) {
|
||||
});
|
||||
}
|
||||
|
||||
async function saveProjectShapes(projectId: string, shapes: WorkplaneShape[], revision: number) {
|
||||
async function saveProjectShapes(projectId: string, entry: ProjectShapeCacheEntry) {
|
||||
const database = await openProjectShapesDb();
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
const transaction = database.transaction(PROJECT_SHAPES_STORE_NAME, "readwrite");
|
||||
@@ -102,10 +124,10 @@ async function saveProjectShapes(projectId: string, shapes: WorkplaneShape[], re
|
||||
};
|
||||
existingRequest.onsuccess = () => {
|
||||
const existing = existingRequest.result as ProjectShapeRecord | undefined;
|
||||
if (existing && existing.revision > revision) {
|
||||
if (existing && existing.revision > entry.revision) {
|
||||
return;
|
||||
}
|
||||
store.put({ id: projectId, revision, shapes, updatedAt: Date.now() } satisfies ProjectShapeRecord);
|
||||
store.put({ id: projectId, ...entry, updatedAt: Date.now() } satisfies ProjectShapeRecord);
|
||||
};
|
||||
transaction.oncomplete = () => {
|
||||
database.close();
|
||||
@@ -151,7 +173,7 @@ function readStoredProjects() {
|
||||
const revision = typeof project.revision === "number" ? project.revision : updatedAt;
|
||||
const designShapes = Array.isArray(project.designShapes) ? (project.designShapes as WorkplaneShape[]) : null;
|
||||
if (designShapes) {
|
||||
legacyShapes[id] = { revision, shapes: designShapes };
|
||||
legacyShapes[id] = projectShapeCacheEntry(revision, designShapes);
|
||||
}
|
||||
return {
|
||||
id,
|
||||
@@ -272,7 +294,7 @@ export default function Home() {
|
||||
if (Object.keys(legacyShapes).length > 0) {
|
||||
setProjectShapesById(legacyShapes);
|
||||
Object.entries(legacyShapes).forEach(([projectId, entry]) => {
|
||||
void saveProjectShapes(projectId, entry.shapes, entry.revision).catch(() => {
|
||||
void saveProjectShapes(projectId, entry).catch(() => {
|
||||
setDashboardNotice("Could not migrate project shapes to larger storage");
|
||||
});
|
||||
});
|
||||
@@ -348,12 +370,10 @@ export default function Home() {
|
||||
.then((record) => {
|
||||
if (canceled) return;
|
||||
const revision = activeProject.revision ?? record?.revision ?? Date.now();
|
||||
const entry = projectShapeCacheEntry(revision, record?.shapes ?? [], record?.history, record?.historyIndex);
|
||||
setProjectShapesById((current) => ({
|
||||
...current,
|
||||
[activeProjectId]: {
|
||||
revision,
|
||||
shapes: record?.shapes ?? [],
|
||||
},
|
||||
[activeProjectId]: entry,
|
||||
}));
|
||||
})
|
||||
.catch((error) => {
|
||||
@@ -361,10 +381,7 @@ export default function Home() {
|
||||
setDashboardNotice(error instanceof Error ? error.message : "Could not load project shapes");
|
||||
setProjectShapesById((current) => ({
|
||||
...current,
|
||||
[activeProjectId]: {
|
||||
revision: activeProject.revision ?? Date.now(),
|
||||
shapes: [],
|
||||
},
|
||||
[activeProjectId]: projectShapeCacheEntry(activeProject.revision ?? Date.now(), []),
|
||||
}));
|
||||
}
|
||||
});
|
||||
@@ -449,9 +466,15 @@ export default function Home() {
|
||||
});
|
||||
}, []);
|
||||
|
||||
const updateProjectShapes = useCallback((snapshot: { projectId: string; shapes: WorkplaneShape[] }) => {
|
||||
const updateProjectShapes = useCallback((snapshot: {
|
||||
projectId: string;
|
||||
shapes: WorkplaneShape[];
|
||||
history: EditorHistoryEntry[];
|
||||
historyIndex: number;
|
||||
}) => {
|
||||
const revision = Math.max(Date.now(), nextProjectRevisionRef.current + 1);
|
||||
nextProjectRevisionRef.current = revision;
|
||||
const entry = projectShapeCacheEntry(revision, snapshot.shapes, snapshot.history, snapshot.historyIndex);
|
||||
setProjectShapesById((current) => {
|
||||
const existing = current[snapshot.projectId];
|
||||
if (existing && existing.revision > revision) {
|
||||
@@ -459,12 +482,12 @@ export default function Home() {
|
||||
}
|
||||
return {
|
||||
...current,
|
||||
[snapshot.projectId]: { revision, shapes: snapshot.shapes },
|
||||
[snapshot.projectId]: entry,
|
||||
};
|
||||
});
|
||||
|
||||
const previousSave = projectShapeSaveQueuesRef.current[snapshot.projectId] ?? Promise.resolve();
|
||||
const queuedSave = previousSave.catch(() => undefined).then(() => saveProjectShapes(snapshot.projectId, snapshot.shapes, revision));
|
||||
const queuedSave = previousSave.catch(() => undefined).then(() => saveProjectShapes(snapshot.projectId, entry));
|
||||
projectShapeSaveQueuesRef.current[snapshot.projectId] = queuedSave;
|
||||
|
||||
void queuedSave
|
||||
@@ -519,9 +542,9 @@ export default function Home() {
|
||||
const project = newProject(name ?? `Untitled design ${projects.length + 1}`, projects.length);
|
||||
setProjectShapesById((current) => ({
|
||||
...current,
|
||||
[project.id]: { revision: project.revision ?? project.updatedAt, shapes: [] },
|
||||
[project.id]: projectShapeCacheEntry(project.revision ?? project.updatedAt, []),
|
||||
}));
|
||||
void saveProjectShapes(project.id, [], project.revision ?? project.updatedAt).catch(() => {
|
||||
void saveProjectShapes(project.id, projectShapeCacheEntry(project.revision ?? project.updatedAt, [])).catch(() => {
|
||||
setDashboardNotice("Could not prepare project shape storage");
|
||||
});
|
||||
setProjects((current) => [project, ...current]);
|
||||
@@ -542,10 +565,11 @@ export default function Home() {
|
||||
: importedShapeFromStl(file.name, await file.arrayBuffer());
|
||||
const project = newProject(projectNameFromFileName(file.name), projects.length, 1);
|
||||
const revision = project.revision ?? project.updatedAt;
|
||||
await saveProjectShapes(project.id, [shape], revision);
|
||||
const entry = projectShapeCacheEntry(revision, [shape]);
|
||||
await saveProjectShapes(project.id, entry);
|
||||
setProjectShapesById((current) => ({
|
||||
...current,
|
||||
[project.id]: { revision, shapes: [shape] },
|
||||
[project.id]: entry,
|
||||
}));
|
||||
setDashboardNotice(`Imported ${file.name}`);
|
||||
setProjects((current) => [project, ...current]);
|
||||
@@ -674,6 +698,8 @@ export default function Home() {
|
||||
<div className={view === "editor" ? "editor-stage active" : "editor-stage"} aria-hidden={view !== "editor"}>
|
||||
<SketchForgeEditor
|
||||
initialShapes={activeProjectShapeEntry?.shapes ?? []}
|
||||
initialHistory={activeProjectShapeEntry?.history}
|
||||
initialHistoryIndex={activeProjectShapeEntry?.historyIndex}
|
||||
initialSnap={activeProject?.snapGrid ?? DEFAULT_SNAP_GRID}
|
||||
initialWorkspace={activeProject?.workspace ?? DEFAULT_WORKPLANE_WORKSPACE}
|
||||
onHome={openDashboard}
|
||||
|
||||
Reference in New Issue
Block a user