@3dsource/metabox-front-api 0.0.2 → 0.0.4
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 +169 -21
- package/dist/actions/ApiAction.d.ts +2 -1
- package/dist/actions/GetFastRender.d.ts +36 -5
- package/dist/actions/GetFastRender.js +38 -7
- package/dist/actions/GetPdf.d.ts +25 -1
- package/dist/actions/GetPdf.js +27 -3
- package/dist/actions/SetEnvironment.d.ts +17 -1
- package/dist/actions/SetEnvironment.js +19 -3
- package/dist/actions/SetMaterial.d.ts +32 -0
- package/dist/actions/SetMaterial.js +34 -2
- package/dist/actions/SetProduct.js +2 -2
- package/dist/actions/ShowEmbeddedMenu.js +2 -2
- package/dist/actions/WatchCallbacks.d.ts +16 -0
- package/dist/actions/WatchCallbacks.js +27 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +2 -1
- package/dist/interfaces/FromMetaboxMessagePayloads.d.ts +130 -0
- package/dist/{lib/MetaBoxApiAction.js → interfaces/FromMetaboxMessagePayloads.js} +1 -18
- package/dist/interfaces/ToMetaboxMessagePayloads.d.ts +53 -0
- package/dist/interfaces/ToMetaboxMessagePayloads.js +12 -0
- package/dist/interfaces/UniversalConfigurator.d.ts +101 -81
- package/dist/lib/initializeCommunicator.d.ts +13 -12
- package/dist/lib/initializeCommunicator.js +23 -21
- package/dist/lib/integrateMetaBox.d.ts +11 -0
- package/dist/lib/integrateMetaBox.js +13 -2
- package/package.json +3 -2
- package/dist/interfaces/metabox-message.interface.d.ts +0 -10
- package/dist/interfaces/metabox-message.interface.js +0 -6
- package/dist/lib/MetaBoxApiAction.d.ts +0 -92
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,15 @@ export { SetProduct } from './actions/SetProduct';
|
|
|
4
4
|
export { GetPdf } from './actions/GetPdf';
|
|
5
5
|
export { SetMaterial } from './actions/SetMaterial';
|
|
6
6
|
export { GetFastRender } from './actions/GetFastRender';
|
|
7
|
-
export
|
|
7
|
+
export { MimeType } from './actions/GetFastRender';
|
|
8
8
|
export * from './lib/integrateMetaBox';
|
|
9
|
+
export * from './lib/initializeCommunicator';
|
|
9
10
|
export * from './lib/saveImage';
|
|
10
11
|
export * from './lib/sleep';
|
|
11
12
|
export * from './lib/UrlUtils';
|
|
13
|
+
export * from './interfaces/UniversalConfigurator';
|
|
14
|
+
export { ToMetaboxMessagePayloads } from './interfaces/ToMetaboxMessagePayloads';
|
|
15
|
+
export { FromMetaBoxAPIEnvelope } from './interfaces/FromMetaboxMessagePayloads';
|
|
16
|
+
export { MetaBoxApiEnvelope } from './interfaces/FromMetaboxMessagePayloads';
|
|
17
|
+
export { FromMetaBoxApiEvents } from './interfaces/FromMetaboxMessagePayloads';
|
|
18
|
+
export { FromMetaboxMessagePayloads } from './interfaces/FromMetaboxMessagePayloads';
|
package/dist/index.js
CHANGED
|
@@ -14,8 +14,9 @@ export { SetProduct } from './actions/SetProduct';
|
|
|
14
14
|
export { GetPdf } from './actions/GetPdf';
|
|
15
15
|
export { SetMaterial } from './actions/SetMaterial';
|
|
16
16
|
export { GetFastRender } from './actions/GetFastRender';
|
|
17
|
-
export * from './lib/MetaBoxApiAction';
|
|
18
17
|
export * from './lib/integrateMetaBox';
|
|
18
|
+
export * from './lib/initializeCommunicator';
|
|
19
19
|
export * from './lib/saveImage';
|
|
20
20
|
export * from './lib/sleep';
|
|
21
21
|
export * from './lib/UrlUtils';
|
|
22
|
+
export * from './interfaces/UniversalConfigurator';
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { ConfiguratorEnvelope } from './UniversalConfigurator';
|
|
2
|
+
export declare const FromMetaboxApiActions: {
|
|
3
|
+
readonly bridge: "bridge";
|
|
4
|
+
readonly unrealCallback: "unrealCallback";
|
|
5
|
+
readonly unrealFeatureBridge: "unrealFeatureBridge";
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
|
|
8
|
+
*/
|
|
9
|
+
readonly configuratorDataWithStateBridge: "configuratorDataWithStateBridge";
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
|
|
12
|
+
*/
|
|
13
|
+
readonly configuratorDataBridge: "configuratorDataBridge";
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
|
|
16
|
+
*/
|
|
17
|
+
readonly menuDataBridge: "menuDataBridge";
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
|
|
20
|
+
*/
|
|
21
|
+
readonly flatMenuDataBridge: "flatMenuDataBridge";
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated, use Bridge with isFullscreen
|
|
24
|
+
*/
|
|
25
|
+
readonly fullScreenBridge: "fullScreenBridge";
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated, use Bridge with streamResolution
|
|
28
|
+
*/
|
|
29
|
+
readonly videoSize: "videoSize";
|
|
30
|
+
/**
|
|
31
|
+
* Used in platform, must be removed in future
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated\
|
|
35
|
+
*/
|
|
36
|
+
readonly unrealResponse: "unrealResponse";
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated\
|
|
39
|
+
*/
|
|
40
|
+
readonly getFastRender: "getFastRender";
|
|
41
|
+
readonly appLoaded: "appLoaded";
|
|
42
|
+
};
|
|
43
|
+
export type FromMetaBoxAction = (typeof FromMetaboxApiActions)[keyof typeof FromMetaboxApiActions];
|
|
44
|
+
/**
|
|
45
|
+
* @internal
|
|
46
|
+
* Used for signaling that the app is loaded and ready to open api.
|
|
47
|
+
*/
|
|
48
|
+
interface MCAppLoaded {
|
|
49
|
+
action: string;
|
|
50
|
+
eventType?: unknown;
|
|
51
|
+
payload?: unknown;
|
|
52
|
+
}
|
|
53
|
+
export interface FromMetaboxMessagePayloads {
|
|
54
|
+
/**
|
|
55
|
+
* Dispatches Every time the configurator data is updated.
|
|
56
|
+
* I.e. when the user changes the configuration. (Material, Product, Environment)
|
|
57
|
+
*/
|
|
58
|
+
basicConfiguratorDataWithState: ConfiguratorEnvelope;
|
|
59
|
+
/**
|
|
60
|
+
* @internal
|
|
61
|
+
* Dispatches Every time when configurator connected/disconnected with Unreal Engine.
|
|
62
|
+
*/
|
|
63
|
+
dataChannelConnected: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Dispatches Every time when Unreal Viewport is visible/hidden.
|
|
66
|
+
*/
|
|
67
|
+
viewportReady: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Dispatches Every time viewport shows/hides its internal menu .
|
|
70
|
+
*/
|
|
71
|
+
isFullscreen: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Dispatches at the moment while configurator loads. Shows status information.
|
|
74
|
+
*/
|
|
75
|
+
statusMessage: string | null;
|
|
76
|
+
/**
|
|
77
|
+
* @internal
|
|
78
|
+
* @experimental
|
|
79
|
+
* Dispatches every time when freeze-frame is arrived or updated.
|
|
80
|
+
*/
|
|
81
|
+
freezeFrame: {
|
|
82
|
+
dataUrl: string | null;
|
|
83
|
+
progress: number | null;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* @internal
|
|
87
|
+
* Dispatches every Unreal is sending command callback.
|
|
88
|
+
* Works only after new WatchCallbacks() command is sent.
|
|
89
|
+
*/
|
|
90
|
+
unrealCallback: object;
|
|
91
|
+
/**
|
|
92
|
+
* Dispatches every time when Unreal is sending ordered render with new GetFastRender() command.
|
|
93
|
+
*/
|
|
94
|
+
getFastRender: string | null;
|
|
95
|
+
/**
|
|
96
|
+
* @internal
|
|
97
|
+
* @callback
|
|
98
|
+
* Dispatches every Unreal state is changing, including all unreal module state.
|
|
99
|
+
*/
|
|
100
|
+
unrealFeature: object;
|
|
101
|
+
/**
|
|
102
|
+
* Dispatches every time when Unreal is changing its video stream size.
|
|
103
|
+
*/
|
|
104
|
+
streamResolution: {
|
|
105
|
+
width: number;
|
|
106
|
+
number: number;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export type FromMetaBoxApiEvents = keyof FromMetaboxMessagePayloads;
|
|
110
|
+
/**
|
|
111
|
+
* @internal
|
|
112
|
+
* This creates an all event envelopes defined in MetaBoxAPIPayloads.
|
|
113
|
+
*/
|
|
114
|
+
export interface MetaBoxApiEnvelope<T extends FromMetaBoxApiEvents> {
|
|
115
|
+
action: 'bridge';
|
|
116
|
+
eventType: T;
|
|
117
|
+
payload: FromMetaboxMessagePayloads[T];
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* @internal
|
|
121
|
+
* This creates a union of all event envelopes defined in MetaBoxAPIPayloads.
|
|
122
|
+
*/
|
|
123
|
+
export type FromMetaBoxAPIEnvelope = {
|
|
124
|
+
[K in keyof FromMetaboxMessagePayloads]: MetaBoxApiEnvelope<K>;
|
|
125
|
+
}[keyof FromMetaboxMessagePayloads] | MCAppLoaded;
|
|
126
|
+
export interface FromMetaBoxMessage {
|
|
127
|
+
host: 'metabox';
|
|
128
|
+
payload: FromMetaBoxAPIEnvelope;
|
|
129
|
+
}
|
|
130
|
+
export {};
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Copyright (c) 2025.
|
|
3
|
-
* 3DSource.com, Sergii Karanda steve@3dsource.com
|
|
4
|
-
* All Rights Reserved
|
|
5
|
-
*/
|
|
6
|
-
export const FromMetaBoxApiAction = {
|
|
1
|
+
export const FromMetaboxApiActions = {
|
|
7
2
|
bridge: 'bridge',
|
|
8
3
|
unrealCallback: 'unrealCallback',
|
|
9
4
|
unrealFeatureBridge: 'unrealFeatureBridge',
|
|
@@ -44,15 +39,3 @@ export const FromMetaBoxApiAction = {
|
|
|
44
39
|
getFastRender: 'getFastRender',
|
|
45
40
|
appLoaded: 'appLoaded',
|
|
46
41
|
};
|
|
47
|
-
export const ToMetaBoxApiAction = {
|
|
48
|
-
getPdf: 'getPdf',
|
|
49
|
-
loadLevel: 'loadLevel',
|
|
50
|
-
setProduct: 'setProduct',
|
|
51
|
-
addResponse: 'addResponse',
|
|
52
|
-
getFastRender: 'getFastRender',
|
|
53
|
-
watchCallbacks: 'watchCallbacks',
|
|
54
|
-
setExternalMode: 'setExternalMode',
|
|
55
|
-
setMaterialById: 'setMaterialById',
|
|
56
|
-
showEmbeddedMenu: 'showEmbeddedMenu',
|
|
57
|
-
forceSetDeviceType: 'forceSetDeviceType',
|
|
58
|
-
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { MimeType } from '../actions/GetFastRender';
|
|
2
|
+
export declare const ToMetaBoxApiActions: {
|
|
3
|
+
readonly getPdf: "getPdf";
|
|
4
|
+
readonly loadLevel: "loadLevel";
|
|
5
|
+
readonly setProduct: "setProduct";
|
|
6
|
+
readonly addResponse: "addResponse";
|
|
7
|
+
readonly getFastRender: "getFastRender";
|
|
8
|
+
readonly watchCallbacks: "watchCallbacks";
|
|
9
|
+
readonly setExternalMode: "setExternalMode";
|
|
10
|
+
readonly setMaterialById: "setMaterialById";
|
|
11
|
+
readonly showEmbeddedMenu: "showEmbeddedMenu";
|
|
12
|
+
readonly forceSetDeviceType: "forceSetDeviceType";
|
|
13
|
+
};
|
|
14
|
+
export type ToMetaBoxAction = (typeof ToMetaBoxApiActions)[keyof typeof ToMetaBoxApiActions];
|
|
15
|
+
export type ToMetaboxMessagePayload = ToMetaboxMessagePayloads[keyof ToMetaboxMessagePayloads];
|
|
16
|
+
export interface ToMetaboxMessagePayloads {
|
|
17
|
+
getPdf: void;
|
|
18
|
+
loadLevel: {
|
|
19
|
+
id: string;
|
|
20
|
+
};
|
|
21
|
+
setProduct: {
|
|
22
|
+
productId: string;
|
|
23
|
+
};
|
|
24
|
+
addResponse: void;
|
|
25
|
+
getFastRender: {
|
|
26
|
+
format: MimeType;
|
|
27
|
+
size?: {
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
watchCallbacks: void;
|
|
33
|
+
setExternalMode: void;
|
|
34
|
+
setMaterialById: {
|
|
35
|
+
productId: string;
|
|
36
|
+
slotId: string;
|
|
37
|
+
materialId: string;
|
|
38
|
+
};
|
|
39
|
+
showEmbeddedMenu: {
|
|
40
|
+
visible: boolean;
|
|
41
|
+
};
|
|
42
|
+
forceSetDeviceType: {
|
|
43
|
+
deviceType: 'deviceTypeAuto' | 'deviceTypeMobile' | 'deviceTypeDesktop';
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export interface ToMetaBoxMessageEnvelope {
|
|
47
|
+
action: ToMetaBoxAction;
|
|
48
|
+
payload?: ToMetaboxMessagePayload | never;
|
|
49
|
+
}
|
|
50
|
+
export interface ToMetaBoxMessage {
|
|
51
|
+
host: 'metaBoxHost';
|
|
52
|
+
payload: ToMetaBoxMessageEnvelope;
|
|
53
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const ToMetaBoxApiActions = {
|
|
2
|
+
getPdf: 'getPdf',
|
|
3
|
+
loadLevel: 'loadLevel',
|
|
4
|
+
setProduct: 'setProduct',
|
|
5
|
+
addResponse: 'addResponse',
|
|
6
|
+
getFastRender: 'getFastRender',
|
|
7
|
+
watchCallbacks: 'watchCallbacks',
|
|
8
|
+
setExternalMode: 'setExternalMode',
|
|
9
|
+
setMaterialById: 'setMaterialById',
|
|
10
|
+
showEmbeddedMenu: 'showEmbeddedMenu',
|
|
11
|
+
forceSetDeviceType: 'forceSetDeviceType',
|
|
12
|
+
};
|
|
@@ -1,132 +1,152 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Represents a configurator object with its configuration, selected materials,
|
|
3
|
+
* product identifier, and associated environment.
|
|
4
|
+
*/
|
|
5
|
+
export interface ConfiguratorEnvelope {
|
|
6
|
+
/**
|
|
7
|
+
* A reference to the universal configurator.
|
|
8
|
+
*/
|
|
7
9
|
configurator: UniversalConfigurator | null;
|
|
10
|
+
/**
|
|
11
|
+
* A record mapping material selections.
|
|
12
|
+
*/
|
|
8
13
|
selectedMaterials: SelectedMaterials;
|
|
14
|
+
/**
|
|
15
|
+
* The unique product identifier.
|
|
16
|
+
*/
|
|
9
17
|
productId: string;
|
|
18
|
+
/**
|
|
19
|
+
* The environment configuration for the universal configurator.
|
|
20
|
+
*/
|
|
10
21
|
environment: UniversalConfiguratorEnvironment;
|
|
11
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Represents the universal configurator with its basic properties and components.
|
|
25
|
+
*/
|
|
12
26
|
export interface UniversalConfigurator {
|
|
27
|
+
/** Unique identifier for the configurator. */
|
|
13
28
|
id: string;
|
|
14
|
-
|
|
29
|
+
/** Indicates if the configurator is active. */
|
|
30
|
+
/** Label for the product collection. */
|
|
15
31
|
productCollectionLabel: string;
|
|
32
|
+
/** The name of the configurator. */
|
|
16
33
|
name: string;
|
|
17
|
-
camera
|
|
18
|
-
|
|
34
|
+
/** The camera settings used in the configurator. */
|
|
35
|
+
/** Client information associated with the configurator. */
|
|
36
|
+
/** A list of products for the configurator. */
|
|
19
37
|
products: UniversalConfiguratorProduct[];
|
|
38
|
+
/** A list of available environments. */
|
|
20
39
|
environments: UniversalConfiguratorEnvironment[];
|
|
40
|
+
/** GraphQL typename for the configurator. */
|
|
21
41
|
__typename: 'UniversalConfigurator';
|
|
22
42
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
position: Position;
|
|
27
|
-
rotation: Rotation;
|
|
28
|
-
restrictions: Restrictions;
|
|
29
|
-
__typename: 'Camera';
|
|
30
|
-
}
|
|
31
|
-
export interface Position {
|
|
32
|
-
x: number;
|
|
33
|
-
y: number;
|
|
34
|
-
z: number;
|
|
35
|
-
__typename: 'Position';
|
|
36
|
-
}
|
|
37
|
-
export interface Rotation {
|
|
38
|
-
pitch: number;
|
|
39
|
-
yaw: number;
|
|
40
|
-
roll: number;
|
|
41
|
-
__typename: 'Rotation';
|
|
42
|
-
}
|
|
43
|
-
export interface Restrictions {
|
|
44
|
-
maxZoom?: null;
|
|
45
|
-
minZoom: number;
|
|
46
|
-
minPitch: number;
|
|
47
|
-
maxPitch: number;
|
|
48
|
-
maxYaw?: null;
|
|
49
|
-
minYaw?: null;
|
|
50
|
-
panBoundariesRadius?: null;
|
|
51
|
-
panBoundariesBox?: null;
|
|
52
|
-
__typename: 'Restrictions';
|
|
53
|
-
}
|
|
54
|
-
export interface Client {
|
|
55
|
-
id: string;
|
|
56
|
-
name: string;
|
|
57
|
-
unrealVersion: string;
|
|
58
|
-
hasPublicAssets: boolean;
|
|
59
|
-
__typename: 'Client';
|
|
60
|
-
}
|
|
43
|
+
/**
|
|
44
|
+
* Represents a product within the universal configurator.
|
|
45
|
+
*/
|
|
61
46
|
export interface UniversalConfiguratorProduct {
|
|
47
|
+
/** The product's unique identifier. */
|
|
62
48
|
productId: string;
|
|
49
|
+
/** Position index of the product. */
|
|
63
50
|
position: number;
|
|
51
|
+
/** Display label for the product. */
|
|
64
52
|
label: string;
|
|
65
|
-
camera
|
|
53
|
+
/** Optional camera settings for the product. */
|
|
54
|
+
/** The detailed product information. */
|
|
66
55
|
product: Product;
|
|
56
|
+
/** GraphQL typename for the product. */
|
|
67
57
|
__typename: 'UniversalConfiguratorProduct';
|
|
68
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Represents product details including visual assets and configuration.
|
|
61
|
+
*/
|
|
69
62
|
export interface Product {
|
|
63
|
+
/** The title of the product. */
|
|
70
64
|
title: string;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
/** List of thumbnails for the product. */
|
|
66
|
+
thumbnailList: Thumbnail[];
|
|
67
|
+
/** Available slots for the product. */
|
|
68
|
+
slots: Slot[];
|
|
69
|
+
/** The model information associated with the product. */
|
|
70
|
+
/** Unique identifier for the product. */
|
|
74
71
|
id: string;
|
|
75
|
-
|
|
72
|
+
/** Showcase details for the product. */
|
|
73
|
+
/** GraphQL typename for the product. */
|
|
76
74
|
__typename: 'Product';
|
|
77
75
|
}
|
|
78
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Represents a thumbnail image entity with dimensions and URL path.
|
|
78
|
+
*/
|
|
79
|
+
export interface Thumbnail {
|
|
80
|
+
/** Width of the thumbnail. */
|
|
79
81
|
width: number;
|
|
82
|
+
/** Height of the thumbnail. */
|
|
80
83
|
height: number;
|
|
84
|
+
/** URL path to the thumbnail image. */
|
|
81
85
|
urlPath: string;
|
|
82
|
-
|
|
86
|
+
/** GraphQL typename (as a string, flexible type). */
|
|
87
|
+
__typename: 'Thumbnail';
|
|
83
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Represents a slot within a product that may allow material customization.
|
|
91
|
+
*/
|
|
84
92
|
export interface Slot {
|
|
93
|
+
/** Unique identifier for the slot. */
|
|
85
94
|
id: string;
|
|
95
|
+
/** Display label for the slot. */
|
|
86
96
|
label: string;
|
|
87
|
-
|
|
97
|
+
/** A list of enabled materials for the slot. */
|
|
98
|
+
enabledMaterials: Material[];
|
|
99
|
+
/** GraphQL typename for the slot. */
|
|
88
100
|
__typename: 'Slot';
|
|
89
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Represents a material that can be applied to a product slot.
|
|
104
|
+
*/
|
|
90
105
|
export interface Material {
|
|
106
|
+
/** Unique identifier for the material. */
|
|
91
107
|
id: string;
|
|
108
|
+
/** Title or name of the material. */
|
|
92
109
|
title: string;
|
|
93
|
-
|
|
94
|
-
|
|
110
|
+
/** List of thumbnails for the material. */
|
|
111
|
+
thumbnailList: Thumbnail[];
|
|
112
|
+
/** The model information associated with the material. */
|
|
113
|
+
/** GraphQL typename for the material. */
|
|
95
114
|
__typename: 'Material';
|
|
96
115
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
assetPath: string;
|
|
101
|
-
unrealVersion: string;
|
|
102
|
-
__typename: 'Model';
|
|
103
|
-
}
|
|
104
|
-
export interface Showcase {
|
|
105
|
-
lowBandwidth?: (LowBandwidthEntity | null)[] | null;
|
|
106
|
-
duration?: null;
|
|
107
|
-
__typename: 'Showcase';
|
|
108
|
-
}
|
|
109
|
-
export interface LowBandwidthEntity {
|
|
110
|
-
time: number;
|
|
111
|
-
duration: number;
|
|
112
|
-
__typename: string;
|
|
113
|
-
}
|
|
116
|
+
/**
|
|
117
|
+
* Represents the environment settings for a universal configurator.
|
|
118
|
+
*/
|
|
114
119
|
export interface UniversalConfiguratorEnvironment {
|
|
120
|
+
/** Unique identifier for the environment. */
|
|
115
121
|
environmentId: string;
|
|
122
|
+
/** Position index of the environment. */
|
|
116
123
|
position: number;
|
|
124
|
+
/** Display label for the environment. */
|
|
117
125
|
label: string;
|
|
126
|
+
/** Detailed environment configuration. */
|
|
118
127
|
environment: Environment;
|
|
128
|
+
/** GraphQL typename for the environment. */
|
|
119
129
|
__typename: 'UniversalConfiguratorEnvironment';
|
|
120
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Represents an environment with associated media and configuration.
|
|
133
|
+
*/
|
|
121
134
|
export interface Environment {
|
|
135
|
+
/** Unique identifier for the environment. */
|
|
122
136
|
id: string;
|
|
137
|
+
/** Title or name of the environment. */
|
|
123
138
|
title: string;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
139
|
+
/** Flag indicating if UDS is enabled. */
|
|
140
|
+
/** The north yaw of the sun in the environment. */
|
|
141
|
+
/** The UDS hour setting for the environment. */
|
|
142
|
+
/** GraphQL typename for the environment. */
|
|
127
143
|
__typename: 'Environment';
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
144
|
+
/** List of thumbnails for the environment (optional). */
|
|
145
|
+
thumbnailList: Thumbnail[];
|
|
146
|
+
/** List of slots for the environment (optional). */
|
|
147
|
+
slots: Slot[];
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Defines the structure for a mapping of selected materials.
|
|
151
|
+
*/
|
|
132
152
|
export type SelectedMaterials = Record<string, Record<string, string>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ToMetaBoxMessageEnvelope } from '../interfaces/ToMetaboxMessagePayloads';
|
|
2
2
|
declare global {
|
|
3
3
|
interface Window {
|
|
4
4
|
env3DSource: {
|
|
@@ -9,11 +9,13 @@ declare global {
|
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* API class to handle communication with the embedded content.
|
|
12
|
+
* @internal Do not Create an instance of this class directly.
|
|
13
|
+
* integrateMetabox will create an instance of this class.
|
|
12
14
|
*
|
|
13
15
|
* @remarks
|
|
14
16
|
* This class sets up a communication channel with the embedded content via window messages.
|
|
15
17
|
*/
|
|
16
|
-
declare class Communicator {
|
|
18
|
+
export declare class Communicator {
|
|
17
19
|
/**
|
|
18
20
|
* Storage for callback listeners by message type.
|
|
19
21
|
*/
|
|
@@ -28,7 +30,7 @@ declare class Communicator {
|
|
|
28
30
|
static instance: Communicator | null;
|
|
29
31
|
/**
|
|
30
32
|
* Creates an instance of Communicator.
|
|
31
|
-
*
|
|
33
|
+
* @internal
|
|
32
34
|
* @remarks
|
|
33
35
|
* If an instance already exists, it will be destroyed before creating a new one.
|
|
34
36
|
* The instance listens for messages from the iframe.
|
|
@@ -43,7 +45,7 @@ declare class Communicator {
|
|
|
43
45
|
*
|
|
44
46
|
* @param data - The data to send.
|
|
45
47
|
*/
|
|
46
|
-
sendMessageToMetaBox(data:
|
|
48
|
+
sendMessageToMetaBox(data: ToMetaBoxMessageEnvelope): void;
|
|
47
49
|
/**
|
|
48
50
|
* Adds an event listener for receiving specific types of messages.
|
|
49
51
|
*
|
|
@@ -75,12 +77,11 @@ declare class Communicator {
|
|
|
75
77
|
* @param callback - The callback function to remove.
|
|
76
78
|
*/
|
|
77
79
|
removeEventListener(messageType: string, callback: (data: unknown) => void): void;
|
|
80
|
+
/**
|
|
81
|
+
* Initializes the communicator when the embedded content is ready.
|
|
82
|
+
* @internal
|
|
83
|
+
* @remarks
|
|
84
|
+
* This function sets up a listener that waits for the 'appLoaded' action and then initializes the Communicator.
|
|
85
|
+
*/
|
|
86
|
+
static createInstance(): void;
|
|
78
87
|
}
|
|
79
|
-
/**
|
|
80
|
-
* Initializes the communicator when the embedded content is ready.
|
|
81
|
-
*
|
|
82
|
-
* @remarks
|
|
83
|
-
* This function sets up a listener that waits for the 'appLoaded' action and then initializes the Communicator.
|
|
84
|
-
*/
|
|
85
|
-
export declare function initializeCommunicator(): void;
|
|
86
|
-
export {};
|
|
@@ -6,14 +6,16 @@
|
|
|
6
6
|
const messageType = 'metaboxData';
|
|
7
7
|
/**
|
|
8
8
|
* API class to handle communication with the embedded content.
|
|
9
|
+
* @internal Do not Create an instance of this class directly.
|
|
10
|
+
* integrateMetabox will create an instance of this class.
|
|
9
11
|
*
|
|
10
12
|
* @remarks
|
|
11
13
|
* This class sets up a communication channel with the embedded content via window messages.
|
|
12
14
|
*/
|
|
13
|
-
class Communicator {
|
|
15
|
+
export class Communicator {
|
|
14
16
|
/**
|
|
15
17
|
* Creates an instance of Communicator.
|
|
16
|
-
*
|
|
18
|
+
* @internal
|
|
17
19
|
* @remarks
|
|
18
20
|
* If an instance already exists, it will be destroyed before creating a new one.
|
|
19
21
|
* The instance listens for messages from the iframe.
|
|
@@ -105,27 +107,27 @@ class Communicator {
|
|
|
105
107
|
removeEventListener(messageType, callback) {
|
|
106
108
|
this.listeners = this.listeners.filter((listener) => !(listener.messageType === messageType && listener.callback === callback));
|
|
107
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Initializes the communicator when the embedded content is ready.
|
|
112
|
+
* @internal
|
|
113
|
+
* @remarks
|
|
114
|
+
* This function sets up a listener that waits for the 'appLoaded' action and then initializes the Communicator.
|
|
115
|
+
*/
|
|
116
|
+
static createInstance() {
|
|
117
|
+
window.env3DSource = window.env3DSource || {};
|
|
118
|
+
const startHandler = (event) => {
|
|
119
|
+
var _a, _b;
|
|
120
|
+
if (((_b = (_a = event === null || event === void 0 ? void 0 : event.data) === null || _a === void 0 ? void 0 : _a.payload) === null || _b === void 0 ? void 0 : _b.action) === 'appLoaded' &&
|
|
121
|
+
'apiReady' in window.env3DSource) {
|
|
122
|
+
window.env3DSource.api = new Communicator();
|
|
123
|
+
window.env3DSource.apiReady(window.env3DSource.api);
|
|
124
|
+
window.removeEventListener('message', startHandler);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
window.addEventListener('message', startHandler);
|
|
128
|
+
}
|
|
108
129
|
}
|
|
109
130
|
/**
|
|
110
131
|
* The singleton instance of the communicator.
|
|
111
132
|
*/
|
|
112
133
|
Communicator.instance = null;
|
|
113
|
-
/**
|
|
114
|
-
* Initializes the communicator when the embedded content is ready.
|
|
115
|
-
*
|
|
116
|
-
* @remarks
|
|
117
|
-
* This function sets up a listener that waits for the 'appLoaded' action and then initializes the Communicator.
|
|
118
|
-
*/
|
|
119
|
-
export function initializeCommunicator() {
|
|
120
|
-
window.env3DSource = window.env3DSource || {};
|
|
121
|
-
const startHandler = (event) => {
|
|
122
|
-
var _a, _b;
|
|
123
|
-
if (((_b = (_a = event === null || event === void 0 ? void 0 : event.data) === null || _a === void 0 ? void 0 : _a.payload) === null || _b === void 0 ? void 0 : _b.action) === 'appLoaded' &&
|
|
124
|
-
'apiReady' in window.env3DSource) {
|
|
125
|
-
window.env3DSource.api = new Communicator();
|
|
126
|
-
window.env3DSource.apiReady(window.env3DSource.api);
|
|
127
|
-
window.removeEventListener('message', startHandler);
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
window.addEventListener('message', startHandler);
|
|
131
|
-
}
|
|
@@ -9,5 +9,16 @@
|
|
|
9
9
|
* @param containerId - The ID of the layout element. Defaults to 'embed3DSource'.
|
|
10
10
|
*
|
|
11
11
|
* @throws Error if the container element with the specified ID is not found.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
*
|
|
15
|
+
* import {
|
|
16
|
+
* integrateMetaBox,
|
|
17
|
+
* } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
|
|
18
|
+
*
|
|
19
|
+
* integrateMetaBox(
|
|
20
|
+
* 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
|
|
21
|
+
* 'embed3DSource'
|
|
22
|
+
* );
|
|
12
23
|
*/
|
|
13
24
|
export declare function integrateMetaBox(iframeSrc: string, containerId?: string): void;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* 3DSource.com, Sergii Karanda steve@3dsource.com
|
|
4
4
|
* All Rights Reserved
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { Communicator } from './initializeCommunicator';
|
|
7
7
|
/**
|
|
8
8
|
* Integrates the MetaBox into the provided layout.
|
|
9
9
|
*
|
|
@@ -15,13 +15,24 @@ import { initializeCommunicator } from './initializeCommunicator';
|
|
|
15
15
|
* @param containerId - The ID of the layout element. Defaults to 'embed3DSource'.
|
|
16
16
|
*
|
|
17
17
|
* @throws Error if the container element with the specified ID is not found.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
*
|
|
21
|
+
* import {
|
|
22
|
+
* integrateMetaBox,
|
|
23
|
+
* } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
|
|
24
|
+
*
|
|
25
|
+
* integrateMetaBox(
|
|
26
|
+
* 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
|
|
27
|
+
* 'embed3DSource'
|
|
28
|
+
* );
|
|
18
29
|
*/
|
|
19
30
|
export function integrateMetaBox(iframeSrc, containerId = 'embed3DSource') {
|
|
20
31
|
const container = document.getElementById(containerId);
|
|
21
32
|
if (!container) {
|
|
22
33
|
throw new Error(`Container element with id ${containerId} not found`);
|
|
23
34
|
}
|
|
24
|
-
|
|
35
|
+
Communicator.createInstance();
|
|
25
36
|
const style = document.createElement('style');
|
|
26
37
|
style.innerHTML = `
|
|
27
38
|
#${containerId} {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@3dsource/metabox-front-api",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "API for MetaBox configurator",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"unpkg": "dist/index.js",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "tsc",
|
|
10
10
|
"clean": "rimraf dist",
|
|
11
|
-
"publishApi": "npm pack && npm publish --access public"
|
|
11
|
+
"publishApi": "npm run clean && npm run build && npm pack && npm publish --access public",
|
|
12
|
+
"apiDoc": "typedoc --entryPointStrategy Expand src/index.ts --tsconfig ./../../tsconfig.typedoc.json --out ./../../dist/browser/apiDoc"
|
|
12
13
|
},
|
|
13
14
|
"files": [
|
|
14
15
|
"dist"
|