@3dsource/metabox-front-api 1.2.1-dev.0 → 1.2.1-dev.3
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/LICENSE +14 -0
- package/README.md +218 -216
- package/{dist/index.esm.js → fesm2022/3dsource-metabox-front-api.mjs} +47 -46
- package/fesm2022/3dsource-metabox-front-api.mjs.map +1 -0
- package/index.d.ts +860 -0
- package/package.json +39 -53
- package/dist/actions/CommandBase.d.ts +0 -7
- package/dist/actions/GetFastRender.d.ts +0 -2
- package/dist/actions/GetPdf.d.ts +0 -24
- package/dist/actions/GetScreenshot.d.ts +0 -34
- package/dist/actions/SetEnvironment.d.ts +0 -21
- package/dist/actions/SetEnvironmentMaterial.d.ts +0 -24
- package/dist/actions/SetMaterial.d.ts +0 -24
- package/dist/actions/SetProduct.d.ts +0 -25
- package/dist/actions/ShowEmbeddedMenu.d.ts +0 -20
- package/dist/actions/ShowOverlayInterface.d.ts +0 -23
- package/dist/actions/UnrealCommand.d.ts +0 -14
- package/dist/actions/WatchCallbacks.d.ts +0 -18
- package/dist/const/FromMetaboxApiAction.d.ts +0 -58
- package/dist/index.d.ts +0 -23
- package/dist/index.esm.js.map +0 -1
- package/dist/index.umd.js +0 -604
- package/dist/index.umd.js.map +0 -1
- package/dist/interfaces/FromMetaboxMessagePayloads.d.ts +0 -134
- package/dist/interfaces/ToMetaboxMessagePayloads.d.ts +0 -72
- package/dist/interfaces/UniversalConfigurator.d.ts +0 -213
- package/dist/interfaces/application-device-types.d.ts +0 -1
- package/dist/lib/Communicator.d.ts +0 -57
- package/dist/lib/EventDispatcher.d.ts +0 -39
- package/dist/lib/UrlUtils.d.ts +0 -18
- package/dist/lib/fromCommunicatorEvent.d.ts +0 -9
- package/dist/lib/integrateMetaBox.d.ts +0 -31
- package/dist/lib/saveImage.d.ts +0 -11
- package/dist/lib/sleep.d.ts +0 -10
- package/dist/lib/test/Communicator.spec.d.ts +0 -1
- package/dist/lib/test/integrateMetabox.spec.d.ts +0 -9
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import type { ConfiguratorEnvelope } from './UniversalConfigurator';
|
|
2
|
-
import type { StreamResolutionProps, UnrealCallBackJson, UnrealState } from '@3dsource/angular-unreal-module';
|
|
3
|
-
import type { FromMetaboxApiAction, FromMetaboxDeprecatedApiAction } from '../const/FromMetaboxApiAction';
|
|
4
|
-
export interface FromMetaboxMessagePayloads {
|
|
5
|
-
/**
|
|
6
|
-
* Dispatches Every time the configurator data is updated.
|
|
7
|
-
* I.e., when the user changes the configuration. (Material, Product, Environment)
|
|
8
|
-
*/
|
|
9
|
-
configuratorData: ConfiguratorEnvelope;
|
|
10
|
-
/**
|
|
11
|
-
* @hidden
|
|
12
|
-
* @deprecated, use configuratorData instead.
|
|
13
|
-
*/
|
|
14
|
-
basicConfiguratorDataWithState: ConfiguratorEnvelope;
|
|
15
|
-
/**
|
|
16
|
-
* Dispatches Every time when the configurator connected/disconnected with Unreal Engine.
|
|
17
|
-
*/
|
|
18
|
-
dataChannelConnected: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Dispatches Every time when the Unreal Viewport is visible/hidden.
|
|
21
|
-
*/
|
|
22
|
-
viewportReady: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Dispatches Every when user toggles fullscreen button in an internal menu.
|
|
25
|
-
*/
|
|
26
|
-
isFullScreen: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Dispatches at the moment while the configurator loads. Shows status information.
|
|
29
|
-
*/
|
|
30
|
-
statusMessage: string | null;
|
|
31
|
-
/**
|
|
32
|
-
* @deprecated
|
|
33
|
-
* @hidden
|
|
34
|
-
* Dispatches every time when the freeze-frame is arrived or updated.
|
|
35
|
-
*/
|
|
36
|
-
freezeFrame: {
|
|
37
|
-
dataUrl: string | null;
|
|
38
|
-
progress: number | null;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* @experimental
|
|
42
|
-
* Dispatches every Unreal is sending a command callback.
|
|
43
|
-
* Works only after the new WatchCallbacks () command is sent.
|
|
44
|
-
*/
|
|
45
|
-
unrealCallback: {
|
|
46
|
-
json: UnrealCallBackJson;
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Dispatches every time when Unreal is sending ordered render with new GetFastRender() command.
|
|
50
|
-
*/
|
|
51
|
-
screenshot: string | null;
|
|
52
|
-
getScreenshot: string | null;
|
|
53
|
-
/**
|
|
54
|
-
* @hidden
|
|
55
|
-
* @deprecated, use screenshot
|
|
56
|
-
*/
|
|
57
|
-
fastRender: string | null;
|
|
58
|
-
/**
|
|
59
|
-
* @hidden
|
|
60
|
-
* @deprecated, use fastRender
|
|
61
|
-
*/
|
|
62
|
-
getFastRender: string | null;
|
|
63
|
-
/**
|
|
64
|
-
* @experimental
|
|
65
|
-
* Dispatches every Unreal state is changing, including all unreal module state.
|
|
66
|
-
*/
|
|
67
|
-
unrealState: UnrealState;
|
|
68
|
-
/**
|
|
69
|
-
* @hidden
|
|
70
|
-
* @deprecated, use unrealState
|
|
71
|
-
*/
|
|
72
|
-
unrealFeature: UnrealState;
|
|
73
|
-
/**
|
|
74
|
-
* Dispatches every time when Unreal is changing its video stream size.
|
|
75
|
-
*/
|
|
76
|
-
videoResolution: StreamResolutionProps;
|
|
77
|
-
/**
|
|
78
|
-
* @hidden
|
|
79
|
-
* @deprecated, use videoResolution
|
|
80
|
-
*/
|
|
81
|
-
streamResolution: StreamResolutionProps;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* @hidden
|
|
85
|
-
*/
|
|
86
|
-
export type FromMetaBoxApiEvents = keyof FromMetaboxMessagePayloads;
|
|
87
|
-
/**
|
|
88
|
-
* @internal
|
|
89
|
-
* This creates all event envelopes defined in MetaBoxAPIPayloads.
|
|
90
|
-
*/
|
|
91
|
-
export interface MetaBoxApiEnvelope<T extends FromMetaBoxApiEvents> {
|
|
92
|
-
action: 'bridge';
|
|
93
|
-
eventType: T;
|
|
94
|
-
payload: FromMetaboxMessagePayloads[T];
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* @hidden
|
|
98
|
-
* @internal
|
|
99
|
-
* Used for signaling that the app is loaded and ready to open api.
|
|
100
|
-
*/
|
|
101
|
-
export interface MCAppLoaded {
|
|
102
|
-
action: 'appLoaded';
|
|
103
|
-
eventType?: unknown;
|
|
104
|
-
payload?: unknown;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* @hidden
|
|
108
|
-
* Preserved for backward compatibility.
|
|
109
|
-
* @deprecated
|
|
110
|
-
* Used for sending deprecated messages, must be removed in the future.
|
|
111
|
-
*/
|
|
112
|
-
export interface DeprecatedEnvelope {
|
|
113
|
-
action: FromMetaboxDeprecatedApiAction | FromMetaboxApiAction;
|
|
114
|
-
eventType?: unknown;
|
|
115
|
-
payload?: unknown;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* @internal
|
|
119
|
-
* @hidden
|
|
120
|
-
* This creates a union of all event envelopes defined in MetaBoxAPIPayloads.
|
|
121
|
-
*/
|
|
122
|
-
export type FromMetaBoxAPIEnvelope = {
|
|
123
|
-
[K in keyof FromMetaboxMessagePayloads]: MetaBoxApiEnvelope<K>;
|
|
124
|
-
}[keyof FromMetaboxMessagePayloads] | MCAppLoaded | DeprecatedEnvelope;
|
|
125
|
-
export interface FromMetaBoxMessage {
|
|
126
|
-
host: 'metabox';
|
|
127
|
-
/**
|
|
128
|
-
* @hidden
|
|
129
|
-
* Preserved for backward compatibility.
|
|
130
|
-
* @deprecated, use `envelope` instead.
|
|
131
|
-
*/
|
|
132
|
-
payload?: FromMetaBoxAPIEnvelope;
|
|
133
|
-
envelope: FromMetaBoxAPIEnvelope;
|
|
134
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type { MimeType } from '../actions/GetScreenshot';
|
|
2
|
-
import type { ApplicationDeviceTypes } from './application-device-types';
|
|
3
|
-
import type { MetaBoxCommandPacket } from '@3dsource/types-unreal';
|
|
4
|
-
export type ToMetaBoxActions = 'getPdf' | 'loadLevel' | 'setProduct' | 'getFastRender' | 'getScreenshot' | 'watchCallbacks' | 'setMaterialById' | 'showEmbeddedMenu' | 'forceSetDeviceType' | 'sendCommandToUnreal' | 'showOverlayInterface' | 'setEnvironmentMaterialById' | 'resetCamera' | 'addResponse';
|
|
5
|
-
/**
|
|
6
|
-
* @internal
|
|
7
|
-
* @hidden
|
|
8
|
-
*/
|
|
9
|
-
export type ToMetaboxMessagePayload = ToMetaboxMessagePayloads[keyof ToMetaboxMessagePayloads];
|
|
10
|
-
/**
|
|
11
|
-
* Interface for messages sent from the application to the MetaBox.
|
|
12
|
-
*/
|
|
13
|
-
export interface ToMetaboxMessagePayloads {
|
|
14
|
-
getPdf: void;
|
|
15
|
-
loadLevel: {
|
|
16
|
-
id: string;
|
|
17
|
-
};
|
|
18
|
-
setProduct: {
|
|
19
|
-
productId: string;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* @deprecated
|
|
23
|
-
* @hidden
|
|
24
|
-
*/
|
|
25
|
-
addResponse: void;
|
|
26
|
-
/**
|
|
27
|
-
* @deprecated
|
|
28
|
-
* @hidden
|
|
29
|
-
*/
|
|
30
|
-
getFastRender: {
|
|
31
|
-
format: MimeType;
|
|
32
|
-
size?: {
|
|
33
|
-
x: number;
|
|
34
|
-
y: number;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
getScreenshot: {
|
|
38
|
-
format: MimeType;
|
|
39
|
-
size?: {
|
|
40
|
-
x: number;
|
|
41
|
-
y: number;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
watchCallbacks: void;
|
|
45
|
-
setMaterialById: {
|
|
46
|
-
slotId: string;
|
|
47
|
-
materialId: string;
|
|
48
|
-
};
|
|
49
|
-
sendCommandToUnreal: MetaBoxCommandPacket;
|
|
50
|
-
setEnvironmentMaterialById: {
|
|
51
|
-
slotId: string;
|
|
52
|
-
materialId: string;
|
|
53
|
-
};
|
|
54
|
-
showEmbeddedMenu: {
|
|
55
|
-
visible: boolean;
|
|
56
|
-
};
|
|
57
|
-
showOverlayInterface: {
|
|
58
|
-
visible: boolean;
|
|
59
|
-
};
|
|
60
|
-
forceSetDeviceType: {
|
|
61
|
-
deviceType: ApplicationDeviceTypes;
|
|
62
|
-
};
|
|
63
|
-
resetCamera: void;
|
|
64
|
-
}
|
|
65
|
-
export interface ToMetaBoxMessageEnvelope {
|
|
66
|
-
action: ToMetaBoxActions;
|
|
67
|
-
payload?: ToMetaboxMessagePayload | never;
|
|
68
|
-
}
|
|
69
|
-
export interface ToMetaBoxMessage {
|
|
70
|
-
host: 'metaBoxHost';
|
|
71
|
-
payload: ToMetaBoxMessageEnvelope;
|
|
72
|
-
}
|
|
@@ -1,213 +0,0 @@
|
|
|
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
|
-
*/
|
|
9
|
-
configurator: UniversalConfigurator;
|
|
10
|
-
/**
|
|
11
|
-
* The unique product identifier.
|
|
12
|
-
*/
|
|
13
|
-
productId: string;
|
|
14
|
-
/**
|
|
15
|
-
* A record mapping product material selections.
|
|
16
|
-
*/
|
|
17
|
-
productMaterialsIds: SelectedIds;
|
|
18
|
-
/**
|
|
19
|
-
* @deprecated,
|
|
20
|
-
* use `productMaterialsIds` instead.
|
|
21
|
-
* @hidden
|
|
22
|
-
*/
|
|
23
|
-
selectedMaterials: SelectedIds;
|
|
24
|
-
/**
|
|
25
|
-
* The unique environment identifier.
|
|
26
|
-
*/
|
|
27
|
-
environmentId: string;
|
|
28
|
-
/**
|
|
29
|
-
* A record mapping environment material selections.
|
|
30
|
-
*/
|
|
31
|
-
environmentMaterialsIds: SelectedIds;
|
|
32
|
-
/**
|
|
33
|
-
* A configurator quote for sales
|
|
34
|
-
*/
|
|
35
|
-
configuration: SelectedConfigurationForQuote | null;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Represents the universal configurator with its basic properties and components.
|
|
39
|
-
*/
|
|
40
|
-
export interface UniversalConfigurator {
|
|
41
|
-
/** Unique identifier for the configurator. */
|
|
42
|
-
id: string;
|
|
43
|
-
/** Indicates if the configurator is active. */
|
|
44
|
-
/** Label for the product collection. */
|
|
45
|
-
productCollectionLabel: string;
|
|
46
|
-
/** The name of the configurator. */
|
|
47
|
-
name: string;
|
|
48
|
-
/** The camera settings used in the configurator. */
|
|
49
|
-
/** Client information associated with the configurator. */
|
|
50
|
-
/** A list of products for the configurator. */
|
|
51
|
-
products: UniversalConfiguratorProduct[];
|
|
52
|
-
/** A list of available environments. */
|
|
53
|
-
environments: UniversalConfiguratorEnvironment[];
|
|
54
|
-
/** GraphQL typename for the configurator. */
|
|
55
|
-
__typename: 'UniversalConfigurator';
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Represents a product within the universal configurator.
|
|
59
|
-
*/
|
|
60
|
-
export interface UniversalConfiguratorProduct {
|
|
61
|
-
/** The product's unique identifier. */
|
|
62
|
-
productId: string;
|
|
63
|
-
/** Position index of the product. */
|
|
64
|
-
position: number;
|
|
65
|
-
/** Display label for the product. */
|
|
66
|
-
label: string;
|
|
67
|
-
/** Optional camera settings for the product. */
|
|
68
|
-
/** The detailed product information. */
|
|
69
|
-
product: Product;
|
|
70
|
-
/** GraphQL typename for the product. */
|
|
71
|
-
__typename: 'UniversalConfiguratorProduct';
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Represents product details including visual assets and configuration.
|
|
75
|
-
*/
|
|
76
|
-
export interface Product {
|
|
77
|
-
/** The title of the product. */
|
|
78
|
-
title: string;
|
|
79
|
-
/** List of thumbnails for the product. */
|
|
80
|
-
thumbnailList: Thumbnail[];
|
|
81
|
-
/** Available slots for the product. */
|
|
82
|
-
slots: Slot[];
|
|
83
|
-
/** List of metaProperties for the product (optional). */
|
|
84
|
-
metaProperties: MetaProperty[];
|
|
85
|
-
/** The model information associated with the product. */
|
|
86
|
-
/** Unique identifier for the product. */
|
|
87
|
-
id: string;
|
|
88
|
-
/** Unique external id for the product. */
|
|
89
|
-
externalId: string;
|
|
90
|
-
/** Showcase details for the product. */
|
|
91
|
-
/** GraphQL typename for the product. */
|
|
92
|
-
__typename: 'Product';
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Represents a thumbnail image entity with dimensions and URL path.
|
|
96
|
-
*/
|
|
97
|
-
export interface Thumbnail {
|
|
98
|
-
/** Width of the thumbnail. */
|
|
99
|
-
width: number;
|
|
100
|
-
/** Height of the thumbnail. */
|
|
101
|
-
height: number;
|
|
102
|
-
/** URL path to the thumbnail image. */
|
|
103
|
-
urlPath: string;
|
|
104
|
-
/** GraphQL typename (as a string, flexible type). */
|
|
105
|
-
__typename: 'Thumbnail';
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Represents a slot within a product that may allow material customization.
|
|
109
|
-
*/
|
|
110
|
-
export interface Slot {
|
|
111
|
-
/** Unique identifier for the slot. */
|
|
112
|
-
id: string;
|
|
113
|
-
/** Display a label for the slot. */
|
|
114
|
-
label: string;
|
|
115
|
-
/** A list of enabled materials for the slot. */
|
|
116
|
-
enabledMaterials: Material[];
|
|
117
|
-
/** GraphQL typename for the slot. */
|
|
118
|
-
__typename: 'Slot';
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Represents a metaProperty within a product that may allow business logic customization.
|
|
122
|
-
*/
|
|
123
|
-
export interface MetaProperty {
|
|
124
|
-
/** Unique identifier for the metaProperty. */
|
|
125
|
-
id: string;
|
|
126
|
-
/** Display the name for the metaProperty. */
|
|
127
|
-
name: string;
|
|
128
|
-
/** Value for the metaProperty. */
|
|
129
|
-
value: string;
|
|
130
|
-
/** Type for the metaProperty. */
|
|
131
|
-
type: string;
|
|
132
|
-
/** GraphQL typename for the metaProperty. */
|
|
133
|
-
__typename: 'MetaProperty';
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Represents a material that can be applied to a product slot.
|
|
137
|
-
*/
|
|
138
|
-
export interface Material {
|
|
139
|
-
/** Unique identifier for the material. */
|
|
140
|
-
id: string;
|
|
141
|
-
/** Title or name of the material. */
|
|
142
|
-
title: string;
|
|
143
|
-
/** Unique external id for the material. */
|
|
144
|
-
externalId: string;
|
|
145
|
-
/** List of thumbnails for the material. */
|
|
146
|
-
thumbnailList: Thumbnail[];
|
|
147
|
-
/** The model information associated with the material. */
|
|
148
|
-
/** GraphQL typename for the material. */
|
|
149
|
-
__typename: 'Material';
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Represents the environment settings for a universal configurator.
|
|
153
|
-
*/
|
|
154
|
-
export interface UniversalConfiguratorEnvironment {
|
|
155
|
-
/** Unique identifier for the environment. */
|
|
156
|
-
environmentId: string;
|
|
157
|
-
/** Position index of the environment. */
|
|
158
|
-
position: number;
|
|
159
|
-
/** Display label for the environment. */
|
|
160
|
-
label: string;
|
|
161
|
-
/** Detailed environment configuration. */
|
|
162
|
-
environment: Environment;
|
|
163
|
-
/** GraphQL typename for the environment. */
|
|
164
|
-
__typename: 'UniversalConfiguratorEnvironment';
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Represents an environment with associated media and configuration.
|
|
168
|
-
*/
|
|
169
|
-
export interface Environment {
|
|
170
|
-
/** Unique identifier for the environment. */
|
|
171
|
-
id: string;
|
|
172
|
-
/** Title or name of the environment. */
|
|
173
|
-
title: string;
|
|
174
|
-
/** Flag indicating if UDS is enabled. */
|
|
175
|
-
/** The north yaw of the sun in the environment. */
|
|
176
|
-
/** The UDS hour setting for the environment. */
|
|
177
|
-
/** GraphQL typename for the environment. */
|
|
178
|
-
__typename: 'Environment';
|
|
179
|
-
/** List of thumbnails for the environment (optional). */
|
|
180
|
-
thumbnailList: Thumbnail[];
|
|
181
|
-
/** List of slots for the environment (optional). */
|
|
182
|
-
slots: Slot[];
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Defines the structure for a mapping of selected materials.
|
|
186
|
-
*/
|
|
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
|
-
externalId: string;
|
|
194
|
-
title: string;
|
|
195
|
-
slots: {
|
|
196
|
-
label: string;
|
|
197
|
-
material: {
|
|
198
|
-
externalId: string;
|
|
199
|
-
title: string;
|
|
200
|
-
};
|
|
201
|
-
}[];
|
|
202
|
-
};
|
|
203
|
-
environment?: {
|
|
204
|
-
title: string;
|
|
205
|
-
slots: {
|
|
206
|
-
label: string;
|
|
207
|
-
material: {
|
|
208
|
-
externalId: string;
|
|
209
|
-
title: string;
|
|
210
|
-
};
|
|
211
|
-
}[];
|
|
212
|
-
};
|
|
213
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type ApplicationDeviceTypes = 'deviceTypeAuto' | 'deviceTypeMobile' | 'deviceTypeDesktop';
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { EventDispatcher } from './EventDispatcher';
|
|
2
|
-
import type { CommandBase } from '../actions/CommandBase';
|
|
3
|
-
import type { FromMetaBoxApiEvents, FromMetaboxMessagePayloads } from '../interfaces/FromMetaboxMessagePayloads';
|
|
4
|
-
/**
|
|
5
|
-
* Handles messaging between the host page and embedded MetaBox content.
|
|
6
|
-
* @internal Use {@link Communicator.createInstance} or the {@link integrateMetaBox} helper to instantiate.
|
|
7
|
-
*/
|
|
8
|
-
export declare class Communicator extends EventDispatcher {
|
|
9
|
-
/**
|
|
10
|
-
* Bound handler for incoming postMessage events.
|
|
11
|
-
*/
|
|
12
|
-
private binder;
|
|
13
|
-
/**
|
|
14
|
-
* Singleton reference to the current communicator instance.
|
|
15
|
-
*/
|
|
16
|
-
static instance: Communicator | null;
|
|
17
|
-
/**
|
|
18
|
-
* Constructs a Communicator, replacing any existing instance, and begins listening for messages.
|
|
19
|
-
* @internal
|
|
20
|
-
*/
|
|
21
|
-
constructor();
|
|
22
|
-
/**
|
|
23
|
-
* Cleans up resources and stops listening for messages.
|
|
24
|
-
*/
|
|
25
|
-
destroy(): void;
|
|
26
|
-
/**
|
|
27
|
-
* Posts a command to the MetaBox iframe.
|
|
28
|
-
* @param command - An action command containing data to send.
|
|
29
|
-
*/
|
|
30
|
-
sendCommandToMetaBox<T extends CommandBase>(command: T): void;
|
|
31
|
-
/**
|
|
32
|
-
* Filters and dispatches incoming messages from MetaBox.
|
|
33
|
-
* @param messageType - Expected message type for filtering ('metaboxData').
|
|
34
|
-
* @param event - The postMessage event received on window.
|
|
35
|
-
*/
|
|
36
|
-
private handleMessageReceived;
|
|
37
|
-
/**
|
|
38
|
-
* Listens for MetaBox to signal readiness, then initializes communicator.
|
|
39
|
-
* @param apiReadyCallback - Called with the new Communicator once MetaBox is loaded.
|
|
40
|
-
*/
|
|
41
|
-
static createInstance(apiReadyCallback: (api: Communicator) => void): void;
|
|
42
|
-
/**
|
|
43
|
-
* Registers an event listener for messages dispatched by MetaBox.
|
|
44
|
-
* @override
|
|
45
|
-
*/
|
|
46
|
-
addEventListener<T extends FromMetaBoxApiEvents>(messageType: T, callback: (data: FromMetaboxMessagePayloads[T]) => void): this;
|
|
47
|
-
/**
|
|
48
|
-
* Dispatches a typed event to all registered listeners.
|
|
49
|
-
* @override
|
|
50
|
-
*/
|
|
51
|
-
dispatchEvent<T extends FromMetaBoxApiEvents>(messageType: T, data: FromMetaboxMessagePayloads[T]): this;
|
|
52
|
-
/**
|
|
53
|
-
* Removes a previously registered event listener.
|
|
54
|
-
* @override
|
|
55
|
-
*/
|
|
56
|
-
removeEventListener<T extends FromMetaBoxApiEvents>(messageType: T, callback: (data: FromMetaboxMessagePayloads[T]) => void): this;
|
|
57
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents a callback listener for specific message types.
|
|
3
|
-
*/
|
|
4
|
-
interface Listener {
|
|
5
|
-
messageType: string;
|
|
6
|
-
callback: (data: unknown) => void;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* EventDispatcher is a class that manages event listeners and dispatches events to them.
|
|
10
|
-
*/
|
|
11
|
-
export declare class EventDispatcher {
|
|
12
|
-
/**
|
|
13
|
-
* Storage for callback listeners by message type.
|
|
14
|
-
*/
|
|
15
|
-
listeners: Listener[];
|
|
16
|
-
destroy(): void;
|
|
17
|
-
/**
|
|
18
|
-
* Adds an event listener for receiving specific types of messages.
|
|
19
|
-
*
|
|
20
|
-
* @param messageType - The message type to listen for.
|
|
21
|
-
* @param callback - The callback function to execute when a message is received.
|
|
22
|
-
*/
|
|
23
|
-
addEventListener(messageType: string, callback: (data: unknown) => void): this;
|
|
24
|
-
/**
|
|
25
|
-
* Dispatches an event to all listeners of a specific message type.
|
|
26
|
-
*
|
|
27
|
-
* @param messageType - The message type.
|
|
28
|
-
* @param data - The data associated with the event.
|
|
29
|
-
*/
|
|
30
|
-
dispatchEvent(messageType: string, data: unknown): this;
|
|
31
|
-
/**
|
|
32
|
-
* Removes an event listener for a specific type of message.
|
|
33
|
-
*
|
|
34
|
-
* @param messageType - The message type.
|
|
35
|
-
* @param callback - The callback function to remove.
|
|
36
|
-
*/
|
|
37
|
-
removeEventListener(messageType: string, callback: (data: unknown) => void): this;
|
|
38
|
-
}
|
|
39
|
-
export {};
|
package/dist/lib/UrlUtils.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sets the URL parameters based on the provided state.
|
|
3
|
-
*
|
|
4
|
-
* @remarks
|
|
5
|
-
* This function updates the current URL by replacing its search parameters with the key-value pairs from the provided state object.
|
|
6
|
-
*
|
|
7
|
-
* @param state - An object containing key-value pairs to set as URL parameters.
|
|
8
|
-
*/
|
|
9
|
-
export declare function setUrlParams(state: Record<string, string>): void;
|
|
10
|
-
/**
|
|
11
|
-
* Retrieves the URL parameters as an object.
|
|
12
|
-
*
|
|
13
|
-
* @remarks
|
|
14
|
-
* This function parses the current URL's search parameters and returns them as a key-value object.
|
|
15
|
-
*
|
|
16
|
-
* @returns An object containing the URL parameters.
|
|
17
|
-
*/
|
|
18
|
-
export declare function getUrlParams(): Record<string, string>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Communicator } from './Communicator';
|
|
2
|
-
import type { FromMetaBoxApiEvents, FromMetaboxMessagePayloads } from '../interfaces/FromMetaboxMessagePayloads';
|
|
3
|
-
import type { Observable } from 'rxjs';
|
|
4
|
-
/**
|
|
5
|
-
* Wrapper helper function to use it with rxJs same as `fromEvent` to listen to events from the Communicator.
|
|
6
|
-
* @param target
|
|
7
|
-
* @param eventName
|
|
8
|
-
*/
|
|
9
|
-
export declare function fromCommunicatorEvent<T extends FromMetaBoxApiEvents>(target: Communicator, eventName: T): Observable<FromMetaboxMessagePayloads[T]>;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Communicator } from './Communicator';
|
|
2
|
-
/**
|
|
3
|
-
* Integrates the MetaBox into the provided layout.
|
|
4
|
-
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* This function injects an iframe into a specified container element in the DOM and initializes
|
|
7
|
-
* the communicator for interacting with the MetaBox embedded content.
|
|
8
|
-
*
|
|
9
|
-
* @param iframeSrc - The source URL of the MetaBox iframe.
|
|
10
|
-
* Additional url parameters:
|
|
11
|
-
* ```javascript
|
|
12
|
-
* sidebar=false - disables the internal MetaBox menu
|
|
13
|
-
* introImage=https://example.com/image.png - sets the intro image
|
|
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
|
|
16
|
-
*
|
|
17
|
-
* @param containerId - The ID of the layout element. Defaults to 'embed3DSource'.
|
|
18
|
-
* @param apiReadyCallback
|
|
19
|
-
* @throws Error if the container element with the specified ID is not found.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* import {
|
|
23
|
-
* integrateMetaBox,
|
|
24
|
-
* } from '@3dsource/metabox-front-api';
|
|
25
|
-
*
|
|
26
|
-
* integrateMetaBox(
|
|
27
|
-
* 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
|
|
28
|
-
* 'embed3DSource'
|
|
29
|
-
* );
|
|
30
|
-
*/
|
|
31
|
-
export declare function integrateMetaBox(iframeSrc: string, containerId: string | undefined, apiReadyCallback: (api: Communicator) => void): void;
|
package/dist/lib/saveImage.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Saves an image by triggering a download.
|
|
3
|
-
*
|
|
4
|
-
* @remarks
|
|
5
|
-
* This function creates an anchor element, sets its `href` attribute to the provided image URL,
|
|
6
|
-
* and triggers a click event to initiate a download with the specified filename.
|
|
7
|
-
*
|
|
8
|
-
* @param imageUrl - The URL of the image to save.
|
|
9
|
-
* @param filename - The name of the file to save.
|
|
10
|
-
*/
|
|
11
|
-
export declare function saveImage(imageUrl: string, filename: string): void;
|
package/dist/lib/sleep.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pauses execution for a specified duration.
|
|
3
|
-
*
|
|
4
|
-
* @remarks
|
|
5
|
-
* This function returns a promise that resolves after the given number of milliseconds.
|
|
6
|
-
*
|
|
7
|
-
* @param time - The time to sleep in milliseconds.
|
|
8
|
-
* @returns A promise that resolves after the specified duration.
|
|
9
|
-
*/
|
|
10
|
-
export declare function sleep(time: number): Promise<void>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
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 {};
|