@thatopen/services 0.12.0 → 0.13.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.
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
/** Mirrors the platform-supplied `executionContext` global (see cloud-component template). */
|
|
2
|
+
export interface EngineExecutionContext {
|
|
3
|
+
projectId?: string;
|
|
4
|
+
executionId: string;
|
|
5
|
+
toolId: string;
|
|
6
|
+
toolVersion: string;
|
|
7
|
+
}
|
|
1
8
|
/**
|
|
2
9
|
* Generates the local execution engine script.
|
|
3
10
|
*
|
|
4
11
|
* Mirrors the server-side `v1/thatOpenEngine.js` template:
|
|
5
12
|
* - Provides the same globals (OBC, THREE, WEBIFC, fs, executionReporter,
|
|
6
|
-
* thatOpenServices, executionParams).
|
|
13
|
+
* thatOpenServices, executionParams, executionContext).
|
|
7
14
|
* - Inlines the IIFE bundle code (which ends with `var main = ...`).
|
|
8
15
|
* - Calls `main()` and sends the result back via IPC.
|
|
9
16
|
*/
|
|
10
|
-
export declare function buildEngineScript(bundleCode: string, accessToken: string, apiUrl: string, executionParams: object): string;
|
|
17
|
+
export declare function buildEngineScript(bundleCode: string, accessToken: string, apiUrl: string, executionParams: object, executionContext: EngineExecutionContext): string;
|
package/dist/cli.js
CHANGED
|
@@ -11246,7 +11246,7 @@ function detectGlobalName(cwd) {
|
|
|
11246
11246
|
}
|
|
11247
11247
|
return "ThatOpenApp";
|
|
11248
11248
|
}
|
|
11249
|
-
function buildEngineScript(bundleCode, accessToken, apiUrl, executionParams) {
|
|
11249
|
+
function buildEngineScript(bundleCode, accessToken, apiUrl, executionParams, executionContext) {
|
|
11250
11250
|
return `/* eslint-disable */
|
|
11251
11251
|
const { EngineServicesClient } = require('@thatopen/services');
|
|
11252
11252
|
|
|
@@ -11271,6 +11271,7 @@ const executionReporter = {
|
|
|
11271
11271
|
};
|
|
11272
11272
|
|
|
11273
11273
|
let thatOpenServices, executionParams;
|
|
11274
|
+
const executionContext = ${JSON.stringify(executionContext)};
|
|
11274
11275
|
|
|
11275
11276
|
// --- User bundle code (IIFE) ---
|
|
11276
11277
|
${bundleCode}
|
|
@@ -11356,13 +11357,20 @@ const runCommand = new Command2("run").description("Build and run a cloud compon
|
|
|
11356
11357
|
process.exit(1);
|
|
11357
11358
|
}
|
|
11358
11359
|
const bundleCode = require$$3.readFileSync(bundlePath, "utf-8");
|
|
11360
|
+
const executionId = node_crypto.randomUUID();
|
|
11361
|
+
const localConfig = readLocalConfig(cwd);
|
|
11359
11362
|
const engineScript = buildEngineScript(
|
|
11360
11363
|
bundleCode,
|
|
11361
11364
|
config.accessToken,
|
|
11362
11365
|
config.apiUrl,
|
|
11363
|
-
executionParams
|
|
11366
|
+
executionParams,
|
|
11367
|
+
{
|
|
11368
|
+
executionId,
|
|
11369
|
+
toolId: localConfig?.componentId ?? "local",
|
|
11370
|
+
toolVersion: "local"
|
|
11371
|
+
}
|
|
11364
11372
|
);
|
|
11365
|
-
const tmpFile = require$$2.join(node_os.tmpdir(), `thatopen-run-${
|
|
11373
|
+
const tmpFile = require$$2.join(node_os.tmpdir(), `thatopen-run-${executionId}.js`);
|
|
11366
11374
|
require$$3.writeFileSync(tmpFile, engineScript);
|
|
11367
11375
|
console.log("Running cloud component...\n");
|
|
11368
11376
|
const startTime = Date.now();
|
|
@@ -11478,7 +11486,12 @@ class ExecutionManager {
|
|
|
11478
11486
|
bundleCode,
|
|
11479
11487
|
config.accessToken,
|
|
11480
11488
|
config.apiUrl,
|
|
11481
|
-
executionParams
|
|
11489
|
+
executionParams,
|
|
11490
|
+
{
|
|
11491
|
+
executionId,
|
|
11492
|
+
toolId: componentId,
|
|
11493
|
+
toolVersion: "local"
|
|
11494
|
+
}
|
|
11482
11495
|
);
|
|
11483
11496
|
const tmpFile = require$$2.join(node_os.tmpdir(), `thatopen-local-${executionId}.js`);
|
|
11484
11497
|
require$$3.writeFileSync(tmpFile, engineScript);
|
package/docs/builtin/paths.json
CHANGED
|
@@ -95,6 +95,10 @@
|
|
|
95
95
|
"path": "src/built-in/UIManager/src/models-list/example.ts",
|
|
96
96
|
"description": "top-models-list — top-models-list is the project's 3D-viewable-files tree: it mirrors the real storage folder structure, converts IFC to fragments, and loads `.frag`/`.potree`/`.splat` models into the 3D scene. Its loaders are PLUGGABLE — the panel owns the UI and the orchestration (progress, refresh, association), but the HOST decides how each extra file format is loaded, so you can teach it new formats without forking the built-in."
|
|
97
97
|
},
|
|
98
|
+
{
|
|
99
|
+
"path": "src/built-in/UIManager/src/settings-panel/example.ts",
|
|
100
|
+
"description": "top-settings-panel — Every viewer app ends up needing the same settings screen: rendering options, clip/measurement styling, a \"which cloud component converts this format\" picker, a keyboard-shortcut reference — plus a search box that filters all of it and a \"restore defaults\" button that resets whatever has persisted state. Building that, and keeping it in sync with the tools it configures, is real work before you've added a single setting of your own."
|
|
101
|
+
},
|
|
98
102
|
{
|
|
99
103
|
"path": "src/built-in/UIManager/src/topics-panel/example.ts",
|
|
100
104
|
"description": "topics-panel — Every coordination workflow needs a place to track issues, clashes, and action items against a 3D model — who's responsible, what still needs review, and where in the model it actually is. Building that from scratch means a BCF-compatible data model, a form, comment threads, viewpoint capture/navigation, document links, and a persistence layer — all before a single issue gets tracked."
|
package/package.json
CHANGED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/* MD
|
|
2
|
+
## top-settings-panel
|
|
3
|
+
---
|
|
4
|
+
Every viewer app ends up needing the same settings screen: rendering
|
|
5
|
+
options, clip/measurement styling, a "which cloud component converts this
|
|
6
|
+
format" picker, a keyboard-shortcut reference — plus a search box that
|
|
7
|
+
filters all of it and a "restore defaults" button that resets whatever has
|
|
8
|
+
persisted state. Building that, and keeping it in sync with the tools it
|
|
9
|
+
configures, is real work before you've added a single setting of your own.
|
|
10
|
+
|
|
11
|
+
`top-settings-panel` is a ready-made web component that delivers exactly
|
|
12
|
+
that. Mounted as-is, it's a complete, self-wiring Settings panel. But like
|
|
13
|
+
`top-viewer-toolbar` (see that tutorial), it's built out of standalone,
|
|
14
|
+
individually-importable `<top-*-settings>` elements — so you can drop the
|
|
15
|
+
panel it builds for you and compose your own layout out of the same
|
|
16
|
+
pieces, mixed freely with sections of your own.
|
|
17
|
+
|
|
18
|
+
This tutorial covers the prerequisites; the default, batteries-included
|
|
19
|
+
panel; what it manages automatically; building your own section with
|
|
20
|
+
`bim-panel-section`; and composing a custom layout with `headless`.
|
|
21
|
+
|
|
22
|
+
By the end, you'll have a working default panel plus your own custom
|
|
23
|
+
section, both wired into the same shared search box and reset button as
|
|
24
|
+
the stock ones.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { html, LitElement } from "lit";
|
|
28
|
+
import { customElement, state } from "lit/decorators.js";
|
|
29
|
+
import { consume } from "@lit/context";
|
|
30
|
+
import * as THREE from "three";
|
|
31
|
+
import * as OBC from "@thatopen/components";
|
|
32
|
+
import * as OBF from "@thatopen/components-front";
|
|
33
|
+
import * as FRAGS from "@thatopen/fragments";
|
|
34
|
+
import * as BUI from "@thatopen/ui";
|
|
35
|
+
import { PlatformClient, UIManager } from "@thatopen/services";
|
|
36
|
+
// TODO(#34 follow-up): `settingsSearchContext` is not part of the published
|
|
37
|
+
// `@thatopen/services` surface yet — see the TODO in settings-panel/index.ts.
|
|
38
|
+
// Imported by local relative path until the distribute pipeline exports
|
|
39
|
+
// context objects too; same workaround `app/examples/Contexts/example.ts`
|
|
40
|
+
// uses for `componentsContext`/`clientContext`.
|
|
41
|
+
import { settingsSearchContext } from "./src/context";
|
|
42
|
+
import type { App } from "../app/index";
|
|
43
|
+
|
|
44
|
+
/* MD
|
|
45
|
+
### ✅ Prerequisites
|
|
46
|
+
|
|
47
|
+
`UIManager` must be in the setup call so `<top-settings-panel>` and every
|
|
48
|
+
`<top-*-settings>` element are registered. `<top-settings-panel>` must be
|
|
49
|
+
mounted as a descendant of `<top-app>` — it and its sections consume
|
|
50
|
+
`componentsContext`/`clientContext`, which `top-app` provides. It does
|
|
51
|
+
**not** need to be a descendant of `<top-viewer>` specifically — but the
|
|
52
|
+
sections that talk to the 3D engine (Graphics, Clip styling, Measurement,
|
|
53
|
+
Commands) render an empty placeholder until a `<top-viewer>` exists
|
|
54
|
+
somewhere in the same app, since that's what actually builds the tools they
|
|
55
|
+
configure.
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
const client = PlatformClient.fromPlatformContext();
|
|
59
|
+
|
|
60
|
+
const { components } = (await client.setup(
|
|
61
|
+
{ OBC, OBF, BUI, THREE, FRAGS },
|
|
62
|
+
{ uuid: UIManager.uuid },
|
|
63
|
+
)) as { components: OBC.Components };
|
|
64
|
+
|
|
65
|
+
components.get(UIManager).init();
|
|
66
|
+
|
|
67
|
+
/* MD
|
|
68
|
+
### 🖥️ Default panel (batteries included)
|
|
69
|
+
|
|
70
|
+
Add it as a plain element anywhere under `top-app` — a side-by-side layout
|
|
71
|
+
with the 3D viewer is the most natural arrangement, since most of its
|
|
72
|
+
sections act on what's in the scene:
|
|
73
|
+
|
|
74
|
+
```html
|
|
75
|
+
<top-viewer>...</top-viewer>
|
|
76
|
+
<top-settings-panel></top-settings-panel>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 🤖 What the default panel manages automatically
|
|
80
|
+
|
|
81
|
+
**Graphics** — point/line/edge styling, background, shadows, ambient
|
|
82
|
+
occlusion — whatever `top-viewer` supports, persisted across reloads.
|
|
83
|
+
|
|
84
|
+
**Clip styling** — fill/edge color, opacity, width for the clip tool,
|
|
85
|
+
shared live with `top-viewer-toolbar`'s clip button.
|
|
86
|
+
|
|
87
|
+
**Measurement** — units (length/area/angle), color, decimals, per-snap-kind
|
|
88
|
+
toggles, shared live with the toolbar's measurement buttons.
|
|
89
|
+
|
|
90
|
+
**File conversion** — which provisioned cloud component converts each
|
|
91
|
+
format when a file is opened, per project.
|
|
92
|
+
|
|
93
|
+
**Commands** — a click-to-run shortcut reference (focus, hide, isolate,
|
|
94
|
+
ghost, show all, clear selection) that also registers the actual keyboard
|
|
95
|
+
shortcuts while mounted.
|
|
96
|
+
|
|
97
|
+
**Search box** — filters every section's own rows by label, stock or
|
|
98
|
+
custom, as long as a section opts in (see below).
|
|
99
|
+
|
|
100
|
+
**Restore defaults** — a two-click-confirm button that resets every
|
|
101
|
+
section with persisted state (currently: Graphics) back to its defaults.
|
|
102
|
+
|
|
103
|
+
### 🧩 Building your own section
|
|
104
|
+
|
|
105
|
+
A custom section is a `LitElement` that renders its own `<bim-panel-section>`
|
|
106
|
+
— nothing about it is specific to `top-settings-panel` beyond that. Consume
|
|
107
|
+
`settingsSearchContext` if you want the shared search box to filter your
|
|
108
|
+
rows too; skip it and your section simply never filters.
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
@customElement("my-lidar-settings")
|
|
112
|
+
class MyLidarSettings extends LitElement {
|
|
113
|
+
@consume({ context: settingsSearchContext, subscribe: true })
|
|
114
|
+
searchQuery = "";
|
|
115
|
+
|
|
116
|
+
@state() private _pointBudget = 2_000_000;
|
|
117
|
+
@state() private _showIntensity = false;
|
|
118
|
+
|
|
119
|
+
render() {
|
|
120
|
+
const rows = [
|
|
121
|
+
{
|
|
122
|
+
label: "Point budget",
|
|
123
|
+
control: html`<bim-number-input
|
|
124
|
+
label="Point budget"
|
|
125
|
+
slider
|
|
126
|
+
value=${this._pointBudget}
|
|
127
|
+
min="100000"
|
|
128
|
+
max="10000000"
|
|
129
|
+
step="100000"
|
|
130
|
+
@change=${(e: Event) => {
|
|
131
|
+
this._pointBudget = Number((e.target as HTMLInputElement).value);
|
|
132
|
+
}}
|
|
133
|
+
></bim-number-input>`,
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
label: "Show intensity",
|
|
137
|
+
control: html`<bim-checkbox
|
|
138
|
+
label="Show intensity"
|
|
139
|
+
toggle
|
|
140
|
+
?checked=${this._showIntensity}
|
|
141
|
+
@change=${(e: Event) => {
|
|
142
|
+
this._showIntensity = (e.target as HTMLInputElement).checked;
|
|
143
|
+
}}
|
|
144
|
+
></bim-checkbox>`,
|
|
145
|
+
},
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
const q = this.searchQuery.trim().toLowerCase();
|
|
149
|
+
const visible = q
|
|
150
|
+
? rows.filter((r) => r.label.toLowerCase().includes(q))
|
|
151
|
+
: rows;
|
|
152
|
+
|
|
153
|
+
return html`<bim-panel-section label="LIDAR" icon="mdi:radar">
|
|
154
|
+
${visible.length
|
|
155
|
+
? visible.map((r) => r.control)
|
|
156
|
+
: html`<bim-label style="opacity: 0.6; font-size: 0.78rem;"
|
|
157
|
+
>No settings match "${this.searchQuery}".</bim-label
|
|
158
|
+
>`}
|
|
159
|
+
</bim-panel-section>`;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/* MD
|
|
164
|
+
### 🧱 Composing a custom layout with `headless`
|
|
165
|
+
|
|
166
|
+
Set the `headless` attribute to skip the panel's own 5 stock sections —
|
|
167
|
+
everything else (the search box, the reset button, both contexts) keeps
|
|
168
|
+
running. Slot whatever `top-*-settings` elements and/or your own sections
|
|
169
|
+
as light-DOM children, in whatever order you want; that's exactly what
|
|
170
|
+
renders.
|
|
171
|
+
|
|
172
|
+
The most common case: keep every stock section and just add your own —
|
|
173
|
+
this is the live demo below.
|
|
174
|
+
|
|
175
|
+
```html
|
|
176
|
+
<top-settings-panel headless>
|
|
177
|
+
<top-graphic-settings></top-graphic-settings>
|
|
178
|
+
<top-clipstyling-settings></top-clipstyling-settings>
|
|
179
|
+
<top-measurement-settings></top-measurement-settings>
|
|
180
|
+
<top-fileconversion-settings></top-fileconversion-settings>
|
|
181
|
+
<top-commands-settings></top-commands-settings>
|
|
182
|
+
<my-lidar-settings></my-lidar-settings>
|
|
183
|
+
</top-settings-panel>
|
|
184
|
+
```
|
|
185
|
+
*/
|
|
186
|
+
|
|
187
|
+
const app = document.createElement("top-app") as unknown as App;
|
|
188
|
+
|
|
189
|
+
app.setup = (waitUntil) => {
|
|
190
|
+
waitUntil(
|
|
191
|
+
(async () => {
|
|
192
|
+
const fragments = components.get(OBC.FragmentsManager);
|
|
193
|
+
const workerUrl = await FRAGS.FragmentsModels.getWorker();
|
|
194
|
+
fragments.init(await FRAGS.toClassicWorker(workerUrl), { classicWorker: true });
|
|
195
|
+
})(),
|
|
196
|
+
"Fragments Core",
|
|
197
|
+
);
|
|
198
|
+
return { components, client };
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
app.elements = {
|
|
202
|
+
viewer: () =>
|
|
203
|
+
html`<top-viewer><top-viewer-toolbar></top-viewer-toolbar></top-viewer>`,
|
|
204
|
+
settings: () => html`
|
|
205
|
+
<top-settings-panel headless>
|
|
206
|
+
<top-graphic-settings></top-graphic-settings>
|
|
207
|
+
<top-clipstyling-settings></top-clipstyling-settings>
|
|
208
|
+
<top-measurement-settings></top-measurement-settings>
|
|
209
|
+
<top-fileconversion-settings></top-fileconversion-settings>
|
|
210
|
+
<top-commands-settings></top-commands-settings>
|
|
211
|
+
<my-lidar-settings></my-lidar-settings>
|
|
212
|
+
</top-settings-panel>
|
|
213
|
+
`,
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
app.layouts = {
|
|
217
|
+
main: {
|
|
218
|
+
label: "Main",
|
|
219
|
+
icon: "solar:3d-square-bold",
|
|
220
|
+
template: `"viewer settings" 1fr / 1fr 22rem`,
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
app.layout = "main";
|
|
225
|
+
|
|
226
|
+
const container = document.getElementById("that-open-app") ?? document.body;
|
|
227
|
+
container.appendChild(app);
|
|
228
|
+
document.body.style.margin = "0";
|
|
229
|
+
|
|
230
|
+
/* MD
|
|
231
|
+
### 🔀 A few other ways to compose it
|
|
232
|
+
|
|
233
|
+
A lighter viewer that only needs Graphics plus its own section — drop
|
|
234
|
+
everything else:
|
|
235
|
+
|
|
236
|
+
```html
|
|
237
|
+
<top-settings-panel headless>
|
|
238
|
+
<top-graphic-settings></top-graphic-settings>
|
|
239
|
+
<my-lidar-settings></my-lidar-settings>
|
|
240
|
+
</top-settings-panel>
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Reordering — `headless` respects DOM order, so Commands first is just:
|
|
244
|
+
|
|
245
|
+
```html
|
|
246
|
+
<top-settings-panel headless>
|
|
247
|
+
<top-commands-settings></top-commands-settings>
|
|
248
|
+
<top-graphic-settings></top-graphic-settings>
|
|
249
|
+
<top-clipstyling-settings></top-clipstyling-settings>
|
|
250
|
+
<top-measurement-settings></top-measurement-settings>
|
|
251
|
+
<top-fileconversion-settings></top-fileconversion-settings>
|
|
252
|
+
</top-settings-panel>
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Swapping a single stock section for your own (e.g. Measurement with
|
|
256
|
+
different units) — the same `headless` list, just with that one tag
|
|
257
|
+
replaced:
|
|
258
|
+
|
|
259
|
+
```html
|
|
260
|
+
<top-settings-panel headless>
|
|
261
|
+
<top-graphic-settings></top-graphic-settings>
|
|
262
|
+
<top-clipstyling-settings></top-clipstyling-settings>
|
|
263
|
+
<my-measurement-settings></my-measurement-settings>
|
|
264
|
+
<top-fileconversion-settings></top-fileconversion-settings>
|
|
265
|
+
<top-commands-settings></top-commands-settings>
|
|
266
|
+
</top-settings-panel>
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Keeping the full stock default and only ADDING a section, without going
|
|
270
|
+
`headless` at all — the non-headless layout also projects a trailing
|
|
271
|
+
`<slot>`, so any light-DOM children you give it render after the 5 stock
|
|
272
|
+
sections:
|
|
273
|
+
|
|
274
|
+
```html
|
|
275
|
+
<top-settings-panel>
|
|
276
|
+
<my-lidar-settings></my-lidar-settings>
|
|
277
|
+
</top-settings-panel>
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### ⚠️ Gotchas
|
|
281
|
+
|
|
282
|
+
- **Never `document.createElement` a `bim-*` element** — same rule as
|
|
283
|
+
`top-viewer-toolbar`. Render them with lit's `html`/`render` (or, as
|
|
284
|
+
here, from inside your own `LitElement`'s `render()`); never build them
|
|
285
|
+
imperatively.
|
|
286
|
+
- **A custom section renders its OWN `<bim-panel-section>`**, in its own
|
|
287
|
+
shadow root — there's no API to inject rows into a stock section, only
|
|
288
|
+
to sit alongside it.
|
|
289
|
+
- **`fixed` layout quirk**: `<bim-panel-section>`'s default logic checks
|
|
290
|
+
`this.closest("bim-panel")`, which can't see past your own section's
|
|
291
|
+
shadow boundary — so, like the stock sections, a custom one may render
|
|
292
|
+
with `fixed` behavior until the upstream `@thatopen/ui` fix ships. Not
|
|
293
|
+
something to work around here; tracked separately.
|
|
294
|
+
- **Search filtering is opt-in per section** — consuming
|
|
295
|
+
`settingsSearchContext` is what makes a section respond to the shared
|
|
296
|
+
search box; forgetting it just means that section never filters, not an
|
|
297
|
+
error.
|
|
298
|
+
*/
|