@floless/app 0.99.3 → 0.100.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +7186 -6744
- package/dist/web/app.css +8 -0
- package/dist/web/workspaces.js +107 -23
- package/package.json +2 -1
package/dist/web/app.css
CHANGED
|
@@ -3454,8 +3454,16 @@ body.mode-workspaces #menu .menu-item[data-action="bake"] { display:none; }
|
|
|
3454
3454
|
|
|
3455
3455
|
/* landing */
|
|
3456
3456
|
.ws-landing { flex:1; min-height:0; overflow-y:auto; padding:6px 20px 24px; }
|
|
3457
|
+
.ws-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
|
|
3458
|
+
.ws-head-text { min-width:0; }
|
|
3457
3459
|
.ws-head h2 { font-size:17px; font-weight:650; letter-spacing:.01em; }
|
|
3458
3460
|
.ws-head .ws-sub { color:var(--text-muted); font-size:12px; margin:2px 0 14px; }
|
|
3461
|
+
/* Import project — a secondary/ghost utility action beside the heading (a restore, not another
|
|
3462
|
+
"create from scratch" card). Matches the .btn-mini ghost treatment used elsewhere on the landing. */
|
|
3463
|
+
.ws-import-btn { flex:none; background:none; border:1px solid var(--border-strong); color:var(--text-muted);
|
|
3464
|
+
border-radius:6px; padding:6px 12px; font-size:12px; cursor:pointer; white-space:nowrap; }
|
|
3465
|
+
.ws-import-btn:hover { color:var(--text); border-color:var(--accent); }
|
|
3466
|
+
.ws-import-btn:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
|
|
3459
3467
|
.ws-create-grid { display:grid; gap:14px; grid-template-columns:repeat(auto-fit,minmax(220px,260px));
|
|
3460
3468
|
align-content:start; align-items:stretch; margin-bottom:14px; }
|
|
3461
3469
|
.ws-grid { display:grid; gap:14px; grid-template-columns:repeat(auto-fill,minmax(240px,1fr)); align-content:start; }
|
package/dist/web/workspaces.js
CHANGED
|
@@ -85,6 +85,32 @@
|
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
// Single-.zip picker for Import project — same File System Access preference + hidden-input fallback
|
|
89
|
+
// as pickDrawingFiles. Returns null on cancel; never throws.
|
|
90
|
+
const ZIP_FILE_TYPES = [{ description: 'Project archive (.zip)', accept: { 'application/zip': ['.zip'] } }];
|
|
91
|
+
async function pickZipFile(fallbackInput) {
|
|
92
|
+
if (window.showOpenFilePicker) {
|
|
93
|
+
try {
|
|
94
|
+
const [handle] = await window.showOpenFilePicker({ multiple: false, types: ZIP_FILE_TYPES });
|
|
95
|
+
return handle ? handle.getFile() : null;
|
|
96
|
+
} catch (err) {
|
|
97
|
+
if (err && err.name === 'AbortError') return null; // user cancelled — not an error
|
|
98
|
+
throw err;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return new Promise((resolve) => {
|
|
102
|
+
const cleanup = () => {
|
|
103
|
+
fallbackInput.removeEventListener('change', onChange);
|
|
104
|
+
fallbackInput.removeEventListener('cancel', onCancel);
|
|
105
|
+
};
|
|
106
|
+
const onChange = () => { cleanup(); const f = (fallbackInput.files || [])[0] || null; fallbackInput.value = ''; resolve(f); };
|
|
107
|
+
const onCancel = () => { cleanup(); resolve(null); };
|
|
108
|
+
fallbackInput.addEventListener('change', onChange);
|
|
109
|
+
fallbackInput.addEventListener('cancel', onCancel);
|
|
110
|
+
fallbackInput.click();
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
88
114
|
let exportState = null; // kind → { path, exportedAt } after a successful list; null = unknown/failed
|
|
89
115
|
if (!$switch || !$landing || !$app) return; // markup absent — nothing to wire
|
|
90
116
|
|
|
@@ -111,17 +137,17 @@
|
|
|
111
137
|
createActions: [
|
|
112
138
|
{
|
|
113
139
|
kind: 'drawing',
|
|
114
|
-
headline: '
|
|
115
|
-
capability: '
|
|
116
|
-
sub: '
|
|
140
|
+
headline: 'Steel model from drawings',
|
|
141
|
+
capability: 'PDF or image → 3D steel model',
|
|
142
|
+
sub: 'Turn steel drawings into a 3D model you can review and export.',
|
|
117
143
|
label: 'Pick drawings',
|
|
118
144
|
},
|
|
119
145
|
{
|
|
120
146
|
kind: 'current',
|
|
121
|
-
headline: '
|
|
122
|
-
capability: 'Open model
|
|
123
|
-
sub: '
|
|
124
|
-
label: '
|
|
147
|
+
headline: 'Copy from Workflows',
|
|
148
|
+
capability: 'Open model → new project',
|
|
149
|
+
sub: 'Copies the steel model open in Workflows into a new project here.',
|
|
150
|
+
label: 'Copy the open model',
|
|
125
151
|
},
|
|
126
152
|
],
|
|
127
153
|
editor: '/steel-editor.html',
|
|
@@ -148,9 +174,9 @@
|
|
|
148
174
|
createActions: [
|
|
149
175
|
{
|
|
150
176
|
kind: 'drawing',
|
|
151
|
-
headline: 'Trace drawing',
|
|
152
|
-
capability: 'Drawing
|
|
153
|
-
sub: '
|
|
177
|
+
headline: 'Trace a drawing',
|
|
178
|
+
capability: 'Drawing → editable shapes',
|
|
179
|
+
sub: 'Turn one drawing into editable lines and shapes.',
|
|
154
180
|
label: 'Pick drawing',
|
|
155
181
|
},
|
|
156
182
|
],
|
|
@@ -291,8 +317,9 @@
|
|
|
291
317
|
}
|
|
292
318
|
|
|
293
319
|
function renderLanding() {
|
|
294
|
-
let html = `<div class="ws-head"><h2>Workspaces</h2>` +
|
|
295
|
-
`<div class="ws-sub">Live projects — open a document to keep working. No Run here.</div></div
|
|
320
|
+
let html = `<div class="ws-head"><div class="ws-head-text"><h2>Workspaces</h2>` +
|
|
321
|
+
`<div class="ws-sub">Live projects — open a document to keep working. No Run here.</div></div>` +
|
|
322
|
+
`<button type="button" class="ws-import-btn" id="ws-import-project" data-tip="Restore a project from an exported .zip file">↓ Import project…</button></div>`;
|
|
296
323
|
// Create affordances stay docked at the top, separate from existing projects. Drawing-first
|
|
297
324
|
// entries lead; importing the current Workflows model stays last because it is a different mode.
|
|
298
325
|
const createEntries = wsAppIds
|
|
@@ -333,20 +360,13 @@
|
|
|
333
360
|
`<span class="ws-body"><span><span class="ws-name">${escapeHtml(p.name)}</span>` +
|
|
334
361
|
(projectCapability ? `<span class="ws-meta">${escapeHtml(projectCapability)}</span>` : '') +
|
|
335
362
|
`<span class="ws-meta">${escapeHtml(displayApp)} · <span class="t">${escapeHtml(relAgo(p.updatedAt))}</span></span></span>` +
|
|
336
|
-
`<button type="button" class="ws-kebab" data-kebab="${escapeAttr(p.id)}" aria-label="Project actions" data-tip="Rename · Duplicate · Archive">⋯</button>` +
|
|
363
|
+
`<button type="button" class="ws-kebab" data-kebab="${escapeAttr(p.id)}" aria-label="Project actions" data-tip="Rename · Duplicate · Export · Archive">⋯</button>` +
|
|
337
364
|
`</span></div>`;
|
|
338
365
|
}
|
|
339
366
|
html += `</div>`;
|
|
340
|
-
// Empty
|
|
367
|
+
// Empty state: point at the create cards above and the Import button in the header.
|
|
341
368
|
if (!projects.length) {
|
|
342
|
-
const
|
|
343
|
-
const hasDrawingSeed = actions.some((action) => action.kind === 'drawing');
|
|
344
|
-
const hasCurrentSeed = actions.some((action) => action.kind === 'current');
|
|
345
|
-
const note = hasDrawingSeed && hasCurrentSeed
|
|
346
|
-
? 'No projects yet — drop drawings above, or import your current steel model.'
|
|
347
|
-
: hasDrawingSeed
|
|
348
|
-
? 'No projects yet — drop a drawing above, or ask your terminal AI to trace a drawing set.'
|
|
349
|
-
: 'No projects yet — import your current steel model above, or ask your terminal AI to read a drawing set.';
|
|
369
|
+
const note = 'No projects yet — start one from the cards above, or Import project to restore an exported .zip.';
|
|
350
370
|
html += `<div class="ws-empty-note">${escapeHtml(note)}${archived.length ? ' You have archived projects below.' : ''}</div>`;
|
|
351
371
|
}
|
|
352
372
|
// Archived ("Trash") section — a collapsed disclosure below the live grid, only when non-empty.
|
|
@@ -381,6 +401,7 @@
|
|
|
381
401
|
if (restore) { e.stopPropagation(); unarchiveProject(restore.dataset.restore); return; }
|
|
382
402
|
const del = e.target.closest('[data-delete-archived]');
|
|
383
403
|
if (del) { e.stopPropagation(); deleteArchivedProject(del.dataset.deleteArchived); return; }
|
|
404
|
+
if (e.target.closest('#ws-import-project')) { importProject(); return; }
|
|
384
405
|
const card = e.target.closest('[data-open]');
|
|
385
406
|
if (card) { openProject(card.dataset.open); return; }
|
|
386
407
|
const seed = e.target.closest('[data-seed-app]');
|
|
@@ -407,6 +428,11 @@
|
|
|
407
428
|
const $seedFile = document.createElement('input');
|
|
408
429
|
$seedFile.type = 'file'; $seedFile.accept = '.pdf,image/*'; $seedFile.multiple = true; $seedFile.hidden = true;
|
|
409
430
|
document.body.appendChild($seedFile);
|
|
431
|
+
// Fallback picker for Import project (used when the File System Access API is absent). Outside
|
|
432
|
+
// $landing so an innerHTML re-render can't wipe it — same as $seedFile.
|
|
433
|
+
const $importZip = document.createElement('input');
|
|
434
|
+
$importZip.type = 'file'; $importZip.accept = '.zip,application/zip'; $importZip.hidden = true;
|
|
435
|
+
document.body.appendChild($importZip);
|
|
410
436
|
$landing.addEventListener('dragover', (e) => {
|
|
411
437
|
const zone = e.target.closest('[data-seed-drop]');
|
|
412
438
|
if (!zone) return;
|
|
@@ -2433,6 +2459,7 @@
|
|
|
2433
2459
|
function openProjMenu(id, anchor) {
|
|
2434
2460
|
menuFor = id;
|
|
2435
2461
|
$projMenu.innerHTML = menuItem('rename', 'Rename…') + menuItem('duplicate', 'Duplicate') +
|
|
2462
|
+
menuItem('export', 'Export…') +
|
|
2436
2463
|
'<div class="menu-divider"></div>' + menuItem('archive', 'Archive');
|
|
2437
2464
|
const r = anchor.getBoundingClientRect();
|
|
2438
2465
|
$projMenu.style.left = Math.round(Math.max(8, Math.min(r.left, window.innerWidth - 260))) + 'px';
|
|
@@ -2447,8 +2474,12 @@
|
|
|
2447
2474
|
$projMenu.addEventListener('click', (e) => {
|
|
2448
2475
|
const act = e.target.closest('[data-act]');
|
|
2449
2476
|
if (!act || !menuFor) return;
|
|
2477
|
+
const id = menuFor;
|
|
2450
2478
|
closeProjMenu();
|
|
2451
|
-
|
|
2479
|
+
// Export is read-only — keep it out of the rename/duplicate/archive busy-lock (and its
|
|
2480
|
+
// trailing loadProjects reconcile), so it can run alongside them without contention.
|
|
2481
|
+
if (act.dataset.act === 'export') { exportProject(id); return; }
|
|
2482
|
+
doProjectAction(act.dataset.act, id);
|
|
2452
2483
|
});
|
|
2453
2484
|
|
|
2454
2485
|
// Ring the card that just changed so the eye lands on it before the background reload repaints —
|
|
@@ -2513,6 +2544,59 @@
|
|
|
2513
2544
|
loadProjects();
|
|
2514
2545
|
}
|
|
2515
2546
|
|
|
2547
|
+
// Export a project as a portable .zip (back it up / move it to another machine). Fetch → Blob →
|
|
2548
|
+
// download anchor so a server error surfaces as a toast (not a broken download) and success is
|
|
2549
|
+
// confirmed. ponytail: the whole zip lands in memory here — fine for desktop-scale projects.
|
|
2550
|
+
async function exportProject(id) {
|
|
2551
|
+
const proj = projects.find((p) => p.id === id);
|
|
2552
|
+
const label = proj ? proj.name : id;
|
|
2553
|
+
showToast(`Exporting “${label}”…`, 'ok');
|
|
2554
|
+
try {
|
|
2555
|
+
const res = await fetch(`/api/projects/${encodeURIComponent(id)}/export.zip`);
|
|
2556
|
+
if (!res.ok) throw new Error((await res.json().catch(() => ({}))).error || `HTTP ${res.status}`);
|
|
2557
|
+
const blob = await res.blob();
|
|
2558
|
+
const cd = res.headers.get('content-disposition') || '';
|
|
2559
|
+
const name = (cd.match(/filename="?([^"]+)"?/) || [])[1] || `${label}.zip`;
|
|
2560
|
+
const url = URL.createObjectURL(blob);
|
|
2561
|
+
const a = document.createElement('a');
|
|
2562
|
+
a.href = url; a.download = name;
|
|
2563
|
+
document.body.appendChild(a); a.click(); a.remove();
|
|
2564
|
+
setTimeout(() => URL.revokeObjectURL(url), 1000);
|
|
2565
|
+
showToast(`Exported ✓ — ${name}`, 'ok');
|
|
2566
|
+
track('workspace_project_exported', { app: proj ? proj.app : undefined });
|
|
2567
|
+
} catch (err) {
|
|
2568
|
+
showToast('Export failed: ' + (err && err.message || err), 'warn');
|
|
2569
|
+
}
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2572
|
+
// Import a project from an exported .zip → restores it as a NEW project (fresh id). The app it runs
|
|
2573
|
+
// on is a SEPARATE install, so warn (never block) when the server reports appInstalled===false.
|
|
2574
|
+
async function importProject() {
|
|
2575
|
+
let file;
|
|
2576
|
+
try { file = await pickZipFile($importZip); }
|
|
2577
|
+
catch { showToast('Couldn’t open the file picker', 'warn'); return; }
|
|
2578
|
+
if (!file) return; // cancelled
|
|
2579
|
+
showToast(`Importing “${file.name}”…`, 'ok');
|
|
2580
|
+
try {
|
|
2581
|
+
const buf = await file.arrayBuffer();
|
|
2582
|
+
const { project, appInstalled } = await api('/api/projects/import', {
|
|
2583
|
+
method: 'POST', headers: { 'content-type': 'application/zip' }, body: buf,
|
|
2584
|
+
});
|
|
2585
|
+
projects.unshift(project); // newest → front, matching duplicate/create
|
|
2586
|
+
renderLanding();
|
|
2587
|
+
flashCard(project.id, { scroll: true });
|
|
2588
|
+
track('workspace_project_imported', { app: project.app });
|
|
2589
|
+
if (appInstalled === false) {
|
|
2590
|
+
showToast(`Imported “${project.name}”, but its app isn’t installed here — some tools may be missing until you install it.`, 'warn');
|
|
2591
|
+
} else {
|
|
2592
|
+
showToast(`Imported ✓ — “${project.name}” added`, 'ok');
|
|
2593
|
+
}
|
|
2594
|
+
loadProjects(); // background reconcile against the server truth (mirrors duplicate/rename/archive)
|
|
2595
|
+
} catch (err) {
|
|
2596
|
+
showToast('Import failed: ' + (err && err.message || err), 'warn');
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
|
|
2516
2600
|
// Restore an archived project to the live grid (the inverse of Archive). Fully reversible — Archive
|
|
2517
2601
|
// puts it right back — so no confirm: a toast is consistent with how Rename/Duplicate/Archive confirm.
|
|
2518
2602
|
async function unarchiveProject(id) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floless/app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.100.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Thin localhost host for floless.app — serves web/ and shells the aware CLI. No engine, no LLM.",
|
|
6
6
|
"bin": {
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"chokidar": "^4.0.0",
|
|
36
36
|
"esbuild": "^0.28.0",
|
|
37
37
|
"fastify": "^5.0.0",
|
|
38
|
+
"fflate": "^0.8.3",
|
|
38
39
|
"pino-pretty": "^13.0.0",
|
|
39
40
|
"postject": "^1.0.0-alpha.6",
|
|
40
41
|
"rcedit": "^5.0.2",
|