@elliemae/ssf-host 2.23.6 → 2.23.8

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.
@@ -61,6 +61,14 @@ export type HostOption = {
61
61
  * callback to process guest event unsubscription
62
62
  */
63
63
  onGuestEventUnsubscribe?: GuestEventUnsubscribeCallback;
64
+ /**
65
+ * **UNSAFE**: When true, uses '*' as the targetOrigin for all outbound postMessage calls from host to guest,
66
+ * allowing messages to be delivered regardless of the guest window's current origin. This means any window
67
+ * can receive messages intended for the guest, potentially exposing sensitive data.
68
+ * Only enable this if you fully understand the security implications.
69
+ * @default false
70
+ */
71
+ unsafeAllowAnyGuestOrigin?: boolean;
64
72
  };
65
73
  /**
66
74
  * parameters for rendering a guest
@@ -196,5 +204,20 @@ export interface ISSFHost<AppObjects extends ScriptingObjects = ScriptingObjectT
196
204
  * @throws Error if guestId or Window reference is invalid
197
205
  */
198
206
  unloadGuest: (guestIdOrWindowOrEle: string | Window | HTMLIFrameElement) => void;
207
+ /**
208
+ * Unloads guest application with comprehensive memory leak prevention.
209
+ *
210
+ * This method implements industry best practices for iframe cleanup to prevent
211
+ * memory leaks, particularly detached window retention and webpack bundle accumulation.
212
+ *
213
+ * **Enhanced for selfInitialize=true pattern:** Does not clean window.emui[appId]
214
+ * registry as the guest handles its own cleanup internally.
215
+ *
216
+ * **Synchronous by design:** Works with React useEffect cleanup functions.
217
+ * @param guestIdOrWindowOrEle unique id of the guest application or window object or dom element
218
+ * @param cleanupFunctionName name of cleanup function on window.emui (default: 'unmount')
219
+ * @throws Error if guestId or Window reference is invalid
220
+ */
221
+ unloadGuestWithFullCleanup: (guestIdOrWindowOrEle: string | Window | HTMLIFrameElement, cleanupFunctionName?: string) => void;
199
222
  onGuestClose: (param: GuestCloseParam) => void;
200
223
  }
@@ -1,4 +1,4 @@
1
- export type { GuestOptions, AttachParam, WindowFeatures } from './types.js';
1
+ export type { GuestOptions, AttachParam, WindowFeatures, UnloadOptions, } from './types.js';
2
2
  export type { HostOption, LoadGuestParam, LoadGuestsParam, GuestEventSubscribeCallback, GuestEventUnsubscribeCallback, GuestEventSubscribeParam, GuestEventUnsubscribeParam, } from './ihost.js';
3
3
  export type { IScriptingObjectProxy } from '@elliemae/pui-scripting-object';
4
4
  export { Event, ScriptingObject } from '@elliemae/microfe-common';
@@ -143,3 +143,62 @@ export type AttachParam = {
143
143
  */
144
144
  searchParams?: Record<string, string | number | boolean>;
145
145
  };
146
+ /**
147
+ * Options for unloading a guest application with enhanced cleanup.
148
+ *
149
+ * When purgeOnDestroy is true, performs comprehensive memory leak prevention:
150
+ * - Calls guest cleanup function (React unmount, Redux teardown)
151
+ * - Closes contentWindow context
152
+ * - Navigates iframe to about:blank (Chrome GC recommendation)
153
+ * - Removes iframe from DOM (deferred)
154
+ * - Clears all window.emui and window.elli.script references
155
+ * - Disconnects FieldMutation observers
156
+ * - Removes from SSF tracking maps
157
+ */
158
+ export type UnloadOptions = {
159
+ /**
160
+ * When true, uses comprehensive cleanup sequence via unloadGuestWithFullCleanup.
161
+ * When false or omitted, uses standard guest disposal.
162
+ * @default false
163
+ */
164
+ purgeOnDestroy?: boolean;
165
+ /**
166
+ * Array of window reference paths to clear recursively.
167
+ * Each path is a dot-separated string (e.g., "window.IMT.focusFormTitle").
168
+ * The "window" prefix is optional and will be stripped automatically.
169
+ *
170
+ * All specified references will be set to null to break closure chains
171
+ * and allow garbage collection.
172
+ * @example
173
+ * ```typescript
174
+ * windowRefsToClear: [
175
+ * "window.IMT.focusFormTitle",
176
+ * "window.emui.customApp",
177
+ * "IMT.someOtherRef" // window prefix is optional
178
+ * ]
179
+ * ```
180
+ */
181
+ windowRefsToClear?: string[];
182
+ /**
183
+ * Optional appId for targeted window.emui[appId] cleanup.
184
+ * When provided, cleans up window.emui[appId] directly without scanning.
185
+ * @example
186
+ * ```typescript
187
+ * appId: "workflowtasks" // cleans window.emui.workflowtasks
188
+ * appId: "loanapp" // cleans window.emui.loanapp
189
+ * ```
190
+ */
191
+ appId?: string;
192
+ /**
193
+ * Name of the cleanup function on window.emui in the guest iframe.
194
+ * This function should handle guest-side cleanup like React unmounting
195
+ * and Redux store teardown.
196
+ * @default "unmount"
197
+ * @example
198
+ * ```typescript
199
+ * cleanupFunctionName: "rendererCleanup" // calls window.emui.rendererCleanup()
200
+ * cleanupFunctionName: "cleanup" // calls window.emui.cleanup()
201
+ * ```
202
+ */
203
+ cleanupFunctionName?: string;
204
+ };