@3dsource/metabox-front-api 1.2.2 → 1.2.3-dev.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 +38 -33
- package/fesm2022/3dsource-metabox-front-api.mjs +40 -8
- package/fesm2022/3dsource-metabox-front-api.mjs.map +1 -1
- package/index.d.ts +66 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@ their material slots, and materials, environments.
|
|
|
11
11
|
- [Installation](#installation)
|
|
12
12
|
- [Quick Start](#quick-start)
|
|
13
13
|
- [API Reference](#api-reference)
|
|
14
|
+
- [System Terminology](#system-terminology)
|
|
14
15
|
- [Core Functions](#core-functions)
|
|
15
16
|
- [Command Classes](#command-classes)
|
|
16
17
|
- [Event Handling](#event-handling)
|
|
@@ -44,7 +45,7 @@ their material slots, and materials, environments.
|
|
|
44
45
|
For use with frameworks like Angular, React, Vue, etc.:
|
|
45
46
|
|
|
46
47
|
```bash
|
|
47
|
-
npm install @3dsource/metabox-front-api@^1.2.
|
|
48
|
+
npm install @3dsource/metabox-front-api@^1.2.2 --save
|
|
48
49
|
```
|
|
49
50
|
|
|
50
51
|
Then import the required components:
|
|
@@ -57,7 +58,7 @@ import { integrateMetaBox, Communicator, ConfiguratorEnvelope, SetProduct, SetMa
|
|
|
57
58
|
|
|
58
59
|
Alternative CDN options:
|
|
59
60
|
|
|
60
|
-
- **jsDelivr**: `https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@^1.2.
|
|
61
|
+
- **jsDelivr**: `https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@^1.2.2/+esm`
|
|
61
62
|
|
|
62
63
|
For quick prototyping or vanilla JavaScript projects:
|
|
63
64
|
|
|
@@ -101,7 +102,7 @@ Create a container element where the Metabox Configurator will be embedded:
|
|
|
101
102
|
|
|
102
103
|
```html
|
|
103
104
|
<script type="module">
|
|
104
|
-
import { integrateMetaBox, SetProduct, SetMaterial, SetEnvironment, GetScreenshot, saveImage } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@1.2.
|
|
105
|
+
import { integrateMetaBox, SetProduct, SetMaterial, SetEnvironment, GetScreenshot, saveImage } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@1.2.2';
|
|
105
106
|
|
|
106
107
|
class MetaboxIntegrator {
|
|
107
108
|
constructor() {
|
|
@@ -118,13 +119,13 @@ Create a container element where the Metabox Configurator will be embedded:
|
|
|
118
119
|
console.log('Metabox API is ready!');
|
|
119
120
|
|
|
120
121
|
// Listen for configurator data updates
|
|
121
|
-
api.addEventListener('
|
|
122
|
+
api.addEventListener('configuratorDataUpdated', (data) => {
|
|
122
123
|
console.log('Configurator data updated:', data);
|
|
123
124
|
this.handleConfiguratorUpdate(data);
|
|
124
125
|
});
|
|
125
126
|
|
|
126
127
|
// Listen for screenshot/render completion
|
|
127
|
-
api.addEventListener('
|
|
128
|
+
api.addEventListener('screenshotReady', (imageData) => {
|
|
128
129
|
console.log('Screenshot ready');
|
|
129
130
|
saveImage(imageData, 'configurator-screenshot.png');
|
|
130
131
|
});
|
|
@@ -199,13 +200,13 @@ class MetaboxIntegrator {
|
|
|
199
200
|
if (!this.api) return;
|
|
200
201
|
|
|
201
202
|
// Listen for configurator data updates
|
|
202
|
-
this.api.addEventListener('
|
|
203
|
+
this.api.addEventListener('configuratorDataUpdated', (data: ConfiguratorEnvelope) => {
|
|
203
204
|
console.log('Configurator data updated:', data);
|
|
204
205
|
this.handleConfiguratorUpdate(data);
|
|
205
206
|
});
|
|
206
207
|
|
|
207
208
|
// Listen for screenshot/render completion
|
|
208
|
-
this.api.addEventListener('
|
|
209
|
+
this.api.addEventListener('screenshotReady', (imageData: string) => {
|
|
209
210
|
console.log('Screenshot ready');
|
|
210
211
|
saveImage(imageData, 'configurator-screenshot.png');
|
|
211
212
|
});
|
|
@@ -213,11 +214,11 @@ class MetaboxIntegrator {
|
|
|
213
214
|
|
|
214
215
|
private handleConfiguratorUpdate(data: ConfiguratorEnvelope): void {
|
|
215
216
|
// Handle configurator state changes with full type safety
|
|
216
|
-
// Access
|
|
217
|
+
// Access ConfiguratorEnvelope properties.
|
|
217
218
|
|
|
218
219
|
// Example: Update UI based on current product
|
|
219
|
-
if (data
|
|
220
|
-
console.log('Current
|
|
220
|
+
if (data) {
|
|
221
|
+
console.log('Current state:', data);
|
|
221
222
|
}
|
|
222
223
|
}
|
|
223
224
|
|
|
@@ -274,6 +275,18 @@ const metaboxIntegrator = new MetaboxIntegrator();
|
|
|
274
275
|
|
|
275
276
|
## API Reference
|
|
276
277
|
|
|
278
|
+
### System Terminology
|
|
279
|
+
|
|
280
|
+
- **product** - 3D digital twin of the actual physical product within a Metabox system; concept is used in Basic configurator.
|
|
281
|
+
- **productId** - Unique Product ID within the Metabox system; mandatory. Assigned by the Metabox system automatically after the product's 3D digital twin is uploaded into Metabox.
|
|
282
|
+
- **environment** - 3D digital twin of the actual environment (room scene or other) within a Metabox system.
|
|
283
|
+
- **environmentId** - Unique environment ID within the Metabox system; mandatory. Assigned by the Metabox system automatically after the environment's 3D digital twin is uploaded into Metabox.
|
|
284
|
+
- **externalId** - Product or Material ID assigned to product or material in Metabox; optional; can be a combination of letters or numbers or both. Should be identical to the product SKU number in any other non-Metabox e-commerce system that is used for managing products, so Metabox can be integrated with such a system.
|
|
285
|
+
- **showcase** - Exists as an attribute of product only; optional. If present, it means the product's digital twin contains a camera sequence that causes the video mode added automatically to the configurator by Metabox system to play this camera sequence.
|
|
286
|
+
- **component** - Product in the Modular configurator context.
|
|
287
|
+
- **componentId** - Unique Component ID within the Metabox system; mandatory. Assigned by the Metabox system automatically after the Modular configurator is created in Metabox.
|
|
288
|
+
- **componentType** - Exists in Modular Configurator only; the name of the type of the product component, which can include one or several separate products of the same category (examples of product component types: truck wheel, truck bumper). It is set by an unreal artist while creating the digital twin model and is automatically added to the Metabox system after this twin is uploaded to Metabox.
|
|
289
|
+
|
|
277
290
|
### Core Functions
|
|
278
291
|
|
|
279
292
|
#### `integrateMetaBox`
|
|
@@ -391,14 +404,6 @@ api.sendCommandToMetaBox(new GetScreenshot(mimeType, { x: 1920, y: 1080 }));
|
|
|
391
404
|
- `mimeType`: Image format ('image/png', 'image/jpeg', etc.)
|
|
392
405
|
- `size`: Optional dimensions object with x and y properties
|
|
393
406
|
|
|
394
|
-
##### `GetFastRender`
|
|
395
|
-
|
|
396
|
-
Captures a fast render of the current view (optimized for speed).
|
|
397
|
-
|
|
398
|
-
```typescript
|
|
399
|
-
api.sendCommandToMetaBox(new GetFastRender());
|
|
400
|
-
```
|
|
401
|
-
|
|
402
407
|
##### `GetPdf`
|
|
403
408
|
|
|
404
409
|
Generates a PDF of the current view.
|
|
@@ -447,23 +452,23 @@ The API uses an event-driven architecture. Listen for events using the `addEvent
|
|
|
447
452
|
|
|
448
453
|
#### Available Events
|
|
449
454
|
|
|
450
|
-
##### `
|
|
455
|
+
##### `configuratorDataUpdated`
|
|
451
456
|
|
|
452
457
|
Fired when the configurator state changes (product, materials, environment, etc.).
|
|
453
458
|
|
|
454
459
|
```typescript
|
|
455
|
-
api.addEventListener('
|
|
460
|
+
api.addEventListener('configuratorDataUpdated', (data: ConfiguratorEnvelope) => {
|
|
456
461
|
console.log('Configurator state updated:', data);
|
|
457
462
|
// Access data.product, data.materials, data.environment, etc.
|
|
458
463
|
});
|
|
459
464
|
```
|
|
460
465
|
|
|
461
|
-
##### `
|
|
466
|
+
##### `screenshotReady`
|
|
462
467
|
|
|
463
468
|
Fired when a screenshot or fast render is completed.
|
|
464
469
|
|
|
465
470
|
```typescript
|
|
466
|
-
api.addEventListener('
|
|
471
|
+
api.addEventListener('screenshotReady', (imageData: string) => {
|
|
467
472
|
console.log('Render completed');
|
|
468
473
|
// imageData contains the base64 encoded image
|
|
469
474
|
saveImage(imageData, 'screenshot.png');
|
|
@@ -499,7 +504,7 @@ function saveImage(imageUrl: string, filename: string): void;
|
|
|
499
504
|
**Example:**
|
|
500
505
|
|
|
501
506
|
```typescript
|
|
502
|
-
api.addEventListener('
|
|
507
|
+
api.addEventListener('screenshotReady', (imageData: string | null) => {
|
|
503
508
|
saveImage(imageData ?? '', 'my-render.png');
|
|
504
509
|
});
|
|
505
510
|
```
|
|
@@ -611,14 +616,14 @@ A complete HTML example showing how to integrate the Metabox configurator with v
|
|
|
611
616
|
console.log('Configurator ready!');
|
|
612
617
|
|
|
613
618
|
// Listen for configurator state changes
|
|
614
|
-
api.addEventListener('
|
|
619
|
+
api.addEventListener('configuratorDataUpdated', (data) => {
|
|
615
620
|
console.log('Configurator state updated:', data);
|
|
616
621
|
// You can update your UI based on the current state
|
|
617
622
|
// For example, update available materials, products, etc.
|
|
618
623
|
});
|
|
619
624
|
|
|
620
625
|
// Listen for screenshot completion
|
|
621
|
-
api.addEventListener('
|
|
626
|
+
api.addEventListener('screenshotReady', (imageData) => {
|
|
622
627
|
console.log('Screenshot captured successfully');
|
|
623
628
|
// Save the image with a timestamp
|
|
624
629
|
saveImage(imageData, `configurator-screenshot-${Date.now()}.png`);
|
|
@@ -770,13 +775,13 @@ const MetaboxConfigurator: React.FC<MetaboxConfiguratorProps> = ({ configuratorU
|
|
|
770
775
|
setState((prev) => ({ ...prev, isLoading: false, isApiReady: true }));
|
|
771
776
|
|
|
772
777
|
// Set up event listeners with proper typing
|
|
773
|
-
apiInstance.addEventListener('
|
|
778
|
+
apiInstance.addEventListener('configuratorDataUpdated', (data: ConfiguratorEnvelope) => {
|
|
774
779
|
if (mounted) {
|
|
775
780
|
onStateChange?.(data);
|
|
776
781
|
}
|
|
777
782
|
});
|
|
778
783
|
|
|
779
|
-
apiInstance.addEventListener('
|
|
784
|
+
apiInstance.addEventListener('screenshotReady', (imageData: string) => {
|
|
780
785
|
if (mounted) {
|
|
781
786
|
console.log('Screenshot captured successfully');
|
|
782
787
|
saveImage(imageData, `configurator-screenshot-${Date.now()}.png`);
|
|
@@ -1436,7 +1441,7 @@ export class MetaboxConfiguratorComponent implements OnInit {
|
|
|
1436
1441
|
return;
|
|
1437
1442
|
}
|
|
1438
1443
|
// Listen for configurator state changes
|
|
1439
|
-
this.api.addEventListener('
|
|
1444
|
+
this.api.addEventListener('configuratorDataUpdated', (data: ConfiguratorEnvelope) => {
|
|
1440
1445
|
console.log('Configurator state updated:', data);
|
|
1441
1446
|
this.stateChange.emit(data);
|
|
1442
1447
|
});
|
|
@@ -1536,7 +1541,7 @@ Always implement proper error handling when working with the API:
|
|
|
1536
1541
|
integrateMetaBox(configuratorUrl, containerId, (api) => {
|
|
1537
1542
|
try {
|
|
1538
1543
|
// Set up event listeners with error handling
|
|
1539
|
-
api.addEventListener('
|
|
1544
|
+
api.addEventListener('configuratorDataUpdated', (data) => {
|
|
1540
1545
|
try {
|
|
1541
1546
|
handleConfiguratorUpdate(data);
|
|
1542
1547
|
} catch (error) {
|
|
@@ -1700,7 +1705,7 @@ const sendCommand = (command) => {
|
|
|
1700
1705
|
```typescript
|
|
1701
1706
|
integrateMetaBox(configuratorUrl, containerId, (api) => {
|
|
1702
1707
|
// Set up listeners immediately
|
|
1703
|
-
api.addEventListener('
|
|
1708
|
+
api.addEventListener('configuratorDataUpdated', (data) => {
|
|
1704
1709
|
console.log('Event received:', data);
|
|
1705
1710
|
});
|
|
1706
1711
|
|
|
@@ -1724,7 +1729,7 @@ integrateMetaBox(configuratorUrl, containerId, (api) => {
|
|
|
1724
1729
|
|
|
1725
1730
|
```typescript
|
|
1726
1731
|
// Wait for scene to load before screenshot
|
|
1727
|
-
api.addEventListener('
|
|
1732
|
+
api.addEventListener('configuratorDataUpdated', (data) => {
|
|
1728
1733
|
// Scene is loaded, safe to take screenshot
|
|
1729
1734
|
setTimeout(() => {
|
|
1730
1735
|
api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1920, y: 1080 }));
|
|
@@ -1744,11 +1749,11 @@ integrateMetaBox(configuratorUrl, containerId, (api) => {
|
|
|
1744
1749
|
console.log('API initialized:', api);
|
|
1745
1750
|
|
|
1746
1751
|
// Log all events
|
|
1747
|
-
api.addEventListener('
|
|
1752
|
+
api.addEventListener('configuratorDataUpdated', (data) => {
|
|
1748
1753
|
console.log('State update:', data);
|
|
1749
1754
|
});
|
|
1750
1755
|
|
|
1751
|
-
api.addEventListener('
|
|
1756
|
+
api.addEventListener('screenshotReady', (imageData) => {
|
|
1752
1757
|
console.log('Render completed, data length:', imageData.length);
|
|
1753
1758
|
});
|
|
1754
1759
|
});
|
|
@@ -21,6 +21,7 @@ const MetaboxBasicConfiguratorActions = {
|
|
|
21
21
|
setProduct: 'setProduct',
|
|
22
22
|
setMaterialById: 'setMaterialById',
|
|
23
23
|
getPdf: 'getPdf',
|
|
24
|
+
getCallToActionInformation: 'getCallToActionInformation',
|
|
24
25
|
getScreenshot: 'getScreenshot',
|
|
25
26
|
getFastRender: 'getFastRender', // @deprecated, use 'getScreenshot'
|
|
26
27
|
showEmbeddedMenu: 'showEmbeddedMenu',
|
|
@@ -38,7 +39,7 @@ const MetaboxBasicConfiguratorActions = {
|
|
|
38
39
|
};
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
|
-
* Represents a command to get a PDF from Metabox.
|
|
42
|
+
* Represents a command to get a PDF from Metabox Basic Configurator.
|
|
42
43
|
* @remarks
|
|
43
44
|
* This class sends a message to the Metabox API to generate a PDF based on the current configuration.
|
|
44
45
|
* This action does not require any parameters.
|
|
@@ -64,6 +65,35 @@ class GetPdf extends CommandBase {
|
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Represents a command to get a Call To Action Information from Metabox Basic Configurator.
|
|
70
|
+
* @remarks
|
|
71
|
+
* This class sends a message to the Metabox API to generate Call To Action information based on the current configuration and sends it to the endpoint url from the cta information.
|
|
72
|
+
* This action does not require any parameters.
|
|
73
|
+
*
|
|
74
|
+
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* import { GetCallToActionInformation, Communicator } from '@3dsource/metabox-front-api';
|
|
78
|
+
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
79
|
+
* api.sendCommandToMetaBox(new GetCallToActionInformation());
|
|
80
|
+
* };
|
|
81
|
+
*/
|
|
82
|
+
class GetCallToActionInformation extends CommandBase {
|
|
83
|
+
/**
|
|
84
|
+
* Creates an instance of GetCallToActionInformation.
|
|
85
|
+
*
|
|
86
|
+
* @remarks
|
|
87
|
+
* This constructor does not require any parameters.
|
|
88
|
+
*/
|
|
89
|
+
constructor() {
|
|
90
|
+
super();
|
|
91
|
+
this.data = {
|
|
92
|
+
action: MetaboxBasicConfiguratorActions.getCallToActionInformation,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
67
97
|
/**
|
|
68
98
|
* Represents a command to get a screenshot.
|
|
69
99
|
*
|
|
@@ -95,6 +125,9 @@ class GetScreenshot extends CommandBase {
|
|
|
95
125
|
}
|
|
96
126
|
}
|
|
97
127
|
|
|
128
|
+
/**
|
|
129
|
+
* @deprecated, use {@link GetScreenshot} instead.
|
|
130
|
+
*/
|
|
98
131
|
const GetFastRender = GetScreenshot;
|
|
99
132
|
|
|
100
133
|
/**
|
|
@@ -157,23 +190,22 @@ class ApplyZoom extends CommandBase {
|
|
|
157
190
|
* Represents a command to Init Showcase for a product a scene and start a sequence for the product.
|
|
158
191
|
* @remarks
|
|
159
192
|
* This class sends a command to the Metabox API to init showcase if the product has a sequence.
|
|
160
|
-
* For check this needs to find a showcase property in current product
|
|
161
|
-
* If this property
|
|
162
|
-
* @internal Use {@link ModularConfiguratorComponent.product.showcase}
|
|
193
|
+
* For check this needs to find a showcase property in the current product.
|
|
194
|
+
* If this property exists, you can send init showcase command.
|
|
163
195
|
*
|
|
164
196
|
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
165
197
|
*
|
|
166
198
|
* @example
|
|
199
|
+
* ```typescript
|
|
167
200
|
* import { InitShowcase, Communicator } from '@3dsource/metabox-front-api';
|
|
168
201
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
169
|
-
* api.sendCommandToMetaBox(new InitShowcase('ffea6b5c-3a8a-4f56-9417-e605acb5cca3');
|
|
202
|
+
* api.sendCommandToMetaBox(new InitShowcase('ffea6b5c-3a8a-4f56-9417-e605acb5cca3'));
|
|
170
203
|
* };
|
|
171
204
|
*/
|
|
172
205
|
class InitShowcase extends CommandBase {
|
|
173
206
|
/**
|
|
174
207
|
* Creates an instance of InitShowcase.
|
|
175
|
-
*
|
|
176
|
-
* @param {string} productId
|
|
208
|
+
* @param {string} productId - The unique identifier for the product
|
|
177
209
|
*/
|
|
178
210
|
constructor(productId) {
|
|
179
211
|
super();
|
|
@@ -740,5 +772,5 @@ function getUrlParams() {
|
|
|
740
772
|
* Generated bundle index. Do not edit.
|
|
741
773
|
*/
|
|
742
774
|
|
|
743
|
-
export { ApplyZoom, CommandBase, Communicator, EventDispatcher, GetFastRender, GetPdf, GetScreenshot, InitShowcase, MetaboxBasicConfiguratorActions, PauseShowcase, PlayShowcase, ResetCamera, SetEnvironment, SetEnvironmentMaterial, SetMaterial, SetProduct, ShowEmbeddedMenu, ShowOverlayInterface, StopShowcase, UnrealCommand, WatchCallbacks, fromCommunicatorEvent, getUrlParams, integrateMetaBox, saveImage, setUrlParams };
|
|
775
|
+
export { ApplyZoom, CommandBase, Communicator, EventDispatcher, GetCallToActionInformation, GetFastRender, GetPdf, GetScreenshot, InitShowcase, MetaboxBasicConfiguratorActions, PauseShowcase, PlayShowcase, ResetCamera, SetEnvironment, SetEnvironmentMaterial, SetMaterial, SetProduct, ShowEmbeddedMenu, ShowOverlayInterface, StopShowcase, UnrealCommand, WatchCallbacks, fromCommunicatorEvent, getUrlParams, integrateMetaBox, saveImage, setUrlParams };
|
|
744
776
|
//# sourceMappingURL=3dsource-metabox-front-api.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"3dsource-metabox-front-api.mjs","sources":["../../../../projects/3dsource/metabox-front-api/src/lib/actions/CommandBase.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/fromCommunicatorEvent.ts","../../../../projects/3dsource/metabox-front-api/src/lib/interfaces/ToMetaboxMessagePayloads.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/GetPdf.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/GetScreenshot.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/GetFastRender.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/ResetCamera.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/ApplyZoom.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/InitShowcase.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/PlayShowcase.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/UnrealCommand.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/PauseShowcase.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/StopShowcase.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/SetProduct.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/SetMaterial.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/SetEnvironment.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/SetEnvironmentMaterial.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/ShowEmbeddedMenu.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/ShowOverlayInterface.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/WatchCallbacks.ts","../../../../projects/3dsource/metabox-front-api/src/lib/helpers/EventDispatcher.ts","../../../../projects/3dsource/metabox-front-api/src/lib/helpers/Communicator.ts","../../../../projects/3dsource/metabox-front-api/src/lib/helpers/integrate-metabox.ts","../../../../projects/3dsource/metabox-front-api/src/lib/helpers/saveImage.ts","../../../../projects/3dsource/metabox-front-api/src/lib/helpers/url-utils.ts","../../../../projects/3dsource/metabox-front-api/src/3dsource-metabox-front-api.ts"],"sourcesContent":["import type { ToMetaBoxMessageEnvelope } from '../interfaces';\n\n/**\n * Base class for commands sent to the Metabox API.\n */\nexport class CommandBase {\n data!: ToMetaBoxMessageEnvelope;\n}\n","import type { Communicator } from '../helpers';\nimport type {\n FromMetaBoxApiEvents,\n FromMetaboxMessagePayloads,\n} from '../interfaces';\nimport type { Observable } from 'rxjs';\nimport { fromEvent } from 'rxjs';\n\n/**\n * Wrapper helper function to use it with rxJs the same as `fromEvent` to listen to events from the Communicator.\n * @param {Communicator} target\n * @param eventName\n */\nexport function fromCommunicatorEvent<T extends FromMetaBoxApiEvents>(\n target: Communicator,\n eventName: T,\n) {\n return fromEvent(target, eventName) as Observable<\n FromMetaboxMessagePayloads[T]\n >;\n}\n","import type { MimeType } from '../actions';\nimport type { ApplicationDeviceTypes } from './application-device-types';\n\nexport const MetaboxBasicConfiguratorActions = {\n loadLevel: 'loadLevel',\n setEnvironmentMaterialById: 'setEnvironmentMaterialById',\n setProduct: 'setProduct',\n setMaterialById: 'setMaterialById',\n getPdf: 'getPdf',\n getScreenshot: 'getScreenshot',\n getFastRender: 'getFastRender', // @deprecated, use 'getScreenshot'\n showEmbeddedMenu: 'showEmbeddedMenu',\n forceSetDeviceType: 'forceSetDeviceType',\n showOverlayInterface: 'showOverlayInterface',\n resetCamera: 'resetCamera',\n applyZoom: 'applyZoom',\n initShowcase: 'initShowcase',\n playShowcase: 'playShowcase',\n pauseShowcase: 'pauseShowcase',\n stopShowcase: 'stopShowcase',\n sendCommandToUnreal: 'sendCommandToUnreal',\n addResponse: 'addResponse', // @deprecated, use 'watchCallbacks' ;\n watchCallbacks: 'watchCallbacks',\n} as const;\n\nexport type ToMetaBoxActions =\n (typeof MetaboxBasicConfiguratorActions)[keyof typeof MetaboxBasicConfiguratorActions];\n\n/**\n * @internal\n * @hidden\n */\nexport type ToMetaboxMessagePayload =\n ToMetaboxMessagePayloads[keyof ToMetaboxMessagePayloads];\n\n/**\n * Interface for messages sent from the application to the Basic Metabox API.\n */\nexport interface ToMetaboxMessagePayloads {\n [MetaboxBasicConfiguratorActions.getPdf]: void;\n [MetaboxBasicConfiguratorActions.loadLevel]: { id: string };\n [MetaboxBasicConfiguratorActions.setProduct]: { productId: string };\n /**\n * @deprecated\n * @hidden use\n * {@link MetaboxBasicConfiguratorActions.watchCallbacks}\n */\n [MetaboxBasicConfiguratorActions.addResponse]: void;\n [MetaboxBasicConfiguratorActions.watchCallbacks]: void;\n [MetaboxBasicConfiguratorActions.getFastRender]: {\n format: MimeType;\n size?: { x: number; y: number };\n };\n [MetaboxBasicConfiguratorActions.getScreenshot]: {\n format: MimeType;\n size?: { x: number; y: number };\n };\n [MetaboxBasicConfiguratorActions.setMaterialById]: {\n slotId: string;\n materialId: string;\n };\n [MetaboxBasicConfiguratorActions.setEnvironmentMaterialById]: {\n slotId: string;\n materialId: string;\n };\n [MetaboxBasicConfiguratorActions.showEmbeddedMenu]: { visible: boolean };\n [MetaboxBasicConfiguratorActions.showOverlayInterface]: { visible: boolean };\n [MetaboxBasicConfiguratorActions.forceSetDeviceType]: {\n deviceType: ApplicationDeviceTypes;\n };\n [MetaboxBasicConfiguratorActions.resetCamera]: void;\n [MetaboxBasicConfiguratorActions.applyZoom]: { zoom: number };\n [MetaboxBasicConfiguratorActions.initShowcase]: { productId: string };\n [MetaboxBasicConfiguratorActions.playShowcase]: void;\n [MetaboxBasicConfiguratorActions.pauseShowcase]: void;\n [MetaboxBasicConfiguratorActions.stopShowcase]: void;\n [MetaboxBasicConfiguratorActions.sendCommandToUnreal]: object;\n}\n\nexport interface ToMetaBoxMessageEnvelope {\n action: ToMetaBoxActions;\n payload?: ToMetaboxMessagePayload | never;\n}\n\nexport interface ToMetaBoxMessage {\n host: 'metaBoxHost';\n payload: ToMetaBoxMessageEnvelope;\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to get a PDF from Metabox.\n * @remarks\n * This class sends a message to the Metabox API to generate a PDF based on the current configuration.\n * This action does not require any parameters.\n *\n * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.\n *\n * @example\n * import { GetPdf, Communicator } from '@3dsource/metabox-front-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetaBox(new GetPdf());\n * };\n */\n\nexport class GetPdf extends CommandBase {\n /**\n * Creates an instance of GetPdf.\n *\n * @remarks\n * This constructor does not require any parameters.\n */\n constructor() {\n super();\n this.data = { action: MetaboxBasicConfiguratorActions.getPdf };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Image format.\n * @remarks\n * This type represents the allowed image formats.\n */\nexport type MimeType = 'image/png' | 'image/jpeg' | 'image/webp';\n\n/**\n * Represents a command to get a screenshot.\n *\n * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.\n *\n * @example\n * import { GetScreenshot, Communicator, saveImage } from '@3dsource/metabox-front-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * // Listen for events from to the Metabox API\n * api.addEventListener('screenshot', (data) => {\n * // Process the get screenshot response\n * saveImage(data, 'Render.png');\n * });\n * api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));\n * };\n */\nexport class GetScreenshot extends CommandBase {\n /**\n * Constructs an instance of GetScreenshot.\n * @param {MimeType} mimeType - The output format.\n * @param {{ x: number; y: number }} [size] - Optional size in pixels.\n */\n constructor(mimeType: MimeType, size?: { x: number; y: number }) {\n super();\n this.data = {\n payload: { format: mimeType, size },\n action: MetaboxBasicConfiguratorActions.getScreenshot,\n };\n }\n}\n","import { GetScreenshot } from './GetScreenshot';\n\nexport const GetFastRender = GetScreenshot;\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to send to unreal and reset camera to initial.\n * @remarks\n * This class sends a message to the Metabox API to reset the camera on a scene.\n * This action does not require any parameters.\n *\n * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.\n *\n * @example\n * import { ResetCamera, Communicator } from '@3dsource/metabox-front-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetaBox(new ResetCamera());\n * };\n */\n\nexport class ResetCamera extends CommandBase {\n /**\n * Creates an instance of ResetCamera.\n *\n * @remarks\n * This constructor does not require any parameters.\n */\n constructor() {\n super();\n this.data = { action: MetaboxBasicConfiguratorActions.resetCamera };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to ApplyZoom and change zoom camera on a scene.\n * @remarks\n * This class sends a command to the Metabox API to change zoom on a scene.\n *\n * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.\n *\n * @example\n * import { ApplyZoom, Communicator } from '@3dsource/metabox-front-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetaBox(new ApplyZoom(10));\n * api.sendCommandToMetaBox(new ApplyZoom(-10));\n * };\n */\n\nexport class ApplyZoom extends CommandBase {\n /**\n * Creates an instance of ApplyZoom.\n *\n * @param {...number} zoom\n */\n constructor(zoom: number) {\n super();\n this.data = {\n action: MetaboxBasicConfiguratorActions.applyZoom,\n payload: { zoom },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to Init Showcase for a product a scene and start a sequence for the product.\n * @remarks\n * This class sends a command to the Metabox API to init showcase if the product has a sequence.\n * For check this needs to find a showcase property in current product\n * If this property exist you can send init showcase command\n * @internal Use {@link ModularConfiguratorComponent.product.showcase}\n *\n * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.\n *\n * @example\n * import { InitShowcase, Communicator } from '@3dsource/metabox-front-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetaBox(new InitShowcase('ffea6b5c-3a8a-4f56-9417-e605acb5cca3');\n * };\n */\n\nexport class InitShowcase extends CommandBase {\n /**\n * Creates an instance of InitShowcase.\n *\n * @param {string} productId\n */\n constructor(productId: string) {\n super();\n this.data = {\n action: MetaboxBasicConfiguratorActions.initShowcase,\n payload: { productId },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to Play Showcase for a product when it already init, and you call pause, for example, before it.\n * @remarks\n * This class sends a command to the Metabox API to play showcase for a product if it is already initialized and pause.\n *\n * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.\n *\n * @example\n * import { PlayShowcase, Communicator } from '@3dsource/metabox-front-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetaBox(new PlayShowcase());\n * };\n */\n\nexport class PlayShowcase extends CommandBase {\n /**\n * Creates an instance of PlayShowcase.\n *\n * @remarks\n * This constructor does not require any parameters.\n */\n constructor() {\n super();\n this.data = { action: MetaboxBasicConfiguratorActions.playShowcase };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * @internal\n * @hidden\n * Represents a command to send Unreal command.\n */\nexport class UnrealCommand extends CommandBase {\n constructor(payload: object) {\n super();\n this.data = {\n payload,\n action: MetaboxBasicConfiguratorActions.sendCommandToUnreal,\n };\n }\n}\n\n/**\n * @deprecated, use {@link UnrealCommand}\n * */\nexport const SendCommandToUnreal = UnrealCommand;\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to Pause Showcase for a product when it already init and play, and you call pause.\n * @remarks\n * This class sends a command to the Metabox API to pause showcase for a product if it is already initialized and play.\n *\n * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.\n *\n * @example\n * import { PauseShowcase, Communicator } from '@3dsource/metabox-front-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetaBox(new PauseShowcase());\n * };\n */\n\nexport class PauseShowcase extends CommandBase {\n /**\n * Creates an instance of PauseShowcase.\n *\n * @remarks\n * This constructor does not require any parameters.\n */\n constructor() {\n super();\n this.data = { action: MetaboxBasicConfiguratorActions.pauseShowcase };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to Stop Showcase for a product when it already init, and you want to destroy it.\n * @remarks\n * This class sends a command to the Metabox API to Stop showcase for a product if it is already initialized.\n *\n * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.\n *\n * @example\n * import { StopShowcase, Communicator } from '@3dsource/metabox-front-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetaBox(new StopShowcase());\n * };\n */\n\nexport class StopShowcase extends CommandBase {\n /**\n * Creates an instance of StopShowcase.\n *\n * @remarks\n * This constructor does not require any parameters.\n */\n constructor() {\n super();\n this.data = { action: MetaboxBasicConfiguratorActions.stopShowcase };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to set a product by its ID.\n *\n * @remarks\n * This action sends a message to the Metabox API to set a product using the provided product ID.\n *\n * @example\n * import { SetProduct, Communicator } from '@3dsource/metabox-front-api';\n *\n * //...Assume that the integration is already implemented\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.setCommandToMetaBox(new SetProduct(\n * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3'\n * ));\n * };\n */\nexport class SetProduct extends CommandBase {\n /**\n * Creates an instance of SetProduct.\n *\n * @param {string} productId - The product ID.\n */\n constructor(productId: string) {\n super();\n this.data = {\n payload: { productId },\n action: MetaboxBasicConfiguratorActions.setProduct,\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to set a material by its slot ID and Material ID.\n *\n * @example\n * import { SetMaterial, Communicator } from '@3dsource/metabox-front-api';\n *\n * //...Assume that the integration is already implemented\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetaBox(new SetMaterial(\n * 'carpaint',\n * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',\n * ));\n * };\n */\nexport class SetMaterial extends CommandBase {\n /**\n * Creates an instance of SetMaterial.\n *\n * @param {string} slotId - The slot ID.\n * @param {string} materialId - The material ID.\n */\n constructor(slotId: string, materialId: string) {\n super();\n this.data = {\n payload: { slotId, materialId },\n action: MetaboxBasicConfiguratorActions.setMaterialById,\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to set the environment by its ID.\n *\n * @example\n * import { SetEnvironment, Communicator } from '@3dsource/metabox-front-api';\n *\n * //...Assume that the integration is already implemented\n * window.env3DSource.apiReady = (api: Communicator) => {\n * // Change the environment to '55555555-1234-1234-1234-01234567890'\n * api.sendCommandToMetaBox(new SetEnvironment('55555555-1234-1234-1234-01234567890'));\n * };\n */\nexport class SetEnvironment extends CommandBase {\n /**\n * Creates an instance of SetEnvironment.\n *\n * @param {string} environmentId - The environment ID.\n */\n constructor(environmentId: string) {\n super();\n this.data = {\n payload: { id: environmentId },\n action: MetaboxBasicConfiguratorActions.loadLevel,\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to set an environment material by its slot ID and Material ID.\n *\n * @example\n * import { SetEnvironmentMaterial, Communicator } from '@3dsource/metabox-front-api';\n *\n * //...Assume that the integration is already implemented\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetaBox(new SetEnvironmentMaterial(\n * 'carpaint',\n * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',\n * ));\n * };\n */\nexport class SetEnvironmentMaterial extends CommandBase {\n /**\n * Creates an instance of SetEnvironmentMaterial.\n *\n * @param {string} slotId - The slot ID.\n * @param {string} materialId - The material ID.\n */\n constructor(slotId: string, materialId: string) {\n super();\n this.data = {\n payload: { slotId, materialId },\n action: MetaboxBasicConfiguratorActions.setEnvironmentMaterialById,\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to toggle the Embedded to the Metabox Menu.\n *\n * @example\n * import { ShowEmbeddedMenu, Communicator } from '@3dsource/metabox-front-api';\n *\n * //...Assume that the integration is already implemented\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.setCommandToMetaBox(new ShowEmbeddedMenu(true));\n * };\n */\nexport class ShowEmbeddedMenu extends CommandBase {\n /**\n * Creates an instance of ShowEmbeddedMenu.\n *\n * @param {boolean} visible - A flag indicating whether the embedded menu should be visible.\n */\n constructor(visible: boolean) {\n super();\n this.data = {\n action: MetaboxBasicConfiguratorActions.showEmbeddedMenu,\n payload: { visible },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to toggle the Unreal Overlay Interface Menu.\n *\n * @remarks\n * This action sends a message to the Metabox API to toggle the visibility of the Unreal overlay UI.\n *\n * @example\n * import { ShowOverlayInterface, Communicator } from '@3dsource/metabox-front-api';\n *\n * //...Assume that the integration is already implemented\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.setCommandToMetaBox(new ShowOverlayInterface(true));\n * };\n */\nexport class ShowOverlayInterface extends CommandBase {\n /**\n * Creates an instance of ShowOverlayInterface.\n *\n * @param {boolean} visible - A flag indicating whether the Unreal overlay UI should be visible.\n */\n constructor(visible: boolean) {\n super();\n this.data = {\n action: MetaboxBasicConfiguratorActions.showOverlayInterface,\n payload: { visible },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * @experimental\n * @internal\n * @hidden\n * @remarks\n * Represents a command to watch Unreal callbacks from Unreal engine.\n * Can be useful for custom solutions.\n */\nexport class WatchCallbacks extends CommandBase {\n /**\n * Creates an instance of WatchCallbacks.\n *\n * @remarks\n * This constructor does not require any parameters.\n */\n constructor() {\n super();\n this.data = { action: MetaboxBasicConfiguratorActions.watchCallbacks };\n }\n}\n\n/**\n * @deprecated, use {@link WatchCallbacks}\n * */\nexport const AddResponse = WatchCallbacks;\n","/**\n * Represents a callback listener for specific message types.\n * Used internally by EventDispatcher to store event listeners.\n *\n * @public\n */\nexport interface Listener {\n /** The message type this listener is registered for */\n messageType: string;\n /** The callback function to execute when a message of the specified type is received */\n callback: (data: unknown) => void;\n}\n\n/**\n * EventDispatcher is a class that manages event listeners and dispatches events to them.\n */\nexport class EventDispatcher {\n /**\n * Storage for callback listeners by message type.\n */\n listeners: Listener[] = [];\n\n destroy() {\n this.listeners = [];\n }\n\n /**\n * Adds an event listener for receiving specific types of messages.\n *\n * @param messageType - The message type to listen for.\n * @param callback - The callback function to execute when a message is received.\n */\n addEventListener(\n messageType: string,\n callback: (data: unknown) => void,\n ): this {\n this.listeners.push({ messageType, callback });\n return this;\n }\n\n /**\n * Dispatches an event to all listeners of a specific message type.\n *\n * @param messageType - The message type.\n * @param data - The data associated with the event.\n */\n dispatchEvent(messageType: string, data: unknown): this {\n this.listeners\n .filter((listener) => listener.messageType === messageType)\n .forEach((listener) => listener.callback(data));\n return this;\n }\n\n /**\n * Removes an event listener for a specific type of message.\n *\n * @param messageType - The message type.\n * @param callback - The callback function to remove.\n */\n removeEventListener(\n messageType: string,\n callback: (data: unknown) => void,\n ): this {\n this.listeners = this.listeners.filter(\n (listener) =>\n !(\n listener.messageType === messageType && listener.callback === callback\n ),\n );\n return this;\n }\n}\n","import { EventDispatcher } from './EventDispatcher';\nimport type { CommandBase } from '../actions';\nimport type {\n FromMetaBoxApiEvents,\n FromMetaBoxMessage,\n FromMetaboxMessagePayloads,\n} from '../interfaces';\n\n/**\n * Handles messaging between the host page and embedded Metabox content.\n * @internal Use {@link Communicator.createInstance} or the {@link integrateMetaBox} helper to instantiate.\n */\nexport class Communicator extends EventDispatcher {\n /**\n * Singleton reference to the current communicator instance.\n */\n public static instance: Communicator | null = null;\n /**\n * Bound handler for incoming postMessage events.\n */\n private binder = this.handleMessageReceived.bind(this, 'metaboxData');\n\n /**\n * Constructs a Communicator, replacing any existing instance, and begins listening for messages.\n * @internal\n */\n constructor() {\n super();\n Communicator.instance?.destroy();\n Communicator.instance = this;\n window.addEventListener('message', this.binder);\n }\n\n /**\n * Listens for Metabox to signal readiness, then initializes communicator.\n * @param apiReadyCallback - Called with the new Communicator once to the Metabox is loaded.\n */\n static createInstance(apiReadyCallback: (api: Communicator) => void): void {\n const startHandler = (event: MessageEvent): void => {\n const message = event.data as FromMetaBoxMessage;\n if (message?.payload?.action === 'appLoaded') {\n apiReadyCallback(new Communicator());\n window.removeEventListener('message', startHandler);\n }\n };\n\n window.addEventListener('message', startHandler);\n }\n\n /**\n * Cleans up resources and stops listening for messages.\n */\n public override destroy(): void {\n super.destroy();\n window.removeEventListener('message', this.binder);\n }\n\n /**\n * Posts a command to the Metabox iframe.\n * @param command - An action command containing data to send.\n */\n public sendCommandToMetaBox<T extends CommandBase>(command: T): void {\n const { data } = command;\n const iframe = document.getElementById(\n 'embeddedContent',\n ) as HTMLIFrameElement;\n\n if (!iframe?.contentWindow) {\n console.warn('to the Metabox IFrame not found or not ready.');\n return;\n }\n\n const message = {\n host: 'metaBoxHost',\n payload: { ...data },\n };\n\n // Replace '*' with a specific origin in production for better security.\n iframe.contentWindow.postMessage(message, '*');\n }\n\n /**\n * Registers an event listener for messages dispatched by to the Metabox.\n * @override\n */\n override addEventListener<T extends FromMetaBoxApiEvents>(\n messageType: T,\n callback: (data: FromMetaboxMessagePayloads[T]) => void,\n ) {\n return super.addEventListener(\n messageType,\n callback as (data: unknown) => void,\n );\n }\n\n /**\n * Dispatches a typed event to all registered listeners.\n * @override\n */\n override dispatchEvent<T extends FromMetaBoxApiEvents>(\n messageType: T,\n data: FromMetaboxMessagePayloads[T],\n ) {\n return super.dispatchEvent(messageType, data);\n }\n\n /**\n * Removes a previously registered event listener.\n * @override\n */\n override removeEventListener<T extends FromMetaBoxApiEvents>(\n messageType: T,\n callback: (data: FromMetaboxMessagePayloads[T]) => void,\n ) {\n return super.removeEventListener(\n messageType,\n callback as (data: unknown) => void,\n );\n }\n\n /**\n * Filters and dispatches incoming messages from to the Metabox.\n * @param {FromMetaBoxApiEvents | 'metaboxData' } messageType - Expected message type for filtering ('metaboxData').\n * @param {MessageEvent} event - The postMessage event received on a window.\n */\n private handleMessageReceived<T extends FromMetaBoxApiEvents>(\n messageType: T | 'metaboxData',\n event: MessageEvent,\n ): void {\n // Optionally validate event.origin for security.\n if (messageType !== 'metaboxData' || event.data?.host !== 'metabox') {\n return;\n }\n\n const { eventType, payload } = event.data.payload;\n this.dispatchEvent(eventType as T, payload);\n }\n}\n","import { Communicator } from './Communicator';\n\n/**\n * Integrates Metabox Basic Configurator into the provided layout.\n *\n * @remarks\n * This function injects an iframe into a specified container element in the DOM and initializes\n * the communicator for interacting with the Metabox embedded content.\n *\n * @param {string} iframeSrc - The source URL of the Metabox iframe.\n * Additional url parameters:\n * ```javascript\n * sidebar=false - disables the internal Metabox menu\n * introImage=https://example.com/image.png - sets the intro image\n * ```\n * i.e., a final link will look like https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id?sidebar=false&introImage=https://example.com/image.png\n *\n * @param {string} containerId - The ID of the layout element. Defaults to 'embed3DSource'.\n * @param apiReadyCallback\n * @throws Error if the container element with the specified ID is not found.\n *\n * @example\n * import {\n * integrateMetaBox,\n * } from '@3dsource/metabox-front-api';\n *\n * integrateMetaBox(\n * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',\n * 'embed3DSource'\n * );\n */\nexport function integrateMetaBox(\n iframeSrc: string,\n containerId = 'embed3DSource',\n apiReadyCallback: (api: Communicator) => void,\n): void {\n const container = document.getElementById(containerId);\n if (!container) {\n throw new Error(`Container element with id ${containerId} not found`);\n }\n\n const existingIframe = document.getElementById('embeddedContent');\n if (existingIframe) {\n existingIframe.remove();\n }\n\n Communicator.createInstance(apiReadyCallback);\n\n const style = document.createElement('style');\n style.innerHTML = `\n #${containerId} {\n width: 100%;\n height: 100%;\n overflow: hidden;\n position: relative;\n }\n `;\n document.head.appendChild(style);\n\n const iframe = document.createElement('iframe');\n iframe.setAttribute('referrerPolicy', 'no-referrer-when-downgrade');\n iframe.setAttribute('id', 'embeddedContent');\n iframe.style.border = '0';\n iframe.style.width = '100%';\n iframe.style.height = '100%';\n iframe.style.overflow = 'hidden';\n iframe.src = iframeSrc;\n container.appendChild(iframe);\n}\n","/**\n * Saves an image by triggering a download.\n *\n * @remarks\n * This function creates an anchor element, sets its `href` attribute to the provided image URL,\n * and triggers a click event to initiate a download with the specified filename.\n *\n * @param {string} imageUrl - The URL of the image to save.\n * @param {string} filename - The name of the file to save.\n */\nexport function saveImage(imageUrl: string, filename: string): void {\n const a = document.createElement('a');\n a.href = imageUrl;\n a.download = filename;\n document.body.appendChild(a);\n a.click();\n document.body.removeChild(a);\n}\n","/**\n * Sets the URL parameters based on the provided state.\n *\n * @remarks\n * This function updates the current URL by replacing its search parameters with the key-value pairs from the provided state object.\n *\n * @param {Record<string, string>} state - An object containing key-value pairs to set as URL parameters.\n */\nexport function setUrlParams(state: Record<string, string>): void {\n const url = new URL(window.location.href);\n url.search = '';\n Object.entries(state).forEach(([key, value]) => {\n url.searchParams.set(key, value);\n });\n history.replaceState(null, '', url.toString());\n}\n\n/**\n * Retrieves the URL parameters as an object.\n *\n * @remarks\n * This function parses the current URL's search parameters and returns them as a key-value object.\n *\n * @returns An object containing the URL parameters.\n */\nexport function getUrlParams(): Record<string, string> {\n const urlParams = new URLSearchParams(window.location.search);\n const selections: Record<string, string> = {};\n urlParams.forEach((value, key) => {\n selections[key] = value;\n });\n return selections;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAEA;;AAEG;M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AA;IAC1B,MAAM,SAAS,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC7D,MAAM,UAAU,GAA2B,EAAE;IAC7C,SAAS,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,KAAI;AAC/B,QAAA,UAAU,CAAC,GAAG,CAAC,GAAG,KAAK;AACzB,KAAC,CAAC;AACF,IAAA,OAAO,UAAU;AACnB;;AChCA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"3dsource-metabox-front-api.mjs","sources":["../../../../projects/3dsource/metabox-front-api/src/lib/actions/CommandBase.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/fromCommunicatorEvent.ts","../../../../projects/3dsource/metabox-front-api/src/lib/interfaces/ToMetaboxMessagePayloads.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/GetPdf.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/GetCallToActionInformation.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/GetScreenshot.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/GetFastRender.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/ResetCamera.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/ApplyZoom.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/InitShowcase.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/PlayShowcase.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/UnrealCommand.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/PauseShowcase.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/StopShowcase.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/SetProduct.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/SetMaterial.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/SetEnvironment.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/SetEnvironmentMaterial.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/ShowEmbeddedMenu.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/ShowOverlayInterface.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/WatchCallbacks.ts","../../../../projects/3dsource/metabox-front-api/src/lib/helpers/EventDispatcher.ts","../../../../projects/3dsource/metabox-front-api/src/lib/helpers/Communicator.ts","../../../../projects/3dsource/metabox-front-api/src/lib/helpers/integrate-metabox.ts","../../../../projects/3dsource/metabox-front-api/src/lib/helpers/saveImage.ts","../../../../projects/3dsource/metabox-front-api/src/lib/helpers/url-utils.ts","../../../../projects/3dsource/metabox-front-api/src/3dsource-metabox-front-api.ts"],"sourcesContent":["import type { ToMetaBoxMessageEnvelope } from '../interfaces';\n\n/**\n * Base class for commands sent to the Metabox API.\n */\nexport class CommandBase {\n data!: ToMetaBoxMessageEnvelope;\n}\n","import type { Communicator } from '../helpers';\nimport type {\n FromMetaBoxApiEvents,\n FromMetaboxMessagePayloads,\n} from '../interfaces';\nimport type { Observable } from 'rxjs';\nimport { fromEvent } from 'rxjs';\n\n/**\n * Wrapper helper function to use it with rxJs the same as `fromEvent` to listen to events from the Communicator.\n * @param {Communicator} target\n * @param eventName\n */\nexport function fromCommunicatorEvent<T extends FromMetaBoxApiEvents>(\n target: Communicator,\n eventName: T,\n) {\n return fromEvent(target, eventName) as Observable<\n FromMetaboxMessagePayloads[T]\n >;\n}\n","import type { MimeType } from '../actions';\nimport type { ApplicationDeviceTypes } from './application-device-types';\n\nexport const MetaboxBasicConfiguratorActions = {\n loadLevel: 'loadLevel',\n setEnvironmentMaterialById: 'setEnvironmentMaterialById',\n setProduct: 'setProduct',\n setMaterialById: 'setMaterialById',\n getPdf: 'getPdf',\n getCallToActionInformation: 'getCallToActionInformation',\n getScreenshot: 'getScreenshot',\n getFastRender: 'getFastRender', // @deprecated, use 'getScreenshot'\n showEmbeddedMenu: 'showEmbeddedMenu',\n forceSetDeviceType: 'forceSetDeviceType',\n showOverlayInterface: 'showOverlayInterface',\n resetCamera: 'resetCamera',\n applyZoom: 'applyZoom',\n initShowcase: 'initShowcase',\n playShowcase: 'playShowcase',\n pauseShowcase: 'pauseShowcase',\n stopShowcase: 'stopShowcase',\n sendCommandToUnreal: 'sendCommandToUnreal',\n addResponse: 'addResponse', // @deprecated, use 'watchCallbacks' ;\n watchCallbacks: 'watchCallbacks',\n} as const;\n\nexport type ToMetaBoxActions =\n (typeof MetaboxBasicConfiguratorActions)[keyof typeof MetaboxBasicConfiguratorActions];\n\n/**\n * @internal\n * @hidden\n */\nexport type ToMetaboxMessagePayload =\n ToMetaboxMessagePayloads[keyof ToMetaboxMessagePayloads];\n\n/**\n * Interface for messages sent from the application to the Basic Metabox API.\n */\nexport interface ToMetaboxMessagePayloads {\n [MetaboxBasicConfiguratorActions.getPdf]: void;\n [MetaboxBasicConfiguratorActions.getCallToActionInformation]: void;\n [MetaboxBasicConfiguratorActions.loadLevel]: { id: string };\n [MetaboxBasicConfiguratorActions.setProduct]: { productId: string };\n /**\n * @deprecated\n * @hidden use\n * {@link MetaboxBasicConfiguratorActions.watchCallbacks}\n */\n [MetaboxBasicConfiguratorActions.addResponse]: void;\n [MetaboxBasicConfiguratorActions.watchCallbacks]: void;\n [MetaboxBasicConfiguratorActions.getFastRender]: {\n format: MimeType;\n size?: { x: number; y: number };\n };\n [MetaboxBasicConfiguratorActions.getScreenshot]: {\n format: MimeType;\n size?: { x: number; y: number };\n };\n [MetaboxBasicConfiguratorActions.setMaterialById]: {\n slotId: string;\n materialId: string;\n };\n [MetaboxBasicConfiguratorActions.setEnvironmentMaterialById]: {\n slotId: string;\n materialId: string;\n };\n [MetaboxBasicConfiguratorActions.showEmbeddedMenu]: { visible: boolean };\n [MetaboxBasicConfiguratorActions.showOverlayInterface]: { visible: boolean };\n [MetaboxBasicConfiguratorActions.forceSetDeviceType]: {\n deviceType: ApplicationDeviceTypes;\n };\n [MetaboxBasicConfiguratorActions.resetCamera]: void;\n [MetaboxBasicConfiguratorActions.applyZoom]: { zoom: number };\n [MetaboxBasicConfiguratorActions.initShowcase]: { productId: string };\n [MetaboxBasicConfiguratorActions.playShowcase]: void;\n [MetaboxBasicConfiguratorActions.pauseShowcase]: void;\n [MetaboxBasicConfiguratorActions.stopShowcase]: void;\n [MetaboxBasicConfiguratorActions.sendCommandToUnreal]: object;\n}\n\nexport interface ToMetaBoxMessageEnvelope {\n action: ToMetaBoxActions;\n payload?: ToMetaboxMessagePayload | never;\n}\n\nexport interface ToMetaBoxMessage {\n host: 'metaBoxHost';\n payload: ToMetaBoxMessageEnvelope;\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to get a PDF from Metabox Basic Configurator.\n * @remarks\n * This class sends a message to the Metabox API to generate a PDF based on the current configuration.\n * This action does not require any parameters.\n *\n * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.\n *\n * @example\n * import { GetPdf, Communicator } from '@3dsource/metabox-front-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetaBox(new GetPdf());\n * };\n */\n\nexport class GetPdf extends CommandBase {\n /**\n * Creates an instance of GetPdf.\n *\n * @remarks\n * This constructor does not require any parameters.\n */\n constructor() {\n super();\n this.data = { action: MetaboxBasicConfiguratorActions.getPdf };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to get a Call To Action Information from Metabox Basic Configurator.\n * @remarks\n * This class sends a message to the Metabox API to generate Call To Action information based on the current configuration and sends it to the endpoint url from the cta information.\n * This action does not require any parameters.\n *\n * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.\n *\n * @example\n * import { GetCallToActionInformation, Communicator } from '@3dsource/metabox-front-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetaBox(new GetCallToActionInformation());\n * };\n */\n\nexport class GetCallToActionInformation extends CommandBase {\n /**\n * Creates an instance of GetCallToActionInformation.\n *\n * @remarks\n * This constructor does not require any parameters.\n */\n constructor() {\n super();\n this.data = {\n action: MetaboxBasicConfiguratorActions.getCallToActionInformation,\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Image format.\n * @remarks\n * This type represents the allowed image formats.\n */\nexport type MimeType = 'image/png' | 'image/jpeg' | 'image/webp';\n\n/**\n * Represents a command to get a screenshot.\n *\n * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.\n *\n * @example\n * import { GetScreenshot, Communicator, saveImage } from '@3dsource/metabox-front-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * // Listen for events from to the Metabox API\n * api.addEventListener('screenshot', (data) => {\n * // Process the get screenshot response\n * saveImage(data, 'Render.png');\n * });\n * api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));\n * };\n */\nexport class GetScreenshot extends CommandBase {\n /**\n * Constructs an instance of GetScreenshot.\n * @param {MimeType} mimeType - The output format.\n * @param {{ x: number; y: number }} [size] - Optional size in pixels.\n */\n constructor(mimeType: MimeType, size?: { x: number; y: number }) {\n super();\n this.data = {\n payload: { format: mimeType, size },\n action: MetaboxBasicConfiguratorActions.getScreenshot,\n };\n }\n}\n","import { GetScreenshot } from './GetScreenshot';\n\n/**\n * @deprecated, use {@link GetScreenshot} instead.\n */\nexport const GetFastRender = GetScreenshot;\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to send to unreal and reset camera to initial.\n * @remarks\n * This class sends a message to the Metabox API to reset the camera on a scene.\n * This action does not require any parameters.\n *\n * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.\n *\n * @example\n * import { ResetCamera, Communicator } from '@3dsource/metabox-front-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetaBox(new ResetCamera());\n * };\n */\n\nexport class ResetCamera extends CommandBase {\n /**\n * Creates an instance of ResetCamera.\n *\n * @remarks\n * This constructor does not require any parameters.\n */\n constructor() {\n super();\n this.data = { action: MetaboxBasicConfiguratorActions.resetCamera };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to ApplyZoom and change zoom camera on a scene.\n * @remarks\n * This class sends a command to the Metabox API to change zoom on a scene.\n *\n * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.\n *\n * @example\n * import { ApplyZoom, Communicator } from '@3dsource/metabox-front-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetaBox(new ApplyZoom(10));\n * api.sendCommandToMetaBox(new ApplyZoom(-10));\n * };\n */\n\nexport class ApplyZoom extends CommandBase {\n /**\n * Creates an instance of ApplyZoom.\n *\n * @param {...number} zoom\n */\n constructor(zoom: number) {\n super();\n this.data = {\n action: MetaboxBasicConfiguratorActions.applyZoom,\n payload: { zoom },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to Init Showcase for a product a scene and start a sequence for the product.\n * @remarks\n * This class sends a command to the Metabox API to init showcase if the product has a sequence.\n * For check this needs to find a showcase property in the current product.\n * If this property exists, you can send init showcase command.\n *\n * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.\n *\n * @example\n * ```typescript\n * import { InitShowcase, Communicator } from '@3dsource/metabox-front-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetaBox(new InitShowcase('ffea6b5c-3a8a-4f56-9417-e605acb5cca3'));\n * };\n */\nexport class InitShowcase extends CommandBase {\n /**\n * Creates an instance of InitShowcase.\n * @param {string} productId - The unique identifier for the product\n */\n constructor(productId: string) {\n super();\n this.data = {\n action: MetaboxBasicConfiguratorActions.initShowcase,\n payload: { productId },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to Play Showcase for a product when it already init, and you call pause, for example, before it.\n * @remarks\n * This class sends a command to the Metabox API to play showcase for a product if it is already initialized and pause.\n *\n * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.\n *\n * @example\n * import { PlayShowcase, Communicator } from '@3dsource/metabox-front-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetaBox(new PlayShowcase());\n * };\n */\n\nexport class PlayShowcase extends CommandBase {\n /**\n * Creates an instance of PlayShowcase.\n *\n * @remarks\n * This constructor does not require any parameters.\n */\n constructor() {\n super();\n this.data = { action: MetaboxBasicConfiguratorActions.playShowcase };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * @internal\n * @hidden\n * Represents a command to send Unreal command.\n */\nexport class UnrealCommand extends CommandBase {\n constructor(payload: object) {\n super();\n this.data = {\n payload,\n action: MetaboxBasicConfiguratorActions.sendCommandToUnreal,\n };\n }\n}\n\n/**\n * @deprecated, use {@link UnrealCommand}\n * */\nexport const SendCommandToUnreal = UnrealCommand;\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to Pause Showcase for a product when it already init and play, and you call pause.\n * @remarks\n * This class sends a command to the Metabox API to pause showcase for a product if it is already initialized and play.\n *\n * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.\n *\n * @example\n * import { PauseShowcase, Communicator } from '@3dsource/metabox-front-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetaBox(new PauseShowcase());\n * };\n */\n\nexport class PauseShowcase extends CommandBase {\n /**\n * Creates an instance of PauseShowcase.\n *\n * @remarks\n * This constructor does not require any parameters.\n */\n constructor() {\n super();\n this.data = { action: MetaboxBasicConfiguratorActions.pauseShowcase };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to Stop Showcase for a product when it already init, and you want to destroy it.\n * @remarks\n * This class sends a command to the Metabox API to Stop showcase for a product if it is already initialized.\n *\n * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.\n *\n * @example\n * import { StopShowcase, Communicator } from '@3dsource/metabox-front-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetaBox(new StopShowcase());\n * };\n */\n\nexport class StopShowcase extends CommandBase {\n /**\n * Creates an instance of StopShowcase.\n *\n * @remarks\n * This constructor does not require any parameters.\n */\n constructor() {\n super();\n this.data = { action: MetaboxBasicConfiguratorActions.stopShowcase };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to set a product by its ID.\n *\n * @remarks\n * This action sends a message to the Metabox API to set a product using the provided product ID.\n *\n * @example\n * import { SetProduct, Communicator } from '@3dsource/metabox-front-api';\n *\n * //...Assume that the integration is already implemented\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.setCommandToMetaBox(new SetProduct(\n * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3'\n * ));\n * };\n */\nexport class SetProduct extends CommandBase {\n /**\n * Creates an instance of SetProduct.\n *\n * @param {string} productId - The product ID.\n */\n constructor(productId: string) {\n super();\n this.data = {\n payload: { productId },\n action: MetaboxBasicConfiguratorActions.setProduct,\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to set a material by its slot ID and Material ID.\n *\n * @example\n * import { SetMaterial, Communicator } from '@3dsource/metabox-front-api';\n *\n * //...Assume that the integration is already implemented\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetaBox(new SetMaterial(\n * 'carpaint',\n * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',\n * ));\n * };\n */\nexport class SetMaterial extends CommandBase {\n /**\n * Creates an instance of SetMaterial.\n *\n * @param {string} slotId - The slot ID.\n * @param {string} materialId - The material ID.\n */\n constructor(slotId: string, materialId: string) {\n super();\n this.data = {\n payload: { slotId, materialId },\n action: MetaboxBasicConfiguratorActions.setMaterialById,\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to set the environment by its ID.\n *\n * @example\n * import { SetEnvironment, Communicator } from '@3dsource/metabox-front-api';\n *\n * //...Assume that the integration is already implemented\n * window.env3DSource.apiReady = (api: Communicator) => {\n * // Change the environment to '55555555-1234-1234-1234-01234567890'\n * api.sendCommandToMetaBox(new SetEnvironment('55555555-1234-1234-1234-01234567890'));\n * };\n */\nexport class SetEnvironment extends CommandBase {\n /**\n * Creates an instance of SetEnvironment.\n *\n * @param {string} environmentId - The environment ID.\n */\n constructor(environmentId: string) {\n super();\n this.data = {\n payload: { id: environmentId },\n action: MetaboxBasicConfiguratorActions.loadLevel,\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to set an environment material by its slot ID and Material ID.\n *\n * @example\n * import { SetEnvironmentMaterial, Communicator } from '@3dsource/metabox-front-api';\n *\n * //...Assume that the integration is already implemented\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetaBox(new SetEnvironmentMaterial(\n * 'carpaint',\n * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',\n * ));\n * };\n */\nexport class SetEnvironmentMaterial extends CommandBase {\n /**\n * Creates an instance of SetEnvironmentMaterial.\n *\n * @param {string} slotId - The slot ID.\n * @param {string} materialId - The material ID.\n */\n constructor(slotId: string, materialId: string) {\n super();\n this.data = {\n payload: { slotId, materialId },\n action: MetaboxBasicConfiguratorActions.setEnvironmentMaterialById,\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to toggle the Embedded to the Metabox Menu.\n *\n * @example\n * import { ShowEmbeddedMenu, Communicator } from '@3dsource/metabox-front-api';\n *\n * //...Assume that the integration is already implemented\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.setCommandToMetaBox(new ShowEmbeddedMenu(true));\n * };\n */\nexport class ShowEmbeddedMenu extends CommandBase {\n /**\n * Creates an instance of ShowEmbeddedMenu.\n *\n * @param {boolean} visible - A flag indicating whether the embedded menu should be visible.\n */\n constructor(visible: boolean) {\n super();\n this.data = {\n action: MetaboxBasicConfiguratorActions.showEmbeddedMenu,\n payload: { visible },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to toggle the Unreal Overlay Interface Menu.\n *\n * @remarks\n * This action sends a message to the Metabox API to toggle the visibility of the Unreal overlay UI.\n *\n * @example\n * import { ShowOverlayInterface, Communicator } from '@3dsource/metabox-front-api';\n *\n * //...Assume that the integration is already implemented\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.setCommandToMetaBox(new ShowOverlayInterface(true));\n * };\n */\nexport class ShowOverlayInterface extends CommandBase {\n /**\n * Creates an instance of ShowOverlayInterface.\n *\n * @param {boolean} visible - A flag indicating whether the Unreal overlay UI should be visible.\n */\n constructor(visible: boolean) {\n super();\n this.data = {\n action: MetaboxBasicConfiguratorActions.showOverlayInterface,\n payload: { visible },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\n\n/**\n * @experimental\n * @internal\n * @hidden\n * @remarks\n * Represents a command to watch Unreal callbacks from Unreal engine.\n * Can be useful for custom solutions.\n */\nexport class WatchCallbacks extends CommandBase {\n /**\n * Creates an instance of WatchCallbacks.\n *\n * @remarks\n * This constructor does not require any parameters.\n */\n constructor() {\n super();\n this.data = { action: MetaboxBasicConfiguratorActions.watchCallbacks };\n }\n}\n\n/**\n * @deprecated, use {@link WatchCallbacks}\n * */\nexport const AddResponse = WatchCallbacks;\n","/**\n * Represents a callback listener for specific message types.\n * Used internally by EventDispatcher to store event listeners.\n *\n * @public\n */\nexport interface Listener {\n /** The message type this listener is registered for */\n messageType: string;\n /** The callback function to execute when a message of the specified type is received */\n callback: (data: unknown) => void;\n}\n\n/**\n * EventDispatcher is a class that manages event listeners and dispatches events to them.\n */\nexport class EventDispatcher {\n /**\n * Storage for callback listeners by message type.\n */\n listeners: Listener[] = [];\n\n destroy() {\n this.listeners = [];\n }\n\n /**\n * Adds an event listener for receiving specific types of messages.\n *\n * @param messageType - The message type to listen for.\n * @param callback - The callback function to execute when a message is received.\n */\n addEventListener(\n messageType: string,\n callback: (data: unknown) => void,\n ): this {\n this.listeners.push({ messageType, callback });\n return this;\n }\n\n /**\n * Dispatches an event to all listeners of a specific message type.\n *\n * @param messageType - The message type.\n * @param data - The data associated with the event.\n */\n dispatchEvent(messageType: string, data: unknown): this {\n this.listeners\n .filter((listener) => listener.messageType === messageType)\n .forEach((listener) => listener.callback(data));\n return this;\n }\n\n /**\n * Removes an event listener for a specific type of message.\n *\n * @param messageType - The message type.\n * @param callback - The callback function to remove.\n */\n removeEventListener(\n messageType: string,\n callback: (data: unknown) => void,\n ): this {\n this.listeners = this.listeners.filter(\n (listener) =>\n !(\n listener.messageType === messageType && listener.callback === callback\n ),\n );\n return this;\n }\n}\n","import { EventDispatcher } from './EventDispatcher';\nimport type { CommandBase } from '../actions';\nimport type {\n FromMetaBoxApiEvents,\n FromMetaBoxMessage,\n FromMetaboxMessagePayloads,\n} from '../interfaces';\n\n/**\n * Handles messaging between the host page and embedded Metabox content.\n * @internal Use {@link Communicator.createInstance} or the {@link integrateMetaBox} helper to instantiate.\n */\nexport class Communicator extends EventDispatcher {\n /**\n * Singleton reference to the current communicator instance.\n */\n public static instance: Communicator | null = null;\n /**\n * Bound handler for incoming postMessage events.\n */\n private binder = this.handleMessageReceived.bind(this, 'metaboxData');\n\n /**\n * Constructs a Communicator, replacing any existing instance, and begins listening for messages.\n * @internal\n */\n constructor() {\n super();\n Communicator.instance?.destroy();\n Communicator.instance = this;\n window.addEventListener('message', this.binder);\n }\n\n /**\n * Listens for Metabox to signal readiness, then initializes communicator.\n * @param apiReadyCallback - Called with the new Communicator once to the Metabox is loaded.\n */\n static createInstance(apiReadyCallback: (api: Communicator) => void): void {\n const startHandler = (event: MessageEvent): void => {\n const message = event.data as FromMetaBoxMessage;\n if (message?.payload?.action === 'appLoaded') {\n apiReadyCallback(new Communicator());\n window.removeEventListener('message', startHandler);\n }\n };\n\n window.addEventListener('message', startHandler);\n }\n\n /**\n * Cleans up resources and stops listening for messages.\n */\n public override destroy(): void {\n super.destroy();\n window.removeEventListener('message', this.binder);\n }\n\n /**\n * Posts a command to the Metabox iframe.\n * @param command - An action command containing data to send.\n */\n public sendCommandToMetaBox<T extends CommandBase>(command: T): void {\n const { data } = command;\n const iframe = document.getElementById(\n 'embeddedContent',\n ) as HTMLIFrameElement;\n\n if (!iframe?.contentWindow) {\n console.warn('to the Metabox IFrame not found or not ready.');\n return;\n }\n\n const message = {\n host: 'metaBoxHost',\n payload: { ...data },\n };\n\n // Replace '*' with a specific origin in production for better security.\n iframe.contentWindow.postMessage(message, '*');\n }\n\n /**\n * Registers an event listener for messages dispatched by to the Metabox.\n * @override\n */\n override addEventListener<T extends FromMetaBoxApiEvents>(\n messageType: T,\n callback: (data: FromMetaboxMessagePayloads[T]) => void,\n ) {\n return super.addEventListener(\n messageType,\n callback as (data: unknown) => void,\n );\n }\n\n /**\n * Dispatches a typed event to all registered listeners.\n * @override\n */\n override dispatchEvent<T extends FromMetaBoxApiEvents>(\n messageType: T,\n data: FromMetaboxMessagePayloads[T],\n ) {\n return super.dispatchEvent(messageType, data);\n }\n\n /**\n * Removes a previously registered event listener.\n * @override\n */\n override removeEventListener<T extends FromMetaBoxApiEvents>(\n messageType: T,\n callback: (data: FromMetaboxMessagePayloads[T]) => void,\n ) {\n return super.removeEventListener(\n messageType,\n callback as (data: unknown) => void,\n );\n }\n\n /**\n * Filters and dispatches incoming messages from to the Metabox.\n * @param {FromMetaBoxApiEvents | 'metaboxData' } messageType - Expected message type for filtering ('metaboxData').\n * @param {MessageEvent} event - The postMessage event received on a window.\n */\n private handleMessageReceived<T extends FromMetaBoxApiEvents>(\n messageType: T | 'metaboxData',\n event: MessageEvent,\n ): void {\n // Optionally validate event.origin for security.\n if (messageType !== 'metaboxData' || event.data?.host !== 'metabox') {\n return;\n }\n\n const { eventType, payload } = event.data.payload;\n this.dispatchEvent(eventType as T, payload);\n }\n}\n","import { Communicator } from './Communicator';\n\n/**\n * Integrates Metabox Basic Configurator into the provided layout.\n *\n * @remarks\n * This function injects an iframe into a specified container element in the DOM and initializes\n * the communicator for interacting with the Metabox embedded content.\n *\n * @param {string} iframeSrc - The source URL of the Metabox iframe.\n * Additional url parameters:\n * ```javascript\n * sidebar=false - disables the internal Metabox menu\n * introImage=https://example.com/image.png - sets the intro image\n * ```\n * i.e., a final link will look like https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id?sidebar=false&introImage=https://example.com/image.png\n *\n * @param {string} containerId - The ID of the layout element. Defaults to 'embed3DSource'.\n * @param apiReadyCallback\n * @throws Error if the container element with the specified ID is not found.\n *\n * @example\n * import {\n * integrateMetaBox,\n * } from '@3dsource/metabox-front-api';\n *\n * integrateMetaBox(\n * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',\n * 'embed3DSource'\n * );\n */\nexport function integrateMetaBox(\n iframeSrc: string,\n containerId = 'embed3DSource',\n apiReadyCallback: (api: Communicator) => void,\n): void {\n const container = document.getElementById(containerId);\n if (!container) {\n throw new Error(`Container element with id ${containerId} not found`);\n }\n\n const existingIframe = document.getElementById('embeddedContent');\n if (existingIframe) {\n existingIframe.remove();\n }\n\n Communicator.createInstance(apiReadyCallback);\n\n const style = document.createElement('style');\n style.innerHTML = `\n #${containerId} {\n width: 100%;\n height: 100%;\n overflow: hidden;\n position: relative;\n }\n `;\n document.head.appendChild(style);\n\n const iframe = document.createElement('iframe');\n iframe.setAttribute('referrerPolicy', 'no-referrer-when-downgrade');\n iframe.setAttribute('id', 'embeddedContent');\n iframe.style.border = '0';\n iframe.style.width = '100%';\n iframe.style.height = '100%';\n iframe.style.overflow = 'hidden';\n iframe.src = iframeSrc;\n container.appendChild(iframe);\n}\n","/**\n * Saves an image by triggering a download.\n *\n * @remarks\n * This function creates an anchor element, sets its `href` attribute to the provided image URL,\n * and triggers a click event to initiate a download with the specified filename.\n *\n * @param {string} imageUrl - The URL of the image to save.\n * @param {string} filename - The name of the file to save.\n */\nexport function saveImage(imageUrl: string, filename: string): void {\n const a = document.createElement('a');\n a.href = imageUrl;\n a.download = filename;\n document.body.appendChild(a);\n a.click();\n document.body.removeChild(a);\n}\n","/**\n * Sets the URL parameters based on the provided state.\n *\n * @remarks\n * This function updates the current URL by replacing its search parameters with the key-value pairs from the provided state object.\n *\n * @param {Record<string, string>} state - An object containing key-value pairs to set as URL parameters.\n */\nexport function setUrlParams(state: Record<string, string>): void {\n const url = new URL(window.location.href);\n url.search = '';\n Object.entries(state).forEach(([key, value]) => {\n url.searchParams.set(key, value);\n });\n history.replaceState(null, '', url.toString());\n}\n\n/**\n * Retrieves the URL parameters as an object.\n *\n * @remarks\n * This function parses the current URL's search parameters and returns them as a key-value object.\n *\n * @returns An object containing the URL parameters.\n */\nexport function getUrlParams(): Record<string, string> {\n const urlParams = new URLSearchParams(window.location.search);\n const selections: Record<string, string> = {};\n urlParams.forEach((value, key) => {\n selections[key] = value;\n });\n return selections;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAEA;;AAEG;MACU,WAAW,CAAA;AAEvB;;ACCD;;;;AAIG;AACG,SAAU,qBAAqB,CACnC,MAAoB,EACpB,SAAY,EAAA;AAEZ,IAAA,OAAO,SAAS,CAAC,MAAM,EAAE,SAAS,CAEjC;AACH;;ACjBO,MAAM,+BAA+B,GAAG;AAC7C,IAAA,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,CAAC,QAAQ,EAAE,CAAC;AAChD;AAEA;;;;;;;AAOG;SACa,YAAY,GAAA;IAC1B,MAAM,SAAS,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC7D,MAAM,UAAU,GAA2B,EAAE;IAC7C,SAAS,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,KAAI;AAC/B,QAAA,UAAU,CAAC,GAAG,CAAC,GAAG,KAAK;AACzB,KAAC,CAAC;AACF,IAAA,OAAO,UAAU;AACnB;;AChCA;;AAEG;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ declare const MetaboxBasicConfiguratorActions: {
|
|
|
28
28
|
readonly setProduct: "setProduct";
|
|
29
29
|
readonly setMaterialById: "setMaterialById";
|
|
30
30
|
readonly getPdf: "getPdf";
|
|
31
|
+
readonly getCallToActionInformation: "getCallToActionInformation";
|
|
31
32
|
readonly getScreenshot: "getScreenshot";
|
|
32
33
|
readonly getFastRender: "getFastRender";
|
|
33
34
|
readonly showEmbeddedMenu: "showEmbeddedMenu";
|
|
@@ -54,6 +55,7 @@ type ToMetaboxMessagePayload = ToMetaboxMessagePayloads[keyof ToMetaboxMessagePa
|
|
|
54
55
|
*/
|
|
55
56
|
interface ToMetaboxMessagePayloads {
|
|
56
57
|
[MetaboxBasicConfiguratorActions.getPdf]: void;
|
|
58
|
+
[MetaboxBasicConfiguratorActions.getCallToActionInformation]: void;
|
|
57
59
|
[MetaboxBasicConfiguratorActions.loadLevel]: {
|
|
58
60
|
id: string;
|
|
59
61
|
};
|
|
@@ -119,6 +121,31 @@ interface ToMetaBoxMessage {
|
|
|
119
121
|
payload: ToMetaBoxMessageEnvelope;
|
|
120
122
|
}
|
|
121
123
|
|
|
124
|
+
/** Represents an ecom configurator object with all necessary information about cta */
|
|
125
|
+
interface EcomConfigurator {
|
|
126
|
+
/** The unique ecom configurator identifier. */
|
|
127
|
+
id: string;
|
|
128
|
+
/** The created data of ecom configurator. */
|
|
129
|
+
createdAt: string;
|
|
130
|
+
/** A reference to the Call To Action Information. */
|
|
131
|
+
cta?: Cta;
|
|
132
|
+
/** GraphQL typename for the ecom configurator. */
|
|
133
|
+
__typename: 'Configurator';
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Represents the call-to-action information for an ecom configurator.
|
|
137
|
+
*/
|
|
138
|
+
interface Cta {
|
|
139
|
+
/** The indicator of whether the call-to-action is enabled or not. */
|
|
140
|
+
enabled: boolean;
|
|
141
|
+
/** Label of button for call-to-action. */
|
|
142
|
+
label: string;
|
|
143
|
+
/** Callback URL using for sent configurator selected information to this url and redirected to the url after get response. */
|
|
144
|
+
callbackUrl: string;
|
|
145
|
+
/** GraphQL typename for the CTA object. */
|
|
146
|
+
__typename: 'Cta';
|
|
147
|
+
}
|
|
148
|
+
|
|
122
149
|
/**
|
|
123
150
|
* Represents a basic configurator object with its configuration, selected materials,
|
|
124
151
|
* product identifier, and associated environment with its materials.
|
|
@@ -357,6 +384,10 @@ interface FromMetaboxMessagePayloads {
|
|
|
357
384
|
* I.e., when the user changes the configuration. (Material, Product, Environment)
|
|
358
385
|
*/
|
|
359
386
|
configuratorDataUpdated: ConfiguratorEnvelope;
|
|
387
|
+
/**
|
|
388
|
+
* Dispatches Every time the ecom configurator data is updated (label, endpointUrl).
|
|
389
|
+
*/
|
|
390
|
+
ecomConfiguratorDataUpdated: EcomConfigurator;
|
|
360
391
|
/**
|
|
361
392
|
* Dispatches Every time when the configurator connected/disconnected with Unreal Engine.
|
|
362
393
|
*/
|
|
@@ -421,7 +452,6 @@ interface FromMetaboxMessagePayloads {
|
|
|
421
452
|
getFastRender: string | null;
|
|
422
453
|
/**
|
|
423
454
|
* @internal
|
|
424
|
-
* @experimental
|
|
425
455
|
* Dispatches every Unreal is sending a command callback.
|
|
426
456
|
* Works only after the new WatchCallbacks () command is sent.
|
|
427
457
|
* !!! WARNING use at your own risk. We don't guarantee right behavior
|
|
@@ -688,7 +718,7 @@ declare function getUrlParams(): Record<string, string>;
|
|
|
688
718
|
declare function fromCommunicatorEvent<T extends FromMetaBoxApiEvents>(target: Communicator, eventName: T): Observable<FromMetaboxMessagePayloads[T]>;
|
|
689
719
|
|
|
690
720
|
/**
|
|
691
|
-
* Represents a command to get a PDF from Metabox.
|
|
721
|
+
* Represents a command to get a PDF from Metabox Basic Configurator.
|
|
692
722
|
* @remarks
|
|
693
723
|
* This class sends a message to the Metabox API to generate a PDF based on the current configuration.
|
|
694
724
|
* This action does not require any parameters.
|
|
@@ -711,6 +741,30 @@ declare class GetPdf extends CommandBase {
|
|
|
711
741
|
constructor();
|
|
712
742
|
}
|
|
713
743
|
|
|
744
|
+
/**
|
|
745
|
+
* Represents a command to get a Call To Action Information from Metabox Basic Configurator.
|
|
746
|
+
* @remarks
|
|
747
|
+
* This class sends a message to the Metabox API to generate Call To Action information based on the current configuration and sends it to the endpoint url from the cta information.
|
|
748
|
+
* This action does not require any parameters.
|
|
749
|
+
*
|
|
750
|
+
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
751
|
+
*
|
|
752
|
+
* @example
|
|
753
|
+
* import { GetCallToActionInformation, Communicator } from '@3dsource/metabox-front-api';
|
|
754
|
+
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
755
|
+
* api.sendCommandToMetaBox(new GetCallToActionInformation());
|
|
756
|
+
* };
|
|
757
|
+
*/
|
|
758
|
+
declare class GetCallToActionInformation extends CommandBase {
|
|
759
|
+
/**
|
|
760
|
+
* Creates an instance of GetCallToActionInformation.
|
|
761
|
+
*
|
|
762
|
+
* @remarks
|
|
763
|
+
* This constructor does not require any parameters.
|
|
764
|
+
*/
|
|
765
|
+
constructor();
|
|
766
|
+
}
|
|
767
|
+
|
|
714
768
|
/**
|
|
715
769
|
* Image format.
|
|
716
770
|
* @remarks
|
|
@@ -745,6 +799,9 @@ declare class GetScreenshot extends CommandBase {
|
|
|
745
799
|
});
|
|
746
800
|
}
|
|
747
801
|
|
|
802
|
+
/**
|
|
803
|
+
* @deprecated, use {@link GetScreenshot} instead.
|
|
804
|
+
*/
|
|
748
805
|
declare const GetFastRender: typeof GetScreenshot;
|
|
749
806
|
|
|
750
807
|
/**
|
|
@@ -798,23 +855,22 @@ declare class ApplyZoom extends CommandBase {
|
|
|
798
855
|
* Represents a command to Init Showcase for a product a scene and start a sequence for the product.
|
|
799
856
|
* @remarks
|
|
800
857
|
* This class sends a command to the Metabox API to init showcase if the product has a sequence.
|
|
801
|
-
* For check this needs to find a showcase property in current product
|
|
802
|
-
* If this property
|
|
803
|
-
* @internal Use {@link ModularConfiguratorComponent.product.showcase}
|
|
858
|
+
* For check this needs to find a showcase property in the current product.
|
|
859
|
+
* If this property exists, you can send init showcase command.
|
|
804
860
|
*
|
|
805
861
|
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
806
862
|
*
|
|
807
863
|
* @example
|
|
864
|
+
* ```typescript
|
|
808
865
|
* import { InitShowcase, Communicator } from '@3dsource/metabox-front-api';
|
|
809
866
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
810
|
-
* api.sendCommandToMetaBox(new InitShowcase('ffea6b5c-3a8a-4f56-9417-e605acb5cca3');
|
|
867
|
+
* api.sendCommandToMetaBox(new InitShowcase('ffea6b5c-3a8a-4f56-9417-e605acb5cca3'));
|
|
811
868
|
* };
|
|
812
869
|
*/
|
|
813
870
|
declare class InitShowcase extends CommandBase {
|
|
814
871
|
/**
|
|
815
872
|
* Creates an instance of InitShowcase.
|
|
816
|
-
*
|
|
817
|
-
* @param {string} productId
|
|
873
|
+
* @param {string} productId - The unique identifier for the product
|
|
818
874
|
*/
|
|
819
875
|
constructor(productId: string);
|
|
820
876
|
}
|
|
@@ -1052,5 +1108,5 @@ declare class WatchCallbacks extends CommandBase {
|
|
|
1052
1108
|
constructor();
|
|
1053
1109
|
}
|
|
1054
1110
|
|
|
1055
|
-
export { ApplyZoom, CommandBase, Communicator, EventDispatcher, GetFastRender, GetPdf, GetScreenshot, InitShowcase, MetaboxBasicConfiguratorActions, PauseShowcase, PlayShowcase, ResetCamera, SetEnvironment, SetEnvironmentMaterial, SetMaterial, SetProduct, ShowEmbeddedMenu, ShowOverlayInterface, StopShowcase, UnrealCommand, WatchCallbacks, fromCommunicatorEvent, getUrlParams, integrateMetaBox, saveImage, setUrlParams };
|
|
1056
|
-
export type { ApplicationDeviceTypes, ConfiguratorEnvelope, DeprecatedEnvelope, Environment, FromMetaBoxAPIEnvelope, FromMetaBoxApiEvents, FromMetaBoxMessage, FromMetaboxApiAction, FromMetaboxDeprecatedApiAction, FromMetaboxMessagePayloads, Listener, MCAppLoaded, Material, MetaBoxApiEnvelope, MetaProperty, MimeType, Product, SelectedIds, ShowCaseStatus, Slot, Thumbnail, ToMetaBoxActions, ToMetaBoxMessage, ToMetaBoxMessageEnvelope, ToMetaboxMessagePayload, ToMetaboxMessagePayloads, UniversalConfigurator, UniversalConfiguratorEnvironment, UniversalConfiguratorProduct, VideoResolution };
|
|
1111
|
+
export { ApplyZoom, CommandBase, Communicator, EventDispatcher, GetCallToActionInformation, GetFastRender, GetPdf, GetScreenshot, InitShowcase, MetaboxBasicConfiguratorActions, PauseShowcase, PlayShowcase, ResetCamera, SetEnvironment, SetEnvironmentMaterial, SetMaterial, SetProduct, ShowEmbeddedMenu, ShowOverlayInterface, StopShowcase, UnrealCommand, WatchCallbacks, fromCommunicatorEvent, getUrlParams, integrateMetaBox, saveImage, setUrlParams };
|
|
1112
|
+
export type { ApplicationDeviceTypes, ConfiguratorEnvelope, Cta, DeprecatedEnvelope, EcomConfigurator, Environment, FromMetaBoxAPIEnvelope, FromMetaBoxApiEvents, FromMetaBoxMessage, FromMetaboxApiAction, FromMetaboxDeprecatedApiAction, FromMetaboxMessagePayloads, Listener, MCAppLoaded, Material, MetaBoxApiEnvelope, MetaProperty, MimeType, Product, SelectedIds, ShowCaseStatus, Showcase, Slot, Thumbnail, Timecode, ToMetaBoxActions, ToMetaBoxMessage, ToMetaBoxMessageEnvelope, ToMetaboxMessagePayload, ToMetaboxMessagePayloads, UniversalConfigurator, UniversalConfiguratorEnvironment, UniversalConfiguratorProduct, VideoResolution };
|