@3dsource/metabox-modular-configurator-api 3.0.19-dev.1 → 3.0.19-dev.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,19 @@ import { fromEvent } from 'rxjs';
2
2
 
3
3
  /**
4
4
  * Base class for commands sent to the Metabox API.
5
+ *
6
+ * ### What does it unlock?
7
+ * Base class that all other commands inherit from in a class hierarchy. Provides common properties
8
+ * and methods that are automatically available to all command subclasses.
9
+ *
10
+ * ### Practical Application
11
+ * Base class all commands inherit from. Never instantiate directly — use specific subclasses like
12
+ * SetProduct, SetCamera, etc. All commands are sent via `api.sendCommandToMetabox(new CommandName(...))`.
13
+ *
14
+ * ### AI Coding Best Practices
15
+ * Never construct a generic CommandBase. Always use the specific typed command class. When generating
16
+ * dynamic command dispatch, use a switch/map pattern matching command names to their constructors.
17
+ *
5
18
  * @internal
6
19
  * @hidden
7
20
  */
@@ -9,18 +22,48 @@ class CommandBase {
9
22
  }
10
23
 
11
24
  /**
12
- * Wrapper helper function to use it with rxJs the same as `fromEvent` to listen to events from the Communicator.
25
+ * Wrapper helper function to use with RxJS the same way as `fromEvent`, to listen to events from the Communicator.
26
+ *
27
+ * ### What does it unlock?
28
+ * Function that creates an event listener subscription. Allows developers to subscribe to specific events from the Communicator.
29
+ *
30
+ * ### Practical Application
31
+ * Function that creates event listener subscriptions. Alternative to api.addEventListener() — both subscribe
32
+ * to configurator events. Use to react to state changes, screenshot readiness, viewport loading, showcase status, etc.
13
33
  *
14
- * @param {Communicator} target
15
- * @param eventName
34
+ * ### AI Coding Best Practices
35
+ * Prefer api.addEventListener() directly from the Communicator object. If using fromCommunicatorEvent, pass the
36
+ * event name and handler. Key events: configuratorDataUpdated, viewportReady, screenshotReady, showcaseStatusChanged,
37
+ * getCameraResult. Always subscribe BEFORE sending commands that trigger responses.
38
+ *
39
+ * @param {Communicator} target - The Communicator instance to listen on.
40
+ * @param {T} eventName - The event name from {@link FromMetaBoxApiEvents} to subscribe to.
41
+ * @returns An Observable that emits the typed payload each time the event fires.
16
42
  * @internal
17
43
  */
18
44
  function fromCommunicatorEvent(target, eventName) {
19
45
  return fromEvent(target, eventName);
20
46
  }
21
47
 
