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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,8 +20,6 @@ import { FromMetaBoxApiAction, GetFastRender, GetPdf, integrateMetaBox, saveImag
20
20
  import { FromMetaBoxApiAction, GetFastRender, GetPdf, integrateMetaBox, saveImage, SetEnvironment, SetMaterial, SetProduct, ShowEmbeddedMenu, ShowOverlayInterface, SetEnvironmentMaterial, Communicator, ConfiguratorEnvelope } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@1.0.0';
21
21
  ```
22
22
 
23
- **We strongly recommend using the first option with npm and locking it to the latest version at the time of integration, as the second option can change rapidly and may cause unexpected behavior in your existing code.**
24
-
25
23
  ## Usage
26
24
 
27
25
  ### 1. Create HTML Structure
@@ -129,8 +127,8 @@ new TsIntegrator();
129
127
 
130
128
  #### `integrateMetaBox`
131
129
 
132
- * **Description**: Integrates the MetaBox configurator into the specified container.
133
- * **Usage**:
130
+ - **Description**: Integrates the MetaBox configurator into the specified container.
131
+ - **Usage**:
134
132
 
135
133
  ```typescript
136
134
  integrateMetaBox(configuratorUrl: string, containerId: string, apiReadyCallback: (api: Communicator) => void);
@@ -138,8 +136,8 @@ new TsIntegrator();
138
136
 
139
137
  #### `SetEnvironment`
140
138
 
141
- * **Description**: Sets the environment by ID.
142
- * **Usage**:
139
+ - **Description**: Sets the environment by ID.
140
+ - **Usage**:
143
141
 
144
142
  ```typescript
145
143
  api.sendCommandToMetaBox(new SetEnvironment(environmentId: string));
@@ -147,8 +145,8 @@ new TsIntegrator();
147
145
 
148
146
  #### `SetMaterial`
149
147
 
150
- * **Description**: Sets the material for a given product slot.
151
- * **Usage**:
148
+ - **Description**: Sets the material for a given product slot.
149
+ - **Usage**:
152
150
 
153
151
  ```typescript
154
152
  api.sendCommandToMetaBox(new SetMaterial(productId: string, slotId: string, materialId: string));
@@ -156,8 +154,8 @@ new TsIntegrator();
156
154
 
157
155
  #### `SetEnvironmentMaterial`
158
156
 
159
- * **Description**: Sets the material for a given environment slot.
160
- * **Usage**:
157
+ - **Description**: Sets the material for a given environment slot.
158
+ - **Usage**:
161
159
 
162
160
  ```typescript
163
161
  api.sendCommandToMetaBox(new SetEnvironmentMaterial(productId: string, slotId: string, materialId: string));
@@ -165,8 +163,8 @@ new TsIntegrator();
165
163
 
166
164
  #### `SetProduct`
167
165
 
168
- * **Description**: Sets the product by ID.
169
- * **Usage**:
166
+ - **Description**: Sets the product by ID.
167
+ - **Usage**:
170
168
 
171
169
  ```typescript
172
170
  api.sendCommandToMetaBox(new SetProduct(productId: string));
@@ -174,8 +172,8 @@ new TsIntegrator();
174
172
 
175
173
  #### `ShowEmbeddedMenu`
176
174
 
177
- * **Description**: Toggles the embedded menu in the MetaBox configurator.
178
- * **Usage**:
175
+ - **Description**: Toggles the embedded menu in the MetaBox configurator.
176
+ - **Usage**:
179
177
 
180
178
  ```typescript
181
179
  api.sendCommandToMetaBox(new ShowEmbeddedMenu(visible: boolean));
@@ -183,8 +181,8 @@ new TsIntegrator();
183
181
 
184
182
  #### `ShowOverlayInterface`
185
183
 
186
- * **Description**: Toggles the overlay interface over Unreal viewport.
187
- * **Usage**:
184
+ - **Description**: Toggles the overlay interface over Unreal viewport.
185
+ - **Usage**:
188
186
 
189
187
  ```typescript
190
188
  api.sendCommandToMetaBox(new ShowOverlayInterface(visible: boolean));
@@ -192,8 +190,8 @@ new TsIntegrator();
192
190
 
193
191
  #### `GetFastRender`
194
192
 
195
- * **Description**: Retrieves a fast render of the current view.
196
- * **Usage**:
193
+ - **Description**: Retrieves a fast render of the current view.
194
+ - **Usage**:
197
195
 
198
196
  ```typescript
199
197
  api.sendCommandToMetaBox(new GetFastRender(mimeType: string, size?: { x: number, y: number }));
@@ -201,8 +199,8 @@ new TsIntegrator();
201
199
 
202
200
  #### `GetPdf`
203
201
 
204
- * **Description**: Generates a PDF of the current view.
205
- * **Usage**:
202
+ - **Description**: Generates a PDF of the current view.
203
+ - **Usage**:
206
204
 
207
205
  ```typescript
208
206
  api.sendCommandToMetaBox(new GetPdf());
@@ -210,8 +208,8 @@ new TsIntegrator();
210
208
 
211
209
  #### `saveImage`
212
210
 
213
- * **Description**: Saves the arrived rendered image to a file using utility function.
214
- * **Usage**:
211
+ - **Description**: Saves the arrived rendered image to a file using utility function.
212
+ - **Usage**:
215
213
 
216
214
  ```typescript
217
215
  saveImage(renderData: string, fileName: string): void;
@@ -1,36 +1,2 @@
1
- import { CommandBase } from './CommandBase';
2
- /**
3
- * Image format.
4
- * @remarks
5
- * This type represents the allowed image formats.
6
- */
7
- export type MimeType = 'image/png' | 'image/jpeg' | 'image/webp';
8
- /**
9
- * {@inheritDoc CommandBase}
10
- *
11
- * Represents a command to get fast render.
12
- *
13
- * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
14
- *
15
- * @example
16
- * import { GetFastRender,Communicator,saveImage } from '@3dsource/metabox-front-api';
17
- * window.env3DSource.apiReady = (api:Communicator) => {
18
- * // Listen for events from the MetaBox API
19
- * api.addEventListener('fastRender', (data) => {
20
- * // Process the fast render response
21
- * saveImage(data, 'Render.png');
22
- * });
23
- * api.sendCommandToMetaBox(new GetFastRender('image/png', { x: 1024, y: 1024 }));
24
- * };
25
- */
26
- export declare class GetFastRender extends CommandBase {
27
- /**
28
- * Constructs an instance of GetFastRender.
29
- * @param mimeType - The output format.
30
- * @param size - Optional size in pixels.
31
- */
32
- constructor(mimeType: MimeType, size?: {
33
- x: number;
34
- y: number;
35
- });
36
- }
1
+ import { GetScreenshot } from './GetScreenshot';
2
+ export declare const GetFastRender: typeof GetScreenshot;
@@ -1,7 +1,5 @@
1
1
  import { CommandBase } from './CommandBase';
2
2
  /**
3
- * {@inheritDoc CommandBase}
4
- *
5
3
  * Represents a command to get a PDF from Metabox.
6
4
  * @remarks
7
5
  * This class sends a message to the MetaBox API to generate a PDF based on the current configuration.
@@ -0,0 +1,34 @@
1
+ import { CommandBase } from './CommandBase';
2
+ /**
3
+ * Image format.
4
+ * @remarks
5
+ * This type represents the allowed image formats.
6
+ */
7
+ export type MimeType = 'image/png' | 'image/jpeg' | 'image/webp';
8
+ /**
9
+ * Represents a command to get fast render.
10
+ *
11
+ * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
12
+ *
13
+ * @example
14
+ * import { GetScreenshot,Communicator,saveImage } from '@3dsource/metabox-front-api';
15
+ * window.env3DSource.apiReady = (api:Communicator) => {
16
+ * // Listen for events from the MetaBox API
17
+ * api.addEventListener('fastRender', (data) => {
18
+ * // Process the fast render response
19
+ * saveImage(data, 'Render.png');
20
+ * });
21
+ * api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
22
+ * };
23
+ */
24
+ export declare class GetScreenshot extends CommandBase {
25
+ /**
26
+ * Constructs an instance of GetScreenshot.
27
+ * @param mimeType - The output format.
28
+ * @param size - Optional size in pixels.
29
+ */
30
+ constructor(mimeType: MimeType, size?: {
31
+ x: number;
32
+ y: number;
33
+ });
34
+ }
@@ -1,6 +1,5 @@
1
1
  import { CommandBase } from './CommandBase';
2
2
  /**
3
- * {@inheritDoc CommandBase}
4
3
  * @internal
5
4
  * @hidden
6
5
  * Represents a command to send Unreal command.
@@ -1,11 +1,11 @@
1
1
  import { CommandBase } from './CommandBase';
2
2
  /**
3
- * {@inheritDoc CommandBase}
4
- *
5
3
  * Represents a command to set the environment by its ID.
6
4
  *
7
5
  * @example
8
6
  * import { SetEnvironment,Communicator } from '@3dsource/metabox-front-api';
7
+ *
8
+ * //...Assume that the integration is already implemented
9
9
  * window.env3DSource.apiReady = (api:Communicator) => {
10
10
  * // Change the environment to '55555555-1234-1234-1234-01234567890'
11
11
  * api.sendCommandToMetaBox(new SetEnvironment('55555555-1234-1234-1234-01234567890'));
@@ -1,14 +1,13 @@
1
1
  import { CommandBase } from './CommandBase';
2
2
  /**
3
- * {@inheritDoc CommandBase}
4
- *
5
3
  * Represents a command to set an environment material by its ID.
6
4
  *
7
5
  * @example
8
6
  * import { SetEnvironmentMaterial,Communicator } from '@3dsource/metabox-front-api';
7
+ *
8
+ * //...Assume that the integration is already implemented
9
9
  * window.env3DSource.apiReady = (api:Communicator) => {
10
10
  * api.sendCommandToMetaBox(new SetEnvironmentMaterial(
11
- * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
12
11
  * 'carpaint',
13
12
  * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
14
13
  * ));
@@ -18,9 +17,8 @@ export declare class SetEnvironmentMaterial extends CommandBase {
18
17
  /**
19
18
  * Creates an instance of SetEnvironmentMaterial.
20
19
  *
21
- * @param productId - The product ID.
22
20
  * @param slotId - The slot ID.
23
21
  * @param materialId - The material ID.
24
22
  */
25
- constructor(productId: string, slotId: string, materialId: string);
23
+ constructor(slotId: string, materialId: string);
26
24
  }
@@ -1,14 +1,13 @@
1
1
  import { CommandBase } from './CommandBase';
2
2
  /**
3
- * {@inheritDoc CommandBase}
4
- *
5
3
  * Represents a command to set a material by its ID.
6
4
  *
7
5
  * @example
8
6
  * import { SetMaterial,Communicator } from '@3dsource/metabox-front-api';
7
+ *
8
+ * //...Assume that the integration is already implemented
9
9
  * window.env3DSource.apiReady = (api:Communicator) => {
10
10
  * api.sendCommandToMetaBox(new SetMaterial(
11
- * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
12
11
  * 'carpaint',
13
12
  * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
14
13
  * ));
@@ -18,9 +17,8 @@ export declare class SetMaterial extends CommandBase {
18
17
  /**
19
18
  * Creates an instance of SetMaterial.
20
19
  *
21
- * @param productId - The product ID.
22
20
  * @param slotId - The slot ID.
23
21
  * @param materialId - The material ID.
24
22
  */
25
- constructor(productId: string, slotId: string, materialId: string);
23
+ constructor(slotId: string, materialId: string);
26
24
  }
@@ -1,7 +1,5 @@
1
1
  import { CommandBase } from './CommandBase';
2
2
  /**
3
- * {@inheritDoc CommandBase}
4
- *
5
3
  * Represents a command to set a product by its ID.
6
4
  *
7
5
  * @remarks
@@ -9,6 +7,8 @@ import { CommandBase } from './CommandBase';
9
7
  *
10
8
  * @example
11
9
  * import { SetProduct,Communicator } from '@3dsource/metabox-front-api';
10
+ *
11
+ * //...Assume that the integration is already implemented
12
12
  * window.env3DSource.apiReady = (api:Communicator) => {
13
13
  * api.setCommandToMetaBox(new SetProduct(
14
14
  * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3'
@@ -1,11 +1,11 @@
1
1
  import { CommandBase } from './CommandBase';
2
2
  /**
3
- * {@inheritDoc CommandBase}
4
- *
5
3
  * Represents a command to toggle the Embedded MetaBox Menu.
6
4
  *
7
5
  * @example
8
6
  * import { ShowEmbeddedMenu,Communicator } from '@3dsource/metabox-front-api';
7
+ *
8
+ * //...Assume that the integration is already implemented
9
9
  * window.env3DSource.apiReady = (api:Communicator) => {
10
10
  * api.setCommandToMetaBox(new ShowEmbeddedMenu(true));
11
11
  * };
@@ -1,7 +1,5 @@
1
1
  import { CommandBase } from './CommandBase';
2
2
  /**
3
- * {@inheritDoc CommandBase}
4
- *
5
3
  * Represents a command to toggle the Unreal Overlay Interface Menu.
6
4
  *
7
5
  * @remarks
@@ -9,6 +7,8 @@ import { CommandBase } from './CommandBase';
9
7
  *
10
8
  * @example
11
9
  * import { ShowOverlayInterface,Communicator } from '@3dsource/metabox-front-api';
10
+ *
11
+ * //...Assume that the integration is already implemented
12
12
  * window.env3DSource.apiReady = (api:Communicator) => {
13
13
  * api.setCommandToMetaBox(new ShowOverlayInterface(true));
14
14
  * };
package/dist/index.d.ts CHANGED
@@ -5,10 +5,10 @@ export { SetProduct } from './actions/SetProduct';
5
5
  export { GetPdf } from './actions/GetPdf';
6
6
  export { SetMaterial } from './actions/SetMaterial';
7
7
  export { SetEnvironmentMaterial } from './actions/SetEnvironmentMaterial';
8
- export { GetFastRender } from './actions/GetFastRender';
8
+ export { GetScreenshot } from './actions/GetScreenshot';
9
9
  export { SendCommandToUnreal } from './actions/SendCommandToUnreal';
10
10
  export { WatchCallbacks } from './actions/WatchCallbacks';
11
- export type { MimeType } from './actions/GetFastRender';
11
+ export type { MimeType } from './actions/GetScreenshot';
12
12
  export { CommandBase } from './actions/CommandBase';
13
13
  export * from './lib/integrateMetaBox';
14
14
  export * from './lib/Communicator';
package/dist/index.esm.js CHANGED
@@ -7,8 +7,6 @@ class CommandBase {
7
7
  }
8
8
 
9
9
  /**
10
- * {@inheritDoc CommandBase}
11
- *
12
10
  * Represents a command to toggle the Unreal Overlay Interface Menu.
13
11
  *
14
12
  * @remarks
@@ -16,6 +14,8 @@ class CommandBase {
16
14
  *
17
15
  * @example
18
16
  * import { ShowOverlayInterface,Communicator } from '@3dsource/metabox-front-api';
17
+ *
18
+ * //...Assume that the integration is already implemented
19
19
  * window.env3DSource.apiReady = (api:Communicator) => {
20
20
  * api.setCommandToMetaBox(new ShowOverlayInterface(true));
21
21
  * };
@@ -38,12 +38,12 @@ class ShowOverlayInterface extends CommandBase {
38
38
  }
39
39
 
40
40
  /**
41
- * {@inheritDoc CommandBase}
42
- *
43
41
  * Represents a command to toggle the Embedded MetaBox Menu.
44
42
  *
45
43
  * @example
46
44
  * import { ShowEmbeddedMenu,Communicator } from '@3dsource/metabox-front-api';
45
+ *
46
+ * //...Assume that the integration is already implemented
47
47
  * window.env3DSource.apiReady = (api:Communicator) => {
48
48
  * api.setCommandToMetaBox(new ShowEmbeddedMenu(true));
49
49
  * };
@@ -66,12 +66,12 @@ class ShowEmbeddedMenu extends CommandBase {
66
66
  }
67
67
 
68
68
  /**
69
- * {@inheritDoc CommandBase}
70
- *
71
69
  * Represents a command to set the environment by its ID.
72
70
  *
73
71
  * @example
74
72
  * import { SetEnvironment,Communicator } from '@3dsource/metabox-front-api';
73
+ *
74
+ * //...Assume that the integration is already implemented
75
75
  * window.env3DSource.apiReady = (api:Communicator) => {
76
76
  * // Change the environment to '55555555-1234-1234-1234-01234567890'
77
77
  * api.sendCommandToMetaBox(new SetEnvironment('55555555-1234-1234-1234-01234567890'));
@@ -95,8 +95,6 @@ class SetEnvironment extends CommandBase {
95
95
  }
96
96
 
97
97
  /**
98
- * {@inheritDoc CommandBase}
99
- *
100
98
  * Represents a command to set a product by its ID.
101
99
  *
102
100
  * @remarks
@@ -104,6 +102,8 @@ class SetEnvironment extends CommandBase {
104
102
  *
105
103
  * @example
106
104
  * import { SetProduct,Communicator } from '@3dsource/metabox-front-api';
105
+ *
106
+ * //...Assume that the integration is already implemented
107
107
  * window.env3DSource.apiReady = (api:Communicator) => {
108
108
  * api.setCommandToMetaBox(new SetProduct(
109
109
  * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3'
@@ -128,8 +128,6 @@ class SetProduct extends CommandBase {
128
128
  }
129
129
 
130
130
  /**
131
- * {@inheritDoc CommandBase}
132
- *
133
131
  * Represents a command to get a PDF from Metabox.
134
132
  * @remarks
135
133
  * This class sends a message to the MetaBox API to generate a PDF based on the current configuration.
@@ -159,15 +157,14 @@ class GetPdf extends CommandBase {
159
157
  }
160
158
 
161
159
  /**
162
- * {@inheritDoc CommandBase}
163
- *
164
160
  * Represents a command to set a material by its ID.
165
161
  *
166
162
  * @example
167
163
  * import { SetMaterial,Communicator } from '@3dsource/metabox-front-api';
164
+ *
165
+ * //...Assume that the integration is already implemented
168
166
  * window.env3DSource.apiReady = (api:Communicator) => {
169
167
  * api.sendCommandToMetaBox(new SetMaterial(
170
- * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
171
168
  * 'carpaint',
172
169
  * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
173
170
  * ));
@@ -177,15 +174,13 @@ class SetMaterial extends CommandBase {
177
174
  /**
178
175
  * Creates an instance of SetMaterial.
179
176
  *
180
- * @param productId - The product ID.
181
177
  * @param slotId - The slot ID.
182
178
  * @param materialId - The material ID.
183
179
  */
184
- constructor(productId, slotId, materialId) {
180
+ constructor(slotId, materialId) {
185
181
  super();
186
182
  this.data = {
187
183
  payload: {
188
- productId,
189
184
  slotId,
190
185
  materialId,
191
186
  },
@@ -195,15 +190,14 @@ class SetMaterial extends CommandBase {
195
190
  }
196
191
 
197
192
  /**
198
- * {@inheritDoc CommandBase}
199
- *
200
193
  * Represents a command to set an environment material by its ID.
201
194
  *
202
195
  * @example
203
196
  * import { SetEnvironmentMaterial,Communicator } from '@3dsource/metabox-front-api';
197
+ *
198
+ * //...Assume that the integration is already implemented
204
199
  * window.env3DSource.apiReady = (api:Communicator) => {
205
200
  * api.sendCommandToMetaBox(new SetEnvironmentMaterial(
206
- * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
207
201
  * 'carpaint',
208
202
  * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
209
203
  * ));
@@ -213,15 +207,13 @@ class SetEnvironmentMaterial extends CommandBase {
213
207
  /**
214
208
  * Creates an instance of SetEnvironmentMaterial.
215
209
  *
216
- * @param productId - The product ID.
217
210
  * @param slotId - The slot ID.
218
211
  * @param materialId - The material ID.
219
212
  */
220
- constructor(productId, slotId, materialId) {
213
+ constructor(slotId, materialId) {
221
214
  super();
222
215
  this.data = {
223
216
  payload: {
224
- productId,
225
217
  slotId,
226
218
  materialId,
227
219
  },
@@ -231,26 +223,24 @@ class SetEnvironmentMaterial extends CommandBase {
231
223
  }
232
224
 
233
225
  /**
234
- * {@inheritDoc CommandBase}
235
- *
236
226
  * Represents a command to get fast render.
237
227
  *
238
228
  * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
239
229
  *
240
230
  * @example
241
- * import { GetFastRender,Communicator,saveImage } from '@3dsource/metabox-front-api';
231
+ * import { GetScreenshot,Communicator,saveImage } from '@3dsource/metabox-front-api';
242
232
  * window.env3DSource.apiReady = (api:Communicator) => {
243
233
  * // Listen for events from the MetaBox API
244
234
  * api.addEventListener('fastRender', (data) => {
245
235
  * // Process the fast render response
246
236
  * saveImage(data, 'Render.png');
247
237
  * });
248
- * api.sendCommandToMetaBox(new GetFastRender('image/png', { x: 1024, y: 1024 }));
238
+ * api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
249
239
  * };
250
240
  */
251
- class GetFastRender extends CommandBase {
241
+ class GetScreenshot extends CommandBase {
252
242
  /**
253
- * Constructs an instance of GetFastRender.
243
+ * Constructs an instance of GetScreenshot.
254
244
  * @param mimeType - The output format.
255
245
  * @param size - Optional size in pixels.
256
246
  */
@@ -261,13 +251,12 @@ class GetFastRender extends CommandBase {
261
251
  format: mimeType,
262
252
  size,
263
253
  },
264
- action: 'getFastRender',
254
+ action: 'getScreenshot',
265
255
  };
266
256
  }
267
257
  }
268
258
 
269
259
  /**
270
- * {@inheritDoc CommandBase}
271
260
  * @internal
272
261
  * @hidden
273
262
  * Represents a command to send Unreal command.
@@ -353,26 +342,19 @@ class EventDispatcher {
353
342
  }
354
343
 
355
344
  /**
356
- * API class to handle communication with the embedded content.
357
- * @internal Do not Create an instance of this class directly.
358
- * integrateMetabox will create an instance of this class.
359
- *
360
- * @remarks
361
- * This class sets up a communication channel with the embedded content via window messages.
345
+ * Handles messaging between the host page and embedded MetaBox content.
346
+ * @internal Use {@link Communicator.createInstance} or the {@link integrateMetaBox} helper to instantiate.
362
347
  */
363
348
  class Communicator extends EventDispatcher {
364
349
  /**
365
- * Creates an instance of Communicator.
350
+ * Constructs a Communicator, replacing any existing instance, and begins listening for messages.
366
351
  * @internal
367
- * @remarks
368
- * If an instance already exists, it will be destroyed before creating a new one.
369
- * The instance listens for messages from the iframe.
370
352
  */
371
353
  constructor() {
372
354
  var _a;
373
355
  super();
374
356
  /**
375
- * Binder function for handling incoming messages.
357
+ * Bound handler for incoming postMessage events.
376
358
  */
377
359
  this.binder = this.handleMessageReceived.bind(this, 'metaboxData');
378
360
  (_a = Communicator.instance) === null || _a === void 0 ? void 0 : _a.destroy();
@@ -380,44 +362,38 @@ class Communicator extends EventDispatcher {
380
362
  window.addEventListener('message', this.binder);
381
363
  }
382
364
  /**
383
- * Destroys the communicator instance by clearing listeners and removing event listeners.
365
+ * Cleans up resources and stops listening for messages.
384
366
  */
385
367
  destroy() {
386
368
  super.destroy();
387
369
  window.removeEventListener('message', this.binder);
388
370
  }
389
371
  /**
390
- * Sends a message to the embedded content (MetaBox).
391
- * @param command
372
+ * Posts a command to the MetaBox iframe.
373
+ * @param command - An action command containing data to send.
392
374
  */
393
375
  sendCommandToMetaBox(command) {
394
- var _a;
395
- const data = command.data;
376
+ const { data } = command;
396
377
  const iframe = document.getElementById('embeddedContent');
397
378
  if (!(iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow)) {
398
- console.warn('IFrame not found or not ready');
379
+ console.warn('MetaBox iframe is not available.');
399
380
  return;
400
381
  }
401
- const dataToSend = {
382
+ const message = {
402
383
  host: 'metaBoxHost',
403
384
  payload: Object.assign({}, data),
404
385
  };
405
- // In production, replace "*" with the actual origin for added security.
406
- (_a = iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage(dataToSend, '*');
386
+ // Replace '*' with a specific origin in production for better security.
387
+ iframe.contentWindow.postMessage(message, '*');
407
388
  }
408
389
  /**
409
- * Handles incoming messages by invoking the appropriate callbacks.
410
- *
411
- * @param messageType - The message type to filter for.
412
- * @param event - The incoming message event.
413
- *
414
- * @remarks
415
- * Optionally, you can perform an origin check for added security.
390
+ * Filters and dispatches incoming messages from MetaBox.
391
+ * @param messageType - Expected message type for filtering ('metaboxData').
392
+ * @param event - The postMessage event received on window.
416
393
  */
417
394
  handleMessageReceived(messageType, event) {
418
395
  var _a;
419
- // Optional: Perform origin check here for added security
420
- // if (event.origin !== "EXPECTED_ORIGIN") return;
396
+ // Optionally validate event.origin for security.
421
397
  if (messageType !== 'metaboxData' || ((_a = event.data) === null || _a === void 0 ? void 0 : _a.host) !== 'metabox') {
422
398
  return;
423
399
  }
@@ -425,10 +401,8 @@ class Communicator extends EventDispatcher {
425
401
  this.dispatchEvent(eventType, payload);
426
402
  }
427
403
  /**
428
- * Initializes the communicator when the embedded content is ready.
429
- * @internal
430
- * @remarks
431
- * This function sets up a listener that waits for the 'appLoaded' action and then initializes the Communicator.
404
+ * Listens for MetaBox to signal readiness, then initializes communicator.
405
+ * @param apiReadyCallback - Called with the new Communicator once MetaBox is loaded.
432
406
  */
433
407
  static createInstance(apiReadyCallback) {
434
408
  const startHandler = (event) => {
@@ -441,18 +415,30 @@ class Communicator extends EventDispatcher {
441
415
  };
442
416
  window.addEventListener('message', startHandler);
443
417
  }
418
+ /**
419
+ * Registers an event listener for messages dispatched by MetaBox.
420
+ * @override
421
+ */
444
422
  addEventListener(messageType, callback) {
445
423
  return super.addEventListener(messageType, callback);
446
424
  }
425
+ /**
426
+ * Dispatches a typed event to all registered listeners.
427
+ * @override
428
+ */
447
429
  dispatchEvent(messageType, data) {
448
430
  return super.dispatchEvent(messageType, data);
449
431
  }
432
+ /**
433
+ * Removes a previously registered event listener.
434
+ * @override
435
+ */
450
436
  removeEventListener(messageType, callback) {
451
437
  return super.removeEventListener(messageType, callback);
452
438
  }
453
439
  }
454
440
  /**
455
- * The singleton instance of the communicator.
441
+ * Singleton reference to the current communicator instance.
456
442
  */
457
443
  Communicator.instance = null;
458
444
 
@@ -512,6 +498,11 @@ function integrateMetaBox(iframeSrc, containerId = 'embed3DSource', apiReadyCall
512
498
  container.appendChild(iframe);
513
499
  }
514
500
 
501
+ /**
502
+ * Wrapper helper function to use it with rxJs same as `fromEvent` to listen to events from the Communicator.
503
+ * @param target
504
+ * @param eventName
505
+ */
515
506
  function fromCommunicatorEvent(target, eventName) {
516
507
  return fromEvent(target, eventName);
517
508
  }
@@ -523,12 +514,12 @@ function fromCommunicatorEvent(target, eventName) {
523
514
  * This function creates an anchor element, sets its `href` attribute to the provided image URL,
524
515
  * and triggers a click event to initiate a download with the specified filename.
525
516
  *
526
- * @param image - The URL of the image to save.
517
+ * @param imageUrl - The URL of the image to save.
527
518
  * @param filename - The name of the file to save.
528
519
  */
529
- function saveImage(image, filename) {
520
+ function saveImage(imageUrl, filename) {
530
521
  const a = document.createElement('a');
531
- a.href = image;
522
+ a.href = imageUrl;
532
523
  a.download = filename;
533
524
  document.body.appendChild(a);
534
525
  a.click();
@@ -581,5 +572,5 @@ function getUrlParams() {
581
572
  return selections;
582
573
  }
583
574
 
584
- export { CommandBase, Communicator, GetFastRender, GetPdf, SendCommandToUnreal, SetEnvironment, SetEnvironmentMaterial, SetMaterial, SetProduct, ShowEmbeddedMenu, ShowOverlayInterface, WatchCallbacks, fromCommunicatorEvent, getUrlParams, integrateMetaBox, saveImage, setUrlParams, sleep };
575
+ export { CommandBase, Communicator, GetPdf, GetScreenshot, SendCommandToUnreal, SetEnvironment, SetEnvironmentMaterial, SetMaterial, SetProduct, ShowEmbeddedMenu, ShowOverlayInterface, WatchCallbacks, fromCommunicatorEvent, getUrlParams, integrateMetaBox, saveImage, setUrlParams, sleep };
585
576
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.umd.js CHANGED
@@ -11,8 +11,6 @@
11
11
  }
12
12
 
13
13
  /**
14
- * {@inheritDoc CommandBase}
15
- *
16
14
  * Represents a command to toggle the Unreal Overlay Interface Menu.
17
15
  *
18
16
  * @remarks
@@ -20,6 +18,8 @@
20
18
  *
21
19
  * @example
22
20
  * import { ShowOverlayInterface,Communicator } from '@3dsource/metabox-front-api';
21
+ *
22
+ * //...Assume that the integration is already implemented
23
23
  * window.env3DSource.apiReady = (api:Communicator) => {
24
24
  * api.setCommandToMetaBox(new ShowOverlayInterface(true));
25
25
  * };
@@ -42,12 +42,12 @@
42
42
  }
43
43
 
44
44
  /**
45
- * {@inheritDoc CommandBase}
46
- *
47
45
  * Represents a command to toggle the Embedded MetaBox Menu.
48
46
  *
49
47
  * @example
50
48
  * import { ShowEmbeddedMenu,Communicator } from '@3dsource/metabox-front-api';
49
+ *
50
+ * //...Assume that the integration is already implemented
51
51
  * window.env3DSource.apiReady = (api:Communicator) => {
52
52
  * api.setCommandToMetaBox(new ShowEmbeddedMenu(true));
53
53
  * };
@@ -70,12 +70,12 @@
70
70
  }
71
71
 
72
72
  /**
73
- * {@inheritDoc CommandBase}
74
- *
75
73
  * Represents a command to set the environment by its ID.
76
74
  *
77
75
  * @example
78
76
  * import { SetEnvironment,Communicator } from '@3dsource/metabox-front-api';
77
+ *
78
+ * //...Assume that the integration is already implemented
79
79
  * window.env3DSource.apiReady = (api:Communicator) => {
80
80
  * // Change the environment to '55555555-1234-1234-1234-01234567890'
81
81
  * api.sendCommandToMetaBox(new SetEnvironment('55555555-1234-1234-1234-01234567890'));
@@ -99,8 +99,6 @@
99
99
  }
100
100
 
101
101
  /**
102
- * {@inheritDoc CommandBase}
103
- *
104
102
  * Represents a command to set a product by its ID.
105
103
  *
106
104
  * @remarks
@@ -108,6 +106,8 @@
108
106
  *
109
107
  * @example
110
108
  * import { SetProduct,Communicator } from '@3dsource/metabox-front-api';
109
+ *
110
+ * //...Assume that the integration is already implemented
111
111
  * window.env3DSource.apiReady = (api:Communicator) => {
112
112
  * api.setCommandToMetaBox(new SetProduct(
113
113
  * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3'
@@ -132,8 +132,6 @@
132
132
  }
133
133
 
134
134
  /**
135
- * {@inheritDoc CommandBase}
136
- *
137
135
  * Represents a command to get a PDF from Metabox.
138
136
  * @remarks
139
137
  * This class sends a message to the MetaBox API to generate a PDF based on the current configuration.
@@ -163,15 +161,14 @@
163
161
  }
164
162
 
165
163
  /**
166
- * {@inheritDoc CommandBase}
167
- *
168
164
  * Represents a command to set a material by its ID.
169
165
  *
170
166
  * @example
171
167
  * import { SetMaterial,Communicator } from '@3dsource/metabox-front-api';
168
+ *
169
+ * //...Assume that the integration is already implemented
172
170
  * window.env3DSource.apiReady = (api:Communicator) => {
173
171
  * api.sendCommandToMetaBox(new SetMaterial(
174
- * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
175
172
  * 'carpaint',
176
173
  * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
177
174
  * ));
@@ -181,15 +178,13 @@
181
178
  /**
182
179
  * Creates an instance of SetMaterial.
183
180
  *
184
- * @param productId - The product ID.
185
181
  * @param slotId - The slot ID.
186
182
  * @param materialId - The material ID.
187
183
  */
188
- constructor(productId, slotId, materialId) {
184
+ constructor(slotId, materialId) {
189
185
  super();
190
186
  this.data = {
191
187
  payload: {
192
- productId,
193
188
  slotId,
194
189
  materialId,
195
190
  },
@@ -199,15 +194,14 @@
199
194
  }
200
195
 
201
196
  /**
202
- * {@inheritDoc CommandBase}
203
- *
204
197
  * Represents a command to set an environment material by its ID.
205
198
  *
206
199
  * @example
207
200
  * import { SetEnvironmentMaterial,Communicator } from '@3dsource/metabox-front-api';
201
+ *
202
+ * //...Assume that the integration is already implemented
208
203
  * window.env3DSource.apiReady = (api:Communicator) => {
209
204
  * api.sendCommandToMetaBox(new SetEnvironmentMaterial(
210
- * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
211
205
  * 'carpaint',
212
206
  * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
213
207
  * ));
@@ -217,15 +211,13 @@
217
211
  /**
218
212
  * Creates an instance of SetEnvironmentMaterial.
219
213
  *
220
- * @param productId - The product ID.
221
214
  * @param slotId - The slot ID.
222
215
  * @param materialId - The material ID.
223
216
  */
224
- constructor(productId, slotId, materialId) {
217
+ constructor(slotId, materialId) {
225
218
  super();
226
219
  this.data = {
227
220
  payload: {
228
- productId,
229
221
  slotId,
230
222
  materialId,
231
223
  },
@@ -235,26 +227,24 @@
235
227
  }
236
228
 
237
229
  /**
238
- * {@inheritDoc CommandBase}
239
- *
240
230
  * Represents a command to get fast render.
241
231
  *
242
232
  * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
243
233
  *
244
234
  * @example
245
- * import { GetFastRender,Communicator,saveImage } from '@3dsource/metabox-front-api';
235
+ * import { GetScreenshot,Communicator,saveImage } from '@3dsource/metabox-front-api';
246
236
  * window.env3DSource.apiReady = (api:Communicator) => {
247
237
  * // Listen for events from the MetaBox API
248
238
  * api.addEventListener('fastRender', (data) => {
249
239
  * // Process the fast render response
250
240
  * saveImage(data, 'Render.png');
251
241
  * });
252
- * api.sendCommandToMetaBox(new GetFastRender('image/png', { x: 1024, y: 1024 }));
242
+ * api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
253
243
  * };
254
244
  */
255
- class GetFastRender extends CommandBase {
245
+ class GetScreenshot extends CommandBase {
256
246
  /**
257
- * Constructs an instance of GetFastRender.
247
+ * Constructs an instance of GetScreenshot.
258
248
  * @param mimeType - The output format.
259
249
  * @param size - Optional size in pixels.
260
250
  */
@@ -265,13 +255,12 @@
265
255
  format: mimeType,
266
256
  size,
267
257
  },
268
- action: 'getFastRender',
258
+ action: 'getScreenshot',
269
259
  };
270
260
  }
271
261
  }
272
262
 
273
263
  /**
274
- * {@inheritDoc CommandBase}
275
264
  * @internal
276
265
  * @hidden
277
266
  * Represents a command to send Unreal command.
@@ -357,26 +346,19 @@
357
346
  }
358
347
 
359
348
  /**
360
- * API class to handle communication with the embedded content.
361
- * @internal Do not Create an instance of this class directly.
362
- * integrateMetabox will create an instance of this class.
363
- *
364
- * @remarks
365
- * This class sets up a communication channel with the embedded content via window messages.
349
+ * Handles messaging between the host page and embedded MetaBox content.
350
+ * @internal Use {@link Communicator.createInstance} or the {@link integrateMetaBox} helper to instantiate.
366
351
  */
367
352
  class Communicator extends EventDispatcher {
368
353
  /**
369
- * Creates an instance of Communicator.
354
+ * Constructs a Communicator, replacing any existing instance, and begins listening for messages.
370
355
  * @internal
371
- * @remarks
372
- * If an instance already exists, it will be destroyed before creating a new one.
373
- * The instance listens for messages from the iframe.
374
356
  */
375
357
  constructor() {
376
358
  var _a;
377
359
  super();
378
360
  /**
379
- * Binder function for handling incoming messages.
361
+ * Bound handler for incoming postMessage events.
380
362
  */
381
363
  this.binder = this.handleMessageReceived.bind(this, 'metaboxData');
382
364
  (_a = Communicator.instance) === null || _a === void 0 ? void 0 : _a.destroy();
@@ -384,44 +366,38 @@
384
366
  window.addEventListener('message', this.binder);
385
367
  }
386
368
  /**
387
- * Destroys the communicator instance by clearing listeners and removing event listeners.
369
+ * Cleans up resources and stops listening for messages.
388
370
  */
389
371
  destroy() {
390
372
  super.destroy();
391
373
  window.removeEventListener('message', this.binder);
392
374
  }
393
375
  /**
394
- * Sends a message to the embedded content (MetaBox).
395
- * @param command
376
+ * Posts a command to the MetaBox iframe.
377
+ * @param command - An action command containing data to send.
396
378
  */
397
379
  sendCommandToMetaBox(command) {
398
- var _a;
399
- const data = command.data;
380
+ const { data } = command;
400
381
  const iframe = document.getElementById('embeddedContent');
401
382
  if (!(iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow)) {
402
- console.warn('IFrame not found or not ready');
383
+ console.warn('MetaBox iframe is not available.');
403
384
  return;
404
385
  }
405
- const dataToSend = {
386
+ const message = {
406
387
  host: 'metaBoxHost',
407
388
  payload: Object.assign({}, data),
408
389
  };
409
- // In production, replace "*" with the actual origin for added security.
410
- (_a = iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage(dataToSend, '*');
390
+ // Replace '*' with a specific origin in production for better security.
391
+ iframe.contentWindow.postMessage(message, '*');
411
392
  }
412
393
  /**
413
- * Handles incoming messages by invoking the appropriate callbacks.
414
- *
415
- * @param messageType - The message type to filter for.
416
- * @param event - The incoming message event.
417
- *
418
- * @remarks
419
- * Optionally, you can perform an origin check for added security.
394
+ * Filters and dispatches incoming messages from MetaBox.
395
+ * @param messageType - Expected message type for filtering ('metaboxData').
396
+ * @param event - The postMessage event received on window.
420
397
  */
421
398
  handleMessageReceived(messageType, event) {
422
399
  var _a;
423
- // Optional: Perform origin check here for added security
424
- // if (event.origin !== "EXPECTED_ORIGIN") return;
400
+ // Optionally validate event.origin for security.
425
401
  if (messageType !== 'metaboxData' || ((_a = event.data) === null || _a === void 0 ? void 0 : _a.host) !== 'metabox') {
426
402
  return;
427
403
  }
@@ -429,10 +405,8 @@
429
405
  this.dispatchEvent(eventType, payload);
430
406
  }
431
407
  /**
432
- * Initializes the communicator when the embedded content is ready.
433
- * @internal
434
- * @remarks
435
- * This function sets up a listener that waits for the 'appLoaded' action and then initializes the Communicator.
408
+ * Listens for MetaBox to signal readiness, then initializes communicator.
409
+ * @param apiReadyCallback - Called with the new Communicator once MetaBox is loaded.
436
410
  */
437
411
  static createInstance(apiReadyCallback) {
438
412
  const startHandler = (event) => {
@@ -445,18 +419,30 @@
445
419
  };
446
420
  window.addEventListener('message', startHandler);
447
421
  }
422
+ /**
423
+ * Registers an event listener for messages dispatched by MetaBox.
424
+ * @override
425
+ */
448
426
  addEventListener(messageType, callback) {
449
427
  return super.addEventListener(messageType, callback);
450
428
  }
429
+ /**
430
+ * Dispatches a typed event to all registered listeners.
431
+ * @override
432
+ */
451
433
  dispatchEvent(messageType, data) {
452
434
  return super.dispatchEvent(messageType, data);
453
435
  }
436
+ /**
437
+ * Removes a previously registered event listener.
438
+ * @override
439
+ */
454
440
  removeEventListener(messageType, callback) {
455
441
  return super.removeEventListener(messageType, callback);
456
442
  }
457
443
  }
458
444
  /**
459
- * The singleton instance of the communicator.
445
+ * Singleton reference to the current communicator instance.
460
446
  */
461
447
  Communicator.instance = null;
462
448
 
@@ -516,6 +502,11 @@
516
502
  container.appendChild(iframe);
517
503
  }
518
504
 
505
+ /**
506
+ * Wrapper helper function to use it with rxJs same as `fromEvent` to listen to events from the Communicator.
507
+ * @param target
508
+ * @param eventName
509
+ */
519
510
  function fromCommunicatorEvent(target, eventName) {
520
511
  return rxjs.fromEvent(target, eventName);
521
512
  }
@@ -527,12 +518,12 @@
527
518
  * This function creates an anchor element, sets its `href` attribute to the provided image URL,
528
519
  * and triggers a click event to initiate a download with the specified filename.
529
520
  *
530
- * @param image - The URL of the image to save.
521
+ * @param imageUrl - The URL of the image to save.
531
522
  * @param filename - The name of the file to save.
532
523
  */
533
- function saveImage(image, filename) {
524
+ function saveImage(imageUrl, filename) {
534
525
  const a = document.createElement('a');
535
- a.href = image;
526
+ a.href = imageUrl;
536
527
  a.download = filename;
537
528
  document.body.appendChild(a);
538
529
  a.click();
@@ -587,8 +578,8 @@
587
578
 
588
579
  exports.CommandBase = CommandBase;
589
580
  exports.Communicator = Communicator;
590
- exports.GetFastRender = GetFastRender;
591
581
  exports.GetPdf = GetPdf;
582
+ exports.GetScreenshot = GetScreenshot;
592
583
  exports.SendCommandToUnreal = SendCommandToUnreal;
593
584
  exports.SetEnvironment = SetEnvironment;
594
585
  exports.SetEnvironmentMaterial = SetEnvironmentMaterial;
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.umd.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -5,6 +5,11 @@ export interface FromMetaboxMessagePayloads {
5
5
  * Dispatches Every time the configurator data is updated.
6
6
  * I.e., when the user changes the configuration. (Material, Product, Environment)
7
7
  */
8
+ configuratorData: ConfiguratorEnvelope;
9
+ /**
10
+ * @hidden
11
+ * @deprecated, use configuratorData instead.
12
+ */
8
13
  basicConfiguratorDataWithState: ConfiguratorEnvelope;
9
14
  /**
10
15
  * Dispatches Every time when the configurator connected/disconnected with Unreal Engine.
@@ -42,6 +47,11 @@ export interface FromMetaboxMessagePayloads {
42
47
  /**
43
48
  * Dispatches every time when Unreal is sending ordered render with new GetFastRender() command.
44
49
  */
50
+ screenshot: string | null;
51
+ /**
52
+ * @hidden
53
+ * @deprecated, use screenshot
54
+ */
45
55
  fastRender: string | null;
46
56
  /**
47
57
  * @hidden
@@ -52,10 +62,20 @@ export interface FromMetaboxMessagePayloads {
52
62
  * @experimental
53
63
  * Dispatches every Unreal state is changing, including all unreal module state.
54
64
  */
65
+ unrealState: UnrealState;
66
+ /**
67
+ * @hidden
68
+ * @deprecated, use unrealState
69
+ */
55
70
  unrealFeature: UnrealState;
56
71
  /**
57
72
  * Dispatches every time when Unreal is changing its video stream size.
58
73
  */
74
+ videoResolution: StreamResolutionProps;
75
+ /**
76
+ * @hidden
77
+ * @deprecated, use videoResolution
78
+ */
59
79
  streamResolution: StreamResolutionProps;
60
80
  }
61
81
  /**
@@ -1,6 +1,6 @@
1
- import type { MimeType } from '../actions/GetFastRender';
1
+ import type { MimeType } from '../actions/GetScreenshot';
2
2
  import type { ApplicationDeviceTypes } from './application-device-types';
3
- export type ToMetaBoxActions = 'getPdf' | 'loadLevel' | 'setProduct' | 'getFastRender' | 'watchCallbacks' | 'setMaterialById' | 'showEmbeddedMenu' | 'forceSetDeviceType' | 'sendCommandToUnreal' | 'showOverlayInterface' | 'setEnvironmentMaterialById' | 'resetCamera' | 'addResponse';
3
+ export type ToMetaBoxActions = 'getPdf' | 'loadLevel' | 'setProduct' | 'getFastRender' | 'getScreenshot' | 'watchCallbacks' | 'setMaterialById' | 'showEmbeddedMenu' | 'forceSetDeviceType' | 'sendCommandToUnreal' | 'showOverlayInterface' | 'setEnvironmentMaterialById' | 'resetCamera' | 'addResponse';
4
4
  /**
5
5
  * @internal
6
6
  * @hidden
@@ -22,6 +22,10 @@ export interface ToMetaboxMessagePayloads {
22
22
  * @hidden
23
23
  */
24
24
  addResponse: void;
25
+ /**
26
+ * @deprecated
27
+ * @hidden
28
+ */
25
29
  getFastRender: {
26
30
  format: MimeType;
27
31
  size?: {
@@ -29,6 +33,13 @@ export interface ToMetaboxMessagePayloads {
29
33
  y: number;
30
34
  };
31
35
  };
36
+ getScreenshot: {
37
+ format: MimeType;
38
+ size?: {
39
+ x: number;
40
+ y: number;
41
+ };
42
+ };
32
43
  watchCallbacks: void;
33
44
  setMaterialById: {
34
45
  productId: string;
@@ -2,57 +2,56 @@ import { EventDispatcher } from './EventDispatcher';
2
2
  import type { CommandBase } from '../actions/CommandBase';
3
3
  import type { FromMetaBoxApiEvents, FromMetaboxMessagePayloads } from '../interfaces/FromMetaboxMessagePayloads';
4
4
  /**
5
- * API class to handle communication with the embedded content.
6
- * @internal Do not Create an instance of this class directly.
7
- * integrateMetabox will create an instance of this class.
8
- *
9
- * @remarks
10
- * This class sets up a communication channel with the embedded content via window messages.
5
+ * Handles messaging between the host page and embedded MetaBox content.
6
+ * @internal Use {@link Communicator.createInstance} or the {@link integrateMetaBox} helper to instantiate.
11
7
  */
12
8
  export declare class Communicator extends EventDispatcher {
13
9
  /**
14
- * Binder function for handling incoming messages.
10
+ * Bound handler for incoming postMessage events.
15
11
  */
16
12
  private binder;
17
13
  /**
18
- * The singleton instance of the communicator.
14
+ * Singleton reference to the current communicator instance.
19
15
  */
20
16
  static instance: Communicator | null;
21
17
  /**
22
- * Creates an instance of Communicator.
18
+ * Constructs a Communicator, replacing any existing instance, and begins listening for messages.
23
19
  * @internal
24
- * @remarks
25
- * If an instance already exists, it will be destroyed before creating a new one.
26
- * The instance listens for messages from the iframe.
27
20
  */
28
21
  constructor();
29
22
  /**
30
- * Destroys the communicator instance by clearing listeners and removing event listeners.
23
+ * Cleans up resources and stops listening for messages.
31
24
  */
32
25
  destroy(): void;
33
26
  /**
34
- * Sends a message to the embedded content (MetaBox).
35
- * @param command
27
+ * Posts a command to the MetaBox iframe.
28
+ * @param command - An action command containing data to send.
36
29
  */
37
30
  sendCommandToMetaBox<T extends CommandBase>(command: T): void;
38
31
  /**
39
- * Handles incoming messages by invoking the appropriate callbacks.
40
- *
41
- * @param messageType - The message type to filter for.
42
- * @param event - The incoming message event.
43
- *
44
- * @remarks
45
- * Optionally, you can perform an origin check for added security.
32
+ * Filters and dispatches incoming messages from MetaBox.
33
+ * @param messageType - Expected message type for filtering ('metaboxData').
34
+ * @param event - The postMessage event received on window.
46
35
  */
47
36
  private handleMessageReceived;
48
37
  /**
49
- * Initializes the communicator when the embedded content is ready.
50
- * @internal
51
- * @remarks
52
- * This function sets up a listener that waits for the 'appLoaded' action and then initializes the Communicator.
38
+ * Listens for MetaBox to signal readiness, then initializes communicator.
39
+ * @param apiReadyCallback - Called with the new Communicator once MetaBox is loaded.
53
40
  */
54
41
  static createInstance(apiReadyCallback: (api: Communicator) => void): void;
42
+ /**
43
+ * Registers an event listener for messages dispatched by MetaBox.
44
+ * @override
45
+ */
55
46
  addEventListener<T extends FromMetaBoxApiEvents>(messageType: T, callback: (data: FromMetaboxMessagePayloads[T]) => void): this;
47
+ /**
48
+ * Dispatches a typed event to all registered listeners.
49
+ * @override
50
+ */
56
51
  dispatchEvent<T extends FromMetaBoxApiEvents>(messageType: T, data: FromMetaboxMessagePayloads[T]): this;
52
+ /**
53
+ * Removes a previously registered event listener.
54
+ * @override
55
+ */
57
56
  removeEventListener<T extends FromMetaBoxApiEvents>(messageType: T, callback: (data: FromMetaboxMessagePayloads[T]) => void): this;
58
57
  }
@@ -1,4 +1,9 @@
1
1
  import type { Communicator } from './Communicator';
2
2
  import type { FromMetaBoxApiEvents, FromMetaboxMessagePayloads } from '../interfaces/FromMetaboxMessagePayloads';
3
3
  import type { Observable } from 'rxjs';
4
+ /**
5
+ * Wrapper helper function to use it with rxJs same as `fromEvent` to listen to events from the Communicator.
6
+ * @param target
7
+ * @param eventName
8
+ */
4
9
  export declare function fromCommunicatorEvent<T extends FromMetaBoxApiEvents>(target: Communicator, eventName: T): Observable<FromMetaboxMessagePayloads[T]>;
@@ -5,7 +5,7 @@
5
5
  * This function creates an anchor element, sets its `href` attribute to the provided image URL,
6
6
  * and triggers a click event to initiate a download with the specified filename.
7
7
  *
8
- * @param image - The URL of the image to save.
8
+ * @param imageUrl - The URL of the image to save.
9
9
  * @param filename - The name of the file to save.
10
10
  */
11
- export declare function saveImage(image: string, filename: string): void;
11
+ export declare function saveImage(imageUrl: string, filename: string): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@3dsource/metabox-front-api",
3
- "version": "0.0.19-dev.1",
3
+ "version": "0.0.19-dev.3",
4
4
  "description": "API for MetaBox BASIC configurator",
5
5
  "keywords": [
6
6
  "metabox",
@@ -12,7 +12,7 @@
12
12
  "url": "git@bitbucket.org:dreamsoft/ams_vps-frontend.git"
13
13
  },
14
14
  "license": "MIT",
15
- "author": "3dsource.com",
15
+ "author": "Sergii Karanda @ 3dsource.com",
16
16
  "type": "module",
17
17
  "exports": {
18
18
  ".": {
@@ -32,12 +32,15 @@
32
32
  "scripts": {
33
33
  "apiDoc": "typedoc --entryPointStrategy Expand src/index.ts --tsconfig ./../../../tsconfig.typedoc.json --out ./../../../dist/browser/apiDocBasic",
34
34
  "build": "rollup -c",
35
+ "bump:dev": "npm version prerelease --preid=dev && npm run publish:dev",
36
+ "bump:minor": "npm version minor && npm run publish:prod",
37
+ "bump:preminor:beta": "npm version preminor --preid=beta && npm run publish --tag beta",
38
+ "bump:preminor:dev": "npm version preminor --preid=dev && npm run publish:dev",
39
+ "bump:prod": "npm version patch && npm run publish:prod",
35
40
  "clean": "rimraf dist",
36
41
  "packAll": "npm run clean && npm run build && npm pack",
37
- "publish:prod": "npm run packAll && npm publish --access public",
38
42
  "publish:dev": "npm run packAll && npm publish --access public --tag dev",
39
- "bump:prod": "npm version patch && npm run publish:prod",
40
- "bump:dev": "npm version prerelease --preid=dev && npm run publish:dev"
43
+ "publish:prod": "npm run packAll && npm publish --access public"
41
44
  },
42
45
  "peerDependencies": {
43
46
  "@3dsource/angular-unreal-module": "^0.0.29",