@floless/app 0.155.1 → 0.156.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/cli-actions.mjs +376 -0
- package/dist/floless-server.cjs +101615 -87681
- package/dist/skills/floless-app-actions/SKILL.md +137 -0
- package/dist/skills/floless-app-approval/SKILL.md +8 -5
- package/dist/skills/floless-app-bridge/SKILL.md +12 -9
- package/dist/skills/floless-app-knowledge/SKILL.md +30 -13
- package/dist/skills/floless-app-new-workflow/SKILL.md +4 -4
- package/dist/skills/floless-app-onboarding/SKILL.md +1 -1
- package/dist/skills/floless-app-onboarding/references/aware-runtime.md +4 -4
- package/dist/skills/floless-app-queue/SKILL.md +10 -6
- package/dist/skills/floless-app-report-issue/SKILL.md +13 -10
- package/dist/skills/floless-app-rfi/SKILL.md +59 -68
- package/dist/skills/floless-app-routines/SKILL.md +19 -14
- package/dist/skills/floless-app-routines/references/routines-api.md +8 -2
- package/dist/skills/floless-app-workflows/SKILL.md +5 -4
- package/dist/web/agent-steps.js +933 -0
- package/dist/web/agents.js +5 -0
- package/dist/web/app.css +210 -5
- package/dist/web/app.js +1 -0
- package/dist/web/aware.js +584 -44
- package/dist/web/chat.css +9 -0
- package/dist/web/chat.js +195 -13
- package/dist/web/commands-shell.js +299 -1
- package/dist/web/commands-tekla-parser.js +7 -0
- package/dist/web/index.html +52 -1
- package/dist/web/instructor.js +5 -3
- package/dist/web/leave-guard.js +4 -2
- package/dist/web/left-pane.js +145 -42
- package/dist/web/model-editor.css +10 -0
- package/dist/web/model-group-navigator.js +331 -0
- package/dist/web/model-panel-bridge.js +63 -5
- package/dist/web/model-pointer-dock.js +55 -5
- package/dist/web/model-revit-module.js +15 -0
- package/dist/web/model-selection-tools.js +53 -17
- package/dist/web/model-tekla-selection.js +75 -2
- package/dist/web/model-viewport-revit-adapter.js +17 -10
- package/dist/web/pages.js +27 -3
- package/dist/web/panels.js +3 -3
- package/dist/web/project-reconciliation.js +357 -0
- package/dist/web/revit-editor.js +464 -76
- package/dist/web/steel-3d-view.js +1 -0
- package/dist/web/terminal-requests.js +541 -0
- package/dist/web/tool-updates.js +147 -13
- package/dist/web/workspaces.js +213 -12
- package/launch.mjs +80 -2
- package/package.json +1 -1
package/dist/web/revit-editor.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from './model-editor-revit-adapter.js';
|
|
8
8
|
import {
|
|
9
9
|
buildRevitClassificationTree, filterRevitPropertyGroups, groupRevitProperties,
|
|
10
|
-
renderRevitNoModelState, revitExplorerTabs, revitInitialAuthority, revitNoModelCopy, revitPropertyEncodingLabel,
|
|
10
|
+
modelFailureCopy, renderRevitNoModelState, revitExplorerTabs, revitInitialAuthority, revitNoModelCopy, revitPropertyEncodingLabel,
|
|
11
11
|
teklaNoSnapshotCopy,
|
|
12
12
|
} from './model-revit-module.js';
|
|
13
13
|
import { createRevitViewport } from './model-viewport-revit-adapter.js';
|
|
@@ -16,7 +16,7 @@ import { mountModelOrientationOverlay } from './model-orientation-overlay.js';
|
|
|
16
16
|
import { mountModelMeasureTool } from './model-measure.js';
|
|
17
17
|
import { createModelCadToolController } from './model-cad-tools.js';
|
|
18
18
|
import { createModelSelectionTools } from './model-selection-tools.js';
|
|
19
|
-
import { mountModelPointerDock,
|
|
19
|
+
import { mountModelPointerDock, teklaModelPointerDockPlan, REVIT_POINTER_DOCK_PLAN } from './model-pointer-dock.js';
|
|
20
20
|
import { createModelSpatialTools } from './model-spatial-tools.js';
|
|
21
21
|
import { mountModelSpatialPanel } from './model-spatial-panel.js';
|
|
22
22
|
import { createModelClipSession } from './model-clip-session.js';
|
|
@@ -30,7 +30,8 @@ import { createModelPanelBridge, createModelSelectionOriginGuard, createPanelHos
|
|
|
30
30
|
import { mountModelDisplayUnits } from './model-display-units.js';
|
|
31
31
|
import { formatModelProperty, teklaObjectFields, teklaObjectLabel, teklaPropertyGroups, teklaTypeGroups } from './model-property-display.js';
|
|
32
32
|
import { formatLength, parseLengthMm } from './display-units.js';
|
|
33
|
-
import { TEKLA_GEOMETRY_SELECTION_CAP, teklaAssemblyMembership, teklaGeometrySelection } from './model-tekla-selection.js';
|
|
33
|
+
import { TEKLA_GEOMETRY_SELECTION_CAP, changeTeklaSelectionScope, readTeklaSelectionScopes, teklaAssemblyMembership, teklaGeometrySelection, teklaHierarchyIndexes } from './model-tekla-selection.js';
|
|
34
|
+
import { createModelGroupNavigator } from './model-group-navigator.js';
|
|
34
35
|
import { displayNeedsSelection, dominantColour, evaluateModelViewQuery, objectFact, parseModelViewCommand, propertyFact } from './model-view-query.js';
|
|
35
36
|
import { modelSubjectLabel, renderChatQuestions, subjectLabelText, subjectsKeyOf } from './model-chat-questions.js';
|
|
36
37
|
|
|
@@ -75,6 +76,9 @@ let editorStateDirtyGeneration = 0;
|
|
|
75
76
|
let editorStateSavedGeneration = 0;
|
|
76
77
|
let editorStateSaveQueue = Promise.resolve();
|
|
77
78
|
let editorStateDirtyPayload = null;
|
|
79
|
+
let editorStateAccessWarned = null; // the access-refusal sentence already shown for the opened model (#2361)
|
|
80
|
+
// The hidden grid elevations last saved or restored, as JSON; null while a revision loads (nothing is saved then).
|
|
81
|
+
let gridVisibilitySignature = null;
|
|
78
82
|
let projectContract = null;
|
|
79
83
|
let teklaAudit = null;
|
|
80
84
|
let sharedTools = null;
|
|
@@ -83,7 +87,12 @@ let propertyDisplayRefresh = new Set();
|
|
|
83
87
|
let toolbarChrome = null;
|
|
84
88
|
let lightingPanel = null;
|
|
85
89
|
let teklaAssemblyMembers = new Map();
|
|
90
|
+
let teklaHierarchy = teklaHierarchyIndexes([], []);
|
|
91
|
+
let teklaGroupNavigator = null;
|
|
92
|
+
let teklaHierarchyGeneration = 0;
|
|
93
|
+
let teklaSelectionScopes = readTeklaSelectionScopes(localStorage);
|
|
86
94
|
let geometrySelectionIds = [];
|
|
95
|
+
let lastSelectionHoverHit = null;
|
|
87
96
|
let terminalDisposed = false;
|
|
88
97
|
let bfcacheSuspended = false;
|
|
89
98
|
let revisionLoadToken = 0;
|
|
@@ -195,8 +204,16 @@ function modelUnavailableCopy() {
|
|
|
195
204
|
? 'This verified Tekla snapshot could not be opened. Open Source to check the read, then choose the Tekla source again if needed.'
|
|
196
205
|
: 'This verified Revit snapshot could not be opened. Open Source to check the import, then choose the Revit file again if needed.';
|
|
197
206
|
}
|
|
198
|
-
|
|
199
|
-
|
|
207
|
+
// `failure` is the server's own sentence for what went wrong (modelFailureCopy), shown instead of the snapshot copy.
|
|
208
|
+
function fail(failure = null) {
|
|
209
|
+
const state = $('loadingState');
|
|
210
|
+
// A boot that stopped before reading the project would leave the header saying it is still loading.
|
|
211
|
+
if ($('modelName').textContent === 'Loading model…') $('modelName').textContent = 'Model unavailable';
|
|
212
|
+
if (failure) { $('editorRoot').dataset.modelState = 'empty'; renderRevitNoModelState(state, failure); return; }
|
|
213
|
+
state.replaceChildren(); const strong = document.createElement('strong'); strong.textContent = 'Model unavailable'; const copy = document.createElement('span'); copy.textContent = modelUnavailableCopy(); state.append(strong, copy);
|
|
214
|
+
}
|
|
215
|
+
// Any answer that is not ok rides on the error (`status`, `body`), so a failure can say what the server wrote for a person.
|
|
216
|
+
async function json(url, options) { const response = await fetch(url, { credentials: 'same-origin', ...options }); const value = await response.json().catch(() => ({})); if (!response.ok || value.ok === false) throw Object.assign(new Error(value.message || value.error || `Request failed (${response.status})`), { status: response.status, body: value }); return value; }
|
|
200
217
|
|
|
201
218
|
function propertySection(heading, rows) {
|
|
202
219
|
return { id: heading.toLowerCase().replace(/\W+/g, '-'), heading, editable: false, render(host) {
|
|
@@ -276,10 +293,13 @@ const TEKLA_AUDIT_COPY = Object.freeze({
|
|
|
276
293
|
'weld-recipes-unevaluated': Object.freeze({ group: 'shape-not-evaluated', title: 'Shape detail not evaluated', detail: 'Some weld-shape instructions were preserved as database facts but were not evaluated into display geometry.' }),
|
|
277
294
|
'grid-mapping-unevaluated': Object.freeze({ group: 'shape-not-evaluated', title: 'Grid not shown in 3D', detail: 'This grid is present in the Tekla database, but its display extents could not be mapped safely.' }),
|
|
278
295
|
'grid-record-undecoded': Object.freeze({ group: 'not-shown', title: 'Grid not shown in 3D', detail: 'This grid is in the Tekla model, but it could not be drawn: the model has more than one grid, or its grid record could not be read. The rest of the model is unaffected. To see the grid, keep one grid in the Tekla model and read the model again; if it is still not shown, use Report an issue.' }),
|
|
296
|
+
'uda-value-unreadable': Object.freeze({ group: 'property-not-read', title: 'UDA not read', detail: 'An unreadable user-defined attribute value was omitted. The object’s other readable properties and verified relationships were kept.' }),
|
|
279
297
|
'unsupported-native-type': Object.freeze({ group: 'shape-not-evaluated', title: 'Shape detail not evaluated', detail: 'This native Tekla object type is recorded but is not yet interpreted by the parser.' }),
|
|
280
298
|
// #1836: the model was read without a Tekla catalogue file the person chose to continue without.
|
|
281
299
|
'profile-catalogue-missing': Object.freeze({ group: 'shape-not-evaluated', title: 'Shown as a stand-in bar', detail: 'This part’s profile shape isn’t known because profdb.bin was missing, so it is drawn as a thin stand-in bar where it can be placed. Read the model again with that file for the real shape.' }),
|
|
282
300
|
'bolt-catalogue-missing': Object.freeze({ group: 'not-shown', title: 'Bolt not drawn', detail: 'This bolt needs a catalogue file that was missing (screwdb.db or assdb.db), so it is not drawn. Read the model again with the file to see it.' }),
|
|
301
|
+
'component-parent-unverified': Object.freeze({ group: 'hierarchy-not-confirmed', title: 'Connection hierarchy not confirmed', detail: 'This object remains in the imported model, but the parser could not verify its recorded Connection or Component parent from the available database records. The unverified hierarchy link was omitted.' }),
|
|
302
|
+
'assembly-parent-unverified': Object.freeze({ group: 'hierarchy-not-confirmed', title: 'Assembly hierarchy not confirmed', detail: 'This object remains in the imported model, but the parser could not verify its recorded Assembly parent from the available database records. The unverified hierarchy link was omitted.' }),
|
|
283
303
|
});
|
|
284
304
|
|
|
285
305
|
// #1836: what a missing catalogue file affects, for the Audit tab's Missing source files group.
|
|
@@ -303,6 +323,12 @@ const TEKLA_CATALOGUE_ORIGINS = Object.freeze(['model-local', 'user-supplied-pac
|
|
|
303
323
|
// #1836: a part profdb.bin's absence left with no axis is not drawn at all, so it is never called a stand-in bar.
|
|
304
324
|
const TEKLA_UNPLACED_PROFILE_COPY = Object.freeze({ group: 'not-shown', title: 'Part not drawn', detail: 'This part’s profile shape isn’t known because profdb.bin was missing, and it has no usable start and end point, so it is not drawn. Read the model again with that file to see it.' });
|
|
305
325
|
function auditCopyFor(finding) {
|
|
326
|
+
if (finding.code === 'uda-value-unreadable') {
|
|
327
|
+
const names = [...new Set((finding.evidence?.udas ?? []).map((row) => row.name).filter((name) => typeof name === 'string' && name.length))];
|
|
328
|
+
const label = names.length ? names.join(', ') : 'unnamed attribute';
|
|
329
|
+
return { ...TEKLA_AUDIT_COPY[finding.code], title: `UDA not read: ${label}`,
|
|
330
|
+
detail: `The parser could not read ${names.length === 1 ? 'the value of the' : 'values of the'} user-defined ${names.length === 1 ? 'attribute' : 'attributes'} “${label}” on this object. Its other readable properties and verified relationships were kept. Check ${names.length === 1 ? 'this attribute' : 'these attributes'} in Tekla, then read the model again; if ${names.length === 1 ? 'it still cannot' : 'they still cannot'} be read, report the problem.` };
|
|
331
|
+
}
|
|
306
332
|
return finding.code === 'profile-catalogue-missing' && finding.hasGeometry === false ? TEKLA_UNPLACED_PROFILE_COPY : TEKLA_AUDIT_COPY[finding.code];
|
|
307
333
|
}
|
|
308
334
|
|
|
@@ -324,6 +350,27 @@ function auditInspectorSection(findings) {
|
|
|
324
350
|
} };
|
|
325
351
|
}
|
|
326
352
|
|
|
353
|
+
// A Type branch builds its rows only when it is first opened, so an object picked in 3D inside a Type nobody has opened
|
|
354
|
+
// has no row, and the left panel's Follow selection has nothing to reveal. Build the rows of just the Type (and subtype)
|
|
355
|
+
// holding the picked object. Rebuilding the whole tree would also empty every other branch already built; the left panel
|
|
356
|
+
// then asks for those rows again, and they arrive above the picked row after it has been scrolled to.
|
|
357
|
+
// A row the branch already built still lacks (past its first 500) gets that one branch built again around the object.
|
|
358
|
+
function followTeklaPick(id) {
|
|
359
|
+
const host = $('revitExplorerTypes');
|
|
360
|
+
const hasRow = () => [...host.querySelectorAll('[data-entity-id]')].some((row) => row.dataset.entityId === id);
|
|
361
|
+
if (!host || hasRow()) return false;
|
|
362
|
+
let scope = host, holder = null;
|
|
363
|
+
for (;;) {
|
|
364
|
+
const trigger = [...scope.querySelectorAll(':scope > .revit-tree-branch > .revit-tree-trigger')].find((item) => item.__holdsEntity?.(id));
|
|
365
|
+
const children = trigger?.parentElement?.querySelector(':scope > .revit-tree-children');
|
|
366
|
+
if (!children) break;
|
|
367
|
+
trigger.__populateTreeItem?.(id);
|
|
368
|
+
holder = trigger; scope = children;
|
|
369
|
+
}
|
|
370
|
+
if (!hasRow() && holder?.__populateTreeItem) holder.__populateTreeItem(id, true);
|
|
371
|
+
return hasRow() || renderExplorerSearch('type', modelSearchQueries.get('type') || '', id);
|
|
372
|
+
}
|
|
373
|
+
|
|
327
374
|
function inspect(id, syncViewport = true, publish = true, origin = 'tree') {
|
|
328
375
|
propertyDisplayRefresh = new Set();
|
|
329
376
|
selectedId = id;
|
|
@@ -339,6 +386,7 @@ function inspect(id, syncViewport = true, publish = true, origin = 'tree') {
|
|
|
339
386
|
}
|
|
340
387
|
selectionOriginGuard.run(() => viewport.setSelection({ ids: isTeklaParser ? geometrySelectionIds : id ? [id] : [] }));
|
|
341
388
|
}
|
|
389
|
+
if (syncViewport && isTeklaParser) synchronizeTeklaNavigatorSelection();
|
|
342
390
|
updateSelectionActions();
|
|
343
391
|
const modelHostId = modelExplorerTabs.find((tab) => tab.key === 'model')?.bodyId;
|
|
344
392
|
const nextFollowedId = selectedIds.length === 1 && entities.slice(MODEL_EXPLORER_ENTITY_CAP).some((item) => item.id === selectedIds[0]) ? selectedIds[0] : null;
|
|
@@ -348,6 +396,8 @@ function inspect(id, syncViewport = true, publish = true, origin = 'tree') {
|
|
|
348
396
|
classificationFollowedId = nextFollowedId;
|
|
349
397
|
if (publish) modelPanelBridge?.publishSnapshot();
|
|
350
398
|
}
|
|
399
|
+
// Every 3D pick — the plain viewport pick and the hierarchy navigator's — so the panel has the row before it is told.
|
|
400
|
+
if (isTeklaParser && origin === 'viewport' && selectedIds.length === 1 && followTeklaPick(selectedIds[0]) && publish) modelPanelBridge?.publishSnapshot();
|
|
351
401
|
if (!id) { inspector.render({ state: 'empty', after: [chatQuestionsSection] }); if (publish) modelPanelBridge?.publishSelection(selectionOrigin); return true; }
|
|
352
402
|
const entity = entityById.get(id);
|
|
353
403
|
if (!entity) { inspector.render({ state: 'unavailable', message: 'This object is not in the loaded revision.', after: [chatQuestionsSection] }); if (publish) modelPanelBridge?.publishSelection(selectionOrigin); return false; }
|
|
@@ -373,7 +423,57 @@ function selectRevitEntities(id, ids, fit = false, origin = 'tree') {
|
|
|
373
423
|
return result;
|
|
374
424
|
}
|
|
375
425
|
|
|
426
|
+
function decorateSelectionHits(hits) {
|
|
427
|
+
return (Array.isArray(hits) ? hits : []).map((hit) => {
|
|
428
|
+
const sourceId = hit?.entity?.sourceId ?? hit?.sourceId ?? hit?.providerToken;
|
|
429
|
+
const entity = entityById.get(sourceId);
|
|
430
|
+
return { ...hit, entity: { kind: hit?.entity?.kind ?? 'native', sourceId: String(sourceId) }, facets: {
|
|
431
|
+
...(hit?.facets ?? {}), level: entity?.levelName ?? '', category: entity?.categoryName ?? entity?.category ?? '',
|
|
432
|
+
family: entity?.familyName ?? entity?.family ?? '', type: entity?.typeName ?? '',
|
|
433
|
+
} };
|
|
434
|
+
}).filter((hit) => hit.entity.sourceId && hit.entity.sourceId !== 'undefined');
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// Type selections and Audit inspection also write the viewer selection. Carry that exact set
|
|
438
|
+
// into the navigator before its next additive operation, retaining known occurrence anchors.
|
|
439
|
+
function synchronizeTeklaNavigatorSelection() {
|
|
440
|
+
if (!teklaGroupNavigator) return false;
|
|
441
|
+
const previous = new Map(teklaGroupNavigator.state().selectedItems.map((item) => [item.entityId, item]));
|
|
442
|
+
const occurrences = selectedIds.map((id) => previous.get(id) ?? { entityId: id, occurrencePath: [id] });
|
|
443
|
+
return teklaGroupNavigator.synchronizeSelection(occurrences, selectedId).ok;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function resolveTeklaOccurrences(occurrences, { origin = 'tree', operation = 'replace', altAssembly = false, eligibleHits = null } = {}) {
|
|
447
|
+
if (!teklaGroupNavigator || !Array.isArray(occurrences) || !occurrences.length) return { handled: false, accepted: false };
|
|
448
|
+
for (const occurrence of occurrences) {
|
|
449
|
+
if (!occurrence?.entityId || entityById.get(occurrence.entityId)?.hierarchyContract !== 'tekla-hierarchy/v1') return { handled: false, accepted: false };
|
|
450
|
+
}
|
|
451
|
+
const proposal = teklaGroupNavigator.resolveMany(occurrences, teklaSelectionScopes, { origin, operation: 'replace', altAssembly });
|
|
452
|
+
if (!proposal.ok) {
|
|
453
|
+
if (proposal.reason === 'geometry-cap') toast('Not selected: this hierarchy contains more than 5,000 visible geometry objects. Expand it and select a smaller branch.');
|
|
454
|
+
else if (proposal.reason === 'hierarchy-cap') toast('Not selected: this hierarchy is too large to resolve safely. Expand it and select a smaller branch.');
|
|
455
|
+
return { handled: true, accepted: false, reason: proposal.reason };
|
|
456
|
+
}
|
|
457
|
+
if (operation !== 'replace' && !synchronizeTeklaNavigatorSelection()) return { handled: true, accepted: false };
|
|
458
|
+
const selectedItems = proposal.selectedItems;
|
|
459
|
+
const filter = eligibleHits ?? selectionTools?.eligibleHits;
|
|
460
|
+
const decorated = decorateSelectionHits(selectedItems.map((item) => ({ entity: { kind: 'native', sourceId: item.entityId }, occurrencePath: item.occurrencePath })));
|
|
461
|
+
const eligible = typeof filter === 'function' ? filter(decorated) : decorated;
|
|
462
|
+
if (!eligible.length) {
|
|
463
|
+
toast('Nothing selected: the current selection filters exclude every object in this hierarchy.');
|
|
464
|
+
return { handled: true, accepted: true, reason: 'filtered' };
|
|
465
|
+
}
|
|
466
|
+
const result = teklaGroupNavigator.selectResolved(eligible.map((hit) => ({ entityId: hit.entity.sourceId, occurrencePath: hit.occurrencePath })),
|
|
467
|
+
{ origin, operation, exitDrill: altAssembly === true && proposal.exitDrill === true });
|
|
468
|
+
if (!result.ok && result.reason === 'geometry-cap') toast('Not selected: this hierarchy contains more than 5,000 visible geometry objects. Expand it and select a smaller branch.');
|
|
469
|
+
else if (!result.ok && result.reason === 'hierarchy-cap') toast('Not selected: this hierarchy is too large to resolve safely. Expand it and select a smaller branch.');
|
|
470
|
+
return { handled: true, accepted: result.ok, reason: result.reason };
|
|
471
|
+
}
|
|
472
|
+
|
|
376
473
|
function selectTeklaObjects(id, ids, visibleOnly = false, fit = true, origin = 'tree') {
|
|
474
|
+
if (origin === 'tree' && fit && id && ids.length === 1 && teklaGroupNavigator && entityById.get(id)?.hierarchyContract === 'tekla-hierarchy/v1') {
|
|
475
|
+
return resolveTeklaOccurrences([{ entityId: id, occurrencePath: [id] }], { origin }).accepted;
|
|
476
|
+
}
|
|
377
477
|
if (!ids.every((each) => entityById.has(each))) return false;
|
|
378
478
|
const visible = visibleOnly
|
|
379
479
|
? new Set((viewport.selectionTools?.allHits() || []).map((hit) => hit.entity.sourceId)) : null;
|
|
@@ -388,6 +488,7 @@ function selectTeklaObjects(id, ids, visibleOnly = false, fit = true, origin = '
|
|
|
388
488
|
selectionOriginGuard.run(() => viewport.setSelection({ ids: geometryIds }));
|
|
389
489
|
const selected = ids.includes(id) ? id : (ids.at(-1) ?? null);
|
|
390
490
|
const result = inspect(selected, false, true, origin);
|
|
491
|
+
synchronizeTeklaNavigatorSelection();
|
|
391
492
|
if (geometryIds.length) { if (fit) facade.dispatch('model.fit-selection'); }
|
|
392
493
|
else if (ids.length) toast(visibleOnly ? 'This type has no visible geometry to select.' : 'This object has no verified geometry to frame.');
|
|
393
494
|
return result;
|
|
@@ -492,7 +593,7 @@ function applyModelView(command, target) {
|
|
|
492
593
|
if (display?.visibility === 'isolate') { facade.dispatch('model.isolate'); applied.push('isolate'); }
|
|
493
594
|
if (display?.visibility === 'hide-selected') { facade.dispatch('model.hide-selected'); applied.push('hide-selected'); }
|
|
494
595
|
// The toolbar's Show all also brings back hidden grid levels (its click handler, below).
|
|
495
|
-
if (display?.visibility === 'show-all') { facade.dispatch('model.show-all'); viewport.setGridHiddenLevels([]); syncGridVisibilityAction(); applied.push('show-all'); }
|
|
596
|
+
if (display?.visibility === 'show-all') { facade.dispatch('model.show-all'); viewport.setGridHiddenLevels([]); syncGridVisibilityAction(); noteGridVisibilityChange(); applied.push('show-all'); }
|
|
496
597
|
if (display?.ghostUnselected != null) { facade.dispatch('model.ghost-unselected.set', display.ghostUnselected); applied.push('ghost'); }
|
|
497
598
|
if (display?.mode) {
|
|
498
599
|
if (VIEWER_DISPLAY_MODES.includes(display.mode)) { facade.dispatch('model.display-mode.set', display.mode); applied.push('mode'); }
|
|
@@ -519,7 +620,54 @@ function applyModelView(command, target) {
|
|
|
519
620
|
};
|
|
520
621
|
}
|
|
521
622
|
|
|
522
|
-
function
|
|
623
|
+
function createTeklaNavigator() {
|
|
624
|
+
if (!isTeklaParser) return null;
|
|
625
|
+
return createModelGroupNavigator({
|
|
626
|
+
isGroup: (id) => teklaHierarchy.children.has(id),
|
|
627
|
+
groupKind: (id) => teklaHierarchy.groupKind(id),
|
|
628
|
+
childrenOf: (id) => teklaHierarchy.children.get(id) || [],
|
|
629
|
+
hasGeometry: (id) => !!entityById.get(id)?.geometry?.length || entityById.get(id)?.structuralGrid?.mapping?.kind === 'symmetric',
|
|
630
|
+
groupCandidatesOfPick: (id) => teklaHierarchy.candidates(id),
|
|
631
|
+
generation: () => teklaHierarchyGeneration,
|
|
632
|
+
commitSelection(proposal) {
|
|
633
|
+
geometrySelectionIds = [...proposal.geometryIds]; selectedIds = proposal.selectedItems.map((item) => item.entityId);
|
|
634
|
+
if (selectedIds.length) clipSession?.clearSelection?.();
|
|
635
|
+
selectionOriginGuard.run(() => viewport.setSelection({ ids: geometrySelectionIds }));
|
|
636
|
+
const primary = proposal.primaryEntityId;
|
|
637
|
+
if (selectedIds.length > 1) {
|
|
638
|
+
selectedId = null; selectionOrigin = proposal.origin === 'mesh' ? 'viewport' : 'tree';
|
|
639
|
+
inspector.render({ state: 'ready', heading: `${selectedIds.length.toLocaleString()} objects selected`,
|
|
640
|
+
sections: [propertySection('Selection', [['Objects', selectedIds.length], ['Geometry objects', geometrySelectionIds.length]])], after: [chatQuestionsSection] });
|
|
641
|
+
updateSelectionActions(); modelPanelBridge?.publishSelection(selectionOrigin); window.__instructor?.notifyChanged();
|
|
642
|
+
} else inspect(primary, false, true, proposal.origin === 'mesh' ? 'viewport' : 'tree');
|
|
643
|
+
if (geometrySelectionIds.length && proposal.origin === 'tree') facade?.dispatch('model.fit-selection');
|
|
644
|
+
else if (!geometrySelectionIds.length && primary) toast('This object has no verified geometry to frame.');
|
|
645
|
+
return true;
|
|
646
|
+
},
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
function enterTeklaDrillFromPick(id) {
|
|
651
|
+
if (!teklaGroupNavigator || entityById.get(id)?.hierarchyContract !== 'tekla-hierarchy/v1') return false;
|
|
652
|
+
const ownKind = teklaHierarchy.groupKind(id); const candidates = teklaHierarchy.candidates(id);
|
|
653
|
+
const groupId = ownKind ? id
|
|
654
|
+
: teklaSelectionScopes.connection === 'group' && candidates.connection.length ? candidates.connection[0]
|
|
655
|
+
: teklaSelectionScopes.assembly === 'group' && candidates.assembly.length ? candidates.assembly[0] : null;
|
|
656
|
+
if (!groupId || !teklaGroupNavigator.enter({ entityId: groupId, occurrencePath: [groupId] })) return false;
|
|
657
|
+
if (id !== groupId) teklaGroupNavigator.select({ entityId: id, occurrencePath: [groupId, id] }, teklaSelectionScopes, { origin: 'mesh' });
|
|
658
|
+
return true;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
function isCurrentTeklaOccurrence(entityId, occurrencePath) {
|
|
662
|
+
if (!Array.isArray(occurrencePath) || !occurrencePath.length || occurrencePath.at(-1) !== entityId) return false;
|
|
663
|
+
if (!occurrencePath.every((id) => entityById.get(id)?.hierarchyContract === 'tekla-hierarchy/v1')) return false;
|
|
664
|
+
for (let index = 1; index < occurrencePath.length; index++) {
|
|
665
|
+
if (!(teklaHierarchy.children.get(occurrencePath[index - 1]) || []).includes(occurrencePath[index])) return false;
|
|
666
|
+
}
|
|
667
|
+
return true;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
function row(label, count, entityId, objectFields = null, occurrencePath = null) {
|
|
523
671
|
const button = document.createElement('button'); button.type = 'button'; button.className = 'explorer-row';
|
|
524
672
|
if (entityId) button.dataset.entityId = entityId;
|
|
525
673
|
const text = document.createElement('span'); text.className = 'row-label'; text.textContent = label;
|
|
@@ -541,7 +689,17 @@ function row(label, count, entityId, objectFields = null) {
|
|
|
541
689
|
button.append(summary);
|
|
542
690
|
} else button.append(text);
|
|
543
691
|
if (count != null) { const number = document.createElement('span'); number.className = 'explorer-count'; number.textContent = String(count); button.append(number); }
|
|
544
|
-
if (entityId) button.
|
|
692
|
+
if (entityId && occurrencePath) button.dataset.occurrencePath = JSON.stringify(occurrencePath);
|
|
693
|
+
if (entityId) button.addEventListener('click', (event) => {
|
|
694
|
+
if (event.detail > 1) return false;
|
|
695
|
+
if ((event.ctrlKey || event.metaKey) && event.shiftKey) { event.preventDefault(); return false; }
|
|
696
|
+
if (!isTeklaParser) return inspect(entityId);
|
|
697
|
+
if (occurrencePath && teklaGroupNavigator && entityById.get(entityId)?.hierarchyContract === 'tekla-hierarchy/v1') {
|
|
698
|
+
const operation = event.ctrlKey || event.metaKey ? 'toggle' : event.shiftKey ? 'add' : 'replace';
|
|
699
|
+
return resolveTeklaOccurrences([{ entityId, occurrencePath }], { origin: 'tree', operation }).accepted;
|
|
700
|
+
}
|
|
701
|
+
return selectTeklaObjects(entityId, [entityId]);
|
|
702
|
+
});
|
|
545
703
|
return button;
|
|
546
704
|
}
|
|
547
705
|
|
|
@@ -590,26 +748,72 @@ function dropStaleFollowedRow(selected) {
|
|
|
590
748
|
return true;
|
|
591
749
|
}
|
|
592
750
|
|
|
593
|
-
function renderEntityList(host, values, ownProperties = propertyByEntity, memberships = teklaAssemblyMembers, followedId = null) {
|
|
751
|
+
function renderEntityList(host, values, ownProperties = propertyByEntity, memberships = teklaAssemblyMembers, parentPath = [], followedId = null) {
|
|
594
752
|
host.replaceChildren();
|
|
595
753
|
if (!values.length) { const empty = document.createElement('div'); empty.className = 'explorer-empty'; empty.textContent = 'No objects in this index.'; host.append(empty); return; }
|
|
596
|
-
const fragment = document.createDocumentFragment();
|
|
597
754
|
const limit = 500;
|
|
598
|
-
|
|
755
|
+
let shown = 0;
|
|
756
|
+
const appendNextPage = (focusNew = false) => {
|
|
757
|
+
host.querySelector(':scope > .explorer-load-more')?.remove();
|
|
758
|
+
const fragment = document.createDocumentFragment();
|
|
759
|
+
let firstNewTreeItem = null;
|
|
760
|
+
for (const entity of values.slice(shown, shown + limit)) {
|
|
761
|
+
const extra = [...host.querySelectorAll(':scope > [data-followed-row]')].find((item) => item.dataset.entityId === entity.id);
|
|
762
|
+
if (extra) { extra.remove(); const note = host.querySelector(':scope > [data-plain-note]'); if (note) { note.textContent = note.dataset.plainNote; delete note.dataset.plainNote; } }
|
|
763
|
+
const hierarchyChildren = isTeklaParser ? (teklaHierarchy.children.get(entity.id) || []) : [];
|
|
764
|
+
const memberCount = hierarchyChildren.length || (isTeklaParser && memberships.has(entity.id) ? memberships.get(entity.id).length : null);
|
|
765
|
+
const fields = isTeklaParser ? teklaObjectFields(entity, ownProperties.get(entity.id)) : null;
|
|
766
|
+
const occurrencePath = isTeklaParser ? [...parentPath, entity.id] : null;
|
|
767
|
+
const item = row(isTeklaParser ? (fields.name ?? entity.nativeKind ?? entity.typeName ?? 'Tekla object') : (entity.name || entity.typeName || entity.id), memberCount, entity.id, fields, occurrencePath);
|
|
768
|
+
if (isTeklaParser) { item.setAttribute('role', 'treeitem'); item.tabIndex = -1; }
|
|
769
|
+
if (!firstNewTreeItem && item.getAttribute('role') === 'treeitem') firstNewTreeItem = item;
|
|
770
|
+
if (memberCount != null) item.dataset.tip = `${memberCount} verified descendants; selection follows the active group scope`;
|
|
771
|
+
if (!hierarchyChildren.length) { fragment.append(item); continue; }
|
|
772
|
+
item.dataset.commandId = 'tekla-parser.hierarchy-drill';
|
|
773
|
+
item.dataset.commandInstanceLabel = fields.name ?? entity.nativeKind ?? entity.id;
|
|
774
|
+
const branch = document.createElement('div'); branch.className = 'revit-tree-branch tekla-hierarchy-branch'; branch.setAttribute('role', 'none');
|
|
775
|
+
item.setAttribute('aria-expanded', 'false');
|
|
776
|
+
const disclosure = document.createElement('span'); disclosure.className = 'tekla-hierarchy-disclosure'; disclosure.dataset.tip = 'Show verified objects in this group'; disclosure.setAttribute('aria-hidden', 'true'); disclosure.textContent = '›';
|
|
777
|
+
item.prepend(disclosure);
|
|
778
|
+
const children = document.createElement('div'); children.className = 'revit-tree-children'; children.setAttribute('role', 'group'); children.hidden = true; let populated = false;
|
|
779
|
+
const toggle = (force = null) => {
|
|
780
|
+
const open = force ?? item.getAttribute('aria-expanded') !== 'true';
|
|
781
|
+
if (open && !populated) { renderEntityList(children, hierarchyChildren.map((id) => entityById.get(id)).filter(Boolean), ownProperties, memberships, occurrencePath); populated = true; }
|
|
782
|
+
item.setAttribute('aria-expanded', String(open)); disclosure.textContent = open ? '⌄' : '›'; children.hidden = !open;
|
|
783
|
+
};
|
|
784
|
+
disclosure.addEventListener('click', (event) => { event.preventDefault(); event.stopPropagation(); toggle(); });
|
|
785
|
+
item.addEventListener('dblclick', (event) => { if (event.ctrlKey || event.metaKey || event.shiftKey || event.altKey) { event.preventDefault(); return; } if (teklaGroupNavigator?.enter({ entityId: entity.id, occurrencePath })) { event.preventDefault(); toggle(true); } });
|
|
786
|
+
item.__toggleTreeItem = toggle;
|
|
787
|
+
branch.append(item, children); fragment.append(branch);
|
|
788
|
+
}
|
|
789
|
+
shown = Math.min(values.length, shown + limit); host.append(fragment);
|
|
790
|
+
if (shown < values.length) {
|
|
791
|
+
const more = document.createElement('button'); more.type = 'button'; more.className = 'explorer-row explorer-load-more';
|
|
792
|
+
more.setAttribute('role', 'treeitem'); more.tabIndex = -1;
|
|
793
|
+
more.dataset.pageKey = `model-page:${JSON.stringify(parentPath)}:${values[0]?.id ?? ''}:${values.at(-1)?.id ?? ''}:${shown}:${values.length}`;
|
|
794
|
+
if (isTeklaParser) {
|
|
795
|
+
more.dataset.commandId = 'tekla-parser.hierarchy-load-more';
|
|
796
|
+
more.dataset.commandInstanceLabel = `${values.length.toLocaleString()} objects`;
|
|
797
|
+
}
|
|
798
|
+
more.textContent = `Load 500 more · ${shown.toLocaleString()} of ${values.length.toLocaleString()} shown`;
|
|
799
|
+
more.addEventListener('click', () => appendNextPage(true), { once: true }); host.append(more);
|
|
800
|
+
}
|
|
801
|
+
if (focusNew && firstNewTreeItem) {
|
|
802
|
+
host.closest('[role="tree"]')?.querySelectorAll('[role="treeitem"]').forEach((item) => { item.tabIndex = item === firstNewTreeItem ? 0 : -1; });
|
|
803
|
+
firstNewTreeItem.focus();
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
appendNextPage();
|
|
599
807
|
const followed = followedId && values.length > limit ? values.slice(limit).find((entity) => entity.id === followedId) : null;
|
|
600
|
-
|
|
601
|
-
const
|
|
602
|
-
const
|
|
603
|
-
|
|
604
|
-
if (memberCount != null) item.dataset.tip = `${memberCount} assembly members; selects all signed member geometry`;
|
|
605
|
-
fragment.append(item);
|
|
606
|
-
if (entity === followed) item.dataset.followedRow = 'true';
|
|
808
|
+
if (followed) {
|
|
809
|
+
const fields = isTeklaParser ? teklaObjectFields(followed, ownProperties.get(followed.id)) : null;
|
|
810
|
+
const item = row(isTeklaParser ? (fields.name ?? followed.nativeKind ?? followed.typeName ?? 'Tekla object') : (followed.name || followed.typeName || followed.id), null, followed.id, fields, isTeklaParser ? [...parentPath, followed.id] : null);
|
|
811
|
+
item.dataset.followedRow = 'true'; host.append(item);
|
|
607
812
|
}
|
|
608
|
-
|
|
609
|
-
if (values.length > 500) {
|
|
813
|
+
if (values.length > limit) {
|
|
610
814
|
const note = document.createElement('div'); note.className = 'explorer-empty';
|
|
611
815
|
const plain = `Showing first 500 of ${values.length.toLocaleString()} objects. Select the Type to select all visible matching geometry.`;
|
|
612
|
-
note.textContent =
|
|
816
|
+
note.textContent = followed ? plain.replace(' objects.', ' objects, plus the selected object.') : plain;
|
|
613
817
|
if (followed) note.dataset.plainNote = plain;
|
|
614
818
|
host.append(note);
|
|
615
819
|
}
|
|
@@ -632,22 +836,34 @@ function renderGroupList(host, key, fallback, values = entities, ownProperties =
|
|
|
632
836
|
if (ordered.length > MODEL_EXPLORER_GROUP_CAP) { const note = document.createElement('div'); note.className = 'explorer-empty explorer-limit'; note.textContent = `Showing ${MODEL_EXPLORER_GROUP_CAP} of ${ordered.length.toLocaleString()} groups. Refine the model before browsing the remaining groups.`; host.append(note); }
|
|
633
837
|
}
|
|
634
838
|
|
|
635
|
-
function renderTeklaTypes(host, values, ownProperties, memberships = teklaAssemblyMembers, { query = '', followedId = null } = {}) {
|
|
839
|
+
function renderTeklaTypes(host, values, ownProperties, memberships = teklaAssemblyMembers, { query = '', followedId = null, hierarchy = teklaHierarchy } = {}) {
|
|
636
840
|
host.replaceChildren(); host.setAttribute('role', 'tree'); host.setAttribute('aria-label', 'Browse Tekla objects by Type');
|
|
637
841
|
const valuesById = new Map(values.map((entity) => [entity.id, entity]));
|
|
638
842
|
const branch = (parent, label, values, populate, { expanded = false, populated = expanded } = {}) => {
|
|
639
|
-
const node = document.createElement('div'); node.className = 'revit-tree-branch'; node.setAttribute('role', '
|
|
843
|
+
const node = document.createElement('div'); node.className = 'revit-tree-branch'; node.setAttribute('role', 'none');
|
|
640
844
|
const trigger = row(label, values.length); trigger.classList.add('revit-tree-trigger'); trigger.setAttribute('aria-expanded', String(expanded));
|
|
845
|
+
trigger.setAttribute('role', 'treeitem'); trigger.tabIndex = -1;
|
|
641
846
|
trigger.dataset.selectable = 'true';
|
|
642
847
|
const children = document.createElement('div'); children.className = 'revit-tree-children'; children.setAttribute('role', 'group'); children.hidden = !expanded;
|
|
643
848
|
let hasChildren = false;
|
|
644
849
|
const selectGroup = () => selectTeklaObjects(values[0]?.id ?? null, values.map((entity) => entity.id), true);
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
const open = trigger.getAttribute('aria-expanded') !== 'true';
|
|
850
|
+
const toggle = (force = null) => {
|
|
851
|
+
const open = force ?? trigger.getAttribute('aria-expanded') !== 'true';
|
|
648
852
|
if (open && !hasChildren) { populate(children); hasChildren = true; }
|
|
649
853
|
trigger.setAttribute('aria-expanded', String(open)); children.hidden = !open;
|
|
650
|
-
|
|
854
|
+
};
|
|
855
|
+
trigger.__toggleTreeItem = toggle;
|
|
856
|
+
// What followTeklaPick needs to open only the branch that holds a picked object (and leave every other one as it is).
|
|
857
|
+
let ids = null;
|
|
858
|
+
trigger.__holdsEntity = (id) => (ids ??= new Set(values.map((entity) => entity.id))).has(id);
|
|
859
|
+
// `rebuild` builds an already-built branch again, around `followed` (a row past its first 500).
|
|
860
|
+
trigger.__populateTreeItem = (followed, rebuild = false) => {
|
|
861
|
+
if (hasChildren && !rebuild) return;
|
|
862
|
+
children.replaceChildren(); populate(children, followed); hasChildren = true;
|
|
863
|
+
};
|
|
864
|
+
trigger.addEventListener('model-group-select', selectGroup);
|
|
865
|
+
trigger.addEventListener('click', () => {
|
|
866
|
+
toggle(); selectGroup();
|
|
651
867
|
});
|
|
652
868
|
if (populated) { populate(children); hasChildren = true; }
|
|
653
869
|
node.append(trigger, children); parent.append(node);
|
|
@@ -655,8 +871,10 @@ function renderTeklaTypes(host, values, ownProperties, memberships = teklaAssemb
|
|
|
655
871
|
const allBrowsable = values.filter((entity) => {
|
|
656
872
|
if (entity.geometry?.length) return true;
|
|
657
873
|
if (entity.structuralGrid?.mapping?.kind === 'symmetric') return true;
|
|
658
|
-
|
|
659
|
-
return
|
|
874
|
+
const groupKind = hierarchy.groupKind(entity.id);
|
|
875
|
+
if (groupKind) return !(groupKind === 'assembly' && entity.assemblyActionable === false) && hierarchy.children.has(entity.id);
|
|
876
|
+
return (entity.nativeKind || entity.typeName) === 'Assembly' && entity.assemblyActionable !== false
|
|
877
|
+
&& memberships.get(entity.id)?.some((memberId) => valuesById.get(memberId)?.geometry?.length) === true;
|
|
660
878
|
});
|
|
661
879
|
const normalized = query.trim().toLocaleLowerCase();
|
|
662
880
|
const browsable = normalized ? allBrowsable.filter((entity) => {
|
|
@@ -666,11 +884,11 @@ function renderTeklaTypes(host, values, ownProperties, memberships = teklaAssemb
|
|
|
666
884
|
}) : allBrowsable;
|
|
667
885
|
for (const group of teklaTypeGroups(browsable)) {
|
|
668
886
|
const grouped = [...group.values, ...group.subtypes.flatMap((subtype) => subtype.values)];
|
|
669
|
-
branch(host, group.label, grouped, (children) => {
|
|
670
|
-
if (group.values.length) renderEntityList(children, group.values, ownProperties, memberships,
|
|
887
|
+
branch(host, group.label, grouped, (children, followed = followedId) => {
|
|
888
|
+
if (group.values.length) renderEntityList(children, group.values, ownProperties, memberships, [], followed);
|
|
671
889
|
for (const subtype of group.subtypes) {
|
|
672
|
-
const containsFollowed = subtype.values.some((entity) => entity.id ===
|
|
673
|
-
branch(children, subtype.label, subtype.values, (body) => renderEntityList(body, subtype.values, ownProperties, memberships,
|
|
890
|
+
const containsFollowed = subtype.values.some((entity) => entity.id === followed);
|
|
891
|
+
branch(children, subtype.label, subtype.values, (body, inner = followed) => renderEntityList(body, subtype.values, ownProperties, memberships, [], inner),
|
|
674
892
|
{ expanded: !!normalized, populated: !!normalized || containsFollowed });
|
|
675
893
|
}
|
|
676
894
|
}, { expanded: !!normalized, populated: !!normalized || grouped.some((entity) => entity.id === followedId) });
|
|
@@ -680,6 +898,26 @@ function renderTeklaTypes(host, values, ownProperties, memberships = teklaAssemb
|
|
|
680
898
|
// "no match" (the search only ever looks through drawn objects).
|
|
681
899
|
: values.length ? 'None of this model’s objects could be drawn, so there is nothing to browse here. The Audit tab lists the missing files and the objects they affect.'
|
|
682
900
|
: 'No verified model objects are available.'; host.append(empty); }
|
|
901
|
+
const treeItems = [...host.querySelectorAll('[role="treeitem"]')]; if (treeItems.length) treeItems[0].tabIndex = 0;
|
|
902
|
+
host.onkeydown = (event) => {
|
|
903
|
+
const current = event.target.closest?.('[role="treeitem"]'); if (!current || !host.contains(current)) return;
|
|
904
|
+
const visible = [...host.querySelectorAll('[role="treeitem"]')].filter((item) => !item.closest('[role="group"][hidden]'));
|
|
905
|
+
const move = (next) => { if (!next) return; visible.forEach((item) => { item.tabIndex = item === next ? 0 : -1; }); next.focus(); event.preventDefault(); };
|
|
906
|
+
const index = visible.indexOf(current);
|
|
907
|
+
if (event.key === 'ArrowDown') return move(visible[index + 1]);
|
|
908
|
+
if (event.key === 'ArrowUp') return move(visible[index - 1]);
|
|
909
|
+
if (event.key === 'Home') return move(visible[0]);
|
|
910
|
+
if (event.key === 'End') return move(visible.at(-1));
|
|
911
|
+
if (event.key === 'ArrowRight' && current.hasAttribute('aria-expanded')) {
|
|
912
|
+
if (current.getAttribute('aria-expanded') !== 'true') { if (current.__toggleTreeItem) current.__toggleTreeItem(true); else current.click(); }
|
|
913
|
+
else move(current.parentElement?.querySelector('[role="group"] [role="treeitem"]'));
|
|
914
|
+
event.preventDefault(); return;
|
|
915
|
+
}
|
|
916
|
+
if (event.key === 'ArrowLeft') {
|
|
917
|
+
if (current.getAttribute('aria-expanded') === 'true') { if (current.__toggleTreeItem) current.__toggleTreeItem(false); else current.click(); event.preventDefault(); return; }
|
|
918
|
+
const parent = current.parentElement?.parentElement?.querySelector(':scope > [role="treeitem"]'); if (parent) move(parent);
|
|
919
|
+
}
|
|
920
|
+
};
|
|
683
921
|
return { shown: browsable.length, total: allBrowsable.length };
|
|
684
922
|
}
|
|
685
923
|
|
|
@@ -767,7 +1005,7 @@ function validateTeklaAuditDocument(value, manifest, auditReceipt, snapshotEntit
|
|
|
767
1005
|
|| typeof finding.code !== 'string' || !Object.hasOwn(TEKLA_AUDIT_COPY, finding.code)
|
|
768
1006
|
|| typeof finding.hasGeometry !== 'boolean' || auditCopyFor(finding).group !== finding.group
|
|
769
1007
|
|| !finding.evidence || typeof finding.evidence !== 'object' || Array.isArray(finding.evidence)
|
|
770
|
-
|| JSON.stringify(finding.evidence).length > 4096) failAudit();
|
|
1008
|
+
|| JSON.stringify(finding.evidence).length > (finding.code === 'uda-value-unreadable' ? 512 * 1024 : 4096)) failAudit();
|
|
771
1009
|
ids.add(finding.issueId); affected.add(finding.entityId);
|
|
772
1010
|
}
|
|
773
1011
|
if (affected.size !== value.summary.affectedObjects) failAudit();
|
|
@@ -783,6 +1021,7 @@ function selectAuditFinding(finding) {
|
|
|
783
1021
|
selectedIds = []; geometrySelectionIds = [];
|
|
784
1022
|
selectionOriginGuard.run(() => viewport.setSelection({ ids: [] }));
|
|
785
1023
|
inspect(finding.entityId, false, true, 'audit');
|
|
1024
|
+
synchronizeTeklaNavigatorSelection();
|
|
786
1025
|
}
|
|
787
1026
|
renderTeklaAudit();
|
|
788
1027
|
}
|
|
@@ -837,7 +1076,7 @@ function renderTeklaAudit() {
|
|
|
837
1076
|
}
|
|
838
1077
|
const filters = document.createElement('div'); filters.className = 'tekla-audit-filters'; filters.setAttribute('role', 'group'); filters.setAttribute('aria-label', 'Filter import findings');
|
|
839
1078
|
const filterSpecs = [
|
|
840
|
-
['all', 'All'], ['not-shown', 'Not shown'], ['fit-not-confirmed', 'Fit not confirmed'], ['shape-not-evaluated', 'Shape detail not evaluated'],
|
|
1079
|
+
['all', 'All'], ['not-shown', 'Not shown'], ['fit-not-confirmed', 'Fit not confirmed'], ['shape-not-evaluated', 'Shape detail not evaluated'], ['hierarchy-not-confirmed', 'Hierarchy not confirmed'], ['property-not-read', 'Property not read'],
|
|
841
1080
|
];
|
|
842
1081
|
let active = host.dataset.filter || 'all';
|
|
843
1082
|
const list = document.createElement('div'); list.className = 'tekla-audit-list'; list.setAttribute('role', 'listbox'); list.setAttribute('aria-label', 'Import findings');
|
|
@@ -873,13 +1112,13 @@ function renderTeklaAudit() {
|
|
|
873
1112
|
}
|
|
874
1113
|
|
|
875
1114
|
function updateSelectionActions() {
|
|
876
|
-
const blocked =
|
|
1115
|
+
const blocked = isTeklaParser ? geometrySelectionIds.length === 0 : !selectedId || selectedIds.length === 0;
|
|
877
1116
|
for (const command of [`${commandPrefix}.fit-selection`]) {
|
|
878
1117
|
const control = [...document.querySelectorAll('[data-command-id]')].find((item) => item.dataset.commandId === command);
|
|
879
1118
|
if (!control) continue;
|
|
880
1119
|
if (command === `${commandPrefix}.fit-selection`) {
|
|
881
1120
|
control.disabled = blocked;
|
|
882
|
-
if (blocked) control.dataset.blockedReason = selectedId ? 'This audit object has no 3D location to frame.' : 'Select a model object first.'; else delete control.dataset.blockedReason;
|
|
1121
|
+
if (blocked) control.dataset.blockedReason = selectedId ? 'This audit object has no 3D location to frame.' : selectedIds.length ? 'This selection has no verified 3D location to frame.' : 'Select a model object first.'; else delete control.dataset.blockedReason;
|
|
883
1122
|
}
|
|
884
1123
|
}
|
|
885
1124
|
}
|
|
@@ -959,11 +1198,67 @@ function mountRevitSelectionFilters(tools) {
|
|
|
959
1198
|
});
|
|
960
1199
|
}
|
|
961
1200
|
|
|
1201
|
+
function mountTeklaSelectionScopes() {
|
|
1202
|
+
const subscribers = new Set(); let destroyed = false;
|
|
1203
|
+
const state = () => teklaGroupNavigator?.state().drillStack.length ? { connection: 'objects', assembly: 'objects', drillOverride: true } : { ...teklaSelectionScopes, drillOverride: false };
|
|
1204
|
+
const publish = () => {
|
|
1205
|
+
for (const subscriber of subscribers) subscriber(state());
|
|
1206
|
+
modelPanelBridge?.publishSelection(selectionOrigin);
|
|
1207
|
+
if (lastSelectionHoverHit) reflectSelectionHover(lastSelectionHoverHit);
|
|
1208
|
+
window.__instructor?.notifyChanged();
|
|
1209
|
+
};
|
|
1210
|
+
const unsubscribeNavigator = teklaGroupNavigator?.subscribe?.(publish) ?? null;
|
|
1211
|
+
return Object.freeze({
|
|
1212
|
+
port: Object.freeze({
|
|
1213
|
+
getState: state,
|
|
1214
|
+
subscribe(listener) { subscribers.add(listener); listener(state()); return () => subscribers.delete(listener); },
|
|
1215
|
+
set(axis, value) {
|
|
1216
|
+
const result = changeTeklaSelectionScope({ storage: localStorage, navigator: teklaGroupNavigator, current: teklaSelectionScopes, axis, value });
|
|
1217
|
+
if (!result.changed) return false;
|
|
1218
|
+
teklaSelectionScopes = result.scopes; publish(); return true;
|
|
1219
|
+
},
|
|
1220
|
+
ascend() { return teklaGroupNavigator?.ascend() ?? false; },
|
|
1221
|
+
}),
|
|
1222
|
+
destroy() { if (destroyed) return; destroyed = true; unsubscribeNavigator?.(); subscribers.clear(); },
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1225
|
+
|
|
962
1226
|
function reflectSelectionHover(hit) {
|
|
963
|
-
|
|
1227
|
+
lastSelectionHoverHit = hit ?? null;
|
|
1228
|
+
const id = hit?.entity?.sourceId ?? null;
|
|
964
1229
|
const summary = $('modelHoverSummary');
|
|
965
|
-
if (!id) { summary.hidden = true; summary.textContent = ''; return; }
|
|
966
|
-
|
|
1230
|
+
if (!id) { viewport?.setHover?.([]); summary.hidden = true; summary.textContent = ''; return; }
|
|
1231
|
+
let previewIds = [id]; let previewId = id; let previewCount = 1;
|
|
1232
|
+
if (isTeklaParser && teklaGroupNavigator && entityById.get(id)?.hierarchyContract === 'tekla-hierarchy/v1') {
|
|
1233
|
+
const proposal = teklaGroupNavigator.resolveMany([{ entityId: id, occurrencePath: hit?.occurrencePath ?? [id] }],
|
|
1234
|
+
teklaSelectionScopes, { origin: 'mesh', operation: 'replace' });
|
|
1235
|
+
if (proposal.ok) {
|
|
1236
|
+
const decorated = decorateSelectionHits(proposal.selectedItems.map((item) => ({ entity: { kind: 'native', sourceId: item.entityId }, occurrencePath: item.occurrencePath })));
|
|
1237
|
+
const eligible = selectionTools?.eligibleHits?.(decorated) ?? decorated;
|
|
1238
|
+
if (!eligible.length) { viewport?.setHover?.([]); summary.hidden = true; summary.textContent = ''; return; }
|
|
1239
|
+
const preview = teklaGroupNavigator.resolveResolved(eligible.map((item) => ({
|
|
1240
|
+
entityId: item.entity.sourceId, occurrencePath: item.occurrencePath,
|
|
1241
|
+
})));
|
|
1242
|
+
if (!preview.ok) {
|
|
1243
|
+
viewport?.setHover?.([]); summary.hidden = true; summary.textContent = '';
|
|
1244
|
+
if (preview.reason === 'geometry-cap' || preview.reason === 'hierarchy-cap') {
|
|
1245
|
+
summary.textContent = 'Too large to preview — select a smaller branch.'; summary.hidden = false;
|
|
1246
|
+
}
|
|
1247
|
+
return;
|
|
1248
|
+
}
|
|
1249
|
+
previewIds = [...preview.geometryIds]; previewId = proposal.primaryEntityId ?? preview.primaryEntityId ?? id; previewCount = previewIds.length;
|
|
1250
|
+
} else {
|
|
1251
|
+
viewport?.setHover?.([]); summary.hidden = true; summary.textContent = '';
|
|
1252
|
+
if (proposal.reason === 'geometry-cap' || proposal.reason === 'hierarchy-cap') {
|
|
1253
|
+
summary.textContent = 'Too large to preview — select a smaller branch.'; summary.hidden = false;
|
|
1254
|
+
}
|
|
1255
|
+
return;
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
viewport?.setHover?.(previewIds);
|
|
1259
|
+
const entity = entityById.get(previewId);
|
|
1260
|
+
const label = isTeklaParser && entity ? teklaObjectLabel(entity, propertyByEntity.get(previewId)) : (entity?.name || entity?.typeName || previewId);
|
|
1261
|
+
summary.textContent = previewId !== id ? `${label} · ${previewCount.toLocaleString()} objects` : label; summary.hidden = false;
|
|
967
1262
|
}
|
|
968
1263
|
|
|
969
1264
|
function reflectSelectionMarquee(rect) {
|
|
@@ -1005,7 +1300,33 @@ function editorStatePayload() {
|
|
|
1005
1300
|
state: view.state ?? { camera: view.camera ?? null, displayMode: view.displayMode ?? 'solid' } })),
|
|
1006
1301
|
coordinateFrames: value.frames.filter((frame) => frame.id !== 'global').map((frame) => ({ schemaVersion: 'floless.model-frame/v1', frameId: frame.id,
|
|
1007
1302
|
originMm: frame.origin, xAxis: frame.xAxis, yAxis: frame.yAxis, zAxis: frame.zAxis })),
|
|
1008
|
-
sections: { clips: value.clips, workArea: value.workArea }
|
|
1303
|
+
sections: { clips: value.clips, workArea: value.workArea },
|
|
1304
|
+
...gridVisibilityPayload() };
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
// The grid elevations turned off, saved with the model's view state so it opens with them still off. A model with no
|
|
1308
|
+
// grid sends nothing, which leaves whatever was saved as it was.
|
|
1309
|
+
function gridVisibilityPayload() {
|
|
1310
|
+
const levels = viewport?.gridLevels?.() || [];
|
|
1311
|
+
return levels.length ? { gridVisibility: { hiddenLevelsMm: [...new Set(levels.filter((level) => !level.visible).map((level) => level.mm))] } } : {};
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
function restoreGridVisibility(state) {
|
|
1315
|
+
const hidden = state?.gridVisibility?.hiddenLevelsMm;
|
|
1316
|
+
const restored = Array.isArray(hidden) && (viewport?.gridLevels?.() || []).length > 0;
|
|
1317
|
+
if (restored) { viewport.setGridHiddenLevels(hidden.filter((mm) => typeof mm === 'number' && Number.isFinite(mm))); syncGridVisibilityAction(); }
|
|
1318
|
+
gridVisibilitySignature = JSON.stringify(gridVisibilityPayload().gridVisibility ?? null);
|
|
1319
|
+
return restored;
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
// Saves the grid elevations whenever the set shown changes, whatever changed it: a left-panel switch, the toolbar or
|
|
1323
|
+
// AI Chat Show all, or anything else that resets the grid. Nothing is saved while a revision is still loading.
|
|
1324
|
+
function noteGridVisibilityChange() {
|
|
1325
|
+
if (gridVisibilitySignature === null) return false;
|
|
1326
|
+
const signature = JSON.stringify(gridVisibilityPayload().gridVisibility ?? null);
|
|
1327
|
+
if (signature === gridVisibilitySignature) return false;
|
|
1328
|
+
gridVisibilitySignature = signature; scheduleEditorStateSave('grid-visibility');
|
|
1329
|
+
return true;
|
|
1009
1330
|
}
|
|
1010
1331
|
|
|
1011
1332
|
function editorStateUrl(binding) {
|
|
@@ -1018,7 +1339,8 @@ function readEditorStateRecovery(binding, etag) {
|
|
|
1018
1339
|
|
|
1019
1340
|
function retainEditorStateRecovery() {
|
|
1020
1341
|
if (!editorStateBinding || !editorStateDirtyPayload || editorStateSavedGeneration >= editorStateDirtyGeneration) return;
|
|
1021
|
-
const owned = { namedViews: editorStateDirtyPayload.namedViews, coordinateFrames: editorStateDirtyPayload.coordinateFrames, sections: editorStateDirtyPayload.sections
|
|
1342
|
+
const owned = { namedViews: editorStateDirtyPayload.namedViews, coordinateFrames: editorStateDirtyPayload.coordinateFrames, sections: editorStateDirtyPayload.sections,
|
|
1343
|
+
...(editorStateDirtyPayload.gridVisibility ? { gridVisibility: editorStateDirtyPayload.gridVisibility } : {}) };
|
|
1022
1344
|
editorStateRecovery.retain(editorStateBinding, editorStateEtag, owned);
|
|
1023
1345
|
}
|
|
1024
1346
|
|
|
@@ -1040,12 +1362,14 @@ async function putEditorState({ binding, token, payload, etag }) {
|
|
|
1040
1362
|
const fresh = await fetch(editorStateUrl(binding), { credentials: 'same-origin' });
|
|
1041
1363
|
if (!fresh.ok) throw new Error(`Editor state conflict reload failed (${fresh.status})`);
|
|
1042
1364
|
const freshValue = await fresh.json(); const freshPayload = payloadOnly(freshValue.state) || {};
|
|
1043
|
-
sentPayload = { ...freshPayload, namedViews: payload.namedViews, coordinateFrames: payload.coordinateFrames, sections: payload.sections
|
|
1365
|
+
sentPayload = { ...freshPayload, namedViews: payload.namedViews, coordinateFrames: payload.coordinateFrames, sections: payload.sections,
|
|
1366
|
+
...(payload.gridVisibility ? { gridVisibility: payload.gridVisibility } : {}) };
|
|
1044
1367
|
response = await request(sentPayload, fresh.headers.get('etag') || freshValue.state?.etag || null);
|
|
1045
1368
|
}
|
|
1046
1369
|
const value = await response.json().catch(() => ({}));
|
|
1047
|
-
if (!response.ok || value.ok === false) throw new Error(value.message || value.error || `Editor state save failed (${response.status})`);
|
|
1370
|
+
if (!response.ok || value.ok === false) throw Object.assign(new Error(value.message || value.error || `Editor state save failed (${response.status})`), { code: value.error });
|
|
1048
1371
|
if (token !== editorStateBindingToken) return;
|
|
1372
|
+
editorStateAccessWarned = null;
|
|
1049
1373
|
editorStateEtag = response.headers.get('etag') || value.state?.etag || editorStateEtag;
|
|
1050
1374
|
editorStateLoaded = payloadOnly(value.state) || sentPayload;
|
|
1051
1375
|
}
|
|
@@ -1066,11 +1390,26 @@ function drainEditorStateSaves() {
|
|
|
1066
1390
|
return editorStateSaveQueue;
|
|
1067
1391
|
}
|
|
1068
1392
|
|
|
1393
|
+
// #2361: view-only access refuses every save. Say so once per opened model and reason, not on every change. The last
|
|
1394
|
+
// change is kept in this browser (retainEditorStateRecovery) and retried on the next open, best-effort, so the copy
|
|
1395
|
+
// promises nothing. `state-access-unconfirmed` is the server failing to confirm access for this save at all.
|
|
1396
|
+
const editorStateAccessRefused = (error) => error?.code === 'model_module_unavailable' || error?.code === 'state-access-unconfirmed';
|
|
1397
|
+
function reportEditorStateSaveError(error, fallback) {
|
|
1398
|
+
const refused = editorStateAccessRefused(error);
|
|
1399
|
+
if (refused) { if (editorStateAccessWarned === error.message) return; editorStateAccessWarned = error.message; }
|
|
1400
|
+
toast(error?.message || fallback, refused ? 8000 : undefined);
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1069
1403
|
async function flushEditorStateSave() {
|
|
1070
1404
|
clearTimeout(editorStateSaveTimer); editorStateSaveTimer = null;
|
|
1071
1405
|
if (editorStateDirtyGeneration > editorStateSavedGeneration) await Promise.race([
|
|
1072
|
-
|
|
1073
|
-
|
|
1406
|
+
// A save refused for view-only access must not stop the switch: in view-only access nothing here is being saved.
|
|
1407
|
+
drainEditorStateSaves().catch((error) => { if (!editorStateAccessRefused(error)) throw error; reportEditorStateSaveError(error); }),
|
|
1408
|
+
// Each save first refreshes model access with the server (#2361): on a stalled network that alone may take the
|
|
1409
|
+
// server's DESKTOP_ACCESS_EXPECTED_MS (45 s), so the switch waits that long plus the write before giving up.
|
|
1410
|
+
// ponytail: covers ONE refresh. A retry queued behind a failed one on a stalled network can outlast it; the switch
|
|
1411
|
+
// then asks to try again, which works once the server answers. Budget the queued attempts if that becomes common.
|
|
1412
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error('Saving this model view timed out. Try again before switching models.')), 50_000)),
|
|
1074
1413
|
]);
|
|
1075
1414
|
}
|
|
1076
1415
|
|
|
@@ -1079,7 +1418,7 @@ function scheduleEditorStateSave(reason) {
|
|
|
1079
1418
|
editorStateDirtyPayload = editorStatePayload(); editorStateDirtyGeneration += 1;
|
|
1080
1419
|
retainEditorStateRecovery();
|
|
1081
1420
|
clearTimeout(editorStateSaveTimer);
|
|
1082
|
-
editorStateSaveTimer = setTimeout(() => { editorStateSaveTimer = null; drainEditorStateSaves().catch((error) =>
|
|
1421
|
+
editorStateSaveTimer = setTimeout(() => { editorStateSaveTimer = null; drainEditorStateSaves().catch((error) => reportEditorStateSaveError(error, 'Could not save model view state.')); }, 350);
|
|
1083
1422
|
}
|
|
1084
1423
|
|
|
1085
1424
|
async function prepareSpatialForRevision(state, handle) {
|
|
@@ -1121,7 +1460,9 @@ async function prepareSpatialForRevision(state, handle) {
|
|
|
1121
1460
|
function commitSpatialForRevision(candidate) {
|
|
1122
1461
|
editorStateBindingToken += 1; clearTimeout(editorStateSaveTimer); editorStateSaveTimer = null;
|
|
1123
1462
|
editorStateBinding = candidate.binding; editorStateEtag = candidate.etag; editorStateLoaded = candidate.loaded;
|
|
1124
|
-
editorStateDirtyPayload = null; editorStateDirtyGeneration = 0; editorStateSavedGeneration = 0;
|
|
1463
|
+
editorStateDirtyPayload = null; editorStateDirtyGeneration = 0; editorStateSavedGeneration = 0; editorStateAccessWarned = null;
|
|
1464
|
+
// The grid elevations last turned off go back first, before the recovery branch below captures what to save.
|
|
1465
|
+
restoreGridVisibility(candidate.loaded);
|
|
1125
1466
|
clipList?.destroy(); clipList = null; releaseClipEditor?.(); releaseClipEditor = null; releaseClipViewport?.(); releaseClipViewport = null; clipSession?.dispose(); clipSession = null;
|
|
1126
1467
|
spatialPanel?.destroy(); spatialPanel = null; releaseSpatialViewport?.(); releaseSpatialViewport = null; spatialTools?.dispose(); spatialTools = null;
|
|
1127
1468
|
spatialTools = candidate.tools; clipSession = candidate.clip; candidate.committed = true;
|
|
@@ -1136,7 +1477,7 @@ function commitSpatialForRevision(candidate) {
|
|
|
1136
1477
|
spatialPanel = mountModelSpatialPanel({ tools: spatialTools, trigger: $('modelFrameStatus'), onBeforeOpen: () => { closeSpatialDialog(); toolbarChrome?.closeMenus(); selectionFilterChrome?.close(); lightingPanel?.close({ restoreFocus: false }); },
|
|
1137
1478
|
lengthDisplay: { format: (mm) => formatLength(mm, displayUnitControl.units()), parse: (text) => parseLengthMm(text, displayUnitControl.units()), unitLabel: () => displayUnitControl.units() },
|
|
1138
1479
|
onError: (error) => toast(error.message || 'That spatial action is unavailable.') });
|
|
1139
|
-
if (candidate.recovered) { editorStateDirtyPayload = editorStatePayload(); editorStateDirtyGeneration = 1; retainEditorStateRecovery(); editorStateSaveTimer = setTimeout(() => drainEditorStateSaves().catch((error) =>
|
|
1480
|
+
if (candidate.recovered) { editorStateDirtyPayload = editorStatePayload(); editorStateDirtyGeneration = 1; retainEditorStateRecovery(); editorStateSaveTimer = setTimeout(() => drainEditorStateSaves().catch((error) => reportEditorStateSaveError(error, 'Could not restore model view state.')), 0); }
|
|
1140
1481
|
}
|
|
1141
1482
|
|
|
1142
1483
|
function positionDialog(panel, anchor) {
|
|
@@ -1286,7 +1627,6 @@ function wireToolbar() {
|
|
|
1286
1627
|
else if (control.id === 'revitFitSelection') facade.dispatch('model.fit-selection');
|
|
1287
1628
|
else if (control.id === 'revitSavedViews') facade.dispatch('model.saved-views');
|
|
1288
1629
|
else if (control.dataset.spatial) handleSpatialAction(control.dataset.spatial, control);
|
|
1289
|
-
if (control.dataset.vis === 'show-all') viewport.setGridHiddenLevels([]);
|
|
1290
1630
|
for (const radio of control.parentElement?.querySelectorAll('[role="menuitemradio"]') || []) radio.setAttribute('aria-checked', String(radio === control));
|
|
1291
1631
|
reflectToolbarState();
|
|
1292
1632
|
modelPanelBridge?.publishSnapshot();
|
|
@@ -1295,7 +1635,9 @@ function wireToolbar() {
|
|
|
1295
1635
|
});
|
|
1296
1636
|
updateSelectionActions();
|
|
1297
1637
|
reflectToolbarState();
|
|
1298
|
-
|
|
1638
|
+
// A grid change made here (the toolbar Show all runs in its menu, out of reach of the listener above) also repaints the
|
|
1639
|
+
// left panel's elevation switches.
|
|
1640
|
+
const release = facade.subscribe(() => { try { syncGridVisibilityAction(); reflectToolbarState(); if (noteGridVisibilityChange()) modelPanelBridge?.publishSnapshot(); } catch (_) {} });
|
|
1299
1641
|
return { closeMenus: () => chrome.closeMenus(), destroy() { document.removeEventListener('mousedown', outsideDialog, true); clipButton?.removeEventListener('click', cancelArmedClip, true); release?.(); lightingChrome.destroy(); chrome.destroy(); } };
|
|
1300
1642
|
}
|
|
1301
1643
|
|
|
@@ -1378,10 +1720,11 @@ async function loadRevision(state, authority, spatialCandidate) {
|
|
|
1378
1720
|
renderGroupList(staged.levels, 'levelName', 'No level', nextEntities);
|
|
1379
1721
|
renderGroupList(staged.categories, (entity) => entity.categoryName ?? entity.category, 'No category', nextEntities);
|
|
1380
1722
|
}
|
|
1381
|
-
if (isTeklaParser) renderTeklaTypes(staged.types, nextEntities, nextPropertyByEntity, teklaAssemblyMembership(nextRelationships));
|
|
1723
|
+
if (isTeklaParser) renderTeklaTypes(staged.types, nextEntities, nextPropertyByEntity, teklaAssemblyMembership(nextRelationships), { hierarchy: teklaHierarchyIndexes(nextEntities, nextRelationships) });
|
|
1382
1724
|
else renderGroupList(staged.types, 'typeName', 'No type', nextEntities, nextPropertyByEntity);
|
|
1383
1725
|
if (token !== revisionLoadToken) return false;
|
|
1384
1726
|
const nextStructuralGrid = isTeklaParser ? findTeklaStructuralGrid(nextEntities) : null;
|
|
1727
|
+
gridVisibilitySignature = null;
|
|
1385
1728
|
await viewport.load(tile, owners, { schema: manifest.schema, providerKind: manifest.provider.kind, geometryToRenderMatrix: manifest.geometryToRenderMatrix }, nextStructuralGrid);
|
|
1386
1729
|
if (token !== revisionLoadToken) return false;
|
|
1387
1730
|
commitSpatialForRevision(spatialCandidate);
|
|
@@ -1392,6 +1735,9 @@ async function loadRevision(state, authority, spatialCandidate) {
|
|
|
1392
1735
|
loadedRevisionId = handle.revisionId; loadedSourceDigest = handle.sourceSha256;
|
|
1393
1736
|
entities = nextEntities; properties = nextProperties; relationships = nextRelationships; entityById = nextEntityById; propertyByEntity = nextPropertyByEntity; teklaAudit = nextAudit;
|
|
1394
1737
|
teklaAssemblyMembers = isTeklaParser ? teklaAssemblyMembership(nextRelationships) : new Map();
|
|
1738
|
+
teklaHierarchy = isTeklaParser ? teklaHierarchyIndexes(nextEntities, nextRelationships) : teklaHierarchyIndexes([], []);
|
|
1739
|
+
teklaHierarchyGeneration++;
|
|
1740
|
+
teklaGroupNavigator = isTeklaParser ? createTeklaNavigator() : null;
|
|
1395
1741
|
selectionTools?.generationChanged();
|
|
1396
1742
|
selectionFilterChrome?.refresh();
|
|
1397
1743
|
$('revitExplorerClassification').replaceChildren(...staged.model.childNodes);
|
|
@@ -1401,7 +1747,9 @@ async function loadRevision(state, authority, spatialCandidate) {
|
|
|
1401
1747
|
$('revitExplorerCategories').replaceChildren(...staged.categories.childNodes);
|
|
1402
1748
|
}
|
|
1403
1749
|
$('revitExplorerTypes').replaceChildren(...staged.types.childNodes);
|
|
1750
|
+
if (isTeklaParser) renderTeklaTypes($('revitExplorerTypes'), entities, propertyByEntity, teklaAssemblyMembers);
|
|
1404
1751
|
inspect(null, true, false, 'tree');
|
|
1752
|
+
refreshTeklaModelToolsForRevision();
|
|
1405
1753
|
renderTeklaAudit();
|
|
1406
1754
|
viewerLoading = false;
|
|
1407
1755
|
modelPanelBridge?.ready(handle.revisionId);
|
|
@@ -1425,7 +1773,7 @@ async function loadRevision(state, authority, spatialCandidate) {
|
|
|
1425
1773
|
// The main window's left Model section shows the clip list as a PANEL tab (web/model-panel-bridge.js).
|
|
1426
1774
|
const REVIT_PANEL_TABS = Object.freeze([
|
|
1427
1775
|
Object.freeze({ key: 'clips', label: 'Clips', tip: 'Clips — the planes and boxes cutting the model: select, rename, switch on or off, remove' }),
|
|
1428
|
-
...(isTeklaParser ? [Object.freeze({ key: 'audit', label: 'Audit', tip: 'Audit —
|
|
1776
|
+
...(isTeklaParser ? [Object.freeze({ key: 'audit', label: 'Audit', tip: 'Audit — model properties, hierarchy, shape or placement that could not be fully verified' })] : []),
|
|
1429
1777
|
]);
|
|
1430
1778
|
// Held, not looked up: once shown, the Clips tab lives in the main window's frame, where $() cannot find it.
|
|
1431
1779
|
const revitClipListHost = $('revitClipListHost');
|
|
@@ -1438,15 +1786,38 @@ function mountPanels() {
|
|
|
1438
1786
|
mountSidePanel({ panel: $('inspectorPanel'), resizer: $('inspectorResizer'), toggle: $('inspectorToggle'), root: $('editorRoot'), doc: document, win: window, widthKey: `${storagePrefix}:inspector-width`, collapsedKey: `${storagePrefix}:inspector-collapsed`, label: (collapsed) => (collapsed ? 'Expand Properties' : 'Collapse Properties') });
|
|
1439
1787
|
modelPanelBridge = createModelPanelBridge({
|
|
1440
1788
|
win: window, origin: location.origin, snapshot: modelPanelSnapshot, selectedId: () => selectedId, selectedIds: () => [...selectedIds],
|
|
1441
|
-
selectionState: () => isTeklaParser ? { focusEntityId: selectedId, geometrySelectionIds: [...geometrySelectionIds]
|
|
1789
|
+
selectionState: () => isTeklaParser ? { focusEntityId: selectedId, geometrySelectionIds: [...geometrySelectionIds],
|
|
1790
|
+
drillDepth: teklaGroupNavigator?.state().drillStack.length ?? 0 } : {},
|
|
1442
1791
|
// ids: what a list click selects (Ctrl/Shift can make it several, or none). The Properties panel shows the row clicked
|
|
1443
1792
|
// when it stays selected, else the last one; the viewport shows them all.
|
|
1444
|
-
select: (id, ids = [id]
|
|
1793
|
+
select: (id, ids = [id], context = {}) => {
|
|
1794
|
+
if (isTeklaParser) {
|
|
1795
|
+
if (!ids.every((each) => entityById.has(each))) return false;
|
|
1796
|
+
// Older authenticated snapshots have assembly membership but no occurrence hierarchy.
|
|
1797
|
+
// Keep their existing list selection; a full hierarchy still requires every signed path.
|
|
1798
|
+
if (!entities.some((entity) => entity.hierarchyContract === 'tekla-hierarchy/v1')) return selectTeklaObjects(id, ids);
|
|
1799
|
+
const occurrences = Array.isArray(context.occurrences) ? context.occurrences : [];
|
|
1800
|
+
if (!teklaGroupNavigator || !occurrences.length || !occurrences.every((item) => isCurrentTeklaOccurrence(item.entityId, item.occurrencePath))) return false;
|
|
1801
|
+
return resolveTeklaOccurrences(occurrences, { origin: 'tree', operation: context.operation }).accepted;
|
|
1802
|
+
}
|
|
1803
|
+
return selectRevitEntities(id, ids);
|
|
1804
|
+
},
|
|
1445
1805
|
// #2255: an AI view command this window claimed, applied in this viewer.
|
|
1446
1806
|
view: (command, target) => applyModelView(command, target),
|
|
1447
1807
|
expand: (groupId) => expandModelPanelGroup(modelExplorerTabs, $, groupId),
|
|
1808
|
+
drill: (entityId, occurrencePath) => {
|
|
1809
|
+
if (!isTeklaParser || !teklaGroupNavigator || !teklaHierarchy.groupKind(entityId) || !isCurrentTeklaOccurrence(entityId, occurrencePath)) return false;
|
|
1810
|
+
return teklaGroupNavigator.enter({ entityId, occurrencePath });
|
|
1811
|
+
},
|
|
1812
|
+
ascend: () => isTeklaParser && (teklaGroupNavigator?.ascend() ?? false),
|
|
1813
|
+
clearSelection: () => isTeklaParser && (teklaGroupNavigator?.clear() ?? false),
|
|
1448
1814
|
selectGroup: (groupId) => isTeklaParser && selectModelPanelGroup(modelExplorerTabs, $, groupId),
|
|
1449
1815
|
search: (tab, query) => renderExplorerSearch(tab, query, selectedIds.length === 1 ? selectedIds[0] : null),
|
|
1816
|
+
loadMore: (pageKey) => {
|
|
1817
|
+
const button = [...document.querySelectorAll('.explorer-load-more')].find((item) => item.dataset.pageKey === pageKey);
|
|
1818
|
+
if (!button) return false;
|
|
1819
|
+
button.click(); return true;
|
|
1820
|
+
},
|
|
1450
1821
|
gridVisibility: ({ levelKey, visible }) => {
|
|
1451
1822
|
const levels = viewport?.gridLevels?.() || [];
|
|
1452
1823
|
if (!levels.length || (levelKey !== null && !levels.some((level) => String(level.key) === levelKey))) return false;
|
|
@@ -1454,7 +1825,7 @@ function mountPanels() {
|
|
|
1454
1825
|
? (visible ? [] : levels.map((level) => level.mm))
|
|
1455
1826
|
: levels.filter((level) => String(level.key) === levelKey ? !visible : !level.visible).map((level) => level.mm);
|
|
1456
1827
|
viewport.setGridHiddenLevels(hidden);
|
|
1457
|
-
syncGridVisibilityAction(); reflectToolbarState();
|
|
1828
|
+
syncGridVisibilityAction(); reflectToolbarState(); noteGridVisibilityChange();
|
|
1458
1829
|
return true;
|
|
1459
1830
|
},
|
|
1460
1831
|
panel: (tab) => tab === null || revitPanelHost.show(tab),
|
|
@@ -1464,6 +1835,14 @@ function mountPanels() {
|
|
|
1464
1835
|
});
|
|
1465
1836
|
}
|
|
1466
1837
|
|
|
1838
|
+
// Scope controls and their navigator subscription belong to the displayed revision.
|
|
1839
|
+
function refreshTeklaModelToolsForRevision() {
|
|
1840
|
+
if (!isTeklaParser || !sharedTools) return false;
|
|
1841
|
+
sharedTools.destroy(); sharedTools = null;
|
|
1842
|
+
mountSharedModelTools();
|
|
1843
|
+
return true;
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1467
1846
|
function mountSharedModelTools() {
|
|
1468
1847
|
const measureListeners = new Set(); const snapListeners = new Set();
|
|
1469
1848
|
const cleanup = []; let destroyed = false;
|
|
@@ -1504,23 +1883,25 @@ function mountSharedModelTools() {
|
|
|
1504
1883
|
let nextSelectionTools = null;
|
|
1505
1884
|
if (selectionPort && ['coordinator', 'hitsAt', 'allHits', 'marqueeHits', 'generationToken', 'registerInterceptor']
|
|
1506
1885
|
.every((name) => name === 'coordinator' ? selectionPort.coordinator : typeof selectionPort[name] === 'function')) {
|
|
1507
|
-
const decorate = (hits) => (Array.isArray(hits) ? hits : []).map((hit) => {
|
|
1508
|
-
const sourceId = hit?.entity?.sourceId ?? hit?.sourceId ?? hit?.providerToken;
|
|
1509
|
-
const entity = entityById.get(sourceId);
|
|
1510
|
-
return { ...hit, entity: { kind: hit?.entity?.kind ?? 'native', sourceId: String(sourceId) }, facets: {
|
|
1511
|
-
...(hit?.facets ?? {}), level: entity?.levelName ?? '', category: entity?.categoryName ?? entity?.category ?? '',
|
|
1512
|
-
family: entity?.familyName ?? entity?.family ?? '', type: entity?.typeName ?? '',
|
|
1513
|
-
} };
|
|
1514
|
-
}).filter((hit) => hit.entity.sourceId && hit.entity.sourceId !== 'undefined');
|
|
1515
1886
|
nextSelectionTools = createModelSelectionTools({
|
|
1516
1887
|
coordinator: selectionPort.coordinator,
|
|
1517
|
-
hitsAt: (pointer, event) =>
|
|
1518
|
-
allHits: () =>
|
|
1519
|
-
marqueeHits: (rect) =>
|
|
1888
|
+
hitsAt: (pointer, event) => decorateSelectionHits(selectionPort.hitsAt(pointer, event)),
|
|
1889
|
+
allHits: () => decorateSelectionHits(selectionPort.allHits()),
|
|
1890
|
+
marqueeHits: (rect) => decorateSelectionHits(selectionPort.marqueeHits(rect)),
|
|
1520
1891
|
generationToken: () => selectionPort.generationToken(),
|
|
1521
1892
|
fitSelection: () => facade.dispatch('model.fit-selection'),
|
|
1893
|
+
cancelActiveTool: () => isTeklaParser ? (teklaGroupNavigator?.ascend() ?? false) : false,
|
|
1522
1894
|
onHover: reflectSelectionHover,
|
|
1523
1895
|
onMarquee: reflectSelectionMarquee,
|
|
1896
|
+
onHierarchyDoubleClick: isTeklaParser ? (hit) => enterTeklaDrillFromPick(hit?.entity?.sourceId) : null,
|
|
1897
|
+
clearSelection: isTeklaParser ? () => teklaGroupNavigator?.clear() ?? selectionPort.coordinator.clear('mesh') : null,
|
|
1898
|
+
resolveSelection: isTeklaParser ? (hits, context) => {
|
|
1899
|
+
if (!hits.length || !teklaGroupNavigator) return false;
|
|
1900
|
+
const occurrences = hits.map((hit) => ({ entityId: hit?.entity?.sourceId, occurrencePath: hit?.occurrencePath ?? [hit?.entity?.sourceId] }));
|
|
1901
|
+
const outcome = resolveTeklaOccurrences(occurrences, { origin: context.origin, operation: context.operation,
|
|
1902
|
+
altAssembly: context.event?.altKey === true, eligibleHits: context.eligibleHits });
|
|
1903
|
+
return outcome.handled;
|
|
1904
|
+
} : null,
|
|
1524
1905
|
});
|
|
1525
1906
|
own(() => nextSelectionTools.destroy());
|
|
1526
1907
|
const releaseInput = selectionPort.registerInterceptor(nextSelectionTools.interceptor); if (releaseInput) own(releaseInput);
|
|
@@ -1528,12 +1909,18 @@ function mountSharedModelTools() {
|
|
|
1528
1909
|
}
|
|
1529
1910
|
const nextSelectionFilterChrome = nextSelectionTools ? mountRevitSelectionFilters(nextSelectionTools) : null;
|
|
1530
1911
|
if (nextSelectionFilterChrome) own(() => nextSelectionFilterChrome.destroy());
|
|
1912
|
+
const nextTeklaScopeChrome = isTeklaParser ? mountTeklaSelectionScopes() : null;
|
|
1913
|
+
if (nextTeklaScopeChrome) own(() => nextTeklaScopeChrome.destroy());
|
|
1531
1914
|
const subscribe = (set) => (listener) => { set.add(listener); let live = true; return () => { if (live) { live = false; set.delete(listener); } }; };
|
|
1532
1915
|
const dock = mountModelPointerDock({
|
|
1533
1916
|
selectionHost: $('modelSelectBar'), snapHost: $('modelSnapBar'), actionsHost: $('modelModuleActions'),
|
|
1534
|
-
plan: isTeklaParser ?
|
|
1917
|
+
plan: isTeklaParser ? teklaModelPointerDockPlan({
|
|
1918
|
+
connection: entities.some((entity) => entity.nativeKind === 'Component' || entity.nativeKind === 'Connection'),
|
|
1919
|
+
assembly: entities.some((entity) => entity.nativeKind === 'Assembly'),
|
|
1920
|
+
}) : REVIT_POINTER_DOCK_PLAN,
|
|
1535
1921
|
ports: {
|
|
1536
1922
|
selection: nextSelectionFilterChrome?.port,
|
|
1923
|
+
scope: nextTeklaScopeChrome?.port,
|
|
1537
1924
|
snap: {
|
|
1538
1925
|
getState: () => nextCadTools.snapState(), subscribe: subscribe(snapListeners),
|
|
1539
1926
|
toggle: (kind) => { const state = nextCadTools.snapState(); nextCadTools.setSnapMode(kind, state[kind] === false); },
|
|
@@ -1659,11 +2046,8 @@ async function boot() {
|
|
|
1659
2046
|
onSelect: (ids) => {
|
|
1660
2047
|
if (selectionOriginGuard.isProgrammatic()) return;
|
|
1661
2048
|
selectedIds = [...ids]; geometrySelectionIds = [...ids]; if (ids.length) clipSession?.clearSelection?.();
|
|
1662
|
-
if (isTeklaParser && ids.length === 1) {
|
|
1663
|
-
renderExplorerSearch('type', modelSearchQueries.get('type') || '', ids[0]);
|
|
1664
|
-
modelPanelBridge?.publishSnapshot();
|
|
1665
|
-
}
|
|
1666
2049
|
inspect(ids.at(-1) || null, false, true, 'viewport');
|
|
2050
|
+
if (isTeklaParser) synchronizeTeklaNavigatorSelection();
|
|
1667
2051
|
} });
|
|
1668
2052
|
facade = createReadOnlyModelEditorAdapter({ viewport, host: { openSavedViews } }); toolbarChrome = wireToolbar();
|
|
1669
2053
|
window.__revitEditorTest = { dispatchLog: () => facade.dispatchLog(), selected: () => selectedId, entityCount: () => entities.length,
|
|
@@ -1672,7 +2056,8 @@ async function boot() {
|
|
|
1672
2056
|
semantic: row.semantic ?? null, valueEncoding: row.valueEncoding ?? null })),
|
|
1673
2057
|
drawnIds: () => entities.filter((entity) => (entity.geometry || []).length).map((entity) => entity.id),
|
|
1674
2058
|
selectedIds: () => [...selectedIds],
|
|
1675
|
-
selectionState: () => ({ focusEntityId: selectedId, geometrySelectionIds: [...geometrySelectionIds]
|
|
2059
|
+
selectionState: () => ({ focusEntityId: selectedId, selectedIds: [...selectedIds], geometrySelectionIds: [...geometrySelectionIds],
|
|
2060
|
+
drillStack: teklaGroupNavigator?.state().drillStack.map((item) => ({ entityId: item.entityId, occurrencePath: [...item.occurrencePath] })) ?? [] }),
|
|
1676
2061
|
selectionCapabilities: () => selectionTools?.capabilities() ?? null, spatialState: () => spatialTools?.state() ?? null,
|
|
1677
2062
|
editorState: () => facade.getState(), presentation: () => viewport.presentationProbe(),
|
|
1678
2063
|
lighting: () => facade.lightingState(), gridLevels: () => viewport.gridLevels(),
|
|
@@ -1729,10 +2114,13 @@ installTooltips(document);
|
|
|
1729
2114
|
|
|
1730
2115
|
boot().catch((error) => {
|
|
1731
2116
|
if (terminalDisposed) return;
|
|
1732
|
-
|
|
1733
|
-
|
|
2117
|
+
const failure = modelFailureCopy(error?.body);
|
|
2118
|
+
// A module refusal the server explained is a state the page shows, not a fault. Anything else stays an error for
|
|
2119
|
+
// diagnostics: a read failure (even one with its own sentence), and a refusal that came without one, a gap in copy.
|
|
2120
|
+
if (failure?.refused) console.warn('[model] the server refused this model:', error.message); else console.error(error);
|
|
2121
|
+
modelPanelBridge?.failed(failure?.body ?? modelUnavailableCopy());
|
|
1734
2122
|
// A failed session fetch, project read, or first revision load is terminal for this editor instance.
|
|
1735
2123
|
// Release the provider renderer and both shared mini-renderers instead of waiting for page navigation.
|
|
1736
2124
|
disposeEditor();
|
|
1737
|
-
fail();
|
|
2125
|
+
fail(failure);
|
|
1738
2126
|
});
|