@3dsource/metabox-front-api 0.0.6 → 0.0.8
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 +31 -31
- package/dist/actions/ApiAction.d.ts +3 -0
- package/dist/actions/ApiAction.js +3 -0
- package/dist/actions/SetEnvironmentMaterial.d.ts +49 -0
- package/dist/actions/SetEnvironmentMaterial.js +65 -0
- package/dist/actions/WatchCallbacks.d.ts +3 -3
- package/dist/actions/WatchCallbacks.js +3 -3
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/interfaces/FromMetaboxMessagePayloads.d.ts +21 -8
- package/dist/interfaces/FromMetaboxMessagePayloads.js +19 -5
- package/dist/interfaces/ToMetaboxMessagePayloads.d.ts +20 -3
- package/dist/interfaces/ToMetaboxMessagePayloads.js +6 -1
- package/dist/interfaces/UniversalConfigurator.d.ts +15 -7
- package/dist/interfaces/application-device-types.d.ts +10 -0
- package/dist/interfaces/application-device-types.js +10 -0
- package/dist/lib/initializeCommunicator.d.ts +2 -1
- package/dist/lib/initializeCommunicator.js +1 -0
- package/dist/lib/integrateMetaBox.d.ts +7 -1
- package/dist/lib/integrateMetaBox.js +7 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# MetaBox API
|
|
1
|
+
# MetaBox Basic Configurators API
|
|
2
2
|
|
|
3
|
-
This package provides an API for interacting with the MetaBox
|
|
3
|
+
This package provides an API for interacting with the MetaBox Basic Configurator using plain JavaScript.
|
|
4
4
|
|
|
5
|
-
### Installation (for using with frameworks like Angular, React, etc.)
|
|
5
|
+
### Installation (for using with frameworks like Angular, React, etc.) This is recommended method
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
8
|
npm install @3dsource/metabox-front-api --save
|
|
@@ -20,9 +20,22 @@ import { FromMetaBoxApiAction, GetFastRender, GetPdf, integrateMetaBox, saveImag
|
|
|
20
20
|
import { FromMetaBoxApiAction, GetFastRender, GetPdf, integrateMetaBox, saveImage, SetEnvironment, SetMaterial, SetProduct, ShowEmbeddedMenu,... } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
**WE ARE HIGHLY RECOMMENDING TO USE THE FIRST OPTION WITH NPM, AS THE SECOND ONE CAN RAPIDLY CHANGE AND MAY CAUSE UNEXPECTED BEHAVIOR WITH CODE YOU ARE ALREADY USING.**
|
|
24
|
+
|
|
23
25
|
## Usage
|
|
24
26
|
|
|
25
|
-
### 1.
|
|
27
|
+
### 1. Create HTML Structure
|
|
28
|
+
|
|
29
|
+
Ensure your HTML page has the following structure, where the MetaBox Configurator will be integrated.
|
|
30
|
+
You **MUST** control CSS style of `embed3DSource` element to make the configurator responsive and fit your needs on your own.
|
|
31
|
+
|
|
32
|
+
```html
|
|
33
|
+
<div id="embed3DSource">
|
|
34
|
+
<!-- Your Configurator iframe will be embedded here -->
|
|
35
|
+
</div>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 2. Include Required Scripts
|
|
26
39
|
|
|
27
40
|
Below is an example demonstrating how to use the MetaBox API functions:
|
|
28
41
|
|
|
@@ -32,14 +45,13 @@ Insert this code into your HTML file just before the closing `</body>` tag:
|
|
|
32
45
|
|
|
33
46
|
```html
|
|
34
47
|
<script type="module">
|
|
35
|
-
import { integrateMetaBox, SetEnvironment, SetMaterial, SetProduct, ShowEmbeddedMenu, GetFastRender, GetPdf, saveImage } from '@3dsource/metabox-front-api';
|
|
36
|
-
|
|
48
|
+
import { integrateMetaBox, SetEnvironment, SetMaterial, SetProduct, ShowEmbeddedMenu, GetFastRender, GetPdf, saveImage, FromMetaboxApiAction } from '@3dsource/metabox-front-api';
|
|
49
|
+
let initilaized = false;
|
|
37
50
|
// Expose API
|
|
38
51
|
window.env3DSource.apiReady = (api) => {
|
|
39
|
-
|
|
40
|
-
this.api.addEventListener('metaboxData', (data) => {
|
|
52
|
+
api.addEventListener('metaboxData', (data) => {
|
|
41
53
|
const { action, payload, eventType } = data;
|
|
42
|
-
if (action !==
|
|
54
|
+
if (action !== FromMetaboxApiAction.bridge) {
|
|
43
55
|
return;
|
|
44
56
|
}
|
|
45
57
|
|
|
@@ -55,8 +67,8 @@ Insert this code into your HTML file just before the closing `</body>` tag:
|
|
|
55
67
|
}
|
|
56
68
|
|
|
57
69
|
if (eventType === 'basicConfiguratorDataWithState') {
|
|
58
|
-
|
|
59
|
-
|
|
70
|
+
updateConfiguratorData(data);
|
|
71
|
+
setupInitialState();
|
|
60
72
|
}
|
|
61
73
|
|
|
62
74
|
if (eventType === 'getFastRender') {
|
|
@@ -78,6 +90,9 @@ Insert this code into your HTML file just before the closing `</body>` tag:
|
|
|
78
90
|
* Setup initial state
|
|
79
91
|
*/
|
|
80
92
|
function setupInitialState() {
|
|
93
|
+
if (initilaized) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
81
96
|
// Set product
|
|
82
97
|
new SetProduct('product-id');
|
|
83
98
|
|
|
@@ -93,27 +108,16 @@ Insert this code into your HTML file just before the closing `</body>` tag:
|
|
|
93
108
|
|
|
94
109
|
// Integrate the 3D configurator into your page
|
|
95
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Additional url parameters:
|
|
113
|
+
* @see integrateMetaBox
|
|
114
|
+
* @type {string}
|
|
115
|
+
*/
|
|
96
116
|
const url = 'https://metabox.3dsource.com/metabox-configurator/basic/your-configurator-id?sidebar=false';
|
|
97
|
-
// Additional url parameters:
|
|
98
|
-
// sidebar=false - disables the internal MetaBox menu
|
|
99
|
-
// introImage=https://example.com/image.png - sets the intro image
|
|
100
|
-
// 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
|
|
101
117
|
integrateMetaBox(url, 'embed3DSource');
|
|
102
118
|
</script>
|
|
103
119
|
```
|
|
104
120
|
|
|
105
|
-
### 2. HTML Structure
|
|
106
|
-
|
|
107
|
-
Ensure your HTML page has the following structure, where the MetaBox Configurator will be integrated:
|
|
108
|
-
|
|
109
|
-
```html
|
|
110
|
-
<div class="container">
|
|
111
|
-
<div id="embed3DSource">
|
|
112
|
-
<!-- Your Configurator iframe will be embedded here -->
|
|
113
|
-
</div>
|
|
114
|
-
</div>
|
|
115
|
-
```
|
|
116
|
-
|
|
117
121
|
### Documentation for current example
|
|
118
122
|
|
|
119
123
|
### `integrateMetaBox`
|
|
@@ -191,7 +195,3 @@ data.eventType === 'viewportReady' && data.payload === true.
|
|
|
191
195
|
```typescript
|
|
192
196
|
saveImage(renderData: string, fileName: string): void;
|
|
193
197
|
```
|
|
194
|
-
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
```
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ApiAction } from './ApiAction';
|
|
2
|
+
/**
|
|
3
|
+
* Represents an action to set a material by its ID.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* This action sends a message to the MetaBox API to update the material on a specific product slot using the provided identifiers.
|
|
7
|
+
|
|
8
|
+
* **Important:** Before invoking this action, ensure that the MetaBox already dispatched
|
|
9
|
+
* as minimum one eventType:"basicConfiguratorDataWithState":
|
|
10
|
+
* ```javascript
|
|
11
|
+
* data.eventType === 'basicConfiguratorDataWithState'.
|
|
12
|
+
* ```
|
|
13
|
+
* Only then request be processed.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* import { SetMaterial } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
|
|
17
|
+
*
|
|
18
|
+
* // Integrate the MetaBox configurator into an HTML element with the ID 'embed3DSource'
|
|
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
|
+
* );
|
|
23
|
+
*
|
|
24
|
+
* // Set up the global API environment
|
|
25
|
+
* window.env3DSource = window.env3DSource || {};
|
|
26
|
+
* window.env3DSource.apiReady = (api) => {
|
|
27
|
+
* // Listen for events from the MetaBox API
|
|
28
|
+
* api.addEventListener('metaboxData', (data) => {
|
|
29
|
+
* // Process SetMaterial
|
|
30
|
+
* if (data.eventType === 'basicConfiguratorDataWithState') {
|
|
31
|
+
* new SetEnvironmentMaterial(
|
|
32
|
+
* 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
|
|
33
|
+
* 'carpaint',
|
|
34
|
+
* 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
|
|
35
|
+
* );
|
|
36
|
+
* }
|
|
37
|
+
* });
|
|
38
|
+
* };
|
|
39
|
+
*/
|
|
40
|
+
export declare class SetEnvironmentMaterial extends ApiAction {
|
|
41
|
+
/**
|
|
42
|
+
* Creates an instance of SetMaterial.
|
|
43
|
+
*
|
|
44
|
+
* @param productId - The product ID.
|
|
45
|
+
* @param slotId - The slot ID.
|
|
46
|
+
* @param materialId - The material ID.
|
|
47
|
+
*/
|
|
48
|
+
constructor(productId: string, slotId: string, materialId: string);
|
|
49
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025.
|
|
3
|
+
* 3DSource.com, Sergii Karanda steve@3dsource.com
|
|
4
|
+
* All Rights Reserved
|
|
5
|
+
*/
|
|
6
|
+
import { ApiAction } from './ApiAction';
|
|
7
|
+
import { ToMetaBoxApiAction } from '../interfaces/ToMetaboxMessagePayloads';
|
|
8
|
+
/**
|
|
9
|
+
* Represents an action to set a material by its ID.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* This action sends a message to the MetaBox API to update the material on a specific product slot using the provided identifiers.
|
|
13
|
+
|
|
14
|
+
* **Important:** Before invoking this action, ensure that the MetaBox already dispatched
|
|
15
|
+
* as minimum one eventType:"basicConfiguratorDataWithState":
|
|
16
|
+
* ```javascript
|
|
17
|
+
* data.eventType === 'basicConfiguratorDataWithState'.
|
|
18
|
+
* ```
|
|
19
|
+
* Only then request be processed.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* import { SetMaterial } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
|
|
23
|
+
*
|
|
24
|
+
* // Integrate the MetaBox configurator into an HTML element with the ID 'embed3DSource'
|
|
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
|
+
* );
|
|
29
|
+
*
|
|
30
|
+
* // Set up the global API environment
|
|
31
|
+
* window.env3DSource = window.env3DSource || {};
|
|
32
|
+
* window.env3DSource.apiReady = (api) => {
|
|
33
|
+
* // Listen for events from the MetaBox API
|
|
34
|
+
* api.addEventListener('metaboxData', (data) => {
|
|
35
|
+
* // Process SetMaterial
|
|
36
|
+
* if (data.eventType === 'basicConfiguratorDataWithState') {
|
|
37
|
+
* new SetEnvironmentMaterial(
|
|
38
|
+
* 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
|
|
39
|
+
* 'carpaint',
|
|
40
|
+
* 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
|
|
41
|
+
* );
|
|
42
|
+
* }
|
|
43
|
+
* });
|
|
44
|
+
* };
|
|
45
|
+
*/
|
|
46
|
+
export class SetEnvironmentMaterial extends ApiAction {
|
|
47
|
+
/**
|
|
48
|
+
* Creates an instance of SetMaterial.
|
|
49
|
+
*
|
|
50
|
+
* @param productId - The product ID.
|
|
51
|
+
* @param slotId - The slot ID.
|
|
52
|
+
* @param materialId - The material ID.
|
|
53
|
+
*/
|
|
54
|
+
constructor(productId, slotId, materialId) {
|
|
55
|
+
super();
|
|
56
|
+
this.api.sendMessageToMetaBox({
|
|
57
|
+
payload: {
|
|
58
|
+
productId,
|
|
59
|
+
slotId,
|
|
60
|
+
materialId,
|
|
61
|
+
},
|
|
62
|
+
action: ToMetaBoxApiAction.setEnvironmentMaterialById,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ApiAction } from './ApiAction';
|
|
2
2
|
/**
|
|
3
|
-
* @
|
|
4
|
-
* Represents an action to watch Unreal callbacks from Unreal engine.
|
|
3
|
+
* @experimental
|
|
5
4
|
* @remarks
|
|
6
|
-
*
|
|
5
|
+
* Represents an action to watch Unreal callbacks from Unreal engine.
|
|
6
|
+
* Can be useful for custom solutions.
|
|
7
7
|
*/
|
|
8
8
|
export declare class WatchCallbacks extends ApiAction {
|
|
9
9
|
/**
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
import { ApiAction } from './ApiAction';
|
|
7
7
|
import { ToMetaBoxApiAction } from '../interfaces/ToMetaboxMessagePayloads';
|
|
8
8
|
/**
|
|
9
|
-
* @
|
|
10
|
-
* Represents an action to watch Unreal callbacks from Unreal engine.
|
|
9
|
+
* @experimental
|
|
11
10
|
* @remarks
|
|
12
|
-
*
|
|
11
|
+
* Represents an action to watch Unreal callbacks from Unreal engine.
|
|
12
|
+
* Can be useful for custom solutions.
|
|
13
13
|
*/
|
|
14
14
|
export class WatchCallbacks extends ApiAction {
|
|
15
15
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -3,9 +3,11 @@ export { SetEnvironment } from './actions/SetEnvironment';
|
|
|
3
3
|
export { SetProduct } from './actions/SetProduct';
|
|
4
4
|
export { GetPdf } from './actions/GetPdf';
|
|
5
5
|
export { SetMaterial } from './actions/SetMaterial';
|
|
6
|
+
export { SetEnvironmentMaterial } from './actions/SetEnvironmentMaterial';
|
|
6
7
|
export { GetFastRender } from './actions/GetFastRender';
|
|
7
8
|
export { WatchCallbacks } from './actions/WatchCallbacks';
|
|
8
9
|
export { MimeType } from './actions/GetFastRender';
|
|
10
|
+
export { ApiAction } from './actions/ApiAction';
|
|
9
11
|
export * from './lib/integrateMetaBox';
|
|
10
12
|
export * from './lib/initializeCommunicator';
|
|
11
13
|
export * from './lib/saveImage';
|
|
@@ -14,3 +16,4 @@ export * from './lib/UrlUtils';
|
|
|
14
16
|
export * from './interfaces/UniversalConfigurator';
|
|
15
17
|
export * from './interfaces/ToMetaboxMessagePayloads';
|
|
16
18
|
export * from './interfaces/FromMetaboxMessagePayloads';
|
|
19
|
+
export * from './interfaces/application-device-types';
|
package/dist/index.js
CHANGED
|
@@ -8,8 +8,10 @@ export { SetEnvironment } from './actions/SetEnvironment';
|
|
|
8
8
|
export { SetProduct } from './actions/SetProduct';
|
|
9
9
|
export { GetPdf } from './actions/GetPdf';
|
|
10
10
|
export { SetMaterial } from './actions/SetMaterial';
|
|
11
|
+
export { SetEnvironmentMaterial } from './actions/SetEnvironmentMaterial';
|
|
11
12
|
export { GetFastRender } from './actions/GetFastRender';
|
|
12
13
|
export { WatchCallbacks } from './actions/WatchCallbacks';
|
|
14
|
+
export { ApiAction } from './actions/ApiAction';
|
|
13
15
|
export * from './lib/integrateMetaBox';
|
|
14
16
|
export * from './lib/initializeCommunicator';
|
|
15
17
|
export * from './lib/saveImage';
|
|
@@ -18,3 +20,4 @@ export * from './lib/UrlUtils';
|
|
|
18
20
|
export * from './interfaces/UniversalConfigurator';
|
|
19
21
|
export * from './interfaces/ToMetaboxMessagePayloads';
|
|
20
22
|
export * from './interfaces/FromMetaboxMessagePayloads';
|
|
23
|
+
export * from './interfaces/application-device-types';
|
|
@@ -1,51 +1,66 @@
|
|
|
1
1
|
import type { ConfiguratorEnvelope } from './UniversalConfigurator';
|
|
2
2
|
export declare const FromMetaboxApiAction: {
|
|
3
3
|
readonly bridge: "bridge";
|
|
4
|
-
readonly
|
|
4
|
+
readonly appLoaded: "appLoaded";
|
|
5
|
+
/**
|
|
6
|
+
* @hidden
|
|
7
|
+
* @deprecated, use MetaBoxApiAction.Bridge with eventType: "unrealFeature"
|
|
8
|
+
*/
|
|
5
9
|
readonly unrealFeatureBridge: "unrealFeatureBridge";
|
|
6
10
|
/**
|
|
11
|
+
* @hidden
|
|
12
|
+
* @deprecated, use MetaBoxApiAction.Bridge with eventType: "unrealCallback"
|
|
13
|
+
*/
|
|
14
|
+
readonly unrealCallback: "unrealCallback";
|
|
15
|
+
/**
|
|
16
|
+
* @hidden
|
|
7
17
|
* @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
|
|
8
18
|
*/
|
|
9
19
|
readonly configuratorDataWithStateBridge: "configuratorDataWithStateBridge";
|
|
10
20
|
/**
|
|
21
|
+
* @hidden
|
|
11
22
|
* @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
|
|
12
23
|
*/
|
|
13
24
|
readonly configuratorDataBridge: "configuratorDataBridge";
|
|
14
25
|
/**
|
|
26
|
+
* @hidden
|
|
15
27
|
* @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
|
|
16
28
|
*/
|
|
17
29
|
readonly menuDataBridge: "menuDataBridge";
|
|
18
30
|
/**
|
|
31
|
+
* @hidden
|
|
19
32
|
* @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
|
|
20
33
|
*/
|
|
21
34
|
readonly flatMenuDataBridge: "flatMenuDataBridge";
|
|
22
35
|
/**
|
|
36
|
+
* @hidden
|
|
23
37
|
* @deprecated, use Bridge with isFullscreen
|
|
24
38
|
*/
|
|
25
39
|
readonly fullScreenBridge: "fullScreenBridge";
|
|
26
40
|
/**
|
|
41
|
+
* @hidden
|
|
27
42
|
* @deprecated, use Bridge with streamResolution
|
|
28
43
|
*/
|
|
29
44
|
readonly videoSize: "videoSize";
|
|
30
45
|
/**
|
|
46
|
+
* @hidden
|
|
31
47
|
* Used in platform, must be removed in future
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @deprecated\
|
|
48
|
+
* @deprecated
|
|
35
49
|
*/
|
|
36
50
|
readonly unrealResponse: "unrealResponse";
|
|
37
51
|
/**
|
|
52
|
+
* @hidden
|
|
38
53
|
* @deprecated\
|
|
39
54
|
*/
|
|
40
55
|
readonly getFastRender: "getFastRender";
|
|
41
|
-
readonly appLoaded: "appLoaded";
|
|
42
56
|
};
|
|
43
57
|
export type FromMetaBoxActions = (typeof FromMetaboxApiAction)[keyof typeof FromMetaboxApiAction];
|
|
44
58
|
/**
|
|
59
|
+
* @hidden
|
|
45
60
|
* @internal
|
|
46
61
|
* Used for signaling that the app is loaded and ready to open api.
|
|
47
62
|
*/
|
|
48
|
-
interface MCAppLoaded {
|
|
63
|
+
export interface MCAppLoaded {
|
|
49
64
|
action: string;
|
|
50
65
|
eventType?: unknown;
|
|
51
66
|
payload?: unknown;
|
|
@@ -75,7 +90,6 @@ export interface FromMetaboxMessagePayloads {
|
|
|
75
90
|
statusMessage: string | null;
|
|
76
91
|
/**
|
|
77
92
|
* @internal
|
|
78
|
-
* @experimental
|
|
79
93
|
* Dispatches every time when freeze-frame is arrived or updated.
|
|
80
94
|
*/
|
|
81
95
|
freezeFrame: {
|
|
@@ -127,4 +141,3 @@ export interface FromMetaBoxMessage {
|
|
|
127
141
|
host: 'metabox';
|
|
128
142
|
payload: FromMetaBoxAPIEnvelope;
|
|
129
143
|
}
|
|
130
|
-
export {};
|
|
@@ -5,42 +5,56 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export const FromMetaboxApiAction = {
|
|
7
7
|
bridge: 'bridge',
|
|
8
|
-
|
|
8
|
+
appLoaded: 'appLoaded',
|
|
9
|
+
/**
|
|
10
|
+
* @hidden
|
|
11
|
+
* @deprecated, use MetaBoxApiAction.Bridge with eventType: "unrealFeature"
|
|
12
|
+
*/
|
|
9
13
|
unrealFeatureBridge: 'unrealFeatureBridge',
|
|
10
14
|
/**
|
|
15
|
+
* @hidden
|
|
16
|
+
* @deprecated, use MetaBoxApiAction.Bridge with eventType: "unrealCallback"
|
|
17
|
+
*/
|
|
18
|
+
unrealCallback: 'unrealCallback',
|
|
19
|
+
/**
|
|
20
|
+
* @hidden
|
|
11
21
|
* @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
|
|
12
22
|
*/
|
|
13
23
|
configuratorDataWithStateBridge: 'configuratorDataWithStateBridge',
|
|
14
24
|
/**
|
|
25
|
+
* @hidden
|
|
15
26
|
* @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
|
|
16
27
|
*/
|
|
17
28
|
configuratorDataBridge: 'configuratorDataBridge',
|
|
18
29
|
/**
|
|
30
|
+
* @hidden
|
|
19
31
|
* @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
|
|
20
32
|
*/
|
|
21
33
|
menuDataBridge: 'menuDataBridge',
|
|
22
34
|
/**
|
|
35
|
+
* @hidden
|
|
23
36
|
* @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
|
|
24
37
|
*/
|
|
25
38
|
flatMenuDataBridge: 'flatMenuDataBridge',
|
|
26
39
|
/**
|
|
40
|
+
* @hidden
|
|
27
41
|
* @deprecated, use Bridge with isFullscreen
|
|
28
42
|
*/
|
|
29
43
|
fullScreenBridge: 'fullScreenBridge',
|
|
30
44
|
/**
|
|
45
|
+
* @hidden
|
|
31
46
|
* @deprecated, use Bridge with streamResolution
|
|
32
47
|
*/
|
|
33
48
|
videoSize: 'videoSize',
|
|
34
49
|
/**
|
|
50
|
+
* @hidden
|
|
35
51
|
* Used in platform, must be removed in future
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* @deprecated\
|
|
52
|
+
* @deprecated
|
|
39
53
|
*/
|
|
40
54
|
unrealResponse: 'unrealResponse',
|
|
41
55
|
/**
|
|
56
|
+
* @hidden
|
|
42
57
|
* @deprecated\
|
|
43
58
|
*/
|
|
44
59
|
getFastRender: 'getFastRender',
|
|
45
|
-
appLoaded: 'appLoaded',
|
|
46
60
|
};
|
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
import type { MimeType } from '../actions/GetFastRender';
|
|
2
|
+
import type { ApplicationDeviceType } from './application-device-types';
|
|
2
3
|
export declare const ToMetaBoxApiAction: {
|
|
3
4
|
readonly getPdf: "getPdf";
|
|
4
5
|
readonly loadLevel: "loadLevel";
|
|
5
6
|
readonly setProduct: "setProduct";
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated, use 'watchCallbacks'"
|
|
9
|
+
* use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
|
|
10
|
+
* @hidden
|
|
11
|
+
*/
|
|
6
12
|
readonly addResponse: "addResponse";
|
|
7
13
|
readonly getFastRender: "getFastRender";
|
|
8
14
|
readonly watchCallbacks: "watchCallbacks";
|
|
9
|
-
readonly setExternalMode: "setExternalMode";
|
|
10
15
|
readonly setMaterialById: "setMaterialById";
|
|
11
16
|
readonly showEmbeddedMenu: "showEmbeddedMenu";
|
|
12
17
|
readonly forceSetDeviceType: "forceSetDeviceType";
|
|
18
|
+
readonly setEnvironmentMaterialById: "setEnvironmentMaterialById";
|
|
13
19
|
};
|
|
14
20
|
export type ToMetaBoxActions = (typeof ToMetaBoxApiAction)[keyof typeof ToMetaBoxApiAction];
|
|
21
|
+
/**
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
15
24
|
export type ToMetaboxMessagePayload = ToMetaboxMessagePayloads[keyof ToMetaboxMessagePayloads];
|
|
16
25
|
export interface ToMetaboxMessagePayloads {
|
|
17
26
|
getPdf: void;
|
|
@@ -21,6 +30,10 @@ export interface ToMetaboxMessagePayloads {
|
|
|
21
30
|
setProduct: {
|
|
22
31
|
productId: string;
|
|
23
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated
|
|
35
|
+
* @hidden
|
|
36
|
+
*/
|
|
24
37
|
addResponse: void;
|
|
25
38
|
getFastRender: {
|
|
26
39
|
format: MimeType;
|
|
@@ -30,17 +43,21 @@ export interface ToMetaboxMessagePayloads {
|
|
|
30
43
|
};
|
|
31
44
|
};
|
|
32
45
|
watchCallbacks: void;
|
|
33
|
-
setExternalMode: void;
|
|
34
46
|
setMaterialById: {
|
|
35
47
|
productId: string;
|
|
36
48
|
slotId: string;
|
|
37
49
|
materialId: string;
|
|
38
50
|
};
|
|
51
|
+
setEnvironmentMaterialById: {
|
|
52
|
+
productId: string;
|
|
53
|
+
slotId: string;
|
|
54
|
+
materialId: string;
|
|
55
|
+
};
|
|
39
56
|
showEmbeddedMenu: {
|
|
40
57
|
visible: boolean;
|
|
41
58
|
};
|
|
42
59
|
forceSetDeviceType: {
|
|
43
|
-
deviceType:
|
|
60
|
+
deviceType: ApplicationDeviceType;
|
|
44
61
|
};
|
|
45
62
|
}
|
|
46
63
|
export interface ToMetaBoxMessageEnvelope {
|
|
@@ -7,11 +7,16 @@ export const ToMetaBoxApiAction = {
|
|
|
7
7
|
getPdf: 'getPdf',
|
|
8
8
|
loadLevel: 'loadLevel',
|
|
9
9
|
setProduct: 'setProduct',
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated, use 'watchCallbacks'"
|
|
12
|
+
* use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
|
|
13
|
+
* @hidden
|
|
14
|
+
*/
|
|
10
15
|
addResponse: 'addResponse',
|
|
11
16
|
getFastRender: 'getFastRender',
|
|
12
17
|
watchCallbacks: 'watchCallbacks',
|
|
13
|
-
setExternalMode: 'setExternalMode',
|
|
14
18
|
setMaterialById: 'setMaterialById',
|
|
15
19
|
showEmbeddedMenu: 'showEmbeddedMenu',
|
|
16
20
|
forceSetDeviceType: 'forceSetDeviceType',
|
|
21
|
+
setEnvironmentMaterialById: 'setEnvironmentMaterialById',
|
|
17
22
|
};
|
|
@@ -7,18 +7,26 @@ export interface ConfiguratorEnvelope {
|
|
|
7
7
|
* A reference to the universal configurator.
|
|
8
8
|
*/
|
|
9
9
|
configurator: UniversalConfigurator | null;
|
|
10
|
-
/**
|
|
11
|
-
* A record mapping material selections.
|
|
12
|
-
*/
|
|
13
|
-
selectedMaterials: SelectedMaterials;
|
|
14
10
|
/**
|
|
15
11
|
* The unique product identifier.
|
|
16
12
|
*/
|
|
17
13
|
productId: string;
|
|
18
14
|
/**
|
|
19
|
-
*
|
|
15
|
+
* A record mapping product material selections.
|
|
16
|
+
*/
|
|
17
|
+
productMaterialsIds: SelectedIds;
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated, use `productMaterialsIds` instead.
|
|
20
|
+
*/
|
|
21
|
+
selectedMaterials: SelectedIds;
|
|
22
|
+
/**
|
|
23
|
+
* The unique environment identifier.
|
|
24
|
+
*/
|
|
25
|
+
environmentId: string;
|
|
26
|
+
/**
|
|
27
|
+
* A record mapping environment material selections.
|
|
20
28
|
*/
|
|
21
|
-
|
|
29
|
+
environmentMaterialsIds: SelectedIds;
|
|
22
30
|
}
|
|
23
31
|
/**
|
|
24
32
|
* Represents the universal configurator with its basic properties and components.
|
|
@@ -149,4 +157,4 @@ export interface Environment {
|
|
|
149
157
|
/**
|
|
150
158
|
* Defines the structure for a mapping of selected materials.
|
|
151
159
|
*/
|
|
152
|
-
export type
|
|
160
|
+
export type SelectedIds = Record<string, Record<string, string>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const APPLICATION_DEVICE_TYPES: {
|
|
2
|
+
readonly deviceTypeAuto: "deviceTypeAuto";
|
|
3
|
+
readonly deviceTypeMobile: "deviceTypeMobile";
|
|
4
|
+
readonly deviceTypeDesktop: "deviceTypeDesktop";
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
* Represents the type of device for the application.
|
|
9
|
+
*/
|
|
10
|
+
export type ApplicationDeviceType = (typeof APPLICATION_DEVICE_TYPES)[keyof typeof APPLICATION_DEVICE_TYPES];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025.
|
|
3
|
+
* 3DSource.com, Sergii Karanda steve@3dsource.com
|
|
4
|
+
* All Rights Reserved
|
|
5
|
+
*/
|
|
6
|
+
export const APPLICATION_DEVICE_TYPES = {
|
|
7
|
+
deviceTypeAuto: 'deviceTypeAuto',
|
|
8
|
+
deviceTypeMobile: 'deviceTypeMobile',
|
|
9
|
+
deviceTypeDesktop: 'deviceTypeDesktop',
|
|
10
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ToMetaBoxMessageEnvelope } from '../interfaces/ToMetaboxMessagePayloads';
|
|
1
|
+
import type { ToMetaBoxMessageEnvelope } from '../interfaces/ToMetaboxMessagePayloads';
|
|
2
2
|
declare global {
|
|
3
3
|
interface Window {
|
|
4
4
|
env3DSource: {
|
|
@@ -14,6 +14,7 @@ declare global {
|
|
|
14
14
|
*
|
|
15
15
|
* @remarks
|
|
16
16
|
* This class sets up a communication channel with the embedded content via window messages.
|
|
17
|
+
* @hidden
|
|
17
18
|
*/
|
|
18
19
|
export declare class Communicator {
|
|
19
20
|
/**
|
|
@@ -6,12 +6,18 @@
|
|
|
6
6
|
* the communicator for interacting with the MetaBox embedded content.
|
|
7
7
|
*
|
|
8
8
|
* @param iframeSrc - The source URL of the MetaBox iframe.
|
|
9
|
+
* Additional url parameters:
|
|
10
|
+
* ```javascript
|
|
11
|
+
* sidebar=false - disables the internal MetaBox menu
|
|
12
|
+
* introImage=https://example.com/image.png - sets the intro image
|
|
13
|
+
* ```
|
|
14
|
+
* 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
|
|
15
|
+
*
|
|
9
16
|
* @param containerId - The ID of the layout element. Defaults to 'embed3DSource'.
|
|
10
17
|
*
|
|
11
18
|
* @throws Error if the container element with the specified ID is not found.
|
|
12
19
|
*
|
|
13
20
|
* @example
|
|
14
|
-
*
|
|
15
21
|
* import {
|
|
16
22
|
* integrateMetaBox,
|
|
17
23
|
* } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
|
|
@@ -12,12 +12,18 @@ import { Communicator } from './initializeCommunicator';
|
|
|
12
12
|
* the communicator for interacting with the MetaBox embedded content.
|
|
13
13
|
*
|
|
14
14
|
* @param iframeSrc - The source URL of the MetaBox iframe.
|
|
15
|
+
* Additional url parameters:
|
|
16
|
+
* ```javascript
|
|
17
|
+
* sidebar=false - disables the internal MetaBox menu
|
|
18
|
+
* introImage=https://example.com/image.png - sets the intro image
|
|
19
|
+
* ```
|
|
20
|
+
* 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
|
|
21
|
+
*
|
|
15
22
|
* @param containerId - The ID of the layout element. Defaults to 'embed3DSource'.
|
|
16
23
|
*
|
|
17
24
|
* @throws Error if the container element with the specified ID is not found.
|
|
18
25
|
*
|
|
19
26
|
* @example
|
|
20
|
-
*
|
|
21
27
|
* import {
|
|
22
28
|
* integrateMetaBox,
|
|
23
29
|
* } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@3dsource/metabox-front-api",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "API for MetaBox configurator",
|
|
3
|
+
"version": "0.0.8",
|
|
4
|
+
"description": "API for MetaBox BASIC configurator",
|
|
5
5
|
"main": "dist/index.ts",
|
|
6
6
|
"unpkg": "dist/index.js",
|
|
7
7
|
"type": "module",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"clean": "rimraf dist",
|
|
11
11
|
"packAll": "npm run clean && npm run build && npm pack",
|
|
12
12
|
"publishApi": "npm run packAll && npm publish --access public",
|
|
13
|
-
"apiDoc": "typedoc --entryPointStrategy Expand src/index.ts --tsconfig
|
|
13
|
+
"apiDoc": "typedoc --entryPointStrategy Expand src/index.ts --tsconfig ./../../../tsconfig.typedoc.json --out ./../../../dist/browser/apiDocBasic"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"dist"
|