@thatopen/services 0.11.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.
- package/dist/built-in/index.d.ts +232 -0
- package/dist/cli/lib/engine-script.d.ts +9 -2
- package/dist/cli.js +17 -4
- package/dist/index.cjs.js +2 -2
- package/dist/index.es.js +4 -3
- package/docs/builtin/paths.json +16 -0
- package/package.json +1 -1
- package/src/built-in/ProjectManager/example.ts +163 -0
- package/src/built-in/UIManager/src/settings-panel/example.ts +298 -0
- package/src/built-in/UIManager/src/viewer/example.ts +182 -0
- package/src/built-in/UIManager/src/viewer-toolbar/example.ts +252 -0
- package/src/built-in/index.ts +233 -0
package/dist/built-in/index.d.ts
CHANGED
|
@@ -1567,6 +1567,238 @@ export type HelloWorld = InstanceType<typeof _HelloWorld>;
|
|
|
1567
1567
|
export declare const HelloWorld: typeof _HelloWorld & {
|
|
1568
1568
|
uuid: "2c4ae432-fc24-43e9-9783-0c960c674e96";
|
|
1569
1569
|
};
|
|
1570
|
+
export type ProjectNamespaceKey = "origin" | "georeferencing" | "appSettings";
|
|
1571
|
+
export interface ProjectNamespace {
|
|
1572
|
+
label: string;
|
|
1573
|
+
description?: string;
|
|
1574
|
+
}
|
|
1575
|
+
export interface ProjectEntity<T = unknown> {
|
|
1576
|
+
namespaceId: ProjectNamespaceKey;
|
|
1577
|
+
label: string;
|
|
1578
|
+
description?: string;
|
|
1579
|
+
data: T;
|
|
1580
|
+
}
|
|
1581
|
+
/** GIS origin point that fixes the scene's (0,0,0) to a real-world coordinate. */
|
|
1582
|
+
export interface OriginData {
|
|
1583
|
+
lat: number;
|
|
1584
|
+
lon: number;
|
|
1585
|
+
height: number;
|
|
1586
|
+
rotation: number;
|
|
1587
|
+
}
|
|
1588
|
+
export interface BimSite {
|
|
1589
|
+
label: string;
|
|
1590
|
+
description?: string;
|
|
1591
|
+
lat: number;
|
|
1592
|
+
lon: number;
|
|
1593
|
+
height: number;
|
|
1594
|
+
rotation: number;
|
|
1595
|
+
/** Column-major 4x4 matrix (16 values) mapping BIM local space to the site's georeferenced frame. */
|
|
1596
|
+
baseMatrix: number[];
|
|
1597
|
+
}
|
|
1598
|
+
export interface BimCoordinatesData {
|
|
1599
|
+
defaultSiteId?: string;
|
|
1600
|
+
sites: Record<string, BimSite>;
|
|
1601
|
+
}
|
|
1602
|
+
export type AssetCoordinateType = "splat" | "ifc" | "point-cloud" | (string & {});
|
|
1603
|
+
export interface AssetCoordinate {
|
|
1604
|
+
fileId: string;
|
|
1605
|
+
type: AssetCoordinateType;
|
|
1606
|
+
lat: number;
|
|
1607
|
+
lon: number;
|
|
1608
|
+
height: number;
|
|
1609
|
+
rotation: number;
|
|
1610
|
+
}
|
|
1611
|
+
export interface GraphicsSettingsData {
|
|
1612
|
+
stylePreset: string;
|
|
1613
|
+
postproduction: boolean;
|
|
1614
|
+
edges: {
|
|
1615
|
+
enabled: boolean;
|
|
1616
|
+
color: string;
|
|
1617
|
+
opacity: number;
|
|
1618
|
+
};
|
|
1619
|
+
ambientOcclusion: {
|
|
1620
|
+
enabled: boolean;
|
|
1621
|
+
value: number;
|
|
1622
|
+
};
|
|
1623
|
+
tonalShading: {
|
|
1624
|
+
enabled: boolean;
|
|
1625
|
+
value: number;
|
|
1626
|
+
};
|
|
1627
|
+
surfaceColor: {
|
|
1628
|
+
enabled: boolean;
|
|
1629
|
+
};
|
|
1630
|
+
transparentBackground: {
|
|
1631
|
+
enabled: boolean;
|
|
1632
|
+
color: string;
|
|
1633
|
+
};
|
|
1634
|
+
grid: {
|
|
1635
|
+
enabled: boolean;
|
|
1636
|
+
color: string;
|
|
1637
|
+
};
|
|
1638
|
+
gridHeight: {
|
|
1639
|
+
auto: boolean;
|
|
1640
|
+
value: number;
|
|
1641
|
+
};
|
|
1642
|
+
antiAliasing: boolean;
|
|
1643
|
+
nativeResolution: boolean;
|
|
1644
|
+
adaptiveResolution: {
|
|
1645
|
+
enabled: boolean;
|
|
1646
|
+
value: number;
|
|
1647
|
+
};
|
|
1648
|
+
minResolution: number;
|
|
1649
|
+
renderScale: number;
|
|
1650
|
+
}
|
|
1651
|
+
export interface ProjectManagerData {
|
|
1652
|
+
schemaVersion: 1;
|
|
1653
|
+
namespaces: Record<ProjectNamespaceKey, ProjectNamespace>;
|
|
1654
|
+
entities: {
|
|
1655
|
+
origin: ProjectEntity<OriginData>;
|
|
1656
|
+
bimCoordinates: ProjectEntity<BimCoordinatesData>;
|
|
1657
|
+
assetCoordinates: ProjectEntity<AssetCoordinate[]>;
|
|
1658
|
+
graphicsSettings: ProjectEntity<GraphicsSettingsData>;
|
|
1659
|
+
};
|
|
1660
|
+
}
|
|
1661
|
+
export interface SingletonEntity<T> {
|
|
1662
|
+
get(): T | undefined;
|
|
1663
|
+
set(data: T): Promise<void>;
|
|
1664
|
+
update(partial: Partial<T>): Promise<void>;
|
|
1665
|
+
}
|
|
1666
|
+
export interface BimCoordinatesEntity {
|
|
1667
|
+
get(): BimCoordinatesData;
|
|
1668
|
+
getSites(): Record<string, BimSite>;
|
|
1669
|
+
getSite(siteId: string): BimSite | undefined;
|
|
1670
|
+
getDefaultSite(): BimSite | undefined;
|
|
1671
|
+
/** Creates a new site. `ProjectManager` generates the opaque `siteId` — callers
|
|
1672
|
+
* never invent their own (see the class-level JSDoc on `ProjectManager` for why). */
|
|
1673
|
+
createSite(site: BimSite): Promise<string>;
|
|
1674
|
+
/** Updates a site that already exists (from `createSite`). Throws if `siteId`
|
|
1675
|
+
* isn't in `sites` — this is not an upsert; use `createSite` to add one. */
|
|
1676
|
+
setSite(siteId: string, site: BimSite): Promise<void>;
|
|
1677
|
+
setDefaultSite(siteId: string): Promise<void>;
|
|
1678
|
+
removeSite(siteId: string): Promise<void>;
|
|
1679
|
+
}
|
|
1680
|
+
export interface AssetCoordinatesEntity {
|
|
1681
|
+
getAll(): AssetCoordinate[];
|
|
1682
|
+
get(fileId: string): AssetCoordinate | undefined;
|
|
1683
|
+
getByType(type: AssetCoordinateType): AssetCoordinate[];
|
|
1684
|
+
set(fileId: string, data: Omit<AssetCoordinate, "fileId">): Promise<void>;
|
|
1685
|
+
remove(fileId: string): Promise<void>;
|
|
1686
|
+
}
|
|
1687
|
+
/**
|
|
1688
|
+
* ProjectManager is the platform's canonical store for project-level
|
|
1689
|
+
* configuration and data — origin/georeferencing/app-settings today, with
|
|
1690
|
+
* room to grow. It persists a single JSON file (`${ProjectManager.uuid}.json`)
|
|
1691
|
+
* loose directly inside `__project_data` (same folder convention `GISManager`
|
|
1692
|
+
* already used) — NOT in a per-app subfolder like `collider`/`cde`, which are
|
|
1693
|
+
* for secondary, per-builtin data. Sharing that root folder with other
|
|
1694
|
+
* builtins doesn't change its role: it's still the one canonical project
|
|
1695
|
+
* record, meant to stop each builtin from inventing its own ad-hoc
|
|
1696
|
+
* project-persistence pattern.
|
|
1697
|
+
*
|
|
1698
|
+
* Schema shape (see `src/types.ts` for the full rationale):
|
|
1699
|
+
* - `namespaces`/`entities` are maps keyed by a fixed, readable slug — a
|
|
1700
|
+
* closed set this code defines, never created at runtime.
|
|
1701
|
+
* - `bimCoordinates.data.sites` is the one open, runtime-created collection
|
|
1702
|
+
* today, so its keys are opaque generated ids instead of slugs.
|
|
1703
|
+
* - `origin`/`graphicsSettings` are singletons; `sites`/`assetCoordinates`
|
|
1704
|
+
* are collections.
|
|
1705
|
+
* - `entities[id]` is a uniform envelope: `namespaceId`, mandatory `label`,
|
|
1706
|
+
* optional `description` (omitted, not stored empty), free-form `data`.
|
|
1707
|
+
*
|
|
1708
|
+
* Id generation rule: whenever a collection needs an opaque id (today just
|
|
1709
|
+
* `sites`, potentially more collections later), `ProjectManager` generates it
|
|
1710
|
+
* internally (`crypto.randomUUID()`, no prefix) — callers never invent their
|
|
1711
|
+
* own. `createSite` is the current example; follow the same pattern for any
|
|
1712
|
+
* future `create*` method.
|
|
1713
|
+
*/
|
|
1714
|
+
declare class _ProjectManager extends OBC.Component {
|
|
1715
|
+
static readonly uuid: "6f3a9c2e-8b1d-4e6a-9c3f-1d7b5a8e2c4f";
|
|
1716
|
+
enabled: boolean;
|
|
1717
|
+
/** True once init(client) has been called — safe to use the entity accessors. */
|
|
1718
|
+
get ready(): boolean;
|
|
1719
|
+
/** Suppress auto-save while bulk-loading data. */
|
|
1720
|
+
private _loadingData;
|
|
1721
|
+
readonly onSaveStart: OBC.Event<void>;
|
|
1722
|
+
readonly onSaveComplete: OBC.Event<boolean>;
|
|
1723
|
+
private _client?;
|
|
1724
|
+
private _fileId?;
|
|
1725
|
+
private _data;
|
|
1726
|
+
private _saveTimer?;
|
|
1727
|
+
private _savePromise?;
|
|
1728
|
+
private _scheduleSave;
|
|
1729
|
+
private _queueSave;
|
|
1730
|
+
private _doSave;
|
|
1731
|
+
/** Cancels the pending debounce and runs the save immediately. Awaits completion. */
|
|
1732
|
+
flush(): Promise<void>;
|
|
1733
|
+
init(client: PlatformClient): Promise<void>;
|
|
1734
|
+
/** Opaque id generator for any collection needing one (currently just
|
|
1735
|
+
* `bimCoordinates.sites`) — see the class-level JSDoc's id-generation rule. */
|
|
1736
|
+
private _generateId;
|
|
1737
|
+
origin: SingletonEntity<OriginData>;
|
|
1738
|
+
graphicsSettings: SingletonEntity<GraphicsSettingsData>;
|
|
1739
|
+
bimCoordinates: BimCoordinatesEntity;
|
|
1740
|
+
assetCoordinates: AssetCoordinatesEntity;
|
|
1741
|
+
getNamespaces(): Record<ProjectNamespaceKey, ProjectNamespace>;
|
|
1742
|
+
getNamespace(key: ProjectNamespaceKey): Record<string, unknown>;
|
|
1743
|
+
}
|
|
1744
|
+
/**
|
|
1745
|
+
* ProjectManager is the platform's canonical store for project-level
|
|
1746
|
+
* configuration and data — origin/georeferencing/app-settings today, with
|
|
1747
|
+
* room to grow. It persists a single JSON file (`${ProjectManager.uuid}.json`)
|
|
1748
|
+
* loose directly inside `__project_data` (same folder convention `GISManager`
|
|
1749
|
+
* already used) — NOT in a per-app subfolder like `collider`/`cde`, which are
|
|
1750
|
+
* for secondary, per-builtin data. Sharing that root folder with other
|
|
1751
|
+
* builtins doesn't change its role: it's still the one canonical project
|
|
1752
|
+
* record, meant to stop each builtin from inventing its own ad-hoc
|
|
1753
|
+
* project-persistence pattern.
|
|
1754
|
+
*
|
|
1755
|
+
* Schema shape (see `src/types.ts` for the full rationale):
|
|
1756
|
+
* - `namespaces`/`entities` are maps keyed by a fixed, readable slug — a
|
|
1757
|
+
* closed set this code defines, never created at runtime.
|
|
1758
|
+
* - `bimCoordinates.data.sites` is the one open, runtime-created collection
|
|
1759
|
+
* today, so its keys are opaque generated ids instead of slugs.
|
|
1760
|
+
* - `origin`/`graphicsSettings` are singletons; `sites`/`assetCoordinates`
|
|
1761
|
+
* are collections.
|
|
1762
|
+
* - `entities[id]` is a uniform envelope: `namespaceId`, mandatory `label`,
|
|
1763
|
+
* optional `description` (omitted, not stored empty), free-form `data`.
|
|
1764
|
+
*
|
|
1765
|
+
* Id generation rule: whenever a collection needs an opaque id (today just
|
|
1766
|
+
* `sites`, potentially more collections later), `ProjectManager` generates it
|
|
1767
|
+
* internally (`crypto.randomUUID()`, no prefix) — callers never invent their
|
|
1768
|
+
* own. `createSite` is the current example; follow the same pattern for any
|
|
1769
|
+
* future `create*` method.
|
|
1770
|
+
*/
|
|
1771
|
+
export type ProjectManager = InstanceType<typeof _ProjectManager>;
|
|
1772
|
+
/**
|
|
1773
|
+
* ProjectManager is the platform's canonical store for project-level
|
|
1774
|
+
* configuration and data — origin/georeferencing/app-settings today, with
|
|
1775
|
+
* room to grow. It persists a single JSON file (`${ProjectManager.uuid}.json`)
|
|
1776
|
+
* loose directly inside `__project_data` (same folder convention `GISManager`
|
|
1777
|
+
* already used) — NOT in a per-app subfolder like `collider`/`cde`, which are
|
|
1778
|
+
* for secondary, per-builtin data. Sharing that root folder with other
|
|
1779
|
+
* builtins doesn't change its role: it's still the one canonical project
|
|
1780
|
+
* record, meant to stop each builtin from inventing its own ad-hoc
|
|
1781
|
+
* project-persistence pattern.
|
|
1782
|
+
*
|
|
1783
|
+
* Schema shape (see `src/types.ts` for the full rationale):
|
|
1784
|
+
* - `namespaces`/`entities` are maps keyed by a fixed, readable slug — a
|
|
1785
|
+
* closed set this code defines, never created at runtime.
|
|
1786
|
+
* - `bimCoordinates.data.sites` is the one open, runtime-created collection
|
|
1787
|
+
* today, so its keys are opaque generated ids instead of slugs.
|
|
1788
|
+
* - `origin`/`graphicsSettings` are singletons; `sites`/`assetCoordinates`
|
|
1789
|
+
* are collections.
|
|
1790
|
+
* - `entities[id]` is a uniform envelope: `namespaceId`, mandatory `label`,
|
|
1791
|
+
* optional `description` (omitted, not stored empty), free-form `data`.
|
|
1792
|
+
*
|
|
1793
|
+
* Id generation rule: whenever a collection needs an opaque id (today just
|
|
1794
|
+
* `sites`, potentially more collections later), `ProjectManager` generates it
|
|
1795
|
+
* internally (`crypto.randomUUID()`, no prefix) — callers never invent their
|
|
1796
|
+
* own. `createSite` is the current example; follow the same pattern for any
|
|
1797
|
+
* future `create*` method.
|
|
1798
|
+
*/
|
|
1799
|
+
export declare const ProjectManager: typeof _ProjectManager & {
|
|
1800
|
+
uuid: "6f3a9c2e-8b1d-4e6a-9c3f-1d7b5a8e2c4f";
|
|
1801
|
+
};
|
|
1570
1802
|
/** `main.bcf`'s path relative to `__project_data/` — shared with
|
|
1571
1803
|
* `requestBcfSave` (`UIManager/src/utils/bcf-storage.ts`) so both sides of
|
|
1572
1804
|
* the save/load round-trip agree on where the file lives. */
|
|
@@ -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);
|