@3dsource/metabox-front-api 3.0.14 → 3.0.16-dev.1

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.
@@ -2,14 +2,18 @@ import { fromEvent } from 'rxjs';
2
2
 
3
3
  /**
4
4
  * Base class for commands sent to the Metabox API.
5
+ * @internal
6
+ * @hidden
5
7
  */
6
8
  class CommandBase {
7
9
  }
8
10
 
9
11
  /**
10
12
  * Wrapper helper function to use it with rxJs the same as `fromEvent` to listen to events from the Communicator.
13
+ *
11
14
  * @param {Communicator} target
12
15
  * @param eventName
16
+ * @internal
13
17
  */
14
18
  function fromCommunicatorEvent(target, eventName) {
15
19
  return fromEvent(target, eventName);
@@ -36,7 +40,6 @@ const MetaboxBasicConfiguratorActions = {
36
40
  pauseShowcase: 'pauseShowcase',
37
41
  stopShowcase: 'stopShowcase',
38
42
  sendCommandToUnreal: 'sendCommandToUnreal',
39
- watchCallbacks: 'watchCallbacks',
40
43
  showMeasurement: 'showMeasurement',
41
44
  hideMeasurement: 'hideMeasurement',
42
45
  };
@@ -44,6 +47,9 @@ const MetaboxBasicConfiguratorActions = {
44
47
  /**
45
48
  * Represents a command to send Metabox Config to Metabox Basic Configurator.
46
49
  * @remarks
50
+ * **Important**: No need to listen to any events to see changes.
51
+ *
52
+ * @internal
47
53
  * Automatically sent when the Communicator instance is ready.
48
54
  */
49
55
  class MetaboxConfig extends CommandBase {
@@ -65,12 +71,13 @@ class MetaboxConfig extends CommandBase {
65
71
  * Represents a command to get a PDF from Metabox Basic Configurator.
66
72
  * @remarks
67
73
  * This class sends a message to the Metabox API to generate a PDF based on the current configuration.
68
- * This action does not require any parameters.
69
- *
74
+ * **Important**: No need to listen to any events to see changes.
70
75
  * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
71
76
  *
72
77
  * @example
73
78
  * import { GetPdf, Communicator } from '@3dsource/metabox-front-api';
79
+ *
80
+ * @param {Communicator} api - communicator instance api
74
81
  * window.env3DSource.apiReady = (api: Communicator) => {
75
82
  * api.sendCommandToMetabox(new GetPdf());
76
83
  * };
@@ -91,13 +98,27 @@ class GetPdf extends CommandBase {
91
98
  /**
92
99
  * Represents a command to get a Call To Action Information from Metabox Basic Configurator.
93
100
  * @remarks
94
- * 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.
95
- * This action does not require any parameters.
101
+ * 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.
102
+ *
103
+ * To listen for changes after sending this command, listen to the 'ecomConfiguratorDataUpdated' event.
104
+ * //...Assume that the integration is already implemented (only once)
105
+ * @example
106
+ * import { Communicator } from '@3dsource/metabox-front-api';
107
+ *
108
+ * @param {Communicator} api - communicator instance api
109
+ * window.env3DSource.apiReady = (api: Communicator) => {
110
+ * @param {EcomConfigurator} data - description for all ecom configurator params
111
+ * api.addEventListener('ecomConfiguratorDataUpdated', (data) => {
112
+ * console.log('Ecom configurator params:', data);
113
+ * });
114
+ * };
96
115
  *
97
116
  * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
98
117
  *
99
118
  * @example
100
119
  * import { GetCallToActionInformation, Communicator } from '@3dsource/metabox-front-api';
120
+ *
121
+ * @param {Communicator} api - communicator instance api
101
122
  * window.env3DSource.apiReady = (api: Communicator) => {
102
123
  * api.sendCommandToMetabox(new GetCallToActionInformation());
103
124
  * };
@@ -118,15 +139,28 @@ class GetCallToActionInformation extends CommandBase {
118
139
  }
119
140
 
120
141
  /**
121
- * Represents a command to send to unreal and get the camera from unreal to api.
142
+ * Represents a command to get the camera configuration from Unreal.
122
143
  * @remarks
123
144
  * This class sends a message to the Metabox API to get the camera from a scene.
124
- * This action does not require any parameters.
145
+ *
146
+ * To listen for changes after sending this command, listen to the 'getCameraResult' event.
147
+ * //...Assume that the integration is already implemented (only once)
148
+ * @example
149
+ * import { Communicator } from '@3dsource/metabox-front-api';
150
+ *
151
+ * @param {Communicator} api - communicator instance api
152
+ * window.env3DSource.apiReady = (api: Communicator) => {
153
+ * @param {CameraCommandPayload} data - camera params
154
+ * api.addEventListener('getCameraResult', (data) => {
155
+ * console.log('Camera params after get camera command:', data);
156
+ * });
157
+ * };
125
158
  *
126
159
  * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
127
160
  *
128
161
  * @example
129
162
  * import { GetCamera, Communicator } from '@3dsource/metabox-front-api';
163
+ * @param {Communicator} api - communicator instance api
130
164
  * window.env3DSource.apiReady = (api: Communicator) => {
131
165
  * api.sendCommandToMetabox(new GetCamera());
132
166
  * };
@@ -145,14 +179,15 @@ class GetCamera extends CommandBase {
145
179
  }
146
180
 
147
181
  /**
148
- * Represents a command to send to unreal and set camera to need.
182
+ * Represents a command to set the camera configuration.
149
183
  * @remarks
150
184
  * This class sends a message to the Metabox API to set the camera on a scene.
151
- *
185
+ * **Important**: No need to listen to any events to see changes.
152
186
  * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
153
187
  *
154
188
  * @example
155
- * import { ResetCamera, Communicator } from '@3dsource/metabox-front-api';
189
+ * import { SetCamera, Communicator } from '@3dsource/metabox-front-api';
190
+ * @param {Communicator} api - communicator instance api
156
191
  * window.env3DSource.apiReady = (api: Communicator) => {
157
192
  * api.sendCommandToMetabox(new SetCamera({
158
193
  * fov: 45,
@@ -176,8 +211,7 @@ class SetCamera extends CommandBase {
176
211
  /**
177
212
  * Creates an instance of SetCamera.
178
213
  *
179
- * @remarks
180
- * @param {CameraCommandPayload} camera - camera config
214
+ * @param {CameraCommandPayload} camera - The camera configuration.
181
215
  */
182
216
  constructor(camera) {
183
217
  super();
@@ -189,15 +223,15 @@ class SetCamera extends CommandBase {
189
223
  }
190
224
 
191
225
  /**
192
- * Represents a command to send to unreal and reset camera to initial.
226
+ * Represents a command to reset the camera to its initial position.
193
227
  * @remarks
194
228
  * This class sends a message to the Metabox API to reset the camera on a scene.
195
- * This action does not require any parameters.
196
- *
229
+ * **Important**: No need to listen to any events to see changes.
197
230
  * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
198
231
  *
199
232
  * @example
200
233
  * import { ResetCamera, Communicator } from '@3dsource/metabox-front-api';
234
+ * @param {Communicator} api - communicator instance api
201
235
  * window.env3DSource.apiReady = (api: Communicator) => {
202
236
  * api.sendCommandToMetabox(new ResetCamera());
203
237
  * };
@@ -216,14 +250,16 @@ class ResetCamera extends CommandBase {
216
250
  }
217
251
 
218
252
  /**
219
- * Represents a command to ApplyZoom and change zoom camera on a scene.
253
+ * Represents a command to apply zoom and change the camera zoom on a scene.
220
254
  * @remarks
221
255
  * This class sends a command to the Metabox API to change zoom on a scene.
222
- *
256
+ * **Important**: No need to listen to any events to see changes.
223
257
  * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
224
258
  *
225
259
  * @example
226
260
  * import { ApplyZoom, Communicator } from '@3dsource/metabox-front-api';
261
+ *
262
+ * @param {Communicator} api - communicator instance api
227
263
  * window.env3DSource.apiReady = (api: Communicator) => {
228
264
  * api.sendCommandToMetabox(new ApplyZoom(10));
229
265
  * api.sendCommandToMetabox(new ApplyZoom(-10));
@@ -233,7 +269,7 @@ class ApplyZoom extends CommandBase {
233
269
  /**
234
270
  * Creates an instance of ApplyZoom.
235
271
  *
236
- * @param {...number} zoom
272
+ * @param {number} zoom - The zoom value to apply.
237
273
  */
238
274
  constructor(zoom) {
239
275
  super();
@@ -245,17 +281,43 @@ class ApplyZoom extends CommandBase {
245
281
  }
246
282
 
247
283
  /**
248
- * Represents a command to Init Showcase for a product a scene and start a sequence for the product.
284
+ * Represents a command to initialize Showcase for a product scene and start a sequence for the product.
249
285
  * @remarks
250
- * This class sends a command to the Metabox API to init showcase if the product has a sequence.
251
- * For check this needs to find a showcase property in the current product.
252
- * If this property exists, you can send init showcase command.
286
+ * This class sends a command to the Metabox API to initialize showcase if the product has a sequence.
287
+ * To check this, find the showcase property in the current product and listen to the 'configuratorDataUpdated' event.
288
+ * //...Assume that the integration is already implemented (only once)
289
+ * @example
290
+ * import { Communicator } from '@3dsource/metabox-front-api';
291
+ *
292
+ * @param {Communicator} api - communicator instance api
293
+ * window.env3DSource.apiReady = (api: Communicator) => {
294
+ * @param {ConfiguratorEnvelope} data - configurator state after updated
295
+ * api.addEventListener('configuratorDataUpdated', (data) => {
296
+ * console.log('State updated after applied new environment:', data);
297
+ * });
298
+ * };
299
+ *
300
+ * If this property exists, you can send the init showcase command.
301
+ *
302
+ * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.
303
+ * //...Assume that the integration is already implemented (only once)
304
+ * @example
305
+ * import { Communicator } from '@3dsource/metabox-front-api';
306
+ *
307
+ * @param {Communicator} api - communicator instance api
308
+ * window.env3DSource.apiReady = (api: Communicator) => {
309
+ * @param {ShowCaseStatus} data - showcase status value
310
+ * api.addEventListener('showcaseStatusChanged', (data) => {
311
+ * console.log('Showcase status value after changed:', data);
312
+ * });
313
+ * };
253
314
  *
254
315
  * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
255
316
  *
256
317
  * @example
257
- * ```typescript
258
318
  * import { InitShowcase, Communicator } from '@3dsource/metabox-front-api';
319
+ *
320
+ * @param {Communicator} api - communicator instance api
259
321
  * window.env3DSource.apiReady = (api: Communicator) => {
260
322
  * api.sendCommandToMetabox(new InitShowcase());
261
323
  * };
@@ -276,14 +338,29 @@ class InitShowcase extends CommandBase {
276
338
  }
277
339
 
278
340
  /**
279
- * Represents a command to Play Showcase for a product when it already init, and you call pause, for example, before it.
341
+ * Represents a command to play Showcase for a product when it is already initialized and paused.
280
342
  * @remarks
281
- * This class sends a command to the Metabox API to play showcase for a product if it is already initialized and pause.
343
+ * This class sends a command to the Metabox API to play showcase for a product if it is already initialized and paused.
344
+ *
345
+ * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.
346
+ * //...Assume that the integration is already implemented (only once)
347
+ * @example
348
+ * import { Communicator } from '@3dsource/metabox-front-api';
349
+ *
350
+ * @param {Communicator} api - communicator instance api
351
+ * window.env3DSource.apiReady = (api: Communicator) => {
352
+ * @param {ShowCaseStatus} data - showcase status value
353
+ * api.addEventListener('showcaseStatusChanged', (data) => {
354
+ * console.log('Showcase status value after changed:', data);
355
+ * });
356
+ * };
282
357
  *
283
358
  * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
284
359
  *
285
360
  * @example
286
361
  * import { PlayShowcase, Communicator } from '@3dsource/metabox-front-api';
362
+ *
363
+ * @param {Communicator} api - communicator instance api
287
364
  * window.env3DSource.apiReady = (api: Communicator) => {
288
365
  * api.sendCommandToMetabox(new PlayShowcase());
289
366
  * };
@@ -317,14 +394,29 @@ class UnrealCommand extends CommandBase {
317
394
  }
318
395
 
319
396
  /**
320
- * Represents a command to Pause Showcase for a product when it already init and play, and you call pause.
397
+ * Represents a command to pause Showcase for a product when it is already initialized and playing.
321
398
  * @remarks
322
- * This class sends a command to the Metabox API to pause showcase for a product if it is already initialized and play.
399
+ * This class sends a command to the Metabox API to pause showcase for a product if it is already initialized and playing.
400
+ *
401
+ * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.
402
+ * //...Assume that the integration is already implemented (only once)
403
+ * @example
404
+ * import { Communicator } from '@3dsource/metabox-front-api';
405
+ *
406
+ * @param {Communicator} api - communicator instance api
407
+ * window.env3DSource.apiReady = (api: Communicator) => {
408
+ * @param {ShowCaseStatus} data - showcase status value
409
+ * api.addEventListener('showcaseStatusChanged', (data) => {
410
+ * console.log('Showcase status value after changed:', data);
411
+ * });
412
+ * };
323
413
  *
324
414
  * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
325
415
  *
326
416
  * @example
327
417
  * import { PauseShowcase, Communicator } from '@3dsource/metabox-front-api';
418
+ *
419
+ * @param {Communicator} api - communicator instance api
328
420
  * window.env3DSource.apiReady = (api: Communicator) => {
329
421
  * api.sendCommandToMetabox(new PauseShowcase());
330
422
  * };
@@ -343,14 +435,29 @@ class PauseShowcase extends CommandBase {
343
435
  }
344
436
 
345
437
  /**
346
- * Represents a command to Stop Showcase for a product when it already init, and you want to destroy it.
438
+ * Represents a command to stop Showcase for a product when it is already initialized, and you want to destroy it.
347
439
  * @remarks
348
- * This class sends a command to the Metabox API to Stop showcase for a product if it is already initialized.
440
+ * This class sends a command to the Metabox API to stop showcase for a product if it is already initialized.
441
+ *
442
+ * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.
443
+ * //...Assume that the integration is already implemented (only once)
444
+ * @example
445
+ * import { Communicator } from '@3dsource/metabox-front-api';
446
+ *
447
+ * @param {Communicator} api - communicator instance api
448
+ * window.env3DSource.apiReady = (api: Communicator) => {
449
+ * @param {ShowCaseStatus} data - showcase status value
450
+ * api.addEventListener('showcaseStatusChanged', (data) => {
451
+ * console.log('Showcase status value after changed:', data);
452
+ * });
453
+ * };
349
454
  *
350
455
  * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
351
456
  *
352
457
  * @example
353
458
  * import { StopShowcase, Communicator } from '@3dsource/metabox-front-api';
459
+ *
460
+ * @param {Communicator} api - communicator instance api
354
461
  * window.env3DSource.apiReady = (api: Communicator) => {
355
462
  * api.sendCommandToMetabox(new StopShowcase());
356
463
  * };
@@ -370,17 +477,28 @@ class StopShowcase extends CommandBase {
370
477
 
371
478
  /**
372
479
  * Represents a command to get a screenshot.
373
- *
374
480
  * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
375
481
  *
482
+ * @remarks
483
+ * To listen for changes after sending this command, listen to the 'screenshot' event.
484
+ * //...Assume that the integration is already implemented (only once)
485
+ * @example
486
+ * import { Communicator } from '@3dsource/metabox-front-api';
487
+ *
488
+ * @param {Communicator} api - communicator instance api
489
+ * window.env3DSource.apiReady = (api: Communicator) => {
490
+ * @param {string} data - base64 string image
491
+ * api.addEventListener('screenshot', (data) => {
492
+ * console.log('Get screenshot here:', data);
493
+ * saveImage(data, 'Render.png');
494
+ * });
495
+ * };
496
+ *
376
497
  * @example
377
498
  * import { GetScreenshot, Communicator, saveImage } from '@3dsource/metabox-front-api';
499
+ *
500
+ * @param {Communicator} api - communicator instance api
378
501
  * window.env3DSource.apiReady = (api: Communicator) => {
379
- * // Listen for events from to the Metabox API
380
- * api.addEventListener('screenshot', (data) => {
381
- * // Process the get screenshot response
382
- * saveImage(data, 'Render.png');
383
- * });
384
502
  * api.sendCommandToMetabox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
385
503
  * };
386
504
  */
@@ -405,10 +523,23 @@ class GetScreenshot extends CommandBase {
405
523
  * @remarks
406
524
  * This action sends a message to the Metabox API to set a product using the provided product ID.
407
525
  *
526
+ * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.
527
+ * //...Assume that the integration is already implemented (only once)
528
+ * @example
529
+ * import { Communicator } from '@3dsource/metabox-front-api';
530
+ *
531
+ * @param {Communicator} api - communicator instance api
532
+ * window.env3DSource.apiReady = (api: Communicator) => {
533
+ * @param {ConfiguratorEnvelope} data - configurator state after updated
534
+ * api.addEventListener('configuratorDataUpdated', (data) => {
535
+ * console.log('State updated after applied new product:', data);
536
+ * });
537
+ * };
538
+ *
408
539
  * @example
409
540
  * import { SetProduct, Communicator } from '@3dsource/metabox-front-api';
410
541
  *
411
- * //...Assume that the integration is already implemented
542
+ * @param {Communicator} api - communicator instance api
412
543
  * window.env3DSource.apiReady = (api: Communicator) => {
413
544
  * api.setCommandToMetaBox(new SetProduct(
414
545
  * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3'
@@ -433,10 +564,25 @@ class SetProduct extends CommandBase {
433
564
  /**
434
565
  * Represents a command to set a material by its slot ID and Material ID.
435
566
  *
567
+ * @remarks
568
+ * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.
569
+ * //...Assume that the integration is already implemented (only once)
570
+ *
571
+ * @example
572
+ * import { Communicator } from '@3dsource/metabox-front-api';
573
+ *
574
+ * @param {Communicator} api - communicator instance api
575
+ * window.env3DSource.apiReady = (api: Communicator) => {
576
+ * @param {ConfiguratorEnvelope} data - configurator state after updated
577
+ * api.addEventListener('configuratorDataUpdated', (data) => {
578
+ * console.log('State updated after applied new material:', data);
579
+ * });
580
+ * };
581
+ *
436
582
  * @example
437
583
  * import { SetProductMaterial, Communicator } from '@3dsource/metabox-front-api';
438
584
  *
439
- * //...Assume that the integration is already implemented
585
+ * @param {Communicator} api - communicator instance api
440
586
  * window.env3DSource.apiReady = (api: Communicator) => {
441
587
  * api.sendCommandToMetabox(new SetProductMaterial(
442
588
  * 'carpaint',
@@ -463,12 +609,25 @@ class SetProductMaterial extends CommandBase {
463
609
  /**
464
610
  * Represents a command to set the environment by its ID.
465
611
  *
612
+ * @remarks
613
+ * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.
614
+ * //...Assume that the integration is already implemented (only once)
615
+ * @example
616
+ * import { Communicator } from '@3dsource/metabox-front-api';
617
+ *
618
+ * @param {Communicator} api - communicator instance api
619
+ * window.env3DSource.apiReady = (api: Communicator) => {
620
+ * @param {ConfiguratorEnvelope} data - configurator state after updated
621
+ * api.addEventListener('configuratorDataUpdated', (data) => {
622
+ * console.log('State updated after applied new environment:', data);
623
+ * });
624
+ * };
625
+ *
466
626
  * @example
467
627
  * import { SetEnvironment, Communicator } from '@3dsource/metabox-front-api';
468
628
  *
469
- * //...Assume that the integration is already implemented
629
+ * @param {Communicator} api - communicator instance api
470
630
  * window.env3DSource.apiReady = (api: Communicator) => {
471
- * // Change the environment to '55555555-1234-1234-1234-01234567890'
472
631
  * api.sendCommandToMetabox(new SetEnvironment('55555555-1234-1234-1234-01234567890'));
473
632
  * };
474
633
  */
@@ -490,10 +649,24 @@ class SetEnvironment extends CommandBase {
490
649
  /**
491
650
  * Represents a command to set an environment material by its slot ID and Material ID.
492
651
  *
652
+ * @remarks
653
+ * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.
654
+ * //...Assume that the integration is already implemented (only once)
655
+ * @example
656
+ * import { Communicator } from '@3dsource/metabox-front-api';
657
+ *
658
+ * @param {Communicator} api - communicator instance api
659
+ * window.env3DSource.apiReady = (api: Communicator) => {
660
+ * @param {ConfiguratorEnvelope} data - configurator state after updated
661
+ * api.addEventListener('configuratorDataUpdated', (data) => {
662
+ * console.log('State updated after applied new environment material:', data);
663
+ * });
664
+ * };
665
+ *
493
666
  * @example
494
667
  * import { SetEnvironmentMaterial, Communicator } from '@3dsource/metabox-front-api';
495
668
  *
496
- * //...Assume that the integration is already implemented
669
+ * @param {Communicator} api - communicator instance api
497
670
  * window.env3DSource.apiReady = (api: Communicator) => {
498
671
  * api.sendCommandToMetabox(new SetEnvironmentMaterial(
499
672
  * 'carpaint',
@@ -518,14 +691,17 @@ class SetEnvironmentMaterial extends CommandBase {
518
691
  }
519
692
 
520
693
  /**
521
- * Represents a command to toggle the Embedded to the Metabox Menu.
694
+ * Represents a command to toggle the embedded Metabox menu.
695
+ * @remarks
696
+ * This command can only be used when using the metabox menu.
697
+ * **Important**: No need to listen to any events to see changes.
522
698
  *
523
699
  * @example
524
700
  * import { ShowEmbeddedMenu, Communicator } from '@3dsource/metabox-front-api';
525
701
  *
526
- * //...Assume that the integration is already implemented
702
+ * @param {Communicator} api - communicator instance api
527
703
  * window.env3DSource.apiReady = (api: Communicator) => {
528
- * api.setCommandToMetaBox(new ShowEmbeddedMenu(true));
704
+ * api.sendCommandToMetabox(new ShowEmbeddedMenu(true));
529
705
  * };
530
706
  */
531
707
  class ShowEmbeddedMenu extends CommandBase {
@@ -548,11 +724,12 @@ class ShowEmbeddedMenu extends CommandBase {
548
724
  *
549
725
  * @remarks
550
726
  * This action sends a message to the Metabox API to toggle the visibility of the Unreal overlay UI.
727
+ * **Important**: No need to listen to any events to see changes.
551
728
  *
552
729
  * @example
553
730
  * import { ShowOverlayInterface, Communicator } from '@3dsource/metabox-front-api';
554
731
  *
555
- * //...Assume that the integration is already implemented
732
+ * @param {Communicator} api - communicator instance api
556
733
  * window.env3DSource.apiReady = (api: Communicator) => {
557
734
  * api.setCommandToMetaBox(new ShowOverlayInterface(true));
558
735
  * };
@@ -573,42 +750,23 @@ class ShowOverlayInterface extends CommandBase {
573
750
  }
574
751
 
575
752
  /**
576
- * @experimental
577
- * @internal
578
- * @hidden
579
- * @remarks
580
- * Represents a command to watch Unreal callbacks from Unreal engine.
581
- * Can be useful for custom solutions.
582
- */
583
- class WatchCallbacks extends CommandBase {
584
- /**
585
- * Creates an instance of WatchCallbacks.
586
- *
587
- * @remarks
588
- * This constructor does not require any parameters.
589
- */
590
- constructor() {
591
- super();
592
- this.data = { action: MetaboxBasicConfiguratorActions.watchCallbacks };
593
- }
594
- }
595
-
596
- /**
597
- * Represents a command to Show Measurement for a product when it already loaded.
753
+ * Represents a command to show measurement for a product when it is already loaded.
598
754
  * @remarks
599
- * This class sends a command to the Metabox API to Show Measurement for a product if it is already initialized.
600
- *
755
+ * This class sends a command to the Metabox API to show measurement for a product if it is already initialized.
756
+ * **Important**: No need to listen to any events to see changes.
601
757
  * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
602
758
  *
603
759
  * @example
604
760
  * import { ShowMeasurement, Communicator } from '@3dsource/metabox-front-api';
761
+ *
762
+ * @param {Communicator} api - communicator instance api
605
763
  * window.env3DSource.apiReady = (api: Communicator) => {
606
764
  * api.sendCommandToMetabox(new ShowMeasurement());
607
765
  * };
608
766
  */
609
767
  class ShowMeasurement extends CommandBase {
610
768
  /**
611
- * Creates an instance of HideMeasurement.
769
+ * Creates an instance of ShowMeasurement.
612
770
  *
613
771
  * @remarks
614
772
  * This constructor does not require any parameters.
@@ -620,14 +778,16 @@ class ShowMeasurement extends CommandBase {
620
778
  }
621
779
 
622
780
  /**
623
- * Represents a command to Hide Measurement for a product when it already loaded.
781
+ * Represents a command to hide measurement for a product when it is already loaded.
624
782
  * @remarks
625
- * This class sends a command to the Metabox API to Hide Measurement for a product if it is already initialized.
626
- *
783
+ * This class sends a command to the Metabox API to hide measurement for a product if it is already initialized.
784
+ * **Important**: No need to listen to any events to see changes.
627
785
  * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
628
786
  *
629
787
  * @example
630
788
  * import { HideMeasurement, Communicator } from '@3dsource/metabox-front-api';
789
+ *
790
+ * @param {Communicator} api - communicator instance api
631
791
  * window.env3DSource.apiReady = (api: Communicator) => {
632
792
  * api.sendCommandToMetabox(new HideMeasurement());
633
793
  * };
@@ -649,12 +809,14 @@ class HideMeasurement extends CommandBase {
649
809
  * Represents a command to force set the device type.
650
810
  *
651
811
  * @remarks
652
- * This class sends a message to the Metabox API to force to set the device type.
812
+ * This class sends a message to the Metabox API to force set the device type.
813
+ * **Important**: No need to listen to any events to see changes.
814
+ * //...Assume that the integration is already implemented (only once)
653
815
  *
654
816
  * @example
655
817
  * import { ForceSetDeviceType, Communicator } from '@3dsource/metabox-front-api';
656
818
  *
657
- * //...Assume that the integration is already implemented
819
+ * @param {Communicator} api - communicator instance api
658
820
  * window.env3DSource.apiReady = (api: Communicator) => {
659
821
  * api.sendCommandToMetabox(new ForceSetDeviceType('desktop'));
660
822
  * };
@@ -722,21 +884,41 @@ class EventDispatcher {
722
884
  }
723
885
  }
724
886
 
887
+ /**
888
+ * @internal
889
+ * @hidden
890
+ * Represents main constants.
891
+ */
725
892
  const Metabox = 'metabox_v3';
726
893
  const MetaboxHost = 'metaboxHost_v3';
727
- const MetaboxData = 'metaboxData_v3';
728
894
  const AppLoaded = 'appLoaded_v3';
895
+ /**
896
+ * @deprecated
897
+ */
898
+ const Metabox_V3 = 'metabox_v3';
899
+ /**
900
+ * @deprecated
901
+ */
902
+ const MetaboxHost_V3 = 'metaboxHost_v3';
903
+ /**
904
+ * @deprecated
905
+ */
906
+ const AppLoaded_V3 = 'appLoaded_v3';
729
907
  const MetaboxDomain = 'metabox.3dsource.com';
730
908
  const BasicRouteUrl = 'metabox-configurator/basic';
731
909
 
732
- const VERSION = '3.0.14';
910
+ const VERSION = '3.0.16-dev.1';
733
911
 
734
912
  const communicatorMap = new Map();
735
913
  /**
736
- * Handles messaging between the host page and embedded Metabox content.
914
+ * Handles messaging between the host page and embedded to the Metabox content.
737
915
  * @internal Use {@link Communicator.createInstance} or the {@link integrateMetabox} helper to instantiate.
738
916
  */
739
917
  class Communicator extends EventDispatcher {
918
+ /**
919
+ * Singleton reference to the current communicator instance.
920
+ */
921
+ static { this.instance = null; }
740
922
  /**
741
923
  * Constructs a Communicator, replacing any existing instance, and begins listening for messages.
742
924
  * @internal
@@ -746,7 +928,7 @@ class Communicator extends EventDispatcher {
746
928
  /**
747
929
  * Bound handler for incoming postMessage events.
748
930
  */
749
- this.binder = this.handleMessageReceived.bind(this, MetaboxData);
931
+ this.binder = this.handleMessageReceived.bind(this);
750
932
  const { appId = 'unknown', version = VERSION } = data ?? {};
751
933
  const key = `${version}_${environment}_${appId}`;
752
934
  communicatorMap.get(key)?.instance.destroy(key);
@@ -760,9 +942,9 @@ class Communicator extends EventDispatcher {
760
942
  }
761
943
  /**
762
944
  * Listens for Metabox to signal readiness, then initializes communicator.
763
- * @param apiReadyCallback - Called with the new Communicator once to the Metabox is loaded.
945
+ * @param apiReadyCallback - Called with the new Communicator once the Metabox is loaded.
764
946
  * @param {MetaboxEnvironment} environment - The environment in which the Communicator is running.
765
- * @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic
947
+ * @param {MetaboxCommandConfig} config - Optional initial config: standalone - if true, disable metabox custom template and all logic.
766
948
  */
767
949
  static createInstance(apiReadyCallback, environment, config) {
768
950
  const startHandler = (event) => {
@@ -798,20 +980,23 @@ class Communicator extends EventDispatcher {
798
980
  sendCommandToMetabox(command) {
799
981
  const { data } = command;
800
982
  const iframe = document.getElementById('embeddedContent');
801
- const message = {
983
+ const toMetaboxMessage = {
802
984
  host: MetaboxHost,
985
+ envelope: { ...data },
803
986
  payload: { ...data },
987
+ target: iframe?.contentWindow ? 'child' : 'metabox',
988
+ apiVersion: VERSION,
804
989
  };
990
+ console.log('DEBUG sendCommandToMetabox: ', toMetaboxMessage, command);
805
991
  if (!iframe?.contentWindow) {
806
- console.warn('to the Metabox IFrame not found or not ready. Message sends to the same window');
807
- window.postMessage({ ...message, target: 'metabox' }, '*');
992
+ console.warn('Metabox IFrame not found or not ready. Message sends to the same window');
993
+ window.postMessage(toMetaboxMessage, '*');
808
994
  return;
809
995
  }
810
- // Replace '*' with a specific origin in production for better security.
811
- iframe.contentWindow.postMessage({ ...message, target: 'child' }, '*');
996
+ iframe.contentWindow.postMessage(toMetaboxMessage, '*');
812
997
  }
813
998
  /**
814
- * Registers an event listener for messages dispatched by to the Metabox.
999
+ * Registers an event listener for messages dispatched by the Metabox.
815
1000
  * @override
816
1001
  */
817
1002
  addEventListener(messageType, callback) {
@@ -832,13 +1017,11 @@ class Communicator extends EventDispatcher {
832
1017
  return super.removeEventListener(messageType, callback);
833
1018
  }
834
1019
  /**
835
- * Filters and dispatches incoming messages from to the Metabox.
836
- * @param {FromMetaBoxApiEvents | 'metaboxData' } messageType - Expected message type for filtering ('metaboxData').
1020
+ * Filters and dispatches incoming messages from the Metabox.
837
1021
  * @param {MessageEvent} event - The postMessage event received on a window.
838
1022
  */
839
- handleMessageReceived(messageType, event) {
840
- // Optionally validate event.origin for security.
841
- if (messageType !== MetaboxData || event.data?.host !== Metabox) {
1023
+ handleMessageReceived(event) {
1024
+ if (event.data?.host !== Metabox) {
842
1025
  return;
843
1026
  }
844
1027
  const data = event.data?.envelope;
@@ -846,6 +1029,15 @@ class Communicator extends EventDispatcher {
846
1029
  }
847
1030
  }
848
1031
 
1032
+ /**
1033
+ *
1034
+ * @remarks
1035
+ * @internal
1036
+ * @hidden
1037
+ *
1038
+ * @param {string} configuratorId - An string identifier for the configurator.
1039
+ * @param {IntegrateMetaboxConfig} config - An object containing the configuration options.
1040
+ */
849
1041
  const prepareIframeSrc = (configuratorId, config) => {
850
1042
  const base = `https://${config?.domain || MetaboxDomain}/${BasicRouteUrl}/${configuratorId}`;
851
1043
  const params = new URLSearchParams();
@@ -982,6 +1174,8 @@ function saveImage(imageUrl, filename) {
982
1174
  * Sets the URL parameters based on the provided state.
983
1175
  *
984
1176
  * @remarks
1177
+ * @internal
1178
+ * @hidden
985
1179
  * This function updates the current URL by replacing its search parameters with the key-value pairs from the provided state object.
986
1180
  *
987
1181
  * @param {Record<string, string>} state - An object containing key-value pairs to set as URL parameters.
@@ -998,6 +1192,8 @@ function setUrlParams(state) {
998
1192
  * Retrieves the URL parameters as an object.
999
1193
  *
1000
1194
  * @remarks
1195
+ * @internal
1196
+ * @hidden
1001
1197
  * This function parses the current URL's search parameters and returns them as a key-value object.
1002
1198
  *
1003
1199
  * @returns An object containing the URL parameters.
@@ -1015,5 +1211,5 @@ function getUrlParams() {
1015
1211
  * Generated bundle index. Do not edit.
1016
1212
  */
1017
1213
 
1018
- export { AppLoaded, ApplyZoom, BasicRouteUrl, CommandBase, Communicator, EventDispatcher, ForceSetDeviceType, GetCallToActionInformation, GetCamera, GetPdf, GetScreenshot, HideMeasurement, InitShowcase, Metabox, MetaboxBasicConfiguratorActions, MetaboxConfig, MetaboxData, MetaboxDomain, MetaboxHost, PauseShowcase, PlayShowcase, ResetCamera, SetCamera, SetEnvironment, SetEnvironmentMaterial, SetProduct, SetProductMaterial, ShowEmbeddedMenu, ShowMeasurement, ShowOverlayInterface, StopShowcase, UnrealCommand, VERSION, WatchCallbacks, fromCommunicatorEvent, getUrlParams, integrateMetabox, prepareIframeSrc, saveImage, setUrlParams };
1214
+ export { AppLoaded, AppLoaded_V3, ApplyZoom, BasicRouteUrl, CommandBase, Communicator, EventDispatcher, ForceSetDeviceType, GetCallToActionInformation, GetCamera, GetPdf, GetScreenshot, HideMeasurement, InitShowcase, Metabox, MetaboxBasicConfiguratorActions, MetaboxConfig, MetaboxDomain, MetaboxHost, MetaboxHost_V3, Metabox_V3, PauseShowcase, PlayShowcase, ResetCamera, SetCamera, SetEnvironment, SetEnvironmentMaterial, SetProduct, SetProductMaterial, ShowEmbeddedMenu, ShowMeasurement, ShowOverlayInterface, StopShowcase, UnrealCommand, VERSION, fromCommunicatorEvent, getUrlParams, integrateMetabox, prepareIframeSrc, saveImage, setUrlParams };
1019
1215
  //# sourceMappingURL=3dsource-metabox-front-api.mjs.map