@corto-ai/integrations-messenger 0.0.10-dev.0 → 0.0.10-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/package.json +2 -2
- package/src/index.d.ts +4 -0
- package/src/lib/actions/base.d.ts +7 -1
- package/src/lib/actions/base.js +2 -0
- package/src/lib/actions/base.js.map +1 -1
- package/src/lib/actions/index.d.ts +4 -0
- package/src/lib/actions/utils.d.ts +2 -2
- package/src/lib/actions/utils.js +4 -2
- package/src/lib/actions/utils.js.map +1 -1
- package/src/lib/actions/window/close-modal.d.ts +10 -0
- package/src/lib/actions/window/close-modal.js +6 -0
- package/src/lib/actions/window/close-modal.js.map +1 -0
- package/src/lib/actions/window/index.d.ts +4 -0
- package/src/lib/actions/window/index.js +4 -0
- package/src/lib/actions/window/index.js.map +1 -1
- package/src/lib/actions/window/open-modal.d.ts +12 -0
- package/src/lib/actions/window/open-modal.js +6 -0
- package/src/lib/actions/window/open-modal.js.map +1 -0
- package/src/lib/core/listener.js +7 -2
- package/src/lib/core/listener.js.map +1 -1
- package/src/lib/models/handlers.d.ts +7 -1
package/README.md
CHANGED
|
@@ -78,6 +78,8 @@ messenger.registerChild(iframe.contentWindow, 'my-integration-app');
|
|
|
78
78
|
| `auth` | `sendUserDataRequest` / `handleUserDataRequest` | Request the current user's data from the host (currently returns `userId`). |
|
|
79
79
|
| `pubsub` | `sendNotificationRequest` / `handleNotificationRequest` | Subscribe to (or publish) notifications on a `channel`, supporting multiple responses over time. |
|
|
80
80
|
| `window` | `sendUpdateUrl` / `handleUpdateUrl` | Update the url in the host application _without navigating_. Used to support routing/refreshing within an integration |
|
|
81
|
+
| `window` | `sendOpenModal` / `handleOpenModal` | Opens a modal overlay that can be used to host integration iframes. Appends the provided path to the root target origin. |
|
|
82
|
+
| `window` | `sendCloseModal` / `handleCloseModal` | Closes a modal overlay that was previously opened with the `sendOpenModal` command |
|
|
81
83
|
|
|
82
84
|
All `matter`, `contact`, and `settings` actions accept an optional `newTab` flag to indicate the host should open the target in a new tab, and `matter` actions also accept an optional `matterId` beyond what's called out above.
|
|
83
85
|
|
|
@@ -127,6 +129,10 @@ const handle = messenger.actions.pubsub.sendNotificationRequest({ channel: 'docu
|
|
|
127
129
|
handle.remove();
|
|
128
130
|
```
|
|
129
131
|
|
|
132
|
+
#### Modal communication
|
|
133
|
+
|
|
134
|
+
As mentioned above, the `window.sendOpenModal` command allows integrations to trigger a modal overlay and display a custom modal from their application. Its worth noting though that this new modal **will not be able to communicate with the parent application**. Modals should instead communicate with their sibling integration (ie the integration which opened the modal) via the [BroadcastChannelAPI](https://developer.mozilla.org/en-US/docs/Web/API/Broadcast_Channel_API). This way they can notify the sibling of whatever user interaction might be required, including closing the modal.
|
|
135
|
+
|
|
130
136
|
### Forwarding
|
|
131
137
|
|
|
132
138
|
In order to support multiple levels of iframe nesting, the package inherently has a "forwarding" mechanic: for any action, if no handler is defined in a given window, the message continues up or down the iframe tree until a handler picks it up. This is enabled by default and requires no opt-in.
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -56,6 +56,10 @@ declare const _default: {
|
|
|
56
56
|
window: {
|
|
57
57
|
sendUpdateUrl: import(".").ActionCreatorFn<import(".").ActionTypeEnum.WindowUpdateUrl>;
|
|
58
58
|
handleUpdateUrl: import(".").ActionHandlerFn<import(".").ActionTypeEnum.WindowUpdateUrl>;
|
|
59
|
+
sendOpenModal: import(".").ActionCreatorFn<import(".").ActionTypeEnum.WindowOpenModal>;
|
|
60
|
+
handleOpenModal: import(".").ActionHandlerFn<import(".").ActionTypeEnum.WindowOpenModal>;
|
|
61
|
+
sendCloseModal: import(".").ActionCreatorFn<import(".").ActionTypeEnum.WindowCloseModal>;
|
|
62
|
+
handleCloseModal: import(".").ActionHandlerFn<import(".").ActionTypeEnum.WindowCloseModal>;
|
|
59
63
|
};
|
|
60
64
|
};
|
|
61
65
|
};
|
|
@@ -17,6 +17,8 @@ import { type MatterPreviewDocumentDataTypeDTO } from './matter/preview-document
|
|
|
17
17
|
import { type MatterSetFullScreenDataTypeDTO } from './matter/set-fullscreen';
|
|
18
18
|
import { type PubsubNotificationDataTypeDTO } from './pubsub/notification';
|
|
19
19
|
import { type SettingsOpenDataTypeDTO } from './settings/open';
|
|
20
|
+
import { type WindowCloseModalDataTypeDTO } from './window/close-modal';
|
|
21
|
+
import { type WindowOpenModalDataTypeDTO } from './window/open-modal';
|
|
20
22
|
import { type WindowUpdateUrlDataTypeDTO } from './window/update-url';
|
|
21
23
|
export declare enum InternalActionTypeEnum {
|
|
22
24
|
Handshake = "Handshake"
|
|
@@ -39,7 +41,9 @@ export declare enum ActionTypeEnum {
|
|
|
39
41
|
PubsubNotification = "PubsubNotification",
|
|
40
42
|
RequestExchangeToken = "RequestExchangeToken",
|
|
41
43
|
RequestUserData = "RequestUserData",
|
|
42
|
-
WindowUpdateUrl = "WindowUpdateUrl"
|
|
44
|
+
WindowUpdateUrl = "WindowUpdateUrl",
|
|
45
|
+
WindowOpenModal = "WindowOpenModal",
|
|
46
|
+
WindowCloseModal = "WindowCloseModal"
|
|
43
47
|
}
|
|
44
48
|
export declare const AdditionalMessageConfig: {
|
|
45
49
|
[key in ActionTypeEnum]?: AdditionalMessageConfigDTO;
|
|
@@ -64,4 +68,6 @@ export type DataTypeMapDTO = {
|
|
|
64
68
|
[ActionTypeEnum.RequestExchangeToken]: ExchangeTokenDataTypeDTO;
|
|
65
69
|
[ActionTypeEnum.RequestUserData]: UserDataDataTypeDTO;
|
|
66
70
|
[ActionTypeEnum.WindowUpdateUrl]: WindowUpdateUrlDataTypeDTO;
|
|
71
|
+
[ActionTypeEnum.WindowOpenModal]: WindowOpenModalDataTypeDTO;
|
|
72
|
+
[ActionTypeEnum.WindowCloseModal]: WindowCloseModalDataTypeDTO;
|
|
67
73
|
};
|
package/src/lib/actions/base.js
CHANGED
|
@@ -22,6 +22,8 @@ export var ActionTypeEnum;
|
|
|
22
22
|
ActionTypeEnum["RequestExchangeToken"] = "RequestExchangeToken";
|
|
23
23
|
ActionTypeEnum["RequestUserData"] = "RequestUserData";
|
|
24
24
|
ActionTypeEnum["WindowUpdateUrl"] = "WindowUpdateUrl";
|
|
25
|
+
ActionTypeEnum["WindowOpenModal"] = "WindowOpenModal";
|
|
26
|
+
ActionTypeEnum["WindowCloseModal"] = "WindowCloseModal";
|
|
25
27
|
})(ActionTypeEnum || (ActionTypeEnum = {}));
|
|
26
28
|
export const AdditionalMessageConfig = {
|
|
27
29
|
[ActionTypeEnum.PubsubNotification]: { keepAlive: true }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../../libs/integrations-messenger/src/lib/actions/base.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../../libs/integrations-messenger/src/lib/actions/base.ts"],"names":[],"mappings":"AAuBA,MAAM,CAAN,IAAY,sBAEX;AAFD,WAAY,sBAAsB;IAChC,iDAAuB,CAAA;AACzB,CAAC,EAFW,sBAAsB,KAAtB,sBAAsB,QAEjC;AAED,MAAM,CAAN,IAAY,cA2BX;AA3BD,WAAY,cAAc;IACxB,iEAA+C,CAAA;IAC/C,mEAAiD,CAAA;IACjD,qEAAmD,CAAA;IACnD,uDAAqC,CAAA;IACrC,yDAAuC,CAAA;IACvC,mDAAiC,CAAA;IACjC,uEAAqD,CAAA;IACrD,iEAA+C,CAAA;IAC/C,2CAAyB,CAAA;IACzB,6DAA2C,CAAA;IAE3C,6CAA2B,CAAA;IAC3B,qDAAmC,CAAA;IAEnC,+CAA6B,CAAA;IAE7B,6CAA2B,CAAA;IAE3B,2DAAyC,CAAA;IAEzC,+DAA6C,CAAA;IAC7C,qDAAmC,CAAA;IAEnC,qDAAmC,CAAA;IACnC,qDAAmC,CAAA;IACnC,uDAAqC,CAAA;AACvC,CAAC,EA3BW,cAAc,KAAd,cAAc,QA2BzB;AAED,MAAM,CAAC,MAAM,uBAAuB,GAA6D;IAC/F,CAAC,cAAc,CAAC,kBAAkB,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;CACzD,CAAC"}
|
|
@@ -48,6 +48,10 @@ declare const _default: {
|
|
|
48
48
|
window: {
|
|
49
49
|
sendUpdateUrl: import("../models").ActionCreatorFn<import("./base").ActionTypeEnum.WindowUpdateUrl>;
|
|
50
50
|
handleUpdateUrl: import("../models").ActionHandlerFn<import("./base").ActionTypeEnum.WindowUpdateUrl>;
|
|
51
|
+
sendOpenModal: import("../models").ActionCreatorFn<import("./base").ActionTypeEnum.WindowOpenModal>;
|
|
52
|
+
handleOpenModal: import("../models").ActionHandlerFn<import("./base").ActionTypeEnum.WindowOpenModal>;
|
|
53
|
+
sendCloseModal: import("../models").ActionCreatorFn<import("./base").ActionTypeEnum.WindowCloseModal>;
|
|
54
|
+
handleCloseModal: import("../models").ActionHandlerFn<import("./base").ActionTypeEnum.WindowCloseModal>;
|
|
51
55
|
};
|
|
52
56
|
};
|
|
53
57
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ActionTypeEnum } from './base';
|
|
2
|
-
import { type ActionCreatorConfigDTO, type ActionCreatorFn, type ActionHandlerFn, type StreamActionCreatorFn, type StreamActionHandlerFn } from '../models';
|
|
2
|
+
import { type ActionCreatorConfigDTO, type ActionCreatorFn, type ActionHandlerBuildOptions, type ActionHandlerFn, type StreamActionCreatorFn, type StreamActionHandlerFn } from '../models';
|
|
3
3
|
export declare const buildActionCreatorFn: <T extends ActionTypeEnum>(type: T, opts?: ActionCreatorConfigDTO<T>) => ActionCreatorFn<T>;
|
|
4
|
-
export declare const buildActionHandlerFn: <T extends ActionTypeEnum>(type: T) => ActionHandlerFn<T>;
|
|
4
|
+
export declare const buildActionHandlerFn: <T extends ActionTypeEnum>(type: T, opts?: ActionHandlerBuildOptions) => ActionHandlerFn<T>;
|
|
5
5
|
export declare const buildAsyncActionCreatorFn: <T extends ActionTypeEnum>(type: T, opts?: ActionCreatorConfigDTO<T>) => StreamActionCreatorFn<T>;
|
|
6
6
|
export declare const buildAsyncActionHandlerFn: <T extends ActionTypeEnum>(type: T) => StreamActionHandlerFn<T>;
|
|
7
7
|
export declare const isInternalActionType: (type: string) => boolean;
|
package/src/lib/actions/utils.js
CHANGED
|
@@ -24,8 +24,10 @@ export const buildActionCreatorFn = (type, opts = {}) => (request) => new Promis
|
|
|
24
24
|
target: parentId
|
|
25
25
|
});
|
|
26
26
|
});
|
|
27
|
-
export const buildActionHandlerFn = (type) => (handler) => listener.addMessageHandler(type, async ({ data: request }) => {
|
|
28
|
-
const response = await handler(request.data
|
|
27
|
+
export const buildActionHandlerFn = (type, opts) => (handler) => listener.addMessageHandler(type, async ({ data: request }) => {
|
|
28
|
+
const response = await handler(request.data, {
|
|
29
|
+
srcOrigin: opts?.includeSrcOrigin ? target.getTarget(request.src)?.origin : undefined
|
|
30
|
+
});
|
|
29
31
|
emitter.sendData({
|
|
30
32
|
id: request.id,
|
|
31
33
|
type: `${type}Response`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../libs/integrations-messenger/src/lib/actions/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAuB,sBAAsB,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,OAAO,MAAM,iBAAiB,CAAC;AACtC,OAAO,QAAQ,MAAM,kBAAkB,CAAC;AACxC,OAAO,MAAM,MAAM,gBAAgB,CAAC;AACpC,OAAO,MAAM,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../libs/integrations-messenger/src/lib/actions/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAuB,sBAAsB,EAAE,MAAM,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AC;IAEH,OAAO,CAAC,QAAQ,CAAC;QACf,EAAE,EAAE,SAAS;QACb,IAAI;QACJ,IAAI,EAAE,OAAiC;QACvC,MAAM,EAAE,QAAQ;KACjB,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEJ,MAAM,CAAC,MAAM,yBAAyB,GACpC,CAA2B,IAAO,EAA4B,EAAE,CAChE,CAAC,OAAO,EAAE,EAAE,CACV,QAAQ,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;IACrD,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE;QACjC,OAAO,CAAC,QAAQ,CAAC;YACf,EAAE,EAAE,OAAO,CAAC,EAAE;YACd,IAAI,EAAE,GAAG,IAAI,UAAU;YACvB,MAAM,EAAE,OAAO,CAAC,GAAG;YACnB,IAAI,EAAE,QAA+C;SACtD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEP,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAW,EAAE,CAC5D,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ActionResponseBaseDTO, ActionTypeEnum } from '../../models';
|
|
2
|
+
import { type ActionDataTypeDTO } from '../utils';
|
|
3
|
+
type WindowCloseModalDTO = void;
|
|
4
|
+
type WindowCloseModalResponseDTO = ActionResponseBaseDTO;
|
|
5
|
+
export type WindowCloseModalDataTypeDTO = ActionDataTypeDTO<WindowCloseModalDTO, WindowCloseModalResponseDTO>;
|
|
6
|
+
declare const _default: {
|
|
7
|
+
sendCloseModal: import("../../models").ActionCreatorFn<ActionTypeEnum.WindowCloseModal>;
|
|
8
|
+
handleCloseModal: import("../../models").ActionHandlerFn<ActionTypeEnum.WindowCloseModal>;
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ActionTypeEnum } from '../../models';
|
|
2
|
+
import { buildActionCreatorFn, buildActionHandlerFn } from '../utils';
|
|
3
|
+
const sendCloseModal = buildActionCreatorFn(ActionTypeEnum.WindowCloseModal);
|
|
4
|
+
const handleCloseModal = buildActionHandlerFn(ActionTypeEnum.WindowCloseModal);
|
|
5
|
+
export default { sendCloseModal, handleCloseModal };
|
|
6
|
+
//# sourceMappingURL=close-modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"close-modal.js","sourceRoot":"","sources":["../../../../../../../libs/integrations-messenger/src/lib/actions/window/close-modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,cAAc,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAA0B,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAQ9F,MAAM,cAAc,GAAG,oBAAoB,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC;AAC7E,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC;AAE/E,eAAe,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
2
|
sendUpdateUrl: import("../../models").ActionCreatorFn<import("../base").ActionTypeEnum.WindowUpdateUrl>;
|
|
3
3
|
handleUpdateUrl: import("../../models").ActionHandlerFn<import("../base").ActionTypeEnum.WindowUpdateUrl>;
|
|
4
|
+
sendOpenModal: import("../../models").ActionCreatorFn<import("../base").ActionTypeEnum.WindowOpenModal>;
|
|
5
|
+
handleOpenModal: import("../../models").ActionHandlerFn<import("../base").ActionTypeEnum.WindowOpenModal>;
|
|
6
|
+
sendCloseModal: import("../../models").ActionCreatorFn<import("../base").ActionTypeEnum.WindowCloseModal>;
|
|
7
|
+
handleCloseModal: import("../../models").ActionHandlerFn<import("../base").ActionTypeEnum.WindowCloseModal>;
|
|
4
8
|
};
|
|
5
9
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/integrations-messenger/src/lib/actions/window/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,eAAe;IACb,GAAG,SAAS;CACb,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/integrations-messenger/src/lib/actions/window/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,eAAe;IACb,GAAG,UAAU;IACb,GAAG,SAAS;IACZ,GAAG,SAAS;CACb,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ActionResponseBaseDTO, ActionTypeEnum } from '../../models';
|
|
2
|
+
import { type ActionDataTypeDTO } from '../utils';
|
|
3
|
+
type WindowOpenModalDTO = {
|
|
4
|
+
path: string;
|
|
5
|
+
};
|
|
6
|
+
type WindowOpenModalResponseDTO = ActionResponseBaseDTO;
|
|
7
|
+
export type WindowOpenModalDataTypeDTO = ActionDataTypeDTO<WindowOpenModalDTO, WindowOpenModalResponseDTO>;
|
|
8
|
+
declare const _default: {
|
|
9
|
+
sendOpenModal: import("../../models").ActionCreatorFn<ActionTypeEnum.WindowOpenModal>;
|
|
10
|
+
handleOpenModal: import("../../models").ActionHandlerFn<ActionTypeEnum.WindowOpenModal>;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ActionTypeEnum } from '../../models';
|
|
2
|
+
import { buildActionCreatorFn, buildActionHandlerFn } from '../utils';
|
|
3
|
+
const sendOpenModal = buildActionCreatorFn(ActionTypeEnum.WindowOpenModal);
|
|
4
|
+
const handleOpenModal = buildActionHandlerFn(ActionTypeEnum.WindowOpenModal, { includeSrcOrigin: true });
|
|
5
|
+
export default { sendOpenModal, handleOpenModal };
|
|
6
|
+
//# sourceMappingURL=open-modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-modal.js","sourceRoot":"","sources":["../../../../../../../libs/integrations-messenger/src/lib/actions/window/open-modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,cAAc,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAA0B,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAU9F,MAAM,aAAa,GAAG,oBAAoB,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;AAC3E,MAAM,eAAe,GAAG,oBAAoB,CAAC,cAAc,CAAC,eAAe,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC;AAEzG,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC"}
|
package/src/lib/core/listener.js
CHANGED
|
@@ -5,6 +5,8 @@ import { ActionTypeEnum, AdditionalMessageConfig, InternalActionTypeEnum } from
|
|
|
5
5
|
import { isInternalActionType } from '../actions/utils';
|
|
6
6
|
import { ALL_MESSAGE_TYPES } from '../models';
|
|
7
7
|
const eventTarget = new EventTarget();
|
|
8
|
+
/** The handshake handler currently armed for each registered child, so re-registering replaces it. */
|
|
9
|
+
const childHandshakeHandlers = {};
|
|
8
10
|
const eventIsPlatformMessage = (
|
|
9
11
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
12
|
event) => !!event.data && typeof event.data === 'object' && 'type' in event.data && ALL_MESSAGE_TYPES.includes(event.data.type);
|
|
@@ -27,7 +29,10 @@ const setupDefaultListeners = () => {
|
|
|
27
29
|
};
|
|
28
30
|
const registerChild = (child, id) => new Promise((resolve) => {
|
|
29
31
|
logger.info('wait for handshake from', id);
|
|
30
|
-
|
|
32
|
+
// Re-registering a child replaces its handler rather than stacking another one on top. The new
|
|
33
|
+
// handler is armed before the old one is dropped so there's never a moment with none listening.
|
|
34
|
+
const previousHandler = childHandshakeHandlers[id];
|
|
35
|
+
childHandshakeHandlers[id] = addMessageHandler(InternalActionTypeEnum.Handshake, (event) => {
|
|
31
36
|
if (event.source !== child || event.data.src !== id) {
|
|
32
37
|
logger.error('Received handshake from unexpected source');
|
|
33
38
|
return;
|
|
@@ -42,9 +47,9 @@ const registerChild = (child, id) => new Promise((resolve) => {
|
|
|
42
47
|
src: target.getSourceId(),
|
|
43
48
|
data: void 0
|
|
44
49
|
}, targetRef);
|
|
45
|
-
handler.remove();
|
|
46
50
|
resolve();
|
|
47
51
|
});
|
|
52
|
+
previousHandler?.remove();
|
|
48
53
|
});
|
|
49
54
|
const addMessageHandler = (type, callback, config = {}) => {
|
|
50
55
|
if (!config.silent) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listener.js","sourceRoot":"","sources":["../../../../../../libs/integrations-messenger/src/lib/core/listener.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAClG,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EACL,iBAAiB,EAOlB,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAEtC,MAAM,sBAAsB,GAAG;AAC7B,8DAA8D;AAC9D,KAAwB,EACgC,EAAE,CAC1D,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK,CAAC,IAAI,I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C,IAAI,CAAC;QACxB,MAAM,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAErC,oGAAoG;QACpG,IAAI,CAAC,EAAE,MAAM,KAAK,KAAK,CAAC,MAAM,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACnE,MAAM,CAAC,IAAI,CAAC,kDAAkD,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;YACjH,OAAO;QACT,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;QAEtC,8DAA8D;QAC9D,MAAM,WAAW,GAAG,IAAI,WAAW,CAAoC,IAAI,CAAC,IAAI,EAAE;YAChF,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;QACH,WAAW,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,eAAe,EAAE,iBAAiB,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -16,6 +16,12 @@ export type ActionCreatorConfigDTO<T extends ActionTypeEnum> = {
|
|
|
16
16
|
skipWhen?: (request: ActionRequestDTO<T>, response: ActionResponseDTO<T>) => boolean;
|
|
17
17
|
};
|
|
18
18
|
export type ActionCreatorFn<T extends ActionTypeEnum> = (request: ActionRequestDTO<T>) => Promise<ActionResponseDTO<T>>;
|
|
19
|
-
export type
|
|
19
|
+
export type ActionHandlerBuildOptions = {
|
|
20
|
+
includeSrcOrigin: boolean;
|
|
21
|
+
};
|
|
22
|
+
export type ActionHandlerExtraParams = {
|
|
23
|
+
srcOrigin?: string;
|
|
24
|
+
};
|
|
25
|
+
export type ActionHandlerFn<T extends ActionTypeEnum> = (handler: (request: ActionRequestDTO<T>, extras: ActionHandlerExtraParams) => ActionResponseDTO<T> | Promise<ActionResponseDTO<T>>) => MessageHandlerResponseDTO;
|
|
20
26
|
export type StreamActionCreatorFn<T extends ActionTypeEnum> = (request: ActionRequestDTO<T>, handler: (response: ActionResponseDTO<T>) => void) => MessageHandlerResponseDTO;
|
|
21
27
|
export type StreamActionHandlerFn<T extends ActionTypeEnum> = (handler: (request: ActionRequestDTO<T>, resolve: (response: ActionResponseDTO<T>) => void) => void) => MessageHandlerResponseDTO;
|