@fyul/embed-sdk 2.7.1 → 2.7.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/dist/cjs/helpers/jwtDecoder.d.ts +7 -0
- package/dist/cjs/helpers/jwtDecoder.js +20 -0
- package/dist/cjs/modules/embed-studio/embedStudioModule.d.ts +2 -1
- package/dist/cjs/modules/embed-studio/embedStudioModule.js +4 -0
- package/dist/cjs/modules/embed-studio/events.d.ts +2 -0
- package/dist/cjs/modules/embed-studio/events.js +1 -0
- package/dist/cjs/modules/embed-studio/types/event/resultEvent.types.d.ts +3 -2
- package/dist/cjs/modules/embed-studio/types/event/resultEventPayload.types.d.ts +4 -1
- package/dist/cjs/modules/eventTypes.d.ts +1 -1
- package/dist/cjs/modules/events.d.ts +2 -0
- package/dist/cjs/modules/white-label/types/data.types.d.ts +1 -1
- package/dist/cjs/services/edm.js +2 -1
- package/dist/cjs/services/embed.js +2 -1
- package/dist/cjs/services/embedStudio.d.ts +2 -1
- package/dist/cjs/services/embedStudio.js +5 -1
- package/dist/cjs/services/iFrameManager.js +4 -1
- package/dist/cjs/services/whiteLabel.d.ts +4 -2
- package/dist/cjs/services/whiteLabel.js +34 -12
- package/dist/cjs/types/jwtData.d.ts +8 -0
- package/dist/cjs/types/jwtData.js +2 -0
- package/dist/cjs/types/module/module.types.d.ts +2 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/helpers/jwtDecoder.d.ts +7 -0
- package/dist/esm/helpers/jwtDecoder.js +17 -0
- package/dist/esm/modules/embed-studio/embedStudioModule.d.ts +2 -1
- package/dist/esm/modules/embed-studio/embedStudioModule.js +4 -0
- package/dist/esm/modules/embed-studio/events.d.ts +2 -0
- package/dist/esm/modules/embed-studio/events.js +1 -0
- package/dist/esm/modules/embed-studio/types/event/resultEvent.types.d.ts +3 -2
- package/dist/esm/modules/embed-studio/types/event/resultEventPayload.types.d.ts +4 -1
- package/dist/esm/modules/eventTypes.d.ts +1 -1
- package/dist/esm/modules/events.d.ts +2 -0
- package/dist/esm/modules/white-label/types/data.types.d.ts +1 -1
- package/dist/esm/services/edm.js +2 -1
- package/dist/esm/services/embed.js +2 -1
- package/dist/esm/services/embedStudio.d.ts +2 -1
- package/dist/esm/services/embedStudio.js +5 -1
- package/dist/esm/services/iFrameManager.js +4 -1
- package/dist/esm/services/whiteLabel.d.ts +4 -2
- package/dist/esm/services/whiteLabel.js +34 -12
- package/dist/esm/types/jwtData.d.ts +8 -0
- package/dist/esm/types/jwtData.js +1 -0
- package/dist/esm/types/module/module.types.d.ts +2 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseJwt = parseJwt;
|
|
4
|
+
function parseJwt(token) {
|
|
5
|
+
try {
|
|
6
|
+
const base64Url = token.split('.')[1];
|
|
7
|
+
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
|
8
|
+
const jsonPayload = decodeURIComponent(window
|
|
9
|
+
.atob(base64)
|
|
10
|
+
.split('')
|
|
11
|
+
.map(function (c) {
|
|
12
|
+
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
|
13
|
+
})
|
|
14
|
+
.join(''));
|
|
15
|
+
return { data: JSON.parse(jsonPayload), error: null };
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
return { data: null, error: e };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { IEmbedStudioModule } from '../../types/module/module.types';
|
|
2
2
|
import { BaseModule } from '../../modules/baseModule';
|
|
3
|
-
import { InitializeEmbedStudioPayload, SaveDesignResultPayload } from './types';
|
|
3
|
+
import { InitializeEmbedStudioPayload, SaveDesignResultPayload, SetStoreContextPayload, SetStoreContextResultPayload } from './types';
|
|
4
4
|
import { NotificationEventPayload } from '../../types/event/notification/notificationEventPayload.types';
|
|
5
5
|
import { WithHandledResponses } from '../../helpers/typeHelper.types';
|
|
6
6
|
export declare class EmbedStudioModule extends BaseModule implements WithHandledResponses<IEmbedStudioModule> {
|
|
7
7
|
constructor();
|
|
8
8
|
setup(payload?: InitializeEmbedStudioPayload): Promise<NotificationEventPayload>;
|
|
9
9
|
saveDesign(): Promise<import("../..").HandledResponse<SaveDesignResultPayload, Error>>;
|
|
10
|
+
setStoreContext(payload: SetStoreContextPayload): Promise<import("../..").HandledResponse<SetStoreContextResultPayload, Error>>;
|
|
10
11
|
}
|
|
@@ -17,5 +17,9 @@ class EmbedStudioModule extends baseModule_1.BaseModule {
|
|
|
17
17
|
const response = await this.sendRequest(events_1.EVENTS_ACTION.SAVE_DESIGN, {}).catch((e) => e);
|
|
18
18
|
return (0, responseHandler_1.handleResponse)(response, 'Failed to save design');
|
|
19
19
|
}
|
|
20
|
+
async setStoreContext(payload) {
|
|
21
|
+
const response = await this.sendRequest(events_1.EVENTS_ACTION.SET_STORE_CONTEXT, payload).catch((e) => e);
|
|
22
|
+
return (0, responseHandler_1.handleResponse)(response, 'Failed to set store context');
|
|
23
|
+
}
|
|
20
24
|
}
|
|
21
25
|
exports.EmbedStudioModule = EmbedStudioModule;
|
|
@@ -9,6 +9,7 @@ export declare const EVENTS_NOTIFICATION: {
|
|
|
9
9
|
};
|
|
10
10
|
export declare const EVENTS_RESULT: {
|
|
11
11
|
readonly SAVE_DESIGN_RESULT: "resultSaveDesign";
|
|
12
|
+
readonly SET_STORE_CONTEXT_RESULT: "resultSetStoreContext";
|
|
12
13
|
};
|
|
13
14
|
export declare const EVENT_BROADCAST: {
|
|
14
15
|
readonly ON_DESIGN_STATUS_UPDATE: "onDesignStatusUpdate";
|
|
@@ -18,6 +19,7 @@ export declare const EVENTS: {
|
|
|
18
19
|
readonly ON_DESIGN_STATUS_UPDATE: "onDesignStatusUpdate";
|
|
19
20
|
readonly ON_INTERNAL_ERROR: "onError";
|
|
20
21
|
readonly SAVE_DESIGN_RESULT: "resultSaveDesign";
|
|
22
|
+
readonly SET_STORE_CONTEXT_RESULT: "resultSetStoreContext";
|
|
21
23
|
readonly EMBED_STUDIO_INITIALIZATION_SUCCESS: "notificationEdmInitializationSuccess";
|
|
22
24
|
readonly SAVE_DESIGN_FAILURE: "actionSaveDesignFailure";
|
|
23
25
|
readonly INITIALIZE_EMBED_STUDIO: "actionInitializeEdm";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BaseResultEvent } from '../../../../types/event/result/resultEvent.types';
|
|
2
2
|
import type { EVENTS_RESULT } from '../../../../modules/embed-studio/events';
|
|
3
|
-
import { SaveDesignResultPayload } from '../../../../modules/embed-studio/types/event/resultEventPayload.types';
|
|
3
|
+
import { SaveDesignResultPayload, SetStoreContextResultPayload } from '../../../../modules/embed-studio/types/event/resultEventPayload.types';
|
|
4
4
|
export type SaveDesignResultEvent = BaseResultEvent<typeof EVENTS_RESULT.SAVE_DESIGN_RESULT, SaveDesignResultPayload>;
|
|
5
|
-
export type
|
|
5
|
+
export type SetStoreContextResultEvent = BaseResultEvent<typeof EVENTS_RESULT.SET_STORE_CONTEXT_RESULT, SetStoreContextResultPayload>;
|
|
6
|
+
export type ResultEvent = SaveDesignResultEvent | SetStoreContextResultEvent;
|
|
@@ -2,4 +2,7 @@ import { FyulTemplate } from '../../../../modules/embed-studio/types/data.types'
|
|
|
2
2
|
export type SaveDesignResultPayload = {
|
|
3
3
|
template: FyulTemplate;
|
|
4
4
|
};
|
|
5
|
-
export type
|
|
5
|
+
export type SetStoreContextResultPayload = {
|
|
6
|
+
storeId: string;
|
|
7
|
+
};
|
|
8
|
+
export type EmbedStudioResultPayload = SaveDesignResultPayload | SetStoreContextResultPayload;
|
|
@@ -7,5 +7,5 @@ export declare const EVENT_TYPES: {
|
|
|
7
7
|
};
|
|
8
8
|
export declare function isAction(event: AnyEvent): event is import("./sdk/types").InitializeSdkAction | import("./sdk/types").LoadModuleAction | import("./mockup-generation/types").GetMockupsAction | import("./mockup-generation/types").GetMoreMockupsAction | import("./mockup-generation/types").AdjustMockupAction | import("./edm/types").InitializeEdmAction | import("./edm/types").SaveDesignAction | import("./edm/types").AddImageAction | import("./edm/types").NavigateStepAction | import("./white-label/types").InitializeWhiteLabelAction | import("./catalog/types").GetCatalogCategoriesAction | import("./catalog/types").GetCatalogProductsByIdsAction | import("./catalog/types").GetCatalogProductsAction | import("./catalog/types").GetSingleCatalogProductAction | import("./product-publish/types").DeleteProductsAction | import("./product-publish/types").GetSavedProductsAction | import("./product-publish/types").GetProductPublishAction | import("./embed-studio/types").InitializeEmbedStudioAction | import("./embed-studio/types").SaveDesignAction | import("./embed-studio/types").SetStoreContextAction;
|
|
9
9
|
export declare function isNotification(event: AnyEvent): event is import("..").NotificationEvent;
|
|
10
|
-
export declare function isResult(event: AnyEvent): event is import("./catalog/types").GetCatalogProductsResult | import("./catalog/types").GetSingleCatalogProductResult | import("./catalog/types").GetCatalogCategoriesResult | import("./product-publish/types").GetProductPublishResult | import("./product-publish/types").GetSavedProductsResult | import("./product-publish/types").GetSavedProductMockupsResult | import("./product-publish/types").DeleteProductsResult | import("./edm/types").SaveDesignResultEvent | import("./edm/types").AddImageResultEvent | import("./edm/types").SetStyleResultEvent | import("./edm/types").NavigateStepResultEvent | import("./embed-studio/types").SaveDesignResultEvent | import("./mockup-generation/types").GetMockupsResultEvent | import("./mockup-generation/types").GetMoreMockupsResultEvent | import("./mockup-generation/types").AdjustMockupResultEvent | import("./white-label/types").GoToViewResultEvent;
|
|
10
|
+
export declare function isResult(event: AnyEvent): event is import("./catalog/types").GetCatalogProductsResult | import("./catalog/types").GetSingleCatalogProductResult | import("./catalog/types").GetCatalogCategoriesResult | import("./product-publish/types").GetProductPublishResult | import("./product-publish/types").GetSavedProductsResult | import("./product-publish/types").GetSavedProductMockupsResult | import("./product-publish/types").DeleteProductsResult | import("./edm/types").SaveDesignResultEvent | import("./edm/types").AddImageResultEvent | import("./edm/types").SetStyleResultEvent | import("./edm/types").NavigateStepResultEvent | import("./embed-studio/types").SaveDesignResultEvent | import("./embed-studio/types").SetStoreContextResultEvent | import("./mockup-generation/types").GetMockupsResultEvent | import("./mockup-generation/types").GetMoreMockupsResultEvent | import("./mockup-generation/types").AdjustMockupResultEvent | import("./white-label/types").GoToViewResultEvent;
|
|
11
11
|
export declare function isBroadcast(event: AnyEvent): event is import("./edm/types/event/broadcastEvent.types").OnDesignStatusUpdateBroadcast | import("./edm/types/event/broadcastEvent.types").OnPricingStatusUpdateBroadcast | import("./edm/types/event/broadcastEvent.types").OnFilePickerRequestBroadcast | import("./edm/types/event/broadcastEvent.types").OnStepStatusUpdateBroadcast | import("./edm/types/event/broadcastEvent.types").OnErrorUpdateBroadcast | import("./white-label/types").OnShoppingCartUpdateBroadcast | import("./white-label/types").OnContentSizeChangeBroadcast;
|
|
@@ -46,6 +46,7 @@ export declare const ALL_NOTIFICATION_EVENTS: {
|
|
|
46
46
|
export declare const ALL_RESULT_EVENTS: {
|
|
47
47
|
readonly GO_TO_VIEW_RESULT: "resultGoToView";
|
|
48
48
|
readonly SAVE_DESIGN_RESULT: "resultSaveDesign";
|
|
49
|
+
readonly SET_STORE_CONTEXT_RESULT: "resultSetStoreContext";
|
|
49
50
|
readonly ADD_IMAGE_RESULT: "resultAddImage";
|
|
50
51
|
readonly SET_STYLE_RESULT: "resultSetStyle";
|
|
51
52
|
readonly NAVIGATE_STEP_RESULT: "resultNavigateStep";
|
|
@@ -79,6 +80,7 @@ export declare const ALL_EVENTS: {
|
|
|
79
80
|
readonly ON_STEP_STATUS_UPDATE: "onStepStatusUpdate";
|
|
80
81
|
readonly GO_TO_VIEW_RESULT: "resultGoToView";
|
|
81
82
|
readonly SAVE_DESIGN_RESULT: "resultSaveDesign";
|
|
83
|
+
readonly SET_STORE_CONTEXT_RESULT: "resultSetStoreContext";
|
|
82
84
|
readonly ADD_IMAGE_RESULT: "resultAddImage";
|
|
83
85
|
readonly SET_STYLE_RESULT: "resultSetStyle";
|
|
84
86
|
readonly NAVIGATE_STEP_RESULT: "resultNavigateStep";
|
package/dist/cjs/services/edm.js
CHANGED
|
@@ -11,7 +11,8 @@ const edmBroadcastModule_1 = require("../modules/edm/edmBroadcastModule");
|
|
|
11
11
|
class EDM {
|
|
12
12
|
params;
|
|
13
13
|
config;
|
|
14
|
-
static BASE_URL =
|
|
14
|
+
static BASE_URL = globalThis.__FYUL_TESTING_VARS__?.edmUrl ??
|
|
15
|
+
'https://www.printful.com/embedded-designer';
|
|
15
16
|
static broadCastEventHandler;
|
|
16
17
|
nonce;
|
|
17
18
|
iFrameManager = null;
|
|
@@ -12,7 +12,8 @@ const modules_1 = require("../modules/modules");
|
|
|
12
12
|
const version_1 = require("../version");
|
|
13
13
|
class Embed {
|
|
14
14
|
config;
|
|
15
|
-
static BASE_URL =
|
|
15
|
+
static BASE_URL = globalThis.__FYUL_TESTING_VARS__?.sdkUrl ??
|
|
16
|
+
'https://www.printful.com/embed-sdk';
|
|
16
17
|
nonce;
|
|
17
18
|
iFrameManager = null;
|
|
18
19
|
communicator = embedCommunicator_1.EmbedCommunicator.getInstance();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EmbedStudioBroadcastModule } from '../modules/embed-studio/embedStudioBroadcastModule';
|
|
2
2
|
import type { EmbedStudioParams, EmbedStudioConfig } from '../modules/embed-studio/types/data.types';
|
|
3
3
|
import type { EmbedStudioBroadcastListeners } from '../modules/embed-studio/types/event/broadcastEvent.types';
|
|
4
|
-
import type { SaveDesignResultPayload } from '../modules/embed-studio/types/event/resultEventPayload.types';
|
|
4
|
+
import type { SaveDesignResultPayload, SetStoreContextResultPayload } from '../modules/embed-studio/types/event/resultEventPayload.types';
|
|
5
5
|
import type { HandledResponse } from '../types/event/result/resultEventPayload.types';
|
|
6
6
|
export declare class EmbedStudio {
|
|
7
7
|
private params;
|
|
@@ -15,6 +15,7 @@ export declare class EmbedStudio {
|
|
|
15
15
|
constructor(params: EmbedStudioParams, config?: EmbedStudioConfig | undefined, callbacks?: Partial<EmbedStudioBroadcastListeners>);
|
|
16
16
|
init(): Promise<void>;
|
|
17
17
|
saveDesign(): Promise<HandledResponse<SaveDesignResultPayload, Error>>;
|
|
18
|
+
setStoreContext(storeId: string): Promise<HandledResponse<SetStoreContextResultPayload, Error>>;
|
|
18
19
|
destroy(): void;
|
|
19
20
|
static getBroadCastEventHandler(): EmbedStudioBroadcastModule;
|
|
20
21
|
}
|
|
@@ -11,7 +11,7 @@ const messageLogger_1 = require("../helpers/messageLogger");
|
|
|
11
11
|
class EmbedStudio {
|
|
12
12
|
params;
|
|
13
13
|
config;
|
|
14
|
-
static BASE_URL = globalThis.__FYUL_TESTING_VARS__?.
|
|
14
|
+
static BASE_URL = globalThis.__FYUL_TESTING_VARS__?.embedStudioUrl ??
|
|
15
15
|
'https://embed-studio.fyul.com';
|
|
16
16
|
static broadCastEventHandler = null;
|
|
17
17
|
iFrameManager = null;
|
|
@@ -68,6 +68,10 @@ class EmbedStudio {
|
|
|
68
68
|
const module = this.moduleLoader.getModule(moduleNames_1.MODULE_NAMES.EMBED_STUDIO);
|
|
69
69
|
return module.saveDesign();
|
|
70
70
|
}
|
|
71
|
+
setStoreContext(storeId) {
|
|
72
|
+
const module = this.moduleLoader.getModule(moduleNames_1.MODULE_NAMES.EMBED_STUDIO);
|
|
73
|
+
return module.setStoreContext({ storeId });
|
|
74
|
+
}
|
|
71
75
|
destroy() {
|
|
72
76
|
if (this.iFrameManager) {
|
|
73
77
|
this.iFrameManager.destroy();
|
|
@@ -20,7 +20,10 @@ class iFrameManager {
|
|
|
20
20
|
iFrame.setAttribute('class', this.config.class);
|
|
21
21
|
}
|
|
22
22
|
const convertedUrlParams = Object.entries(this.config.urlParams).map(([k, v]) => [k, String(v)]);
|
|
23
|
-
|
|
23
|
+
const query = convertedUrlParams.length
|
|
24
|
+
? `?${new URLSearchParams(convertedUrlParams).toString()}`
|
|
25
|
+
: '';
|
|
26
|
+
iFrame.src = `${this.config.baseUrl}${query}`;
|
|
24
27
|
let settled = false;
|
|
25
28
|
const cleanup = () => {
|
|
26
29
|
settled = true;
|
|
@@ -7,13 +7,15 @@ export declare class WhiteLabel {
|
|
|
7
7
|
private config?;
|
|
8
8
|
static BASE_URL: string;
|
|
9
9
|
static broadCastEventHandler: WhiteLabelBroadcastModule | null;
|
|
10
|
-
private
|
|
10
|
+
private jwt;
|
|
11
11
|
private iFrameManager;
|
|
12
12
|
private communicator;
|
|
13
13
|
private moduleLoader;
|
|
14
14
|
private initialized;
|
|
15
15
|
constructor(params: WhiteLabelParams, config?: WhiteLabelConfig | undefined, callbacks?: Partial<BroadcastListeners>);
|
|
16
|
-
init(): Promise<
|
|
16
|
+
init(): Promise<{
|
|
17
|
+
error: null | string;
|
|
18
|
+
}>;
|
|
17
19
|
destroy(): void;
|
|
18
20
|
goToView(payload: GoToViewPayload): Promise<import("..").HandledResponse<import("../modules/white-label/types").GoToViewResultPayload, Error>>;
|
|
19
21
|
static getBroadCastEventHandler(): WhiteLabelBroadcastModule;
|
|
@@ -8,12 +8,14 @@ const messageLogger_1 = require("../helpers/messageLogger");
|
|
|
8
8
|
const moduleNames_1 = require("../modules/moduleNames");
|
|
9
9
|
const version_1 = require("../version");
|
|
10
10
|
const whiteLabelBroadcastModule_1 = require("../modules/white-label/whiteLabelBroadcastModule");
|
|
11
|
+
const jwtDecoder_1 = require("../helpers/jwtDecoder");
|
|
11
12
|
class WhiteLabel {
|
|
12
13
|
params;
|
|
13
14
|
config;
|
|
14
|
-
static BASE_URL =
|
|
15
|
+
static BASE_URL = globalThis.__FYUL_TESTING_VARS__?.ewlUrl ??
|
|
16
|
+
'https://embed-white-label-fe.nonprod.printify.com/iframe';
|
|
15
17
|
static broadCastEventHandler;
|
|
16
|
-
|
|
18
|
+
jwt;
|
|
17
19
|
iFrameManager = null;
|
|
18
20
|
communicator = embedCommunicator_1.EmbedCommunicator.getInstance();
|
|
19
21
|
moduleLoader = moduleLoaderService_1.ModuleLoaderService.getInstance();
|
|
@@ -21,35 +23,54 @@ class WhiteLabel {
|
|
|
21
23
|
constructor(params, config, callbacks) {
|
|
22
24
|
this.params = params;
|
|
23
25
|
this.config = config;
|
|
24
|
-
this.
|
|
26
|
+
this.jwt = params.jwt;
|
|
25
27
|
WhiteLabel.broadCastEventHandler = new whiteLabelBroadcastModule_1.WhiteLabelBroadcastModule(callbacks);
|
|
26
28
|
(0, messageLogger_1.setLoggerState)(params?.debug ?? false, messageLogger_1.SOURCES.WHITE_LABEL);
|
|
27
29
|
}
|
|
28
30
|
async init() {
|
|
29
31
|
if (this.initialized) {
|
|
32
|
+
const message = 'WhiteLabel already initialized';
|
|
30
33
|
(0, messageLogger_1.logEmbedMessage)({
|
|
31
|
-
message
|
|
34
|
+
message,
|
|
32
35
|
logType: messageLogger_1.LOG_TYPES.WARN,
|
|
33
36
|
});
|
|
34
|
-
return;
|
|
37
|
+
return { error: message };
|
|
35
38
|
}
|
|
36
39
|
const elementToBindTo = this.params.element ?? document.getElementById(this.params.elementId);
|
|
37
40
|
if (!elementToBindTo) {
|
|
41
|
+
const message = 'Cant find element for WhiteLabel';
|
|
38
42
|
(0, messageLogger_1.logEmbedMessage)({
|
|
39
|
-
message
|
|
43
|
+
message,
|
|
40
44
|
logType: messageLogger_1.LOG_TYPES.ERROR,
|
|
41
45
|
});
|
|
42
|
-
return;
|
|
46
|
+
return { error: message };
|
|
47
|
+
}
|
|
48
|
+
const { data, error } = (0, jwtDecoder_1.parseJwt)(this.jwt);
|
|
49
|
+
if (error) {
|
|
50
|
+
const message = 'Failed to parse JWT';
|
|
51
|
+
(0, messageLogger_1.logEmbedMessage)({
|
|
52
|
+
message,
|
|
53
|
+
logType: messageLogger_1.LOG_TYPES.ERROR,
|
|
54
|
+
});
|
|
55
|
+
return { error: message };
|
|
43
56
|
}
|
|
44
57
|
this.iFrameManager = new iFrameManager_1.iFrameManager({
|
|
45
|
-
baseUrl: WhiteLabel.BASE_URL
|
|
46
|
-
urlParams: {
|
|
47
|
-
nonce: this.nonce,
|
|
48
|
-
},
|
|
58
|
+
baseUrl: WhiteLabel.BASE_URL + `/${data.tenant_id}`,
|
|
59
|
+
urlParams: {},
|
|
49
60
|
class: this.params.iframeClassName,
|
|
50
61
|
elementToAppendTo: elementToBindTo,
|
|
51
62
|
});
|
|
52
|
-
|
|
63
|
+
try {
|
|
64
|
+
await this.iFrameManager.create();
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
const message = 'Failed to to load Iframe';
|
|
68
|
+
(0, messageLogger_1.logEmbedMessage)({
|
|
69
|
+
message,
|
|
70
|
+
logType: messageLogger_1.LOG_TYPES.ERROR,
|
|
71
|
+
});
|
|
72
|
+
return { error: message };
|
|
73
|
+
}
|
|
53
74
|
this.communicator.setIFrameManager(moduleNames_1.MODULE_NAMES.WHITE_LABEL, this.iFrameManager);
|
|
54
75
|
this.communicator.setupListener();
|
|
55
76
|
const whiteLabelModule = this.moduleLoader.getModule(moduleNames_1.MODULE_NAMES.WHITE_LABEL);
|
|
@@ -63,6 +84,7 @@ class WhiteLabel {
|
|
|
63
84
|
logType: messageLogger_1.LOG_TYPES.LOG,
|
|
64
85
|
});
|
|
65
86
|
this.initialized = true;
|
|
87
|
+
return { error: null };
|
|
66
88
|
}
|
|
67
89
|
destroy() {
|
|
68
90
|
if (this.iFrameManager) {
|
|
@@ -7,7 +7,7 @@ import { DeleteProductsPayload, DeleteProductResultPayload, GetProductPublishPay
|
|
|
7
7
|
import { OnDesignStatusEventPayload, OnErrorEventPayload, OnFilePickerRequestedEventPayload, OnPricingStatusUpdateEventPayload, OnStepStatusUpdateEventPayload } from '../../modules/edm/types/event/broadcastEventPayload.types';
|
|
8
8
|
import { OnDesignStatusEventPayload as EmbedStudioOnDesignStatusEventPayload, OnErrorEventPayload as EmbedStudioOnErrorEventPayload } from '../../modules/embed-studio/types/event/broadcastEventPayload.types';
|
|
9
9
|
import { AddImagePayload, AddImageResultPayload, InitializeEdmPayload, NavigateStepPayload, NavigateStepResultPayload, SaveDesignResultPayload, SetStylePayload, SetStyleResultPayload } from '../../modules/edm/types';
|
|
10
|
-
import { InitializeEmbedStudioPayload, SaveDesignResultPayload as EmbedStudioSaveDesignResultPayload } from '../../modules/embed-studio/types';
|
|
10
|
+
import { InitializeEmbedStudioPayload, SaveDesignResultPayload as EmbedStudioSaveDesignResultPayload, SetStoreContextPayload, SetStoreContextResultPayload as EmbedStudioSetStoreContextResultPayload } from '../../modules/embed-studio/types';
|
|
11
11
|
import { InitializeWhiteLabelPayload, GoToViewResultPayload, GoToViewPayload } from '../../modules/white-label/types';
|
|
12
12
|
import { OnShoppingCartUpdateEventPayload, OnContentSizeChangeEventPayload } from '../../modules/white-label/types/event/broadcastEventPayload.types';
|
|
13
13
|
/** This file ensures that Iframe and SDK has the same source of truth for return values */
|
|
@@ -40,6 +40,7 @@ export interface IEdmModule {
|
|
|
40
40
|
export interface IEmbedStudioModule {
|
|
41
41
|
setup(config?: InitializeEmbedStudioPayload): NotificationEventPayload | void;
|
|
42
42
|
saveDesign(): EmbedStudioSaveDesignResultPayload;
|
|
43
|
+
setStoreContext(payload: SetStoreContextPayload): EmbedStudioSetStoreContextResultPayload;
|
|
43
44
|
}
|
|
44
45
|
export interface IEdmBroadcastModule {
|
|
45
46
|
onDesignStatusUpdate(event: OnDesignStatusEventPayload): void;
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION: "2.7.
|
|
1
|
+
export declare const VERSION: "2.7.3";
|
package/dist/cjs/version.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function parseJwt(token) {
|
|
2
|
+
try {
|
|
3
|
+
const base64Url = token.split('.')[1];
|
|
4
|
+
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
|
5
|
+
const jsonPayload = decodeURIComponent(window
|
|
6
|
+
.atob(base64)
|
|
7
|
+
.split('')
|
|
8
|
+
.map(function (c) {
|
|
9
|
+
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
|
10
|
+
})
|
|
11
|
+
.join(''));
|
|
12
|
+
return { data: JSON.parse(jsonPayload), error: null };
|
|
13
|
+
}
|
|
14
|
+
catch (e) {
|
|
15
|
+
return { data: null, error: e };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { IEmbedStudioModule } from '../../types/module/module.types';
|
|
2
2
|
import { BaseModule } from '../../modules/baseModule';
|
|
3
|
-
import { InitializeEmbedStudioPayload, SaveDesignResultPayload } from './types';
|
|
3
|
+
import { InitializeEmbedStudioPayload, SaveDesignResultPayload, SetStoreContextPayload, SetStoreContextResultPayload } from './types';
|
|
4
4
|
import { NotificationEventPayload } from '../../types/event/notification/notificationEventPayload.types';
|
|
5
5
|
import { WithHandledResponses } from '../../helpers/typeHelper.types';
|
|
6
6
|
export declare class EmbedStudioModule extends BaseModule implements WithHandledResponses<IEmbedStudioModule> {
|
|
7
7
|
constructor();
|
|
8
8
|
setup(payload?: InitializeEmbedStudioPayload): Promise<NotificationEventPayload>;
|
|
9
9
|
saveDesign(): Promise<import("../..").HandledResponse<SaveDesignResultPayload, Error>>;
|
|
10
|
+
setStoreContext(payload: SetStoreContextPayload): Promise<import("../..").HandledResponse<SetStoreContextResultPayload, Error>>;
|
|
10
11
|
}
|
|
@@ -14,4 +14,8 @@ export class EmbedStudioModule extends BaseModule {
|
|
|
14
14
|
const response = await this.sendRequest(EVENTS_ACTION.SAVE_DESIGN, {}).catch((e) => e);
|
|
15
15
|
return handleResponse(response, 'Failed to save design');
|
|
16
16
|
}
|
|
17
|
+
async setStoreContext(payload) {
|
|
18
|
+
const response = await this.sendRequest(EVENTS_ACTION.SET_STORE_CONTEXT, payload).catch((e) => e);
|
|
19
|
+
return handleResponse(response, 'Failed to set store context');
|
|
20
|
+
}
|
|
17
21
|
}
|
|
@@ -9,6 +9,7 @@ export declare const EVENTS_NOTIFICATION: {
|
|
|
9
9
|
};
|
|
10
10
|
export declare const EVENTS_RESULT: {
|
|
11
11
|
readonly SAVE_DESIGN_RESULT: "resultSaveDesign";
|
|
12
|
+
readonly SET_STORE_CONTEXT_RESULT: "resultSetStoreContext";
|
|
12
13
|
};
|
|
13
14
|
export declare const EVENT_BROADCAST: {
|
|
14
15
|
readonly ON_DESIGN_STATUS_UPDATE: "onDesignStatusUpdate";
|
|
@@ -18,6 +19,7 @@ export declare const EVENTS: {
|
|
|
18
19
|
readonly ON_DESIGN_STATUS_UPDATE: "onDesignStatusUpdate";
|
|
19
20
|
readonly ON_INTERNAL_ERROR: "onError";
|
|
20
21
|
readonly SAVE_DESIGN_RESULT: "resultSaveDesign";
|
|
22
|
+
readonly SET_STORE_CONTEXT_RESULT: "resultSetStoreContext";
|
|
21
23
|
readonly EMBED_STUDIO_INITIALIZATION_SUCCESS: "notificationEdmInitializationSuccess";
|
|
22
24
|
readonly SAVE_DESIGN_FAILURE: "actionSaveDesignFailure";
|
|
23
25
|
readonly INITIALIZE_EMBED_STUDIO: "actionInitializeEdm";
|
|
@@ -9,6 +9,7 @@ export const EVENTS_NOTIFICATION = {
|
|
|
9
9
|
};
|
|
10
10
|
export const EVENTS_RESULT = {
|
|
11
11
|
SAVE_DESIGN_RESULT: 'resultSaveDesign',
|
|
12
|
+
SET_STORE_CONTEXT_RESULT: 'resultSetStoreContext',
|
|
12
13
|
};
|
|
13
14
|
export const EVENT_BROADCAST = {
|
|
14
15
|
ON_DESIGN_STATUS_UPDATE: 'onDesignStatusUpdate',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BaseResultEvent } from '../../../../types/event/result/resultEvent.types';
|
|
2
2
|
import type { EVENTS_RESULT } from '../../../../modules/embed-studio/events';
|
|
3
|
-
import { SaveDesignResultPayload } from '../../../../modules/embed-studio/types/event/resultEventPayload.types';
|
|
3
|
+
import { SaveDesignResultPayload, SetStoreContextResultPayload } from '../../../../modules/embed-studio/types/event/resultEventPayload.types';
|
|
4
4
|
export type SaveDesignResultEvent = BaseResultEvent<typeof EVENTS_RESULT.SAVE_DESIGN_RESULT, SaveDesignResultPayload>;
|
|
5
|
-
export type
|
|
5
|
+
export type SetStoreContextResultEvent = BaseResultEvent<typeof EVENTS_RESULT.SET_STORE_CONTEXT_RESULT, SetStoreContextResultPayload>;
|
|
6
|
+
export type ResultEvent = SaveDesignResultEvent | SetStoreContextResultEvent;
|
|
@@ -2,4 +2,7 @@ import { FyulTemplate } from '../../../../modules/embed-studio/types/data.types'
|
|
|
2
2
|
export type SaveDesignResultPayload = {
|
|
3
3
|
template: FyulTemplate;
|
|
4
4
|
};
|
|
5
|
-
export type
|
|
5
|
+
export type SetStoreContextResultPayload = {
|
|
6
|
+
storeId: string;
|
|
7
|
+
};
|
|
8
|
+
export type EmbedStudioResultPayload = SaveDesignResultPayload | SetStoreContextResultPayload;
|
|
@@ -7,5 +7,5 @@ export declare const EVENT_TYPES: {
|
|
|
7
7
|
};
|
|
8
8
|
export declare function isAction(event: AnyEvent): event is import("./sdk/types").InitializeSdkAction | import("./sdk/types").LoadModuleAction | import("./mockup-generation/types").GetMockupsAction | import("./mockup-generation/types").GetMoreMockupsAction | import("./mockup-generation/types").AdjustMockupAction | import("./edm/types").InitializeEdmAction | import("./edm/types").SaveDesignAction | import("./edm/types").AddImageAction | import("./edm/types").NavigateStepAction | import("./white-label/types").InitializeWhiteLabelAction | import("./catalog/types").GetCatalogCategoriesAction | import("./catalog/types").GetCatalogProductsByIdsAction | import("./catalog/types").GetCatalogProductsAction | import("./catalog/types").GetSingleCatalogProductAction | import("./product-publish/types").DeleteProductsAction | import("./product-publish/types").GetSavedProductsAction | import("./product-publish/types").GetProductPublishAction | import("./embed-studio/types").InitializeEmbedStudioAction | import("./embed-studio/types").SaveDesignAction | import("./embed-studio/types").SetStoreContextAction;
|
|
9
9
|
export declare function isNotification(event: AnyEvent): event is import("..").NotificationEvent;
|
|
10
|
-
export declare function isResult(event: AnyEvent): event is import("./catalog/types").GetCatalogProductsResult | import("./catalog/types").GetSingleCatalogProductResult | import("./catalog/types").GetCatalogCategoriesResult | import("./product-publish/types").GetProductPublishResult | import("./product-publish/types").GetSavedProductsResult | import("./product-publish/types").GetSavedProductMockupsResult | import("./product-publish/types").DeleteProductsResult | import("./edm/types").SaveDesignResultEvent | import("./edm/types").AddImageResultEvent | import("./edm/types").SetStyleResultEvent | import("./edm/types").NavigateStepResultEvent | import("./embed-studio/types").SaveDesignResultEvent | import("./mockup-generation/types").GetMockupsResultEvent | import("./mockup-generation/types").GetMoreMockupsResultEvent | import("./mockup-generation/types").AdjustMockupResultEvent | import("./white-label/types").GoToViewResultEvent;
|
|
10
|
+
export declare function isResult(event: AnyEvent): event is import("./catalog/types").GetCatalogProductsResult | import("./catalog/types").GetSingleCatalogProductResult | import("./catalog/types").GetCatalogCategoriesResult | import("./product-publish/types").GetProductPublishResult | import("./product-publish/types").GetSavedProductsResult | import("./product-publish/types").GetSavedProductMockupsResult | import("./product-publish/types").DeleteProductsResult | import("./edm/types").SaveDesignResultEvent | import("./edm/types").AddImageResultEvent | import("./edm/types").SetStyleResultEvent | import("./edm/types").NavigateStepResultEvent | import("./embed-studio/types").SaveDesignResultEvent | import("./embed-studio/types").SetStoreContextResultEvent | import("./mockup-generation/types").GetMockupsResultEvent | import("./mockup-generation/types").GetMoreMockupsResultEvent | import("./mockup-generation/types").AdjustMockupResultEvent | import("./white-label/types").GoToViewResultEvent;
|
|
11
11
|
export declare function isBroadcast(event: AnyEvent): event is import("./edm/types/event/broadcastEvent.types").OnDesignStatusUpdateBroadcast | import("./edm/types/event/broadcastEvent.types").OnPricingStatusUpdateBroadcast | import("./edm/types/event/broadcastEvent.types").OnFilePickerRequestBroadcast | import("./edm/types/event/broadcastEvent.types").OnStepStatusUpdateBroadcast | import("./edm/types/event/broadcastEvent.types").OnErrorUpdateBroadcast | import("./white-label/types").OnShoppingCartUpdateBroadcast | import("./white-label/types").OnContentSizeChangeBroadcast;
|
|
@@ -46,6 +46,7 @@ export declare const ALL_NOTIFICATION_EVENTS: {
|
|
|
46
46
|
export declare const ALL_RESULT_EVENTS: {
|
|
47
47
|
readonly GO_TO_VIEW_RESULT: "resultGoToView";
|
|
48
48
|
readonly SAVE_DESIGN_RESULT: "resultSaveDesign";
|
|
49
|
+
readonly SET_STORE_CONTEXT_RESULT: "resultSetStoreContext";
|
|
49
50
|
readonly ADD_IMAGE_RESULT: "resultAddImage";
|
|
50
51
|
readonly SET_STYLE_RESULT: "resultSetStyle";
|
|
51
52
|
readonly NAVIGATE_STEP_RESULT: "resultNavigateStep";
|
|
@@ -79,6 +80,7 @@ export declare const ALL_EVENTS: {
|
|
|
79
80
|
readonly ON_STEP_STATUS_UPDATE: "onStepStatusUpdate";
|
|
80
81
|
readonly GO_TO_VIEW_RESULT: "resultGoToView";
|
|
81
82
|
readonly SAVE_DESIGN_RESULT: "resultSaveDesign";
|
|
83
|
+
readonly SET_STORE_CONTEXT_RESULT: "resultSetStoreContext";
|
|
82
84
|
readonly ADD_IMAGE_RESULT: "resultAddImage";
|
|
83
85
|
readonly SET_STYLE_RESULT: "resultSetStyle";
|
|
84
86
|
readonly NAVIGATE_STEP_RESULT: "resultNavigateStep";
|
package/dist/esm/services/edm.js
CHANGED
|
@@ -8,7 +8,8 @@ import { EdmBroadcastModule } from '../modules/edm/edmBroadcastModule';
|
|
|
8
8
|
export class EDM {
|
|
9
9
|
params;
|
|
10
10
|
config;
|
|
11
|
-
static BASE_URL =
|
|
11
|
+
static BASE_URL = globalThis.__FYUL_TESTING_VARS__?.edmUrl ??
|
|
12
|
+
'https://www.printful.com/embedded-designer';
|
|
12
13
|
static broadCastEventHandler;
|
|
13
14
|
nonce;
|
|
14
15
|
iFrameManager = null;
|
|
@@ -9,7 +9,8 @@ import { MODULE_NAMES } from '../modules/modules';
|
|
|
9
9
|
import { VERSION } from '../version';
|
|
10
10
|
export class Embed {
|
|
11
11
|
config;
|
|
12
|
-
static BASE_URL =
|
|
12
|
+
static BASE_URL = globalThis.__FYUL_TESTING_VARS__?.sdkUrl ??
|
|
13
|
+
'https://www.printful.com/embed-sdk';
|
|
13
14
|
nonce;
|
|
14
15
|
iFrameManager = null;
|
|
15
16
|
communicator = EmbedCommunicator.getInstance();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EmbedStudioBroadcastModule } from '../modules/embed-studio/embedStudioBroadcastModule';
|
|
2
2
|
import type { EmbedStudioParams, EmbedStudioConfig } from '../modules/embed-studio/types/data.types';
|
|
3
3
|
import type { EmbedStudioBroadcastListeners } from '../modules/embed-studio/types/event/broadcastEvent.types';
|
|
4
|
-
import type { SaveDesignResultPayload } from '../modules/embed-studio/types/event/resultEventPayload.types';
|
|
4
|
+
import type { SaveDesignResultPayload, SetStoreContextResultPayload } from '../modules/embed-studio/types/event/resultEventPayload.types';
|
|
5
5
|
import type { HandledResponse } from '../types/event/result/resultEventPayload.types';
|
|
6
6
|
export declare class EmbedStudio {
|
|
7
7
|
private params;
|
|
@@ -15,6 +15,7 @@ export declare class EmbedStudio {
|
|
|
15
15
|
constructor(params: EmbedStudioParams, config?: EmbedStudioConfig | undefined, callbacks?: Partial<EmbedStudioBroadcastListeners>);
|
|
16
16
|
init(): Promise<void>;
|
|
17
17
|
saveDesign(): Promise<HandledResponse<SaveDesignResultPayload, Error>>;
|
|
18
|
+
setStoreContext(storeId: string): Promise<HandledResponse<SetStoreContextResultPayload, Error>>;
|
|
18
19
|
destroy(): void;
|
|
19
20
|
static getBroadCastEventHandler(): EmbedStudioBroadcastModule;
|
|
20
21
|
}
|
|
@@ -8,7 +8,7 @@ import { LOG_TYPES, logEmbedMessage, setLoggerState, SOURCES, } from '../helpers
|
|
|
8
8
|
export class EmbedStudio {
|
|
9
9
|
params;
|
|
10
10
|
config;
|
|
11
|
-
static BASE_URL = globalThis.__FYUL_TESTING_VARS__?.
|
|
11
|
+
static BASE_URL = globalThis.__FYUL_TESTING_VARS__?.embedStudioUrl ??
|
|
12
12
|
'https://embed-studio.fyul.com';
|
|
13
13
|
static broadCastEventHandler = null;
|
|
14
14
|
iFrameManager = null;
|
|
@@ -65,6 +65,10 @@ export class EmbedStudio {
|
|
|
65
65
|
const module = this.moduleLoader.getModule(MODULE_NAMES.EMBED_STUDIO);
|
|
66
66
|
return module.saveDesign();
|
|
67
67
|
}
|
|
68
|
+
setStoreContext(storeId) {
|
|
69
|
+
const module = this.moduleLoader.getModule(MODULE_NAMES.EMBED_STUDIO);
|
|
70
|
+
return module.setStoreContext({ storeId });
|
|
71
|
+
}
|
|
68
72
|
destroy() {
|
|
69
73
|
if (this.iFrameManager) {
|
|
70
74
|
this.iFrameManager.destroy();
|
|
@@ -17,7 +17,10 @@ export class iFrameManager {
|
|
|
17
17
|
iFrame.setAttribute('class', this.config.class);
|
|
18
18
|
}
|
|
19
19
|
const convertedUrlParams = Object.entries(this.config.urlParams).map(([k, v]) => [k, String(v)]);
|
|
20
|
-
|
|
20
|
+
const query = convertedUrlParams.length
|
|
21
|
+
? `?${new URLSearchParams(convertedUrlParams).toString()}`
|
|
22
|
+
: '';
|
|
23
|
+
iFrame.src = `${this.config.baseUrl}${query}`;
|
|
21
24
|
let settled = false;
|
|
22
25
|
const cleanup = () => {
|
|
23
26
|
settled = true;
|
|
@@ -7,13 +7,15 @@ export declare class WhiteLabel {
|
|
|
7
7
|
private config?;
|
|
8
8
|
static BASE_URL: string;
|
|
9
9
|
static broadCastEventHandler: WhiteLabelBroadcastModule | null;
|
|
10
|
-
private
|
|
10
|
+
private jwt;
|
|
11
11
|
private iFrameManager;
|
|
12
12
|
private communicator;
|
|
13
13
|
private moduleLoader;
|
|
14
14
|
private initialized;
|
|
15
15
|
constructor(params: WhiteLabelParams, config?: WhiteLabelConfig | undefined, callbacks?: Partial<BroadcastListeners>);
|
|
16
|
-
init(): Promise<
|
|
16
|
+
init(): Promise<{
|
|
17
|
+
error: null | string;
|
|
18
|
+
}>;
|
|
17
19
|
destroy(): void;
|
|
18
20
|
goToView(payload: GoToViewPayload): Promise<import("..").HandledResponse<import("../modules/white-label/types").GoToViewResultPayload, Error>>;
|
|
19
21
|
static getBroadCastEventHandler(): WhiteLabelBroadcastModule;
|
|
@@ -5,12 +5,14 @@ import { LOG_TYPES, logEmbedMessage, setLoggerState, SOURCES, } from '../helpers
|
|
|
5
5
|
import { MODULE_NAMES } from '../modules/moduleNames';
|
|
6
6
|
import { VERSION } from '../version';
|
|
7
7
|
import { WhiteLabelBroadcastModule } from '../modules/white-label/whiteLabelBroadcastModule';
|
|
8
|
+
import { parseJwt } from '../helpers/jwtDecoder';
|
|
8
9
|
export class WhiteLabel {
|
|
9
10
|
params;
|
|
10
11
|
config;
|
|
11
|
-
static BASE_URL =
|
|
12
|
+
static BASE_URL = globalThis.__FYUL_TESTING_VARS__?.ewlUrl ??
|
|
13
|
+
'https://embed-white-label-fe.nonprod.printify.com/iframe';
|
|
12
14
|
static broadCastEventHandler;
|
|
13
|
-
|
|
15
|
+
jwt;
|
|
14
16
|
iFrameManager = null;
|
|
15
17
|
communicator = EmbedCommunicator.getInstance();
|
|
16
18
|
moduleLoader = ModuleLoaderService.getInstance();
|
|
@@ -18,35 +20,54 @@ export class WhiteLabel {
|
|
|
18
20
|
constructor(params, config, callbacks) {
|
|
19
21
|
this.params = params;
|
|
20
22
|
this.config = config;
|
|
21
|
-
this.
|
|
23
|
+
this.jwt = params.jwt;
|
|
22
24
|
WhiteLabel.broadCastEventHandler = new WhiteLabelBroadcastModule(callbacks);
|
|
23
25
|
setLoggerState(params?.debug ?? false, SOURCES.WHITE_LABEL);
|
|
24
26
|
}
|
|
25
27
|
async init() {
|
|
26
28
|
if (this.initialized) {
|
|
29
|
+
const message = 'WhiteLabel already initialized';
|
|
27
30
|
logEmbedMessage({
|
|
28
|
-
message
|
|
31
|
+
message,
|
|
29
32
|
logType: LOG_TYPES.WARN,
|
|
30
33
|
});
|
|
31
|
-
return;
|
|
34
|
+
return { error: message };
|
|
32
35
|
}
|
|
33
36
|
const elementToBindTo = this.params.element ?? document.getElementById(this.params.elementId);
|
|
34
37
|
if (!elementToBindTo) {
|
|
38
|
+
const message = 'Cant find element for WhiteLabel';
|
|
35
39
|
logEmbedMessage({
|
|
36
|
-
message
|
|
40
|
+
message,
|
|
37
41
|
logType: LOG_TYPES.ERROR,
|
|
38
42
|
});
|
|
39
|
-
return;
|
|
43
|
+
return { error: message };
|
|
44
|
+
}
|
|
45
|
+
const { data, error } = parseJwt(this.jwt);
|
|
46
|
+
if (error) {
|
|
47
|
+
const message = 'Failed to parse JWT';
|
|
48
|
+
logEmbedMessage({
|
|
49
|
+
message,
|
|
50
|
+
logType: LOG_TYPES.ERROR,
|
|
51
|
+
});
|
|
52
|
+
return { error: message };
|
|
40
53
|
}
|
|
41
54
|
this.iFrameManager = new iFrameManager({
|
|
42
|
-
baseUrl: WhiteLabel.BASE_URL
|
|
43
|
-
urlParams: {
|
|
44
|
-
nonce: this.nonce,
|
|
45
|
-
},
|
|
55
|
+
baseUrl: WhiteLabel.BASE_URL + `/${data.tenant_id}`,
|
|
56
|
+
urlParams: {},
|
|
46
57
|
class: this.params.iframeClassName,
|
|
47
58
|
elementToAppendTo: elementToBindTo,
|
|
48
59
|
});
|
|
49
|
-
|
|
60
|
+
try {
|
|
61
|
+
await this.iFrameManager.create();
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
const message = 'Failed to to load Iframe';
|
|
65
|
+
logEmbedMessage({
|
|
66
|
+
message,
|
|
67
|
+
logType: LOG_TYPES.ERROR,
|
|
68
|
+
});
|
|
69
|
+
return { error: message };
|
|
70
|
+
}
|
|
50
71
|
this.communicator.setIFrameManager(MODULE_NAMES.WHITE_LABEL, this.iFrameManager);
|
|
51
72
|
this.communicator.setupListener();
|
|
52
73
|
const whiteLabelModule = this.moduleLoader.getModule(MODULE_NAMES.WHITE_LABEL);
|
|
@@ -60,6 +81,7 @@ export class WhiteLabel {
|
|
|
60
81
|
logType: LOG_TYPES.LOG,
|
|
61
82
|
});
|
|
62
83
|
this.initialized = true;
|
|
84
|
+
return { error: null };
|
|
63
85
|
}
|
|
64
86
|
destroy() {
|
|
65
87
|
if (this.iFrameManager) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -7,7 +7,7 @@ import { DeleteProductsPayload, DeleteProductResultPayload, GetProductPublishPay
|
|
|
7
7
|
import { OnDesignStatusEventPayload, OnErrorEventPayload, OnFilePickerRequestedEventPayload, OnPricingStatusUpdateEventPayload, OnStepStatusUpdateEventPayload } from '../../modules/edm/types/event/broadcastEventPayload.types';
|
|
8
8
|
import { OnDesignStatusEventPayload as EmbedStudioOnDesignStatusEventPayload, OnErrorEventPayload as EmbedStudioOnErrorEventPayload } from '../../modules/embed-studio/types/event/broadcastEventPayload.types';
|
|
9
9
|
import { AddImagePayload, AddImageResultPayload, InitializeEdmPayload, NavigateStepPayload, NavigateStepResultPayload, SaveDesignResultPayload, SetStylePayload, SetStyleResultPayload } from '../../modules/edm/types';
|
|
10
|
-
import { InitializeEmbedStudioPayload, SaveDesignResultPayload as EmbedStudioSaveDesignResultPayload } from '../../modules/embed-studio/types';
|
|
10
|
+
import { InitializeEmbedStudioPayload, SaveDesignResultPayload as EmbedStudioSaveDesignResultPayload, SetStoreContextPayload, SetStoreContextResultPayload as EmbedStudioSetStoreContextResultPayload } from '../../modules/embed-studio/types';
|
|
11
11
|
import { InitializeWhiteLabelPayload, GoToViewResultPayload, GoToViewPayload } from '../../modules/white-label/types';
|
|
12
12
|
import { OnShoppingCartUpdateEventPayload, OnContentSizeChangeEventPayload } from '../../modules/white-label/types/event/broadcastEventPayload.types';
|
|
13
13
|
/** This file ensures that Iframe and SDK has the same source of truth for return values */
|
|
@@ -40,6 +40,7 @@ export interface IEdmModule {
|
|
|
40
40
|
export interface IEmbedStudioModule {
|
|
41
41
|
setup(config?: InitializeEmbedStudioPayload): NotificationEventPayload | void;
|
|
42
42
|
saveDesign(): EmbedStudioSaveDesignResultPayload;
|
|
43
|
+
setStoreContext(payload: SetStoreContextPayload): EmbedStudioSetStoreContextResultPayload;
|
|
43
44
|
}
|
|
44
45
|
export interface IEdmBroadcastModule {
|
|
45
46
|
onDesignStatusUpdate(event: OnDesignStatusEventPayload): void;
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION: "2.7.
|
|
1
|
+
export declare const VERSION: "2.7.3";
|
package/dist/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// AUTO-GENERATED
|
|
2
|
-
export const VERSION = '2.7.
|
|
2
|
+
export const VERSION = '2.7.3';
|