@thatopen/services 0.34.5 → 0.35.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.
Files changed (118) hide show
  1. package/README.md +66 -66
  2. package/dist/cli.js +54 -12
  3. package/dist/cli.js.map +1 -1
  4. package/dist/core/app-cache.d.ts +32 -0
  5. package/dist/core/app-cache.test.d.ts +1 -0
  6. package/dist/core/client.d.ts +9 -1
  7. package/dist/index.cjs.js +5 -5
  8. package/dist/index.cjs.js.map +1 -1
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.es.js +974 -917
  11. package/dist/index.es.js.map +1 -1
  12. package/dist/types/context.d.ts +6 -0
  13. package/dist/vite-env.d.ts +1 -1
  14. package/docs/ai-quickstart.md +548 -548
  15. package/docs/builtin/paths.json +130 -130
  16. package/docs/cli/create.md +29 -29
  17. package/docs/cli/local-server.md +38 -38
  18. package/docs/cli/login.md +32 -32
  19. package/docs/cli/mcp.md +46 -46
  20. package/docs/cli/publish.md +31 -31
  21. package/docs/cli/run.md +26 -26
  22. package/docs/cli/serve.md +43 -43
  23. package/docs/cli/swap.md +30 -30
  24. package/docs/cloud/GaussianSplatConverter.md +43 -43
  25. package/docs/cloud/PointCloudConverter.md +53 -53
  26. package/docs/flow-architecture.md +393 -393
  27. package/docs/flow-plugin-guide.md +354 -354
  28. package/docs/platform-token.md +81 -81
  29. package/docs/rate-limits.md +133 -133
  30. package/docs/recipes-guide.md +243 -243
  31. package/docs/revit-collab-quickstart.md +445 -445
  32. package/docs/rhino-interop-quickstart.md +387 -387
  33. package/docs/sheet-sets-guide.md +69 -69
  34. package/package.json +4 -4
  35. package/resources/AGENTS.md +57 -57
  36. package/src/built-in/CDEManager/example.ts +214 -214
  37. package/src/built-in/CDEManager/examples/FileEditing/example.ts +226 -226
  38. package/src/built-in/CDEManager/examples/FileMoves/example.ts +186 -186
  39. package/src/built-in/CDEManager/examples/FileOperations/example.ts +295 -295
  40. package/src/built-in/CDEManager/examples/FileTransfers/example.ts +210 -210
  41. package/src/built-in/CDEManager/examples/FolderManagement/example.ts +230 -230
  42. package/src/built-in/CDEManager/examples/MetadataSchema/example.ts +230 -230
  43. package/src/built-in/CDEManager/examples/MetadataViews/example.ts +166 -166
  44. package/src/built-in/CDEManager/examples/ProjectConfig/example.ts +177 -177
  45. package/src/built-in/ClashesManager/example.ts +283 -283
  46. package/src/built-in/GISManager/example.ts +355 -355
  47. package/src/built-in/ProjectManager/example.ts +124 -124
  48. package/src/built-in/UIManager/src/app/example.ts +97 -97
  49. package/src/built-in/UIManager/src/app/examples/AppState/example.ts +140 -140
  50. package/src/built-in/UIManager/src/app/examples/Banner/example.ts +159 -159
  51. package/src/built-in/UIManager/src/app/examples/Contexts/example.ts +123 -123
  52. package/src/built-in/UIManager/src/app/examples/FileDrop/example.ts +124 -124
  53. package/src/built-in/UIManager/src/app/examples/FloatingLayout/example.ts +90 -90
  54. package/src/built-in/UIManager/src/app/examples/Modal/example.ts +163 -163
  55. package/src/built-in/UIManager/src/app/examples/Notifications/example.ts +133 -133
  56. package/src/built-in/UIManager/src/app/examples/ProjectFileStorage/example.ts +150 -150
  57. package/src/built-in/UIManager/src/app/examples/Sidebar/example.ts +105 -105
  58. package/src/built-in/UIManager/src/clashes-panel/example.ts +183 -183
  59. package/src/built-in/UIManager/src/gis-panel/example.ts +163 -163
  60. package/src/built-in/UIManager/src/gis-properties-panel/example.ts +168 -168
  61. package/src/built-in/UIManager/src/git-history-panel/example.ts +70 -70
  62. package/src/built-in/UIManager/src/map-panel/example.ts +189 -189
  63. package/src/built-in/UIManager/src/models-list/example.ts +181 -181
  64. package/src/built-in/UIManager/src/settings-panel/example.ts +303 -303
  65. package/src/built-in/UIManager/src/topics-panel/example.ts +170 -170
  66. package/src/built-in/UIManager/src/viewer/example.ts +182 -182
  67. package/src/built-in/UIManager/src/viewer-toolbar/example.ts +376 -376
  68. package/src/built-in/index.ts +2995 -2995
  69. package/src/cli/templates/app/README.md +250 -250
  70. package/src/cli/templates/app/index.html +35 -35
  71. package/src/cli/templates/app/package.json +32 -32
  72. package/src/cli/templates/app/src/app.ts +37 -37
  73. package/src/cli/templates/app/src/assets/tool-placeholder.ts +50 -50
  74. package/src/cli/templates/app/src/bim-components/CloudRunner/index.ts +95 -95
  75. package/src/cli/templates/app/src/bim-components/CloudRunner/src/index.ts +1 -1
  76. package/src/cli/templates/app/src/bim-components/CloudRunner/src/types.ts +5 -5
  77. package/src/cli/templates/app/src/bim-components/index.ts +1 -1
  78. package/src/cli/templates/app/src/globals.ts +1 -1
  79. package/src/cli/templates/app/src/main.history.ts +191 -191
  80. package/src/cli/templates/app/src/main.ts +226 -226
  81. package/src/cli/templates/app/src/setups/channel.ts +76 -76
  82. package/src/cli/templates/app/src/setups/reality-capture/lib/hidden-tiles-plugin.ts +88 -88
  83. package/src/cli/templates/app/src/setups/reality-capture/lib/point-tile-plugin.ts +166 -166
  84. package/src/cli/templates/app/src/setups/reality-capture/lib/render-frame.ts +31 -31
  85. package/src/cli/templates/app/src/setups/reality-capture/lib/splat-tile-plugin.ts +51 -51
  86. package/src/cli/templates/app/src/setups/reality-capture-viewer.ts +1383 -1383
  87. package/src/cli/templates/app/src/ui-components/app-info-section/index.ts +26 -26
  88. package/src/cli/templates/app/src/ui-components/app-info-section/src/index.ts +1 -1
  89. package/src/cli/templates/app/src/ui-components/app-info-section/src/types.ts +15 -15
  90. package/src/cli/templates/app/src/ui-components/cloud-runner-section/index.ts +37 -37
  91. package/src/cli/templates/app/src/ui-components/cloud-runner-section/src/index.ts +1 -1
  92. package/src/cli/templates/app/src/ui-components/cloud-runner-section/src/types.ts +14 -14
  93. package/src/cli/templates/app/src/ui-components/index.ts +2 -2
  94. package/src/cli/templates/app/tsconfig.json +16 -16
  95. package/src/cli/templates/app/vite.config.js +57 -57
  96. package/src/cli/templates/cloud-component/README.md +205 -205
  97. package/src/cli/templates/cloud-component/_thatopen +5 -5
  98. package/src/cli/templates/cloud-component/declarations.json +4 -4
  99. package/src/cli/templates/cloud-component/package.json +21 -21
  100. package/src/cli/templates/cloud-component/src/main.ts +70 -70
  101. package/src/cli/templates/cloud-component/tsconfig.json +16 -16
  102. package/src/cli/templates/cloud-component/vite.config.js +46 -46
  103. package/src/cli/templates/shared/AGENTS.md +8 -8
  104. package/src/cli/templates/shared/CLAUDE.md +1 -1
  105. package/src/cli/templates/shared/_gitignore +5 -5
  106. package/src/core/examples/.env.example +7 -7
  107. package/src/core/examples/apps.ts +67 -67
  108. package/src/core/examples/batch-reads.ts +99 -99
  109. package/src/core/examples/channel.ts +65 -65
  110. package/src/core/examples/components.ts +91 -91
  111. package/src/core/examples/execution.ts +75 -75
  112. package/src/core/examples/file-metadata.ts +94 -94
  113. package/src/core/examples/files.ts +81 -81
  114. package/src/core/examples/folders.ts +82 -82
  115. package/src/core/examples/hidden-files.ts +88 -88
  116. package/src/core/examples/history.ts +103 -103
  117. package/src/core/examples/icons.ts +68 -68
  118. package/src/core/examples/permissions.ts +87 -87
