@fyul/embed-sdk 2.4.19 → 2.5.1

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.
Files changed (113) hide show
  1. package/dist/cjs/helpers/messageLogger.d.ts +1 -0
  2. package/dist/cjs/helpers/messageLogger.js +2 -0
  3. package/dist/cjs/index.d.ts +2 -0
  4. package/dist/cjs/index.js +4 -1
  5. package/dist/cjs/modules/baseModule.d.ts +2 -2
  6. package/dist/cjs/modules/edm/broadcastEvents/baseEdmBroadcastEvent.d.ts +2 -1
  7. package/dist/cjs/modules/eventTypes.d.ts +3 -3
  8. package/dist/cjs/modules/events.d.ts +12 -0
  9. package/dist/cjs/modules/events.js +5 -0
  10. package/dist/cjs/modules/moduleNames.d.ts +1 -0
  11. package/dist/cjs/modules/moduleNames.js +1 -0
  12. package/dist/cjs/modules/modules.d.ts +3 -0
  13. package/dist/cjs/modules/modules.js +3 -0
  14. package/dist/cjs/modules/white-label/broadcastEvents/baseWhiteLabelBroadcastEvent.d.ts +6 -0
  15. package/dist/cjs/modules/white-label/broadcastEvents/baseWhiteLabelBroadcastEvent.js +10 -0
  16. package/dist/cjs/modules/white-label/broadcastEvents/onShoppingCartUpdate.d.ts +5 -0
  17. package/dist/cjs/modules/white-label/broadcastEvents/onShoppingCartUpdate.js +10 -0
  18. package/dist/cjs/modules/white-label/events.d.ts +22 -0
  19. package/dist/cjs/modules/white-label/events.js +23 -0
  20. package/dist/cjs/modules/white-label/types/data.types.d.ts +30 -0
  21. package/dist/cjs/modules/white-label/types/data.types.js +2 -0
  22. package/dist/cjs/modules/white-label/types/event/actionEvent.types.d.ts +5 -0
  23. package/dist/cjs/modules/white-label/types/event/actionEvent.types.js +2 -0
  24. package/dist/cjs/modules/white-label/types/event/actionEventPayload.types.d.ts +8 -0
  25. package/dist/cjs/modules/white-label/types/event/actionEventPayload.types.js +2 -0
  26. package/dist/cjs/modules/white-label/types/event/broadcastEvent.types.d.ts +8 -0
  27. package/dist/cjs/modules/white-label/types/event/broadcastEvent.types.js +2 -0
  28. package/dist/cjs/modules/white-label/types/event/broadcastEventPayload.types.d.ts +3 -0
  29. package/dist/cjs/modules/white-label/types/event/broadcastEventPayload.types.js +2 -0
  30. package/dist/cjs/modules/white-label/types/event/resultEvent.types.d.ts +5 -0
  31. package/dist/cjs/modules/white-label/types/event/resultEvent.types.js +2 -0
  32. package/dist/cjs/modules/white-label/types/event/resultEventPayload.types.d.ts +4 -0
  33. package/dist/cjs/modules/white-label/types/event/resultEventPayload.types.js +3 -0
  34. package/dist/cjs/modules/white-label/types/index.d.ts +8 -0
  35. package/dist/cjs/modules/white-label/types/index.js +27 -0
  36. package/dist/cjs/modules/white-label/whiteLabelBroadcastModule.d.ts +8 -0
  37. package/dist/cjs/modules/white-label/whiteLabelBroadcastModule.js +15 -0
  38. package/dist/cjs/modules/white-label/whiteLabelModule.d.ts +10 -0
  39. package/dist/cjs/modules/white-label/whiteLabelModule.js +21 -0
  40. package/dist/cjs/services/embedCommunicator.d.ts +4 -4
  41. package/dist/cjs/services/embedCommunicator.js +10 -7
  42. package/dist/cjs/services/whiteLabel.d.ts +20 -0
  43. package/dist/cjs/services/whiteLabel.js +89 -0
  44. package/dist/cjs/types/event/action/actionEvent.types.d.ts +2 -1
  45. package/dist/cjs/types/event/action/actionEventPayload.types.d.ts +2 -1
  46. package/dist/cjs/types/event/broadcast/baseBroadcastEventHandler.d.ts +4 -0
  47. package/dist/cjs/types/event/broadcast/baseBroadcastEventHandler.js +2 -0
  48. package/dist/cjs/types/event/broadcast/broadcastEvent.types.d.ts +2 -1
  49. package/dist/cjs/types/event/broadcast/broadcastEventMap.d.ts +2 -0
  50. package/dist/cjs/types/event/broadcast/broadcastEventMap.js +2 -0
  51. package/dist/cjs/types/event/broadcast/broadcastEventPayload.types.d.ts +3 -2
  52. package/dist/cjs/types/event/result/resultEvent.types.d.ts +2 -1
  53. package/dist/cjs/types/event/result/resultEventPayload.types.d.ts +2 -1
  54. package/dist/cjs/types/module/module.types.d.ts +9 -0
  55. package/dist/cjs/version.d.ts +1 -1
  56. package/dist/cjs/version.js +1 -1
  57. package/dist/esm/helpers/messageLogger.d.ts +1 -0
  58. package/dist/esm/helpers/messageLogger.js +2 -0
  59. package/dist/esm/index.d.ts +2 -0
  60. package/dist/esm/index.js +2 -0
  61. package/dist/esm/modules/baseModule.d.ts +2 -2
  62. package/dist/esm/modules/edm/broadcastEvents/baseEdmBroadcastEvent.d.ts +2 -1
  63. package/dist/esm/modules/eventTypes.d.ts +3 -3
  64. package/dist/esm/modules/events.d.ts +12 -0
  65. package/dist/esm/modules/events.js +5 -0
  66. package/dist/esm/modules/moduleNames.d.ts +1 -0
  67. package/dist/esm/modules/moduleNames.js +1 -0
  68. package/dist/esm/modules/modules.d.ts +3 -0
  69. package/dist/esm/modules/modules.js +3 -0
  70. package/dist/esm/modules/white-label/broadcastEvents/baseWhiteLabelBroadcastEvent.d.ts +6 -0
  71. package/dist/esm/modules/white-label/broadcastEvents/baseWhiteLabelBroadcastEvent.js +6 -0
  72. package/dist/esm/modules/white-label/broadcastEvents/onShoppingCartUpdate.d.ts +5 -0
  73. package/dist/esm/modules/white-label/broadcastEvents/onShoppingCartUpdate.js +6 -0
  74. package/dist/esm/modules/white-label/events.d.ts +22 -0
  75. package/dist/esm/modules/white-label/events.js +20 -0
  76. package/dist/esm/modules/white-label/types/data.types.d.ts +30 -0
  77. package/dist/esm/modules/white-label/types/data.types.js +1 -0
  78. package/dist/esm/modules/white-label/types/event/actionEvent.types.d.ts +5 -0
  79. package/dist/esm/modules/white-label/types/event/actionEvent.types.js +1 -0
  80. package/dist/esm/modules/white-label/types/event/actionEventPayload.types.d.ts +8 -0
  81. package/dist/esm/modules/white-label/types/event/actionEventPayload.types.js +1 -0
  82. package/dist/esm/modules/white-label/types/event/broadcastEvent.types.d.ts +8 -0
  83. package/dist/esm/modules/white-label/types/event/broadcastEvent.types.js +1 -0
  84. package/dist/esm/modules/white-label/types/event/broadcastEventPayload.types.d.ts +3 -0
  85. package/dist/esm/modules/white-label/types/event/broadcastEventPayload.types.js +1 -0
  86. package/dist/esm/modules/white-label/types/event/resultEvent.types.d.ts +5 -0
  87. package/dist/esm/modules/white-label/types/event/resultEvent.types.js +1 -0
  88. package/dist/esm/modules/white-label/types/event/resultEventPayload.types.d.ts +4 -0
  89. package/dist/esm/modules/white-label/types/event/resultEventPayload.types.js +2 -0
  90. package/dist/esm/modules/white-label/types/index.d.ts +8 -0
  91. package/dist/esm/modules/white-label/types/index.js +11 -0
  92. package/dist/esm/modules/white-label/whiteLabelBroadcastModule.d.ts +8 -0
  93. package/dist/esm/modules/white-label/whiteLabelBroadcastModule.js +11 -0
  94. package/dist/esm/modules/white-label/whiteLabelModule.d.ts +10 -0
  95. package/dist/esm/modules/white-label/whiteLabelModule.js +17 -0
  96. package/dist/esm/services/embedCommunicator.d.ts +4 -4
  97. package/dist/esm/services/embedCommunicator.js +10 -7
  98. package/dist/esm/services/whiteLabel.d.ts +20 -0
  99. package/dist/esm/services/whiteLabel.js +85 -0
  100. package/dist/esm/types/event/action/actionEvent.types.d.ts +2 -1
  101. package/dist/esm/types/event/action/actionEventPayload.types.d.ts +2 -1
  102. package/dist/esm/types/event/broadcast/baseBroadcastEventHandler.d.ts +4 -0
  103. package/dist/esm/types/event/broadcast/baseBroadcastEventHandler.js +1 -0
  104. package/dist/esm/types/event/broadcast/broadcastEvent.types.d.ts +2 -1
  105. package/dist/esm/types/event/broadcast/broadcastEventMap.d.ts +2 -0
  106. package/dist/esm/types/event/broadcast/broadcastEventMap.js +2 -0
  107. package/dist/esm/types/event/broadcast/broadcastEventPayload.types.d.ts +3 -2
  108. package/dist/esm/types/event/result/resultEvent.types.d.ts +2 -1
  109. package/dist/esm/types/event/result/resultEventPayload.types.d.ts +2 -1
  110. package/dist/esm/types/module/module.types.d.ts +9 -0
  111. package/dist/esm/version.d.ts +1 -1
  112. package/dist/esm/version.js +1 -1
  113. package/package.json +1 -1
