@floless/app 0.99.0 → 0.99.2

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.
@@ -53106,7 +53106,7 @@ function appVersion() {
53106
53106
  return resolveVersion({
53107
53107
  isSea: isSea2(),
53108
53108
  sqVersionXml: readSqVersionXml(),
53109
- define: true ? "0.99.0" : void 0,
53109
+ define: true ? "0.99.2" : void 0,
53110
53110
  pkgVersion: readPkgVersion()
53111
53111
  });
53112
53112
  }
@@ -53116,7 +53116,7 @@ function resolveChannel(s) {
53116
53116
  return "dev";
53117
53117
  }
53118
53118
  function appChannel() {
53119
- return resolveChannel({ isSea: isSea2(), define: true ? "0.99.0" : void 0 });
53119
+ return resolveChannel({ isSea: isSea2(), define: true ? "0.99.2" : void 0 });
53120
53120
  }
53121
53121
 
53122
53122
  // workflow-update.ts
package/dist/web/app.css CHANGED
@@ -3981,6 +3981,8 @@ tr.hist-diff-row[hidden] { display:none; }
3981
3981
  .kb-g-hint { font-size: 10.5px; color: var(--text-dim); }
3982
3982
  .kb-graph-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 8px; position: relative; }
3983
3983
  .kb-graph-svg { width: 100%; height: 100%; }
3984
+ .kb-graph-svg.kb-zoomed { cursor: grab; } /* pannable (zoomed in) — nodes keep their own pointer */
3985
+ .kb-graph-svg.kb-panning, .kb-graph-svg.kb-panning * { cursor: grabbing; } /* while dragging, grabbing everywhere incl. over nodes */
3984
3986
  .kb-g-fit { position: absolute; top: 10px; right: 10px; background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-muted); border-radius: 6px; padding: 3px 9px; font-size: 12px; cursor: pointer; font: inherit; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4); }
3985
3987
  .kb-g-fit:hover { color: var(--text); border-color: var(--accent); }
3986
3988
  .kb-g-fit[hidden] { display: none; }
@@ -1490,7 +1490,7 @@ function edit(fn){const pv=snapshot();fn();pushUndo(pv);render();sync3D();}
1490
1490
  // --- auto-save: edits persist to this browser (localStorage). Raster stays embedded; only members + TOS are stored. ---
1491
1491
  const LSKEY = 'steeltakeoff:edits:v1:' + APP_ID;
1492
1492
  function dataSig(){return C.plans.map(p=>p.sheet+':'+((p.segments||[]).length)).join('|');} // ignore stored edits if the dataset changed
