@floless/app 0.138.2 → 0.139.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/autostart.mjs +6 -2
- package/desktop-access-production-manifest.mjs +7 -0
- package/dist/floless-server.cjs +157207 -70887
- package/dist/schemas/model.continuation.v1.schema.json +19 -0
- package/dist/schemas/model.continuation.v2.schema.json +19 -0
- package/dist/schemas/model.query-response.v1.schema.json +95 -0
- package/dist/schemas/model.query-response.v2.schema.json +80 -0
- package/dist/schemas/model.query.v1.schema.json +87 -0
- package/dist/schemas/model.query.v2.schema.json +87 -0
- package/dist/schemas/model.snap-candidate.v1.schema.json +48 -0
- package/dist/schemas/model.snap-constraint.v1.schema.json +18 -0
- package/dist/schemas/model.snap-query.v1.schema.json +24 -0
- package/dist/schemas/model.snap-result.v1.schema.json +33 -0
- package/dist/schemas/model.snapshot.v1.schema.json +136 -0
- package/dist/schemas/revit.model.v1.schema.json +24 -0
- package/dist/schemas/steel.model.v2.schema.json +45 -6
- package/dist/skills/floless-app-approval/SKILL.md +19 -5
- package/dist/skills/floless-app-bridge/SKILL.md +19 -6
- package/dist/skills/floless-app-knowledge/SKILL.md +22 -1
- package/dist/skills/floless-app-new-workflow/SKILL.md +31 -27
- package/dist/skills/floless-app-new-workflow/references/build-and-verify.md +13 -12
- package/dist/skills/floless-app-onboarding/SKILL.md +3 -3
- package/dist/skills/floless-app-onboarding/references/floless-app-tour.md +16 -9
- package/dist/skills/floless-app-steel-model/SKILL.md +11 -2
- package/dist/skills/floless-app-steel-model/references/detail-from-a-screenshot.md +95 -0
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +142 -21
- package/dist/skills/floless-app-steel-takeoff/references/elevation-registration.md +19 -0
- package/dist/skills/floless-app-tweak-contract/SKILL.md +42 -8
- package/dist/skills/floless-app-vectorize/SKILL.md +19 -6
- package/dist/skills/floless-app-workflows/SKILL.md +30 -3
- package/dist/skills/floless-app-workflows/references/workspace-data.md +77 -4
- package/dist/templates/floless-workspace-model-report.flo +77 -0
- package/dist/templates/revit-model.flo +111 -0
- package/dist/web/app.css +415 -177
- package/dist/web/app.js +302 -51
- package/dist/web/aware.js +1357 -1032
- package/dist/web/chat.css +692 -0
- package/dist/web/chat.js +2651 -0
- package/dist/web/commands-revit.js +42 -0
- package/dist/web/commands-shell.js +531 -70
- package/dist/web/commands-steel.js +344 -146
- package/dist/web/commands.js +1 -1
- package/dist/web/index.html +283 -77
- package/dist/web/instructor.js +217 -36
- package/dist/web/left-pane.js +636 -0
- package/dist/web/model-artifact-loader.js +75 -0
- package/dist/web/model-authoring-gestures.js +141 -0
- package/dist/web/model-cad-tools.js +20 -0
- package/dist/web/model-clip-gesture.js +148 -0
- package/dist/web/model-clip-list.js +156 -0
- package/dist/web/model-clip-session.js +274 -0
- package/dist/web/model-clip-three-overlay.js +295 -0
- package/dist/web/model-clip-three-preview.js +59 -0
- package/dist/web/model-editor-contract.js +519 -0
- package/dist/web/model-editor-revit-adapter.js +139 -0
- package/dist/web/model-editor-shell.js +271 -0
- package/dist/web/model-editor-state-recovery.js +44 -0
- package/dist/web/model-editor-steel-adapter.js +415 -0
- package/dist/web/model-editor.css +268 -0
- package/dist/web/model-frame.js +192 -0
- package/dist/web/model-inspector.js +128 -0
- package/dist/web/model-measure.js +390 -0
- package/dist/web/model-navigation-controls.js +246 -0
- package/dist/web/model-orientation-overlay.js +217 -0
- package/dist/web/model-panel-bridge.js +230 -0
- package/dist/web/model-pointer-dock.js +164 -0
- package/dist/web/model-revit-module.js +83 -0
- package/dist/web/model-selection-coordinator.js +151 -0
- package/dist/web/model-selection-tools.js +290 -0
- package/dist/web/model-snap-contract.js +267 -0
- package/dist/web/model-snapping.js +497 -0
- package/dist/web/model-spatial-panel.js +294 -0
- package/dist/web/model-spatial-tools.js +249 -0
- package/dist/web/model-tree.js +47 -0
- package/dist/web/model-viewport-lighting.js +166 -0
- package/dist/web/model-viewport-revit-adapter.js +1224 -0
- package/dist/web/model-viewport-state.js +505 -0
- package/dist/web/model-viewport-steel-adapter.js +150 -0
- package/dist/web/model-viewport-toolbar.js +516 -0
- package/dist/web/model-viewport.js +717 -0
- package/dist/web/panels.js +8 -15
- package/dist/web/renderers.js +3 -0
- package/dist/web/revit-editor.css +35 -0
- package/dist/web/revit-editor.html +74 -0
- package/dist/web/revit-editor.js +845 -0
- package/dist/web/steel-3d-core.js +16 -44
- package/dist/web/steel-3d-view.js +1384 -633
- package/dist/web/steel-canvas-guidance.js +3 -1
- package/dist/web/steel-editor.html +2145 -1255
- package/dist/web/steel-filter.html +5 -1
- package/dist/web/steel-model-v2-commands.js +80 -3
- package/dist/web/steel-split-view.js +5 -39
- package/dist/web/steel-view-generation.js +107 -17
- package/dist/web/vector-3d.html +12 -0
- package/dist/web/workspaces.js +2154 -283
- package/distribution-profile-active.mjs +2 -0
- package/distribution-profile-production.mjs +47 -0
- package/distribution-profile-shared.mjs +8 -0
- package/distribution-profile.mjs +18 -0
- package/distribution-resource-inventory.mjs +81 -0
- package/launch.mjs +18 -10
- package/log.mjs +2 -1
- package/managed-runtime-policy.mjs +104 -0
- package/model-reader-policy-active.mjs +7 -0
- package/network-policy-active.mjs +6 -0
- package/package.json +17 -2
- package/post-update-marker.mjs +3 -1
- package/rvt-production-uat-authority.mjs +60 -0
- package/teardown.mjs +4 -3
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* model-editor-contract.js — the ONE canonical toolbar specification and command-capability
|
|
3
|
+
* vocabulary for every 3D editor module (Steel today, Revit next). Pure data plus pure functions:
|
|
4
|
+
* no DOM, no Three.js, so it is unit-tested in node (server/model-editor-contract.test.ts) and
|
|
5
|
+
* imported by the editor pages themselves.
|
|
6
|
+
*
|
|
7
|
+
* WHY A SPECIFICATION RATHER THAN MARKUP. The toolbar exists twice the moment a second editor
|
|
8
|
+
* appears — once in the page and once in whatever test claims to check it — and the two drift. Plan
|
|
9
|
+
* review caught exactly that: a task restated the toolbar order and quietly dropped Hide and Show
|
|
10
|
+
* all, and the restated list read as authoritative. So the order lives HERE, and both the rendering
|
|
11
|
+
* and the tests derive from it. A second list anywhere is the bug.
|
|
12
|
+
*
|
|
13
|
+
* COMMON IDS ARE PROVIDER-NEUTRAL `model.*`. Steel's own vocabulary stays `steel.*` and is bound to
|
|
14
|
+
* these by `model-editor-steel-adapter.js`; Revit will bind its own. Nothing here knows what a
|
|
15
|
+
* member, a member type, or a Revit category is — the moment it does, this file has become a domain
|
|
16
|
+
* module wearing a shared name.
|
|
17
|
+
*
|
|
18
|
+
* ABSENT, NOT DISABLED. `resolveToolbar` DROPS an unsupported control instead of rendering it
|
|
19
|
+
* greyed. A read-only model must not advertise a mutation it can never perform, and a disabled
|
|
20
|
+
* button is an advertisement. Only a control that is genuinely supported-but-blocked-right-now stays
|
|
21
|
+
* visible, and it must carry the reason.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
export const MODEL_TOOLBAR_SCHEMA = 'floless.model-toolbar/v1';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The canonical common toolbar: groups in order, controls in order within a group.
|
|
28
|
+
*
|
|
29
|
+
* MENU ITEMS ARE ORDERED. The shared Visibility menu is Show all, Isolate, Ghost unselected, Hide;
|
|
30
|
+
* providers may omit unsupported rows, but they may not silently rearrange the surviving actions.
|
|
31
|
+
* The divider is presentation owned by each renderer and is not a command id.
|
|
32
|
+
*
|
|
33
|
+
* Domain-only controls are NOT here. Steel's 3D-label menu is Steel's; a module contributes those
|
|
34
|
+
* through its own extension slot and may never duplicate a common control.
|
|
35
|
+
*/
|
|
36
|
+
export const MODEL_TOOLBAR_V1 = Object.freeze({
|
|
37
|
+
schema: MODEL_TOOLBAR_SCHEMA,
|
|
38
|
+
groups: Object.freeze([
|
|
39
|
+
Object.freeze({
|
|
40
|
+
id: 'camera',
|
|
41
|
+
separatorBefore: false,
|
|
42
|
+
label: 'Camera',
|
|
43
|
+
controls: Object.freeze([
|
|
44
|
+
Object.freeze({ id: 'model.projection', kind: 'menu' }),
|
|
45
|
+
Object.freeze({ id: 'model.fit', kind: 'button' }),
|
|
46
|
+
Object.freeze({ id: 'model.fit-selection', kind: 'button' }),
|
|
47
|
+
]),
|
|
48
|
+
}),
|
|
49
|
+
Object.freeze({
|
|
50
|
+
id: 'display',
|
|
51
|
+
separatorBefore: true,
|
|
52
|
+
label: 'Display',
|
|
53
|
+
controls: Object.freeze([
|
|
54
|
+
Object.freeze({ id: 'model.display-mode', kind: 'menu' }),
|
|
55
|
+
Object.freeze({
|
|
56
|
+
id: 'model.visibility',
|
|
57
|
+
kind: 'menu',
|
|
58
|
+
items: Object.freeze(['model.show-all', 'model.isolate', 'model.ghost-unselected', 'model.hide-selected']),
|
|
59
|
+
}),
|
|
60
|
+
]),
|
|
61
|
+
}),
|
|
62
|
+
Object.freeze({
|
|
63
|
+
id: 'views',
|
|
64
|
+
separatorBefore: false,
|
|
65
|
+
label: 'Views',
|
|
66
|
+
controls: Object.freeze([Object.freeze({ id: 'model.saved-views', kind: 'button' })]),
|
|
67
|
+
}),
|
|
68
|
+
Object.freeze({
|
|
69
|
+
id: 'sectioning',
|
|
70
|
+
separatorBefore: true,
|
|
71
|
+
label: 'Sectioning',
|
|
72
|
+
controls: Object.freeze([
|
|
73
|
+
Object.freeze({ id: 'model.clip', kind: 'menu' }),
|
|
74
|
+
Object.freeze({ id: 'model.work-plane', kind: 'menu' }),
|
|
75
|
+
Object.freeze({ id: 'model.work-area', kind: 'menu' }),
|
|
76
|
+
]),
|
|
77
|
+
}),
|
|
78
|
+
]),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* View orientation is a VIEWPORT OVERLAY, not a toolbar control.
|
|
83
|
+
*
|
|
84
|
+
* The design's canonical list names it beside Saved views, which reads as a twelfth button — and
|
|
85
|
+
* Steel has no such button. It is the orientation cube floating over the canvas, carrying no command
|
|
86
|
+
* id at all. Recording it here, outside `groups`, is what stops the next extraction from
|
|
87
|
+
* manufacturing a toolbar button the product never had and then "preserving" it forever. Which
|
|
88
|
+
* element that cube IS belongs to the module that owns it, and is pinned there, not here — a shared
|
|
89
|
+
* file that knows a Steel element id has started to depend on Steel.
|
|
90
|
+
*/
|
|
91
|
+
export const MODEL_VIEWPORT_OVERLAYS_V1 = Object.freeze(['model.view-orientation']);
|
|
92
|
+
|
|
93
|
+
/** Every command id the common toolbar declares, controls and menu items alike. */
|
|
94
|
+
export function toolbarCommandIds(spec = MODEL_TOOLBAR_V1) {
|
|
95
|
+
const out = [];
|
|
96
|
+
for (const group of spec.groups) {
|
|
97
|
+
for (const control of group.controls) {
|
|
98
|
+
out.push(control.id);
|
|
99
|
+
for (const item of control.items ?? []) out.push(item);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return out;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export const COMMAND_AVAILABILITY = Object.freeze(['available', 'temporarily-unavailable', 'policy-blocked']);
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Build a capability map, refusing anything the specification does not declare.
|
|
109
|
+
*
|
|
110
|
+
* Capabilities come from the loaded PROVIDER, never from a check such as `editor === 'revit'` — that
|
|
111
|
+
* is the whole reason this is a map and not a branch. Validating ids here means a typo surfaces as a
|
|
112
|
+
* thrown error at load rather than as a control that silently never renders.
|
|
113
|
+
*
|
|
114
|
+
* An id the caller omits is unsupported. That default is deliberate: a provider that forgets to
|
|
115
|
+
* declare a command gets a missing button, not a button that dispatches into nothing.
|
|
116
|
+
*/
|
|
117
|
+
export function capabilityMap(entries, spec = MODEL_TOOLBAR_V1) {
|
|
118
|
+
const declared = new Set(toolbarCommandIds(spec));
|
|
119
|
+
const out = Object.create(null);
|
|
120
|
+
for (const [id, value] of Object.entries(entries ?? {})) {
|
|
121
|
+
if (!declared.has(id)) {
|
|
122
|
+
throw new Error(`capabilityMap: "${id}" is not declared by ${spec.schema} — add it to the specification, `
|
|
123
|
+
+ 'or contribute it as a domain-only command in the module\'s own slot.');
|
|
124
|
+
}
|
|
125
|
+
const supported = value?.supported === true;
|
|
126
|
+
const availability = value?.availability ?? 'available';
|
|
127
|
+
if (!COMMAND_AVAILABILITY.includes(availability)) {
|
|
128
|
+
throw new Error(`capabilityMap: "${id}" has availability "${availability}", not one of ${COMMAND_AVAILABILITY.join(', ')}.`);
|
|
129
|
+
}
|
|
130
|
+
if (supported && availability !== 'available' && !value?.reason) {
|
|
131
|
+
throw new Error(`capabilityMap: "${id}" is ${availability} with no reason. A control the user can see but `
|
|
132
|
+
+ 'cannot use must say why — an unexplained dead control is the failure this field exists to prevent.');
|
|
133
|
+
}
|
|
134
|
+
out[id] = Object.freeze({ supported, availability, reason: value?.reason ?? null });
|
|
135
|
+
}
|
|
136
|
+
return Object.freeze(out);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const RENDERABLE = (cap) => !!cap && cap.supported && cap.availability !== 'policy-blocked';
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The toolbar to render: groups and controls in canonical order, with everything unsupported or
|
|
143
|
+
* policy-blocked ABSENT rather than disabled, and an emptied group dropped along with its separator.
|
|
144
|
+
*
|
|
145
|
+
* A menu whose every item is unsupported is itself absent — an empty Visibility menu is a control
|
|
146
|
+
* that opens onto nothing, which is worse than no control.
|
|
147
|
+
*/
|
|
148
|
+
export function resolveToolbar(capabilities, spec = MODEL_TOOLBAR_V1) {
|
|
149
|
+
const groups = [];
|
|
150
|
+
for (const group of spec.groups) {
|
|
151
|
+
const controls = [];
|
|
152
|
+
for (const control of group.controls) {
|
|
153
|
+
const cap = capabilities[control.id];
|
|
154
|
+
if (!RENDERABLE(cap)) continue;
|
|
155
|
+
const items = (control.items ?? []).filter((id) => RENDERABLE(capabilities[id]));
|
|
156
|
+
if (control.items && !items.length) continue;
|
|
157
|
+
controls.push({
|
|
158
|
+
id: control.id,
|
|
159
|
+
kind: control.kind,
|
|
160
|
+
availability: cap.availability,
|
|
161
|
+
reason: cap.reason,
|
|
162
|
+
...(control.items ? { items } : {}),
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
if (controls.length) {
|
|
166
|
+
groups.push({ id: group.id, separatorBefore: group.separatorBefore === true, label: group.label, controls });
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return groups;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* WHY `separatorBefore` IS DATA AND NOT DERIVED FROM THE GROUPS.
|
|
174
|
+
*
|
|
175
|
+
* The rendered bar has FOUR visual clusters and THREE rules, and they do not line up one-to-one with
|
|
176
|
+
* the four groups: `display` and `views` deliberately share a cluster with no rule between them, and
|
|
177
|
+
* a module's contribution sits between `views` and `sectioning`. Deriving a rule from every group
|
|
178
|
+
* boundary would put a new hairline between Isolate and Views — which widens the bar, which changes
|
|
179
|
+
* where it wraps, which changes how much of the 3D view the bar covers. Plan
|
|
180
|
+
* review measured that chain; the "one pixel" is not one pixel. So the layout is stated rather than
|
|
181
|
+
* inferred, and it stays behaviour-neutral.
|
|
182
|
+
*
|
|
183
|
+
* `separatorBefore` is ADDITIVE: a reader that ignores it renders exactly what it rendered before,
|
|
184
|
+
* so the schema is extended rather than redefined and no migration is owed.
|
|
185
|
+
*/
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Merge a module's own contributions into the resolved groups, producing the ordered CLUSTER list a
|
|
189
|
+
* renderer walks. A cluster is a group or a contribution; nothing else exists at the bar's top level.
|
|
190
|
+
*
|
|
191
|
+
* `contributions` are `{ id, after, separatorBefore }`. `after` names the group the contribution
|
|
192
|
+
* follows — and the interesting case is the one a single-editor codebase never sees: **the anchor may
|
|
193
|
+
* not survive**. A read-only Revit that supports no Saved views drops the `views` group, and a slot
|
|
194
|
+
* declared `after: 'views'` would then be placing itself after nothing. So the rule is
|
|
195
|
+
* NEAREST-SURVIVING-ANCHOR: fall back to the closest earlier group in DECLARED order that did
|
|
196
|
+
* survive, and to the front of the bar if none did. Silently dropping the contribution instead would
|
|
197
|
+
* make a module's own menu vanish because of an unrelated capability.
|
|
198
|
+
*/
|
|
199
|
+
export function toolbarClusters(groups, contributions = [], spec = MODEL_TOOLBAR_V1) {
|
|
200
|
+
const order = spec.groups.map((g) => g.id);
|
|
201
|
+
const alive = new Set(groups.map((g) => g.id));
|
|
202
|
+
const at = new Map(groups.map((g, i) => [g.id, i]));
|
|
203
|
+
const after = new Map(); // group index → contributions that follow it
|
|
204
|
+
const front = [];
|
|
205
|
+
for (const c of contributions) {
|
|
206
|
+
let anchor = null;
|
|
207
|
+
for (let i = order.indexOf(c.after); i >= 0; i--) {
|
|
208
|
+
if (alive.has(order[i])) { anchor = order[i]; break; }
|
|
209
|
+
}
|
|
210
|
+
if (anchor === null) { front.push(c); continue; }
|
|
211
|
+
const i = at.get(anchor);
|
|
212
|
+
if (!after.has(i)) after.set(i, []);
|
|
213
|
+
after.get(i).push(c);
|
|
214
|
+
}
|
|
215
|
+
const clusters = [];
|
|
216
|
+
const push = (c) => clusters.push({ kind: 'contribution', id: c.id, separatorBefore: c.separatorBefore === true });
|
|
217
|
+
for (const c of front) push(c);
|
|
218
|
+
groups.forEach((group, i) => {
|
|
219
|
+
clusters.push({ kind: 'group', ...group });
|
|
220
|
+
for (const c of after.get(i) ?? []) push(c);
|
|
221
|
+
});
|
|
222
|
+
// The separator RULE, in one place: a cluster draws one only if it asked for it AND something is
|
|
223
|
+
// there for it to separate. Both clauses matter — the second is what stops a dropped leading group
|
|
224
|
+
// from leaving a rule against the bar's left edge, and a dropped trailing group from orphaning one.
|
|
225
|
+
return clusters.map((c, i) => ({ ...c, separatorBefore: i > 0 && c.separatorBefore }));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/* ───────────────────────────────────────────────────────────────────────────────────────────────
|
|
229
|
+
* THE VIEWPORT FACADE
|
|
230
|
+
*
|
|
231
|
+
* The toolbar specification above says WHICH controls exist. This half says what pressing one DOES:
|
|
232
|
+
* a typed command carrying its payload, and one dispatcher that routes it to a provider.
|
|
233
|
+
*
|
|
234
|
+
* WHY TYPED COMMANDS AND NOT A METHOD CALL. Plan review's sharpest point was that a facade nothing
|
|
235
|
+
* calls is unverifiable — the page would keep calling its viewport global directly while an adapter
|
|
236
|
+
* sat orphaned beside it. Routing the common toolbar through `dispatch(id, payload)` makes the facade
|
|
237
|
+
* authoritative over exactly the surface Task 2 extracts, and makes "did this button go through the
|
|
238
|
+
* facade" a question with an answer (`dispatchLog`) rather than an assumption.
|
|
239
|
+
*
|
|
240
|
+
* MENU TRIGGERS ARE CHROME. Opening the Clip menu is not a viewport operation, so those six ids carry
|
|
241
|
+
* no method and dispatching one is an error. What is beneath them — arm a clip, set a plane, pick a
|
|
242
|
+
* work area — is the part a second editor has to implement, and that is what the table types.
|
|
243
|
+
*
|
|
244
|
+
* SAVED VIEWS IS A HOST ACTION. It opens a panel. If it lived on the provider, a fake non-Steel
|
|
245
|
+
* viewport would have to implement page behaviour before it could pass conformance — which would make
|
|
246
|
+
* the conformance test agree with anything.
|
|
247
|
+
* ─────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
248
|
+
|
|
249
|
+
export const MODEL_VIEWPORT_SCHEMA = 'floless.model-viewport/v1';
|
|
250
|
+
|
|
251
|
+
/** Payload specs: `null` = takes none, `'boolean'`, `{ enum }`, or `{ shape }` of primitive specs. */
|
|
252
|
+
const P = {
|
|
253
|
+
projection: Object.freeze({ enum: Object.freeze(['ortho', 'persp']) }),
|
|
254
|
+
displayMode: Object.freeze({ enum: Object.freeze(['solid', 'wire', 'xray', 'realistic', 'shadowed']) }), // `shadowed`, not `shadow` — the token the page and the renderer both use
|
|
255
|
+
clipKind: Object.freeze({ enum: Object.freeze(['plane', 'box']) }),
|
|
256
|
+
planePick: Object.freeze({ enum: Object.freeze(['face', '3pt']) }),
|
|
257
|
+
workAreaFrom: Object.freeze({ enum: Object.freeze(['all', 'selection']) }),
|
|
258
|
+
principal: Object.freeze({ shape: Object.freeze({ plane: Object.freeze({ enum: Object.freeze(['xy', 'xz', 'yz']) }), offsetMm: 'number' }) }),
|
|
259
|
+
selection: Object.freeze({ shape: Object.freeze({ ids: 'string[]' }) }),
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
const cmd = (control, target, method, payload = null) => Object.freeze({ control, target, method, payload });
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Every command the common toolbar can issue: the twelve controls and every action beneath them.
|
|
266
|
+
*
|
|
267
|
+
* `control` is the toolbar control the command belongs to, and is checked against MODEL_TOOLBAR_V1 —
|
|
268
|
+
* two independent lists of the same toolbar is the drift this file exists to prevent.
|
|
269
|
+
*/
|
|
270
|
+
export const MODEL_COMMANDS_V1 = Object.freeze({
|
|
271
|
+
'model.projection': cmd('model.projection', 'chrome', null),
|
|
272
|
+
'model.projection.set': cmd('model.projection', 'viewport', 'setProjection', P.projection),
|
|
273
|
+
'model.fit': cmd('model.fit', 'viewport', 'fitAll'),
|
|
274
|
+
'model.fit-selection': cmd('model.fit-selection', 'viewport', 'fitSelection'),
|
|
275
|
+
|
|
276
|
+
'model.display-mode': cmd('model.display-mode', 'chrome', null),
|
|
277
|
+
'model.display-mode.set': cmd('model.display-mode', 'viewport', 'setDisplayMode', P.displayMode),
|
|
278
|
+
'model.visibility': cmd('model.visibility', 'chrome', null),
|
|
279
|
+
'model.isolate': cmd('model.isolate', 'viewport', 'isolateSelected'),
|
|
280
|
+
'model.ghost-unselected': cmd('model.ghost-unselected', 'viewport', 'toggleGhostUnselected'),
|
|
281
|
+
'model.hide-selected': cmd('model.hide-selected', 'viewport', 'hideSelected'),
|
|
282
|
+
'model.show-all': cmd('model.show-all', 'viewport', 'showAll'),
|
|
283
|
+
|
|
284
|
+
'model.saved-views': cmd('model.saved-views', 'host', 'openSavedViews'),
|
|
285
|
+
|
|
286
|
+
'model.clip': cmd('model.clip', 'chrome', null),
|
|
287
|
+
'model.clip.arm': cmd('model.clip', 'viewport', 'armClip', P.clipKind),
|
|
288
|
+
'model.clip.cancel': cmd('model.clip', 'viewport', 'cancelClip'),
|
|
289
|
+
'model.clip.clear': cmd('model.clip', 'viewport', 'clearClips'),
|
|
290
|
+
|
|
291
|
+
'model.work-plane': cmd('model.work-plane', 'chrome', null),
|
|
292
|
+
'model.work-plane.pick': cmd('model.work-plane', 'viewport', 'armWorkPlanePick', P.planePick),
|
|
293
|
+
'model.work-plane.principal': cmd('model.work-plane', 'viewport', 'setWorkPlane', P.principal),
|
|
294
|
+
'model.work-plane.show': cmd('model.work-plane', 'viewport', 'setWorkPlaneVisible', 'boolean'),
|
|
295
|
+
'model.work-plane.reset': cmd('model.work-plane', 'viewport', 'clearWorkPlane'),
|
|
296
|
+
|
|
297
|
+
'model.work-area': cmd('model.work-area', 'chrome', null),
|
|
298
|
+
'model.work-area.set': cmd('model.work-area', 'viewport', 'setWorkArea', P.workAreaFrom),
|
|
299
|
+
'model.work-area.toggle': cmd('model.work-area', 'viewport', 'toggleWorkArea'),
|
|
300
|
+
'model.work-area.whole': cmd('model.work-area', 'viewport', 'toggleWorkAreaWhole'),
|
|
301
|
+
|
|
302
|
+
// Selection is PUSH-ONLY in this slice. Steel exposes a setter and no public getter, and state
|
|
303
|
+
// ownership moves in Task 2 — promising a neutral read contract now would be a promise the code
|
|
304
|
+
// cannot keep, so there is deliberately no `model.selection.get`.
|
|
305
|
+
'model.selection.set': cmd(null, 'viewport', 'setSelection', P.selection),
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
/** Reads a shell may make of a viewport. Anything absent here is not part of the interface. */
|
|
309
|
+
export const MODEL_VIEWPORT_READS_V1 = Object.freeze(['isReady', 'getState', 'subscribe', 'projection', 'displayMode', 'ghostUnselected', 'clipMode', 'workPlaneInfo', 'workAreaState']);
|
|
310
|
+
|
|
311
|
+
/** Lifecycle operations, outside the toolbar: the shell owns these, not a button. */
|
|
312
|
+
const LIFECYCLE = Object.freeze(['dispose', 'rebuild']);
|
|
313
|
+
|
|
314
|
+
/** Every method a viewport provider must implement, derived from the command table. */
|
|
315
|
+
export function viewportMethodNames(capabilities = null) {
|
|
316
|
+
return Object.values(MODEL_COMMANDS_V1)
|
|
317
|
+
.filter((command) => command.target === 'viewport')
|
|
318
|
+
.filter((command) => capabilities === null || capabilities?.[command.control]?.supported === true)
|
|
319
|
+
.map((command) => command.method);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
const READ_CAPABILITY = Object.freeze({
|
|
323
|
+
projection: 'model.projection',
|
|
324
|
+
displayMode: 'model.display-mode',
|
|
325
|
+
ghostUnselected: 'model.visibility',
|
|
326
|
+
clipMode: 'model.clip',
|
|
327
|
+
workPlaneInfo: 'model.work-plane',
|
|
328
|
+
workAreaState: 'model.work-area',
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
class FacadeError extends Error {
|
|
332
|
+
constructor(code, message) { super(message); this.name = 'FacadeError'; this.code = code; }
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function payloadOk(spec, value) {
|
|
336
|
+
if (spec === null) return value === undefined;
|
|
337
|
+
if (spec === 'boolean') return typeof value === 'boolean';
|
|
338
|
+
if (spec === 'number') return typeof value === 'number' && Number.isFinite(value);
|
|
339
|
+
if (spec === 'string') return typeof value === 'string';
|
|
340
|
+
if (spec === 'string[]') return Array.isArray(value) && value.every((v) => typeof v === 'string');
|
|
341
|
+
if (spec.enum) return spec.enum.includes(value);
|
|
342
|
+
if (spec.shape) {
|
|
343
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return false;
|
|
344
|
+
const keys = Object.keys(spec.shape);
|
|
345
|
+
// Exact keys, not "at least": an unexpected key is a caller that thinks it is configuring
|
|
346
|
+
// something, and silently dropping it is how a payload contract stops meaning anything.
|
|
347
|
+
if (Object.keys(value).length !== keys.length) return false;
|
|
348
|
+
return keys.every((k) => payloadOk(spec.shape[k], value[k]));
|
|
349
|
+
}
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/** Throws unless `provider` implements the whole interface, naming what is missing. */
|
|
354
|
+
export function assertViewportProvider(provider, capabilities = null) {
|
|
355
|
+
const reads = capabilities === null
|
|
356
|
+
? MODEL_VIEWPORT_READS_V1
|
|
357
|
+
: MODEL_VIEWPORT_READS_V1.filter((name) => ['isReady', 'getState', 'subscribe'].includes(name) || capabilities?.[READ_CAPABILITY[name]]?.supported === true);
|
|
358
|
+
const need = [...new Set([...viewportMethodNames(capabilities), ...reads, ...LIFECYCLE])];
|
|
359
|
+
const missing = need.filter((m) => typeof provider?.[m] !== 'function');
|
|
360
|
+
if (missing.length) {
|
|
361
|
+
throw new FacadeError('E_PROVIDER_INCOMPLETE',
|
|
362
|
+
`${MODEL_VIEWPORT_SCHEMA}: the provider does not implement ${missing.join(', ')}. A viewport that `
|
|
363
|
+
+ 'cannot answer the whole interface is not a provider — add the method, or the shell will call '
|
|
364
|
+
+ 'into undefined the first time a user presses that control.');
|
|
365
|
+
}
|
|
366
|
+
return true;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Mount the facade over a viewport provider and a host.
|
|
371
|
+
*
|
|
372
|
+
* `provider` may be a FUNCTION, resolved on every use. That is not a convenience: `main()` mounts the
|
|
373
|
+
* adapter thousands of lines before `Steel3DView.init` runs, so a facade that resolved eagerly would
|
|
374
|
+
* hold `undefined` for the whole of that window and report itself ready.
|
|
375
|
+
*
|
|
376
|
+
* `host` carries the editor-owned actions (Saved views) and optional notifications. It is deliberately
|
|
377
|
+
* a different object from the provider, so a fake non-Steel viewport never has to implement page
|
|
378
|
+
* behaviour to pass conformance.
|
|
379
|
+
*/
|
|
380
|
+
/** @param {{ provider: any, host?: any, capabilities?: any, logLimit?: number }} options */
|
|
381
|
+
export function createModelEditorFacade({ provider, host = {}, capabilities = null, logLimit = 50 }) {
|
|
382
|
+
const resolve = typeof provider === 'function' ? provider : () => provider;
|
|
383
|
+
// Validated eagerly when the provider is already there; a late one is validated on first use
|
|
384
|
+
// instead, so mounting early is not a way around conformance.
|
|
385
|
+
if (typeof provider !== 'function') assertViewportProvider(provider, capabilities);
|
|
386
|
+
|
|
387
|
+
let disposed = false, sequence = 0;
|
|
388
|
+
const log = [];
|
|
389
|
+
|
|
390
|
+
const live = () => {
|
|
391
|
+
if (disposed) throw new FacadeError('E_FACADE_DISPOSED', 'the facade was disposed; this belongs to a view that is gone');
|
|
392
|
+
const p = resolve();
|
|
393
|
+
if (!p) throw new FacadeError('E_VIEWPORT_NOT_READY', 'there is no viewport yet');
|
|
394
|
+
assertViewportProvider(p, capabilities);
|
|
395
|
+
return p;
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
const facade = {
|
|
399
|
+
schema: MODEL_VIEWPORT_SCHEMA,
|
|
400
|
+
|
|
401
|
+
isReady() {
|
|
402
|
+
if (disposed) return false;
|
|
403
|
+
const p = resolve();
|
|
404
|
+
return !!(p && typeof p.isReady === 'function' && p.isReady());
|
|
405
|
+
},
|
|
406
|
+
|
|
407
|
+
dispatch(id, payload) {
|
|
408
|
+
const spec = MODEL_COMMANDS_V1[id];
|
|
409
|
+
if (!spec) throw new FacadeError('E_UNKNOWN_COMMAND', `${id} is not a command of ${MODEL_VIEWPORT_SCHEMA}`);
|
|
410
|
+
if (capabilities !== null && spec.control && capabilities?.[spec.control]?.supported !== true) {
|
|
411
|
+
throw new FacadeError('E_CAPABILITY_UNSUPPORTED', `${id} is not supported by this model provider`);
|
|
412
|
+
}
|
|
413
|
+
if (spec.target === 'chrome') {
|
|
414
|
+
throw new FacadeError('E_CHROME_COMMAND', `${id} opens a menu — that is page chrome, not a viewport operation`);
|
|
415
|
+
}
|
|
416
|
+
if (!payloadOk(spec.payload, payload)) {
|
|
417
|
+
throw new FacadeError('E_BAD_PAYLOAD', `${id} was given a payload it does not accept: ${JSON.stringify(payload ?? null)}`);
|
|
418
|
+
}
|
|
419
|
+
if (disposed) throw new FacadeError('E_FACADE_DISPOSED', `${id} belongs to a view that is gone`);
|
|
420
|
+
|
|
421
|
+
let target;
|
|
422
|
+
if (spec.target === 'host') {
|
|
423
|
+
if (typeof host?.[spec.method] !== 'function') {
|
|
424
|
+
throw new FacadeError('E_NO_HOST_ACTION', `${id} is an editor action and this host provides no ${spec.method}`);
|
|
425
|
+
}
|
|
426
|
+
target = host;
|
|
427
|
+
} else {
|
|
428
|
+
const p = live();
|
|
429
|
+
if (!p.isReady()) throw new FacadeError('E_VIEWPORT_NOT_READY', `${id} needs a viewport that is ready`);
|
|
430
|
+
target = p;
|
|
431
|
+
}
|
|
432
|
+
const result = spec.payload === null ? target[spec.method]() : target[spec.method](payload);
|
|
433
|
+
log.push({ id, payload: payload ?? null });
|
|
434
|
+
if (log.length > logLimit) log.shift();
|
|
435
|
+
return result;
|
|
436
|
+
},
|
|
437
|
+
|
|
438
|
+
/** What really went through the facade — so a browser test can assert dispatch, not just a click. */
|
|
439
|
+
dispatchLog() { return log.map((e) => ({ ...e })); },
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Optional revisioned selection channel. It is deliberately outside MODEL_COMMANDS_V1 so an
|
|
443
|
+
* unchanged v1 provider remains conformant. Canonical keys cannot be sent to the legacy raw-id
|
|
444
|
+
* setter: absence is an explicit capability error, never a lossy downgrade.
|
|
445
|
+
*/
|
|
446
|
+
commitSelection(commit) {
|
|
447
|
+
const p = live();
|
|
448
|
+
if (!p.isReady()) throw new FacadeError('E_VIEWPORT_NOT_READY', 'selection commit needs a viewport that is ready');
|
|
449
|
+
if (typeof p.commitSelection !== 'function') {
|
|
450
|
+
throw new FacadeError('E_SELECTION_COMMIT_UNSUPPORTED', 'this v1 provider has no revisioned selection capability');
|
|
451
|
+
}
|
|
452
|
+
const result = p.commitSelection(commit);
|
|
453
|
+
log.push({ id: 'model.selection.commit', payload: commit ?? null });
|
|
454
|
+
if (log.length > logLimit) log.shift();
|
|
455
|
+
return result;
|
|
456
|
+
},
|
|
457
|
+
|
|
458
|
+
suspend() {
|
|
459
|
+
if (disposed) return false;
|
|
460
|
+
const p = live();
|
|
461
|
+
if (typeof p.suspend !== 'function') return false;
|
|
462
|
+
p.suspend(); return true;
|
|
463
|
+
},
|
|
464
|
+
|
|
465
|
+
resume() {
|
|
466
|
+
if (disposed) return false;
|
|
467
|
+
const p = live();
|
|
468
|
+
if (typeof p.resume !== 'function') return false;
|
|
469
|
+
p.resume(); return true;
|
|
470
|
+
},
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Rebuild, with the staleness the old code kept by hand. A rebuild that settles after a newer one
|
|
474
|
+
* started, or after disposal, is reported stale rather than acted on; a LIVE failure still rejects,
|
|
475
|
+
* because the page toasts it and swallowing that would hide a real bake failure.
|
|
476
|
+
*/
|
|
477
|
+
async rebuild(...args) {
|
|
478
|
+
const mine = ++sequence;
|
|
479
|
+
const p = live();
|
|
480
|
+
try {
|
|
481
|
+
const result = await p.rebuild(...args);
|
|
482
|
+
return { ok: true, stale: mine !== sequence || disposed, result };
|
|
483
|
+
} catch (error) {
|
|
484
|
+
if (mine !== sequence || disposed) {
|
|
485
|
+
if (typeof host?.onStaleRebuild === 'function') host.onStaleRebuild(error);
|
|
486
|
+
return { ok: false, stale: true, error };
|
|
487
|
+
}
|
|
488
|
+
throw error;
|
|
489
|
+
}
|
|
490
|
+
},
|
|
491
|
+
|
|
492
|
+
dispose() {
|
|
493
|
+
if (disposed) return;
|
|
494
|
+
disposed = true;
|
|
495
|
+
sequence++;
|
|
496
|
+
const p = resolve();
|
|
497
|
+
if (p && typeof p.dispose === 'function') p.dispose();
|
|
498
|
+
},
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
// The reads are spelled out rather than looped from MODEL_VIEWPORT_READS_V1 so they are part of the
|
|
502
|
+
// returned TYPE and a caller's typo is a compile error. `model-editor-facade.test.ts` asserts the two
|
|
503
|
+
// stay in step, which is the half a loop would have given for free.
|
|
504
|
+
return Object.freeze({
|
|
505
|
+
...facade,
|
|
506
|
+
getState: () => live().getState(),
|
|
507
|
+
subscribe: (listener) => live().subscribe(listener),
|
|
508
|
+
projection: (...args) => live().projection?.(...args) ?? null,
|
|
509
|
+
displayMode: (...args) => live().displayMode?.(...args) ?? null,
|
|
510
|
+
ghostUnselected: (...args) => live().ghostUnselected?.(...args) ?? false,
|
|
511
|
+
clipMode: (...args) => live().clipMode?.(...args) ?? null,
|
|
512
|
+
workPlaneInfo: (...args) => live().workPlaneInfo?.(...args) ?? null,
|
|
513
|
+
workAreaState: (...args) => live().workAreaState?.(...args) ?? null,
|
|
514
|
+
// Lighting is an optional shared extension. Steel and Revit both implement it, while a future
|
|
515
|
+
// provider with no lighting panel can still satisfy the core viewport contract.
|
|
516
|
+
lightingState: (...args) => live().lightingState?.(...args) ?? null,
|
|
517
|
+
setLighting: (...args) => live().setLighting?.(...args) ?? null,
|
|
518
|
+
});
|
|
519
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/* Revit's read-only binding to the shared model-editor contract. */
|
|
2
|
+
import { capabilityMap, createModelEditorFacade, resolveToolbar, toolbarClusters } from './model-editor-contract.js';
|
|
3
|
+
import { toolbarCarriers } from './model-viewport-toolbar.js';
|
|
4
|
+
|
|
5
|
+
export const REVIT_COMMAND_BINDING_V1 = Object.freeze({
|
|
6
|
+
'model.projection': 'revit.projection',
|
|
7
|
+
'model.fit': 'revit.fit',
|
|
8
|
+
'model.fit-selection': 'revit.fit-selection',
|
|
9
|
+
'model.display-mode': 'revit.display-mode',
|
|
10
|
+
'model.visibility': 'revit.visibility',
|
|
11
|
+
'model.isolate': 'revit.isolate',
|
|
12
|
+
'model.ghost-unselected': 'revit.ghost-unselected',
|
|
13
|
+
'model.hide-selected': 'revit.hide-selected',
|
|
14
|
+
'model.show-all': 'revit.show-all',
|
|
15
|
+
'model.saved-views': 'revit.saved-views',
|
|
16
|
+
'model.clip': 'revit.clip',
|
|
17
|
+
'model.work-plane': 'revit.work-plane',
|
|
18
|
+
'model.work-area': 'revit.work-area',
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export function revitCapabilityEntries() {
|
|
22
|
+
const out = Object.create(null);
|
|
23
|
+
for (const id of Object.keys(REVIT_COMMAND_BINDING_V1)) out[id] = { supported: true, availability: 'available' };
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const CONTROLS = Object.freeze({
|
|
28
|
+
'model.projection': {
|
|
29
|
+
kind: 'button', el: 'revitProjection', label: 'Perspective', data: { 'data-proj': 'persp' },
|
|
30
|
+
tip: 'Perspective — click for orthographic true scale',
|
|
31
|
+
},
|
|
32
|
+
'model.fit': { kind: 'button', el: 'revitFit', label: 'Fit', tip: 'Fit the whole Revit model to the view' },
|
|
33
|
+
'model.fit-selection': { kind: 'button', el: 'revitFitSelection', label: 'Zoom sel', tip: 'Zoom to selected — frame the selected Revit object (Alt+Z)' },
|
|
34
|
+
'model.display-mode': {
|
|
35
|
+
kind: 'menu', aria: true, el: 'revitDisplay', menu: 'revitDisplayMenu', label: 'Solid', data: { 'data-mode': 'solid' },
|
|
36
|
+
tip: 'Display mode — solid, wireframe, see-through, or realistic',
|
|
37
|
+
items: [
|
|
38
|
+
{ kind: 'item', cmd: 'revit.display-mode-set#solid', data: { 'data-mode': 'solid' }, role: 'menuitemradio', checked: true, label: 'Solid', tip: 'Solid shaded model' },
|
|
39
|
+
{ kind: 'item', cmd: 'revit.display-mode-set#wireframe', data: { 'data-mode': 'wire' }, role: 'menuitemradio', checked: false, label: 'Wireframe', tip: 'Edges only' },
|
|
40
|
+
{ kind: 'item', cmd: 'revit.display-mode-set#x-ray', data: { 'data-mode': 'xray' }, role: 'menuitemradio', checked: false, label: 'X-ray', tip: 'See through model surfaces' },
|
|
41
|
+
{ kind: 'item', cmd: 'revit.display-mode-set#realistic', data: { 'data-mode': 'realistic' }, role: 'menuitemradio', checked: false, label: 'Realistic', tip: 'Realistic — fuller shading in the model’s own Revit colours (Revit material finishes are not part of the conversion)' },
|
|
42
|
+
{ kind: 'divider' },
|
|
43
|
+
{ kind: 'item', cmd: 'revit.lighting', el: 'revitLighting', data: { 'data-lighting': 'open' }, label: 'Lighting…', tip: 'Adjust sunlight direction and model brightness' },
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
'model.visibility': {
|
|
47
|
+
kind: 'menu', aria: true, el: 'revitVisibility', menu: 'revitVisibilityMenu', label: 'Visibility ▾',
|
|
48
|
+
tip: 'Temporarily isolate, hide, or restore model objects',
|
|
49
|
+
items: [
|
|
50
|
+
{ cap: 'model.show-all', kind: 'item', cmd: 'revit.show-all', role: 'menuitem', data: { 'data-vis': 'show-all' }, hidden: true, label: 'Show all', tip: 'Restore every hidden or isolated object' },
|
|
51
|
+
{ cap: 'model.show-all', kind: 'divider', mark: 'data-vis-divider', hidden: true },
|
|
52
|
+
{ cap: 'model.isolate', kind: 'item', cmd: 'revit.isolate', role: 'menuitem', data: { 'data-vis': 'isolate' }, label: 'Isolate selected', tip: 'Show only the selected object' },
|
|
53
|
+
{ cap: 'model.ghost-unselected', kind: 'toggle', cmd: 'revit.ghost-unselected', data: { 'data-vis': 'ghost' }, checked: false, label: 'Ghost unselected', tip: 'Fade everything except the current selection' },
|
|
54
|
+
{ cap: 'model.hide-selected', kind: 'item', cmd: 'revit.hide-selected', role: 'menuitem', data: { 'data-vis': 'hide' }, label: 'Hide selected', tip: 'Temporarily hide the selected object' },
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
'model.saved-views': { kind: 'button', el: 'revitSavedViews', label: 'Views', tip: 'Save, restore, rename, or remove camera views' },
|
|
58
|
+
'model.clip': {
|
|
59
|
+
kind: 'menu', aria: true, el: 'revitClip', menu: 'revitClipMenu', label: 'Clip ▾', tip: 'Section the model with shared clip planes or boxes',
|
|
60
|
+
items: [
|
|
61
|
+
{ kind: 'item', cmd: 'revit.clip-action#plane', data: { 'data-spatial': 'clip-plane' }, label: 'Add clip plane', tip: 'Pick a model face to place the clip plane' },
|
|
62
|
+
{ kind: 'item', cmd: 'revit.clip-action#box', data: { 'data-spatial': 'clip-box' }, label: 'Clip box', tip: 'Pick two footprint corners, then set the height' },
|
|
63
|
+
{ kind: 'divider' },
|
|
64
|
+
{ kind: 'item', cmd: 'revit.clip-action#clear', data: { 'data-spatial': 'clip-clear' }, class: 'mdanger', label: 'Clear all clips', tip: 'Remove every active clip' },
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
'model.work-plane': {
|
|
68
|
+
kind: 'menu', aria: true, el: 'revitWorkPlane', menu: 'revitWorkPlaneMenu', label: 'Plane ▾', tip: 'Choose the active measuring and coordinate plane',
|
|
69
|
+
items: [
|
|
70
|
+
{ kind: 'item', cmd: 'revit.work-plane-action#xy', data: { 'data-spatial': 'plane-xy' }, label: 'XY plane…', tip: 'Set an XY working plane with a millimetre offset' },
|
|
71
|
+
{ kind: 'item', cmd: 'revit.work-plane-action#xz', data: { 'data-spatial': 'plane-xz' }, label: 'XZ plane…', tip: 'Set an XZ working plane with a millimetre offset' },
|
|
72
|
+
{ kind: 'item', cmd: 'revit.work-plane-action#yz', data: { 'data-spatial': 'plane-yz' }, label: 'YZ plane…', tip: 'Set a YZ working plane with a millimetre offset' },
|
|
73
|
+
{ kind: 'divider' },
|
|
74
|
+
{ kind: 'item', cmd: 'revit.work-plane-action#toggle', data: { 'data-spatial': 'plane-toggle' }, label: 'Show / hide plane', tip: 'Toggle the working-plane grid' },
|
|
75
|
+
{ kind: 'item', cmd: 'revit.work-plane-action#global', data: { 'data-spatial': 'frame-global' }, label: 'Reset to Global', tip: 'Return dimensions and coordinates to the global frame' },
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
'model.work-area': {
|
|
79
|
+
kind: 'menu', aria: true, el: 'revitWorkArea', menu: 'revitWorkAreaMenu', label: 'Work area ▾', tip: 'Limit the viewport to the model or current selection',
|
|
80
|
+
items: [
|
|
81
|
+
{ kind: 'item', cmd: 'revit.work-area-action#model', data: { 'data-spatial': 'area-model' }, label: 'From model', tip: 'Set the work area to the whole model' },
|
|
82
|
+
{ kind: 'item', cmd: 'revit.work-area-action#selection', data: { 'data-spatial': 'area-selection' }, label: 'From selection', tip: 'Set the work area to selected objects' },
|
|
83
|
+
{ kind: 'item', cmd: 'revit.work-area-action#whole', data: { 'data-spatial': 'area-whole' }, label: 'Whole parts / section cut', tip: 'Toggle whole intersecting parts versus a physical section cut' },
|
|
84
|
+
{ kind: 'item', cmd: 'revit.work-area-action#toggle', data: { 'data-spatial': 'area-toggle' }, label: 'Show / hide work area', tip: 'Toggle the active work area' },
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
export function revitRenderPlan(entries = revitCapabilityEntries()) {
|
|
90
|
+
const resolved = resolveToolbar(capabilityMap(entries));
|
|
91
|
+
const clusters = toolbarClusters(resolved).map((cluster) => ({
|
|
92
|
+
...cluster,
|
|
93
|
+
controls: cluster.controls.map((control) => {
|
|
94
|
+
const descriptor = CONTROLS[control.id];
|
|
95
|
+
if (!descriptor) throw new Error(`revitRenderPlan: no descriptor for "${control.id}"`);
|
|
96
|
+
const withCommand = { ...descriptor, semantic: control.id, cmd: descriptor.cmd ?? REVIT_COMMAND_BINDING_V1[control.id] };
|
|
97
|
+
if (!control.items) return withCommand;
|
|
98
|
+
const live = new Set(control.items);
|
|
99
|
+
return { ...withCommand, items: descriptor.items.filter((item) => !item.cap || live.has(item.cap)) };
|
|
100
|
+
}),
|
|
101
|
+
}));
|
|
102
|
+
const plan = { schema: 'floless.model-toolbar-plan/v1', clusters };
|
|
103
|
+
return Object.freeze({ ...plan, carriers: Object.freeze(toolbarCarriers(plan)) });
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function provider(viewport) {
|
|
107
|
+
return {
|
|
108
|
+
isReady: viewport.isReady,
|
|
109
|
+
dispose: viewport.dispose,
|
|
110
|
+
suspend: viewport.suspend,
|
|
111
|
+
resume: viewport.resume,
|
|
112
|
+
rebuild: async () => undefined,
|
|
113
|
+
projection: viewport.projection,
|
|
114
|
+
displayMode: viewport.displayMode,
|
|
115
|
+
ghostUnselected: viewport.ghostUnselected,
|
|
116
|
+
getState: viewport.getState,
|
|
117
|
+
subscribe: viewport.subscribe,
|
|
118
|
+
setProjection: viewport.setProjection,
|
|
119
|
+
setDisplayMode: viewport.setDisplayMode,
|
|
120
|
+
fitAll: viewport.fitAll,
|
|
121
|
+
fitSelection: viewport.fitSelection,
|
|
122
|
+
isolateSelected: viewport.isolateSelected,
|
|
123
|
+
toggleGhostUnselected: viewport.toggleGhostUnselected,
|
|
124
|
+
hideSelected: viewport.hideSelected,
|
|
125
|
+
showAll: viewport.showAll,
|
|
126
|
+
setSelection: viewport.setSelection,
|
|
127
|
+
armClip: viewport.armClip, cancelClip: viewport.cancelClip, clearClips: viewport.clearClips,
|
|
128
|
+
armWorkPlanePick: viewport.armWorkPlanePick, setWorkPlane: viewport.setWorkPlane,
|
|
129
|
+
setWorkPlaneVisible: viewport.setWorkPlaneVisible, clearWorkPlane: viewport.clearWorkPlane,
|
|
130
|
+
setWorkArea: viewport.setWorkArea, toggleWorkArea: viewport.toggleWorkArea, toggleWorkAreaWhole: viewport.toggleWorkAreaWhole,
|
|
131
|
+
clipMode: viewport.clipMode, workPlaneInfo: viewport.workPlaneInfo, workAreaState: viewport.workAreaState,
|
|
132
|
+
lightingState: viewport.lightingState, setLighting: viewport.setLighting,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function createRevitEditorAdapter({ viewport, host = {} }) {
|
|
137
|
+
const capabilities = capabilityMap(revitCapabilityEntries());
|
|
138
|
+
return createModelEditorFacade({ provider: provider(viewport), capabilities, host });
|
|
139
|
+
}
|