@3dsource/metabox-front-api 2.0.1-dev.0 → 2.0.2

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 CHANGED
@@ -17,6 +17,7 @@ their material slots, and materials, environments.
17
17
  - [Command Classes](#command-classes)
18
18
  - [Event Handling](#event-handling)
19
19
  - [Utility Functions](#utility-functions)
20
+ - [Standalone Mode](#standalone-mode)
20
21
  - [Examples](#examples)
21
22
  - [Best Practices](#best-practices)
22
23
  - [Troubleshooting](#troubleshooting)
@@ -39,6 +40,8 @@ their material slots, and materials, environments.
39
40
  - HTTPS connection (required for unreal engine)
40
41
  - Valid Metabox basic configurator URL
41
42
 
43
+ Important: integrateMetaBox validates inputs at runtime. It requires a non-empty HTTPS URL for iframeSrc and a non-empty containerId. An error will be thrown if these are invalid.
44
+
42
45
  ## Installation
43
46
 
44
47
  ### Method 1: NPM Package (Recommended)
@@ -46,7 +49,7 @@ their material slots, and materials, environments.
46
49
  For use with frameworks like Angular, React, Vue, etc.:
47
50
 
48
51
  ```bash
49
- npm install @3dsource/metabox-front-api@^1.2.4 --save
52
+ npm install @3dsource/metabox-front-api@^2.0.1 --save
50
53
  ```
51
54
 
52
55
  Then import the required components:
@@ -59,7 +62,7 @@ import { integrateMetaBox, Communicator, ConfiguratorEnvelope, SetProduct, SetMa
59
62
 
60
63
  Alternative CDN options:
61
64
 
62
- - **jsDelivr**: `https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@^1.2.4/+esm`
65
+ - **jsDelivr**: `https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@^2.0.1/+esm`
63
66
 
64
67
  For quick prototyping or vanilla JavaScript projects:
65
68
 
@@ -103,12 +106,12 @@ Create a container element where the Metabox Configurator will be embedded:
103
106
 
104
107
  ```html
105
108
  <script type="module">
106
- import { integrateMetaBox, SetProduct, SetMaterial, SetEnvironment, GetScreenshot, saveImage } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@1.2.4';
109
+ import { integrateMetaBox, SetProduct, SetMaterial, SetEnvironment, GetScreenshot, saveImage } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@2.0.1/+esm';
107
110
 
108
111
  class MetaboxIntegrator {
109
112
  constructor() {
110
113
  // Replace 'your-configurator-id' with your actual basic configurator ID
111
- const configuratorUrl = 'https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id?sidebar=false';
114
+ const configuratorUrl = 'https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id';
112
115
 
113
116
  // Initialize the configurator
114
117
  integrateMetaBox(configuratorUrl, 'embed3DSource', (api) => {
@@ -175,7 +178,7 @@ class MetaboxIntegrator {
175
178
  private async initialize(): Promise<void> {
176
179
  try {
177
180
  // Replace 'your-configurator-id' with your actual configurator ID
178
- const configuratorUrl = 'https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id?sidebar=false';
181
+ const configuratorUrl = 'https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id';
179
182
 
180
183
  // Initialize the configurator with type safety
181
184
  integrateMetaBox(configuratorUrl, 'embed3DSource', (api: Communicator) => {
@@ -323,7 +326,12 @@ Integrates the Metabox configurator into the specified container element.
323
326
  **TypeScript Signature:**
324
327
 
325
328
  ```typescript
326
- function integrateMetaBox(configuratorUrl: string, containerId: string, apiReadyCallback: (api: Communicator) => void): void;
329
+ function integrateMetaBox(
330
+ configuratorUrl: string,
331
+ containerId: string,
332
+ apiReadyCallback: (api: Communicator) => void,
333
+ config?: Partial<MetaboxCommandConfig>
334
+ ): void;
327
335
  ```
328
336
 
329
337
  **Parameters:**
@@ -331,6 +339,7 @@ function integrateMetaBox(configuratorUrl: string, containerId: string, apiReady
331
339
  - `configuratorUrl` (string): The URL of your Metabox basic configurator
332
340
  - `containerId` (string): The ID of the HTML element where the configurator will be embedded
333
341
  - `apiReadyCallback` (function): Callback function that receives the Communicator API instance
342
+ - `config` (Partial<MetaboxCommandConfig>, optional): Initial configuration for the integration. Set `standalone: true` to disable Metabox’s built-in UI/template logic and control everything from the host app. Other fields like `hostUrl` and `apiVersion` are populated automatically.
334
343
 
335
344
  **Example:**
336
345
 
@@ -373,7 +382,7 @@ interface ToMetaboxMessagePayloads {
373
382
  };
374
383
  [MetaboxBasicConfiguratorActions.resetCamera]: void;
375
384
  [MetaboxBasicConfiguratorActions.applyZoom]: { zoom: number };
376
- [MetaboxBasicConfiguratorActions.initShowcase]: { productId: string };
385
+ [MetaboxBasicConfiguratorActions.initShowcase]: void;
377
386
  [MetaboxBasicConfiguratorActions.playShowcase]: void;
378
387
  [MetaboxBasicConfiguratorActions.pauseShowcase]: void;
379
388
  [MetaboxBasicConfiguratorActions.stopShowcase]: void;
@@ -437,20 +446,34 @@ api.sendCommandToMetaBox(new ApplyZoom(zoom));
437
446
 
438
447
  #### Interface Controls
439
448
 
440
- ##### `ShowEmbeddedMenu`
449
+ ##### `ShowEmbeddedMenu(visible)`
450
+
451
+ Controls the visibility of the embedded configurator menu (right sidebar).
452
+
453
+ Parameters:
454
+
455
+ - `visible` (boolean): `true` to show the built-in menu; `false` to hide it.
441
456
 
442
- Toggles the visibility of the embedded menu in the configurator.
457
+ Examples:
443
458
 
444
459
  ```typescript
445
- api.sendCommandToMetaBox(new ShowEmbeddedMenu(visible));
460
+ api.sendCommandToMetaBox(new ShowEmbeddedMenu(true)); // Show menu
461
+ api.sendCommandToMetaBox(new ShowEmbeddedMenu(false)); // Hide menu
446
462
  ```
447
463
 
448
- ##### `ShowOverlayInterface`
464
+ ##### `ShowOverlayInterface(visible)`
449
465
 
450
- Toggles the overlay interface over the Unreal viewport.
466
+ Controls the visibility of the overlay interface over the Unreal viewport (e.g., on‑viewport buttons, tooltips, hotspots).
467
+
468
+ Parameters:
469
+
470
+ - `visible` (boolean): `true` to show the overlay; `false` to hide it.
471
+
472
+ Examples:
451
473
 
452
474
  ```typescript
453
- api.sendCommandToMetaBox(new ShowOverlayInterface(visible));
475
+ api.sendCommandToMetaBox(new ShowOverlayInterface(true)); // Show overlay
476
+ api.sendCommandToMetaBox(new ShowOverlayInterface(false)); // Hide overlay
454
477
  ```
455
478
 
456
479
  #### Media Generation
@@ -502,10 +525,10 @@ Example backend response expected by Metabox:
502
525
 
503
526
  ##### `InitShowcase`
504
527
 
505
- Initializes a showcase with the given showcase ID.
528
+ Initializes a showcase with current product on scene.
506
529
 
507
530
  ```typescript
508
- api.sendCommandToMetaBox(new InitShowcase(showcaseId));
531
+ api.sendCommandToMetaBox(new InitShowcase());
509
532
  ```
510
533
 
511
534
  ##### `PlayShowcase`
@@ -1238,7 +1261,7 @@ interface ConfiguratorState {
1238
1261
  <div class="controls-title">Configurator Controls:</div>
1239
1262
  <div class="controls-buttons">
1240
1263
  <button (click)="changeProduct('541f46ab-a86c-48e3-bcfa-f92341483db3')" [disabled]="!_state.isApiReady" class="control-button">Product Change</button>
1241
- <button (click)="initShowcase('685e656f-32e4-4a63-a9f3-bf3c9e440906')" [disabled]="!_state.isApiReady" class="control-button">Init showcase</button>
1264
+ <button (click)="initShowcase()" [disabled]="!_state.isApiReady" class="control-button">Init showcase</button>
1242
1265
  <button (click)="stopShowcase()" [disabled]="!_state.isApiReady" class="control-button">Stop showcase</button>
1243
1266
  <button (click)="playShowcase()" [disabled]="!_state.isApiReady" class="control-button">Play showcase</button>
1244
1267
  <button (click)="pauseShowcase()" [disabled]="!_state.isApiReady" class="control-button">Pause showcase</button>
@@ -1423,15 +1446,14 @@ export class MetaboxConfiguratorComponent implements OnInit {
1423
1446
  }
1424
1447
  }
1425
1448
 
1426
- initShowcase(productId: string): void {
1449
+ initShowcase(): void {
1427
1450
  if (!this.state().isApiReady || !this.api) {
1428
1451
  console.warn('API not ready yet');
1429
1452
  return;
1430
1453
  }
1431
1454
 
1432
1455
  try {
1433
- console.log(`Init showcase for product: ${productId}`);
1434
- this.api.sendCommandToMetaBox(new InitShowcase(productId));
1456
+ this.api.sendCommandToMetaBox(new InitShowcase());
1435
1457
  } catch (error) {
1436
1458
  this.handleError(`Failed to init showcase for product: ${this.getErrorMessage(error)}`);
1437
1459
  }
@@ -1959,3 +1981,61 @@ We're always looking to improve the API. Feel free to suggest new features or en
1959
1981
  ---
1960
1982
 
1961
1983
  **Need help?** Contact our support team or check our documentation for more detailed guides and tutorials.
1984
+
1985
+
1986
+ ## Standalone Mode
1987
+
1988
+ Standalone mode lets you embed the Metabox renderer without the built‑in Metabox UI and template logic. This is ideal when you want to build a fully custom UI (menus, buttons, flows) and drive the configurator entirely through this API.
1989
+
1990
+ When standalone is enabled, the embedded page does not render Metabox’s internal menus, overlays, or template logic. You are responsible for sending commands (e.g., setProduct, setMaterial, setEnvironment) and listening to events to keep your UI in sync.
1991
+
1992
+ Key points:
1993
+ - Purpose: use when you need a 100% custom interface and logic on the host page.
1994
+ - Behavior: Metabox default UI, embedded menu and template logic are disabled on the iframe side.
1995
+ - Control: you drive everything with API commands and events.
1996
+ - Availability: supported since v2 of the API (example versions ≥ 2.0.1).
1997
+
1998
+ How to enable
1999
+
2000
+ Pass the 4th argument config with standalone set to true when calling integrateMetaBox.
2001
+
2002
+ TypeScript example:
2003
+
2004
+ ```typescript
2005
+ import { integrateMetaBox, Communicator, SetProduct, SetEnvironment } from '@3dsource/metabox-front-api';
2006
+
2007
+ integrateMetaBox(
2008
+ 'https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id',
2009
+ 'embed3DSource',
2010
+ (api: Communicator) => {
2011
+ // Send your initial commands to establish state
2012
+ api.sendCommandToMetaBox(new SetProduct('your-product-id'));
2013
+ api.sendCommandToMetaBox(new SetEnvironment('your-environment-id'));
2014
+ },
2015
+ { standalone: true }
2016
+ );
2017
+ ```
2018
+
2019
+ JavaScript (CDN) example:
2020
+
2021
+ ```html
2022
+ <script type="module">
2023
+ import { integrateMetaBox, SetProduct, SetEnvironment } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@2.0.1/+esm';
2024
+
2025
+ integrateMetaBox(
2026
+ 'https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id',
2027
+ 'embed3DSource',
2028
+ (api) => {
2029
+ api.sendCommandToMetaBox(new SetProduct('your-product-id'));
2030
+ api.sendCommandToMetaBox(new SetEnvironment('your-environment-id'));
2031
+ },
2032
+ { standalone: true }
2033
+ );
2034
+ </script>
2035
+ ```
2036
+
2037
+ Notes and tips
2038
+
2039
+ - In standalone mode, nothing will change until you send initial commands (e.g., set product/environment). If you see a blank/default view, ensure you dispatch the necessary SetProduct/SetEnvironment commands once api is ready.
2040
+ - All events (like configuratorDataUpdated, screenshotReady) still work; use them to keep your UI synchronized.
2041
+ - Runtime validation still applies: use an HTTPS URL and a valid containerId. The config.hostUrl and config.apiVersion are set automatically by the library; you typically don’t need to pass them.
@@ -16,12 +16,12 @@ function fromCommunicatorEvent(target, eventName) {
16
16
  }
17
17
 
18
18
  const MetaboxBasicConfiguratorActions = {
19
- loadLevel: 'loadLevel',
19
+ metaboxConfig: 'metaboxConfig',
20
+ setEnvironment: 'setEnvironment',
20
21
  setEnvironmentMaterialById: 'setEnvironmentMaterialById',
21
22
  setProduct: 'setProduct',
22
23
  setMaterialById: 'setMaterialById',
23
24
  getPdf: 'getPdf',
24
- metaboxConfig: 'metaboxConfig',
25
25
  getCallToActionInformation: 'getCallToActionInformation',
26
26
  getScreenshot: 'getScreenshot',
27
27
  showEmbeddedMenu: 'showEmbeddedMenu',
@@ -182,19 +182,20 @@ class ApplyZoom extends CommandBase {
182
182
  * ```typescript
183
183
  * import { InitShowcase, Communicator } from '@3dsource/metabox-front-api';
184
184
  * window.env3DSource.apiReady = (api: Communicator) => {
185
- * api.sendCommandToMetaBox(new InitShowcase('ffea6b5c-3a8a-4f56-9417-e605acb5cca3'));
185
+ * api.sendCommandToMetaBox(new InitShowcase());
186
186
  * };
187
187
  */
188
188
  class InitShowcase extends CommandBase {
189
189
  /**
190
190
  * Creates an instance of InitShowcase.
191
- * @param {string} productId - The unique identifier for the product
191
+ *
192
+ * @remarks
193
+ * This constructor does not require any parameters.
192
194
  */
193
- constructor(productId) {
195
+ constructor() {
194
196
  super();
195
197
  this.data = {
196
198
  action: MetaboxBasicConfiguratorActions.initShowcase,
197
- payload: { productId },
198
199
  };
199
200
  }
200
201
  }
@@ -405,7 +406,7 @@ class SetEnvironment extends CommandBase {
405
406
  constructor(environmentId) {
406
407
  super();
407
408
  this.data = {
408
- action: MetaboxBasicConfiguratorActions.loadLevel,
409
+ action: MetaboxBasicConfiguratorActions.setEnvironment,
409
410
  payload: { id: environmentId },
410
411
  };
411
412
  }
@@ -569,7 +570,8 @@ const Metabox_V2 = 'metabox_v2';
569
570
  const MetaboxHost_V2 = 'metaboxHost_v2';
570
571
  const MetaboxData_V2 = 'metaboxData_v2';
571
572
  const AppLoaded_V2 = 'appLoaded_v2';
572
- const IframeEmbeddedContent = 'embeddedContent';
573
+
574
+ const VERSION = '2.0.2';
573
575
 
574
576
  const communicatorMap = new Map();
575
577
  /**
@@ -587,15 +589,16 @@ class Communicator extends EventDispatcher {
587
589
  * Bound handler for incoming postMessage events.
588
590
  */
589
591
  this.binder = this.handleMessageReceived.bind(this, MetaboxData_V2);
590
- const { appId = 'legacy', version = '1.2.6' } = data ?? {};
592
+ const { appId = 'unknown', version = VERSION } = data ?? {};
591
593
  const key = `${version}_${environment}_${appId}`;
592
594
  communicatorMap.get(key)?.instance.destroy(key);
593
- communicatorMap.set(key, {
594
- instance: this,
595
- config: config ?? { standalone: false },
596
- });
595
+ communicatorMap.set(key, { instance: this });
597
596
  window.addEventListener('message', this.binder);
598
- this.sendCommandToMetaBox(new MetaboxConfig(appId, config));
597
+ this.sendCommandToMetaBox(new MetaboxConfig(appId, {
598
+ ...config,
599
+ hostUrl: location.href,
600
+ apiVersion: VERSION,
601
+ }));
599
602
  }
600
603
  /**
601
604
  * Listens for Metabox to signal readiness, then initializes communicator.
@@ -606,8 +609,8 @@ class Communicator extends EventDispatcher {
606
609
  static createInstance(apiReadyCallback, environment, config) {
607
610
  const startHandler = (event) => {
608
611
  const message = event.data;
609
- if (message?.envelope?.action === 'appLoaded_v2' &&
610
- message.host === 'metabox_v2') {
612
+ if (message?.envelope?.action === AppLoaded_V2 &&
613
+ message.host === Metabox_V2) {
611
614
  apiReadyCallback(new Communicator(message.envelope.payload, environment, config));
612
615
  window.removeEventListener('message', startHandler);
613
616
  }
@@ -696,10 +699,9 @@ class Communicator extends EventDispatcher {
696
699
  * @param {string} iframeSrc - The source URL of the Metabox iframe.
697
700
  * Additional url parameters:
698
701
  * ```javascript
699
- * sidebar=false - disables the internal Metabox menu
700
702
  * introImage=https://example.com/image.png - sets the intro image
701
703
  * ```
702
- * 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
704
+ * i.e., a final link will look like https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id?introImage=https://example.com/image.png
703
705
  *
704
706
  * @param {string} containerId - The ID of the layout element. Defaults to 'embed3DSource'.
705
707
  * @param apiReadyCallback - Callback after communicator will be created.
@@ -712,11 +714,28 @@ class Communicator extends EventDispatcher {
712
714
  * } from '@3dsource/metabox-front-api';
713
715
  *
714
716
  * integrateMetaBox(
715
- * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
717
+ * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp',
716
718
  * 'embed3DSource'
717
719
  * );
718
720
  */
719
721
  function integrateMetaBox(iframeSrc, containerId = 'embed3DSource', apiReadyCallback, config) {
722
+ // Basic validation of input data to prevent invalid embeds
723
+ if (typeof iframeSrc !== 'string' || !iframeSrc.trim()) {
724
+ throw new Error('integrateMetaBox: iframeSrc must be a non-empty string URL');
725
+ }
726
+ let parsedUrl;
727
+ try {
728
+ parsedUrl = new URL(iframeSrc);
729
+ }
730
+ catch (e) {
731
+ throw new Error('integrateMetaBox: Provided iframeSrc is not a valid URL');
732
+ }
733
+ if (parsedUrl.protocol !== 'https:') {
734
+ throw new Error('integrateMetaBox: iframeSrc must use HTTPS protocol');
735
+ }
736
+ if (typeof containerId !== 'string' || !containerId.trim()) {
737
+ throw new Error('integrateMetaBox: containerId must be a non-empty string');
738
+ }
720
739
  const container = document.getElementById(containerId);
721
740
  if (!container) {
722
741
  throw new Error(`Container element with id ${containerId} not found`);
@@ -803,5 +822,5 @@ function getUrlParams() {
803
822
  * Generated bundle index. Do not edit.
804
823
  */
805
824
 
806
- export { AppLoaded_V2, ApplyZoom, CommandBase, Communicator, EventDispatcher, GetCallToActionInformation, GetPdf, GetScreenshot, IframeEmbeddedContent, 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 };
825
+ export { AppLoaded_V2, 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, VERSION, WatchCallbacks, fromCommunicatorEvent, getUrlParams, integrateMetaBox, saveImage, setUrlParams };
807
826
  //# 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/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 // eslint-disable-next-line @typescript-eslint/no-unused-vars\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_V2 = 'appLoaded_v2';\nexport const IframeEmbeddedContent = 'embeddedContent';\n","import { EventDispatcher } from './EventDispatcher';\nimport { CommandBase, MetaboxConfig } from '../actions';\nimport {\n FromMetaBoxApiEvents,\n FromMetaBoxMessage,\n FromMetaboxMessagePayloads,\n MCAppLoaded,\n MetaboxEnvironment,\n} from '../interfaces';\nimport { Metabox_V2, MetaboxData_V2, MetaboxHost_V2 } from '../constants';\nimport { MetaboxCommandConfig } from '../interfaces/metabox-config';\n\nconst communicatorMap = new Map<\n string,\n { instance: Communicator; config: MetaboxCommandConfig }\n>();\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(\n data: MCAppLoaded['payload'],\n environment: MetaboxEnvironment,\n config?: MetaboxCommandConfig,\n ) {\n super();\n const { appId = 'legacy', version = '1.2.6' } = data ?? {};\n const key = `${version}_${environment}_${appId}`;\n communicatorMap.get(key)?.instance.destroy(key);\n communicatorMap.set(key, {\n instance: this,\n config: config ?? { standalone: false },\n });\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 {MetaboxEnvironment} environment - The environment in which the Communicator is running.\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 environment: MetaboxEnvironment,\n config?: MetaboxCommandConfig,\n ): void {\n const startHandler = (event: MessageEvent): void => {\n const message = event.data as FromMetaBoxMessage;\n if (\n message?.envelope?.action === 'appLoaded_v2' &&\n message.host === 'metabox_v2'\n ) {\n apiReadyCallback(\n new Communicator(message.envelope.payload, environment, 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 super.destroy(key);\n window.removeEventListener('message', this.binder);\n }\n\n static clearAll() {\n if (communicatorMap.size === 0) {\n return;\n }\n\n communicatorMap.forEach((value, key) => value.instance.destroy(key));\n communicatorMap.clear();\n }\n\n static getCommunicator(key: string) {\n return communicatorMap.get(key);\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;\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, 'host', 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,OAAO,SAAS,CAAC,MAAM,EAAE,SAAS,CAEjC;AACH;;AChBO,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,aAAa,EAAE,eAAe;AAC9B,IAAA,0BAA0B,EAAE,4BAA4B;AACxD,IAAA,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;AAC1C,IAA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"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/constants/version.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';\nimport { MetaboxCommandConfig } from './metabox-config';\n\nexport const MetaboxBasicConfiguratorActions = {\n metaboxConfig: 'metaboxConfig',\n setEnvironment: 'setEnvironment',\n setEnvironmentMaterialById: 'setEnvironmentMaterialById',\n setProduct: 'setProduct',\n setMaterialById: 'setMaterialById',\n getPdf: 'getPdf',\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.metaboxConfig]: {\n appId: string;\n config: MetaboxCommandConfig;\n };\n [MetaboxBasicConfiguratorActions.setProduct]: { productId: string };\n [MetaboxBasicConfiguratorActions.setEnvironment]: { id: string };\n [MetaboxBasicConfiguratorActions.getPdf]: void;\n [MetaboxBasicConfiguratorActions.getCallToActionInformation]: void;\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]: void;\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 {\n MetaboxBasicConfiguratorActions,\n MetaboxCommandConfig,\n} from '../interfaces';\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());\n * };\n */\nexport class InitShowcase extends CommandBase {\n /**\n * Creates an instance of InitShowcase.\n *\n * @remarks\n * This constructor does not require any parameters.\n */\n constructor() {\n super();\n this.data = {\n action: MetaboxBasicConfiguratorActions.initShowcase,\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.setEnvironment,\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 // eslint-disable-next-line @typescript-eslint/no-unused-vars\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_V2 = 'appLoaded_v2';\n","export const VERSION = '2.0.2';\n","import { EventDispatcher } from './EventDispatcher';\nimport { CommandBase, MetaboxConfig } from '../actions';\nimport {\n FromMetaBoxApiEvents,\n FromMetaBoxMessage,\n FromMetaboxMessagePayloads,\n MCAppLoaded,\n MetaboxCommandConfig,\n MetaboxEnvironment,\n} from '../interfaces';\nimport {\n AppLoaded_V2,\n Metabox_V2,\n MetaboxData_V2,\n MetaboxHost_V2,\n VERSION,\n} from '../constants';\n\nconst communicatorMap = new Map<string, { instance: 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(\n data: MCAppLoaded['payload'],\n environment: MetaboxEnvironment,\n config?: Partial<MetaboxCommandConfig>,\n ) {\n super();\n const { appId = 'unknown', version = VERSION } = data ?? {};\n const key = `${version}_${environment}_${appId}`;\n communicatorMap.get(key)?.instance.destroy(key);\n communicatorMap.set(key, { instance: this });\n window.addEventListener('message', this.binder);\n this.sendCommandToMetaBox(\n new MetaboxConfig(appId, {\n ...config,\n hostUrl: location.href,\n apiVersion: VERSION,\n }),\n );\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 {MetaboxEnvironment} environment - The environment in which the Communicator is running.\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 environment: MetaboxEnvironment,\n config?: Partial<MetaboxCommandConfig>,\n ): void {\n const startHandler = (event: MessageEvent): void => {\n const message = event.data as FromMetaBoxMessage;\n if (\n message?.envelope?.action === AppLoaded_V2 &&\n message.host === Metabox_V2\n ) {\n apiReadyCallback(\n new Communicator(message.envelope.payload, environment, 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 super.destroy(key);\n window.removeEventListener('message', this.binder);\n }\n\n static clearAll() {\n if (communicatorMap.size === 0) {\n return;\n }\n\n communicatorMap.forEach((value, key) => value.instance.destroy(key));\n communicatorMap.clear();\n }\n\n static getCommunicator(key: string) {\n return communicatorMap.get(key);\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;\n this.dispatchEvent(data?.eventType as T, data?.payload);\n }\n}\n","import { Communicator } from './Communicator';\nimport { MetaboxCommandConfig } from '../interfaces';\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 * 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?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',\n * 'embed3DSource'\n * );\n */\nexport function integrateMetaBox(\n iframeSrc: string,\n containerId = 'embed3DSource',\n apiReadyCallback: (api: Communicator) => void,\n config?: Partial<MetaboxCommandConfig>,\n): void {\n // Basic validation of input data to prevent invalid embeds\n if (typeof iframeSrc !== 'string' || !iframeSrc.trim()) {\n throw new Error(\n 'integrateMetaBox: iframeSrc must be a non-empty string URL',\n );\n }\n let parsedUrl: URL;\n try {\n parsedUrl = new URL(iframeSrc);\n } catch (e) {\n throw new Error('integrateMetaBox: Provided iframeSrc is not a valid URL');\n }\n if (parsedUrl.protocol !== 'https:') {\n throw new Error('integrateMetaBox: iframeSrc must use HTTPS protocol');\n }\n if (typeof containerId !== 'string' || !containerId.trim()) {\n throw new Error('integrateMetaBox: containerId must be a non-empty string');\n }\n\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, 'host', 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,OAAO,SAAS,CAAC,MAAM,EAAE,SAAS,CAEjC;AACH;;ACfO,MAAM,+BAA+B,GAAG;AAC7C,IAAA,aA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ts CHANGED
@@ -6,17 +6,24 @@ declare const Metabox_V2 = "metabox_v2";
6
6
  declare const MetaboxHost_V2 = "metaboxHost_v2";
7
7
  declare const MetaboxData_V2 = "metaboxData_v2";
8
8
  declare const AppLoaded_V2 = "appLoaded_v2";
9
- declare const IframeEmbeddedContent = "embeddedContent";
9
+
10
+ declare const VERSION = "2.0.2";
10
11
 
11
12
  type FromMetaboxApiAction = 'bridge' | typeof AppLoaded_V2;
12
13
 
14
+ interface MetaboxCommandConfig {
15
+ standalone?: boolean;
16
+ hostUrl: string;
17
+ apiVersion: string;
18
+ }
19
+
13
20
  declare const MetaboxBasicConfiguratorActions: {
14
- readonly loadLevel: "loadLevel";
21
+ readonly metaboxConfig: "metaboxConfig";
22
+ readonly setEnvironment: "setEnvironment";
15
23
  readonly setEnvironmentMaterialById: "setEnvironmentMaterialById";
16
24
  readonly setProduct: "setProduct";
17
25
  readonly setMaterialById: "setMaterialById";
18
26
  readonly getPdf: "getPdf";
19
- readonly metaboxConfig: "metaboxConfig";
20
27
  readonly getCallToActionInformation: "getCallToActionInformation";
21
28
  readonly getScreenshot: "getScreenshot";
22
29
  readonly showEmbeddedMenu: "showEmbeddedMenu";
@@ -41,14 +48,18 @@ type ToMetaboxMessagePayload = ToMetaboxMessagePayloads[keyof ToMetaboxMessagePa
41
48
  * Interface for messages sent from the application to the Basic Metabox API.
42
49
  */
43
50
  interface ToMetaboxMessagePayloads {
44
- [MetaboxBasicConfiguratorActions.getPdf]: void;
45
- [MetaboxBasicConfiguratorActions.getCallToActionInformation]: void;
46
- [MetaboxBasicConfiguratorActions.loadLevel]: {
47
- id: string;
51
+ [MetaboxBasicConfiguratorActions.metaboxConfig]: {
52
+ appId: string;
53
+ config: MetaboxCommandConfig;
48
54
  };
49
55
  [MetaboxBasicConfiguratorActions.setProduct]: {
50
56
  productId: string;
51
57
  };
58
+ [MetaboxBasicConfiguratorActions.setEnvironment]: {
59
+ id: string;
60
+ };
61
+ [MetaboxBasicConfiguratorActions.getPdf]: void;
62
+ [MetaboxBasicConfiguratorActions.getCallToActionInformation]: void;
52
63
  [MetaboxBasicConfiguratorActions.watchCallbacks]: void;
53
64
  [MetaboxBasicConfiguratorActions.getScreenshot]: {
54
65
  format: MimeType;
@@ -78,9 +89,7 @@ interface ToMetaboxMessagePayloads {
78
89
  [MetaboxBasicConfiguratorActions.applyZoom]: {
79
90
  zoom: number;
80
91
  };
81
- [MetaboxBasicConfiguratorActions.initShowcase]: {
82
- productId: string;
83
- };
92
+ [MetaboxBasicConfiguratorActions.initShowcase]: void;
84
93
  [MetaboxBasicConfiguratorActions.playShowcase]: void;
85
94
  [MetaboxBasicConfiguratorActions.pauseShowcase]: void;
86
95
  [MetaboxBasicConfiguratorActions.stopShowcase]: void;
@@ -562,10 +571,6 @@ declare class EventDispatcher {
562
571
  removeEventListener(messageType: string, callback: (data: unknown) => void): this;
563
572
  }
564
573
 
565
- interface MetaboxCommandConfig {
566
- standalone: boolean;
567
- }
568
-
569
574
  /**
570
575
  * Handles messaging between the host page and embedded Metabox content.
571
576
  * @internal Use {@link Communicator.createInstance} or the {@link integrateMetaBox} helper to instantiate.
@@ -579,14 +584,14 @@ declare class Communicator extends EventDispatcher {
579
584
  * Constructs a Communicator, replacing any existing instance, and begins listening for messages.
580
585
  * @internal
581
586
  */
582
- constructor(data: MCAppLoaded['payload'], environment: MetaboxEnvironment, config?: MetaboxCommandConfig);
587
+ constructor(data: MCAppLoaded['payload'], environment: MetaboxEnvironment, config?: Partial<MetaboxCommandConfig>);
583
588
  /**
584
589
  * Listens for Metabox to signal readiness, then initializes communicator.
585
590
  * @param apiReadyCallback - Called with the new Communicator once to the Metabox is loaded.
586
591
  * @param {MetaboxEnvironment} environment - The environment in which the Communicator is running.
587
592
  * @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic
588
593
  */
589
- static createInstance(apiReadyCallback: (api: Communicator) => void, environment: MetaboxEnvironment, config?: MetaboxCommandConfig): void;
594
+ static createInstance(apiReadyCallback: (api: Communicator) => void, environment: MetaboxEnvironment, config?: Partial<MetaboxCommandConfig>): void;
590
595
  /**
591
596
  * Cleans up resources and stops listening for messages.
592
597
  */
@@ -594,7 +599,6 @@ declare class Communicator extends EventDispatcher {
594
599
  static clearAll(): void;
595
600
  static getCommunicator(key: string): {
596
601
  instance: Communicator;
597
- config: MetaboxCommandConfig;
598
602
  } | undefined;
599
603
  /**
600
604
  * Posts a command to the Metabox iframe.
@@ -634,10 +638,9 @@ declare class Communicator extends EventDispatcher {
634
638
  * @param {string} iframeSrc - The source URL of the Metabox iframe.
635
639
  * Additional url parameters:
636
640
  * ```javascript
637
- * sidebar=false - disables the internal Metabox menu
638
641
  * introImage=https://example.com/image.png - sets the intro image
639
642
  * ```
640
- * 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
643
+ * i.e., a final link will look like https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id?introImage=https://example.com/image.png
641
644
  *
642
645
  * @param {string} containerId - The ID of the layout element. Defaults to 'embed3DSource'.
643
646
  * @param apiReadyCallback - Callback after communicator will be created.
@@ -650,11 +653,11 @@ declare class Communicator extends EventDispatcher {
650
653
  * } from '@3dsource/metabox-front-api';
651
654
  *
652
655
  * integrateMetaBox(
653
- * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
656
+ * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp',
654
657
  * 'embed3DSource'
655
658
  * );
656
659
  */
657
- declare function integrateMetaBox(iframeSrc: string, containerId: string | undefined, apiReadyCallback: (api: Communicator) => void, config?: MetaboxCommandConfig): void;
660
+ declare function integrateMetaBox(iframeSrc: string, containerId: string | undefined, apiReadyCallback: (api: Communicator) => void, config?: Partial<MetaboxCommandConfig>): void;
658
661
 
659
662
  /**
660
663
  * Saves an image by triggering a download.
@@ -705,7 +708,7 @@ declare class MetaboxConfig extends CommandBase {
705
708
  * @param {string} appId - The unique identifier for the Communicator Instance
706
709
  * @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic
707
710
  */
708
- constructor(appId: string, config?: MetaboxCommandConfig);
711
+ constructor(appId: string, config: MetaboxCommandConfig);
709
712
  }
710
713
 
711
714
  /**
@@ -816,15 +819,17 @@ declare class ApplyZoom extends CommandBase {
816
819
  * ```typescript
817
820
  * import { InitShowcase, Communicator } from '@3dsource/metabox-front-api';
818
821
  * window.env3DSource.apiReady = (api: Communicator) => {
819
- * api.sendCommandToMetaBox(new InitShowcase('ffea6b5c-3a8a-4f56-9417-e605acb5cca3'));
822
+ * api.sendCommandToMetaBox(new InitShowcase());
820
823
  * };
821
824
  */
822
825
  declare class InitShowcase extends CommandBase {
823
826
  /**
824
827
  * Creates an instance of InitShowcase.
825
- * @param {string} productId - The unique identifier for the product
828
+ *
829
+ * @remarks
830
+ * This constructor does not require any parameters.
826
831
  */
827
- constructor(productId: string);
832
+ constructor();
828
833
  }
829
834
 
830
835
  /**
@@ -1094,5 +1099,5 @@ declare class WatchCallbacks extends CommandBase {
1094
1099
  constructor();
1095
1100
  }
1096
1101
 
1097
- export { AppLoaded_V2, ApplyZoom, CommandBase, Communicator, EventDispatcher, GetCallToActionInformation, GetPdf, GetScreenshot, IframeEmbeddedContent, 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 };
1098
- export type { ApplicationDeviceTypes, ConfiguratorEnvelope, Cta, EcomConfigurator, Environment, FromMetaBoxAPIEnvelope, FromMetaBoxApiEvents, FromMetaBoxMessage, FromMetaboxApiAction, FromMetaboxMessagePayloads, Listener, MCAppLoaded, Material, MetaBoxApiEnvelope, MetaProperty, MetaboxEnvironment, MimeType, Product, SelectedIds, ShowCaseStatus, Showcase, Slot, Thumbnail, Timecode, ToMetaBoxActions, ToMetaBoxMessage, ToMetaBoxMessageEnvelope, ToMetaboxMessagePayload, ToMetaboxMessagePayloads, UniversalConfigurator, UniversalConfiguratorEnvironment, UniversalConfiguratorProduct, VideoResolution };
1102
+ export { AppLoaded_V2, 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, VERSION, WatchCallbacks, fromCommunicatorEvent, getUrlParams, integrateMetaBox, saveImage, setUrlParams };
1103
+ export type { ApplicationDeviceTypes, ConfiguratorEnvelope, Cta, EcomConfigurator, Environment, FromMetaBoxAPIEnvelope, FromMetaBoxApiEvents, FromMetaBoxMessage, FromMetaboxApiAction, FromMetaboxMessagePayloads, Listener, MCAppLoaded, Material, MetaBoxApiEnvelope, MetaProperty, MetaboxCommandConfig, MetaboxEnvironment, MimeType, Product, SelectedIds, ShowCaseStatus, Showcase, Slot, Thumbnail, Timecode, ToMetaBoxActions, ToMetaBoxMessage, ToMetaBoxMessageEnvelope, ToMetaboxMessagePayload, ToMetaboxMessagePayloads, UniversalConfigurator, UniversalConfiguratorEnvironment, UniversalConfiguratorProduct, VideoResolution };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@3dsource/metabox-front-api",
3
- "version": "2.0.1-dev.0",
3
+ "version": "2.0.2",
4
4
  "description": "API for Metabox BASIC configurator",
5
5
  "keywords": [
6
6
  "metabox",