@elliemae/ssf-host 2.25.2 → 2.25.4
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/host.js +591 -21
- package/dist/cjs/tests/utils.js +2 -2
- package/dist/esm/host.js +594 -22
- package/dist/esm/tests/utils.js +2 -2
- package/dist/public/callchain-host.html +1 -1
- package/dist/public/callchain-intermediate.html +1 -1
- package/dist/public/e2e-host.html +1 -1
- package/dist/public/e2e-index.html +1 -1
- package/dist/public/index.html +1 -1
- package/dist/public/js/emuiSsfHost.1f1cbf6c2111a68bc2c8.js +3 -0
- package/dist/public/js/emuiSsfHost.1f1cbf6c2111a68bc2c8.js.br +0 -0
- package/dist/public/js/emuiSsfHost.1f1cbf6c2111a68bc2c8.js.gz +0 -0
- package/dist/public/js/emuiSsfHost.1f1cbf6c2111a68bc2c8.js.map +1 -0
- package/dist/public/popup-focus-host.html +1 -1
- package/dist/public/v1-guest-v2-host.html +1 -1
- package/dist/public/v2-host-v1-guest.html +1 -1
- package/dist/types/lib/host.d.ts +98 -8
- package/dist/types/lib/ihost.d.ts +15 -0
- package/dist/types/lib/index.d.ts +1 -1
- package/dist/types/lib/tests/guestCapabilities.test.d.ts +1 -0
- package/dist/types/lib/tests/utils.d.ts +1 -1
- package/dist/types/lib/types.d.ts +59 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.br +0 -0
- package/dist/umd/index.js.gz +0 -0
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/public/js/emuiSsfHost.3a32945e82d7f91f1e22.js +0 -3
- package/dist/public/js/emuiSsfHost.3a32945e82d7f91f1e22.js.br +0 -0
- package/dist/public/js/emuiSsfHost.3a32945e82d7f91f1e22.js.gz +0 -0
- package/dist/public/js/emuiSsfHost.3a32945e82d7f91f1e22.js.map +0 -1
package/dist/types/lib/host.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IScriptingObjectProxy, ScriptingObjectTypes, Events } from '@elliemae/pui-scripting-object';
|
|
2
2
|
import type { EventListeners, AddScriptingObjectParams, GetObjectParams, DispatchEventParam, EventOptions } from '@elliemae/microfe-common';
|
|
3
3
|
import { LogLevels } from '@elliemae/pui-diagnostics';
|
|
4
|
-
import { IFrameSandboxValues, ValueOf, ScriptingObjects } from './types.js';
|
|
4
|
+
import { IFrameSandboxValues, ValueOf, ScriptingObjects, UnloadOptions } from './types.js';
|
|
5
5
|
import { ISSFHost, HostOption, LoadGuestParam, LoadGuestsParam, GuestCloseParam } from './ihost.js';
|
|
6
6
|
import { Guest } from './guest.js';
|
|
7
7
|
export declare const SANDBOX_DEFAULT: IFrameSandboxValues[];
|
|
@@ -85,16 +85,106 @@ export declare class SSFHost<AppObjects extends ScriptingObjects = ScriptingObje
|
|
|
85
85
|
*/
|
|
86
86
|
setLogLevel: (level: LogLevels) => void;
|
|
87
87
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
88
|
+
* Unloads guest application from host with optional enhanced cleanup.
|
|
89
|
+
*
|
|
90
|
+
* **Basic Mode (no options):**
|
|
91
|
+
* - Standard guest disposal
|
|
92
|
+
* - Removes from tracking maps
|
|
93
|
+
*
|
|
94
|
+
* **Enhanced Mode (with options):**
|
|
95
|
+
* - `purgeOnDestroy: true` - Uses comprehensive cleanup via `unloadGuestWithFullCleanup`
|
|
96
|
+
* - Calls guest cleanup function (React unmount, Redux teardown)
|
|
97
|
+
* - Closes contentWindow context
|
|
98
|
+
* - Navigates iframe to about:blank
|
|
99
|
+
* - Removes iframe from DOM (deferred)
|
|
100
|
+
* - Clears all window.emui and window.elli.script references
|
|
101
|
+
* - Disconnects FieldMutation observers
|
|
102
|
+
* - Removes from SSF tracking
|
|
103
|
+
*
|
|
104
|
+
* - `windowRefsToClear` - Array of paths to window refs to clear recursively
|
|
105
|
+
* - Example: ["window.IMT.focusFormTitle", "window.emui.customApp"]
|
|
106
|
+
* - Each path is parsed and set to null
|
|
107
|
+
*
|
|
108
|
+
* - `appId` - Optional appId for targeted window.emui[appId] cleanup
|
|
109
|
+
*
|
|
110
|
+
* - `cleanupFunctionName` - Name of cleanup function on window.emui (default: 'unmount')
|
|
111
|
+
* @param {string | Window | HTMLIFrameElement} guestIdOrWindowOrEle - Unique id, window object, or iframe element
|
|
112
|
+
* @param {object} options - Optional cleanup configuration
|
|
113
|
+
* @param {boolean} options.purgeOnDestroy - When true, use comprehensive cleanup sequence
|
|
114
|
+
* @param {string[]} options.windowRefsToClear - Array of window ref paths to clear
|
|
115
|
+
* @param {string} options.appId - Optional appId for targeted cleanup
|
|
116
|
+
* @param {string} options.cleanupFunctionName - Guest cleanup function name (default: 'unmount')
|
|
117
|
+
* @example
|
|
118
|
+
* // Basic cleanup
|
|
119
|
+
* host.unloadGuest('my-guest-id');
|
|
120
|
+
* @example
|
|
121
|
+
* // Enhanced cleanup with purge
|
|
122
|
+
* host.unloadGuest('my-guest-id', {
|
|
123
|
+
* purgeOnDestroy: true,
|
|
124
|
+
* windowRefsToClear: ["window.IMT.focusFormTitle"],
|
|
125
|
+
* cleanupFunctionName: 'appCleanup'
|
|
126
|
+
* });
|
|
127
|
+
* @example
|
|
128
|
+
* // Enhanced cleanup with appId
|
|
129
|
+
* host.unloadGuest('my-guest-id', {
|
|
130
|
+
* purgeOnDestroy: true,
|
|
131
|
+
* appId: 'workflowtasks',
|
|
132
|
+
* cleanupFunctionName: 'cleanup'
|
|
133
|
+
* });
|
|
91
134
|
*/
|
|
92
|
-
unloadGuest: (guestIdOrWindowOrEle: string | Window | HTMLIFrameElement) => void;
|
|
135
|
+
unloadGuest: (guestIdOrWindowOrEle: string | Window | HTMLIFrameElement, options?: UnloadOptions) => void;
|
|
136
|
+
/**
|
|
137
|
+
* Unloads guest application with comprehensive memory leak prevention.
|
|
138
|
+
*
|
|
139
|
+
* This method implements industry best practices for iframe and popup cleanup to prevent
|
|
140
|
+
* memory leaks, particularly detached window retention and webpack bundle accumulation.
|
|
141
|
+
*
|
|
142
|
+
* **Enhanced Cleanup Sequence for Embedded Iframes:**
|
|
143
|
+
* 1. Call guest cleanup function (React unmount, Redux teardown, etc.)
|
|
144
|
+
* 2. Close contentWindow context explicitly
|
|
145
|
+
* 3. Navigate iframe to about:blank (Chrome GC recommendation)
|
|
146
|
+
* 4. Small delay, then remove iframe from DOM
|
|
147
|
+
* 5. Remove from SSF tracking maps
|
|
148
|
+
* 6. Null all internal references
|
|
149
|
+
*
|
|
150
|
+
* **Enhanced Cleanup Sequence for Popup Windows:**
|
|
151
|
+
* 1. Call guest cleanup function (React unmount, Redux teardown, etc.)
|
|
152
|
+
* 2. Null all window.emui and window.elli.script references
|
|
153
|
+
* 3. Clear Google Tag Manager data layer
|
|
154
|
+
* 4. Close popup window explicitly
|
|
155
|
+
* 5. Dispose guest (cleanup event listeners)
|
|
156
|
+
* 6. Remove from SSF tracking maps
|
|
157
|
+
*
|
|
158
|
+
* **Memory Leak Prevention:**
|
|
159
|
+
* - Breaks all closures from contentWindow/popup to parent
|
|
160
|
+
* - Signals V8 to GC webpack bundle backing store strings
|
|
161
|
+
* - Removes iframe from browser back/forward cache
|
|
162
|
+
* - Clears all SSF remoting message handlers
|
|
163
|
+
* - Nulls all window.emui and window.elli.script properties
|
|
164
|
+
*
|
|
165
|
+
* **Important:** This method does NOT clean up window.emui[appId] registry.
|
|
166
|
+
* When using selfInitialize=true pattern, the guest application handles
|
|
167
|
+
* its own emui registry cleanup internally.
|
|
168
|
+
*
|
|
169
|
+
* **Synchronous Design:** This method is intentionally synchronous to work
|
|
170
|
+
* with React useEffect cleanup functions. Cleanup steps use setTimeout
|
|
171
|
+
* for deferred operations rather than async/await.
|
|
172
|
+
* @param {string | Window | HTMLIFrameElement} guestIdOrWindowOrEle - unique id of the guest application or window object or dom element
|
|
173
|
+
* @param {string} cleanupFunctionName - name of cleanup function on window.emui (default: 'unmount')
|
|
174
|
+
* @example
|
|
175
|
+
* // Standard usage with app cleanup
|
|
176
|
+
* host.unloadGuestWithFullCleanup('my-guest-id', 'appCleanup');
|
|
177
|
+
* @example
|
|
178
|
+
* // Usage with custom cleanup function
|
|
179
|
+
* host.unloadGuestWithFullCleanup('my-guest-id', 'customUnmount');
|
|
180
|
+
* @example
|
|
181
|
+
* // Usage when guest uses default unmount
|
|
182
|
+
* host.unloadGuestWithFullCleanup('my-guest-id');
|
|
183
|
+
*/
|
|
184
|
+
unloadGuestWithFullCleanup: (guestIdOrWindowOrEle: string | Window | HTMLIFrameElement, cleanupFunctionName?: string) => void;
|
|
93
185
|
/**
|
|
94
186
|
* monitors guest window close action and executes the callback from host.
|
|
95
|
-
* @param
|
|
96
|
-
* @param id unique id of the guest application
|
|
97
|
-
* @param param
|
|
187
|
+
* @param param - Guest close parameters including id and callback
|
|
98
188
|
*/
|
|
99
189
|
onGuestClose: (param: GuestCloseParam) => void;
|
|
100
190
|
}
|
|
@@ -236,5 +236,20 @@ export interface ISSFHost<AppObjects extends ScriptingObjects = ScriptingObjectT
|
|
|
236
236
|
* @throws Error if guestId or Window reference is invalid
|
|
237
237
|
*/
|
|
238
238
|
unloadGuest: (guestIdOrWindowOrEle: string | Window | HTMLIFrameElement) => void;
|
|
239
|
+
/**
|
|
240
|
+
* Unloads guest application with comprehensive memory leak prevention.
|
|
241
|
+
*
|
|
242
|
+
* This method implements industry best practices for iframe cleanup to prevent
|
|
243
|
+
* memory leaks, particularly detached window retention and webpack bundle accumulation.
|
|
244
|
+
*
|
|
245
|
+
* **Enhanced for selfInitialize=true pattern:** Does not clean window.emui[appId]
|
|
246
|
+
* registry as the guest handles its own cleanup internally.
|
|
247
|
+
*
|
|
248
|
+
* **Synchronous by design:** Works with React useEffect cleanup functions.
|
|
249
|
+
* @param guestIdOrWindowOrEle unique id of the guest application or window object or dom element
|
|
250
|
+
* @param cleanupFunctionName name of cleanup function on window.emui (default: 'unmount')
|
|
251
|
+
* @throws Error if guestId or Window reference is invalid
|
|
252
|
+
*/
|
|
253
|
+
unloadGuestWithFullCleanup: (guestIdOrWindowOrEle: string | Window | HTMLIFrameElement, cleanupFunctionName?: string) => void;
|
|
239
254
|
onGuestClose: (param: GuestCloseParam) => void;
|
|
240
255
|
}
|
|
@@ -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';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -11,7 +11,7 @@ export declare const postMessage: ({ srcWindow, targetWindow, message, }: {
|
|
|
11
11
|
targetWindow: Window;
|
|
12
12
|
message: Record<string, unknown>;
|
|
13
13
|
}) => void;
|
|
14
|
-
export declare const initGuest: (guestId: string) => Window;
|
|
14
|
+
export declare const initGuest: (guestId: string, capabilities?: Record<string, unknown>) => Window;
|
|
15
15
|
export declare const releaseJSThread: () => Promise<unknown>;
|
|
16
16
|
export type Data = {
|
|
17
17
|
data: {
|
|
@@ -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
|
+
};
|