@cognite/reveal-widget 0.1.0 → 0.3.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/README.md +35 -1
- package/dist/index.d.ts +132 -252
- package/dist/index.js +8 -23116
- package/package.json +7 -4
- package/dist/reveal-react-components-B1-bTCTc.js +0 -186
- package/dist/reveal-react-components-B6thjZdg.js +0 -186
- package/dist/reveal-react-components-BAeZgxZG.js +0 -186
- package/dist/reveal-react-components-BfD2xhEp.js +0 -186
- package/dist/reveal-react-components-Buqu6QHG.js +0 -186
- package/dist/reveal-react-components-C4ryTxfZ.js +0 -186
- package/dist/reveal-react-components-D4HmA1Qd.js +0 -186
- package/dist/reveal-react-components-DQD0i_VN.js +0 -186
- package/dist/reveal-react-components-DlU0U_dH.js +0 -186
- package/dist/reveal-react-components-VqLOjpah.js +0 -186
- package/dist/reveal-react-components-khfvnXNb.js +0 -186
- package/dist/reveal-react-components-s41hyIfX.js +0 -186
package/README.md
CHANGED
|
@@ -6,9 +6,43 @@ A React component for embedding an interactive [Cognite Reveal](https://cognited
|
|
|
6
6
|
(assets) within them.
|
|
7
7
|
|
|
8
8
|
This package exposes `RevealWidget` and the types needed to drive it via
|
|
9
|
-
`RevealWidgetController`. More capabilities from the broader Reveal
|
|
9
|
+
`RevealWidgetController`. More capabilities from the broader Reveal Components toolkit
|
|
10
10
|
will be exposed here incrementally over time.
|
|
11
11
|
|
|
12
|
+
## Usage tracking (Mixpanel)
|
|
13
|
+
|
|
14
|
+
`RevealWidget` can report anonymous usage events to a Cognite-owned Mixpanel project. This
|
|
15
|
+
tells us which features of the widget are actually used (loading a resource, styling
|
|
16
|
+
instances, moving the camera, etc.) so we can prioritize development. No event payload
|
|
17
|
+
includes page URLs, referrers, resource IDs, or any other identifying data.
|
|
18
|
+
|
|
19
|
+
`RevealWidget` requires an `appIdentifier` prop so aggregate usage can be attributed
|
|
20
|
+
correctly. The optional `tracking` prop lets you change where events go:
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
// Reports to the default Cognite Mixpanel project (the default when `tracking` is omitted).
|
|
24
|
+
<RevealWidget viewerOptions={...} appIdentifier="my-app" />
|
|
25
|
+
|
|
26
|
+
// Opt out entirely — no events are sent anywhere.
|
|
27
|
+
<RevealWidget viewerOptions={...} appIdentifier="my-app" tracking={{ disabled: true }} />
|
|
28
|
+
|
|
29
|
+
// Report to your own Mixpanel project instead of Cognite's.
|
|
30
|
+
<RevealWidget
|
|
31
|
+
viewerOptions={...}
|
|
32
|
+
appIdentifier="my-app"
|
|
33
|
+
tracking={{ mixpanelToken: 'your-own-project-token' }}
|
|
34
|
+
/>
|
|
35
|
+
|
|
36
|
+
// Route events through your own tracking/analytics pipeline instead of Mixpanel.
|
|
37
|
+
<RevealWidget
|
|
38
|
+
viewerOptions={...}
|
|
39
|
+
appIdentifier="my-app"
|
|
40
|
+
tracking={{ usageMetricsTracker: { track: (event, properties) => myOwnTracker(event, properties) } }}
|
|
41
|
+
/>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
See `RevealWidgetTrackingProps` for the full set of options.
|
|
45
|
+
|
|
12
46
|
## Install
|
|
13
47
|
|
|
14
48
|
```bash
|
package/dist/index.d.ts
CHANGED
|
@@ -1,252 +1,132 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Cognite3DViewerOptions } from '@cognite/reveal';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
readonly
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
export
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
mapped?: NodeAppearance;
|
|
134
|
-
};
|
|
135
|
-
modelCategory: 'model3d';
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
export declare type PointCloudResourceIdentifier = (
|
|
139
|
-
| Classic3DResourceIdentifier
|
|
140
|
-
| DM3DResourceIdentifier
|
|
141
|
-
) & { type: 'pointcloud' };
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* A narrow, external-facing view of a loaded 3D resource (CAD model, point cloud, image360
|
|
145
|
-
* collection, or scene). This is a type-only narrowing — the actual object returned at runtime
|
|
146
|
-
* by `addResource()`/`getModels()` is still the real `RevealDomainObject`/`SceneDomainObject`.
|
|
147
|
-
* Only `.remove()` is published here to keep the exported type surface minimal.
|
|
148
|
-
*/
|
|
149
|
-
export declare type Reveal3DResourceHandle = {
|
|
150
|
-
remove(): boolean;
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
export declare const RevealWidget: (props: PropsWithChildren<RevealWidgetProps>) => ReactElement;
|
|
154
|
-
|
|
155
|
-
export declare type RevealWidgetCameraController = {
|
|
156
|
-
/**
|
|
157
|
-
* Focus all visible models in the scene
|
|
158
|
-
*/
|
|
159
|
-
focusCameraAll(): void;
|
|
160
|
-
/**
|
|
161
|
-
* Focus on a single given 3D model
|
|
162
|
-
*/
|
|
163
|
-
focusModel(handle: Reveal3DResourceHandle): void;
|
|
164
|
-
/**
|
|
165
|
-
* Returns the state of the camera in the Reveal viewer
|
|
166
|
-
*/
|
|
167
|
-
getCameraState(): Required<CameraState>;
|
|
168
|
-
/**
|
|
169
|
-
* Sets the state of the camera
|
|
170
|
-
*/
|
|
171
|
-
setCameraState(cameraState: CameraState): void;
|
|
172
|
-
enterNearby360Image(): Promise<void> | undefined;
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
export declare type RevealWidgetController = {
|
|
176
|
-
/**
|
|
177
|
-
* Access the RevealWidgetCameraController for camera controls
|
|
178
|
-
*/
|
|
179
|
-
readonly cameraController: RevealWidgetCameraController;
|
|
180
|
-
/**
|
|
181
|
-
* Add a 3D resource (i.e. model or scene) to the widget.
|
|
182
|
-
* Added resources can be removed by calling their `.remove` method.
|
|
183
|
-
*/
|
|
184
|
-
addResource(resource: AllResourceIdentifier): Promise<Reveal3DResourceHandle>;
|
|
185
|
-
/**
|
|
186
|
-
* Get all models added to the RevealWidget
|
|
187
|
-
*/
|
|
188
|
-
getModels(): Reveal3DResourceHandle[];
|
|
189
|
-
/**
|
|
190
|
-
* Get all models added to the RevealWidget that are visible
|
|
191
|
-
*/
|
|
192
|
-
getVisibleModels(): Reveal3DResourceHandle[];
|
|
193
|
-
/**
|
|
194
|
-
* Style the provided instances with the associated styles in the given models, if
|
|
195
|
-
* the instances are contextualized to the models
|
|
196
|
-
*/
|
|
197
|
-
styleByInstance(instanceStylingGroups: InstanceStylingGroup[], handles: Reveal3DResourceHandle[]): Promise<void>;
|
|
198
|
-
/**
|
|
199
|
-
* Moves the camera to show the provided instances in the visible models in the scene.
|
|
200
|
-
*/
|
|
201
|
-
focusInstances(instances: InstanceId[]): Promise<void>;
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
export declare type RevealWidgetProps = {
|
|
205
|
-
/**
|
|
206
|
-
* Defines the initialization options for the RevealWidget, including the SDK and data modeling status
|
|
207
|
-
* The user can either specify these separately, or opt for the object
|
|
208
|
-
* `{ inheritFromRevealContext: true }`, in which case the Widget will assume the existence of
|
|
209
|
-
* a `RevealContext` mounted above it in the hierarchy.
|
|
210
|
-
*/
|
|
211
|
-
viewerOptions: (Pick<Cognite3DViewerOptions, 'sdk' | 'onLoading'> & {
|
|
212
|
-
useCoreDm: boolean;
|
|
213
|
-
}) | {
|
|
214
|
-
/**
|
|
215
|
-
* Disables the RevealWidget's own RevealContext, relying on one defined in the application
|
|
216
|
-
* layer instead.
|
|
217
|
-
*/
|
|
218
|
-
inheritFromRevealContext: true;
|
|
219
|
-
};
|
|
220
|
-
/**
|
|
221
|
-
* The widget uses this to set a reference to the widget controller.
|
|
222
|
-
* The widget calls this with `undefined` when the component unmounts or this callback changes
|
|
223
|
-
*/
|
|
224
|
-
setControllerRef?: (controller: RevealWidgetController | undefined) => void;
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
export declare type SceneAddOptions = {
|
|
228
|
-
sourceType: 'dm';
|
|
229
|
-
externalId: string;
|
|
230
|
-
space: string;
|
|
231
|
-
modelCategory: 'scene';
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
export declare type SceneResourceIdentifier = {
|
|
235
|
-
type: 'scene';
|
|
236
|
-
externalId: string;
|
|
237
|
-
space: string;
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
export declare type Space = string;
|
|
241
|
-
|
|
242
|
-
export declare type ThreeDResourceIdentifier =
|
|
243
|
-
| CadResourceIdentifier
|
|
244
|
-
| PointCloudResourceIdentifier
|
|
245
|
-
| Image360ResourceIdentifier;
|
|
246
|
-
|
|
247
|
-
export declare type TreeIndexStylingGroup = {
|
|
248
|
-
treeIndexSet: IndexSet;
|
|
249
|
-
style: NodeAppearance;
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
export { }
|
|
1
|
+
import { PropsWithChildren, ReactElement } from 'react';
|
|
2
|
+
import { CameraState, Cognite3DViewerOptions, NodeAppearance } from '@cognite/reveal';
|
|
3
|
+
import { DmsUniqueIdentifier, ExternalId, Space } from '@cognite/reveal-components/data-providers';
|
|
4
|
+
import { AssetId } from '@cognite/reveal-components/data-providers/cache';
|
|
5
|
+
import { AddReveal3DResource, AllResourceIdentifier, BaseAddOptions, CadAddOptions, NewCadModelStyling as CadModelStyling, CadResourceIdentifier, Classic3DResourceIdentifier, DM3DResourceIdentifier, Image360AddOptions, Image360DMResourceIdentifier, Image360EventsResourceIdentifier, Image360IconCullingOptions, Image360ResourceIdentifier, PointCloudAddOptions, PointCloudResourceIdentifier, SceneAddOptions, SceneResourceIdentifier, ThreeDResourceIdentifier } from '@cognite/reveal-components/data-providers/types';
|
|
6
|
+
import { RevealWidgetTrackingProps } from '@cognite/reveal-components/ui/components';
|
|
7
|
+
import { InstanceId, UsageMetricsTracker } from '@cognite/reveal-components/utilities';
|
|
8
|
+
import { InstanceStylingGroup } from '@cognite/reveal-components/utilities/modelIds';
|
|
9
|
+
import { TreeIndexStylingGroup } from '@cognite/reveal-components/utilities/styling';
|
|
10
|
+
export type { AddReveal3DResource, AllResourceIdentifier, AssetId, BaseAddOptions, CadAddOptions, CadModelStyling, CadResourceIdentifier, Classic3DResourceIdentifier, DM3DResourceIdentifier, DmsUniqueIdentifier, ExternalId, Image360AddOptions, Image360DMResourceIdentifier, Image360EventsResourceIdentifier, Image360IconCullingOptions, Image360ResourceIdentifier, InstanceId, InstanceStylingGroup, UsageMetricsTracker, PointCloudAddOptions, PointCloudResourceIdentifier, RevealWidgetTrackingProps, SceneAddOptions, SceneResourceIdentifier, Space, ThreeDResourceIdentifier, TreeIndexStylingGroup, };
|
|
11
|
+
/**
|
|
12
|
+
* Public API surface for the standalone `@cognite/reveal-widget` npm package.
|
|
13
|
+
*
|
|
14
|
+
* `RevealWidget` here is the real, unmodified implementation from
|
|
15
|
+
* `@cognite/reveal-components` — there is no runtime wrapper. `@cognite/reveal-components`
|
|
16
|
+
* is a `dependencies` entry, so it and its own published dependencies (`@cognite/signal-utils`,
|
|
17
|
+
* `@cognite/underscore`) are treated as external. The resource/identifier types above are
|
|
18
|
+
* re-exported directly from `@cognite/reveal-components`'s narrow, already-subpath-exported
|
|
19
|
+
* type barrels (`./data-providers/types`, `./utilities/modelIds`, `./utilities`), which an
|
|
20
|
+
* external consumer resolves normally since that package is published.
|
|
21
|
+
*
|
|
22
|
+
* `Reveal3DResourceHandle`, `RevealWidgetController`, `RevealWidgetCameraController`, and
|
|
23
|
+
* `RevealWidgetProps` below are still hand-declared, because their real counterparts (only
|
|
24
|
+
* reachable via the entangled `./ui/components` export) expose `RevealDomainObject`/
|
|
25
|
+
* `SceneDomainObject` directly in their signatures — too large for API Extractor's type bundler
|
|
26
|
+
* and not meaningful for an external consumer anyway. `src/index.test.ts` has compile-time-only
|
|
27
|
+
* (`// @ts-expect-error`-driven) tests asserting these hand-written types stay structurally
|
|
28
|
+
* compatible with the real implementation — update both together when the real API changes.
|
|
29
|
+
* `RevealWidgetTrackingProps` (and its arms) don't have this problem — they only reference
|
|
30
|
+
* `UsageMetricsTracker`, so they're imported and re-exported directly from `./ui/components`
|
|
31
|
+
* rather than hand-declared.
|
|
32
|
+
*
|
|
33
|
+
* `tracking`/`appIdentifier` (on `RevealWidgetProps`) plumb through to the real `RevealWidget`'s
|
|
34
|
+
* usage-tracking seam, which reports to a dedicated, named `mixpanel-browser` instance *by
|
|
35
|
+
* default* — not Fusion's own `@cognite/metrics`/Mixpanel setup, since `@cognite/reveal-widget`
|
|
36
|
+
* is also consumed outside this monorepo. Pass `tracking: { disabled: true }` to opt out
|
|
37
|
+
* entirely, or `tracking: { mixpanelToken }` (with `appIdentifier`) to report to your own
|
|
38
|
+
* Mixpanel project instead.
|
|
39
|
+
*/
|
|
40
|
+
export declare const Default3DStyles: {
|
|
41
|
+
Highlighted: {
|
|
42
|
+
cad: NodeAppearance;
|
|
43
|
+
pointcloud: NodeAppearance;
|
|
44
|
+
image360: NodeAppearance;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* A narrow, external-facing view of a loaded 3D resource (CAD model, point cloud, image360
|
|
49
|
+
* collection, or scene). This is a type-only narrowing — the actual object returned at runtime
|
|
50
|
+
* by `addResource()`/`getModels()` is still the real `RevealDomainObject`/`SceneDomainObject`.
|
|
51
|
+
* Only `.remove()` is published here to keep the exported type surface minimal.
|
|
52
|
+
*/
|
|
53
|
+
export type Reveal3DResourceHandle = {
|
|
54
|
+
remove(): boolean;
|
|
55
|
+
};
|
|
56
|
+
export type RevealWidgetCameraController = {
|
|
57
|
+
/**
|
|
58
|
+
* Focus all visible models in the scene
|
|
59
|
+
*/
|
|
60
|
+
focusCameraAll(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Focus on a single given 3D model
|
|
63
|
+
*/
|
|
64
|
+
focusModel(handle: Reveal3DResourceHandle): void;
|
|
65
|
+
/**
|
|
66
|
+
* Returns the state of the camera in the Reveal viewer
|
|
67
|
+
*/
|
|
68
|
+
getCameraState(): Required<CameraState>;
|
|
69
|
+
/**
|
|
70
|
+
* Sets the state of the camera
|
|
71
|
+
*/
|
|
72
|
+
setCameraState(cameraState: CameraState): void;
|
|
73
|
+
enterNearby360Image(): Promise<void> | undefined;
|
|
74
|
+
};
|
|
75
|
+
export type RevealWidgetController = {
|
|
76
|
+
/**
|
|
77
|
+
* Access the RevealWidgetCameraController for camera controls
|
|
78
|
+
*/
|
|
79
|
+
readonly cameraController: RevealWidgetCameraController;
|
|
80
|
+
/**
|
|
81
|
+
* Add a 3D resource (i.e. model or scene) to the widget.
|
|
82
|
+
* Added resources can be removed by calling their `.remove` method.
|
|
83
|
+
*/
|
|
84
|
+
addResource(resource: AllResourceIdentifier): Promise<Reveal3DResourceHandle>;
|
|
85
|
+
/**
|
|
86
|
+
* Get all models added to the RevealWidget
|
|
87
|
+
*/
|
|
88
|
+
getModels(): Reveal3DResourceHandle[];
|
|
89
|
+
/**
|
|
90
|
+
* Get all models added to the RevealWidget that are visible
|
|
91
|
+
*/
|
|
92
|
+
getVisibleModels(): Reveal3DResourceHandle[];
|
|
93
|
+
/**
|
|
94
|
+
* Style the provided instances with the associated styles in the given models, if
|
|
95
|
+
* the instances are contextualized to the models
|
|
96
|
+
*/
|
|
97
|
+
styleByInstance(instanceStylingGroups: InstanceStylingGroup[], handles: Reveal3DResourceHandle[]): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Moves the camera to show the provided instances in the visible models in the scene.
|
|
100
|
+
*/
|
|
101
|
+
focusInstances(instances: InstanceId[]): Promise<void>;
|
|
102
|
+
};
|
|
103
|
+
export type RevealWidgetProps = {
|
|
104
|
+
/**
|
|
105
|
+
* Defines the initialization options for the RevealWidget, including the SDK and data modeling status
|
|
106
|
+
* The user can either specify these separately, or opt for the object
|
|
107
|
+
* `{ inheritFromRevealContext: true }`, in which case the Widget will assume the existence of
|
|
108
|
+
* a `RevealContext` mounted above it in the hierarchy.
|
|
109
|
+
*/
|
|
110
|
+
viewerOptions: (Pick<Cognite3DViewerOptions, 'sdk' | 'onLoading'> & {
|
|
111
|
+
useCoreDm: boolean;
|
|
112
|
+
}) | {
|
|
113
|
+
/**
|
|
114
|
+
* Disables the RevealWidget's own RevealContext, relying on one defined in the application
|
|
115
|
+
* layer instead.
|
|
116
|
+
*/
|
|
117
|
+
inheritFromRevealContext: true;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* The widget uses this to set a reference to the widget controller.
|
|
121
|
+
* The widget calls this with `undefined` when the component unmounts or this callback changes
|
|
122
|
+
*/
|
|
123
|
+
setControllerRef?: (controller: RevealWidgetController | undefined) => void;
|
|
124
|
+
/**
|
|
125
|
+
* Reports which application is using the widget and which of its features are being triggered
|
|
126
|
+
* (e.g. adding a resource, moving the camera). See `RevealWidgetTrackingProps` for the options.
|
|
127
|
+
*/
|
|
128
|
+
tracking?: RevealWidgetTrackingProps;
|
|
129
|
+
/** Identifies the host application */
|
|
130
|
+
appIdentifier: string;
|
|
131
|
+
};
|
|
132
|
+
export declare const RevealWidget: (props: PropsWithChildren<RevealWidgetProps>) => ReactElement;
|