@3dsource/metabox-front-api 2.0.2 → 2.0.4-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +257 -512
- package/fesm2022/3dsource-metabox-front-api.mjs +85 -52
- package/fesm2022/3dsource-metabox-front-api.mjs.map +1 -1
- package/index.d.ts +70 -44
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -6,11 +6,20 @@ declare const Metabox_V2 = "metabox_v2";
|
|
|
6
6
|
declare const MetaboxHost_V2 = "metaboxHost_v2";
|
|
7
7
|
declare const MetaboxData_V2 = "metaboxData_v2";
|
|
8
8
|
declare const AppLoaded_V2 = "appLoaded_v2";
|
|
9
|
+
declare const MetaboxDomain = "metabox.3dsource.com";
|
|
10
|
+
declare const BasicRouteUrl = "metabox-configurator/basic";
|
|
9
11
|
|
|
10
|
-
declare const VERSION = "2.0.
|
|
12
|
+
declare const VERSION = "2.0.4-dev.0";
|
|
11
13
|
|
|
12
14
|
type FromMetaboxApiAction = 'bridge' | typeof AppLoaded_V2;
|
|
13
15
|
|
|
16
|
+
interface IntegrateMetaboxConfig {
|
|
17
|
+
standalone?: boolean;
|
|
18
|
+
loadingImage?: string;
|
|
19
|
+
introVideo?: string;
|
|
20
|
+
introImage?: string;
|
|
21
|
+
domain?: string;
|
|
22
|
+
}
|
|
14
23
|
interface MetaboxCommandConfig {
|
|
15
24
|
standalone?: boolean;
|
|
16
25
|
hostUrl: string;
|
|
@@ -22,7 +31,7 @@ declare const MetaboxBasicConfiguratorActions: {
|
|
|
22
31
|
readonly setEnvironment: "setEnvironment";
|
|
23
32
|
readonly setEnvironmentMaterialById: "setEnvironmentMaterialById";
|
|
24
33
|
readonly setProduct: "setProduct";
|
|
25
|
-
readonly
|
|
34
|
+
readonly setProductMaterialById: "setProductMaterialById";
|
|
26
35
|
readonly getPdf: "getPdf";
|
|
27
36
|
readonly getCallToActionInformation: "getCallToActionInformation";
|
|
28
37
|
readonly getScreenshot: "getScreenshot";
|
|
@@ -68,7 +77,7 @@ interface ToMetaboxMessagePayloads {
|
|
|
68
77
|
y: number;
|
|
69
78
|
};
|
|
70
79
|
};
|
|
71
|
-
[MetaboxBasicConfiguratorActions.
|
|
80
|
+
[MetaboxBasicConfiguratorActions.setProductMaterialById]: {
|
|
72
81
|
slotId: string;
|
|
73
82
|
materialId: string;
|
|
74
83
|
};
|
|
@@ -504,7 +513,7 @@ interface MCAppLoaded {
|
|
|
504
513
|
eventType?: unknown;
|
|
505
514
|
payload: {
|
|
506
515
|
appId: string;
|
|
507
|
-
version
|
|
516
|
+
version?: string;
|
|
508
517
|
};
|
|
509
518
|
}
|
|
510
519
|
/**
|
|
@@ -573,7 +582,7 @@ declare class EventDispatcher {
|
|
|
573
582
|
|
|
574
583
|
/**
|
|
575
584
|
* Handles messaging between the host page and embedded Metabox content.
|
|
576
|
-
* @internal Use {@link Communicator.createInstance} or the {@link
|
|
585
|
+
* @internal Use {@link Communicator.createInstance} or the {@link integrateMetabox} helper to instantiate.
|
|
577
586
|
*/
|
|
578
587
|
declare class Communicator extends EventDispatcher {
|
|
579
588
|
/**
|
|
@@ -604,7 +613,7 @@ declare class Communicator extends EventDispatcher {
|
|
|
604
613
|
* Posts a command to the Metabox iframe.
|
|
605
614
|
* @param command - An action command containing data to send.
|
|
606
615
|
*/
|
|
607
|
-
|
|
616
|
+
sendCommandToMetabox<T extends CommandBase>(command: T): void;
|
|
608
617
|
/**
|
|
609
618
|
* Registers an event listener for messages dispatched by to the Metabox.
|
|
610
619
|
* @override
|
|
@@ -629,35 +638,50 @@ declare class Communicator extends EventDispatcher {
|
|
|
629
638
|
}
|
|
630
639
|
|
|
631
640
|
/**
|
|
632
|
-
* Integrates Metabox Basic Configurator into the
|
|
641
|
+
* Integrates the Metabox Basic Configurator into the page by injecting an iframe and
|
|
642
|
+
* initializing a Communicator instance for host-to-iframe messaging.
|
|
633
643
|
*
|
|
634
644
|
* @remarks
|
|
635
|
-
*
|
|
636
|
-
* the
|
|
645
|
+
* - Builds a secure iframe URL using the provided configuratorId and config options.
|
|
646
|
+
* - Ensures the resulting URL uses HTTPS and that the target container exists.
|
|
647
|
+
* - Removes any previously embedded iframe with id "embeddedContent" before inserting a new one.
|
|
648
|
+
*
|
|
649
|
+
* @param {string} configuratorId - The Basic Configurator ID (not a full URL). It is appended to
|
|
650
|
+
* `https://{domain}/metabox-configurator/basic/{configuratorId}` to form the iframe src.
|
|
637
651
|
*
|
|
638
|
-
* @param {string}
|
|
639
|
-
* Additional url parameters:
|
|
640
|
-
* ```javascript
|
|
641
|
-
* introImage=https://example.com/image.png - sets the intro image
|
|
642
|
-
* ```
|
|
643
|
-
* i.e., a final link will look like https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id?introImage=https://example.com/image.png
|
|
652
|
+
* @param {string} [containerId='embed3DSource'] - The id of the container element where the iframe will be injected.
|
|
644
653
|
*
|
|
645
|
-
* @param {
|
|
646
|
-
*
|
|
647
|
-
* @param {
|
|
648
|
-
*
|
|
654
|
+
* @param {(api: Communicator) => void} apiReadyCallback - Called when the Communicator instance is created on the host side.
|
|
655
|
+
*
|
|
656
|
+
* @param {IntegrateMetaboxConfig} config - Optional configuration used to build the iframe URL and initialize the communicator.
|
|
657
|
+
* Supported fields:
|
|
658
|
+
* - standalone?: boolean — if true, disables Metabox custom template and related logic.
|
|
659
|
+
* - introImage?: string — URL to an image shown on the intro screen (added as ?introImage=...).
|
|
660
|
+
* - introVideo?: string — URL to a video shown on the intro screen (added as ?introVideo=...).
|
|
661
|
+
* - loadingImage?: string — URL to an image displayed while loading (added as ?loadingImage=...).
|
|
662
|
+
* - domain?: string — custom domain for testing (defaults to metabox.3dsource.com). HTTPS is enforced.
|
|
663
|
+
*
|
|
664
|
+
* @throws Error If configuratorId or containerId are empty strings.
|
|
665
|
+
* @throws Error If the computed iframe URL is invalid or does not use HTTPS.
|
|
666
|
+
* @throws Error If the container element with the provided id cannot be found.
|
|
649
667
|
*
|
|
650
668
|
* @example
|
|
651
|
-
* import {
|
|
652
|
-
* integrateMetaBox,
|
|
653
|
-
* } from '@3dsource/metabox-front-api';
|
|
669
|
+
* import { integrateMetabox } from '@3dsource/metabox-front-api';
|
|
654
670
|
*
|
|
655
|
-
*
|
|
656
|
-
* '
|
|
657
|
-
* 'embed3DSource'
|
|
671
|
+
* integrateMetabox(
|
|
672
|
+
* 'configurator-id',
|
|
673
|
+
* 'embed3DSource',
|
|
674
|
+
* (api) => {
|
|
675
|
+
* // Communicator is ready to use
|
|
676
|
+
* },
|
|
677
|
+
* {
|
|
678
|
+
* standalone: false,
|
|
679
|
+
* introImage: 'https://example.com/intro.png',
|
|
680
|
+
* loadingImage: 'https://example.com/loading.png',
|
|
681
|
+
* },
|
|
658
682
|
* );
|
|
659
683
|
*/
|
|
660
|
-
declare function
|
|
684
|
+
declare function integrateMetabox(configuratorId: string, containerId: string | undefined, apiReadyCallback: (api: Communicator) => void, config?: IntegrateMetaboxConfig): void;
|
|
661
685
|
|
|
662
686
|
/**
|
|
663
687
|
* Saves an image by triggering a download.
|
|
@@ -690,6 +714,8 @@ declare function setUrlParams(state: Record<string, string>): void;
|
|
|
690
714
|
*/
|
|
691
715
|
declare function getUrlParams(): Record<string, string>;
|
|
692
716
|
|
|
717
|
+
declare const prepareIframeSrc: (configuratorId: string, config?: IntegrateMetaboxConfig) => string;
|
|
718
|
+
|
|
693
719
|
/**
|
|
694
720
|
* Wrapper helper function to use it with rxJs the same as `fromEvent` to listen to events from the Communicator.
|
|
695
721
|
* @param {Communicator} target
|
|
@@ -722,7 +748,7 @@ declare class MetaboxConfig extends CommandBase {
|
|
|
722
748
|
* @example
|
|
723
749
|
* import { GetPdf, Communicator } from '@3dsource/metabox-front-api';
|
|
724
750
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
725
|
-
* api.
|
|
751
|
+
* api.sendCommandToMetabox(new GetPdf());
|
|
726
752
|
* };
|
|
727
753
|
*/
|
|
728
754
|
declare class GetPdf extends CommandBase {
|
|
@@ -746,7 +772,7 @@ declare class GetPdf extends CommandBase {
|
|
|
746
772
|
* @example
|
|
747
773
|
* import { GetCallToActionInformation, Communicator } from '@3dsource/metabox-front-api';
|
|
748
774
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
749
|
-
* api.
|
|
775
|
+
* api.sendCommandToMetabox(new GetCallToActionInformation());
|
|
750
776
|
* };
|
|
751
777
|
*/
|
|
752
778
|
declare class GetCallToActionInformation extends CommandBase {
|
|
@@ -770,7 +796,7 @@ declare class GetCallToActionInformation extends CommandBase {
|
|
|
770
796
|
* @example
|
|
771
797
|
* import { ResetCamera, Communicator } from '@3dsource/metabox-front-api';
|
|
772
798
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
773
|
-
* api.
|
|
799
|
+
* api.sendCommandToMetabox(new ResetCamera());
|
|
774
800
|
* };
|
|
775
801
|
*/
|
|
776
802
|
declare class ResetCamera extends CommandBase {
|
|
@@ -793,8 +819,8 @@ declare class ResetCamera extends CommandBase {
|
|
|
793
819
|
* @example
|
|
794
820
|
* import { ApplyZoom, Communicator } from '@3dsource/metabox-front-api';
|
|
795
821
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
796
|
-
* api.
|
|
797
|
-
* api.
|
|
822
|
+
* api.sendCommandToMetabox(new ApplyZoom(10));
|
|
823
|
+
* api.sendCommandToMetabox(new ApplyZoom(-10));
|
|
798
824
|
* };
|
|
799
825
|
*/
|
|
800
826
|
declare class ApplyZoom extends CommandBase {
|
|
@@ -819,7 +845,7 @@ declare class ApplyZoom extends CommandBase {
|
|
|
819
845
|
* ```typescript
|
|
820
846
|
* import { InitShowcase, Communicator } from '@3dsource/metabox-front-api';
|
|
821
847
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
822
|
-
* api.
|
|
848
|
+
* api.sendCommandToMetabox(new InitShowcase());
|
|
823
849
|
* };
|
|
824
850
|
*/
|
|
825
851
|
declare class InitShowcase extends CommandBase {
|
|
@@ -842,7 +868,7 @@ declare class InitShowcase extends CommandBase {
|
|
|
842
868
|
* @example
|
|
843
869
|
* import { PlayShowcase, Communicator } from '@3dsource/metabox-front-api';
|
|
844
870
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
845
|
-
* api.
|
|
871
|
+
* api.sendCommandToMetabox(new PlayShowcase());
|
|
846
872
|
* };
|
|
847
873
|
*/
|
|
848
874
|
declare class PlayShowcase extends CommandBase {
|
|
@@ -874,7 +900,7 @@ declare class UnrealCommand extends CommandBase {
|
|
|
874
900
|
* @example
|
|
875
901
|
* import { PauseShowcase, Communicator } from '@3dsource/metabox-front-api';
|
|
876
902
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
877
|
-
* api.
|
|
903
|
+
* api.sendCommandToMetabox(new PauseShowcase());
|
|
878
904
|
* };
|
|
879
905
|
*/
|
|
880
906
|
declare class PauseShowcase extends CommandBase {
|
|
@@ -897,7 +923,7 @@ declare class PauseShowcase extends CommandBase {
|
|
|
897
923
|
* @example
|
|
898
924
|
* import { StopShowcase, Communicator } from '@3dsource/metabox-front-api';
|
|
899
925
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
900
|
-
* api.
|
|
926
|
+
* api.sendCommandToMetabox(new StopShowcase());
|
|
901
927
|
* };
|
|
902
928
|
*/
|
|
903
929
|
declare class StopShowcase extends CommandBase {
|
|
@@ -929,7 +955,7 @@ type MimeType = 'image/png' | 'image/jpeg' | 'image/webp';
|
|
|
929
955
|
* // Process the get screenshot response
|
|
930
956
|
* saveImage(data, 'Render.png');
|
|
931
957
|
* });
|
|
932
|
-
* api.
|
|
958
|
+
* api.sendCommandToMetabox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
|
|
933
959
|
* };
|
|
934
960
|
*/
|
|
935
961
|
declare class GetScreenshot extends CommandBase {
|
|
@@ -973,19 +999,19 @@ declare class SetProduct extends CommandBase {
|
|
|
973
999
|
* Represents a command to set a material by its slot ID and Material ID.
|
|
974
1000
|
*
|
|
975
1001
|
* @example
|
|
976
|
-
* import {
|
|
1002
|
+
* import { SetProductMaterial, Communicator } from '@3dsource/metabox-front-api';
|
|
977
1003
|
*
|
|
978
1004
|
* //...Assume that the integration is already implemented
|
|
979
1005
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
980
|
-
* api.
|
|
1006
|
+
* api.sendCommandToMetabox(new SetProductMaterial(
|
|
981
1007
|
* 'carpaint',
|
|
982
1008
|
* 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
|
|
983
1009
|
* ));
|
|
984
1010
|
* };
|
|
985
1011
|
*/
|
|
986
|
-
declare class
|
|
1012
|
+
declare class SetProductMaterial extends CommandBase {
|
|
987
1013
|
/**
|
|
988
|
-
* Creates an instance of
|
|
1014
|
+
* Creates an instance of SetProductMaterial.
|
|
989
1015
|
*
|
|
990
1016
|
* @param {string} slotId - The slot ID.
|
|
991
1017
|
* @param {string} materialId - The material ID.
|
|
@@ -1002,7 +1028,7 @@ declare class SetMaterial extends CommandBase {
|
|
|
1002
1028
|
* //...Assume that the integration is already implemented
|
|
1003
1029
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
1004
1030
|
* // Change the environment to '55555555-1234-1234-1234-01234567890'
|
|
1005
|
-
* api.
|
|
1031
|
+
* api.sendCommandToMetabox(new SetEnvironment('55555555-1234-1234-1234-01234567890'));
|
|
1006
1032
|
* };
|
|
1007
1033
|
*/
|
|
1008
1034
|
declare class SetEnvironment extends CommandBase {
|
|
@@ -1022,7 +1048,7 @@ declare class SetEnvironment extends CommandBase {
|
|
|
1022
1048
|
*
|
|
1023
1049
|
* //...Assume that the integration is already implemented
|
|
1024
1050
|
* window.env3DSource.apiReady = (api: Communicator) => {
|
|
1025
|
-
* api.
|
|
1051
|
+
* api.sendCommandToMetabox(new SetEnvironmentMaterial(
|
|
1026
1052
|
* 'carpaint',
|
|
1027
1053
|
* 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
|
|
1028
1054
|
* ));
|
|
@@ -1099,5 +1125,5 @@ declare class WatchCallbacks extends CommandBase {
|
|
|
1099
1125
|
constructor();
|
|
1100
1126
|
}
|
|
1101
1127
|
|
|
1102
|
-
export { AppLoaded_V2, ApplyZoom, CommandBase, Communicator, EventDispatcher, GetCallToActionInformation, GetPdf, GetScreenshot, InitShowcase, MetaboxBasicConfiguratorActions, MetaboxConfig, MetaboxData_V2, MetaboxHost_V2, Metabox_V2, PauseShowcase, PlayShowcase, ResetCamera, SetEnvironment, SetEnvironmentMaterial,
|
|
1103
|
-
export type { ApplicationDeviceTypes, ConfiguratorEnvelope, Cta, EcomConfigurator, Environment, FromMetaBoxAPIEnvelope, FromMetaBoxApiEvents, FromMetaBoxMessage, FromMetaboxApiAction, FromMetaboxMessagePayloads, Listener, MCAppLoaded, Material, MetaBoxApiEnvelope, MetaProperty, MetaboxCommandConfig, MetaboxEnvironment, MimeType, Product, SelectedIds, ShowCaseStatus, Showcase, Slot, Thumbnail, Timecode, ToMetaBoxActions, ToMetaBoxMessage, ToMetaBoxMessageEnvelope, ToMetaboxMessagePayload, ToMetaboxMessagePayloads, UniversalConfigurator, UniversalConfiguratorEnvironment, UniversalConfiguratorProduct, VideoResolution };
|
|
1128
|
+
export { AppLoaded_V2, ApplyZoom, BasicRouteUrl, CommandBase, Communicator, EventDispatcher, GetCallToActionInformation, GetPdf, GetScreenshot, InitShowcase, MetaboxBasicConfiguratorActions, MetaboxConfig, MetaboxData_V2, MetaboxDomain, MetaboxHost_V2, Metabox_V2, PauseShowcase, PlayShowcase, ResetCamera, SetEnvironment, SetEnvironmentMaterial, SetProduct, SetProductMaterial, ShowEmbeddedMenu, ShowOverlayInterface, StopShowcase, UnrealCommand, VERSION, WatchCallbacks, fromCommunicatorEvent, getUrlParams, integrateMetabox, prepareIframeSrc, saveImage, setUrlParams };
|
|
1129
|
+
export type { ApplicationDeviceTypes, ConfiguratorEnvelope, Cta, EcomConfigurator, Environment, FromMetaBoxAPIEnvelope, FromMetaBoxApiEvents, FromMetaBoxMessage, FromMetaboxApiAction, FromMetaboxMessagePayloads, IntegrateMetaboxConfig, Listener, MCAppLoaded, Material, MetaBoxApiEnvelope, MetaProperty, MetaboxCommandConfig, MetaboxEnvironment, MimeType, Product, SelectedIds, ShowCaseStatus, Showcase, Slot, Thumbnail, Timecode, ToMetaBoxActions, ToMetaBoxMessage, ToMetaBoxMessageEnvelope, ToMetaboxMessagePayload, ToMetaboxMessagePayloads, UniversalConfigurator, UniversalConfiguratorEnvironment, UniversalConfiguratorProduct, VideoResolution };
|