@3dsource/metabox-modular-configurator-api 2.0.4 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,18 +9,49 @@ components, component types, materials, and capture screenshots or PDFs.
9
9
  - [Features](#features)
10
10
  - [Prerequisites](#prerequisites)
11
11
  - [Installation](#installation)
12
+ - [NPM Installation (Recommended)](#npm-installation-recommended)
13
+ - [CDN Installation](#cdn-installation)
12
14
  - [Quick Start](#quick-start)
15
+ - [1. HTML Setup](#1-html-setup)
16
+ - [2. Basic Integration](#2-basic-integration)
17
+ - [JavaScript (ES6 Modules)](#javascript-es6-modules)
18
+ - [TypeScript/Angular/React](#typescriptangularreact)
13
19
  - [API Reference](#api-reference)
14
20
  - [System Terminology](#system-terminology)
15
- - [Steps to build custom menu](#steps-to-build-custom-menu)
21
+ - [Steps to build a custom menu](#steps-to-build-a-custom-menu)
16
22
  - [Core Integration](#core-integration)
23
+ - [`integrateMetabox`](#integratemetabox)
17
24
  - [Type Definitions](#type-definitions)
25
+ - [Core Types](#core-types)
26
+ - [`Communicator`](#communicator)
27
+ - [`ModularConfiguratorEnvelope`](#modularconfiguratorenvelope)
28
+ - [`ModularConfiguratorComponent`](#modularconfiguratorcomponent)
29
+ - [`Material`](#material)
30
+ - [`Environment`](#environment)
31
+ - [Command Payload Types](#command-payload-types)
32
+ - [Utility Types](#utility-types)
33
+ - [`MimeType`](#mimetype)
34
+ - [`ApplicationDeviceTypes`](#applicationdevicetypes)
35
+ - [`Position` and `Rotation`](#position-and-rotation)
18
36
  - [Command Classes](#command-classes)
19
- - [Standalone Mode](#standalone-mode)
20
- - [Examples](#examples)
37
+ - [Core Configuration Commands](#core-configuration-commands)
38
+ - [UI / Interface](#ui--interface)
39
+ - [Camera / View](#camera--view)
40
+ - [Showcase Control](#showcase-control)
41
+ - [Export / Media](#export--media)
42
+ - [Unreal / Advanced](#unreal--advanced)
43
+ - [Internal Message Payload Shape (Excerpt)](#internal-message-payload-shape-excerpt)
21
44
  - [Event Handling](#event-handling)
45
+ - [Available Events](#available-events)
46
+ - [Event Examples](#event-examples)
22
47
  - [Troubleshooting](#troubleshooting)
23
- - [Contributing](#contributing)
48
+ - [Common Issues](#common-issues)
49
+ - [Configurator Not Loading](#configurator-not-loading)
50
+ - [Commands Not Working](#commands-not-working)
51
+ - [TypeScript Errors](#typescript-errors)
52
+ - [Performance Tips](#performance-tips)
53
+ - [Browser Compatibility](#browser-compatibility)
54
+ - [Standalone Mode](#standalone-mode)
24
55
 
25
56
  ## Features
26
57
 
@@ -37,9 +68,9 @@ components, component types, materials, and capture screenshots or PDFs.
37
68
 
38
69
  - Modern web browser with ES6 module support
39
70
  - HTTPS connection (required for Unreal Engine)
40
- - Valid Metabox modular configurator URL
71
+ - Valid Metabox configurator ID (not a full URL)
41
72
 
42
- Important: Use an HTTPS configurator URL and a valid container element ID. integrateMetabox will throw if the container element is not found.
73
+ Important: integrateMetabox validates inputs at runtime. It requires a non-empty configuratorId and a non-empty containerId. The iframe URL is constructed internally as `https://{domain}/metabox-configurator/modular/{configuratorId}` with optional query parameters (introImage, introVideo, loadingImage). HTTPS is enforced and non-HTTPS URLs are rejected. It will throw if the container element is not found.
43
74
 
44
75
  ## Installation
45
76
 
@@ -48,7 +79,7 @@ Important: Use an HTTPS configurator URL and a valid container element ID. integ
48
79
  For use with modern frameworks like Angular, React, Vue, etc.:
49
80
 
50
81
  ```bash
51
- npm install @3dsource/metabox-modular-configurator-api@^2.0.1 --save
82
+ npm install @3dsource/metabox-modular-configurator-api@latest --save
52
83
  ```
53
84
 
54
85
  ### CDN Installation
@@ -56,12 +87,12 @@ npm install @3dsource/metabox-modular-configurator-api@^2.0.1 --save
56
87
  For direct browser usage without a build system:
57
88
 
58
89
  ```javascript
59
- import { integrateMetabox, Communicator, SetEnvironment, SetComponent } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-modular-configurator-api@2.0.1/+esm';
90
+ import { integrateMetabox, Communicator, SetEnvironment, SetComponent } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-modular-configurator-api@latest/+esm';
60
91
  ```
61
92
 
62
93
  Alternative CDN options:
63
94
 
64
- - **jsDelivr**: `https://cdn.jsdelivr.net/npm/@3dsource/metabox-modular-configurator-api@^2.0.1/+esm`
95
+ - **jsDelivr**: `https://cdn.jsdelivr.net/npm/@3dsource/metabox-modular-configurator-api@latest/+esm`
65
96
 
66
97
  ## Quick Start
67
98
 
@@ -101,12 +132,12 @@ Create a container element where the configurator will be embedded:
101
132
 
102
133
  ```html
103
134
  <script type="module">
104
- import { GetPdf, GetScreenshot, GetCallToActionInformation, integrateMetabox, saveImage, SetComponent, SetComponentMaterial, SetEnvironment, SetEnvironmentMaterial, ShowEmbeddedMenu, ShowOverlayInterface, ResetCamera, ApplyZoom } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-modular-configurator-api@2.0.1/+esm';
135
+ import { GetPdf, GetScreenshot, GetCallToActionInformation, integrateMetabox, saveImage, SetComponent, SetComponentMaterial, SetEnvironment, SetEnvironmentMaterial, ShowEmbeddedMenu, ShowOverlayInterface, ResetCamera, ApplyZoom } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-modular-configurator-api@latest/+esm';
105
136
 
106
- // Replace it with your actual configurator URL
107
- const configuratorUrl = 'https://metabox.3dsource.com/metabox-configurator/modular/your-configurator-id';
137
+ // Replace it with your actual configurator ID (not a full URL)
138
+ const configuratorId = 'configurator-id';
108
139
 
109
- integrateMetabox(configuratorUrl, 'embed3DSource', (api) => {
140
+ integrateMetabox(configuratorId, 'embed3DSource', (api) => {
110
141
  console.log('Configurator API ready!');
111
142
 
112
143
  // Listen for configurator data updates
@@ -120,15 +151,15 @@ Create a container element where the configurator will be embedded:
120
151
  });
121
152
 
122
153
  // Set initial configuration
123
- api.sendCommandToMetaBox(new SetComponent('componentId', 'typeId', true));
124
- api.sendCommandToMetaBox(new SetEnvironment('environmentId'));
125
- api.sendCommandToMetaBox(new SetComponentMaterial('slotId', 'materialId'));
126
- api.sendCommandToMetaBox(new SetEnvironmentMaterial('slotId', 'materialId'));
127
- api.sendCommandToMetaBox(new ShowEmbeddedMenu(false));
128
- api.sendCommandToMetaBox(new ShowOverlayInterface(false));
129
- api.sendCommandToMetaBox(new GetPdf());
130
- api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
131
- api.sendCommandToMetaBox(new GetCallToActionInformation());
154
+ api.sendCommandToMetabox(new SetComponent('componentId', 'typeId', true));
155
+ api.sendCommandToMetabox(new SetEnvironment('environmentId'));
156
+ api.sendCommandToMetabox(new SetComponentMaterial('slotId', 'materialId'));
157
+ api.sendCommandToMetabox(new SetEnvironmentMaterial('slotId', 'materialId'));
158
+ api.sendCommandToMetabox(new ShowEmbeddedMenu(false));
159
+ api.sendCommandToMetabox(new ShowOverlayInterface(false));
160
+ api.sendCommandToMetabox(new GetPdf());
161
+ api.sendCommandToMetabox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
162
+ api.sendCommandToMetabox(new GetCallToActionInformation());
132
163
  });
133
164
  </script>
134
165
  ```
@@ -140,15 +171,15 @@ import { integrateMetabox, Communicator, ModularConfiguratorEnvelope, SetEnviron
140
171
 
141
172
  class ConfiguratorIntegration {
142
173
  private api: Communicator | null = null;
143
- private readonly configuratorUrl: string;
174
+ private readonly configuratorId: string;
144
175
 
145
- constructor(configuratorUrl: string) {
146
- this.configuratorUrl = configuratorUrl;
176
+ constructor(configuratorId: string) {
177
+ this.configuratorId = configuratorId;
147
178
  this.initialize();
148
179
  }
149
180
 
150
181
  private initialize(): void {
151
- integrateMetabox(this.configuratorUrl, 'embed3DSource', (api: Communicator) => {
182
+ integrateMetabox(this.configuratorId, 'embed3DSource', (api: Communicator) => {
152
183
  this.api = api;
153
184
  this.setupEventListeners();
154
185
  this.setupInitialState();
@@ -184,10 +215,10 @@ class ConfiguratorIntegration {
184
215
  if (!this.api) return;
185
216
 
186
217
  // Configure initial environment and components
187
- this.api.sendCommandToMetaBox(new SetEnvironment('default-environment'));
188
- this.api.sendCommandToMetaBox(new SetComponent('main-product', 'chair', true));
189
- this.api.sendCommandToMetaBox(new ShowOverlayInterface(true));
190
- this.api.sendCommandToMetaBox(new ShowEmbeddedMenu(true));
218
+ this.api.sendCommandToMetabox(new SetEnvironment('default-environment'));
219
+ this.api.sendCommandToMetabox(new SetComponent('main-product', 'chair', true));
220
+ this.api.sendCommandToMetabox(new ShowOverlayInterface(true));
221
+ this.api.sendCommandToMetabox(new ShowEmbeddedMenu(true));
191
222
  }
192
223
 
193
224
  private handleConfiguratorData(data: ModularConfiguratorEnvelope): void {
@@ -211,19 +242,19 @@ class ConfiguratorIntegration {
211
242
  // Public API methods
212
243
  public takeScreenshot(format: MimeType = 'image/png', size?: { x: number; y: number }): void {
213
244
  if (this.api) {
214
- this.api.sendCommandToMetaBox(new GetScreenshot(format, size));
245
+ this.api.sendCommandToMetabox(new GetScreenshot(format, size));
215
246
  }
216
247
  }
217
248
 
218
249
  public changeMaterial(slotId: string, materialId: string): void {
219
250
  if (this.api) {
220
- this.api.sendCommandToMetaBox(new SetComponentMaterialById(slotId, materialId));
251
+ this.api.sendCommandToMetabox(new SetComponentMaterial(slotId, materialId));
221
252
  }
222
253
  }
223
254
 
224
255
  public changeEnvironment(environmentId: string): void {
225
256
  if (this.api) {
226
- this.api.sendCommandToMetaBox(new SetEnvironment(environmentId));
257
+ this.api.sendCommandToMetabox(new SetEnvironment(environmentId));
227
258
  }
228
259
  }
229
260
 
@@ -234,7 +265,7 @@ class ConfiguratorIntegration {
234
265
  }
235
266
 
236
267
  // Usage example
237
- const configurator = new ConfiguratorIntegration('https://metabox.3dsource.com/metabox-configurator/modular/your-configurator-id');
268
+ const configurator = new ConfiguratorIntegration('configurator-id');
238
269
 
239
270
  // Take a high-resolution screenshot
240
271
  configurator.takeScreenshot('image/png', { x: 1920, y: 1080 });
@@ -270,45 +301,65 @@ configurator.changeMaterial('seat-fabric', 'leather-brown');
270
301
  - Your backend decides how to use the configuration JSON (e.g., generate a PDF or build a product list).
271
302
  - After your endpoint responds with a JSON containing "redirectUrl", the user is redirected in a new browser tab to that URL (a non‑Metabox page on your side) to complete the flow (e.g., leave contact information, proceed to checkout, etc.).
272
303
 
273
- ### Steps to build custom menu
304
+ ### Steps to build a custom menu
274
305
 
275
- - **configuratorDataUpdated** - add event listener to receive get configurator data and then updates
276
- - **showEmbeddedMenu** - hide embedded metabox right sidebar, but if you want to show it again, you can use this method
277
- - **showOverlayInterface** - hide viewport metabox actions if you want to add yours
278
- - **setEnvironment** - set active environment when you want to change environment
279
- - **setEnvironmentMaterialById** - set environment material by slot ID
280
- - **setComponentType** - set component type when you want to change component type !!!IMPORTANT!!!
281
- - **setComponent** - set active component
282
- - **setComponentMaterialById** - set component material by slot ID
283
- - **getScreenshot** - get screenshot
284
- - **getCallToActionInformation** - send call to action information to api endpoint provided in CTA configuration
285
- - **getPdf** - get PDF.
286
-
287
- ### Core Integration
306
+ Updated recommendations:
288
307
 
289
- #### `integrateMetabox(configuratorUrl, containerId, apiReadyCallback)`
308
+ - Use `configuratorDataUpdated` to hydrate custom UI and subscribe for deltas.
309
+ - Hide built‑in menu: `ShowEmbeddedMenu(false)`; restore with `ShowEmbeddedMenu(true)`.
310
+ - Hide overlay elements if replacing viewport controls: `ShowOverlayInterface(false)`.
311
+ - Switch component type before presenting a list of components: `SetComponentType(typeId)`.
290
312
 
291
- Integrates the Metabox modular configurator into the specified container.
313
+ ### Core Integration
292
314
 
293
- **Parameters:**
315
+ #### `integrateMetabox`
294
316
 
295
- - `configuratorUrl` (`string`): The URL of your Metabox configurator
296
- - `containerId` (`string`): The ID of the HTML element where the configurator will be embedded
297
- - `apiReadyCallback` (`(api: Communicator) => void`): Callback function that receives the API communicator instance
298
- - `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.
317
+ Integrates the Metabox Modular Configurator into the specified container element.
299
318
 
300
319
  **TypeScript Signature:**
301
320
 
302
321
  ```typescript
303
- function integrateMetabox(configuratorUrl: string, containerId: string, apiReadyCallback: (api: Communicator) => void, config?: Partial<MetaboxCommandConfig>): void;
322
+ function integrateMetabox(
323
+ configuratorId: string,
324
+ containerId: string, // defaults to 'embed3DSource'
325
+ apiReadyCallback: (api: Communicator) => void, // required
326
+ config?: IntegrateMetaboxConfig,
327
+ ): void;
304
328
  ```
305
329
 
330
+ **Parameters:**
331
+
332
+ - `configuratorId` (required): Modular configurator ID (not full URL). Iframe src internally: `https://{domain}/metabox-configurator/modular/{configuratorId}`.
333
+ - `containerId` (optional): Host element id (default `embed3DSource`).
334
+ - `apiReadyCallback` (required): Called once the embedded app signals readiness (`appLoaded_v2`).
335
+ - `config` (optional):
336
+ - `standalone?`: Disable built‑in template / UI logic inside iframe.
337
+ - `introImage?`, `introVideo?`, `loadingImage?`: Optional URLs appended as query params when present.
338
+ - `domain?`: Override default domain (HTTPS enforced).
339
+
340
+ **Throws:** Error if IDs empty, container missing, or computed iframe URL not HTTPS.
341
+
342
+ **Notes:** A previous iframe with id `embeddedContent` is removed before adding a new one.
343
+
306
344
  **Example:**
307
345
 
308
346
  ```typescript
309
- integrateMetabox('https://metabox.3dsource.com/metabox-configurator/modular/your-id', 'embed3DSource', (api) => {
310
- console.log('API ready!', api);
311
- });
347
+ import { IntegrateMetaboxConfig } from '@3dsource/metabox-modular-configurator-api';
348
+
349
+ const config: IntegrateMetaboxConfig = {
350
+ introImage: 'https://example.com/intro.png',
351
+ loadingImage: 'https://example.com/loading.png',
352
+ standalone: false,
353
+ };
354
+
355
+ integrateMetabox(
356
+ 'configurator-id',
357
+ 'embed3DSource',
358
+ (api) => {
359
+ console.log('API ready!', api);
360
+ },
361
+ config,
362
+ );
312
363
  ```
313
364
 
314
365
  ### Type Definitions
@@ -323,7 +374,7 @@ The main API interface for sending commands and listening to events.
323
374
 
324
375
  ```typescript
325
376
  interface Communicator {
326
- sendCommandToMetaBox<T extends keyof ToMetaboxMessagePayloads>(command: CommandBase<T>): void;
377
+ sendCommandToMetabox<T extends keyof ToMetaboxMessagePayloads>(command: CommandBase<T>): void;
327
378
 
328
379
  addEventListener<K extends keyof FromMetaboxMessagePayloads>(eventType: K, listener: (data: FromMetaboxMessagePayloads[K]) => void): void;
329
380
 
@@ -427,8 +478,8 @@ All commands use strongly typed payloads defined in `ToMetaboxMessagePayloads`:
427
478
  interface ToMetaboxMessagePayloads {
428
479
  setEnvironment: { id: string };
429
480
  setEnvironmentMaterialById: { slotId: string; materialId: string };
430
- setComponent: { id: string; typeId: string; isRoot: boolean };
431
481
  setComponentType: { typeId: string };
482
+ setComponent: { id: string; typeId: string; isRoot: boolean };
432
483
  setComponentMaterialById: { slotId: string; materialId: string };
433
484
  getScreenshot: { format: MimeType; size?: { x: number; y: number } };
434
485
  getCallToActionInformation: void;
@@ -484,590 +535,125 @@ interface Rotation {
484
535
 
485
536
  ### Command Classes
486
537
 
487
- ### Environment & Scene Control
488
-
489
- #### `SetEnvironment(environmentId)`
490
-
491
- Sets the active environment/scene in the configurator.
492
-
493
- **Parameters:**
494
-
495
- - `environmentId` (string): The ID of the environment to activate
496
-
497
- **Example:**
498
-
499
- ```typescript
500
- api.sendCommandToMetaBox(new SetEnvironment('environment-001'));
501
- ```
502
-
503
- #### `SetEnvironmentMaterial(slotId, materialId)`
504
-
505
- Changes the material of an environment element.
506
-
507
- **Parameters:**
508
-
509
- - `slotId` (string): The slot identifier for the environment element
510
- - `materialId` (string): The ID of the material to apply
511
-
512
- **Example:**
513
-
514
- ```typescript
515
- api.sendCommandToMetaBox(new SetEnvironmentMaterial('floor-slot', 'wood-material'));
516
- ```
517
-
518
- ### Component Management
519
-
520
- #### `SetComponent(id, typeId, isRoot)`
521
-
522
- Adds or updates a component in the configurator.
523
-
524
- **Parameters:**
525
-
526
- - `id` (string): Unique identifier for the component
527
- - `typeId` (string): The type/category of the component
528
- - `isRoot` (boolean): Whether this is a root component
529
-
530
- **Example:**
531
-
532
- ```typescript
533
- api.sendCommandToMetaBox(new SetComponent('chair-001', 'furniture', true));
534
- ```
535
-
536
- #### `SetComponentType(componentId, typeId)`
537
-
538
- Changes the type of the existing component.
539
-
540
- **Parameters:**
541
-
542
- - `componentId` (string): The ID of the component to modify
543
- - `typeId` (string): The new type ID to assign
544
-
545
- **Example:**
538
+ All commands are dispatched via:
546
539
 
547
540
  ```typescript
548
- api.sendCommandToMetaBox(new SetComponentType('chair-001', 'office-chair'));
541
+ api.sendCommandToMetabox(new SomeCommand(...));
549
542
  ```
550
543
 
551
- #### `SetComponentMaterial(slotId, materialId)`
552
-
553
- Applies a material to a component's material slot.
554
-
555
- **Parameters:**
556
-
557
- - `slotId` (string): The material slot identifier
558
- - `materialId` (string): The ID of the material to apply
559
-
560
- **Example:**
561
-
562
- ```typescript
563
- api.sendCommandToMetaBox(new SetComponentMaterial('chair-fabric', 'leather-brown'));
564
- ```
544
+ #### Core Configuration Commands
565
545
 
566
- ### UI Control
546
+ - `SetComponent(id, typeId, isRoot)` – Add/select a component (root or child).
547
+ - `SetComponentType(typeId)` – Switch active component type context.
548
+ - `SetComponentMaterial(slotId, materialId)` – Apply material to a component slot.
549
+ - `SetEnvironment(id)` – Activate environment.
550
+ - `SetEnvironmentMaterial(slotId, materialId)` – Apply material to environment slot.
567
551
 
568
- #### `ShowEmbeddedMenu(visible)`
552
+ #### UI / Interface
569
553
 
570
- Controls the visibility of the embedded configurator menu (right sidebar).
554
+ - `ShowEmbeddedMenu(visible)` – Toggle built‑in right sidebar menu.
555
+ - `ShowOverlayInterface(visible)` – Toggle overlay UI elements (hotspots / viewport controls).
556
+ - `forceSetDeviceType(deviceType)` – Force layout/device mode (desktop/tablet/mobile) without relying on viewport breakpoints.
571
557
 
572
- **Parameters:**
558
+ #### Camera / View
573
559
 
574
- - `visible` (boolean): `true` to show the built-in menu; `false` to hide it.
560
+ - `ResetCamera()` – Reset to initial camera transform.
561
+ - `ApplyZoom(zoom)` – Apply zoom delta (positive/negative). Respect configured min/max.
575
562
 
576
- **Examples:**
563
+ #### Showcase Control
577
564
 
578
- ```typescript
579
- api.sendCommandToMetaBox(new ShowEmbeddedMenu(true)); // Show menu
580
- api.sendCommandToMetaBox(new ShowEmbeddedMenu(false)); // Hide menu
581
- ```
565
+ - `InitShowcase()` – Initialize a showcase sequence for current component/product context.
566
+ - `PlayShowcase()` / `PauseShowcase()` / `StopShowcase()` – Playback controls.
582
567
 
583
- #### `ShowOverlayInterface(visible)`
568
+ #### Export / Media
584
569
 
585
- Controls the visibility of the overlay interface over the Unreal viewport (e.g., on‑viewport buttons, tooltips, hotspots).
570
+ - `GetScreenshot(format, size?)` – Request ordered render; listen to `screenshotReady`.
571
+ - `GetPdf()` – Request PDF generation (no dedicated completion event; follow status messages).
572
+ - `GetCallToActionInformation()` – Trigger CTA flow; backend must respond with `{ redirectUrl }`.
586
573
 
587
- **Parameters:**
574
+ #### Unreal / Advanced
588
575
 
589
- - `visible` (boolean): `true` to show the overlay; `false` to hide it.
576
+ - `UnrealCommand(command: object | string)` – Send custom Unreal engine command (low‑level; not guaranteed stable).
577
+ - `MetaboxConfig(appId, partialConfig)` – Initialization command auto‑sent internally.
578
+ - `forceSetDeviceType(deviceType)` – Force layout/device mode (desktop/tablet/mobile) without relying on viewport breakpoints.
590
579
 
591
580
  **Examples:**
592
581
 
593
582
  ```typescript
594
- api.sendCommandToMetaBox(new ShowOverlayInterface(true)); // Show overlay
595
- api.sendCommandToMetaBox(new ShowOverlayInterface(false)); // Hide overlay
596
- ```
597
-
598
- ### Camera Control
599
-
600
- #### `ResetCamera()`
601
-
602
- Resets the camera to its default position and rotation.
603
-
604
- **Example:**
605
-
606
- ```typescript
607
- api.sendCommandToMetaBox(new ResetCamera());
608
- ```
609
-
610
- #### `ApplyZoom(zoom)`
611
-
612
- Applies zoom to the camera view.
613
-
614
- **Parameters:**
615
-
616
- - `zoom` (number): Zoom level (typically between 0.1 and 3.0)
617
-
618
- **Example:**
619
-
620
- ```typescript
621
- api.sendCommandToMetaBox(new ApplyZoom(1.5)); // 150% zoom
622
- ```
623
-
624
- ### Export & Capture
625
-
626
- #### `GetScreenshot(mimeType, size?)`
627
-
628
- Captures a screenshot of the current configurator view.
629
-
630
- **Parameters:**
631
-
632
- - `mimeType` (`string`): Image format ('image/png', 'image/jpeg', 'image/webp')
633
- - `size` (`{ x: number; y: number }`, optional): Screenshot dimensions in pixels
634
-
635
- **TypeScript Interface:**
636
-
637
- ```typescript
638
- interface ScreenshotSize {
639
- x: number; // Width in pixels
640
- y: number; // Height in pixels
641
- }
642
- ```
643
-
644
- **Example:**
645
-
646
- ```typescript
647
- api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1920, y: 1080 }));
648
- ```
649
-
650
- #### `GetPdf()`
651
-
652
- Generates a PDF document of the current configuration.
653
-
654
- **Example:**
655
-
656
- ```typescript
657
- api.sendCommandToMetaBox(new GetPdf());
658
- ```
659
-
660
- ### Commerce & CTA
583
+ // Force device type to mobile layout
584
+ api.sendCommandToMetabox(new ForceSetDeviceType('mobile'));
661
585
 
662
- #### `GetCallToActionInformation()`
586
+ // Adjust zoom smoothly
587
+ api.sendCommandToMetabox(new ApplyZoom(0.25)); // zoom in
588
+ api.sendCommandToMetabox(new ApplyZoom(-0.25)); // zoom out
663
589
 
664
- Requests Call-To-Action information based on the current configuration. The configurator will compile CTA data and post it to the endpoint specified in the CTA configuration.
590
+ // Low-level Unreal command (example payload)
591
+ api.sendCommandToMetabox(new UnrealCommand({ action: 'SetLightIntensity', lightId: 'keyLight', value: 2.5 }));
665
592
 
666
- - No parameters.
667
- - The response is delivered to the configured endpoint URL; listen to your backend or proxy endpoint to handle it.
668
-
669
- **Example:**
670
-
671
- ```typescript
672
- api.sendCommandToMetaBox(new GetCallToActionInformation());
593
+ // Simpler string-based Unreal command variant (if supported)
594
+ api.sendCommandToMetabox(new UnrealCommand('SetSunTime 14:30'));
673
595
  ```
674
596
 
675
- #### `saveImage(renderData, fileName)`
676
-
677
- Utility function to save image data to a file.
678
-
679
- **Parameters:**
680
-
681
- - `renderData` (string): Base64 image data
682
- - `fileName` (string): Name for the downloaded file
683
-
684
- **Example:**
597
+ #### Internal Message Payload Shape (Excerpt)
685
598
 
686
599
  ```typescript
687
- saveImage(data, 'my-configuration.png');
688
- ```
689
-
690
- ### Showcase Control
691
-
692
- #### `InitShowcase()`
693
-
694
- Initializes a showcase animation sequence.
695
-
696
- **Example:**
697
-
698
- ```typescript
699
- api.sendCommandToMetaBox(new InitShowcase());
700
- ```
701
-
702
- #### `PlayShowcase()` / `PauseShowcase()` / `StopShowcase()`
703
-
704
- Controls showcase playback.
705
-
706
- **Examples:**
707
-
708
- ```typescript
709
- api.sendCommandToMetaBox(new PlayShowcase()); // Start playback
710
- api.sendCommandToMetaBox(new PauseShowcase()); // Pause playback
711
- api.sendCommandToMetaBox(new StopShowcase()); // Stop and reset
712
- ```
713
-
714
- ### Advanced Features
715
-
716
- #### `UnrealCommand(command)`
717
-
718
- Sends custom commands directly to the Unreal Engine.
719
-
720
- **Parameters:**
721
-
722
- - `command` (string): Custom Unreal Engine command
723
-
724
- **Example:**
725
-
726
- ```typescript
727
- api.sendCommandToMetaBox(new UnrealCommand('SetLightIntensity 2.5'));
728
- ```
729
-
730
- ## Examples
731
-
732
- ### CTA Request Example
733
-
734
- ```typescript
735
- import { integrateMetabox, Communicator, GetCallToActionInformation } from '@3dsource/metabox-modular-configurator-api';
736
-
737
- integrateMetabox('https://metabox.3dsource.com/metabox-configurator/modular/your-configurator-id', 'embed3DSource', (api: Communicator) => {
738
- // Request CTA data for the current configuration
739
- api.sendCommandToMetaBox(new GetCallToActionInformation());
740
- });
741
- ```
742
-
743
- ### Complete Product Configurator
744
-
745
- ```typescript
746
- import { integrateMetabox, Communicator, ModularConfiguratorEnvelope, SetEnvironment, SetComponent, SetComponentMaterial, ShowOverlayInterface, GetScreenshot, ResetCamera } from '@3dsource/metabox-modular-configurator-api';
747
-
748
- class ProductConfigurator {
749
- private api: Communicator | null = null;
750
- private currentConfig: ModularConfiguratorEnvelope | null = null;
751
-
752
- constructor(configuratorUrl: string) {
753
- integrateMetabox(configuratorUrl, 'embed3DSource', (api) => {
754
- this.api = api;
755
- this.setupEventListeners();
756
- this.initializeProduct();
757
- });
758
- }
759
-
760
- private setupEventListeners(): void {
761
- if (!this.api) return;
762
-
763
- this.api.addEventListener('configuratorDataUpdated', (data: ModularConfiguratorEnvelope) => {
764
- this.currentConfig = data;
765
- this.onConfigurationChange(data);
766
- });
767
-
768
- this.api.addEventListener('screenshotReady', (imageData: string | null) => {
769
- if (imageData) {
770
- this.onScreenshotReady(imageData);
771
- }
772
- });
773
- }
774
-
775
- private initializeProduct(): void {
776
- if (!this.api) return;
777
-
778
- // Set up the initial environment
779
- this.api.sendCommandToMetaBox(new SetEnvironment('showroom-001'));
780
-
781
- // Add main product component
782
- this.api.sendCommandToMetaBox(new SetComponent('product-main', 'chair', true));
783
-
784
- // Configure UI
785
- this.api.sendCommandToMetaBox(new ShowOverlayInterface(true));
786
-
787
- // Reset camera to default position
788
- this.api.sendCommandToMetaBox(new ResetCamera());
789
- }
790
-
791
- public changeMaterial(slotId: string, materialId: string): void {
792
- if (this.api) {
793
- this.api.sendCommandToMetaBox(new SetComponentMaterial(slotId, materialId));
794
- }
795
- }
796
-
797
- public takeProductPhoto(): void {
798
- if (this.api) {
799
- this.api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1920, y: 1080 }));
800
- }
801
- }
802
-
803
- private onConfigurationChange(data: ModularConfiguratorEnvelope): void {
804
- console.log('Configuration updated:', data);
805
- // Update your UI, save state, etc.
806
- }
807
-
808
- private onScreenshotReady(imageData: string): void {
809
- // Create download link or display image
810
- const link = document.createElement('a');
811
- link.download = 'product-configuration.png';
812
- link.href = imageData;
813
- link.click();
814
- }
815
- }
816
- ```
817
-
818
- ### React Hook Example
819
-
820
- ```typescript
821
- import { useCallback, useEffect, useRef, useState } from 'react';
822
- import {
823
- Communicator,
824
- GetScreenshot,
825
- integrateMetabox,
826
- ModularConfiguratorEnvelope,
827
- SetComponent,
828
- SetComponentMaterial,
829
- SetEnvironment,
830
- } from '@3dsource/metabox-modular-configurator-api';
831
-
832
- interface UseMetaboxConfiguratorOptions {
833
- configuratorUrl: string;
834
- autoInitialize?: boolean;
835
- }
836
-
837
- interface UseMetaboxConfiguratorReturn {
838
- containerRef: React.RefObject<HTMLDivElement>;
839
- api: Communicator | null;
840
- isReady: boolean;
841
- configData: ModularConfiguratorEnvelope | null;
842
- isLoading: boolean;
843
- error: string | null;
844
- // Actions
845
- changeEnvironment: (environmentId: string) => void;
846
- takeScreenshot: (format?: MimeType, size?: { x: number; y: number }) => void;
847
- changeMaterial: (slotId: string, materialId: string) => void;
848
- addComponent: (id: string, typeId: string, isRoot?: boolean) => void;
849
- initialize: () => void;
850
- destroy: () => void;
600
+ interface ToMetaboxMessagePayloads {
601
+ setEnvironment: { id: string };
602
+ setEnvironmentMaterialById: { slotId: string; materialId: string };
603
+ setComponentType: { typeId: string };
604
+ setComponent: { id: string; typeId: string; isRoot: boolean };
605
+ setComponentMaterialById: { slotId: string; materialId: string };
606
+ getScreenshot: { format: MimeType; size?: { x: number; y: number } };
607
+ getCallToActionInformation: void;
608
+ getPdf: void;
609
+ showEmbeddedMenu: { visible: boolean };
610
+ showOverlayInterface: { visible: boolean };
611
+ forceSetDeviceType: { deviceType: ApplicationDeviceTypes };
612
+ resetCamera: void;
613
+ applyZoom: { zoom: number };
614
+ initShowcase: void;
615
+ playShowcase: void;
616
+ pauseShowcase: void;
617
+ stopShowcase: void;
618
+ sendCommandToUnreal: object;
851
619
  }
852
-
853
- export const useMetaboxConfigurator = ({
854
- configuratorUrl,
855
- autoInitialize = true,
856
- }: UseMetaboxConfiguratorOptions): UseMetaboxConfiguratorReturn => {
857
- const [api, setApi] = useState<Communicator | null>(null);
858
- const [isReady, setIsReady] = useState<boolean>(false);
859
- const [isLoading, setIsLoading] = useState<boolean>(false);
860
- const [error, setError] = useState<string | null>(null);
861
- const [configData, setConfigData] = useState<ModularConfiguratorEnvelope | null>(null);
862
- const containerRef = useRef<HTMLDivElement>(null);
863
-
864
- const initialize = useCallback(() => {
865
- if (!containerRef.current || !configuratorUrl || isLoading) return;
866
-
867
- setIsLoading(true);
868
- setError(null);
869
-
870
- try {
871
- const containerId = 'metabox-container-' + Date.now();
872
- containerRef.current.id = containerId;
873
-
874
- integrateMetabox(configuratorUrl, containerId, (apiInstance: Communicator) => {
875
- setApi(apiInstance);
876
- setIsReady(true);
877
- setIsLoading(false);
878
-
879
- // Set up event listeners
880
- apiInstance.addEventListener('configuratorDataUpdated', (data: ModularConfiguratorEnvelope) => {
881
- setConfigData(data);
882
- });
883
-
884
- apiInstance.addEventListener('screenshotReady', (imageData: string | null) => {
885
- // Handle screenshot data - could emit custom event or callback
886
- if (imageData) {
887
- console.log('Screenshot ready:', imageData);
888
- }
889
- });
890
-
891
- apiInstance.addEventListener('pdfGenerating', (isGenerating: boolean) => {
892
- // Handle PDF generation state
893
- console.log('PDF generating:', isGenerating);
894
- });
895
- });
896
- } catch (err) {
897
- setError(err instanceof Error ? err.message : 'Failed to initialize configurator');
898
- setIsLoading(false);
899
- }
900
- }, [configuratorUrl, isLoading]);
901
-
902
- const destroy = useCallback(() => {
903
- setApi(null);
904
- setIsReady(false);
905
- setIsLoading(false);
906
- setConfigData(null);
907
- setError(null);
908
- }, []);
909
-
910
- useEffect(() => {
911
- if (autoInitialize) {
912
- initialize();
913
- }
914
-
915
- return destroy;
916
- }, [initialize, destroy, autoInitialize]);
917
-
918
- // Action methods
919
- const changeEnvironment = useCallback((environmentId: string) => {
920
- if (api && isReady) {
921
- api.sendCommandToMetaBox(new SetEnvironment(environmentId));
922
- }
923
- }, [api, isReady]);
924
-
925
- const takeScreenshot = useCallback((
926
- format: MimeType = 'image/png',
927
- size?: { x: number; y: number },
928
- ) => {
929
- if (api && isReady) {
930
- api.sendCommandToMetaBox(new GetScreenshot(format, size));
931
- }
932
- }, [api, isReady]);
933
-
934
- const changeMaterial = useCallback((slotId: string, materialId: string) => {
935
- if (api && isReady) {
936
- api.sendCommandToMetaBox(new SetComponentMaterial(slotId, materialId));
937
- }
938
- }, [api, isReady]);
939
-
940
- const addComponent = useCallback((id: string, typeId: string, isRoot: boolean = false) => {
941
- if (api && isReady) {
942
- api.sendCommandToMetaBox(new SetComponent(id, typeId, isRoot));
943
- }
944
- }, [api, isReady]);
945
-
946
- return {
947
- containerRef,
948
- api,
949
- isReady,
950
- configData,
951
- isLoading,
952
- error,
953
- changeEnvironment,
954
- takeScreenshot,
955
- changeMaterial,
956
- addComponent,
957
- initialize,
958
- destroy,
959
- };
960
- };
961
-
962
- // Usage example in a React component
963
- const ConfiguratorComponent: React.FC = () => {
964
- const {
965
- containerRef,
966
- isReady,
967
- isLoading,
968
- error,
969
- configData,
970
- changeEnvironment,
971
- takeScreenshot,
972
- changeMaterial,
973
- } = useMetaboxConfigurator({
974
- configuratorUrl: 'https://metabox.3dsource.com/metabox-configurator/modular/your-id',
975
- });
976
-
977
- const handleEnvironmentChange = (envId: string) => {
978
- changeEnvironment(envId);
979
- };
980
-
981
- const handleTakeScreenshot = () => {
982
- takeScreenshot('image/png', { x: 1920, y: 1080 });
983
- };
984
-
985
- if (error) {
986
- return <div className="error">Error loading configurator: {error}</div>;
987
- }
988
-
989
- return (
990
- <div className="configurator-wrapper">
991
- {isLoading && <div className="loading">Loading configurator...</div>}
992
-
993
- <div ref={containerRef} className="configurator-container" />
994
-
995
- {isReady && (
996
- <div className="controls">
997
- <button onClick={() => handleEnvironmentChange('showroom-1')}>
998
- Showroom Environment
999
- </button>
1000
- <button onClick={() => changeMaterial('seat', 'leather-brown')}>
1001
- Brown Leather
1002
- </button>
1003
- <button onClick={handleTakeScreenshot}>
1004
- Take Screenshot
1005
- </button>
1006
- </div>
1007
- )}
1008
-
1009
- {configData && (
1010
- <div className="config-info">
1011
- <p>Components: {configData.componentsByComponentType ? Object.keys(configData.componentsByComponentType).length : 0}</p>
1012
- <p>Environment: {configData.environmentId}</p>
1013
- </div>
1014
- )}
1015
- </div>
1016
- );
1017
- };
1018
620
  ```
1019
621
 
1020
- ## Event Handling
622
+ ### Event Handling
1021
623
 
1022
- The API provides several events that you can listen to for real-time updates:
624
+ The below events originate from the embedded configurator (`FromMetaboxMessagePayloads`). Register via `api.addEventListener(name, handler)`.
1023
625
 
1024
626
  ### Available Events
1025
627
 
1026
- | Event Name | Description | Data Type |
1027
- | ------------------------- | ------------------------------------- | ----------------------------- |
1028
- | `configuratorDataUpdated` | Fired when configuration data changes | `ModularConfiguratorEnvelope` |
1029
- | `screenshotReady` | Fired when a screenshot is ready | `string` (base64 image data) |
1030
- | `showcaseStatusChanged` | Fired when showcase status changes | `ShowCaseStatus` |
1031
- | `viewportReady` | Fired when viewport is ready | `boolean` |
1032
- | `statusMessageChanged` | Fired when status message changes | `string \| null` |
628
+ | Event | Payload | Description |
629
+ | ----------------------------- | --------------------------- | --------------------------------------------------------------------- | ------ | -------------------------- | ------ |
630
+ | `configuratorDataUpdated` | ModularConfiguratorEnvelope | Any configuration change (components, types, materials, environment). |
631
+ | `ecomConfiguratorDataUpdated` | EcomConfigurator | CTA label/callback updates (E‑Com enabled). |
632
+ | `showcaseStatusChanged` | ShowCaseStatus | Showcase playback status: `init | play | pause | stop`. |
633
+ | `dataChannelConnected` | boolean | Unreal data channel connectivity (true = connected). |
634
+ | `viewportReady` | boolean | Unreal viewport visibility / readiness. |
635
+ | `statusMessageChanged` | string \| null | Loading / progress status messages. |
636
+ | `screenshotReady` | string \| null | Base64 image from latest screenshot (null if failed). |
637
+ | `videoResolutionChanged` | { width: number | null; height: number | null } | Stream resolution changed. |
1033
638
 
1034
- ### Event Listener Examples
639
+ ### Event Examples
1035
640
 
1036
641
  ```typescript
1037
- // Listen for configuration changes
1038
- api.addEventListener('configuratorDataUpdated', (data: ModularConfiguratorEnvelope) => {
1039
- console.log('Configuration updated:', data);
1040
-
1041
- // Access specific data
1042
- console.log('Configurator:', data.configurator);
1043
- console.log('Configuration tree:', data.configurationTree);
1044
- console.log('Components by type:', data.componentsByComponentType);
1045
- console.log('Environment ID:', data.environmentId);
1046
- });
1047
-
1048
- // Handle screenshot events
1049
- api.addEventListener('screenshotReady', (imageData: string | null) => {
1050
- // imageData is a base64 encoded image
1051
- if (!imageData) return;
1052
- const img = document.createElement('img');
1053
- img.src = imageData;
1054
- document.body.appendChild(img);
642
+ api.addEventListener('configuratorDataUpdated', (env) => {
643
+ console.log('Active environment:', env.environmentId);
644
+ console.log('Components per type:', env.componentsByComponentType);
1055
645
  });
1056
646
 
1057
- // Monitor showcase playback
1058
- api.addEventListener('showcaseStatusChanged', (status: ShowCaseStatus) => {
1059
- console.log('Showcase status:', status);
1060
- // Handle play/pause/stop states
647
+ api.addEventListener('screenshotReady', (img) => {
648
+ if (img) saveImage(img, 'modular-configurator.png');
1061
649
  });
1062
650
 
1063
- // Handle viewport ready events
1064
- api.addEventListener('viewportReady', (isReady: boolean) => {
1065
- console.log('Viewport ready:', isReady);
651
+ api.addEventListener('dataChannelConnected', (connected) => {
652
+ console.log('Unreal channel connected?', connected);
1066
653
  });
1067
654
 
1068
- // Handle status messages
1069
- api.addEventListener('statusMessageChanged', (message: string | null) => {
1070
- console.log('Status message:', message);
655
+ api.addEventListener('videoResolutionChanged', (res) => {
656
+ console.log('Viewport resolution:', res.width, 'x', res.height);
1071
657
  });
1072
658
  ```
1073
659
 
@@ -1081,14 +667,14 @@ api.addEventListener('statusMessageChanged', (message: string | null) => {
1081
667
 
1082
668
  **Solutions**:
1083
669
 
1084
- 1. Verify the configurator URL is correct and accessible
670
+ 1. Verify the configurator ID is correct and accessible
1085
671
  2. Check that the container element exists in the DOM
1086
672
  3. Ensure the container has proper dimensions (width/height)
1087
673
  4. Check the browser console for CORS or network errors
1088
674
 
1089
675
  ```typescript
1090
- // Ensure the element exists and URL is correct before calling
1091
- integrateMetabox(configuratorUrl, 'embed3DSource', (api) => {
676
+ // Ensure the element exists and ID is correct before calling
677
+ integrateMetabox(configuratorId, 'embed3DSource', (api) => {
1092
678
  console.log('API ready!');
1093
679
  });
1094
680
  ```
@@ -1105,9 +691,9 @@ integrateMetabox(configuratorUrl, 'embed3DSource', (api) => {
1105
691
 
1106
692
  ```typescript
1107
693
  // Wait for API to be ready
1108
- integrateMetabox(url, containerId, (api) => {
694
+ integrateMetabox(configuratorId, containerId, (api) => {
1109
695
  // Only send commands after this callback
1110
- api.sendCommandToMetaBox(new SetEnvironment('env-001'));
696
+ api.sendCommandToMetabox(new SetEnvironment('env-001'));
1111
697
  });
1112
698
  ```
1113
699
 
@@ -1146,7 +732,7 @@ let timeoutId: NodeJS.Timeout;
1146
732
  const debouncedMaterialChange = (slotId: string, materialId: string) => {
1147
733
  clearTimeout(timeoutId);
1148
734
  timeoutId = setTimeout(() => {
1149
- api.sendCommandToMetaBox(new SetComponentMaterial(slotId, materialId));
735
+ api.sendCommandToMetabox(new SetComponentMaterial(slotId, materialId));
1150
736
  }, 300);
1151
737
  };
1152
738
  ```
@@ -1157,17 +743,6 @@ const debouncedMaterialChange = (slotId: string, materialId: string) => {
1157
743
  - **ES6 modules**: Required for CDN usage
1158
744
  - **HTTPS**: Required for production deployments
1159
745
 
1160
- ## Contributing
1161
-
1162
- We welcome contributions to improve the Metabox Modular Configurator API!
1163
-
1164
- ### Development Setup
1165
-
1166
- 1. Clone the repository
1167
- 2. Install dependencies: `npm install`
1168
- 3. Build the library: `npm run build`
1169
- 4. Run tests: `npm test`
1170
-
1171
746
  ---
1172
747
 
1173
748
  For more examples and advanced usage, visit
@@ -1184,11 +759,10 @@ Key points:
1184
759
  - Purpose: use when you need a 100% custom interface and logic on the host page.
1185
760
  - Behavior: Metabox default UI, embedded menu and template logic are disabled on the iframe side.
1186
761
  - Control: you drive everything with API commands and events.
1187
- - Availability: supported since v2 of the API (example versions ≥ 2.0.1).
1188
762
 
1189
763
  How to enable
1190
764
 
1191
- Pass the 4th argument config with standalone set to true when calling integrateMetabox.
765
+ Pass as param to config with a standalone set to true when calling integrateMetabox.
1192
766
 
1193
767
  TypeScript example:
1194
768
 
@@ -1196,12 +770,12 @@ TypeScript example:
1196
770
  import { integrateMetabox, Communicator, SetComponent, SetEnvironment } from '@3dsource/metabox-modular-configurator-api';
1197
771
 
1198
772
  integrateMetabox(
1199
- 'https://metabox.3dsource.com/metabox-configurator/modular/your-configurator-id',
773
+ 'configurator-id',
1200
774
  'embed3DSource',
1201
775
  (api: Communicator) => {
1202
776
  // Send your initial commands to establish state
1203
- api.sendCommandToMetaBox(new SetComponent('your-component-id', 'your-type-id', true));
1204
- api.sendCommandToMetaBox(new SetEnvironment('your-environment-id'));
777
+ api.sendCommandToMetabox(new SetComponent('your-component-id', 'your-type-id', true));
778
+ api.sendCommandToMetabox(new SetEnvironment('your-environment-id'));
1205
779
  },
1206
780
  { standalone: true },
1207
781
  );
@@ -1214,11 +788,11 @@ JavaScript (CDN) example:
1214
788
  import { integrateMetabox, SetComponent, SetEnvironment } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-modular-configurator-api@2.0.1/+esm';
1215
789
 
1216
790
  integrateMetabox(
1217
- 'https://metabox.3dsource.com/metabox-configurator/modular/your-configurator-id',
791
+ 'configurator-id',
1218
792
  'embed3DSource',
1219
793
  (api) => {
1220
- api.sendCommandToMetaBox(new SetComponent('your-component-id', 'your-type-id', true));
1221
- api.sendCommandToMetaBox(new SetEnvironment('your-environment-id'));
794
+ api.sendCommandToMetabox(new SetComponent('your-component-id', 'your-type-id', true));
795
+ api.sendCommandToMetabox(new SetEnvironment('your-environment-id'));
1222
796
  },
1223
797
  { standalone: true },
1224
798
  );
@@ -1229,4 +803,4 @@ Notes and tips
1229
803
 
1230
804
  - In standalone mode, nothing will change until you send initial commands (e.g., set component/environment). If you see a blank/default view, ensure you dispatch the necessary SetComponent/SetEnvironment commands once api is ready.
1231
805
  - All events (like configuratorDataUpdated, screenshotReady) still work; use them to keep your UI synchronized.
1232
- - The config.hostUrl and config.apiVersion are set automatically by the library; you typically don’t need to pass them.
806
+ - The library sets the config.hostUrl and config.apiVersion automatically; you typically don’t need to pass them.