@3dsource/metabox-modular-configurator-api 3.0.19-dev.10 → 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.
@@ -1,17 +1,110 @@
1
1
  import { Observable } from 'rxjs';
2
2
 
3
+ /**
4
+ * Device type identifiers used by {@link ForceSetDeviceType} to override the auto-detected device.
5
+ *
6
+ * - `'deviceTypeAuto'` — let the configurator detect the device automatically.
7
+ * - `'deviceTypeMobile'` — force mobile layout and controls.
8
+ * - `'deviceTypeDesktop'` — force desktop layout and controls.
9
+ *
10
+ * ### What does it unlock?
11
+ * Type alias defining available application device types (desktop, mobile, etc.). Specifies supported device targets.
12
+ *
13
+ * ### Practical Application
14
+ * Used by MetaBox for responsive rendering behavior. Typically auto-detected — only override with
15
+ * ForceSetDeviceType for specific kiosk or showroom setups.
16
+ *
17
+ * ### AI Coding Best Practices
18
+ * Prefer auto-detection. Use standard browser APIs for your own responsive logic. Only reference this type
19
+ * if you need to force a device mode via ForceSetDeviceType, which is likely deprecated.
20
+ */
3
21
  type ApplicationDeviceTypes = 'deviceTypeAuto' | 'deviceTypeMobile' | 'deviceTypeDesktop';
4
22
 
5
23
  /**
6
24
  * @internal
7
25
  * @hidden
8
- * Represents main constants.
9
- * IMPORTANT !!! DO NOT CHANGE THESE CONSTANTS !!!!
10
- * CHANGING THESE CONSTANTS WILL BROKE CUSTOM MENUS
26
+ * Core constants used for host-to-iframe communication and URL construction.
27
+ */
28
+ /**
29
+ * Storage key for the Metabox Communicator instance registry.
30
+ *
31
+ * ### What does it unlock?
32
+ * Constant string identifier for MetaBox version. Used internally to reference the MetaBox system and versioning.
33
+ *
34
+ * ### Practical Application
35
+ * Internal system reference for versioning.
36
+ * Not needed in front-end application code.
37
+ *
38
+ * ### AI Coding Best Practices
39
+ * Skip in application code. This constant is for internal MetaBox system identification only.
40
+ *
41
+ * @internal
11
42
  */
12
43
  declare const Metabox = "metabox";
44
+ /**
45
+ * Identifier used as the `host` field in postMessage envelopes sent to the iframe.
46
+ *
47
+ * ### What does it unlock?
48
+ * Constant for the MetaBox host connection point. Specifies endpoint for MetaBox connections.
49
+ *
50
+ * ### Practical Application
51
+ * MetaBox endpoint constant. The host the configurator iframe connects to for Unreal Engine pixel streaming.
52
+ * Not needed in front-end application code.
53
+ *
54
+ * ### AI Coding Best Practices
55
+ * Skip in application code. This constant is for internal MetaBox system identification only.
56
+ *
57
+ * @internal
58
+ */
13
59
  declare const MetaboxHost = "metaboxHost";
14
- declare const AppLoaded = "appLoaded";
60
+ /**
61
+ * Identifier used as the `host` field in postMessage envelopes received from the iframe.
62
+ *
63
+ * ### What does it unlock?
64
+ * Constant identifier used internally to reference and compare MetaBox data. Used for data validation and internal routing.
65
+ *
66
+ * ### Practical Application
67
+ * Internal data reference constant used for validation and message routing within the communication layer.
68
+ * Not needed in front-end application code.
69
+ *
70
+ * ### AI Coding Best Practices
71
+ * Skip in application code. Only relevant if debugging very low-level message traffic between your app and the MetaBox iframe.
72
+ *
73
+ * @internal
74
+ */
75
+ declare const MetaboxData = "metaboxData";
76
+ /**
77
+ * Action string dispatched by the iframe when the configurator app has loaded.
78
+ *
79
+ * ### What does it unlock?
80
+ * App initialization flag variable. Signals when MetaBox has completed loading.
81
+ *
82
+ * ### Practical Application
83
+ * Use the viewportReady event (more reliable) to gate your UI rendering — don't show controls until MetaBox confirms it's ready.
84
+ *
85
+ * ### AI Coding Best Practices
86
+ * Prefer the viewportReady event over this variable: `api.addEventListener('viewportReady', (ready) => { if(ready) enableUI(); })`.
87
+ * viewportReady is the reliable signal that MetaBox is ready to accept commands.
88
+ *
89
+ * @internal
90
+ */
91
+ declare const AppLoaded = "appLoaded_v3";
92
+ /**
93
+ * Default MetaBox domain for production environments.
94
+ *
95
+ * ### What does it unlock?
96
+ * Constant for the standard default MetaBox domain. Used as the primary domain for connecting to MetaBox server.
97
+ *
98
+ * ### Practical Application
99
+ * Default MetaBox domain constant (HTTPS). The base domain used when no override is specified.
100
+ * Override only via IntegrateMetaboxConfig.domain if connecting to a custom or self-hosted MetaBox instance.
101
+ *
102
+ * ### AI Coding Best Practices
103
+ * Let integrateMetabox() use the default. Override only if needed:
104
+ * `integrateMetabox(id, container, callback, { domain: 'https://custom.domain.com' })`. HTTPS is mandatory.
105
+ *
106
+ * @internal
107
+ */
15
108
  /**
16
109
  * @deprecated
17
110
  */
@@ -25,26 +118,101 @@ declare const MetaboxHost_V3 = "metaboxHost_v3";
25
118
  */
26
119
  declare const AppLoaded_V3 = "appLoaded_v3";
27
120
  declare const MetaboxDomain = "metabox.3dsource.com";
121
+ /**
122
+ * Base route URL segment for the Modular Configurator.
123
+ *
124
+ * ### What does it unlock?
125
+ * Base route URL constant used for loading the configurator. Standard path endpoint for accessing the modular configurator.
126
+ *
127
+ * ### Practical Application
128
+ * The modular configurator URL format is: `https://{domain}/metabox-configurator/modular/{configuratorId}`.
129
+ * Automatically constructed by integrateMetabox().
130
+ *
131
+ * ### AI Coding Best Practices
132
+ * Let integrateMetabox() handle URL construction. Only reference if building URLs manually
133
+ * (e.g., QR codes, email links, server-side rendering). The modular path is `/modular/{id}`.
134
+ *
135
+ * @internal
136
+ */
28
137
  declare const BasicRouteUrl = "metabox-configurator/modular";
29
138
 
30
- declare const VERSION = "3.0.19-dev.10";
139
+ declare const VERSION = "3.0.19-dev.11";
31
140
 
141
+ /**
142
+ * Configuration options for integrating the Metabox Modular Configurator iframe into a host page.
143
+ * Passed as the `config` parameter to {@link integrateMetabox}.
144
+ *
145
+ * ### What does it unlock?
146
+ * Configuration interface for initializing the configurator. Passed to integrateMetabox function with settings
147
+ * like domain, host, and standalone mode.
148
+ *
149
+ * ### Practical Application
150
+ * Config interface for integrateMetabox() initialization. Supports: standalone (boolean — disables all built-in UI),
151
+ * introImage/introVideo (URLs), loadingImage (URL), state (initial component tree), domain (HTTPS override).
152
+ *
153
+ * ### AI Coding Best Practices
154
+ * Pass as 4th parameter to integrateMetabox(). Key: `standalone:true` for custom UI builds. loadingImage for branded
155
+ * loading. domain only if overriding the default MetaBox server. All URLs must be HTTPS. The state field lets you
156
+ * restore a previously saved configuration.
157
+ */
32
158
  interface IntegrateMetaboxConfig {
159
+ /** If true, disables Metabox custom template and all related logic. */
33
160
  standalone?: boolean;
161
+ /** URL to an image displayed while the configurator is loading (added as `?loadingImage=...`). */
34
162
  loadingImage?: string;
163
+ /** URL to a video shown on the intro screen (added as `?introVideo=...`). */
35
164
  introVideo?: string;
165
+ /** URL to an image shown on the intro screen (added as `?introImage=...`). */
36
166
  introImage?: string;
167
+ /** Predefined state for the configurator on initial loading in rison format (see
168
+ * https://github.com/Nanonid/rison) (added as `?state=...`). */
37
169
  state?: string;
170
+ /** Custom domain for testing purposes. Defaults to `metabox.3dsource.com`. HTTPS is enforced. */
38
171
  domain?: string;
39
172
  }
173
+ /**
174
+ * Internal configuration sent to the Metabox Modular Configurator via postMessage.
175
+ * Used by {@link Communicator} when establishing host-to-iframe communication.
176
+ *
177
+ * ### What does it unlock?
178
+ * Configuration object for MetaBox commands. Contains parameters for command execution and behavior settings.
179
+ *
180
+ * ### Practical Application
181
+ * Configuration object for MetaBox command execution. Contains parameters controlling command behavior and settings.
182
+ * Used internally by the command dispatch system.
183
+ *
184
+ * ### AI Coding Best Practices
185
+ * Read-only reference — commands use this internally. When building dynamic command systems, refer to individual
186
+ * command class constructors for their specific parameter requirements rather than this config.
187
+ */
40
188
  interface MetaboxCommandConfig {
189
+ /** If true, disables Metabox custom template and all related logic. */
41
190
  standalone?: boolean;
191
+ /** The URL of the host page embedding the configurator. */
42
192
  hostUrl: string;
193
+ /** The API version string sent to the configurator for compatibility. */
43
194
  apiVersion: string;
44
195
  }
45
196
 
