@floless/app 0.134.0 → 0.134.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 +4995 -2851
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +93 -6
- package/dist/web/app.css +34 -8
- package/dist/web/aware.js +590 -102
- package/dist/web/commands-filter.js +79 -5
- package/dist/web/commands-shell.js +98 -11
- package/dist/web/commands-steel.js +7 -7
- package/dist/web/index.html +17 -15
- package/dist/web/instructor.js +89 -34
- package/dist/web/steel-3d-core.js +242 -3
- package/dist/web/steel-3d-view.js +261 -13
- package/dist/web/steel-editor.html +230 -11
- package/dist/web/steel-filter-core.js +189 -16
- package/dist/web/steel-filter.html +865 -46
- package/dist/web/steel-model-commands.js +23 -2
- package/dist/web/steel-model-v2-commands.js +124 -0
- package/dist/web/workspaces.js +369 -69
- package/package.json +1 -1
|
@@ -3401,7 +3401,13 @@ function commitPositionEdit(members,userPatch,source){const captured=positionAut
|
|
|
3401
3401
|
prepared.push({m,patch:Object.assign({},patch,userPatch)});}
|
|
3402
3402
|
if(blockers.length)return positionRefuse('No changes made — '+blockers.join('; ')+'. Resolve every blocker, or set Depth and Width to Middle in each stored frame first.',source);
|
|
3403
3403
|
const current=positionAuthoringBasis();if(current.generation!==captured.generation)return positionRefuse('Frame changed — review the refreshed Profile Position and try again.',source);
|
|
3404
|
-
edit(
|
|
3404
|
+
// Return what edit() ACTUALLY did, not an unconditional true. edit() catches a V2CommandError, toasts it
|
|
3405
|
+
// and returns false; discarding that made a refusal read to the caller as success, and the 3D gizmo keys
|
|
3406
|
+
// its "put the live preview back" branch on exactly this boolean (steel-3d-view.js onUp), so a refused
|
|
3407
|
+
// commit left the moved mesh on screen over an unchanged model. Of the callers here only
|
|
3408
|
+
// commitMemberPosition propagates the value — every other one ignores it in statement position — so this
|
|
3409
|
+
// reaches precisely the consumer that wanted the truth. (slice 3b.1)
|
|
3410
|
+
return edit(()=>{for(const row of prepared)ModelCmd.patchMember(row.m,row.patch);})===true;}
|
|
3405
3411
|
/*
|
|
3406
3412
|
* Read-only snapshot the 3D Profile Position gizmo (slice 3a) renders from. The editor owns the
|
|
3407
3413
|
* semantics; the 3D view only draws the arrows and reports back an ABSOLUTE new value, which
|
|
@@ -3434,13 +3440,107 @@ function memberPositionGizmoState(id){
|
|
|
3434
3440
|
const f=SteelCore.positionGizmoFrame(input.from,input.to,captured);
|
|
3435
3441
|
if(!f)return{available:false,reason:m.id+' has no Profile Position frame in the current view'};
|
|
3436
3442
|
return{available:true,id,anchor:[...input.from],xAxis:[...f.x],yAxis:[...f.y],zAxis:[...f.z],
|
|
3437
|
-
positionOffset:+m.positionOffset||0,positionHOffset:+m.positionHOffset||0,rot:positionAuthoringRoll(m),degenerate:!!f.degenerate
|
|
3443
|
+
positionOffset:+m.positionOffset||0,positionHOffset:+m.positionHOffset||0,rot:positionAuthoringRoll(m),degenerate:!!f.degenerate,
|
|
3444
|
+
// slice 3b.1 — the reference-line handles need the FAR work point and the basis UP vector as well, plus a
|
|
3445
|
+
// drag-start FINGERPRINT. The fingerprint has to be captured HERE, when the gesture starts, because that
|
|
3446
|
+
// is the state the drag's arithmetic is frozen against; taking it again at commit time would compare the
|
|
3447
|
+
// live member with itself and the staleness guard could never fire (found in review).
|
|
3448
|
+
end:[...input.to],up:positionBasisUp(captured),fingerprint:V2Commands.memberFingerprint(input.canonical),
|
|
3449
|
+
handles:refLineHandleAvailability(m,f,input.from,input.to,positionBasisUp(captured))};}
|
|
3450
|
+
/*
|
|
3451
|
+
* The authoring basis' up vector — world Z under the global basis, else x × y. This is the PLAN-SWING
|
|
3452
|
+
* AXIS, and deliberately not the member's own tilted zAxis: rotating about up leaves both the rise and the
|
|
3453
|
+
* run untouched, so the slope is invariant, the rebuilt part frame equals the rigid preview exactly, and
|
|
3454
|
+
* the swing is provably immune to the 30° depth-face fold. Rotating about the body z would change the
|
|
3455
|
+
* slope on any sloped member and make preview and commit disagree.
|
|
3456
|
+
*/
|
|
3457
|
+
function positionBasisUp(basis){
|
|
3458
|
+
if(!basis||basis.kind==='global')return[0,0,1];
|
|
3459
|
+
const x=basis.x,y=basis.y;
|
|
3460
|
+
return[x[1]*y[2]-x[2]*y[1],x[2]*y[0]-x[0]*y[2],x[0]*y[1]-x[1]*y[0]];}
|
|
3461
|
+
/*
|
|
3462
|
+
* Which reference-line handles this member can actually take, decided from GEOMETRY rather than from its
|
|
3463
|
+
* role alone, each with the reason it is refused.
|
|
3464
|
+
*
|
|
3465
|
+
* The slide is representable for EVERY member, a plumb column included — there it is raise/lower, and the
|
|
3466
|
+
* model stores exactly that. The swings are not: a v2 column is plumb by construction (both work points
|
|
3467
|
+
* share the plan point; only the elevations differ), so a tilt has nowhere to live. And on a DEGENERATE
|
|
3468
|
+
* start frame — partFrame's seeded branch — the closed-form plumb barrier does not apply at all, because
|
|
3469
|
+
* `yAxis` is projected from `upX` there and need not be perpendicular to up. A plan swing additionally
|
|
3470
|
+
* preserves the member's distance from the degeneracy cone, so a member that starts inside it can never
|
|
3471
|
+
* leave: the handle would be permanently inert rather than merely awkward. Refuse both, and say why.
|
|
3472
|
+
*/
|
|
3473
|
+
function refLineHandleAvailability(m,f,from,to,up){
|
|
3474
|
+
const col=m.role==='column';
|
|
3475
|
+
const swing=col?{available:false,reason:'A column stays plumb — set its elevations in the Inspect panel.'}
|
|
3476
|
+
:f.degenerate?{available:false,reason:'This member is plumb — there is no direction to swing it from.'}
|
|
3477
|
+
:{available:true};
|
|
3478
|
+
// A member that is NEARLY plumb is not degenerate, so the check above lets it through — but its two plumb
|
|
3479
|
+
// barriers then sit on the same side of zero, leaving no legal travel one way. A handle that refuses every
|
|
3480
|
+
// drag is worse than one that is not drawn, so require a whole snap step each side and say why. (Review:
|
|
3481
|
+
// without this, a Shift-held tilt on such a member committed roughly a degree in the OPPOSITE direction.)
|
|
3482
|
+
const elev=swing.available&&!SteelCore.swingHasTravel(
|
|
3483
|
+
SteelCore.swingBarriers(from,to,f.y,up,SteelCore.POSITION_SWING_MARGIN_RAD),SteelCore.POSITION_ROT_SNAP_DEG*Math.PI/180)
|
|
3484
|
+
?{available:false,reason:'This member is within a degree of plumb — set its elevations in the Inspect panel.'}
|
|
3485
|
+
:swing;
|
|
3486
|
+
return{slide:{available:true},swingPlan:swing,swingElev:elev};}
|
|
3438
3487
|
/*
|
|
3439
3488
|
* The gizmo's one write path: the 3D view hands back an absolute new offset (mm) or roll (deg) for a
|
|
3440
3489
|
* single member; this routes it through `commitPositionEdit`, which rebases to the current frame,
|
|
3441
3490
|
* applies the edit, and produces exactly one undo entry. Returns a boolean (false = refused).
|
|
3442
3491
|
*/
|
|
3443
3492
|
function commitMemberPosition(id,patch,source){const m=byId(id);if(!m)return positionRefuse('That member is no longer in the model.',source);return commitPositionEdit([m],patch,source||null);}
|
|
3493
|
+
/*
|
|
3494
|
+
* The reference-line handles' one write path (slice 3b.1): the 3D view hands back ABSOLUTE new work points
|
|
3495
|
+
* in world mm, and this commits them as a single undoable edit.
|
|
3496
|
+
*
|
|
3497
|
+
* Deliberately separate from `commitMemberPosition`. That one rebases the stored placement into the current
|
|
3498
|
+
* authoring frame before applying an offset/roll; an endpoint move needs none of that dance, because it does
|
|
3499
|
+
* not change the authoring frame at all — `m.rot` and `m.positionBasis` stay untouched and the displayed
|
|
3500
|
+
* roll re-derives on the new part frame through `positionAuthoringRoll`.
|
|
3501
|
+
*
|
|
3502
|
+
* WHAT THIS OWNS, and what the model command re-checks underneath it:
|
|
3503
|
+
* - the authoring basis must not have drifted since the gesture began (the same generation compare the
|
|
3504
|
+
* panel commit does);
|
|
3505
|
+
* - the candidate points are QUANTISED here, before anything is decided from them, because the depth-face
|
|
3506
|
+
* fold is a threshold test and an unquantised preview can land on the other side of it from what is
|
|
3507
|
+
* actually stored;
|
|
3508
|
+
* - the depth-face pin is computed HERE, from current canonical state, through the same shared helper the
|
|
3509
|
+
* command verifies with — so the two can never drift apart;
|
|
3510
|
+
* - FRAME-BRANCH STABILITY. A swing must land on partFrame's ordinary branch. A slide must merely keep the
|
|
3511
|
+
* branch it started on, IN BOTH DIRECTIONS: a slide is not frame-preserving to the bit (each endpoint
|
|
3512
|
+
* quantises independently, perturbing the direction by ~1e-9), so near the cone it can nudge a member
|
|
3513
|
+
* OUT of the seeded branch as easily as into it — and leaving the cone rebuilds a different section
|
|
3514
|
+
* frame than the rigid preview showed.
|
|
3515
|
+
*
|
|
3516
|
+
* Returns a plain boolean. The pin, when one is applied, is announced here and only AFTER the write lands,
|
|
3517
|
+
* so a refused commit can never announce a pin that was never stored.
|
|
3518
|
+
*/
|
|
3519
|
+
function commitMemberEndpoints(id,spec,source){
|
|
3520
|
+
const m=byId(id);if(!m)return positionRefuse('That member is no longer in the model.',source);
|
|
3521
|
+
const captured=positionAuthoringBasis();if(!captured.ok)return positionRefuse(captured.message,source);
|
|
3522
|
+
const input=positionRebaseInput(m);if(!input)return positionRefuse(m.id+' has incomplete work points.',source);
|
|
3523
|
+
const q=(p)=>[SteelCore.quantizeMm(p[0]),SteelCore.quantizeMm(p[1]),SteelCore.quantizeMm(p[2])];
|
|
3524
|
+
const from=spec&&spec.from?q(spec.from):[...input.from],to=spec&&spec.to?q(spec.to):[...input.to];
|
|
3525
|
+
if(![...from,...to].every(Number.isFinite))return positionRefuse('That move produced a coordinate the model cannot store.',source);
|
|
3526
|
+
const before=SteelCore.positionGizmoFrame(input.from,input.to,captured);
|
|
3527
|
+
const after=SteelCore.positionGizmoFrame(from,to,captured);
|
|
3528
|
+
if(!after)return positionRefuse('That move leaves the member with no length.',source);
|
|
3529
|
+
const gesture=spec&&spec.gesture;
|
|
3530
|
+
if(gesture==='slide'?(!!after.degenerate!==!!(before&&before.degenerate))
|
|
3531
|
+
:after.degenerate)return positionRefuse('That move would leave the section with no usable frame — try a smaller change.',source);
|
|
3532
|
+
const pin=SteelCore.requiredDepthPin(input.canonical,{from:input.from,to:input.to},{from,to}).pin;
|
|
3533
|
+
const current=positionAuthoringBasis();if(current.generation!==captured.generation)return positionRefuse('Frame changed — review the refreshed Profile Position and try again.',source);
|
|
3534
|
+
const ok=edit(()=>{MC().moveWorkPoints(m,{
|
|
3535
|
+
points:{from:{x:from[0],y:from[1],z:from[2]},to:{x:to[0],y:to[1],z:to[2]}},
|
|
3536
|
+
// The DRAG-START fingerprint when the caller froze one (every gesture does, via the gizmo state); only
|
|
3537
|
+
// the typed path falls back to a fresh read, and there the endpoints are derived from that same fresh
|
|
3538
|
+
// read, so the two agree by construction. Recomputing it here for a drag would compare the live member
|
|
3539
|
+
// against itself and render the staleness guard inert.
|
|
3540
|
+
expect:(spec&&spec.expect)||V2Commands.memberFingerprint(input.canonical),
|
|
3541
|
+
...(pin===undefined?{}:{position:pin})});})===true;
|
|
3542
|
+
if(ok&&pin!==undefined)toast('Depth face pinned to “'+pin+'” so the steel stays where you put it.',false,5200);
|
|
3543
|
+
return ok;}
|
|
3444
3544
|
/*
|
|
3445
3545
|
* ONE row of the Profile Position section: heading + offset box on the first line, named faces on the
|
|
3446
3546
|
* second. The mockup drew all three on one line; at 280 px — ~246 px of content once the rail's padding and
|
|
@@ -4007,6 +4107,67 @@ function confirmDanger({title,body,confirmLabel}){
|
|
|
4007
4107
|
// exact tag, so a deliberate overwrite still cannot create a store out of nothing. Only the explicit
|
|
4008
4108
|
// "Overwrite and save" confirm passes it. (This said "skips the precondition" until P1c made a write
|
|
4009
4109
|
// without one a 428; it was already inaccurate, and would now describe an impossible request.)
|
|
4110
|
+
// The write-boundary connection revalidation report (server/contract-gateway.ts) → ONE plain-English toast.
|
|
4111
|
+
// The server decides the fate of every shear-plate/brace-gusset joint a member move could have affected and
|
|
4112
|
+
// has already stored the result; this only TELLS the user, in their words, what changed. Kept-only is silent.
|
|
4113
|
+
// Marks where the model has them (byId(id).mark), else the id. Capped at three clauses so a big move is a
|
|
4114
|
+
// sentence, not a wall. No barrier, no re-install: the local model keeps its own undo history.
|
|
4115
|
+
// The server revalidated connections at the write boundary and reported what it did. Apply that report to
|
|
4116
|
+
// the LIVE joints and tell the user. Applying is not cosmetic: the durable contract already holds the
|
|
4117
|
+
// removal/repoint, but the browser's `C.joints` still carries the stale joint — and because the endpoints
|
|
4118
|
+
// no longer change on the NEXT save, revalidation would be a no-op there and the server would faithfully
|
|
4119
|
+
// persist the stale joint the client re-sent, silently resurrecting it. So we must reconcile `C.joints`.
|
|
4120
|
+
// It is SURGICAL — only the joints the report names are touched — so it needs no full-contract install and
|
|
4121
|
+
// therefore never clears the undo stack (unlike installMemberEndContract): on the ordinary move (the common
|
|
4122
|
+
// case) one Ctrl+Z restores the pre-move snapshot (endpoints AND the original joint), and revalidation
|
|
4123
|
+
// re-derives idempotently from there. The one exception is a move that ALSO invalidates a retained work-point
|
|
4124
|
+
// decision: that write returns the transformed contract, so the caller runs installMemberEndContract FIRST
|
|
4125
|
+
// (which does clear undo, for its own server-owned-decision reason) and this reconcile is then a redundant
|
|
4126
|
+
// no-op — the joints are still correct, only the undo affordance is lost, in that rare combined case.
|
|
4127
|
+
// Guarded by the caller on `seq===saveSeq`: a report is only applied while `C` still equals what was sent.
|
|
4128
|
+
function applyRevalidation(rv){
|
|
4129
|
+
if(!rv)return;
|
|
4130
|
+
const mk=id=>{const m=byId(id);return (m&&(m.mark||m.id))||id;};
|
|
4131
|
+
const KIND={'shear-plate':'Shear plate','brace-gusset':'Brace gusset'};
|
|
4132
|
+
const kindLabel=k=>KIND[k]||'Connection';
|
|
4133
|
+
const rm=rv.removed||[],rp=rv.repointed||[],fl=rv.flagged||[],df=rv.deferred||[];
|
|
4134
|
+
const clauses=[];
|
|
4135
|
+
if(rm.length)clauses.push(rm.length===1?(kindLabel(rm[0].kind)+' removed — no supporting member'):(rm.length+' connections removed — no supporting member'));
|
|
4136
|
+
if(rp.length){
|
|
4137
|
+
if(rp.length===1){const j=(C.joints||[]).find(x=>x.id===rp[0].id);clauses.push(kindLabel(j&&j.kind)+' re-seated onto '+mk(rp[0].to));}
|
|
4138
|
+
else clauses.push(rp.length+' connections re-seated onto new supports');
|
|
4139
|
+
}
|
|
4140
|
+
if(fl.length)clauses.push(fl.length===1?'Custom connection may need review':(fl.length+' custom connections may need review'));
|
|
4141
|
+
if(df.length)clauses.push(df.length+' connection'+(df.length===1?'':'s')+' left unchanged — geometry unresolved');
|
|
4142
|
+
// Reconcile the live joints with the server's authoritative result (removed dropped, repointed re-bound).
|
|
4143
|
+
// The report is server-authored but consumed defensively (a malformed entry must not write `undefined`
|
|
4144
|
+
// into a live binding): only well-shaped ids/targets are applied, the rest are logged and skipped.
|
|
4145
|
+
const removedIds=new Set(rm.filter(r=>r&&typeof r.id==='string').map(r=>r.id));
|
|
4146
|
+
const repoints=rp.filter(r=>r&&typeof r.id==='string'&&typeof r.to==='string');
|
|
4147
|
+
if(removedIds.size||repoints.length){
|
|
4148
|
+
C.joints=(C.joints||[]).filter(j=>!removedIds.has(j.id));
|
|
4149
|
+
for(const r of repoints){const j=(C.joints||[]).find(x=>x.id===r.id);if(j)j.secondaries=[r.to];}
|
|
4150
|
+
persist();render();sync3D(); // persist() rewrites the localStorage draft; the durable copy already holds this
|
|
4151
|
+
}
|
|
4152
|
+
if(rm.length!==removedIds.size||rp.length!==repoints.length)console.warn('steel-editor: a malformed revalidation report entry was skipped',rv);
|
|
4153
|
+
if(clauses.length)toast(clauses.slice(0,3).join(' · '));
|
|
4154
|
+
}
|
|
4155
|
+
// THE CLIENT NEVER DECIDES A JOINT'S FATE — THE SERVER DOES, AND IT NEEDS NOTHING FROM US TO DO IT.
|
|
4156
|
+
//
|
|
4157
|
+
// Normally the server's revalidation report rides the write response and `applyRevalidation` mirrors it into
|
|
4158
|
+
// `C.joints`. Some responses this tab cannot safely apply: a STALE one (a newer edit landed while the PUT was
|
|
4159
|
+
// in flight, so the report's delta no longer describes the live `C`), an UNREADABLE body, or one LOST after
|
|
4160
|
+
// the write committed. On those legs we simply do nothing — no merge, no bookkeeping, no guessing.
|
|
4161
|
+
//
|
|
4162
|
+
// That is safe because of where the guarantee actually lives: the server re-decides every joint a write
|
|
4163
|
+
// INTRODUCES (present in the incoming contract, absent from the stored one), and a joint this tab kept after
|
|
4164
|
+
// missing its removal is exactly that shape. So the next ordinary save re-decides it and removes it again,
|
|
4165
|
+
// authoritatively, with the user told in the usual toast. Undo behaves correctly for free — it restores the
|
|
4166
|
+
// endpoint too, so the support is valid again and the joint is simply `kept`.
|
|
4167
|
+
//
|
|
4168
|
+
// This replaced a client-side merge (fingerprints, ownership rules, etag-generation heuristics) that four
|
|
4169
|
+
// adversarial review rounds kept finding concurrency bugs in: reconciling a server-authoritative transform
|
|
4170
|
+
// against a concurrently-edited local copy is a CRDT-class problem, and the way to win it was not to play.
|
|
4010
4171
|
async function persistServer(force){const seq=saveSeq;
|
|
4011
4172
|
// Once conflicted, stop firing doomed PUTs; re-surface the explanation instead of hammering the
|
|
4012
4173
|
// network every debounce tick. Cleared only by a reload or a confirmed overwrite.
|
|
@@ -4047,11 +4208,24 @@ async function persistServer(force){const seq=saveSeq;
|
|
|
4047
4208
|
// write is usually still in flight — the server broadcasts before it replies — so releasing here would
|
|
4048
4209
|
// make the tab read its OWN echo as external and reload itself mid-edit. The id is released when the
|
|
4049
4210
|
// echo consumes it, when the write fails, or when the SSE channel closes (nothing can echo after that).
|
|
4050
|
-
if(res.ok){
|
|
4211
|
+
if(res.ok){let d={},bodyReadable=true;try{d=await res.json();}catch(_){bodyReadable=false;}const t=d.etag||res.headers.get('ETag');if(d.contract&&t&&Number.isSafeInteger(d.storeRevision))installMemberEndContract(d.contract,t,d.storeRevision);else{if(t){const pv=serverEtag;serverEtag=t;restampDraftBase(pv,t);}if(Number.isSafeInteger(d.storeRevision))serverRevision=Math.max(serverRevision,d.storeRevision);}conflicted=false;
|
|
4212
|
+
// The write COMMITTED. Apply its revalidation report ONLY when we can prove it describes the live `C`:
|
|
4213
|
+
// the body was readable AND `seq===saveSeq` (no newer edit landed while this PUT was in flight). Otherwise
|
|
4214
|
+
// do NOTHING — no merge, no bookkeeping. That is safe because a joint whose removal we then miss is
|
|
4215
|
+
// re-INTRODUCED by the next save, and the server re-decides every introduced joint.
|
|
4216
|
+
const usable=!!t||Number.isSafeInteger(d.storeRevision);
|
|
4217
|
+
// Apply ONLY a report we can prove is current; otherwise do nothing — the server re-decides an
|
|
4218
|
+
// introduced joint on the next save, so a missed removal cannot survive (see the note above).
|
|
4219
|
+
if(bodyReadable&&usable&&seq===saveSeq)applyRevalidation(d.revalidation);
|
|
4220
|
+
} // chain the next edit off the new tag, and install any server-staled endpoint authority instead of leaving the browser on bytes the server deliberately transformed; then tell the user what the write-boundary revalidation did to their connections
|
|
4051
4221
|
else releaseMutation(mid); // 400/500: nothing was written, so nothing will echo
|
|
4052
4222
|
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)
|
|
4053
4223
|
if(!res.ok)console.error('server save rejected ('+res.status+')',await res.text().catch(()=>'')); // 400 = schema reject: edits won't be what Approve bakes
|
|
4054
|
-
}catch(e){releaseMutation(mid);if(seq===saveSeq)setSaved('err');console.error('server save failed',e);
|
|
4224
|
+
}catch(e){releaseMutation(mid);if(seq===saveSeq)setSaved('err');console.error('server save failed',e);
|
|
4225
|
+
// The write may have committed even though we never saw the response — nothing to do here. `C.joints` can
|
|
4226
|
+
// then still carry a joint the store removed, and the NEXT save re-introduces it, which is exactly the
|
|
4227
|
+
// shape the server always re-decides. So the removal simply happens again, authoritatively.
|
|
4228
|
+
}
|
|
4055
4229
|
});}
|
|
4056
4230
|
function scheduleSave(){if(memberEndStatus.known||memberEndReview)invalidateMemberEndReview();setSaved('dirty');++saveSeq;clearTimeout(saveT);saveT=setTimeout(()=>{saveT=null;persist();persistServer();},500);} // clear the handle as it fires: `saveT !== null` is read as "a write is still pending" (the project send refuses on it), and a spent timer id would read as pending forever // ++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)
|
|
4057
4231
|
// The boot-scope SSE handler's seam into that debounce — see `flushLocalDraft` for why the handler
|
|
@@ -4086,12 +4260,12 @@ window.flushContract = async () => {
|
|
|
4086
4260
|
const headers = { 'content-type': 'application/json', 'x-floless-mutation-id': mid };
|
|
4087
4261
|
// Same total rule as persistServer — see the comment there for why "no tag" means If-None-Match: *.
|
|
4088
4262
|
if (serverEtag) headers['if-match'] = serverEtag; else headers['if-none-match'] = '*';
|
|
4089
|
-
res = await fetch('/api/contract/' + encodeURIComponent(APP_ID) + PROJECT_QS, {
|
|
4090
|
-
method: 'PUT', headers, body: JSON.stringify(C),
|
|
4091
|
-
});
|
|
4263
|
+
res = await fetch('/api/contract/' + encodeURIComponent(APP_ID) + PROJECT_QS, { method: 'PUT', headers, body: JSON.stringify(C) });
|
|
4092
4264
|
} catch (e) {
|
|
4093
4265
|
releaseMutation(mid); // nothing was written, so no broadcast will ever carry this id
|
|
4094
4266
|
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)
|
|
4267
|
+
// Parity with persistServer: a lost response needs no bookkeeping here — a joint whose removal we missed
|
|
4268
|
+
// is re-introduced by the next save, and the server always re-decides an introduced joint.
|
|
4095
4269
|
throw e; // still reject so the parent (Approve) aborts — regardless of seq
|
|
4096
4270
|
}
|
|
4097
4271
|
if (res.status === 428) { // same cause as persistServer's 428 branch — a writer sent no precondition
|
|
@@ -4110,7 +4284,12 @@ window.flushContract = async () => {
|
|
|
4110
4284
|
showConflictBanner();
|
|
4111
4285
|
throw new Error('save conflict');
|
|
4112
4286
|
}
|
|
4113
|
-
if (res.ok) {
|
|
4287
|
+
if (res.ok) { let d = {}, bodyReadable = true; try { d = await res.json(); } catch (_) { bodyReadable = false; } const t = d.etag || res.headers.get('ETag'); if (d.contract && t && Number.isSafeInteger(d.storeRevision)) installMemberEndContract(d.contract, t, d.storeRevision); else { if (t) { const pv = serverEtag; serverEtag = t; restampDraftBase(pv, t); } if (Number.isSafeInteger(d.storeRevision)) serverRevision = Math.max(serverRevision, d.storeRevision); } conflicted = false;
|
|
4288
|
+
// The flush committed. Same rule as persistServer: apply the report only when the body was readable and
|
|
4289
|
+
// `seq===saveSeq` (Approve awaits this flush, so the user CAN edit meanwhile and make it stale). Otherwise
|
|
4290
|
+
// do nothing — the next save re-introduces any joint whose removal we missed, and the server re-decides it.
|
|
4291
|
+
const usable = !!t || Number.isSafeInteger(d.storeRevision);
|
|
4292
|
+
if (bodyReadable && usable && seq === saveSeq) applyRevalidation(d.revalidation); }
|
|
4114
4293
|
else releaseMutation(mid);
|
|
4115
4294
|
if (seq === saveSeq) setSaved(res.ok ? 'ok' : 'err'); // only the latest save owns the pill
|
|
4116
4295
|
if (!res.ok) throw new Error('save failed (' + res.status + ')');
|
|
@@ -8225,7 +8404,14 @@ function openPositionHud(id,axis,scr){
|
|
|
8225
8404
|
if(!st||!st.available){ // a double-click on a VISIBLE handle that opens nothing is confusing — the view picked it from a cached snapshot, but a fresh read can disagree (a mid-flight external write, a roll that became unresolvable). Surface it instead of a silent return (mirrors currentPositionGizmoState's console.debug + the drag bail).
|
|
8226
8405
|
console.debug('steel: position HUD not opened —',st&&st.reason);
|
|
8227
8406
|
toast('Can’t edit this handle right now'+(st&&st.reason?' — '+st.reason:'')+'. Try the Inspect panel.');return;}
|
|
8228
|
-
|
|
8407
|
+
// The reference-line handles (3b.1) type a DELTA — how far to slide, how far to swing — so their "current
|
|
8408
|
+
// value" hint is 0, unlike the three profile handles whose current absolute value is the hint. A handle the
|
|
8409
|
+
// member cannot take never opens a HUD either, or the user would type a value into something that can only
|
|
8410
|
+
// refuse it.
|
|
8411
|
+
const refline=axis==='slide'||axis==='swingPlan'||axis==='swingElev';
|
|
8412
|
+
if(refline&&!(st.handles&&st.handles[axis]&&st.handles[axis].available)){
|
|
8413
|
+
toast((st.handles&&st.handles[axis]&&st.handles[axis].reason)||'That handle isn’t available on this member.');return;}
|
|
8414
|
+
const cur=refline?0:axis==='depth'?st.positionOffset:axis==='width'?st.positionHOffset:st.rot;
|
|
8229
8415
|
posHudTarget={id,axis,cur};
|
|
8230
8416
|
if(view3d&&window.Steel3DView&&window.Steel3DView.setPositionTyping)window.Steel3DView.setPositionTyping(true);
|
|
8231
8417
|
cmHudShow('',{consumer:'position',scr});
|
|
@@ -8241,7 +8427,8 @@ function cmHudSyncPill(){if(!cmHudEl)return;const pill=cmHudEl.querySelector('#c
|
|
|
8241
8427
|
pill.querySelectorAll('.cmHudSeg').forEach(s=>{const on=((s.dataset.mode==='abs')===cmHudAbs);s.setAttribute('aria-checked',on?'true':'false');s.tabIndex=on?0:-1;s.classList.toggle('on',on);}); // roving tabindex: only the selected radio is Tab-reachable
|
|
8242
8428
|
const abs=pill.querySelector('.cmHudSeg[data-mode="abs"]');if(abs)abs.setAttribute('data-tip',cmHudLock?'First point has no anchor to offset from — absolute only':'Absolute — X′,Y′,Z′ in the local frame (X,Y,Z if none)');}
|
|
8243
8429
|
function cmHudPlaceholder(){if(!cmHudEl)return;const inp=cmHudEl.querySelector('input');if(!inp)return;
|
|
8244
|
-
if(cmHudConsumer==='position'){
|
|
8430
|
+
if(cmHudConsumer==='position'){const ang=posHudTarget&&(posHudTarget.axis==='rot'||posHudTarget.axis==='swingPlan'||posHudTarget.axis==='swingElev');
|
|
8431
|
+
inp.placeholder=posHudTarget?(ang?(String(+(+posHudTarget.cur||0).toFixed(2))+'°'):(posOffDisp(posHudTarget.cur)||'0"')):'';return;} // 3b.3: the current value is the hint (HUD opens empty). 3b.1: a reference-line handle types a DELTA, so its hint is 0.
|
|
8245
8432
|
inp.placeholder=cmHudAbs?(cmHudPrimed?"X′,Y′ · or X′,Y′,Z′":"X,Y · or X,Y,Z"):(cmHudConsumer==='add'?"dx,dy · or dx,dy,dz":"12'-6 · or dx,dy");}
|
|
8246
8433
|
function cmHudEcho(){const inp=cmHudEl.querySelector('input'),lbl=cmHudEl.querySelector('#cmHudLbl');
|
|
8247
8434
|
const pv=parseVec(inp.value),n=(cmTool==='copy'&&!cmArrayMode&&cmCount>1)?(' ×'+cmCount):'';let txt='';
|
|
@@ -8290,6 +8477,37 @@ function cmHudCommit(str){
|
|
|
8290
8477
|
if(cmHudConsumer==='position'){ // 3b.3: single scalar → commitMemberPosition (same path as a drag: absolute value, one undo entry). Typed values BYPASS the ¼"/5° snap.
|
|
8291
8478
|
const t=String(str==null?'':str).trim();
|
|
8292
8479
|
if(t===''||!posHudTarget){cmHudClose();return;} // empty = no-op close
|
|
8480
|
+
if(posHudTarget.axis==='slide'||posHudTarget.axis==='swingPlan'||posHudTarget.axis==='swingElev'){ // 3b.1: a reference-line handle — the typed value is a DELTA, committed as absolute work points
|
|
8481
|
+
const st=memberPositionGizmoState(posHudTarget.id);
|
|
8482
|
+
if(!st||!st.available){cmHudEl.classList.add('err');toast('Can’t move this member right now'+(st&&st.reason?' — '+st.reason:'')+'.');return;}
|
|
8483
|
+
let spec=null;
|
|
8484
|
+
if(posHudTarget.axis==='slide'){
|
|
8485
|
+
const inch=parseLen(t);if(inch==null||!isFinite(inch)){cmHudEl.classList.add('err');toast('Couldn’t read “'+t+'” as a length — try 3 1/2" or 1\'-3 1/2".');return;}
|
|
8486
|
+
if(Math.abs(inch)<1e-9){cmHudClose();return;} // typing 0 is "never mind", not an error — close quietly rather than toasting the command's inert-move refusal
|
|
8487
|
+
const r=SteelCore.slideEndpoints(st.anchor,st.end,st.xAxis,inch*25.4);
|
|
8488
|
+
if(!r){cmHudEl.classList.add('err');toast('That slide can’t be applied to this member.');return;}
|
|
8489
|
+
spec={from:r.from,to:r.to,gesture:'slide'};
|
|
8490
|
+
}else{
|
|
8491
|
+
const deg=Number(t.replace(',','.'));if(!isFinite(deg)){cmHudEl.classList.add('err');toast('Enter an angle in degrees, e.g. 45 or -90.');return;}
|
|
8492
|
+
let theta=deg*Math.PI/180;
|
|
8493
|
+
const swingAxis=posHudTarget.axis==='swingPlan'?st.up:st.yAxis;
|
|
8494
|
+
if(posHudTarget.axis==='swingElev'){
|
|
8495
|
+
// A typed value bypasses the SNAP — that is the shipped 3b.3 contract — but it does not bypass
|
|
8496
|
+
// geometry. 'typed' mode REFUSES rather than silently rewriting the number the user asked for; the
|
|
8497
|
+
// HUD stays open in its error state so they can see nothing was committed and pick another angle.
|
|
8498
|
+
const bars=SteelCore.swingBarriers(st.anchor,st.end,st.yAxis,st.up,SteelCore.POSITION_SWING_MARGIN_RAD); // ONE constant shared with the drag path — if they drift, typing a number the drag allowed gets refused
|
|
8499
|
+
const c=bars&&SteelCore.clampSwingTheta(theta,bars,'typed',0);
|
|
8500
|
+
if(!c){cmHudEl.classList.add('err');toast('That angle would tilt the member through plumb — nothing was committed. Try a smaller angle.');return;}
|
|
8501
|
+
theta=c.theta;
|
|
8502
|
+
}
|
|
8503
|
+
const to=SteelCore.swingEndpoint(st.anchor,st.end,swingAxis,theta);
|
|
8504
|
+
if(!to){cmHudEl.classList.add('err');toast('That swing can’t be applied to this member.');return;}
|
|
8505
|
+
spec={to,gesture:posHudTarget.axis};
|
|
8506
|
+
}
|
|
8507
|
+
const okRef=commitMemberEndpoints(posHudTarget.id,spec,cmHudEl);
|
|
8508
|
+
if(!okRef){cmHudEl.classList.add('err');return;}
|
|
8509
|
+
cmHudClose();return;
|
|
8510
|
+
}
|
|
8293
8511
|
let val;
|
|
8294
8512
|
if(posHudTarget.axis==='rot'){val=Number(t.replace(',','.'));if(!isFinite(val)){cmHudEl.classList.add('err');toast('Enter an angle in degrees, e.g. 45 or -90.');return;}val=SteelCore.rollCommitNorm(val);}
|
|
8295
8513
|
else{const inch=parseLen(t);if(inch==null||!isFinite(inch)){cmHudEl.classList.add('err');toast('Couldn’t read “'+t+'” as a length — try 3 1/2" or 1\'-3 1/2".');return;}val=inch*25.4;}
|
|
@@ -8765,7 +8983,7 @@ function updRefToggle(){const b=document.getElementById('refToggleB');if(!b)retu
|
|
|
8765
8983
|
// that flag — the reader writes it and Steel Filter only dims the row. So say it here, on the one
|
|
8766
8984
|
// control a user consults to reason about the backdrop, instead of leaving the omission silent.
|
|
8767
8985
|
const n=hiddenLayerCount();
|
|
8768
|
-
b.setAttribute('data-tip',REF_TIP+(n?(' '+n+' layer'+(n===1?'':'s')+' marked “listed but not drawn” '+(n===1?'is':'are')+' always excluded — review them in
|
|
8986
|
+
b.setAttribute('data-tip',REF_TIP+(n?(' '+n+' layer'+(n===1?'':'s')+' marked “listed but not drawn” '+(n===1?'is':'are')+' always excluded — review them in Drawing Filter.'):''));}
|
|
8769
8987
|
document.getElementById('refToggleB').onclick=e=>{e.stopPropagation();refSheetOn=!refSheetOn;try{localStorage.setItem('steel:refSheet:v2',refSheetOn?'1':'0');}catch(_){}updRefToggle();render();};
|
|
8770
8988
|
document.getElementById('gridEditB').onclick=()=>{setGridMode(!gridMode);render();};
|
|
8771
8989
|
document.getElementById('dimStyleB').onclick=()=>{setDimStyleMode(!dimStyleMode);render();};
|
|
@@ -9520,6 +9738,7 @@ const view3dApi={
|
|
|
9520
9738
|
onMoveMember:(id,newWp)=>{edit(()=>{const m=byId(id);if(m)MC().replaceEndpoints(m,newWp);});}, // 3D drag → write wp (undoable, autosaves, syncs 2D/chip/BOM). NOTE: the Select filter gates SELECTION (pick/marquee/Ctrl+A), NOT direct 3D drag-manipulation — gating here would strand the renderer's live preview (the mesh is already moved), so a filtered member is still directly draggable in 3D by design.
|
|
9521
9739
|
positionGizmoState:(id)=>memberPositionGizmoState(id), // 3D Profile Position gizmo (slice 3a): read-only frame axes + current-frame offset/roll for one member
|
|
9522
9740
|
commitMemberPosition:(id,patch,source)=>commitMemberPosition(id,patch,source), // gizmo drag/type → absolute {positionOffset|positionHOffset|rot} through the shipped commitPositionEdit (one undo entry)
|
|
9741
|
+
commitMemberEndpoints:(id,spec,source)=>commitMemberEndpoints(id,spec,source), // slice 3b.1: reference-line handles → absolute world-mm work points through moveWorkPoints (one undo entry, connections revalidate at the server write boundary)
|
|
9523
9742
|
openPositionHud:(id,axis,scr)=>openPositionHud(id,axis,scr), // 3b.3: double-click a handle → dock the shared #cmHud typed-entry HUD at it, commit bypasses snap
|
|
9524
9743
|
showHandleTip:(txt,x,y)=>{if(window.__tip)window.__tip.showText(txt,x,y);}, // 3b.3: canvas gizmo handles carry no DOM data-tip — route through the shared themed #tooltip programmatically
|
|
9525
9744
|
hideHandleTip:()=>{if(window.__tip)window.__tip.hide();},
|
|
@@ -12,12 +12,110 @@
|
|
|
12
12
|
* element : { kind:'line'|'text', layer:string, w:number, color:string, d?:string, text?:string, bbox?:number[], dashed?:boolean }
|
|
13
13
|
* mode : any '+'-joined combo of 'layer'/'thickness'/'color', AND-ed (e.g. 'thickness+layer').
|
|
14
14
|
* '' = match nothing. Canonical order = MODE_ORDER.
|
|
15
|
-
* sel : { layers:Set<string>, thicknesses:Set<number>, colors:Set<string> }
|
|
15
|
+
* sel : { layers:Set<string>, thicknesses:Set<number>, colors:Set<string> } — CANONICAL keys
|
|
16
|
+
* (`facetKey`), never raw row/element values. Every producer and consumer of this object
|
|
17
|
+
* must agree on that, which is why they all route through FACET_DIMS + facetKey.
|
|
16
18
|
* filter : { mode, layers:[…], thicknesses:[…], colors:[…], sheets:[{sheet,sourceHash,elements:[…]}] }
|
|
17
19
|
*/
|
|
18
20
|
|
|
19
21
|
/** Canonical dimension order for a mode string. */
|
|
20
|
-
const MODE_ORDER = ['thickness', 'layer', 'color'];
|
|
22
|
+
export const MODE_ORDER = Object.freeze(['thickness', 'layer', 'color']);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* THE dimension descriptor — the ONE place that knows a dimension's three different names for itself.
|
|
26
|
+
*
|
|
27
|
+
* A dimension is called `thickness` in a mode string, its control rows live on `filter.thicknesses`
|
|
28
|
+
* keyed `w`, and the element it matches keys `w` too — but `layer` rows key on `name` while their
|
|
29
|
+
* elements key on `layer`, and nothing in the shapes makes that correspondence visible. The first
|
|
30
|
+
* draft of the Phase D design wrote `line.facets[dim]` with `dim === 'thickness'`, which reads
|
|
31
|
+
* `undefined`: the entire thickness dimension would have matched nothing, silently. Index every
|
|
32
|
+
* lookup through here so that mistake cannot be written a second time.
|
|
33
|
+
*
|
|
34
|
+
* `control` is deliberately ONE field for two things — the filter's control array (`filter.colors`)
|
|
35
|
+
* and the in-memory selection Set (`sel.colors`) already share a name. Keeping it one field is what
|
|
36
|
+
* lets a PRODUCER and a CONSUMER of a selection set be routed through the same descriptor entry, and
|
|
37
|
+
* the whole point of #805 Phase D slice D1 is that they cannot be routed through different ones.
|
|
38
|
+
*
|
|
39
|
+
* FROZEN, and MODE_ORDER with it: these three tables are now the single place the browser predicate,
|
|
40
|
+
* the ledger predicate and the census all resolve a dimension through, and they are exported
|
|
41
|
+
* cross-module into the server. A mutable single source of truth is one assignment away from not
|
|
42
|
+
* being single. (Same treatment as MODEL_V2_TOL in web/steel-3d-core.js.)
|
|
43
|
+
*/
|
|
44
|
+
export const FACET_DIMS = Object.freeze({
|
|
45
|
+
thickness: Object.freeze({ dim: 'thickness', control: 'thicknesses', rowKey: 'w', elementKey: 'w' }),
|
|
46
|
+
layer: Object.freeze({ dim: 'layer', control: 'layers', rowKey: 'name', elementKey: 'layer' }),
|
|
47
|
+
color: Object.freeze({ dim: 'color', control: 'colors', rowKey: 'hex', elementKey: 'color' }),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
/** The dimension a control / selection-set name belongs to — 'colors' -> 'color'. */
|
|
51
|
+
export const FACET_DIM_BY_CONTROL = Object.freeze({ thicknesses: 'thickness', layers: 'layer', colors: 'color' });
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* PURE canonicalisation of one facet value, and nothing else.
|
|
55
|
+
*
|
|
56
|
+
* Behaviour-preserving by construction: this is exactly what the ledger's `selectionIndex` and
|
|
57
|
+
* `selectedBy` have always done — widths rounded to 2 dp, colours lowercased, layer names compared
|
|
58
|
+
* exactly — including the parts nobody designed on purpose. `NaN`, `Infinity`, `-0` and `''` all come
|
|
59
|
+
* back OUT as values because they go IN as values today; `server/steel-selection-predicate.test.ts`
|
|
60
|
+
* pins each one against the pre-refactor code.
|
|
61
|
+
*
|
|
62
|
+
* `undefined` means "not a value for this dimension at all" — the wrong JS type — and is the ONLY
|
|
63
|
+
* rejection performed here. Whether a value is one a human could meaningfully have been SHOWN and
|
|
64
|
+
* EXCLUDED is a different question with a different answer, and it lives in
|
|
65
|
+
* `isDismissibleFacetValue`. Merging the two would turn a refactor of the selection predicate into a
|
|
66
|
+
* silent verdict change, which is precisely what this slice exists to avoid.
|
|
67
|
+
*/
|
|
68
|
+
export function facetKey(dim, value) {
|
|
69
|
+
if (dim === 'thickness') return typeof value === 'number' ? Number(value.toFixed(2)) : undefined;
|
|
70
|
+
if (dim === 'layer') return typeof value === 'string' ? value : undefined;
|
|
71
|
+
if (dim === 'color') return typeof value === 'string' ? value.toLowerCase() : undefined;
|
|
72
|
+
// LOUD, and unreachable from correct code is exactly why. Returning `undefined` for an unknown
|
|
73
|
+
// dimension is indistinguishable from "this value is the wrong type" — so a single typo
|
|
74
|
+
// (`facetKey('colors', …)`, the CONTROL name rather than the dim) would disable every checkbox and
|
|
75
|
+
// make Save write every `on` to false, silently, behind a screen that looks plausible.
|
|
76
|
+
throw new Error(`facetKey: unknown dimension ${JSON.stringify(dim)}`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Is this CANONICAL key a value a human could meaningfully have been shown and excluded?
|
|
81
|
+
*
|
|
82
|
+
* Asked only about dismissibility, never about selection: a non-empty string, or a finite number.
|
|
83
|
+
* `NaN`, `Infinity` and `''` stay selectable (see `facetKey`) — they are simply never a basis for
|
|
84
|
+
* dismissing a line without a written justification, so a line carrying one gets an explicit row
|
|
85
|
+
* instead. Fail-closed, and a deliberate behaviour CHANGE from the layer-only rule it generalises,
|
|
86
|
+
* which admitted every non-empty string including a width that is not a width.
|
|
87
|
+
*/
|
|
88
|
+
export function isDismissibleFacetValue(dim, key) {
|
|
89
|
+
if (dim === 'thickness') return typeof key === 'number' && Number.isFinite(key);
|
|
90
|
+
if (dim === 'layer' || dim === 'color') return typeof key === 'string' && key !== '';
|
|
91
|
+
// Same reason as `facetKey`: a quiet `false` here would silently withhold the shorthand for a whole
|
|
92
|
+
// dimension, which reads as "the human excluded nothing" rather than as the typo it is.
|
|
93
|
+
throw new Error(`isDismissibleFacetValue: unknown dimension ${JSON.stringify(dim)}`);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The persisted mode as the LEDGER's predicate reads it: a non-string mode defaults to 'layer'.
|
|
98
|
+
* Stated once, here, because `selectionIndex` needs the string and `selectionDims` needs the rule.
|
|
99
|
+
*/
|
|
100
|
+
export function selectionMode(mode) {
|
|
101
|
+
return typeof mode === 'string' ? mode : 'layer';
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The dimensions a persisted mode activates under the LEDGER's rule — a RAW SUBSTRING test, kept
|
|
106
|
+
* verbatim. `xlayer` activates layer; `colour+layer` activates layer and NOT colour; an unknown mode
|
|
107
|
+
* activates nothing and therefore selects everything.
|
|
108
|
+
*
|
|
109
|
+
* Deliberately NOT `modeDims`, which normalises by splitting on '+'. The two genuinely disagree on a
|
|
110
|
+
* malformed persisted mode, and normalising here would silently change a stored verdict. Phase D's
|
|
111
|
+
* answer to that divergence is a canonicity gate on the saved mode — a refusal, not a quiet rewrite —
|
|
112
|
+
* and it lands in a later slice; until then the rule stays exactly as it was, in ONE place instead of
|
|
113
|
+
* being re-derived wherever it is needed.
|
|
114
|
+
*/
|
|
115
|
+
export function selectionDims(mode) {
|
|
116
|
+
const raw = selectionMode(mode);
|
|
117
|
+
return MODE_ORDER.filter((dim) => raw.includes(dim));
|
|
118
|
+
}
|
|
21
119
|
|
|
22
120
|
/** The dimensions a mode activates, order-agnostic: 'thickness+layer' -> ['thickness','layer']. */
|
|
23
121
|
export function modeDims(mode) {
|
|
@@ -33,14 +131,22 @@ export function canonicalMode(dims) {
|
|
|
33
131
|
/**
|
|
34
132
|
* The active match predicate — an element passes when it matches EVERY checked dimension (AND).
|
|
35
133
|
* Zero checked dimensions match nothing (a valid, visible "0 shown" state, not a fall-through to all).
|
|
134
|
+
*
|
|
135
|
+
* It compares CANONICAL keys (`facetKey`), which is what makes it the same question the ledger's
|
|
136
|
+
* `selectedBy` asks rather than a lookalike: before #805 Phase D this compared raw values, so a
|
|
137
|
+
* `#ABC123` element and a `#abc123` row were the same value to the server and different values here.
|
|
138
|
+
* An element whose value is not a value for its dimension at all (a numeric layer, a string width)
|
|
139
|
+
* has no canonical key and matches nothing — the ledger has always refused it, and a tick the ledger
|
|
140
|
+
* would never honour is a lie the panel used to be able to tell.
|
|
36
141
|
*/
|
|
37
142
|
export function matchesActive(el, mode, sel) {
|
|
38
143
|
const dims = modeDims(mode);
|
|
39
144
|
if (!dims.length) return false;
|
|
40
|
-
return dims.every((
|
|
41
|
-
d
|
|
42
|
-
|
|
43
|
-
|
|
145
|
+
return dims.every((dim) => {
|
|
146
|
+
const d = FACET_DIMS[dim];
|
|
147
|
+
const key = facetKey(dim, el[d.elementKey]);
|
|
148
|
+
return key !== undefined && sel[d.control].has(key);
|
|
149
|
+
});
|
|
44
150
|
}
|
|
45
151
|
|
|
46
152
|
/**
|
|
@@ -50,10 +156,22 @@ export function matchesActive(el, mode, sel) {
|
|
|
50
156
|
*/
|
|
51
157
|
export function selFromFilter(filter) {
|
|
52
158
|
const onOr = (it, dflt) => (it.on === undefined ? dflt : !!it.on);
|
|
159
|
+
// Sets hold CANONICAL keys, never raw row values — see `matchesActive`. A row whose value is not a
|
|
160
|
+
// value for its dimension contributes nothing: it could never have matched an element the ledger
|
|
161
|
+
// accepts, so admitting it would only let the panel show a tick with no consequence.
|
|
162
|
+
const keys = (dim, rows, dflt) => {
|
|
163
|
+
const out = new Set();
|
|
164
|
+
for (const row of rows) {
|
|
165
|
+
if (!onOr(row, dflt(row))) continue;
|
|
166
|
+
const key = facetKey(dim, row[FACET_DIMS[dim].rowKey]);
|
|
167
|
+
if (key !== undefined) out.add(key);
|
|
168
|
+
}
|
|
169
|
+
return out;
|
|
170
|
+
};
|
|
53
171
|
return {
|
|
54
|
-
layers:
|
|
55
|
-
thicknesses:
|
|
56
|
-
colors:
|
|
172
|
+
layers: keys('layer', filter.layers || [], (l) => !!l.steel),
|
|
173
|
+
thicknesses: keys('thickness', filter.thicknesses || [], () => true),
|
|
174
|
+
colors: keys('color', filter.colors || [], () => true),
|
|
57
175
|
};
|
|
58
176
|
}
|
|
59
177
|
|
|
@@ -65,10 +183,25 @@ export function eyedropperAdd(sel, el, which) {
|
|
|
65
183
|
// Text spans / hairlines (w<=0) have no meaningful stroke width — the popover hides their
|
|
66
184
|
// Thickness row, so "all" must not slip a w:0 into the thickness selection (which would then
|
|
67
185
|
// match every text/hairline element in any thickness mode — the opposite of isolating steel).
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
186
|
+
// The guard is on the CANONICAL key, not the raw width, and that is load-bearing: a raw `0.004`
|
|
187
|
+
// passes `el.w > 0` but canonicalises to `0`, which would slip exactly the `w: 0` this comment
|
|
188
|
+
// forbids into the thickness selection — and then match every text/hairline element in any
|
|
189
|
+
// thickness mode. Unreachable from our own extractor (1-dp widths floor at 0.1) and reachable on
|
|
190
|
+
// the hand-edited filters this slice says genuinely behave differently, which is the population
|
|
191
|
+
// that needs the guard most. A `0 pt` value is also never a row the Filter shows, so ticking it
|
|
192
|
+
// would tick nothing the human can see.
|
|
193
|
+
const width = facetKey('thickness', el.w);
|
|
194
|
+
const hasStroke = el.kind !== 'text' && width !== undefined && width > 0;
|
|
195
|
+
// Canonical keys, for the same reason `selFromFilter` builds them: what lands in the Set has to be
|
|
196
|
+
// the same value `matchesActive` and `applySelToFilter` will look for, or a picked element ticks a
|
|
197
|
+
// box that Save then writes OFF.
|
|
198
|
+
const add = (dim) => {
|
|
199
|
+
const key = facetKey(dim, el[FACET_DIMS[dim].elementKey]);
|
|
200
|
+
if (key !== undefined) sel[FACET_DIMS[dim].control].add(key);
|
|
201
|
+
};
|
|
202
|
+
if (which === 'layer' || which === 'all') add('layer');
|
|
203
|
+
if ((which === 'thickness' || which === 'all') && hasStroke) add('thickness');
|
|
204
|
+
if (which === 'color' || which === 'all') add('color');
|
|
72
205
|
return sel;
|
|
73
206
|
}
|
|
74
207
|
|
|
@@ -172,12 +305,22 @@ export function textFontSize(bbox, text) {
|
|
|
172
305
|
/**
|
|
173
306
|
* Write the live selection + mode back onto the filter block's `on` flags so it persists on the
|
|
174
307
|
* contract (what Save PUTs, and what the reader reads). Mutates and returns `filter`.
|
|
308
|
+
*
|
|
309
|
+
* This is the CONSUMER half of the pair that must never disagree with the producers. Reading a raw
|
|
310
|
+
* row value out of a Set that holds canonical keys is not a near miss — it is a silent discard: the
|
|
311
|
+
* human clicks All, the checkbox renders ticked, and Save writes the row OFF with no error and no
|
|
312
|
+
* visible sign. Every producer (`selFromFilter`, `eyedropperAdd`, and the panel's own All/None and
|
|
313
|
+
* per-row handlers) therefore goes through `facetKey` too.
|
|
175
314
|
*/
|
|
176
315
|
export function applySelToFilter(filter, sel, mode) {
|
|
177
316
|
filter.mode = mode;
|
|
178
|
-
for (const
|
|
179
|
-
|
|
180
|
-
|
|
317
|
+
for (const dim of MODE_ORDER) {
|
|
318
|
+
const d = FACET_DIMS[dim];
|
|
319
|
+
for (const row of filter[d.control] || []) {
|
|
320
|
+
const key = facetKey(dim, row[d.rowKey]);
|
|
321
|
+
row.on = key !== undefined && sel[d.control].has(key);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
181
324
|
return filter;
|
|
182
325
|
}
|
|
183
326
|
|
|
@@ -249,6 +392,10 @@ export function statChip(state) {
|
|
|
249
392
|
// Not an error: the user's selection is fine, the model simply moved under them.
|
|
250
393
|
case 'conflict': return { cls: 'conflict', text: 'Save conflict', badge: null };
|
|
251
394
|
case 'stale': return { cls: 'conflict', text: 'Out of date', badge: null };
|
|
395
|
+
// The filter edit SAVED but the read's layer approval was refused, so the read cannot proceed.
|
|
396
|
+
// Wears the same pill for the same reason: what you see no longer matches the server, and the chip
|
|
397
|
+
// is the route back to the explanation.
|
|
398
|
+
case 'signoff-blocked': return { cls: 'conflict', text: 'Approval needed', badge: null };
|
|
252
399
|
// Informational, not the result of an action the user took — so no green ✓ for a save that never happened.
|
|
253
400
|
case 'note': return { cls: '', text: NOTE_TEXT, badge: null };
|
|
254
401
|
default: return { cls: '', text: '', badge: null };
|
|
@@ -370,3 +517,29 @@ export function liveUpdateAction(frame, ctx) {
|
|
|
370
517
|
// caller's table lookup can never be handed an object or a number off the wire.
|
|
371
518
|
return { act: 'banner', reason: typeof frame.reason === 'string' ? frame.reason : null };
|
|
372
519
|
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* THE canonical "dismissible" layer set — the ONE definition shared by the recorded layer sign-off's
|
|
523
|
+
* server digest (server/steel-read-manifest.ts), the sign-off confirm step in steel-filter.html, and
|
|
524
|
+
* (from #805 Phase C slice 2) the completion audit's shorthand-eligibility predicate. Defining it once
|
|
525
|
+
* is the point: three predicates that merely agree can drift, and one of them decides when real steel
|
|
526
|
+
* may be dismissed without a line-by-line justification.
|
|
527
|
+
*
|
|
528
|
+
* A layer name qualifies iff it is a NON-EMPTY string and EVERY row carrying that name has
|
|
529
|
+
* `on === false` (a duplicated name with one row ticked ON is therefore NOT dismissible, and neither
|
|
530
|
+
* is a non-boolean `on`, which is neither ON nor OFF). Emitted once per name, in the filter's
|
|
531
|
+
* persisted order — never sorted, because the order is part of the list the human was shown and a
|
|
532
|
+
* reorder must read as a change.
|
|
533
|
+
*/
|
|
534
|
+
export function dismissibleLayerNames(filter) {
|
|
535
|
+
const rows = (filter && typeof filter === 'object' && Array.isArray(filter.layers)) ? filter.layers : [];
|
|
536
|
+
const allOff = new Map();
|
|
537
|
+
const order = [];
|
|
538
|
+
for (const row of rows) {
|
|
539
|
+
if (!row || typeof row !== 'object' || Array.isArray(row)) continue;
|
|
540
|
+
if (typeof row.name !== 'string' || row.name === '') continue;
|
|
541
|
+
if (!allOff.has(row.name)) order.push(row.name);
|
|
542
|
+
allOff.set(row.name, (allOff.get(row.name) ?? true) && row.on === false);
|
|
543
|
+
}
|
|
544
|
+
return order.filter((name) => allOff.get(name) === true);
|
|
545
|
+
}
|