1493
- let saveT=null;
1493
+ let saveT=null, saveSeq=0; // saveSeq: monotonic id per server save. Only the LATEST save's response may set the pill — an older in-flight PUT that resolves late must not overwrite a newer verdict (e.g. a stale 'ok' clobbering a fresh 'err').
1494
1494
  function setSaved(state,msg){const el=document.getElementById('saveStat');if(!el)return;el.classList.remove('dirty','ok','err');
1495
1495
  if(state==='ok'){el.classList.add('ok');el.textContent=msg||'Saved ✓';}
1496
1496
  else if(state==='dirty'){el.classList.add('dirty');el.textContent='Saving…';}
@@ -1502,19 +1502,23 @@ function setSaved(state,msg){const el=document.getElementById('saveStat');if(!el
1502
1502
  // snapshots as-is (activateView applies each defensively — a malformed sub-snapshot is caught, not fatal —
1503
1503
  // since the engine's setClipState does NOT re-sanitise its input), and caps the list at 10.
1504
1504
  function sanitizeViews(arr){if(!Array.isArray(arr))return [];const out=[];for(const v of arr){if(!v||typeof v!=='object')continue;const id=(typeof v.id==='string'&&v.id)?v.id:('v'+Math.random().toString(36).slice(2,9));const name=(typeof v.name==='string'&&v.name.trim())?v.name.slice(0,80):'View';out.push({v:1,id,name,order:typeof v.order==='number'?v.order:out.length,camera:(v.camera&&typeof v.camera==='object')?v.camera:null,projection:v.projection==='ortho'?'ortho':'persp',mode:['solid','wire','xray'].includes(v.mode)?v.mode:'solid',clips:(v.clips&&typeof v.clips==='object')?v.clips:null,objects:(v.objects&&typeof v.objects==='object')?v.objects:null});if(out.length>=10)break;}return out;}
1505
+ // B9: do NOT flip to 'Saved ✓' here. localStorage is the instant per-browser draft; the durable copy is the
1506
+ // async persistServer() PUT (or flushContract()), which resolves later and OWNS the 'ok'/'err' transition — so
1507
+ // green means the server truly has it. Every persist() caller is paired with such a server write (before or
1508
+ // after), so the pill always resolves. A localStorage write failure is still logged + flagged 'err' here.
1505
1509
  function persist(){try{localStorage.setItem(LSKEY,JSON.stringify({sig:dataSig(),ts:Date.now(),active:C.active,
1506
1510
  custom_details:C.custom_details, profile_colors:C.profile_colors, member_styles:C.member_styles, member_types:C.member_types, target_confidence:C.target_confidence, dims3d:C.dims3d, dim_overlays:C.dim_overlays, dim_style:C.dim_style, prop_labels:C.prop_labels, joints:C.joints, detail_placements:C.detail_placements, views:C.views,
1507
- plans:C.plans.map(p=>({sheet:p.sheet,members:p.members,default_tos:p.default_tos,details:p.details,dims:p.dims,frame:p.frame||null,grid:p.grid||null}))}));setSaved('ok');}catch(e){setSaved('err');console.error('local autosave failed',e);}}
1511
+ plans:C.plans.map(p=>({sheet:p.sheet,members:p.members,default_tos:p.default_tos,details:p.details,dims:p.dims,frame:p.frame||null,grid:p.grid||null}))}));}catch(e){setSaved('err');console.error('local autosave failed',e);}}
1508
1512
  // --- server-side draft save: PUT the FULL contract C — this is the copy Approve bakes.
1509
1513
  // localStorage (persist) stays the instant per-browser draft cache; this is the durable one.
1510
1514
  // fetch does NOT reject on HTTP 400 (schema rejection), so treat !res.ok as 'err' (not a false 'Saved ✓'). ---
1511
- async function persistServer(){try{
1515
+ async function persistServer(){const seq=saveSeq;try{ // capture THIS intent's id (scheduleSave already bumped saveSeq for the edit) — a newer edit/flush bumps it again and invalidates this PUT's late response
1512
1516
  lastLocalPut = Date.now();
1513
1517
  const res=await fetch('/api/contract/'+encodeURIComponent(APP_ID)+PROJECT_QS,{method:'PUT',headers:{'content-type':'application/json'},body:JSON.stringify(C)});
1514
- setSaved(res.ok?'ok':'err');
1518
+ if(seq===saveSeq)setSaved(res.ok?'ok':'err'); // only the latest save owns the pill (a stale late response must not clobber a newer verdict)
1515
1519
  if(!res.ok)console.error('server save rejected ('+res.status+')',await res.text().catch(()=>'')); // 400 = schema reject: edits won't be what Approve bakes
1516
- }catch(e){setSaved('err');console.error('server save failed',e);}}
1517
- function scheduleSave(){setSaved('dirty');clearTimeout(saveT);saveT=setTimeout(()=>{persist();persistServer();},500);}
1520
+ }catch(e){if(seq===saveSeq)setSaved('err');console.error('server save failed',e);}}
1521
+ function scheduleSave(){setSaved('dirty');++saveSeq;clearTimeout(saveT);saveT=setTimeout(()=>{persist();persistServer();},500);} // ++saveSeq: a fresh edit is a new save intent — it invalidates any still-in-flight PUT so that PUT's late response can't flip the pill to a stale 'Saved ✓' while this edit is still unsaved (persistServer below captures this same intent id)
1518
1522
  // Flush: cancel the pending debounce and PUT the current in-memory contract to the