48
+ /**
49
+ * Registry of all action identifiers that can be sent from the host application to the Metabox Modular Configurator.
50
+ * Each key maps to a string used as the `action` field in the postMessage envelope.
51
+ *
52
+ * ### What does it unlock?
53
+ * Variable containing all available action names. Interface listing all actions that the modular configurator supports.
54
+ *
55
+ * ### Practical Application
56
+ * Master action registry object — all supported configurator action names. Invaluable reference for building
57
+ * admin dashboards, permission systems, or feature-availability displays.
58
+ *
59
+ * ### AI Coding Best Practices
60
+ * Iterate this object to dynamically build action dropdowns, command palettes, or feature checklists in admin tools.
61
+ * Each key is an action name, value is its description. Excellent reference for AI coding agents to understand
62
+ * the full command vocabulary available.
63
+ */
22
64
  const MetaboxModularConfiguratorActions = {
23
65
  metaboxConfig: 'metaboxConfig',
66
+ resumeStream: 'resumeStream',
24
67
  setEnvironment: 'setEnvironment',
25
68
  setEnvironmentMaterialById: 'setEnvironmentMaterialById',
26
69
  setComponent: 'setComponent',
@@ -45,19 +88,28 @@ const MetaboxModularConfiguratorActions = {
45
88
  };
46
89
 
47
90
  /**
48
- * Represents a command to send Metabox Config to Metabox Basic Configurator.
49
- * @remarks
50
- * **Important**: No need to listen to any events to see changes.
91
+ * Represents a command to send Metabox Config to Metabox Modular Configurator.
92
+ *
93
+ * ### What does it unlock?
94
+ * Configuration object passed to MetaBox during initialization. Specifies domain, host, standalone mode,
95
+ * and other parameters that control how the configurator behaves.
96
+ *
97
+ * ### Practical Application
98
+ * Internal configuration object auto-sent during initialization. Contains appId and config.
99
+ * DO NOT call directly — integrateMetabox() handles this automatically as part of its setup sequence.
100
+ *
101
+ * ### AI Coding Best Practices
102
+ * NEVER instantiate or send MetaboxConfig manually. It is auto-sent by integrateMetabox().
103
+ * Use the IntegrateMetaboxConfig parameter of integrateMetabox() instead for setting domain, standalone,
104
+ * loadingImage, introImage, state, etc.
51
105
  *
52
106
  * @internal
53
107
  * Automatically sent when the Communicator instance is ready.
108
+ *
109
+ * @param {string} appId - The unique identifier for the Communicator Instance
110
+ * @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic
54
111
  */
55
112
  class MetaboxConfig extends CommandBase {
56
- /**
57
- * Creates an instance of MetaboxConfig.
58
- * @param {string} appId - The unique identifier for the Communicator Instance
59
- * @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic
60
- */
61
113
  constructor(appId, config) {
62
114
  super();
63
115
  this.data = {
@@ -68,27 +120,28 @@ class MetaboxConfig extends CommandBase {
68
120
  }
69
121
 
70
122
  /**
71
- * Represents a command to get a PDF from Metabox Basic Configurator.
72
- * @remarks
123
+ * Represents a command to get a PDF from Metabox Modular Configurator.
73
124
  * This class sends a message to the Metabox API to generate a PDF based on the current configuration.
74
- * **Important**: No need to listen to any events to see changes.
75
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
125
+ * **Important**: No need to listen to any events to see changes. Pdf will be downloaded automatically once it's ready.
126
+ *
127
+ * ### What does it unlock?
128
+ * Generates a native MetaBox PDF document. No subscription required — it executes independently.
129
+ *
130
+ * ### Practical Application
131
+ * Generates a branded PDF from the current configurator state server-side. No event subscription needed.
132
+ * Use for B2B quote workflows, downloadable spec sheets, or emailing configured product summaries to prospects.
133
+ *
134
+ * ### AI Coding Best Practices
135
+ * Simply call `api.sendCommandToMetabox(new GetPdf())`. No parameters or event subscription required.
136
+ * The PDF generates inside MetaBox application.
76
137
  *
77
138
  * @example
78
139
  * import { GetPdf, Communicator } from '@3dsource/metabox-modular-configurator-api';
79
- *
80
- * @param {Communicator} api - communicator instance api
81
140
  * window.env3DSource.apiReady = (api: Communicator) => {
82
141
  * api.sendCommandToMetabox(new GetPdf());
83
142
  * };
84
143
  */
85
144
  class GetPdf extends CommandBase {
86
- /**
87
- * Creates an instance of GetPdf.
88
- *
89
- * @remarks
90
- * This constructor does not require any parameters.
91
- */
92
145
  constructor() {
93
146
  super();
94
147
  this.data = { action: MetaboxModularConfiguratorActions.getPdf };
@@ -96,40 +149,38 @@ class GetPdf extends CommandBase {
96
149
  }
97
150
 
98
151
  /**
99
- * Represents a command to get a Call To Action Information from Metabox Basic Configurator.
100
- * @remarks
101
- * This class sends a message to the Metabox API to generate Call To Action information based on the current configuration and sends it to the endpoint URL from the CTA information.
152
+ * Represents a command to get a Call To Action Information from Metabox Modular Configurator.
153
+ * This class sends a message to the Metabox API to generate Call To Action information based on the current
154
+ * configuration and sends it to the endpoint URL from the CTA information.
102
155
  *
103
156
  * To listen for changes after sending this command, listen to the 'ecomConfiguratorDataUpdated' event.
104
- * //...Assume that the integration is already implemented (only once)
105
- * @example
106
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
107
157
  *
108
- * @param {Communicator} api - communicator instance api
109
- * window.env3DSource.apiReady = (api: Communicator) => {
110
- * @param {EcomConfigurator} data - description for all ecom configurator params
111
- * api.addEventListener('ecomConfiguratorDataUpdated', (data) => {
112
- * console.log('Ecom configurator params:', data);
113
- * });
114
- * };
158
+ * ### What does it unlock?
159
+ * Retrieves information about call-to-action that were added to the configurator. Requires subscription to receive data.
115
160
  *
116
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
161
+ * ### Practical Application
162
+ * Triggers the CTA (Call-to-Action) workflow configured in MetaBox admin. The CTA label and callback URL are set in admin.
163
+ * When invoked, MetaBox POSTs the full configuration JSON (including BOM) to your callback URL endpoint, which returns a { redirectUrl }.
117
164
  *
118
- * @example
119
- * import { GetCallToActionInformation, Communicator } from '@3dsource/metabox-modular-configurator-api';
165
+ * ### AI Coding Best Practices
166
+ * Call only after user completes configuration. Subscribe to ecomConfiguratorDataUpdated to get CTA label/URL for building
167
+ * custom CTA buttons in your UI. The POST payload includes the full bill of materials — your backend endpoint processes it
168
+ * and returns a redirect URL.
120
169
  *
121
- * @param {Communicator} api - communicator instance api
170
+ * @example
171
+ * import { Communicator, EcomConfigurator, GetCallToActionInformation } from '@3dsource/metabox-modular-configurator-api';
122
172
  * window.env3DSource.apiReady = (api: Communicator) => {
173
+ *
174
+ * //Subscribe to the event before sending the command to ensure you capture the response
175
+ * api.addEventListener('ecomConfiguratorDataUpdated', (data:EcomConfigurator) => {
176
+ * console.log('Ecom configurator params:', data);
177
+ * });
178
+ *
179
+ * // Send the command to get Call To Action information from Metabox Modular Configurator
123
180
  * api.sendCommandToMetabox(new GetCallToActionInformation());
124
181
  * };
125
182
  */
126
183
  class GetCallToActionInformation extends CommandBase {
127
- /**
128
- * Creates an instance of GetCallToActionInformation.
129
- *
130
- * @remarks
131
- * This constructor does not require any parameters.
132
- */
133
184
  constructor() {
134
185
  super();
135
186
  this.data = {
@@ -140,38 +191,35 @@ class GetCallToActionInformation extends CommandBase {
140
191
 
141
192
  /**
142
193
  * Represents a command to get the camera configuration from Unreal.
143
- * @remarks
144
194
  * This class sends a message to the Metabox API to get the camera from a scene.
145
- *
146
195
  * To listen for changes after sending this command, listen to the 'getCameraResult' event.
147
- * //...Assume that the integration is already implemented (only once)
148
- * @example
149
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
150
196
  *
151
- * @param {Communicator} api - communicator instance api
152
- * window.env3DSource.apiReady = (api: Communicator) => {
153
- * @param {CameraCommandPayload} data - camera params
154
- * api.addEventListener('getCameraResult', (data) => {
155
- * console.log('Camera params after get camera command:', data);
156
- * });
157
- * };
197
+ * ### What does it unlock?
198
+ * Retrieves camera presets for the configurator; allowing extraction and application of saved camera positions.
199
+ *
200
+ * ### Practical Application
201
+ * Requests current camera state — returns asynchronously via the getCameraResult event. Returns a CameraCommandPayload
202
+ * with fov, mode, position, rotation, and restrictions. Use to save camera positions, create shareable view links,
203
+ * or build 'save this angle' features.
158
204
  *
159
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
205
+ * ### AI Coding Best Practices
206
+ * ALWAYS subscribe to getCameraResult BEFORE calling GetCamera(). Pattern: `api.addEventListener('getCameraResult', handler);`
207
+ * then `api.sendCommandToMetabox(new GetCamera())`. The returned CameraCommandPayload can be fed directly back into
208
+ * SetCamera to restore the view.
160
209
  *
161
210
  * @example
162
- * import { GetCamera, Communicator } from '@3dsource/metabox-modular-configurator-api';
163
- * @param {Communicator} api - communicator instance api
211
+ * import { Communicator, CameraCommandPayload, GetCamera } from '@3dsource/metabox-modular-configurator-api';
164
212
  * window.env3DSource.apiReady = (api: Communicator) => {
213
+ *
214
+ * //Subscribe to the event before sending the command to ensure you capture the response
215
+ * api.addEventListener('getCameraResult', (data:CameraCommandPayload) => {
216
+ * console.log('Camera params after get camera command:', data);
217
+ * });
218
+ *
165
219
  * api.sendCommandToMetabox(new GetCamera());
166
220
  * };
167
221
  */
168
222
  class GetCamera extends CommandBase {
169
- /**
170
- * Creates an instance of GetCamera.
171
- *
172
- * @remarks
173
- * This constructor does not require any parameters.
174
- */
175
223
  constructor() {
176
224
  super();
177
225
  this.data = { action: MetaboxModularConfiguratorActions.getCamera };
@@ -180,14 +228,24 @@ class GetCamera extends CommandBase {
180
228
 
181
229
  /**
182
230
  * Represents a command to set the camera configuration.
183
- * @remarks
184
231
  * This class sends a message to the Metabox API to set the camera on a scene.
185
232
  * **Important**: No need to listen to any events to see changes.
186
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
233
+ *
234
+ * ### What does it unlock?
235
+ * Sets camera presets with restriction parameters (FOV, rotation, position).
236
+ *
237
+ * ### Practical Application
238
+ * Sets camera with precise control: fov (degrees), mode ('orbit'|'fps'), position ({x,y,z}),
239
+ * rotation ({horizontal,vertical}), and restrictions (min/max distance, FOV, rotation bounds).
240
+ * Use for guided tours, preset view buttons, or restricting camera to prevent users seeing behind the product.
241
+ *
242
+ * ### AI Coding Best Practices
243
+ * Only include fields you want to change — omitted values keep current settings. Use orbit mode for typical product viewing,
244
+ * fps for walkthrough/room scenes. Apply restrictions to prevent bad angles. Full interface:
245
+ * `{fov?, mode?, position?, rotation?, restrictions?}`.
187
246
  *
188
247
  * @example
189
248
  * import { SetCamera, Communicator } from '@3dsource/metabox-modular-configurator-api';
190
- * @param {Communicator} api - communicator instance api
191
249
  * window.env3DSource.apiReady = (api: Communicator) => {
192
250
  * api.sendCommandToMetabox(new SetCamera({
193
251
  * fov: 45,
@@ -203,16 +261,13 @@ class GetCamera extends CommandBase {
203
261
  * minFov: 0,
204
262
  * minHorizontalRotation: 0,
205
263
  * minVerticalRotation: 0,
206
- * },
264
+ * },
207
265
  * }));
208
266
  * };
267
+ *
268
+ * @param {CameraCommandPayload} camera - The camera configuration.
209
269
  */
210
270
  class SetCamera extends CommandBase {
211
- /**
212
- * Creates an instance of SetCamera.
213
- *
214
- * @param {CameraCommandPayload} camera - The camera configuration.
215
- */
216
271
  constructor(camera) {
217
272
  super();
218
273
  this.data = {
@@ -224,25 +279,26 @@ class SetCamera extends CommandBase {
224
279
 
225
280
  /**
226
281
  * Represents a command to reset the camera to its initial position.
227
- * @remarks
228
282
  * This class sends a message to the Metabox API to reset the camera on a scene.
229
- * **Important**: No need to listen to any events to see changes.
230
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
283
+ *
284
+ * ### What does it unlock?
285
+ * Resets the camera to its default state and position. Used to return camera to initial configuration after user manipulation.
286
+ *
287
+ * ### Practical Application
288
+ * Resets camera to the default position defined in the component/environment template. Essential for 'Reset View' buttons.
289
+ * Also, useful after programmatic camera moves to return to a known starting state.
290
+ *
291
+ * ### AI Coding Best Practices
292
+ * Call `api.sendCommandToMetabox(new ResetCamera())`. No parameters. Restores template defaults — not the last user position.
293
+ * Good practice to call after SetComponent changes that may shift the focal point of the assembly.
231
294
  *
232
295
  * @example
233
296
  * import { ResetCamera, Communicator } from '@3dsource/metabox-modular-configurator-api';
234
- * @param {Communicator} api - communicator instance api
235
297
  * window.env3DSource.apiReady = (api: Communicator) => {
236
298
  * api.sendCommandToMetabox(new ResetCamera());
237
299
  * };
238
300
  */
239
301
  class ResetCamera extends CommandBase {
240
- /**
241
- * Creates an instance of ResetCamera.
242
- *
243
- * @remarks
244
- * This constructor does not require any parameters.
245
- */
246
302
  constructor() {
247
303
  super();
248
304
  this.data = { action: MetaboxModularConfiguratorActions.resetCamera };
@@ -251,26 +307,30 @@ class ResetCamera extends CommandBase {
251
307
 
252
308
  /**
253
309
  * Represents a command to apply zoom and change the camera zoom on a scene.
254
- * @remarks
255
310
  * This class sends a command to the Metabox API to change zoom on a scene.
256
- * **Important**: No need to listen to any events to see changes.
257
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
311
+ *
312
+ * ### What does it unlock?
313
+ * Controls zoom functionality for the configurator; allowing users to adjust the zoom level of 3D objects and camera presets.
314
+ *
315
+ * ### Practical Application
316
+ * Implements programmatic zoom on the pixel-streamed viewport. Use to build zoom slider controls, pinch-to-zoom on mobile,
317
+ * or 'zoom to detail' buttons. Takes a numeric delta: positive zooms in, negative zooms out
318
+ * (e.g., ApplyZoom(50) zooms in, ApplyZoom(-50) zooms out).
319
+ *
320
+ * ### AI Coding Best Practices
321
+ * Always use numeric delta values, not absolute zoom levels. Pair with a UI slider that sends incremental values.
322
+ * Debounce zoom input to ~100ms intervals to prevent overwhelming the Unreal stream.
323
+ * Pattern: `api.sendCommandToMetabox(new ApplyZoom(50))`.
258
324
  *
259
325
  * @example
260
326
  * import { ApplyZoom, Communicator } from '@3dsource/metabox-modular-configurator-api';
261
- *
262
- * @param {Communicator} api - communicator instance api
263
327
  * window.env3DSource.apiReady = (api: Communicator) => {
264
- * api.sendCommandToMetabox(new ApplyZoom(10));
265
- * api.sendCommandToMetabox(new ApplyZoom(-10));
328
+ * api.sendCommandToMetabox(new ApplyZoom(50));
266
329
  * };
330
+ *
331
+ * @param {number} zoom - The zoom value to apply.
267
332
  */
268
333
  class ApplyZoom extends CommandBase {
269
- /**
270
- * Creates an instance of ApplyZoom.
271
- *
272
- * @param {number} zoom - The zoom value to apply.
273
- */
274
334
  constructor(zoom) {
275
335
  super();
276
336
  this.data = {
@@ -281,54 +341,36 @@ class ApplyZoom extends CommandBase {
281
341
  }
282
342
 
283
343
  /**
284
- * Represents a command to initialize Showcase for a product scene and start a sequence for the product.
285
- * @remarks
286
- * This class sends a command to the Metabox API to initialize showcase if the product has a sequence.
287
- * To check this, find the showcase property in the current product and listen to the 'configuratorDataUpdated' event.
288
- * //...Assume that the integration is already implemented (only once)
289
- * @example
290
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
291
- *
292
- * @param {Communicator} api - communicator instance api
293
- * window.env3DSource.apiReady = (api: Communicator) => {
294
- * @param {ConfiguratorEnvelope} data - configurator state after updated
295
- * api.addEventListener('configuratorDataUpdated', (data) => {
296
- * console.log('State updated after applied new environment:', data);
297
- * });
298
- * };
299
- *
344
+ * Represents a command to initialize Showcase for a component scene and start a sequence for the component.
345
+ * This class sends a command to the Metabox API to initialize showcase if the component has a sequence.
346
+ * To check this, find the showcase property in the current component and listen to the 'configuratorDataUpdated' event.
300
347
  * If this property exists, you can send the init showcase command.
301
348
  *
302
349
  * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.
303
- * //...Assume that the integration is already implemented (only once)
304
- * @example
305
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
306
350
  *
307
- * @param {Communicator} api - communicator instance api
308
- * window.env3DSource.apiReady = (api: Communicator) => {
309
- * @param {ShowCaseStatus} data - showcase status value
310
- * api.addEventListener('showcaseStatusChanged', (data) => {
311
- * console.log('Showcase status value after changed:', data);
312
- * });
313
- * };
351
+ * ### What does it unlock?
352
+ * Initializes and displays the showcase/demo view for the configurator. Used when transitioning into presentation or demo mode.
314
353
  *
315
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
354
+ * ### Practical Application
355
+ * Loads the showcase/animation sequence attached to the current component. Must be called BEFORE PlayShowcase.
356
+ * Use to initialize auto-playing product demos, trade show presentations, or hero section animations on landing pages.
316
357
  *
317
- * @example
318
- * import { InitShowcase, Communicator } from '@3dsource/metabox-modular-configurator-api';
358
+ * ### AI Coding Best Practices
359
+ * ALWAYS call InitShowcase() before PlayShowcase(). Required sequence: InitShowcase → PlayShowcase → PauseShowcase/StopShowcase.
360
+ * Subscribe to showcaseStatusChanged to track playback state ('playing'/'paused'/'stopped').
319
361
  *
320
- * @param {Communicator} api - communicator instance api
362
+ * @example
363
+ * import { Communicator, ShowCaseStatus, InitShowcase } from '@3dsource/metabox-modular-configurator-api';
321
364
  * window.env3DSource.apiReady = (api: Communicator) => {
365
+ * //Subscribe to the event before sending the command to ensure you capture the response
366
+ * api.addEventListener('showcaseStatusChanged', (data:ShowCaseStatus) => {
367
+ * console.log('Showcase status value after changed:', data);
368
+ * });
369
+ *
322
370
  * api.sendCommandToMetabox(new InitShowcase());
323
371
  * };
324
372
  */
325
373
  class InitShowcase extends CommandBase {
326
- /**
327
- * Creates an instance of InitShowcase.
328
- *
329
- * @remarks
330
- * This constructor does not require any parameters.
331
- */
332
374
  constructor() {
333
375
  super();
334
376
  this.data = {
@@ -338,40 +380,35 @@ class InitShowcase extends CommandBase {
338
380
  }
339
381
 
340
382
  /**
341
- * Represents a command to play Showcase for a product when it is already initialized and paused.
342
- * @remarks
343
- * This class sends a command to the Metabox API to play showcase for a product if it is already initialized and paused.
383
+ * Represents a command to play Showcase for a component when it is already initialized and paused.
384
+ * This class sends a command to the Metabox API to play showcase for a component if it is already initialized and paused.
344
385
  *
345
386
  * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.
346
- * //...Assume that the integration is already implemented (only once)
347
- * @example
348
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
349
387
  *
350
- * @param {Communicator} api - communicator instance api
388
+ * ### What does it unlock?
389
+ * Starts or resumes the showcase/timeline playback. Executes the internal MetaBox play command internally.
390
+ *
391
+ * ### Practical Application
392
+ * Starts or resumes showcase playback. Use for 'Play Demo' buttons on landing pages, auto-play on page load,
393
+ * or resuming demos after inactivity timeout on kiosk displays.
394
+ *
395
+ * ### AI Coding Best Practices
396
+ * Call `api.sendCommandToMetabox(new PlayShowcase())`. Must call InitShowcase() first or it won't play.
397
+ * Subscribe to showcaseStatusChanged to track state. Auto-play pattern: wait for viewportReady → InitShowcase →
398
+ * PlayShowcase.
399
+ *
400
+ * @example
401
+ * import { Communicator, PlayShowcase } from '@3dsource/metabox-modular-configurator-api';
351
402
  * window.env3DSource.apiReady = (api: Communicator) => {
352
- * @param {ShowCaseStatus} data - showcase status value
403
+ * //Subscribe to the event before sending the command to ensure you capture the response
353
404
  * api.addEventListener('showcaseStatusChanged', (data) => {
354
405
  * console.log('Showcase status value after changed:', data);
355
406
  * });
356
- * };
357
- *
358
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
359
- *
360
- * @example
361
- * import { PlayShowcase, Communicator } from '@3dsource/metabox-modular-configurator-api';
362
407
  *
363
- * @param {Communicator} api - communicator instance api
364
- * window.env3DSource.apiReady = (api: Communicator) => {
365
408
  * api.sendCommandToMetabox(new PlayShowcase());
366
409
  * };
367
410
  */
368
411
  class PlayShowcase extends CommandBase {
369
- /**
370
- * Creates an instance of PlayShowcase.
371
- *
372
- * @remarks
373
- * This constructor does not require any parameters.
374
- */
375
412
  constructor() {
376
413
  super();
377
414
  this.data = { action: MetaboxModularConfiguratorActions.playShowcase };
@@ -394,40 +431,35 @@ class UnrealCommand extends CommandBase {
394
431
  }
395
432
 
396
433
  /**
397
- * Represents a command to pause Showcase for a product when it is already initialized and playing.
398
- * @remarks
399
- * This class sends a command to the Metabox API to pause showcase for a product if it is already initialized and playing.
434
+ * Represents a command to pause Showcase for a component when it is already initialized and playing.
435
+ * This class sends a command to the Metabox API to pause showcase for a component if it is already initialized and playing.
400
436
  *
401
437
  * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.
402
- * //...Assume that the integration is already implemented (only once)
403
- * @example
404
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
405
438
  *
406
- * @param {Communicator} api - communicator instance api
407
- * window.env3DSource.apiReady = (api: Communicator) => {
408
- * @param {ShowCaseStatus} data - showcase status value
409
- * api.addEventListener('showcaseStatusChanged', (data) => {
410
- * console.log('Showcase status value after changed:', data);
411
- * });
412
- * };
439
+ * ### What does it unlock?
440
+ * Pauses the showcase/timeline playback. Can be called independently without requiring any flag parameters.
413
441
  *
414
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
442
+ * ### Practical Application
443
+ * Pauses showcase animation playback. The showcase remains initialized and can be resumed with
444
+ * PlayShowcase. Use when you need to temporarily freeze the animation (e.g., on a "Pause" button click).
415
445
  *
416
- * @example
417
- * import { PauseShowcase, Communicator } from '@3dsource/metabox-modular-configurator-api';
446
+ * ### AI Coding Best Practices
447
+ * Call `api.sendCommandToMetabox(new PauseShowcase())`. No parameters. Subscribe to showcaseStatusChanged
448
+ * to confirm 'pause' state. Use PlayShowcase to resume or StopShowcase to reset.
418
449
  *
419
- * @param {Communicator} api - communicator instance api
450
+ * @example
451
+ * import { Communicator, ShowCaseStatus, PauseShowcase } from '@3dsource/metabox-modular-configurator-api';
420
452
  * window.env3DSource.apiReady = (api: Communicator) => {
421
- * api.sendCommandToMetabox(new PauseShowcase());
453
+ *
454
+ * //Subscribe to the event before sending the command to ensure you capture the response
455
+ * api.addEventListener('showcaseStatusChanged', (data:ShowCaseStatus) => {
456
+ * console.log('Showcase status value after changed:', data);
457
+ * });
458
+ *
459
+ * api.sendCommandToMetabox(new PauseShowcase());
422
460
  * };
423
461
  */
424
462
  class PauseShowcase extends CommandBase {
425
- /**
426
- * Creates an instance of PauseShowcase.
427
- *
428
- * @remarks
429
- * This constructor does not require any parameters.
430
- */
431
463
  constructor() {
432
464
  super();
433
465
  this.data = { action: MetaboxModularConfiguratorActions.pauseShowcase };
@@ -435,40 +467,36 @@ class PauseShowcase extends CommandBase {
435
467
  }
436
468
 
437
469
  /**
438
- * Represents a command to stop Showcase for a product when it is already initialized, and you want to destroy it.
439
- * @remarks
440
- * This class sends a command to the Metabox API to stop showcase for a product if it is already initialized.
470
+ * Represents a command to stop Showcase for a component when it is already initialized, and you want to destroy it.
471
+ * This class sends a command to the Metabox API to stop showcase for a component if it is already initialized.
441
472
  *
442
473
  * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.
443
- * //...Assume that the integration is already implemented (only once)
444
- * @example
445
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
446
474
  *
447
- * @param {Communicator} api - communicator instance api
448
- * window.env3DSource.apiReady = (api: Communicator) => {
449
- * @param {ShowCaseStatus} data - showcase status value
450
- * api.addEventListener('showcaseStatusChanged', (data) => {
451
- * console.log('Showcase status value after changed:', data);
452
- * });
453
- * };
475
+ * ### What does it unlock?
476
+ * Stops the showcase/timeline playback and closes the showcase mode. Returns to normal configurator view.
454
477
  *
455
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
478
+ * ### Practical Application
479
+ * Stops showcase playback and exits showcase mode entirely. Returns to normal interactive configurator view.
480
+ * Use for 'Exit Demo' buttons or auto-trigger when the user starts actively configuring the product.
456
481
  *
457
- * @example
458
- * import { StopShowcase, Communicator } from '@3dsource/metabox-modular-configurator-api';
482
+ * ### AI Coding Best Practices
483
+ * Call `api.sendCommandToMetabox(new StopShowcase())`. Fully resets the showcase state. Subscribe to
484
+ * showcaseStatusChanged to confirm 'stopped' status. After stopping, the configurator returns to full
485
+ * interactive mode — re-enable configuration controls.
459
486
  *
460
- * @param {Communicator} api - communicator instance api
487
+ * @example
488
+ * import { Communicator, ShowCaseStatus } from '@3dsource/metabox-modular-configurator-api';
461
489
  * window.env3DSource.apiReady = (api: Communicator) => {
462
- * api.sendCommandToMetabox(new StopShowcase());
490
+ *
491
+ * //Subscribe to the event before sending the command to ensure you capture the response
492
+ * api.addEventListener('showcaseStatusChanged', (data:ShowCaseStatus) => {
493
+ * console.log('Showcase status value after changed:', data);
494
+ * });
495
+ *
496
+ * api.sendCommandToMetabox(new StopShowcase());
463
497
  * };
464
498
  */
465
499
  class StopShowcase extends CommandBase {
466
- /**
467
- * Creates an instance of StopShowcase.
468
- *
469
- * @remarks
470
- * This constructor does not require any parameters.
471
- */
472
500
  constructor() {
473
501
  super();
474
502
  this.data = { action: MetaboxModularConfiguratorActions.stopShowcase };
@@ -477,37 +505,42 @@ class StopShowcase extends CommandBase {
477
505
 
478
506
  /**
479
507
  * Represents a command to get a screenshot.
480
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
481
508
  *
482
- * @remarks
483
- * To listen for changes after sending this command, listen to the 'screenshot' event.
484
- * //...Assume that the integration is already implemented (only once)
485
- * @example
486
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
509
+ * To listen for changes after sending this command, listen to the 'screenshot' event before command is sent.
510
+ *
511
+ * ### What does it unlock?
512
+ * Takes a screenshot on the server side (Unreal Engine) of the 3D scene. Returns high-quality image.
513
+ * Requires subscription to the screenshotReady event to receive the rendered image.
514
+ *
515
+ * ### Practical Application
516
+ * Renders a high-res screenshot on the Unreal Engine server. Takes format ('image/png'|'image/jpeg'|'image/webp')
517
+ * and optional size ({x, y}). Returns base64 data via screenshotReady event. Use for thumbnails, social sharing,
518
+ * saving config snapshots, or attaching images to quotes.
519
+ *
520
+ * ### AI Coding Best Practices
521
+ * Subscribe to screenshotReady BEFORE sending GetScreenshot. Pattern:
522
+ * `api.addEventListener('screenshotReady', (data) => { if(data) saveImage(data, 'name.png'); })`.
523
+ * Specify size for consistent outputs: `new GetScreenshot('image/png', {x:2048, y:2048})`.
524
+ * Use saveImage() helper to convert base64 to downloadable file.
487
525
  *
488
- * @param {Communicator} api - communicator instance api
526
+ * @example
527
+ * import { Communicator, saveImage, GetScreenshot } from '@3dsource/metabox-modular-configurator-api';
489
528
  * window.env3DSource.apiReady = (api: Communicator) => {
490
- * @param {string} data - base64 string image
491
- * api.addEventListener('screenshot', (data) => {
529
+ *
530
+ * //Subscribe to the event before sending the command to ensure you capture the response
531
+ * api.addEventListener('screenshot', (data:string) => {
532
+ * // The data is a base64 string of the image. You can use it to display the image or save it as a file.
492
533
  * console.log('Get screenshot here:', data);
493
534
  * saveImage(data, 'Render.png');
494
535
  * });
495
- * };
496
- *
497
- * @example
498
- * import { GetScreenshot, Communicator, saveImage } from '@3dsource/metabox-modular-configurator-api';
499
536
  *
500
- * @param {Communicator} api - communicator instance api
501
- * window.env3DSource.apiReady = (api: Communicator) => {
502
- * api.sendCommandToMetabox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
537
+ * api.sendCommandToMetabox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
503
538
  * };
539
+ *
540
+ * @param {MimeType} mimeType - The output format.
541
+ * @param {{ x: number; y: number }} [size] - Optional size in pixels.
504
542
  */
505
543
  class GetScreenshot extends CommandBase {
506
- /**
507
- * Constructs an instance of GetScreenshot.
508
- * @param {MimeType} mimeType - The output format.
509
- * @param {{ x: number; y: number }} [size] - Optional size in pixels.
510
- */
511
544
  constructor(mimeType, size) {
512
545
  super();
513
546
  this.data = {
@@ -518,44 +551,46 @@ class GetScreenshot extends CommandBase {
518
551
  }
519
552
 
520
553
  /**
521
- * Represents a command to set a component by its data (ID, typeId, isRoot).
522
- *
523
- * @remarks
554
+ * Represents a command to set a component by its data (ID, typeId).
555
+ * This action sends a message to the Metabox API to set a component using the provided data.
524
556
  * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.
525
- * //...Assume that the integration is already implemented (only once)
526
- * @example
527
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
528
557
  *
529
- * @param {Communicator} api - communicator instance api
558
+ * ### What does it unlock?
559
+ * Sets a component during initialization, which triggers the reconstruction of the component tree structure.
560
+ * Simulates clicking a component in the menu.
561
+ *
562
+ * ### Practical Application
563
+ * Selects a component in the modular assembly. Takes componentId (UUID), typeId (category string).
564
+ * CRITICAL: Always set root component (isRoot:true) FIRST — nothing renders without it. Then add children (isRoot:false).
565
+ * Simulates clicking a component in the menu.
566
+ *
567
+ * ### AI Coding Best Practices
568
+ * ALWAYS set root first: `new SetComponent('id', 'type', true)`. Then children: `new SetComponent('childId', 'childType', false)`.
569
+ * Get valid IDs from configuratorDataUpdated event data — the configurator definition contains all available components and types.
570
+ * Wrong order = blank viewport. The typeId must match componentType values from the configurator.
571
+ *
572
+ * @example
573
+ * import { Communicator, ModularConfiguratorEnvelope, SetComponent } from '@3dsource/metabox-modular-configurator-api';
530
574
  * window.env3DSource.apiReady = (api: Communicator) => {
531
- * @param {ConfiguratorEnvelope} data - configurator state after updated
532
- * api.addEventListener('configuratorDataUpdated', (data) => {
575
+ *
576
+ * //Subscribe to the event before sending the command to ensure you capture the response
577
+ * api.addEventListener('configuratorDataUpdated', (data:ModularConfiguratorEnvelope) => {
533
578
  * console.log('State updated after applied new component:', data);
534
579
  * });
535
- * };
536
- *
537
- * @example
538
- * import { SetComponent, Communicator } from '@3dsource/metabox-modular-configurator-api';
539
580
  *
540
- * @param {Communicator} api - communicator instance api
541
- * window.env3DSource.apiReady = (api: Communicator) => {
542
- * api.sendCommandToMetabox(new SetComponent(
543
- * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3', 'typeId', true
581
+ * api.sendCommandToMetabox(new SetComponent(
582
+ * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3', 'typeId'
544
583
  * ));
545
584
  * };
585
+ *
586
+ * @param {string} id - The component ID.
587
+ * @param {string} typeId - The component type ID.
546
588
  */
547
589
  class SetComponent extends CommandBase {
548
- /**
549
- * Creates an instance of SetComponent.
550
- *
551
- * @param {string} id - The component ID.
552
- * @param {string} typeId - The component type ID.
553
- * @param {boolean} isRoot - Whether this is a root component.
554
- */
555
- constructor(id, typeId, isRoot) {
590
+ constructor(id, typeId) {
556
591
  super();
557
592
  this.data = {
558
- payload: { id, typeId, isRoot },
593
+ payload: { id, typeId },
559
594
  action: MetaboxModularConfiguratorActions.setComponent,
560
595
  };
561
596
  }
@@ -563,41 +598,42 @@ class SetComponent extends CommandBase {
563
598
 
564
599
  /**
565
600
  * Represents a command to set component material by its slot ID and Material ID.
566
- *
567
- * @remarks
568
601
  * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.
569
- * //...Assume that the integration is already implemented (only once)
570
- * @example
571
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
572
602
  *
573
- * @param {Communicator} api - communicator instance api
574
- * window.env3DSource.apiReady = (api: Communicator) => {
575
- * @param {ConfiguratorEnvelope} data - configurator state after updated
576
- * api.addEventListener('configuratorDataUpdated', (data) => {
577
- * console.log('State updated after applied new product:', data);
578
- * });
579
- * };
603
+ * ### What does it unlock?
604
+ * Sets a material variant for a component. Simulates selecting a different material from the menu for a specific component.
580
605
  *
581
- * @example
582
- * import { SetComponentMaterial, Communicator } from '@3dsource/metabox-modular-configurator-api';
606
+ * ### Practical Application
607
+ * Applies a material to a specific slot on a component. Takes componentId (UUID), slotId (string), and materialId (UUID).
608
+ * Use to build swatch pickers, apply preset themes/bundles, or sync material selections from an external
609
+ * PIM/ERP system via externalId mapping.
610
+ *
611
+ * ### AI Coding Best Practices
612
+ * Get valid slotId and materialId values from the configuratorDataUpdated envelope —
613
+ * check component slot definitions and material lists. Pattern:
614
+ * `new SetComponentMaterial('component-uuid', 'slot-name', 'material-uuid')`. The referenced component must already be set in the tree.
583
615
  *
584
- * @param {Communicator} api - communicator instance api
616
+ * @example
617
+ * import { Communicator, ModularConfiguratorEnvelope, SetComponentMaterial } from '@3dsource/metabox-modular-configurator-api';
585
618
  * window.env3DSource.apiReady = (api: Communicator) => {
586
- * api.sendCommandToMetabox(new SetComponentMaterial(
619
+ *
620
+ * //Subscribe to the event before sending the command to ensure you capture the response
621
+ * api.addEventListener('configuratorDataUpdated', (data:ModularConfiguratorEnvelope) => {
622
+ * console.log('State updated after applied new material:', data);
623
+ * });
624
+ *
625
+ * api.sendCommandToMetabox(new SetComponentMaterial(
587
626
  * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
588
627
  * 'carpaint',
589
628
  * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
590
629
  * ));
591
630
  * };
631
+ *
632
+ * @param {string} componentId - The component ID.
633
+ * @param {string} slotId - The slot ID.
634
+ * @param {string} materialId - The material ID.
592
635
  */
593
636
  class SetComponentMaterial extends CommandBase {
594
- /**
595
- * Creates an instance of SetComponentMaterial.
596
- *
597
- * @param {string} componentId - The component ID.
598
- * @param {string} slotId - The slot ID.
599
- * @param {string} materialId - The material ID.
600
- */
601
637
  constructor(componentId, slotId, materialId) {
602
638
  super();
603
639
  this.data = {
@@ -609,35 +645,35 @@ class SetComponentMaterial extends CommandBase {
609
645
 
610
646
  /**
611
647
  * Represents a command to set the environment by its ID.
612
- *
613
- * @remarks
614
648
  * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.
615
- * //...Assume that the integration is already implemented (only once)
616
- * @example
617
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
618
649
  *
619
- * @param {Communicator} api - communicator instance api
650
+ * ### What does it unlock?
651
+ * Sets environmental/lighting settings for the scene. Controls factors like lighting conditions and environmental appearance.
652
+ *
653
+ * ### Practical Application
654
+ * Changes the 3D scene/environment (studio, showroom, outdoor, etc.). Takes an environmentId UUID.
655
+ * Environments include lighting, backdrop, and optionally dynamic sky (udsEnabled) with time-of-day (udsHour) control.
656
+ *
657
+ * ### AI Coding Best Practices
658
+ * Call `api.sendCommandToMetabox(new SetEnvironment('env-uuid'))`. Get valid environment IDs from the configurator
659
+ * definition in configuratorDataUpdated. Set environment after root component during initialization. Each environment has
660
+ * its own material slots, thumbnails, and lighting properties.
661
+ *
662
+ * @example
663
+ * import { Communicator, ModularConfiguratorEnvelope } from '@3dsource/metabox-modular-configurator-api';
620
664
  * window.env3DSource.apiReady = (api: Communicator) => {
621
- * @param {ConfiguratorEnvelope} data - configurator state after updated
622
- * api.addEventListener('configuratorDataUpdated', (data) => {
665
+ *
666
+ * //Subscribe to the event before sending the command to ensure you capture the response
667
+ * api.addEventListener('configuratorDataUpdated', (data:ModularConfiguratorEnvelope) => {
623
668
  * console.log('State updated after applied new environment:', data);
624
669
  * });
625
- * };
626
670
  *
627
- * @example
628
- * import { SetEnvironment, Communicator } from '@3dsource/metabox-modular-configurator-api';
629
- *
630
- * @param {Communicator} api - communicator instance api
631
- * window.env3DSource.apiReady = (api: Communicator) => {
632
- * api.sendCommandToMetabox(new SetEnvironment('55555555-1234-1234-1234-01234567890'));
671
+ * api.sendCommandToMetabox(new SetEnvironment('55555555-1234-1234-1234-01234567890'))
633
672
  * };
673
+ *
674
+ * @param {string} environmentId - The environment ID.
634
675
  */
635
676
  class SetEnvironment extends CommandBase {
636
- /**
637
- * Creates an instance of SetEnvironment.
638
- *
639
- * @param {string} environmentId - The environment ID.
640
- */
641
677
  constructor(environmentId) {
642
678
  super();
643
679
  this.data = {
@@ -649,39 +685,40 @@ class SetEnvironment extends CommandBase {
649
685
 
650
686
  /**
651
687
  * Represents a command to set an environment material by its slot ID and Material ID.
652
- *
653
- * @remarks
654
688
  * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.
655
- * //...Assume that the integration is already implemented (only once)
656
- * @example
657
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
658
689
  *
659
- * @param {Communicator} api - communicator instance api
690
+ * ### What does it unlock?
691
+ * Sets environmental material properties such as textures and appearance attributes for the scene environment.
692
+ *
693
+ * ### Practical Application
694
+ * Applies materials to environment slots (floor, walls, backdrop textures). Takes slotId and materialId.
695
+ * Use for scene-based configurators where the environment is also customizable — kitchen visualizers,
696
+ * room planners, trade show booth designers.
697
+ *
698
+ * ### AI Coding Best Practices
699
+ * Pattern: `new SetEnvironmentMaterial('floor-slot-id', 'material-uuid')`. Get valid slot and material IDs from
700
+ * the environment definition's slots array in configuratorDataUpdated. Only useful when the active environment
701
+ * has configurable material slots.
702
+ *
703
+ * @example
704
+ * import { Communicator, ModularConfiguratorEnvelope } from '@3dsource/metabox-modular-configurator-api';
660
705
  * window.env3DSource.apiReady = (api: Communicator) => {
661
- * @param {ConfiguratorEnvelope} data - configurator state after updated
662
- * api.addEventListener('configuratorDataUpdated', (data) => {
706
+ *
707
+ * //Subscribe to the event before sending the command to ensure you capture the response
708
+ * api.addEventListener('configuratorDataUpdated', (data:ModularConfiguratorEnvelope) => {
663
709
  * console.log('State updated after applied new environment material:', data);
664
710
  * });
665
- * };
666
- *
667
- * @example
668
- * import { SetEnvironmentMaterial, Communicator } from '@3dsource/metabox-modular-configurator-api';
669
711
  *
670
- * @param {Communicator} api - communicator instance api
671
- * window.env3DSource.apiReady = (api: Communicator) => {
672
- * api.sendCommandToMetabox(new SetEnvironmentMaterial(
712
+ * api.sendCommandToMetabox(new SetEnvironmentMaterial(
673
713
  * 'carpaint',
674
714
  * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
675
715
  * ));
676
716
  * };
717
+ *
718
+ * @param {string} slotId - The slot ID.
719
+ * @param {string} materialId - The material ID.
677
720
  */
678
721
  class SetEnvironmentMaterial extends CommandBase {
679
- /**
680
- * Creates an instance of SetEnvironmentMaterial.
681
- *
682
- * @param {string} slotId - The slot ID.
683
- * @param {string} materialId - The material ID.
684
- */
685
722
  constructor(slotId, materialId) {
686
723
  super();
687
724
  this.data = {
@@ -693,24 +730,30 @@ class SetEnvironmentMaterial extends CommandBase {
693
730
 
694
731
  /**
695
732
  * Represents a command to toggle the embedded Metabox menu.
696
- * @remarks
697
733
  * This command can only be used when using the metabox menu.
698
- * **Important**: No need to listen to any events to see changes.
734
+ *
735
+ * ### What does it unlock?
736
+ * Shows the embedded menu interface. Only works when using the MetaBox native menu (not in standalone/custom menu
737
+ * mode).
738
+ *
739
+ * ### Practical Application
740
+ * Toggles the native MetaBox right sidebar menu. Takes a boolean parameter. Pass false to hide when building custom UI.
741
+ * In standalone mode, the menu is already hidden — this is only relevant in default (non-standalone) mode.
742
+ *
743
+ * ### AI Coding Best Practices
744
+ * In standalone mode (`{standalone:true}`), this is unnecessary (menu already hidden). In default mode,
745
+ * call `new ShowEmbeddedMenu(false)` early in initialization to hide built-in UI before rendering custom controls.
746
+ * Pattern for custom UI: `ShowEmbeddedMenu(false)` + `ShowOverlayInterface(false)`.
699
747
  *
700
748
  * @example
701
749
  * import { ShowEmbeddedMenu, Communicator } from '@3dsource/metabox-modular-configurator-api';
702
- *
703
- * @param {Communicator} api - communicator instance api
704
750
  * window.env3DSource.apiReady = (api: Communicator) => {
705
751
  * api.sendCommandToMetabox(new ShowEmbeddedMenu(true));
706
752
  * };
753
+ *
754
+ * @param {boolean} visible - A flag indicating whether the embedded menu should be visible.
707
755
  */
708
756
  class ShowEmbeddedMenu extends CommandBase {
709
- /**
710
- * Creates an instance of ShowEmbeddedMenu.
711
- *
712
- * @param {boolean} visible - A flag indicating whether the embedded menu should be visible.
713
- */
714
757
  constructor(visible) {
715
758
  super();
716
759
  this.data = {
@@ -722,25 +765,30 @@ class ShowEmbeddedMenu extends CommandBase {
722
765
 
723
766
  /**
724
767
  * Represents a command to toggle the Unreal Overlay Interface Menu.
725
- *
726
- * @remarks
727
768
  * This action sends a message to the Metabox API to toggle the visibility of the Unreal overlay UI.
728
- * **Important**: No need to listen to any events to see changes.
769
+ *
770
+ * ### What does it unlock?
771
+ * Shows the overlay interface elements. Displays UI controls and buttons overlaid on the 3D scene.
772
+ *
773
+ * ### Practical Application
774
+ * Toggles viewport overlay controls (buttons overlaid on the 3D scene). Takes a boolean.
775
+ * Use `ShowOverlayInterface(false)` alongside `ShowEmbeddedMenu(false)` when building fully custom UI
776
+ * that replaces all native MetaBox controls.
777
+ *
778
+ * ### AI Coding Best Practices
779
+ * In standalone mode, overlays are already hidden. In default mode, call `new ShowOverlayInterface(false)`
780
+ * early in initialization to prevent flash of native UI. Always pair with `ShowEmbeddedMenu(false)` for clean custom UI.
781
+ * Pass true to restore if entering a mode that uses native controls.
729
782
  *
730
783
  * @example
731
784
  * import { ShowOverlayInterface, Communicator } from '@3dsource/metabox-modular-configurator-api';
732
- *
733
- * @param {Communicator} api - communicator instance api
734
785
  * window.env3DSource.apiReady = (api: Communicator) => {
735
- * api.setCommandToMetaBox(new ShowOverlayInterface(true));
786
+ * api.sendCommandToMetabox(new ShowOverlayInterface(true));
736
787
  * };
788
+ *
789
+ * @param {boolean} visible - A flag indicating whether the Unreal overlay UI should be visible.
737
790
  */
738
791
  class ShowOverlayInterface extends CommandBase {
739
- /**
740
- * Creates an instance of ShowOverlayInterface.
741
- *
742
- * @param {boolean} visible - A flag indicating whether the Unreal overlay UI should be visible.
743
- */
744
792
  constructor(visible) {
745
793
  super();
746
794
  this.data = {
@@ -752,26 +800,26 @@ class ShowOverlayInterface extends CommandBase {
752
800
 
753
801
  /**
754
802
  * Represents a command to show measurement for a product when it is already loaded.
755
- * @remarks
756
803
  * This class sends a command to the Metabox API to show measurement for a product if it is already initialized.
757
- * **Important**: No need to listen to any events to see changes.
758
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
804
+ *
805
+ * ### What does it unlock?
806
+ * Shows the measurement overlay. Works as a toggle with HideMeasurement to control visibility.
807
+ *
808
+ * ### Practical Application
809
+ * Shows the measurement/dimension overlay tools on the 3D viewport. Use for B2B or technical applications
810
+ * where buyers need to verify product dimensions, check fit specifications, or confirm measurements during procurement.
811
+ *
812
+ * ### AI Coding Best Practices
813
+ * Call `api.sendCommandToMetabox(new ShowMeasurement())`. No parameters. Pair with HideMeasurement for toggle behavior.
814
+ * Track visibility state in your app to keep toggle buttons in sync.
759
815
  *
760
816
  * @example
761
817
  * import { ShowMeasurement, Communicator } from '@3dsource/metabox-modular-configurator-api';
762
- *
763
- * @param {Communicator} api - communicator instance api
764
818
  * window.env3DSource.apiReady = (api: Communicator) => {
765
819
  * api.sendCommandToMetabox(new ShowMeasurement());
766
820
  * };
767
821
  */
768
822
  class ShowMeasurement extends CommandBase {
769
- /**
770
- * Creates an instance of ShowMeasurement.
771
- *
772
- * @remarks
773
- * This constructor does not require any parameters.
774
- */
775
823
  constructor() {
776
824
  super();
777
825
  this.data = { action: MetaboxModularConfiguratorActions.showMeasurement };
@@ -780,26 +828,26 @@ class ShowMeasurement extends CommandBase {
780
828
 
781
829
  /**
782
830
  * Represents a command to hide measurement for a product when it is already loaded.
783
- * @remarks
784
831
  * This class sends a command to the Metabox API to hide measurement for a product if it is already initialized.
785
- * **Important**: No need to listen to any events to see changes.
786
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
832
+ *
833
+ * ### What does it unlock?
834
+ * Hides the measurement overlay. Executes unconditionally to hide the UI controls.
835
+ *
836
+ * ### Practical Application
837
+ * Hides the measurement/dimension overlay. Use when transitioning from a technical spec view back to a clean
838
+ * product presentation, or to keep consumer-facing configurators visually clean.
839
+ *
840
+ * ### AI Coding Best Practices
841
+ * Call `api.sendCommandToMetabox(new HideMeasurement())`. No parameters. Pair with ShowMeasurement as a toggle.
842
+ * Track visibility state in your app state to keep toggle buttons in sync.
787
843
  *
788
844
  * @example
789
845
  * import { HideMeasurement, Communicator } from '@3dsource/metabox-modular-configurator-api';
790
- *
791
- * @param {Communicator} api - communicator instance api
792
846
  * window.env3DSource.apiReady = (api: Communicator) => {
793
847
  * api.sendCommandToMetabox(new HideMeasurement());
794
848
  * };
795
849
  */
796
850
  class HideMeasurement extends CommandBase {
797
- /**
798
- * Creates an instance of HideMeasurement.
799
- *
800
- * @remarks
801
- * This constructor does not require any parameters.
802
- */
803
851
  constructor() {
804
852
  super();
805
853
  this.data = { action: MetaboxModularConfiguratorActions.hideMeasurement };
@@ -808,26 +856,29 @@ class HideMeasurement extends CommandBase {
808
856
 
809
857
  /**
810
858
  * Represents a command to force set the device type.
811
- *
812
- * @remarks
813
859
  * This class sends a message to the Metabox API to force set the device type.
814
- * **Important**: No need to listen to any events to see changes.
815
- * //...Assume that the integration is already implemented (only once)
860
+ *
861
+ * ### What does it unlock?
862
+ * Forces the specification of device type (desktop or mobile) for the MetaBox configurator. Possibly deprecated.
863
+ *
864
+ * ### Practical Application
865
+ * Forces device type override (desktop/tablet/mobile). Likely deprecated — MetaBox auto-detects via ApplicationDeviceTypes.
866
+ * Only relevant for kiosk or showroom setups where you need to force a specific rendering mode.
867
+ *
868
+ * ### AI Coding Best Practices
869
+ * Avoid unless you have a confirmed kiosk/showroom use case. If needed, set it once during initialization only.
870
+ * Prefer letting MetaBox handle device detection automatically.
816
871
  *
817
872
  * @example
818
873
  * import { ForceSetDeviceType, Communicator } from '@3dsource/metabox-modular-configurator-api';
819
874
  *
820
- * @param {Communicator} api - communicator instance api
821
875
  * window.env3DSource.apiReady = (api: Communicator) => {
822
876
  * api.sendCommandToMetabox(new ForceSetDeviceType('desktop'));
823
877
  * };
878
+ *
879
+ * @param {ApplicationDeviceTypes} deviceType - The device type to force set.
824
880
  */
825
881
  class ForceSetDeviceType extends CommandBase {
826
- /**
827
- * Creates an instance of ForceSetDeviceType.
828
- *
829
- * @param {ApplicationDeviceTypes} deviceType - The device type to force set.
830
- */
831
882
  constructor(deviceType) {
832
883
  super();
833
884
  this.data = {
@@ -837,8 +888,47 @@ class ForceSetDeviceType extends CommandBase {
837
888
  }
838
889
  }
839
890
 
891
+ /**
892
+ * Represents a command to resume the pixel streaming session.
893
+ * This class sends a message to the Metabox API to resume a paused or disconnected stream.
894
+ *
895
+ * ### What does it unlock?
896
+ * Resumes the Unreal Engine pixel streaming connection after it has been paused, disconnected, or stopped due to inactivity (AFK timeout).
897
+ *
898
+ * ### Practical Application
899
+ * Used to reconnect the 3D streaming session without a full page reload. Essential for 'Reconnect' or 'Resume' buttons
900
+ * shown when the stream is interrupted, e.g., after an idle timeout or network disruption.
901
+ *
902
+ * ### AI Coding Best Practices
903
+ * Call `api.sendCommandToMetabox(new ResumeStream())`. No parameters. Resumes the existing streaming session —
904
+ * does not reinitialize the configurator or reset component/environment state.
905
+ *
906
+ * @example
907
+ * import { ResumeStream, Communicator } from '@3dsource/metabox-modular-configurator-api';
908
+ * window.env3DSource.apiReady = (api: Communicator) => {
909
+ * api.sendCommandToMetabox(new ResumeStream());
910
+ * };
911
+ */
912
+ class ResumeStream extends CommandBase {
913
+ constructor() {
914
+ super();
915
+ this.data = { action: MetaboxModularConfiguratorActions.resumeStream };
916
+ }
917
+ }
918
+
840
919
  /**
841
920
  * EventDispatcher is a class that manages event listeners and dispatches events to them.
921
+ *
922
+ * ### What does it unlock?
923
+ * Parent class of Communicator that dispatches commands. Acts as an event dispatcher that routes command messages internally.
924
+ *
925
+ * ### Practical Application
926
+ * Internal event routing layer — parent class of Communicator. Routes postMessage commands between your app
927
+ * and the Unreal Engine pixel stream. Not used directly but understanding it helps debug message delivery issues.
928
+ *
929
+ * ### AI Coding Best Practices
930
+ * Do not reference or extend EventDispatcher in application code. Use only the Communicator interface methods.
931
+ * If debugging communication failures, check browser console for postMessage errors related to this layer.
842
932
  */
843
933
  class EventDispatcher {
844
934
  constructor() {
@@ -847,6 +937,10 @@ class EventDispatcher {
847
937
  */
848
938
  this.listeners = [];
849
939
  }
940
+ /**
941
+ * Removes all registered listeners. Subclasses override this to perform additional cleanup.
942
+ * @param key - Instance key (used by subclass overrides for registry cleanup).
943
+ */
850
944
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
851
945
  destroy(key) {
852
946
  this.listeners = [];
@@ -888,28 +982,142 @@ class EventDispatcher {
888
982
  /**
889
983
  * @internal
890
984
  * @hidden
891
- * Represents main constants.
985
+ * Core constants used for host-to-iframe communication and URL construction.
986
+ */
987
+ /**
988
+ * Storage key for the Metabox Communicator instance registry.
989
+ *
990
+ * ### What does it unlock?
991
+ * Constant string identifier for MetaBox version. Used internally to reference the MetaBox system and versioning.
992
+ *
993
+ * ### Practical Application
994
+ * Internal system reference for versioning.
995
+ * Not needed in front-end application code.
996
+ *
997
+ * ### AI Coding Best Practices
998
+ * Skip in application code. This constant is for internal MetaBox system identification only.
999
+ *
1000
+ * @internal
1001
+ */
1002
+ const Metabox = 'metabox';
1003
+ /**
1004
+ * Identifier used as the `host` field in postMessage envelopes sent to the iframe.
1005
+ *
1006
+ * ### What does it unlock?
1007
+ * Constant for the MetaBox host connection point. Specifies endpoint for MetaBox connections.
1008
+ *
1009
+ * ### Practical Application
1010
+ * MetaBox endpoint constant. The host the configurator iframe connects to for Unreal Engine pixel streaming.
1011
+ * Not needed in front-end application code.
1012
+ *
1013
+ * ### AI Coding Best Practices
1014
+ * Skip in application code. This constant is for internal MetaBox system identification only.
1015
+ *
1016
+ * @internal
1017
+ */
1018
+ const MetaboxHost = 'metaboxHost';
1019
+ /**
1020
+ * Identifier used as the `host` field in postMessage envelopes received from the iframe.
1021
+ *
1022
+ * ### What does it unlock?
1023
+ * Constant identifier used internally to reference and compare MetaBox data. Used for data validation and internal routing.
1024
+ *
1025
+ * ### Practical Application
1026
+ * Internal data reference constant used for validation and message routing within the communication layer.
1027
+ * Not needed in front-end application code.
1028
+ *
1029
+ * ### AI Coding Best Practices
1030
+ * Skip in application code. Only relevant if debugging very low-level message traffic between your app and the MetaBox iframe.
1031
+ *
1032
+ * @internal
1033
+ */
1034
+ const MetaboxData = 'metaboxData';
1035
+ /**
1036
+ * Action string dispatched by the iframe when the configurator app has loaded.
1037
+ *
1038
+ * ### What does it unlock?
1039
+ * App initialization flag variable. Signals when MetaBox has completed loading.
1040
+ *
1041
+ * ### Practical Application
1042
+ * Use the viewportReady event (more reliable) to gate your UI rendering — don't show controls until MetaBox confirms it's ready.
1043
+ *
1044
+ * ### AI Coding Best Practices
1045
+ * Prefer the viewportReady event over this variable: `api.addEventListener('viewportReady', (ready) => { if(ready) enableUI(); })`.
1046
+ * viewportReady is the reliable signal that MetaBox is ready to accept commands.
1047
+ *
1048
+ * @internal
892
1049
  */
893
- const Metabox = 'metabox_v3';
894
- // TODO need to delete all of this
895
- const MetaboxHost = 'metaboxHost_v3';
896
- const MetaboxData = 'metaboxData_v3';
897
1050
  const AppLoaded = 'appLoaded_v3';
1051
+ /**
1052
+ * Default MetaBox domain for production environments.
1053
+ *
1054
+ * ### What does it unlock?
1055
+ * Constant for the standard default MetaBox domain. Used as the primary domain for connecting to MetaBox server.
1056
+ *
1057
+ * ### Practical Application
1058
+ * Default MetaBox domain constant (HTTPS). The base domain used when no override is specified.
1059
+ * Override only via IntegrateMetaboxConfig.domain if connecting to a custom or self-hosted MetaBox instance.
1060
+ *
1061
+ * ### AI Coding Best Practices
1062
+ * Let integrateMetabox() use the default. Override only if needed:
1063
+ * `integrateMetabox(id, container, callback, { domain: 'https://custom.domain.com' })`. HTTPS is mandatory.
1064
+ *
1065
+ * @internal
1066
+ */
1067
+ /**
1068
+ * @deprecated
1069
+ */
1070
+ const Metabox_V3 = 'metabox_v3';
1071
+ /**
1072
+ * @deprecated
1073
+ */
1074
+ const MetaboxHost_V3 = 'metaboxHost_v3';
1075
+ /**
1076
+ * @deprecated
1077
+ */
1078
+ const AppLoaded_V3 = 'appLoaded_v3';
898
1079
  const MetaboxDomain = 'metabox.3dsource.com';
1080
+ /**
1081
+ * Base route URL segment for the Modular Configurator.
1082
+ *
1083
+ * ### What does it unlock?
1084
+ * Base route URL constant used for loading the configurator. Standard path endpoint for accessing the modular configurator.
1085
+ *
1086
+ * ### Practical Application
1087
+ * The modular configurator URL format is: `https://{domain}/metabox-configurator/modular/{configuratorId}`.
1088
+ * Automatically constructed by integrateMetabox().
1089
+ *
1090
+ * ### AI Coding Best Practices
1091
+ * Let integrateMetabox() handle URL construction. Only reference if building URLs manually
1092
+ * (e.g., QR codes, email links, server-side rendering). The modular path is `/modular/{id}`.
1093
+ *
1094
+ * @internal
1095
+ */
899
1096
  const BasicRouteUrl = 'metabox-configurator/modular';
900
1097
 
901
- const VERSION = '3.0.19-dev.1';
1098
+ const VERSION = '3.0.19-dev.11';
902
1099
 
903
1100
  const communicatorMap = new Map();
904
1101
  /**
905
- * Handles messaging between the host page and embedded to the Metabox content.
1102
+ * Handles messaging between the host page and embedded Metabox content.
1103
+ *
1104
+ * ### What does it unlock?
1105
+ * Internal class that creates a proxy/communication layer between the API and MetaBox.
1106
+ * Handles reading and sending commands through the established connection.
1107
+ *
1108
+ * ### Practical Application
1109
+ * The API handle returned in the integrateMetabox callback. Provides sendCommandToMetabox() to send commands,
1110
+ * and addEventListener()/removeEventListener() for event subscriptions. This is your entire interface to
1111
+ * the MetaBox Unreal Engine stream.
1112
+ *
1113
+ * ### AI Coding Best Practices
1114
+ * Store the Communicator reference from the apiReadyCallback in a module-scoped variable or state store.
1115
+ * NEVER send commands before this callback fires. All commands and event listeners go through this single
1116
+ * api object. Clean up listeners with removeEventListener on component unmount.
1117
+ *
906
1118
  * @internal Use {@link Communicator.createInstance} or the {@link integrateMetabox} helper to instantiate.
907
1119
  */
908
1120
  class Communicator extends EventDispatcher {
909
- /**
910
- * Singleton reference to the current communicator instance.
911
- */
912
- static { this.instance = null; }
913
1121
  /**
914
1122
  * Constructs a Communicator, replacing any existing instance, and begins listening for messages.
915
1123
  * @internal
@@ -919,7 +1127,7 @@ class Communicator extends EventDispatcher {
919
1127
  /**
920
1128
  * Bound handler for incoming postMessage events.
921
1129
  */
922
- this.binder = this.handleMessageReceived.bind(this, MetaboxData);
1130
+ this.binder = this.handleMessageReceived.bind(this);
923
1131
  const { appId = 'unknown', version = VERSION } = data ?? {};
924
1132
  const key = `${version}_${environment}_${appId}`;
925
1133
  communicatorMap.get(key)?.instance.destroy(key);
@@ -933,15 +1141,14 @@ class Communicator extends EventDispatcher {
933
1141
  }
934
1142
  /**
935
1143
  * Listens for Metabox to signal readiness, then initializes communicator.
936
- * @param apiReadyCallback - Called with the new Communicator once to the Metabox is loaded.
1144
+ * @param apiReadyCallback - Called with the new Communicator once the Metabox is loaded.
937
1145
  * @param {MetaboxEnvironment} environment - The environment in which the Communicator is running.
938
1146
  * @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic
939
1147
  */
940
1148
  static createInstance(apiReadyCallback, environment, config) {
941
1149
  const startHandler = (event) => {
942
1150
  const message = event.data;
943
- if (message?.envelope?.action === 'appLoaded_v3' &&
944
- message.host === Metabox) {
1151
+ if (message?.envelope?.action === AppLoaded && message.host === Metabox) {
945
1152
  apiReadyCallback(new Communicator(message.envelope.payload, environment, config));
946
1153
  window.removeEventListener('message', startHandler);
947
1154
  }
@@ -955,6 +1162,7 @@ class Communicator extends EventDispatcher {
955
1162
  super.destroy(key);
956
1163
  window.removeEventListener('message', this.binder);
957
1164
  }
1165
+ /** Destroys all active Communicator instances and clears the internal registry. */
958
1166
  static clearAll() {
959
1167
  if (communicatorMap.size === 0) {
960
1168
  return;
@@ -962,6 +1170,10 @@ class Communicator extends EventDispatcher {
962
1170
  communicatorMap.forEach((value, key) => value.instance.destroy(key));
963
1171
  communicatorMap.clear();
964
1172
  }
1173
+ /**
1174
+ * Retrieves a registered Communicator instance by its key.
1175
+ * @param key - The composite key (`version_environment_appId`) identifying the instance.
1176
+ */
965
1177
  static getCommunicator(key) {
966
1178
  return communicatorMap.get(key);
967
1179
  }
@@ -973,9 +1185,11 @@ class Communicator extends EventDispatcher {
973
1185
  const { data } = command;
974
1186
  const iframe = document.getElementById('embeddedContent');
975
1187
  const toMetaboxMessage = {
976
- host: Metabox,
1188
+ host: MetaboxHost,
977
1189
  envelope: { ...data },
1190
+ payload: { ...data },
978
1191
  target: iframe?.contentWindow ? 'child' : 'metabox',
1192
+ apiVersion: VERSION,
979
1193
  };
980
1194
  if (!iframe?.contentWindow) {
981
1195
  console.warn('Metabox IFrame not found or not ready. Message sends to the same window');
@@ -985,7 +1199,9 @@ class Communicator extends EventDispatcher {
985
1199
  iframe.contentWindow.postMessage(toMetaboxMessage, '*');
986
1200
  }
987
1201
  /**
988
- * Registers an event listener for messages dispatched by Metabox.
1202
+ * Registers an event listener for messages dispatched by the Metabox.
1203
+ * @param messageType - The event name to listen for (e.g. `'configuratorDataUpdated'`).
1204
+ * @param callback - Handler invoked with the typed payload when the event fires.
989
1205
  * @override
990
1206
  */
991
1207
  addEventListener(messageType, callback) {
@@ -993,6 +1209,8 @@ class Communicator extends EventDispatcher {
993
1209
  }
994
1210
  /**
995
1211
  * Dispatches a typed event to all registered listeners.
1212
+ * @param messageType - The event name to dispatch.
1213
+ * @param data - The payload to pass to each listener.
996
1214
  * @override
997
1215
  */
998
1216
  dispatchEvent(messageType, data) {
@@ -1000,6 +1218,8 @@ class Communicator extends EventDispatcher {
1000
1218
  }
1001
1219
  /**
1002
1220
  * Removes a previously registered event listener.
1221
+ * @param messageType - The event name the listener was registered for.
1222
+ * @param callback - The same function reference that was passed to {@link addEventListener}.
1003
1223
  * @override
1004
1224
  */
1005
1225
  removeEventListener(messageType, callback) {
@@ -1007,22 +1227,33 @@ class Communicator extends EventDispatcher {
1007
1227
  }
1008
1228
  /**
1009
1229
  * Filters and dispatches incoming messages from the Metabox.
1010
- * @param messageType - Expected message type for filtering (MetaboxData).
1011
1230
  * @param event - The postMessage event received on a window.
1012
1231
  */
1013
- handleMessageReceived(messageType, event) {
1014
- // Optionally validate event.origin for security.
1015
- if (messageType !== MetaboxData || event.data?.host !== Metabox) {
1232
+ handleMessageReceived(event) {
1233
+ if (event.data?.host !== Metabox) {
1016
1234
  return;
1017
1235
  }
1018
1236
  const data = event.data?.envelope;
1019
- this.dispatchEvent(data?.eventType, data.payload);
1237
+ this.dispatchEvent(data?.eventType, data?.payload);
1020
1238
  }
1021
1239
  }
1022
1240
 
1023
1241
  /**
1242
+ * Constructs the iframe source URL for the Metabox Modular Configurator.
1243
+ *
1244
+ * ### What does it unlock?
1245
+ * Utility function that prepares the iframe source URL. Constructs the proper URL with parameters
1246
+ * for loading the MetaBox configurator.
1247
+ *
1248
+ * ### Practical Application
1249
+ * Utility function that constructs the iframe source URL with proper parameters.
1250
+ * URL format: `https://{domain}/metabox-configurator/modular/{configuratorId}`.
1251
+ * Called internally by integrateMetabox() — use directly only for manual URL construction.
1252
+ *
1253
+ * ### AI Coding Best Practices
1254
+ * Usually called internally. Use directly only for pre-constructing embed URLs (QR codes, email links,
1255
+ * preview URLs). Verify output is HTTPS. Remember modular configurators use `/modular/` path.
1024
1256
  *
1025
- * @remarks
1026
1257
  * @internal
1027
1258
  * @hidden
1028
1259
  *
@@ -1052,15 +1283,31 @@ const prepareIframeSrc = (configuratorId, config) => {
1052
1283
  * Integrates the Metabox Modular Configurator into the page by injecting an iframe and
1053
1284
  * initializing a Communicator instance for host-to-iframe messaging.
1054
1285
  *
1055
- * @remarks
1056
1286
  * - Builds a secure iframe URL using the provided configuratorId and config options.
1057
1287
  * - Ensures the resulting URL uses HTTPS and that the target container exists.
1058
1288
  * - Removes any previously embedded iframe with id "embeddedContent" before inserting a new one.
1059
1289
  *
1290
+ * ### What does it unlock?
1291
+ * Main initialization function for MetaBox integration. Initializes the configurator, receives an API handle,
1292
+ * and sets up all configurations.
1293
+ *
1294
+ * ### Practical Application
1295
+ * THE entry point function. Creates the configurator iframe, establishes postMessage communication, and returns
1296
+ * the Communicator api handle via callback. Call ONCE per configurator. Params: configuratorId (modular UUID),
1297
+ * containerId (DOM element ID, default 'embed3DSource'), apiReadyCallback, config (IntegrateMetaboxConfig).
1298
+ *
1299
+ * ### AI Coding Best Practices
1300
+ * Pattern: `integrateMetabox('uuid', 'div-id', (api) => {
1301
+ * setup listeners, then set root component, then environment, then children
1302
+ * }, { standalone: true })`.
1303
+ * Ensure container div exists in DOM with non-zero dimensions. HTTPS required.
1304
+ * Inside callback: 1) addEventListener for configuratorDataUpdated, 2) SetComponent root, 3) SetEnvironment,
1305
+ * 4) SetComponent children, 5) SetComponentMaterial.
1306
+ *
1060
1307
  * @param {string} configuratorId - The Modular Configurator ID (not a full URL). It is appended to
1061
1308
  * `https://{domain}/metabox-configurator/modular/{configuratorId}` to form the iframe src.
1062
1309
  *
1063
- * @param {string} [containerId='embed3DSource'] - The id of the container element where the iframe will be injected.
1310
+ * @param {string} containerId - The id of the container element where the iframe will be injected.
1064
1311
  *
1065
1312
  * @param {(api: Communicator) => void} apiReadyCallback - Called when the Communicator instance is created on the host side.
1066
1313
  *
@@ -1093,7 +1340,7 @@ const prepareIframeSrc = (configuratorId, config) => {
1093
1340
  * },
1094
1341
  * );
1095
1342
  */
1096
- function integrateMetabox(configuratorId, containerId = 'embed3DSource', apiReadyCallback, config) {
1343
+ function integrateMetabox(configuratorId, containerId, apiReadyCallback, config) {
1097
1344
  if (!configuratorId.trim()) {
1098
1345
  throw new Error('integrateMetabox: configuratorId must be a non-empty string');
1099
1346
  }
@@ -1145,10 +1392,22 @@ function integrateMetabox(configuratorId, containerId = 'embed3DSource', apiRead
1145
1392
  /**
1146
1393
  * Saves an image by triggering a download.
1147
1394
  *
1148
- * @remarks
1149
1395
  * This function creates an anchor element, sets its `href` attribute to the provided image URL,
1150
1396
  * and triggers a click event to initiate a download with the specified filename.
1151
1397
  *
1398
+ * ### What does it unlock?
1399
+ * Main exported function to save images from the configurator. Converts base64 image data to actual image
1400
+ * files and saves them to the local filesystem.
1401
+ *
1402
+ * ### Practical Application
1403
+ * Exported utility function that converts base64 screenshot data (from screenshotReady event) to a downloadable
1404
+ * image file. Handles the base64 → blob → browser download flow. Import directly from the API package.
1405
+ *
1406
+ * ### AI Coding Best Practices
1407
+ * Pattern: `api.addEventListener('screenshotReady', (data) => { if(data) saveImage(data, 'config-screenshot.png'); })`.
1408
+ * Filename extension should match the MimeType passed to GetScreenshot.
1409
+ * Import: `import { saveImage } from '@3dsource/metabox-modular-configurator-api'`.
1410
+ *
1152
1411
  * @param {string} imageUrl - The URL of the image to save.
1153
1412
  * @param {string} filename - The name of the file to save.
1154
1413
  */
@@ -1165,5 +1424,5 @@ function saveImage(imageUrl, filename) {
1165
1424
  * Generated bundle index. Do not edit.
1166
1425
  */
1167
1426
 
1168
- export { AppLoaded, ApplyZoom, BasicRouteUrl, CommandBase, Communicator, EventDispatcher, ForceSetDeviceType, GetCallToActionInformation, GetCamera, GetPdf, GetScreenshot, HideMeasurement, InitShowcase, Metabox, MetaboxConfig, MetaboxData, MetaboxDomain, MetaboxHost, MetaboxModularConfiguratorActions, PauseShowcase, PlayShowcase, ResetCamera, SetCamera, SetComponent, SetComponentMaterial, SetEnvironment, SetEnvironmentMaterial, ShowEmbeddedMenu, ShowMeasurement, ShowOverlayInterface, StopShowcase, UnrealCommand, VERSION, fromCommunicatorEvent, integrateMetabox, prepareIframeSrc, saveImage };
1427
+ export { AppLoaded, AppLoaded_V3, ApplyZoom, BasicRouteUrl, CommandBase, Communicator, EventDispatcher, ForceSetDeviceType, GetCallToActionInformation, GetCamera, GetPdf, GetScreenshot, HideMeasurement, InitShowcase, Metabox, MetaboxConfig, MetaboxData, MetaboxDomain, MetaboxHost, MetaboxHost_V3, MetaboxModularConfiguratorActions, Metabox_V3, PauseShowcase, PlayShowcase, ResetCamera, ResumeStream, SetCamera, SetComponent, SetComponentMaterial, SetEnvironment, SetEnvironmentMaterial, ShowEmbeddedMenu, ShowMeasurement, ShowOverlayInterface, StopShowcase, UnrealCommand, VERSION, fromCommunicatorEvent, integrateMetabox, prepareIframeSrc, saveImage };
1169
1428
  //# sourceMappingURL=3dsource-metabox-modular-configurator-api.mjs.map