Skip to content

Commit 79ab520

Browse files
committed
feat(template): sync app template to current viewer (A2/UIManager) + gate app to --beta
- Re-sync the app template from the canonical bim-viewer (post-A2: top-app/ top-viewer/UIManager), replacing the stale pre-A2 port. - Strip the local-dev :4100 builtin-override block from the template main.ts. - Gate the 'app' template to --beta: it depends on beta-only engine APIs (deferred postproduction, adaptive resolution, Outliner extras, fragments Table API, components-front NearPlaneLineMaterial, nested-relations props spec). Without --beta, error clearly — public engine support lands in Oct. cloud-component template is unaffected.
1 parent cdd9ccb commit 79ab520

11 files changed

Lines changed: 447 additions & 267 deletions

File tree

src/cli/commands/create.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ export const createCommand = new Command('create')
3434
process.exit(1);
3535
}
3636

37+
// The app template (the full BIM viewer) currently depends on engine APIs
38+
// that only exist in the beta libraries. Until the public engine catches up
39+
// (October release), scaffolding the app without --beta would produce a
40+
// project that doesn't type-check or run — so require --beta explicitly.
41+
if (template === 'app' && !opts.beta) {
42+
console.error(
43+
'The "app" template currently requires the beta engine libraries.\n\n' +
44+
` thatopen create ${projectName} --beta\n\n` +
45+
'Public (non-beta) engine support is coming with the October release.',
46+
);
47+
process.exit(1);
48+
}
49+
3750
const isCloud = template === 'cloud-component';
3851
const projectKind = isCloud ? 'cloud component' : 'app';
3952
const useCurrentDir = projectName === '.';

src/cli/templates/app/src/app.ts

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
1-
import * as OBC from "@thatopen/components";
2-
import * as BUI from "@thatopen/ui";
3-
import { AppManager } from "@thatopen/services";
4-
import { icons } from "./globals";
5-
6-
export type App = {
7-
icons: (keyof typeof icons)[];
8-
grid: BUI.Grid<
9-
["Explorer", "Files", "Graphics"],
10-
["viewer", "explorer", "files", "graphics"]
11-
>;
1+
import { PlatformClient, ProjectData } from "@thatopen/services";
2+
3+
// ─── A2 migration shim ───────────────────────────────────────────────────────
4+
// Pre-A2 the platform `AppManager` built-in held the platform `client` +
5+
// `projectData`, reached via `components.get(AppManager)`. Juan removed
6+
// AppManager (consolidated into UIManager / top-app). top-app now owns that
7+
// state and exposes it via lit contexts — but a few non-lit call sites
8+
// (CloudRunner, data-table-panel, app-info-section) just need `.client` /
9+
// `.projectData` synchronously. This tiny module holds them, set once from
10+
// main.ts, and keeps `getAppManager(...)` returning the same `{ client,
11+
// projectData }` shape those call sites expect.
12+
13+
let _client: PlatformClient | undefined;
14+
let _projectData: ProjectData | undefined;
15+
16+
/** Called once from main.ts after the platform client (and projectData) exist. */
17+
export const setAppContext = (
18+
client: PlatformClient,
19+
projectData?: ProjectData,
20+
) => {
21+
_client = client;
22+
_projectData = projectData;
1223
};
1324

14-
export const getAppManager = (components: OBC.Components) =>
15-
components.get(AppManager<App>);
25+
/**
26+
* Back-compat accessor mirroring the old `components.get(AppManager)` surface
27+
* the remaining call sites use (`.client` / `.projectData`). The `components`
28+
* arg is ignored — kept only for signature compatibility with existing callers.
29+
*/
30+
export const getAppManager = (_components?: unknown) => ({
31+
get client() {
32+
return _client;
33+
},
34+
get projectData() {
35+
return _projectData;
36+
},
37+
});

src/cli/templates/app/src/bim-components/CloudRunner/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as OBC from "@thatopen/components";
2-
import { AppManager } from "@thatopen/services";
2+
import { getAppManager } from "../../app";
33
import { CloudRunnerStatus } from "./src";
44

55
export class CloudRunner extends OBC.Component {
@@ -24,9 +24,13 @@ export class CloudRunner extends OBC.Component {
2424
}
2525

2626
async run(useLocal: boolean) {
27-
// Resolve client at call time via AppManager — never store it as a field.
28-
const app = this.components.get(AppManager);
29-
const client = app.client;
27+
// Resolve client at call time via the app shim — never store it as a field.
28+
const client = getAppManager(this.components).client;
29+
if (!client) {
30+
this.status = "No platform client available.";
31+
this._trigger();
32+
return;
33+
}
3034

3135
client.localServerUrl = useLocal ? this.localServerUrl : null;
3236

0 commit comments

Comments
 (0)