@@ -0,0 +1,8 @@
1
+ import { WhiteLabelConfig, WhiteLabelCommonParams } from '../../../../modules/white-label/types/data.types';
2
+ export type InitializeWhiteLabelPayload = WhiteLabelConfig & WhiteLabelCommonParams & {
3
+ clientVersion: string;
4
+ };
5
+ export interface GoToViewPayload {
6
+ view: string;
7
+ }
8
+ export type ActionEventPayload = InitializeWhiteLabelPayload | GoToViewPayload;
@@ -0,0 +1,8 @@
1
+ import { EVENT_BROADCAST } from '../../../../modules/white-label/events';
2
+ import { BaseBroadcastEvent } from '../../../../types/event/broadcast/broadcastEvent.types';
3
+ import { OnShoppingCartUpdateEventPayload } from '../../../../modules/white-label/types/event/broadcastEventPayload.types';
4
+ export type OnShoppingCartUpdateBroadcast = BaseBroadcastEvent<typeof EVENT_BROADCAST.ON_SHOPPING_CART_UPDATE, OnShoppingCartUpdateEventPayload>;
5
+ export type BroadcastEvent = OnShoppingCartUpdateBroadcast;
6
+ export type BroadcastListeners = {
7
+ [K in BroadcastEvent as K['name']]: (event: Exclude<K['payload'], undefined>) => void;
8
+ };
@@ -0,0 +1,3 @@
1
+ import { OnShoppingCartUpdateEvent } from '../../../../modules/white-label/types';
2
+ export type OnShoppingCartUpdateEventPayload = OnShoppingCartUpdateEvent;
3
+ export type BroadcastEventPayload = OnShoppingCartUpdateEventPayload;
@@ -0,0 +1,5 @@
1
+ import { BaseResultEvent } from '../../../../types/event/result/resultEvent.types';
2
+ import type { EVENTS_RESULT } from '../../../../modules/white-label/events';
3
+ import { GoToViewResultPayload } from '../../../../modules/white-label/types';
4
+ export type GoToViewResultEvent = BaseResultEvent<typeof EVENTS_RESULT.GO_TO_VIEW_RESULT, GoToViewResultPayload>;
5
+ export type ResultEvent = GoToViewResultEvent;
@@ -0,0 +1,4 @@
1
+ export type GoToViewResultPayload = {
2
+ success: boolean;
3
+ };
4
+ export type WhiteLabelResultPayload = GoToViewResultPayload;
@@ -0,0 +1,2 @@
1
+ // Result event payloads for Whitelabel module
2
+ export {};
@@ -0,0 +1,8 @@
1
+ export * from '../../../modules/white-label/types/data.types';
2
+ export * from '../../../modules/white-label/types/event/actionEvent.types';
3
+ export * from '../../../modules/white-label/types/event/actionEventPayload.types';
4
+ export * from '../../../modules/white-label/types/event/resultEvent.types';
5
+ export * from '../../../modules/white-label/types/event/resultEventPayload.types';
6
+ export * from '../../../modules/white-label/types/event/broadcastEventPayload.types';
7
+ export * from '../../../modules/white-label/types/event/broadcastEvent.types';
8
+ export * from '../../../modules/white-label/events';
@@ -0,0 +1,11 @@
1
+ // Data types
2
+ export * from '../../../modules/white-label/types/data.types';
3
+ // Event types
4
+ export * from '../../../modules/white-label/types/event/actionEvent.types';
5
+ export * from '../../../modules/white-label/types/event/actionEventPayload.types';
6
+ export * from '../../../modules/white-label/types/event/resultEvent.types';
7
+ export * from '../../../modules/white-label/types/event/resultEventPayload.types';
8
+ export * from '../../../modules/white-label/types/event/broadcastEventPayload.types';
9
+ export * from '../../../modules/white-label/types/event/broadcastEvent.types';
10
+ // Event names
11
+ export * from '../../../modules/white-label/events';
@@ -0,0 +1,8 @@
1
+ import { IWhiteLabelBroadcastModule } from '../../types/module/module.types';
2
+ import { BroadcastListeners } from '../../modules/white-label/types/event/broadcastEvent.types';
3
+ import { OnShoppingCartUpdateEventPayload } from '../../modules/white-label/types/event/broadcastEventPayload.types';
4
+ export declare class WhiteLabelBroadcastModule implements IWhiteLabelBroadcastModule {
5
+ protected listeners?: Partial<BroadcastListeners>;
6
+ constructor(listeners?: Partial<BroadcastListeners>);
7
+ onShoppingCartUpdate(event: OnShoppingCartUpdateEventPayload): void;
8
+ }
@@ -0,0 +1,11 @@
1
+ export class WhiteLabelBroadcastModule {
2
+ listeners;
3
+ constructor(listeners) {
4
+ this.listeners = listeners;
5
+ }
6
+ onShoppingCartUpdate(event) {
7
+ if (this.listeners?.onShoppingCartUpdate) {
8
+ this.listeners.onShoppingCartUpdate(event);
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,10 @@
1
+ import { IWhiteLabelModule } from '../../types/module/module.types';
2
+ import { BaseModule } from '../../modules/baseModule';
3
+ import { InitializeWhiteLabelPayload, GoToViewPayload, GoToViewResultPayload } from './types';
4
+ import { NotificationEventPayload } from '../../types/event/notification/notificationEventPayload.types';
5
+ import { WithHandledResponses } from '../../helpers/typeHelper.types';
6
+ export declare class WhiteLabelModule extends BaseModule implements WithHandledResponses<IWhiteLabelModule> {
7
+ constructor();
8
+ setup(payload?: InitializeWhiteLabelPayload): Promise<NotificationEventPayload>;
9
+ goToView(event: GoToViewPayload): Promise<import("../..").HandledResponse<GoToViewResultPayload, Error>>;
10
+ }
@@ -0,0 +1,17 @@
1
+ import { BaseModule } from '../../modules/baseModule';
2
+ import { EVENTS_ACTION } from './events';
3
+ import { MODULE_NAMES } from '../../modules/modules';
4
+ import { handleResponse } from '../../helpers/responseHandler';
5
+ export class WhiteLabelModule extends BaseModule {
6
+ constructor() {
7
+ super(MODULE_NAMES.WHITE_LABEL);
8
+ }
9
+ // @ts-expect-error setup does not return data
10
+ async setup(payload) {
11
+ return await this.sendRequest(EVENTS_ACTION.INITIALIZE_WHITE_LABEL, payload);
12
+ }
13
+ async goToView(event) {
14
+ const response = await this.sendRequest(EVENTS_ACTION.GO_TO_VIEW, event).catch((e) => e);
15
+ return handleResponse(response, 'Failed to navigate to view');
16
+ }
17
+ }
@@ -11,17 +11,17 @@ export declare class EmbedCommunicator {
11
11
  private isListening;
12
12
  private constructor();
13
13
  static getInstance(): EmbedCommunicator;
14
- sendCorrelatedRequest<TReturn>(eventName: ActionEventName, moduleType: typeof MODULE_NAMES.SDK | typeof MODULE_NAMES.EDM, payload?: ActionEventPayload): Promise<TReturn>;
15
- setIFrameManager(mainModule: typeof MODULE_NAMES.SDK | typeof MODULE_NAMES.EDM, iFrameManager: iFrameManager): void;
14
+ sendCorrelatedRequest<TReturn>(eventName: ActionEventName, moduleType: typeof MODULE_NAMES.SDK | typeof MODULE_NAMES.EDM | typeof MODULE_NAMES.WHITE_LABEL, payload?: ActionEventPayload): Promise<TReturn>;
15
+ setIFrameManager(mainModule: typeof MODULE_NAMES.SDK | typeof MODULE_NAMES.EDM | typeof MODULE_NAMES.WHITE_LABEL, iFrameManager: iFrameManager): void;
16
16
  setupListener(): void;
17
17
  private handleInboundMessageEvent;
18
18
  private handleInboundEvent;
19
19
  private handleInboundEventNotification;
20
20
  private getIframeManagerByMainModule;
21
21
  private isNotificationSuccess;
22
- isValidBroadcastEvent(event: BroadcastEvent): false | import("../modules/edm/types").OnDesignStatusEvent | import("../modules/edm/types").OnErrorEvent | import("../modules/edm/types").OnFilePickerRequestedEvent | import("../modules/edm/types").StepResponse | import("../modules/edm/types/event/broadcastEventPayload.types").OnPricingStatusUpdateEventPayload | undefined;
22
+ isValidBroadcastEvent(event: BroadcastEvent): false | import("../modules/edm/types").OnDesignStatusEvent | import("../modules/edm/types").OnErrorEvent | import("../modules/edm/types").OnFilePickerRequestedEvent | import("../modules/edm/types").StepResponse | import("../modules/white-label/types").OnShoppingCartUpdateEvent | import("../modules/edm/types/event/broadcastEventPayload.types").OnPricingStatusUpdateEventPayload | undefined;
23
23
  private resolveSuccessfulEvent;
24
24
  handleBroadcastEvent(event: BroadcastEvent): void;
25
- protected send(event: ActionEvent, moduleType: typeof MODULE_NAMES.SDK | typeof MODULE_NAMES.EDM): void;
25
+ protected send(event: ActionEvent, moduleType: typeof MODULE_NAMES.SDK | typeof MODULE_NAMES.EDM | typeof MODULE_NAMES.WHITE_LABEL): void;
26
26
  cleanup(): void;
27
27
  }
@@ -8,7 +8,11 @@ export class EmbedCommunicator {
8
8
  static #instance;
9
9
  broadcastEventHandler = new BroadcastEventDispatcher();
10
10
  messageBroker = new MessageBroker();
11
- iFrameManagers = { [MODULE_NAMES.SDK]: null, [MODULE_NAMES.EDM]: null };
11
+ iFrameManagers = {
12
+ [MODULE_NAMES.SDK]: null,
13
+ [MODULE_NAMES.EDM]: null,
14
+ [MODULE_NAMES.WHITE_LABEL]: null,
15
+ };
12
16
  isListening = false;
13
17
  constructor() { }
14
18
  static getInstance() {
@@ -54,11 +58,8 @@ export class EmbedCommunicator {
54
58
  logType: LOG_TYPES.LOG,
55
59
  });
56
60
  const iframeManagerType = this.getIframeManagerByMainModule(event);
57
- if (!iframeManagerType) {
58
- throw new Error('iFrameManager not set');
59
- }
60
- // Only process messages from our iframe
61
- if (!iframeManagerType.isMessageFromIFrame(event)) {
61
+ // Only process messages from our iframe and let cross iframe communication fail silently
62
+ if (!iframeManagerType?.isMessageFromIFrame(event)) {
62
63
  return;
63
64
  }
64
65
  this.handleInboundEvent(event.data);
@@ -68,8 +69,10 @@ export class EmbedCommunicator {
68
69
  this.handleBroadcastEvent(event);
69
70
  return;
70
71
  }
72
+ // Some browser extensions will attach themselves to iframes and will call postMessage
73
+ // If no identification from our side is found, just ignore it
71
74
  if (!event.correlationId) {
72
- throw new Error(`Fail [handleInboundEvent (${event.name})]: correlationId missing`);
75
+ return;
73
76
  }
74
77
  // Result event gets inbound ONLY if there's nothing wrong.
75
78
  // Otherwise it's a notification.
@@ -0,0 +1,20 @@
1
+ import { WhiteLabelConfig, WhiteLabelParams } from '../modules/white-label/types/data.types';
2
+ import { WhiteLabelBroadcastModule } from '../modules/white-label/whiteLabelBroadcastModule';
3
+ import { BroadcastListeners } from '../modules/white-label/types/event/broadcastEvent.types';
4
+ import { GoToViewPayload } from '../modules/white-label/types';
5
+ export declare class WhiteLabel {
6
+ private params;
7
+ private config?;
8
+ static BASE_URL: string;
9
+ static broadCastEventHandler: WhiteLabelBroadcastModule | null;
10
+ private nonce;
11
+ private iFrameManager;
12
+ private communicator;
13
+ private moduleLoader;
14
+ private initialized;
15
+ constructor(params: WhiteLabelParams, config?: WhiteLabelConfig | undefined, callbacks?: Partial<BroadcastListeners>);
16
+ init(): Promise<void>;
17
+ destroy(): void;
18
+ goToView(payload: GoToViewPayload): Promise<import("..").HandledResponse<import("../modules/white-label/types").GoToViewResultPayload, Error>>;
19
+ static getBroadCastEventHandler(): WhiteLabelBroadcastModule;
20
+ }
@@ -0,0 +1,85 @@
1
+ import { iFrameManager } from '../services/iFrameManager';
2
+ import { EmbedCommunicator } from '../services/embedCommunicator';
3
+ import { ModuleLoaderService } from '../services/moduleLoaderService';
4
+ import { LOG_TYPES, logEmbedMessage, setLoggerState, SOURCES, } from '../helpers/messageLogger';
5
+ import { MODULE_NAMES } from '../modules/moduleNames';
6
+ import { VERSION } from '../version';
7
+ import { WhiteLabelBroadcastModule } from '../modules/white-label/whiteLabelBroadcastModule';
8
+ export class WhiteLabel {
9
+ params;
10
+ config;
11
+ static BASE_URL = 'https://embed-white-label-fe.nonprod.printify.com/iframe';
12
+ static broadCastEventHandler;
13
+ nonce;
14
+ iFrameManager = null;
15
+ communicator = EmbedCommunicator.getInstance();
16
+ moduleLoader = ModuleLoaderService.getInstance();
17
+ initialized = false;
18
+ constructor(params, config, callbacks) {
19
+ this.params = params;
20
+ this.config = config;
21
+ this.nonce = params.nonce;
22
+ WhiteLabel.broadCastEventHandler = new WhiteLabelBroadcastModule(callbacks);
23
+ setLoggerState(params?.debug ?? false, SOURCES.WHITE_LABEL);
24
+ }
25
+ async init() {
26
+ if (this.initialized) {
27
+ logEmbedMessage({
28
+ message: 'WhiteLabel already initialized',
29
+ logType: LOG_TYPES.WARN,
30
+ });
31
+ return;
32
+ }
33
+ const elementToBindTo = this.params.element ?? document.getElementById(this.params.elementId);
34
+ if (!elementToBindTo) {
35
+ logEmbedMessage({
36
+ message: 'Cant find element for WhiteLabel',
37
+ logType: LOG_TYPES.ERROR,
38
+ });
39
+ return;
40
+ }
41
+ this.iFrameManager = new iFrameManager({
42
+ baseUrl: WhiteLabel.BASE_URL,
43
+ urlParams: {
44
+ nonce: this.nonce,
45
+ sdkMode: true,
46
+ },
47
+ class: this.params.iframeClassName,
48
+ elementToAppendTo: elementToBindTo,
49
+ });
50
+ await this.iFrameManager.create();
51
+ this.communicator.setIFrameManager(MODULE_NAMES.WHITE_LABEL, this.iFrameManager);
52
+ this.communicator.setupListener();
53
+ const whiteLabelModule = this.moduleLoader.getModule(MODULE_NAMES.WHITE_LABEL);
54
+ const notification = await whiteLabelModule.setup({
55
+ ...this.config,
56
+ ...this.params,
57
+ clientVersion: VERSION,
58
+ });
59
+ logEmbedMessage({
60
+ message: ['WhiteLabel setup notification', notification],
61
+ logType: LOG_TYPES.LOG,
62
+ });
63
+ this.initialized = true;
64
+ }
65
+ destroy() {
66
+ if (this.iFrameManager) {
67
+ this.iFrameManager.destroy();
68
+ this.iFrameManager = null;
69
+ }
70
+ this.communicator.cleanup();
71
+ this.moduleLoader.clearCache();
72
+ this.initialized = false;
73
+ WhiteLabel.broadCastEventHandler = null;
74
+ }
75
+ goToView(payload) {
76
+ const whiteLabelModule = this.moduleLoader.getModule(MODULE_NAMES.WHITE_LABEL);
77
+ return whiteLabelModule.goToView(payload);
78
+ }
79
+ static getBroadCastEventHandler() {
80
+ if (!WhiteLabel.broadCastEventHandler) {
81
+ throw new Error('No active WhiteLabelBroadcastModule instance');
82
+ }
83
+ return WhiteLabel.broadCastEventHandler;
84
+ }
85
+ }
@@ -3,10 +3,11 @@ import { ActionEvent as CatalogActionEvent } from '../../../modules/catalog/type
3
3
  import { ActionEvent as MockupGenerationActionEvent } from '../../../modules/mockup-generation/types/event/actionEvent.types';
4
4
  import { ActionEvent as ProductPublishActionEvent } from '../../../modules/product-publish/types/event/actionEvent.types';
5
5
  import { ActionEvent as EdmActionEvent } from '../../../modules/edm/types/event/actionEvent.types';
6
+ import { ActionEvent as WhiteLabelActionEvent } from '../../../modules/white-label/types/event/actionEvent.types';
6
7
  import { ALL_ACTION_EVENTS } from '../../../modules/events';
7
8
  import { Event } from '../../../types/event/event.types';
8
9
  import { EVENT_TYPES } from '../../../modules/eventTypes';
9
10
  import { ActionEventPayload } from './actionEventPayload.types';
10
11
  export type ActionEventName = (typeof ALL_ACTION_EVENTS)[keyof typeof ALL_ACTION_EVENTS];
11
12
  export type BaseActionEvent<TName extends ActionEventName, TPayload extends ActionEventPayload> = Event<TName, typeof EVENT_TYPES.ACTION, TPayload>;
12
- export type ActionEvent = MockupGenerationActionEvent | CatalogActionEvent | ProductPublishActionEvent | SdkActionEvent | EdmActionEvent;
13
+ export type ActionEvent = MockupGenerationActionEvent | CatalogActionEvent | ProductPublishActionEvent | SdkActionEvent | EdmActionEvent | WhiteLabelActionEvent;
@@ -3,4 +3,5 @@ import { ActionEventPayload as CatalogEventPayload } from '../../../modules/cata
3
3
  import { ActionEventPayload as MockupGenerationEventPayload } from '../../../modules/mockup-generation/types/event/actionEventPayload.types';
4
4
  import { ActionEventPayload as ProductPublishEventPayload } from '../../../modules/product-publish/types/event/actionEventPayload.types';
5
5
  import { ActionEventPayload as EdmEventPayload } from '../../../modules/edm/types/event/actionEventPayload.types';
6
- export type ActionEventPayload = LoadModulePayload | MockupGenerationEventPayload | CatalogEventPayload | SdkEventPayload | ProductPublishEventPayload | EdmEventPayload | undefined;
6
+ import { ActionEventPayload as WhiteLabelEventPayload } from '../../../modules/white-label/types/event/actionEventPayload.types';
7
+ export type ActionEventPayload = LoadModulePayload | MockupGenerationEventPayload | CatalogEventPayload | SdkEventPayload | ProductPublishEventPayload | EdmEventPayload | WhiteLabelEventPayload | undefined;
@@ -0,0 +1,4 @@
1
+ import { BroadcastEventPayload } from '../../../types/event/broadcast/broadcastEventPayload.types';
2
+ export interface BaseBroadcastEventHandler {
3
+ handle(event: BroadcastEventPayload): void;
4
+ }
@@ -3,6 +3,7 @@ import { Event } from '../../../types/event/event.types';
3
3
  import { EVENT_TYPES } from '../../../modules/eventTypes';
4
4
  import { BroadcastEventPayload } from '../../../types/event/broadcast/broadcastEventPayload.types';
5
5
  import { BroadcastEvent as EdmBroadcastEvent } from '../../../modules/edm/types/event/broadcastEvent.types';
6
+ import { BroadcastEvent as WhiteLabelBroadcastEvent } from '../../../modules/white-label/types/event/broadcastEvent.types';
6
7
  export type BroadcastEventName = (typeof ALL_BROADCAST_EVENTS)[keyof typeof ALL_BROADCAST_EVENTS];
7
8
  export type BaseBroadcastEvent<TName extends BroadcastEventName, TPayload extends BroadcastEventPayload> = Event<TName, typeof EVENT_TYPES.BROADCAST, TPayload>;
8
- export type BroadcastEvent = EdmBroadcastEvent;
9
+ export type BroadcastEvent = EdmBroadcastEvent | WhiteLabelBroadcastEvent;
@@ -3,10 +3,12 @@ import { OnStepStatusUpdate } from '../../../modules/edm/broadcastEvents/onStepS
3
3
  import { OnPricingStatusUpdate } from '../../../modules/edm/broadcastEvents/onPricingStatusUpdate';
4
4
  import { OnFilePickerRequested } from '../../../modules/edm/broadcastEvents/onFilePickerRequested';
5
5
  import { OnErrorUpdate } from '../../../modules/edm/broadcastEvents/onErrorUpdate';
6
+ import { OnShoppingCartUpdate } from '../../../modules/white-label/broadcastEvents/onShoppingCartUpdate';
6
7
  export declare const BROADCAST_EVENT_MAP: {
7
8
  onDesignStatusUpdate: typeof OnDesignStatusUpdate;
8
9
  onFilePickerRequested: typeof OnFilePickerRequested;
9
10
  onStepStatusUpdate: typeof OnStepStatusUpdate;
10
11
  onPricingStatusUpdate: typeof OnPricingStatusUpdate;
11
12
  onError: typeof OnErrorUpdate;
13
+ onShoppingCartUpdate: typeof OnShoppingCartUpdate;
12
14
  };
@@ -4,10 +4,12 @@ import { OnStepStatusUpdate } from '../../../modules/edm/broadcastEvents/onStepS
4
4
  import { OnPricingStatusUpdate } from '../../../modules/edm/broadcastEvents/onPricingStatusUpdate';
5
5
  import { OnFilePickerRequested } from '../../../modules/edm/broadcastEvents/onFilePickerRequested';
6
6
  import { OnErrorUpdate } from '../../../modules/edm/broadcastEvents/onErrorUpdate';
7
+ import { OnShoppingCartUpdate } from '../../../modules/white-label/broadcastEvents/onShoppingCartUpdate';
7
8
  export const BROADCAST_EVENT_MAP = {
8
9
  [ALL_BROADCAST_EVENTS.ON_DESIGN_STATUS_UPDATE]: OnDesignStatusUpdate,
9
10
  [ALL_BROADCAST_EVENTS.ON_FILE_PICKER_REQUESTED]: OnFilePickerRequested,
10
11
  [ALL_BROADCAST_EVENTS.ON_STEP_STATUS_UPDATE]: OnStepStatusUpdate,
11
12
  [ALL_BROADCAST_EVENTS.ON_PRICING_STATUS_UPDATE]: OnPricingStatusUpdate,
12
13
  [ALL_BROADCAST_EVENTS.ON_INTERNAL_ERROR]: OnErrorUpdate,
14
+ [ALL_BROADCAST_EVENTS.ON_SHOPPING_CART_UPDATE]: OnShoppingCartUpdate,
13
15
  };
@@ -1,2 +1,3 @@
1
- import { BroadcastEventPayload as EdmBroadcastEvent } from '../../../modules/edm/types/event/broadcastEventPayload.types';
2
- export type BroadcastEventPayload = EdmBroadcastEvent;
1
+ import { BroadcastEventPayload as EdmBroadcastEventPayload } from '../../../modules/edm/types/event/broadcastEventPayload.types';
2
+ import { BroadcastEventPayload as WhiteLabelBroadcastEventPayload } from '../../../modules/white-label/types/event/broadcastEventPayload.types';
3
+ export type BroadcastEventPayload = EdmBroadcastEventPayload | WhiteLabelBroadcastEventPayload;
@@ -2,10 +2,11 @@ import { ResultEvent as CatalogResultEvent } from '../../../modules/catalog/type
2
2
  import { ResultEvent as MockupGenerationResultEvent } from '../../../modules/mockup-generation/types/event/resultEvent.types';
3
3
  import { ResultEvent as ProductPublishResultEvent } from '../../../modules/product-publish/types/event/resultEvent.types';
4
4
  import { ResultEvent as EdmResultPayload } from '../../../modules/edm/types/event/resultEvent.types';
5
+ import { ResultEvent as WhiteLabelResultPayload } from '../../../modules/white-label/types/event/resultEvent.types';
5
6
  import { ResultEventPayload } from './resultEventPayload.types';
6
7
  import { EVENT_TYPES } from '../../../modules/eventTypes';
7
8
  import { Event } from '../../../types/event/event.types';
8
9
  import { ALL_RESULT_EVENTS } from '../../../modules/events';
9
10
  export type ResultEventName = (typeof ALL_RESULT_EVENTS)[keyof typeof ALL_RESULT_EVENTS];
10
11
  export type BaseResultEvent<TName extends ResultEventName, TPayload extends ResultEventPayload> = Event<TName, typeof EVENT_TYPES.RESULT, TPayload>;
11
- export type ResultEvent = MockupGenerationResultEvent | CatalogResultEvent | ProductPublishResultEvent | EdmResultPayload;
12
+ export type ResultEvent = MockupGenerationResultEvent | CatalogResultEvent | ProductPublishResultEvent | EdmResultPayload | WhiteLabelResultPayload;
@@ -2,7 +2,8 @@ import type { CatalogResultPayload } from '../../../modules/catalog/types';
2
2
  import type { MockupGenerationResultPayload } from '../../../modules/mockup-generation/types';
3
3
  import type { ProductPublishResultPayload } from '../../../modules/product-publish/types';
4
4
  import type { EdmResultPayload } from '../../../modules/edm/types/event/resultEventPayload.types';
5
- export type ResultEventPayload = MockupGenerationResultPayload | CatalogResultPayload | ProductPublishResultPayload | EdmResultPayload;
5
+ import type { WhiteLabelResultPayload } from '../../../modules/white-label/types/event/resultEventPayload.types';
6
+ export type ResultEventPayload = MockupGenerationResultPayload | CatalogResultPayload | ProductPublishResultPayload | EdmResultPayload | WhiteLabelResultPayload;
6
7
  export type HandledResponse<T, K extends Error> = {
7
8
  data: T;
8
9
  error: null;
@@ -6,6 +6,8 @@ import { NotificationEventPayload } from '../../types/event/notification/notific
6
6
  import { DeleteProductsPayload, DeleteProductResultPayload, GetProductPublishPayload, GetSavedProductsPayload, GetSavedProductsResultPayload, ProductPublishData } from '../../modules/product-publish/types';
7
7
  import { OnDesignStatusEventPayload, OnErrorEventPayload, OnFilePickerRequestedEventPayload, OnPricingStatusUpdateEventPayload, OnStepStatusUpdateEventPayload } from '../../modules/edm/types/event/broadcastEventPayload.types';
8
8
  import { AddImagePayload, AddImageResultPayload, InitializeEdmPayload, NavigateStepPayload, NavigateStepResultPayload, SaveDesignResultPayload, SetStylePayload, SetStyleResultPayload } from '../../modules/edm/types';
9
+ import { InitializeWhiteLabelPayload, GoToViewResultPayload, GoToViewPayload } from '../../modules/white-label/types';
10
+ import { OnShoppingCartUpdateEventPayload } from '../../modules/white-label/types/event/broadcastEventPayload.types';
9
11
  /** This file ensures that Iframe and SDK has the same source of truth for return values */
10
12
  export type ModuleName = (typeof MODULE_NAMES)[keyof typeof MODULE_NAMES];
11
13
  export interface ISdkModule {
@@ -40,3 +42,10 @@ export interface IEdmBroadcastModule {
40
42
  onStepStatusUpdate(event: OnStepStatusUpdateEventPayload): void;
41
43
  onErrorUpdate(event: OnErrorEventPayload): void;
42
44
  }
45
+ export interface IWhiteLabelModule {
46
+ setup(config: InitializeWhiteLabelPayload): NotificationEventPayload | void;
47
+ goToView(event: GoToViewPayload): GoToViewResultPayload;
48
+ }
49
+ export interface IWhiteLabelBroadcastModule {
50
+ onShoppingCartUpdate(event: OnShoppingCartUpdateEventPayload): void;
51
+ }
@@ -1 +1 @@
1
- export declare const VERSION: "2.4.19";
1
+ export declare const VERSION: "2.5.1";
@@ -1,2 +1,2 @@
1
1
  // AUTO-GENERATED
2
- export const VERSION = '2.4.19';
2
+ export const VERSION = '2.5.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fyul/embed-sdk",
3
- "version": "2.4.19",
3
+ "version": "2.5.1",
4
4
  "description": "",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",