@floless/app 0.99.2 → 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/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; }
@@ -428,8 +428,8 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
428
428
  body.dimon #svg,body.dimon line.member,body.dimon line.seg,body.dimon image,body.add #svg,body.add line.member,body.add line.seg,body.add image,body.add polygon.member,body.add rect.pdfsheet{cursor:crosshair} /* Add-member is click-to-place like the Dimension tool → the whole canvas shows the crosshair */
429
429
  body.csaxison #svg,body.csaxison line.member,body.csaxison line.seg,body.csaxison image{cursor:crosshair}
430
430
  g.csglyph text{user-select:none}
431
- body.geo line.seg{opacity:.45;cursor:crosshair} body.geo line.member{cursor:crosshair}
432
- body.geo line.seg:hover{stroke:#22d3ee;opacity:1;stroke-width:4} body.geo line.member:hover{stroke-width:8}
431
+ body.geo line.seg{opacity:.45;cursor:crosshair} body.geo line.member{cursor:crosshair} body.geoel line.gridhit{cursor:crosshair} /* a grid line is an extend/trim target (geoel) — crosshair only then, not in Split; leaves its drag/resize cursor everywhere else */
432
+ body.geo line.seg:hover{stroke:#22d3ee;opacity:1;stroke-width:4} body.geo line.member:hover{stroke-width:8} body.geoel line.gridhit:hover{stroke:#22d3ee;opacity:.55} /* target cue on the coincident transparent hit line — colour only, KEEP its 9px width (shrinking it would shrink the pointer-events:stroke hit area and flicker the hover) */
433
433
  circle.numbg{fill:var(--brand);stroke:#fff;stroke-width:1.5;vector-effect:non-scaling-stroke;pointer-events:none}
434
434
  text.numtx{fill:#fff;font:bold 12px system-ui;text-anchor:middle;dominant-baseline:central;pointer-events:none}
435
435
  #dupStat.has b{color:#fca5a5} #dupB.alert{background:#7f1d1d;border-color:#991b1b} #dupB.alert:hover{background:#991b1b}
@@ -1863,15 +1863,23 @@ function renderDims(){return `<g class=dimsg>${renderDimsInner()}</g>`;}
1863
1863
  const GC=()=>window.GridCore||null;
1864
1864
  function gridOn(){return !!(typeof P!=='undefined'&&P&&P.grid&&P.grid.on!==false);}
1865
1865
  function gridGeo(){const gc=GC();if(!gc||typeof P==='undefined'||!P||!P.grid)return null;try{return gc.gridGeometry(P.grid,(P.pt_per_ft>0)?P.pt_per_ft:1);}catch(_){return null;}}
1866
+ // A grid <line> element (.gridhit) → its two endpoints [[x,y],[x,y]], or null. Mirrors the axis/index decode
1867
+ // in the grid-drag path so a grid line can also serve as an extend/trim target.
1868
+ function gridLineEndpoints(el){const geo=gridGeo();if(!geo||!el||!el.dataset)return null;
1869
+ const free=el.dataset.gl!=null,axis=free?'l':(el.dataset.gv!=null?'v':(el.dataset.gh!=null?'h':null));if(!axis)return null;
1870
+ const gi=+(free?el.dataset.gl:(el.dataset.gv!=null?el.dataset.gv:el.dataset.gh));if(!isFinite(gi))return null;
1871
+ const line=free?(geo.lines||[])[gi]:geo[axis][gi];if(!line)return null;
1872
+ return free?[line.a.slice(),line.b.slice()]:(axis==='v'?[[line.x,line.lo],[line.x,line.hi]]:[[line.lo,line.y],[line.hi,line.y]]);}
1866
1873
  function gridSvg(){
1867
1874
  if(!gridOn())return '';
1868
1875
  const geo=gridGeo();if(!geo||(!geo.v.length&&!geo.h.length&&!(geo.lines&&geo.lines.length)))return '';
1869
1876
  const R=11/zoom,F=12/zoom;
1870
1877
  let s='<g id=gridG>';
1871
1878
  const gsel=i=>selGridIds.has(i)?' sel':''; // marquee/Ctrl+A grid selection → highlight the visible line
1872
- geo.v.forEach((l,i)=>{s+=`<line class="gridln${gsel('gv:'+i)}" data-gv="${i}" x1="${l.x}" y1="${l.lo}" x2="${l.x}" y2="${l.hi}"/><line class="gridhit gv" data-gv="${i}" x1="${l.x}" y1="${l.lo}" x2="${l.x}" y2="${l.hi}" data-tip="Grid ${esc(l.label)} — drag to move"></line>`;});
1873
- geo.h.forEach((l,i)=>{s+=`<line class="gridln${gsel('gh:'+i)}" data-gh="${i}" x1="${l.lo}" y1="${l.y}" x2="${l.hi}" y2="${l.y}"/><line class="gridhit gh" data-gh="${i}" x1="${l.lo}" y1="${l.y}" x2="${l.hi}" y2="${l.y}" data-tip="Grid ${esc(l.label)} — drag to move"></line>`;});
1874
- (geo.lines||[]).forEach((l,i)=>{s+=`<line class="gridln${gsel('gl:'+(l.id!=null?l.id:i))}" data-gl="${i}" x1="${l.a[0]}" y1="${l.a[1]}" x2="${l.b[0]}" y2="${l.b[1]}"/><line class="gridhit gl" data-gl="${i}" x1="${l.a[0]}" y1="${l.a[1]}" x2="${l.b[0]}" y2="${l.b[1]}" data-tip="Grid ${esc(l.label)} — drag to move"></line>`;});
1879
+ const gTip=geoMode==='el'?'extend/trim target':'drag to move'; // while Extend/Trim is armed, a grid line is a target (drag is disabled) — don't promise "drag to move"
1880
+ geo.v.forEach((l,i)=>{s+=`<line class="gridln${gsel('gv:'+i)}" data-gv="${i}" x1="${l.x}" y1="${l.lo}" x2="${l.x}" y2="${l.hi}"/><line class="gridhit gv" data-gv="${i}" x1="${l.x}" y1="${l.lo}" x2="${l.x}" y2="${l.hi}" data-tip="Grid ${esc(l.label)} — ${gTip}"></line>`;});
1881
+ geo.h.forEach((l,i)=>{s+=`<line class="gridln${gsel('gh:'+i)}" data-gh="${i}" x1="${l.lo}" y1="${l.y}" x2="${l.hi}" y2="${l.y}"/><line class="gridhit gh" data-gh="${i}" x1="${l.lo}" y1="${l.y}" x2="${l.hi}" y2="${l.y}" data-tip="Grid ${esc(l.label)} — ${gTip}"></line>`;});
1882
+ (geo.lines||[]).forEach((l,i)=>{s+=`<line class="gridln${gsel('gl:'+(l.id!=null?l.id:i))}" data-gl="${i}" x1="${l.a[0]}" y1="${l.a[1]}" x2="${l.b[0]}" y2="${l.b[1]}"/><line class="gridhit gl" data-gl="${i}" x1="${l.a[0]}" y1="${l.a[1]}" x2="${l.b[0]}" y2="${l.b[1]}" data-tip="Grid ${esc(l.label)} — ${gTip}"></line>`;});
1875
1883
  const bub=(x,y,lb,ax,i,end)=>`<g class=gridbubg data-${ax}="${i}" data-end="${end}" data-tip="Grid ${esc(lb)} — drag to move or adjust · dbl-click to rename · click to edit the grid"><circle class=gridbub data-bx="${x}" data-by="${y}" cx="${x}" cy="${y}" r="${R}"/><text class=gridtx data-bx="${x}" data-by="${y}" x="${x}" y="${y}" style="font-size:${F}px">${esc(lb)}</text></g>`;
1876
1884
  geo.v.forEach((l,i)=>{s+=bub(l.x,l.lo,l.label,'gv',i,0)+bub(l.x,l.hi,l.label,'gv',i,1);});
1877
1885
  geo.h.forEach((l,i)=>{s+=bub(l.lo,l.y,l.label,'gh',i,0)+bub(l.hi,l.y,l.label,'gh',i,1);});
@@ -2117,7 +2125,7 @@ function renderGridPanel(p){
2117
2125
  document.getElementById('gridRemoveB').onclick=()=>{edit(()=>{P.grid=null;});};
2118
2126
  document.getElementById('gridDoneB').onclick=()=>{setGridMode(false);render();};
2119
2127
  }
2120
- function setGeo(){document.body.classList.toggle('geo',!!geoMode);}
2128
+ function setGeo(){document.body.classList.toggle('geo',!!geoMode);document.body.classList.toggle('geoel',geoMode==='el');} // geoel = Extend/Trim armed; grid lines are a target ONLY then (not in Split), so their crosshair/highlight keys off geoel, not geo
2121
2129
  // --- repeat last command (AutoCAD/Tekla): when NO tool is active, Space/Enter re-invokes the last command ---
2122
2130
  let lastCmd=null;
2123
2131
  function setLastCmd(label,run){lastCmd={label,run};}
@@ -2249,7 +2257,7 @@ function esc(s){return String(s).replace(/[<>&"]/g,c=>({'<':'&lt;','>':'&gt;','&
2249
2257
  function render(){
2250
2258
  document.body.classList.remove('snapping'); // a wholesale svg rebuild drops any #snapMark → clear the cursor-hide flag too (the next pointermove re-adds it if still snapping)
2251
2259
  buildColorRank(); // refresh the model-global colour rank before any colorFor() call below (B2 — keeps 2D hues stable across plans + matched to 3D)
2252
- if(geoMode&&(selIds.size<1||(geoMode==='split'&&selIds.size!==1))){geoMode=null;document.body.classList.remove('geo');} // Split needs exactly one member; Extend/Trim works on any selection
2260
+ if(geoMode&&(selIds.size<1||(geoMode==='split'&&selIds.size!==1))){geoMode=null;setGeo();} // Split needs exactly one member; Extend/Trim works on any selection. setGeo() clears BOTH geo + geoel (not a bare remove('geo')) so the grid affordance can't outlive the tool
2253
2261
  let s=overlaySvg(); // crisp vector linework (snappable) when the sheet has vectors; raster only for scanned PDFs
2254
2262
  s+=gridSvg(); // structural grid under the linework (members/dims stay on top)
2255
2263
  for(const sg of P.segments) s+=`<line class=seg data-seg="${sg.id}" x1="${sg.a[0]}" y1="${sg.a[1]}" x2="${sg.b[0]}" y2="${sg.b[1]}"/>`;
@@ -2745,7 +2753,7 @@ function panel(){
2745
2753
  <div class=seg2 style="margin-top:6px"><button id=rot0>0°</button><button id=rot90>90°</button><button id=rot180>180°</button><button id=rot270>270°</button></div>
2746
2754
  <div class=divrow><hr><span class=sect style="margin:0">Modify geometry</span><hr></div>
2747
2755
  <div class=seg2 style="margin-top:0"><button id=geoEL class="${geoMode==='el'?'on':''}">Extend / Trim all</button></div>
2748
- <div class=hint style="margin-top:6px">${geoMode==='el'?'Click a <b>target line</b> — the nearest end of <b>every</b> selected member snaps to where it meets that line.':'<b>Extend/Trim</b> (E) every selected member\'s nearest end to one line. <b>Esc</b> cancels.'}</div>
2756
+ <div class=hint style="margin-top:6px">${geoMode==='el'?'Click a <b>target line</b> (member, segment, or grid line) — the nearest end of <b>every</b> selected member snaps to where it meets that line.':'<b>Extend/Trim</b> (E) every selected member\'s nearest end to one line. <b>Esc</b> cancels.'}</div>
2749
2757
  <div class=row><button class=ghostw id=swapEnds data-tip="Reverse every selected member: swap each one's start and end (yellow ↔ magenta / bottom ↔ top) handles · Shortcut: P">⇄ Swap start ↔ end (all) <span style="opacity:.55">(P)</span></button></div>
2750
2758
  <div class="row f"><button class=danger id=del>Delete selected (${arr.length})</button></div>`;
2751
2759
  wireTypeFilter(p);
@@ -2929,7 +2937,7 @@ function panel(){
2929
2937
  <div class=seg2 style="margin-top:6px"><button id=rot0 class="${rotN===0?'on':''}">0°</button><button id=rot90 class="${rotN===90?'on':''}">90°</button><button id=rot180 class="${rotN===180?'on':''}">180°</button><button id=rot270 class="${rotN===270?'on':''}">270°</button></div>
2930
2938
  ${br?'':`<div class=divrow><hr><span class=sect style="margin:0">Modify geometry</span><hr></div>
2931
2939
  <div class=seg2 style="margin-top:0"><button id=geoEL class="${geoMode==='el'?'on':''}">Extend / Trim</button><button id=geoSplit class="${geoMode==='split'?'on':''}">Split</button></div>
2932
- <div class=hint style="margin-top:6px">${geoMode==='el'?'Click a <b>target line</b> — another member or a grey segment. The nearest end of this member snaps to where the two lines meet (extends if short, trims if it overshoots).':geoMode==='split'?'Click a <b>point on this member</b> to cut it into two members.':'<b>Extend/Trim</b> (E) an end to meet another line · <b>Split</b> (S) at a point. <b>Esc</b> cancels.'}</div>
2940
+ <div class=hint style="margin-top:6px">${geoMode==='el'?'Click a <b>target line</b> — another member, a grey segment, or a grid line. The nearest end of this member snaps to where the two lines meet (extends if short, trims if it overshoots).':geoMode==='split'?'Click a <b>point on this member</b> to cut it into two members.':'<b>Extend/Trim</b> (E) an end to meet another line · <b>Split</b> (S) at a point. <b>Esc</b> cancels.'}</div>
2933
2941
  <div class=row><button class=ghostw id=swapEnds data-tip="Reverse the member: swap the start (${col?'bottom':'yellow'}) and end (${col?'top':'magenta'}) handles · Shortcut: P">⇄ Swap start ↔ end <span style="opacity:.55">(P)</span></button></div>`}
2934
2942
  <div class="row f"><button class=danger id=del>Delete member</button></div>`;
2935
2943
  wireTypeFilter(p);
@@ -3998,7 +4006,8 @@ svg.addEventListener('pointerdown',e=>{if(e.button!==0)return;const t=e.target;
3998
4006
  if(tm&&isBrace(tm))toast('A brace can’t be an extend/trim target — its drawn line is offset from its work points'); // clicking the VISIBLE brace body would silently target its invisible baseline
3999
4007
  else if(tm)tgt=[tm.wp[0],tm.wp[1]];}
4000
4008
  else if(t.classList.contains('seg')){const sg=P.segments.find(s=>s.id===t.dataset.seg);if(sg)tgt=[sg.a,sg.b];}
4001
- if(tgt){geoMode=null;setGeo();snapEndMulti(sel2d(),tgt[0],tgt[1]);} // miss (empty/own line) keeps the mode armed
4009
+ else if(t.classList.contains('gridhit')){const gp=gridLineEndpoints(t);if(gp)tgt=gp;} // a grid line is a valid target — its two endpoints define the line to meet
4010
+ if(tgt){geoMode=null;setGeo();if(!snapEndMulti(sel2d(),tgt[0],tgt[1]))render();} // miss (empty/own line) keeps the mode armed; a 0-result target (all parallel / all braces) still needs a render() to un-arm the panel + grid affordance (snapEndMulti only renders when it moved something)
4002
4011
  return;}
4003
4012
  if(t.classList.contains('handle')){const id=t.dataset.mid||[...selIds][0],m=byId(id),h=+t.dataset.h;if(!m)return;buildSnap(id);
4004
4013
  drag={type:'end',h,id,anchor:m.wp[1-h].slice(),orig:m.wp[h].slice(),pre:snapshot()};svg.setPointerCapture(e.pointerId);e.preventDefault();return;} // anchor = the fixed end (length ref); orig = where this end started (moved ref)
@@ -6395,7 +6404,7 @@ function setPlan(i){C.active=i;P=C.plans[i];
6395
6404
  profs=[...new Set([...P.members.map(m=>m.profile), ...Object.keys(WT)])].sort();
6396
6405
  // undo/redo is one GLOBAL stack (module-level, declared once) — NOT swapped per plane. A plane switch
6397
6406
  // must not reset or re-scope undo, since snapshots are whole-model and selection/edits span sheets.
6398
- selIds=new Set();findHits=new Set();selGridIds=new Set();picking=false;pickKind='profile';pickEnd=null;mode='sel';geoMode=null; // findHits + selGridIds reset per plan like selIds — a stale highlight (or, for grids, an index-based id) must not bleed onto another sheet (grids are per-plan)
6407
+ selIds=new Set();findHits=new Set();selGridIds=new Set();picking=false;pickKind='profile';pickEnd=null;mode='sel';geoMode=null;setGeo(); // findHits + selGridIds reset per plan like selIds — a stale highlight (or, for grids, an index-based id) must not bleed onto another sheet (grids are per-plan). setGeo() clears body.geo/geoel so an armed Extend/Trim tool doesn't leave the grid crosshair on the next sheet
6399
6408
  dimMode=false;dimChain=false;dimSplitMode=false;selDimIds=new Set();setDimMode(); // Dimension tool resets per plan (incl. chain + split); setDimMode syncs the button/body.dimon classes + clears any draft/preview/chain (dimsVisible persists across plans)
6400
6409
  setMode(); // Add-member likewise resets per plan: syncs body.add (crosshair) + the button off, and drops any in-progress start point (a plan-pixel draft is stale on another sheet)
6401
6410
  if(gridMode||gridPick||gridLinePick){if(gridLinePick&&gridLinePick.line)gridLinePick.line.remove();gridMode=false;gridPick=false;gridLinePick=null;gridSetPickClass();} // grid panel/pick disarms per plan like the other takeover tools (a leaked pick would set geometry in the WRONG sheet's display space)
@@ -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: 'Read steel drawings',
115
- capability: 'Drawings to model, review, exports',
116
- sub: 'Create a steel model from drawings.',
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: 'Import current model',
122
- capability: 'Open model to workspace context',
123
- sub: 'Bring the open model into a new workspace.',
124
- label: 'Import from Workflows',
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 to vectors and editable shapes',
153
- sub: 'Trace geometry into an editable canvas.',
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-note copy adapts to which create affordances are on screen.
367
+ // Empty state: point at the create cards above and the Import button in the header.
341
368
  if (!projects.length) {
342
- const actions = createEntries.map((entry) => entry.action);
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
- doProjectAction(act.dataset.act, menuFor);
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.99.2",
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",