@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
|
@@ -38,7 +38,20 @@ export function createModelSelectionOriginGuard() {
|
|
|
38
38
|
|
|
39
39
|
export function serializeModelPanelNodes(host, path = 'root') {
|
|
40
40
|
const nodes = [];
|
|
41
|
+
const occurrencePath = (row) => {
|
|
42
|
+
if (!row?.dataset?.occurrencePath) return null;
|
|
43
|
+
try {
|
|
44
|
+
const value = JSON.parse(row.dataset.occurrencePath);
|
|
45
|
+
return Array.isArray(value) && value.length && value.every((id) => typeof id === 'string') ? value : null;
|
|
46
|
+
} catch { return null; }
|
|
47
|
+
};
|
|
48
|
+
const objectFields = (row) => row?.classList.contains('model-object-row')
|
|
49
|
+
? Object.fromEntries(['name', 'profile', 'id'].map((key) => [key, row.querySelector(`[data-object-field="${key}"]`)?.textContent ?? null]))
|
|
50
|
+
: null;
|
|
41
51
|
for (const [index, child] of [...(host?.children || [])].entries()) {
|
|
52
|
+
if (child.classList.contains('explorer-load-more')) {
|
|
53
|
+
nodes.push({ kind: 'more', label: child.textContent || 'Load more', pageKey: child.dataset.pageKey || null }); continue;
|
|
54
|
+
}
|
|
42
55
|
if (child.classList.contains('revit-explorer-label')) { nodes.push({ kind: 'label', label: child.textContent || '' }); continue; }
|
|
43
56
|
if (child.classList.contains('explorer-empty')) { nodes.push({ kind: 'note', label: child.textContent || '' }); continue; }
|
|
44
57
|
if (child.classList.contains('revit-tree-branch')) {
|
|
@@ -49,6 +62,9 @@ export function serializeModelPanelNodes(host, path = 'root') {
|
|
|
49
62
|
nodes.push({ label: trigger.querySelector('.row-label')?.textContent || trigger.textContent || '',
|
|
50
63
|
count: trigger.querySelector('.explorer-count')?.textContent || null, children,
|
|
51
64
|
tip: trigger.dataset.tip || null,
|
|
65
|
+
...(trigger.dataset.entityId ? { entityId: trigger.dataset.entityId } : {}),
|
|
66
|
+
...(occurrencePath(trigger) ? { occurrencePath: occurrencePath(trigger) } : {}),
|
|
67
|
+
...(objectFields(trigger) ? { objectFields: objectFields(trigger) } : {}),
|
|
52
68
|
...(trigger.dataset.selectable === 'true' ? { selectable: true } : {}),
|
|
53
69
|
lazy: !children.length && Number(trigger.querySelector('.explorer-count')?.textContent || 0) > 0,
|
|
54
70
|
expanded: trigger.getAttribute('aria-expanded') === 'true', groupId: `${path}.${index}` });
|
|
@@ -57,7 +73,8 @@ export function serializeModelPanelNodes(host, path = 'root') {
|
|
|
57
73
|
}
|
|
58
74
|
if (child.classList.contains('explorer-row')) nodes.push({ label: child.querySelector('.row-label')?.textContent ?? child.textContent ?? '',
|
|
59
75
|
count: child.querySelector('.explorer-count')?.textContent || null, entityId: child.dataset.entityId || null,
|
|
60
|
-
...(child
|
|
76
|
+
...(occurrencePath(child) ? { occurrencePath: occurrencePath(child) } : {}),
|
|
77
|
+
...(objectFields(child) ? { objectFields: objectFields(child) } : {}),
|
|
61
78
|
tip: child.dataset.tip || null });
|
|
62
79
|
}
|
|
63
80
|
return nodes;
|
|
@@ -76,7 +93,10 @@ export function expandModelPanelGroup(tabs, byId, groupId) {
|
|
|
76
93
|
const trigger = branch.querySelector(':scope > .explorer-row');
|
|
77
94
|
const children = branch.querySelector(':scope > .revit-tree-children');
|
|
78
95
|
if (!trigger || !children) return false;
|
|
79
|
-
if (!children.children.length)
|
|
96
|
+
if (!children.children.length) {
|
|
97
|
+
if (typeof trigger.__toggleTreeItem === 'function') trigger.__toggleTreeItem(true);
|
|
98
|
+
else trigger.click();
|
|
99
|
+
}
|
|
80
100
|
host = children;
|
|
81
101
|
}
|
|
82
102
|
return true;
|
|
@@ -171,7 +191,8 @@ export function createPanelHost({ win = window, root, bodies, install = (_doc) =
|
|
|
171
191
|
|
|
172
192
|
export function createModelPanelBridge({ win = window, origin = location.origin, snapshot, selectedId, selectedIds = () => {
|
|
173
193
|
const id = selectedId(); return typeof id === 'string' ? [id] : [];
|
|
174
|
-
}, select, expand, selectGroup = (_groupId) => false, search = (_tab, _query) => false,
|
|
194
|
+
}, select, expand, drill = (_entityId, _occurrencePath) => false, ascend = () => false, clearSelection = () => false, selectGroup = (_groupId) => false, search = (_tab, _query) => false,
|
|
195
|
+
loadMore = (_pageKey) => false,
|
|
175
196
|
selectionState = () => ({}), panel = (_tab, _person, _follow) => false,
|
|
176
197
|
gridVisibility = (_action) => false, selectedSubjects = () => null, chatLinksChanged = null, view = /** @type {((command: any, target: any) => any) | null} */ (null) }) {
|
|
177
198
|
let requested = false;
|
|
@@ -189,7 +210,7 @@ gridVisibility = (_action) => false, selectedSubjects = () => null, chatLinksCha
|
|
|
189
210
|
const publishStatus = (message = '') => send({ type: 'status', state: lifecycle, message });
|
|
190
211
|
const publishSnapshot = () => {
|
|
191
212
|
if (lifecycle !== 'ready') return false;
|
|
192
|
-
return send({ type: 'snapshot', snapshot: { ...snapshot(), subjects: selectedSubjects(), datasetKey } });
|
|
213
|
+
return send({ type: 'snapshot', snapshot: { ...snapshot(), subjects: selectedSubjects(), datasetKey, ...selectionState() } });
|
|
193
214
|
};
|
|
194
215
|
// `subjects` is the selection as model objects a chat message may be about (#1653): {source, revision, total,
|
|
195
216
|
// items: [{kind, id, label}]}, or null. Raw selected ids stay beside it for the tree's own rows.
|
|
@@ -219,7 +240,13 @@ gridVisibility = (_action) => false, selectedSubjects = () => null, chatLinksCha
|
|
|
219
240
|
let ok = false;
|
|
220
241
|
// entityId is the row clicked; entityIds what the click selects (a Ctrl/Shift click: more rows, or none left).
|
|
221
242
|
const ids = Array.isArray(data.entityIds) ? data.entityIds.filter((id) => typeof id === 'string') : [data.entityId];
|
|
222
|
-
|
|
243
|
+
const validOccurrence = (value) => value && typeof value.entityId === 'string' && Array.isArray(value.occurrencePath)
|
|
244
|
+
&& value.occurrencePath.length > 0 && value.occurrencePath.every((id) => typeof id === 'string')
|
|
245
|
+
&& value.occurrencePath.at(-1) === value.entityId;
|
|
246
|
+
const occurrences = Array.isArray(data.occurrences) ? data.occurrences.filter(validOccurrence)
|
|
247
|
+
: (validOccurrence(data.occurrence) ? [data.occurrence] : []);
|
|
248
|
+
const operation = ['replace', 'add', 'toggle'].includes(data.operation) ? data.operation : 'replace';
|
|
249
|
+
try { ok = !!select(data.entityId, ids, { operation, occurrences }); if (ok) publishSnapshot(); publishSelection('tree'); }
|
|
223
250
|
catch (error) { try { win.console?.error?.('[model-panel] select action failed', error); } catch { /* reporting must still continue */ } }
|
|
224
251
|
actionResult(data.requestId, ok, ok ? '' : 'That object is no longer in this model revision.');
|
|
225
252
|
return;
|
|
@@ -231,6 +258,37 @@ gridVisibility = (_action) => false, selectedSubjects = () => null, chatLinksCha
|
|
|
231
258
|
actionResult(data.requestId, ok, ok ? '' : 'That model group has changed. Try opening it again.');
|
|
232
259
|
return;
|
|
233
260
|
}
|
|
261
|
+
if (data.action === 'drill' && typeof data.entityId === 'string') {
|
|
262
|
+
let ok = false;
|
|
263
|
+
const occurrencePath = Array.isArray(data.occurrencePath) && data.occurrencePath.length > 0
|
|
264
|
+
&& data.occurrencePath.every((id) => typeof id === 'string') && data.occurrencePath.at(-1) === data.entityId
|
|
265
|
+
? data.occurrencePath : null;
|
|
266
|
+
try { ok = data.datasetKey === datasetKey && !!drill(data.entityId, occurrencePath); if (ok) publishSnapshot(); }
|
|
267
|
+
catch (error) { try { win.console?.error?.('[model-panel] drill action failed', error); } catch { /* reporting must still continue */ } ok = false; }
|
|
268
|
+
actionResult(data.requestId, ok, ok ? '' : 'That model group has changed. Try entering it again.');
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (data.action === 'load-more' && typeof data.pageKey === 'string') {
|
|
272
|
+
let ok = false;
|
|
273
|
+
try { ok = data.datasetKey === datasetKey && !!loadMore(data.pageKey); if (ok) publishSnapshot(); }
|
|
274
|
+
catch (error) { try { win.console?.error?.('[model-panel] load-more action failed', error); } catch { /* reporting must still continue */ } ok = false; }
|
|
275
|
+
actionResult(data.requestId, ok, ok ? '' : 'That part of the model index has changed. Try loading it again.');
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
if (data.action === 'ascend') {
|
|
279
|
+
let ok = false;
|
|
280
|
+
try { ok = data.datasetKey === datasetKey && !!ascend(); if (ok) publishSnapshot(); }
|
|
281
|
+
catch (error) { try { win.console?.error?.('[model-panel] ascend action failed', error); } catch { /* reporting must still continue */ } ok = false; }
|
|
282
|
+
actionResult(data.requestId, ok, ok ? '' : 'There is no parent group to return to.');
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
if (data.action === 'clear-selection') {
|
|
286
|
+
let ok = false;
|
|
287
|
+
try { ok = data.datasetKey === datasetKey && !!clearSelection(); if (ok) publishSnapshot(); publishSelection('tree'); }
|
|
288
|
+
catch (error) { try { win.console?.error?.('[model-panel] clear selection action failed', error); } catch { /* reporting must still continue */ } ok = false; }
|
|
289
|
+
actionResult(data.requestId, ok, ok ? '' : 'The selection has already been cleared.');
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
234
292
|
if (data.action === 'select-group' && typeof data.groupId === 'string') {
|
|
235
293
|
let ok = false;
|
|
236
294
|
try { ok = data.datasetKey === datasetKey && !!selectGroup(data.groupId); if (ok) { publishSnapshot(); publishSelection('tree'); } }
|
|
@@ -14,6 +14,8 @@ const REFERENCE_ICON = '<svg viewBox="0 0 18 18" fill="none" stroke="currentColo
|
|
|
14
14
|
const CATEGORY_ICON = '<svg viewBox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><rect x="2.5" y="2.5" width="5" height="5" rx="1"/><rect x="10.5" y="2.5" width="5" height="5" rx="1"/><rect x="2.5" y="10.5" width="5" height="5" rx="1"/><rect x="10.5" y="10.5" width="5" height="5" rx="1"/></svg>';
|
|
15
15
|
const TYPE_ICON = '<svg viewBox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" aria-hidden="true"><path d="M3 4h12M5 9h8M7 14h4"/></svg>';
|
|
16
16
|
const CLASS_ICON = '<svg viewBox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round" aria-hidden="true"><path d="M9 2.5l6 3.2v6.6L9 15.5l-6-3.2V5.7L9 2.5Z"/><path d="M3 5.7L9 9l6-3.3M9 9v6.5"/></svg>';
|
|
17
|
+
const GROUP_ICON = '<svg viewBox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><rect x="3" y="3" width="12" height="12" rx="2"/><path d="M6 6h6v6H6z"/></svg>';
|
|
18
|
+
const OBJECTS_ICON = '<svg viewBox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><rect x="2.5" y="2.5" width="5" height="5" rx="1"/><rect x="10.5" y="2.5" width="5" height="5" rx="1"/><rect x="6.5" y="10.5" width="5" height="5" rx="1"/></svg>';
|
|
17
19
|
|
|
18
20
|
const frozen = (value) => Object.freeze(value);
|
|
19
21
|
const selection = (id, command, carrier, label, tip, icon, extra = {}) => frozen({ id, command, carrier, label, tip, icon, ...extra });
|
|
@@ -80,17 +82,42 @@ export function readOnlyModelPointerDockPlan(commandPrefix = 'revit', sourceLabe
|
|
|
80
82
|
});
|
|
81
83
|
}
|
|
82
84
|
|
|
85
|
+
/** Tekla mirrors the native Component/Object and Assembly/Object selection granularity controls. */
|
|
86
|
+
export function teklaModelPointerDockPlan({ connection = true, assembly = true } = {}) {
|
|
87
|
+
const base = readOnlyModelPointerDockPlan('tekla-parser', 'Tekla');
|
|
88
|
+
const scopeItem = (axis, value, command, carrier, label, shortLabel, tip, icon) => frozen({ axis, value, command,
|
|
89
|
+
carrier, label, shortLabel, tip, icon });
|
|
90
|
+
return frozen({
|
|
91
|
+
...base,
|
|
92
|
+
ascend: frozen({ command: 'tekla-parser.hierarchy-ascend', carrier: 'data-command-id="tekla-parser.hierarchy-ascend"',
|
|
93
|
+
label: 'Leave group', tip: 'Leave the current Connection or Assembly drill-down (Esc)' }),
|
|
94
|
+
selection: frozen(base.selection.filter((item) => item.id === 'type')),
|
|
95
|
+
scopeGroups: frozen([
|
|
96
|
+
frozen({ axis: 'connection', label: 'Connection selection scope', items: frozen([
|
|
97
|
+
scopeItem('connection', 'group', 'tekla-parser.connection-scope-group', 'data-command-id="tekla-parser.connection-scope-group"', 'Select Connections as groups', 'Conn', 'Connection scope — select the Connection as one logical object', GROUP_ICON),
|
|
98
|
+
scopeItem('connection', 'objects', 'tekla-parser.connection-scope-objects', 'data-command-id="tekla-parser.connection-scope-objects"', 'Select objects inside Connections', 'Obj', 'Connection scope — select its descendant objects individually', OBJECTS_ICON),
|
|
99
|
+
]) }),
|
|
100
|
+
frozen({ axis: 'assembly', label: 'Assembly selection scope', items: frozen([
|
|
101
|
+
scopeItem('assembly', 'group', 'tekla-parser.assembly-scope-group', 'data-command-id="tekla-parser.assembly-scope-group"', 'Select Assemblies as groups', 'Asm', 'Assembly scope — select the Assembly as one logical object', GROUP_ICON),
|
|
102
|
+
scopeItem('assembly', 'objects', 'tekla-parser.assembly-scope-objects', 'data-command-id="tekla-parser.assembly-scope-objects"', 'Select objects inside Assemblies', 'Obj', 'Assembly scope — select its descendant objects individually', OBJECTS_ICON),
|
|
103
|
+
]) }),
|
|
104
|
+
].filter((group) => group.axis === 'connection' ? connection : assembly)),
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
83
108
|
function escapeAttr(value) {
|
|
84
109
|
return String(value ?? '').replaceAll('&', '&').replaceAll('"', '"').replaceAll('<', '<').replaceAll('>', '>');
|
|
85
110
|
}
|
|
86
111
|
|
|
87
112
|
export function pointerDockCarriers(plan) {
|
|
88
|
-
return [...(plan.selection ?? []), ...(plan.snaps ?? []), ...(plan.actions ?? [])].map((item) => item.command).filter(Boolean);
|
|
113
|
+
return [...(plan.scopeGroups ?? []).flatMap((group) => group.items ?? []), ...(plan.ascend ? [plan.ascend] : []), ...(plan.selection ?? []), ...(plan.snaps ?? []), ...(plan.actions ?? [])].map((item) => item.command).filter(Boolean);
|
|
89
114
|
}
|
|
90
115
|
|
|
91
116
|
export function renderSelectionBarMarkup(plan) {
|
|
92
|
-
if (!plan.selection?.length) return '';
|
|
93
|
-
|
|
117
|
+
if (!plan.selection?.length && !plan.scopeGroups?.length) return '';
|
|
118
|
+
const scopes = (plan.scopeGroups ?? []).map((group) => `<span class="model-selection-scope" role="group" aria-label="${escapeAttr(group.label)}">${(group.items ?? []).map((item) => `<button type="button" ${item.carrier} data-selection-scope-axis="${escapeAttr(item.axis)}" data-selection-scope-value="${escapeAttr(item.value)}" aria-label="${escapeAttr(item.label)}" data-tip="${escapeAttr(item.tip)}" aria-pressed="false" tabindex="-1">${item.icon ?? ''}<span class="model-scope-short" aria-hidden="true">${escapeAttr(item.shortLabel)}</span></button>`).join('')}</span>`).join('');
|
|
119
|
+
const status = plan.scopeGroups?.length ? `<span class="model-scope-status" role="status" aria-live="polite"></span>${plan.ascend ? `<button type="button" class="model-scope-ascend" ${plan.ascend.carrier} data-tip="${escapeAttr(plan.ascend.tip)}" hidden>${escapeAttr(plan.ascend.label)}</button>` : ''}` : '';
|
|
120
|
+
return '<span class="lbl">Select</span>' + scopes + status + plan.selection.map((item) => {
|
|
94
121
|
const fly = item.fly ? ` data-fly="${escapeAttr(item.fly)}"` : '';
|
|
95
122
|
const caret = item.caret ? '<span class="car" aria-hidden="true">▾</span>' : '';
|
|
96
123
|
return `<button type="button" ${item.carrier} data-cls="${escapeAttr(item.id)}"${fly} aria-label="${escapeAttr(item.label)}" data-tip="${escapeAttr(item.tip)}">${item.icon ?? ''}${caret}</button>`;
|
|
@@ -119,7 +146,7 @@ function validatePort(port, name) {
|
|
|
119
146
|
/** Render and optionally wire the shared pointer chrome. Provider ports remain the only state owners. */
|
|
120
147
|
export function mountModelPointerDock({ selectionHost = null, snapHost = null, actionsHost = null, plan, ports = {} }) {
|
|
121
148
|
if (!plan || plan.schema !== 'floless.model-pointer-dock/v1') throw new Error('Unsupported model pointer-dock plan.');
|
|
122
|
-
validatePort(ports.selection, 'selection'); validatePort(ports.snap, 'snap'); validatePort(ports.measure, 'measure');
|
|
149
|
+
validatePort(ports.selection, 'selection'); validatePort(ports.scope, 'scope'); validatePort(ports.snap, 'snap'); validatePort(ports.measure, 'measure');
|
|
123
150
|
const cleanup = []; let destroyed = false;
|
|
124
151
|
const listen = (node, type, handler) => { node.addEventListener(type, handler); cleanup.push(() => node.removeEventListener(type, handler)); };
|
|
125
152
|
try {
|
|
@@ -137,6 +164,15 @@ export function mountModelPointerDock({ selectionHost = null, snapHost = null, a
|
|
|
137
164
|
else if (!partial) dot?.remove();
|
|
138
165
|
});
|
|
139
166
|
};
|
|
167
|
+
const reflectScope = (state = ports.scope?.getState?.() ?? {}) => {
|
|
168
|
+
selectionHost?.querySelectorAll('[data-selection-scope-axis]').forEach((button) => {
|
|
169
|
+
const pressed = state[button.dataset.selectionScopeAxis] === button.dataset.selectionScopeValue;
|
|
170
|
+
button.classList.toggle('on', pressed); button.setAttribute('aria-pressed', String(pressed)); button.tabIndex = pressed ? 0 : -1;
|
|
171
|
+
});
|
|
172
|
+
const status = selectionHost?.querySelector('.model-scope-status');
|
|
173
|
+
if (status) { const text = state.drillOverride ? 'Inside group: selecting individual objects' : ''; if (status.textContent !== text) status.textContent = text; }
|
|
174
|
+
const ascend = selectionHost?.querySelector('.model-scope-ascend'); if (ascend) ascend.hidden = state.drillOverride !== true;
|
|
175
|
+
};
|
|
140
176
|
const reflectSnap = (state = ports.snap?.getState?.() ?? {}) => {
|
|
141
177
|
snapHost?.querySelectorAll('[data-snap],[data-snap3d]').forEach((button) => { const key = button.dataset.snap ?? '3d'; const on = state[key] !== false; button.classList.toggle('on', on); button.setAttribute('aria-pressed', String(on)); });
|
|
142
178
|
};
|
|
@@ -171,12 +207,26 @@ export function mountModelPointerDock({ selectionHost = null, snapHost = null, a
|
|
|
171
207
|
});
|
|
172
208
|
listen(button, 'keydown', (event) => { if ((event.key === 'Enter' || event.key === ' ') && !event.repeat) { event.preventDefault(); event.stopPropagation(); ports.selection?.toggle?.(button.dataset.cls, event); } });
|
|
173
209
|
});
|
|
210
|
+
selectionHost?.querySelectorAll('[data-selection-scope-axis]').forEach((button) => {
|
|
211
|
+
const choose = () => ports.scope?.set?.(button.dataset.selectionScopeAxis, button.dataset.selectionScopeValue);
|
|
212
|
+
listen(button, 'click', choose);
|
|
213
|
+
listen(button, 'keydown', (event) => {
|
|
214
|
+
if (event.key === 'Enter' || event.key === ' ') { if (!event.repeat) choose(); event.preventDefault(); event.stopPropagation(); return; }
|
|
215
|
+
if (!['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(event.key)) return;
|
|
216
|
+
const group = button.closest('[data-selection-scope-axis]')?.parentElement;
|
|
217
|
+
const items = [...(group?.querySelectorAll('[data-selection-scope-axis]') ?? [])];
|
|
218
|
+
const delta = event.key === 'ArrowLeft' || event.key === 'ArrowUp' ? -1 : 1;
|
|
219
|
+
const next = items[(items.indexOf(button) + delta + items.length) % items.length];
|
|
220
|
+
ports.scope?.set?.(next.dataset.selectionScopeAxis, next.dataset.selectionScopeValue); next.focus(); event.preventDefault(); event.stopPropagation();
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
const ascend = selectionHost?.querySelector('.model-scope-ascend'); if (ascend) listen(ascend, 'click', () => ports.scope?.ascend?.());
|
|
174
224
|
snapHost?.querySelectorAll('[data-snap],[data-snap3d]').forEach((button) => listen(button, 'click', () => ports.snap?.toggle?.(button.dataset.snap ?? '3d')));
|
|
175
225
|
const measure = actionsHost?.querySelector('[data-model-action="measure"]'); if (measure) listen(measure, 'click', () => ports.measure?.toggle?.());
|
|
176
226
|
actionsHost?.querySelectorAll('[data-model-axis]').forEach((button) => listen(button, 'click', () => ports.measure?.setAxisLock?.(button.dataset.modelAxis)));
|
|
177
227
|
const clear = actionsHost?.querySelector('[data-model-action="clear"]'); if (clear) listen(clear, 'click', () => ports.measure?.clear?.());
|
|
178
228
|
|
|
179
|
-
for (const [port, reflect] of [[ports.selection, reflectSelection], [ports.snap, reflectSnap], [ports.measure, reflectMeasure]]) {
|
|
229
|
+
for (const [port, reflect] of [[ports.selection, reflectSelection], [ports.scope, reflectScope], [ports.snap, reflectSnap], [ports.measure, reflectMeasure]]) {
|
|
180
230
|
if (!port) continue; reflect(port.getState()); const unsub = port.subscribe(reflect); if (typeof unsub === 'function') cleanup.push(unsub);
|
|
181
231
|
}
|
|
182
232
|
} catch (error) {
|
|
@@ -133,6 +133,21 @@ export function teklaNoSnapshotCopy(state) {
|
|
|
133
133
|
};
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* #2355: copy for a failed request whose answer carries a sentence written for a person (`userMessage`,
|
|
138
|
+
* which the server sets only from copy authored for people: its module-refusal table, and a few read
|
|
139
|
+
* failures), or null, which keeps the generic "could not be opened" copy. The sentence is shown as the
|
|
140
|
+
* server wrote it, under a title that names no cause, so the page never guesses one. `refused` marks a
|
|
141
|
+
* module refusal (the code is `model_module_unavailable`: in `error` on the Revit route, `code` on the
|
|
142
|
+
* Tekla one), which is a state the page shows rather than a fault.
|
|
143
|
+
*/
|
|
144
|
+
export function modelFailureCopy(body) {
|
|
145
|
+
const sentence = typeof body?.userMessage === 'string' ? body.userMessage.trim() : '';
|
|
146
|
+
if (!sentence) return null;
|
|
147
|
+
const refused = body.error === 'model_module_unavailable' || body.code === 'model_module_unavailable';
|
|
148
|
+
return { kind: refused ? 'refused' : 'unavailable', title: 'Model unavailable', body: sentence, refused };
|
|
149
|
+
}
|
|
150
|
+
|
|
136
151
|
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
137
152
|
/**
|
|
138
153
|
* Render the no-model state into the viewport's status overlay: a muted outline cube, a title and
|
|
@@ -99,6 +99,8 @@ export function modelSelectionHitsInMarquee(hits, rect) {
|
|
|
99
99
|
function prevent(event) { event?.preventDefault?.(); }
|
|
100
100
|
function pointer(event) { return { x: Number(event?.clientX), y: Number(event?.clientY) }; }
|
|
101
101
|
function toggles(event) { return event?.ctrlKey === true || event?.metaKey === true || event?.shiftKey === true; }
|
|
102
|
+
function selectionOperation(event) { return event?.ctrlKey === true || event?.metaKey === true ? 'toggle' : event?.shiftKey === true ? 'add' : 'replace'; }
|
|
103
|
+
function conflictingModifiers(event) { return (event?.ctrlKey === true || event?.metaKey === true) && event?.shiftKey === true; }
|
|
102
104
|
|
|
103
105
|
/**
|
|
104
106
|
* @param {{
|
|
@@ -113,6 +115,9 @@ function toggles(event) { return event?.ctrlKey === true || event?.metaKey === t
|
|
|
113
115
|
* filterHit?: (hit: any, filters: any) => boolean,
|
|
114
116
|
* generationToken?: () => any,
|
|
115
117
|
* hierarchy?: null|((direction: string, entries: any[]) => any[]),
|
|
118
|
+
* resolveSelection?: null|((hits:any[], context:{event:any,origin:string,operation:string,eligibleHits:(hits:any[])=>any[]})=>boolean),
|
|
119
|
+
* onHierarchyDoubleClick?: null|((hit:any, context:{event:any,origin:string})=>boolean),
|
|
120
|
+
* clearSelection?: null|((origin:string)=>any),
|
|
116
121
|
* initialFilters?: Record<string, any>,
|
|
117
122
|
* dragThreshold?: number,
|
|
118
123
|
* cycleRadius?: number,
|
|
@@ -130,17 +135,23 @@ export function createModelSelectionTools({
|
|
|
130
135
|
filterHit = () => true,
|
|
131
136
|
generationToken = () => null,
|
|
132
137
|
hierarchy = null,
|
|
138
|
+
resolveSelection = null,
|
|
139
|
+
onHierarchyDoubleClick = null,
|
|
140
|
+
clearSelection = null,
|
|
133
141
|
initialFilters = {},
|
|
134
142
|
dragThreshold = 5,
|
|
135
143
|
cycleRadius = 3,
|
|
136
144
|
} = {}) {
|
|
137
|
-
if (!coordinator || !['replaceAll', 'toggle', 'clear', 'entries'].every((name) => typeof coordinator[name] === 'function')) {
|
|
145
|
+
if (!coordinator || !['replaceAll', 'add', 'toggle', 'clear', 'entries'].every((name) => typeof coordinator[name] === 'function')) {
|
|
138
146
|
throw new Error('Model selection tools need a model-selection-coordinator.');
|
|
139
147
|
}
|
|
140
148
|
for (const [name, value] of Object.entries({ hitsAt, allHits, onHover, onMarquee, fitSelection, cancelActiveTool, filterHit, generationToken })) {
|
|
141
149
|
if (typeof value !== 'function') throw new TypeError(`Model selection tools: ${name} must be a function.`);
|
|
142
150
|
}
|
|
143
151
|
if (marqueeHits !== null && typeof marqueeHits !== 'function') throw new TypeError('Model selection tools: marqueeHits must be a function or null.');
|
|
152
|
+
if (resolveSelection !== null && typeof resolveSelection !== 'function') throw new TypeError('Model selection tools: resolveSelection must be a function or null.');
|
|
153
|
+
if (onHierarchyDoubleClick !== null && typeof onHierarchyDoubleClick !== 'function') throw new TypeError('Model selection tools: onHierarchyDoubleClick must be a function or null.');
|
|
154
|
+
if (clearSelection !== null && typeof clearSelection !== 'function') throw new TypeError('Model selection tools: clearSelection must be a function or null.');
|
|
144
155
|
if (!finite(dragThreshold) || dragThreshold < 0 || !finite(cycleRadius) || cycleRadius < 0) throw new TypeError('Model selection thresholds must be non-negative.');
|
|
145
156
|
|
|
146
157
|
let filters = normalizeFacetFilters(initialFilters);
|
|
@@ -148,12 +159,22 @@ export function createModelSelectionTools({
|
|
|
148
159
|
const filterListeners = new Set();
|
|
149
160
|
const notifyFilters = () => { const state = filters; for (const listener of filterListeners) listener(state); };
|
|
150
161
|
const candidates = (hits) => selectableHits(hits, filters, generationToken, filterHit);
|
|
162
|
+
const semanticCandidates = (hits) => resolveSelection
|
|
163
|
+
? selectableHits(hits, {}, generationToken, () => true)
|
|
164
|
+
: candidates(hits);
|
|
151
165
|
const at = (event) => visibleHits(hitsAt(pointer(event), event));
|
|
152
166
|
const sameEntity = (a, b) => a?.kind === b?.kind && a?.sourceId === b?.sourceId;
|
|
153
167
|
const isSelected = (entity) => coordinator.entries().some((entry) => sameEntity(entry, entity));
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
168
|
+
const clear = clearSelection ?? ((origin) => coordinator.clear(origin));
|
|
169
|
+
const commitHits = (hits, event, origin, operation = selectionOperation(event)) => {
|
|
170
|
+
if (resolveSelection?.(hits, { event, origin, operation, eligibleHits: candidates }) === true) return true;
|
|
171
|
+
const eligible = candidates(hits);
|
|
172
|
+
if (!eligible.length) return false;
|
|
173
|
+
const entities = eligible.map(entityOf);
|
|
174
|
+
if (operation === 'toggle') coordinator.toggle(entities, origin);
|
|
175
|
+
else if (operation === 'add') coordinator.add(entities, origin);
|
|
176
|
+
else coordinator.replaceAll(entities, origin);
|
|
177
|
+
return true;
|
|
157
178
|
};
|
|
158
179
|
const setHover = (next) => {
|
|
159
180
|
if (hover === next) return;
|
|
@@ -163,22 +184,25 @@ export function createModelSelectionTools({
|
|
|
163
184
|
const resetCycle = () => { cycle = null; };
|
|
164
185
|
|
|
165
186
|
const chooseAt = (event) => {
|
|
166
|
-
const raw = at(event); const eligible =
|
|
187
|
+
const raw = at(event); const eligible = semanticCandidates(raw);
|
|
167
188
|
if (!eligible.length) {
|
|
168
189
|
resetCycle();
|
|
169
|
-
if (!raw.length && !toggles(event))
|
|
190
|
+
if (!raw.length && !toggles(event)) clear('mesh');
|
|
170
191
|
return frozen({ handled: true, rawVisible: raw.length, selected: null });
|
|
171
192
|
}
|
|
172
193
|
const p = pointer(event); const fingerprint = eligible.map(entityToken).join('|');
|
|
173
194
|
const continuing = cycle && cycle.fingerprint === fingerprint && Math.hypot(p.x - cycle.x, p.y - cycle.y) <= cycleRadius;
|
|
174
195
|
const index = continuing ? (cycle.index + 1) % eligible.length : 0;
|
|
175
196
|
const hit = eligible[index]; cycle = { fingerprint, x: p.x, y: p.y, index };
|
|
176
|
-
|
|
197
|
+
commitHits([hit], event, 'mesh');
|
|
177
198
|
return frozen({ handled: true, rawVisible: raw.length, selected: hit, overlapIndex: index, overlapCount: eligible.length });
|
|
178
199
|
};
|
|
179
200
|
|
|
180
201
|
const finishMarquee = (event) => {
|
|
181
202
|
if (!gesture?.active) return false;
|
|
203
|
+
if (event?.altKey === true || conflictingModifiers(event)) {
|
|
204
|
+
gesture = null; suppressClick = true; onMarquee(null); resetCycle(); prevent(event); return true;
|
|
205
|
+
}
|
|
182
206
|
const rect = marqueeRect(gesture.start, pointer(event));
|
|
183
207
|
// Providers may pre-query candidates, but the common layer remains the authority for LTR/RTL
|
|
184
208
|
// geometry whenever projected bounds are present. A returned record without bounds is already
|
|
@@ -187,15 +211,16 @@ export function createModelSelectionTools({
|
|
|
187
211
|
const raw = reported
|
|
188
212
|
? reported.filter((hit) => !screenBounds(hit) || modelSelectionHitsInMarquee([hit], rect).length === 1)
|
|
189
213
|
: modelSelectionHitsInMarquee(allHits(), rect);
|
|
190
|
-
const eligible =
|
|
191
|
-
if (eligible.length)
|
|
192
|
-
else if (!raw.length && !toggles(event))
|
|
214
|
+
const eligible = semanticCandidates(raw);
|
|
215
|
+
if (eligible.length) commitHits(eligible, event, 'mesh');
|
|
216
|
+
else if (!raw.length && !toggles(event)) clear('mesh');
|
|
193
217
|
gesture = null; suppressClick = true; onMarquee(null); resetCycle(); prevent(event); return true;
|
|
194
218
|
};
|
|
195
219
|
|
|
196
220
|
const interceptor = frozen({
|
|
197
221
|
pointerDown(event) {
|
|
198
222
|
if (destroyed || event.defaultPrevented || event.button !== 0) return false;
|
|
223
|
+
if (event.altKey === true) return false;
|
|
199
224
|
const p = pointer(event); if (!finite(p.x) || !finite(p.y)) return false;
|
|
200
225
|
// If the preceding drag released outside the surface, the browser emitted no click to consume
|
|
201
226
|
// suppression. A genuinely new pointer sequence must never lose its eventual click.
|
|
@@ -211,7 +236,7 @@ export function createModelSelectionTools({
|
|
|
211
236
|
if (!gesture.active && Math.hypot(p.x - gesture.start.x, p.y - gesture.start.y) > dragThreshold) gesture.active = true;
|
|
212
237
|
if (gesture.active) { onMarquee(marqueeRect(gesture.start, p)); prevent(event); return true; }
|
|
213
238
|
}
|
|
214
|
-
setHover(
|
|
239
|
+
setHover(semanticCandidates(at(event))[0] ?? null); return false;
|
|
215
240
|
},
|
|
216
241
|
pointerLeave() { if (!gesture?.active) setHover(null); return false; },
|
|
217
242
|
pointerCancel(event) {
|
|
@@ -229,27 +254,37 @@ export function createModelSelectionTools({
|
|
|
229
254
|
if (suppressClick) { suppressClick = false; prevent(event); return true; }
|
|
230
255
|
gesture = null;
|
|
231
256
|
if (Number(event.detail) > 1) { prevent(event); return true; }
|
|
257
|
+
if (conflictingModifiers(event)) { prevent(event); resetCycle(); return true; }
|
|
258
|
+
if (event.altKey === true && (event.ctrlKey === true || event.metaKey === true || event.shiftKey === true)) return false;
|
|
232
259
|
const result = chooseAt(event); prevent(event); return result;
|
|
233
260
|
},
|
|
234
261
|
doubleClick(event) {
|
|
235
262
|
if (destroyed) return false;
|
|
236
|
-
|
|
263
|
+
if (event.altKey === true) return false;
|
|
264
|
+
if (conflictingModifiers(event)) { prevent(event); resetCycle(); return true; }
|
|
265
|
+
const raw = at(event); const hit = semanticCandidates(raw)[0];
|
|
237
266
|
if (!hit) { if (raw.length) prevent(event); return false; }
|
|
238
|
-
|
|
239
|
-
|
|
267
|
+
if (event.ctrlKey === true || event.metaKey === true || event.shiftKey === true) {
|
|
268
|
+
commitHits([hit], event, 'mesh'); prevent(event); return true;
|
|
269
|
+
}
|
|
270
|
+
if (onHierarchyDoubleClick?.(hit, { event, origin: 'mesh' }) === true) { prevent(event); return true; }
|
|
271
|
+
const entity = entityOf(hit); const committed = isSelected(entity) || commitHits([hit], event, 'mesh', 'replace');
|
|
272
|
+
if (committed) fitSelection(); prevent(event); return true;
|
|
240
273
|
},
|
|
241
274
|
keyDown(event) {
|
|
242
275
|
if (destroyed || event.defaultPrevented || editable(event.target)) return false;
|
|
276
|
+
if (conflictingModifiers(event) && String(event.key).toLowerCase() === 'a') { prevent(event); resetCycle(); return true; }
|
|
243
277
|
if ((event.ctrlKey || event.metaKey) && !event.altKey && String(event.key).toLowerCase() === 'a') {
|
|
244
|
-
const raw = visibleHits(allHits()); const eligible =
|
|
245
|
-
if (eligible.length
|
|
278
|
+
const raw = visibleHits(allHits()); const eligible = semanticCandidates(raw);
|
|
279
|
+
if (eligible.length) commitHits(eligible, event, 'mesh', 'replace');
|
|
280
|
+
else if (!raw.length) clear('mesh');
|
|
246
281
|
prevent(event); resetCycle(); return true;
|
|
247
282
|
}
|
|
248
283
|
if (event.key !== 'Escape') return false;
|
|
249
284
|
if (cancelActiveTool()) { prevent(event); return true; }
|
|
250
285
|
if (gesture?.active) { gesture = null; suppressClick = true; onMarquee(null); prevent(event); return true; }
|
|
251
286
|
if (hover) { setHover(null); prevent(event); return true; }
|
|
252
|
-
if (coordinator.entries().length) {
|
|
287
|
+
if (coordinator.entries().length) { clear('mesh'); prevent(event); return true; }
|
|
253
288
|
return false;
|
|
254
289
|
},
|
|
255
290
|
windowBlur() {
|
|
@@ -275,6 +310,7 @@ export function createModelSelectionTools({
|
|
|
275
310
|
capabilities: () => capabilities,
|
|
276
311
|
commandInventory: () => commands,
|
|
277
312
|
filters: () => filters,
|
|
313
|
+
eligibleHits: (hits) => candidates(hits),
|
|
278
314
|
setFilters(next) { filters = normalizeFacetFilters(next); resetCycle(); setHover(null); notifyFilters(); return filters; },
|
|
279
315
|
setFacet(name, values) { filters = normalizeFacetFilters({ ...filters, [name]: values }); resetCycle(); setHover(null); notifyFilters(); return filters; },
|
|
280
316
|
subscribeFilters(listener) {
|
|
@@ -1,4 +1,33 @@
|
|
|
1
1
|
export const TEKLA_GEOMETRY_SELECTION_CAP = 5000;
|
|
2
|
+
export const TEKLA_SELECTION_SCOPE_KEY = 'floless:tekla-parser:selection-scopes:v1';
|
|
3
|
+
export const TEKLA_DEFAULT_SELECTION_SCOPES = Object.freeze({ connection: 'group', assembly: 'group' });
|
|
4
|
+
|
|
5
|
+
export function readTeklaSelectionScopes(storage) {
|
|
6
|
+
try {
|
|
7
|
+
const value = JSON.parse(storage?.getItem?.(TEKLA_SELECTION_SCOPE_KEY) || 'null');
|
|
8
|
+
if (value && ['group', 'objects'].includes(value.connection) && ['group', 'objects'].includes(value.assembly)) return Object.freeze({ connection: value.connection, assembly: value.assembly });
|
|
9
|
+
} catch {}
|
|
10
|
+
return TEKLA_DEFAULT_SELECTION_SCOPES;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function writeTeklaSelectionScopes(storage, value) {
|
|
14
|
+
if (!value || !['group', 'objects'].includes(value.connection) || !['group', 'objects'].includes(value.assembly)) throw new TypeError('Tekla selection scopes must be group or objects.');
|
|
15
|
+
storage?.setItem?.(TEKLA_SELECTION_SCOPE_KEY, JSON.stringify(value)); return Object.freeze({ connection: value.connection, assembly: value.assembly });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function changeTeklaSelectionScope({ storage, navigator, current, axis, value }) {
|
|
19
|
+
if (!['connection', 'assembly'].includes(axis) || !['group', 'objects'].includes(value)) return Object.freeze({ changed: false, scopes: current });
|
|
20
|
+
const before = navigator?.state?.();
|
|
21
|
+
if (current?.[axis] === value && !before?.drillStack?.length) return Object.freeze({ changed: false, scopes: current });
|
|
22
|
+
let exitedDrill = false;
|
|
23
|
+
while (navigator?.state?.().drillStack?.length) { navigator.ascend(); exitedDrill = true; }
|
|
24
|
+
const scopes = writeTeklaSelectionScopes(storage, { ...current, [axis]: value });
|
|
25
|
+
const after = navigator?.state?.();
|
|
26
|
+
if (before && after && (JSON.stringify(before.selectedItems) !== JSON.stringify(after.selectedItems) || JSON.stringify(before.geometryIds) !== JSON.stringify(after.geometryIds))) {
|
|
27
|
+
throw new Error('Changing selection scope must not reinterpret the current selection.');
|
|
28
|
+
}
|
|
29
|
+
return Object.freeze({ changed: true, scopes, exitedDrill });
|
|
30
|
+
}
|
|
2
31
|
|
|
3
32
|
/**
|
|
4
33
|
* Resolve only supplied geometry and authenticated membership; labels never imply membership.
|
|
@@ -20,13 +49,57 @@ export function teklaGeometrySelection(ids, entityById, membersByAssembly = new
|
|
|
20
49
|
return [...selected];
|
|
21
50
|
}
|
|
22
51
|
|
|
23
|
-
/** The verifier
|
|
52
|
+
/** The verifier exposes legacy `contains` and native-v2 assembly membership explicitly. */
|
|
24
53
|
export function teklaAssemblyMembership(relationships) {
|
|
25
54
|
const members = new Map();
|
|
26
55
|
for (const relationship of relationships || []) {
|
|
27
|
-
if (relationship.kind !== 'contains'
|
|
56
|
+
if (relationship.kind !== 'contains'
|
|
57
|
+
&& !(relationship.kind === 'provider-explicit' && relationship.providerRelationKind === 'tekla-assembly-member')) continue;
|
|
28
58
|
const ids = members.get(relationship.from) || [];
|
|
29
59
|
ids.push(relationship.to); members.set(relationship.from, ids);
|
|
30
60
|
}
|
|
31
61
|
return members;
|
|
32
62
|
}
|
|
63
|
+
|
|
64
|
+
/** Build only verifier-authenticated native-v2 hierarchy edges; labels never create ancestry. */
|
|
65
|
+
export function teklaHierarchyIndexes(entities, relationships) {
|
|
66
|
+
const byId = new Map((entities || []).map((entity) => [String(entity.id), entity]));
|
|
67
|
+
const children = new Map(); const parents = { connection: new Map(), assembly: new Map() };
|
|
68
|
+
const append = (map, key, value) => { const values = map.get(key) || []; if (!values.includes(value)) values.push(value); map.set(key, values); };
|
|
69
|
+
for (const relationship of relationships || []) {
|
|
70
|
+
if (relationship.kind !== 'provider-explicit') continue;
|
|
71
|
+
const axis = relationship.providerRelationKind === 'tekla-component-child' ? 'connection'
|
|
72
|
+
: relationship.providerRelationKind === 'tekla-assembly-member' ? 'assembly' : null;
|
|
73
|
+
if (!axis) continue;
|
|
74
|
+
const from = String(relationship.from); const to = String(relationship.to);
|
|
75
|
+
if (byId.get(from)?.hierarchyContract !== 'tekla-hierarchy/v1' || byId.get(to)?.hierarchyContract !== 'tekla-hierarchy/v1') continue;
|
|
76
|
+
append(children, from, to); append(parents[axis], to, from);
|
|
77
|
+
}
|
|
78
|
+
// The verifier-derived main part is presentation order, never inferred hierarchy authority.
|
|
79
|
+
for (const [groupId, memberIds] of children) {
|
|
80
|
+
const entity = byId.get(groupId); const main = Number.isInteger(entity?.assemblyMainPartId) ? `element:${entity.assemblyMainPartId}` : entity?.assemblyMainPartId;
|
|
81
|
+
if (!main) continue;
|
|
82
|
+
const index = memberIds.indexOf(String(main));
|
|
83
|
+
if (index > 0) memberIds.unshift(...memberIds.splice(index, 1));
|
|
84
|
+
}
|
|
85
|
+
const ancestors = (id, axis) => {
|
|
86
|
+
const out = []; const seen = new Set();
|
|
87
|
+
let frontier = [...(parents.connection.get(String(id)) || []), ...(parents.assembly.get(String(id)) || [])];
|
|
88
|
+
while (frontier.length) {
|
|
89
|
+
const parent = frontier.shift(); if (seen.has(parent)) continue;
|
|
90
|
+
seen.add(parent);
|
|
91
|
+
const kind = byId.get(parent)?.nativeKind;
|
|
92
|
+
if ((axis === 'assembly' && kind === 'Assembly') || (axis === 'connection' && (kind === 'Component' || kind === 'Connection'))) out.push(parent);
|
|
93
|
+
frontier = [...(parents.connection.get(parent) || []), ...(parents.assembly.get(parent) || []), ...frontier];
|
|
94
|
+
}
|
|
95
|
+
return out.reverse(); // highest authenticated ancestor first
|
|
96
|
+
};
|
|
97
|
+
return Object.freeze({
|
|
98
|
+
children,
|
|
99
|
+
groupKind(id) {
|
|
100
|
+
const kind = byId.get(String(id))?.nativeKind;
|
|
101
|
+
return kind === 'Assembly' ? 'assembly' : (kind === 'Component' || kind === 'Connection') ? 'connection' : null;
|
|
102
|
+
},
|
|
103
|
+
candidates(id) { return Object.freeze({ connection: Object.freeze(ancestors(id, 'connection')), assembly: Object.freeze(ancestors(id, 'assembly')) }); },
|
|
104
|
+
});
|
|
105
|
+
}
|
|
@@ -504,7 +504,8 @@ export function applyRevitDisplayMode(meshes, next, presentation = {}) {
|
|
|
504
504
|
const selectedIds = new Set(presentation.selectedIds ?? []);
|
|
505
505
|
const ghostActive = presentation.ghostUnselected === true && selectedIds.size > 0;
|
|
506
506
|
const wire = next === 'wire';
|
|
507
|
-
const
|
|
507
|
+
const hoveredIds = new Set(Array.isArray(presentation.hoveredIds) ? presentation.hoveredIds
|
|
508
|
+
: typeof presentation.hoveredId === 'string' ? [presentation.hoveredId] : []);
|
|
508
509
|
const materials = presentation.edgeMaterials ?? null;
|
|
509
510
|
for (const mesh of meshes) {
|
|
510
511
|
const material = mesh.material;
|
|
@@ -539,7 +540,7 @@ export function applyRevitDisplayMode(meshes, next, presentation = {}) {
|
|
|
539
540
|
outline.visible = wire;
|
|
540
541
|
if (wire && materials) {
|
|
541
542
|
const chosen = selectedIds.has(mesh.userData.entityId);
|
|
542
|
-
const hovered =
|
|
543
|
+
const hovered = hoveredIds.has(mesh.userData.entityId);
|
|
543
544
|
// Selected outranks hovered, and this ternary is the ONLY place that says so — guarding
|
|
544
545
|
// `hovered` with `!chosen` as well would state the precedence twice, which leaves each copy
|
|
545
546
|
// free to rot without a test noticing.
|
|
@@ -638,7 +639,7 @@ export function createRevitViewport({ canvas, onSelect = () => {}, onOutlineBuil
|
|
|
638
639
|
perspective.up.set(0, 0, 1); orthographic.up.set(0, 0, 1);
|
|
639
640
|
perspective.position.set(1, -1, 1); orthographic.position.copy(perspective.position);
|
|
640
641
|
perspective.lookAt(0, 0, 0); orthographic.lookAt(0, 0, 0);
|
|
641
|
-
let camera = perspective; let model = null; let modelDisposer = null; let meshes = []; let ownedMeshes = []; let mode = 'solid'; let selected = []; let
|
|
642
|
+
let camera = perspective; let model = null; let modelDisposer = null; let meshes = []; let ownedMeshes = []; let mode = 'solid'; let selected = []; let hoveredIds = []; let ghostUnselected = false; let disposed = false; let mounted = false; let shown = false; let paintAllowed = false; let orthoSpan = 10; let geometryFrame = revitGeometryFrame();
|
|
642
643
|
let mountContext = null; let inputArbiter = null; let releaseClipInput = null; let releaseClipOverlayInput = null; let pendingLoad = null; let loadSequence = 0; let controller = null;
|
|
643
644
|
let spatialTools = null; let releaseSpatial = null; let spatialState = null; let workPlaneHelper = null;
|
|
644
645
|
let structuralGrid = null; let structuralGridReceipt = null; let structuralGridOwnerId = null;
|
|
@@ -986,15 +987,19 @@ export function createRevitViewport({ canvas, onSelect = () => {}, onOutlineBuil
|
|
|
986
987
|
function paintSelection(items, ids) {
|
|
987
988
|
const eligible = ids.filter((id) => items.some((mesh) => mesh.userData.entityId === id && hasVisibleFragment(mesh)));
|
|
988
989
|
const set = new Set(eligible);
|
|
989
|
-
|
|
990
|
+
const hoverSet = new Set(hoveredIds);
|
|
991
|
+
applyRevitDisplayMode(items, mode, { selectedIds: eligible, ghostUnselected, hoveredIds, edgeMaterials });
|
|
990
992
|
items.forEach((mesh) => {
|
|
991
|
-
const chosen = set.has(mesh.userData.entityId); const hovered = !chosen &&
|
|
993
|
+
const chosen = set.has(mesh.userData.entityId); const hovered = !chosen && hoverSet.has(mesh.userData.entityId);
|
|
992
994
|
mesh.material.emissive?.set(chosen ? 0x2563eb : hovered ? 0x0ea5e9 : 0x000000);
|
|
993
995
|
mesh.material.emissiveIntensity = chosen ? .65 : hovered ? .34 : 0;
|
|
994
996
|
});
|
|
995
997
|
}
|
|
996
998
|
function reflectSelection(ids) { selected = [...ids]; paintSelection(ownedMeshes, ids); }
|
|
997
|
-
function reflectHover(
|
|
999
|
+
function reflectHover(value) {
|
|
1000
|
+
hoveredIds = [...new Set((Array.isArray(value) ? value : typeof value === 'string' ? [value] : []).filter((id) => typeof id === 'string'))];
|
|
1001
|
+
paintSelection(ownedMeshes, selected);
|
|
1002
|
+
}
|
|
998
1003
|
function display(next) {
|
|
999
1004
|
mode = next;
|
|
1000
1005
|
if (mode === 'wire') ensureOutlines(); else outlineJob?.stop();
|
|
@@ -1089,13 +1094,13 @@ export function createRevitViewport({ canvas, onSelect = () => {}, onOutlineBuil
|
|
|
1089
1094
|
canonicalToRenderPoint: (point) => geometryFrame.canonicalToRenderPoint(point) });
|
|
1090
1095
|
baseVisibility = new Map(ownedMeshes.map((mesh) => [mesh, true])); isolation.forget(); structuralGridBaseVisible = true; structuralGridVisibilityBeforeIsolation = null; spatialVisibilityBox = null;
|
|
1091
1096
|
modelDisposer = next.dispose;
|
|
1092
|
-
snapIndex = nextSnapIndex; selected = [];
|
|
1097
|
+
snapIndex = nextSnapIndex; selected = []; hoveredIds = []; applyRealistic(); if (spatialState) paintSpatialState(spatialState); clipOverlay.render();
|
|
1093
1098
|
// The staged generation is only live from here, so the outline build starts now —
|
|
1094
1099
|
// not at the applyRevitDisplayMode above, which still ran against a staged scene.
|
|
1095
1100
|
cancelOutlineJob(); sceneGeneration += 1; ensureOutlines();
|
|
1096
1101
|
},
|
|
1097
1102
|
onRelease() {
|
|
1098
|
-
if (model === next.root) { cancelOutlineJob(); model = null; modelDisposer = null; meshes = []; ownedMeshes = [];
|
|
1103
|
+
if (model === next.root) { cancelOutlineJob(); model = null; modelDisposer = null; meshes = []; ownedMeshes = []; hoveredIds = []; baseVisibility.clear(); isolation.forget(); structuralGridBaseVisible = true; structuralGridVisibilityBeforeIsolation = null; spatialVisibilityBox = null; snapIndex = buildModelSnapIndex([]); structuralGridView.clear(); structuralGrid = null; structuralGridReceipt = null; structuralGridOwnerId = null; }
|
|
1099
1104
|
},
|
|
1100
1105
|
});
|
|
1101
1106
|
// A structural grid is drawn from its own record, so a Tekla read with no drawn object but a grid
|
|
@@ -1134,7 +1139,7 @@ export function createRevitViewport({ canvas, onSelect = () => {}, onOutlineBuil
|
|
|
1134
1139
|
spatialTools.replaceSections({ clips: value?.clipping ?? value?.clips ?? [], workArea: value?.workArea ?? null });
|
|
1135
1140
|
},
|
|
1136
1141
|
applyPresentation({ selectedKeys = [], hoverKey = null, ghostUnselected: ghost = false }) {
|
|
1137
|
-
ghostUnselected = ghost === true;
|
|
1142
|
+
ghostUnselected = ghost === true; hoveredIds = idsForKeys(hoverKey ? [hoverKey] : []);
|
|
1138
1143
|
reflectSelection(idsForKeys(selectedKeys));
|
|
1139
1144
|
structuralGridView.applyPaint({ selectedIds: structuralGridOwnerId && selected.includes(structuralGridOwnerId) ? structuralGridView.info().ids : [],
|
|
1140
1145
|
ghost: { active: ghostUnselected && selected.length > 0, focusIds: structuralGridOwnerId && selected.includes(structuralGridOwnerId) ? structuralGridView.info().ids : [], opacity: .18 } });
|
|
@@ -1325,7 +1330,9 @@ export function createRevitViewport({ canvas, onSelect = () => {}, onOutlineBuil
|
|
|
1325
1330
|
projection: () => controller.cameraState().projection, displayMode: () => controller.displayMode(),
|
|
1326
1331
|
lightingState: () => ({ ...lighting }), setLighting: (value) => ({ ...applyLighting(value) }),
|
|
1327
1332
|
gridLevels: () => adapter.gridLevels(),
|
|
1328
|
-
|
|
1333
|
+
// Republished, so the toolbar sees the hidden grid levels as a visibility filter (Show all enabled) and the editor's
|
|
1334
|
+
// subscribers hear about the change. An internal refresh, not counted as the person hiding objects.
|
|
1335
|
+
setGridHiddenLevels: (values) => { adapter.setGridHiddenLevels(values); controller.reportVisibility(undefined, { intentional: false }); },
|
|
1329
1336
|
realisticState,
|
|
1330
1337
|
outlineState: () => ({
|
|
1331
1338
|
mode, meshes: ownedMeshes.length,
|