@floless/app 0.102.0 → 0.103.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 +4077 -1492
- package/dist/web/app.css +71 -2
- package/dist/web/app.js +11 -0
- package/dist/web/aware.js +328 -13
- package/dist/web/index.html +1 -1
- package/dist/web/steel-editor.html +13 -10
- package/dist/web/workspaces.js +246 -30
- package/package.json +1 -1
|
@@ -6397,7 +6397,7 @@ function updConnBtn(){const b=document.getElementById('connBtn');if(b)b.textCont
|
|
|
6397
6397
|
// --- Auto-detail base plates: one click adds a base-plate joint (engine defaults) to every column
|
|
6398
6398
|
// that lacks one; once all columns are detailed, clicking again clears the AUTO ones (user-placed/
|
|
6399
6399
|
// AI-tuned base plates are kept). The engine renders the plate + anchor kit + weld in 3D. ---
|
|
6400
|
-
function colMemberIds(){const ids=[];for(const m of (
|
|
6400
|
+
function colMemberIds(){const ids=[];for(const m of allMembers())if(m&&m.role==='column'&&m.id)ids.push(m.id);return ids;} // EVERY sheet's columns — selection, joints (C.joints) and undo are all model-wide, so the selection-scoped auto-detail must see columns on any sheet (else selecting a column on a non-active sheet in 3D wrongly disables Base plates).
|
|
6401
6401
|
function bpTargetIds(){const all=colMemberIds();return selIds.size?all.filter(id=>selIds.has(id)):all;} // selected columns scope the auto-detail; empty selection = every column (issue: create for selection, still supports all)
|
|
6402
6402
|
function bpJointId(mid){const ids=new Set((C.joints||[]).map(j=>j&&j.id));let id='bp-'+mid,k=2;while(ids.has(id))id='bp-'+mid+'-'+(k++);return id;} // unique vs ANY existing joint id (no collision with a user-placed joint)
|
|
6403
6403
|
function updBpBtn(){const b=document.getElementById('bpBtn');if(!b)return;
|
|
@@ -6429,8 +6429,8 @@ function toggleBasePlates(){
|
|
|
6429
6429
|
// --- Auto-detail shear plates: one click adds a shear-plate joint to every ELIGIBLE beam end that lacks
|
|
6430
6430
|
// one; once all eligible ends are detailed, clicking again clears the AUTO ones (user/AI-tuned kept). An
|
|
6431
6431
|
// end is eligible when its connection note/row reads shear/simple, or it frames into a support and isn't
|
|
6432
|
-
// marked moment. main = the beam, at = end0|end1, secondaries = [support] (geometry inferred).
|
|
6433
|
-
// undoable (rides snapshot()/apply()
|
|
6432
|
+
// marked moment. main = the beam, at = end0|end1, secondaries = [support] (geometry inferred). Model-wide
|
|
6433
|
+
// (like base plates — targets scan allMembers()), undoable (rides snapshot()/apply()). The engine renders the fin plate + bolt
|
|
6434
6434
|
// group + weld (+ optional stiffener) in 3D. ---
|
|
6435
6435
|
function spConnText(end){const r=end&&end.conn?connRowById(end.conn):null;return ((r&&r.type)||'')+' '+((end&&end.note)||'');}
|
|
6436
6436
|
function spIsMoment(t){return /moment|fixed|\bmf\b|fully\s*weld/i.test(t||'');}
|
|
@@ -6438,17 +6438,18 @@ function spIsShear(t){return /shear|fin|tab|clip|simple|pin|web/i.test(t||'');}
|
|
|
6438
6438
|
function spDist(a,b){return Math.hypot(a[0]-b[0],a[1]-b[1]);}
|
|
6439
6439
|
function spDistToSeg(p,a,b){const vx=b[0]-a[0],vy=b[1]-a[1],L2=vx*vx+vy*vy;if(L2<1e-9)return spDist(p,a);
|
|
6440
6440
|
let t=((p[0]-a[0])*vx+(p[1]-a[1])*vy)/L2;t=Math.max(0,Math.min(1,t));return spDist(p,[a[0]+t*vx,a[1]+t*vy]);}
|
|
6441
|
-
function spSupportTol(){const k=(
|
|
6441
|
+
function spSupportTol(pl){const p=pl||P,k=(p.pt_per_ft&&p.pt_per_ft>0)?p.pt_per_ft:12;return Math.max(6,0.75*k);} // ~9in at the given plan's scale, min 6 display-pts: "the beam end meets this member". pt_per_ft is PER-SHEET, so the tolerance must use the beam's OWN plane (below), not the active one.
|
|
6442
6442
|
function spInferSupport(beam,endIdx){if(!beam||!Array.isArray(beam.wp)||beam.wp.length<2)return null;const pt=beam.wp[endIdx];if(!pt)return null;
|
|
6443
|
-
|
|
6443
|
+
const pl=planeOfMember(beam)||P; // measure distances AND scale the tolerance in the beam's OWN sheet (wp are per-sheet 2D coords at that sheet's pt_per_ft — cross-sheet proximity is meaningless)
|
|
6444
|
+
let best=null,bd=Infinity;for(const m of (pl.members||[])){if(!m||m.id===beam.id||isBrace(m)||!Array.isArray(m.wp)||!m.wp.length)continue; // a brace never SUPPORTS a shear plate (mirrors server inferSupport)
|
|
6444
6445
|
const d=(m.role==='column')?spDist(pt,m.wp[0]):(m.wp.length>=2?spDistToSeg(pt,m.wp[0],m.wp[1]):spDist(pt,m.wp[0]));if(d<bd){bd=d;best=m;}}
|
|
6445
|
-
return (best&&bd<=spSupportTol())?best:null;}
|
|
6446
|
+
return (best&&bd<=spSupportTol(pl))?best:null;}
|
|
6446
6447
|
function spEndEligible(beam,endIdx){if(!beam||beam.role==='column'||isBrace(beam)||!beam.ends)return false; // a brace never CARRIES a shear plate (mirrors server expandJoints)
|
|
6447
6448
|
if(beam.mf===true||/^MF/i.test(beam.profile||''))return false; // a moment-frame girder (resolved via Frames → m.mf, or an unresolved MF mark) takes a MOMENT connection, not a shear tab
|
|
6448
6449
|
const end=beam.ends[endIdx];if(!end)return false;
|
|
6449
6450
|
const t=spConnText(end);if(spIsMoment(t))return false;if(spIsShear(t))return true;return !!spInferSupport(beam,endIdx);} // explicit moment → no; explicit shear → yes; else propose only where the end frames into a support
|
|
6450
|
-
function spEligibleEnds(){const out=[];for(const m of (
|
|
6451
|
-
function spBeamIds(){const s=new Set();for(const m of (
|
|
6451
|
+
function spEligibleEnds(){const out=[];for(const m of allMembers()){if(!m||m.role==='column'||isBrace(m))continue;for(const e of [0,1])if(spEndEligible(m,e))out.push({beam:m,endIdx:e});}return out;} // EVERY sheet's beams — eligibility per end still resolves the support within the beam's own sheet (spInferSupport)
|
|
6452
|
+
function spBeamIds(){const s=new Set();for(const m of allMembers())if(m&&m.role!=='column'&&!isBrace(m)&&m.id)s.add(m.id);return s;} // EVERY sheet's beams (never braces) — selection/joints/undo are model-wide, so a model-wide selection scopes correctly
|
|
6452
6453
|
function spJointOf(beamId,endIdx){return (C.joints||[]).find(j=>j&&j.kind==='shear-plate'&&j.main===beamId&&j.at==='end'+endIdx);}
|
|
6453
6454
|
function spTargetEnds(){const e=spEligibleEnds();return selIds.size?e.filter(({beam})=>selIds.has(beam.id)):e;} // eligible ends of the SELECTED beams; empty selection = every eligible end (issue: create for selection, still supports all)
|
|
6454
6455
|
function spJointId(beamId,endIdx){const ids=new Set((C.joints||[]).map(j=>j&&j.id));let id='sp-'+beamId+'-e'+endIdx,k=2;while(ids.has(id))id='sp-'+beamId+'-e'+endIdx+'-'+(k++);return id;} // unique vs ANY existing joint id
|
|
@@ -6890,6 +6891,7 @@ const _restored=restoreSaved(); // bring back this brows
|
|
|
6890
6891
|
// non-brace, clamp bad values. Covers reader-emitted, partial and localStorage-restored payloads, so it runs
|
|
6891
6892
|
// AFTER restoreSaved() and BEFORE the first paint. (normBrace lives inside main(); boot() can't see it.)
|
|
6892
6893
|
for(const _p of (C.plans||[]))for(const _m of (_p.members||[]))normBrace(_m);
|
|
6894
|
+
for(const _p of (C.plans||[]))for(const _m of (_p.members||[]))ensureMeta(_m); // normalize role/ends/col on EVERY sheet, not just the active one setPlan() does — model-wide detailing (Base/Shear plates) reads off-sheet members, so a beam with no authored `ends` must be normalized here or it reads as ineligible until its sheet is opened. Same order as the active plan (normBrace → ensureMeta).
|
|
6893
6895
|
for(const _p of (C.plans||[]))sanitizeDims(_p); // F9: validate magnetic dim refs on EVERY sheet (not just the active one setPlan sanitizes) — an unvisited plan could otherwise keep a stale/cross-plan ref (Codex R1 #17). Runs after normBrace so isBrace is reliable.
|
|
6894
6896
|
// Migrate every plan before the first whole-contract validation/save/3D build. Visiting sheets one-by-one must
|
|
6895
6897
|
// not be required to turn legacy scalar/overlong labels_z into the canonical bounded array.
|
|
@@ -7362,7 +7364,8 @@ if(new URLSearchParams(location.search).get('selftest')==='1'){(function(){
|
|
|
7362
7364
|
C.joints=sj;}
|
|
7363
7365
|
|
|
7364
7366
|
// Detailing scoping + selected-connection delete (issue: create/remove for the selection, not the whole model)
|
|
7365
|
-
{const sj=C.joints,ss=selIds,sPb=partsById;
|
|
7367
|
+
{const sj=C.joints,ss=selIds,sPb=partsById,sPl=C.plans,sA=C.active;
|
|
7368
|
+
C.plans=[P];C.active=0; // isolate: the target helpers are model-wide (allMembers over C.plans), so pin the world to this one test plan or a real multi-sheet contract's off-sheet columns/beams would leak into the counts
|
|
7366
7369
|
// base plates: selection scopes the target columns; empty selection = every column
|
|
7367
7370
|
P.members=[{id:'C1',role:'column',wp:[[0,0]]},{id:'C2',role:'column',wp:[[100,0]]}];
|
|
7368
7371
|
selIds=new Set();ok(bpTargetIds().length===2,'bpTargetIds → every column when nothing is selected');
|
|
@@ -7378,7 +7381,7 @@ if(new URLSearchParams(location.search).get('selftest')==='1'){(function(){
|
|
|
7378
7381
|
selIds=new Set(['jA:plate','jA:bolt0']);
|
|
7379
7382
|
ok(selIsConnOnly()&&selJointIds().size===1&&selJointIds().has('jA'),'selJointIds/selIsConnOnly → the one joint of the selected parts');
|
|
7380
7383
|
selIds=new Set(['jA:plate','C1']);ok(!selIsConnOnly(),'selIsConnOnly false when a member is mixed in');
|
|
7381
|
-
C.joints=sj;selIds=ss;partsById=sPb;}
|
|
7384
|
+
C.joints=sj;selIds=ss;partsById=sPb;C.plans=sPl;C.active=sA;}
|
|
7382
7385
|
|
|
7383
7386
|
// the editor's confidence mirror: brace ends are not scored as beam connections
|
|
7384
7387
|
{const spl=C.plans,sa=C.active;
|
package/dist/web/workspaces.js
CHANGED
|
@@ -112,6 +112,9 @@
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
let exportState = null; // kind → { path, exportedAt } after a successful list; null = unknown/failed
|
|
115
|
+
let teklaReadinessState = null; // latest machine-readable readiness result; {state:'checking'} while probing
|
|
116
|
+
const exportReceipts = new Map(); // projectId:kind → reconciled receipt counts for this browser session
|
|
117
|
+
const exportBusy = new Set(); // projectId:kind → one in-flight export
|
|
115
118
|
if (!$switch || !$landing || !$app) return; // markup absent — nothing to wire
|
|
116
119
|
|
|
117
120
|
// The picker menu is a `.menu` (display:none by default; `.menu.show` → display:block, which
|
|
@@ -535,6 +538,8 @@
|
|
|
535
538
|
// matching the create-card skip. wsApp() would return null for it and the frame wiring would fail.
|
|
536
539
|
if (!WORKSPACE_APPS[p.app]) { showToast('This project’s app isn’t available as a workspace.', 'warn'); return; }
|
|
537
540
|
current = p;
|
|
541
|
+
exportState = null;
|
|
542
|
+
teklaReadinessState = null;
|
|
538
543
|
track('workspace_project_opened', { app: p.app }); // a real open (card click or post-create landing)
|
|
539
544
|
lastRevState = 'none'; stopRevisionPoll(); // fresh project — drop any prior revision-poll state
|
|
540
545
|
$projName.textContent = p.name;
|
|
@@ -557,6 +562,8 @@
|
|
|
557
562
|
}
|
|
558
563
|
function closeProject() {
|
|
559
564
|
current = null;
|
|
565
|
+
exportState = null;
|
|
566
|
+
teklaReadinessState = null;
|
|
560
567
|
stopRevisionPoll();
|
|
561
568
|
stopKnowledgePoll(); kbCloseConfirm(); kbResetViewer(); knowledgeState = null; // the KB pane is per-project — never carry it across
|
|
562
569
|
lastRevState = 'none'; $revisionCard.hidden = true; closeProjMenu(); applyMode(); syncWorkspaceGuide();
|
|
@@ -1838,12 +1845,85 @@
|
|
|
1838
1845
|
return `${base}/export-tekla${qs}`; // tekla
|
|
1839
1846
|
}
|
|
1840
1847
|
|
|
1848
|
+
const receiptKey = (kind) => `${current ? current.id : ''}:${kind}`;
|
|
1849
|
+
|
|
1850
|
+
function receiptItemText(prefix, value) {
|
|
1851
|
+
if (typeof value === 'string') return `${prefix}: ${value}`;
|
|
1852
|
+
if (!value || typeof value !== 'object') return `${prefix}: ${String(value)}`;
|
|
1853
|
+
const parts = [value.id, value.code, value.message].filter((part) => typeof part === 'string' && part.trim());
|
|
1854
|
+
if (parts.length) return `${prefix}: ${parts.join(' · ')}`;
|
|
1855
|
+
try { return `${prefix}: ${JSON.stringify(value)}`; }
|
|
1856
|
+
catch { return `${prefix}: detail unavailable`; }
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
function receiptSummary(receipt, kind) {
|
|
1860
|
+
if (!receipt || !receipt.counts) return null;
|
|
1861
|
+
const c = receipt.counts;
|
|
1862
|
+
const parts = [`${Number(c.emitted) || 0} emitted`];
|
|
1863
|
+
if (kind === 'tekla' && Number.isFinite(Number(c.native))) parts.push(`${Number(c.native)} native`);
|
|
1864
|
+
if (Number(c.unsupported)) parts.push(`${Number(c.unsupported)} unsupported`);
|
|
1865
|
+
if (Number(c.warnings)) parts.push(`${Number(c.warnings)} warning${Number(c.warnings) === 1 ? '' : 's'}`);
|
|
1866
|
+
return {
|
|
1867
|
+
text: parts.join(' · '),
|
|
1868
|
+
partial: Number(c.unsupported) > 0 || Number(c.warnings) > 0,
|
|
1869
|
+
details: [
|
|
1870
|
+
...(Array.isArray(receipt.unsupported) ? receipt.unsupported.map((row) => receiptItemText('Unsupported', row)) : []),
|
|
1871
|
+
...(Array.isArray(receipt.warnings) ? receipt.warnings.map((warning) => receiptItemText('Warning', warning)) : []),
|
|
1872
|
+
].join('\n'),
|
|
1873
|
+
};
|
|
1874
|
+
}
|
|
1875
|
+
|
|
1876
|
+
function receiptHtml(kind, approved) {
|
|
1877
|
+
const receipt = exportReceipts.get(receiptKey(kind));
|
|
1878
|
+
if (!approved || !receipt || receipt.approvedAt !== current.approvedAt) return '';
|
|
1879
|
+
const summary = receiptSummary(receipt, kind);
|
|
1880
|
+
if (!summary) return '';
|
|
1881
|
+
return `<div class="e-receipt${summary.partial ? ' partial' : ''}">` +
|
|
1882
|
+
`<span role="status" aria-live="polite">Last export${summary.partial ? ' with gaps' : ''} · ${escapeHtml(summary.text)}</span>` +
|
|
1883
|
+
(summary.details ? `<button type="button" class="e-receipt-details" data-export-details="${escapeAttr(kind)}">View details</button>` : '') +
|
|
1884
|
+
`</div>`;
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
function teklaCardState(approved) {
|
|
1888
|
+
if (!approved) return {
|
|
1889
|
+
meta: '<span class="e-status">Available after approval</span>',
|
|
1890
|
+
disabled: true,
|
|
1891
|
+
tip: 'Approve this version first',
|
|
1892
|
+
};
|
|
1893
|
+
const readiness = teklaReadinessState;
|
|
1894
|
+
if (!readiness || readiness.state === 'checking') return {
|
|
1895
|
+
meta: '<span class="e-readiness checking" role="status" aria-live="polite"><span class="rtn-spinner" aria-hidden="true"></span> Checking Tekla readiness…</span>',
|
|
1896
|
+
disabled: true,
|
|
1897
|
+
tip: 'Checking AWARE, the Tekla bridge, and the open model',
|
|
1898
|
+
};
|
|
1899
|
+
if (readiness.ok && readiness.state === 'ready') {
|
|
1900
|
+
const version = readiness.host && readiness.host.version ? ` · Tekla ${readiness.host.version}` : '';
|
|
1901
|
+
return {
|
|
1902
|
+
meta: `<span class="e-readiness ready" role="status" aria-live="polite">Ready${escapeHtml(version)}</span>`,
|
|
1903
|
+
disabled: false,
|
|
1904
|
+
tip: 'Create native parts in the open Tekla model',
|
|
1905
|
+
};
|
|
1906
|
+
}
|
|
1907
|
+
const recovery = readiness.recovery || { action: 'retry', label: 'Check again' };
|
|
1908
|
+
const label = recovery.action === 'open-tekla' || recovery.action === 'open-model' || recovery.action === 'retry'
|
|
1909
|
+
? 'Check again'
|
|
1910
|
+
: recovery.label;
|
|
1911
|
+
return {
|
|
1912
|
+
meta: `<span class="e-readiness blocked" role="status" aria-live="polite">${escapeHtml(readiness.message || 'Tekla readiness could not be verified.')}</span>` +
|
|
1913
|
+
`<button type="button" class="e-recovery" data-tekla-recovery="${escapeAttr(recovery.action)}">${escapeHtml(label)}</button>`,
|
|
1914
|
+
disabled: true,
|
|
1915
|
+
tip: readiness.message || 'Resolve the Tekla readiness check first',
|
|
1916
|
+
};
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1841
1919
|
function cardHtml(c, approved) {
|
|
1842
1920
|
let meta;
|
|
1843
|
-
|
|
1921
|
+
const busy = exportBusy.has(`${current.id}:${c.kind}`);
|
|
1922
|
+
const tekla = c.kind === 'tekla' ? teklaCardState(approved) : null;
|
|
1923
|
+
if (tekla) {
|
|
1924
|
+
meta = tekla.meta;
|
|
1925
|
+
} else if (!approved) {
|
|
1844
1926
|
meta = `<span class="e-status">Available after approval</span>`;
|
|
1845
|
-
} else if (!c.file) {
|
|
1846
|
-
meta = `<span class="e-status">Creates parts in the open Tekla model</span>`;
|
|
1847
1927
|
} else if (exportState == null) {
|
|
1848
1928
|
// The listing failed — say so honestly; never a fake "not exported yet" (silent-failure rule).
|
|
1849
1929
|
meta = `<span class="e-status">Status unavailable</span>`;
|
|
@@ -1860,74 +1940,206 @@
|
|
|
1860
1940
|
}
|
|
1861
1941
|
}
|
|
1862
1942
|
const exported = approved && c.file && exportState && exportState[c.kind] && exportState[c.kind].exportedAt;
|
|
1863
|
-
const label = exported ? 'Re-export' : c.verb;
|
|
1864
|
-
const
|
|
1943
|
+
const label = busy ? (c.kind === 'tekla' ? 'Sending…' : 'Exporting…') : (exported ? 'Re-export' : c.verb);
|
|
1944
|
+
const disabled = tekla ? tekla.disabled : !approved;
|
|
1945
|
+
const tip = busy ? (c.kind === 'tekla' ? 'Sending the approved model to Tekla' : 'Export in progress')
|
|
1946
|
+
: tekla ? tekla.tip : (approved ? '' : 'Approve this version first');
|
|
1947
|
+
const dis = `${disabled && !busy ? ' disabled' : ''}${busy ? ' aria-disabled="true" aria-busy="true"' : ''}${tip ? ` data-tip="${escapeAttr(tip)}"` : ''}`;
|
|
1865
1948
|
return `<div class="ecard">` +
|
|
1866
1949
|
`<div class="e-top"><div class="e-ico">${escapeHtml(c.ico)}</div>` +
|
|
1867
1950
|
`<div><div class="e-name">${escapeHtml(c.name)}</div><div class="e-fmt">${escapeHtml(c.fmt)}</div></div></div>` +
|
|
1868
|
-
`<div class="e-meta">${meta}</div>` +
|
|
1951
|
+
`<div class="e-meta${tekla ? ' e-meta-tekla' : ''}">${meta}</div>` +
|
|
1952
|
+
receiptHtml(c.kind, approved) +
|
|
1869
1953
|
`<div class="e-act"><button type="button" data-export="${escapeAttr(c.kind)}"${dis}>↗ ${escapeHtml(label)}</button></div>` +
|
|
1870
1954
|
`</div>`;
|
|
1871
1955
|
}
|
|
1872
1956
|
|
|
1957
|
+
const EXPORT_FOCUS_ATTRS = [
|
|
1958
|
+
'data-export',
|
|
1959
|
+
'data-openfile',
|
|
1960
|
+
'data-reveal',
|
|
1961
|
+
'data-export-details',
|
|
1962
|
+
'data-tekla-recovery',
|
|
1963
|
+
];
|
|
1964
|
+
|
|
1965
|
+
function exportFocusIdentity(element) {
|
|
1966
|
+
if (!element || !$wsExports.contains(element)) return null;
|
|
1967
|
+
const cardKind = element.closest('.ecard')?.querySelector('[data-export]')?.dataset.export || null;
|
|
1968
|
+
for (const attr of EXPORT_FOCUS_ATTRS) {
|
|
1969
|
+
if (element.hasAttribute(attr)) return { attr, value: element.getAttribute(attr), cardKind };
|
|
1970
|
+
}
|
|
1971
|
+
return element.id === 'ws-exports-approve' ? { id: element.id, cardKind: null } : null;
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1974
|
+
function restoreExportFocus(identity) {
|
|
1975
|
+
if (!identity) return;
|
|
1976
|
+
const replacement = identity.id
|
|
1977
|
+
? $wsExports.querySelector(`#${identity.id}`)
|
|
1978
|
+
: Array.from($wsExports.querySelectorAll(`[${identity.attr}]`))
|
|
1979
|
+
.find((candidate) => candidate.getAttribute(identity.attr) === identity.value);
|
|
1980
|
+
if (replacement && !replacement.disabled) {
|
|
1981
|
+
replacement.focus();
|
|
1982
|
+
return;
|
|
1983
|
+
}
|
|
1984
|
+
if (!identity.cardKind) return;
|
|
1985
|
+
const card = Array.from($wsExports.querySelectorAll('.ecard'))
|
|
1986
|
+
.find((candidate) => candidate.querySelector('[data-export]')?.dataset.export === identity.cardKind);
|
|
1987
|
+
card?.querySelector('.e-recovery:not([disabled]), [data-export]:not([disabled])')?.focus();
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
function paintExports(approvedAt, requestedRestoreKind) {
|
|
1991
|
+
const restoreIdentity = requestedRestoreKind
|
|
1992
|
+
? { attr: 'data-export', value: requestedRestoreKind, cardKind: requestedRestoreKind }
|
|
1993
|
+
: exportFocusIdentity(document.activeElement);
|
|
1994
|
+
const approved = !!approvedAt;
|
|
1995
|
+
let html = '';
|
|
1996
|
+
if (!approved) {
|
|
1997
|
+
html += `<div class="ws-exports-gate">Exports go out after sign-off — ` +
|
|
1998
|
+
`<button type="button" id="ws-exports-approve">Approve this version</button> to enable them.</div>`;
|
|
1999
|
+
}
|
|
2000
|
+
html += `<div class="exports-note"><b>Export at any stage</b> — polishing is optional. ` +
|
|
2001
|
+
`Each writes to this project’s <code>exports</code> folder.</div>`;
|
|
2002
|
+
const cards = (wsApp() && wsApp().exports) || [];
|
|
2003
|
+
html += '<div class="export-grid">' + cards.map((c) => cardHtml(c, approved)).join('') + '</div>';
|
|
2004
|
+
$wsExports.innerHTML = html;
|
|
2005
|
+
restoreExportFocus(restoreIdentity);
|
|
2006
|
+
}
|
|
2007
|
+
|
|
1873
2008
|
async function renderExports() {
|
|
1874
2009
|
if (!current) return;
|
|
1875
2010
|
const id = current.id, app = current.app;
|
|
1876
|
-
|
|
2011
|
+
const cards = (wsApp() && wsApp().exports) || [];
|
|
2012
|
+
const hasTekla = cards.some((card) => card.kind === 'tekla');
|
|
2013
|
+
teklaReadinessState = hasTekla ? { ok: false, state: 'checking' } : null;
|
|
2014
|
+
paintExports(current.approvedAt);
|
|
1877
2015
|
let state = null;
|
|
1878
2016
|
let approvedAt = current.approvedAt; // fallback if the fetch fails (best-known)
|
|
1879
|
-
|
|
1880
|
-
|
|
2017
|
+
const exportPromise = api(`/api/contract/${encodeURIComponent(app)}/exports?project=${encodeURIComponent(id)}`);
|
|
2018
|
+
const readinessPromise = hasTekla ? api('/api/tekla-readiness') : Promise.resolve(null);
|
|
2019
|
+
const [exportResult, readinessResult] = await Promise.allSettled([exportPromise, readinessPromise]);
|
|
2020
|
+
if (exportResult.status === 'fulfilled') {
|
|
2021
|
+
const r = exportResult.value;
|
|
1881
2022
|
state = {};
|
|
1882
2023
|
for (const e of r.exports || []) state[e.kind] = e;
|
|
1883
2024
|
// Authoritative gate state: an in-session edit clears approvedAt server-side, so trust the
|
|
1884
2025
|
// server, not the possibly-stale current.approvedAt — and re-sync current to match.
|
|
1885
2026
|
approvedAt = r.approvedAt || undefined;
|
|
1886
2027
|
current.approvedAt = approvedAt;
|
|
1887
|
-
}
|
|
2028
|
+
} else {
|
|
2029
|
+
const err = exportResult.reason;
|
|
1888
2030
|
// Surface the load failure — don't let it read as "nothing exported yet" (a lie).
|
|
1889
2031
|
showToast('Couldn’t load export status: ' + (err && err.message || err), 'warn');
|
|
1890
2032
|
state = null;
|
|
1891
2033
|
}
|
|
2034
|
+
if (hasTekla) {
|
|
2035
|
+
teklaReadinessState = readinessResult.status === 'fulfilled'
|
|
2036
|
+
? readinessResult.value.readiness
|
|
2037
|
+
: {
|
|
2038
|
+
ok: false,
|
|
2039
|
+
state: 'error',
|
|
2040
|
+
message: readinessResult.reason && readinessResult.reason.message
|
|
2041
|
+
? readinessResult.reason.message
|
|
2042
|
+
: 'Could not verify Tekla readiness.',
|
|
2043
|
+
recovery: { action: 'retry', label: 'Check again' },
|
|
2044
|
+
};
|
|
2045
|
+
}
|
|
1892
2046
|
// The user may have switched project/step during the await — don't paint stale.
|
|
1893
2047
|
if (!current || current.id !== id || $wsExports.hidden) return;
|
|
1894
2048
|
exportState = state;
|
|
1895
2049
|
syncWorkspaceGuide(); // fresh approve/export state → tick the Export (and re-sync Approve) guide rows
|
|
1896
|
-
|
|
1897
|
-
let html = '';
|
|
1898
|
-
if (!approved) {
|
|
1899
|
-
html += `<div class="ws-exports-gate">Exports go out after sign-off — ` +
|
|
1900
|
-
`<button type="button" id="ws-exports-approve">Approve this version</button> to enable them.</div>`;
|
|
1901
|
-
}
|
|
1902
|
-
html += `<div class="exports-note"><b>Export at any stage</b> — polishing is optional. ` +
|
|
1903
|
-
`Each writes to this project’s <code>exports</code> folder.</div>`;
|
|
1904
|
-
const cards = (wsApp() && wsApp().exports) || [];
|
|
1905
|
-
html += '<div class="export-grid">' + cards.map((c) => cardHtml(c, approved)).join('') + '</div>';
|
|
1906
|
-
$wsExports.innerHTML = html;
|
|
2050
|
+
paintExports(approvedAt);
|
|
1907
2051
|
}
|
|
1908
2052
|
|
|
1909
2053
|
async function doExport(kind) {
|
|
1910
2054
|
if (!current) return;
|
|
1911
|
-
const app = current.app; // capture — the user may switch projects during the await
|
|
1912
|
-
const
|
|
1913
|
-
|
|
1914
|
-
|
|
2055
|
+
const app = current.app, projectId = current.id, approvedAt = current.approvedAt; // capture — the user may switch projects during the await
|
|
2056
|
+
const busyKey = `${projectId}:${kind}`;
|
|
2057
|
+
if (exportBusy.has(busyKey)) return;
|
|
2058
|
+
exportBusy.add(busyKey);
|
|
2059
|
+
// The delegated click can report BODY as active by the time this synchronous repaint runs.
|
|
2060
|
+
// Carry the activated kind through the first replacement explicitly; later repaints infer
|
|
2061
|
+
// focus normally, so moving elsewhere during a long export is still respected.
|
|
2062
|
+
paintExports(current.approvedAt, kind);
|
|
1915
2063
|
try {
|
|
1916
2064
|
const res = await api(exportUrl(kind), { method: 'POST' });
|
|
1917
2065
|
track('workspace_export', { app, kind }); // a successful export/bake (e.g. { app:'vectorize', kind:'svg' })
|
|
2066
|
+
if (res.counts) exportReceipts.set(`${projectId}:${kind}`, {
|
|
2067
|
+
counts: res.counts,
|
|
2068
|
+
warnings: res.warnings || [],
|
|
2069
|
+
unsupported: res.receipt && Array.isArray(res.receipt.unsupported) ? res.receipt.unsupported : [],
|
|
2070
|
+
approvedAt,
|
|
2071
|
+
});
|
|
2072
|
+
const summary = receiptSummary(exportReceipts.get(`${projectId}:${kind}`), kind);
|
|
1918
2073
|
if (kind === 'tekla') {
|
|
1919
|
-
|
|
1920
|
-
|
|
2074
|
+
showToast(summary && summary.partial
|
|
2075
|
+
? `Sent to Tekla with gaps — ${summary.text}`
|
|
2076
|
+
: (res.message || 'Baked into the Tekla model.'),
|
|
2077
|
+
summary && summary.partial ? 'warn' : 'ok');
|
|
1921
2078
|
} else {
|
|
1922
|
-
showToast(
|
|
1923
|
-
|
|
2079
|
+
showToast(summary && summary.partial
|
|
2080
|
+
? `Exported with gaps — ${summary.text}`
|
|
2081
|
+
: `Exported — ${res.filename || kind}`,
|
|
2082
|
+
summary && summary.partial ? 'warn' : 'ok');
|
|
1924
2083
|
}
|
|
2084
|
+
return renderExports(); // repaint status + the authoritative receipt summary
|
|
1925
2085
|
} catch (err) {
|
|
2086
|
+
// The durable export listing may still show the previously published file, but its in-session
|
|
2087
|
+
// receipt must not masquerade as the result of this failed attempt.
|
|
2088
|
+
exportReceipts.delete(`${projectId}:${kind}`);
|
|
1926
2089
|
const needsTekla = err && err.body && err.body.needsTekla;
|
|
2090
|
+
if (kind === 'tekla' && err && err.body && err.body.readiness) teklaReadinessState = err.body.readiness;
|
|
1927
2091
|
showToast(err && err.message ? err.message : String(err), needsTekla ? 'info' : 'warn');
|
|
2092
|
+
if (kind === 'tekla' && current && current.id === projectId) paintExports(current.approvedAt);
|
|
1928
2093
|
} finally {
|
|
1929
|
-
|
|
2094
|
+
exportBusy.delete(busyKey);
|
|
2095
|
+
if (current && current.id === projectId) paintExports(current.approvedAt);
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
function showExportReceiptDetails(kind, returnFocusTo) {
|
|
2100
|
+
const projectId = current && current.id;
|
|
2101
|
+
const receipt = exportReceipts.get(receiptKey(kind));
|
|
2102
|
+
const summary = receiptSummary(receipt, kind);
|
|
2103
|
+
if (!summary || !summary.details || !bridge.formModal) return;
|
|
2104
|
+
bridge.formModal({
|
|
2105
|
+
title: `${kind === 'tekla' ? 'Tekla' : 'IFC'} export details`,
|
|
2106
|
+
sub: 'Details from the last successful export for this approved version.',
|
|
2107
|
+
fields: [{ name: 'details', label: 'Receipt details', type: 'note', value: summary.details }],
|
|
2108
|
+
okLabel: 'Close',
|
|
2109
|
+
hideCancel: true,
|
|
2110
|
+
returnFocusTo,
|
|
2111
|
+
returnFocusFallback: () => current && current.id === projectId
|
|
2112
|
+
? $wsExports.querySelector(`[data-export-details="${kind}"]`)
|
|
2113
|
+
: null,
|
|
2114
|
+
});
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
async function recoverTekla(action) {
|
|
2118
|
+
if (!current) return;
|
|
2119
|
+
if (action === 'open-tekla' || action === 'open-model' || action === 'retry') {
|
|
2120
|
+
return renderExports();
|
|
2121
|
+
}
|
|
2122
|
+
teklaReadinessState = { ok: false, state: 'checking' };
|
|
2123
|
+
paintExports(current.approvedAt);
|
|
2124
|
+
try {
|
|
2125
|
+
if (action === 'update-aware') {
|
|
2126
|
+
if (!bridge.formModal) throw new Error('Could not open the AWARE update dialog.');
|
|
2127
|
+
const go = await bridge.formModal({
|
|
2128
|
+
title: 'Update AWARE runtime',
|
|
2129
|
+
sub: 'Installs the current AWARE release in place. FloLess stays open.',
|
|
2130
|
+
fields: [],
|
|
2131
|
+
okLabel: 'Update AWARE',
|
|
2132
|
+
});
|
|
2133
|
+
if (!go) return renderExports();
|
|
2134
|
+
await api('/api/aware/update/apply', { method: 'POST', signal: AbortSignal.timeout(120000) });
|
|
2135
|
+
} else if (action === 'install-bridge') {
|
|
2136
|
+
await api('/api/tekla-readiness/setup', { method: 'POST' });
|
|
2137
|
+
}
|
|
2138
|
+
showToast(action === 'update-aware' ? 'AWARE updated.' : 'Tekla bridge installed.', 'ok');
|
|
2139
|
+
} catch (err) {
|
|
2140
|
+
showToast(err && err.message ? err.message : String(err), 'warn');
|
|
1930
2141
|
}
|
|
2142
|
+
return renderExports();
|
|
1931
2143
|
}
|
|
1932
2144
|
|
|
1933
2145
|
async function fileAction(endpoint, kind, failMsg) {
|
|
@@ -1943,6 +2155,10 @@
|
|
|
1943
2155
|
|
|
1944
2156
|
$wsExports.addEventListener('click', (e) => {
|
|
1945
2157
|
if (e.target.closest('#ws-exports-approve')) { approveProject(); return; }
|
|
2158
|
+
const details = e.target.closest('[data-export-details]');
|
|
2159
|
+
if (details) { showExportReceiptDetails(details.dataset.exportDetails, details); return; }
|
|
2160
|
+
const recovery = e.target.closest('[data-tekla-recovery]');
|
|
2161
|
+
if (recovery) { recoverTekla(recovery.dataset.teklaRecovery); return; }
|
|
1946
2162
|
const exp = e.target.closest('[data-export]');
|
|
1947
2163
|
if (exp && !exp.disabled) { doExport(exp.dataset.export); return; }
|
|
1948
2164
|
const open = e.target.closest('[data-openfile]');
|