@@ -1,250 +1,250 @@
1
- # ThatOpen BIM App
2
-
3
- This is a BIM (Building Information Modeling) app built for the That Open Platform.
4
- It runs in the browser inside the platform's iframe and has access to a 3D viewer,
5
- UI components, and the platform API.
6
-
7
- > IMPORTANT for AI assistants: the authoritative, always-current reference for the
8
- > platform rules, the built-in components, and how to wire each one is shipped
9
- > inside the installed package. Read these before writing code:
10
- >
11
- > - `node_modules/@thatopen/services/resources/AGENTS.md` — platform rules + the
12
- > full navigation table.
13
- > - `node_modules/@thatopen/services/docs/builtin/paths.json` — the index of every
14
- > built-in component, with a one-line description and the path to its example.
15
- > - `node_modules/@thatopen/services/src/built-in/<Component>/example.ts` — a
16
- > complete, copy-adaptable integration example per component.
17
- >
18
- > This README explains the app's shape and the general pattern. For the exact API
19
- > of any built-in, trust `paths.json` + the example files over any list here.
20
-
21
- ## How this app works
22
-
23
- - **Entry point**: `src/main.ts` — runs as an IIFE when the platform loads the app.
24
- - **Build output**: `dist/bundle.js` — a single IIFE file.
25
- - **Platform context**: the platform injects the app's context (project id, access
26
- token, API url). `PlatformClient.fromPlatformContext()` reads it for you.
27
-
28
- ## Commands
29
-
30
- ```bash
31
- npm run dev # Start the dev server (esbuild watch + serve on :4000)
32
- npm run build # Build dist/bundle.js
33
- npm run login # Authenticate with the platform (saves token locally)
34
- npm run publish # Publish to the platform
35
- ```
36
-
37
- ### Local development
38
-
39
- Apps run inside the That Open Platform within a project, not as standalone websites.
40
- To develop locally:
41
-
42
- 1. Run `npm run dev` — watches source with esbuild and serves the bundle on port 4000.
43
- 2. Open your project on the platform, click the Local App icon, then Get Started.
44
- 3. Live reload is enabled — save a file to rebuild automatically.
45
-
46
- **Important**: use `npm run dev` (it runs `thatopen serve` under the hood). Do NOT run
47
- `vite` / `vite build --watch` directly for development — `thatopen serve` applies the
48
- correct build settings (including the beta engine-library aliases for beta projects).
49
-
50
- ## Key libraries
51
-
52
- | Package | Import as | Purpose |
53
- |---------|-----------|---------|
54
- | `@thatopen/components` | `OBC` | BIM engine — components, fragments, worlds |
55
- | `@thatopen/components-front` | `OBF` | Front-end BIM components (Highlighter, measurements, …) |
56
- | `@thatopen/fragments` | `FRAGS` | Fragment geometry format |
57
- | `@thatopen/ui` | `BUI` | UI web components (`<bim-panel>`, `<bim-grid>`, …) |
58
- | `three` | `THREE` | 3D rendering engine |
59
- | `@markerjs/markerjs3` | `MARKERJS` | Screenshot annotation |
60
- | `@thatopen/services` | (named exports) | Platform API client (`PlatformClient`) + built-in components |
61
-
62
- ```ts
63
- import * as OBC from "@thatopen/components";
64
- import * as OBF from "@thatopen/components-front";
65
- import * as FRAGS from "@thatopen/fragments";
66
- import * as BUI from "@thatopen/ui";
67
- import * as THREE from "three";
68
- import * as MARKERJS from "@markerjs/markerjs3";
69
- import { PlatformClient, UIManager } from "@thatopen/services";
70
- ```
71
-
72
- ## Architecture
73
-
74
- The app boots on the **`UIManager`** built-in. `UIManager` registers the platform's
75
- web components — the app shell and viewport plus every panel — as custom elements you
76
- place with plain HTML/`BUI.html`:
77
-
78
- - `<top-app>` — the app shell: a CSS-grid layout system with a sidebar (activity bar)
79
- for switching named layouts.
80
- - `<top-viewer>` — the 3D viewport (pre-configured world: scene, camera, renderer,
81
- fragments), with its own tools baked in.
82
- - `<top-viewer-toolbar>` — the bottom viewer toolbar (visibility/inspect, clip, measure).
83
- - Side panels — `<top-model-tree>`, `<top-properties-panel>`, `<top-models-list>`,
84
- `<top-data-table-panel>`, `<top-objects-panel>`, `<top-settings-panel>`, … — each
85
- self-wires from the contexts `<top-app>` provides (no `components` plumbing needed).
86
-
87
- The scaffolded `src/main.ts` already sets this up. The shape is:
88
-
89
- ```ts
90
- const client = PlatformClient.fromPlatformContext();
91
-
92
- // 1. Register the platform web components. UIManager MUST be in setup — it
93
- // defines <top-app>, <top-viewer>, the panels, etc. before the DOM renders.
94
- const { components } = await client.setup<OBC.Components>(
95
- { OBC, OBF, BUI, THREE, FRAGS, MARKERJS },
96
- { uuid: UIManager.uuid },
97
- );
98
- components.get(UIManager).init();
99
-
100
- // 2. Build the shell: <top-app> with named element slots + named layouts.
101
- const app = document.createElement("top-app") as any;
102
- app.elements = {
103
- viewer: () => BUI.html`<top-viewer></top-viewer>`,
104
- tree: () => BUI.html`<top-model-tree></top-model-tree>`,
105
- // …more panels…
106
- };
107
- app.layouts = {
108
- Explorer: { icon: "mdi:file-tree", template: `"tree viewer" 1fr / 22rem 1fr` },
109
- // …more layouts…
110
- };
111
- app.layout = "Explorer";
112
- app.sidebar = true;
113
- document.getElementById("that-open-app")?.appendChild(app);
114
- ```
115
-
116
- A layout `template` is CSS `grid-template` shorthand: `"areas" rows / columns`, where
117
- each area name maps to a key in `app.elements`. Each layout with an `icon` becomes a
118
- sidebar (activity-bar) button.
119
-
120
- Built-ins are loaded from the platform at runtime **by uuid** through the `setup`
121
- call. You import each one as a named export from `@thatopen/services` (a ready
122
- `{ uuid }` stub with types), never by a deep/internal path.
123
-
124
- ## Built-in components
125
-
126
- The current, authoritative list lives in
127
- `node_modules/@thatopen/services/docs/builtin/paths.json` (index) with a full example
128
- per component under `node_modules/@thatopen/services/src/built-in/`. At a high level:
129
-
130
- - **`UIManager`** — the shell + viewport + all `top-*` panels above (already wired by
131
- the scaffold).
132
- - **`CDEManager`** — the platform CDE: files, folders, versions, metadata.
133
- - **`ClashesManager`** + `<top-clashes-panel>` — clash detection and the ready-made
134
- clash review UI (detection matrix, run controls, status filters, markers, highlights).
135
- - **`FileList`** — a simple file list.
136
-
137
- Read the matching `example.ts` for each before using it — the examples are the
138
- source of truth for imports, ordering constraints, and wiring.
139
-
140
- ### Adding a built-in feature (the general pattern)
141
-
142
- Every manager-style built-in follows the same three steps. Example — adding clash
143
- detection (see `ClashesManager/example.ts` and `UIManager/src/clashes-panel/example.ts`):
144
-
145
- ```ts
146
- // 1. Import the built-in as a named export from @thatopen/services.
147
- import { PlatformClient, UIManager, ClashesManager } from "@thatopen/services";
148
-
149
- // 2. Register it by uuid in the SAME setup call as UIManager.
150
- const { components } = await client.setup<OBC.Components>(
151
- { OBC, OBF, BUI, THREE, FRAGS, MARKERJS },
152
- { uuid: UIManager.uuid },
153
- { uuid: ClashesManager.uuid },
154
- );
155
-
156
- // 3a. Init the manager. Do this BEFORE its panel mounts — the panel reads its
157
- // initial data in connectedCallback and only subscribes to changes afterward.
158
- await components.get(ClashesManager).init(client);
159
-
160
- // 3b. Mount the panel web component in a layout slot (UIManager registered it).
161
- app.elements = {
162
- // …existing elements…
163
- clashes: () => BUI.html`<top-clashes-panel></top-clashes-panel>`,
164
- };
165
- app.layouts = {
166
- // …existing layouts…
167
- Clashes: { icon: "mdi:vector-intersection", template: `"clashes viewer" 1fr / 22rem 1fr` },
168
- };
169
- ```
170
-
171
- The panel self-wires to its manager — you do not pass props or wire events by hand.
172
-
173
- ## Loading a BIM model
174
-
175
- ```ts
176
- const fragments = components.get(OBC.FragmentsManager);
177
-
178
- // From URL
179
- const buffer = await (await fetch("https://example.com/model.frag")).arrayBuffer();
180
- await fragments.core.load(buffer, { modelId: "my-model" });
181
-
182
- // From platform storage
183
- const fileBuffer = await (await client.downloadFile(fileId)).arrayBuffer();
184
- await fragments.core.load(fileBuffer, { modelId: "my-model" });
185
- ```
186
-
187
- (The scaffold's `<top-models-list>` panel already loads models the user picks, so you
188
- usually don't need to do this by hand.)
189
-
190
- ## PlatformClient API (commonly used in apps)
191
-
192
- ```ts
193
- const client = PlatformClient.fromPlatformContext();
194
- console.log(client.context.projectId);
195
-
196
- // Files / folders
197
- const files = await client.listFiles();
198
- const response = await client.downloadFile(fileId);
199
- await client.createFile({ file: blob, name: "model.ifc", versionTag: "v1" });
200
- await client.createFolder("My Folder");
201
-
202
- // Execute cloud components
203
- const { executionId } = await client.executeComponent(componentId, { param: "value" });
204
- client.onExecutionProgress(executionId, (data) => {
205
- // data.progressUpdate — progress %, data.messageUpdate — status
206
- });
207
-
208
- // Test against a local cloud component (thatopen local-server running in that project)
209
- client.localServerUrl = "http://localhost:4001";
210
- ```
211
-
212
- ## The channel: external control + multiplayer
213
-
214
- This app ships listening on the platform channel (`src/setups/channel.ts`). Two
215
- things work out of the box:
216
-
217
- - **External tools can command it.** An MCP server, a CLI or a plugin
218
- authenticated with a platform token of the same account can send the commands
219
- declared in `AppCommands` (`ping`, `get-loaded-models`) and gets typed
220
- replies back. This is how a desktop LLM drives the running app.
221
- - **Tabs of this app see each other.** Every open tab joins a collaboration
222
- room shared across accounts (`AppCollabEvents`) — the base for cursors,
223
- presence and live sync.
224
-
225
- To add a command, extend the map and handle it; whatever you return is the reply:
226
-
227
- ```ts
228
- export type AppCommands = {
229
- // ...existing commands...
230
- "select-by-category": { payload: { category: string }; reply: { count: number } };
231
- };
232
-
233
- external.on("select-by-category", async ({ category }) => {
234
- const count = await selectByCategory(category);
235
- return { count };
236
- });
237
- ```
238
-
239
- The app never opens a socket: the platform shell owns the connection and relays
240
- it, which is also the security boundary. Joining is opt-in per room — the
241
- scaffold joins at boot; move the `join()` calls behind a button to make it a
242
- user choice. Full walkthrough with a collab example:
243
- `node_modules/@thatopen/services/src/core/examples/channel.ts`.
244
-
245
- ## Configuration
246
-
247
- - `.thatopen` — local config (gitignored). Created by `npm run login`; also holds
248
- `beta: true` for beta projects and the `appId` after the first publish.
249
- - `vite.config.js` — builds the IIFE `dist/bundle.js`; for beta projects it aliases
250
- the `@thatopen/*` engine imports to their `@thatopen-platform/*-beta` packages.
1
+ # ThatOpen BIM App
2
+
3
+ This is a BIM (Building Information Modeling) app built for the That Open Platform.
4
+ It runs in the browser inside the platform's iframe and has access to a 3D viewer,
5
+ UI components, and the platform API.
6
+
7
+ > IMPORTANT for AI assistants: the authoritative, always-current reference for the
8
+ > platform rules, the built-in components, and how to wire each one is shipped
9
+ > inside the installed package. Read these before writing code:
10
+ >
11
+ > - `node_modules/@thatopen/services/resources/AGENTS.md` — platform rules + the
12
+ > full navigation table.
13
+ > - `node_modules/@thatopen/services/docs/builtin/paths.json` — the index of every
14
+ > built-in component, with a one-line description and the path to its example.
15
+ > - `node_modules/@thatopen/services/src/built-in/<Component>/example.ts` — a
16
+ > complete, copy-adaptable integration example per component.
17
+ >
18
+ > This README explains the app's shape and the general pattern. For the exact API
19
+ > of any built-in, trust `paths.json` + the example files over any list here.
20
+
21
+ ## How this app works
22
+
23
+ - **Entry point**: `src/main.ts` — runs as an IIFE when the platform loads the app.
24
+ - **Build output**: `dist/bundle.js` — a single IIFE file.
25
+ - **Platform context**: the platform injects the app's context (project id, access
26
+ token, API url). `PlatformClient.fromPlatformContext()` reads it for you.
27
+
28
+ ## Commands
29
+
30
+ ```bash
31
+ npm run dev # Start the dev server (esbuild watch + serve on :4000)
32
+ npm run build # Build dist/bundle.js
33
+ npm run login # Authenticate with the platform (saves token locally)
34
+ npm run publish # Publish to the platform
35
+ ```
36
+
37
+ ### Local development
38
+
39
+ Apps run inside the That Open Platform within a project, not as standalone websites.
40
+ To develop locally:
41
+
42
+ 1. Run `npm run dev` — watches source with esbuild and serves the bundle on port 4000.
43
+ 2. Open your project on the platform, click the Local App icon, then Get Started.
44
+ 3. Live reload is enabled — save a file to rebuild automatically.
45
+
46
+ **Important**: use `npm run dev` (it runs `thatopen serve` under the hood). Do NOT run
47
+ `vite` / `vite build --watch` directly for development — `thatopen serve` applies the
48
+ correct build settings (including the beta engine-library aliases for beta projects).
49
+
50
+ ## Key libraries
51
+
52
+ | Package | Import as | Purpose |
53
+ |---------|-----------|---------|
54
+ | `@thatopen/components` | `OBC` | BIM engine — components, fragments, worlds |
55
+ | `@thatopen/components-front` | `OBF` | Front-end BIM components (Highlighter, measurements, …) |
56
+ | `@thatopen/fragments` | `FRAGS` | Fragment geometry format |
57
+ | `@thatopen/ui` | `BUI` | UI web components (`<bim-panel>`, `<bim-grid>`, …) |
58
+ | `three` | `THREE` | 3D rendering engine |
59
+ | `@markerjs/markerjs3` | `MARKERJS` | Screenshot annotation |
60
+ | `@thatopen/services` | (named exports) | Platform API client (`PlatformClient`) + built-in components |
61
+
62
+ ```ts
63
+ import * as OBC from "@thatopen/components";
64
+ import * as OBF from "@thatopen/components-front";
65
+ import * as FRAGS from "@thatopen/fragments";
66
+ import * as BUI from "@thatopen/ui";
67
+ import * as THREE from "three";
68
+ import * as MARKERJS from "@markerjs/markerjs3";
69
+ import { PlatformClient, UIManager } from "@thatopen/services";
70
+ ```
71
+
72
+ ## Architecture
73
+
74
+ The app boots on the **`UIManager`** built-in. `UIManager` registers the platform's
75
+ web components — the app shell and viewport plus every panel — as custom elements you
76
+ place with plain HTML/`BUI.html`:
77
+
78
+ - `<top-app>` — the app shell: a CSS-grid layout system with a sidebar (activity bar)
79
+ for switching named layouts.
80
+ - `<top-viewer>` — the 3D viewport (pre-configured world: scene, camera, renderer,
81
+ fragments), with its own tools baked in.
82
+ - `<top-viewer-toolbar>` — the bottom viewer toolbar (visibility/inspect, clip, measure).
83
+ - Side panels — `<top-model-tree>`, `<top-properties-panel>`, `<top-models-list>`,
84
+ `<top-data-table-panel>`, `<top-objects-panel>`, `<top-settings-panel>`, … — each
85
+ self-wires from the contexts `<top-app>` provides (no `components` plumbing needed).
86
+
87
+ The scaffolded `src/main.ts` already sets this up. The shape is:
88
+
89
+ ```ts
90
+ const client = PlatformClient.fromPlatformContext();
91
+
92
+ // 1. Register the platform web components. UIManager MUST be in setup — it
93
+ // defines <top-app>, <top-viewer>, the panels, etc. before the DOM renders.
94
+ const { components } = await client.setup<OBC.Components>(
95
+ { OBC, OBF, BUI, THREE, FRAGS, MARKERJS },
96
+ { uuid: UIManager.uuid },
97
+ );
98
+ components.get(UIManager).init();
99
+
100
+ // 2. Build the shell: <top-app> with named element slots + named layouts.
101
+ const app = document.createElement("top-app") as any;
102
+ app.elements = {
103
+ viewer: () => BUI.html`<top-viewer></top-viewer>`,
104
+ tree: () => BUI.html`<top-model-tree></top-model-tree>`,
105
+ // …more panels…
106
+ };
107
+ app.layouts = {
108
+ Explorer: { icon: "mdi:file-tree", template: `"tree viewer" 1fr / 22rem 1fr` },
109
+ // …more layouts…
110
+ };
111
+ app.layout = "Explorer";
112
+ app.sidebar = true;
113
+ document.getElementById("that-open-app")?.appendChild(app);
114
+ ```
115
+
116
+ A layout `template` is CSS `grid-template` shorthand: `"areas" rows / columns`, where
117
+ each area name maps to a key in `app.elements`. Each layout with an `icon` becomes a
118
+ sidebar (activity-bar) button.
119
+
120
+ Built-ins are loaded from the platform at runtime **by uuid** through the `setup`
121
+ call. You import each one as a named export from `@thatopen/services` (a ready
122
+ `{ uuid }` stub with types), never by a deep/internal path.
123
+
124
+ ## Built-in components
125
+
126
+ The current, authoritative list lives in
127
+ `node_modules/@thatopen/services/docs/builtin/paths.json` (index) with a full example
128
+ per component under `node_modules/@thatopen/services/src/built-in/`. At a high level:
129
+
130
+ - **`UIManager`** — the shell + viewport + all `top-*` panels above (already wired by
131
+ the scaffold).
132
+ - **`CDEManager`** — the platform CDE: files, folders, versions, metadata.
133
+ - **`ClashesManager`** + `<top-clashes-panel>` — clash detection and the ready-made
134
+ clash review UI (detection matrix, run controls, status filters, markers, highlights).
135
+ - **`FileList`** — a simple file list.
136
+
137
+ Read the matching `example.ts` for each before using it — the examples are the
138
+ source of truth for imports, ordering constraints, and wiring.
139
+
140
+ ### Adding a built-in feature (the general pattern)
141
+
142
+ Every manager-style built-in follows the same three steps. Example — adding clash
143
+ detection (see `ClashesManager/example.ts` and `UIManager/src/clashes-panel/example.ts`):
144
+
145
+ ```ts
146
+ // 1. Import the built-in as a named export from @thatopen/services.
147
+ import { PlatformClient, UIManager, ClashesManager } from "@thatopen/services";
148
+
149
+ // 2. Register it by uuid in the SAME setup call as UIManager.
150
+ const { components } = await client.setup<OBC.Components>(
151
+ { OBC, OBF, BUI, THREE, FRAGS, MARKERJS },
152
+ { uuid: UIManager.uuid },
153
+ { uuid: ClashesManager.uuid },
154
+ );
155
+
156
+ // 3a. Init the manager. Do this BEFORE its panel mounts — the panel reads its
157
+ // initial data in connectedCallback and only subscribes to changes afterward.
158
+ await components.get(ClashesManager).init(client);
159
+
160
+ // 3b. Mount the panel web component in a layout slot (UIManager registered it).
161
+ app.elements = {
162
+ // …existing elements…
163
+ clashes: () => BUI.html`<top-clashes-panel></top-clashes-panel>`,
164
+ };
165
+ app.layouts = {
166
+ // …existing layouts…
167
+ Clashes: { icon: "mdi:vector-intersection", template: `"clashes viewer" 1fr / 22rem 1fr` },
168
+ };
169
+ ```
170
+
171
+ The panel self-wires to its manager — you do not pass props or wire events by hand.
172
+
173
+ ## Loading a BIM model
174
+
175
+ ```ts
176
+ const fragments = components.get(OBC.FragmentsManager);
177
+
178
+ // From URL
179
+ const buffer = await (await fetch("https://example.com/model.frag")).arrayBuffer();
180
+ await fragments.core.load(buffer, { modelId: "my-model" });
181
+
182
+ // From platform storage
183
+ const fileBuffer = await (await client.downloadFile(fileId)).arrayBuffer();
184
+ await fragments.core.load(fileBuffer, { modelId: "my-model" });
185
+ ```
186
+
187
+ (The scaffold's `<top-models-list>` panel already loads models the user picks, so you
188
+ usually don't need to do this by hand.)
189
+
190
+ ## PlatformClient API (commonly used in apps)
191
+
192
+ ```ts
193
+ const client = PlatformClient.fromPlatformContext();
194
+ console.log(client.context.projectId);
195
+
196
+ // Files / folders
197
+ const files = await client.listFiles();
198
+ const response = await client.downloadFile(fileId);
199
+ await client.createFile({ file: blob, name: "model.ifc", versionTag: "v1" });
200
+ await client.createFolder("My Folder");
201
+
202
+ // Execute cloud components
203
+ const { executionId } = await client.executeComponent(componentId, { param: "value" });
204
+ client.onExecutionProgress(executionId, (data) => {
205
+ // data.progressUpdate — progress %, data.messageUpdate — status
206
+ });
207
+
208
+ // Test against a local cloud component (thatopen local-server running in that project)
209
+ client.localServerUrl = "http://localhost:4001";
210
+ ```
211
+
212
+ ## The channel: external control + multiplayer
213
+
214
+ This app ships listening on the platform channel (`src/setups/channel.ts`). Two
215
+ things work out of the box:
216
+
217
+ - **External tools can command it.** An MCP server, a CLI or a plugin
218
+ authenticated with a platform token of the same account can send the commands
219
+ declared in `AppCommands` (`ping`, `get-loaded-models`) and gets typed
220
+ replies back. This is how a desktop LLM drives the running app.
221
+ - **Tabs of this app see each other.** Every open tab joins a collaboration
222
+ room shared across accounts (`AppCollabEvents`) — the base for cursors,
223
+ presence and live sync.
224
+
225
+ To add a command, extend the map and handle it; whatever you return is the reply:
226
+
227
+ ```ts
228
+ export type AppCommands = {
229
+ // ...existing commands...
230
+ "select-by-category": { payload: { category: string }; reply: { count: number } };
231
+ };
232
+
233
+ external.on("select-by-category", async ({ category }) => {
234
+ const count = await selectByCategory(category);
235
+ return { count };
236
+ });
237
+ ```
238
+
239
+ The app never opens a socket: the platform shell owns the connection and relays
240
+ it, which is also the security boundary. Joining is opt-in per room — the
241
+ scaffold joins at boot; move the `join()` calls behind a button to make it a
242
+ user choice. Full walkthrough with a collab example:
243
+ `node_modules/@thatopen/services/src/core/examples/channel.ts`.
244
+
245
+ ## Configuration
246
+
247
+ - `.thatopen` — local config (gitignored). Created by `npm run login`; also holds
248
+ `beta: true` for beta projects and the `appId` after the first publish.
249
+ - `vite.config.js` — builds the IIFE `dist/bundle.js`; for beta projects it aliases
250
+ the `@thatopen/*` engine imports to their `@thatopen-platform/*-beta` packages.
@@ -1,35 +1,35 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>ThatOpen App</title>
7
- <style>
8
- *, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
9
- html, body { width: 100%; height: 100%; overflow: hidden; font-family: system-ui, -apple-system, sans-serif; }
10
- #that-open-app { width: 100%; height: 100%; }
11
- /* Scrollbar rail = the panel surface (#262629). Every panel (app .xxx-vp
12
- tracks) and every bim-* shadow-DOM scrollbar reads var(--bim-scrollbar--bgc,
13
- …), so defining it once here makes all rails match the surface instead of
14
- falling back to the lighter bg-contrast-40 (#5F5F64).
15
- NOTE: must use --bim-ui_gray-1 (defined UNCONDITIONALLY at :root = #262629),
16
- not --bim-ui_bg-contrast-* (only defined under @media/theme-class scopes, so
17
- it doesn't resolve at <html>:root and left --bim-scrollbar--bgc unset). */
18
- :root { --bim-scrollbar--bgc: var(--bim-ui_gray-1, #262629); }
19
- </style>
20
- </head>
21
- <body>
22
- <div id="that-open-app"></div>
23
- <script>
24
- // Simulates the context that the platform provides in production.
25
- // When running inside the platform iframe, these values come from query params.
26
- window.__THATOPEN_CONTEXT__ = {
27
- appId: 'local-dev',
28
- projectId: 'local-project',
29
- accessToken: '',
30
- apiUrl: 'http://localhost:3000',
31
- };
32
- </script>
33
- <script type="module" src="/src/main.ts"></script>
34
- </body>
35
- </html>
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>ThatOpen App</title>
7
+ <style>
8
+ *, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
9
+ html, body { width: 100%; height: 100%; overflow: hidden; font-family: system-ui, -apple-system, sans-serif; }
10
+ #that-open-app { width: 100%; height: 100%; }
11
+ /* Scrollbar rail = the panel surface (#262629). Every panel (app .xxx-vp
12
+ tracks) and every bim-* shadow-DOM scrollbar reads var(--bim-scrollbar--bgc,
13
+ …), so defining it once here makes all rails match the surface instead of
14
+ falling back to the lighter bg-contrast-40 (#5F5F64).
15
+ NOTE: must use --bim-ui_gray-1 (defined UNCONDITIONALLY at :root = #262629),
16
+ not --bim-ui_bg-contrast-* (only defined under @media/theme-class scopes, so
17
+ it doesn't resolve at <html>:root and left --bim-scrollbar--bgc unset). */
18
+ :root { --bim-scrollbar--bgc: var(--bim-ui_gray-1, #262629); }
19
+ </style>
20
+ </head>
21
+ <body>
22
+ <div id="that-open-app"></div>
23
+ <script>
24
+ // Simulates the context that the platform provides in production.
25
+ // When running inside the platform iframe, these values come from query params.
26
+ window.__THATOPEN_CONTEXT__ = {
27
+ appId: 'local-dev',
28
+ projectId: 'local-project',
29
+ accessToken: '',
30
+ apiUrl: 'http://localhost:3000',
31
+ };
32
+ </script>
33
+ <script type="module" src="/src/main.ts"></script>
34
+ </body>
35
+ </html>
@@ -1,33 +1,33 @@
1
- {
2
- "name": "{{PROJECT_NAME}}",
3
- "version": "1.0.0",
4
- "private": true,
5
- "scripts": {
6
- "dev": "thatopen serve",
7
- "build": "vite build",
8
- "login": "thatopen login --local",
9
- "publish": "thatopen publish"
10
- },
11
- "dependencies": {
12
- "@lit/context": "^1.1.6",
13
- "lit": "^3.0.0",
14
- "@markerjs/markerjs3": "^3.9.0",
15
- "@thatopen/components": "~3.4.0",
16
- "@thatopen/components-front": "~3.4.0",
17
- "@thatopen/fragments": "~3.4.0",
18
- "@thatopen/services": "file:../../../..",
19
- "@thatopen/ui": "~3.4.0",
20
- "three": "0.185.0",
21
- "@sparkjsdev/spark": "^0.1.10",
22
- "3d-tiles-renderer": "^0.4.28",
23
- "camera-controls": "^3.1.2",
24
- "opentype.js": "1.3.4",
25
- "potree-core": "^2.0.15",
26
- "web-ifc": "^0.0.77"
27
- },
28
- "devDependencies": {
29
- "@types/three": "^0.182.0",
30
- "typescript": "^5.2.0",
31
- "vite": "^5.2.0"
32
- }
1
+ {
2
+ "name": "{{PROJECT_NAME}}",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "scripts": {
6
+ "dev": "thatopen serve",
7
+ "build": "vite build",
8
+ "login": "thatopen login --local",
9
+ "publish": "thatopen publish"
10
+ },
11
+ "dependencies": {
12
+ "@lit/context": "^1.1.6",
13
+ "lit": "^3.0.0",
14
+ "@markerjs/markerjs3": "^3.9.0",
15
+ "@thatopen/components": "^3.6.0",
16
+ "@thatopen/components-front": "^3.6.1",
17
+ "@thatopen/fragments": "^3.6.1",
18
+ "@thatopen/services": "file:../../../..",
19
+ "@thatopen/ui": "^3.4.27",
20
+ "three": "0.185.0",
21
+ "@sparkjsdev/spark": "^0.1.10",
22
+ "3d-tiles-renderer": "^0.4.28",
23
+ "camera-controls": "^3.1.2",
24
+ "opentype.js": "1.3.4",
25
+ "potree-core": "^2.0.15",
26
+ "web-ifc": "^0.0.77"
27
+ },
28
+ "devDependencies": {
29
+ "@types/three": "^0.182.0",
30
+ "typescript": "^5.2.0",
31
+ "vite": "^5.2.0"
32
+ }
33
33
  }