@elliemae/pui-app-bridge 2.35.3 → 2.35.5

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.
@@ -13,6 +13,11 @@ type EventListenerDetails = {
13
13
  * guest instance id when subscribed via a guest iframe host
14
14
  */
15
15
  guestId?: string;
16
+ /**
17
+ * instance id of the guest host (openApp uuid) that registered this listener.
18
+ * Used only for cleanup; it never affects event delivery.
19
+ */
20
+ ownerInstanceId?: string;
16
21
  /**
17
22
  * event listener
18
23
  */
@@ -61,19 +66,32 @@ export declare class EventManager<AppEvents extends EventListeners = Events> {
61
66
  */
62
67
  subscribe: <EventId extends Extract<keyof AppEvents, string>>(param: SubscribeParam<EventId, AppEvents[EventId]> & {
63
68
  guestId?: string;
69
+ ownerInstanceId?: string;
64
70
  }) => string;
65
71
  /**
66
- * Unsubscribe from an event
72
+ * Unsubscribe from an event.
73
+ *
74
+ * With a token, removes that subscription; a token that matches nothing
75
+ * (including an empty string) removes nothing. Without a token (undefined or
76
+ * null), removes every listener of the event, or, when `ownerInstanceId` is
77
+ * given, only the listeners registered by that owner. When `ownerInstanceId`
78
+ * is given, a token unsubscribe only removes a listener registered by that
79
+ * owner; a token owned by someone else is kept and a warning is logged.
80
+ * Removal never mutates the listener array an in-progress dispatch iterates.
67
81
  * @param {UnsubscribeParam<EventId>} param - parameters for unsubscribing from an event
68
82
  */
69
- unsubscribe: <EventId extends Extract<keyof AppEvents, string>>(param: UnsubscribeParam<EventId>) => void;
83
+ unsubscribe: <EventId extends Extract<keyof AppEvents, string>>(param: Omit<UnsubscribeParam<EventId>, "token"> & {
84
+ token?: string | null;
85
+ ownerInstanceId?: string;
86
+ }) => void;
70
87
  /**
71
88
  * Unsubscribe from all events
72
89
  */
73
90
  unsubscribeAll: () => void;
74
91
  /**
75
- * Removes every listener registered for a guest iframe host instance.
76
- * Global listeners (no guestId) are preserved.
92
+ * Removes every listener registered for a guest iframe host instance:
93
+ * listeners scoped to it (`guestId`) and listeners it owns
94
+ * (`ownerInstanceId`). Listeners of the host and of other guests are preserved.
77
95
  * @param guestId openApp instance id
78
96
  */
79
97
  unsubscribeByGuestId: (guestId: string) => void;
@@ -4,6 +4,13 @@ import type { EventListeners, GuestContext, SubscribeParam, UnsubscribeParam } f
4
4
  import { ScriptingObjectManager, ScriptingObjects } from '@elliemae/microfe-common';
5
5
  import { EventManager } from './eventManager.js';
6
6
  import { IMicroFEHost, AppWindowSize } from './typings/host.js';
7
+ /**
8
+ * Key of the method that disposes a host when its guest closes. Only the app
9
+ * bridge imports it; it is not exported from the package index, so guests
10
+ * holding the host have no named way to call it.
11
+ * @internal
12
+ */
13
+ export declare const DISPOSE_HOST: unique symbol;
7
14
  /**
8
15
  * Constructor parameters for the host application
9
16
  */
@@ -67,14 +74,22 @@ export declare class CMicroFEHost<AppObjects extends ScriptingObjects = Partial<
67
74
  */
68
75
  setAppWindowSize: (appSize: AppWindowSize) => void;
69
76
  /**
70
- * add listener to the scripting object event
77
+ * add listener to the scripting object event.
78
+ * The listener is owned by this guest instance and is removed when the guest is closed.
71
79
  * @param {SubscribeParam<EventId, EventListener>} params - parameters to add event listener
72
- * @returns subscription id
80
+ * @returns subscription id, or an empty string when the guest is already closed
73
81
  */
74
82
  subscribe: <EventId extends Extract<keyof AppEvents, string>>(params: SubscribeParam<EventId, AppEvents[EventId]>) => string;
75
83
  /**
76
- * removes listener from the scripting object event
84
+ * removes listener from the scripting object event.
85
+ * Only listeners registered by this guest instance are removed.
77
86
  * @param {UnsubscribeParam<EventId>} params - parameters to remove event listener
78
87
  */
79
88
  unsubscribe: <EventId extends Extract<keyof AppEvents, string>>(params: UnsubscribeParam<EventId>) => void;
89
+ /**
90
+ * Called by the app bridge when the guest is closed.
91
+ * Later subscribe calls are ignored so a closed guest cannot register listeners again.
92
+ * @internal
93
+ */
94
+ [DISPOSE_HOST](): void;
80
95
  }