@3dsource/metabox-front-api 1.2.7-dev.1 → 1.2.7-dev.10
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 +0 -2
- package/fesm2022/3dsource-metabox-front-api.mjs +89 -75
- package/fesm2022/3dsource-metabox-front-api.mjs.map +1 -1
- package/index.d.ts +73 -188
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -543,8 +543,6 @@ The API uses an event-driven architecture. Listen for events using the `addEvent
|
|
|
543
543
|
| `configuratorDataUpdated` | Fired when configuration data changes | `ModularConfiguratorEnvelope` |
|
|
544
544
|
| `screenshotReady` | Fired when a screenshot is ready | `string` (base64 image data) |
|
|
545
545
|
| `showcaseStatusChanged` | Fired when showcase status changes | `ShowCaseStatus` |
|
|
546
|
-
| `viewModeChanged` | Fired when view mode status change | `manual \| showcase` |
|
|
547
|
-
| `pdfGenerating` | Fired when pdf is generating or not | `boolean` |
|
|
548
546
|
| `viewportReady` | Fired when viewport is ready | `boolean` |
|
|
549
547
|
| `statusMessageChanged` | Fired when status message changes | `string \| null` |
|
|
550
548
|
|
|
@@ -21,9 +21,9 @@ const MetaboxBasicConfiguratorActions = {
|
|
|
21
21
|
setProduct: 'setProduct',
|
|
22
22
|
setMaterialById: 'setMaterialById',
|
|
23
23
|
getPdf: 'getPdf',
|
|
24
|
+
metaboxConfig: 'metaboxConfig',
|
|
24
25
|
getCallToActionInformation: 'getCallToActionInformation',
|
|
25
26
|
getScreenshot: 'getScreenshot',
|
|
26
|
-
getFastRender: 'getFastRender', // @deprecated, use 'getScreenshot'
|
|
27
27
|
showEmbeddedMenu: 'showEmbeddedMenu',
|
|
28
28
|
forceSetDeviceType: 'forceSetDeviceType',
|
|
29
29
|
showOverlayInterface: 'showOverlayInterface',
|
|
@@ -34,10 +34,29 @@ const MetaboxBasicConfiguratorActions = {
|
|
|
34
34
|
pauseShowcase: 'pauseShowcase',
|
|
35
35
|
stopShowcase: 'stopShowcase',
|
|
36
36
|
sendCommandToUnreal: 'sendCommandToUnreal',
|
|
37
|
-
addResponse: 'addResponse', // @deprecated, use 'watchCallbacks' ;
|
|
38
37
|
watchCallbacks: 'watchCallbacks',
|
|
39
38
|
};
|
|
40
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Represents a command to send Metabox Config to Metabox Basic Configurator.
|
|
42
|
+
* @remarks
|
|
43
|
+
* Automatically sent when the Communicator instance is ready.
|
|
44
|
+
*/
|
|
45
|
+
class MetaboxConfig extends CommandBase {
|
|
46
|
+
/**
|
|
47
|
+
* Creates an instance of MetaboxConfig.
|
|
48
|
+
* @param {string} appId - The unique identifier for the Communicator Instance
|
|
49
|
+
* @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic
|
|
50
|
+
*/
|
|
51
|
+
constructor(appId, config) {
|
|
52
|
+
super();
|
|
53
|
+
this.data = {
|
|
54
|
+
action: MetaboxBasicConfiguratorActions.metaboxConfig,
|
|
55
|
+
payload: { appId, config },
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
41
60
|
/**
|
|
42
61
|
* Represents a command to get a PDF from Metabox Basic Configurator.
|
|
43
62
|
* @remarks
|
|
@@ -94,42 +113,6 @@ class GetCallToActionInformation extends CommandBase {
|
|
|
94
113
|
}
|
|
95
114
|
}
|
|
96
115
|
|
|
97
|
-
/**
|
|
98
|
-
* Represents a command to get a screenshot.
|
|
99
|
-
*
|
|
100
|
-
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* import { GetScreenshot, Communicator, saveImage } from '@3dsource/metabox-front-api';
|
|
104
|
-
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
105
|
-
* // Listen for events from to the Metabox API
|
|
106
|
-
* api.addEventListener('screenshot', (data) => {
|
|
107
|
-
* // Process the get screenshot response
|
|
108
|
-
* saveImage(data, 'Render.png');
|
|
109
|
-
* });
|
|
110
|
-
* api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
|
|
111
|
-
* };
|
|
112
|
-
*/
|
|
113
|
-
class GetScreenshot extends CommandBase {
|
|
114
|
-
/**
|
|
115
|
-
* Constructs an instance of GetScreenshot.
|
|
116
|
-
* @param {MimeType} mimeType - The output format.
|
|
117
|
-
* @param {{ x: number; y: number }} [size] - Optional size in pixels.
|
|
118
|
-
*/
|
|
119
|
-
constructor(mimeType, size) {
|
|
120
|
-
super();
|
|
121
|
-
this.data = {
|
|
122
|
-
payload: { format: mimeType, size },
|
|
123
|
-
action: MetaboxBasicConfiguratorActions.getScreenshot,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* @deprecated, use {@link GetScreenshot} instead.
|
|
130
|
-
*/
|
|
131
|
-
const GetFastRender = GetScreenshot;
|
|
132
|
-
|
|
133
116
|
/**
|
|
134
117
|
* Represents a command to send to unreal and reset camera to initial.
|
|
135
118
|
* @remarks
|
|
@@ -251,15 +234,11 @@ class UnrealCommand extends CommandBase {
|
|
|
251
234
|
constructor(payload) {
|
|
252
235
|
super();
|
|
253
236
|
this.data = {
|
|
254
|
-
payload,
|
|
255
237
|
action: MetaboxBasicConfiguratorActions.sendCommandToUnreal,
|
|
238
|
+
payload,
|
|
256
239
|
};
|
|
257
240
|
}
|
|
258
241
|
}
|
|
259
|
-
/**
|
|
260
|
-
* @deprecated, use {@link UnrealCommand}
|
|
261
|
-
* */
|
|
262
|
-
const SendCommandToUnreal = UnrealCommand;
|
|
263
242
|
|
|
264
243
|
/**
|
|
265
244
|
* Represents a command to Pause Showcase for a product when it already init and play, and you call pause.
|
|
@@ -313,6 +292,37 @@ class StopShowcase extends CommandBase {
|
|
|
313
292
|
}
|
|
314
293
|
}
|
|
315
294
|
|
|
295
|
+
/**
|
|
296
|
+
* Represents a command to get a screenshot.
|
|
297
|
+
*
|
|
298
|
+
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* import { GetScreenshot, Communicator, saveImage } from '@3dsource/metabox-front-api';
|
|
302
|
+
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
303
|
+
* // Listen for events from to the Metabox API
|
|
304
|
+
* api.addEventListener('screenshot', (data) => {
|
|
305
|
+
* // Process the get screenshot response
|
|
306
|
+
* saveImage(data, 'Render.png');
|
|
307
|
+
* });
|
|
308
|
+
* api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
|
|
309
|
+
* };
|
|
310
|
+
*/
|
|
311
|
+
class GetScreenshot extends CommandBase {
|
|
312
|
+
/**
|
|
313
|
+
* Constructs an instance of GetScreenshot.
|
|
314
|
+
* @param {MimeType} mimeType - The output format.
|
|
315
|
+
* @param {{ x: number; y: number }} [size] - Optional size in pixels.
|
|
316
|
+
*/
|
|
317
|
+
constructor(mimeType, size) {
|
|
318
|
+
super();
|
|
319
|
+
this.data = {
|
|
320
|
+
action: MetaboxBasicConfiguratorActions.getScreenshot,
|
|
321
|
+
payload: { format: mimeType, size },
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
316
326
|
/**
|
|
317
327
|
* Represents a command to set a product by its ID.
|
|
318
328
|
*
|
|
@@ -338,8 +348,8 @@ class SetProduct extends CommandBase {
|
|
|
338
348
|
constructor(productId) {
|
|
339
349
|
super();
|
|
340
350
|
this.data = {
|
|
341
|
-
payload: { productId },
|
|
342
351
|
action: MetaboxBasicConfiguratorActions.setProduct,
|
|
352
|
+
payload: { productId },
|
|
343
353
|
};
|
|
344
354
|
}
|
|
345
355
|
}
|
|
@@ -368,8 +378,8 @@ class SetMaterial extends CommandBase {
|
|
|
368
378
|
constructor(slotId, materialId) {
|
|
369
379
|
super();
|
|
370
380
|
this.data = {
|
|
371
|
-
payload: { slotId, materialId },
|
|
372
381
|
action: MetaboxBasicConfiguratorActions.setMaterialById,
|
|
382
|
+
payload: { slotId, materialId },
|
|
373
383
|
};
|
|
374
384
|
}
|
|
375
385
|
}
|
|
@@ -395,8 +405,8 @@ class SetEnvironment extends CommandBase {
|
|
|
395
405
|
constructor(environmentId) {
|
|
396
406
|
super();
|
|
397
407
|
this.data = {
|
|
398
|
-
payload: { id: environmentId },
|
|
399
408
|
action: MetaboxBasicConfiguratorActions.loadLevel,
|
|
409
|
+
payload: { id: environmentId },
|
|
400
410
|
};
|
|
401
411
|
}
|
|
402
412
|
}
|
|
@@ -425,8 +435,8 @@ class SetEnvironmentMaterial extends CommandBase {
|
|
|
425
435
|
constructor(slotId, materialId) {
|
|
426
436
|
super();
|
|
427
437
|
this.data = {
|
|
428
|
-
payload: { slotId, materialId },
|
|
429
438
|
action: MetaboxBasicConfiguratorActions.setEnvironmentMaterialById,
|
|
439
|
+
payload: { slotId, materialId },
|
|
430
440
|
};
|
|
431
441
|
}
|
|
432
442
|
}
|
|
@@ -506,10 +516,6 @@ class WatchCallbacks extends CommandBase {
|
|
|
506
516
|
this.data = { action: MetaboxBasicConfiguratorActions.watchCallbacks };
|
|
507
517
|
}
|
|
508
518
|
}
|
|
509
|
-
/**
|
|
510
|
-
* @deprecated, use {@link WatchCallbacks}
|
|
511
|
-
* */
|
|
512
|
-
const AddResponse = WatchCallbacks;
|
|
513
519
|
|
|
514
520
|
/**
|
|
515
521
|
* EventDispatcher is a class that manages event listeners and dispatches events to them.
|
|
@@ -521,7 +527,7 @@ class EventDispatcher {
|
|
|
521
527
|
*/
|
|
522
528
|
this.listeners = [];
|
|
523
529
|
}
|
|
524
|
-
destroy() {
|
|
530
|
+
destroy(key) {
|
|
525
531
|
this.listeners = [];
|
|
526
532
|
}
|
|
527
533
|
/**
|
|
@@ -558,39 +564,45 @@ class EventDispatcher {
|
|
|
558
564
|
}
|
|
559
565
|
}
|
|
560
566
|
|
|
567
|
+
const Metabox_V2 = 'metabox_v2';
|
|
568
|
+
const MetaboxHost_V2 = 'metaboxHost_v2';
|
|
569
|
+
const MetaboxData_V2 = 'metaboxData_v2';
|
|
570
|
+
const AppLoaded = 'appLoaded';
|
|
571
|
+
|
|
572
|
+
const versionMap = new Map();
|
|
561
573
|
/**
|
|
562
574
|
* Handles messaging between the host page and embedded Metabox content.
|
|
563
575
|
* @internal Use {@link Communicator.createInstance} or the {@link integrateMetaBox} helper to instantiate.
|
|
564
576
|
*/
|
|
565
577
|
class Communicator extends EventDispatcher {
|
|
566
|
-
/**
|
|
567
|
-
* Singleton reference to the current communicator instance.
|
|
568
|
-
*/
|
|
569
|
-
static { this.instance = null; }
|
|
570
578
|
/**
|
|
571
579
|
* Constructs a Communicator, replacing any existing instance, and begins listening for messages.
|
|
572
580
|
* @internal
|
|
573
581
|
*/
|
|
574
|
-
constructor() {
|
|
582
|
+
constructor(appId, version = '1.2.6', config) {
|
|
575
583
|
super();
|
|
576
584
|
/**
|
|
577
585
|
* Bound handler for incoming postMessage events.
|
|
578
586
|
*/
|
|
579
|
-
this.binder = this.handleMessageReceived.bind(this,
|
|
580
|
-
|
|
581
|
-
|
|
587
|
+
this.binder = this.handleMessageReceived.bind(this, MetaboxData_V2);
|
|
588
|
+
const key = `${version}_${appId}`;
|
|
589
|
+
versionMap.get(key)?.destroy(key);
|
|
590
|
+
versionMap.set(key, this);
|
|
591
|
+
console.log('COMMUNICATOR active version: ', key);
|
|
582
592
|
window.addEventListener('message', this.binder);
|
|
593
|
+
this.sendCommandToMetaBox(new MetaboxConfig(appId, config));
|
|
583
594
|
}
|
|
584
595
|
/**
|
|
585
596
|
* Listens for Metabox to signal readiness, then initializes communicator.
|
|
586
597
|
* @param apiReadyCallback - Called with the new Communicator once to the Metabox is loaded.
|
|
598
|
+
* @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic
|
|
587
599
|
*/
|
|
588
|
-
static createInstance(apiReadyCallback) {
|
|
600
|
+
static createInstance(apiReadyCallback, config) {
|
|
589
601
|
const startHandler = (event) => {
|
|
590
602
|
const message = event.data;
|
|
591
|
-
if (message?.
|
|
592
|
-
message
|
|
593
|
-
apiReadyCallback(new Communicator());
|
|
603
|
+
if (message?.envelope?.action === 'appLoaded') {
|
|
604
|
+
console.log('appId: ', message.envelope.payload);
|
|
605
|
+
apiReadyCallback(new Communicator(message.envelope.payload, '', config));
|
|
594
606
|
window.removeEventListener('message', startHandler);
|
|
595
607
|
}
|
|
596
608
|
};
|
|
@@ -599,8 +611,9 @@ class Communicator extends EventDispatcher {
|
|
|
599
611
|
/**
|
|
600
612
|
* Cleans up resources and stops listening for messages.
|
|
601
613
|
*/
|
|
602
|
-
destroy() {
|
|
603
|
-
|
|
614
|
+
destroy(key) {
|
|
615
|
+
console.log('COMMUNICATOR destroyed version: ', key);
|
|
616
|
+
super.destroy(key);
|
|
604
617
|
window.removeEventListener('message', this.binder);
|
|
605
618
|
}
|
|
606
619
|
/**
|
|
@@ -611,16 +624,16 @@ class Communicator extends EventDispatcher {
|
|
|
611
624
|
const { data } = command;
|
|
612
625
|
const iframe = document.getElementById('embeddedContent');
|
|
613
626
|
const message = {
|
|
614
|
-
host:
|
|
627
|
+
host: MetaboxHost_V2,
|
|
615
628
|
payload: { ...data },
|
|
616
629
|
};
|
|
617
630
|
if (!iframe?.contentWindow) {
|
|
618
|
-
console.warn('to the Metabox IFrame not found or not ready. Message sends to the
|
|
619
|
-
window.postMessage(message, '*');
|
|
631
|
+
console.warn('to the Metabox IFrame not found or not ready. Message sends to the same window');
|
|
632
|
+
window.postMessage({ ...message, target: 'metabox' }, '*');
|
|
620
633
|
return;
|
|
621
634
|
}
|
|
622
635
|
// Replace '*' with a specific origin in production for better security.
|
|
623
|
-
iframe.contentWindow.postMessage(message, '*');
|
|
636
|
+
iframe.contentWindow.postMessage({ ...message, target: 'child' }, '*');
|
|
624
637
|
}
|
|
625
638
|
/**
|
|
626
639
|
* Registers an event listener for messages dispatched by to the Metabox.
|
|
@@ -650,7 +663,7 @@ class Communicator extends EventDispatcher {
|
|
|
650
663
|
*/
|
|
651
664
|
handleMessageReceived(messageType, event) {
|
|
652
665
|
// Optionally validate event.origin for security.
|
|
653
|
-
if (messageType !==
|
|
666
|
+
if (messageType !== MetaboxData_V2 || event.data?.host !== Metabox_V2) {
|
|
654
667
|
return;
|
|
655
668
|
}
|
|
656
669
|
const data = event.data?.envelope || event.data?.payload;
|
|
@@ -674,7 +687,8 @@ class Communicator extends EventDispatcher {
|
|
|
674
687
|
* 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
|
|
675
688
|
*
|
|
676
689
|
* @param {string} containerId - The ID of the layout element. Defaults to 'embed3DSource'.
|
|
677
|
-
* @param apiReadyCallback
|
|
690
|
+
* @param apiReadyCallback - Callback after communicator will be created.
|
|
691
|
+
* @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic
|
|
678
692
|
* @throws Error if the container element with the specified ID is not found.
|
|
679
693
|
*
|
|
680
694
|
* @example
|
|
@@ -687,7 +701,7 @@ class Communicator extends EventDispatcher {
|
|
|
687
701
|
* 'embed3DSource'
|
|
688
702
|
* );
|
|
689
703
|
*/
|
|
690
|
-
function integrateMetaBox(iframeSrc, containerId = 'embed3DSource', apiReadyCallback) {
|
|
704
|
+
function integrateMetaBox(iframeSrc, containerId = 'embed3DSource', apiReadyCallback, config) {
|
|
691
705
|
const container = document.getElementById(containerId);
|
|
692
706
|
if (!container) {
|
|
693
707
|
throw new Error(`Container element with id ${containerId} not found`);
|
|
@@ -696,7 +710,7 @@ function integrateMetaBox(iframeSrc, containerId = 'embed3DSource', apiReadyCall
|
|
|
696
710
|
if (existingIframe) {
|
|
697
711
|
existingIframe.remove();
|
|
698
712
|
}
|
|
699
|
-
Communicator.createInstance(apiReadyCallback);
|
|
713
|
+
Communicator.createInstance(apiReadyCallback, config);
|
|
700
714
|
const style = document.createElement('style');
|
|
701
715
|
style.innerHTML = `
|
|
702
716
|
#${containerId} {
|
|
@@ -774,5 +788,5 @@ function getUrlParams() {
|
|
|
774
788
|
* Generated bundle index. Do not edit.
|
|
775
789
|
*/
|
|
776
790
|
|
|
777
|
-
export { ApplyZoom, CommandBase, Communicator, EventDispatcher, GetCallToActionInformation,
|
|
791
|
+
export { AppLoaded, ApplyZoom, CommandBase, Communicator, EventDispatcher, GetCallToActionInformation, GetPdf, GetScreenshot, InitShowcase, MetaboxBasicConfiguratorActions, MetaboxConfig, MetaboxData_V2, MetaboxHost_V2, Metabox_V2, PauseShowcase, PlayShowcase, ResetCamera, SetEnvironment, SetEnvironmentMaterial, SetMaterial, SetProduct, ShowEmbeddedMenu, ShowOverlayInterface, StopShowcase, UnrealCommand, WatchCallbacks, fromCommunicatorEvent, getUrlParams, integrateMetaBox, saveImage, setUrlParams };
|
|
778
792
|
//# 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/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 (\n message?.payload?.action === 'appLoaded' ||\n message?.envelope?.action === 'appLoaded'\n ) {\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 const message = {\n host: 'metaBoxHost',\n payload: { ...data },\n };\n\n if (!iframe?.contentWindow) {\n console.warn(\n 'to the Metabox IFrame not found or not ready. Message sends to the host!',\n );\n window.postMessage(message, '*');\n return;\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 const data = event.data?.envelope || event.data?.payload;\n this.dispatchEvent(data?.eventType as T, data?.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,SAAS,EAAE,WAAW;AACtB,IAAA,0BAA0B,EAAE,4BAA4B;AACxD,IAAA,UAAU,EAAE,YAAY;AACxB,IAAA,eAAe,EAAE,iBAAiB;AAClC,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,0BAA0B,EAAE,4BAA4B;AACxD,IAAA,aAAa,EAAE,eAAe;IAC9B,aAAa,EAAE,eAAe;AAC9B,IAAA,gBAAgB,EAAE,kBAAkB;AACpC,IAAA,kBAAkB,EAAE,oBAAoB;AACxC,IAAA,oBAAoB,EAAE,sBAAsB;AAC5C,IAAA,WAAW,EAAE,aAAa;AAC1B,IAAA,SAAS,EAAE,WAAW;AACtB,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,aAAa,EAAE,eAAe;AAC9B,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,mBAAmB,EAAE,qBAAqB;IAC1C,WAAW,EAAE,aAAa;AAC1B,IAAA,cAAc,EAAE,gBAAgB;;;ACpBlC;;;;;;;;;;;;;AAaG;AAEG,MAAO,MAAO,SAAQ,WAAW,CAAA;AACrC;;;;;AAKG;AACH,IAAA,WAAA,GAAA;AACE,QAAA,KAAK,EAAE;QACP,IAAI,CAAC,IAAI,GAAG,EAAE,MAAM,EAAE,+BAA+B,CAAC,MAAM,EAAE;;AAEjE;;AC1BD;;;;;;;;;;;;;AAaG;AAEG,MAAO,0BA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AACT,IAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;AAC9B;;ACjBA;;;;;;;AAOG;AACG,SAAU,YAAY,CAAC,KAA6B,EAAA;IACxD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;AACzC,IAAA,GAAG,CAAC,MAAM,GAAG,EAAE;AACf,IAAA,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;QAC7C,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC;AAClC,KAAC,CAAC;AACF,IAAA,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,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;;;;"}
|
|
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/MetaboxConfig.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/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/GetScreenshot.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/constants/common.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';\nimport { MetaboxHost_V2 } from '../constants';\n\nexport const MetaboxBasicConfiguratorActions = {\n loadLevel: 'loadLevel',\n setEnvironmentMaterialById: 'setEnvironmentMaterialById',\n setProduct: 'setProduct',\n setMaterialById: 'setMaterialById',\n getPdf: 'getPdf',\n metaboxConfig: 'metaboxConfig',\n getCallToActionInformation: 'getCallToActionInformation',\n getScreenshot: '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 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 [MetaboxBasicConfiguratorActions.watchCallbacks]: void;\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: typeof MetaboxHost_V2;\n payload: ToMetaBoxMessageEnvelope;\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxBasicConfiguratorActions } from '../interfaces';\nimport { MetaboxCommandConfig } from '../interfaces/metabox-config';\n\n/**\n * Represents a command to send Metabox Config to Metabox Basic Configurator.\n * @remarks\n * Automatically sent when the Communicator instance is ready.\n */\n\nexport class MetaboxConfig extends CommandBase {\n /**\n * Creates an instance of MetaboxConfig.\n * @param {string} appId - The unique identifier for the Communicator Instance\n * @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic\n */\n constructor(appId: string, config?: MetaboxCommandConfig) {\n super();\n this.data = {\n action: MetaboxBasicConfiguratorActions.metaboxConfig,\n payload: { appId, config },\n };\n }\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 * 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 action: MetaboxBasicConfiguratorActions.sendCommandToUnreal,\n payload,\n };\n }\n}\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 * 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 action: MetaboxBasicConfiguratorActions.getScreenshot,\n payload: { format: mimeType, size },\n };\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 action: MetaboxBasicConfiguratorActions.setProduct,\n payload: { productId },\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 action: MetaboxBasicConfiguratorActions.setMaterialById,\n payload: { slotId, materialId },\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 action: MetaboxBasicConfiguratorActions.loadLevel,\n payload: { id: environmentId },\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 action: MetaboxBasicConfiguratorActions.setEnvironmentMaterialById,\n payload: { slotId, materialId },\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 * 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(key: string): void {\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","export const Metabox_V2 = 'metabox_v2';\nexport const MetaboxHost_V2 = 'metaboxHost_v2';\nexport const MetaboxData_V2 = 'metaboxData_v2';\nexport const AppLoaded = 'appLoaded';\n","import { EventDispatcher } from './EventDispatcher';\nimport { CommandBase, MetaboxConfig } from '../actions';\nimport type { FromMetaBoxApiEvents, FromMetaBoxMessage, FromMetaboxMessagePayloads, } from '../interfaces';\nimport { Metabox_V2, MetaboxData_V2, MetaboxHost_V2 } from '../constants';\nimport { MetaboxCommandConfig } from '../interfaces/metabox-config';\n\nconst versionMap = new Map<string, Communicator>();\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 * Bound handler for incoming postMessage events.\n */\n private binder = this.handleMessageReceived.bind(this, MetaboxData_V2);\n\n /**\n * Constructs a Communicator, replacing any existing instance, and begins listening for messages.\n * @internal\n */\n constructor(appId: string, version = '1.2.6', config?: MetaboxCommandConfig) {\n super();\n const key = `${version}_${appId}`;\n versionMap.get(key)?.destroy(key);\n versionMap.set(key, this);\n console.log('COMMUNICATOR active version: ', key);\n window.addEventListener('message', this.binder);\n this.sendCommandToMetaBox(new MetaboxConfig(appId, config));\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 * @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic\n */\n static createInstance(\n apiReadyCallback: (api: Communicator) => void,\n config?: MetaboxCommandConfig,\n ): void {\n const startHandler = (event: MessageEvent): void => {\n const message = event.data as FromMetaBoxMessage;\n if (message?.envelope?.action === 'appLoaded') {\n console.log('appId: ', message.envelope.payload);\n apiReadyCallback(\n new Communicator(message.envelope.payload as string, '', config),\n );\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(key: string): void {\n console.log('COMMUNICATOR destroyed version: ', key);\n super.destroy(key);\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 const message = {\n host: MetaboxHost_V2,\n payload: { ...data },\n };\n\n if (!iframe?.contentWindow) {\n console.warn(\n 'to the Metabox IFrame not found or not ready. Message sends to the same window',\n );\n window.postMessage({ ...message, target: 'metabox' }, '*');\n return;\n }\n\n // Replace '*' with a specific origin in production for better security.\n iframe.contentWindow.postMessage({ ...message, target: 'child' }, '*');\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 | typeof MetaboxData_V2,\n event: MessageEvent,\n ): void {\n // Optionally validate event.origin for security.\n if (messageType !== MetaboxData_V2 || event.data?.host !== Metabox_V2) {\n return;\n }\n const data = event.data?.envelope || event.data?.payload;\n this.dispatchEvent(data?.eventType as T, data?.payload);\n }\n}\n","import { Communicator } from './Communicator';\nimport { MetaboxCommandConfig } from '../interfaces/metabox-config';\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 - Callback after communicator will be created.\n * @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic\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 config?: MetaboxCommandConfig,\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, config);\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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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
|
@@ -2,25 +2,12 @@ import { Observable } from 'rxjs';
|
|
|
2
2
|
|
|
3
3
|
type ApplicationDeviceTypes = 'deviceTypeAuto' | 'deviceTypeMobile' | 'deviceTypeDesktop';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* Union type members:
|
|
12
|
-
* - unrealFeatureBridge: @deprecated, use MetaBoxApiAction.Bridge with eventType: "unrealFeature"
|
|
13
|
-
* - unrealCallback: @deprecated, use MetaBoxApiAction.Bridge with eventType: "unrealCallback"
|
|
14
|
-
* - configuratorDataWithStateBridge: @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
|
|
15
|
-
* - configuratorDataBridge: @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
|
|
16
|
-
* - menuDataBridge: @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
|
|
17
|
-
* - flatMenuDataBridge: @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
|
|
18
|
-
* - fullScreenBridge: @deprecated, use Bridge with isFullscreen
|
|
19
|
-
* - videoSize: @deprecated, use Bridge with streamResolution
|
|
20
|
-
* - unrealResponse: Used in a platform, must be removed in future @deprecated
|
|
21
|
-
* - getFastRender: @deprecated
|
|
22
|
-
*/
|
|
23
|
-
type FromMetaboxDeprecatedApiAction = 'unrealFeatureBridge' | 'unrealCallback' | 'configuratorDataWithStateBridge' | 'configuratorDataBridge' | 'menuDataBridge' | 'flatMenuDataBridge' | 'fullScreenBridge' | 'videoSize' | 'unrealResponse' | 'getFastRender';
|
|
5
|
+
declare const Metabox_V2 = "metabox_v2";
|
|
6
|
+
declare const MetaboxHost_V2 = "metaboxHost_v2";
|
|
7
|
+
declare const MetaboxData_V2 = "metaboxData_v2";
|
|
8
|
+
declare const AppLoaded = "appLoaded";
|
|
9
|
+
|
|
10
|
+
type FromMetaboxApiAction = 'bridge' | typeof AppLoaded;
|
|
24
11
|
|
|
25
12
|
declare const MetaboxBasicConfiguratorActions: {
|
|
26
13
|
readonly loadLevel: "loadLevel";
|
|
@@ -28,9 +15,9 @@ declare const MetaboxBasicConfiguratorActions: {
|
|
|
28
15
|
readonly setProduct: "setProduct";
|
|
29
16
|
readonly setMaterialById: "setMaterialById";
|
|
30
17
|
readonly getPdf: "getPdf";
|
|
18
|
+
readonly metaboxConfig: "metaboxConfig";
|
|
31
19
|
readonly getCallToActionInformation: "getCallToActionInformation";
|
|
32
20
|
readonly getScreenshot: "getScreenshot";
|
|
33
|
-
readonly getFastRender: "getFastRender";
|
|
34
21
|
readonly showEmbeddedMenu: "showEmbeddedMenu";
|
|
35
22
|
readonly forceSetDeviceType: "forceSetDeviceType";
|
|
36
23
|
readonly showOverlayInterface: "showOverlayInterface";
|
|
@@ -41,7 +28,6 @@ declare const MetaboxBasicConfiguratorActions: {
|
|
|
41
28
|
readonly pauseShowcase: "pauseShowcase";
|
|
42
29
|
readonly stopShowcase: "stopShowcase";
|
|
43
30
|
readonly sendCommandToUnreal: "sendCommandToUnreal";
|
|
44
|
-
readonly addResponse: "addResponse";
|
|
45
31
|
readonly watchCallbacks: "watchCallbacks";
|
|
46
32
|
};
|
|
47
33
|
type ToMetaBoxActions = (typeof MetaboxBasicConfiguratorActions)[keyof typeof MetaboxBasicConfiguratorActions];
|
|
@@ -62,20 +48,7 @@ interface ToMetaboxMessagePayloads {
|
|
|
62
48
|
[MetaboxBasicConfiguratorActions.setProduct]: {
|
|
63
49
|
productId: string;
|
|
64
50
|
};
|
|
65
|
-
/**
|
|
66
|
-
* @deprecated
|
|
67
|
-
* @hidden use
|
|
68
|
-
* {@link MetaboxBasicConfiguratorActions.watchCallbacks}
|
|
69
|
-
*/
|
|
70
|
-
[MetaboxBasicConfiguratorActions.addResponse]: void;
|
|
71
51
|
[MetaboxBasicConfiguratorActions.watchCallbacks]: void;
|
|
72
|
-
[MetaboxBasicConfiguratorActions.getFastRender]: {
|
|
73
|
-
format: MimeType;
|
|
74
|
-
size?: {
|
|
75
|
-
x: number;
|
|
76
|
-
y: number;
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
52
|
[MetaboxBasicConfiguratorActions.getScreenshot]: {
|
|
80
53
|
format: MimeType;
|
|
81
54
|
size?: {
|
|
@@ -117,7 +90,7 @@ interface ToMetaBoxMessageEnvelope {
|
|
|
117
90
|
payload?: ToMetaboxMessagePayload | never;
|
|
118
91
|
}
|
|
119
92
|
interface ToMetaBoxMessage {
|
|
120
|
-
host:
|
|
93
|
+
host: typeof MetaboxHost_V2;
|
|
121
94
|
payload: ToMetaBoxMessageEnvelope;
|
|
122
95
|
}
|
|
123
96
|
|
|
@@ -163,12 +136,6 @@ interface ConfiguratorEnvelope {
|
|
|
163
136
|
* A record mapping product material selections.
|
|
164
137
|
*/
|
|
165
138
|
productMaterialsIds: SelectedIds;
|
|
166
|
-
/**
|
|
167
|
-
* @deprecated,
|
|
168
|
-
* use `productMaterialsIds` instead.
|
|
169
|
-
* @hidden
|
|
170
|
-
*/
|
|
171
|
-
selectedMaterials: SelectedIds;
|
|
172
139
|
/**
|
|
173
140
|
* The unique environment identifier.
|
|
174
141
|
*/
|
|
@@ -459,16 +426,6 @@ interface VideoResolution {
|
|
|
459
426
|
}
|
|
460
427
|
|
|
461
428
|
interface FromMetaboxMessagePayloads {
|
|
462
|
-
/**
|
|
463
|
-
* @hidden
|
|
464
|
-
* @deprecated use {@link FromMetaboxMessagePayloads.configuratorDataUpdated}
|
|
465
|
-
*/
|
|
466
|
-
configuratorData: ConfiguratorEnvelope;
|
|
467
|
-
/**
|
|
468
|
-
* @hidden
|
|
469
|
-
* @deprecated use {@link FromMetaboxMessagePayloads.configuratorDataUpdated}
|
|
470
|
-
*/
|
|
471
|
-
basicConfiguratorDataWithState: ConfiguratorEnvelope;
|
|
472
429
|
/**
|
|
473
430
|
* Dispatches every time the configurator data is updated.
|
|
474
431
|
* I.e., when the user changes the configuration. (Material, Product, Environment)
|
|
@@ -490,64 +447,14 @@ interface FromMetaboxMessagePayloads {
|
|
|
490
447
|
* Dispatches every time when while the configurator loads. Shows showcase status information on a scene.
|
|
491
448
|
*/
|
|
492
449
|
showcaseStatusChanged: ShowCaseStatus;
|
|
493
|
-
/**
|
|
494
|
-
* Dispatches every time when the PDF is generating.
|
|
495
|
-
*/
|
|
496
|
-
pdfGenerating: boolean;
|
|
497
|
-
/**
|
|
498
|
-
* Dispatches every time when while the configurator loads. Shows showcase status information on scene.
|
|
499
|
-
*/
|
|
500
|
-
viewModeChanged: 'manual' | 'showcase';
|
|
501
|
-
/**
|
|
502
|
-
* @hidden
|
|
503
|
-
* @deprecated
|
|
504
|
-
* Dispatches Every when user toggles fullscreen button in an internal menu.
|
|
505
|
-
*/
|
|
506
|
-
isFullScreen: boolean;
|
|
507
|
-
/**
|
|
508
|
-
* @hidden
|
|
509
|
-
* @deprecated use {@link FromMetaboxMessagePayloads.statusMessageChanged}
|
|
510
|
-
* Dispatches at the moment while the configurator loads. Shows status information.
|
|
511
|
-
*/
|
|
512
|
-
statusMessage: string | null;
|
|
513
450
|
/**
|
|
514
451
|
* Dispatches at the moment while the configurator loads. Shows status information.
|
|
515
452
|
*/
|
|
516
453
|
statusMessageChanged: string | null;
|
|
517
|
-
/**
|
|
518
|
-
* @hidden
|
|
519
|
-
* @deprecated
|
|
520
|
-
* Dispatches every time when the freeze-frame is arrived or updated.
|
|
521
|
-
*/
|
|
522
|
-
freezeFrame: {
|
|
523
|
-
dataUrl: string | null;
|
|
524
|
-
progress: number | null;
|
|
525
|
-
};
|
|
526
454
|
/**
|
|
527
455
|
* Dispatches every time when Unreal is sending ordered render with new GetScreenshot() command.
|
|
528
456
|
*/
|
|
529
457
|
screenshotReady: string | null;
|
|
530
|
-
/**
|
|
531
|
-
* @hidden
|
|
532
|
-
* @deprecated use {@link FromMetaboxMessagePayloads.screenshotReady}
|
|
533
|
-
* Dispatches every time when Unreal is sending ordered render with new GetScreenshot() command.
|
|
534
|
-
*/
|
|
535
|
-
screenshot: string | null;
|
|
536
|
-
/**
|
|
537
|
-
* @hidden
|
|
538
|
-
* @deprecated, use {@link FromMetaboxMessagePayloads.screenshotReady}
|
|
539
|
-
*/
|
|
540
|
-
getScreenshot: string | null;
|
|
541
|
-
/**
|
|
542
|
-
* @hidden
|
|
543
|
-
* @deprecated, use {@link FromMetaboxMessagePayloads.screenshotReady}
|
|
544
|
-
*/
|
|
545
|
-
fastRender: string | null;
|
|
546
|
-
/**
|
|
547
|
-
* @hidden
|
|
548
|
-
* @deprecated, use {@link FromMetaboxMessagePayloads.screenshotReady}
|
|
549
|
-
*/
|
|
550
|
-
getFastRender: string | null;
|
|
551
458
|
/**
|
|
552
459
|
* @internal
|
|
553
460
|
* Dispatches every Unreal is sending a command callback.
|
|
@@ -566,26 +473,10 @@ interface FromMetaboxMessagePayloads {
|
|
|
566
473
|
* !!! WARNING use at your own risk. We don't guarantee right behavior
|
|
567
474
|
*/
|
|
568
475
|
unrealState: object;
|
|
569
|
-
/**
|
|
570
|
-
* @hidden
|
|
571
|
-
* @internal
|
|
572
|
-
* @deprecated, use {@link FromMetaboxMessagePayloads.unrealState}
|
|
573
|
-
*/
|
|
574
|
-
unrealFeature: object;
|
|
575
476
|
/**
|
|
576
477
|
* Dispatches every time when Unreal is changing its video stream size.
|
|
577
478
|
*/
|
|
578
479
|
videoResolutionChanged: VideoResolution;
|
|
579
|
-
/**
|
|
580
|
-
* @hidden
|
|
581
|
-
* @deprecated, use ${@link FromMetaboxMessagePayloads.videoResolutionChanged }
|
|
582
|
-
*/
|
|
583
|
-
videoResolution: VideoResolution;
|
|
584
|
-
/**
|
|
585
|
-
* @hidden
|
|
586
|
-
* @deprecated, use ${@link FromMetaboxMessagePayloads.videoResolutionChanged }
|
|
587
|
-
*/
|
|
588
|
-
streamResolution: VideoResolution;
|
|
589
480
|
}
|
|
590
481
|
/**
|
|
591
482
|
* @hidden
|
|
@@ -606,18 +497,7 @@ interface MetaBoxApiEnvelope<T extends FromMetaBoxApiEvents> {
|
|
|
606
497
|
* Used for signaling that the app is loaded and ready to open api.
|
|
607
498
|
*/
|
|
608
499
|
interface MCAppLoaded {
|
|
609
|
-
action:
|
|
610
|
-
eventType?: unknown;
|
|
611
|
-
payload?: unknown;
|
|
612
|
-
}
|
|
613
|
-
/**
|
|
614
|
-
* @hidden
|
|
615
|
-
* Preserved for backward compatibility.
|
|
616
|
-
* @deprecated
|
|
617
|
-
* Used for sending deprecated messages, must be removed in the future.
|
|
618
|
-
*/
|
|
619
|
-
interface DeprecatedEnvelope {
|
|
620
|
-
action: FromMetaboxDeprecatedApiAction | FromMetaboxApiAction;
|
|
500
|
+
action: typeof AppLoaded;
|
|
621
501
|
eventType?: unknown;
|
|
622
502
|
payload?: unknown;
|
|
623
503
|
}
|
|
@@ -628,15 +508,9 @@ interface DeprecatedEnvelope {
|
|
|
628
508
|
*/
|
|
629
509
|
type FromMetaBoxAPIEnvelope = {
|
|
630
510
|
[K in keyof FromMetaboxMessagePayloads]: MetaBoxApiEnvelope<K>;
|
|
631
|
-
}[keyof FromMetaboxMessagePayloads] | MCAppLoaded
|
|
511
|
+
}[keyof FromMetaboxMessagePayloads] | MCAppLoaded;
|
|
632
512
|
interface FromMetaBoxMessage {
|
|
633
|
-
host:
|
|
634
|
-
/**
|
|
635
|
-
* @hidden
|
|
636
|
-
* Preserved for backward compatibility.
|
|
637
|
-
* @deprecated, use `envelope` instead.
|
|
638
|
-
*/
|
|
639
|
-
payload?: FromMetaBoxAPIEnvelope;
|
|
513
|
+
host: typeof Metabox_V2;
|
|
640
514
|
envelope: FromMetaBoxAPIEnvelope;
|
|
641
515
|
}
|
|
642
516
|
|
|
@@ -667,7 +541,7 @@ declare class EventDispatcher {
|
|
|
667
541
|
* Storage for callback listeners by message type.
|
|
668
542
|
*/
|
|
669
543
|
listeners: Listener[];
|
|
670
|
-
destroy(): void;
|
|
544
|
+
destroy(key: string): void;
|
|
671
545
|
/**
|
|
672
546
|
* Adds an event listener for receiving specific types of messages.
|
|
673
547
|
*
|
|
@@ -691,15 +565,15 @@ declare class EventDispatcher {
|
|
|
691
565
|
removeEventListener(messageType: string, callback: (data: unknown) => void): this;
|
|
692
566
|
}
|
|
693
567
|
|
|
568
|
+
interface MetaboxCommandConfig {
|
|
569
|
+
standalone: boolean;
|
|
570
|
+
}
|
|
571
|
+
|
|
694
572
|
/**
|
|
695
573
|
* Handles messaging between the host page and embedded Metabox content.
|
|
696
574
|
* @internal Use {@link Communicator.createInstance} or the {@link integrateMetaBox} helper to instantiate.
|
|
697
575
|
*/
|
|
698
576
|
declare class Communicator extends EventDispatcher {
|
|
699
|
-
/**
|
|
700
|
-
* Singleton reference to the current communicator instance.
|
|
701
|
-
*/
|
|
702
|
-
static instance: Communicator | null;
|
|
703
577
|
/**
|
|
704
578
|
* Bound handler for incoming postMessage events.
|
|
705
579
|
*/
|
|
@@ -708,16 +582,17 @@ declare class Communicator extends EventDispatcher {
|
|
|
708
582
|
* Constructs a Communicator, replacing any existing instance, and begins listening for messages.
|
|
709
583
|
* @internal
|
|
710
584
|
*/
|
|
711
|
-
constructor();
|
|
585
|
+
constructor(appId: string, version?: string, config?: MetaboxCommandConfig);
|
|
712
586
|
/**
|
|
713
587
|
* Listens for Metabox to signal readiness, then initializes communicator.
|
|
714
588
|
* @param apiReadyCallback - Called with the new Communicator once to the Metabox is loaded.
|
|
589
|
+
* @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic
|
|
715
590
|
*/
|
|
716
|
-
static createInstance(apiReadyCallback: (api: Communicator) => void): void;
|
|
591
|
+
static createInstance(apiReadyCallback: (api: Communicator) => void, config?: MetaboxCommandConfig): void;
|
|
717
592
|
/**
|
|
718
593
|
* Cleans up resources and stops listening for messages.
|
|
719
594
|
*/
|
|
720
|
-
destroy(): void;
|
|
595
|
+
destroy(key: string): void;
|
|
721
596
|
/**
|
|
722
597
|
* Posts a command to the Metabox iframe.
|
|
723
598
|
* @param command - An action command containing data to send.
|
|
@@ -762,7 +637,8 @@ declare class Communicator extends EventDispatcher {
|
|
|
762
637
|
* 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
|
|
763
638
|
*
|
|
764
639
|
* @param {string} containerId - The ID of the layout element. Defaults to 'embed3DSource'.
|
|
765
|
-
* @param apiReadyCallback
|
|
640
|
+
* @param apiReadyCallback - Callback after communicator will be created.
|
|
641
|
+
* @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic
|
|
766
642
|
* @throws Error if the container element with the specified ID is not found.
|
|
767
643
|
*
|
|
768
644
|
* @example
|
|
@@ -775,7 +651,7 @@ declare class Communicator extends EventDispatcher {
|
|
|
775
651
|
* 'embed3DSource'
|
|
776
652
|
* );
|
|
777
653
|
*/
|
|
778
|
-
declare function integrateMetaBox(iframeSrc: string, containerId: string | undefined, apiReadyCallback: (api: Communicator) => void): void;
|
|
654
|
+
declare function integrateMetaBox(iframeSrc: string, containerId: string | undefined, apiReadyCallback: (api: Communicator) => void, config?: MetaboxCommandConfig): void;
|
|
779
655
|
|
|
780
656
|
/**
|
|
781
657
|
* Saves an image by triggering a download.
|
|
@@ -815,6 +691,20 @@ declare function getUrlParams(): Record<string, string>;
|
|
|
815
691
|
*/
|
|
816
692
|
declare function fromCommunicatorEvent<T extends FromMetaBoxApiEvents>(target: Communicator, eventName: T): Observable<FromMetaboxMessagePayloads[T]>;
|
|
817
693
|
|
|
694
|
+
/**
|
|
695
|
+
* Represents a command to send Metabox Config to Metabox Basic Configurator.
|
|
696
|
+
* @remarks
|
|
697
|
+
* Automatically sent when the Communicator instance is ready.
|
|
698
|
+
*/
|
|
699
|
+
declare class MetaboxConfig extends CommandBase {
|
|
700
|
+
/**
|
|
701
|
+
* Creates an instance of MetaboxConfig.
|
|
702
|
+
* @param {string} appId - The unique identifier for the Communicator Instance
|
|
703
|
+
* @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic
|
|
704
|
+
*/
|
|
705
|
+
constructor(appId: string, config?: MetaboxCommandConfig);
|
|
706
|
+
}
|
|
707
|
+
|
|
818
708
|
/**
|
|
819
709
|
* Represents a command to get a PDF from Metabox Basic Configurator.
|
|
820
710
|
* @remarks
|
|
@@ -863,45 +753,6 @@ declare class GetCallToActionInformation extends CommandBase {
|
|
|
863
753
|
constructor();
|
|
864
754
|
}
|
|
865
755
|
|
|
866
|
-
/**
|
|
867
|
-
* Image format.
|
|
868
|
-
* @remarks
|
|
869
|
-
* This type represents the allowed image formats.
|
|
870
|
-
*/
|
|
871
|
-
type MimeType = 'image/png' | 'image/jpeg' | 'image/webp';
|
|
872
|
-
/**
|
|
873
|
-
* Represents a command to get a screenshot.
|
|
874
|
-
*
|
|
875
|
-
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
876
|
-
*
|
|
877
|
-
* @example
|
|
878
|
-
* import { GetScreenshot, Communicator, saveImage } from '@3dsource/metabox-front-api';
|
|
879
|
-
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
880
|
-
* // Listen for events from to the Metabox API
|
|
881
|
-
* api.addEventListener('screenshot', (data) => {
|
|
882
|
-
* // Process the get screenshot response
|
|
883
|
-
* saveImage(data, 'Render.png');
|
|
884
|
-
* });
|
|
885
|
-
* api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
|
|
886
|
-
* };
|
|
887
|
-
*/
|
|
888
|
-
declare class GetScreenshot extends CommandBase {
|
|
889
|
-
/**
|
|
890
|
-
* Constructs an instance of GetScreenshot.
|
|
891
|
-
* @param {MimeType} mimeType - The output format.
|
|
892
|
-
* @param {{ x: number; y: number }} [size] - Optional size in pixels.
|
|
893
|
-
*/
|
|
894
|
-
constructor(mimeType: MimeType, size?: {
|
|
895
|
-
x: number;
|
|
896
|
-
y: number;
|
|
897
|
-
});
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
/**
|
|
901
|
-
* @deprecated, use {@link GetScreenshot} instead.
|
|
902
|
-
*/
|
|
903
|
-
declare const GetFastRender: typeof GetScreenshot;
|
|
904
|
-
|
|
905
756
|
/**
|
|
906
757
|
* Represents a command to send to unreal and reset camera to initial.
|
|
907
758
|
* @remarks
|
|
@@ -1051,6 +902,40 @@ declare class StopShowcase extends CommandBase {
|
|
|
1051
902
|
constructor();
|
|
1052
903
|
}
|
|
1053
904
|
|
|
905
|
+
/**
|
|
906
|
+
* Image format.
|
|
907
|
+
* @remarks
|
|
908
|
+
* This type represents the allowed image formats.
|
|
909
|
+
*/
|
|
910
|
+
type MimeType = 'image/png' | 'image/jpeg' | 'image/webp';
|
|
911
|
+
/**
|
|
912
|
+
* Represents a command to get a screenshot.
|
|
913
|
+
*
|
|
914
|
+
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
|
|
915
|
+
*
|
|
916
|
+
* @example
|
|
917
|
+
* import { GetScreenshot, Communicator, saveImage } from '@3dsource/metabox-front-api';
|
|
918
|
+
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
919
|
+
* // Listen for events from to the Metabox API
|
|
920
|
+
* api.addEventListener('screenshot', (data) => {
|
|
921
|
+
* // Process the get screenshot response
|
|
922
|
+
* saveImage(data, 'Render.png');
|
|
923
|
+
* });
|
|
924
|
+
* api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
|
|
925
|
+
* };
|
|
926
|
+
*/
|
|
927
|
+
declare class GetScreenshot extends CommandBase {
|
|
928
|
+
/**
|
|
929
|
+
* Constructs an instance of GetScreenshot.
|
|
930
|
+
* @param {MimeType} mimeType - The output format.
|
|
931
|
+
* @param {{ x: number; y: number }} [size] - Optional size in pixels.
|
|
932
|
+
*/
|
|
933
|
+
constructor(mimeType: MimeType, size?: {
|
|
934
|
+
x: number;
|
|
935
|
+
y: number;
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
|
|
1054
939
|
/**
|
|
1055
940
|
* Represents a command to set a product by its ID.
|
|
1056
941
|
*
|
|
@@ -1206,5 +1091,5 @@ declare class WatchCallbacks extends CommandBase {
|
|
|
1206
1091
|
constructor();
|
|
1207
1092
|
}
|
|
1208
1093
|
|
|
1209
|
-
export { ApplyZoom, CommandBase, Communicator, EventDispatcher, GetCallToActionInformation,
|
|
1210
|
-
export type { ApplicationDeviceTypes, ConfiguratorEnvelope, Cta,
|
|
1094
|
+
export { AppLoaded, ApplyZoom, CommandBase, Communicator, EventDispatcher, GetCallToActionInformation, GetPdf, GetScreenshot, InitShowcase, MetaboxBasicConfiguratorActions, MetaboxConfig, MetaboxData_V2, MetaboxHost_V2, Metabox_V2, PauseShowcase, PlayShowcase, ResetCamera, SetEnvironment, SetEnvironmentMaterial, SetMaterial, SetProduct, ShowEmbeddedMenu, ShowOverlayInterface, StopShowcase, UnrealCommand, WatchCallbacks, fromCommunicatorEvent, getUrlParams, integrateMetaBox, saveImage, setUrlParams };
|
|
1095
|
+
export type { ApplicationDeviceTypes, ConfiguratorEnvelope, Cta, EcomConfigurator, Environment, FromMetaBoxAPIEnvelope, FromMetaBoxApiEvents, FromMetaBoxMessage, FromMetaboxApiAction, FromMetaboxMessagePayloads, Listener, MCAppLoaded, Material, MetaBoxApiEnvelope, MetaProperty, MimeType, Product, SelectedIds, ShowCaseStatus, Showcase, Slot, Thumbnail, Timecode, ToMetaBoxActions, ToMetaBoxMessage, ToMetaBoxMessageEnvelope, ToMetaboxMessagePayload, ToMetaboxMessagePayloads, UniversalConfigurator, UniversalConfiguratorEnvironment, UniversalConfiguratorProduct, VideoResolution };
|