@3dsource/metabox-front-api 0.0.18 → 0.0.19-beta.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.
@@ -1,70 +1,5 @@
1
1
  import type { ConfiguratorEnvelope } from './UniversalConfigurator';
2
- export declare const FromMetaboxApiAction: {
3
- readonly bridge: "bridge";
4
- readonly appLoaded: "appLoaded";
5
- /**
6
- * @hidden
7
- * @deprecated, use MetaBoxApiAction.Bridge with eventType: "unrealFeature"
8
- */
9
- readonly unrealFeatureBridge: "unrealFeatureBridge";
10
- /**
11
- * @hidden
12
- * @deprecated, use MetaBoxApiAction.Bridge with eventType: "unrealCallback"
13
- */
14
- readonly unrealCallback: "unrealCallback";
15
- /**
16
- * @hidden
17
- * @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
18
- */
19
- readonly configuratorDataWithStateBridge: "configuratorDataWithStateBridge";
20
- /**
21
- * @hidden
22
- * @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
23
- */
24
- readonly configuratorDataBridge: "configuratorDataBridge";
25
- /**
26
- * @hidden
27
- * @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
28
- */
29
- readonly menuDataBridge: "menuDataBridge";
30
- /**
31
- * @hidden
32
- * @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
33
- */
34
- readonly flatMenuDataBridge: "flatMenuDataBridge";
35
- /**
36
- * @hidden
37
- * @deprecated, use Bridge with isFullscreen
38
- */
39
- readonly fullScreenBridge: "fullScreenBridge";
40
- /**
41
- * @hidden
42
- * @deprecated, use Bridge with streamResolution
43
- */
44
- readonly videoSize: "videoSize";
45
- /**
46
- * @hidden
47
- * Used in a platform, must be removed in future
48
- * @deprecated
49
- */
50
- readonly unrealResponse: "unrealResponse";
51
- /**
52
- * @hidden
53
- * @deprecated\
54
- */
55
- readonly getFastRender: "getFastRender";
56
- };
57
- export type FromMetaBoxActions = (typeof FromMetaboxApiAction)[keyof typeof FromMetaboxApiAction];
58
- /**
59
- * @hidden
60
- * @internal
61
- * Used for signaling that the app is loaded and ready to open api.
62
- */
63
- export interface MCAppLoaded {
64
- action: string;
65
- eventType?: unknown;
66
- payload?: unknown;
67
- }
2
+ import type { StreamResolutionProps, UnrealCallBackJson, UnrealState } from '@3dsource/angular-unreal-module';
68
3
  export interface FromMetaboxMessagePayloads {
69
4
  /**
70
5
  * Dispatches Every time the configurator data is updated.
@@ -101,29 +36,31 @@ export interface FromMetaboxMessagePayloads {
101
36
  * Dispatches every Unreal is sending a command callback.
102
37
  * Works only after the new WatchCallbacks () command is sent.
103
38
  */
104
- unrealCallback: object;
39
+ unrealCallback: {
40
+ json: UnrealCallBackJson;
41
+ };
105
42
  /**
106
43
  * Dispatches every time when Unreal is sending ordered render with new GetFastRender() command.
107
44
  */
108
45
  fastRender: string | null;
109
46
  /**
110
47
  * @hidden
111
- * @Deprecated, use fastRender
48
+ * @deprecated, use fastRender
112
49
  */
113
50
  getFastRender: string | null;
114
51
  /**
115
52
  * @experimental
116
53
  * Dispatches every Unreal state is changing, including all unreal module state.
117
54
  */
118
- unrealFeature: object;
55
+ unrealFeature: UnrealState;
119
56
  /**
120
57
  * Dispatches every time when Unreal is changing its video stream size.
121
58
  */
122
- streamResolution: {
123
- width: number;
124
- height: number;
125
- };
59
+ streamResolution: StreamResolutionProps;
126
60
  }
61
+ /**
62
+ * @hidden
63
+ */
127
64
  export type FromMetaBoxApiEvents = keyof FromMetaboxMessagePayloads;
