Merge remote-tracking branch 'origin/main' into codex/screw-hole-cutters

# Conflicts:
#	apps/web/src/components/WorkplaneViewport.tsx
This commit is contained in:
Francisco Rivero
2026-07-14 01:26:38 +09:00
36 changed files with 1784 additions and 365 deletions
+117 -15
View File
@@ -2797,36 +2797,111 @@ button {
.camera-controls {
position: absolute;
top: 173px;
left: 8px;
left: 10px;
z-index: 8;
display: grid;
gap: 4px;
display: flex;
flex-direction: column;
gap: 2px;
padding: 5px;
background: rgba(255, 255, 255, 0.86);
border: 1px solid rgba(194, 209, 219, 0.9);
border-radius: 17px;
box-shadow: 0 10px 30px rgba(32, 64, 84, 0.14), 0 2px 6px rgba(32, 64, 84, 0.08);
backdrop-filter: blur(14px) saturate(1.15);
}
.camera-controls button {
position: relative;
display: grid;
width: 51px;
height: 51px;
width: 44px;
height: 43px;
place-items: center;
color: #173b5a;
background: rgba(255, 255, 255, 0.88);
border: 1px solid #dfe6eb;
border-radius: 999px;
box-shadow: 0 1px 2px rgba(30, 50, 70, 0.08);
background: transparent;
border: 1px solid transparent;
border-radius: 12px;
box-shadow: none;
cursor: pointer;
transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}
.camera-controls button:hover {
color: #000;
border-color: #c4d2dc;
color: #071f32;
background: rgba(223, 239, 247, 0.82);
border-color: rgba(155, 190, 207, 0.7);
transform: translateX(1px);
}
.camera-controls button:focus-visible {
outline: 2px solid #28a9d2;
outline-offset: 1px;
}
.camera-controls.collapsed {
border-radius: 17px;
}
.camera-controls button.active,
.camera-controls button[aria-pressed="true"] {
color: #007eae;
background: #e8f8fd;
border-color: #63cbe8;
box-shadow: 0 0 0 3px rgba(0, 159, 207, 0.14), 0 1px 2px rgba(30, 50, 70, 0.08);
color: #006b94;
background: #def5fb;
border-color: #6fc8df;
box-shadow: inset 3px 0 0 #079bc6;
}
.ruler-control-group {
position: relative;
margin-top: 6px;
}
.ruler-control-group::before {
position: absolute;
top: -5px;
right: 8px;
left: 8px;
height: 1px;
content: "";
background: rgba(117, 144, 160, 0.28);
}
.ruler-tool-popover {
position: absolute;
top: 2px;
left: calc(100% + 10px);
display: flex;
gap: 3px;
padding: 4px;
background: rgba(255, 255, 255, 0.94);
border: 1px solid rgba(194, 209, 219, 0.94);
border-radius: 13px;
box-shadow: 0 8px 24px rgba(32, 64, 84, 0.18), 0 2px 6px rgba(32, 64, 84, 0.1);
backdrop-filter: blur(14px) saturate(1.15);
animation: ruler-tools-in 130ms ease-out;
}
.camera-controls .ruler-tool-popover button {
width: 35px;
height: 35px;
border-radius: 9px;
}
.camera-controls .ruler-tool-popover .ruler-delete-button.active {
color: #b42318;
background: #fff0ee;
border-color: #ee9b92;
box-shadow: inset 3px 0 0 #dc3f36;
}
@keyframes ruler-tools-in {
from {
opacity: 0;
transform: translateX(-4px) scale(0.96);
}
to {
opacity: 1;
transform: translateX(0) scale(1);
}
}
.workplane-wrap {
@@ -2870,6 +2945,11 @@ button {
cursor: crosshair;
}
.workplane-wrap.ruler-delete-mode .three-workplane-host,
.workplane-wrap.ruler-delete-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;
@@ -2909,6 +2989,7 @@ button {
stroke-width: 2;
vector-effect: non-scaling-stroke;
pointer-events: none;
transition: stroke 120ms ease, stroke-width 120ms ease;
}
.ruler-segment-hit {
@@ -2930,6 +3011,19 @@ button {
.ruler-point {
pointer-events: all;
cursor: pointer;
transition: fill 120ms ease, stroke 120ms ease, filter 120ms ease;
}
.ruler-overlay.delete-mode .ruler-segment-group:hover .ruler-segment {
stroke: #dc3f36;
stroke-width: 3;
filter: drop-shadow(0 0 2px rgba(220, 63, 54, 0.3));
}
.ruler-overlay.delete-mode .ruler-point:hover {
fill: #fff0ee;
stroke: #dc3f36;
filter: drop-shadow(0 0 3px rgba(220, 63, 54, 0.36));
}
.ruler-point.pending {
@@ -4255,6 +4349,14 @@ button {
font-weight: 700;
}
.workspace-global-note {
margin: -10px 0 0 153px;
color: #718697;
font-size: 12px;
font-weight: 650;
line-height: 1.45;
}
.workspace-dimensions {
display: grid;
grid-template-columns: 1fr 1fr;
+1 -1
View File
@@ -16,7 +16,7 @@ export default function RootLayout({
children: React.ReactNode;
}>) {
return (
<html lang="en" suppressHydrationWarning>
<html lang="en" style={{ colorScheme: "light" }}>
<body suppressHydrationWarning>{children}</body>
</html>
);
+46 -28
View File
@@ -2,10 +2,10 @@
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 } from "@/components/SketchForgeEditor";
import { SketchForgeEditor, importedShapeFromStl, importedShapeFromSvg } from "@/components/SketchForgeEditor";
import { createLocalId } from "@/lib/localIds";
import { importExtensionSupported } from "@/lib/stlImport";
import { DEFAULT_SNAP_GRID, DEFAULT_WORKPLANE_WORKSPACE, normalizeSnapGrid, normalizeWorkspaceSettings } from "@/lib/workplaneSettings";
import { DEFAULT_SNAP_GRID, DEFAULT_WORKPLANE_WORKSPACE, normalizeSnapGrid, normalizeWorkspaceSettings, workplaneSettingsFingerprint } from "@/lib/workplaneSettings";
import type { GridSize, WorkplaneShape, WorkplaneWorkspaceSettings } from "@/types/sketchforge";
type AppView = "dashboard" | "editor";
@@ -236,7 +236,7 @@ function newProject(name: string, index: number, shapeCount = 0): DashboardProje
}
function projectNameFromFileName(fileName: string) {
return fileName.replace(/\.[^.]+$/, "").trim() || "Imported STL design";
return fileName.replace(/\.[^.]+$/, "").trim() || "Imported design";
}
export default function Home() {
@@ -255,11 +255,18 @@ export default function Home() {
const [dashboardNotice, setDashboardNotice] = useState("");
const [projectShapesById, setProjectShapesById] = useState<Record<string, ProjectShapeCacheEntry>>({});
const projectsJsonRef = useRef("");
const dashboardStlInputRef = useRef<HTMLInputElement | null>(null);
const dashboardImportInputRef = useRef<HTMLInputElement | null>(null);
const nextProjectRevisionRef = useRef(0);
const projectShapeSaveQueuesRef = useRef<Record<string, Promise<void>>>({});
useEffect(() => {
document.documentElement.removeAttribute("data-theme");
document.documentElement.style.colorScheme = "light";
try {
window.localStorage.removeItem("sketchForge.theme");
} catch {
// Light mode still applies when browser storage is unavailable.
}
const { projects: storedProjects, legacyShapes } = readStoredProjects();
setProjects(storedProjects);
if (Object.keys(legacyShapes).length > 0) {
@@ -486,18 +493,26 @@ export default function Home() {
const version = Date.now();
const workspace = normalizeWorkspaceSettings(snapshot.workspace);
const snapGrid = normalizeSnapGrid(snapshot.snap);
setProjects((current) =>
current.map((project) =>
project.id === snapshot.projectId
? {
...project,
workspace,
snapGrid,
updatedAt: version,
}
: project,
),
);
const nextFingerprint = workplaneSettingsFingerprint(workspace, snapGrid);
setProjects((current) => {
let changed = false;
const next = current.map((project) => {
if (project.id !== snapshot.projectId) return project;
const currentFingerprint = workplaneSettingsFingerprint(
normalizeWorkspaceSettings(project.workspace),
normalizeSnapGrid(project.snapGrid),
);
if (currentFingerprint === nextFingerprint) return project;
changed = true;
return {
...project,
workspace,
snapGrid,
updatedAt: version,
};
});
return changed ? next : current;
});
}, []);
const createAndOpenProject = (name?: string) => {
@@ -513,15 +528,18 @@ export default function Home() {
openEditor(project.id, { allowMissingFromStorage: true });
};
const importStlFileFromDashboard = useCallback(
const importFileFromDashboard = useCallback(
async (file: File) => {
if (!importExtensionSupported(file.name)) {
setDashboardNotice("Unsupported file type. Use STL.");
const isSvg = /\.svg$/i.test(file.name) || file.type === "image/svg+xml";
if (!isSvg && !importExtensionSupported(file.name)) {
setDashboardNotice("Unsupported file type. Use STL or SVG.");
return;
}
try {
const shape = importedShapeFromStl(file.name, await file.arrayBuffer());
const shape = isSvg
? importedShapeFromSvg(file.name, await file.text())
: 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);
@@ -608,14 +626,14 @@ export default function Home() {
{JSON.stringify(projectDebugSummary)}
</pre>
<input
ref={dashboardStlInputRef}
ref={dashboardImportInputRef}
className="hidden-file-input"
type="file"
accept=".stl"
accept=".stl,.svg,image/svg+xml"
onChange={(event) => {
const file = event.currentTarget.files?.[0];
if (file) {
void importStlFileFromDashboard(file);
void importFileFromDashboard(file);
}
event.currentTarget.value = "";
}}
@@ -637,7 +655,7 @@ export default function Home() {
onDeleteProject={deleteProject}
onDownloadFolderChange={setDownloadFolder}
onDownloadModeChange={setDownloadMode}
onImportStl={() => dashboardStlInputRef.current?.click()}
onImportFile={() => dashboardImportInputRef.current?.click()}
onChallenges={() => {
setDashboardSection("challenges");
setDashboardNotice("");
@@ -688,7 +706,7 @@ function Dashboard({
onDeleteProject,
onDownloadFolderChange,
onDownloadModeChange,
onImportStl,
onImportFile,
onChallenges,
onDashboardHome,
onOpenProject,
@@ -714,7 +732,7 @@ function Dashboard({
onDeleteProject: (projectId: string) => void;
onDownloadFolderChange: (value: string) => void;
onDownloadModeChange: (value: DownloadMode) => void;
onImportStl: () => void;
onImportFile: () => void;
onChallenges: () => void;
onDashboardHome: () => void;
onOpenProject: (projectId: string) => void;
@@ -810,11 +828,11 @@ function Dashboard({
</span>
<span>Create new 3D design</span>
</button>
<button className="dashboard-action-tile" type="button" onClick={onImportStl}>
<button className="dashboard-action-tile" type="button" onClick={onImportFile}>
<span className="dashboard-action-icon">
<FileUp size={24} strokeWidth={2.4} />
</span>
<span>Import STL</span>
<span>Import STL/SVG</span>
</button>
<button className="dashboard-action-tile" type="button" onClick={onWorkspace}>
<span className="dashboard-action-icon">