@3dsource/metabox-front-api 1.2.1-dev.2 → 1.2.1-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/LICENSE ADDED
@@ -0,0 +1,14 @@
1
+ Copyright (c) 2025 3dsource
2
+ All Rights Reserved.
3
+
4
+ This software and associated documentation files (the “Software”) are proprietary
5
+ and confidential. Unauthorized copying, modification, distribution, or any other
6
+ use of the Software, in whole or in part, without the prior written consent of
7
+ the copyright holder is strictly prohibited.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11
+ FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
12
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
13
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,581 @@
1
+ import { fromEvent } from 'rxjs';
2
+
3
+ /**
4
+ * Base class for commands sent to the MetaBox.
5
+ */
6
+ class CommandBase {
7
+ }
8
+
9
+ /**
10
+ * Represents a command to toggle the Unreal Overlay Interface Menu.
11
+ *
12
+ * @remarks
13
+ * This action sends a message to the MetaBox API to toggle the visibility of the Unreal overlay UI.
14
+ *
15
+ * @example
16
+ * import { ShowOverlayInterface,Communicator } from '@3dsource/metabox-front-api';
17
+ *
18
+ * //...Assume that the integration is already implemented
19
+ * window.env3DSource.apiReady = (api:Communicator) => {
20
+ * api.setCommandToMetaBox(new ShowOverlayInterface(true));
21
+ * };
22
+ */
23
+ class ShowOverlayInterface extends CommandBase {
24
+ /**
25
+ * Creates an instance of ShowOverlayInterface.
26
+ *
27
+ * @param visible - A flag indicating whether the Unreal overlay UI should be visible.
28
+ */
29
+ constructor(visible) {
30
+ super();
31
+ this.data = {
32
+ action: 'showOverlayInterface',
33
+ payload: {
34
+ visible,
35
+ },
36
+ };
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Represents a command to toggle the Embedded MetaBox Menu.
42
+ *
43
+ * @example
44
+ * import { ShowEmbeddedMenu,Communicator } from '@3dsource/metabox-front-api';
45
+ *
46
+ * //...Assume that the integration is already implemented
47
+ * window.env3DSource.apiReady = (api:Communicator) => {
48
+ * api.setCommandToMetaBox(new ShowEmbeddedMenu(true));
49
+ * };
50
+ */
51
+ class ShowEmbeddedMenu extends CommandBase {
52
+ /**
53
+ * Creates an instance of ShowEmbeddedMenu.
54
+ *
55
+ * @param visible - A flag indicating whether the embedded menu should be visible.
56
+ */
57
+ constructor(visible) {
58
+ super();
59
+ this.data = {
60
+ action: 'showEmbeddedMenu',
61
+ payload: {
62
+ visible,
63
+ },
64
+ };
65
+ }
66
+ }
67
+
68
+ /**
69
+ * Represents a command to set the environment by its ID.
70
+ *
71
+ * @example
72
+ * import { SetEnvironment,Communicator } from '@3dsource/metabox-front-api';
73
+ *
74
+ * //...Assume that the integration is already implemented
75
+ * window.env3DSource.apiReady = (api:Communicator) => {
76
+ * // Change the environment to '55555555-1234-1234-1234-01234567890'
77
+ * api.sendCommandToMetaBox(new SetEnvironment('55555555-1234-1234-1234-01234567890'));
78
+ * };
79
+ */
80
+ class SetEnvironment extends CommandBase {
81
+ /**
82
+ * Creates an instance of SetEnvironment.
83
+ *
84
+ * @param environmentId - The environment ID.
85
+ */
86
+ constructor(environmentId) {
87
+ super();
88
+ this.data = {
89
+ payload: {
90
+ id: environmentId,
91
+ },
92
+ action: 'loadLevel',
93
+ };
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Represents a command to set a product by its ID.
99
+ *
100
+ * @remarks
101
+ * This action sends a message to the MetaBox API to set a product using the provided product ID.
102
+ *
103
+ * @example
104
+ * import { SetProduct,Communicator } from '@3dsource/metabox-front-api';
105
+ *
106
+ * //...Assume that the integration is already implemented
107
+ * window.env3DSource.apiReady = (api:Communicator) => {
108
+ * api.setCommandToMetaBox(new SetProduct(
109
+ * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3'
110
+ * ));
111
+ * };
112
+ */
113
+ class SetProduct extends CommandBase {
114
+ /**
115
+ * Creates an instance of SetProduct.
116
+ *
117
+ * @param productId - The product ID.
118
+ */
119
+ constructor(productId) {
120
+ super();
121
+ this.data = {
122
+ payload: {
123
+ productId,
124
+ },
125
+ action: 'setProduct',
126
+ };
127
+ }
128
+ }
129
+
130
+ /**
131
+ * Represents a command to get a PDF from Metabox.
132
+ * @remarks
133
+ * This class sends a message to the MetaBox API to generate a PDF based on the current configuration.
134
+ * This action does not require any parameters.
135
+ *
136
+ * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
137
+ *
138
+ * @example
139
+ * import { GetPdf,Communicator } from '@3dsource/metabox-front-api';
140
+ * window.env3DSource.apiReady = (api:Communicator) => {
141
+ * api.sendCommandToMetaBox(new GetPdf());
142
+ * };
143
+ */
144
+ class GetPdf extends CommandBase {
145
+ /**
146
+ * Creates an instance of GetPdf.
147
+ *
148
+ * @remarks
149
+ * This constructor does not require any parameters.
150
+ */
151
+ constructor() {
152
+ super();
153
+ this.data = {
154
+ action: 'getPdf',
155
+ };
156
+ }
157
+ }
158
+
159
+ /**
160
+ * Represents a command to set a material by its ID.
161
+ *
162
+ * @example
163
+ * import { SetMaterial,Communicator } from '@3dsource/metabox-front-api';
164
+ *
165
+ * //...Assume that the integration is already implemented
166
+ * window.env3DSource.apiReady = (api:Communicator) => {
167
+ * api.sendCommandToMetaBox(new SetMaterial(
168
+ * 'carpaint',
169
+ * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
170
+ * ));
171
+ * };
172
+ */
173
+ class SetMaterial extends CommandBase {
174
+ /**
175
+ * Creates an instance of SetMaterial.
176
+ *
177
+ * @param slotId - The slot ID.
178
+ * @param materialId - The material ID.
179
+ */
180
+ constructor(slotId, materialId) {
181
+ super();
182
+ this.data = {
183
+ payload: {
184
+ slotId,
185
+ materialId,
186
+ },
187
+ action: 'setMaterialById',
188
+ };
189
+ }
190
+ }
191
+
192
+ /**
193
+ * Represents a command to set an environment material by its ID.
194
+ *
195
+ * @example
196
+ * import { SetEnvironmentMaterial,Communicator } from '@3dsource/metabox-front-api';
197
+ *
198
+ * //...Assume that the integration is already implemented
199
+ * window.env3DSource.apiReady = (api:Communicator) => {
200
+ * api.sendCommandToMetaBox(new SetEnvironmentMaterial(
201
+ * 'carpaint',
202
+ * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
203
+ * ));
204
+ * };
205
+ */
206
+ class SetEnvironmentMaterial extends CommandBase {
207
+ /**
208
+ * Creates an instance of SetEnvironmentMaterial.
209
+ *
210
+ * @param slotId - The slot ID.
211
+ * @param materialId - The material ID.
212
+ */
213
+ constructor(slotId, materialId) {
214
+ super();
215
+ this.data = {
216
+ payload: {
217
+ slotId,
218
+ materialId,
219
+ },
220
+ action: 'setEnvironmentMaterialById',
221
+ };
222
+ }
223
+ }
224
+
225
+ /**
226
+ * Represents a command to get fast render.
227
+ *
228
+ * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
229
+ *
230
+ * @example
231
+ * import { GetScreenshot,Communicator,saveImage } from '@3dsource/metabox-front-api';
232
+ * window.env3DSource.apiReady = (api:Communicator) => {
233
+ * // Listen for events from the MetaBox API
234
+ * api.addEventListener('screenshot', (data) => {
235
+ * // Process the fast render response
236
+ * saveImage(data, 'Render.png');
237
+ * });
238
+ * api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
239
+ * };
240
+ */
241
+ class GetScreenshot extends CommandBase {
242
+ /**
243
+ * Constructs an instance of GetScreenshot.
244
+ * @param mimeType - The output format.
245
+ * @param size - Optional size in pixels.
246
+ */
247
+ constructor(mimeType, size) {
248
+ super();
249
+ this.data = {
250
+ payload: {
251
+ format: mimeType,
252
+ size,
253
+ },
254
+ action: 'getScreenshot',
255
+ };
256
+ }
257
+ }
258
+
259
+ /**
260
+ * @internal
261
+ * @hidden
262
+ * Represents a command to send Unreal command.
263
+ */
264
+ class UnrealCommand extends CommandBase {
265
+ constructor(payload) {
266
+ super();
267
+ this.data = {
268
+ payload,
269
+ action: 'sendCommandToUnreal',
270
+ };
271
+ }
272
+ }
273
+ /**
274
+ * @deprecated, use `UnrealCommand` instead.
275
+ */
276
+ const SendCommandToUnreal = UnrealCommand;
277
+
278
+ /**
279
+ * @experimental
280
+ * @internal
281
+ * @hidden
282
+ * @remarks
283
+ * Represents a command to watch Unreal callbacks from Unreal engine.
284
+ * Can be useful for custom solutions.
285
+ */
286
+ class WatchCallbacks extends CommandBase {
287
+ /**
288
+ * Creates an instance of WatchCallbacks.
289
+ *
290
+ * @remarks
291
+ * This constructor does not require any parameters.
292
+ */
293
+ constructor() {
294
+ super();
295
+ this.data = {
296
+ action: 'watchCallbacks',
297
+ };
298
+ }
299
+ }
300
+
301
+ /**
302
+ * EventDispatcher is a class that manages event listeners and dispatches events to them.
303
+ */
304
+ class EventDispatcher {
305
+ constructor() {
306
+ /**
307
+ * Storage for callback listeners by message type.
308
+ */
309
+ this.listeners = [];
310
+ }
311
+ destroy() {
312
+ this.listeners = [];
313
+ }
314
+ /**
315
+ * Adds an event listener for receiving specific types of messages.
316
+ *
317
+ * @param messageType - The message type to listen for.
318
+ * @param callback - The callback function to execute when a message is received.
319
+ */
320
+ addEventListener(messageType, callback) {
321
+ this.listeners.push({ messageType, callback });
322
+ return this;
323
+ }
324
+ /**
325
+ * Dispatches an event to all listeners of a specific message type.
326
+ *
327
+ * @param messageType - The message type.
328
+ * @param data - The data associated with the event.
329
+ */
330
+ dispatchEvent(messageType, data) {
331
+ this.listeners
332
+ .filter((listener) => listener.messageType === messageType)
333
+ .forEach((listener) => listener.callback(data));
334
+ return this;
335
+ }
336
+ /**
337
+ * Removes an event listener for a specific type of message.
338
+ *
339
+ * @param messageType - The message type.
340
+ * @param callback - The callback function to remove.
341
+ */
342
+ removeEventListener(messageType, callback) {
343
+ this.listeners = this.listeners.filter((listener) => !(listener.messageType === messageType && listener.callback === callback));
344
+ return this;
345
+ }
346
+ }
347
+
348
+ /**
349
+ * Handles messaging between the host page and embedded MetaBox content.
350
+ * @internal Use {@link Communicator.createInstance} or the {@link integrateMetaBox} helper to instantiate.
351
+ */
352
+ class Communicator extends EventDispatcher {
353
+ /**
354
+ * Singleton reference to the current communicator instance.
355
+ */
356
+ static { this.instance = null; }
357
+ /**
358
+ * Constructs a Communicator, replacing any existing instance, and begins listening for messages.
359
+ * @internal
360
+ */
361
+ constructor() {
362
+ super();
363
+ /**
364
+ * Bound handler for incoming postMessage events.
365
+ */
366
+ this.binder = this.handleMessageReceived.bind(this, 'metaboxData');
367
+ Communicator.instance?.destroy();
368
+ Communicator.instance = this;
369
+ window.addEventListener('message', this.binder);
370
+ }
371
+ /**
372
+ * Listens for MetaBox to signal readiness, then initializes communicator.
373
+ * @param apiReadyCallback - Called with the new Communicator once MetaBox is loaded.
374
+ */
375
+ static createInstance(apiReadyCallback) {
376
+ const startHandler = (event) => {
377
+ const message = event.data;
378
+ if (message?.payload?.action === 'appLoaded') {
379
+ apiReadyCallback(new Communicator());
380
+ window.removeEventListener('message', startHandler);
381
+ }
382
+ };
383
+ window.addEventListener('message', startHandler);
384
+ }
385
+ /**
386
+ * Cleans up resources and stops listening for messages.
387
+ */
388
+ destroy() {
389
+ super.destroy();
390
+ window.removeEventListener('message', this.binder);
391
+ }
392
+ /**
393
+ * Posts a command to the MetaBox iframe.
394
+ * @param command - An action command containing data to send.
395
+ */
396
+ sendCommandToMetaBox(command) {
397
+ const { data } = command;
398
+ const iframe = document.getElementById('embeddedContent');
399
+ if (!iframe?.contentWindow) {
400
+ console.warn('MetaBox IFrame not found or not ready.');
401
+ return;
402
+ }
403
+ const message = {
404
+ host: 'metaBoxHost',
405
+ payload: { ...data },
406
+ };
407
+ // Replace '*' with a specific origin in production for better security.
408
+ iframe.contentWindow.postMessage(message, '*');
409
+ }
410
+ /**
411
+ * Registers an event listener for messages dispatched by MetaBox.
412
+ * @override
413
+ */
414
+ addEventListener(messageType, callback) {
415
+ return super.addEventListener(messageType, callback);
416
+ }
417
+ /**
418
+ * Dispatches a typed event to all registered listeners.
419
+ * @override
420
+ */
421
+ dispatchEvent(messageType, data) {
422
+ return super.dispatchEvent(messageType, data);
423
+ }
424
+ /**
425
+ * Removes a previously registered event listener.
426
+ * @override
427
+ */
428
+ removeEventListener(messageType, callback) {
429
+ return super.removeEventListener(messageType, callback);
430
+ }
431
+ /**
432
+ * Filters and dispatches incoming messages from MetaBox.
433
+ * @param messageType - Expected message type for filtering ('metaboxData').
434
+ * @param event - The postMessage event received on window.
435
+ */
436
+ handleMessageReceived(messageType, event) {
437
+ // Optionally validate event.origin for security.
438
+ if (messageType !== 'metaboxData' || event.data?.host !== 'metabox') {
439
+ return;
440
+ }
441
+ const { eventType, payload } = event.data.payload;
442
+ this.dispatchEvent(eventType, payload);
443
+ }
444
+ }
445
+
446
+ /**
447
+ * Integrates the MetaBox into the provided layout.
448
+ *
449
+ * @remarks
450
+ * This function injects an iframe into a specified container element in the DOM and initializes
451
+ * the communicator for interacting with the MetaBox embedded content.
452
+ *
453
+ * @param iframeSrc - The source URL of the MetaBox iframe.
454
+ * Additional url parameters:
455
+ * ```javascript
456
+ * sidebar=false - disables the internal MetaBox menu
457
+ * introImage=https://example.com/image.png - sets the intro image
458
+ * ```
459
+ * i.e. final link will look like https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id?sidebar=false&introImage=https://example.com/image.png
460
+ *
461
+ * @param containerId - The ID of the layout element. Defaults to 'embed3DSource'.
462
+ * @param apiReadyCallback
463
+ * @throws Error if the container element with the specified ID is not found.
464
+ *
465
+ * @example
466
+ * import {
467
+ * integrateMetaBox,
468
+ * } from '@3dsource/metabox-front-api';
469
+ *
470
+ * integrateMetaBox(
471
+ * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
472
+ * 'embed3DSource'
473
+ * );
474
+ */
475
+ function integrateMetaBox(iframeSrc, containerId = 'embed3DSource', apiReadyCallback) {
476
+ const container = document.getElementById(containerId);
477
+ if (!container) {
478
+ throw new Error(`Container element with id ${containerId} not found`);
479
+ }
480
+ Communicator.createInstance(apiReadyCallback);
481
+ const style = document.createElement('style');
482
+ style.innerHTML = `
483
+ #${containerId} {
484
+ width: 100%;
485
+ height: 100%;
486
+ overflow: hidden;
487
+ position: relative;
488
+ }
489
+ `;
490
+ document.head.appendChild(style);
491
+ const iframe = document.createElement('iframe');
492
+ iframe.setAttribute('referrerPolicy', 'no-referrer-when-downgrade');
493
+ iframe.setAttribute('id', 'embeddedContent');
494
+ iframe.style.border = '0';
495
+ iframe.style.width = '100%';
496
+ iframe.style.height = '100%';
497
+ iframe.style.overflow = 'hidden';
498
+ iframe.src = iframeSrc;
499
+ container.appendChild(iframe);
500
+ }
501
+
502
+ /**
503
+ * Wrapper helper function to use it with rxJs the same as `fromEvent` to listen to events from the Communicator.
504
+ * @param target
505
+ * @param eventName
506
+ */
507
+ function fromCommunicatorEvent(target, eventName) {
508
+ return fromEvent(target, eventName);
509
+ }
510
+
511
+ /**
512
+ * Saves an image by triggering a download.
513
+ *
514
+ * @remarks
515
+ * This function creates an anchor element, sets its `href` attribute to the provided image URL,
516
+ * and triggers a click event to initiate a download with the specified filename.
517
+ *
518
+ * @param imageUrl - The URL of the image to save.
519
+ * @param filename - The name of the file to save.
520
+ */
521
+ function saveImage(imageUrl, filename) {
522
+ const a = document.createElement('a');
523
+ a.href = imageUrl;
524
+ a.download = filename;
525
+ document.body.appendChild(a);
526
+ a.click();
527
+ document.body.removeChild(a);
528
+ }
529
+
530
+ /**
531
+ * Pauses execution for a specified duration.
532
+ *
533
+ * @remarks
534
+ * This function returns a promise that resolves after the given number of milliseconds.
535
+ *
536
+ * @param time - The time to sleep in milliseconds.
537
+ * @returns A promise that resolves after the specified duration.
538
+ */
539
+ function sleep(time) {
540
+ return new Promise((resolve) => setTimeout(resolve, time));
541
+ }
542
+
543
+ /**
544
+ * Sets the URL parameters based on the provided state.
545
+ *
546
+ * @remarks
547
+ * This function updates the current URL by replacing its search parameters with the key-value pairs from the provided state object.
548
+ *
549
+ * @param state - An object containing key-value pairs to set as URL parameters.
550
+ */
551
+ function setUrlParams(state) {
552
+ const url = new URL(window.location.href);
553
+ url.search = '';
554
+ Object.entries(state).forEach(([key, value]) => {
555
+ url.searchParams.set(key, value);
556
+ });
557
+ history.replaceState(null, '', url.toString());
558
+ }
559
+ /**
560
+ * Retrieves the URL parameters as an object.
561
+ *
562
+ * @remarks
563
+ * This function parses the current URL's search parameters and returns them as a key-value object.
564
+ *
565
+ * @returns An object containing the URL parameters.
566
+ */
567
+ function getUrlParams() {
568
+ const urlParams = new URLSearchParams(window.location.search);
569
+ const selections = {};
570
+ urlParams.forEach((value, key) => {
571
+ selections[key] = value;
572
+ });
573
+ return selections;
574
+ }
575
+
576
+ /**
577
+ * Generated bundle index. Do not edit.
578
+ */
579
+
580
+ export { CommandBase, Communicator, GetPdf, GetScreenshot, SendCommandToUnreal, SetEnvironment, SetEnvironmentMaterial, SetMaterial, SetProduct, ShowEmbeddedMenu, ShowOverlayInterface, UnrealCommand, WatchCallbacks, fromCommunicatorEvent, getUrlParams, integrateMetaBox, saveImage, setUrlParams, sleep };
581
+ //# sourceMappingURL=3dsource-metabox-front-api.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"3dsource-metabox-front-api.mjs","sources":["../../../../projects/3dsource/metabox-front-api/src/lib/actions/CommandBase.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/ShowOverlayInterface.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/ShowEmbeddedMenu.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/SetEnvironment.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/SetProduct.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/GetPdf.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/SetMaterial.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/SetEnvironmentMaterial.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/GetScreenshot.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/UnrealCommand.ts","../../../../projects/3dsource/metabox-front-api/src/lib/actions/WatchCallbacks.ts","../../../../projects/3dsource/metabox-front-api/src/lib/EventDispatcher.ts","../../../../projects/3dsource/metabox-front-api/src/lib/Communicator.ts","../../../../projects/3dsource/metabox-front-api/src/lib/integrateMetaBox.ts","../../../../projects/3dsource/metabox-front-api/src/lib/fromCommunicatorEvent.ts","../../../../projects/3dsource/metabox-front-api/src/lib/saveImage.ts","../../../../projects/3dsource/metabox-front-api/src/lib/sleep.ts","../../../../projects/3dsource/metabox-front-api/src/lib/UrlUtils.ts","../../../../projects/3dsource/metabox-front-api/src/3dsource-metabox-front-api.ts"],"sourcesContent":["import type { ToMetaBoxMessageEnvelope } from '../interfaces/ToMetaboxMessagePayloads';\n\n/**\n * Base class for commands sent to the MetaBox.\n */\nexport class CommandBase {\n data!: ToMetaBoxMessageEnvelope;\n}\n","import { CommandBase } from './CommandBase';\n\n/**\n * Represents a command to toggle the Unreal Overlay Interface Menu.\n *\n * @remarks\n * This action sends a message to the MetaBox API to toggle the visibility of the Unreal overlay UI.\n *\n * @example\n * import { ShowOverlayInterface,Communicator } from '@3dsource/metabox-front-api';\n *\n * //...Assume that the integration is already implemented\n * window.env3DSource.apiReady = (api:Communicator) => {\n * api.setCommandToMetaBox(new ShowOverlayInterface(true));\n * };\n */\nexport class ShowOverlayInterface extends CommandBase {\n /**\n * Creates an instance of ShowOverlayInterface.\n *\n * @param visible - A flag indicating whether the Unreal overlay UI should be visible.\n */\n constructor(visible: boolean) {\n super();\n this.data = {\n action: 'showOverlayInterface',\n payload: {\n visible,\n },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\n\n/**\n * Represents a command to toggle the Embedded MetaBox Menu.\n *\n * @example\n * import { ShowEmbeddedMenu,Communicator } from '@3dsource/metabox-front-api';\n *\n * //...Assume that the integration is already implemented\n * window.env3DSource.apiReady = (api:Communicator) => {\n * api.setCommandToMetaBox(new ShowEmbeddedMenu(true));\n * };\n */\nexport class ShowEmbeddedMenu extends CommandBase {\n /**\n * Creates an instance of ShowEmbeddedMenu.\n *\n * @param visible - A flag indicating whether the embedded menu should be visible.\n */\n constructor(visible: boolean) {\n super();\n this.data = {\n action: 'showEmbeddedMenu',\n payload: {\n visible,\n },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\n\n/**\n * Represents a command to set the environment by its ID.\n *\n * @example\n * import { SetEnvironment,Communicator } from '@3dsource/metabox-front-api';\n *\n * //...Assume that the integration is already implemented\n * window.env3DSource.apiReady = (api:Communicator) => {\n * // Change the environment to '55555555-1234-1234-1234-01234567890'\n * api.sendCommandToMetaBox(new SetEnvironment('55555555-1234-1234-1234-01234567890'));\n * };\n */\nexport class SetEnvironment extends CommandBase {\n /**\n * Creates an instance of SetEnvironment.\n *\n * @param environmentId - The environment ID.\n */\n constructor(environmentId: string) {\n super();\n this.data = {\n payload: {\n id: environmentId,\n },\n action: 'loadLevel',\n };\n }\n}\n","import { CommandBase } from './CommandBase';\n\n/**\n * Represents a command to set a product by its ID.\n *\n * @remarks\n * This action sends a message to the MetaBox API to set a product using the provided product ID.\n *\n * @example\n * import { SetProduct,Communicator } from '@3dsource/metabox-front-api';\n *\n * //...Assume that the integration is already implemented\n * window.env3DSource.apiReady = (api:Communicator) => {\n * api.setCommandToMetaBox(new SetProduct(\n * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3'\n * ));\n * };\n */\nexport class SetProduct extends CommandBase {\n /**\n * Creates an instance of SetProduct.\n *\n * @param productId - The product ID.\n */\n constructor(productId: string) {\n super();\n this.data = {\n payload: {\n productId,\n },\n action: 'setProduct',\n };\n }\n}\n","import { CommandBase } from './CommandBase';\n\n/**\n * Represents a command to get a PDF from Metabox.\n * @remarks\n * This class sends a message to the MetaBox API to generate a PDF based on the current configuration.\n * This action does not require any parameters.\n *\n * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.\n *\n * @example\n * import { GetPdf,Communicator } from '@3dsource/metabox-front-api';\n * window.env3DSource.apiReady = (api:Communicator) => {\n * api.sendCommandToMetaBox(new GetPdf());\n * };\n */\n\nexport class GetPdf extends CommandBase {\n /**\n * Creates an instance of GetPdf.\n *\n * @remarks\n * This constructor does not require any parameters.\n */\n constructor() {\n super();\n this.data = {\n action: 'getPdf',\n };\n }\n}\n","import { CommandBase } from './CommandBase';\n\n/**\n * Represents a command to set a material by its ID.\n *\n * @example\n * import { SetMaterial,Communicator } from '@3dsource/metabox-front-api';\n *\n * //...Assume that the integration is already implemented\n * window.env3DSource.apiReady = (api:Communicator) => {\n * api.sendCommandToMetaBox(new SetMaterial(\n * 'carpaint',\n * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',\n * ));\n * };\n */\nexport class SetMaterial extends CommandBase {\n /**\n * Creates an instance of SetMaterial.\n *\n * @param slotId - The slot ID.\n * @param materialId - The material ID.\n */\n constructor(slotId: string, materialId: string) {\n super();\n this.data = {\n payload: {\n slotId,\n materialId,\n },\n action: 'setMaterialById',\n };\n }\n}\n","import { CommandBase } from './CommandBase';\n\n/**\n * Represents a command to set an environment material by its ID.\n *\n * @example\n * import { SetEnvironmentMaterial,Communicator } from '@3dsource/metabox-front-api';\n *\n * //...Assume that the integration is already implemented\n * window.env3DSource.apiReady = (api:Communicator) => {\n * api.sendCommandToMetaBox(new SetEnvironmentMaterial(\n * 'carpaint',\n * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',\n * ));\n * };\n */\nexport class SetEnvironmentMaterial extends CommandBase {\n /**\n * Creates an instance of SetEnvironmentMaterial.\n *\n * @param slotId - The slot ID.\n * @param materialId - The material ID.\n */\n constructor(slotId: string, materialId: string) {\n super();\n this.data = {\n payload: {\n slotId,\n materialId,\n },\n action: 'setEnvironmentMaterialById',\n };\n }\n}\n","import { CommandBase } from './CommandBase';\n\n/**\n * Image format.\n * @remarks\n * This type represents the allowed image formats.\n */\nexport type MimeType = 'image/png' | 'image/jpeg' | 'image/webp';\n\n/**\n * Represents a command to get fast render.\n *\n * **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.\n *\n * @example\n * import { GetScreenshot,Communicator,saveImage } from '@3dsource/metabox-front-api';\n * window.env3DSource.apiReady = (api:Communicator) => {\n * // Listen for events from the MetaBox API\n * api.addEventListener('screenshot', (data) => {\n * // Process the fast render response\n * saveImage(data, 'Render.png');\n * });\n * api.sendCommandToMetaBox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));\n * };\n */\nexport class GetScreenshot extends CommandBase {\n /**\n * Constructs an instance of GetScreenshot.\n * @param mimeType - The output format.\n * @param size - Optional size in pixels.\n */\n constructor(mimeType: MimeType, size?: { x: number; y: number }) {\n super();\n this.data = {\n payload: {\n format: mimeType,\n size,\n },\n action: 'getScreenshot',\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport type { MetaBoxCommandPacket } from '@3dsource/types-unreal';\n\n/**\n * @internal\n * @hidden\n * Represents a command to send Unreal command.\n */\nexport class UnrealCommand extends CommandBase {\n constructor(payload: MetaBoxCommandPacket) {\n super();\n this.data = {\n payload,\n action: 'sendCommandToUnreal',\n };\n }\n}\n\n/**\n * @deprecated, use `UnrealCommand` instead.\n */\nexport const SendCommandToUnreal = UnrealCommand;\n","import { CommandBase } from './CommandBase';\n\n/**\n * @experimental\n * @internal\n * @hidden\n * @remarks\n * Represents a command to watch Unreal callbacks from Unreal engine.\n * Can be useful for custom solutions.\n */\nexport class WatchCallbacks extends CommandBase {\n /**\n * Creates an instance of WatchCallbacks.\n *\n * @remarks\n * This constructor does not require any parameters.\n */\n constructor() {\n super();\n this.data = {\n action: 'watchCallbacks',\n };\n }\n}\n","/**\n * Represents a callback listener for specific message types.\n */\ninterface Listener {\n messageType: string;\n callback: (data: unknown) => void;\n}\n\n/**\n * EventDispatcher is a class that manages event listeners and dispatches events to them.\n */\nexport class EventDispatcher {\n /**\n * Storage for callback listeners by message type.\n */\n listeners: Listener[] = [];\n\n destroy() {\n this.listeners = [];\n }\n\n /**\n * Adds an event listener for receiving specific types of messages.\n *\n * @param messageType - The message type to listen for.\n * @param callback - The callback function to execute when a message is received.\n */\n addEventListener(\n messageType: string,\n callback: (data: unknown) => void,\n ): this {\n this.listeners.push({ messageType, callback });\n return this;\n }\n\n /**\n * Dispatches an event to all listeners of a specific message type.\n *\n * @param messageType - The message type.\n * @param data - The data associated with the event.\n */\n dispatchEvent(messageType: string, data: unknown): this {\n this.listeners\n .filter((listener) => listener.messageType === messageType)\n .forEach((listener) => listener.callback(data));\n return this;\n }\n\n /**\n * Removes an event listener for a specific type of message.\n *\n * @param messageType - The message type.\n * @param callback - The callback function to remove.\n */\n removeEventListener(\n messageType: string,\n callback: (data: unknown) => void,\n ): this {\n this.listeners = this.listeners.filter(\n (listener) =>\n !(\n listener.messageType === messageType && listener.callback === callback\n ),\n );\n return this;\n }\n}\n","import { EventDispatcher } from './EventDispatcher';\nimport type { CommandBase } from './actions/CommandBase';\nimport type {\n FromMetaBoxApiEvents,\n FromMetaBoxMessage,\n FromMetaboxMessagePayloads,\n} from './interfaces/FromMetaboxMessagePayloads';\n\n/**\n * Handles messaging between the host page and embedded MetaBox content.\n * @internal Use {@link Communicator.createInstance} or the {@link integrateMetaBox} helper to instantiate.\n */\nexport class Communicator extends EventDispatcher {\n /**\n * Singleton reference to the current communicator instance.\n */\n public static instance: Communicator | null = null;\n /**\n * Bound handler for incoming postMessage events.\n */\n private binder = this.handleMessageReceived.bind(this, 'metaboxData');\n\n /**\n * Constructs a Communicator, replacing any existing instance, and begins listening for messages.\n * @internal\n */\n constructor() {\n super();\n Communicator.instance?.destroy();\n Communicator.instance = this;\n window.addEventListener('message', this.binder);\n }\n\n /**\n * Listens for MetaBox to signal readiness, then initializes communicator.\n * @param apiReadyCallback - Called with the new Communicator once MetaBox is loaded.\n */\n static createInstance(apiReadyCallback: (api: Communicator) => void): void {\n const startHandler = (event: MessageEvent): void => {\n const message = event.data as FromMetaBoxMessage;\n if (message?.payload?.action === 'appLoaded') {\n apiReadyCallback(new Communicator());\n window.removeEventListener('message', startHandler);\n }\n };\n\n window.addEventListener('message', startHandler);\n }\n\n /**\n * Cleans up resources and stops listening for messages.\n */\n public override destroy(): void {\n super.destroy();\n window.removeEventListener('message', this.binder);\n }\n\n /**\n * Posts a command to the MetaBox iframe.\n * @param command - An action command containing data to send.\n */\n public sendCommandToMetaBox<T extends CommandBase>(command: T): void {\n const { data } = command;\n const iframe = document.getElementById(\n 'embeddedContent',\n ) as HTMLIFrameElement;\n\n if (!iframe?.contentWindow) {\n console.warn('MetaBox IFrame not found or not ready.');\n return;\n }\n\n const message = {\n host: 'metaBoxHost',\n payload: { ...data },\n };\n\n // Replace '*' with a specific origin in production for better security.\n iframe.contentWindow.postMessage(message, '*');\n }\n\n /**\n * Registers an event listener for messages dispatched by MetaBox.\n * @override\n */\n override addEventListener<T extends FromMetaBoxApiEvents>(\n messageType: T,\n callback: (data: FromMetaboxMessagePayloads[T]) => void,\n ) {\n return super.addEventListener(\n messageType,\n callback as (data: unknown) => void,\n );\n }\n\n /**\n * Dispatches a typed event to all registered listeners.\n * @override\n */\n override dispatchEvent<T extends FromMetaBoxApiEvents>(\n messageType: T,\n data: FromMetaboxMessagePayloads[T],\n ) {\n return super.dispatchEvent(messageType, data);\n }\n\n /**\n * Removes a previously registered event listener.\n * @override\n */\n override removeEventListener<T extends FromMetaBoxApiEvents>(\n messageType: T,\n callback: (data: FromMetaboxMessagePayloads[T]) => void,\n ) {\n return super.removeEventListener(\n messageType,\n callback as (data: unknown) => void,\n );\n }\n\n /**\n * Filters and dispatches incoming messages from MetaBox.\n * @param messageType - Expected message type for filtering ('metaboxData').\n * @param event - The postMessage event received on window.\n */\n private handleMessageReceived<T extends FromMetaBoxApiEvents>(\n messageType: T | 'metaboxData',\n event: MessageEvent,\n ): void {\n // Optionally validate event.origin for security.\n if (messageType !== 'metaboxData' || event.data?.host !== 'metabox') {\n return;\n }\n\n const { eventType, payload } = event.data.payload;\n this.dispatchEvent(eventType as T, payload);\n }\n}\n","import { Communicator } from './Communicator';\n\n/**\n * Integrates the MetaBox into the provided layout.\n *\n * @remarks\n * This function injects an iframe into a specified container element in the DOM and initializes\n * the communicator for interacting with the MetaBox embedded content.\n *\n * @param iframeSrc - The source URL of the MetaBox iframe.\n * Additional url parameters:\n * ```javascript\n * sidebar=false - disables the internal MetaBox menu\n * introImage=https://example.com/image.png - sets the intro image\n * ```\n * i.e. final link will look like https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id?sidebar=false&introImage=https://example.com/image.png\n *\n * @param containerId - The ID of the layout element. Defaults to 'embed3DSource'.\n * @param apiReadyCallback\n * @throws Error if the container element with the specified ID is not found.\n *\n * @example\n * import {\n * integrateMetaBox,\n * } from '@3dsource/metabox-front-api';\n *\n * integrateMetaBox(\n * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',\n * 'embed3DSource'\n * );\n */\nexport function integrateMetaBox(\n iframeSrc: string,\n containerId = 'embed3DSource',\n apiReadyCallback: (api: Communicator) => void,\n): void {\n const container = document.getElementById(containerId);\n if (!container) {\n throw new Error(`Container element with id ${containerId} not found`);\n }\n\n Communicator.createInstance(apiReadyCallback);\n\n const style = document.createElement('style');\n style.innerHTML = `\n #${containerId} {\n width: 100%;\n height: 100%;\n overflow: hidden;\n position: relative;\n }\n `;\n document.head.appendChild(style);\n\n const iframe = document.createElement('iframe');\n iframe.setAttribute('referrerPolicy', 'no-referrer-when-downgrade');\n iframe.setAttribute('id', 'embeddedContent');\n iframe.style.border = '0';\n iframe.style.width = '100%';\n iframe.style.height = '100%';\n iframe.style.overflow = 'hidden';\n iframe.src = iframeSrc;\n container.appendChild(iframe);\n}\n","import type { Communicator } from './Communicator';\nimport type { FromMetaBoxApiEvents, FromMetaboxMessagePayloads } from './interfaces/FromMetaboxMessagePayloads';\nimport type { Observable } from 'rxjs';\nimport { fromEvent } from 'rxjs';\n\n/**\n * Wrapper helper function to use it with rxJs the same as `fromEvent` to listen to events from the Communicator.\n * @param target\n * @param eventName\n */\nexport function fromCommunicatorEvent<T extends FromMetaBoxApiEvents>(\n target: Communicator,\n eventName: T,\n) {\n return fromEvent(target, eventName) as Observable<\n FromMetaboxMessagePayloads[T]\n >;\n}\n","/**\n * Saves an image by triggering a download.\n *\n * @remarks\n * This function creates an anchor element, sets its `href` attribute to the provided image URL,\n * and triggers a click event to initiate a download with the specified filename.\n *\n * @param imageUrl - The URL of the image to save.\n * @param filename - The name of the file to save.\n */\nexport function saveImage(imageUrl: string, filename: string): void {\n const a = document.createElement('a');\n a.href = imageUrl;\n a.download = filename;\n document.body.appendChild(a);\n a.click();\n document.body.removeChild(a);\n}\n","/**\n * Pauses execution for a specified duration.\n *\n * @remarks\n * This function returns a promise that resolves after the given number of milliseconds.\n *\n * @param time - The time to sleep in milliseconds.\n * @returns A promise that resolves after the specified duration.\n */\nexport function sleep(time: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, time));\n}\n","/**\n * Sets the URL parameters based on the provided state.\n *\n * @remarks\n * This function updates the current URL by replacing its search parameters with the key-value pairs from the provided state object.\n *\n * @param state - An object containing key-value pairs to set as URL parameters.\n */\nexport function setUrlParams(state: Record<string, string>): void {\n const url = new URL(window.location.href);\n url.search = '';\n Object.entries(state).forEach(([key, value]) => {\n url.searchParams.set(key, value);\n });\n history.replaceState(null, '', url.toString());\n}\n\n/**\n * Retrieves the URL parameters as an object.\n *\n * @remarks\n * This function parses the current URL's search parameters and returns them as a key-value object.\n *\n * @returns An object containing the URL parameters.\n */\nexport function getUrlParams(): Record<string, string> {\n const urlParams = new URLSearchParams(window.location.search);\n const selections: Record<string, string> = {};\n urlParams.forEach((value, key) => {\n selections[key] = value;\n });\n return selections;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAEA;;AAEG;MACU,WAAW,CAAA;AAEvB;;ACLD;;;;;;;;;;;;;AAaG;AACG,MAAO,oBAAqB,SAAQ,WAAW,CAAA;AACnD;;;;AAIG;AACH,IAAA,WAAA,CAAY,OAAgB,EAAA;AAC1B,QAAA,KAAK,EAAE;QACP,IAAI,CAAC,IAAI,GAAG;AACV,YAAA,MAAM,EAAE,sBAAsB;AAC9B,YAAA,OAAO,EAAE;gBACP,OAAO;AACR,aAAA;SACF;;AAEJ;;AC7BD;;;;;;;;;;AAUG;AACG,MAAO,gBAAiB,SAAQ,WAAW,CAAA;AAC/C;;;;AAIG;AACH,IAAA,WAAA,CAAY,OAAgB,EAAA;AAC1B,QAAA,KAAK,EAAE;QACP,IAAI,CAAC,IAAI,GAAG;AACV,YAAA,MAAM,EAAE,kBAAkB;AAC1B,YAAA,OAAO,EAAE;gBACP,OAAO;AACR,aAAA;SACF;;AAEJ;;AC1BD;;;;;;;;;;;AAWG;AACG,MAAO,cAAe,SAAQ,WAAW,CAAA;AAC7C;;;;AAIG;AACH,IAAA,WAAA,CAAY,aAAqB,EAAA;AAC/B,QAAA,KAAK,EAAE;QACP,IAAI,CAAC,IAAI,GAAG;AACV,YAAA,OAAO,EAAE;AACP,gBAAA,EAAE,EAAE,aAAa;AAClB,aAAA;AACD,YAAA,MAAM,EAAE,WAAW;SACpB;;AAEJ;;AC3BD;;;;;;;;;;;;;;;AAeG;AACG,MAAO,UAAW,SAAQ,WAAW,CAAA;AACzC;;;;AAIG;AACH,IAAA,WAAA,CAAY,SAAiB,EAAA;AAC3B,QAAA,KAAK,EAAE;QACP,IAAI,CAAC,IAAI,GAAG;AACV,YAAA,OAAO,EAAE;gBACP,SAAS;AACV,aAAA;AACD,YAAA,MAAM,EAAE,YAAY;SACrB;;AAEJ;;AC/BD;;;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