@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 CHANGED
@@ -1,48 +1,196 @@
1
- ````markdown
2
1
  # MetaBox API
3
2
 
4
- This package provides an API for interacting with the MetaBox configurator.
3
+ This package provides an API for interacting with the MetaBox configurator using plain JavaScript.
5
4
 
6
- ## Installation
5
+ ### Installation (for using with frameworks like Angular, React, etc.)
7
6
 
8
7
  ```sh
9
- npm install @3dsource/metabox-front-api
8
+ npm install @3dsource/metabox-front-api --save
10
9
  ```
11
- ````
12
10
 
13
- ## Usage
11
+ then
14
12
 
15
13
  ```typescript
16
- import { SetEnvironment, SetMaterial, SetProduct, ShowEmbeddedMenu } from '@3dsource/metabox-front-api';
14
+ import { FromMetaBoxApiAction, GetFastRender, GetPdf, integrateMetaBox, saveImage, SetEnvironment, SetMaterial, SetProduct, ShowEmbeddedMenu,... } from '@3dsource/metabox-front-api';
15
+ ```
16
+
17
+ **OR** work with direct import from `NPM` using `CDN` network unpkg.com (you can also download package and use it locally):
18
+
19
+ ```javascript
20
+ import { FromMetaBoxApiAction, GetFastRender, GetPdf, integrateMetaBox, saveImage, SetEnvironment, SetMaterial, SetProduct, ShowEmbeddedMenu,... } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
21
+ ```
22
+
23
+ ## Usage
17
24
 
18
- // Example usage
19
- const loadEnv = new SetEnvironment('env-id');
20
- const setMaterial = new SetMaterial('product-id', 'slot-id', 'material-id');
21
- const setProduct = new SetProduct('product-id');
22
- const showMenu = new ShowEmbeddedMenu(true);
25
+ ### 1. Include Required Scripts
26
+
27
+ Below is an example demonstrating how to use the MetaBox API functions:
28
+
29
+ Insert this code into your HTML file just before the closing `</body>` tag:
30
+
31
+ **EXAMPLE:**
32
+
33
+ ```html
34
+ <script type="module">
35
+ import { integrateMetaBox, SetEnvironment, SetMaterial, SetProduct, ShowEmbeddedMenu, GetFastRender, GetPdf, saveImage } from '@3dsource/metabox-front-api';
36
+
37
+ // Expose API
38
+ window.env3DSource.apiReady = (api) => {
39
+ this.api = api;
40
+ this.api.addEventListener('metaboxData', (data) => {
41
+ const { action, payload, eventType } = data;
42
+ if (action !== FromMetaboxApiActions.bridge) {
43
+ return;
44
+ }
45
+
46
+ if (eventType === 'viewportReady' && payload === true) {
47
+ //You can use this event to trigger any action that can work only when the viewport is ready,
48
+ //i.e. GetPdf or GetFastRender
49
+
50
+ // Get a fast render (optionally specify size)
51
+ new GetFastRender('image/png', { x: 1024, y: 1024 });
52
+
53
+ // Generate a PDF of the current view
54
+ new GetPdf();
55
+ }
56
+
57
+ if (eventType === 'basicConfiguratorDataWithState') {
58
+ this.updateConfiguratorData(data);
59
+ this.setupInitialState();
60
+ }
61
+
62
+ if (eventType === 'getFastRender') {
63
+ //Catches the render image
64
+ saveImage(payload, 'Render.png');
65
+ }
66
+ });
67
+ };
68
+
69
+ /**
70
+ * @see examples, @see documentation
71
+ * @param data
72
+ */
73
+ function updateConfiguratorData(data) {
74
+ //Use data on your own
75
+ }
76
+
77
+ /**
78
+ * Setup initial state
79
+ */
80
+ function setupInitialState() {
81
+ // Set product
82
+ new SetProduct('product-id');
83
+
84
+ // Set environment
85
+ new SetEnvironment('env-id');
86
+
87
+ // Set material
88
+ new SetMaterial('product-id', 'slot-id', 'material-id');
89
+
90
+ // Toggle embedded menu
91
+ new ShowEmbeddedMenu(false);
92
+ }
93
+
94
+ // Integrate the 3D configurator into your page
95
+
96
+ 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
+ integrateMetaBox(url, 'embed3DSource');
102
+ </script>
23
103
  ```
