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
Release v0.2.0 with Docker deployment
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
.git
|
||||||
|
.github
|
||||||
|
.codex
|
||||||
|
.codex-remote-attachments
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
**/node_modules
|
||||||
|
**/.next
|
||||||
|
**/out
|
||||||
|
build
|
||||||
|
dist
|
||||||
|
|
||||||
|
coverage
|
||||||
|
test-results
|
||||||
|
playwright-report
|
||||||
|
.playwright-cli
|
||||||
|
|
||||||
|
.env
|
||||||
|
.env*.local
|
||||||
|
*.log
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
.idea
|
||||||
|
.vscode
|
||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
|
FROM node:22-alpine AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
|
ENV STATIC_EXPORT=true
|
||||||
|
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
FROM nginx:stable-alpine AS runner
|
||||||
|
|
||||||
|
COPY deploy/nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
COPY --from=builder /app/apps/web/out /usr/share/nginx/html
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
||||||
|
CMD wget -q -O - http://127.0.0.1/healthz | grep -q '^ok$' || exit 1
|
||||||
|
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
<a href="LICENSE"><img alt="MIT license" src="https://img.shields.io/badge/license-MIT-16a34a"></a>
|
<a href="LICENSE"><img alt="MIT license" src="https://img.shields.io/badge/license-MIT-16a34a"></a>
|
||||||
<a href="https://github.com/Formsmith746/SketchForge-3D/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/Formsmith746/SketchForge-3D?style=social"></a>
|
<a href="https://github.com/Formsmith746/SketchForge-3D/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/Formsmith746/SketchForge-3D?style=social"></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 0.2.0" src="https://img.shields.io/badge/version-0.2.0-2563eb">
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -64,6 +65,83 @@ Open:
|
|||||||
http://127.0.0.1:3000/
|
http://127.0.0.1:3000/
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Docker / FabLab Server (Recommended)
|
||||||
|
|
||||||
|
The Docker image contains a static SketchForge build served by Nginx. Projects stay in each user's browser; STL and OBJ files download through that browser. The container does not receive or store project files.
|
||||||
|
|
||||||
|
Docker is the recommended server setup because it packages the correct Node build environment, static app, Nginx configuration, health check, and restart policy together. It is easier to reproduce and update than configuring each part by hand.
|
||||||
|
|
||||||
|
Requirements:
|
||||||
|
|
||||||
|
- Docker Engine with Docker Compose
|
||||||
|
|
||||||
|
Build and start SketchForge:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose up --build -d
|
||||||
|
```
|
||||||
|
|
||||||
|
Open it on the server:
|
||||||
|
|
||||||
|
```text
|
||||||
|
http://127.0.0.1:3000/
|
||||||
|
```
|
||||||
|
|
||||||
|
Other computers on the same network can use the server's LAN address:
|
||||||
|
|
||||||
|
```text
|
||||||
|
http://SERVER_IP:3000/
|
||||||
|
```
|
||||||
|
|
||||||
|
To use another host port:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
SKETCHFORGE_PORT=8080 docker compose up --build -d
|
||||||
|
```
|
||||||
|
|
||||||
|
On PowerShell:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
$env:SKETCHFORGE_PORT = "8080"
|
||||||
|
docker compose up --build -d
|
||||||
|
```
|
||||||
|
|
||||||
|
Stop the server with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose down
|
||||||
|
```
|
||||||
|
|
||||||
|
### Manual Static Deployment (Advanced)
|
||||||
|
|
||||||
|
This is the harder alternative for servers where Docker cannot be used. The administrator must install and maintain Node.js, npm, Nginx or another static web server, firewall access, startup behavior, and future updates separately.
|
||||||
|
|
||||||
|
Requirements:
|
||||||
|
|
||||||
|
- Node.js 20 or newer
|
||||||
|
- npm
|
||||||
|
- Nginx, Apache, Caddy, or another static web server
|
||||||
|
|
||||||
|
Create the static build on Linux or macOS:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm ci
|
||||||
|
STATIC_EXPORT=true npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
Create it with PowerShell on Windows:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
npm ci
|
||||||
|
$env:STATIC_EXPORT = "true"
|
||||||
|
npm run build
|
||||||
|
Remove-Item Env:STATIC_EXPORT
|
||||||
|
```
|
||||||
|
|
||||||
|
The deployable files are generated in `apps/web/out`. Configure the web server to serve that directory and fall back to `index.html` for unknown application paths. [`deploy/nginx.conf`](deploy/nginx.conf) is the configuration used by the Docker image and can be adapted for a manual Nginx installation.
|
||||||
|
|
||||||
|
The administrator must also open the chosen LAN port in the server firewall and arrange for the web server to start automatically after a reboot. For each SketchForge update, pull the new source, install dependencies, rebuild `apps/web/out`, replace the served files, and reload the web server.
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
+198
-16
@@ -413,7 +413,7 @@ button {
|
|||||||
grid-row: 1 / span 2;
|
grid-row: 1 / span 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.project-delete {
|
.project-menu-trigger {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 12px;
|
top: 12px;
|
||||||
right: 12px;
|
right: 12px;
|
||||||
@@ -430,15 +430,59 @@ button {
|
|||||||
box-shadow: 0 2px 6px rgba(24, 43, 60, 0.1);
|
box-shadow: 0 2px 6px rgba(24, 43, 60, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.project-card:hover .project-delete,
|
.project-card:hover .project-menu-trigger,
|
||||||
.project-delete:focus-visible {
|
.project-menu-trigger:focus-visible {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.project-delete:hover {
|
.project-menu-trigger:hover,
|
||||||
|
.project-menu-trigger[aria-expanded="true"] {
|
||||||
|
color: #264d6b;
|
||||||
|
border-color: #a9bdcc;
|
||||||
|
background: #f5f9fc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-card-menu {
|
||||||
|
position: absolute;
|
||||||
|
top: 52px;
|
||||||
|
right: 12px;
|
||||||
|
z-index: 4;
|
||||||
|
display: grid;
|
||||||
|
width: 148px;
|
||||||
|
gap: 3px;
|
||||||
|
padding: 5px;
|
||||||
|
color: #314b61;
|
||||||
|
background: #ffffff;
|
||||||
|
border: 1px solid #ccd9e3;
|
||||||
|
border-radius: 7px;
|
||||||
|
box-shadow: 0 10px 28px rgba(24, 43, 60, 0.18);
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-card-menu button {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 9px;
|
||||||
|
min-height: 36px;
|
||||||
|
padding: 0 10px;
|
||||||
|
color: inherit;
|
||||||
|
background: transparent;
|
||||||
|
border-radius: 5px;
|
||||||
|
font-weight: 700;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-card-menu button:hover,
|
||||||
|
.project-card-menu button:focus-visible {
|
||||||
|
background: #eef5fa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-card-menu button.delete {
|
||||||
color: #b01925;
|
color: #b01925;
|
||||||
border-color: #efb7be;
|
}
|
||||||
background: #fff4f5;
|
|
||||||
|
.project-card-menu button.delete:hover,
|
||||||
|
.project-card-menu button.delete:focus-visible {
|
||||||
|
background: #fff1f2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dashboard-confirm-overlay {
|
.dashboard-confirm-overlay {
|
||||||
@@ -524,6 +568,44 @@ button {
|
|||||||
background: #c82031;
|
background: #c82031;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dashboard-confirm-save {
|
||||||
|
color: #ffffff;
|
||||||
|
border: 1px solid #147ca8;
|
||||||
|
background: #147ca8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-confirm-save:disabled {
|
||||||
|
cursor: not-allowed;
|
||||||
|
opacity: 0.45;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-rename-dialog > label {
|
||||||
|
display: grid;
|
||||||
|
gap: 7px;
|
||||||
|
padding: 18px;
|
||||||
|
color: #40586c;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-rename-dialog input {
|
||||||
|
width: 100%;
|
||||||
|
height: 42px;
|
||||||
|
padding: 0 12px;
|
||||||
|
color: #1d3448;
|
||||||
|
background: #ffffff;
|
||||||
|
border: 1px solid #b9cad7;
|
||||||
|
border-radius: 6px;
|
||||||
|
font: inherit;
|
||||||
|
font-weight: 600;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-rename-dialog input:focus {
|
||||||
|
border-color: #1486b5;
|
||||||
|
box-shadow: 0 0 0 3px rgba(20, 134, 181, 0.14);
|
||||||
|
}
|
||||||
|
|
||||||
.project-empty {
|
.project-empty {
|
||||||
display: grid;
|
display: grid;
|
||||||
min-height: 190px;
|
min-height: 190px;
|
||||||
@@ -2707,9 +2789,9 @@ button {
|
|||||||
.workspace-modal-card {
|
.workspace-modal-card {
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
width: 520px;
|
width: 760px;
|
||||||
max-width: calc(100vw - 32px);
|
max-width: calc(100vw - 32px);
|
||||||
min-height: min(720px, calc(100vh - 104px));
|
height: min(650px, calc(100vh - 104px));
|
||||||
max-height: calc(100vh - 104px);
|
max-height: calc(100vh - 104px);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
color: #264158;
|
color: #264158;
|
||||||
@@ -2753,14 +2835,86 @@ button {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.workspace-modal-layout {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 190px minmax(0, 1fr);
|
||||||
|
height: calc(100% - 55px);
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.workspace-settings-nav {
|
||||||
|
display: grid;
|
||||||
|
align-content: start;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 16px 10px;
|
||||||
|
background: #f4f7f9;
|
||||||
|
border-right: 1px solid #d8e1e8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.workspace-settings-nav button {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
width: 100%;
|
||||||
|
min-height: 42px;
|
||||||
|
padding: 0 12px;
|
||||||
|
color: #526b7e;
|
||||||
|
background: transparent;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 800;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.workspace-settings-nav button:hover {
|
||||||
|
color: #274861;
|
||||||
|
background: #e9f0f4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.workspace-settings-nav button.active {
|
||||||
|
color: #176f95;
|
||||||
|
background: #ffffff;
|
||||||
|
border-color: #c7d9e4;
|
||||||
|
box-shadow: 0 1px 3px rgba(31, 64, 84, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.workspace-modal-content {
|
||||||
|
display: grid;
|
||||||
|
grid-template-rows: minmax(0, 1fr) auto;
|
||||||
|
min-width: 0;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
.workspace-modal-body {
|
.workspace-modal-body {
|
||||||
display: grid;
|
display: grid;
|
||||||
|
align-content: start;
|
||||||
gap: 20px;
|
gap: 20px;
|
||||||
max-height: calc(100vh - 159px);
|
min-height: 0;
|
||||||
padding: 18px 18px 22px;
|
padding: 22px 24px;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.workspace-section-heading {
|
||||||
|
display: grid;
|
||||||
|
gap: 5px;
|
||||||
|
padding-bottom: 15px;
|
||||||
|
border-bottom: 1px solid #e2e9ee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.workspace-section-heading strong {
|
||||||
|
color: #213d54;
|
||||||
|
font-size: 17px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.workspace-section-heading span {
|
||||||
|
color: #718697;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 650;
|
||||||
|
}
|
||||||
|
|
||||||
.workspace-row,
|
.workspace-row,
|
||||||
.workspace-toggle,
|
.workspace-toggle,
|
||||||
.workspace-select {
|
.workspace-select {
|
||||||
@@ -2858,7 +3012,9 @@ button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.make-default-button {
|
.make-default-button {
|
||||||
height: 30px;
|
min-width: 128px;
|
||||||
|
height: 34px;
|
||||||
|
padding: 0 14px;
|
||||||
color: #264158;
|
color: #264158;
|
||||||
background: #f7fafc;
|
background: #f7fafc;
|
||||||
border: 1px solid #d6e0e8;
|
border: 1px solid #d6e0e8;
|
||||||
@@ -2868,9 +3024,18 @@ button {
|
|||||||
font-weight: 800;
|
font-weight: 800;
|
||||||
}
|
}
|
||||||
|
|
||||||
.make-default-button {
|
.workspace-modal-footer {
|
||||||
width: 240px;
|
display: flex;
|
||||||
margin-left: 153px;
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 16px;
|
||||||
|
min-height: 64px;
|
||||||
|
padding: 12px 24px;
|
||||||
|
color: #718697;
|
||||||
|
background: #fbfcfd;
|
||||||
|
border-top: 1px solid #dfe7ed;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
.workspace-modal-header button:hover,
|
.workspace-modal-header button:hover,
|
||||||
@@ -3333,11 +3498,28 @@ button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.workspace-modal-card {
|
.workspace-modal-card {
|
||||||
width: min(520px, calc(100vw - 24px));
|
width: min(760px, calc(100vw - 24px));
|
||||||
min-height: calc(100vh - 112px);
|
height: calc(100vh - 112px);
|
||||||
max-height: calc(100vh - 112px);
|
max-height: calc(100vh - 112px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.workspace-modal-layout {
|
||||||
|
grid-template-columns: 165px minmax(0, 1fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
.workspace-settings-nav {
|
||||||
|
padding-inline: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.workspace-settings-nav button {
|
||||||
|
padding-inline: 9px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.workspace-modal-body,
|
||||||
|
.workspace-modal-footer {
|
||||||
|
padding-inline: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
.workplane-plane {
|
.workplane-plane {
|
||||||
inset: 0;
|
inset: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+100
-3
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Clock3, FileUp, Grid3X3, HomeIcon, List, Plus, Search, Settings, SlidersHorizontal, Trash2, X } from "lucide-react";
|
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 { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { SketchForgeEditor, importedShapeFromStl } from "@/components/SketchForgeEditor";
|
import { SketchForgeEditor, importedShapeFromStl } from "@/components/SketchForgeEditor";
|
||||||
import { createLocalId } from "@/lib/localIds";
|
import { createLocalId } from "@/lib/localIds";
|
||||||
@@ -574,6 +574,14 @@ export default function Home() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const renameProject = (projectId: string, name: string) => {
|
||||||
|
const nextName = name.trim().slice(0, 80);
|
||||||
|
if (!nextName) return;
|
||||||
|
setProjects((current) =>
|
||||||
|
current.map((project) => (project.id === projectId ? { ...project, name: nextName, updatedAt: Date.now() } : project)),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
if (!mounted) {
|
if (!mounted) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -629,6 +637,7 @@ export default function Home() {
|
|||||||
onOpenProject={openEditor}
|
onOpenProject={openEditor}
|
||||||
onOpenSettings={() => setSettingsOpen(true)}
|
onOpenSettings={() => setSettingsOpen(true)}
|
||||||
onQueryChange={setQuery}
|
onQueryChange={setQuery}
|
||||||
|
onRenameProject={renameProject}
|
||||||
onSortModeChange={setSortMode}
|
onSortModeChange={setSortMode}
|
||||||
onViewModeChange={setViewMode}
|
onViewModeChange={setViewMode}
|
||||||
onWorkspace={openLatestProject}
|
onWorkspace={openLatestProject}
|
||||||
@@ -645,6 +654,7 @@ export default function Home() {
|
|||||||
onProjectSnapshot={updateProjectSnapshot}
|
onProjectSnapshot={updateProjectSnapshot}
|
||||||
onProjectWorkspaceChange={updateProjectWorkspace}
|
onProjectWorkspaceChange={updateProjectWorkspace}
|
||||||
projectId={activeProjectId}
|
projectId={activeProjectId}
|
||||||
|
projectName={activeProject?.name}
|
||||||
projectRevision={activeProjectShapeEntry?.revision ?? activeProject?.revision ?? 0}
|
projectRevision={activeProjectShapeEntry?.revision ?? activeProject?.revision ?? 0}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -672,6 +682,7 @@ function Dashboard({
|
|||||||
onOpenProject,
|
onOpenProject,
|
||||||
onOpenSettings,
|
onOpenSettings,
|
||||||
onQueryChange,
|
onQueryChange,
|
||||||
|
onRenameProject,
|
||||||
onSortModeChange,
|
onSortModeChange,
|
||||||
onViewModeChange,
|
onViewModeChange,
|
||||||
onWorkspace,
|
onWorkspace,
|
||||||
@@ -694,12 +705,17 @@ function Dashboard({
|
|||||||
onOpenProject: (projectId: string) => void;
|
onOpenProject: (projectId: string) => void;
|
||||||
onOpenSettings: () => void;
|
onOpenSettings: () => void;
|
||||||
onQueryChange: (value: string) => void;
|
onQueryChange: (value: string) => void;
|
||||||
|
onRenameProject: (projectId: string, name: string) => void;
|
||||||
onSortModeChange: (value: string) => void;
|
onSortModeChange: (value: string) => void;
|
||||||
onViewModeChange: (value: ViewMode) => void;
|
onViewModeChange: (value: ViewMode) => void;
|
||||||
onWorkspace: () => void;
|
onWorkspace: () => void;
|
||||||
}) {
|
}) {
|
||||||
|
const [openProjectMenuId, setOpenProjectMenuId] = useState<string | null>(null);
|
||||||
const [projectPendingDeleteId, setProjectPendingDeleteId] = useState<string | null>(null);
|
const [projectPendingDeleteId, setProjectPendingDeleteId] = useState<string | null>(null);
|
||||||
|
const [projectPendingRenameId, setProjectPendingRenameId] = useState<string | null>(null);
|
||||||
|
const [projectNameDraft, setProjectNameDraft] = useState("");
|
||||||
const projectPendingDelete = projects.find((project) => project.id === projectPendingDeleteId) ?? null;
|
const projectPendingDelete = projects.find((project) => project.id === projectPendingDeleteId) ?? null;
|
||||||
|
const projectPendingRename = projects.find((project) => project.id === projectPendingRenameId) ?? null;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!projectPendingDeleteId) return;
|
if (!projectPendingDeleteId) return;
|
||||||
@@ -713,6 +729,23 @@ function Dashboard({
|
|||||||
setProjectPendingDeleteId(null);
|
setProjectPendingDeleteId(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const startProjectRename = (project: DashboardProject) => {
|
||||||
|
setOpenProjectMenuId(null);
|
||||||
|
setProjectPendingRenameId(project.id);
|
||||||
|
setProjectNameDraft(project.name);
|
||||||
|
};
|
||||||
|
|
||||||
|
const closeProjectRename = () => {
|
||||||
|
setProjectPendingRenameId(null);
|
||||||
|
setProjectNameDraft("");
|
||||||
|
};
|
||||||
|
|
||||||
|
const confirmProjectRename = () => {
|
||||||
|
if (!projectPendingRename || !projectNameDraft.trim()) return;
|
||||||
|
onRenameProject(projectPendingRename.id, projectNameDraft);
|
||||||
|
closeProjectRename();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="dashboard-shell">
|
<main className="dashboard-shell">
|
||||||
<header className="dashboard-topbar">
|
<header className="dashboard-topbar">
|
||||||
@@ -806,9 +839,36 @@ function Dashboard({
|
|||||||
{formatUpdated(project.updatedAt)} - {project.shapes} shapes
|
{formatUpdated(project.updatedAt)} - {project.shapes} shapes
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<button className="project-delete" type="button" aria-label={`Delete ${project.name}`} title="Delete project" onClick={() => setProjectPendingDeleteId(project.id)}>
|
<button
|
||||||
<Trash2 size={17} strokeWidth={2.4} />
|
className="project-menu-trigger"
|
||||||
|
type="button"
|
||||||
|
aria-label={`Project options for ${project.name}`}
|
||||||
|
aria-expanded={openProjectMenuId === project.id}
|
||||||
|
title="Project options"
|
||||||
|
onClick={() => setOpenProjectMenuId((current) => (current === project.id ? null : project.id))}
|
||||||
|
>
|
||||||
|
<EllipsisVertical size={19} strokeWidth={2.5} />
|
||||||
</button>
|
</button>
|
||||||
|
{openProjectMenuId === project.id ? (
|
||||||
|
<div className="project-card-menu" role="menu" aria-label={`Options for ${project.name}`}>
|
||||||
|
<button type="button" role="menuitem" onClick={() => startProjectRename(project)}>
|
||||||
|
<Pencil size={16} />
|
||||||
|
<span>Rename</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="delete"
|
||||||
|
type="button"
|
||||||
|
role="menuitem"
|
||||||
|
onClick={() => {
|
||||||
|
setOpenProjectMenuId(null);
|
||||||
|
setProjectPendingDeleteId(project.id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Trash2 size={16} />
|
||||||
|
<span>Delete</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
</article>
|
</article>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -845,6 +905,43 @@ function Dashboard({
|
|||||||
</section>
|
</section>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
|
{projectPendingRename ? (
|
||||||
|
<section className="dashboard-confirm-overlay" role="dialog" aria-modal="true" aria-labelledby="rename-project-title">
|
||||||
|
<form
|
||||||
|
className="dashboard-confirm-dialog dashboard-rename-dialog"
|
||||||
|
onSubmit={(event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
confirmProjectRename();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<header>
|
||||||
|
<strong id="rename-project-title">Rename project</strong>
|
||||||
|
<button type="button" aria-label="Cancel project rename" onClick={closeProjectRename}>
|
||||||
|
<X size={18} />
|
||||||
|
</button>
|
||||||
|
</header>
|
||||||
|
<label>
|
||||||
|
<span>Project name</span>
|
||||||
|
<input
|
||||||
|
autoFocus
|
||||||
|
maxLength={80}
|
||||||
|
value={projectNameDraft}
|
||||||
|
onChange={(event) => setProjectNameDraft(event.currentTarget.value)}
|
||||||
|
aria-label="Project name"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<div className="dashboard-confirm-actions">
|
||||||
|
<button className="dashboard-confirm-cancel" type="button" onClick={closeProjectRename}>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
<button className="dashboard-confirm-save" type="submit" disabled={!projectNameDraft.trim()}>
|
||||||
|
Save
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</section>
|
||||||
|
) : null}
|
||||||
|
|
||||||
{settingsOpen ? (
|
{settingsOpen ? (
|
||||||
<section className="dashboard-settings-panel" role="dialog" aria-modal="true" aria-label="Download settings">
|
<section className="dashboard-settings-panel" role="dialog" aria-modal="true" aria-label="Download settings">
|
||||||
<header>
|
<header>
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ import {
|
|||||||
workplaneShapesEqual,
|
workplaneShapesEqual,
|
||||||
} from "@/lib/workplaneShapes";
|
} from "@/lib/workplaneShapes";
|
||||||
import { createLocalId } from "@/lib/localIds";
|
import { createLocalId } from "@/lib/localIds";
|
||||||
|
import { projectExportFileName } from "@/lib/exportNames";
|
||||||
import { makeShapeFromAsset, sceneShape, toolbarShapeAssets, type ToolbarShapeAsset } from "@/lib/shapeCatalog";
|
import { makeShapeFromAsset, sceneShape, toolbarShapeAssets, type ToolbarShapeAsset } from "@/lib/shapeCatalog";
|
||||||
import { importedShapeFromStl, importExtensionSupported } from "@/lib/stlImport";
|
import { importedShapeFromStl, importExtensionSupported } from "@/lib/stlImport";
|
||||||
import type { AlignAxis, AlignHandleStatus, AlignTarget, GridSize, ShapeAsset, WorkplaneShape, WorkplaneWorkspaceSettings } from "@/types/sketchforge";
|
import type { AlignAxis, AlignHandleStatus, AlignTarget, GridSize, ShapeAsset, WorkplaneShape, WorkplaneWorkspaceSettings } from "@/types/sketchforge";
|
||||||
@@ -4006,6 +4007,7 @@ export function SketchForgeEditor({
|
|||||||
onProjectSnapshot,
|
onProjectSnapshot,
|
||||||
onProjectWorkspaceChange,
|
onProjectWorkspaceChange,
|
||||||
projectId,
|
projectId,
|
||||||
|
projectName = "SketchForge design",
|
||||||
projectRevision = 0,
|
projectRevision = 0,
|
||||||
}: {
|
}: {
|
||||||
initialShapes?: WorkplaneShape[];
|
initialShapes?: WorkplaneShape[];
|
||||||
@@ -4016,6 +4018,7 @@ export function SketchForgeEditor({
|
|||||||
onProjectSnapshot?: (snapshot: { image: string; projectId: string; shapes: number }) => void;
|
onProjectSnapshot?: (snapshot: { image: string; projectId: string; shapes: number }) => void;
|
||||||
onProjectWorkspaceChange?: (snapshot: { projectId: string; workspace: WorkplaneWorkspaceSettings; snap: GridSize }) => void;
|
onProjectWorkspaceChange?: (snapshot: { projectId: string; workspace: WorkplaneWorkspaceSettings; snap: GridSize }) => void;
|
||||||
projectId?: string | null;
|
projectId?: string | null;
|
||||||
|
projectName?: string;
|
||||||
projectRevision?: number;
|
projectRevision?: number;
|
||||||
} = {}) {
|
} = {}) {
|
||||||
const [shapes, setShapes] = useState<WorkplaneShape[]>(() => initialShapes.map(canonicalizeShape));
|
const [shapes, setShapes] = useState<WorkplaneShape[]>(() => initialShapes.map(canonicalizeShape));
|
||||||
@@ -4983,7 +4986,6 @@ export function SketchForgeEditor({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const meshes = exportable.map(meshForShape);
|
const meshes = exportable.map(meshForShape);
|
||||||
const scope = hasSelection ? "selection" : "design";
|
|
||||||
const selectedNotice = `Exported ${exportable.length} selected shape${exportable.length === 1 ? "" : "s"}`;
|
const selectedNotice = `Exported ${exportable.length} selected shape${exportable.length === 1 ? "" : "s"}`;
|
||||||
const finishNotice = (label: string, result: DownloadResult) => {
|
const finishNotice = (label: string, result: DownloadResult) => {
|
||||||
if (result.mode === "folder") {
|
if (result.mode === "folder") {
|
||||||
@@ -4996,15 +4998,15 @@ export function SketchForgeEditor({
|
|||||||
setNotice(error instanceof Error ? error.message : `Could not export ${label}`);
|
setNotice(error instanceof Error ? error.message : `Could not export ${label}`);
|
||||||
};
|
};
|
||||||
if (format === "stl") {
|
if (format === "stl") {
|
||||||
void downloadTextFile(`sketchforge-${scope}.stl`, toStl(meshes), "model/stl")
|
void downloadTextFile(projectExportFileName(projectName, "stl"), toStl(meshes), "model/stl")
|
||||||
.then((result) => finishNotice("STL", result))
|
.then((result) => finishNotice("STL", result))
|
||||||
.catch((error: unknown) => failNotice("STL", error));
|
.catch((error: unknown) => failNotice("STL", error));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
void downloadTextFile(`sketchforge-${scope}.obj`, toObj(meshes), "text/plain")
|
void downloadTextFile(projectExportFileName(projectName, "obj"), toObj(meshes), "text/plain")
|
||||||
.then((result) => finishNotice("OBJ", result))
|
.then((result) => finishNotice("OBJ", result))
|
||||||
.catch((error: unknown) => failNotice("OBJ", error));
|
.catch((error: unknown) => failNotice("OBJ", error));
|
||||||
}, [hasSelection, selectedShapes, shapes]);
|
}, [hasSelection, projectName, selectedShapes, shapes]);
|
||||||
|
|
||||||
const clearDesign = useCallback(() => {
|
const clearDesign = useCallback(() => {
|
||||||
commitShapes([], [], "New empty design");
|
commitShapes([], [], "New empty design");
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { X } from "lucide-react";
|
import { Grid3X3, Palette, Ruler, X } from "lucide-react";
|
||||||
import { useState, type CSSProperties } from "react";
|
import { useState, type CSSProperties } from "react";
|
||||||
import { DEFAULT_WORKPLANE_WORKSPACE } from "@/lib/workplaneSettings";
|
import { DEFAULT_WORKPLANE_WORKSPACE } from "@/lib/workplaneSettings";
|
||||||
import type { GridSize, WorkplaneWorkspaceSettings } from "@/types/sketchforge";
|
import type { GridSize, WorkplaneWorkspaceSettings } from "@/types/sketchforge";
|
||||||
|
|
||||||
type WorkspaceSettings = WorkplaneWorkspaceSettings;
|
type WorkspaceSettings = WorkplaneWorkspaceSettings;
|
||||||
|
type WorkspaceSettingsSection = "appearance" | "measurement" | "workplane";
|
||||||
|
|
||||||
const GRID_SIZES: GridSize[] = ["Off", "0.1 mm", "0.25 mm", "0.5 mm", "1.0 mm", "2.0 mm", "5.0 mm", "Brick"];
|
const GRID_SIZES: GridSize[] = ["Off", "0.1 mm", "0.25 mm", "0.5 mm", "1.0 mm", "2.0 mm", "5.0 mm", "Brick"];
|
||||||
const MIN_WORKSPACE_SIZE = 60;
|
const MIN_WORKSPACE_SIZE = 60;
|
||||||
@@ -49,6 +50,7 @@ export function WorkspaceSettingsModal({
|
|||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
}) {
|
}) {
|
||||||
const [defaultSaved, setDefaultSaved] = useState(false);
|
const [defaultSaved, setDefaultSaved] = useState(false);
|
||||||
|
const [activeSection, setActiveSection] = useState<WorkspaceSettingsSection>("appearance");
|
||||||
const patchWorkspace = (patch: Partial<WorkspaceSettings>) => {
|
const patchWorkspace = (patch: Partial<WorkspaceSettings>) => {
|
||||||
setDefaultSaved(false);
|
setDefaultSaved(false);
|
||||||
onWorkspaceChange({ ...workspace, ...patch });
|
onWorkspaceChange({ ...workspace, ...patch });
|
||||||
@@ -83,7 +85,30 @@ export function WorkspaceSettingsModal({
|
|||||||
</button>
|
</button>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
<div className="workspace-modal-layout">
|
||||||
|
<nav className="workspace-settings-nav" aria-label="Workspace settings sections">
|
||||||
|
<button className={activeSection === "appearance" ? "active" : ""} aria-current={activeSection === "appearance" ? "page" : undefined} onClick={() => setActiveSection("appearance")}>
|
||||||
|
<Palette size={18} />
|
||||||
|
<span>Appearance</span>
|
||||||
|
</button>
|
||||||
|
<button className={activeSection === "measurement" ? "active" : ""} aria-current={activeSection === "measurement" ? "page" : undefined} onClick={() => setActiveSection("measurement")}>
|
||||||
|
<Ruler size={18} />
|
||||||
|
<span>Measurement</span>
|
||||||
|
</button>
|
||||||
|
<button className={activeSection === "workplane" ? "active" : ""} aria-current={activeSection === "workplane" ? "page" : undefined} onClick={() => setActiveSection("workplane")}>
|
||||||
|
<Grid3X3 size={18} />
|
||||||
|
<span>Workplane</span>
|
||||||
|
</button>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div className="workspace-modal-content">
|
||||||
<div className="workspace-modal-body">
|
<div className="workspace-modal-body">
|
||||||
|
{activeSection === "appearance" ? (
|
||||||
|
<>
|
||||||
|
<div className="workspace-section-heading">
|
||||||
|
<strong>Appearance</strong>
|
||||||
|
<span>Adjust the canvas and navigation behavior.</span>
|
||||||
|
</div>
|
||||||
<div className="workspace-row">
|
<div className="workspace-row">
|
||||||
<span>Background color</span>
|
<span>Background color</span>
|
||||||
<button
|
<button
|
||||||
@@ -100,7 +125,6 @@ export function WorkspaceSettingsModal({
|
|||||||
checked={workspace.cruiseShapes}
|
checked={workspace.cruiseShapes}
|
||||||
onChange={(cruiseShapes) => patchWorkspace({ cruiseShapes })}
|
onChange={(cruiseShapes) => patchWorkspace({ cruiseShapes })}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<label className="workspace-range">
|
<label className="workspace-range">
|
||||||
<span>Zoom speed</span>
|
<span>Zoom speed</span>
|
||||||
<input
|
<input
|
||||||
@@ -115,7 +139,15 @@ export function WorkspaceSettingsModal({
|
|||||||
<span>Fast</span>
|
<span>Fast</span>
|
||||||
</small>
|
</small>
|
||||||
</label>
|
</label>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{activeSection === "measurement" ? (
|
||||||
|
<>
|
||||||
|
<div className="workspace-section-heading">
|
||||||
|
<strong>Measurement</strong>
|
||||||
|
<span>Choose units, precision, scale, and snapping.</span>
|
||||||
|
</div>
|
||||||
<WorkspaceSelect
|
<WorkspaceSelect
|
||||||
label="Units"
|
label="Units"
|
||||||
value={workspace.units}
|
value={workspace.units}
|
||||||
@@ -143,13 +175,21 @@ export function WorkspaceSettingsModal({
|
|||||||
onSnapChange(next as GridSize);
|
onSnapChange(next as GridSize);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{activeSection === "workplane" ? (
|
||||||
|
<>
|
||||||
|
<div className="workspace-section-heading">
|
||||||
|
<strong>Workplane</strong>
|
||||||
|
<span>Set the plate dimensions and visible grid spacing.</span>
|
||||||
|
</div>
|
||||||
<WorkspaceSelect
|
<WorkspaceSelect
|
||||||
label="Workplane size"
|
label="Workplane size"
|
||||||
value={workspace.sizePreset}
|
value={workspace.sizePreset}
|
||||||
options={WORKSPACE_SIZE_PRESETS.map((preset) => preset.label)}
|
options={WORKSPACE_SIZE_PRESETS.map((preset) => preset.label)}
|
||||||
onChange={setWorkspaceSizePreset}
|
onChange={setWorkspaceSizePreset}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="workspace-dimensions">
|
<div className="workspace-dimensions">
|
||||||
<label>
|
<label>
|
||||||
<span>Width</span>
|
<span>Width</span>
|
||||||
@@ -190,7 +230,12 @@ export function WorkspaceSettingsModal({
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="workspace-modal-footer">
|
||||||
|
<span>Save the current settings for this project.</span>
|
||||||
<button
|
<button
|
||||||
className="make-default-button"
|
className="make-default-button"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -202,6 +247,8 @@ export function WorkspaceSettingsModal({
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<button className="workspace-modal-backdrop" aria-label="Close settings" onClick={onClose} />
|
<button className="workspace-modal-backdrop" aria-label="Close settings" onClick={onClose} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
export type ProjectExportFormat = "stl" | "obj";
|
||||||
|
|
||||||
|
export function projectExportFileName(projectName: string, format: ProjectExportFormat) {
|
||||||
|
const safeProjectName = projectName
|
||||||
|
.trim()
|
||||||
|
.replace(/[<>:"/\\|?*\u0000-\u001f]/g, "-")
|
||||||
|
.replace(/\s+/g, " ")
|
||||||
|
.replace(/[. ]+$/g, "")
|
||||||
|
.slice(0, 120);
|
||||||
|
return `${safeProjectName || "SketchForge design"}.${format}`;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
services:
|
||||||
|
sketchforge:
|
||||||
|
image: sketchforge:local
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
ports:
|
||||||
|
- "${SKETCHFORGE_PORT:-3000}:80"
|
||||||
|
restart: unless-stopped
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
server {
|
||||||
|
listen 80 default_server;
|
||||||
|
listen [::]:80 default_server;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
server_tokens off;
|
||||||
|
gzip on;
|
||||||
|
gzip_types application/javascript application/json application/wasm image/svg+xml text/css text/plain;
|
||||||
|
|
||||||
|
add_header X-Content-Type-Options "nosniff" always;
|
||||||
|
add_header Referrer-Policy "same-origin" always;
|
||||||
|
|
||||||
|
location = /healthz {
|
||||||
|
access_log off;
|
||||||
|
default_type text/plain;
|
||||||
|
return 200 "ok\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
location /_next/static/ {
|
||||||
|
try_files $uri =404;
|
||||||
|
expires 1y;
|
||||||
|
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ $uri.html /index.html;
|
||||||
|
add_header Cache-Control "no-cache";
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "sketchforge",
|
"name": "sketchforge",
|
||||||
"version": "0.1.0",
|
"version": "0.2.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "sketchforge",
|
"name": "sketchforge",
|
||||||
"version": "0.1.0",
|
"version": "0.2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tailwindcss/postcss": "^4.1.8",
|
"@tailwindcss/postcss": "^4.1.8",
|
||||||
"@types/three": "^0.184.1",
|
"@types/three": "^0.184.1",
|
||||||
|
|||||||
+4
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sketchforge",
|
"name": "sketchforge",
|
||||||
"version": "0.1.0",
|
"version": "0.2.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev apps/web",
|
"dev": "next dev apps/web",
|
||||||
@@ -11,7 +11,9 @@
|
|||||||
"test": "vitest run --config tests/vitest.config.ts",
|
"test": "vitest run --config tests/vitest.config.ts",
|
||||||
"test:watch": "vitest --config tests/vitest.config.ts",
|
"test:watch": "vitest --config tests/vitest.config.ts",
|
||||||
"perf": "vitest run --config tests/vitest.perf.config.ts --reporter verbose",
|
"perf": "vitest run --config tests/vitest.perf.config.ts --reporter verbose",
|
||||||
"ci": "npm run typecheck && npm run test"
|
"ci": "npm run typecheck && npm run test",
|
||||||
|
"docker:build": "docker build -t sketchforge:local .",
|
||||||
|
"docker:run": "docker run --rm -p 3000:80 sketchforge:local"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tailwindcss/postcss": "^4.1.8",
|
"@tailwindcss/postcss": "^4.1.8",
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import { projectExportFileName } from "@/lib/exportNames";
|
||||||
|
|
||||||
|
describe("project export filenames", () => {
|
||||||
|
it("uses the project name for each supported export format", () => {
|
||||||
|
expect(projectExportFileName("Gearbox Prototype", "stl")).toBe("Gearbox Prototype.stl");
|
||||||
|
expect(projectExportFileName("Gearbox Prototype", "obj")).toBe("Gearbox Prototype.obj");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("removes filesystem-reserved characters without discarding the project name", () => {
|
||||||
|
expect(projectExportFileName(' enclosure: v2 / final? ', "stl")).toBe("enclosure- v2 - final-.stl");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("falls back to a useful name when the project name cannot be used", () => {
|
||||||
|
expect(projectExportFileName("...", "obj")).toBe("SketchForge design.obj");
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user