@floless/app 0.154.0 → 0.155.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.
- package/dist/floless-server.cjs +49492 -37984
- package/dist/schemas/steel.model.v2.schema.json +19 -5
- package/dist/skills/floless-app-onboarding/SKILL.md +22 -13
- package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +12 -8
- package/dist/skills/floless-app-steel-model/SKILL.md +23 -2
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +158 -65
- package/dist/skills/floless-app-workflows/SKILL.md +23 -5
- package/dist/skills/floless-app-workflows/references/blender-exec.md +183 -0
- package/dist/skills/floless-app-workflows/references/dev-server-and-run-trace.md +27 -12
- package/dist/templates/blender-construction-sequence.flo +96 -0
- package/dist/web/agents.js +33 -13
- package/dist/web/app.css +275 -33
- package/dist/web/aware.js +745 -82
- package/dist/web/chat-question-card.js +477 -0
- package/dist/web/chat.css +177 -12
- package/dist/web/chat.js +1537 -717
- package/dist/web/commands-shell.js +424 -7
- package/dist/web/commands-steel.js +105 -4
- package/dist/web/guide.js +4 -3
- package/dist/web/index.html +96 -7
- package/dist/web/instructor.js +10 -9
- package/dist/web/left-pane.js +40 -3
- package/dist/web/media-player.js +234 -0
- package/dist/web/model-editor-contract.js +2 -0
- package/dist/web/model-editor-revit-adapter.js +1 -0
- package/dist/web/model-editor-steel-adapter.js +89 -1
- package/dist/web/model-panel-bridge.js +16 -2
- package/dist/web/model-view-query.js +590 -0
- package/dist/web/model-viewport-revit-adapter.js +15 -1
- package/dist/web/model-viewport-toolbar.js +5 -2
- package/dist/web/pages.js +592 -0
- package/dist/web/panels.js +2 -1
- package/dist/web/revit-editor.js +181 -16
- package/dist/web/run-progress.js +193 -0
- package/dist/web/run-strip.js +173 -0
- package/dist/web/steel-3d-core.js +70 -0
- package/dist/web/steel-editor.html +2751 -219
- package/dist/web/steel-frames-core.js +958 -0
- package/dist/web/steel-last-seen.js +315 -0
- package/dist/web/steel-marks-core.js +530 -0
- package/dist/web/steel-model-slim.js +95 -0
- package/dist/web/steel-model-v2-client-validation.js +14 -2
- package/dist/web/steel-model-v2-commands.js +258 -27
- package/dist/web/steel-model-v2-projection.js +78 -18
- package/dist/web/steel-read-confidence.js +11 -2
- package/dist/web/workspaces.js +416 -26
- package/package.json +3 -2
|
@@ -18,7 +18,7 @@ import { IN_TO_MM as IN_MM } from './steel-units.js';
|
|
|
18
18
|
import {
|
|
19
19
|
basisFromAxes, endpointPlacementCompensation, effectiveDepthPosition, effectiveWidthPosition, outlineFor, partFrame,
|
|
20
20
|
positionOffsetVector, reversePlacement, sectionExtents,
|
|
21
|
-
quantizeMm, requiredDepthPin,
|
|
21
|
+
quantizeMm, requiredDepthPin, isValidColumnBelowReach,
|
|
22
22
|
POSITION_BASIS_CAPABILITY_VERSION,
|
|
23
23
|
} from './steel-3d-core.js';
|
|
24
24
|
export const POSITION_BASIS_COMMAND_VERSION=POSITION_BASIS_CAPABILITY_VERSION;
|
|
@@ -280,26 +280,170 @@ function detachCopiedEngineeringReferences(member) {
|
|
|
280
280
|
return member;
|
|
281
281
|
}
|
|
282
282
|
|
|
283
|
-
|
|
283
|
+
/**
|
|
284
|
+
* What holds `ids` in place as WHOLE members: a brace they are (or one that rests on them), a member-end connection, the
|
|
285
|
+
* document's connection records, saved views, placed details. Structured (`kind`, plus what the kind needs) so a caller can
|
|
286
|
+
* say it in words; `text` is the line the thrown error has always carried.
|
|
287
|
+
*/
|
|
288
|
+
function wholeMemberRefBlockers(doc, ids, { carryEndpointRefs = false } = {}) {
|
|
284
289
|
const blockers = [];
|
|
285
290
|
for (const member of doc.members || []) {
|
|
286
291
|
if (ids.has(member.id)) {
|
|
287
|
-
if (member.brace) blockers.push(`member ${member.id} brace`);
|
|
288
|
-
if (!carryEndpointRefs && (member.ends || []).some((end) => end?.conn)) blockers.push(`member ${member.id} connection`);
|
|
289
|
-
} else if (referencesString(member.brace, ids)) blockers.push(`member ${member.id} brace`);
|
|
292
|
+
if (member.brace) blockers.push({ kind: 'brace', own: true, id: member.id, text: `member ${member.id} brace` });
|
|
293
|
+
if (!carryEndpointRefs && (member.ends || []).some((end) => end?.conn)) blockers.push({ kind: 'member-connection', id: member.id, text: `member ${member.id} connection` });
|
|
294
|
+
} else if (referencesString(member.brace, ids)) blockers.push({ kind: 'brace', own: false, id: member.id, text: `member ${member.id} brace` });
|
|
290
295
|
}
|
|
291
|
-
if (referencesString(doc.connections, ids)) blockers.push('connections');
|
|
292
|
-
if (referencesString(doc.views, ids)) blockers.push('views');
|
|
293
|
-
|
|
296
|
+
if (referencesString(doc.connections, ids)) blockers.push({ kind: 'connections', text: 'connections' });
|
|
297
|
+
if (referencesString(doc.views, ids)) blockers.push({ kind: 'views', text: 'views' });
|
|
298
|
+
const placed = (doc.detail_placements || []).filter((p) => ids.has(p?.anchorId));
|
|
299
|
+
if (placed.length) blockers.push({ kind: 'detail-placements', count: placed.length, text: 'detail placements' });
|
|
300
|
+
return blockers;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function assertNoWholeMemberRefs(doc, ids, options) {
|
|
304
|
+
const blockers = wholeMemberRefBlockers(doc, ids, options);
|
|
294
305
|
if (blockers.length) {
|
|
295
306
|
throw new V2CommandError(
|
|
296
307
|
'reference-repoint-judgement',
|
|
297
308
|
`the edit needs a detailing decision before ${[...ids].join(', ')} can be retired`,
|
|
298
|
-
blockers,
|
|
309
|
+
blockers.map((b) => b.text),
|
|
299
310
|
);
|
|
300
311
|
}
|
|
301
312
|
}
|
|
302
313
|
|
|
314
|
+
/** What is ATTACHED to `ids` and so must go first: connections (joints) on them, dimensions anchored to them, and the drawing read's evidence. */
|
|
315
|
+
function memberAttachmentBlockers(doc, ids) {
|
|
316
|
+
const blockers = [];
|
|
317
|
+
for (const joint of doc.joints || []) {
|
|
318
|
+
if (ids.has(joint.main) || (joint.secondaries || []).some((id) => ids.has(id))) {
|
|
319
|
+
blockers.push({ kind: 'joint', id: joint.id, jointKind: joint.kind, text: `joint ${joint.id}` });
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
for (const plan of doc.plans || []) {
|
|
323
|
+
for (const dim of plan.dims || []) {
|
|
324
|
+
if (ids.has(dim.aRef?.m) || ids.has(dim.bRef?.m)) blockers.push({ kind: 'dimension', id: dim.id, viewId: planViewId(plan), text: `dimension ${dim.id}` });
|
|
325
|
+
}
|
|
326
|
+
for (const obs of plan.memberObservations || []) {
|
|
327
|
+
if ((obs.binding?.memberIds || []).some((id) => ids.has(id))) blockers.push({ kind: 'observation', id: obs.id, viewId: planViewId(plan), text: `observation ${obs.id}` });
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return blockers;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* EVERYTHING that stops these members being deleted, from the one place that decides it: `deleteMembersFromDocument` throws on
|
|
335
|
+
* exactly this list (the whole-member references first, then what is attached), so a caller that asks BEFORE offering a delete
|
|
336
|
+
* and the delete itself can never disagree. `[]` means the delete is allowed. Each entry carries a `kind` (`joint`, `dimension`,
|
|
337
|
+
* `observation`, `member-connection`, `connections`, `brace`, `views`, `detail-placements`) and what that kind needs to be said
|
|
338
|
+
* in words (`jointKind`, `viewId`, `count`).
|
|
339
|
+
*/
|
|
340
|
+
export function memberDeleteBlockers(doc, ids) {
|
|
341
|
+
const selected = ids instanceof Set ? ids : new Set(ids);
|
|
342
|
+
return [...wholeMemberRefBlockers(doc, selected), ...memberAttachmentBlockers(doc, selected)];
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/** Every string leaf of `value` that is one of `ids`, added to `hits` (the one-pass counterpart of `referencesString`). */
|
|
346
|
+
function collectReferencedIds(value, ids, hits, seen = new WeakSet()) {
|
|
347
|
+
if (typeof value === 'string') { if (ids.has(value)) hits.add(value); return hits; }
|
|
348
|
+
if (!value || typeof value !== 'object' || seen.has(value)) return hits;
|
|
349
|
+
seen.add(value);
|
|
350
|
+
for (const v of Array.isArray(value) ? value : Object.values(value)) collectReferencedIds(v, ids, hits, seen);
|
|
351
|
+
return hits;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* `memberDeleteBlockers(doc, [id])` for EVERY id in `ids`, from ONE walk of the document: a Map of id -> that id's blockers (an
|
|
356
|
+
* entry for each id asked about, `[]` when nothing holds it), each list identical to the per-id answer, in the same order. The
|
|
357
|
+
* Inspector asks this for the whole selection on every refresh; asking `memberDeleteBlockers` once per selected member walked the
|
|
358
|
+
* whole model and every observation per member (about 4 s for 5,000 members), where this walks it once. Holders are indexed by
|
|
359
|
+
* member id as they are met; the per-id function stays the definition and a test holds the two equal.
|
|
360
|
+
*/
|
|
361
|
+
export function memberDeleteBlockerIndex(doc, ids) {
|
|
362
|
+
const asked = ids instanceof Set ? ids : new Set(ids);
|
|
363
|
+
/** @type {Map<string, any[]>} */
|
|
364
|
+
const index = new Map([...asked].map((id) => [id, []]));
|
|
365
|
+
const add = (id, blocker) => { index.get(id)?.push(blocker); };
|
|
366
|
+
// The whole-member references, in the order `wholeMemberRefBlockers` finds them: members (own, then who else rests on it), the
|
|
367
|
+
// document's connection records, saved views, placed details.
|
|
368
|
+
for (const member of doc.members || []) {
|
|
369
|
+
if (asked.has(member.id)) {
|
|
370
|
+
if (member.brace) add(member.id, { kind: 'brace', own: true, id: member.id, text: `member ${member.id} brace` });
|
|
371
|
+
if ((member.ends || []).some((end) => end?.conn)) add(member.id, { kind: 'member-connection', id: member.id, text: `member ${member.id} connection` });
|
|
372
|
+
}
|
|
373
|
+
for (const id of collectReferencedIds(member.brace, asked, new Set())) {
|
|
374
|
+
if (id !== member.id) add(id, { kind: 'brace', own: false, id: member.id, text: `member ${member.id} brace` });
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
for (const id of collectReferencedIds(doc.connections, asked, new Set())) add(id, { kind: 'connections', text: 'connections' });
|
|
378
|
+
for (const id of collectReferencedIds(doc.views, asked, new Set())) add(id, { kind: 'views', text: 'views' });
|
|
379
|
+
const placed = new Map();
|
|
380
|
+
for (const placement of doc.detail_placements || []) if (asked.has(placement?.anchorId)) placed.set(placement.anchorId, (placed.get(placement.anchorId) || 0) + 1);
|
|
381
|
+
for (const [id, count] of placed) add(id, { kind: 'detail-placements', count, text: 'detail placements' });
|
|
382
|
+
// What is attached: connections (joints), then per sheet its dimensions and the drawing read's observations.
|
|
383
|
+
const named = (...refs) => new Set(refs.flat().filter((id) => asked.has(id)));
|
|
384
|
+
for (const joint of doc.joints || []) {
|
|
385
|
+
for (const id of named(joint.main, joint.secondaries || [])) add(id, { kind: 'joint', id: joint.id, jointKind: joint.kind, text: `joint ${joint.id}` });
|
|
386
|
+
}
|
|
387
|
+
for (const plan of doc.plans || []) {
|
|
388
|
+
const viewId = planViewId(plan);
|
|
389
|
+
for (const dim of plan.dims || []) {
|
|
390
|
+
for (const id of named(dim.aRef?.m, dim.bRef?.m)) add(id, { kind: 'dimension', id: dim.id, viewId, text: `dimension ${dim.id}` });
|
|
391
|
+
}
|
|
392
|
+
for (const obs of plan.memberObservations || []) {
|
|
393
|
+
for (const id of named(obs.binding?.memberIds || [])) add(id, { kind: 'observation', id: obs.id, viewId, text: `observation ${obs.id}` });
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
return index;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* What would STILL stop these members being deleted once the drawing read's links to them are released (Delete anyway,
|
|
401
|
+
* the editor's explicit person action): every blocker except an `observation`. `[]` means the read is the ONLY thing
|
|
402
|
+
* holding them, which is exactly when Delete anyway is offered and exactly when `deleteMembersAnyway` proceeds. The
|
|
403
|
+
* same rule the delete command applies, so the offer and the act cannot disagree.
|
|
404
|
+
*/
|
|
405
|
+
export function memberDeleteBlockersBesidesRead(doc, ids) {
|
|
406
|
+
return blockersBesidesRead(memberDeleteBlockers(doc, ids));
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/** The blockers that are not the drawing read's own links: what Delete anyway cannot release. */
|
|
410
|
+
export function blockersBesidesRead(blockers) {
|
|
411
|
+
return blockers.filter((b) => b.kind !== 'observation');
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/** True when `blockers` (one member's) are the drawing read's links and nothing else: Delete anyway is offered exactly then. */
|
|
415
|
+
export function heldOnlyByRead(blockers) {
|
|
416
|
+
return blockers.length > 0 && blockersBesidesRead(blockers).length === 0;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Release `ids` from every observation binding that names them, and record that Delete anyway did (`binding.released`).
|
|
421
|
+
*
|
|
422
|
+
* The SAME rule a re-read's removal follows (`retireEvidenceFor`, server/steel-model-revision.ts), so a deleted
|
|
423
|
+
* member's evidence ends up identical however the member went: the id leaves `memberIds` and its `endpointLineage`
|
|
424
|
+
* rows (`endpoint-lineage-coverage` demands exact coverage), an ACTIVE binding left with no member becomes `archived`
|
|
425
|
+
* (`observation-cardinality`), a `superseded` or `archived` one keeps its status. The observation's `evidence` is never
|
|
426
|
+
* touched, nor are `verified` and `inherited`. What is new is the record: one `{memberId, via: 'delete-anyway'}` per released
|
|
427
|
+
* member, because a status alone cannot say who decided.
|
|
428
|
+
*/
|
|
429
|
+
function releaseObservationBindings(doc, ids) {
|
|
430
|
+
for (const plan of doc.plans || []) {
|
|
431
|
+
for (const obs of plan.memberObservations || []) {
|
|
432
|
+
const binding = obs?.binding;
|
|
433
|
+
if (!binding) continue;
|
|
434
|
+
const named = (binding.memberIds || []).filter((id) => ids.has(id));
|
|
435
|
+
if (!named.length) continue;
|
|
436
|
+
binding.memberIds = binding.memberIds.filter((id) => !ids.has(id));
|
|
437
|
+
if (Array.isArray(binding.endpointLineage)) binding.endpointLineage = binding.endpointLineage.filter((row) => !ids.has(row?.memberId));
|
|
438
|
+
const had = new Set((binding.released || []).map((row) => row?.memberId));
|
|
439
|
+
const released = [...(binding.released || [])];
|
|
440
|
+
for (const memberId of named) if (!had.has(memberId)) released.push({ memberId, via: 'delete-anyway' });
|
|
441
|
+
binding.released = released;
|
|
442
|
+
if (binding.status === 'active' && binding.memberIds.length === 0) binding.status = 'archived';
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
303
447
|
function point3(memberPoint, label) {
|
|
304
448
|
return [Number(memberPoint?.x), Number(memberPoint?.y), known(memberPoint?.z, label)];
|
|
305
449
|
}
|
|
@@ -631,22 +775,14 @@ function mergeMemberGroup(doc, sheet, memberIds, mergedPx, mintId, resolveSectio
|
|
|
631
775
|
return merged.id;
|
|
632
776
|
}
|
|
633
777
|
|
|
634
|
-
function deleteMembersFromDocument(doc, ids) {
|
|
778
|
+
function deleteMembersFromDocument(doc, ids, { releaseReadLinks = false } = {}) {
|
|
635
779
|
const selected = new Set(ids);
|
|
636
|
-
const blockers = [];
|
|
637
|
-
for (const joint of doc.joints || []) {
|
|
638
|
-
if (selected.has(joint.main) || (joint.secondaries || []).some((id) => selected.has(id))) blockers.push(`joint ${joint.id}`);
|
|
639
|
-
}
|
|
640
|
-
for (const plan of doc.plans || []) {
|
|
641
|
-
for (const dim of plan.dims || []) {
|
|
642
|
-
if (selected.has(dim.aRef?.m) || selected.has(dim.bRef?.m)) blockers.push(`dimension ${dim.id}`);
|
|
643
|
-
}
|
|
644
|
-
for (const obs of plan.memberObservations || []) {
|
|
645
|
-
if ((obs.binding?.memberIds || []).some((id) => selected.has(id))) blockers.push(`observation ${obs.id}`);
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
780
|
assertNoWholeMemberRefs(doc, selected);
|
|
649
|
-
|
|
781
|
+
// Delete anyway (`releaseReadLinks`) steps over the drawing read's links and NOTHING else: a joint, a dimension, a placed
|
|
782
|
+
// detail or a saved view that holds a member still refuses it, and then nothing has been released (the draft is dropped).
|
|
783
|
+
const blockers = memberAttachmentBlockers(doc, selected).filter((b) => !releaseReadLinks || b.kind !== 'observation');
|
|
784
|
+
if (blockers.length) throw new V2CommandError('delete-referenced', 'referenced members cannot be deleted', blockers.map((b) => b.text));
|
|
785
|
+
if (releaseReadLinks) releaseObservationBindings(doc, selected);
|
|
650
786
|
doc.members = doc.members.filter((m) => !selected.has(m.id));
|
|
651
787
|
rewritePropLabelPins(doc, selected, []);
|
|
652
788
|
for (const plan of doc.plans || []) plan.memberRefs = (plan.memberRefs || []).filter((id) => !selected.has(id));
|
|
@@ -671,6 +807,41 @@ export function adoptWorkPointDecisions(members, authority) {
|
|
|
671
807
|
}
|
|
672
808
|
}
|
|
673
809
|
|
|
810
|
+
/*
|
|
811
|
+
* ANNOTATIONS IN AN UNDO SNAPSHOT (#2211). A mark is added to a sheet that may not have the key at all, and
|
|
812
|
+
* undoing that add must put the ABSENCE back, not leave a new empty-or-full array behind. So a COMPLETE
|
|
813
|
+
* snapshot (the one `edit()` takes) records each annotation key explicitly as `{has:true, v}` or
|
|
814
|
+
* `{has:false}`, and restore deletes a key the snapshot recorded as absent. A PARTIAL snapshot (the member-end
|
|
815
|
+
* one) never carries a `marks`/`rootMarks` entry at all, and restore then leaves these keys alone — an
|
|
816
|
+
* unconditional restore would wipe every callout on every member-end command. Restore-by-presence, the same
|
|
817
|
+
* rule `frame` and `datum_ref` follow below.
|
|
818
|
+
*
|
|
819
|
+
* The two lists are the ONLY place that names the keys: a later unit that makes another annotation undoable
|
|
820
|
+
* (the moment-frame schedule, a sheet's cut level) extends them here and nowhere else.
|
|
821
|
+
*
|
|
822
|
+
* `elevation_mm` (#2214) is the sheet's floor level, and it belongs here for the same reason a callout does:
|
|
823
|
+
* a sheet that never had one gains it when a person types a level, and Undo must take the KEY away again, not
|
|
824
|
+
* leave `elevation_mm: 0` or `null` behind (either would read as "this sheet is at the datum" and change which
|
|
825
|
+
* columns every sheet draws).
|
|
826
|
+
*/
|
|
827
|
+
export const ANNOTATION_PLAN_KEYS = Object.freeze(['callouts', 'details', 'tos_callouts', 'elevation_mm']);
|
|
828
|
+
export const ANNOTATION_ROOT_KEYS = Object.freeze(['detail_bubbles', 'moment_frames', 'column_below_reach_mm']);
|
|
829
|
+
const capture = (holder, keys) => Object.fromEntries(keys.map((key) => [key,
|
|
830
|
+
Object.hasOwn(holder, key) && holder[key] !== undefined ? { has: true, v: clone(holder[key]) } : { has: false }]));
|
|
831
|
+
/** What `snapshot()` records for one sheet row: every annotation key, with its absence made explicit. */
|
|
832
|
+
export const captureAnnotations = (plan) => capture(plan || {}, ANNOTATION_PLAN_KEYS);
|
|
833
|
+
/** The same for the document root. */
|
|
834
|
+
export const captureRootAnnotations = (doc) => capture(doc || {}, ANNOTATION_ROOT_KEYS);
|
|
835
|
+
const restoreCaptured = (holder, saved, keys) => {
|
|
836
|
+
if (!saved || typeof saved !== 'object') return;
|
|
837
|
+
for (const key of keys) {
|
|
838
|
+
const entry = saved[key];
|
|
839
|
+
if (!entry || typeof entry !== 'object') continue; // this key was not captured: leave it as it is
|
|
840
|
+
if (entry.has === true) holder[key] = clone(entry.v);
|
|
841
|
+
else if (entry.has === false) delete holder[key];
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
|
|
674
845
|
/** @param {any} model @param {{validate?: (doc: any) => any, mintId?: () => string, afterCommit?: (effect: any) => void, resolveSection?: (member:any) => any}} options */
|
|
675
846
|
export function createV2CommandSession(model, options = {}) {
|
|
676
847
|
const {
|
|
@@ -730,7 +901,10 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
730
901
|
if (Object.hasOwn(row, key) && row[key] !== undefined) plan[key] = clone(row[key]);
|
|
731
902
|
else delete plan[key];
|
|
732
903
|
}
|
|
904
|
+
// Annotations (#2211): by PRESENCE, and only when this snapshot captured them at all.
|
|
905
|
+
if (Object.hasOwn(row, 'marks')) restoreCaptured(plan, row.marks, ANNOTATION_PLAN_KEYS);
|
|
733
906
|
}
|
|
907
|
+
if (Object.hasOwn(saved, 'rootMarks')) restoreCaptured(draft, saved.rootMarks, ANNOTATION_ROOT_KEYS);
|
|
734
908
|
draft.joints = clone(saved.joints || []);
|
|
735
909
|
if (Object.hasOwn(saved, 'connections')) draft.connections = clone(saved.connections || []);
|
|
736
910
|
if (Object.hasOwn(saved, 'details')) draft.detail_placements = clone(saved.details || []);
|
|
@@ -1390,6 +1564,11 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
1390
1564
|
});
|
|
1391
1565
|
},
|
|
1392
1566
|
|
|
1567
|
+
/** What stops these members being deleted from the model right now (see `memberDeleteBlockers`); `[]` = the delete is allowed. */
|
|
1568
|
+
deleteBlockers(ids) {
|
|
1569
|
+
return memberDeleteBlockers(model, ids);
|
|
1570
|
+
},
|
|
1571
|
+
|
|
1393
1572
|
deleteMembers(ids) {
|
|
1394
1573
|
return session.transact('delete members', (doc) => {
|
|
1395
1574
|
deleteMembersFromDocument(doc, ids);
|
|
@@ -1397,23 +1576,75 @@ export function createV2CommandSession(model, options = {}) {
|
|
|
1397
1576
|
});
|
|
1398
1577
|
},
|
|
1399
1578
|
|
|
1579
|
+
/** What would still hold these members after the read's links are released; `[]` = Delete anyway will delete them. */
|
|
1580
|
+
deleteAnywayBlockers(ids) {
|
|
1581
|
+
return memberDeleteBlockersBesidesRead(model, ids);
|
|
1582
|
+
},
|
|
1583
|
+
|
|
1584
|
+
/**
|
|
1585
|
+
* `deleteBlockers` for a whole selection in ONE walk of the model (see `memberDeleteBlockerIndex`): a Map of id -> that
|
|
1586
|
+
* member's blockers. The Inspector builds it once per refresh and reads every per-member question from it.
|
|
1587
|
+
*/
|
|
1588
|
+
deleteBlockerIndex(ids) {
|
|
1589
|
+
return memberDeleteBlockerIndex(model, ids);
|
|
1590
|
+
},
|
|
1591
|
+
|
|
1592
|
+
/**
|
|
1593
|
+
* DELETE ANYWAY: delete members the drawing read names, drop the read's link to each and record that Delete anyway did
|
|
1594
|
+
* (`binding.released`), in ONE undoable step. Reserved for the editor's explicit person action: `deleteMembers` and
|
|
1595
|
+
* `deleteSelection` (the Delete key) keep refusing a member the read names. Anything ELSE holding a member still refuses.
|
|
1596
|
+
*/
|
|
1597
|
+
deleteMembersAnyway(ids) {
|
|
1598
|
+
return session.transact('delete members and release their read links', (doc) => {
|
|
1599
|
+
deleteMembersFromDocument(doc, ids, { releaseReadLinks: true });
|
|
1600
|
+
return { structural: true };
|
|
1601
|
+
});
|
|
1602
|
+
},
|
|
1603
|
+
|
|
1604
|
+
/**
|
|
1605
|
+
* The project's "how far under a floor a column can end and still be drawn" setting (`column_below_reach_mm`).
|
|
1606
|
+
* `null` puts the default back by taking the KEY away (a stored default would freeze today's number into the file).
|
|
1607
|
+
* A value outside what a project may hold is refused here with a sentence the editor shows; the model is untouched.
|
|
1608
|
+
*/
|
|
1609
|
+
setColumnBelowReach(mm) {
|
|
1610
|
+
return session.transact('set column below reach', (doc) => {
|
|
1611
|
+
if (mm === null) delete doc.column_below_reach_mm;
|
|
1612
|
+
else {
|
|
1613
|
+
if (!isValidColumnBelowReach(mm)) {
|
|
1614
|
+
throw new V2CommandError('column-below-reach-invalid', 'a column below reach must be a number of millimetres from 0 up to 100 ft', [String(mm)]);
|
|
1615
|
+
}
|
|
1616
|
+
doc.column_below_reach_mm = mm;
|
|
1617
|
+
}
|
|
1618
|
+
return { structural: true };
|
|
1619
|
+
});
|
|
1620
|
+
},
|
|
1621
|
+
|
|
1400
1622
|
/**
|
|
1401
1623
|
* @param {string} viewId
|
|
1402
1624
|
* @param {{memberIds?: string[], dimIds?: string[], jointIds?: string[], gridLineIds?: string[]}} selection
|
|
1403
1625
|
*/
|
|
1404
1626
|
deleteSelection(viewId, { memberIds = [], dimIds = [], jointIds = [], gridLineIds = [] } = {}) {
|
|
1405
1627
|
return session.transact('delete selection', (doc) => {
|
|
1406
|
-
|
|
1628
|
+
// `viewId` is null from the 3D view, which has NO sheet: a column is not "derived on this sheet" there,
|
|
1629
|
+
// so every member is an ordinary geometric delete and a dimension is dropped from whichever sheet holds it.
|
|
1630
|
+
// Judging 3D's Delete by the last 2D sheet that happened to be open was a wrong answer that looked like a rule.
|
|
1631
|
+
const plan = viewId == null ? null : planByViewId(doc, viewId);
|
|
1407
1632
|
const dims = new Set(dimIds), joints = new Set(jointIds), lines = new Set(gridLineIds);
|
|
1408
|
-
if (dims.size)
|
|
1633
|
+
if (dims.size) {
|
|
1634
|
+
for (const row of plan ? [plan] : (doc.plans || [])) if (Array.isArray(row.dims)) row.dims = row.dims.filter((dim) => !dims.has(dim.id));
|
|
1635
|
+
}
|
|
1409
1636
|
if (joints.size) doc.joints = (doc.joints || []).filter((joint) => !joints.has(joint.id));
|
|
1410
1637
|
if (lines.size && doc.grid?.lines) doc.grid.lines = doc.grid.lines.filter((line) => !lines.has(String(line.id)));
|
|
1411
1638
|
const geometric = [];
|
|
1412
1639
|
const presentationOnly = [];
|
|
1413
1640
|
for (const id of new Set(memberIds)) {
|
|
1414
1641
|
const member = memberById(doc, id);
|
|
1415
|
-
const presence = memberPresence(doc, plan, member);
|
|
1416
|
-
|
|
1642
|
+
const presence = plan ? memberPresence(doc, plan, member) : { observed: false, explicit: false, crossing: false, below: false, visible: false };
|
|
1643
|
+
// A column DERIVED onto this sheet by its height — the cut passes through it, or it ends just under
|
|
1644
|
+
// the cut and is drawn as "column below" (#2214) — is on this sheet only because of where it
|
|
1645
|
+
// stands. Deleting it here would remove a real column from the whole model for the sake of one
|
|
1646
|
+
// sheet's picture, so it is presentation-only until the read binds it or a person places it.
|
|
1647
|
+
if ((presence.crossing || presence.below) && !presence.observed && !presence.explicit) presentationOnly.push(id);
|
|
1417
1648
|
else geometric.push(id);
|
|
1418
1649
|
}
|
|
1419
1650
|
if (geometric.length) deleteMembersFromDocument(doc, geometric);
|
|
@@ -10,7 +10,7 @@ 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 {
|
|
13
|
+
import { columnBelowReachOf, columnCutRelation,POSITION_BASIS_CAPABILITY_VERSION } from './steel-3d-core.js';
|
|
14
14
|
export const POSITION_BASIS_PROJECTION_VERSION=POSITION_BASIS_CAPABILITY_VERSION;
|
|
15
15
|
import { worldToSheetPx, planTransform, PlanTransformError } from './steel-plan-transform.js';
|
|
16
16
|
|
|
@@ -41,14 +41,36 @@ function observationIds(plan) {
|
|
|
41
41
|
return ids;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
/**
|
|
45
|
-
export function
|
|
46
|
-
const
|
|
47
|
-
const
|
|
44
|
+
/** Fresh lookup data for one read/Inspector refresh. Never retain it across model edits. */
|
|
45
|
+
export function createMemberPresenceIndex(model) {
|
|
46
|
+
const members = new Map();
|
|
47
|
+
for (const member of model.members || []) if (member && !members.has(member.id)) members.set(member.id, member);
|
|
48
|
+
const plans = new Map();
|
|
49
|
+
for (const plan of model.plans || []) plans.set(plan, { observed: observationIds(plan), explicit: new Set(plan.memberRefs || []) });
|
|
50
|
+
return { members, plans };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The three-source membersOnSheet rule, kept equivalent to the server projection (`membersOnSheet`).
|
|
55
|
+
*
|
|
56
|
+
* A column is DERIVED onto a plan by its height alone in two cases, both decided by `columnCutRelation`
|
|
57
|
+
* (the one function the server twin asks too): the cut passes through it (`crossing`), or it ends just
|
|
58
|
+
* under the cut — within the project's reach (`columnBelowReachOf`: its saved `column_below_reach_mm`, else the default
|
|
59
|
+
* `COLUMN_BELOW_REACH_MM`) — and is drawn there as "column below" (`below`, #2214).
|
|
60
|
+
* Neither applies to a beam or brace, to a member with an unknown elevation, or to a plan with no cut
|
|
61
|
+
* level: those appear by observation or `memberRefs` or not at all.
|
|
62
|
+
*/
|
|
63
|
+
export function memberPresence(model, plan, member, index = null) {
|
|
64
|
+
const lookup = index?.plans.get(plan);
|
|
65
|
+
const observed = (lookup?.observed || observationIds(plan)).has(member.id);
|
|
66
|
+
const explicit = lookup ? lookup.explicit.has(member.id) : (plan.memberRefs || []).includes(member.id);
|
|
48
67
|
const cutMm = Number.isFinite(plan.elevation_mm) ? plan.elevation_mm : null;
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
68
|
+
const relation = cutMm !== null && member.role === 'column'
|
|
69
|
+
? columnCutRelation(member.from?.z, member.to?.z, cutMm, columnBelowReachOf(model))
|
|
70
|
+
: 'unknown';
|
|
71
|
+
const crossing = relation === 'crossing';
|
|
72
|
+
const below = relation === 'below';
|
|
73
|
+
return { observed, explicit, crossing, below, visible: observed || explicit || crossing || below };
|
|
52
74
|
}
|
|
53
75
|
|
|
54
76
|
/**
|
|
@@ -60,10 +82,10 @@ export function memberPresence(model, plan, member) {
|
|
|
60
82
|
* now separate functions, because the callers genuinely want different things: identity here, and a
|
|
61
83
|
* human-facing page list from `memberPhysicalSheets`.
|
|
62
84
|
*/
|
|
63
|
-
export function memberViewIds(model, memberId) {
|
|
64
|
-
const member = (model.members || []).find((m) => m?.id === memberId);
|
|
85
|
+
export function memberViewIds(model, memberId, index = null) {
|
|
86
|
+
const member = index ? index.members.get(memberId) : (model.members || []).find((m) => m?.id === memberId);
|
|
65
87
|
if (!member) return [];
|
|
66
|
-
return (model.plans || []).filter((p) => memberPresence(model, p, member).visible).map(planViewId);
|
|
88
|
+
return (model.plans || []).filter((p) => memberPresence(model, p, member, index).visible).map(planViewId);
|
|
67
89
|
}
|
|
68
90
|
|
|
69
91
|
/**
|
|
@@ -78,11 +100,11 @@ export function memberViewIds(model, memberId) {
|
|
|
78
100
|
* A row with NO `viewKind` is not a plan here either: it is never reclassified as one (see the MUST-MATCH
|
|
79
101
|
* in steel-editor-v2-must-match.test.ts), and the editor refuses such a document at boot.
|
|
80
102
|
*/
|
|
81
|
-
export function memberPlanViewIds(model, memberId) {
|
|
82
|
-
const member = (model.members || []).find((m) => m?.id === memberId);
|
|
103
|
+
export function memberPlanViewIds(model, memberId, index = null) {
|
|
104
|
+
const member = index ? index.members.get(memberId) : (model.members || []).find((m) => m?.id === memberId);
|
|
83
105
|
if (!member) return [];
|
|
84
106
|
return (model.plans || [])
|
|
85
|
-
.filter((p) => p && p.viewKind === 'plan' && memberPresence(model, p, member).visible)
|
|
107
|
+
.filter((p) => p && p.viewKind === 'plan' && memberPresence(model, p, member, index).visible)
|
|
86
108
|
.map(planViewId);
|
|
87
109
|
}
|
|
88
110
|
|
|
@@ -92,11 +114,11 @@ export function memberPlanViewIds(model, memberId) {
|
|
|
92
114
|
* Never an identity: two views on one page yield one page name, which is exactly right for "also shown
|
|
93
115
|
* on S5.1" and exactly wrong for looking a row up.
|
|
94
116
|
*/
|
|
95
|
-
export function memberPhysicalSheets(model, memberId) {
|
|
96
|
-
const member = (model.members || []).find((m) => m?.id === memberId);
|
|
117
|
+
export function memberPhysicalSheets(model, memberId, index = null) {
|
|
118
|
+
const member = index ? index.members.get(memberId) : (model.members || []).find((m) => m?.id === memberId);
|
|
97
119
|
if (!member) return [];
|
|
98
120
|
return [...new Set((model.plans || [])
|
|
99
|
-
.filter((p) => memberPresence(model, p, member).visible)
|
|
121
|
+
.filter((p) => memberPresence(model, p, member, index).visible)
|
|
100
122
|
.map((p) => (p && typeof p.sheet === 'string' ? p.sheet : ''))
|
|
101
123
|
.filter(Boolean))];
|
|
102
124
|
}
|
|
@@ -228,6 +250,14 @@ export function projectMember(member, plan, session = null) {
|
|
|
228
250
|
// properties were extracted (meta keys, then wp, then ends, then col).
|
|
229
251
|
const { ends, col, ...meta } = memberProperties(member);
|
|
230
252
|
const projected = { ...meta, wp: [a, b], ends, col };
|
|
253
|
+
/* A column whose top is under this plan's cut is drawn dashed and lighter as "column below" (#2214).
|
|
254
|
+
Decided HERE, from the member and the plan's own cut, and not handed down by whoever built the list: the
|
|
255
|
+
`patchMembers` path re-projects a row without asking presence at all, so a flag that came from the caller
|
|
256
|
+
would be lost on the first drag. Set only when true, so every other row keeps exactly the shape it had. */
|
|
257
|
+
if (member.role === 'column') {
|
|
258
|
+
const relation = columnCutRelation(member.from?.z, member.to?.z, plan.elevation_mm);
|
|
259
|
+
if (relation === 'below' || relation === 'far-below') projected.belowCut = true;
|
|
260
|
+
}
|
|
231
261
|
// `viewId` is the identity every command resolves its row by; `sheet` rides along for display only
|
|
232
262
|
// and must never be used as a lookup key (#938).
|
|
233
263
|
const base = { session, kind: 'member', memberId: member.id, viewId: planViewId(plan), sheet: plan.sheet };
|
|
@@ -292,7 +322,10 @@ export function createV2Projection(model, viewId, options = {}) {
|
|
|
292
322
|
}
|
|
293
323
|
if (refusal) projection.registrationRefusal = refusal;
|
|
294
324
|
projection.grid = refusal ? null : projectGrid(model.grid || null, projection);
|
|
295
|
-
const visible = refusal ? [] : (
|
|
325
|
+
const visible = refusal ? [] : (() => {
|
|
326
|
+
const index = createMemberPresenceIndex(model);
|
|
327
|
+
return (model.members || []).filter((m) => memberPresence(model, plan, m, index).visible);
|
|
328
|
+
})();
|
|
296
329
|
projection.members = visible.map((m) => projectMember(m, projection, session));
|
|
297
330
|
// Dimensions go with them. A `dim` is anchored to a member point or a grid axis (`aRef`/`bRef`), so on
|
|
298
331
|
// a refused sheet it measures between two things that are no longer there — and it draws in raw sheet
|
|
@@ -322,6 +355,33 @@ export function createV2Projection(model, viewId, options = {}) {
|
|
|
322
355
|
patchMembers(ids) {
|
|
323
356
|
const wanted = ids instanceof Set ? ids : new Set(ids || []);
|
|
324
357
|
const canonical = new Map((model.members || []).map((m) => [m.id, m]));
|
|
358
|
+
/*
|
|
359
|
+
* PRESENCE FIRST (#2214). A patch re-projects the rows this sheet ALREADY draws, and that is only right
|
|
360
|
+
* while an edit cannot change which members the sheet draws. Editing a column's Top or Bottom can: a
|
|
361
|
+
* height is the only thing that puts a column on a sheet by itself, so lowering a column out of the
|
|
362
|
+
* reach leaves a row drawn that the model no longer shows (and Delete, which judges by the model, then
|
|
363
|
+
* removes it from EVERY sheet), and raising a far-away column to the cut leaves it undrawn. When a
|
|
364
|
+
* patched member is drawn and no longer present, or present and not drawn, the list itself is stale: rebuild.
|
|
365
|
+
* A drag that changes nothing about presence keeps the cheap path (the boundary test counts rebuilds).
|
|
366
|
+
*/
|
|
367
|
+
if (!projection.registrationRefusal) {
|
|
368
|
+
// THE CURRENT ROW, looked up on every call. The `plan` this controller closed over is the row as it was when the
|
|
369
|
+
// projection was built, and a transaction replaces `model.plans`: after a floor-level change that row still states
|
|
370
|
+
// the OLD cut, so presence judged against it is wrong in both directions (a column stays drawn that the model no
|
|
371
|
+
// longer shows, and an edit that changes nothing about presence rebuilds every time).
|
|
372
|
+
const current = (model.plans || []).find((p) => planViewId(p) === viewId) || plan;
|
|
373
|
+
const index = createMemberPresenceIndex(model);
|
|
374
|
+
const drawn = new Set(projection.members.map((row) => row?.id));
|
|
375
|
+
for (const id of wanted) {
|
|
376
|
+
const member = canonical.get(id);
|
|
377
|
+
const shown = !!member && memberPresence(model, current, member, index).visible;
|
|
378
|
+
if (shown !== drawn.has(id)) {
|
|
379
|
+
controller.rebuild();
|
|
380
|
+
patchCount += wanted.size;
|
|
381
|
+
return projection;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
325
385
|
for (let i = 0; i < projection.members.length; i += 1) {
|
|
326
386
|
const id = projection.members[i]?.id;
|
|
327
387
|
if (!wanted.has(id)) continue;
|
|
@@ -111,7 +111,7 @@ const validCheckedPage = (value) => isObject(value) && Object.keys(value).length
|
|
|
111
111
|
const HASH_PATTERN = /^sha256:[0-9a-f]{64}$/;
|
|
112
112
|
const MEMBER_OBSERVATION_KEYS = new Set(['id', 'evidence', 'binding']);
|
|
113
113
|
const OBSERVATION_EVIDENCE_KEYS = new Set(['source', 'local', 'provenance', 'observed', 'supersedes']);
|
|
114
|
-
const OBSERVATION_BINDING_KEYS = new Set(['memberIds', 'status', 'verified', 'inherited', 'endpointLineage']);
|
|
114
|
+
const OBSERVATION_BINDING_KEYS = new Set(['memberIds', 'status', 'verified', 'inherited', 'endpointLineage', 'released']);
|
|
115
115
|
const OBSERVED_KEYS = new Set(['role', 'profile', 'mark', 'memberType', 'material', 'fromZ', 'toZ']);
|
|
116
116
|
const UNKNOWN_ELEVATION_KEYS = new Set(['unknown', 'rfiRef', 'why', 'checked']);
|
|
117
117
|
const PROVISIONAL_MEMBER_KEYS = new Set(['id', 'profile', 'provenance', 'material', 'role', 'memberType', 'geometry']);
|
|
@@ -135,13 +135,18 @@ const validEndpointLineageRow = (value) => isObject(value) && Object.keys(value)
|
|
|
135
135
|
&& (value.observationEnd === 0 || value.observationEnd === 1)
|
|
136
136
|
&& nonEmptyString(value.memberId) && (value.memberEnd === 0 || value.memberEnd === 1)
|
|
137
137
|
&& typeof value.lineageId === 'string' && HASH_PATTERN.test(value.lineageId);
|
|
138
|
+
// The editor's record that a member was deleted while this evidence named it (Delete anyway): {memberId, via:'delete-anyway'}, nothing else.
|
|
139
|
+
const validReleasedRow = (value) => isObject(value) && Object.keys(value).length === 2
|
|
140
|
+
&& nonEmptyString(value.memberId) && value.via === 'delete-anyway';
|
|
138
141
|
const validObservationBinding = (value) => isObject(value) && hasOnlyKeys(value, OBSERVATION_BINDING_KEYS)
|
|
139
142
|
&& Array.isArray(value.memberIds) && value.memberIds.every(nonEmptyString)
|
|
140
143
|
&& (value.status === 'active' || value.status === 'superseded' || value.status === 'archived')
|
|
141
144
|
&& (!hasOwn(value, 'verified') || typeof value.verified === 'boolean')
|
|
142
145
|
&& (!hasOwn(value, 'inherited') || typeof value.inherited === 'boolean')
|
|
143
146
|
&& (!hasOwn(value, 'endpointLineage') || (Array.isArray(value.endpointLineage)
|
|
144
|
-
&& value.endpointLineage.length <= 32 && value.endpointLineage.every(validEndpointLineageRow)))
|
|
147
|
+
&& value.endpointLineage.length <= 32 && value.endpointLineage.every(validEndpointLineageRow)))
|
|
148
|
+
&& (!hasOwn(value, 'released') || (Array.isArray(value.released)
|
|
149
|
+
&& value.released.every(validReleasedRow)));
|
|
145
150
|
const validObservationSource = (value) => isObject(value) && Object.keys(value).length === 3
|
|
146
151
|
&& nonEmptyString(value.sourceHash) && nonEmptyString(value.sheet) && nonEmptyString(value.elementId);
|
|
147
152
|
const validObservationLocal = (value) => isObject(value) && Object.keys(value).length === 2
|
|
@@ -176,6 +181,10 @@ const validObservationReferences = (observation, entityCount, owningSheet) => {
|
|
|
176
181
|
if (boundMembers.size !== memberIds.length || memberIds.some((id) => entityCount(id) !== 1)) return false;
|
|
177
182
|
if (observation.binding.status === 'active' && memberIds.length === 0) return false;
|
|
178
183
|
if (observation.binding.status === 'archived' && memberIds.length > 0) return false;
|
|
184
|
+
// A release is a record that a person dropped the link to a member that is GONE: it cannot sit beside a binding that
|
|
185
|
+
// still names that member, and a member is released once (the server's `observation-released-*` rules).
|
|
186
|
+
const releasedIds = (observation.binding.released || []).map((row) => row.memberId);
|
|
187
|
+
if (new Set(releasedIds).size !== releasedIds.length || releasedIds.some((id) => boundMembers.has(id))) return false;
|
|
179
188
|
const lineage = observation.binding.endpointLineage;
|
|
180
189
|
if (!lineage?.length) return true;
|
|
181
190
|
const lineageMembers = new Set();
|