@floless/app 0.160.0 → 0.161.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -542,6 +542,20 @@ body.publication-blocked #empty{position:static;flex:1}
542
542
  #zoombar button[aria-pressed="true"]:hover{background:var(--brand-hover)}
543
543
  /* Forced colors flattens the brand fill, so the pressed state needs a cue that is not a colour. */
544
544
  @media (forced-colors:active){#zoombar button[aria-pressed="true"]{outline:2px solid currentColor;outline-offset:-3px}}
545
+ /* #2777 slice D: a place AI Chat opened here. Its outline is its OWN layer in #canvas, never the #hot halo,
546
+ which hover and the eyedropper repaint at will. It takes no pointer events, so the canvas works as
547
+ before underneath it; only a sheet change, a new place or Clear removes it. */
548
+ #focusPlace rect{fill:var(--brand);fill-opacity:.10;stroke:var(--brand);stroke-width:2.5;stroke-dasharray:6 4;vector-effect:non-scaling-stroke;pointer-events:none}
549
+ /* On arrival the place glows twice, so the eye finds it, then settles. A glow, not a shake: moving the outline would
550
+ show it, for a moment, where the place is not. No motion for a person who asked for less of it. */
551
+ #focusPlace rect.arriving{animation:focus-place-arrive .6s ease-in-out 2}
552
+ @keyframes focus-place-arrive{50%{fill-opacity:.32;stroke-width:6;stroke-dasharray:none}}
553
+ @media (prefers-reduced-motion:reduce){#focusPlace rect.arriving{animation:none}}
554
+ #placebar{position:absolute;left:50%;top:12px;transform:translateX(-50%);max-width:calc(100% - 24px);display:flex;align-items:center;gap:8px;background:var(--stage-panel);border:1px solid var(--stage-line);border-radius:8px;padding:6px 8px 6px 12px;box-shadow:var(--stage-shadow);color:var(--stage-text);font-size:12.5px;line-height:1.35}
555
+ #placebar[hidden]{display:none}
556
+ #placebar.missing{border-color:var(--warn)}
557
+ #placebar button{flex:none;background:var(--stage-btn);border-color:var(--stage-ctrl);color:var(--stage-text)}
558
+ #placebar button:hover{background:var(--stage-btn-hover)}
545
559
  /* The readout: a chip ANCHORED at the line being read. An earlier cut of this slice docked it in the
546
560
  stage's top-right corner and the second review took that apart on the task itself: finding the one
547
561
  layer to untick is a fast sweep across many lines, and a corner readout costs an eye trip from the
@@ -784,6 +798,7 @@ body.publication-blocked #empty{position:static;flex:1}
784
798
  </svg>
785
799
  <svg id="canvas" preserveAspectRatio="xMidYMid meet">
786
800
  <g id="overlay" fill="none"></g>
801
+ <g id="focusPlace" aria-hidden="true"></g>
787
802
  </svg>
788
803
  <div id="empty" role="status" aria-live="polite">
789
804
  <div>
@@ -811,6 +826,7 @@ body.publication-blocked #empty{position:static;flex:1}
811
826
  means longer text costs legibility, never an overhanging bar. "Zoom steel" not "Steel": a
812
827
  bare noun read as a category, not a command. data-tip (never title=) carries the full
813
828
  sentence. -->
829
+ <div id="placebar" role="status" aria-live="polite" hidden><span id="placebarText"></span><button id="placebarClear" type="button" data-command-id="filter.place-clear" data-tip="Remove the marked place from this drawing">Clear</button></div>
814
830
  <div id="zoombar"><button id="fit2" data-command-id="filter.fit" data-tip="Fit the whole page in view">Fit</button><button id="zoomsteel2" data-command-id="filter.zoom-steel" data-tip="Zoom to fit the steel elements on this sheet">Zoom steel</button><span class="zb-sep" aria-hidden="true"></span><button id="hoverInfo" type="button" aria-pressed="false" data-command-id="filter.hover-info" data-tip="Point at any line or label, shown or switched off, to read its layer, thickness and colour — and light up its rows in the Filters panel. Click a switched-off line to see what to tick to bring it back. Background-only linework, on layers the drawing read never picked up, can’t be read by pointing; click an empty spot to ask the original drawing what is there, where the original drawing is available.">Hover info</button></div>
815
831
  <!-- The hover readout, anchored at the line it names (see #hoverbar's CSS for why it is not docked).
816
832
  Hidden until the pointer is on a line with the mode on; hidden again when it leaves the line, or
@@ -1178,6 +1194,125 @@ window.__floFilterAi = Object.freeze({
1178
1194
  keep:(requestId) => keepFilterAi(String(requestId)),
1179
1195
  });
1180
1196
 
1197
+ /**
1198
+ * #2777 slice D: show a place AI Chat named: a sheet, and on it the area its picture outlined.
1199
+ *
1200
+ * ONE SLOT, keyed by the request's id, the same contract as the model editor's `flolessEditorFocus`
1201
+ * (steel-editor.html): `window.flolessFilterFocus(req)` answers `false` for a request it cannot read, and
1202
+ * otherwise a promise of `{ok:true}`, `{ok:false,said}` or `{superseded:true}`. A request made before the
1203
+ * drawings have loaded is held and runs once they have. `flolessFilterFocusCancel(id)` withdraws only
1204
+ * the request with that id. No URL form, for the editor's reason: the shell checks the frame's address.
1205
+ *
1206
+ * The page is matched exactly: the source file, its page id and the sheet name must name ONE saved sheet.
1207
+ * None or several, and the view stays where it was with a notice saying why, never a nearby sheet.
1208
+ */
1209
+ const FilterFocus = (() => {
1210
+ let slot = null, ready = false, failed = '', made = 0;
1211
+ window.flolessFilterState = { project: PROJECT, ready: false };
1212
+ const text = (v, max = 200) => typeof v === 'string' && v && v.length <= max ? v : '';
1213
+ const box = (v) => Array.isArray(v) && v.length === 4 && v.every((n) => typeof n === 'number' && Number.isFinite(n)) && v[2] > v[0] && v[3] > v[1] ? v.slice() : null;
1214
+ const normalise = (req) => {
1215
+ if(!req || !/^[0-9a-f]{64}$/.test(String(req.sourceHash || '').toLowerCase()) || !text(req.pageId) || !text(req.sheet)) return null;
1216
+ if(req.region !== undefined && !box(req.region)) return null;
1217
+ return { sourceHash: String(req.sourceHash).toLowerCase(), pageId: req.pageId, sheet: req.sheet, ...(req.region ? { region: box(req.region) } : {}) };
1218
+ };
1219
+ const run = (job) => {
1220
+ slot = null;
1221
+ let outcome;
1222
+ try { outcome = showFocusPlace(job.req); }
1223
+ catch(error){
1224
+ console.error('[filter] could not show the place asked for', error);
1225
+ outcome = { ok:false, said:'The Drawing Filter could not show this place. Press Open in Drawing Filter again.' };
1226
+ }
1227
+ job.settle(outcome);
1228
+ };
1229
+ window.flolessFilterFocus = (req) => {
1230
+ const clean = normalise(req);
1231
+ if(!clean) return false;
1232
+ const id = text(req.requestId) || 'filter-' + (++made);
1233
+ let settle = null;
1234
+ const outcome = new Promise((resolve) => { settle = resolve; });
1235
+ if(failed){ settle({ ok:false, said:failed }); return outcome; }
1236
+ if(slot) slot.settle({ superseded:true });
1237
+ const job = { id, req:clean, settle };
1238
+ if(ready) run(job); else slot = job;
1239
+ return outcome;
1240
+ };
1241
+ window.flolessFilterFocusCancel = (requestId) => {
1242
+ if(!slot || slot.id !== requestId) return false;
1243
+ const job = slot; slot = null;
1244
+ job.settle({ superseded:true });
1245
+ return true;
1246
+ };
1247
+ return {
1248
+ ready(){
1249
+ if(ready || failed) return;
1250
+ ready = true;
1251
+ window.flolessFilterState = { project: PROJECT, ready: true };
1252
+ if(slot) run(slot);
1253
+ },
1254
+ fail(said){
1255
+ if(ready || failed) return;
1256
+ failed = said || 'The Drawing Filter has no drawings to show this place on.';
1257
+ // Said to the shell too: a page that showed nothing may only be out of date (the read prepared the drawings after
1258
+ // it loaded), and the shell reloads it once before asking it to show a place.
1259
+ window.flolessFilterState = { project: PROJECT, ready: false, failed: true };
1260
+ if(slot){ const job = slot; slot = null; job.settle({ ok:false, said:failed }); }
1261
+ },
1262
+ };
1263
+ })();
1264
+
1265
+ const focusLayer = document.getElementById('focusPlace');
1266
+ const placebar = document.getElementById('placebar');
1267
+ function clearFocusPlace(){
1268
+ focusLayer.replaceChildren();
1269
+ placebar.hidden = true;
1270
+ placebar.classList.remove('missing');
1271
+ }
1272
+ function sayPlace(message, missing){
1273
+ document.getElementById('placebarText').textContent = message;
1274
+ placebar.classList.toggle('missing', !!missing);
1275
+ placebar.hidden = false;
1276
+ }
1277
+ document.getElementById('placebarClear').addEventListener('click', clearFocusPlace);
1278
+
1279
+ /** Show one place. Returns the outcome the shell reports where the person clicked. */
1280
+ function showFocusPlace(req){
1281
+ const matches = [];
1282
+ sheets.forEach((sh, i) => {
1283
+ if(String(sh.sourceHash || '').toLowerCase() === req.sourceHash && sh.pageId === req.pageId && sh.sheet === req.sheet) matches.push(i);
1284
+ });
1285
+ if(matches.length !== 1){
1286
+ const said = matches.length
1287
+ ? `Sheet ${req.sheet} appears more than once in this Drawing Filter, so FloLess cannot tell which one the place is on.`
1288
+ : `Sheet ${req.sheet} is not in this project’s saved Drawing Filter, so the place cannot be marked here. Its picture in AI Chat still shows it.`;
1289
+ clearFocusPlace();
1290
+ sayPlace(said, true);
1291
+ return { ok:false, said };
1292
+ }
1293
+ setSheet(matches[0]);
1294
+ clearFocusPlace();
1295
+ if(!req.region){
1296
+ fit();
1297
+ sayPlace(`Sheet ${req.sheet}, opened from AI Chat. This place has no marked area, so the whole sheet is shown.`);
1298
+ return { ok:true };
1299
+ }
1300
+ const [x0, y0, x1, y1] = req.region;
1301
+ const r = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
1302
+ r.setAttribute('x', x0); r.setAttribute('y', y0); r.setAttribute('width', x1 - x0); r.setAttribute('height', y1 - y0);
1303
+ r.classList.add('arriving');
1304
+ r.addEventListener('animationend', () => r.classList.remove('arriving'), { once:true });
1305
+ focusLayer.appendChild(r);
1306
+ // Room around the place, so the person sees what it sits among; never beyond the page.
1307
+ const pad = Math.max(60, Math.max(x1 - x0, y1 - y0));
1308
+ const vx0 = Math.max(base.x, x0 - pad), vy0 = Math.max(base.y, y0 - pad);
1309
+ const vx1 = Math.min(base.x + base.w, x1 + pad), vy1 = Math.min(base.y + base.h, y1 + pad);
1310
+ vb = { x: vx0, y: vy0, w: Math.max(1, vx1 - vx0), h: Math.max(1, vy1 - vy0) };
1311
+ setVB();
1312
+ sayPlace(`The place from AI Chat is marked on sheet ${req.sheet}.`);
1313
+ return { ok:true };
1314
+ }
1315
+
1181
1316
  /**
1182
1317
  * The project's steel catalogue and display units, stated where the last human stop is.
1183
1318
  *
@@ -1824,6 +1959,7 @@ async function bootOnce(){
1824
1959
  document.getElementById('empty').classList.remove('show');
1825
1960
  document.getElementById('src').textContent = (C.source && C.source.name) ? ('· ' + C.source.name) : '';
1826
1961
  initFromFilter();
1962
+ FilterFocus.ready();
1827
1963
  // AFTER `initFromFilter`, deliberately. `boot()` wraps this in try/finally with no catch, so a
1828
1964
  // cosmetic throw ahead of the functional call would leave a mandatory checkpoint rendering nothing,
1829
1965
  // with no message. Nothing here can throw today -- the formatter is proven total -- but the ordering
@@ -1863,6 +1999,8 @@ function publicationEmptyState(code){
1863
1999
 
1864
2000
  function showEmpty(msg, publicationBlocked = false, detail = ''){
1865
2001
  notifyFilterAi();
2002
+ FilterFocus.fail(msg ? `The Drawing Filter cannot show this place: ${msg} The picture in AI Chat still shows it.`
2003
+ : 'The Drawing Filter has no drawings yet, so it cannot show this place. The picture in AI Chat still shows it; the Drawing Filter can once the read has prepared it.');
1866
2004
  const e = document.getElementById('empty');
1867
2005
  document.body.classList.toggle('publication-blocked', publicationBlocked);
1868
2006
  const body = e.querySelector('.empty-body');
@@ -2057,6 +2195,7 @@ function setSheet(i){
2057
2195
  filterAiSheetEpoch++;
2058
2196
  notifyFilterAi();
2059
2197
  }
2198
+ if(active !== previousSheet) clearFocusPlace();
2060
2199
  const sh = sheets[active] || {};
2061
2200
  const pg = (sh.page && sh.page.w > 0 && sh.page.h > 0) ? sh.page : { w: 1000, h: 1000 }; // guard empty page → no NaN viewBox
2062
2201
  svg.setAttribute('viewBox', `0 0 ${pg.w} ${pg.h}`);
@@ -585,7 +585,7 @@ function assertSplitInferredSupportAuthority(doc) {
585
585
  * DERIVED decision, since the split point is a new end, not the decision's own subject.
586
586
  */
587
587
  function splitMarkSource(fromZ, toZ) {
588
- // A placed end wins over an AI one: it is the weaker claim (unproven, left out of the BOM, asked), so the split
588
+ // A placed end wins over an AI one: it is the weaker claim (unproven, priced only as assumed, asked), so the split
589
589
  // point never reads as more settled than its least settled end.
590
590
  if (fromZ.assumed === true) return fromZ;
591
591
  if (toZ.assumed === true) return toZ;
@@ -1697,12 +1697,12 @@ export function createV2CommandSession(model, options = {}) {
1697
1697
  const presentationOnly = [];
1698
1698
  for (const id of new Set(memberIds)) {
1699
1699
  const member = memberById(doc, id);
1700
- const presence = plan ? memberPresence(doc, plan, member) : { observed: false, explicit: false, crossing: false, below: false, visible: false };
1700
+ const presence = plan ? memberPresence(doc, plan, member) : { observed: false, explicit: false, crossing: false, below: false, nearAbove: false, visible: false };
1701
1701
  // A column DERIVED onto this sheet by its height — the cut passes through it, or it ends just under
1702
1702
  // the cut and is drawn as "column below" (#2214) — is on this sheet only because of where it
1703
1703
  // stands. Deleting it here would remove a real column from the whole model for the sake of one
1704
1704
  // sheet's picture, so it is presentation-only until the read binds it or a person places it.
1705
- if ((presence.crossing || presence.below) && !presence.observed && !presence.explicit) presentationOnly.push(id);
1705
+ if ((presence.crossing || presence.below || presence.nearAbove) && !presence.observed && !presence.explicit) presentationOnly.push(id);
1706
1706
  else geometric.push(id);
1707
1707
  }
1708
1708
  if (geometric.length) deleteMembersFromDocument(doc, geometric);
@@ -10,9 +10,10 @@ import { planViewId, planViewLabels } from './steel-plan-view-id.js';
10
10
  /* Re-exported so the editor, which loads this module dynamically as `V2Projection`, has ONE place to
11
11
  * ask what a row's identity and display name are — rather than reading `.sheet` and hoping (#938). */
12
12
  export { planViewId, planViewLabels };
13
- import { columnBelowReachOf, columnCutRelation,POSITION_BASIS_CAPABILITY_VERSION } from './steel-3d-core.js';
13
+ import { columnBelowReachOf, columnCutRelation, defaultColumnNearCut,POSITION_BASIS_CAPABILITY_VERSION } from './steel-3d-core.js';
14
14
  export const POSITION_BASIS_PROJECTION_VERSION=POSITION_BASIS_CAPABILITY_VERSION;
15
- import { worldToSheetPx, planTransform, PlanTransformError } from './steel-plan-transform.js';
15
+ import { worldToSheetPx, planTransform, PlanTransformError, sourceRegistrationFrame, worldToSourceViewPx, axisOf } from './steel-plan-transform.js';
16
+ import { gridGeometry } from './grid-core.js';
16
17
 
17
18
  const V2_PROJECTION_LINK = Symbol.for('floless.steelModelV2ProjectionLink');
18
19
 
@@ -66,11 +67,13 @@ export function memberPresence(model, plan, member, index = null) {
66
67
  const explicit = lookup ? lookup.explicit.has(member.id) : (plan.memberRefs || []).includes(member.id);
67
68
  const cutMm = Number.isFinite(plan.elevation_mm) ? plan.elevation_mm : null;
68
69
  const relation = cutMm !== null && member.role === 'column'
69
- ? columnCutRelation(member.from?.z, member.to?.z, cutMm, columnBelowReachOf(model))
70
+ ? columnCutRelation(member.from?.z, member.to?.z, cutMm, columnBelowReachOf(model), defaultColumnNearCut(model?.environment))
70
71
  : 'unknown';
71
72
  const crossing = relation === 'crossing';
72
73
  const below = relation === 'below';
73
- return { observed, explicit, crossing, below, visible: observed || explicit || crossing || below };
74
+ // A base read a little over the cut (#2815): drawn where it is, solid, never moved to the level.
75
+ const nearAbove = relation === 'near-above';
76
+ return { observed, explicit, crossing, below, nearAbove, visible: observed || explicit || crossing || below || nearAbove };
74
77
  }
75
78
 
76
79
  /**
@@ -413,3 +416,128 @@ export function createV2Projection(model, viewId, options = {}) {
413
416
  export function projectionLink(value) {
414
417
  return value && typeof value === 'object' ? value[V2_PROJECTION_LINK] || null : null;
415
418
  }
419
+
420
+ /**
421
+ * The ELEVATION and SECTION views, drawn (#2780).
422
+ *
423
+ * `createV2Projection` refuses anything that is not a plan, by design, and an elevation used to have no
424
+ * 2D picture at all: choosing one left the plan on screen. An elevation registers differently — through
425
+ * an origin plus two world axes (`sourceRegistration`) — and this is its read boundary: the members this
426
+ * view shows (the same three-source rule, `memberPresence`), each end mapped from its true world position
427
+ * through that registration, plus the grid lines and levels that stand in the view's plane.
428
+ *
429
+ * Plan-SHAPED on purpose (`members[].wp` in display px, `clip`, empty `dims`/`segments`…) so the editor's
430
+ * canvas, selection and fit-to-window run on it unchanged; `elevationView` carries what only an elevation
431
+ * has, and its presence is how the editor knows this view is for LOOKING. There is no write path: a display
432
+ * pixel in an elevation does not say where a member's depth is, so nothing here maps px back to the model.
433
+ *
434
+ * It never throws for a view that cannot be placed — it projects empty and says why in
435
+ * `elevationView.refusal`, the same shape `registrationRefusal` uses for a plan, so the editor can tell the
436
+ * person in words rather than showing a blank canvas. Members whose height is not known are listed in
437
+ * `elevationView.unplaced`, never drawn at an invented height.
438
+ */
439
+ export function createElevationProjection(model, viewId, options = {}) {
440
+ const { session = null } = options;
441
+ const plan = (model.plans || []).find((p) => planViewId(p) === viewId);
442
+ if (!plan) throw new Error(`steel.model/v2 has no drawing view "${viewId}"`);
443
+ if (plan.viewKind !== 'elevation' && plan.viewKind !== 'section') {
444
+ throw Object.assign(new Error(`${planViewId(plan)} is not an elevation or section view`), { code: 'view-kind-unsupported' });
445
+ }
446
+ const projection = { ...clone(plan), modelGrid: clone(model.grid || null), grid: null };
447
+ for (const key of ['segments', 'labels', 'details', 'callouts', 'tos_callouts', 'dims']) {
448
+ if (!Array.isArray(projection[key])) projection[key] = [];
449
+ }
450
+ projection.default_tos_mm = 0;
451
+ const reg = sourceRegistrationFrame(plan);
452
+ const view = {
453
+ kind: plan.viewKind,
454
+ ok: reg.ok,
455
+ refusal: reg.ok ? null : { code: reg.code, message: reg.message },
456
+ gridLines: [],
457
+ levels: [],
458
+ unplaced: [],
459
+ shown: 0,
460
+ };
461
+ projection.elevationView = view;
462
+ projection.members = [];
463
+ let box = null;
464
+ const grow = (p) => {
465
+ if (!p) return;
466
+ box = box ? [Math.min(box[0], p[0]), Math.min(box[1], p[1]), Math.max(box[2], p[0]), Math.max(box[3], p[1])] : [p[0], p[1], p[0], p[1]];
467
+ };
468
+ if (reg.ok) {
469
+ const frame = reg.frame;
470
+ const index = createMemberPresenceIndex(model);
471
+ for (const member of model.members || []) {
472
+ if (!memberPresence(model, plan, member, index).visible) continue;
473
+ const a = worldToSourceViewPx(member.from, frame), b = worldToSourceViewPx(member.to, frame);
474
+ if (!a || !b) { view.unplaced.push(member.id); continue; }
475
+ const { ends, col, ...meta } = memberProperties(member);
476
+ projection.members.push({ ...meta, wp: [a, b], ends, col });
477
+ grow(a); grow(b);
478
+ }
479
+ view.shown = projection.members.length;
480
+ // Grid lines and levels. Only for a view whose drawing axes are the model's own (u along X or Y, v up Z):
481
+ // a rotated view's grid would be a slanted band this module has no honest way to draw, so it draws none
482
+ // and the members still stand where the registration puts them.
483
+ const uAxis = axisOf(frame.u), vAxis = axisOf(frame.v);
484
+ let geo = null;
485
+ try { geo = model.grid ? gridGeometry(model.grid, 1, { yUp: true }) : null; } catch { geo = null; }
486
+ if (geo && uAxis && uAxis.axis < 2) {
487
+ const lines = uAxis.axis === 0 ? geo.v : geo.h;
488
+ for (const l of lines) {
489
+ const at = uAxis.axis === 0
490
+ ? { x: l.x, y: frame.worldOrigin.y, z: frame.worldOrigin.z }
491
+ : { x: frame.worldOrigin.x, y: l.y, z: frame.worldOrigin.z };
492
+ const p = worldToSourceViewPx(at, frame);
493
+ if (p) view.gridLines.push({ px: p[0], label: String(l.label) });
494
+ }
495
+ }
496
+ if (geo && vAxis && vAxis.axis === 2) {
497
+ for (const z of geo.zs || []) {
498
+ const p = worldToSourceViewPx({ x: frame.worldOrigin.x, y: frame.worldOrigin.y, z: z.mm }, frame);
499
+ if (p) view.levels.push({ py: p[1], mm: z.mm, label: String(z.label) });
500
+ }
501
+ }
502
+ // The grid lines that stand within the span the steel covers (a long elevation's far grids are not
503
+ // this view's business), and the levels within reach of it. With no steel at all, everything.
504
+ if (box) {
505
+ const kPx = frame.mmPerPx, spanX = [box[0] - 1500 / kPx, box[2] + 1500 / kPx], spanY = [box[1] - 400 / kPx, box[3] + 400 / kPx]; // mm of reach, in this view's px
506
+ view.gridLines = view.gridLines.filter((l) => l.px >= spanX[0] && l.px <= spanX[1]);
507
+ view.levels = view.levels.filter((l) => l.py >= spanY[0] && l.py <= spanY[1]);
508
+ }
509
+ for (const l of view.gridLines) grow([l.px, box ? box[1] : 0]);
510
+ for (const l of view.levels) grow([box ? box[0] : 0, l.py]);
511
+ }
512
+ const pad = 90;
513
+ if (box) {
514
+ const w = Math.max(box[2] - box[0], 40), h = Math.max(box[3] - box[1], 40);
515
+ projection.clip = [box[0] - pad * 2, box[1] - pad, box[0] + w + pad, box[1] + h + pad];
516
+ }
517
+ link(projection, { session, kind: 'plan', viewId, sheet: plan.sheet });
518
+
519
+ let rebuildCount = 1;
520
+ let patchCount = 0;
521
+ const controller = {
522
+ model,
523
+ viewId,
524
+ sheet: plan.sheet,
525
+ /** Marks this controller as a view-only one for the editor. */
526
+ elevation: true,
527
+ plan: projection,
528
+ get rebuildCount() { return rebuildCount; },
529
+ get patchCount() { return patchCount; },
530
+ // Nothing here is edited in place, so a patch is a rebuild: cheap (an elevation holds tens of members)
531
+ // and the only way a member added to or removed from the view by a 3D edit shows up.
532
+ patchMembers() { patchCount += 1; return controller.rebuild(); },
533
+ rebuild() {
534
+ const fresh = createElevationProjection(model, viewId, { session });
535
+ for (const key of Object.keys(projection)) delete projection[key];
536
+ Object.assign(projection, fresh.plan);
537
+ link(projection, { session, kind: 'plan', viewId, sheet: plan.sheet });
538
+ rebuildCount += 1;
539
+ return projection;
540
+ },
541
+ };
542
+ return controller;
543
+ }
@@ -302,3 +302,81 @@ export function sourceRegistrationPointToWorld(point, registration, mmPerPx) {
302
302
  z: { known: o.z.known + u[2] * du + v[2] * dv },
303
303
  };
304
304
  }
305
+
306
+ /**
307
+ * Why an ELEVATION or SECTION's `sourceRegistration` cannot place steel on its sheet, or the frame that can.
308
+ *
309
+ * Returns `{ ok: true, frame }` — the origin, the two world axes and the scale, all checked finite — or
310
+ * `{ ok: false, code, message }`. It never throws and never invents a scale or an axis: a view with no stated
311
+ * registration has nowhere to put steel, and the editor says that in words instead of drawing a guess (#2780).
312
+ *
313
+ * @param {any} plan
314
+ * @returns {{ ok: true, frame: { displayOrigin: number[], worldOrigin: { x: number, y: number, z: number }, u: number[], v: number[], mmPerPx: number } }
315
+ * | { ok: false, code: string, message: string }}
316
+ */
317
+ export function sourceRegistrationFrame(plan) {
318
+ const bad = (code, message) => ({ ok: false, code, message });
319
+ const reg = plan && plan.sourceRegistration;
320
+ if (!reg || typeof reg !== 'object') {
321
+ return bad('registration-incomplete', 'This view has no stated position yet, so FloLess has nowhere to place its steel.');
322
+ }
323
+ const mmPerPx = Number(plan.mm_per_px);
324
+ if (!(mmPerPx > 0) || !Number.isFinite(mmPerPx)) {
325
+ return bad('scale-invalid', 'This view has no drawing scale, so FloLess cannot turn its drawn lengths into millimetres.');
326
+ }
327
+ const o = reg.worldOrigin;
328
+ const z0 = o && o.z && Number.isFinite(o.z.known) ? o.z.known : NaN;
329
+ const vec3 = (v) => Array.isArray(v) && v.length === 3 && v.every(Number.isFinite);
330
+ if (!finite2(reg.displayOrigin) || !o || !Number.isFinite(o.x) || !Number.isFinite(o.y) || !Number.isFinite(z0)
331
+ || !vec3(reg.worldU) || !vec3(reg.worldV)) {
332
+ return bad('registration-invalid', 'This view states a position that cannot be read (its origin or axes are missing or not numbers).');
333
+ }
334
+ const [ux, uy, uz] = reg.worldU, [vx, vy, vz] = reg.worldV;
335
+ const uu = ux * ux + uy * uy + uz * uz, vv = vx * vx + vy * vy + vz * vz, uv = ux * vx + uy * vy + uz * vz;
336
+ if (!(uu > 1e-12) || !(vv > 1e-12) || !(uu * vv - uv * uv > 1e-12)) {
337
+ return bad('registration-degenerate', 'This view’s two drawing directions point the same way, so it has no plane to place steel on.');
338
+ }
339
+ return {
340
+ ok: true,
341
+ frame: {
342
+ displayOrigin: reg.displayOrigin.slice(),
343
+ worldOrigin: { x: o.x, y: o.y, z: z0 },
344
+ u: reg.worldU.slice(),
345
+ v: reg.worldV.slice(),
346
+ mmPerPx,
347
+ },
348
+ };
349
+ }
350
+
351
+ /**
352
+ * World point → the elevation/section's display px: the inverse of `sourceRegistrationPointToWorld` for the
353
+ * part of the point that lies in the view's plane. A point off the plane (its depth) is simply not drawn, as
354
+ * in any elevation. `z` may be `{ known }` or a bare number; an unknown height returns null, because a
355
+ * height nobody stated is not a height to draw at.
356
+ *
357
+ * @param {{ x: number, y: number, z: any }} world
358
+ * @param {{ displayOrigin: number[], worldOrigin: { x: number, y: number, z: number }, u: number[], v: number[], mmPerPx: number }} frame
359
+ * @returns {number[] | null}
360
+ */
361
+ export function worldToSourceViewPx(world, frame) {
362
+ const z = world && world.z && typeof world.z === 'object' ? world.z.known : world && world.z;
363
+ if (!world || !Number.isFinite(world.x) || !Number.isFinite(world.y) || !Number.isFinite(z)) return null;
364
+ const k = sheetScaleMm(frame.mmPerPx);
365
+ const dx = world.x - frame.worldOrigin.x, dy = world.y - frame.worldOrigin.y, dz = z - frame.worldOrigin.z;
366
+ const [ux, uy, uz] = frame.u, [vx, vy, vz] = frame.v;
367
+ const uu = ux * ux + uy * uy + uz * uz, vv = vx * vx + vy * vy + vz * vz, uv = ux * vx + uy * vy + uz * vz;
368
+ const du0 = dx * ux + dy * uy + dz * uz, dv0 = dx * vx + dy * vy + dz * vz;
369
+ const det = uu * vv - uv * uv;
370
+ const du = (du0 * vv - dv0 * uv) / det, dv = (dv0 * uu - du0 * uv) / det;
371
+ return [clean(frame.displayOrigin[0] + du / k), clean(frame.displayOrigin[1] - dv / k)];
372
+ }
373
+
374
+ /** The view's px → world-space DIRECTION check: is `worldU` (or `worldV`) along a model axis? ±1 axis index, else 0. */
375
+ export function axisOf(vec, tolerance = 1e-6) {
376
+ const len = Math.hypot(vec[0], vec[1], vec[2]);
377
+ if (!(len > 0)) return null;
378
+ for (let i = 0; i < 3; i++) {
379
+ if (Math.abs(Math.abs(vec[i]) / len - 1) < tolerance) return { axis: i, sign: Math.sign(vec[i]) };
380
+ }
381
+ return null;
382
+ }
@@ -852,12 +852,17 @@
852
852
  var result = { app: item.app, workflowName: item.workflowName, outcome: 'not-moved', sentence: '' };
853
853
  try {
854
854
  var answer = await call('/api/compile', 'POST', JSON.stringify({ id: item.app, bulkReview: item.compileReview }));
855
+ // #2740: AWARE's refusal is an answer (200, ok:false), carried on as the error it explains.
856
+ if (answer && answer.ok === false && answer.code === 'workflow-compile-refused') throw Object.assign(new Error(answer.error), { body: answer });
855
857
  if (!answer || answer.ok !== true) throw new Error('Compile did not answer.');
856
858
  result.outcome = 'compiled';
857
859
  result.sentence = 'Fresh approval recorded with the installed tools. Review its compile notices before running.';
858
860
  } catch (error) {
859
861
  if (error.body && error.body.code === 'bulk-compile-review-again') {
860
862
  result.sentence = error.body.error;
863
+ } else if (error.body && error.body.code === 'workflow-compile-refused' && typeof error.body.userMessage === 'string') {
864
+ // #2740: AWARE refused this workflow and said why (often a pin the update moved past); nothing was approved.
865
+ result.sentence = error.body.userMessage;
861
866
  } else {
862
867
  // A lost reply can follow a successful compile. Check the actual lock; never replay approval.
863
868
  try {