24
104
 
25
- ## API
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
+ ### Documentation for current example
118
+
119
+ ### `integrateMetaBox`
120
+
121
+ - **Description**: Integrates the MetaBox configurator into the specified container.
122
+ - **Usage**:
123
+ ```typescript
124
+ integrateMetaBox(configuratorUrl: string, containerId: string): void;
125
+ ```
26
126
 
27
127
  ### `SetEnvironment`
28
128
 
29
- - **Description**: Set environment by ID.
30
- - **Constructor**: `constructor(environmentId: string)`
129
+ - **Description**: Sets the environment by ID.
130
+ - **Constructor**:
131
+ ```typescript
132
+ new SetEnvironment(environmentId: string);
133
+ ```
31
134
 
32
135
  ### `SetMaterial`
33
136
 
34
- - **Description**: Set material by ID.
35
- - **Constructor**: `constructor(productId: string, slotId: string, materialId: string)`
137
+ - **Description**: Sets the material for a given product slot.
138
+ - **Constructor**:
139
+ ```typescript
140
+ new SetMaterial(productId: string, slotId: string, materialId: string);
141
+ ```
36
142
 
37
143
  ### `SetProduct`
38
144
 
39
- - **Description**: Set product by ID.
40
- - **Constructor**: `constructor(productId: string)`
145
+ - **Description**: Sets the product by ID.
146
+ - **Constructor**:
147
+ ```typescript
148
+ new SetProduct(productId: string);
149
+ ```
41
150
 
42
151
  ### `ShowEmbeddedMenu`
43
152
 
44
- - **Description**: Toggles EmbeddedMenu in MetaBox.
45
- - **Constructor**: `constructor(visible: boolean)`
153
+ - **Description**: Toggles the embedded menu in the MetaBox configurator.
154
+ - **Constructor**:
155
+ ```typescript
156
+ new ShowEmbeddedMenu(visible: boolean);
157
+ ```
158
+
159
+ ### `GetFastRender`
160
+
161
+ **Important:** Before invoking this action, ensure that the MetaBox viewport is fully loaded. This is indicated by the event:
162
+
163
+ ```javascript
164
+ data.eventType === 'viewportReady' && data.payload === true.
165
+ ```
166
+
167
+ - **Description**: Retrieves a fast render of the current view.
168
+ - **Usage**:
169
+ ```typescript
170
+ new GetFastRender(mimeType: string, size?: { x: number, y: number });
171
+ ```
172
+
173
+ ### `GetPdf`
174
+
175
+ **Important:** Before invoking this action, ensure that the MetaBox viewport is fully loaded. This is indicated by the event:
176
+
177
+ ```javascript
178
+ data.eventType === 'viewportReady' && data.payload === true.
179
+ ```
180
+
181
+ - **Description**: Generates a PDF of the current view.
182
+ - **Usage**:
183
+ ```typescript
184
+ new GetPdf();
185
+ ```
186
+
187
+ ### `saveImage`
188
+
189
+ - **Description**: Saves the arrived rendered image to a file using utility function.
190
+ - **Usage**:
191
+ ```typescript
192
+ saveImage(renderData: string, fileName: string): void;
193
+ ```
46
194
 
