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
Move web app into apps workspace
@@ -0,0 +1 @@
|
||||
# No environment variables are required for local development.
|
||||
@@ -0,0 +1,6 @@
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
/// <reference path="./.next/types/routes.d.ts" />
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
||||
@@ -0,0 +1,20 @@
|
||||
import type { NextConfig } from "next";
|
||||
|
||||
const isStaticExport = process.env.STATIC_EXPORT === "true";
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
devIndicators: false,
|
||||
allowedDevOrigins: ["localhost", "127.0.0.1", "192.168.2.5"],
|
||||
images: {
|
||||
unoptimized: true
|
||||
},
|
||||
...(isStaticExport
|
||||
? {
|
||||
output: "export" as const,
|
||||
trailingSlash: true,
|
||||
assetPrefix: "./",
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
@@ -0,0 +1,7 @@
|
||||
const config = {
|
||||
plugins: {
|
||||
"@tailwindcss/postcss": {}
|
||||
}
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 110 B |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 110 B |
|
After Width: | Height: | Size: 5.3 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 6.8 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 119 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 75 KiB |
|
After Width: | Height: | Size: 55 KiB |
|
After Width: | Height: | Size: 61 KiB |
|
After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 61 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 57 KiB |
|
After Width: | Height: | Size: 63 KiB |
|
After Width: | Height: | Size: 57 KiB |
|
After Width: | Height: | Size: 66 KiB |
|
After Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 773 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 109 B |
|
After Width: | Height: | Size: 5.8 KiB |
@@ -0,0 +1,200 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 260 80">
|
||||
<!-- SVG created with Arrow, by QuiverAI (https://quiver.ai) -->
|
||||
<style type="text/css">.cls-0 {fill:#F4F4F4;}
|
||||
.cls-1 {fill:#666666;}
|
||||
.cls-2 {fill:#999999;}
|
||||
.cls-3 {fill:#B5B5B5;}
|
||||
.cls-4 {fill:url(#SVGID_1_);}
|
||||
.cls-5 {fill:url(#SVGID_2_);}
|
||||
.cls-6 {fill:url(#SVGID_3_);}
|
||||
.cls-7 {fill:url(#SVGID_4_);}
|
||||
.cls-8 {fill:url(#SVGID_5_);}
|
||||
.cls-9 {fill:url(#SVGID_6_);}
|
||||
.cls-10 {fill:url(#SVGID_7_);}
|
||||
.cls-11 {fill:url(#SVGID_8_);}
|
||||
.cls-12 {fill:url(#SVGID_9_);}
|
||||
.cls-13 {font-family:'Arial';}
|
||||
.cls-14 {font-size:2px;}</style>
|
||||
<path class="cls-1" d="m17 15.6v-3.6c0-0.3-0.2-0.6-0.5-0.6h-12.8c-0.3 0-0.6 0.3-0.6 0.6v14.6c0 0.2 0.2 0.4 0.5 0.4h3.4v1.7h-3.3c-1 0-1.9-1-1.9-2.1v-14.6c0-1.2 0.9-2.2 1.9-2.2h11.8c1.1 0 2 1 2 2.2v3.6h-0.5z"/>
|
||||
<path class="cls-1" d="m9.2 16.5h13.5c1.2 0 2 0.9 2 2.1v15.4c0 1.2-0.9 2-2 2h-13.1c-1.1 0-2-0.8-2-1.9v-15.5c0-1.2 0.7-2.1 1.6-2.1z"/>
|
||||
<path class="cls-2" d="m9.3 18.1h13.6l0.6 0.5v15.5l-0.5 0.5h-13.7l-0.4-0.5v-15.5z"/>
|
||||
<path class="cls-3" d="m9.9 19.2h12.5l0.3 0.3v13.9l-0.3 0.3h-12.5l-0.2-0.3v-13.9z"/>
|
||||
<linearGradient id="SVGID_1_" x1="18.66" x2="13.46" y1="33.92" y2="18.61" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#999" offset="0"/>
|
||||
<stop stop-color="#B3B3B3" offset="1"/>
|
||||
</linearGradient>
|
||||
<path class="cls-4" d="m10.5 19.8h11.2l0.4 0.4v12.6l-0.4 0.4h-11.2l-0.3-0.4v-12.6z"/>
|
||||
<path class="cls-1" d="m53.1 13.4-1.4 0.1v1.4h1v19.5h-14.9v-19.5h1.2v-1.4h-1.5l-1.4 1v20.1l1.1 1.5h16.1l1.5-1.1v-20.2z"/>
|
||||
<path class="cls-3" d="m40.1 11.6h3.4c0.6-3.2 3.9-3.2 4.7-0.1h2.8v4.3h-10.9v-4.2z"/>
|
||||
<path class="cls-2" d="m40.9 12.4h3.1c0.5-2.8 3.3-2.8 3.9-0.1h2.4v3.4h-9.4v-3.3z"/>
|
||||
<path class="cls-1" d="m45.6 10.6c1.4 0 2.1 2.9 0 3-1.9-0.1-1.4-3 0-3z"/>
|
||||
<path class="cls-3" d="m45.6 11.1c1 0 1.5 2 0 2.1-1.3-0.1-0.9-2.1 0-2.1z"/>
|
||||
<path class="cls-3" d="m38.7 15.7h13.1v0.8l-1 0.6h-10.4l-1.7-0.6z"/>
|
||||
<path class="cls-2" d="m41.1 20.3h9.3v1.1h-9.3z"/>
|
||||
<path class="cls-2" d="m40.9 23.6h9.6v1h-9.6z"/>
|
||||
<path class="cls-2" d="m41 26.5h9.5v1.1h-9.5z"/>
|
||||
<path class="cls-2" d="m41.1 29.5h5v1.1h-5z"/>
|
||||
<path class="cls-1" d="m74.3 10.2h14.4c1.2 0 2.1 1 2.1 2.1v13.3c0 1.7-0.8 2.5-2.1 2.5h-4.5v2.5l-1 0.9-5.2 0.3 0.5 1.2-0.7 2.1-8.3 2-1.2-0.8-2.4-9.9 0.7-1.1 2.9-0.7v-5.8l0.9-1.2 2-0.2v-5.1c0-1.1 0.7-2.1 1.9-2.1z"/>
|
||||
<path class="cls-3" d="m73.8 11.7h15.1l0.5 0.6v14l-0.5 0.4h-5.4v3l-10.2 0.3-3-3.7-0.1-7.7 2.4-0.1v-6.2z"/>
|
||||
<path class="cls-0" d="m74.2 12.3h14.5l0.3 0.4v13.3l-0.3 0.4h-14.5l-0.2-0.4v-13.3z"/>
|
||||
<path class="cls-3" d="m71.1 19.5h1.6v7.7l1.5 1.4 7.8-0.2 0.5 1.3-8.7 0.3-2.5-2.4z"/>
|
||||
<path class="cls-2" d="m67.5 26 1.4-0.2 1.7 4.9 5.1 0.6 1.3 2.5-1 0.4-6.1 1.5-0.7-0.5z"/>
|
||||
<path class="cls-3" d="m69.4 32.8 0.9-0.2 0.8 2.3-0.8 0.3z"/>
|
||||
<path class="cls-3" d="m71.6 32.4 0.6-0.1 0.7 2.1-0.7 0.2z"/>
|
||||
<path class="cls-3" d="m73.3 32 0.9-0.2 0.7 1.7-0.9 0.3z"/>
|
||||
<linearGradient id="SVGID_2_" x1="73.68" x2="84.81" y1="25.61" y2="13.08" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#F2F2F2" offset="0"/>
|
||||
<stop stop-color="#F5F5F5" offset="1"/>
|
||||
</linearGradient>
|
||||
<path class="cls-5" d="m74.9 13.1h12.6l0.8 0.8v11l-0.8 0.7h-12.6l-0.5-0.5v-11.5z"/>
|
||||
<path class="cls-1" d="m106.2 20.8-0.3-1.9c0.5-2.5 2-3.6 4.9-2.1l1.1 0.3 1.9-6.2c1.3-3.2 6.1-1.9 5.1 2.1l-2 5.5 3.7 1.5c1.7 0.8 0.7 3.9 0 5.5l-0.8 0.3-1.5 9.8-1.5 1.2-3.2-0.8 0.1-1.1-0.6 1-7.4-3v-0.6l-4-0.5v-1.9c2.1-2.5 3-5.7 4.5-9.1z"/>
|
||||
<path class="cls-3" d="m106.9 21.4 12.1 4.8-1.9 9.2-0.9 0.6-1.8-0.3 1.7-6.5-0.6-0.8-0.7 0.3-1.9 6.4-1.9-0.5 1.5-6.5-0.3-1.2-0.8 0.6-1.8 6.5-3.2-1.2 1.7-5.9-0.5-0.9-0.7 0.7-1.9 5.4-2.8-1.2c2.2-2.3 3.4-6 4.7-9.5z"/>
|
||||
<path class="cls-3" d="m107 19.4 12.6 5.2 0.8-2.5-0.3-1-3.3-1.7-0.4-1.1 1.8-5.8c0.2-2-2.8-2.8-3.5-0.4l-1.7 5.9-3.6-1.3c-1.5-0.2-2.3 0.7-2.4 2.7z"/>
|
||||
<linearGradient id="SVGID_3_" x1="108" x2="119.5" y1="18.04" y2="22.73" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#B3B3B3" offset="0"/>
|
||||
<stop stop-color="#ADADAD" offset="1"/>
|
||||
</linearGradient>
|
||||
<path class="cls-6" d="m107.9 18.9 11 4.5 0.6-1.7-3.1-1.7-0.9-1.5 1.8-6c-0.2-1.4-1.8-1.4-1.8-0.4l-1.9 6.8-4.4-1.5c-0.9-0.3-1.4 0-1.3 1.5z"/>
|
||||
<linearGradient id="SVGID_4_" x1="108.7" x2="113.7" y1="23.49" y2="32.9" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#B3B3B3" offset="0"/>
|
||||
<stop stop-color="#999" offset="1"/>
|
||||
</linearGradient>
|
||||
<path class="cls-7" d="m107.4 22.6 10.5 4.1-2 8.2-0.7-0.3 1.4-5.4-0.9-1.6-1.2 0.4-2 6-0.6-0.3 1.5-5.3-0.7-2-1.3 0.5-2 6-0.9-0.1 1.4-5.2-0.5-1.8-1.3-0.2-2.4 5.6-0.6-0.3 1.8-4.5-0.2-0.9-1 0.3-2.3 4.2-0.4-0.3c1.3-1.6 2.5-4.1 3.2-6.6z"/>
|
||||
<path class="cls-1" d="m135.8 14.1v2h19.2l0.5-0.5-0.2-1.7h-4.4v-1.8l-2-2.2h-7.2l-2.1 1.5 0.1 2.5-3.9 0.2zm6.2-2.2h6.1l0.6 0.6v1.4h-6.7v-2z"/>
|
||||
<path class="cls-3" d="m136.7 14.6h17.7v1h-17.7z"/>
|
||||
<path class="cls-1" d="m136.7 17.1h17v16.9l-0.9 2.1-14.4 0.2-1.5-0.7-0.2-1.2z"/>
|
||||
<path class="cls-2" d="m137.7 17.9h15.1v16.7l-0.6 0.8h-13.8l-0.7-0.8z"/>
|
||||
<path class="cls-3" d="m139.9 20.3h1.8v12h-1.8z"/>
|
||||
<path class="cls-3" d="m144 20h2.4v12.3h-2.4z"/>
|
||||
<path class="cls-3" d="m148.6 20h1.9v12.3h-1.9z"/>
|
||||
<path class="cls-2" d="m140.6 21.1h0.5v10.4h-0.5z"/>
|
||||
<path class="cls-2" d="m144.7 20.6h0.9v11.4h-0.9z"/>
|
||||
<path class="cls-2" d="m149.3 20.6h0.6v11.2h-0.6z"/>
|
||||
<path class="cls-2" d="m138.4 34.2h13.3l-0.6 0.7h-12.2z"/>
|
||||
<linearGradient id="SVGID_5_" x1="163.2" x2="192.4" y1="22.75" y2="22.75" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#999" offset="0"/>
|
||||
<stop stop-color="#666" offset="1"/>
|
||||
</linearGradient>
|
||||
<path class="cls-8" d="m163.2 21.6 12.9-12h1.6v9.8h5c4.9 0 9.7 4.5 9.7 10.6l-0.2 3.5h-1.4c-0.7-5.1-4.2-7.9-7.8-7.9h-5.3v10.1l-1.6 0.2-12.9-11.5v-2.8z"/>
|
||||
<linearGradient id="SVGID_6_" x1="177.7" x2="177.7" y1="34.17" y2="10.67" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#999" offset="0"/>
|
||||
<stop stop-color="#B3B3B3" offset="1"/>
|
||||
</linearGradient>
|
||||
<path class="cls-9" d="m163.9 22.1 12.2-10.7v9.2h6.3c3.7 0 8.9 3.5 9.1 11.5-1-4.1-3.6-7.4-8.3-7.5h-7.1v9.6l-12.2-10.8v-1.3z"/>
|
||||
<linearGradient id="SVGID_7_" x1="205.3" x2="222.6" y1="36.37" y2="12.54" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#999" offset="0"/>
|
||||
<stop stop-color="#666" offset="1"/>
|
||||
</linearGradient>
|
||||
<path class="cls-10" d="m198.2 34.4-0.1-4.7c0.6-5.1 4.8-9.9 10.5-9.9h4.1v-10.2l1.8-0.3 13 12.3 0.1 3.1-12.5 11.9-2.2-0.3v-9.9h-5.3c-2.7 0-6.8 2-7.7 8h-1.7z"/>
|
||||
<linearGradient id="SVGID_8_" x1="209.1" x2="222" y1="35.04" y2="14.54" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#999" offset="0"/>
|
||||
<stop stop-color="#B3B3B3" offset="1"/>
|
||||
</linearGradient>
|
||||
<path class="cls-11" d="m199.1 33.7c0-6.3 3.8-9.1 8.4-9.3h7v10.7l12.2-11.2v-1.5l-12.2-11.7v9.9h-6.5c-3.9 0-8.8 3.5-8.9 9.1v4z"/>
|
||||
<linearGradient id="SVGID_9_" x1="231.8" x2="244" y1="13.96" y2="31.05" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#999" offset="0"/>
|
||||
<stop stop-color="#B3B3B3" offset="1"/>
|
||||
</linearGradient>
|
||||
<path class="cls-12" d="m235.1 34.2c-1.5-0.2-1.4-2.8 0-2.8h6.3c0.5 1.8-0.5 2.8-1.3 2.8h-5zm0-4.2c-0.7 0.1 0-2-1.9-4.2-6.2-7.2 0-14.4 5.3-14.2 4.9 0.1 9.9 7 5.1 13.5-1.2 1.3-1.5 2.4-1.5 4.9h-7z"/>
|
||||
<path class="cls-3" d="m235.9 29.2c0.1-4.1-3.4-4.6-3.4-9.2 0-3.6 3-7.2 5.7-7-3.3-0.7-5.7 2.8-6 6.8-0.1 4.8 3.3 4.9 2.9 9.4h0.8z"/>
|
||||
<path class="cls-2" d="m235.9 32h4.6l-0.3 0.9h-4z"/>
|
||||
<path class="cls-1" d="m254.2 20.6h4.3v2l-1.8 3.2z"/>
|
||||
<text class="cls-13 cls-14" transform="translate(10.43 2.75)">copy</text>
|
||||
<text class="cls-13 cls-14" transform="translate(9.682 5.417)">54x62</text>
|
||||
<text class="cls-13 cls-14" transform="translate(40.36 2.75)">clipboard</text>
|
||||
<text class="cls-13 cls-14" transform="translate(41.86 5.417)">44x63</text>
|
||||
<text class="cls-13 cls-14" transform="translate(75.9 2.75)">hand</text>
|
||||
<text class="cls-13 cls-14" transform="translate(75.27 5.417)">50x61</text>
|
||||
<text class="cls-13 cls-14" transform="translate(109.1 2.75)">brush</text>
|
||||
<text class="cls-13 cls-14" transform="translate(109.1 5.417)">39x63</text>
|
||||
<text class="cls-13 cls-14" transform="translate(141.8 2.75)">trash</text>
|
||||
<text class="cls-13 cls-14" transform="translate(141.6 5.417)">40x62</text>
|
||||
<text class="cls-13 cls-14" transform="translate(175.8 4.167)">undo</text>
|
||||
<text class="cls-13 cls-14" transform="translate(175.4 6.833)">41x41</text>
|
||||
<text class="cls-13 cls-14" transform="translate(209.1 4.167)">redo</text>
|
||||
<text class="cls-13 cls-14" transform="translate(208.3 6.833)">40x40</text>
|
||||
<text class="cls-13 cls-14" transform="translate(240.3 5.667)">lightbulb</text>
|
||||
<text class="cls-13 cls-14" transform="translate(241.6 8.333)">75x67</text>
|
||||
<text class="cls-13 cls-14" transform="translate(8.564 43.08)">selection</text>
|
||||
<text class="cls-13 cls-14" transform="translate(9.898 45.75)">62x73</text>
|
||||
<text class="cls-13 cls-14" transform="translate(42.23 43.08)">group</text>
|
||||
<text class="cls-13 cls-14" transform="translate(41.81 45.58)">55x62</text>
|
||||
<text class="cls-13 cls-14" transform="translate(75.73 43.08)">burst</text>
|
||||
<text class="cls-13 cls-14" transform="translate(75.31 45.58)">49x62</text>
|
||||
<text class="cls-13 cls-14" transform="translate(109.6 43.08)">align</text>
|
||||
<text class="cls-13 cls-14" transform="translate(108.7 45.58)">47x53</text>
|
||||
<text class="cls-13 cls-14" transform="translate(141.1 43.08)">shapes</text>
|
||||
<text class="cls-13 cls-14" transform="translate(141.6 45.58)">44x53</text>
|
||||
<text class="cls-13 cls-14" transform="translate(174.5 43.08)">magnet</text>
|
||||
<text class="cls-13 cls-14" transform="translate(175.3 45.58)">40x63</text>
|
||||
<text class="cls-13 cls-14" transform="translate(208.2 43.33)">eraser</text>
|
||||
<text class="cls-13 cls-14" transform="translate(208.2 45.58)">48x59</text>
|
||||
<text class="cls-13 cls-14" transform="translate(239.7 43.25)">download</text>
|
||||
<text class="cls-13 cls-14" transform="translate(241.6 45.58)">46x56</text>
|
||||
<path class="cls-1" d="m1.6 49.7h2.9v3.4h-2.9v-3.4zm4.5 0.9h13.5v1.5h-13.5v-1.5zm15.3-1h2.8v3.5h-2.8v-3.5zm-19.3 5h1.5v16.5h-1.5v-16.5zm20.3 0h1.5v16.5h-1.5v-16.5zm-1 17.5h3v3.5h-3v-3.5zm-15.5 1.3h14v1.5h-14v-1.5zm-4.2-1.3h2.9v3.5h-2.9v-3.5z"/>
|
||||
<path class="cls-2" d="m2.2 50.4h1.7v2h-1.7z"/>
|
||||
<path class="cls-2" d="m22.2 50.2h1.4v2.2h-1.4z"/>
|
||||
<path class="cls-2" d="m2.2 72.9h1.8v2h-1.8z"/>
|
||||
<path class="cls-2" d="m22.1 72.7h1.6v2.2h-1.6z"/>
|
||||
<path class="cls-1" d="m32.6 50.5v18.2h7.3c2 8.7 14.8 10 18.5 0.8 2-7.1-2.5-12.6-8.3-13.1v-6l-17.5 0.1z"/>
|
||||
<path class="cls-3" d="m33.4 50.9h15.8v5.7c-4.1 0.3-9.1 3.3-9.6 10.3h-6.2v-16z"/>
|
||||
<path class="cls-2" d="m34.4 52.1h13.5v4.5c-3 0.3-7.3 3-7.9 9.8h-5.6v-14.3z"/>
|
||||
<path class="cls-3" d="m35.1 53h12.5v3.6c-2.5-0.2-6.6 2.8-7.5 9.4h-5v-13z"/>
|
||||
<path class="cls-2" d="m41.6 66.4c0-3.7 3.1-7.8 7.4-8.3 5.6 0 8.9 4.3 8.5 8.8-1 9.6-15.9 11.8-15.9-0.5z"/>
|
||||
<path class="cls-3" d="m42 67.1c-0.5-4 2.7-8 7.2-8.4-3.6 0.9-7.1 4-7.2 8.4z"/>
|
||||
<path class="cls-1" d="m67.9 49.9h9.7l0.3 0.5v11.2l-0.8 0.8h-9.2l-0.3-0.4v-11.6z"/>
|
||||
<path class="cls-2" d="m68.5 50.6h8.5v10.3l-0.4 0.5h-8.1l-0.4-0.5z"/>
|
||||
<path class="cls-3" d="m69.1 51.4h7l0.3 0.2v8.8l-0.3 0.2h-7l-0.2-0.2v-8.8z"/>
|
||||
<path class="cls-1" d="m66.6 65.6 5.3-1.5 0.7 1.3-5.4 1.7z"/>
|
||||
<path class="cls-1" d="m70 72.9-0.9-1.3 3.3-3.2 1.3 1z"/>
|
||||
<path class="cls-1" d="m75 75.7-0.5-0.7 0.6-3.4 1.8-0.2-0.5 4.2z"/>
|
||||
<path class="cls-1" d="m85.6 57.6-2-1 3-3.5h1l0.3 1z"/>
|
||||
<path class="cls-1" d="m85.4 60 0.7 1.7 4.8-1.1v-1.6l-0.9-0.1z"/>
|
||||
<path class="cls-1" d="m84.2 63.6c-7.1 0.8-8.6 10.4-1.2 12.1 8.9 0.8 10-12.1 1.2-12.1z"/>
|
||||
<path class="cls-2" d="m84.5 64.9c-5.6 0.2-6.9 8.2-0.4 9.1 6.4 0 6.5-8.9 0.4-9.1z"/>
|
||||
<path class="cls-1" d="m80.6 49.6 1.5 0.5-1 5h-1.7z"/>
|
||||
<path class="cls-2" d="m5.4 54.9h7.8l1 2.2v3.5c-2 0.8-2.6 2.4-3.1 4.5h-4.9l-0.7-0.1-0.5-0.6v-9l0.4-0.5z"/>
|
||||
<path class="cls-3" d="m6.2 55.9h6.8l0.6 1.2 0.1 3.3c-1.3 0.7-2.3 2-2.7 3.7h-4.6l-0.4-0.1-0.3-0.4v-7.2l0.5-0.5z"/>
|
||||
<path class="cls-2" d="m6.4 56.6h6.2l0.5 1 0.1 2.5c-1.2 0.8-2.3 2-2.6 3.5h-4.1l-0.3-0.2-0.2-0.3v-6.1l0.4-0.4z"/>
|
||||
<path class="cls-1" d="m15.4 60c-4.5 0.7-7.3 9.4-0.3 11.6 7.8 0.8 8.8-11.5 0.3-11.6z"/>
|
||||
<path class="cls-3" d="m15.9 61.4c-4.4 0.5-5.8 7.6 0 9 5.6 0 6.7-8.5 0-9z"/>
|
||||
<path class="cls-1" d="m100.1 48.1 1.8-0.2 0.6 0.5v28.7l-1.4 0.8-1-0.5z"/>
|
||||
<path class="cls-2" d="m100.9 48.4h0.7l0.3 28.2-1 0.3z"/>
|
||||
<path class="cls-1" d="m104.6 64.4 0.5-0.5h18.5l0.8 0.7v9.4l-0.9 0.6h-18.1l-0.8-0.5z"/>
|
||||
<path class="cls-2" d="m105.5 64.9h18v8.7h-18z"/>
|
||||
<path class="cls-3" d="m106.4 65.6h16.2l0.3 0.3v6.7l-0.3 0.3h-16.2l-0.3-0.3v-6.7z"/>
|
||||
<path class="cls-1" d="m104.6 51.9 0.9-1.2h13l0.6 0.7v9.2l-0.6 1h-13.1l-0.8-0.7z"/>
|
||||
<path class="cls-2" d="m105.5 51.9h12.6v8.7h-12.6z"/>
|
||||
<path class="cls-3" d="m106.4 52.6h11l0.2 0.4v6.6l-0.2 0.4h-11l-0.3-0.4v-6.6z"/>
|
||||
<path class="cls-0" d="m106.9 53.4h9.8v6h-9.8z"/>
|
||||
<path class="cls-1" d="m142.6 47.6h0.9v27l-0.4 0.3h-11.1l-0.6-1.9z"/>
|
||||
<path class="cls-3" d="m142.1 50v23.6h-9.5z"/>
|
||||
<path class="cls-0" d="m141.1 55.4v17.2h-7.5z"/>
|
||||
<path class="cls-1" d="m146.1 47.6h1l11.5 26-0.5 1.1h-11.6l-0.1-0.6z"/>
|
||||
<path class="cls-2" d="m147.1 49.6 10.4 24h-10.1z"/>
|
||||
<path class="cls-1" d="m172.9 69-2.8-10.3c0-6.7 7.5-12 13.5-7.3 1.8 1.2 3.1 7.7 4.5 13.2 0.5 1.8-2.9 2.5-4.1 2.3-1.4 0-2.6-9.5-4-10.8-1.5-1.5-4.4-0.5-3.6 3l2 8.3-0.5 1.6-3.5 1-1.5-1z"/>
|
||||
<path class="cls-3" d="m173.5 68.4-2.6-9.7c-0.3-6.3 6.6-11.1 12.2-6.7 1.5 1 2.4 5.6 3.8 11.9l-2.7 1.2-2.2-7.7c-1.5-4.8-7.4-3.3-6.4 1.7l1.8 8.5-3.9 0.8z"/>
|
||||
<path class="cls-2" d="m174.1 67.9 1.8-0.5-0.4-2.3h-1.9z"/>
|
||||
<path class="cls-2" d="m184.1 63.4 0.5 2 1.6-0.3-0.5-2.4z"/>
|
||||
<path class="cls-2" d="m172.6 58.7c-0.5-4.8 3-7.3 5.8-7.8-3.3-0.2-6.7 3.1-5.8 7.8z"/>
|
||||
<path class="cls-1" d="m168.6 72 1.8 0.6 0.1 1.4-1.8-0.1z"/>
|
||||
<path class="cls-1" d="m171.1 74 2.4 0.4-0.1 1.3-1.9-0.1z"/>
|
||||
<path class="cls-1" d="m174.9 74 2-0.6 0.6 1.2-2.1 1z"/>
|
||||
<path class="cls-1" d="m177.7 72.6 2.2-1.2 1.2 1-1 1.2-1.9 0.4z"/>
|
||||
<path class="cls-1" d="m181.9 70.9 0.7 1.5 2.3-0.5-0.3-1.5z"/>
|
||||
<path class="cls-1" d="m186.1 70.9 0.5 1.5 2 0.7 0.1-2c-0.6-0.4-1.2-0.6-2.6-0.2z"/>
|
||||
<path class="cls-1" d="m200.1 65.6 3.5-2.5-3-5.2-0.2-1.9 8.3-6 2.8-0.4 3.9 6.4 2.7-1.4 7.8 6.8v2.6l-20.9 12.1h-2.5z"/>
|
||||
<path class="cls-3" d="m201.1 66 3-2 2.9 4.4 10.9-5.8-2.3-4.6 2.8-1.6 6.6 5.3-21.4 13.2z"/>
|
||||
<path class="cls-0" d="m202.4 66.4 2.2-1.4 0.5 0.6-2.5 1.4z"/>
|
||||
<path class="cls-2" d="m203.1 66.7 2.5-1.3 1.5 3.3 5.5-2.7-0.5-1.4 4.8-2.5-2.3-4 3.3-1.1 6.1 5.4-20.1 11.7z"/>
|
||||
<path class="cls-0" d="m216.1 56.6 1.3-0.6 0.5 0.6-1.5 0.5z"/>
|
||||
<path class="cls-0" d="m213.5 64.6 0.6 1.5 0.5-0.2-0.5-1.8z"/>
|
||||
<path class="cls-0" d="m201.5 56.6 8.1-5.2 7 10.6-9.2 5.1z"/>
|
||||
<path class="cls-1" d="m234.1 62.4h2.4v-5.3l1.1-1.1h3l2.1 2.6h1.7l2.7-2.7h2.5l1.9 1.1v5.4h2l2.4 10.6-1.4 2h-20.5-0.4l-0.4 0.1-0.2-0.1h0.1 0.5-0.2-0.3-0.1 0.6l-0.5 0.1-0.1-0.1v0.1l0.6-0.1-0.6 0.1-0.9-1.1v-2zm1.4 6 0.1 0.5h2.5l-0.1 2.7h1.5v-2h3.9v2h1.7l-0.1-2h3.5l0.1 2 1.3-0.2v-1.8l2-0.6v-0.6h1.7l0.4 4h-19.1l0.6-4z"/>
|
||||
<path class="cls-3" d="m235.6 64h1.5v3.6h-1.2l0.2 0.8h16.4v-0.8h-1v-3.6h1.6l1.5 8.9-0.6 0.7h-19.5l-0.6-0.6z"/>
|
||||
<path class="cls-2" d="m235.5 68.4h1.6v0.7l13.5-0.1v-0.6h3l0.4 4-19-0.3z"/>
|
||||
<path class="cls-2" d="m238.9 57.1 2.5 2.3h4.2l2.6-2.4 1.9 0.6 0.3 11.3h-12.2v-11.5z"/>
|
||||
<path class="cls-3" d="m239.6 58 2 1.9h4l2-2.3 1.9 0.5 0.1 9.8-10.6 0.2z"/>
|
||||
<path class="cls-1" d="m240.4 50.2 1.5 1.4h1.7v-4.9h1.9v4.9l1.9-1.5 1.5 0.5-4.4 5.3h-0.9l-3.5-3.5 0.3-2.2z"/>
|
||||
<path class="cls-2" d="m241.4 51.4 1.1 1.2 2.6-0.2 2-1.3-3 3.5h-0.5z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 6.5 KiB |
@@ -0,0 +1,42 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 165 27">
|
||||
<!-- SVG created with Arrow, by QuiverAI (https://quiver.ai) -->
|
||||
<style type="text/css">.cls-0 {fill:#C1C8CD;}
|
||||
.cls-1 {fill:none;stroke:#555E65;stroke-width:1.4;stroke-linecap:round;stroke-linejoin:round;}
|
||||
.cls-2 {fill:#D4D7D9;}
|
||||
.cls-3 {fill:#BDC4C9;}
|
||||
.cls-4 {fill:none;stroke:#555E65;stroke-width:1.4;stroke-linejoin:round;}
|
||||
.cls-5 {fill:#DEDEDE;}
|
||||
.cls-6 {fill:#ABB2B7;}
|
||||
.cls-7 {fill:none;stroke:#555E65;stroke-width:1.4;stroke-linecap:round;stroke-miterlimit:10;}
|
||||
.cls-8 {fill:none;stroke:#555E65;stroke-width:1.4;stroke-miterlimit:10;}
|
||||
.cls-9 {fill:#FFFFFF;stroke:#555E65;stroke-width:1.4;stroke-linecap:round;stroke-linejoin:round;}
|
||||
.cls-10 {fill:#C2C9CE;}
|
||||
.cls-11 {fill:none;stroke:#555E65;stroke-width:1.4;stroke-linecap:round;}</style>
|
||||
<path class="cls-0" d="m18 13.5c-0.5 0-1 0.5-1 1v2.5c0 0.8-0.6 1.5-1.4 1.5h-7.9c-0.7 0-1.3-0.6-1.3-1.4v-2.6c0-0.5-0.5-1-1-1h-2.9c-0.5 0-0.9 0.4-0.9 0.9v8.4c0 1.1 0.9 2 2 2h16.5c1.1 0 2.2-0.8 2.2-1.9v-8.5c0-0.5-0.4-0.9-0.9-0.9h-3.4z"/>
|
||||
<path class="cls-1" d="m18 13.5c-0.5 0-1 0.5-1 1v2.5c0 0.8-0.6 1.5-1.4 1.5h-7.9c-0.7 0-1.3-0.6-1.3-1.4v-2.6c0-0.5-0.5-1-1-1h-2.9c-0.5 0-0.9 0.4-0.9 0.9v8.4c0 1.1 0.9 2 2 2h16.5c1.1 0 2.2-0.8 2.2-1.9v-8.5c0-0.5-0.4-0.9-0.9-0.9h-3.4z"/>
|
||||
<polyline class="cls-1" points="7.7 9.2 11.5 13.3 15.6 9.2"/>
|
||||
<line class="cls-1" x1="11.5" x2="11.5" y1="12.6" y2=".8"/>
|
||||
<path class="cls-0" d="m53.4 13.5c-0.5 0-1 0.5-1 1v2.5c0 0.8-0.6 1.5-1.4 1.5h-8.6c-0.7 0-1.3-0.6-1.3-1.3v-2.7c0-0.5-0.5-1-1-1h-3.5c-0.5 0-1 0.4-1 0.9v8.3c0 1.1 0.9 2.1 2.1 2.1h17.9c1.1 0 2.1-0.8 2.1-1.9v-8.5c0-0.5-0.4-0.9-0.9-0.9h-3.4z"/>
|
||||
<path class="cls-1" d="m53.4 13.5c-0.5 0-1 0.5-1 1v2.5c0 0.8-0.6 1.5-1.4 1.5h-8.6c-0.7 0-1.3-0.6-1.3-1.3v-2.7c0-0.5-0.5-1-1-1h-3.5c-0.5 0-1 0.4-1 0.9v8.3c0 1.1 0.9 2.1 2.1 2.1h17.9c1.1 0 2.1-0.8 2.1-1.9v-8.5c0-0.5-0.4-0.9-0.9-0.9h-3.4z"/>
|
||||
<polyline class="cls-1" points="42.5 4.7 46.6 0.8 50.7 4.7"/>
|
||||
<line class="cls-1" x1="46.6" x2="46.6" y1="13.4" y2="1.5"/>
|
||||
<path class="cls-2" d="m105.9 6.6 10.1-5.1 10.3 4.9 0.1 9.8-10.3 8.6-10.2-4.6v-13.6z"/>
|
||||
<path class="cls-3" d="m116.2 11.6 10.1-5.2 0.1 9.8-10.1 8.6-0.1-13.2z"/>
|
||||
<path class="cls-4" d="m105.9 6.5v13.6l10.2 4.8 3.5-1.6"/>
|
||||
<path class="cls-4" d="m116.2 11.6 10.1-5.2v9.7"/>
|
||||
<path class="cls-4" d="m105.9 6.4 10.2-4.9 10.2 4.9-10.1 5.2-10.3-5.2z"/>
|
||||
<path class="cls-4" d="m116.2 11.6v13"/>
|
||||
<circle class="cls-2" cx="124.3" cy="21.2" r="4.9"/>
|
||||
<path class="cls-8" d="m126.6 16.3c-2.7-0.8-7.4 0.8-7.5 4.8 0 3.4 3 5.5 5.3 5.2 5.2 0 7-6.3 2.2-10z"/>
|
||||
<line class="cls-7" x1="124.3" x2="124.3" y1="18.7" y2="23.5"/>
|
||||
<line class="cls-7" x1="122.1" x2="126.6" y1="21.1" y2="21.1"/>
|
||||
<path class="cls-5" d="m148.2 5.9c-3.3 0.7-6.9 3.3-8.6 6.1-0.5 0.8-0.7 2.4-0.2 3.1 1.5 2.1 3.9 4.6 6.4 5.9 2.6 1.4 6.3 1.5 8.9 0.5 2.8-1.1 6.2-3.2 8.4-6.5 0.2-0.4 0.3-1.7 0-2.1-2.8-3.2-7.6-8.1-14.9-7z"/>
|
||||
<path class="cls-6" d="m155.5 13.9c0 2.2-1.7 4.5-4 4.5-2.2 0-3.9-2.3-3.9-4.5s1.7-4 3.9-4 4 1.8 4 4z"/>
|
||||
<path class="cls-1" d="m160.2 9.1c1.2 1 2.2 2.1 3 3.2 0.6 0.7 0.6 1.8 0 2.6-2.4 3.3-7.1 7.3-11.6 7.4-1.5 0.1-2.9-0.1-3.6-0.4l0.3 0.1h-0.1l-0.8-0.3"/>
|
||||
<path class="cls-1" d="m146.1 20.8c-2.4-1.2-4.8-3.4-6.5-5.6-0.5-0.7-0.5-1.8 0.1-2.5 2.4-2.8 6.3-6.5 11.2-7 2.7-0.2 5.2 0.7 7.3 2.1"/>
|
||||
<path class="cls-1" d="m155.4 12.9c0.1 0.4 0.1 0.8 0.1 1.2-0.1 2.3-1.9 4.2-4.1 4.2-0.3 0-0.6 0-0.8-0.1"/>
|
||||
<path class="cls-1" d="m149.3 17.6c-1.3-0.6-1.9-1.9-1.8-4 0.1-1.9 1.8-4 4.1-4 1.4 0 2.7 0.7 3.4 1.8"/>
|
||||
<line class="cls-11" x1="142.6" x2="162.5" y1="24.7" y2="3.9"/>
|
||||
<path class="cls-10" d="m93.4 12.3-2.5-0.7c-0.2-0.7-0.5-1.5-0.9-2.2l0.9-2.1c0.1-0.3 0.1-0.6-0.1-0.8l-1.6-1.6c-0.2-0.2-0.5-0.3-0.8-0.1l-2 1c-0.7-0.4-1.4-0.7-2.3-1l-0.6-2.4c-0.1-0.3-0.3-0.5-0.6-0.5h-2.5c-0.3 0-0.6 0.2-0.6 0.5l-0.7 2.2c-0.8 0.3-1.6 0.6-2.4 1l-2.1-1c-0.2-0.1-0.5-0.1-0.7 0.1l-1.6 1.6c-0.2 0.2-0.3 0.5-0.1 0.8l1 2.1c-0.4 0.7-0.7 1.4-0.9 2.2l-2.4 0.8c-0.3 0.1-0.5 0.3-0.5 0.6v2.4c0 0.3 0.2 0.6 0.5 0.6l2.5 0.8c0.2 0.7 0.5 1.5 0.9 2.2l-1 2.1c-0.1 0.3-0.1 0.6 0.1 0.8l1.6 1.6c0.2 0.2 0.5 0.2 0.8 0.1l2-1.1c0.7 0.4 1.5 0.7 2.3 1l0.6 2.4c0.1 0.3 0.3 0.5 0.6 0.5h2.5c0.3 0 0.6-0.2 0.6-0.5l0.6-2.3c0.8-0.3 1.6-0.6 2.4-1l2.1 1c0.2 0.1 0.5 0.1 0.7-0.1l1.6-1.6c0.2-0.2 0.3-0.5 0.1-0.8l-1-2.1c0.4-0.7 0.7-1.4 0.9-2.2l2.4-0.8c0.3-0.1 0.5-0.3 0.5-0.6v-2.4c0.1-0.2-0.1-0.4-0.3-0.5zm-11.9 6c-2.2 0-4.2-1.7-4.3-4s1.7-4.5 4.1-4.7c2.3-0.1 4.5 1.6 4.6 4s-1.9 4.7-4.4 4.7z"/>
|
||||
<path class="cls-8" d="m93.3 12.3-2.5-0.8c-0.2-0.8-0.5-1.6-0.9-2.3l0.9-2.1c0.1-0.2 0.1-0.5-0.1-0.7l-1.5-1.7c-0.2-0.2-0.5-0.2-0.7-0.1l-2 1c-0.7-0.4-1.5-0.7-2.5-1l-0.6-2.6c-0.1-0.2-0.3-0.3-0.5-0.3h-2.6c-0.3 0-0.5 0.1-0.6 0.4l-0.6 2.4c-0.8 0.2-1.6 0.6-2.5 1l-2.1-1c-0.2-0.1-0.5-0.1-0.7 0.1l-1.6 1.6c-0.2 0.2-0.2 0.5 0 0.8l1 2.1c-0.4 0.7-0.7 1.4-0.9 2.2l-2.6 0.9c-0.2 0.1-0.3 0.3-0.3 0.5v2.6c0 0.3 0.1 0.5 0.4 0.5l2.5 0.8c0.2 0.8 0.5 1.6 0.9 2.3l-1 2.2c-0.1 0.2-0.1 0.5 0.1 0.7l1.5 1.5c0.2 0.2 0.5 0.3 0.7 0.1l2.1-1.1c0.7 0.4 1.5 0.7 2.4 1l0.6 2.6c0.1 0.2 0.3 0.3 0.5 0.3h2.7c0.2 0 0.5-0.1 0.6-0.4l0.6-2.4c0.8-0.3 1.6-0.6 2.4-1l2.1 1.1c0.2 0.1 0.5 0.1 0.7-0.1l1.6-1.6c0.2-0.2 0.2-0.5 0.1-0.7l-1-2.2c0.4-0.7 0.7-1.5 0.9-2.3l2.5-0.8c0.2-0.1 0.3-0.3 0.3-0.5v-2.6c0-0.1-0.1-0.3-0.3-0.4zm-11.8 6c-2.3 0-4.3-1.8-4.4-4.1-0.2-2.3 1.8-4.6 4.3-4.6 2.3 0 4.3 1.8 4.3 4.1 0 2.4-1.8 4.6-4.2 4.6z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.2 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
@@ -0,0 +1,38 @@
|
||||
import { mkdir, writeFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
const localHosts = new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
||||
|
||||
function sanitizeFileName(value: unknown) {
|
||||
const fallback = `codex-screenshot-${Date.now()}.png`;
|
||||
if (typeof value !== "string") {
|
||||
return fallback;
|
||||
}
|
||||
const cleaned = value.replace(/[^a-z0-9_.-]+/gi, "_").replace(/^_+|_+$/g, "");
|
||||
return cleaned.endsWith(".png") ? cleaned : `${cleaned || fallback}.png`;
|
||||
}
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
return NextResponse.json({ error: "Codex screenshot capture is only available in local development." }, { status: 404 });
|
||||
}
|
||||
|
||||
const host = request.headers.get("host")?.split(":")[0] ?? "";
|
||||
if (!localHosts.has(host)) {
|
||||
return NextResponse.json({ error: "Codex screenshot capture only accepts local requests." }, { status: 403 });
|
||||
}
|
||||
|
||||
const body = (await request.json()) as { dataUrl?: unknown; name?: unknown };
|
||||
if (typeof body.dataUrl !== "string" || !body.dataUrl.startsWith("data:image/png;base64,")) {
|
||||
return NextResponse.json({ error: "Expected a PNG data URL." }, { status: 400 });
|
||||
}
|
||||
|
||||
const bytes = Buffer.from(body.dataUrl.slice("data:image/png;base64,".length), "base64");
|
||||
const directory = path.join(process.cwd(), ".codex", "screenshots");
|
||||
await mkdir(directory, { recursive: true });
|
||||
|
||||
const filePath = path.join(directory, sanitizeFileName(body.name));
|
||||
await writeFile(filePath, bytes);
|
||||
return NextResponse.json({ path: filePath, bytes: bytes.length });
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { promises as fs } from "fs";
|
||||
import path from "path";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
function safeFileName(filename: string) {
|
||||
const base = path.basename(filename).replace(/[<>:"/\\|?*\u0000-\u001f]/g, "_").trim();
|
||||
return base || "download.txt";
|
||||
}
|
||||
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const body = (await request.json()) as { content?: unknown; filename?: unknown; folder?: unknown };
|
||||
if (typeof body.content !== "string" || typeof body.filename !== "string" || typeof body.folder !== "string") {
|
||||
return NextResponse.json({ error: "Invalid download request" }, { status: 400 });
|
||||
}
|
||||
|
||||
const trimmedFolder = body.folder.trim();
|
||||
if (!trimmedFolder) {
|
||||
return NextResponse.json({ error: "Choose a folder first" }, { status: 400 });
|
||||
}
|
||||
|
||||
const targetDirectory = path.isAbsolute(trimmedFolder) ? trimmedFolder : path.join(process.cwd(), trimmedFolder);
|
||||
await fs.mkdir(targetDirectory, { recursive: true });
|
||||
const targetPath = path.join(targetDirectory, safeFileName(body.filename));
|
||||
await fs.writeFile(targetPath, body.content, "utf8");
|
||||
|
||||
return NextResponse.json({ path: targetPath });
|
||||
} catch (error) {
|
||||
return NextResponse.json({ error: error instanceof Error ? error.message : "Could not save file" }, { status: 500 });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
import { promises as fs } from "fs";
|
||||
import path from "path";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
const THUMBNAIL_DIR = path.join(process.cwd(), ".codex", "project-thumbnails");
|
||||
|
||||
function safeProjectId(projectId: string) {
|
||||
const clean = projectId.replace(/[^a-zA-Z0-9_-]/g, "");
|
||||
return clean || null;
|
||||
}
|
||||
|
||||
function thumbnailPath(projectId: string) {
|
||||
const safeId = safeProjectId(projectId);
|
||||
if (!safeId) {
|
||||
return null;
|
||||
}
|
||||
return path.join(THUMBNAIL_DIR, `${safeId}.png`);
|
||||
}
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const projectId = new URL(request.url).searchParams.get("projectId") ?? "";
|
||||
const filePath = thumbnailPath(projectId);
|
||||
if (!filePath) {
|
||||
return new NextResponse("Invalid project id", { status: 400 });
|
||||
}
|
||||
|
||||
try {
|
||||
const image = await fs.readFile(filePath);
|
||||
return new NextResponse(image, {
|
||||
headers: {
|
||||
"Cache-Control": "no-store",
|
||||
"Content-Type": "image/png",
|
||||
},
|
||||
});
|
||||
} catch {
|
||||
return new NextResponse("Thumbnail not found", { status: 404 });
|
||||
}
|
||||
}
|
||||
|
||||
export async function POST(request: Request) {
|
||||
let body: { dataUrl?: unknown; projectId?: unknown };
|
||||
try {
|
||||
body = (await request.json()) as { dataUrl?: unknown; projectId?: unknown };
|
||||
} catch {
|
||||
return NextResponse.json({ error: "Invalid thumbnail request" }, { status: 400 });
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof body.projectId !== "string" || typeof body.dataUrl !== "string") {
|
||||
return NextResponse.json({ error: "Invalid thumbnail request" }, { status: 400 });
|
||||
}
|
||||
|
||||
const filePath = thumbnailPath(body.projectId);
|
||||
const match = body.dataUrl.match(/^data:image\/png;base64,(.+)$/);
|
||||
if (!filePath || !match) {
|
||||
return NextResponse.json({ error: "Invalid thumbnail image" }, { status: 400 });
|
||||
}
|
||||
|
||||
await fs.mkdir(THUMBNAIL_DIR, { recursive: true });
|
||||
await fs.rm(filePath, { force: true });
|
||||
await fs.writeFile(filePath, Buffer.from(match[1], "base64"));
|
||||
|
||||
return NextResponse.json({ version: Date.now() });
|
||||
} catch (error) {
|
||||
return NextResponse.json({ error: error instanceof Error ? error.message : "Could not save thumbnail" }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
export async function DELETE(request: Request) {
|
||||
const projectId = new URL(request.url).searchParams.get("projectId") ?? "";
|
||||
const filePath = thumbnailPath(projectId);
|
||||
if (!filePath) {
|
||||
return NextResponse.json({ error: "Invalid project id" }, { status: 400 });
|
||||
}
|
||||
|
||||
await fs.rm(filePath, { force: true });
|
||||
return NextResponse.json({ deleted: true });
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import type { Metadata } from "next";
|
||||
import "./globals.css";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "SketchForge 3D editor",
|
||||
description: "Browser-based SketchForge editor workspace",
|
||||
icons: {
|
||||
icon: "assets/sketchforge/sketchforge-logo.png",
|
||||
apple: "assets/sketchforge/sketchforge-logo.png",
|
||||
},
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
return (
|
||||
<html lang="en" suppressHydrationWarning>
|
||||
<body suppressHydrationWarning>{children}</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,807 @@
|
||||
"use client";
|
||||
|
||||
import { Clock3, FileUp, Grid3X3, HomeIcon, List, Plus, Search, Settings, SlidersHorizontal, Trash2, X } from "lucide-react";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { SketchForgeEditor, importedShapeFromStl } from "@/components/SketchForgeEditor";
|
||||
import type { WorkplaneShape } from "@/types/sketchforge";
|
||||
|
||||
type AppView = "dashboard" | "editor";
|
||||
type ViewMode = "grid" | "list";
|
||||
type DownloadMode = "browser" | "folder";
|
||||
|
||||
type DashboardProject = {
|
||||
id: string;
|
||||
name: string;
|
||||
createdAt: number;
|
||||
updatedAt: number;
|
||||
shapes: number;
|
||||
accent: "cyan" | "green" | "gold" | "red";
|
||||
thumbnailUrl?: string | null;
|
||||
thumbnailVersion?: number;
|
||||
revision?: number;
|
||||
};
|
||||
|
||||
type StoredDashboardProject = Partial<DashboardProject> & {
|
||||
designShapes?: unknown;
|
||||
};
|
||||
|
||||
type ProjectShapeCacheEntry = {
|
||||
revision: number;
|
||||
shapes: WorkplaneShape[];
|
||||
};
|
||||
|
||||
type ProjectShapeRecord = ProjectShapeCacheEntry & {
|
||||
id: string;
|
||||
updatedAt: number;
|
||||
};
|
||||
|
||||
const PROJECTS_STORAGE_KEY = "sketchForge.projects";
|
||||
const PROJECT_SHAPES_DB_NAME = "sketchForge.projectShapes";
|
||||
const PROJECT_SHAPES_STORE_NAME = "projectShapes";
|
||||
const DOWNLOAD_MODE_STORAGE_KEY = "sketchForge.downloadMode";
|
||||
const DOWNLOAD_FOLDER_STORAGE_KEY = "sketchForge.downloadFolder";
|
||||
const PROJECT_ACCENTS: DashboardProject["accent"][] = ["cyan", "green", "gold", "red"];
|
||||
|
||||
function formatUpdated(timestamp: number) {
|
||||
const age = Date.now() - timestamp;
|
||||
if (age < 60_000) return "Just now";
|
||||
if (age < 3_600_000) return `${Math.max(1, Math.round(age / 60_000))} min ago`;
|
||||
if (age < 86_400_000) return "Today";
|
||||
return new Intl.DateTimeFormat(undefined, { month: "short", day: "numeric" }).format(new Date(timestamp));
|
||||
}
|
||||
|
||||
function openProjectShapesDb() {
|
||||
return new Promise<IDBDatabase>((resolve, reject) => {
|
||||
if (typeof window === "undefined" || !window.indexedDB) {
|
||||
reject(new Error("Project shape storage is unavailable"));
|
||||
return;
|
||||
}
|
||||
|
||||
const request = window.indexedDB.open(PROJECT_SHAPES_DB_NAME, 1);
|
||||
request.onupgradeneeded = () => {
|
||||
const database = request.result;
|
||||
if (!database.objectStoreNames.contains(PROJECT_SHAPES_STORE_NAME)) {
|
||||
database.createObjectStore(PROJECT_SHAPES_STORE_NAME, { keyPath: "id" });
|
||||
}
|
||||
};
|
||||
request.onerror = () => reject(request.error ?? new Error("Could not open project shape storage"));
|
||||
request.onsuccess = () => resolve(request.result);
|
||||
});
|
||||
}
|
||||
|
||||
async function loadProjectShapes(projectId: string) {
|
||||
const database = await openProjectShapesDb();
|
||||
return new Promise<ProjectShapeRecord | null>((resolve, reject) => {
|
||||
const transaction = database.transaction(PROJECT_SHAPES_STORE_NAME, "readonly");
|
||||
const request = transaction.objectStore(PROJECT_SHAPES_STORE_NAME).get(projectId);
|
||||
request.onerror = () => reject(request.error ?? new Error("Could not load project shapes"));
|
||||
request.onsuccess = () => resolve((request.result as ProjectShapeRecord | undefined) ?? null);
|
||||
transaction.oncomplete = () => database.close();
|
||||
transaction.onerror = () => {
|
||||
database.close();
|
||||
reject(transaction.error ?? new Error("Could not load project shapes"));
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
async function saveProjectShapes(projectId: string, shapes: WorkplaneShape[], revision: number) {
|
||||
const database = await openProjectShapesDb();
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
const transaction = database.transaction(PROJECT_SHAPES_STORE_NAME, "readwrite");
|
||||
transaction.objectStore(PROJECT_SHAPES_STORE_NAME).put({ id: projectId, revision, shapes, updatedAt: Date.now() } satisfies ProjectShapeRecord);
|
||||
transaction.oncomplete = () => {
|
||||
database.close();
|
||||
resolve();
|
||||
};
|
||||
transaction.onerror = () => {
|
||||
database.close();
|
||||
reject(transaction.error ?? new Error("Could not save project shapes"));
|
||||
};
|
||||
transaction.onabort = () => {
|
||||
database.close();
|
||||
reject(transaction.error ?? new Error("Could not save project shapes"));
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
async function deleteProjectShapes(projectId: string) {
|
||||
const database = await openProjectShapesDb();
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
const transaction = database.transaction(PROJECT_SHAPES_STORE_NAME, "readwrite");
|
||||
transaction.objectStore(PROJECT_SHAPES_STORE_NAME).delete(projectId);
|
||||
transaction.oncomplete = () => {
|
||||
database.close();
|
||||
resolve();
|
||||
};
|
||||
transaction.onerror = () => {
|
||||
database.close();
|
||||
reject(transaction.error ?? new Error("Could not delete project shapes"));
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function readStoredProjects() {
|
||||
const legacyShapes: Record<string, ProjectShapeCacheEntry> = {};
|
||||
if (typeof window === "undefined") return { projects: [] as DashboardProject[], legacyShapes };
|
||||
try {
|
||||
const parsed = JSON.parse(window.localStorage.getItem(PROJECTS_STORAGE_KEY) ?? "[]") as StoredDashboardProject[];
|
||||
const projects = parsed
|
||||
.filter((project) => typeof project.id === "string" && typeof project.name === "string")
|
||||
.map((project, index) => {
|
||||
const id = project.id as string;
|
||||
const updatedAt = typeof project.updatedAt === "number" ? project.updatedAt : Date.now();
|
||||
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 };
|
||||
}
|
||||
return {
|
||||
id,
|
||||
name: project.name as string,
|
||||
createdAt: typeof project.createdAt === "number" ? project.createdAt : Date.now(),
|
||||
updatedAt,
|
||||
shapes: typeof project.shapes === "number" ? project.shapes : (designShapes?.length ?? 0),
|
||||
accent: PROJECT_ACCENTS.includes(project.accent as DashboardProject["accent"]) ? (project.accent as DashboardProject["accent"]) : PROJECT_ACCENTS[index % PROJECT_ACCENTS.length],
|
||||
thumbnailUrl: typeof project.thumbnailUrl === "string" ? project.thumbnailUrl : null,
|
||||
thumbnailVersion: typeof project.thumbnailVersion === "number" ? project.thumbnailVersion : undefined,
|
||||
revision,
|
||||
};
|
||||
});
|
||||
return { projects, legacyShapes };
|
||||
} catch {
|
||||
return { projects: [], legacyShapes };
|
||||
}
|
||||
}
|
||||
|
||||
function readProjects() {
|
||||
return readStoredProjects().projects;
|
||||
}
|
||||
|
||||
function mergeProjectForStorage(project: DashboardProject, storedProject?: DashboardProject) {
|
||||
if (!storedProject) {
|
||||
return project;
|
||||
}
|
||||
const projectRevision = project.revision ?? 0;
|
||||
const storedRevision = storedProject.revision ?? 0;
|
||||
if (storedRevision <= projectRevision) {
|
||||
return project;
|
||||
}
|
||||
return {
|
||||
...project,
|
||||
revision: storedProject.revision,
|
||||
shapes: storedProject.shapes || project.shapes,
|
||||
thumbnailUrl: project.thumbnailUrl ?? storedProject.thumbnailUrl,
|
||||
thumbnailVersion: project.thumbnailVersion ?? storedProject.thumbnailVersion,
|
||||
updatedAt: Math.max(project.updatedAt, storedProject.updatedAt),
|
||||
};
|
||||
}
|
||||
|
||||
function projectForStorage(project: DashboardProject): DashboardProject {
|
||||
return {
|
||||
id: project.id,
|
||||
name: project.name,
|
||||
createdAt: project.createdAt,
|
||||
updatedAt: project.updatedAt,
|
||||
shapes: project.shapes,
|
||||
accent: project.accent,
|
||||
thumbnailUrl: project.thumbnailUrl ?? null,
|
||||
thumbnailVersion: project.thumbnailVersion,
|
||||
revision: project.revision,
|
||||
};
|
||||
}
|
||||
|
||||
function mergeProjectsForStorage(projects: DashboardProject[]) {
|
||||
const storedProjects = readProjects();
|
||||
const storedById = new Map(storedProjects.map((project) => [project.id, project]));
|
||||
return projects.map((project) => projectForStorage(mergeProjectForStorage(project, storedById.get(project.id))));
|
||||
}
|
||||
|
||||
function newProject(name: string, index: number, shapeCount = 0): DashboardProject {
|
||||
const now = Date.now();
|
||||
return {
|
||||
id: crypto.randomUUID(),
|
||||
name,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
shapes: shapeCount,
|
||||
accent: PROJECT_ACCENTS[index % PROJECT_ACCENTS.length],
|
||||
revision: now,
|
||||
};
|
||||
}
|
||||
|
||||
function projectNameFromFileName(fileName: string) {
|
||||
return fileName.replace(/\.[^.]+$/, "").trim() || "Imported STL design";
|
||||
}
|
||||
|
||||
export default function Home() {
|
||||
const [mounted, setMounted] = useState(false);
|
||||
const [view, setView] = useState<AppView>("dashboard");
|
||||
const [editorStarted, setEditorStarted] = useState(false);
|
||||
const [activeProjectId, setActiveProjectId] = useState<string | null>(null);
|
||||
const [projects, setProjects] = useState<DashboardProject[]>([]);
|
||||
const [query, setQuery] = useState("");
|
||||
const [viewMode, setViewMode] = useState<ViewMode>("grid");
|
||||
const [sortMode, setSortMode] = useState("recent");
|
||||
const [settingsOpen, setSettingsOpen] = useState(false);
|
||||
const [downloadMode, setDownloadMode] = useState<DownloadMode>("browser");
|
||||
const [downloadFolder, setDownloadFolder] = useState("");
|
||||
const [dashboardNotice, setDashboardNotice] = useState("");
|
||||
const [projectShapesById, setProjectShapesById] = useState<Record<string, ProjectShapeCacheEntry>>({});
|
||||
const projectsJsonRef = useRef("");
|
||||
const dashboardStlInputRef = useRef<HTMLInputElement | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const { projects: storedProjects, legacyShapes } = readStoredProjects();
|
||||
setProjects(storedProjects);
|
||||
if (Object.keys(legacyShapes).length > 0) {
|
||||
setProjectShapesById(legacyShapes);
|
||||
Object.entries(legacyShapes).forEach(([projectId, entry]) => {
|
||||
void saveProjectShapes(projectId, entry.shapes, entry.revision).catch(() => {
|
||||
setDashboardNotice("Could not migrate project shapes to larger storage");
|
||||
});
|
||||
});
|
||||
}
|
||||
setDownloadMode(window.localStorage.getItem(DOWNLOAD_MODE_STORAGE_KEY) === "folder" ? "folder" : "browser");
|
||||
setDownloadFolder(window.localStorage.getItem(DOWNLOAD_FOLDER_STORAGE_KEY) ?? "");
|
||||
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
if (params.has("codexBooleanCase") || params.get("editor") === "1") {
|
||||
const requestedProjectId = params.get("project");
|
||||
if (requestedProjectId && storedProjects.some((project) => project.id === requestedProjectId)) {
|
||||
setActiveProjectId(requestedProjectId);
|
||||
}
|
||||
setEditorStarted(true);
|
||||
setView("editor");
|
||||
}
|
||||
setMounted(true);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!mounted) return;
|
||||
const localSerialized = JSON.stringify(projects);
|
||||
const storageProjects = mergeProjectsForStorage(projects);
|
||||
const serialized = JSON.stringify(storageProjects);
|
||||
if (projectsJsonRef.current === serialized) return;
|
||||
try {
|
||||
window.localStorage.setItem(PROJECTS_STORAGE_KEY, serialized);
|
||||
} catch (error) {
|
||||
try {
|
||||
window.localStorage.removeItem(PROJECTS_STORAGE_KEY);
|
||||
window.localStorage.setItem(PROJECTS_STORAGE_KEY, serialized);
|
||||
} catch {
|
||||
setDashboardNotice(error instanceof Error ? error.message : "Could not save project list");
|
||||
return;
|
||||
}
|
||||
}
|
||||
projectsJsonRef.current = serialized;
|
||||
if (serialized !== localSerialized) {
|
||||
setProjects(storageProjects);
|
||||
}
|
||||
}, [mounted, projects]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!mounted) return;
|
||||
const onStorage = (event: StorageEvent) => {
|
||||
if (event.key !== PROJECTS_STORAGE_KEY) return;
|
||||
projectsJsonRef.current = event.newValue ?? "[]";
|
||||
setProjects(readProjects());
|
||||
};
|
||||
window.addEventListener("storage", onStorage);
|
||||
return () => window.removeEventListener("storage", onStorage);
|
||||
}, [mounted]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!activeProjectId) return;
|
||||
if (projects.some((project) => project.id === activeProjectId)) return;
|
||||
setActiveProjectId(null);
|
||||
setView("dashboard");
|
||||
if (typeof window !== "undefined") {
|
||||
window.history.replaceState(null, "", "/");
|
||||
}
|
||||
}, [activeProjectId, projects]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!mounted || !activeProjectId) return;
|
||||
const activeProject = projects.find((project) => project.id === activeProjectId);
|
||||
if (!activeProject) return;
|
||||
const cached = projectShapesById[activeProjectId];
|
||||
if (cached && cached.revision === activeProject.revision) return;
|
||||
|
||||
let canceled = false;
|
||||
void loadProjectShapes(activeProjectId)
|
||||
.then((record) => {
|
||||
if (canceled) return;
|
||||
const revision = activeProject.revision ?? record?.revision ?? Date.now();
|
||||
setProjectShapesById((current) => ({
|
||||
...current,
|
||||
[activeProjectId]: {
|
||||
revision,
|
||||
shapes: record?.shapes ?? [],
|
||||
},
|
||||
}));
|
||||
})
|
||||
.catch((error) => {
|
||||
if (!canceled) {
|
||||
setDashboardNotice(error instanceof Error ? error.message : "Could not load project shapes");
|
||||
setProjectShapesById((current) => ({
|
||||
...current,
|
||||
[activeProjectId]: {
|
||||
revision: activeProject.revision ?? Date.now(),
|
||||
shapes: [],
|
||||
},
|
||||
}));
|
||||
}
|
||||
});
|
||||
return () => {
|
||||
canceled = true;
|
||||
};
|
||||
}, [activeProjectId, mounted, projectShapesById, projects]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!mounted) return;
|
||||
window.localStorage.setItem(DOWNLOAD_MODE_STORAGE_KEY, downloadMode);
|
||||
window.localStorage.setItem(DOWNLOAD_FOLDER_STORAGE_KEY, downloadFolder);
|
||||
}, [downloadFolder, downloadMode, mounted]);
|
||||
|
||||
const visibleProjects = useMemo(() => {
|
||||
const normalizedQuery = query.trim().toLowerCase();
|
||||
const filtered = normalizedQuery ? projects.filter((project) => project.name.toLowerCase().includes(normalizedQuery)) : projects;
|
||||
return sortMode === "name" ? [...filtered].sort((a, b) => a.name.localeCompare(b.name)) : [...filtered].sort((a, b) => b.updatedAt - a.updatedAt);
|
||||
}, [projects, query, sortMode]);
|
||||
|
||||
const openEditor = (projectId: string | null, options: { allowMissingFromStorage?: boolean } = {}) => {
|
||||
if (projectId && typeof window !== "undefined" && !options.allowMissingFromStorage) {
|
||||
const storedProjects = readProjects();
|
||||
const storedProject = storedProjects.find((project) => project.id === projectId);
|
||||
if (!storedProject) {
|
||||
setProjects(storedProjects);
|
||||
setActiveProjectId(null);
|
||||
setView("dashboard");
|
||||
window.history.replaceState(null, "", "/");
|
||||
return;
|
||||
}
|
||||
setProjects(storedProjects.map((project) => (project.id === projectId ? { ...project, updatedAt: Date.now() } : project)));
|
||||
} else if (projectId) {
|
||||
setProjects((current) => current.map((project) => (project.id === projectId ? { ...project, updatedAt: Date.now() } : project)));
|
||||
}
|
||||
setActiveProjectId(projectId);
|
||||
setEditorStarted(true);
|
||||
setView("editor");
|
||||
if (typeof window !== "undefined") {
|
||||
const nextUrl = projectId ? `/?editor=1&project=${encodeURIComponent(projectId)}` : "/?editor=1";
|
||||
window.history.replaceState(null, "", nextUrl);
|
||||
}
|
||||
};
|
||||
|
||||
const updateProjectSnapshot = useCallback((snapshot: { image: string; projectId: string; shapes: number }) => {
|
||||
const version = Date.now();
|
||||
setProjects((current) =>
|
||||
current.map((project) => (project.id === snapshot.projectId ? { ...project, shapes: snapshot.shapes, updatedAt: version } : project)),
|
||||
);
|
||||
void fetch("/api/project-thumbnail", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ dataUrl: snapshot.image, projectId: snapshot.projectId }),
|
||||
})
|
||||
.then((response) => (response.ok ? response.json() : null))
|
||||
.then((payload: { version?: number } | null) => {
|
||||
const nextVersion = payload?.version ?? Date.now();
|
||||
const thumbnailUrl = `/api/project-thumbnail?projectId=${encodeURIComponent(snapshot.projectId)}&v=${nextVersion}`;
|
||||
setProjects((current) =>
|
||||
current.map((project) =>
|
||||
project.id === snapshot.projectId
|
||||
? { ...project, shapes: snapshot.shapes, thumbnailUrl, thumbnailVersion: nextVersion, updatedAt: nextVersion }
|
||||
: project,
|
||||
),
|
||||
);
|
||||
})
|
||||
.catch(() => {
|
||||
setProjects((current) =>
|
||||
current.map((project) => (project.id === snapshot.projectId ? { ...project, shapes: snapshot.shapes, updatedAt: version } : project)),
|
||||
);
|
||||
});
|
||||
}, []);
|
||||
|
||||
const updateProjectShapes = useCallback((snapshot: { projectId: string; shapes: WorkplaneShape[] }) => {
|
||||
const revision = Date.now();
|
||||
setProjectShapesById((current) => ({
|
||||
...current,
|
||||
[snapshot.projectId]: { revision, shapes: snapshot.shapes },
|
||||
}));
|
||||
void saveProjectShapes(snapshot.projectId, snapshot.shapes, revision)
|
||||
.then(() => {
|
||||
setProjects((current) =>
|
||||
current.map((project) =>
|
||||
project.id === snapshot.projectId
|
||||
? { ...project, shapes: snapshot.shapes.length, updatedAt: revision, revision }
|
||||
: project,
|
||||
),
|
||||
);
|
||||
})
|
||||
.catch((error) => {
|
||||
setDashboardNotice(error instanceof Error ? error.message : "Could not save project shapes");
|
||||
});
|
||||
}, []);
|
||||
|
||||
const createAndOpenProject = (name?: string) => {
|
||||
const project = newProject(name ?? `Untitled design ${projects.length + 1}`, projects.length);
|
||||
setProjectShapesById((current) => ({
|
||||
...current,
|
||||
[project.id]: { revision: project.revision ?? project.updatedAt, shapes: [] },
|
||||
}));
|
||||
void saveProjectShapes(project.id, [], project.revision ?? project.updatedAt).catch(() => {
|
||||
setDashboardNotice("Could not prepare project shape storage");
|
||||
});
|
||||
setProjects((current) => [project, ...current]);
|
||||
openEditor(project.id, { allowMissingFromStorage: true });
|
||||
};
|
||||
|
||||
const importStlFileFromDashboard = useCallback(
|
||||
async (file: File) => {
|
||||
const extension = file.name.split(".").pop()?.toLowerCase();
|
||||
if (extension !== "stl") {
|
||||
setDashboardNotice("Unsupported file type. Use STL.");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const shape = 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);
|
||||
setProjectShapesById((current) => ({
|
||||
...current,
|
||||
[project.id]: { revision, shapes: [shape] },
|
||||
}));
|
||||
setDashboardNotice(`Imported ${file.name}`);
|
||||
setProjects((current) => [project, ...current]);
|
||||
openEditor(project.id, { allowMissingFromStorage: true });
|
||||
} catch (error) {
|
||||
setDashboardNotice(error instanceof Error ? error.message : `Could not import ${file.name}`);
|
||||
}
|
||||
},
|
||||
[projects.length],
|
||||
);
|
||||
|
||||
const openLatestProject = () => {
|
||||
const latest = [...projects].sort((a, b) => b.updatedAt - a.updatedAt)[0];
|
||||
if (latest) {
|
||||
openEditor(latest.id);
|
||||
return;
|
||||
}
|
||||
createAndOpenProject();
|
||||
};
|
||||
|
||||
const openDashboard = () => {
|
||||
if (activeProjectId) {
|
||||
setProjects((current) => current.map((project) => (project.id === activeProjectId ? { ...project, updatedAt: Date.now() } : project)));
|
||||
}
|
||||
setView("dashboard");
|
||||
if (typeof window !== "undefined") {
|
||||
window.history.replaceState(null, "", "/");
|
||||
}
|
||||
};
|
||||
|
||||
const deleteProject = (projectId: string) => {
|
||||
setProjects((current) => current.filter((project) => project.id !== projectId));
|
||||
setProjectShapesById((current) => {
|
||||
const next = { ...current };
|
||||
delete next[projectId];
|
||||
return next;
|
||||
});
|
||||
if (activeProjectId === projectId) {
|
||||
setActiveProjectId(null);
|
||||
}
|
||||
void fetch(`/api/project-thumbnail?projectId=${encodeURIComponent(projectId)}`, { method: "DELETE" });
|
||||
void deleteProjectShapes(projectId).catch(() => {
|
||||
setDashboardNotice("Could not delete project shapes from local storage");
|
||||
});
|
||||
};
|
||||
|
||||
if (!mounted) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const activeProject = activeProjectId ? projects.find((project) => project.id === activeProjectId) ?? null : null;
|
||||
const activeProjectShapeEntry = activeProjectId ? projectShapesById[activeProjectId] : null;
|
||||
const canRenderEditor = !activeProjectId || (Boolean(activeProject) && Boolean(activeProjectShapeEntry));
|
||||
const projectDebugSummary = projects.map((project) => ({
|
||||
id: project.id,
|
||||
revision: project.revision,
|
||||
shapes: project.shapes,
|
||||
designShapes: projectShapesById[project.id]?.shapes.length ?? null,
|
||||
thumbnail: Boolean(project.thumbnailUrl),
|
||||
}));
|
||||
|
||||
return (
|
||||
<>
|
||||
<pre data-codex-projects hidden>
|
||||
{JSON.stringify(projectDebugSummary)}
|
||||
</pre>
|
||||
<input
|
||||
ref={dashboardStlInputRef}
|
||||
className="hidden-file-input"
|
||||
type="file"
|
||||
accept=".stl"
|
||||
onChange={(event) => {
|
||||
const file = event.currentTarget.files?.[0];
|
||||
if (file) {
|
||||
void importStlFileFromDashboard(file);
|
||||
}
|
||||
event.currentTarget.value = "";
|
||||
}}
|
||||
/>
|
||||
{view === "dashboard" ? (
|
||||
<Dashboard
|
||||
dashboardNotice={dashboardNotice}
|
||||
downloadFolder={downloadFolder}
|
||||
downloadMode={downloadMode}
|
||||
projects={visibleProjects}
|
||||
query={query}
|
||||
settingsOpen={settingsOpen}
|
||||
sortMode={sortMode}
|
||||
viewMode={viewMode}
|
||||
onCloseSettings={() => setSettingsOpen(false)}
|
||||
onCreate={() => createAndOpenProject()}
|
||||
onDeleteProject={deleteProject}
|
||||
onDownloadFolderChange={setDownloadFolder}
|
||||
onDownloadModeChange={setDownloadMode}
|
||||
onImportStl={() => dashboardStlInputRef.current?.click()}
|
||||
onOpenProject={openEditor}
|
||||
onOpenSettings={() => setSettingsOpen(true)}
|
||||
onQueryChange={setQuery}
|
||||
onSortModeChange={setSortMode}
|
||||
onViewModeChange={setViewMode}
|
||||
onWorkspace={openLatestProject}
|
||||
/>
|
||||
) : null}
|
||||
{editorStarted && canRenderEditor ? (
|
||||
<div className={view === "editor" ? "editor-stage active" : "editor-stage"} aria-hidden={view !== "editor"}>
|
||||
<SketchForgeEditor
|
||||
initialShapes={activeProjectShapeEntry?.shapes ?? []}
|
||||
onHome={openDashboard}
|
||||
onProjectShapesChange={updateProjectShapes}
|
||||
onProjectSnapshot={updateProjectSnapshot}
|
||||
projectId={activeProjectId}
|
||||
projectRevision={activeProjectShapeEntry?.revision ?? activeProject?.revision ?? 0}
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function Dashboard({
|
||||
dashboardNotice,
|
||||
downloadFolder,
|
||||
downloadMode,
|
||||
projects,
|
||||
query,
|
||||
settingsOpen,
|
||||
sortMode,
|
||||
viewMode,
|
||||
onCloseSettings,
|
||||
onCreate,
|
||||
onDeleteProject,
|
||||
onDownloadFolderChange,
|
||||
onDownloadModeChange,
|
||||
onImportStl,
|
||||
onOpenProject,
|
||||
onOpenSettings,
|
||||
onQueryChange,
|
||||
onSortModeChange,
|
||||
onViewModeChange,
|
||||
onWorkspace,
|
||||
}: {
|
||||
dashboardNotice: string;
|
||||
downloadFolder: string;
|
||||
downloadMode: DownloadMode;
|
||||
projects: DashboardProject[];
|
||||
query: string;
|
||||
settingsOpen: boolean;
|
||||
sortMode: string;
|
||||
viewMode: ViewMode;
|
||||
onCloseSettings: () => void;
|
||||
onCreate: () => void;
|
||||
onDeleteProject: (projectId: string) => void;
|
||||
onDownloadFolderChange: (value: string) => void;
|
||||
onDownloadModeChange: (value: DownloadMode) => void;
|
||||
onImportStl: () => void;
|
||||
onOpenProject: (projectId: string) => void;
|
||||
onOpenSettings: () => void;
|
||||
onQueryChange: (value: string) => void;
|
||||
onSortModeChange: (value: string) => void;
|
||||
onViewModeChange: (value: ViewMode) => void;
|
||||
onWorkspace: () => void;
|
||||
}) {
|
||||
const [projectPendingDeleteId, setProjectPendingDeleteId] = useState<string | null>(null);
|
||||
const projectPendingDelete = projects.find((project) => project.id === projectPendingDeleteId) ?? null;
|
||||
|
||||
useEffect(() => {
|
||||
if (!projectPendingDeleteId) return;
|
||||
if (projects.some((project) => project.id === projectPendingDeleteId)) return;
|
||||
setProjectPendingDeleteId(null);
|
||||
}, [projectPendingDeleteId, projects]);
|
||||
|
||||
const confirmProjectDelete = () => {
|
||||
if (!projectPendingDelete) return;
|
||||
onDeleteProject(projectPendingDelete.id);
|
||||
setProjectPendingDeleteId(null);
|
||||
};
|
||||
|
||||
return (
|
||||
<main className="dashboard-shell">
|
||||
<header className="dashboard-topbar">
|
||||
<button className="dashboard-brand" type="button" aria-label="Home">
|
||||
<img src="assets/sketchforge/sketchforge-logo.png" alt="" />
|
||||
<span>SketchForge</span>
|
||||
</button>
|
||||
<div className="dashboard-search">
|
||||
<Search size={18} strokeWidth={2.4} />
|
||||
<input value={query} onChange={(event) => onQueryChange(event.currentTarget.value)} placeholder="Search projects" aria-label="Search projects" />
|
||||
</div>
|
||||
<button className="dashboard-primary" type="button" onClick={onCreate}>
|
||||
<Plus size={20} strokeWidth={2.6} />
|
||||
<span>Create</span>
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div className="dashboard-layout">
|
||||
<aside className="dashboard-sidebar">
|
||||
<div className="dashboard-nav-stack">
|
||||
<button className="dashboard-nav-item active" type="button" aria-label="Home" title="Home">
|
||||
<HomeIcon size={20} />
|
||||
<span>Home</span>
|
||||
</button>
|
||||
</div>
|
||||
<button className="dashboard-nav-item dashboard-settings-button" type="button" aria-label="Download settings" title="Download settings" onClick={onOpenSettings}>
|
||||
<Settings size={20} />
|
||||
<span>Settings</span>
|
||||
</button>
|
||||
</aside>
|
||||
|
||||
<section className="dashboard-main" aria-label="Dashboard">
|
||||
<div className="dashboard-actions-band">
|
||||
<button className="dashboard-action-tile create" type="button" onClick={onCreate}>
|
||||
<span className="dashboard-action-icon">
|
||||
<Plus size={25} strokeWidth={2.8} />
|
||||
</span>
|
||||
<span>Create new 3D design</span>
|
||||
</button>
|
||||
<button className="dashboard-action-tile" type="button" onClick={onImportStl}>
|
||||
<span className="dashboard-action-icon">
|
||||
<FileUp size={24} strokeWidth={2.4} />
|
||||
</span>
|
||||
<span>Import STL</span>
|
||||
</button>
|
||||
<button className="dashboard-action-tile" type="button" onClick={onWorkspace}>
|
||||
<span className="dashboard-action-icon">
|
||||
<Clock3 size={24} strokeWidth={2.4} />
|
||||
</span>
|
||||
<span>Continue workplane</span>
|
||||
</button>
|
||||
</div>
|
||||
{dashboardNotice ? (
|
||||
<div className="dashboard-import-notice" role="status">
|
||||
{dashboardNotice}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div className="dashboard-section-header">
|
||||
<div>
|
||||
<h1>Projects</h1>
|
||||
<span>{projects.length} visible</span>
|
||||
</div>
|
||||
<div className="dashboard-controls">
|
||||
<label className="dashboard-select">
|
||||
<SlidersHorizontal size={17} />
|
||||
<select value={sortMode} onChange={(event) => onSortModeChange(event.currentTarget.value)} aria-label="Sort projects">
|
||||
<option value="recent">Recent</option>
|
||||
<option value="name">Name</option>
|
||||
</select>
|
||||
</label>
|
||||
<div className="dashboard-segmented" aria-label="Project view">
|
||||
<button className={viewMode === "grid" ? "active" : ""} type="button" aria-label="Grid view" onClick={() => onViewModeChange("grid")}>
|
||||
<Grid3X3 size={17} />
|
||||
</button>
|
||||
<button className={viewMode === "list" ? "active" : ""} type="button" aria-label="List view" onClick={() => onViewModeChange("list")}>
|
||||
<List size={18} />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{projects.length > 0 ? (
|
||||
<div className={viewMode === "grid" ? "project-grid" : "project-list"}>
|
||||
{projects.map((project) => (
|
||||
<article className="project-card" key={project.id}>
|
||||
<button className="project-card-open" type="button" onClick={() => onOpenProject(project.id)}>
|
||||
<ProjectPreview accent={project.accent} thumbnailUrl={project.thumbnailUrl} />
|
||||
<span className="project-card-title">{project.name}</span>
|
||||
<span className="project-card-meta">
|
||||
{formatUpdated(project.updatedAt)} - {project.shapes} shapes
|
||||
</span>
|
||||
</button>
|
||||
<button className="project-delete" type="button" aria-label={`Delete ${project.name}`} title="Delete project" onClick={() => setProjectPendingDeleteId(project.id)}>
|
||||
<Trash2 size={17} strokeWidth={2.4} />
|
||||
</button>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className="project-empty">
|
||||
<strong>No projects yet</strong>
|
||||
<span>Create a 3D design and it will appear here.</span>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
|
||||
{projectPendingDelete ? (
|
||||
<section className="dashboard-confirm-overlay" role="dialog" aria-modal="true" aria-labelledby="delete-project-title">
|
||||
<div className="dashboard-confirm-dialog">
|
||||
<header>
|
||||
<strong id="delete-project-title">Delete project?</strong>
|
||||
<button type="button" aria-label="Cancel project deletion" onClick={() => setProjectPendingDeleteId(null)}>
|
||||
<X size={18} />
|
||||
</button>
|
||||
</header>
|
||||
<p>
|
||||
Do you actually want the project <span>{projectPendingDelete.name}</span> to be deleted?
|
||||
</p>
|
||||
<div className="dashboard-confirm-actions">
|
||||
<button className="dashboard-confirm-cancel" type="button" onClick={() => setProjectPendingDeleteId(null)}>
|
||||
Cancel
|
||||
</button>
|
||||
<button className="dashboard-confirm-delete" type="button" onClick={confirmProjectDelete}>
|
||||
Delete
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
) : null}
|
||||
|
||||
{settingsOpen ? (
|
||||
<section className="dashboard-settings-panel" role="dialog" aria-modal="true" aria-label="Download settings">
|
||||
<header>
|
||||
<strong>Download settings</strong>
|
||||
<button type="button" aria-label="Close download settings" onClick={onCloseSettings}>
|
||||
<X size={18} />
|
||||
</button>
|
||||
</header>
|
||||
<label className="dashboard-setting-row">
|
||||
<span>Save method</span>
|
||||
<select value={downloadMode} onChange={(event) => onDownloadModeChange(event.currentTarget.value === "folder" ? "folder" : "browser")}>
|
||||
<option value="browser">Browser downloads</option>
|
||||
<option value="folder">Save to folder</option>
|
||||
</select>
|
||||
</label>
|
||||
<label className="dashboard-setting-row">
|
||||
<span>Folder path</span>
|
||||
<input
|
||||
disabled={downloadMode !== "folder"}
|
||||
value={downloadFolder}
|
||||
onChange={(event) => onDownloadFolderChange(event.currentTarget.value)}
|
||||
placeholder="C:\\Users\\spiro\\Downloads"
|
||||
/>
|
||||
</label>
|
||||
</section>
|
||||
) : null}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
function ProjectPreview({ accent, thumbnailUrl }: { accent: DashboardProject["accent"]; thumbnailUrl?: string | null }) {
|
||||
return (
|
||||
<span className={`project-preview accent-${accent}`} aria-hidden="true">
|
||||
{thumbnailUrl ? (
|
||||
<img className="project-thumbnail-image" src={thumbnailUrl} alt="" />
|
||||
) : (
|
||||
<>
|
||||
<span className="preview-grid" />
|
||||
<span className="preview-empty-mark">No snapshot yet</span>
|
||||
</>
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
"use client";
|
||||
|
||||
import { ChevronDown, Search } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { NotesToolIcon, RulerToolIcon, WorkplaneToolIcon } from "./icons";
|
||||
import type { ShapeAsset } from "@/types/sketchforge";
|
||||
|
||||
const categories = [
|
||||
"Your Creations",
|
||||
"Favorites",
|
||||
"Basic Shapes",
|
||||
"Letters & Numbers",
|
||||
"Design Starters",
|
||||
"Creatures & Characters",
|
||||
"Vehicles & Machines",
|
||||
"Structures & Scenery",
|
||||
"Hardware",
|
||||
"Electronics",
|
||||
"Fun & Games",
|
||||
"Everyday Objects",
|
||||
"Featured Collections",
|
||||
"Sim Lab",
|
||||
"Shape Generators",
|
||||
];
|
||||
|
||||
const shapes: ShapeAsset[] = [
|
||||
{ id: "box-hole", name: "Box", src: "assets/sketchforge/box-hole.png", kind: "box", color: "#b8c2cc", hole: true },
|
||||
{ id: "cylinder-hole", name: "Cylinder", src: "assets/sketchforge/cylinder-hole.png", kind: "cylinder", color: "#b8c2cc", hole: true },
|
||||
{ id: "sphere-hole", name: "Sphere", src: "assets/sketchforge/sphere-hole.png", kind: "sphere", color: "#b8c2cc", hole: true },
|
||||
{ id: "box-red", name: "Box", src: "assets/sketchforge/box-red.png", kind: "box", color: "#d41721" },
|
||||
{ id: "cylinder-orange", name: "Cylinder", src: "assets/sketchforge/cylinder-orange.png", kind: "cylinder", color: "#d97813" },
|
||||
{ id: "sphere-blue", name: "Sphere", src: "assets/sketchforge/sphere-blue.png", kind: "sphere", color: "#0098c7" },
|
||||
{ id: "cone-purple", name: "Cone", src: "assets/sketchforge/cone-purple.png", kind: "cone", color: "#6e2786" },
|
||||
{ id: "pyramid-yellow", name: "Pyramid", src: "assets/sketchforge/pyramid-yellow.png", kind: "pyramid", color: "#f2cf10" },
|
||||
{ id: "roof-green", name: "Roof", src: "assets/sketchforge/roof-green.png", kind: "roof", color: "#33983d" },
|
||||
{ id: "text-red", name: "Text", src: "assets/sketchforge/text-red.png", kind: "text", color: "#cf101b" },
|
||||
{ id: "round-roof-cyan", name: "Round Roof", src: "assets/sketchforge/round-roof-cyan.png", kind: "roundRoof", color: "#67c4ce" },
|
||||
{ id: "half-sphere-pink", name: "Half Sphere", src: "assets/sketchforge/half-sphere-pink.png", kind: "halfSphere", color: "#c9009a" },
|
||||
{ id: "torus-blue", name: "Torus", src: "assets/sketchforge/torus-blue.png", kind: "torus", color: "#0098c7" },
|
||||
{ id: "tube-orange", name: "Tube", src: "assets/sketchforge/tube-orange.png", kind: "tube", color: "#ce7013" },
|
||||
{ id: "ring-brown", name: "Ring", src: "assets/sketchforge/ring-brown.png", kind: "ring", color: "#8a5a2b" },
|
||||
];
|
||||
|
||||
type ShapesSidebarProps = {
|
||||
onAddShape: (shape: ShapeAsset) => void;
|
||||
};
|
||||
|
||||
export function ShapesSidebar({ onAddShape }: ShapesSidebarProps) {
|
||||
const [categoryOpen, setCategoryOpen] = useState(false);
|
||||
const [searchOpen, setSearchOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<aside className="shapes-sidebar" aria-label="Shapes Library">
|
||||
<div className="sidebar-tools">
|
||||
<button className="sidebar-tool" aria-label="Workplane">
|
||||
<WorkplaneToolIcon />
|
||||
</button>
|
||||
<button className="sidebar-tool" aria-label="Ruler">
|
||||
<RulerToolIcon />
|
||||
</button>
|
||||
<button className="sidebar-tool" aria-label="Notes">
|
||||
<NotesToolIcon />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="category-row">
|
||||
<button className="category-button" onClick={() => setCategoryOpen((value) => !value)}>
|
||||
<span>{searchOpen ? "Basic Shapes" : "Basic Shapes"}</span>
|
||||
<ChevronDown size={17} strokeWidth={3} />
|
||||
</button>
|
||||
<button className="search-button" onClick={() => setSearchOpen((value) => !value)} aria-label="Search shapes">
|
||||
<Search size={30} strokeWidth={2.3} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{searchOpen ? (
|
||||
<div className="sidebar-search">
|
||||
<Search size={19} />
|
||||
<input autoFocus placeholder="Search shapes" />
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{categoryOpen ? (
|
||||
<div className="category-menu">
|
||||
{categories.map((category) => (
|
||||
<button key={category} className={category === "Basic Shapes" ? "selected" : ""}>
|
||||
{category}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div className="shape-scroll">
|
||||
<div className="shape-grid">
|
||||
{shapes.map((shape) => (
|
||||
<button
|
||||
className="shape-tile"
|
||||
draggable
|
||||
key={shape.id}
|
||||
title={`${shape.name}: drag or click to place`}
|
||||
onClick={() => onAddShape(shape)}
|
||||
onDragStart={(event) => {
|
||||
event.dataTransfer.effectAllowed = "copy";
|
||||
event.dataTransfer.setData("application/x-sketchforge-shape", JSON.stringify(shape));
|
||||
}}
|
||||
>
|
||||
<img src={shape.src} alt="" draggable={false} />
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<button className="more-shapes">More Shapes</button>
|
||||
</div>
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
import type { CSSProperties, SVGProps } from "react";
|
||||
|
||||
type IconProps = SVGProps<SVGSVGElement>;
|
||||
type SpriteRect = {
|
||||
x: number;
|
||||
y: number;
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
|
||||
const toolbarSprite = "assets/sketchforge/toolbar-sprite.svg?v=2";
|
||||
const vectorToolbarSprite = "assets/sketchforge/vector-toolbar-icons.svg?v=1";
|
||||
|
||||
function ToolbarSpriteIcon({ rect, className, style }: IconProps & { rect: SpriteRect }) {
|
||||
const size = 35;
|
||||
const scale = size / rect.height;
|
||||
|
||||
return (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={["toolbar-sprite-icon", className].filter(Boolean).join(" ")}
|
||||
style={
|
||||
{
|
||||
"--sprite-x": `${-rect.x * scale}px`,
|
||||
"--sprite-y": `${-rect.y * scale}px`,
|
||||
"--sprite-width": `${260 * scale}px`,
|
||||
"--sprite-height": `${80 * scale}px`,
|
||||
width: `${rect.width * scale}px`,
|
||||
height: `${size}px`,
|
||||
backgroundImage: `url(${toolbarSprite})`,
|
||||
...(style as CSSProperties),
|
||||
} as CSSProperties
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function VectorToolbarSpriteIcon({ rect, className, style }: IconProps & { rect: SpriteRect }) {
|
||||
const size = 35;
|
||||
const scale = size / rect.height;
|
||||
|
||||
return (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={["vector-toolbar-sprite-icon", className].filter(Boolean).join(" ")}
|
||||
style={
|
||||
{
|
||||
"--vector-sprite-x": `${-rect.x * scale}px`,
|
||||
"--vector-sprite-y": `${-rect.y * scale}px`,
|
||||
"--vector-sprite-width": `${165 * scale}px`,
|
||||
"--vector-sprite-height": `${27 * scale}px`,
|
||||
width: `${rect.width * scale}px`,
|
||||
height: `${size}px`,
|
||||
backgroundImage: `url(${vectorToolbarSprite})`,
|
||||
...(style as CSSProperties),
|
||||
} as CSSProperties
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function GridModeIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 48 48" aria-hidden="true" {...props}>
|
||||
<g fill="currentColor">
|
||||
{[7, 20, 33].map((x) =>
|
||||
[7, 20, 33].map((y) => <rect key={`${x}-${y}`} x={x} y={y} width="10" height="10" />),
|
||||
)}
|
||||
</g>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function PickaxeModeIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 48 48" aria-hidden="true" {...props}>
|
||||
<path d="M12 13c9-5 20-4 29 4l-5 5c-6-5-13-7-21-4z" fill="currentColor" />
|
||||
<path d="m27 23 10 10c1.5 1.5 1.5 4 0 5.5s-4 1.5-5.5 0l-10-10z" fill="currentColor" />
|
||||
<path d="m17 27 4-4 4 4-4 4z" fill="currentColor" opacity=".82" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function SimLabIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 48 48" aria-hidden="true" {...props}>
|
||||
<path
|
||||
d="M17 22V11a3 3 0 0 1 6 0v10M23 20V9a3 3 0 0 1 6 0v12M29 21v-8a3 3 0 0 1 6 0v13M17 23l-3-3a3 3 0 0 0-4 4l10 13c2 3 5 4 9 4h2c7 0 11-5 11-12v-8"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="3.5"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
/>
|
||||
<path d="M36 8c2 1 4 3 5 5M39 4c3 2 5 5 6 9" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function BlocksModeIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 48 48" aria-hidden="true" {...props}>
|
||||
<path d="M12 17h24v20H12z" fill="currentColor" />
|
||||
<path d="M17 11h14v6H17z" fill="currentColor" opacity=".92" />
|
||||
<path d="M16 21h16v4H16zM16 29h16v4H16z" fill="white" opacity=".22" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function WorkplaneToolIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 55 55" aria-hidden="true" {...props}>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="m3.4 7.1 42.5-3.3-0.5 46.3-39.8-3.3-2.2-39.7zm8.2 38.4-0.2-5.4-4.4-0.2 0.3 5.3 4.3 0.3zm-0.2-6.1-0.1-4.9-4.5-0.1 0.2 4.7 4.4 0.3zm-0.2-5.6-0.1-4.9-4.5-0.1 0.2 5h4.4zm-0.2-5.8-0.1-5.6-4.6 0.1 0.3 5.4 4.4 0.1zm-0.2-6.2-0.1-6.1-4.8 0.3 0.4 6 4.5-0.2zm-0.1-6.7-0.2-6.5-4.9 0.4 0.3 6.4 4.8-0.3zm5.8 30.8-0.1-5.4-4.3-0.3 0.2 5.3 4.2 0.4zm-0.1-6.1v-4.9l-4.5-0.2 0.2 4.9 4.3 0.2zm-0.1-5.6v-5.2l-4.6-0.1 0.2 5.1 4.4 0.2zm0-6.2v-5.8l-4.7 0.2 0.1 5.5 4.6 0.1zm0-6.3-0.1-6.4-4.8 0.3 0.2 6.3 4.7-0.2zm-0.1-7-0.1-6.6-4.9 0.4 0.2 6.5 4.8-0.3zm6.7 31.7-0.1-5.4-5.4-0.3 0.2 5.3 5.3 0.4zm-0.2-6.1-0.1-5.4-5.2-0.1v5.1l5.3 0.4zm-0.1-6.1v-5.1l-5.3-0.1v5.1l5.3 0.1zm-0.1-6.2v-6l-5.6 0.1 0.1 5.8 5.5 0.1zm-0.1-6.6-0.1-6.5-5.4 0.3 0.1 6.4 5.4-0.2zm-0.2-7.2-0.1-6.5-5.3 0.4 0.1 6.4 5.3-0.3zm7.4 32.7v-5.6l-5.7-0.3 0.1 5.5 5.6 0.4zm-0.1-6.2v-5.4l-5.7-0.3 0.1 5.3 5.6 0.4zm0-6v-5.8h-5.8l0.1 5.5 5.7 0.3zm-0.1-6.7v-6.3l-5.8 0.2 0.1 6 5.7 0.1zm-0.1-6.8v-6.8l-5.8 0.3 0.1 6.7 5.7-0.2zm0-7.4v-6.7l-5.9 0.4 0.1 6.7 5.8-0.4zm7.2 33.7v-5.8l-6.2-0.3v5.6l6.2 0.5zm0-6.4v-5.7l-6.2-0.1v5.5l6.2 0.3zm0-6.3v-5.8l-6.2-0.1v5.8l6.2 0.1zm0-6.8v-6.5l-6.4 0.1v6.3l6.4 0.1zm0-7v-7.1l-6.6 0.4v6.9l6.6-0.2zm0-7.7v-6.7l-6.7 0.4 0.1 6.7 6.6-0.4zm7.1 34.6v-5.7l-6.4-0.4v5.7l6.4 0.4zm0-6.3v-5.9l-6.4-0.2v5.8l6.4 0.3zm0.1-6.5v-5.9l-6.5-0.1v5.8l6.5 0.2zm0.1-6.9v-6.8l-6.6 0.2v6.4l6.6 0.2zm0-7.3 0.1-7.5-6.7 0.4v7.3l6.6-0.2zm0.1-8.2v-6.7l-6.7 0.4v6.8l6.7-0.5z"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function RulerToolIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="98 0 60 55" aria-hidden="true" {...props}>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="m104.8 7.1 11.4-0.5 2.1 30 32.2 1.4-0.4 12.8-42.4-3.5-2.9-40.2zm43.1 41.6 0.3-8.7-6.9-0.4v3.5h-1.4v-3.6l-7.1-0.3v5.5l-1.2-0.1v-5.5l-6.9-0.3v3.6h-1.3v-3.7l-5.7-0.3 0.2 5.3h-1.3l-0.2-5.5-4.8-0.1v-1.3l4.6 0.1-0.5-6.8-3.1 0.1v-1.2l3.1-0.1-0.4-6.4-4.9 0.2-0.1-1.2 4.9-0.2-0.5-5.4h-3.2v-1.4h3.1l-0.4-5.8-7.2 0.2 2.7 36.6 38.2 3.2z"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function NotesToolIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="206 0 44 55" aria-hidden="true" {...props}>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="m228.3 50.6c-1.2 0.8-2.9 0.5-3.3-0.3l-3.3-6.3-0.1-0.1v-0.1l-0.1-0.1v-0.1l-1-2-3.4-0.4c-3-0.1-5.1-2.2-5.1-5.2l-0.5-24.3c0-3 2.4-5.4 5.4-5.6l23.6-1.1c3.2-0.1 5.7 2.3 5.6 5.4l-1.4 27.3c-0.1 3-2.7 5.3-5.6 5l-4.1-0.3-4.6 6.3v0.1h-0.1v0.1l-0.1 0.1-0.9 1.1c-0.2 0.3-0.6 0.3-1 0.5zm0.1-3.6 5.8-7.6 5.1 0.7c1.8 0.2 3.4-1.2 3.5-3.1l1.4-26.7c0.1-2-1.5-3.6-3.6-3.5l-22.9 1.2c-2 0.1-3.5 1.6-3.5 3.5l0.4 23.7c0 1.8 1.4 3.3 3.1 3.4l5.4 0.5 2 4.1v0.1l0.1 0.1v0.1l2.9 5.3 0.3-0.1v-1.7zm-5.8-29.5 13.3-0.2c1 0 1-1.7 0-1.7l-13.3 0.4c-1 0-1 1.6 0 1.5zm0 4.7h12.5c1.1 0 1.1-1.6 0-1.6h-12.5c-1.1 0-1.1 1.6 0 1.6zm0 4.6 13.3 0.5c1.1 0 1.1-1.6 0-1.6l-13.3-0.5c-1.1-0.1-1.1 1.6 0 1.6zm-0.2 4.7 9.1 0.5c1.1 0 1.1-1.6 0-1.7l-9.1-0.5c-1.1 0-1.1 1.7 0 1.7z"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function ToolbarCopyIcon(props: IconProps) {
|
||||
return <ToolbarSpriteIcon rect={{ x: 0, y: 6.7, width: 26.1, height: 33.3 }} {...props} />;
|
||||
}
|
||||
|
||||
export function ToolbarPasteIcon(props: IconProps) {
|
||||
return <ToolbarSpriteIcon rect={{ x: 33.5, y: 6.7, width: 22.9, height: 33.3 }} {...props} />;
|
||||
}
|
||||
|
||||
export function ToolbarDuplicateIcon(props: IconProps) {
|
||||
return <ToolbarSpriteIcon rect={{ x: 65, y: 6.7, width: 27.5, height: 33.3 }} {...props} />;
|
||||
}
|
||||
|
||||
export function ToolbarTrashIcon(props: IconProps) {
|
||||
return <ToolbarSpriteIcon rect={{ x: 134.2, y: 6.7, width: 21.1, height: 33.3 }} {...props} />;
|
||||
}
|
||||
|
||||
export function ToolbarUndoIcon(props: IconProps) {
|
||||
return <ToolbarSpriteIcon rect={{ x: 162.9, y: 8, width: 31, height: 30.6 }} {...props} />;
|
||||
}
|
||||
|
||||
export function ToolbarRedoIcon(props: IconProps) {
|
||||
return <ToolbarSpriteIcon rect={{ x: 196.5, y: 8, width: 31.2, height: 30.6 }} {...props} />;
|
||||
}
|
||||
|
||||
export function ToolbarLightbulbIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 48 48" aria-hidden="true" {...props}>
|
||||
<path
|
||||
d="M17 37h14M19 42h10M16 23c0-5.1 3.8-9 8-9s8 3.9 8 9c0 3.1-1.4 5.3-3.6 7.4-.9.9-1.4 2-1.4 3.3v.3h-6v-.3c0-1.3-.5-2.4-1.4-3.3C17.4 28.3 16 26.1 16 23Z"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="3.2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
/>
|
||||
<path d="M24 7v3M11 14l2.4 2M37 14l-2.4 2" fill="none" stroke="currentColor" strokeWidth="2.6" strokeLinecap="round" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function ToolbarImportIcon(props: IconProps) {
|
||||
return <VectorToolbarSpriteIcon rect={{ x: 0, y: 0, width: 24, height: 27 }} {...props} />;
|
||||
}
|
||||
|
||||
export function ToolbarVectorExportIcon(props: IconProps) {
|
||||
return <VectorToolbarSpriteIcon rect={{ x: 34, y: 0, width: 25, height: 27 }} {...props} />;
|
||||
}
|
||||
|
||||
export function ToolbarSettingsIcon(props: IconProps) {
|
||||
return <VectorToolbarSpriteIcon rect={{ x: 66, y: 0, width: 30, height: 27 }} {...props} />;
|
||||
}
|
||||
|
||||
export function ToolbarShapeAddIcon(props: IconProps) {
|
||||
return <VectorToolbarSpriteIcon rect={{ x: 104, y: 0, width: 29, height: 27 }} {...props} />;
|
||||
}
|
||||
|
||||
export function ToolbarHideSelectedIcon(props: IconProps) {
|
||||
return <VectorToolbarSpriteIcon rect={{ x: 138, y: 0, width: 27, height: 27 }} {...props} />;
|
||||
}
|
||||
|
||||
export function ToolbarHoleIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 48 48" aria-hidden="true" {...props}>
|
||||
<circle cx="24" cy="24" r="13" fill="none" stroke="currentColor" strokeWidth="3" strokeDasharray="7 5" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function ToolbarCaretDownIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 48 48" aria-hidden="true" {...props}>
|
||||
<path d="m16 19 8 9 8-9z" fill="currentColor" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function ToolbarGroupIcon(props: IconProps) {
|
||||
return <ToolbarSpriteIcon rect={{ x: 30.3, y: 46.7, width: 29.1, height: 32.5 }} {...props} />;
|
||||
}
|
||||
|
||||
export function ToolbarUngroupIcon(props: IconProps) {
|
||||
return <ToolbarSpriteIcon rect={{ x: 65.4, y: 46.7, width: 26.5, height: 32.5 }} {...props} />;
|
||||
}
|
||||
|
||||
export function ToolbarAlignIcon(props: IconProps) {
|
||||
return <ToolbarSpriteIcon rect={{ x: 97.3, y: 46.7, width: 29.1, height: 32.5 }} {...props} />;
|
||||
}
|
||||
|
||||
export function ToolbarMirrorIcon(props: IconProps) {
|
||||
return <ToolbarSpriteIcon rect={{ x: 131.4, y: 46.7, width: 27, height: 32.5 }} {...props} />;
|
||||
}
|
||||
|
||||
export function ToolbarMagnetIcon(props: IconProps) {
|
||||
return <ToolbarSpriteIcon rect={{ x: 167.8, y: 46.7, width: 20.8, height: 32.5 }} {...props} />;
|
||||
}
|
||||
|
||||
export function ToolbarPaintIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 48 48" aria-hidden="true" {...props}>
|
||||
<path d="m13 28 16-16 8 8-16 16H13z" fill="currentColor" opacity=".2" />
|
||||
<path d="m13 28 16-16 8 8-16 16H13zM27 14l7 7M13 36h8" fill="none" stroke="currentColor" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round" />
|
||||
<path d="M36 31c3 4 4 6 4 8a4 4 0 0 1-8 0c0-2 1-4 4-8Z" fill="currentColor" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function ToolbarExportIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 48 48" aria-hidden="true" {...props}>
|
||||
<path d="M10 31h28v9H10z" fill="currentColor" opacity=".18" />
|
||||
<path d="M10 31h28v9H10zM24 8v21M16 21l8 8 8-8M15 35v5M33 35v5" fill="none" stroke="currentColor" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function ToolbarSendBackwardIcon(props: IconProps) {
|
||||
return <ToolbarSpriteIcon rect={{ x: 198.3, y: 46.7, width: 27.4, height: 32.5 }} {...props} />;
|
||||
}
|
||||
|
||||
export function ToolbarBringForwardIcon(props: IconProps) {
|
||||
return <ToolbarSpriteIcon rect={{ x: 231.5, y: 46.7, width: 25.7, height: 32.3 }} {...props} />;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { clsx, type ClassValue } from "clsx";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
export type ShapeKind =
|
||||
| "box"
|
||||
| "cylinder"
|
||||
| "sphere"
|
||||
| "sketch"
|
||||
| "scribble"
|
||||
| "cone"
|
||||
| "pyramid"
|
||||
| "roof"
|
||||
| "text"
|
||||
| "roundRoof"
|
||||
| "halfSphere"
|
||||
| "torus"
|
||||
| "tube"
|
||||
| "ring"
|
||||
| "wedge"
|
||||
| "polygon"
|
||||
| "icosahedron"
|
||||
| "star"
|
||||
| "heart"
|
||||
| "mesh";
|
||||
|
||||
export type ShapeAsset = {
|
||||
id: string;
|
||||
name: string;
|
||||
src: string;
|
||||
kind: ShapeKind;
|
||||
color: string;
|
||||
hole?: boolean;
|
||||
};
|
||||
|
||||
export type GridSize = "Off" | "0.1 mm" | "0.25 mm" | "0.5 mm" | "1.0 mm" | "2.0 mm" | "5.0 mm" | "Brick";
|
||||
|
||||
export type AlignAxis = "x" | "y" | "z";
|
||||
export type AlignTarget = "min" | "center" | "max";
|
||||
export type AlignHandleStatus = {
|
||||
axis: AlignAxis;
|
||||
target: AlignTarget;
|
||||
disabled: boolean;
|
||||
aligned: boolean;
|
||||
title: string;
|
||||
};
|
||||
|
||||
export type WorkplaneShape = {
|
||||
id: string;
|
||||
name: string;
|
||||
kind: ShapeKind;
|
||||
color: string;
|
||||
hole?: boolean;
|
||||
x: number;
|
||||
z: number;
|
||||
elevation?: number;
|
||||
size: number;
|
||||
width: number;
|
||||
depth: number;
|
||||
height: number;
|
||||
rotation: number;
|
||||
rotationX?: number;
|
||||
rotationZ?: number;
|
||||
mirrorX?: boolean;
|
||||
mirrorY?: boolean;
|
||||
mirrorZ?: boolean;
|
||||
radius?: number;
|
||||
steps?: number;
|
||||
sides?: number;
|
||||
bevel?: number;
|
||||
segments?: number;
|
||||
topRadius?: number;
|
||||
baseRadius?: number;
|
||||
text?: string;
|
||||
font?: string;
|
||||
importedMesh?: {
|
||||
positions: number[];
|
||||
normals?: number[];
|
||||
baseWidth: number;
|
||||
baseDepth: number;
|
||||
baseHeight: number;
|
||||
triangleCount: number;
|
||||
sourceFormat: "stl" | "obj" | "svg" | "json";
|
||||
};
|
||||
imagePlate?: {
|
||||
dataUrl: string;
|
||||
mimeType: string;
|
||||
pixelWidth: number;
|
||||
pixelHeight: number;
|
||||
};
|
||||
groupedShapes?: WorkplaneShape[];
|
||||
groupedBaseWidth?: number;
|
||||
groupedBaseDepth?: number;
|
||||
groupedBaseHeight?: number;
|
||||
locked?: boolean;
|
||||
hidden?: boolean;
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2017",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": false,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"incremental": true,
|
||||
"plugins": [
|
||||
{
|
||||
"name": "next"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||