128
65
  /**
129
66
  * @internal
@@ -135,7 +72,18 @@ export interface MetaBoxApiEnvelope<T extends FromMetaBoxApiEvents> {
135
72
  payload: FromMetaboxMessagePayloads[T];
136
73
  }
137
74
  /**
75
+ * @hidden
138
76
  * @internal
77
+ * Used for signaling that the app is loaded and ready to open api.
78
+ */
79
+ export interface MCAppLoaded {
80
+ action: 'appLoaded';
81
+ eventType?: unknown;
82
+ payload?: unknown;
83
+ }
84
+ /**
85
+ * @internal
86
+ * @hidden
139
87
  * This creates a union of all event envelopes defined in MetaBoxAPIPayloads.
140
88
  */
141
89
  export type FromMetaBoxAPIEnvelope = {
@@ -1,30 +1,14 @@
1
1
  import type { MimeType } from '../actions/GetFastRender';
2
- import type { ApplicationDeviceTypesKeys } from './application-device-types';
3
- export declare const ToMetaBoxApiAction: {
4
- readonly getPdf: "getPdf";
5
- readonly loadLevel: "loadLevel";
6
- readonly setProduct: "setProduct";
7
- /**
8
- * @deprecated, use 'watchCallbacks'"
9
- * use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
10
- * @hidden
11
- */
12
- readonly addResponse: "addResponse";
13
- readonly getFastRender: "getFastRender";
14
- readonly watchCallbacks: "watchCallbacks";
15
- readonly setMaterialById: "setMaterialById";
16
- readonly showEmbeddedMenu: "showEmbeddedMenu";
17
- readonly forceSetDeviceType: "forceSetDeviceType";
18
- readonly sendCommandToUnreal: "sendCommandToUnreal";
19
- readonly showOverlayInterface: "showOverlayInterface";
20
- readonly setEnvironmentMaterialById: "setEnvironmentMaterialById";
21
- readonly resetCamera: "resetCamera";
22
- };
23
- export type ToMetaBoxActions = (typeof ToMetaBoxApiAction)[keyof typeof ToMetaBoxApiAction];
2
+ import type { ApplicationDeviceTypes } from './application-device-types';
3
+ export type ToMetaBoxActions = 'getPdf' | 'loadLevel' | 'setProduct' | 'getFastRender' | 'watchCallbacks' | 'setMaterialById' | 'showEmbeddedMenu' | 'forceSetDeviceType' | 'sendCommandToUnreal' | 'showOverlayInterface' | 'setEnvironmentMaterialById' | 'resetCamera' | 'addResponse';
24
4
  /**
25
5
  * @internal
6
+ * @hidden
26
7
  */
27
8
  export type ToMetaboxMessagePayload = ToMetaboxMessagePayloads[keyof ToMetaboxMessagePayloads];
9
+ /**
10
+ * Interface for messages sent from the application to the MetaBox.
11
+ */
28
12
  export interface ToMetaboxMessagePayloads {
29
13
  getPdf: void;
30
14
  loadLevel: {
@@ -64,7 +48,7 @@ export interface ToMetaboxMessagePayloads {
64
48
  visible: boolean;
65
49
  };
66
50
  forceSetDeviceType: {
67
- deviceType: ApplicationDeviceTypesKeys;
51
+ deviceType: ApplicationDeviceTypes;
68
52
  };
69
53
  resetCamera: void;
70
54
  }
@@ -29,6 +29,10 @@ export interface ConfiguratorEnvelope {
29
29
  * A record mapping environment material selections.
30
30
  */
31
31
  environmentMaterialsIds: SelectedIds;
32
+ /**
33
+ * A configurator quote for sales
34
+ */
35
+ configuration: SelectedConfigurationForQuote | null;
32
36
  }
33
37
  /**
34
38
  * Represents the universal configurator with its basic properties and components.
@@ -81,6 +85,8 @@ export interface Product {
81
85
  /** The model information associated with the product. */
82
86
  /** Unique identifier for the product. */
83
87
  id: string;
88
+ /** Unique external id for the product. */
89
+ externalId: string;
84
90
  /** Showcase details for the product. */
85
91
  /** GraphQL typename for the product. */
86
92
  __typename: 'Product';
@@ -104,7 +110,7 @@ export interface Thumbnail {
104
110
  export interface Slot {
105
111
  /** Unique identifier for the slot. */
106
112
  id: string;
107
- /** Display label for the slot. */
113
+ /** Display a label for the slot. */
108
114
  label: string;
109
115
  /** A list of enabled materials for the slot. */
110
116
  enabledMaterials: Material[];
@@ -117,7 +123,7 @@ export interface Slot {
117
123
  export interface MetaProperty {
118
124
  /** Unique identifier for the metaProperty. */
119
125
  id: string;
120
- /** Display name for the metaProperty. */
126
+ /** Display the name for the metaProperty. */
121
127
  name: string;
122
128
  /** Value for the metaProperty. */
123
129
  value: string;
@@ -134,6 +140,8 @@ export interface Material {
134
140
  id: string;
135
141
  /** Title or name of the material. */
136
142
  title: string;
143
+ /** Unique external id for the material. */
144
+ externalId: string;
137
145
  /** List of thumbnails for the material. */
138
146
  thumbnailList: Thumbnail[];
139
147
  /** The model information associated with the material. */
@@ -177,3 +185,35 @@ export interface Environment {
177
185
  * Defines the structure for a mapping of selected materials.
178
186
  */
179
187
  export type SelectedIds = Record<string, Record<string, string>>;
188
+ /**
189
+ * Defines the structure for a mapping of the selected configuration.
190
+ */
191
+ export interface SelectedConfigurationForQuote {
192
+ product: {
193
+ id: string;
194
+ externalId: string;
195
+ title: string;
196
+ slots: {
197
+ id: string;
198
+ label: string;
199
+ material: {
200
+ id: string;
201
+ externalId: string;
202
+ title: string;
203
+ };
204
+ }[];
205
+ };
206
+ environment?: {
207
+ id: string;
208
+ title: string;
209
+ slots: {
210
+ id: string;
211
+ label: string;
212
+ material: {
213
+ id: string;
214
+ externalId: string;
215
+ title: string;
216
+ };
217
+ }[];
218
+ };
219
+ }
@@ -1,10 +1 @@
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 ApplicationDeviceTypesKeys = (typeof APPLICATION_DEVICE_TYPES)[keyof typeof APPLICATION_DEVICE_TYPES];
1
+ export type ApplicationDeviceTypes = 'deviceTypeAuto' | 'deviceTypeMobile' | 'deviceTypeDesktop';
@@ -1,13 +1,6 @@
1
- import type { ToMetaBoxMessageEnvelope } from '../interfaces/ToMetaboxMessagePayloads';
2
1
  import { EventDispatcher } from './EventDispatcher';
3
- declare global {
4
- interface Window {
5
- env3DSource: {
6
- api: Communicator;
7
- apiReady: (api: Communicator) => void;
8
- };
9
- }
10
- }
2
+ import type { CommandBase } from '../actions/CommandBase';
3
+ import type { FromMetaBoxApiEvents, FromMetaboxMessagePayloads } from '../interfaces/FromMetaboxMessagePayloads';
11
4
  /**
12
5
  * API class to handle communication with the embedded content.
13
6
  * @internal Do not Create an instance of this class directly.
@@ -40,10 +33,9 @@ export declare class Communicator extends EventDispatcher {
40
33
  destroy(): void;
41
34
  /**
42
35
  * Sends a message to the embedded content (MetaBox).
43
- *
44
- * @param data - The data to send.
36
+ * @param command
45
37
  */
46
- sendMessageToMetaBox(data: ToMetaBoxMessageEnvelope): void;
38
+ sendCommandToMetaBox<T extends CommandBase>(command: T): void;
47
39
  /**
48
40
  * Handles incoming messages by invoking the appropriate callbacks.
49
41
  *
@@ -60,5 +52,7 @@ export declare class Communicator extends EventDispatcher {
60
52
  * @remarks
61
53
  * This function sets up a listener that waits for the 'appLoaded' action and then initializes the Communicator.
62
54
  */
63
- static createInstance(): void;
55
+ static createInstance(apiReadyCallback: (api: Communicator) => void): void;
56
+ addEventListener<T extends FromMetaBoxApiEvents>(eventName: T, callback: (data: FromMetaboxMessagePayloads[T]) => void): this;
57
+ dispatchEvent<T extends FromMetaBoxApiEvents>(eventType: T, data: FromMetaboxMessagePayloads[T]): this;
64
58
  }
@@ -20,20 +20,20 @@ export declare class EventDispatcher {
20
20
  * @param messageType - The message type to listen for.
21
21
  * @param callback - The callback function to execute when a message is received.
22
22
  */
23
- addEventListener(messageType: string, callback: (data: unknown) => void): void;
23
+ addEventListener(messageType: string, callback: (data: unknown) => void): this;
24
24
  /**
25
25
  * Dispatches an event to all listeners of a specific message type.
26
26
  *
27
27
  * @param messageType - The message type.
28
28
  * @param data - The data associated with the event.
29
29
  */
30
- dispatchEvent(messageType: string, data: unknown): void;
30
+ dispatchEvent(messageType: string, data: unknown): this;
31
31
  /**
32
32
  * Removes an event listener for a specific type of message.
33
33
  *
34
34
  * @param messageType - The message type.
35
35
  * @param callback - The callback function to remove.
36
36
  */
37
- removeEventListener(messageType: string, callback: (data: unknown) => void): void;
37
+ removeEventListener(messageType: string, callback: (data: unknown) => void): this;
38
38
  }
39
39
  export {};
@@ -1,3 +1,4 @@
1
+ import { Communicator } from './Communicator';
1
2
  /**
2
3
  * Integrates the MetaBox into the provided layout.
3
4
  *
@@ -14,17 +15,17 @@
14
15
  * 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
16
  *
16
17
  * @param containerId - The ID of the layout element. Defaults to 'embed3DSource'.
17
- *
18
+ * @param apiReadyCallback
18
19
  * @throws Error if the container element with the specified ID is not found.
19
20
  *
20
21
  * @example
21
22
  * import {
22
23
  * integrateMetaBox,
23
- * } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@latest/dist/index.js';
24
+ * } from '@3dsource/metabox-front-api';
24
25
  *
25
26
  * integrateMetaBox(
26
27
  * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
27
28
  * 'embed3DSource'
28
29
  * );
29
30
  */
30
- export declare function integrateMetaBox(iframeSrc: string, containerId?: string): void;
31
+ export declare function integrateMetaBox(iframeSrc: string, containerId: string | undefined, apiReadyCallback: (api: Communicator) => void): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * integrateMetaBox.spec.ts
3
+ *
4
+ * Adjust relative import paths if your folder structure differs.
5
+ *
6
+ * Key point: the Communicator mock (and its spy) is *declared inside* the
7
+ * jest.mock factory, so there is no Temporal-Dead-Zone problem.
8
+ */
9
+ export {};
package/package.json CHANGED
@@ -1,48 +1,52 @@
1
- {
2
- "name": "@3dsource/metabox-front-api",
3
- "version": "0.0.18",
4
- "description": "API for MetaBox BASIC configurator",
5
- "keywords": [
6
- "metabox",
7
- "api",
8
- "configurator"
9
- ],
10
- "repository": {
11
- "type": "git",
12
- "url": "git@bitbucket.org:dreamsoft/ams_vps-frontend.git"
13
- },
14
- "license": "MIT",
15
- "author": "3dsource.com",
16
- "type": "module",
17
- "exports": {
18
- ".": {
19
- "types": "./dist/index.d.ts",
20
- "require": "./dist/index.umd.js",
21
- "import": "./dist/index.esm.js"
22
- }
23
- },
24
- "main": "dist/index.umd.js",
25
- "jsdelivr": "dist/index.esm.js",
26
- "unpkg": "dist/index.esm.js",
27
- "module": "dist/index.esm.js",
28
- "types": "dist/index.d.ts",
29
- "files": [
30
- "dist/**/*"
31
- ],
32
- "scripts": {
33
- "apiDoc": "typedoc --entryPointStrategy Expand src/index.ts --tsconfig ./../../../tsconfig.typedoc.json --out ./../../../dist/browser/apiDocBasic",
34
- "build": "rollup -c",
35
- "clean": "rimraf dist",
36
- "packAll": "npm run clean && npm run build && npm pack",
37
- "publishApi": "npm run packAll && npm publish --access public"
38
- },
39
- "devDependencies": {
40
- "rimraf": "^3.0.2",
41
- "rollup": "^4.39.0",
42
- "rollup-plugin-typescript2": "^0.36.0",
43
- "typescript": "~5.7.3"
44
- },
45
- "publishConfig": {
46
- "access": "public"
47
- }
48
- }
1
+ {
2
+ "name": "@3dsource/metabox-front-api",
3
+ "version": "0.0.19-beta.0",
4
+ "description": "API for MetaBox BASIC configurator",
5
+ "keywords": [
6
+ "metabox",
7
+ "api",
8
+ "configurator"
9
+ ],
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git@bitbucket.org:dreamsoft/ams_vps-frontend.git"
13
+ },
14
+ "license": "MIT",
15
+ "author": "3dsource.com",
16
+ "type": "module",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "require": "./dist/index.umd.js",
21
+ "import": "./dist/index.esm.js"
22
+ }
23
+ },
24
+ "main": "dist/index.umd.js",
25
+ "jsdelivr": "dist/index.esm.js",
26
+ "unpkg": "dist/index.esm.js",
27
+ "module": "dist/index.esm.js",
28
+ "types": "dist/index.d.ts",
29
+ "files": [
30
+ "dist/**/*"
31
+ ],
32
+ "scripts": {
33
+ "apiDoc": "typedoc --entryPointStrategy Expand src/index.ts --tsconfig ./../../../tsconfig.typedoc.json --out ./../../../dist/browser/apiDocBasic",
34
+ "build": "rollup -c",
35
+ "clean": "rimraf dist",
36
+ "packAll": "npm run clean && npm run build && npm pack",
37
+ "publish:prod": "npm run packAll && npm publish --access public",
38
+ "publish:dev": "npm run packAll && npm publish --access public --tag beta",
39
+ "bump:prod": "npm version patch && npm run publish:prod",
40
+ "bump:dev": "npm version prerelease --preid=beta && npm run publish:dev"
41
+ },
42
+ "peerDependencies": {
43
+ "@3dsource/angular-unreal-module": "^0.0.29",
44
+ "rimraf": ">=6.0.0",
45
+ "rollup": ">=4.0.0",
46
+ "rollup-plugin-typescript2": ">=0.36.0",
47
+ "typescript": ">=5.8.1"
48
+ },
49
+ "publishConfig": {
50
+ "access": "public"
51
+ }
52
+ }
@@ -1,26 +0,0 @@
1
- import type { Communicator } from '../lib/initializeCommunicator';
2
- /**
3
- * To integrate the MetaBox configurator into an HTML element, use the following example:
4
- *
5
- * **We strongly recommend using the option with npm and locking it to the latest version at the time of integration, as the option with cdn can change rapidly and may cause unexpected behavior in your existing code. See root documentation.**
6
- *
7
- * ```typescript
8
- * import { integrateMetaBox } from 'https://cdn.jsdelivr.net/npm/@3dsource/metabox-front-api@latest/dist/index.js';
9
- *
10
- * integrateMetaBox(
11
- * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
12
- * 'embed3DSource'
13
- * );
14
- *
15
- * // Set up the global API environment
16
- * window.env3DSource = window.env3DSource || {};
17
- *
18
- * //Listen for the API ready event
19
- * window.env3DSource.apiReady = (api) => {
20
- * // Use the API actions here
21
- * };
22
- * ```
23
- */
24
- export declare class ApiAction {
25
- protected api: Communicator;
26
- }