1519
1523
  // server right now. The parent (aware.js #contract-editor-approve) awaits this before
1520
1524
  // POSTing approve, so Approve always bakes the latest edits — not a stale debounce
@@ -1522,10 +1526,17 @@ function scheduleSave(){setSaved('dirty');clearTimeout(saveT);saveT=setTimeout((
1522
1526
  window.flushContract = async () => {
1523
1527
  clearTimeout(saveT);
1524
1528
  lastLocalPut = Date.now();
1525
- const res = await fetch('/api/contract/' + encodeURIComponent(APP_ID) + PROJECT_QS, {
1526
- method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify(C),
1527
- });
1528
- setSaved(res.ok ? 'ok' : 'err');
1529
+ const seq = ++saveSeq;
1530
+ let res;
1531
+ try {
1532
+ res = await fetch('/api/contract/' + encodeURIComponent(APP_ID) + PROJECT_QS, {
1533
+ method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify(C),
1534
+ });
1535
+ } catch (e) {
1536
+ if (seq === saveSeq) setSaved('err'); // B9: a network rejection must show "Save failed", not leave the pill stuck on "Saving…" (this fn cancels the debounced persistServer that would otherwise flag it)
1537
+ throw e; // still reject so the parent (Approve) aborts — regardless of seq
1538
+ }
1539
+ if (seq === saveSeq) setSaved(res.ok ? 'ok' : 'err'); // only the latest save owns the pill
1529
1540
  if (!res.ok) throw new Error('save failed (' + res.status + ')');
1530
1541
  };
1531
1542
  function restoreSaved(){try{const raw=localStorage.getItem(LSKEY);if(!raw)return false;const d=JSON.parse(raw);
@@ -968,7 +968,7 @@
968
968
  const legend = '<div class="kb-g-legend"><span class="kb-gleg src">Source</span><span class="kb-gleg con">Concept</span><span class="kb-gleg per">Person</span></div>';
969
969
  const note = graph.truncated ? `<div class="kb-view-note">Showing ${graph.nodes.length} — graph truncated (some pages omitted)</div>` : '';
970
970
  return '<section class="kb-col kb-graph"><div class="kb-graph-head"><span>Knowledge graph</span>' + overview + '</div>' +
971
- '<div class="kb-graph-sub">' + legend + '<span class="kb-g-hint">Click a node to open its page · scroll to zoom</span></div>' +
971
+ '<div class="kb-graph-sub">' + legend + '<span class="kb-g-hint">Click a node to open its page · scroll to zoom · drag to pan</span></div>' +
972
972
  `<div class="kb-graph-body"><svg viewBox="0 0 ${W} ${H}" data-vb-base="0 0 ${W} ${H}" class="kb-graph-svg" role="group" aria-label="Knowledge graph">${lines}${dots}</svg>` +
973
973
  `<button type="button" class="kb-g-fit" data-kb-fit hidden data-tip="Zoom to fit (Home)" aria-label="Zoom to fit">⤢ Fit</button></div>${note}</section>`;
974
974
  }
@@ -990,6 +990,7 @@
990
990
  const off = Math.abs(w - bw) > 0.5 || Math.abs(x - bx) > 0.5 || Math.abs(y - by) > 0.5;
991
991
  const fit = svg.parentElement.querySelector('[data-kb-fit]');
992
992
  if (fit) fit.hidden = !off;
993
+ svg.classList.toggle('kb-zoomed', w < bw - 0.5); // pannable (zoomed in) → the SVG shows a grab cursor
993
994
  }
994
995
  function kbFitGraph(svg) { const b = svg.dataset.vbBase.split(' ').map(Number); kbSetVb(svg, b[0], b[1], b[2], b[3]); }
995
996
  function kbZoomGraph(svg, clientX, clientY, factor) {
@@ -1701,6 +1702,42 @@
1701
1702
  e.preventDefault();
1702
1703
  kbZoomGraph(svg, e.clientX, e.clientY, e.deltaY < 0 ? 0.85 : 1 / 0.85);
1703
1704
  }, { passive: false });
1705
+ // Drag to pan — mirrors the main canvas's pan model (web/app.js): MIDDLE-mouse anywhere, OR LEFT-drag
1706
+ // on empty background (never a node — those open on click), so pan is reachable without a middle button
1707
+ // (trackpads have none). Window-level move/up track the drag past the SVG edge; client px ÷ the on-screen
1708
+ // (letterbox-fitted) scale → viewBox units, clamped to the content box like zoom. Only starts when zoomed
1709
+ // in — at fit there's nothing outside the box, so a press there is a true no-op (no cursor flip).
1710
+ let kbPan = null;
1711
+ $wsKnowledge.addEventListener('mousedown', (e) => {
1712
+ const svg = e.target.closest('.kb-graph-svg');
1713
+ if (!svg) return;
1714
+ const isMiddle = e.button === 1;
1715
+ const isLeftBg = e.button === 0 && !e.target.closest('.kb-g-node');
1716
+ if (!isMiddle && !isLeftBg) return;
1717
+ if (isMiddle) e.preventDefault(); // kill middle-click autoscroll even at fit
1718
+ const [x, y, w, h] = svg.getAttribute('viewBox').split(' ').map(Number);
1719
+ const [, , bw, bh] = svg.dataset.vbBase.split(' ').map(Number);
1720
+ if (w >= bw && h >= bh) return; // at fit: nothing to pan
1721
+ e.preventDefault(); // suppress text selection while dragging
1722
+ const rect = svg.getBoundingClientRect();
1723
+ const scale = Math.min(rect.width / w, rect.height / h); // on-screen px per viewBox unit (meet)
1724
+ kbPan = { svg, sx: e.clientX, sy: e.clientY, vx: x, vy: y, w, h, scale, bw, bh };
1725
+ svg.classList.add('kb-panning');
1726
+ });
1727
+ window.addEventListener('mousemove', (e) => {
1728
+ if (!kbPan) return;
1729
+ const { svg, sx, sy, vx, vy, w, h, scale, bw, bh } = kbPan;
1730
+ if (!svg.isConnected) { kbPan = null; return; } // graph re-rendered (generation change) mid-drag — drop the stale ref
1731
+ const nx = Math.max(0, Math.min(bw - w, vx - (e.clientX - sx) / scale));
1732
+ const ny = Math.max(0, Math.min(bh - h, vy - (e.clientY - sy) / scale));
1733
+ kbSetVb(svg, nx, ny, w, h); // node counter-scale is unchanged during a pan (w fixed) — a redundant but cheap re-apply, bounded by the graph's node cap
1734
+ });
1735
+ window.addEventListener('mouseup', () => {
1736
+ if (!kbPan) return;
1737
+ kbPan.svg.classList.remove('kb-panning');
1738
+ kbPan = null;
1739
+ });
1740
+ $wsKnowledge.addEventListener('auxclick', (e) => { if (e.button === 1) e.preventDefault(); }); // suppress the middle-click default aux action (paste / new-tab); autoscroll is already killed on mousedown
1704
1741
  // Graph nodes are keyboard-focusable (tabindex="0" role="button") but SVG <g> elements have no
1705
1742
  // native activation behaviour, so Enter/Space must be wired explicitly.
1706
1743
  $wsKnowledge.addEventListener('keydown', (e) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floless/app",
3
- "version": "0.99.0",
3
+ "version": "0.99.2",
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": {