197
+ /**
198
+ * Registry of all action identifiers that can be sent from the host application to the Metabox Modular Configurator.
199
+ * Each key maps to a string used as the `action` field in the postMessage envelope.
200
+ *
201
+ * ### What does it unlock?
202
+ * Variable containing all available action names. Interface listing all actions that the modular configurator supports.
203
+ *
204
+ * ### Practical Application
205
+ * Master action registry object — all supported configurator action names. Invaluable reference for building
206
+ * admin dashboards, permission systems, or feature-availability displays.
207
+ *
208
+ * ### AI Coding Best Practices
209
+ * Iterate this object to dynamically build action dropdowns, command palettes, or feature checklists in admin tools.
210
+ * Each key is an action name, value is its description. Excellent reference for AI coding agents to understand
211
+ * the full command vocabulary available.
212
+ */
46
213
  declare const MetaboxModularConfiguratorActions: {
47
214
  readonly metaboxConfig: "metaboxConfig";
215
+ readonly resumeStream: "resumeStream";
48
216
  readonly setEnvironment: "setEnvironment";
49
217
  readonly setEnvironmentMaterialById: "setEnvironmentMaterialById";
50
218
  readonly setComponent: "setComponent";
@@ -67,6 +235,20 @@ declare const MetaboxModularConfiguratorActions: {
67
235
  readonly showMeasurement: "showMeasurement";
68
236
  readonly hideMeasurement: "hideMeasurement";
69
237
  };
238
+ /**
239
+ * Union of all action string literals from {@link MetaboxModularConfiguratorActions}.
240
+ *
241
+ * ### What does it unlock?
242
+ * Type alias for all actions that can be sent to MetaBox. Defines the complete set of command types available.
243
+ *
244
+ * ### Practical Application
245
+ * Type alias enumerating all available outgoing command types. Master list of everything your app can tell MetaBox to do.
246
+ * Use as a checklist when planning which features to implement.
247
+ *
248
+ * ### AI Coding Best Practices
249
+ * Reference for building command dispatchers or admin tools. Full command set includes all values of
250
+ * MetaboxModularConfiguratorActions like: "metaboxConfig" | "setEnvironment" | "setEnvironmentMaterialById" | ...
251
+ */
70
252
  type ToMetaBoxActions = (typeof MetaboxModularConfiguratorActions)[keyof typeof MetaboxModularConfiguratorActions];
71
253
  /**
72
254
  * @internal
@@ -75,6 +257,17 @@ type ToMetaBoxActions = (typeof MetaboxModularConfiguratorActions)[keyof typeof
75
257
  type ToMetaboxMessagePayload = ToMetaboxMessagePayloads[keyof ToMetaboxMessagePayloads];
76
258
  /**
77
259
  * Interface for messages sent from the application to the Metabox Modular Configurator.
260
+ *
261
+ * ### What does it unlock?
262
+ * Defines payload structures for different types of outgoing messages to MetaBox. Contains data models for various command parameters.
263
+ *
264
+ * ### Practical Application
265
+ * Payload type definitions for all outgoing command types. Defines required and optional fields per command.
266
+ * Essential TypeScript reference for type-safe command construction.
267
+ *
268
+ * ### AI Coding Best Practices
269
+ * Use as TypeScript type reference for proper typing when building dynamic command dispatchers.
270
+ * Each key corresponds to a command name and its value defines the expected payload structure.
78
271
  */
79
272
  interface ToMetaboxMessagePayloads {
80
273
  [MetaboxModularConfiguratorActions.metaboxConfig]: {
@@ -128,19 +321,44 @@ interface ToMetaboxMessagePayloads {
128
321
  [MetaboxModularConfiguratorActions.pauseShowcase]: void;
129
322
  [MetaboxModularConfiguratorActions.stopShowcase]: void;
130
323
  [MetaboxModularConfiguratorActions.sendCommandToUnreal]: object;
324
+ [MetaboxModularConfiguratorActions.showMeasurement]: void;
325
+ [MetaboxModularConfiguratorActions.hideMeasurement]: void;
131
326
  }
327
+ /**
328
+ * Payload for the {@link SetCamera} command describing the desired camera state in the Unreal scene.
329
+ * All fields are optional — only the provided values will be applied.
330
+ *
331
+ * ### What does it unlock?
332
+ * Defines the payload structure for camera commands. Contains camera-related parameters passed to SetCamera command.
333
+ *
334
+ * ### Practical Application
335
+ * Read-only interface defining camera parameters: fov (degrees), mode ('orbit'|'fps'), position ({x,y,z}),
336
+ * rotation ({horizontal: yaw, vertical: pitch}), and restrictions (distance/FOV/rotation limits).
337
+ * Both returned by getCameraResult event and accepted by SetCamera.
338
+ *
339
+ * ### AI Coding Best Practices
340
+ * This interface is bidirectional — returned from GetCamera and accepted by SetCamera.
341
+ * Capture a camera state via getCameraResult and replay it with SetCamera(payload).
342
+ * Only include restriction fields you want to enforce; omitted values keep current settings.
343
+ * In orbit mode, distance limits are relative to the orbit pivot.
344
+ */
132
345
  interface CameraCommandPayload {
346
+ /** Field of view angle in degrees. */
133
347
  fov?: number;
348
+ /** Camera control mode: `'fps'` for first-person or `'orbit'` for orbital rotation around pivot. */
134
349
  mode?: 'fps' | 'orbit';
350
+ /** Camera position in 3D world space. */
135
351
  position?: {
136
352
  x: number;
137
353
  y: number;
138
354
  z: number;
139
355
  };
356
+ /** Camera rotation angles in degrees. */
140
357
  rotation?: {
141
358
  horizontal: number;
142
359
  vertical: number;
143
360
  };
361
+ /** Min/max constraints applied to camera movement, zoom, and rotation. */
144
362
  restrictions?: {
145
363
  maxDistanceToPivot?: number;
146
364
  maxFov?: number;
@@ -152,11 +370,47 @@ interface CameraCommandPayload {
152
370
  minVerticalRotation?: number;
153
371
  };
154
372
  }
373
+ /**
374
+ * @internal
375
+ * @hidden
376
+ * Envelope wrapping an action and its payload for host-to-Metabox postMessage communication.
377
+ *
378
+ * ### What does it unlock?
379
+ * Envelope structure for outgoing MetaBox messages. Encapsulates messages with protocol headers for transmission.
380
+ *
381
+ * ### Practical Application
382
+ * Protocol envelope for outgoing messages — adds headers for transmission to MetaBox iframe.
383
+ * Internal to the communication layer, handled automatically by the Communicator.
384
+ *
385
+ * ### AI Coding Best Practices
386
+ * Do not construct manually. The Communicator handles all message wrapping. Only reference this interface
387
+ * if debugging raw postMessage traffic in browser devtools to diagnose why commands aren't being received.
388
+ */
155
389
  interface ToMetaBoxMessageEnvelope {
156
390
  action: ToMetaBoxActions;
157
391
  payload?: ToMetaboxMessagePayload | never;
158
392
  }
393
+ /**
394
+ * @internal
395
+ * @hidden
396
+ */
159
397
  type ToMetaboxTarget = 'metabox' | 'child';
398
+ /**
399
+ * @internal
400
+ * @hidden
401
+ * Top-level postMessage structure sent from the host to the Metabox iframe.
402
+ *
403
+ * ### What does it unlock?
404
+ * Message interface for sending data to MetaBox. Wraps outgoing commands with necessary protocol information.
405
+ *
406
+ * ### Practical Application
407
+ * Outgoing message format for commands to MetaBox. Wraps commands with protocol information for postMessage delivery.
408
+ * Handled automatically by Communicator.sendCommandToMetabox() — never construct manually.
409
+ *
410
+ * ### AI Coding Best Practices
411
+ * Do not construct ToMetaBoxMessage objects. Always use `api.sendCommandToMetabox(new CommandName(...))`.
412
+ * The Communicator wraps your command in the correct message format automatically.
413
+ */
160
414
  interface ToMetaBoxMessage {
161
415
  host: typeof MetaboxHost;
162
416
  envelope: ToMetaBoxMessageEnvelope;
@@ -169,9 +423,25 @@ interface ToMetaBoxMessage {
169
423
  }
170
424
 
171
425
  /**
172
- * Represents a modular configurator envelope with an initial configurator, and changes contain a configuration tree,
173
- * all components by active component type, component selected materials,
174
- * and associated environment.
426
+ * Represents a modular configurator envelope with an initial configurator, configuration tree,
427
+ * all components by active component type, component selected materials, and associated environment.
428
+ *
429
+ * ### What does it unlock?
430
+ * Main data envelope interface that comes from MetaBox. Contains all configurator data including components,
431
+ * materials, variants, and state information.
432
+ *
433
+ * ### Practical Application
434
+ * Delivered as the payload of the `configuratorDataUpdated` event. Contains: configurator (full definition of all options),
435
+ * configurationTree (current assembly hierarchy), componentsByComponentType (active selection per category),
436
+ * componentMaterialsIds (material selections), environmentId (current scene), environmentMaterialsIds.
437
+ * This is the single source of truth for building your entire custom UI.
438
+ *
439
+ * ### AI Coding Best Practices
440
+ * Subscribe to configuratorDataUpdated to receive this on EVERY state change.
441
+ * Key fields: configurator (all available options — parse once for menu building),
442
+ * configurationTree (current hierarchy), componentsByComponentType (what's selected per type),
443
+ * componentMaterialsIds (active materials), environmentId (current scene).
444
+ * Rebuild affected UI sections on each update.
175
445
  */
176
446
  interface ModularConfiguratorEnvelope {
177
447
  /**
@@ -190,8 +460,21 @@ interface ModularConfiguratorEnvelope {
190
460
  environmentMaterialsIds: SelectedIds;
191
461
  }
192
462
  /**
193
- * Represents the modular configurator api with its components, component types, and environments
194
- * */
463
+ * Represents the modular configurator API with its components, component types, and environments.
464
+ *
465
+ * ### What does it unlock?
466
+ * Defines payload structures for different message types. Contains data models for various command responses.
467
+ *
468
+ * ### Practical Application
469
+ * Full configurator definition loaded at init — contains all available components, component types,
470
+ * environments, materials, and metadata. Nested inside ModularConfiguratorEnvelope.configurator.
471
+ * This is your catalog of everything the configurator supports.
472
+ *
473
+ * ### AI Coding Best Practices
474
+ * Access via envelope.configurator from configuratorDataUpdated. This is your source of truth for ALL
475
+ * available options. Iterate its component types, components, environments, and material collections
476
+ * to build dynamic selection UIs. Only changes if the configurator definition is updated in MetaBox admin.
477
+ */
195
478
  interface InitialModularConfigurator {
196
479
  /** Unique identifier for the configurator. */
197
480
  id: string;
@@ -210,11 +493,24 @@ interface InitialModularConfigurator {
210
493
  ctaEnabled: boolean;
211
494
  /** A list of available connectors shows connections between all component types. */
212
495
  connectors: ModularConfiguratorConnector[];
213
- /** GraphQL typename for the Modular Configurator. */
496
+ /** Represents object typename for the Modular Configurator. */
214
497
  __typename: 'ModularConfigurator';
215
498
  }
216
499
  /**
217
500
  * Represents a configurator component within the modular configurator.
501
+ *
502
+ * ### What does it unlock?
503
+ * Defines the type structure of a component. Describes component classification and available variants.
504
+ *
505
+ * ### Practical Application
506
+ * Core component data model: id (UUID), name (display string), position (sort order),
507
+ * componentType (category), product (3D asset reference with externalId for SKU mapping),
508
+ * and virtualSocketToConnectorsMap (connection points). THE main data structure for building component UIs.
509
+ *
510
+ * ### AI Coding Best Practices
511
+ * Access from configurator definition in the envelope. Key fields: id (pass to SetComponent),
512
+ * componentType.id (the typeId param), name (display label), position (sort order).
513
+ * Use product.externalId for ERP/PIM lookups. Check virtualSocketToConnectorsMap for modular assembly validation.
218
514
  */
219
515
  interface ModularConfiguratorComponent {
220
516
  /** The id unique identifier. */
@@ -229,11 +525,24 @@ interface ModularConfiguratorComponent {
229
525
  product: Product;
230
526
  /** Connectors between connectors and virtual sockets. */
231
527
  virtualSocketToConnectorsMap?: ModularConfiguratorVirtualSocketToConnector[];
232
- /** GraphQL typename for the component. */
528
+ /** Represents object typename for the component. */
233
529
  __typename: 'ModularConfiguratorComponent';
234
530
  }
235
531
  /**
236
532
  * Represents a component type within the modular configurator.
533
+ *
534
+ * ### What does it unlock?
535
+ * Type definition for modular configurator components. Defines the schema and available options for component types.
536
+ *
537
+ * ### Practical Application
538
+ * Component type/category definitions — groups like 'wheel', 'frame', 'seat'. Each type has a collection
539
+ * of available components. Use to build categorized selection menus (e.g., 'Choose Your Wheel' showing
540
+ * only wheel-type options).
541
+ *
542
+ * ### AI Coding Best Practices
543
+ * Access from the configurator definition. Use type names as section headers in custom menus.
544
+ * Filter components by type to populate category-specific selectors.
545
+ * The type.id is what you pass as typeId to SetComponent.
237
546
  */
238
547
  interface ModularConfiguratorComponentType {
239
548
  /** Display the name for the component type. */
@@ -246,30 +555,70 @@ interface ModularConfiguratorComponentType {
246
555
  isRequired: boolean;
247
556
  /** The id unique identifier. */
248
557
  id: string;
249
- /** GraphQL typename for the component type. */
558
+ /** Represents object typename for the component type. */
250
559
  __typename: 'ModularConfiguratorComponentType';
251
560
  }
252
561
  /**
253
- * Represents a vur virtual map socket to connectors the modular configurator.
562
+ * Represents the mapping between virtual sockets and connectors in the modular configurator.
563
+ *
564
+ * ### What does it unlock?
565
+ * Represents the mapping between virtual sockets and connectors. Manages component connection points.
566
+ *
567
+ * ### Practical Application
568
+ * Maps virtual sockets (connection points) to physical connectors on components. Shows which attachment
569
+ * points on a component accept which other component types. Used for validating and visualizing
570
+ * modular assembly connections.
571
+ *
572
+ * ### AI Coding Best Practices
573
+ * Access via component.virtualSocketToConnectorsMap. Use to validate user-proposed assemblies in
574
+ * drag-and-drop builder UIs. Before calling SetComponent for a child, verify the parent has a
575
+ * compatible socket. Prevents invalid configurations.
254
576
  */
255
577
  interface ModularConfiguratorVirtualSocketToConnector {
256
578
  virtualSocketId: string;
257
579
  connectorId: string;
258
- /** GraphQL typename for the virtual map socket. */
580
+ /** Represents object typename for the virtual map socket. */
259
581
  __typename: 'ModularConfiguratorVirtualSocketToConnector';
260
582
  }
261
583
  /**
262
- * Represents a connector the modular configurator.
584
+ * Represents a connector in the modular configurator.
585
+ *
586
+ * ### What does it unlock?
587
+ * Defines the connection structure between components. Represents the virtual connectors created
588
+ * when loading products based on component tags.
589
+ *
590
+ * ### Practical Application
591
+ * Connector definitions for modular assembly — how components physically attach via virtual sockets
592
+ * and connection tags. Critical for modular products (sectional sofas, modular shelving, multi-piece
593
+ * systems) where parts snap at defined points.
594
+ *
595
+ * ### AI Coding Best Practices
596
+ * Access via virtualSocketToConnectorsMap on each component. These define which component slots accept
597
+ * which other components based on matching connection tags. Use to validate proposed assemblies before
598
+ * sending SetComponent commands in custom builder UIs.
263
599
  */
264
600
  interface ModularConfiguratorConnector {
265
601
  id: string;
266
602
  componentTypeId1: string;
267
603
  componentTypeId2: string;
268
- /** GraphQL typename for connector. */
604
+ /** Represents object typename for connector. */
269
605
  __typename: 'ModularConfiguratorConnector';
270
606
  }
271
607
  /**
272
608
  * Represents product details including visual assets and configuration.
609
+ *
610
+ * ### What does it unlock?
611
+ * Interface representing a product in the configurator system. Contains product metadata, components,
612
+ * and configuration options.
613
+ *
614
+ * ### Practical Application
615
+ * Product data model: the base 3D digital twin referenced by each component. Contains product metadata
616
+ * and externalId (SKU) for e-commerce/ERP mapping. Nested inside each ModularConfiguratorComponent.
617
+ *
618
+ * ### AI Coding Best Practices
619
+ * Access via component.product in the configurator data. Use product.externalId to look up pricing,
620
+ * inventory, and specs in external systems (ERP, PIM, Shopify, etc.). The product represents the
621
+ * underlying 3D asset the component renders in the Unreal viewport.
273
622
  */
274
623
  interface Product {
275
624
  /** The title of the product. */
@@ -287,11 +636,23 @@ interface Product {
287
636
  externalId: string;
288
637
  /** Showcase details for the product. */
289
638
  showcase?: Showcase;
290
- /** GraphQL typename for the product. */
639
+ /** Represents object typename for the product. */
291
640
  __typename: 'Product';
292
641
  }
293
642
  /**
294
643
  * Represents a thumbnail image entity with dimensions and URL path.
644
+ *
645
+ * ### What does it unlock?
646
+ * Thumbnail interface representing preview images. Contains image data and metadata for visual representation.
647
+ *
648
+ * ### Practical Application
649
+ * Preview image data: contains URLs and metadata for thumbnails used in component selectors, material
650
+ * swatch pickers, and environment preview cards. Essential for building visual option pickers.
651
+ *
652
+ * ### AI Coding Best Practices
653
+ * Access thumbnailList arrays from materials, environments, and components. Use URLs directly in `<img>` tags.
654
+ * Implement lazy loading for grids with many options. Consider preloading thumbnails for the currently
655
+ * visible category.
295
656
  */
296
657
  interface Thumbnail {
297
658
  /** Width of the thumbnail. */
@@ -300,11 +661,24 @@ interface Thumbnail {
300
661
  height: number;
301
662
  /** URL path to the thumbnail image. */
302
663
  urlPath: string;
303
- /** GraphQL typename (as a string, flexible type). */
664
+ /** Represents object typename (as a string, flexible type). */
304
665
  __typename: 'Thumbnail';
305
666
  }
306
667
  /**
307
668
  * Represents a slot within a product that may allow material customization.
669
+ *
670
+ * ### What does it unlock?
671
+ * Represents a material slot on a component or environment — a customizable surface.
672
+ *
673
+ * ### Practical Application
674
+ * Material slot on a component or environment — represents a customizable surface. Each slot has an id
675
+ * (used in SetComponentMaterial/SetEnvironmentMaterial) and a list of available materials.
676
+ * Use to build per-surface material pickers.
677
+ *
678
+ * ### AI Coding Best Practices
679
+ * Access slot definitions from component or environment data in the envelope. Each slot's id is the slotId
680
+ * parameter for SetComponentMaterial or SetEnvironmentMaterial. Iterate slot.enabledMaterials to build
681
+ * the swatch picker for that specific surface.
308
682
  */
309
683
  interface Slot {
310
684
  /** Unique identifier for the slot. */
@@ -313,11 +687,23 @@ interface Slot {
313
687
  label: string;
314
688
  /** A list of enabled materials for the slot. */
315
689
  enabledMaterials: Material[];
316
- /** GraphQL typename for the slot. */
690
+ /** Represents object typename for the slot. */
317
691
  __typename: 'Slot';
318
692
  }
319
693
  /**
320
694
  * Represents a metaProperty within a product that may allow business logic customization.
695
+ *
696
+ * ### What does it unlock?
697
+ * Represents a component in the modular configurator with metadata, properties, and hierarchy information.
698
+ *
699
+ * ### Practical Application
700
+ * Represents a component in the modular configurator with metadata, properties, and hierarchy info.
701
+ * May contain custom key-value data (pricing hints, availability flags, descriptions) set in MetaBox admin.
702
+ *
703
+ * ### AI Coding Best Practices
704
+ * Check for MetaProperty data in component definitions from the configurator data. Custom metadata can
705
+ * be used for display purposes — tooltips, pricing, lead times, availability badges. These are set by
706
+ * content teams in MetaBox admin.
321
707
  */
322
708
  interface MetaProperty {
323
709
  /** Unique identifier for the metaProperty. */
@@ -328,11 +714,24 @@ interface MetaProperty {
328
714
  value: string;
329
715
  /** Type for the metaProperty. */
330
716
  type: string;
331
- /** GraphQL typename for the metaProperty. */
717
+ /** Represents object typename for the metaProperty. */
332
718
  __typename: 'MetaProperty';
333
719
  }
334
720
  /**
335
721
  * Represents a material that can be applied to a product slot.
722
+ *
723
+ * ### What does it unlock?
724
+ * Describes material characteristics. Contains properties like name, textures, and appearance attributes.
725
+ *
726
+ * ### Practical Application
727
+ * Material data model: id (UUID), title (display name), externalId (SKU for ERP mapping), and
728
+ * thumbnailList (swatch preview images). Use to build material/finish pickers with visual swatches
729
+ * and to map selections to external product systems.
730
+ *
731
+ * ### AI Coding Best Practices
732
+ * Access material data from component slot definitions in configuratorDataUpdated. Use title for labels,
733
+ * thumbnailList for swatch images, externalId to map to your PIM/ERP for pricing and inventory.
734
+ * Pass material.id to SetComponentMaterial or SetEnvironmentMaterial.
336
735
  */
337
736
  interface Material {
338
737
  /** Unique identifier for the material. */
@@ -344,33 +743,72 @@ interface Material {
344
743
  /** List of thumbnails for the material. */
345
744
  thumbnailList: Thumbnail[];
346
745
  /** The model information associated with the material. */
347
- /** GraphQL typename for the material. */
746
+ /** Represents object typename for the material. */
348
747
  __typename: 'Material';
349
748
  }
350
749
  /**
351
750
  * Details showcase the presentation of a product.
751
+ *
752
+ * ### What does it unlock?
753
+ * Interface for showcase/demo mode features. Defines properties for timeline-based presentation.
754
+ *
755
+ * ### Practical Application
756
+ * Showcase/demo animation data. Defines camera animation sequences for auto-playing product
757
+ * presentations — timeline-based with camera movements, transitions, and durations.
758
+ * Attached to components in the configurator.
759
+ *
760
+ * ### AI Coding Best Practices
761
+ * Check if components have associated showcase data before enabling demo playback buttons.
762
+ * Use showcase metadata (duration, slot count) to build custom timeline controls.
763
+ * Playback sequence: InitShowcase → PlayShowcase → monitor via showcaseStatusChanged.
352
764
  */
353
765
  interface Showcase {
354
766
  /** A list of low-bandwidth versions for the showcase (optional). */
355
767
  lowBandwidth?: (Timecode | null)[] | null;
356
768
  /** Duration for the showcase (optional). */
357
769
  duration?: number;
358
- /** GraphQL typename for the showcase. */
770
+ /** Represents object typename for the showcase. */
359
771
  __typename: 'Showcase';
360
772
  }
361
773
  /**
362
774
  * Represents a low-bandwidth entity used in showcases in LBM mode.
775
+ *
776
+ * ### What does it unlock?
777
+ * Timecode interface for showcase timeline management. Tracks timing and playback position information.
778
+ *
779
+ * ### Practical Application
780
+ * Playback position tracking for showcase animations. Contains current timestamp within the animation
781
+ * timeline. Use for building progress bars, time displays, or syncing external content (captions,
782
+ * annotations) to showcase playback.
783
+ *
784
+ * ### AI Coding Best Practices
785
+ * Access timecode data from showcase status events during playback. Use to update progress indicators
786
+ * in custom playback UIs. Combine with showcaseStatusChanged to build full media player controls
787
+ * for product demo presentations.
363
788
  */
364
789
  interface Timecode {
365
790
  /** Time marker for the entity. */
366
791
  time: number;
367
792
  /** Duration of the entity display. */
368
793
  duration: number;
369
- /** GraphQL typename (as a string, flexible type). */
794
+ /** Represents object typename (as a string, flexible type). */
370
795
  __typename: 'Timecode';
371
796
  }
372
797
  /**
373
798
  * Represents the environment settings for a modular configurator.
799
+ *
800
+ * ### What does it unlock?
801
+ * Environmental settings interface for the configurator. Contains lighting and atmosphere properties.
802
+ *
803
+ * ### Practical Application
804
+ * Environment settings interface: lighting properties, atmosphere, dynamic sky controls (udsEnabled,
805
+ * udsHour, sunNorthYaw). Use to build environment/scene selector UIs showing available scene options
806
+ * with preview thumbnails.
807
+ *
808
+ * ### AI Coding Best Practices
809
+ * Access from configurator.environments in the envelope. Use thumbnailList for visual picker cards.
810
+ * Display title as label. Check udsEnabled before showing time-of-day slider controls.
811
+ * List available slots for environment material customization.
374
812
  */
375
813
  interface ModularConfiguratorEnvironment {
376
814
  /** Unique identifier for the environment. */
@@ -381,11 +819,24 @@ interface ModularConfiguratorEnvironment {
381
819
  label: string;
382
820
  /** Detailed environment configuration. */
383
821
  environment: Environment;
384
- /** GraphQL typename for the environment. */
822
+ /** Represents object typename for the environment. */
385
823
  __typename: 'ModularConfiguratorEnvironment';
386
824
  }
387
825
  /**
388
826
  * Represents an environment with associated media and configuration.
827
+ *
828
+ * ### What does it unlock?
829
+ * Environment data model with lighting, sky, and material slot definitions.
830
+ *
831
+ * ### Practical Application
832
+ * Environment data model: id, title, udsEnabled (dynamic sky toggle), sunNorthYaw, udsHour
833
+ * (time of day for dynamic sky), thumbnailList (preview images), and slots (configurable material slots).
834
+ * Use to build environment/scene picker UIs.
835
+ *
836
+ * ### AI Coding Best Practices
837
+ * Access environment definitions from configurator.environments in the configuratorDataUpdated envelope.
838
+ * Use thumbnailList for preview cards. Check udsEnabled to know if time-of-day controls are available.
839
+ * Iterate slots array to build environment material pickers.
389
840
  */
390
841
  interface Environment {
391
842
  /** Unique identifier for the environment. */
@@ -403,11 +854,24 @@ interface Environment {
403
854
  /** List of slots for the environment (optional). */
404
855
  slots: Slot[];
405
856
  /** The model associated with the environment. */
406
- /** GraphQL typename for the environment. */
857
+ /** Represents object typename for the environment. */
407
858
  __typename: 'Environment';
408
859
  }
409
860
  /**
410
861
  * Defines the structure for a component tree where every component has id and parent.
862
+ *
863
+ * ### What does it unlock?
864
+ * Describes a component with its parent relationship. Used in component hierarchy representation.
865
+ *
866
+ * ### Practical Application
867
+ * Read-only array entries showing parent-child relationships in the component tree. Returned in
868
+ * configurationTree of ModularConfiguratorEnvelope. Each entry includes the component and its parent
869
+ * reference for building hierarchy UIs.
870
+ *
871
+ * ### AI Coding Best Practices
872
+ * Access via envelope.configurationTree from configuratorDataUpdated event. Use to render nested UIs
873
+ * (tree views, accordions, breadcrumbs) mirroring the modular assembly hierarchy.
874
+ * The root component will have no parent reference (parentId is null).
411
875
  */
412
876
  interface ComponentWithParent {
413
877
  id: string;
@@ -416,21 +880,71 @@ interface ComponentWithParent {
416
880
  }
417
881
  /**
418
882
  * Defines the structure for a mapping of selected materials.
883
+ *
884
+ * ### What does it unlock?
885
+ * Type alias representing selected component/item IDs. Used to track which entities are currently selected.
886
+ *
887
+ * ### Practical Application
888
+ * Record type (key-value map) tracking currently selected IDs. Found in componentMaterialsIds and
889
+ * environmentMaterialsIds of ModularConfiguratorEnvelope. Maps slot or type keys to selected
890
+ * material/component UUIDs.
891
+ *
892
+ * ### AI Coding Best Practices
893
+ * Access from configuratorDataUpdated envelope. Use componentMaterialsIds to mark 'active/selected'
894
+ * state on material swatches in your UI. Use componentsByComponentType to highlight which component
895
+ * is selected per category. Both update on every state change.
419
896
  */
420
897
  type SelectedIds = Record<string, Record<string, string>>;
421
898
  /**
422
- * Defines the structure for an available showcase status for the current product on a scene.
899
+ * Defines the structure for an available showcase status for the current component on a scene.
900
+ *
901
+ * ### What does it unlock?
902
+ * Type alias for showcase status states. Defines possible states of showcase/timeline playback.
903
+ *
904
+ * ### Practical Application
905
+ * Type alias: `'init' | 'play' | 'pause' | 'stop'`. Received via showcaseStatusChanged event.
906
+ * Use to conditionally render playback controls and toggle configurator interactivity during demos.
907
+ *
908
+ * ### AI Coding Best Practices
909
+ * Subscribe to showcaseStatusChanged and switch UI state: 'play' → show pause button, disable config
910
+ * controls; 'pause' → show play/stop buttons; 'stop' → show play button, re-enable all config controls.
423
911
  */
424
912
  type ShowCaseStatus = 'init' | 'play' | 'pause' | 'stop';
425
913
  /**
426
914
  * Defines the structure for a video resolution.
915
+ *
916
+ * ### What does it unlock?
917
+ * Defines video resolution settings for the configurator display. Specifies viewport dimensions.
918
+ *
919
+ * ### Practical Application
920
+ * Video resolution interface: `{width: number|null, height: number|null}`. Received via
921
+ * videoResolutionChanged event when the pixel stream resolution changes. Use for responsive
922
+ * layout adjustments or displaying stream quality info.
923
+ *
924
+ * ### AI Coding Best Practices
925
+ * Subscribe to videoResolutionChanged to monitor stream resolution. Use to dynamically adjust UI
926
+ * overlay positioning, inform users about stream quality, or scale screenshot size requests proportionally.
427
927
  */
428
928
  interface VideoResolution {
429
929
  width: number | null;
430
930
  height: number | null;
431
931
  }
432
932
 
433
- /** Represents an ecom configurator object with all necessary information about cta */
933
+ /**
934
+ * Represents an ecom configurator object with all necessary information about cta.
935
+ *
936
+ * ### What does it unlock?
937
+ * Configuration interface for the embedded MetaBox menu. Specifies settings and behavior for the menu system.
938
+ *
939
+ * ### Practical Application
940
+ * Configuration interface for the e-commerce/CTA system. Received via ecomConfiguratorDataUpdated event.
941
+ * Defines CTA button settings (label, callback URL) for the built-in or custom purchase workflow.
942
+ *
943
+ * ### AI Coding Best Practices
944
+ * Read-only data — subscribe to ecomConfiguratorDataUpdated to receive. If building custom UI, extract
945
+ * the CTA label and display it on your own button. The callback URL is where MetaBox POSTs the
946
+ * configuration data when CTA is triggered.
947
+ */
434
948
  interface EcomConfigurator {
435
949
  /** The unique ecom configurator identifier. */
436
950
  id: string;
@@ -438,11 +952,24 @@ interface EcomConfigurator {
438
952
  createdAt: string;
439
953
  /** A reference to the Call To Action Information. */
440
954
  cta?: Cta;
441
- /** GraphQL typename for the ecom configurator. */
955
+ /** Represents object typename for the ecom configurator. */
442
956
  __typename: 'Configurator';
443
957
  }
444
958
  /**
445
959
  * Represents the call-to-action information for an ecom configurator.
960
+ *
961
+ * ### What does it unlock?
962
+ * Call-to-Action interface. Defines interactive elements and buttons for user actions within the configurator.
963
+ *
964
+ * ### Practical Application
965
+ * Read-only CTA definition containing the label text and action URL configured in MetaBox admin. Received via
966
+ * ecomConfiguratorDataUpdated event. Use to render custom CTA buttons matching admin-configured actions
967
+ * (e.g., 'Request Quote', 'Add to Cart').
968
+ *
969
+ * ### AI Coding Best Practices
970
+ * Subscribe to ecomConfiguratorDataUpdated to receive CTA config. Use the label for button text.
971
+ * The actual CTA trigger is `api.sendCommandToMetabox(new GetCallToActionInformation())` — which POSTs
972
+ * the config JSON to the callback URL. The backend returns `{ redirectUrl }`.
446
973
  */
447
974
  interface Cta {
448
975
  /** The indicator of whether the call-to-action is enabled or not. */
@@ -451,10 +978,26 @@ interface Cta {
451
978
  label: string;
452
979
  /** Callback URL using for sent configurator selected information to this url and redirected to the url after get response. */
453
980
  callbackUrl: string;
454
- /** GraphQL typename for the CTA object. */
981
+ /** Represents object typename for the CTA object. */
455
982
  __typename: 'Cta';
456
983
  }
457
984
 
985
+ /**
986
+ * Maps event names received from the Metabox iframe to their typed payloads.
987
+ * Used by {@link Communicator.addEventListener} to provide type-safe event subscriptions.
988
+ *
989
+ * ### What does it unlock?
990
+ * Message format for MetaBox communication protocol. Wraps data for transmission between API and MetaBox.
991
+ *
992
+ * ### Practical Application
993
+ * Payload type map for all incoming event types. Defines the data shape for each event name
994
+ * (configuratorDataUpdated, screenshotReady, viewportReady, etc.). Essential TypeScript reference for properly typing event handlers.
995
+ *
996
+ * ### AI Coding Best Practices
997
+ * Use as TypeScript type reference: `api.addEventListener('configuratorDataUpdated', (data: FromMetaboxMessagePayloads['configuratorDataUpdated']) => {...})`.
998
+ * Key events and their types: configuratorDataUpdated→ModularConfiguratorEnvelope, screenshotReady→string|null,
999
+ * viewportReady→boolean, showcaseStatusChanged→ShowCaseStatus.
1000
+ */
458
1001
  interface FromMetaboxMessagePayloads {
459
1002
  /**
460
1003
  * Dispatches every time the configurator data is updated.
@@ -466,13 +1009,13 @@ interface FromMetaboxMessagePayloads {
466
1009
  */
467
1010
  ecomConfiguratorDataUpdated: EcomConfigurator;
468
1011
  /**
469
- * Dispatches every time when while the configurator loads. Shows showcase status information on a scene.
1012
+ * Dispatches every time when the Unreal Viewport is visible/hidden.
470
1013
  */
471
- showcaseStatusChanged: ShowCaseStatus;
1014
+ viewportReady: boolean;
472
1015
  /**
473
- * Dispatches every time when the Viewport is ready / not ready.
1016
+ * Dispatches every time when while the configurator loads. Shows showcase status information on a scene.
474
1017
  */
475
- viewportReady: boolean;
1018
+ showcaseStatusChanged: ShowCaseStatus;
476
1019
  /**
477
1020
  * Dispatches at the moment while the configurator loads. Shows status information.
478
1021
  */
@@ -496,18 +1039,58 @@ interface FromMetaboxMessagePayloads {
496
1039
  dataChannelConnected: boolean;
497
1040
  }
498
1041
  /**
1042
+ * Union of all event names received from MetaBox.
1043
+ *
1044
+ * ### What does it unlock?
1045
+ * Type alias for MetaBox API actions coming from the server. Defines all possible action types.
1046
+ *
1047
+ * ### Practical Application
1048
+ * Type alias enumerating all possible incoming action/event types from MetaBox. Reference as a complete
1049
+ * checklist of subscribable events for building comprehensive event handling.
1050
+ *
1051
+ * ### AI Coding Best Practices
1052
+ * Use as a reference for all valid event names in api.addEventListener(). Key events:
1053
+ * configuratorDataUpdated, viewportReady, screenshotReady, showcaseStatusChanged, getCameraResult,
1054
+ * statusMessageChanged, ecomConfiguratorDataUpdated, videoResolutionChanged.
1055
+ *
499
1056
  * @hidden
500
1057
  */
501
1058
  type FromMetaBoxApiEvents = keyof FromMetaboxMessagePayloads;
502
1059
  /**
503
1060
  * @internal
504
1061
  * This creates all event envelopes defined in MetaBoxAPIPayloads.
1062
+ *
1063
+ * ### What does it unlock?
1064
+ * Envelope structure for wrapping MetaBox API messages. Encapsulates commands and data for transmission.
1065
+ *
1066
+ * ### Practical Application
1067
+ * Protocol envelope structure wrapping all MetaBox API messages. Internal to the communication layer — adds
1068
+ * routing and protocol headers. The Communicator handles this automatically.
1069
+ *
1070
+ * ### AI Coding Best Practices
1071
+ * For debugging: inspect postMessage events in browser devtools and match
1072
+ * against this structure to diagnose malformed messages. The Communicator handles all wrapping/unwrapping.
505
1073
  */
506
1074
  interface MetaBoxApiEnvelope<T extends FromMetaBoxApiEvents> {
507
1075
  action: 'bridge';
508
1076
  eventType: T;
509
1077
  payload: FromMetaboxMessagePayloads[T];
510
1078
  }
1079
+ /**
1080
+ * Identifies which side of the iframe boundary the Communicator is running on.
1081
+ *
1082
+ * ### What does it unlock?
1083
+ * Distinguishes which side of the postMessage channel the Communicator is operating on —
1084
+ * `'host'` for the embedding page and `'metabox'` for the iframe.
1085
+ *
1086
+ * ### Practical Application
1087
+ * Used internally by the Communicator to tag outgoing messages so the receiving side can verify their origin.
1088
+ * You never need to set or check this value in application code.
1089
+ *
1090
+ * ### AI Coding Best Practices
1091
+ * Skip in application code. The Communicator sets this automatically based on the `createInstance()` call.
1092
+ * Only relevant if debugging raw postMessage traffic between your page and the MetaBox iframe.
1093
+ */
511
1094
  type MetaboxEnvironment = 'metabox' | 'host';
512
1095
  /**
513
1096
  * @hidden
@@ -530,7 +1113,27 @@ interface MCAppLoaded {
530
1113
  type FromMetaBoxAPIEnvelope = {
531
1114
  [K in keyof FromMetaboxMessagePayloads]: MetaBoxApiEnvelope<K>;
532
1115
  }[keyof FromMetaboxMessagePayloads] | MCAppLoaded;
1116
+ /**
1117
+ * @internal
1118
+ * @hidden
1119
+ */
533
1120
  type FromMetaboxTarget = 'parent' | 'communicator';
1121
+ /**
1122
+ * @internal
1123
+ * @hidden
1124
+ * Top-level postMessage structure received from the Metabox iframe.
1125
+ *
1126
+ * ### What does it unlock?
1127
+ * Represents the Top-level postMessage structure received from the Metabox iframe. Contains read-only data.
1128
+ *
1129
+ * ### Practical Application
1130
+ * Incoming message wrapper from MetaBox. Defines how MetaBox wraps response data for postMessage delivery.
1131
+ * Internal to communication layer — the Communicator parses these automatically.
1132
+ *
1133
+ * ### AI Coding Best Practices
1134
+ * Do not parse these manually. The Communicator handles unwrapping and delivers typed payloads to your event listeners.
1135
+ * Only reference if debugging raw postMessage traffic in browser devtools.
1136
+ */
534
1137
  interface FromMetaBoxMessage {
535
1138
  host: typeof Metabox;
536
1139
  envelope: FromMetaBoxAPIEnvelope;
@@ -539,10 +1142,24 @@ interface FromMetaBoxMessage {
539
1142
 
540
1143
  /**
541
1144
  * Base class for commands sent to the Metabox API.
1145
+ *
1146
+ * ### What does it unlock?
1147
+ * Base class that all other commands inherit from in a class hierarchy. Provides common properties
1148
+ * and methods that are automatically available to all command subclasses.
1149
+ *
1150
+ * ### Practical Application
1151
+ * Base class all commands inherit from. Never instantiate directly — use specific subclasses like
1152
+ * SetProduct, SetCamera, etc. All commands are sent via `api.sendCommandToMetabox(new CommandName(...))`.
1153
+ *
1154
+ * ### AI Coding Best Practices
1155
+ * Never construct a generic CommandBase. Always use the specific typed command class. When generating
1156
+ * dynamic command dispatch, use a switch/map pattern matching command names to their constructors.
1157
+ *
542
1158
  * @internal
543
1159
  * @hidden
544
1160
  */
545
1161
  declare class CommandBase {
1162
+ /** The message envelope populated by subclass constructors and sent via {@link Communicator.sendCommandToMetabox}. */
546
1163
  data: ToMetaBoxMessageEnvelope;
547
1164
  }
548
1165
 
@@ -550,6 +1167,18 @@ declare class CommandBase {
550
1167
  * Represents a callback listener for specific message types.
551
1168
  * Used internally by EventDispatcher to store event listeners.
552
1169
  *
1170
+ * ### What does it unlock?
1171
+ * Event listener interface. Allows subscription to specific events from the configurator to receive real-time data updates.
1172
+ *
1173
+ * ### Practical Application
1174
+ * Event listener interface. addEventListener() and removeEventListener() on Communicator. Subscribe to real-time
1175
+ * configurator events: state changes, viewport readiness, screenshots, showcase status, camera results, resolution changes.
1176
+ *
1177
+ * ### AI Coding Best Practices
1178
+ * Set up listeners BEFORE sending commands that trigger them. Always clean up with removeEventListener on component unmount.
1179
+ * Key events: configuratorDataUpdated (every state change), viewportReady (init complete), screenshotReady (captures),
1180
+ * getCameraResult (camera queries), showcaseStatusChanged (demo playback).
1181
+ *
553
1182
  * @public
554
1183
  */
555
1184
  interface Listener {
@@ -560,12 +1189,27 @@ interface Listener {
560
1189
  }
561
1190
  /**
562
1191
  * EventDispatcher is a class that manages event listeners and dispatches events to them.
1192
+ *
1193
+ * ### What does it unlock?
1194
+ * Parent class of Communicator that dispatches commands. Acts as an event dispatcher that routes command messages internally.
1195
+ *
1196
+ * ### Practical Application
1197
+ * Internal event routing layer — parent class of Communicator. Routes postMessage commands between your app
1198
+ * and the Unreal Engine pixel stream. Not used directly but understanding it helps debug message delivery issues.
1199
+ *
1200
+ * ### AI Coding Best Practices
1201
+ * Do not reference or extend EventDispatcher in application code. Use only the Communicator interface methods.
1202
+ * If debugging communication failures, check browser console for postMessage errors related to this layer.
563
1203
  */
564
1204
  declare class EventDispatcher {
565
1205
  /**
566
1206
  * Storage for callback listeners by message type.
567
1207
  */
568
1208
  listeners: Listener[];
1209
+ /**
1210
+ * Removes all registered listeners. Subclasses override this to perform additional cleanup.
1211
+ * @param key - Instance key (used by subclass overrides for registry cleanup).
1212
+ */
569
1213
  destroy(key: string): void;
570
1214
  /**
571
1215
  * Adds an event listener for receiving specific types of messages.
@@ -591,14 +1235,25 @@ declare class EventDispatcher {
591
1235
  }
592
1236
 
593
1237
  /**
594
- * Handles messaging between the host page and embedded to the Metabox content.
1238
+ * Handles messaging between the host page and embedded Metabox content.
1239
+ *
1240
+ * ### What does it unlock?
1241
+ * Internal class that creates a proxy/communication layer between the API and MetaBox.
1242
+ * Handles reading and sending commands through the established connection.
1243
+ *
1244
+ * ### Practical Application
1245
+ * The API handle returned in the integrateMetabox callback. Provides sendCommandToMetabox() to send commands,
1246
+ * and addEventListener()/removeEventListener() for event subscriptions. This is your entire interface to
1247
+ * the MetaBox Unreal Engine stream.
1248
+ *
1249
+ * ### AI Coding Best Practices
1250
+ * Store the Communicator reference from the apiReadyCallback in a module-scoped variable or state store.
1251
+ * NEVER send commands before this callback fires. All commands and event listeners go through this single
1252
+ * api object. Clean up listeners with removeEventListener on component unmount.
1253
+ *
595
1254
  * @internal Use {@link Communicator.createInstance} or the {@link integrateMetabox} helper to instantiate.
596
1255
  */
597
1256
  declare class Communicator extends EventDispatcher {
598
- /**
599
- * Singleton reference to the current communicator instance.
600
- */
601
- static instance: Communicator | null;
602
1257
  /**
603
1258
  * Bound handler for incoming postMessage events.
604
1259
  */
@@ -610,7 +1265,7 @@ declare class Communicator extends EventDispatcher {
610
1265
  constructor(data: MCAppLoaded['payload'], environment: MetaboxEnvironment, config?: Partial<MetaboxCommandConfig>);
611
1266
  /**
612
1267
  * Listens for Metabox to signal readiness, then initializes communicator.
613
- * @param apiReadyCallback - Called with the new Communicator once to the Metabox is loaded.
1268
+ * @param apiReadyCallback - Called with the new Communicator once the Metabox is loaded.
614
1269
  * @param {MetaboxEnvironment} environment - The environment in which the Communicator is running.
615
1270
  * @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic
616
1271
  */
@@ -619,7 +1274,12 @@ declare class Communicator extends EventDispatcher {
619
1274
  * Cleans up resources and stops listening for messages.
620
1275
  */
621
1276
  destroy(key: string): void;
1277
+ /** Destroys all active Communicator instances and clears the internal registry. */
622
1278
  static clearAll(): void;
1279
+ /**
1280
+ * Retrieves a registered Communicator instance by its key.
1281
+ * @param key - The composite key (`version_environment_appId`) identifying the instance.
1282
+ */
623
1283
  static getCommunicator(key: string): {
624
1284
  instance: Communicator;
625
1285
  } | undefined;
@@ -629,17 +1289,23 @@ declare class Communicator extends EventDispatcher {
629
1289
  */
630
1290
  sendCommandToMetabox<T extends CommandBase>(command: T): void;
631
1291
  /**
632
- * Registers an event listener for messages dispatched by Metabox.
1292
+ * Registers an event listener for messages dispatched by the Metabox.
1293
+ * @param messageType - The event name to listen for (e.g. `'configuratorDataUpdated'`).
1294
+ * @param callback - Handler invoked with the typed payload when the event fires.
633
1295
  * @override
634
1296
  */
635
1297
  addEventListener<T extends FromMetaBoxApiEvents>(messageType: T, callback: (data: FromMetaboxMessagePayloads[T]) => void): this;
636
1298
  /**
637
1299
  * Dispatches a typed event to all registered listeners.
1300
+ * @param messageType - The event name to dispatch.
1301
+ * @param data - The payload to pass to each listener.
638
1302
  * @override
639
1303
  */
640
1304
  dispatchEvent<T extends FromMetaBoxApiEvents>(messageType: T, data: FromMetaboxMessagePayloads[T]): this;
641
1305
  /**
642
1306
  * Removes a previously registered event listener.
1307
+ * @param messageType - The event name the listener was registered for.
1308
+ * @param callback - The same function reference that was passed to {@link addEventListener}.
643
1309
  * @override
644
1310
  */
645
1311
  removeEventListener<T extends FromMetaBoxApiEvents>(messageType: T, callback: (data: FromMetaboxMessagePayloads[T]) => void): this;
@@ -654,11 +1320,27 @@ declare class Communicator extends EventDispatcher {
654
1320
  * Integrates the Metabox Modular Configurator into the page by injecting an iframe and
655
1321
  * initializing a Communicator instance for host-to-iframe messaging.
656
1322
  *
657
- * @remarks
658
1323
  * - Builds a secure iframe URL using the provided configuratorId and config options.
659
1324
  * - Ensures the resulting URL uses HTTPS and that the target container exists.
660
1325
  * - Removes any previously embedded iframe with id "embeddedContent" before inserting a new one.
661
1326
  *
1327
+ * ### What does it unlock?
1328
+ * Main initialization function for MetaBox integration. Initializes the configurator, receives an API handle,
1329
+ * and sets up all configurations.
1330
+ *
1331
+ * ### Practical Application
1332
+ * THE entry point function. Creates the configurator iframe, establishes postMessage communication, and returns
1333
+ * the Communicator api handle via callback. Call ONCE per configurator. Params: configuratorId (modular UUID),
1334
+ * containerId (DOM element ID, default 'embed3DSource'), apiReadyCallback, config (IntegrateMetaboxConfig).
1335
+ *
1336
+ * ### AI Coding Best Practices
1337
+ * Pattern: `integrateMetabox('uuid', 'div-id', (api) => {
1338
+ * setup listeners, then set root component, then environment, then children
1339
+ * }, { standalone: true })`.
1340
+ * Ensure container div exists in DOM with non-zero dimensions. HTTPS required.
1341
+ * Inside callback: 1) addEventListener for configuratorDataUpdated, 2) SetComponent root, 3) SetEnvironment,
1342
+ * 4) SetComponent children, 5) SetComponentMaterial.
1343
+ *
662
1344
  * @param {string} configuratorId - The Modular Configurator ID (not a full URL). It is appended to
663
1345
  * `https://{domain}/metabox-configurator/modular/{configuratorId}` to form the iframe src.
664
1346
  *
@@ -700,18 +1382,43 @@ declare function integrateMetabox(configuratorId: string, containerId: string, a
700
1382
  /**
701
1383
  * Saves an image by triggering a download.
702
1384
  *
703
- * @remarks
704
1385
  * This function creates an anchor element, sets its `href` attribute to the provided image URL,
705
1386
  * and triggers a click event to initiate a download with the specified filename.
706
1387
  *
1388
+ * ### What does it unlock?
1389
+ * Main exported function to save images from the configurator. Converts base64 image data to actual image
1390
+ * files and saves them to the local filesystem.
1391
+ *
1392
+ * ### Practical Application
1393
+ * Exported utility function that converts base64 screenshot data (from screenshotReady event) to a downloadable
1394
+ * image file. Handles the base64 → blob → browser download flow. Import directly from the API package.
1395
+ *
1396
+ * ### AI Coding Best Practices
1397
+ * Pattern: `api.addEventListener('screenshotReady', (data) => { if(data) saveImage(data, 'config-screenshot.png'); })`.
1398
+ * Filename extension should match the MimeType passed to GetScreenshot.
1399
+ * Import: `import { saveImage } from '@3dsource/metabox-modular-configurator-api'`.
1400
+ *
707
1401
  * @param {string} imageUrl - The URL of the image to save.
708
1402
  * @param {string} filename - The name of the file to save.
709
1403
  */
710
1404
  declare function saveImage(imageUrl: string, filename: string): void;
711
1405
 
712
1406
  /**
1407
+ * Constructs the iframe source URL for the Metabox Modular Configurator.
1408
+ *
1409
+ * ### What does it unlock?
1410
+ * Utility function that prepares the iframe source URL. Constructs the proper URL with parameters
1411
+ * for loading the MetaBox configurator.
1412
+ *
1413
+ * ### Practical Application
1414
+ * Utility function that constructs the iframe source URL with proper parameters.
1415
+ * URL format: `https://{domain}/metabox-configurator/modular/{configuratorId}`.
1416
+ * Called internally by integrateMetabox() — use directly only for manual URL construction.
1417
+ *
1418
+ * ### AI Coding Best Practices
1419
+ * Usually called internally. Use directly only for pre-constructing embed URLs (QR codes, email links,
1420
+ * preview URLs). Verify output is HTTPS. Remember modular configurators use `/modular/` path.
713
1421
  *
714
- * @remarks
715
1422
  * @internal
716
1423
  * @hidden
717
1424
  *
@@ -721,141 +1428,169 @@ declare function saveImage(imageUrl: string, filename: string): void;
721
1428
  declare const prepareIframeSrc: (configuratorId: string, config?: IntegrateMetaboxConfig) => string;
722
1429
 
723
1430
  /**
724
- * Wrapper helper function to use it with rxJs the same as `fromEvent` to listen to events from the Communicator.
1431
+ * Wrapper helper function to use with RxJS the same way as `fromEvent`, to listen to events from the Communicator.
1432
+ *
1433
+ * ### What does it unlock?
1434
+ * Function that creates an event listener subscription. Allows developers to subscribe to specific events from the Communicator.
1435
+ *
1436
+ * ### Practical Application
1437
+ * Function that creates event listener subscriptions. Alternative to api.addEventListener() — both subscribe
1438
+ * to configurator events. Use to react to state changes, screenshot readiness, viewport loading, showcase status, etc.
1439
+ *
1440
+ * ### AI Coding Best Practices
1441
+ * Prefer api.addEventListener() directly from the Communicator object. If using fromCommunicatorEvent, pass the
1442
+ * event name and handler. Key events: configuratorDataUpdated, viewportReady, screenshotReady, showcaseStatusChanged,
1443
+ * getCameraResult. Always subscribe BEFORE sending commands that trigger responses.
725
1444
  *
726
- * @param {Communicator} target
727
- * @param eventName
1445
+ * @param {Communicator} target - The Communicator instance to listen on.
1446
+ * @param {T} eventName - The event name from {@link FromMetaBoxApiEvents} to subscribe to.
1447
+ * @returns An Observable that emits the typed payload each time the event fires.
728
1448
  * @internal
729
1449
  */
730
1450
  declare function fromCommunicatorEvent<T extends FromMetaBoxApiEvents>(target: Communicator, eventName: T): Observable<FromMetaboxMessagePayloads[T]>;
731
1451
 
732
1452
  /**
733
- * Represents a command to send Metabox Config to Metabox Basic Configurator.
734
- * @remarks
735
- * **Important**: No need to listen to any events to see changes.
1453
+ * Represents a command to send Metabox Config to Metabox Modular Configurator.
1454
+ *
1455
+ * ### What does it unlock?
1456
+ * Configuration object passed to MetaBox during initialization. Specifies domain, host, standalone mode,
1457
+ * and other parameters that control how the configurator behaves.
1458
+ *
1459
+ * ### Practical Application
1460
+ * Internal configuration object auto-sent during initialization. Contains appId and config.
1461
+ * DO NOT call directly — integrateMetabox() handles this automatically as part of its setup sequence.
1462
+ *
1463
+ * ### AI Coding Best Practices
1464
+ * NEVER instantiate or send MetaboxConfig manually. It is auto-sent by integrateMetabox().
1465
+ * Use the IntegrateMetaboxConfig parameter of integrateMetabox() instead for setting domain, standalone,
1466
+ * loadingImage, introImage, state, etc.
736
1467
  *
737
1468
  * @internal
738
1469
  * Automatically sent when the Communicator instance is ready.
1470
+ *
1471
+ * @param {string} appId - The unique identifier for the Communicator Instance
1472
+ * @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic
739
1473
  */
740
1474
  declare class MetaboxConfig extends CommandBase {
741
- /**
742
- * Creates an instance of MetaboxConfig.
743
- * @param {string} appId - The unique identifier for the Communicator Instance
744
- * @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic
745
- */
746
1475
  constructor(appId: string, config: MetaboxCommandConfig);
747
1476
  }
748
1477
 
749
1478
  /**
750
- * Represents a command to get a PDF from Metabox Basic Configurator.
751
- * @remarks
1479
+ * Represents a command to get a PDF from Metabox Modular Configurator.
752
1480
  * This class sends a message to the Metabox API to generate a PDF based on the current configuration.
753
- * **Important**: No need to listen to any events to see changes.
754
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
1481
+ * **Important**: No need to listen to any events to see changes. Pdf will be downloaded automatically once it's ready.
1482
+ *
1483
+ * ### What does it unlock?
1484
+ * Generates a native MetaBox PDF document. No subscription required — it executes independently.
1485
+ *
1486
+ * ### Practical Application
1487
+ * Generates a branded PDF from the current configurator state server-side. No event subscription needed.
1488
+ * Use for B2B quote workflows, downloadable spec sheets, or emailing configured product summaries to prospects.
1489
+ *
1490
+ * ### AI Coding Best Practices
1491
+ * Simply call `api.sendCommandToMetabox(new GetPdf())`. No parameters or event subscription required.
1492
+ * The PDF generates inside MetaBox application.
755
1493
  *
756
1494
  * @example
757
1495
  * import { GetPdf, Communicator } from '@3dsource/metabox-modular-configurator-api';
758
- *
759
- * @param {Communicator} api - communicator instance api
760
1496
  * window.env3DSource.apiReady = (api: Communicator) => {
761
1497
  * api.sendCommandToMetabox(new GetPdf());
762
1498
  * };
763
1499
  */
764
1500
  declare class GetPdf extends CommandBase {
765
- /**
766
- * Creates an instance of GetPdf.
767
- *
768
- * @remarks
769
- * This constructor does not require any parameters.
770
- */
771
1501
  constructor();
772
1502
  }
773
1503
 
774
1504
  /**
775
- * Represents a command to get a Call To Action Information from Metabox Basic Configurator.
776
- * @remarks
777
- * 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.
1505
+ * Represents a command to get a Call To Action Information from Metabox Modular Configurator.
1506
+ * This class sends a message to the Metabox API to generate Call To Action information based on the current
1507
+ * configuration and sends it to the endpoint URL from the CTA information.
778
1508
  *
779
1509
  * To listen for changes after sending this command, listen to the 'ecomConfiguratorDataUpdated' event.
780
- * //...Assume that the integration is already implemented (only once)
781
- * @example
782
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
783
1510
  *
784
- * @param {Communicator} api - communicator instance api
785
- * window.env3DSource.apiReady = (api: Communicator) => {
786
- * @param {EcomConfigurator} data - description for all ecom configurator params
787
- * api.addEventListener('ecomConfiguratorDataUpdated', (data) => {
788
- * console.log('Ecom configurator params:', data);
789
- * });
790
- * };
1511
+ * ### What does it unlock?
1512
+ * Retrieves information about call-to-action that were added to the configurator. Requires subscription to receive data.
791
1513
  *
792
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
1514
+ * ### Practical Application
1515
+ * Triggers the CTA (Call-to-Action) workflow configured in MetaBox admin. The CTA label and callback URL are set in admin.
1516
+ * When invoked, MetaBox POSTs the full configuration JSON (including BOM) to your callback URL endpoint, which returns a { redirectUrl }.
793
1517
  *
794
- * @example
795
- * import { GetCallToActionInformation, Communicator } from '@3dsource/metabox-modular-configurator-api';
1518
+ * ### AI Coding Best Practices
1519
+ * Call only after user completes configuration. Subscribe to ecomConfiguratorDataUpdated to get CTA label/URL for building
1520
+ * custom CTA buttons in your UI. The POST payload includes the full bill of materials — your backend endpoint processes it
1521
+ * and returns a redirect URL.
796
1522
  *
797
- * @param {Communicator} api - communicator instance api
1523
+ * @example
1524
+ * import { Communicator, EcomConfigurator, GetCallToActionInformation } from '@3dsource/metabox-modular-configurator-api';
798
1525
  * window.env3DSource.apiReady = (api: Communicator) => {
1526
+ *
1527
+ * //Subscribe to the event before sending the command to ensure you capture the response
1528
+ * api.addEventListener('ecomConfiguratorDataUpdated', (data:EcomConfigurator) => {
1529
+ * console.log('Ecom configurator params:', data);
1530
+ * });
1531
+ *
1532
+ * // Send the command to get Call To Action information from Metabox Modular Configurator
799
1533
  * api.sendCommandToMetabox(new GetCallToActionInformation());
800
1534
  * };
801
1535
  */
802
1536
  declare class GetCallToActionInformation extends CommandBase {
803
- /**
804
- * Creates an instance of GetCallToActionInformation.
805
- *
806
- * @remarks
807
- * This constructor does not require any parameters.
808
- */
809
1537
  constructor();
810
1538
  }
811
1539
 
812
1540
  /**
813
1541
  * Represents a command to get the camera configuration from Unreal.
814
- * @remarks
815
1542
  * This class sends a message to the Metabox API to get the camera from a scene.
816
- *
817
1543
  * To listen for changes after sending this command, listen to the 'getCameraResult' event.
818
- * //...Assume that the integration is already implemented (only once)
819
- * @example
820
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
821
1544
  *
822
- * @param {Communicator} api - communicator instance api
823
- * window.env3DSource.apiReady = (api: Communicator) => {
824
- * @param {CameraCommandPayload} data - camera params
825
- * api.addEventListener('getCameraResult', (data) => {
826
- * console.log('Camera params after get camera command:', data);
827
- * });
828
- * };
1545
+ * ### What does it unlock?
1546
+ * Retrieves camera presets for the configurator; allowing extraction and application of saved camera positions.
829
1547
  *
830
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
1548
+ * ### Practical Application
1549
+ * Requests current camera state — returns asynchronously via the getCameraResult event. Returns a CameraCommandPayload
1550
+ * with fov, mode, position, rotation, and restrictions. Use to save camera positions, create shareable view links,
1551
+ * or build 'save this angle' features.
1552
+ *
1553
+ * ### AI Coding Best Practices
1554
+ * ALWAYS subscribe to getCameraResult BEFORE calling GetCamera(). Pattern: `api.addEventListener('getCameraResult', handler);`
1555
+ * then `api.sendCommandToMetabox(new GetCamera())`. The returned CameraCommandPayload can be fed directly back into
1556
+ * SetCamera to restore the view.
831
1557
  *
832
1558
  * @example
833
- * import { GetCamera, Communicator } from '@3dsource/metabox-modular-configurator-api';
834
- * @param {Communicator} api - communicator instance api
1559
+ * import { Communicator, CameraCommandPayload, GetCamera } from '@3dsource/metabox-modular-configurator-api';
835
1560
  * window.env3DSource.apiReady = (api: Communicator) => {
1561
+ *
1562
+ * //Subscribe to the event before sending the command to ensure you capture the response
1563
+ * api.addEventListener('getCameraResult', (data:CameraCommandPayload) => {
1564
+ * console.log('Camera params after get camera command:', data);
1565
+ * });
1566
+ *
836
1567
  * api.sendCommandToMetabox(new GetCamera());
837
1568
  * };
838
1569
  */
839
1570
  declare class GetCamera extends CommandBase {
840
- /**
841
- * Creates an instance of GetCamera.
842
- *
843
- * @remarks
844
- * This constructor does not require any parameters.
845
- */
846
1571
  constructor();
847
1572
  }
848
1573
 
849
1574
  /**
850
1575
  * Represents a command to set the camera configuration.
851
- * @remarks
852
1576
  * This class sends a message to the Metabox API to set the camera on a scene.
853
1577
  * **Important**: No need to listen to any events to see changes.
854
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
1578
+ *
1579
+ * ### What does it unlock?
1580
+ * Sets camera presets with restriction parameters (FOV, rotation, position).
1581
+ *
1582
+ * ### Practical Application
1583
+ * Sets camera with precise control: fov (degrees), mode ('orbit'|'fps'), position ({x,y,z}),
1584
+ * rotation ({horizontal,vertical}), and restrictions (min/max distance, FOV, rotation bounds).
1585
+ * Use for guided tours, preset view buttons, or restricting camera to prevent users seeing behind the product.
1586
+ *
1587
+ * ### AI Coding Best Practices
1588
+ * Only include fields you want to change — omitted values keep current settings. Use orbit mode for typical product viewing,
1589
+ * fps for walkthrough/room scenes. Apply restrictions to prevent bad angles. Full interface:
1590
+ * `{fov?, mode?, position?, rotation?, restrictions?}`.
855
1591
  *
856
1592
  * @example
857
1593
  * import { SetCamera, Communicator } from '@3dsource/metabox-modular-configurator-api';
858
- * @param {Communicator} api - communicator instance api
859
1594
  * window.env3DSource.apiReady = (api: Communicator) => {
860
1595
  * api.sendCommandToMetabox(new SetCamera({
861
1596
  * fov: 45,
@@ -871,155 +1606,134 @@ declare class GetCamera extends CommandBase {
871
1606
  * minFov: 0,
872
1607
  * minHorizontalRotation: 0,
873
1608
  * minVerticalRotation: 0,
874
- * },
1609
+ * },
875
1610
  * }));
876
1611
  * };
1612
+ *
1613
+ * @param {CameraCommandPayload} camera - The camera configuration.
877
1614
  */
878
1615
  declare class SetCamera extends CommandBase {
879
- /**
880
- * Creates an instance of SetCamera.
881
- *
882
- * @param {CameraCommandPayload} camera - The camera configuration.
883
- */
884
1616
  constructor(camera: CameraCommandPayload);
885
1617
  }
886
1618
 
887
1619
  /**
888
1620
  * Represents a command to reset the camera to its initial position.
889
- * @remarks
890
1621
  * This class sends a message to the Metabox API to reset the camera on a scene.
891
- * **Important**: No need to listen to any events to see changes.
892
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
1622
+ *
1623
+ * ### What does it unlock?
1624
+ * Resets the camera to its default state and position. Used to return camera to initial configuration after user manipulation.
1625
+ *
1626
+ * ### Practical Application
1627
+ * Resets camera to the default position defined in the component/environment template. Essential for 'Reset View' buttons.
1628
+ * Also, useful after programmatic camera moves to return to a known starting state.
1629
+ *
1630
+ * ### AI Coding Best Practices
1631
+ * Call `api.sendCommandToMetabox(new ResetCamera())`. No parameters. Restores template defaults — not the last user position.
1632
+ * Good practice to call after SetComponent changes that may shift the focal point of the assembly.
893
1633
  *
894
1634
  * @example
895
1635
  * import { ResetCamera, Communicator } from '@3dsource/metabox-modular-configurator-api';
896
- * @param {Communicator} api - communicator instance api
897
1636
  * window.env3DSource.apiReady = (api: Communicator) => {
898
1637
  * api.sendCommandToMetabox(new ResetCamera());
899
1638
  * };
900
1639
  */
901
1640
  declare class ResetCamera extends CommandBase {
902
- /**
903
- * Creates an instance of ResetCamera.
904
- *
905
- * @remarks
906
- * This constructor does not require any parameters.
907
- */
908
1641
  constructor();
909
1642
  }
910
1643
 
911
1644
  /**
912
1645
  * Represents a command to apply zoom and change the camera zoom on a scene.
913
- * @remarks
914
1646
  * This class sends a command to the Metabox API to change zoom on a scene.
915
- * **Important**: No need to listen to any events to see changes.
916
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
1647
+ *
1648
+ * ### What does it unlock?
1649
+ * Controls zoom functionality for the configurator; allowing users to adjust the zoom level of 3D objects and camera presets.
1650
+ *
1651
+ * ### Practical Application
1652
+ * Implements programmatic zoom on the pixel-streamed viewport. Use to build zoom slider controls, pinch-to-zoom on mobile,
1653
+ * or 'zoom to detail' buttons. Takes a numeric delta: positive zooms in, negative zooms out
1654
+ * (e.g., ApplyZoom(50) zooms in, ApplyZoom(-50) zooms out).
1655
+ *
1656
+ * ### AI Coding Best Practices
1657
+ * Always use numeric delta values, not absolute zoom levels. Pair with a UI slider that sends incremental values.
1658
+ * Debounce zoom input to ~100ms intervals to prevent overwhelming the Unreal stream.
1659
+ * Pattern: `api.sendCommandToMetabox(new ApplyZoom(50))`.
917
1660
  *
918
1661
  * @example
919
1662
  * import { ApplyZoom, Communicator } from '@3dsource/metabox-modular-configurator-api';
920
- *
921
- * @param {Communicator} api - communicator instance api
922
1663
  * window.env3DSource.apiReady = (api: Communicator) => {
923
- * api.sendCommandToMetabox(new ApplyZoom(10));
924
- * api.sendCommandToMetabox(new ApplyZoom(-10));
1664
+ * api.sendCommandToMetabox(new ApplyZoom(50));
925
1665
  * };
1666
+ *
1667
+ * @param {number} zoom - The zoom value to apply.
926
1668
  */
927
1669
  declare class ApplyZoom extends CommandBase {
928
- /**
929
- * Creates an instance of ApplyZoom.
930
- *
931
- * @param {number} zoom - The zoom value to apply.
932
- */
933
1670
  constructor(zoom: number);
934
1671
  }
935
1672
 
936
1673
  /**
937
- * Represents a command to initialize Showcase for a product scene and start a sequence for the product.
938
- * @remarks
939
- * This class sends a command to the Metabox API to initialize showcase if the product has a sequence.
940
- * To check this, find the showcase property in the current product and listen to the 'configuratorDataUpdated' event.
941
- * //...Assume that the integration is already implemented (only once)
942
- * @example
943
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
944
- *
945
- * @param {Communicator} api - communicator instance api
946
- * window.env3DSource.apiReady = (api: Communicator) => {
947
- * @param {ConfiguratorEnvelope} data - configurator state after updated
948
- * api.addEventListener('configuratorDataUpdated', (data) => {
949
- * console.log('State updated after applied new environment:', data);
950
- * });
951
- * };
952
- *
1674
+ * Represents a command to initialize Showcase for a component scene and start a sequence for the component.
1675
+ * This class sends a command to the Metabox API to initialize showcase if the component has a sequence.
1676
+ * To check this, find the showcase property in the current component and listen to the 'configuratorDataUpdated' event.
953
1677
  * If this property exists, you can send the init showcase command.
954
1678
  *
955
1679
  * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.
956
- * //...Assume that the integration is already implemented (only once)
957
- * @example
958
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
959
1680
  *
960
- * @param {Communicator} api - communicator instance api
961
- * window.env3DSource.apiReady = (api: Communicator) => {
962
- * @param {ShowCaseStatus} data - showcase status value
963
- * api.addEventListener('showcaseStatusChanged', (data) => {
964
- * console.log('Showcase status value after changed:', data);
965
- * });
966
- * };
1681
+ * ### What does it unlock?
1682
+ * Initializes and displays the showcase/demo view for the configurator. Used when transitioning into presentation or demo mode.
967
1683
  *
968
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
1684
+ * ### Practical Application
1685
+ * Loads the showcase/animation sequence attached to the current component. Must be called BEFORE PlayShowcase.
1686
+ * Use to initialize auto-playing product demos, trade show presentations, or hero section animations on landing pages.
969
1687
  *
970
- * @example
971
- * import { InitShowcase, Communicator } from '@3dsource/metabox-modular-configurator-api';
1688
+ * ### AI Coding Best Practices
1689
+ * ALWAYS call InitShowcase() before PlayShowcase(). Required sequence: InitShowcase → PlayShowcase → PauseShowcase/StopShowcase.
1690
+ * Subscribe to showcaseStatusChanged to track playback state ('playing'/'paused'/'stopped').
972
1691
  *
973
- * @param {Communicator} api - communicator instance api
1692
+ * @example
1693
+ * import { Communicator, ShowCaseStatus, InitShowcase } from '@3dsource/metabox-modular-configurator-api';
974
1694
  * window.env3DSource.apiReady = (api: Communicator) => {
1695
+ * //Subscribe to the event before sending the command to ensure you capture the response
1696
+ * api.addEventListener('showcaseStatusChanged', (data:ShowCaseStatus) => {
1697
+ * console.log('Showcase status value after changed:', data);
1698
+ * });
1699
+ *
975
1700
  * api.sendCommandToMetabox(new InitShowcase());
976
1701
  * };
977
1702
  */
978
1703
  declare class InitShowcase extends CommandBase {
979
- /**
980
- * Creates an instance of InitShowcase.
981
- *
982
- * @remarks
983
- * This constructor does not require any parameters.
984
- */
985
1704
  constructor();
986
1705
  }
987
1706
 
988
1707
  /**
989
- * Represents a command to play Showcase for a product when it is already initialized and paused.
990
- * @remarks
991
- * This class sends a command to the Metabox API to play showcase for a product if it is already initialized and paused.
1708
+ * Represents a command to play Showcase for a component when it is already initialized and paused.
1709
+ * This class sends a command to the Metabox API to play showcase for a component if it is already initialized and paused.
992
1710
  *
993
1711
  * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.
994
- * //...Assume that the integration is already implemented (only once)
995
- * @example
996
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
997
1712
  *
998
- * @param {Communicator} api - communicator instance api
1713
+ * ### What does it unlock?
1714
+ * Starts or resumes the showcase/timeline playback. Executes the internal MetaBox play command internally.
1715
+ *
1716
+ * ### Practical Application
1717
+ * Starts or resumes showcase playback. Use for 'Play Demo' buttons on landing pages, auto-play on page load,
1718
+ * or resuming demos after inactivity timeout on kiosk displays.
1719
+ *
1720
+ * ### AI Coding Best Practices
1721
+ * Call `api.sendCommandToMetabox(new PlayShowcase())`. Must call InitShowcase() first or it won't play.
1722
+ * Subscribe to showcaseStatusChanged to track state. Auto-play pattern: wait for viewportReady → InitShowcase →
1723
+ * PlayShowcase.
1724
+ *
1725
+ * @example
1726
+ * import { Communicator, PlayShowcase } from '@3dsource/metabox-modular-configurator-api';
999
1727
  * window.env3DSource.apiReady = (api: Communicator) => {
1000
- * @param {ShowCaseStatus} data - showcase status value
1728
+ * //Subscribe to the event before sending the command to ensure you capture the response
1001
1729
  * api.addEventListener('showcaseStatusChanged', (data) => {
1002
1730
  * console.log('Showcase status value after changed:', data);
1003
1731
  * });
1004
- * };
1005
- *
1006
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
1007
1732
  *
1008
- * @example
1009
- * import { PlayShowcase, Communicator } from '@3dsource/metabox-modular-configurator-api';
1010
- *
1011
- * @param {Communicator} api - communicator instance api
1012
- * window.env3DSource.apiReady = (api: Communicator) => {
1013
1733
  * api.sendCommandToMetabox(new PlayShowcase());
1014
1734
  * };
1015
1735
  */
1016
1736
  declare class PlayShowcase extends CommandBase {
1017
- /**
1018
- * Creates an instance of PlayShowcase.
1019
- *
1020
- * @remarks
1021
- * This constructor does not require any parameters.
1022
- */
1023
1737
  constructor();
1024
1738
  }
1025
1739
 
@@ -1033,120 +1747,127 @@ declare class UnrealCommand extends CommandBase {
1033
1747
  }
1034
1748
 
1035
1749
  /**
1036
- * Represents a command to pause Showcase for a product when it is already initialized and playing.
1037
- * @remarks
1038
- * This class sends a command to the Metabox API to pause showcase for a product if it is already initialized and playing.
1750
+ * Represents a command to pause Showcase for a component when it is already initialized and playing.
1751
+ * This class sends a command to the Metabox API to pause showcase for a component if it is already initialized and playing.
1039
1752
  *
1040
1753
  * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.
1041
- * //...Assume that the integration is already implemented (only once)
1042
- * @example
1043
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
1044
1754
  *
1045
- * @param {Communicator} api - communicator instance api
1046
- * window.env3DSource.apiReady = (api: Communicator) => {
1047
- * @param {ShowCaseStatus} data - showcase status value
1048
- * api.addEventListener('showcaseStatusChanged', (data) => {
1049
- * console.log('Showcase status value after changed:', data);
1050
- * });
1051
- * };
1755
+ * ### What does it unlock?
1756
+ * Pauses the showcase/timeline playback. Can be called independently without requiring any flag parameters.
1052
1757
  *
1053
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
1758
+ * ### Practical Application
1759
+ * Pauses showcase animation playback. The showcase remains initialized and can be resumed with
1760
+ * PlayShowcase. Use when you need to temporarily freeze the animation (e.g., on a "Pause" button click).
1054
1761
  *
1055
- * @example
1056
- * import { PauseShowcase, Communicator } from '@3dsource/metabox-modular-configurator-api';
1762
+ * ### AI Coding Best Practices
1763
+ * Call `api.sendCommandToMetabox(new PauseShowcase())`. No parameters. Subscribe to showcaseStatusChanged
1764
+ * to confirm 'pause' state. Use PlayShowcase to resume or StopShowcase to reset.
1057
1765
  *
1058
- * @param {Communicator} api - communicator instance api
1766
+ * @example
1767
+ * import { Communicator, ShowCaseStatus, PauseShowcase } from '@3dsource/metabox-modular-configurator-api';
1059
1768
  * window.env3DSource.apiReady = (api: Communicator) => {
1060
- * api.sendCommandToMetabox(new PauseShowcase());
1769
+ *
1770
+ * //Subscribe to the event before sending the command to ensure you capture the response
1771
+ * api.addEventListener('showcaseStatusChanged', (data:ShowCaseStatus) => {
1772
+ * console.log('Showcase status value after changed:', data);
1773
+ * });
1774
+ *
1775
+ * api.sendCommandToMetabox(new PauseShowcase());
1061
1776
  * };
1062
1777
  */
1063
1778
  declare class PauseShowcase extends CommandBase {
1064
- /**
1065
- * Creates an instance of PauseShowcase.
1066
- *
1067
- * @remarks
1068
- * This constructor does not require any parameters.
1069
- */
1070
1779
  constructor();
1071
1780
  }
1072
1781
 
1073
1782
  /**
1074
- * Represents a command to stop Showcase for a product when it is already initialized, and you want to destroy it.
1075
- * @remarks
1076
- * This class sends a command to the Metabox API to stop showcase for a product if it is already initialized.
1783
+ * Represents a command to stop Showcase for a component when it is already initialized, and you want to destroy it.
1784
+ * This class sends a command to the Metabox API to stop showcase for a component if it is already initialized.
1077
1785
  *
1078
1786
  * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.
1079
- * //...Assume that the integration is already implemented (only once)
1080
- * @example
1081
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
1082
1787
  *
1083
- * @param {Communicator} api - communicator instance api
1084
- * window.env3DSource.apiReady = (api: Communicator) => {
1085
- * @param {ShowCaseStatus} data - showcase status value
1086
- * api.addEventListener('showcaseStatusChanged', (data) => {
1087
- * console.log('Showcase status value after changed:', data);
1088
- * });
1089
- * };
1788
+ * ### What does it unlock?
1789
+ * Stops the showcase/timeline playback and closes the showcase mode. Returns to normal configurator view.
1090
1790
  *
1091
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
1791
+ * ### Practical Application
1792
+ * Stops showcase playback and exits showcase mode entirely. Returns to normal interactive configurator view.
1793
+ * Use for 'Exit Demo' buttons or auto-trigger when the user starts actively configuring the product.
1092
1794
  *
1093
- * @example
1094
- * import { StopShowcase, Communicator } from '@3dsource/metabox-modular-configurator-api';
1795
+ * ### AI Coding Best Practices
1796
+ * Call `api.sendCommandToMetabox(new StopShowcase())`. Fully resets the showcase state. Subscribe to
1797
+ * showcaseStatusChanged to confirm 'stopped' status. After stopping, the configurator returns to full
1798
+ * interactive mode — re-enable configuration controls.
1095
1799
  *
1096
- * @param {Communicator} api - communicator instance api
1800
+ * @example
1801
+ * import { Communicator, ShowCaseStatus } from '@3dsource/metabox-modular-configurator-api';
1097
1802
  * window.env3DSource.apiReady = (api: Communicator) => {
1098
- * api.sendCommandToMetabox(new StopShowcase());
1803
+ *
1804
+ * //Subscribe to the event before sending the command to ensure you capture the response
1805
+ * api.addEventListener('showcaseStatusChanged', (data:ShowCaseStatus) => {
1806
+ * console.log('Showcase status value after changed:', data);
1807
+ * });
1808
+ *
1809
+ * api.sendCommandToMetabox(new StopShowcase());
1099
1810
  * };
1100
1811
  */
1101
1812
  declare class StopShowcase extends CommandBase {
1102
- /**
1103
- * Creates an instance of StopShowcase.
1104
- *
1105
- * @remarks
1106
- * This constructor does not require any parameters.
1107
- */
1108
1813
  constructor();
1109
1814
  }
1110
1815
 
1111
1816
  /**
1112
1817
  * Image format.
1113
- * @remarks
1114
1818
  * This type represents the allowed image formats.
1819
+ *
1820
+ * ### What does it unlock?
1821
+ * Type alias for MIME types used in file/media handling. Defines supported file formats and media types.
1822
+ *
1823
+ * ### Practical Application
1824
+ * Type alias: 'image/png' | 'image/jpeg' | 'image/webp'. Used as the format parameter in GetScreenshot.
1825
+ * PNG for quality/transparency, JPEG for smaller files, WebP for modern browser optimization.
1826
+ *
1827
+ * ### AI Coding Best Practices
1828
+ * Pass as first param to GetScreenshot: `new GetScreenshot('image/png', {x:2048, y:2048})`.
1829
+ * Use PNG for highest quality and transparency. JPEG for smaller file size. WebP for modern browser optimization.
1830
+ * Match the saveImage filename extension to the format.
1115
1831
  */
1116
1832
  type MimeType = 'image/png' | 'image/jpeg' | 'image/webp';
1117
1833
  /**
1118
1834
  * Represents a command to get a screenshot.
1119
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
1120
1835
  *
1121
- * @remarks
1122
- * To listen for changes after sending this command, listen to the 'screenshot' event.
1123
- * //...Assume that the integration is already implemented (only once)
1124
- * @example
1125
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
1836
+ * To listen for changes after sending this command, listen to the 'screenshot' event before command is sent.
1837
+ *
1838
+ * ### What does it unlock?
1839
+ * Takes a screenshot on the server side (Unreal Engine) of the 3D scene. Returns high-quality image.
1840
+ * Requires subscription to the screenshotReady event to receive the rendered image.
1126
1841
  *
1127
- * @param {Communicator} api - communicator instance api
1842
+ * ### Practical Application
1843
+ * Renders a high-res screenshot on the Unreal Engine server. Takes format ('image/png'|'image/jpeg'|'image/webp')
1844
+ * and optional size ({x, y}). Returns base64 data via screenshotReady event. Use for thumbnails, social sharing,
1845
+ * saving config snapshots, or attaching images to quotes.
1846
+ *
1847
+ * ### AI Coding Best Practices
1848
+ * Subscribe to screenshotReady BEFORE sending GetScreenshot. Pattern:
1849
+ * `api.addEventListener('screenshotReady', (data) => { if(data) saveImage(data, 'name.png'); })`.
1850
+ * Specify size for consistent outputs: `new GetScreenshot('image/png', {x:2048, y:2048})`.
1851
+ * Use saveImage() helper to convert base64 to downloadable file.
1852
+ *
1853
+ * @example
1854
+ * import { Communicator, saveImage, GetScreenshot } from '@3dsource/metabox-modular-configurator-api';
1128
1855
  * window.env3DSource.apiReady = (api: Communicator) => {
1129
- * @param {string} data - base64 string image
1130
- * api.addEventListener('screenshot', (data) => {
1856
+ *
1857
+ * //Subscribe to the event before sending the command to ensure you capture the response
1858
+ * api.addEventListener('screenshot', (data:string) => {
1859
+ * // The data is a base64 string of the image. You can use it to display the image or save it as a file.
1131
1860
  * console.log('Get screenshot here:', data);
1132
1861
  * saveImage(data, 'Render.png');
1133
1862
  * });
1134
- * };
1135
- *
1136
- * @example
1137
- * import { GetScreenshot, Communicator, saveImage } from '@3dsource/metabox-modular-configurator-api';
1138
1863
  *
1139
- * @param {Communicator} api - communicator instance api
1140
- * window.env3DSource.apiReady = (api: Communicator) => {
1141
- * api.sendCommandToMetabox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
1864
+ * api.sendCommandToMetabox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
1142
1865
  * };
1866
+ *
1867
+ * @param {MimeType} mimeType - The output format.
1868
+ * @param {{ x: number; y: number }} [size] - Optional size in pixels.
1143
1869
  */
1144
1870
  declare class GetScreenshot extends CommandBase {
1145
- /**
1146
- * Constructs an instance of GetScreenshot.
1147
- * @param {MimeType} mimeType - The output format.
1148
- * @param {{ x: number; y: number }} [size] - Optional size in pixels.
1149
- */
1150
1871
  constructor(mimeType: MimeType, size?: {
1151
1872
  x: number;
1152
1873
  y: number;
@@ -1155,274 +1876,318 @@ declare class GetScreenshot extends CommandBase {
1155
1876
 
1156
1877
  /**
1157
1878
  * Represents a command to set a component by its data (ID, typeId).
1158
- *
1159
- * @remarks
1879
+ * This action sends a message to the Metabox API to set a component using the provided data.
1160
1880
  * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.
1161
- * //...Assume that the integration is already implemented (only once)
1162
- * @example
1163
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
1164
1881
  *
1165
- * @param {Communicator} api - communicator instance api
1882
+ * ### What does it unlock?
1883
+ * Sets a component during initialization, which triggers the reconstruction of the component tree structure.
1884
+ * Simulates clicking a component in the menu.
1885
+ *
1886
+ * ### Practical Application
1887
+ * Selects a component in the modular assembly. Takes componentId (UUID), typeId (category string).
1888
+ * CRITICAL: Always set root component (isRoot:true) FIRST — nothing renders without it. Then add children (isRoot:false).
1889
+ * Simulates clicking a component in the menu.
1890
+ *
1891
+ * ### AI Coding Best Practices
1892
+ * ALWAYS set root first: `new SetComponent('id', 'type', true)`. Then children: `new SetComponent('childId', 'childType', false)`.
1893
+ * Get valid IDs from configuratorDataUpdated event data — the configurator definition contains all available components and types.
1894
+ * Wrong order = blank viewport. The typeId must match componentType values from the configurator.
1895
+ *
1896
+ * @example
1897
+ * import { Communicator, ModularConfiguratorEnvelope, SetComponent } from '@3dsource/metabox-modular-configurator-api';
1166
1898
  * window.env3DSource.apiReady = (api: Communicator) => {
1167
- * @param {ConfiguratorEnvelope} data - configurator state after updated
1168
- * api.addEventListener('configuratorDataUpdated', (data) => {
1899
+ *
1900
+ * //Subscribe to the event before sending the command to ensure you capture the response
1901
+ * api.addEventListener('configuratorDataUpdated', (data:ModularConfiguratorEnvelope) => {
1169
1902
  * console.log('State updated after applied new component:', data);
1170
1903
  * });
1171
- * };
1172
1904
  *
1173
- * @example
1174
- * import { SetComponent, Communicator } from '@3dsource/metabox-modular-configurator-api';
1175
- *
1176
- * @param {Communicator} api - communicator instance api
1177
- * window.env3DSource.apiReady = (api: Communicator) => {
1178
- * api.sendCommandToMetabox(new SetComponent(
1905
+ * api.sendCommandToMetabox(new SetComponent(
1179
1906
  * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3', 'typeId'
1180
1907
  * ));
1181
1908
  * };
1909
+ *
1910
+ * @param {string} id - The component ID.
1911
+ * @param {string} typeId - The component type ID.
1182
1912
  */
1183
1913
  declare class SetComponent extends CommandBase {
1184
- /**
1185
- * Creates an instance of SetComponent.
1186
- *
1187
- * @param {string} id - The component ID.
1188
- * @param {string} typeId - The component type ID.
1189
- */
1190
1914
  constructor(id: string, typeId: string);
1191
1915
  }
1192
1916
 
1193
1917
  /**
1194
1918
  * Represents a command to set component material by its slot ID and Material ID.
1195
- *
1196
- * @remarks
1197
1919
  * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.
1198
- * //...Assume that the integration is already implemented (only once)
1199
- * @example
1200
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
1201
1920
  *
1202
- * @param {Communicator} api - communicator instance api
1203
- * window.env3DSource.apiReady = (api: Communicator) => {
1204
- * @param {ConfiguratorEnvelope} data - configurator state after updated
1205
- * api.addEventListener('configuratorDataUpdated', (data) => {
1206
- * console.log('State updated after applied new product:', data);
1207
- * });
1208
- * };
1921
+ * ### What does it unlock?
1922
+ * Sets a material variant for a component. Simulates selecting a different material from the menu for a specific component.
1209
1923
  *
1210
- * @example
1211
- * import { SetComponentMaterial, Communicator } from '@3dsource/metabox-modular-configurator-api';
1924
+ * ### Practical Application
1925
+ * Applies a material to a specific slot on a component. Takes componentId (UUID), slotId (string), and materialId (UUID).
1926
+ * Use to build swatch pickers, apply preset themes/bundles, or sync material selections from an external
1927
+ * PIM/ERP system via externalId mapping.
1212
1928
  *
1213
- * @param {Communicator} api - communicator instance api
1929
+ * ### AI Coding Best Practices
1930
+ * Get valid slotId and materialId values from the configuratorDataUpdated envelope —
1931
+ * check component slot definitions and material lists. Pattern:
1932
+ * `new SetComponentMaterial('component-uuid', 'slot-name', 'material-uuid')`. The referenced component must already be set in the tree.
1933
+ *
1934
+ * @example
1935
+ * import { Communicator, ModularConfiguratorEnvelope, SetComponentMaterial } from '@3dsource/metabox-modular-configurator-api';
1214
1936
  * window.env3DSource.apiReady = (api: Communicator) => {
1215
- * api.sendCommandToMetabox(new SetComponentMaterial(
1937
+ *
1938
+ * //Subscribe to the event before sending the command to ensure you capture the response
1939
+ * api.addEventListener('configuratorDataUpdated', (data:ModularConfiguratorEnvelope) => {
1940
+ * console.log('State updated after applied new material:', data);
1941
+ * });
1942
+ *
1943
+ * api.sendCommandToMetabox(new SetComponentMaterial(
1216
1944
  * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
1217
1945
  * 'carpaint',
1218
1946
  * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
1219
1947
  * ));
1220
1948
  * };
1949
+ *
1950
+ * @param {string} componentId - The component ID.
1951
+ * @param {string} slotId - The slot ID.
1952
+ * @param {string} materialId - The material ID.
1221
1953
  */
1222
1954
  declare class SetComponentMaterial extends CommandBase {
1223
- /**
1224
- * Creates an instance of SetComponentMaterial.
1225
- *
1226
- * @param {string} componentId - The component ID.
1227
- * @param {string} slotId - The slot ID.
1228
- * @param {string} materialId - The material ID.
1229
- */
1230
1955
  constructor(componentId: string, slotId: string, materialId: string);
1231
1956
  }
1232
1957
 
1233
1958
  /**
1234
1959
  * Represents a command to set the environment by its ID.
1235
- *
1236
- * @remarks
1237
1960
  * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.
1238
- * //...Assume that the integration is already implemented (only once)
1239
- * @example
1240
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
1241
1961
  *
1242
- * @param {Communicator} api - communicator instance api
1962
+ * ### What does it unlock?
1963
+ * Sets environmental/lighting settings for the scene. Controls factors like lighting conditions and environmental appearance.
1964
+ *
1965
+ * ### Practical Application
1966
+ * Changes the 3D scene/environment (studio, showroom, outdoor, etc.). Takes an environmentId UUID.
1967
+ * Environments include lighting, backdrop, and optionally dynamic sky (udsEnabled) with time-of-day (udsHour) control.
1968
+ *
1969
+ * ### AI Coding Best Practices
1970
+ * Call `api.sendCommandToMetabox(new SetEnvironment('env-uuid'))`. Get valid environment IDs from the configurator
1971
+ * definition in configuratorDataUpdated. Set environment after root component during initialization. Each environment has
1972
+ * its own material slots, thumbnails, and lighting properties.
1973
+ *
1974
+ * @example
1975
+ * import { Communicator, ModularConfiguratorEnvelope } from '@3dsource/metabox-modular-configurator-api';
1243
1976
  * window.env3DSource.apiReady = (api: Communicator) => {
1244
- * @param {ConfiguratorEnvelope} data - configurator state after updated
1245
- * api.addEventListener('configuratorDataUpdated', (data) => {
1977
+ *
1978
+ * //Subscribe to the event before sending the command to ensure you capture the response
1979
+ * api.addEventListener('configuratorDataUpdated', (data:ModularConfiguratorEnvelope) => {
1246
1980
  * console.log('State updated after applied new environment:', data);
1247
1981
  * });
1248
- * };
1249
1982
  *
1250
- * @example
1251
- * import { SetEnvironment, Communicator } from '@3dsource/metabox-modular-configurator-api';
1252
- *
1253
- * @param {Communicator} api - communicator instance api
1254
- * window.env3DSource.apiReady = (api: Communicator) => {
1255
- * api.sendCommandToMetabox(new SetEnvironment('55555555-1234-1234-1234-01234567890'));
1983
+ * api.sendCommandToMetabox(new SetEnvironment('55555555-1234-1234-1234-01234567890'))
1256
1984
  * };
1985
+ *
1986
+ * @param {string} environmentId - The environment ID.
1257
1987
  */
1258
1988
  declare class SetEnvironment extends CommandBase {
1259
- /**
1260
- * Creates an instance of SetEnvironment.
1261
- *
1262
- * @param {string} environmentId - The environment ID.
1263
- */
1264
1989
  constructor(environmentId: string);
1265
1990
  }
1266
1991
 
1267
1992
  /**
1268
1993
  * Represents a command to set an environment material by its slot ID and Material ID.
1269
- *
1270
- * @remarks
1271
1994
  * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.
1272
- * //...Assume that the integration is already implemented (only once)
1273
- * @example
1274
- * import { Communicator } from '@3dsource/metabox-modular-configurator-api';
1275
1995
  *
1276
- * @param {Communicator} api - communicator instance api
1996
+ * ### What does it unlock?
1997
+ * Sets environmental material properties such as textures and appearance attributes for the scene environment.
1998
+ *
1999
+ * ### Practical Application
2000
+ * Applies materials to environment slots (floor, walls, backdrop textures). Takes slotId and materialId.
2001
+ * Use for scene-based configurators where the environment is also customizable — kitchen visualizers,
2002
+ * room planners, trade show booth designers.
2003
+ *
2004
+ * ### AI Coding Best Practices
2005
+ * Pattern: `new SetEnvironmentMaterial('floor-slot-id', 'material-uuid')`. Get valid slot and material IDs from
2006
+ * the environment definition's slots array in configuratorDataUpdated. Only useful when the active environment
2007
+ * has configurable material slots.
2008
+ *
2009
+ * @example
2010
+ * import { Communicator, ModularConfiguratorEnvelope } from '@3dsource/metabox-modular-configurator-api';
1277
2011
  * window.env3DSource.apiReady = (api: Communicator) => {
1278
- * @param {ConfiguratorEnvelope} data - configurator state after updated
1279
- * api.addEventListener('configuratorDataUpdated', (data) => {
2012
+ *
2013
+ * //Subscribe to the event before sending the command to ensure you capture the response
2014
+ * api.addEventListener('configuratorDataUpdated', (data:ModularConfiguratorEnvelope) => {
1280
2015
  * console.log('State updated after applied new environment material:', data);
1281
2016
  * });
1282
- * };
1283
2017
  *
1284
- * @example
1285
- * import { SetEnvironmentMaterial, Communicator } from '@3dsource/metabox-modular-configurator-api';
1286
- *
1287
- * @param {Communicator} api - communicator instance api
1288
- * window.env3DSource.apiReady = (api: Communicator) => {
1289
- * api.sendCommandToMetabox(new SetEnvironmentMaterial(
2018
+ * api.sendCommandToMetabox(new SetEnvironmentMaterial(
1290
2019
  * 'carpaint',
1291
2020
  * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
1292
2021
  * ));
1293
2022
  * };
2023
+ *
2024
+ * @param {string} slotId - The slot ID.
2025
+ * @param {string} materialId - The material ID.
1294
2026
  */
1295
2027
  declare class SetEnvironmentMaterial extends CommandBase {
1296
- /**
1297
- * Creates an instance of SetEnvironmentMaterial.
1298
- *
1299
- * @param {string} slotId - The slot ID.
1300
- * @param {string} materialId - The material ID.
1301
- */
1302
2028
  constructor(slotId: string, materialId: string);
1303
2029
  }
1304
2030
 
1305
2031
  /**
1306
2032
  * Represents a command to toggle the embedded Metabox menu.
1307
- * @remarks
1308
2033
  * This command can only be used when using the metabox menu.
1309
- * **Important**: No need to listen to any events to see changes.
2034
+ *
2035
+ * ### What does it unlock?
2036
+ * Shows the embedded menu interface. Only works when using the MetaBox native menu (not in standalone/custom menu
2037
+ * mode).
2038
+ *
2039
+ * ### Practical Application
2040
+ * Toggles the native MetaBox right sidebar menu. Takes a boolean parameter. Pass false to hide when building custom UI.
2041
+ * In standalone mode, the menu is already hidden — this is only relevant in default (non-standalone) mode.
2042
+ *
2043
+ * ### AI Coding Best Practices
2044
+ * In standalone mode (`{standalone:true}`), this is unnecessary (menu already hidden). In default mode,
2045
+ * call `new ShowEmbeddedMenu(false)` early in initialization to hide built-in UI before rendering custom controls.
2046
+ * Pattern for custom UI: `ShowEmbeddedMenu(false)` + `ShowOverlayInterface(false)`.
1310
2047
  *
1311
2048
  * @example
1312
2049
  * import { ShowEmbeddedMenu, Communicator } from '@3dsource/metabox-modular-configurator-api';
1313
- *
1314
- * @param {Communicator} api - communicator instance api
1315
2050
  * window.env3DSource.apiReady = (api: Communicator) => {
1316
2051
  * api.sendCommandToMetabox(new ShowEmbeddedMenu(true));
1317
2052
  * };
2053
+ *
2054
+ * @param {boolean} visible - A flag indicating whether the embedded menu should be visible.
1318
2055
  */
1319
2056
  declare class ShowEmbeddedMenu extends CommandBase {
1320
- /**
1321
- * Creates an instance of ShowEmbeddedMenu.
1322
- *
1323
- * @param {boolean} visible - A flag indicating whether the embedded menu should be visible.
1324
- */
1325
2057
  constructor(visible: boolean);
1326
2058
  }
1327
2059
 
1328
2060
  /**
1329
2061
  * Represents a command to toggle the Unreal Overlay Interface Menu.
1330
- *
1331
- * @remarks
1332
2062
  * This action sends a message to the Metabox API to toggle the visibility of the Unreal overlay UI.
1333
- * **Important**: No need to listen to any events to see changes.
2063
+ *
2064
+ * ### What does it unlock?
2065
+ * Shows the overlay interface elements. Displays UI controls and buttons overlaid on the 3D scene.
2066
+ *
2067
+ * ### Practical Application
2068
+ * Toggles viewport overlay controls (buttons overlaid on the 3D scene). Takes a boolean.
2069
+ * Use `ShowOverlayInterface(false)` alongside `ShowEmbeddedMenu(false)` when building fully custom UI
2070
+ * that replaces all native MetaBox controls.
2071
+ *
2072
+ * ### AI Coding Best Practices
2073
+ * In standalone mode, overlays are already hidden. In default mode, call `new ShowOverlayInterface(false)`
2074
+ * early in initialization to prevent flash of native UI. Always pair with `ShowEmbeddedMenu(false)` for clean custom UI.
2075
+ * Pass true to restore if entering a mode that uses native controls.
1334
2076
  *
1335
2077
  * @example
1336
2078
  * import { ShowOverlayInterface, Communicator } from '@3dsource/metabox-modular-configurator-api';
1337
- *
1338
- * @param {Communicator} api - communicator instance api
1339
2079
  * window.env3DSource.apiReady = (api: Communicator) => {
1340
- * api.setCommandToMetaBox(new ShowOverlayInterface(true));
2080
+ * api.sendCommandToMetabox(new ShowOverlayInterface(true));
1341
2081
  * };
2082
+ *
2083
+ * @param {boolean} visible - A flag indicating whether the Unreal overlay UI should be visible.
1342
2084
  */
1343
2085
  declare class ShowOverlayInterface extends CommandBase {
1344
- /**
1345
- * Creates an instance of ShowOverlayInterface.
1346
- *
1347
- * @param {boolean} visible - A flag indicating whether the Unreal overlay UI should be visible.
1348
- */
1349
2086
  constructor(visible: boolean);
1350
2087
  }
1351
2088
 
1352
2089
  /**
1353
2090
  * Represents a command to show measurement for a product when it is already loaded.
1354
- * @remarks
1355
2091
  * This class sends a command to the Metabox API to show measurement for a product if it is already initialized.
1356
- * **Important**: No need to listen to any events to see changes.
1357
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
2092
+ *
2093
+ * ### What does it unlock?
2094
+ * Shows the measurement overlay. Works as a toggle with HideMeasurement to control visibility.
2095
+ *
2096
+ * ### Practical Application
2097
+ * Shows the measurement/dimension overlay tools on the 3D viewport. Use for B2B or technical applications
2098
+ * where buyers need to verify product dimensions, check fit specifications, or confirm measurements during procurement.
2099
+ *
2100
+ * ### AI Coding Best Practices
2101
+ * Call `api.sendCommandToMetabox(new ShowMeasurement())`. No parameters. Pair with HideMeasurement for toggle behavior.
2102
+ * Track visibility state in your app to keep toggle buttons in sync.
1358
2103
  *
1359
2104
  * @example
1360
2105
  * import { ShowMeasurement, Communicator } from '@3dsource/metabox-modular-configurator-api';
1361
- *
1362
- * @param {Communicator} api - communicator instance api
1363
2106
  * window.env3DSource.apiReady = (api: Communicator) => {
1364
2107
  * api.sendCommandToMetabox(new ShowMeasurement());
1365
2108
  * };
1366
2109
  */
1367
2110
  declare class ShowMeasurement extends CommandBase {
1368
- /**
1369
- * Creates an instance of ShowMeasurement.
1370
- *
1371
- * @remarks
1372
- * This constructor does not require any parameters.
1373
- */
1374
2111
  constructor();
1375
2112
  }
1376
2113
 
1377
2114
  /**
1378
2115
  * Represents a command to hide measurement for a product when it is already loaded.
1379
- * @remarks
1380
2116
  * This class sends a command to the Metabox API to hide measurement for a product if it is already initialized.
1381
- * **Important**: No need to listen to any events to see changes.
1382
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
2117
+ *
2118
+ * ### What does it unlock?
2119
+ * Hides the measurement overlay. Executes unconditionally to hide the UI controls.
2120
+ *
2121
+ * ### Practical Application
2122
+ * Hides the measurement/dimension overlay. Use when transitioning from a technical spec view back to a clean
2123
+ * product presentation, or to keep consumer-facing configurators visually clean.
2124
+ *
2125
+ * ### AI Coding Best Practices
2126
+ * Call `api.sendCommandToMetabox(new HideMeasurement())`. No parameters. Pair with ShowMeasurement as a toggle.
2127
+ * Track visibility state in your app state to keep toggle buttons in sync.
1383
2128
  *
1384
2129
  * @example
1385
2130
  * import { HideMeasurement, Communicator } from '@3dsource/metabox-modular-configurator-api';
1386
- *
1387
- * @param {Communicator} api - communicator instance api
1388
2131
  * window.env3DSource.apiReady = (api: Communicator) => {
1389
2132
  * api.sendCommandToMetabox(new HideMeasurement());
1390
2133
  * };
1391
2134
  */
1392
2135
  declare class HideMeasurement extends CommandBase {
1393
- /**
1394
- * Creates an instance of HideMeasurement.
1395
- *
1396
- * @remarks
1397
- * This constructor does not require any parameters.
1398
- */
1399
2136
  constructor();
1400
2137
  }
1401
2138
 
1402
2139
  /**
1403
2140
  * Represents a command to force set the device type.
1404
- *
1405
- * @remarks
1406
2141
  * This class sends a message to the Metabox API to force set the device type.
1407
- * **Important**: No need to listen to any events to see changes.
1408
- * //...Assume that the integration is already implemented (only once)
2142
+ *
2143
+ * ### What does it unlock?
2144
+ * Forces the specification of device type (desktop or mobile) for the MetaBox configurator. Possibly deprecated.
2145
+ *
2146
+ * ### Practical Application
2147
+ * Forces device type override (desktop/tablet/mobile). Likely deprecated — MetaBox auto-detects via ApplicationDeviceTypes.
2148
+ * Only relevant for kiosk or showroom setups where you need to force a specific rendering mode.
2149
+ *
2150
+ * ### AI Coding Best Practices
2151
+ * Avoid unless you have a confirmed kiosk/showroom use case. If needed, set it once during initialization only.
2152
+ * Prefer letting MetaBox handle device detection automatically.
1409
2153
  *
1410
2154
  * @example
1411
2155
  * import { ForceSetDeviceType, Communicator } from '@3dsource/metabox-modular-configurator-api';
1412
2156
  *
1413
- * @param {Communicator} api - communicator instance api
1414
2157
  * window.env3DSource.apiReady = (api: Communicator) => {
1415
2158
  * api.sendCommandToMetabox(new ForceSetDeviceType('desktop'));
1416
2159
  * };
2160
+ *
2161
+ * @param {ApplicationDeviceTypes} deviceType - The device type to force set.
1417
2162
  */
1418
2163
  declare class ForceSetDeviceType extends CommandBase {
1419
- /**
1420
- * Creates an instance of ForceSetDeviceType.
1421
- *
1422
- * @param {ApplicationDeviceTypes} deviceType - The device type to force set.
1423
- */
1424
2164
  constructor(deviceType: ApplicationDeviceTypes);
1425
2165
  }
1426
2166
 
1427
- export { AppLoaded, AppLoaded_V3, ApplyZoom, BasicRouteUrl, CommandBase, Communicator, EventDispatcher, ForceSetDeviceType, GetCallToActionInformation, GetCamera, GetPdf, GetScreenshot, HideMeasurement, InitShowcase, Metabox, MetaboxConfig, MetaboxDomain, MetaboxHost, MetaboxHost_V3, MetaboxModularConfiguratorActions, Metabox_V3, PauseShowcase, PlayShowcase, ResetCamera, SetCamera, SetComponent, SetComponentMaterial, SetEnvironment, SetEnvironmentMaterial, ShowEmbeddedMenu, ShowMeasurement, ShowOverlayInterface, StopShowcase, UnrealCommand, VERSION, fromCommunicatorEvent, integrateMetabox, prepareIframeSrc, saveImage };
2167
+ /**
2168
+ * Represents a command to resume the pixel streaming session.
2169
+ * This class sends a message to the Metabox API to resume a paused or disconnected stream.
2170
+ *
2171
+ * ### What does it unlock?
2172
+ * Resumes the Unreal Engine pixel streaming connection after it has been paused, disconnected, or stopped due to inactivity (AFK timeout).
2173
+ *
2174
+ * ### Practical Application
2175
+ * Used to reconnect the 3D streaming session without a full page reload. Essential for 'Reconnect' or 'Resume' buttons
2176
+ * shown when the stream is interrupted, e.g., after an idle timeout or network disruption.
2177
+ *
2178
+ * ### AI Coding Best Practices
2179
+ * Call `api.sendCommandToMetabox(new ResumeStream())`. No parameters. Resumes the existing streaming session —
2180
+ * does not reinitialize the configurator or reset component/environment state.
2181
+ *
2182
+ * @example
2183
+ * import { ResumeStream, Communicator } from '@3dsource/metabox-modular-configurator-api';
2184
+ * window.env3DSource.apiReady = (api: Communicator) => {
2185
+ * api.sendCommandToMetabox(new ResumeStream());
2186
+ * };
2187
+ */
2188
+ declare class ResumeStream extends CommandBase {
2189
+ constructor();
2190
+ }
2191
+
2192
+ 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 };
1428
2193
  export type { ApplicationDeviceTypes, CameraCommandPayload, ComponentWithParent, Cta, EcomConfigurator, Environment, FromMetaBoxAPIEnvelope, FromMetaBoxApiEvents, FromMetaBoxMessage, FromMetaboxMessagePayloads, FromMetaboxTarget, InitialModularConfigurator, IntegrateMetaboxConfig, Listener, MCAppLoaded, Material, MetaBoxApiEnvelope, MetaProperty, MetaboxCommandConfig, MetaboxEnvironment, MimeType, ModularConfiguratorComponent, ModularConfiguratorComponentType, ModularConfiguratorConnector, ModularConfiguratorEnvelope, ModularConfiguratorEnvironment, ModularConfiguratorVirtualSocketToConnector, Product, SelectedIds, ShowCaseStatus, Showcase, Slot, Thumbnail, Timecode, ToMetaBoxActions, ToMetaBoxMessage, ToMetaBoxMessageEnvelope, ToMetaboxMessagePayload, ToMetaboxMessagePayloads, ToMetaboxTarget, VideoResolution };