47
195
  ```
48
196
 
@@ -1,3 +1,4 @@
1
+ import type { Communicator } from '../lib/initializeCommunicator';
1
2
  export declare class ApiAction {
2
- api: any;
3
+ protected api: Communicator;
3
4
  }
@@ -4,20 +4,51 @@ import { ApiAction } from './ApiAction';
4
4
  * @remarks
5
5
  * This type represents the allowed image formats.
6
6
  */
7
- export type ImageFormat = 'image/png' | 'image/jpeg';
7
+ export type MimeType = 'image/png' | 'image/jpeg' | 'image/webp';
8
8
  /**
9
9
  * Represents a fast render action.
10
10
  * @remarks
11
- * This class sends a message to the MetaBox API to obtain a fast render
12
- * based on the provided format and optional size.
11
+ * This class sends a message to the MetaBox API to obtain a fast render based on the provided format and optional size.
12
+ *
13
+ * **Important:** Before invoking this action, ensure that the MetaBox viewport is fully loaded. This is indicated by the event:
14
+ * ```javascript
15
+ * data.eventType === 'viewportReady' && data.payload === true.
16
+ * ```
17
+ * Only then request be processed.
18
+ *
19
+ * @example
20
+ * import { integrateMetaBox, GetFastRender, saveImage } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
21
+ *
22
+ * // Integrate the MetaBox configurator into an HTML element with the ID 'embed3DSource'
23
+ * integrateMetaBox(
24
+ * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
25
+ * 'embed3DSource'
26
+ * );
27
+ *
28
+ * // Set up the global API environment
29
+ * window.env3DSource = window.env3DSource || {};
30
+ * window.env3DSource.apiReady = (api) => {
31
+ * // Listen for events from the MetaBox API
32
+ * api.addEventListener('metaboxData', (data) => {
33
+ * // Ensure the viewport is ready before sending render requests
34
+ * if (data.eventType === 'viewportReady' && data.payload === true) {
35
+ * // Request a fast render (PNG image with 1024x1024 dimensions)
36
+ * new GetFastRender('image/png', { x: 1024, y: 1024 });
37
+ * }
38
+ * // Process the fast render response
39
+ * if (data.eventType === 'getFastRender') {
40
+ * saveImage(data.payload, 'Render.png');
41
+ * }
42
+ * });
43
+ * };
13
44
  */
14
45
  export declare class GetFastRender extends ApiAction {
15
46
  /**
16
47
  * Constructs an instance of GetFastRender.
17
- * @param format - The output format.
48
+ * @param mimeType - The output format.
18
49
  * @param size - Optional size in pixels.
19
50
  */
20
- constructor(format: ImageFormat, size?: {
51
+ constructor(mimeType: MimeType, size?: {
21
52
  x: number;
22
53
  y: number;
23
54
  });
@@ -3,28 +3,59 @@
3
3
  * 3DSource.com, Sergii Karanda steve@3dsource.com
4
4
  * All Rights Reserved
5
5
  */
6
- import { ToMetaBoxApiAction } from '../lib/MetaBoxApiAction';
7
6
  import { ApiAction } from './ApiAction';
7
+ import { ToMetaBoxApiActions } from '../interfaces/ToMetaboxMessagePayloads';
8
8
  /**
9
9
  * Represents a fast render action.
10
10
  * @remarks
11
- * This class sends a message to the MetaBox API to obtain a fast render
12
- * based on the provided format and optional size.
11
+ * This class sends a message to the MetaBox API to obtain a fast render based on the provided format and optional size.
12
+ *
13
+ * **Important:** Before invoking this action, ensure that the MetaBox viewport is fully loaded. This is indicated by the event:
14
+ * ```javascript
15
+ * data.eventType === 'viewportReady' && data.payload === true.
16
+ * ```
17
+ * Only then request be processed.
18
+ *
19
+ * @example
20
+ * import { integrateMetaBox, GetFastRender, saveImage } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
21
+ *
22
+ * // Integrate the MetaBox configurator into an HTML element with the ID 'embed3DSource'
23
+ * integrateMetaBox(
24
+ * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
25
+ * 'embed3DSource'
26
+ * );
27
+ *
28
+ * // Set up the global API environment
29
+ * window.env3DSource = window.env3DSource || {};
30
+ * window.env3DSource.apiReady = (api) => {
31
+ * // Listen for events from the MetaBox API
32
+ * api.addEventListener('metaboxData', (data) => {
33
+ * // Ensure the viewport is ready before sending render requests
34
+ * if (data.eventType === 'viewportReady' && data.payload === true) {
35
+ * // Request a fast render (PNG image with 1024x1024 dimensions)
36
+ * new GetFastRender('image/png', { x: 1024, y: 1024 });
37
+ * }
38
+ * // Process the fast render response
39
+ * if (data.eventType === 'getFastRender') {
40
+ * saveImage(data.payload, 'Render.png');
41
+ * }
42
+ * });
43
+ * };
13
44
  */
14
45
  export class GetFastRender extends ApiAction {
15
46
  /**
16
47
  * Constructs an instance of GetFastRender.
17
- * @param format - The output format.
48
+ * @param mimeType - The output format.
18
49
  * @param size - Optional size in pixels.
19
50
  */
20
- constructor(format, size) {
51
+ constructor(mimeType, size) {
21
52
  super();
22
53
  this.api.sendMessageToMetaBox({
23
54
  payload: {
24
- format,
55
+ format: mimeType,
25
56
  size,
26
57
  },
27
- action: ToMetaBoxApiAction.getFastRender,
58
+ action: ToMetaBoxApiActions.getFastRender,
28
59
  });
29
60
  }
30
61
  }
@@ -1,9 +1,33 @@
1
1
  import { ApiAction } from './ApiAction';
2
2
  /**
3
3
  * Represents an action to get a PDF from Metabox.
4
- *
5
4
  * @remarks
5
+ * This class sends a message to the MetaBox API to generate a PDF based on the current configuration.
6
6
  * This action does not require any parameters.
7
+ *
8
+ * **Important:** Before invoking this action, ensure that the MetaBox viewport is fully loaded. This is indicated by the event:
9
+ *```javascript
10
+ * data.eventType === 'viewportReady' && data.payload === true.
11
+ * ```
12
+ * Only then request be processed.
13
+ *
14
+ * @example
15
+ * import { integrateMetaBox, GetPdf } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
16
+ *
17
+ * integrateMetaBox(
18
+ * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
19
+ * 'embed3DSource'
20
+ * );
21
+ *
22
+ * window.env3DSource = window.env3DSource || {};
23
+ * window.env3DSource.apiReady = (api) => {
24
+ * api.addEventListener('metaboxData', (data) => {
25
+ * if (data.eventType === 'viewportReady' && data.payload === true) {
26
+ * // Request a PDF of the current configuration
27
+ * new GetPdf();
28
+ * }
29
+ * });
30
+ * };
7
31
  */
8
32
  export declare class GetPdf extends ApiAction {
9
33
  /**
@@ -3,13 +3,37 @@
3
3
  * 3DSource.com, Sergii Karanda steve@3dsource.com
4
4
  * All Rights Reserved
5
5
  */
6
- import { ToMetaBoxApiAction } from '../lib/MetaBoxApiAction';
7
6
  import { ApiAction } from './ApiAction';
7
+ import { ToMetaBoxApiActions } from '../interfaces/ToMetaboxMessagePayloads';
8
8
  /**
9
9
  * Represents an action to get a PDF from Metabox.
10
- *
11
10
  * @remarks
11
+ * This class sends a message to the MetaBox API to generate a PDF based on the current configuration.
12
12
  * This action does not require any parameters.
13
+ *
14
+ * **Important:** Before invoking this action, ensure that the MetaBox viewport is fully loaded. This is indicated by the event:
15
+ *```javascript
16
+ * data.eventType === 'viewportReady' && data.payload === true.
17
+ * ```
18
+ * Only then request be processed.
19
+ *
20
+ * @example
21
+ * import { integrateMetaBox, GetPdf } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
22
+ *
23
+ * integrateMetaBox(
24
+ * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
25
+ * 'embed3DSource'
26
+ * );
27
+ *
28
+ * window.env3DSource = window.env3DSource || {};
29
+ * window.env3DSource.apiReady = (api) => {
30
+ * api.addEventListener('metaboxData', (data) => {
31
+ * if (data.eventType === 'viewportReady' && data.payload === true) {
32
+ * // Request a PDF of the current configuration
33
+ * new GetPdf();
34
+ * }
35
+ * });
36
+ * };
13
37
  */
14
38
  export class GetPdf extends ApiAction {
15
39
  /**
@@ -21,7 +45,7 @@ export class GetPdf extends ApiAction {
21
45
  constructor() {
22
46
  super();
23
47
  this.api.sendMessageToMetaBox({
24
- action: ToMetaBoxApiAction.getPdf,
48
+ action: ToMetaBoxApiActions.getPdf,
25
49
  });
26
50
  }
27
51
  }
@@ -1,9 +1,25 @@
1
1
  import { ApiAction } from './ApiAction';
2
2
  /**
3
3
  * Represents an action to set the environment by its ID.
4
- *
5
4
  * @remarks
6
5
  * This action sends a message to the MetaBox API to load the environment level using the specified environment ID.
6
+ * It requires the MetaBox API to be properly initialized and an event listener to be registered.
7
+ *
8
+ * @example
9
+ * import { integrateMetaBox, SetEnvironment } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
10
+ *
11
+ * // Integrate the MetaBox configurator into an HTML element with the ID 'embed3DSource'
12
+ * integrateMetaBox(
13
+ * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
14
+ * 'embed3DSource'
15
+ * );
16
+ *
17
+ * // Setup API ready callback
18
+ * window.env3DSource = window.env3DSource || {};
19
+ * window.env3DSource.apiReady = (api) => {
20
+ * // Change the environment to '55555555-1234-1234-1234-01234567890'
21
+ * new SetEnvironment('55555555-1234-1234-1234-01234567890');
22
+ * };
7
23
  */
8
24
  export declare class SetEnvironment extends ApiAction {
9
25
  /**
@@ -3,13 +3,29 @@
3
3
  * 3DSource.com, Sergii Karanda steve@3dsource.com
4
4
  * All Rights Reserved
5
5
  */
6
- import { ToMetaBoxApiAction } from '../lib/MetaBoxApiAction';
7
6
  import { ApiAction } from './ApiAction';
7
+ import { ToMetaBoxApiActions } from '../interfaces/ToMetaboxMessagePayloads';
8
8
  /**
9
9
  * Represents an action to set the environment by its ID.
10
- *
11
10
  * @remarks
12
11
  * This action sends a message to the MetaBox API to load the environment level using the specified environment ID.
12
+ * It requires the MetaBox API to be properly initialized and an event listener to be registered.
13
+ *
14
+ * @example
15
+ * import { integrateMetaBox, SetEnvironment } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
16
+ *
17
+ * // Integrate the MetaBox configurator into an HTML element with the ID 'embed3DSource'
18
+ * integrateMetaBox(
19
+ * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
20
+ * 'embed3DSource'
21
+ * );
22
+ *
23
+ * // Setup API ready callback
24
+ * window.env3DSource = window.env3DSource || {};
25
+ * window.env3DSource.apiReady = (api) => {
26
+ * // Change the environment to '55555555-1234-1234-1234-01234567890'
27
+ * new SetEnvironment('55555555-1234-1234-1234-01234567890');
28
+ * };
13
29
  */
14
30
  export class SetEnvironment extends ApiAction {
15
31
  /**
@@ -23,7 +39,7 @@ export class SetEnvironment extends ApiAction {
23
39
  payload: {
24
40
  id: environmentId,
25
41
  },
26
- action: ToMetaBoxApiAction.loadLevel,
42
+ action: ToMetaBoxApiActions.loadLevel,
27
43
  });
28
44
  }
29
45
  }
@@ -4,6 +4,38 @@ import { ApiAction } from './ApiAction';
4
4
  *
5
5
  * @remarks
6
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 SetMaterial(
32
+ * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
33
+ * 'carpaint',
34
+ * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
35
+ * );
36
+ * }
37
+ * });
38
+ * };
7
39
  */
8
40
  export declare class SetMaterial extends ApiAction {
9
41
  /**
@@ -3,13 +3,45 @@
3
3
  * 3DSource.com, Sergii Karanda steve@3dsource.com
4
4
  * All Rights Reserved
5
5
  */
6
- import { ToMetaBoxApiAction } from '../lib/MetaBoxApiAction';
7
6
  import { ApiAction } from './ApiAction';
7
+ import { ToMetaBoxApiActions } from '../interfaces/ToMetaboxMessagePayloads';
8
8
  /**
9
9
  * Represents an action to set a material by its ID.
10
10
  *
11
11
  * @remarks
12
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 SetMaterial(
38
+ * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
39
+ * 'carpaint',
40
+ * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
41
+ * );
42
+ * }
43
+ * });
44
+ * };
13
45
  */
14
46
  export class SetMaterial extends ApiAction {
15
47
  /**
@@ -27,7 +59,7 @@ export class SetMaterial extends ApiAction {
27
59
  slotId,
28
60
  materialId,
29
61
  },
30
- action: ToMetaBoxApiAction.setMaterialById,
62
+ action: ToMetaBoxApiActions.setMaterialById,
31
63
  });
32
64
  }
33
65
  }
@@ -3,8 +3,8 @@
3
3
  * 3DSource.com, Sergii Karanda steve@3dsource.com
4
4
  * All Rights Reserved
5
5
  */
6
- import { ToMetaBoxApiAction } from '../lib/MetaBoxApiAction';
7
6
  import { ApiAction } from './ApiAction';
7
+ import { ToMetaBoxApiActions } from '../interfaces/ToMetaboxMessagePayloads';
8
8
  /**
9
9
  * Represents an action to set a product by its ID.
10
10
  *
@@ -23,7 +23,7 @@ export class SetProduct extends ApiAction {
23
23
  payload: {
24
24
  productId,
25
25
  },
26
- action: ToMetaBoxApiAction.setProduct,
26
+ action: ToMetaBoxApiActions.setProduct,
27
27
  });
28
28
  }
29
29
  }
@@ -3,8 +3,8 @@
3
3
  * 3DSource.com, Sergii Karanda steve@3dsource.com
4
4
  * All Rights Reserved
5
5
  */
6
- import { ToMetaBoxApiAction } from '../lib/MetaBoxApiAction';
7
6
  import { ApiAction } from './ApiAction';
7
+ import { ToMetaBoxApiActions } from '../interfaces/ToMetaboxMessagePayloads';
8
8
  /**
9
9
  * Represents an action to toggle the Embedded Menu in MetaBox.
10
10
  *
@@ -20,7 +20,7 @@ export class ShowEmbeddedMenu extends ApiAction {
20
20
  constructor(visible) {
21
21
  super();
22
22
  this.api.sendMessageToMetaBox({
23
- action: ToMetaBoxApiAction.showEmbeddedMenu,
23
+ action: ToMetaBoxApiActions.showEmbeddedMenu,
24
24
  payload: {
25
25
  visible,
26
26
  },
@@ -0,0 +1,16 @@
1
+ import { ApiAction } from './ApiAction';
2
+ /**
3
+ * @internal
4
+ * Represents an action to watch Unreal callbacks from Unreal engine.
5
+ * @remarks
6
+ * This class sends a message to the MetaBox API to generate a PDF based on the current configuration.
7
+ */
8
+ export declare class WatchCallbacks extends ApiAction {
9
+ /**
10
+ * Creates an instance of WatchCallbacks.
11
+ *
12
+ * @remarks
13
+ * This constructor does not require any parameters.
14
+ */
15
+ constructor();
16
+ }
@@ -0,0 +1,27 @@
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 { ToMetaBoxApiActions } from '../interfaces/ToMetaboxMessagePayloads';
8
+ /**
9
+ * @internal
10
+ * Represents an action to watch Unreal callbacks from Unreal engine.
11
+ * @remarks
12
+ * This class sends a message to the MetaBox API to generate a PDF based on the current configuration.
13
+ */
14
+ export class WatchCallbacks extends ApiAction {
15
+ /**
16
+ * Creates an instance of WatchCallbacks.
17
+ *
18
+ * @remarks
19
+ * This constructor does not require any parameters.
20
+ */
21
+ constructor() {
22
+ super();
23
+ this.api.sendMessageToMetaBox({
24
+ action: ToMetaBoxApiActions.watchCallbacks,
25
+ });
26
+ }
27
+ }