@3dsource/metabox-front-api 1.2.1-dev.2 → 1.2.1-dev.4
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/LICENSE +14 -0
- package/README.md +0 -2
- package/fesm2022/3dsource-metabox-front-api.mjs +581 -0
- package/fesm2022/3dsource-metabox-front-api.mjs.map +1 -0
- package/index.d.ts +860 -0
- package/package.json +20 -25
package/index.d.ts
ADDED
|
@@ -0,0 +1,860 @@
|
|
|
1
|
+
import { MetaBoxCommandPacket } from '@3dsource/types-unreal';
|
|
2
|
+
import { UnrealCallBackJson, UnrealState, StreamResolutionProps } from '@3dsource/angular-unreal-module';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Image format.
|
|
7
|
+
* @remarks
|
|
8
|
+
* This type represents the allowed image formats.
|
|
9
|
+
*/
|
|
10
|
+
type MimeType = 'image/png' | 'image/jpeg' | 'image/webp';
|
|
11
|
+
/**
|
|
12
|
+
* Represents a command to get fast render.
|
|
13
|
+
*
|
|
14
|
+
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* import { GetScreenshot,Communicator,saveImage } from '@3dsource/metabox-front-api';
|
|
18
|
+
* window.env3DSource.apiReady = (api:Communicator) => {
|
|
19
|
+
* // Listen for events from the MetaBox API
|
|
20
|
+
* api.addEventListener('screenshot', (data) => {
|
|
21
|
+
* // Process the fast render response
|
|
22
|
+
* saveImage(data, 'Render.png');
|
|
23
|
+
* });
|
|
24
|
+
* api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
|
|
25
|
+
* };
|
|
26
|
+
*/
|
|
27
|
+
declare class GetScreenshot extends CommandBase {
|
|
28
|
+
/**
|
|
29
|
+
* Constructs an instance of GetScreenshot.
|
|
30
|
+
* @param mimeType - The output format.
|
|
31
|
+
* @param size - Optional size in pixels.
|
|
32
|
+
*/
|
|
33
|
+
constructor(mimeType: MimeType, size?: {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
type ApplicationDeviceTypes = 'deviceTypeAuto' | 'deviceTypeMobile' | 'deviceTypeDesktop';
|
|
40
|
+
|
|
41
|
+
type ToMetaBoxActions = 'getPdf' | 'loadLevel' | 'setProduct' | 'getFastRender' | 'getScreenshot' | 'watchCallbacks' | 'setMaterialById' | 'showEmbeddedMenu' | 'forceSetDeviceType' | 'sendCommandToUnreal' | 'showOverlayInterface' | 'setEnvironmentMaterialById' | 'resetCamera' | 'addResponse';
|
|
42
|
+
/**
|
|
43
|
+
* @internal
|
|
44
|
+
* @hidden
|
|
45
|
+
*/
|
|
46
|
+
type ToMetaboxMessagePayload = ToMetaboxMessagePayloads[keyof ToMetaboxMessagePayloads];
|
|
47
|
+
/**
|
|
48
|
+
* Interface for messages sent from the application to the MetaBox.
|
|
49
|
+
*/
|
|
50
|
+
interface ToMetaboxMessagePayloads {
|
|
51
|
+
getPdf: void;
|
|
52
|
+
loadLevel: {
|
|
53
|
+
id: string;
|
|
54
|
+
};
|
|
55
|
+
setProduct: {
|
|
56
|
+
productId: string;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated
|
|
60
|
+
* @hidden
|
|
61
|
+
*/
|
|
62
|
+
addResponse: void;
|
|
63
|
+
/**
|
|
64
|
+
* @deprecated
|
|
65
|
+
* @hidden
|
|
66
|
+
*/
|
|
67
|
+
getFastRender: {
|
|
68
|
+
format: MimeType;
|
|
69
|
+
size?: {
|
|
70
|
+
x: number;
|
|
71
|
+
y: number;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
getScreenshot: {
|
|
75
|
+
format: MimeType;
|
|
76
|
+
size?: {
|
|
77
|
+
x: number;
|
|
78
|
+
y: number;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
watchCallbacks: void;
|
|
82
|
+
setMaterialById: {
|
|
83
|
+
slotId: string;
|
|
84
|
+
materialId: string;
|
|
85
|
+
};
|
|
86
|
+
sendCommandToUnreal: MetaBoxCommandPacket;
|
|
87
|
+
setEnvironmentMaterialById: {
|
|
88
|
+
slotId: string;
|
|
89
|
+
materialId: string;
|
|
90
|
+
};
|
|
91
|
+
showEmbeddedMenu: {
|
|
92
|
+
visible: boolean;
|
|
93
|
+
};
|
|
94
|
+
showOverlayInterface: {
|
|
95
|
+
visible: boolean;
|
|
96
|
+
};
|
|
97
|
+
forceSetDeviceType: {
|
|
98
|
+
deviceType: ApplicationDeviceTypes;
|
|
99
|
+
};
|
|
100
|
+
resetCamera: void;
|
|
101
|
+
}
|
|
102
|
+
interface ToMetaBoxMessageEnvelope {
|
|
103
|
+
action: ToMetaBoxActions;
|
|
104
|
+
payload?: ToMetaboxMessagePayload | never;
|
|
105
|
+
}
|
|
106
|
+
interface ToMetaBoxMessage {
|
|
107
|
+
host: 'metaBoxHost';
|
|
108
|
+
payload: ToMetaBoxMessageEnvelope;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Base class for commands sent to the MetaBox.
|
|
113
|
+
*/
|
|
114
|
+
declare class CommandBase {
|
|
115
|
+
data: ToMetaBoxMessageEnvelope;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Represents a command to toggle the Unreal Overlay Interface Menu.
|
|
120
|
+
*
|
|
121
|
+
* @remarks
|
|
122
|
+
* This action sends a message to the MetaBox API to toggle the visibility of the Unreal overlay UI.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* import { ShowOverlayInterface,Communicator } from '@3dsource/metabox-front-api';
|
|
126
|
+
*
|
|
127
|
+
* //...Assume that the integration is already implemented
|
|
128
|
+
* window.env3DSource.apiReady = (api:Communicator) => {
|
|
129
|
+
* api.setCommandToMetaBox(new ShowOverlayInterface(true));
|
|
130
|
+
* };
|
|
131
|
+
*/
|
|
132
|
+
declare class ShowOverlayInterface extends CommandBase {
|
|
133
|
+
/**
|
|
134
|
+
* Creates an instance of ShowOverlayInterface.
|
|
135
|
+
*
|
|
136
|
+
* @param visible - A flag indicating whether the Unreal overlay UI should be visible.
|
|
137
|
+
*/
|
|
138
|
+
constructor(visible: boolean);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Represents a command to toggle the Embedded MetaBox Menu.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* import { ShowEmbeddedMenu,Communicator } from '@3dsource/metabox-front-api';
|
|
146
|
+
*
|
|
147
|
+
* //...Assume that the integration is already implemented
|
|
148
|
+
* window.env3DSource.apiReady = (api:Communicator) => {
|
|
149
|
+
* api.setCommandToMetaBox(new ShowEmbeddedMenu(true));
|
|
150
|
+
* };
|
|
151
|
+
*/
|
|
152
|
+
declare class ShowEmbeddedMenu extends CommandBase {
|
|
153
|
+
/**
|
|
154
|
+
* Creates an instance of ShowEmbeddedMenu.
|
|
155
|
+
*
|
|
156
|
+
* @param visible - A flag indicating whether the embedded menu should be visible.
|
|
157
|
+
*/
|
|
158
|
+
constructor(visible: boolean);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Represents a command to set the environment by its ID.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* import { SetEnvironment,Communicator } from '@3dsource/metabox-front-api';
|
|
166
|
+
*
|
|
167
|
+
* //...Assume that the integration is already implemented
|
|
168
|
+
* window.env3DSource.apiReady = (api:Communicator) => {
|
|
169
|
+
* // Change the environment to '55555555-1234-1234-1234-01234567890'
|
|
170
|
+
* api.sendCommandToMetaBox(new SetEnvironment('55555555-1234-1234-1234-01234567890'));
|
|
171
|
+
* };
|
|
172
|
+
*/
|
|
173
|
+
declare class SetEnvironment extends CommandBase {
|
|
174
|
+
/**
|
|
175
|
+
* Creates an instance of SetEnvironment.
|
|
176
|
+
*
|
|
177
|
+
* @param environmentId - The environment ID.
|
|
178
|
+
*/
|
|
179
|
+
constructor(environmentId: string);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Represents a command to set a product by its ID.
|
|
184
|
+
*
|
|
185
|
+
* @remarks
|
|
186
|
+
* This action sends a message to the MetaBox API to set a product using the provided product ID.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* import { SetProduct,Communicator } from '@3dsource/metabox-front-api';
|
|
190
|
+
*
|
|
191
|
+
* //...Assume that the integration is already implemented
|
|
192
|
+
* window.env3DSource.apiReady = (api:Communicator) => {
|
|
193
|
+
* api.setCommandToMetaBox(new SetProduct(
|
|
194
|
+
* 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3'
|
|
195
|
+
* ));
|
|
196
|
+
* };
|
|
197
|
+
*/
|
|
198
|
+
declare class SetProduct extends CommandBase {
|
|
199
|
+
/**
|
|
200
|
+
* Creates an instance of SetProduct.
|
|
201
|
+
*
|
|
202
|
+
* @param productId - The product ID.
|
|
203
|
+
*/
|
|
204
|
+
constructor(productId: string);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Represents a command to get a PDF from Metabox.
|
|
209
|
+
* @remarks
|
|
210
|
+
* This class sends a message to the MetaBox API to generate a PDF based on the current configuration.
|
|
211
|
+
* This action does not require any parameters.
|
|
212
|
+
*
|
|
213
|
+
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* import { GetPdf,Communicator } from '@3dsource/metabox-front-api';
|
|
217
|
+
* window.env3DSource.apiReady = (api:Communicator) => {
|
|
218
|
+
* api.sendCommandToMetaBox(new GetPdf());
|
|
219
|
+
* };
|
|
220
|
+
*/
|
|
221
|
+
declare class GetPdf extends CommandBase {
|
|
222
|
+
/**
|
|
223
|
+
* Creates an instance of GetPdf.
|
|
224
|
+
*
|
|
225
|
+
* @remarks
|
|
226
|
+
* This constructor does not require any parameters.
|
|
227
|
+
*/
|
|
228
|
+
constructor();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Represents a command to set a material by its ID.
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* import { SetMaterial,Communicator } from '@3dsource/metabox-front-api';
|
|
236
|
+
*
|
|
237
|
+
* //...Assume that the integration is already implemented
|
|
238
|
+
* window.env3DSource.apiReady = (api:Communicator) => {
|
|
239
|
+
* api.sendCommandToMetaBox(new SetMaterial(
|
|
240
|
+
* 'carpaint',
|
|
241
|
+
* 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
|
|
242
|
+
* ));
|
|
243
|
+
* };
|
|
244
|
+
*/
|
|
245
|
+
declare class SetMaterial extends CommandBase {
|
|
246
|
+
/**
|
|
247
|
+
* Creates an instance of SetMaterial.
|
|
248
|
+
*
|
|
249
|
+
* @param slotId - The slot ID.
|
|
250
|
+
* @param materialId - The material ID.
|
|
251
|
+
*/
|
|
252
|
+
constructor(slotId: string, materialId: string);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Represents a command to set an environment material by its ID.
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* import { SetEnvironmentMaterial,Communicator } from '@3dsource/metabox-front-api';
|
|
260
|
+
*
|
|
261
|
+
* //...Assume that the integration is already implemented
|
|
262
|
+
* window.env3DSource.apiReady = (api:Communicator) => {
|
|
263
|
+
* api.sendCommandToMetaBox(new SetEnvironmentMaterial(
|
|
264
|
+
* 'carpaint',
|
|
265
|
+
* 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
|
|
266
|
+
* ));
|
|
267
|
+
* };
|
|
268
|
+
*/
|
|
269
|
+
declare class SetEnvironmentMaterial extends CommandBase {
|
|
270
|
+
/**
|
|
271
|
+
* Creates an instance of SetEnvironmentMaterial.
|
|
272
|
+
*
|
|
273
|
+
* @param slotId - The slot ID.
|
|
274
|
+
* @param materialId - The material ID.
|
|
275
|
+
*/
|
|
276
|
+
constructor(slotId: string, materialId: string);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* @internal
|
|
281
|
+
* @hidden
|
|
282
|
+
* Represents a command to send Unreal command.
|
|
283
|
+
*/
|
|
284
|
+
declare class UnrealCommand extends CommandBase {
|
|
285
|
+
constructor(payload: MetaBoxCommandPacket);
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* @deprecated, use `UnrealCommand` instead.
|
|
289
|
+
*/
|
|
290
|
+
declare const SendCommandToUnreal: typeof UnrealCommand;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* @experimental
|
|
294
|
+
* @internal
|
|
295
|
+
* @hidden
|
|
296
|
+
* @remarks
|
|
297
|
+
* Represents a command to watch Unreal callbacks from Unreal engine.
|
|
298
|
+
* Can be useful for custom solutions.
|
|
299
|
+
*/
|
|
300
|
+
declare class WatchCallbacks extends CommandBase {
|
|
301
|
+
/**
|
|
302
|
+
* Creates an instance of WatchCallbacks.
|
|
303
|
+
*
|
|
304
|
+
* @remarks
|
|
305
|
+
* This constructor does not require any parameters.
|
|
306
|
+
*/
|
|
307
|
+
constructor();
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Represents a callback listener for specific message types.
|
|
312
|
+
*/
|
|
313
|
+
interface Listener {
|
|
314
|
+
messageType: string;
|
|
315
|
+
callback: (data: unknown) => void;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* EventDispatcher is a class that manages event listeners and dispatches events to them.
|
|
319
|
+
*/
|
|
320
|
+
declare class EventDispatcher {
|
|
321
|
+
/**
|
|
322
|
+
* Storage for callback listeners by message type.
|
|
323
|
+
*/
|
|
324
|
+
listeners: Listener[];
|
|
325
|
+
destroy(): void;
|
|
326
|
+
/**
|
|
327
|
+
* Adds an event listener for receiving specific types of messages.
|
|
328
|
+
*
|
|
329
|
+
* @param messageType - The message type to listen for.
|
|
330
|
+
* @param callback - The callback function to execute when a message is received.
|
|
331
|
+
*/
|
|
332
|
+
addEventListener(messageType: string, callback: (data: unknown) => void): this;
|
|
333
|
+
/**
|
|
334
|
+
* Dispatches an event to all listeners of a specific message type.
|
|
335
|
+
*
|
|
336
|
+
* @param messageType - The message type.
|
|
337
|
+
* @param data - The data associated with the event.
|
|
338
|
+
*/
|
|
339
|
+
dispatchEvent(messageType: string, data: unknown): this;
|
|
340
|
+
/**
|
|
341
|
+
* Removes an event listener for a specific type of message.
|
|
342
|
+
*
|
|
343
|
+
* @param messageType - The message type.
|
|
344
|
+
* @param callback - The callback function to remove.
|
|
345
|
+
*/
|
|
346
|
+
removeEventListener(messageType: string, callback: (data: unknown) => void): this;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Represents a configurator object with its configuration, selected materials,
|
|
351
|
+
* product identifier, and associated environment.
|
|
352
|
+
*/
|
|
353
|
+
interface ConfiguratorEnvelope {
|
|
354
|
+
/**
|
|
355
|
+
* A reference to the universal configurator.
|
|
356
|
+
*/
|
|
357
|
+
configurator: UniversalConfigurator;
|
|
358
|
+
/**
|
|
359
|
+
* The unique product identifier.
|
|
360
|
+
*/
|
|
361
|
+
productId: string;
|
|
362
|
+
/**
|
|
363
|
+
* A record mapping product material selections.
|
|
364
|
+
*/
|
|
365
|
+
productMaterialsIds: SelectedIds;
|
|
366
|
+
/**
|
|
367
|
+
* @deprecated,
|
|
368
|
+
* use `productMaterialsIds` instead.
|
|
369
|
+
* @hidden
|
|
370
|
+
*/
|
|
371
|
+
selectedMaterials: SelectedIds;
|
|
372
|
+
/**
|
|
373
|
+
* The unique environment identifier.
|
|
374
|
+
*/
|
|
375
|
+
environmentId: string;
|
|
376
|
+
/**
|
|
377
|
+
* A record mapping environment material selections.
|
|
378
|
+
*/
|
|
379
|
+
environmentMaterialsIds: SelectedIds;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Represents the universal configurator with its basic properties and components.
|
|
383
|
+
*/
|
|
384
|
+
interface UniversalConfigurator {
|
|
385
|
+
/** Unique identifier for the configurator. */
|
|
386
|
+
id: string;
|
|
387
|
+
/** Indicates if the configurator is active. */
|
|
388
|
+
/** Label for the product collection. */
|
|
389
|
+
productCollectionLabel: string;
|
|
390
|
+
/** The name of the configurator. */
|
|
391
|
+
name: string;
|
|
392
|
+
/** The camera settings used in the configurator. */
|
|
393
|
+
/** Client information associated with the configurator. */
|
|
394
|
+
/** A list of products for the configurator. */
|
|
395
|
+
products: UniversalConfiguratorProduct[];
|
|
396
|
+
/** A list of available environments. */
|
|
397
|
+
environments: UniversalConfiguratorEnvironment[];
|
|
398
|
+
/** GraphQL typename for the configurator. */
|
|
399
|
+
__typename: 'UniversalConfigurator';
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Represents a product within the universal configurator.
|
|
403
|
+
*/
|
|
404
|
+
interface UniversalConfiguratorProduct {
|
|
405
|
+
/** The product's unique identifier. */
|
|
406
|
+
productId: string;
|
|
407
|
+
/** Position index of the product. */
|
|
408
|
+
position: number;
|
|
409
|
+
/** Display label for the product. */
|
|
410
|
+
label: string;
|
|
411
|
+
/** Optional camera settings for the product. */
|
|
412
|
+
/** The detailed product information. */
|
|
413
|
+
product: Product;
|
|
414
|
+
/** GraphQL typename for the product. */
|
|
415
|
+
__typename: 'UniversalConfiguratorProduct';
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Represents product details including visual assets and configuration.
|
|
419
|
+
*/
|
|
420
|
+
interface Product {
|
|
421
|
+
/** The title of the product. */
|
|
422
|
+
title: string;
|
|
423
|
+
/** List of thumbnails for the product. */
|
|
424
|
+
thumbnailList: Thumbnail[];
|
|
425
|
+
/** Available slots for the product. */
|
|
426
|
+
slots: Slot[];
|
|
427
|
+
/** List of metaProperties for the product (optional). */
|
|
428
|
+
metaProperties: MetaProperty[];
|
|
429
|
+
/** The model information associated with the product. */
|
|
430
|
+
/** Unique identifier for the product. */
|
|
431
|
+
id: string;
|
|
432
|
+
/** Unique external id for the product. */
|
|
433
|
+
externalId: string;
|
|
434
|
+
/** Showcase details for the product. */
|
|
435
|
+
/** GraphQL typename for the product. */
|
|
436
|
+
__typename: 'Product';
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Represents a thumbnail image entity with dimensions and URL path.
|
|
440
|
+
*/
|
|
441
|
+
interface Thumbnail {
|
|
442
|
+
/** Width of the thumbnail. */
|
|
443
|
+
width: number;
|
|
444
|
+
/** Height of the thumbnail. */
|
|
445
|
+
height: number;
|
|
446
|
+
/** URL path to the thumbnail image. */
|
|
447
|
+
urlPath: string;
|
|
448
|
+
/** GraphQL typename (as a string, flexible type). */
|
|
449
|
+
__typename: 'Thumbnail';
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Represents a slot within a product that may allow material customization.
|
|
453
|
+
*/
|
|
454
|
+
interface Slot {
|
|
455
|
+
/** Unique identifier for the slot. */
|
|
456
|
+
id: string;
|
|
457
|
+
/** Display a label for the slot. */
|
|
458
|
+
label: string;
|
|
459
|
+
/** A list of enabled materials for the slot. */
|
|
460
|
+
enabledMaterials: Material[];
|
|
461
|
+
/** GraphQL typename for the slot. */
|
|
462
|
+
__typename: 'Slot';
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Represents a metaProperty within a product that may allow business logic customization.
|
|
466
|
+
*/
|
|
467
|
+
interface MetaProperty {
|
|
468
|
+
/** Unique identifier for the metaProperty. */
|
|
469
|
+
id: string;
|
|
470
|
+
/** Display the name for the metaProperty. */
|
|
471
|
+
name: string;
|
|
472
|
+
/** Value for the metaProperty. */
|
|
473
|
+
value: string;
|
|
474
|
+
/** Type for the metaProperty. */
|
|
475
|
+
type: string;
|
|
476
|
+
/** GraphQL typename for the metaProperty. */
|
|
477
|
+
__typename: 'MetaProperty';
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Represents a material that can be applied to a product slot.
|
|
481
|
+
*/
|
|
482
|
+
interface Material {
|
|
483
|
+
/** Unique identifier for the material. */
|
|
484
|
+
id: string;
|
|
485
|
+
/** Title or name of the material. */
|
|
486
|
+
title: string;
|
|
487
|
+
/** Unique external id for the material. */
|
|
488
|
+
externalId: string;
|
|
489
|
+
/** List of thumbnails for the material. */
|
|
490
|
+
thumbnailList: Thumbnail[];
|
|
491
|
+
/** The model information associated with the material. */
|
|
492
|
+
/** GraphQL typename for the material. */
|
|
493
|
+
__typename: 'Material';
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Represents the environment settings for a universal configurator.
|
|
497
|
+
*/
|
|
498
|
+
interface UniversalConfiguratorEnvironment {
|
|
499
|
+
/** Unique identifier for the environment. */
|
|
500
|
+
environmentId: string;
|
|
501
|
+
/** Position index of the environment. */
|
|
502
|
+
position: number;
|
|
503
|
+
/** Display label for the environment. */
|
|
504
|
+
label: string;
|
|
505
|
+
/** Detailed environment configuration. */
|
|
506
|
+
environment: Environment;
|
|
507
|
+
/** GraphQL typename for the environment. */
|
|
508
|
+
__typename: 'UniversalConfiguratorEnvironment';
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Represents an environment with associated media and configuration.
|
|
512
|
+
*/
|
|
513
|
+
interface Environment {
|
|
514
|
+
/** Unique identifier for the environment. */
|
|
515
|
+
id: string;
|
|
516
|
+
/** Title or name of the environment. */
|
|
517
|
+
title: string;
|
|
518
|
+
/** Flag indicating if UDS is enabled. */
|
|
519
|
+
/** The north yaw of the sun in the environment. */
|
|
520
|
+
/** The UDS hour setting for the environment. */
|
|
521
|
+
/** GraphQL typename for the environment. */
|
|
522
|
+
__typename: 'Environment';
|
|
523
|
+
/** List of thumbnails for the environment (optional). */
|
|
524
|
+
thumbnailList: Thumbnail[];
|
|
525
|
+
/** List of slots for the environment (optional). */
|
|
526
|
+
slots: Slot[];
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Defines the structure for a mapping of selected materials.
|
|
530
|
+
*/
|
|
531
|
+
type SelectedIds = Record<string, Record<string, string>>;
|
|
532
|
+
|
|
533
|
+
type FromMetaboxApiAction = 'bridge' | 'appLoaded';
|
|
534
|
+
/**
|
|
535
|
+
* @hidden
|
|
536
|
+
* Preserved for backward compatibility.
|
|
537
|
+
* @deprecated Use FromMetaboxApiAction type instead.
|
|
538
|
+
*/
|
|
539
|
+
type FromMetaboxDeprecatedApiAction =
|
|
540
|
+
/**
|
|
541
|
+
* @hidden
|
|
542
|
+
* @deprecated, use MetaBoxApiAction.Bridge with eventType: "unrealFeature"
|
|
543
|
+
*/
|
|
544
|
+
'unrealFeatureBridge'
|
|
545
|
+
/**
|
|
546
|
+
* @hidden
|
|
547
|
+
* @deprecated, use MetaBoxApiAction.Bridge with eventType: "unrealCallback"
|
|
548
|
+
*/
|
|
549
|
+
| 'unrealCallback'
|
|
550
|
+
/**
|
|
551
|
+
* @hidden
|
|
552
|
+
* @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
|
|
553
|
+
*/
|
|
554
|
+
| 'configuratorDataWithStateBridge'
|
|
555
|
+
/**
|
|
556
|
+
* @hidden
|
|
557
|
+
* @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
|
|
558
|
+
*/
|
|
559
|
+
| 'configuratorDataBridge'
|
|
560
|
+
/**
|
|
561
|
+
* @hidden
|
|
562
|
+
* @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
|
|
563
|
+
*/
|
|
564
|
+
| 'menuDataBridge'
|
|
565
|
+
/**
|
|
566
|
+
* @hidden
|
|
567
|
+
* @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
|
|
568
|
+
*/
|
|
569
|
+
| 'flatMenuDataBridge'
|
|
570
|
+
/**
|
|
571
|
+
* @hidden
|
|
572
|
+
* @deprecated, use Bridge with isFullscreen
|
|
573
|
+
*/
|
|
574
|
+
| 'fullScreenBridge'
|
|
575
|
+
/**
|
|
576
|
+
* @hidden
|
|
577
|
+
* @deprecated, use Bridge with streamResolution
|
|
578
|
+
*/
|
|
579
|
+
| 'videoSize'
|
|
580
|
+
/**
|
|
581
|
+
* @hidden
|
|
582
|
+
* Used in a platform, must be removed in future
|
|
583
|
+
* @deprecated
|
|
584
|
+
*/
|
|
585
|
+
| 'unrealResponse'
|
|
586
|
+
/**
|
|
587
|
+
* @hidden
|
|
588
|
+
* @deprecated\
|
|
589
|
+
*/
|
|
590
|
+
| 'getFastRender';
|
|
591
|
+
|
|
592
|
+
interface FromMetaboxMessagePayloads {
|
|
593
|
+
/**
|
|
594
|
+
* Dispatches Every time the configurator data is updated.
|
|
595
|
+
* I.e., when the user changes the configuration. (Material, Product, Environment)
|
|
596
|
+
*/
|
|
597
|
+
configuratorData: ConfiguratorEnvelope;
|
|
598
|
+
/**
|
|
599
|
+
* @hidden
|
|
600
|
+
* @deprecated, use configuratorData instead.
|
|
601
|
+
*/
|
|
602
|
+
basicConfiguratorDataWithState: ConfiguratorEnvelope;
|
|
603
|
+
/**
|
|
604
|
+
* Dispatches Every time when the configurator connected/disconnected with Unreal Engine.
|
|
605
|
+
*/
|
|
606
|
+
dataChannelConnected: boolean;
|
|
607
|
+
/**
|
|
608
|
+
* Dispatches Every time when the Unreal Viewport is visible/hidden.
|
|
609
|
+
*/
|
|
610
|
+
viewportReady: boolean;
|
|
611
|
+
/**
|
|
612
|
+
* Dispatches Every when user toggles fullscreen button in an internal menu.
|
|
613
|
+
*/
|
|
614
|
+
isFullScreen: boolean;
|
|
615
|
+
/**
|
|
616
|
+
* Dispatches at the moment while the configurator loads. Shows status information.
|
|
617
|
+
*/
|
|
618
|
+
statusMessage: string | null;
|
|
619
|
+
/**
|
|
620
|
+
* @deprecated
|
|
621
|
+
* @hidden
|
|
622
|
+
* Dispatches every time when the freeze-frame is arrived or updated.
|
|
623
|
+
*/
|
|
624
|
+
freezeFrame: {
|
|
625
|
+
dataUrl: string | null;
|
|
626
|
+
progress: number | null;
|
|
627
|
+
};
|
|
628
|
+
/**
|
|
629
|
+
* @experimental
|
|
630
|
+
* Dispatches every Unreal is sending a command callback.
|
|
631
|
+
* Works only after the new WatchCallbacks () command is sent.
|
|
632
|
+
*/
|
|
633
|
+
unrealCallback: {
|
|
634
|
+
json: UnrealCallBackJson;
|
|
635
|
+
};
|
|
636
|
+
/**
|
|
637
|
+
* Dispatches every time when Unreal is sending ordered render with new GetFastRender() command.
|
|
638
|
+
*/
|
|
639
|
+
screenshot: string | null;
|
|
640
|
+
getScreenshot: string | null;
|
|
641
|
+
/**
|
|
642
|
+
* @hidden
|
|
643
|
+
* @deprecated, use screenshot
|
|
644
|
+
*/
|
|
645
|
+
fastRender: string | null;
|
|
646
|
+
/**
|
|
647
|
+
* @hidden
|
|
648
|
+
* @deprecated, use fastRender
|
|
649
|
+
*/
|
|
650
|
+
getFastRender: string | null;
|
|
651
|
+
/**
|
|
652
|
+
* @experimental
|
|
653
|
+
* Dispatches every Unreal state is changing, including all unreal module state.
|
|
654
|
+
*/
|
|
655
|
+
unrealState: UnrealState;
|
|
656
|
+
/**
|
|
657
|
+
* @hidden
|
|
658
|
+
* @deprecated, use unrealState
|
|
659
|
+
*/
|
|
660
|
+
unrealFeature: UnrealState;
|
|
661
|
+
/**
|
|
662
|
+
* Dispatches every time when Unreal is changing its video stream size.
|
|
663
|
+
*/
|
|
664
|
+
videoResolution: StreamResolutionProps;
|
|
665
|
+
/**
|
|
666
|
+
* @hidden
|
|
667
|
+
* @deprecated, use videoResolution
|
|
668
|
+
*/
|
|
669
|
+
streamResolution: StreamResolutionProps;
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* @hidden
|
|
673
|
+
*/
|
|
674
|
+
type FromMetaBoxApiEvents = keyof FromMetaboxMessagePayloads;
|
|
675
|
+
/**
|
|
676
|
+
* @internal
|
|
677
|
+
* This creates all event envelopes defined in MetaBoxAPIPayloads.
|
|
678
|
+
*/
|
|
679
|
+
interface MetaBoxApiEnvelope<T extends FromMetaBoxApiEvents> {
|
|
680
|
+
action: 'bridge';
|
|
681
|
+
eventType: T;
|
|
682
|
+
payload: FromMetaboxMessagePayloads[T];
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* @hidden
|
|
686
|
+
* @internal
|
|
687
|
+
* Used for signaling that the app is loaded and ready to open api.
|
|
688
|
+
*/
|
|
689
|
+
interface MCAppLoaded {
|
|
690
|
+
action: 'appLoaded';
|
|
691
|
+
eventType?: unknown;
|
|
692
|
+
payload?: unknown;
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
695
|
+
* @hidden
|
|
696
|
+
* Preserved for backward compatibility.
|
|
697
|
+
* @deprecated
|
|
698
|
+
* Used for sending deprecated messages, must be removed in the future.
|
|
699
|
+
*/
|
|
700
|
+
interface DeprecatedEnvelope {
|
|
701
|
+
action: FromMetaboxDeprecatedApiAction | FromMetaboxApiAction;
|
|
702
|
+
eventType?: unknown;
|
|
703
|
+
payload?: unknown;
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* @internal
|
|
707
|
+
* @hidden
|
|
708
|
+
* This creates a union of all event envelopes defined in MetaBoxAPIPayloads.
|
|
709
|
+
*/
|
|
710
|
+
type FromMetaBoxAPIEnvelope = {
|
|
711
|
+
[K in keyof FromMetaboxMessagePayloads]: MetaBoxApiEnvelope<K>;
|
|
712
|
+
}[keyof FromMetaboxMessagePayloads] | MCAppLoaded | DeprecatedEnvelope;
|
|
713
|
+
interface FromMetaBoxMessage {
|
|
714
|
+
host: 'metabox';
|
|
715
|
+
/**
|
|
716
|
+
* @hidden
|
|
717
|
+
* Preserved for backward compatibility.
|
|
718
|
+
* @deprecated, use `envelope` instead.
|
|
719
|
+
*/
|
|
720
|
+
payload?: FromMetaBoxAPIEnvelope;
|
|
721
|
+
envelope: FromMetaBoxAPIEnvelope;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* Handles messaging between the host page and embedded MetaBox content.
|
|
726
|
+
* @internal Use {@link Communicator.createInstance} or the {@link integrateMetaBox} helper to instantiate.
|
|
727
|
+
*/
|
|
728
|
+
declare class Communicator extends EventDispatcher {
|
|
729
|
+
/**
|
|
730
|
+
* Singleton reference to the current communicator instance.
|
|
731
|
+
*/
|
|
732
|
+
static instance: Communicator | null;
|
|
733
|
+
/**
|
|
734
|
+
* Bound handler for incoming postMessage events.
|
|
735
|
+
*/
|
|
736
|
+
private binder;
|
|
737
|
+
/**
|
|
738
|
+
* Constructs a Communicator, replacing any existing instance, and begins listening for messages.
|
|
739
|
+
* @internal
|
|
740
|
+
*/
|
|
741
|
+
constructor();
|
|
742
|
+
/**
|
|
743
|
+
* Listens for MetaBox to signal readiness, then initializes communicator.
|
|
744
|
+
* @param apiReadyCallback - Called with the new Communicator once MetaBox is loaded.
|
|
745
|
+
*/
|
|
746
|
+
static createInstance(apiReadyCallback: (api: Communicator) => void): void;
|
|
747
|
+
/**
|
|
748
|
+
* Cleans up resources and stops listening for messages.
|
|
749
|
+
*/
|
|
750
|
+
destroy(): void;
|
|
751
|
+
/**
|
|
752
|
+
* Posts a command to the MetaBox iframe.
|
|
753
|
+
* @param command - An action command containing data to send.
|
|
754
|
+
*/
|
|
755
|
+
sendCommandToMetaBox<T extends CommandBase>(command: T): void;
|
|
756
|
+
/**
|
|
757
|
+
* Registers an event listener for messages dispatched by MetaBox.
|
|
758
|
+
* @override
|
|
759
|
+
*/
|
|
760
|
+
addEventListener<T extends FromMetaBoxApiEvents>(messageType: T, callback: (data: FromMetaboxMessagePayloads[T]) => void): this;
|
|
761
|
+
/**
|
|
762
|
+
* Dispatches a typed event to all registered listeners.
|
|
763
|
+
* @override
|
|
764
|
+
*/
|
|
765
|
+
dispatchEvent<T extends FromMetaBoxApiEvents>(messageType: T, data: FromMetaboxMessagePayloads[T]): this;
|
|
766
|
+
/**
|
|
767
|
+
* Removes a previously registered event listener.
|
|
768
|
+
* @override
|
|
769
|
+
*/
|
|
770
|
+
removeEventListener<T extends FromMetaBoxApiEvents>(messageType: T, callback: (data: FromMetaboxMessagePayloads[T]) => void): this;
|
|
771
|
+
/**
|
|
772
|
+
* Filters and dispatches incoming messages from MetaBox.
|
|
773
|
+
* @param messageType - Expected message type for filtering ('metaboxData').
|
|
774
|
+
* @param event - The postMessage event received on window.
|
|
775
|
+
*/
|
|
776
|
+
private handleMessageReceived;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* Integrates the MetaBox into the provided layout.
|
|
781
|
+
*
|
|
782
|
+
* @remarks
|
|
783
|
+
* This function injects an iframe into a specified container element in the DOM and initializes
|
|
784
|
+
* the communicator for interacting with the MetaBox embedded content.
|
|
785
|
+
*
|
|
786
|
+
* @param iframeSrc - The source URL of the MetaBox iframe.
|
|
787
|
+
* Additional url parameters:
|
|
788
|
+
* ```javascript
|
|
789
|
+
* sidebar=false - disables the internal MetaBox menu
|
|
790
|
+
* introImage=https://example.com/image.png - sets the intro image
|
|
791
|
+
* ```
|
|
792
|
+
* i.e. final link will look like https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id?sidebar=false&introImage=https://example.com/image.png
|
|
793
|
+
*
|
|
794
|
+
* @param containerId - The ID of the layout element. Defaults to 'embed3DSource'.
|
|
795
|
+
* @param apiReadyCallback
|
|
796
|
+
* @throws Error if the container element with the specified ID is not found.
|
|
797
|
+
*
|
|
798
|
+
* @example
|
|
799
|
+
* import {
|
|
800
|
+
* integrateMetaBox,
|
|
801
|
+
* } from '@3dsource/metabox-front-api';
|
|
802
|
+
*
|
|
803
|
+
* integrateMetaBox(
|
|
804
|
+
* 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
|
|
805
|
+
* 'embed3DSource'
|
|
806
|
+
* );
|
|
807
|
+
*/
|
|
808
|
+
declare function integrateMetaBox(iframeSrc: string, containerId: string | undefined, apiReadyCallback: (api: Communicator) => void): void;
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* Wrapper helper function to use it with rxJs the same as `fromEvent` to listen to events from the Communicator.
|
|
812
|
+
* @param target
|
|
813
|
+
* @param eventName
|
|
814
|
+
*/
|
|
815
|
+
declare function fromCommunicatorEvent<T extends FromMetaBoxApiEvents>(target: Communicator, eventName: T): Observable<FromMetaboxMessagePayloads[T]>;
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* Saves an image by triggering a download.
|
|
819
|
+
*
|
|
820
|
+
* @remarks
|
|
821
|
+
* This function creates an anchor element, sets its `href` attribute to the provided image URL,
|
|
822
|
+
* and triggers a click event to initiate a download with the specified filename.
|
|
823
|
+
*
|
|
824
|
+
* @param imageUrl - The URL of the image to save.
|
|
825
|
+
* @param filename - The name of the file to save.
|
|
826
|
+
*/
|
|
827
|
+
declare function saveImage(imageUrl: string, filename: string): void;
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Pauses execution for a specified duration.
|
|
831
|
+
*
|
|
832
|
+
* @remarks
|
|
833
|
+
* This function returns a promise that resolves after the given number of milliseconds.
|
|
834
|
+
*
|
|
835
|
+
* @param time - The time to sleep in milliseconds.
|
|
836
|
+
* @returns A promise that resolves after the specified duration.
|
|
837
|
+
*/
|
|
838
|
+
declare function sleep(time: number): Promise<void>;
|
|
839
|
+
|
|
840
|
+
/**
|
|
841
|
+
* Sets the URL parameters based on the provided state.
|
|
842
|
+
*
|
|
843
|
+
* @remarks
|
|
844
|
+
* This function updates the current URL by replacing its search parameters with the key-value pairs from the provided state object.
|
|
845
|
+
*
|
|
846
|
+
* @param state - An object containing key-value pairs to set as URL parameters.
|
|
847
|
+
*/
|
|
848
|
+
declare function setUrlParams(state: Record<string, string>): void;
|
|
849
|
+
/**
|
|
850
|
+
* Retrieves the URL parameters as an object.
|
|
851
|
+
*
|
|
852
|
+
* @remarks
|
|
853
|
+
* This function parses the current URL's search parameters and returns them as a key-value object.
|
|
854
|
+
*
|
|
855
|
+
* @returns An object containing the URL parameters.
|
|
856
|
+
*/
|
|
857
|
+
declare function getUrlParams(): Record<string, string>;
|
|
858
|
+
|
|
859
|
+
export { CommandBase, Communicator, GetPdf, GetScreenshot, SendCommandToUnreal, SetEnvironment, SetEnvironmentMaterial, SetMaterial, SetProduct, ShowEmbeddedMenu, ShowOverlayInterface, UnrealCommand, WatchCallbacks, fromCommunicatorEvent, getUrlParams, integrateMetaBox, saveImage, setUrlParams, sleep };
|
|
860
|
+
export type { ApplicationDeviceTypes, ConfiguratorEnvelope, DeprecatedEnvelope, Environment, FromMetaBoxAPIEnvelope, FromMetaBoxApiEvents, FromMetaBoxMessage, FromMetaboxApiAction, FromMetaboxDeprecatedApiAction, FromMetaboxMessagePayloads, MCAppLoaded, Material, MetaBoxApiEnvelope, MetaProperty, MimeType, Product, SelectedIds, Slot, Thumbnail, ToMetaBoxActions, ToMetaBoxMessage, ToMetaBoxMessageEnvelope, ToMetaboxMessagePayload, ToMetaboxMessagePayloads, UniversalConfigurator, UniversalConfiguratorEnvironment, UniversalConfiguratorProduct };
|