@floless/app 0.98.0 → 0.99.1
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 +1359 -1266
- package/dist/web/steel-editor.html +41 -21
- package/package.json +1 -1
|
@@ -1098,7 +1098,7 @@ async function boot() {
|
|
|
1098
1098
|
}
|
|
1099
1099
|
} catch (_) { /* no target goal shown */ }
|
|
1100
1100
|
PAL = (Array.isArray(C.palette) && C.palette.length) ? C.palette : DEFAULT_PAL; WT = C.weights || {};
|
|
1101
|
-
try { const _sr = await fetch('/api/aisc-shapes'); if (_sr.ok) { const _sj = await _sr.json(); if (Array.isArray(_sj.shapes)) window.__AISC_SHAPES = new Set(_sj.shapes); if (_sj.bf && typeof _sj.bf === 'object') window.__AISC_BF = _sj.bf; } } catch (_) { /* no shape table → _nominalPlf falls back to regex-only; columns fall back to the marker footprint */ }
|
|
1101
|
+
try { const _sr = await fetch('/api/aisc-shapes'); if (_sr.ok) { const _sj = await _sr.json(); if (Array.isArray(_sj.shapes)) window.__AISC_SHAPES = new Set(_sj.shapes); if (_sj.bf && typeof _sj.bf === 'object') window.__AISC_BF = _sj.bf; if (_sj.sections && typeof _sj.sections === 'object') window.__AISC_SECTIONS = _sj.sections; } } catch (_) { /* no shape table → _nominalPlf falls back to regex-only; columns fall back to the marker footprint */ }
|
|
1102
1102
|
// No weight seeding needed: every RFI/weight read resolves through _wt(), which falls back to the
|
|
1103
1103
|
// SHAPES-guarded _nominalPlf for a valid AISC designation absent from the contract's weights map.
|
|
1104
1104
|
C.custom_details = C.custom_details || {};
|
|
@@ -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}))}));
|
|
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
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
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);
|
|
@@ -1551,9 +1562,12 @@ function updUR(){document.getElementById('undoB').disabled=!undo.length;document
|
|
|
1551
1562
|
// index moved off it — a blank/RFI/other-plan profile must not shift a real profile's slot.) Rebuilt at
|
|
1552
1563
|
// render() top so it tracks edits without touching every profs.push site.
|
|
1553
1564
|
let colorRank=[];
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1565
|
+
// Canonical designation (MIRRORS server contract-to-scene canonProfile): upper, x/X/× → X, whitespace
|
|
1566
|
+
// around X / after the prefix removed, mixed-fraction spaces kept. One identity for 2D / 3D / IFC / Tekla.
|
|
1567
|
+
function canonProfile(s){return String(s||'').trim().toUpperCase().replace(/×/g,'X').replace(/\s*X\s*/g,'X').replace(/^([A-Z]+)\s+/,'$1');}
|
|
1568
|
+
function buildColorRank(){colorRank=[...new Set([...(C.plans||[]).flatMap(pl=>(pl.members||[]).map(m=>canonProfile(m.profile))).filter(Boolean), ...Object.keys(WT||{}).map(canonProfile)])].sort();}
|
|
1569
|
+
function colorFor(p){const k=canonProfile(p);
|
|
1570
|
+
const ov=C.profile_colors[p]??(Object.entries(C.profile_colors).find(([kk])=>canonProfile(kk)===k)||[])[1]; // override: exact key, then canonical (case + x/X/× + separator whitespace) — mirrors contract-to-scene pickColor so an override resolves identically in 2D + 3D
|
|
1557
1571
|
if(ov)return ov;
|
|
1558
1572
|
const i=colorRank.indexOf(k);return PAL[((i%PAL.length)+PAL.length)%PAL.length];} // i<0 (blank/CUSTOM/unresolved) wraps to PAL[last], matching pickColor so those members agree in 2D + 3D too
|
|
1559
1573
|
// F5: per member-type 2D line style. Tokens → px; dashes chosen to avoid the reserved semantic patterns
|
|
@@ -1585,14 +1599,20 @@ function len(a,b){return Math.hypot(a[0]-b[0],a[1]-b[1]);}
|
|
|
1585
1599
|
// /api/aisc-shapes. Returns null for an unresolved mark (RFI).
|
|
1586
1600
|
function profileDimsIn(profile){
|
|
1587
1601
|
if(!profile)return null;
|
|
1588
|
-
const p=String(profile).trim().toUpperCase();
|
|
1602
|
+
const p=String(profile).trim().toUpperCase().replace(/×/g,'X'); // separator may be x / X / ×
|
|
1589
1603
|
if(p===''||/(^|[^A-Z])MF($|[^A-Z])/.test(p))return null;
|
|
1590
|
-
const m=p.match(/^([A-Z]+)\s*(
|
|
1591
|
-
|
|
1604
|
+
const m=p.match(/^([A-Z]+)\s*(.+)$/);if(!m)return null;
|
|
1605
|
+
// parseDim (not parseFloat) so a mixed-fraction leg "3 1/2" → 3.5, not 3 — mirrors server contract-to-scene.
|
|
1606
|
+
const _pd=t=>{const s=String(t).trim();let mm=s.match(/^(\d+)\s+(\d+)\/(\d+)$/);if(mm)return +mm[1]+ +mm[2]/+mm[3];mm=s.match(/^(\d+)\/(\d+)$/);if(mm)return +mm[1]/+mm[2];const d=parseFloat(s);return isFinite(d)?d:null;};
|
|
1607
|
+
const prefix=m[1],nums=m[2].split('X').map(_pd).filter(n=>n!=null);
|
|
1592
1608
|
if(!nums.length)return null;
|
|
1593
1609
|
if((prefix==='HSS'||prefix==='TUBE'||prefix==='L')&&nums.length>=3)return{d:nums[0],w:nums[1]};
|
|
1594
1610
|
if(prefix==='HSS'||prefix==='PIPE'){const dia=nums[0];return{d:dia,w:dia};}
|
|
1595
|
-
if(/^(W|S|M|HP|C|MC|WT|ST|MT)$/.test(prefix)){const
|
|
1611
|
+
if(/^(W|S|M|HP|C|MC|WT|ST|MT)$/.test(prefix)){const key=p.replace(/\s+/g,'');
|
|
1612
|
+
// ACTUAL AISC depth+width when tabulated (the leading number is the NOMINAL series depth). Mirrors
|
|
1613
|
+
// server sectionDimsIn → __AISC_SECTIONS {designation:[d,bf]} from /api/aisc-shapes.
|
|
1614
|
+
const sec=(window.__AISC_SECTIONS||{})[key];if(sec)return{d:sec[0],w:sec[1]};
|
|
1615
|
+
const d=nums[0],bf=(window.__AISC_BF||{})[key];
|
|
1596
1616
|
if(bf!==undefined)return{d,w:bf};const ratio=(prefix==='C'||prefix==='MC')?0.28:0.42;return{d,w:d*ratio};}
|
|
1597
1617
|
return null;
|
|
1598
1618
|
}
|
|
@@ -4872,7 +4892,7 @@ function wireTypeFilter(p){
|
|
|
4872
4892
|
b.onkeydown=e=>{if(e.key==='Enter'||e.key===' '){e.preventDefault();e.stopPropagation();act(e.altKey);}}; // native <button> Enter/Space bubbles to the global idle-repeat-last handler (:3838, !inForm) which preventDefaults activation — activate here + stopPropagation, mirroring the F12 RFI pill (:2632). Alt+Enter/Space isolates (keyboard parity).
|
|
4873
4893
|
});
|
|
4874
4894
|
}
|
|
4875
|
-
function profileKeyOf(m){return (m&&m.profile
|
|
4895
|
+
function profileKeyOf(m){return canonProfile(m&&m.profile);} // matches the scene group key (contract-to-scene canonProfile)
|
|
4876
4896
|
function categoryOfProfile(profKey){for(const m of (P.members||[]))if(profileKeyOf(m)===profKey)return memberTypeOf(m);return 'beam';} // a profile-group's category = the type of its member(s)
|
|
4877
4897
|
let legendMode=(localStorage.getItem('floless.legendMode')==='type')?'type':'profile';
|
|
4878
4898
|
let collapsedCats=new Set((()=>{try{return JSON.parse(localStorage.getItem('floless.legendCollapsed')||'[]');}catch{return [];}})());
|
|
@@ -6122,11 +6142,11 @@ const BANDPILL={verified:'background:#166534;color:#86efac',high:'background:#14
|
|
|
6122
6142
|
// "×" IS the AISC lb/ft (W10X33 = 33). Resolves a valid size even with no weights map — but ONLY a size that
|
|
6123
6143
|
// actually exists in the AISC catalogue (SHAPES), so a regex-matching but non-standard string (e.g. W99X999)
|
|
6124
6144
|
// stays unresolved (RFI) instead of being trusted for a bogus name-encoded weight.
|
|
6125
|
-
function _nominalPlf(p){const k=String(p||'').toUpperCase().replace(/\s/g,'');const m=k.match(/^(W|M|S|HP|C|MC|WT|MT|ST)\d+(?:\.\d+)?X([\d.]+)$/);if(!m)return null;const _S=window.__AISC_SHAPES;if(_S&&!_S.has(k))return null;return parseFloat(m[2]);}
|
|
6145
|
+
function _nominalPlf(p){const k=String(p||'').toUpperCase().replace(/\s/g,'').replace(/×/g,'X');const m=k.match(/^(W|M|S|HP|C|MC|WT|MT|ST)\d+(?:\.\d+)?X([\d.]+)$/);if(!m)return null;const _S=window.__AISC_SHAPES;if(_S&&!_S.has(k))return null;return parseFloat(m[2]);}
|
|
6126
6146
|
function _ensureWt(p){if(p&&WT&&WT[p]==null){const v=_nominalPlf(p);if(v!=null)WT[p]=v;}}
|
|
6127
6147
|
function _wt(profile){if(!profile)return null;
|
|
6128
6148
|
if(WT&&profile in WT&&WT[profile]!=null)return WT[profile];
|
|
6129
|
-
if(WT){const h=Object.entries(WT).find(([k])=>k
|
|
6149
|
+
if(WT){const t=canonProfile(profile);const h=Object.entries(WT).find(([k])=>canonProfile(k)===t);if(h&&h[1]!=null)return h[1];} // shared canonProfile identity so a ×/spaced designation matches its weight-map key
|
|
6130
6150
|
return _nominalPlf(profile);} // fall back to the lb/ft encoded in a standard designation
|
|
6131
6151
|
const _isMf=p=>!!p&&/(^|[^A-Z])MF($|[^A-Z])/i.test(p);
|
|
6132
6152
|
// Elevation-aware coincident dedupe for the browser confidence panel — same footprint+wildcard-elevation logic as
|