@elliemae/microfe-common 2.24.0 → 2.26.0-alpha.0
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/app.js +33 -0
- package/dist/cjs/auditThrottler.js +60 -0
- package/dist/cjs/config.js +65 -0
- package/dist/cjs/frame.html +47 -0
- package/dist/cjs/frame.js +61 -0
- package/dist/cjs/history.js +27 -0
- package/dist/cjs/host.js +105 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/loader.js +158 -0
- package/dist/cjs/logRecords.js +57 -0
- package/dist/cjs/logger.js +34 -0
- package/dist/cjs/manifestLoader.js +66 -0
- package/dist/cjs/scriptLoader.js +71 -0
- package/dist/cjs/styleLoader.js +57 -0
- package/dist/cjs/tests/loan/latest/index.js +80 -0
- package/dist/cjs/tests/loan/latest/manifest.json +3 -0
- package/dist/cjs/tests/server.js +29 -0
- package/dist/cjs/tests/serverHandlers.js +81 -0
- package/dist/cjs/tests/task/latest/index.js +58 -0
- package/dist/cjs/tests/task/latest/manifest.json +3 -0
- package/dist/cjs/typings/guest.js +16 -0
- package/dist/cjs/typings/host.js +16 -0
- package/dist/cjs/typings/index.js +16 -0
- package/dist/cjs/typings/microapp.js +16 -0
- package/dist/cjs/utils.js +33 -0
- package/dist/cjs/window.js +63 -0
- package/dist/esm/app.js +13 -0
- package/dist/esm/auditThrottler.js +40 -0
- package/dist/esm/config.js +35 -0
- package/dist/esm/frame.html +47 -0
- package/dist/esm/frame.js +41 -0
- package/dist/esm/history.js +7 -0
- package/dist/esm/host.js +85 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/loader.js +145 -0
- package/dist/esm/logRecords.js +37 -0
- package/dist/esm/logger.js +17 -0
- package/dist/esm/manifestLoader.js +46 -0
- package/dist/esm/scriptLoader.js +51 -0
- package/dist/esm/styleLoader.js +37 -0
- package/dist/esm/tests/loan/latest/index.js +79 -0
- package/dist/esm/tests/loan/latest/manifest.json +3 -0
- package/dist/esm/tests/server.js +9 -0
- package/dist/esm/tests/serverHandlers.js +51 -0
- package/dist/esm/tests/task/latest/index.js +57 -0
- package/dist/esm/tests/task/latest/manifest.json +3 -0
- package/dist/esm/typings/guest.js +0 -0
- package/dist/esm/typings/host.js +0 -0
- package/dist/esm/typings/index.js +0 -0
- package/dist/esm/typings/microapp.js +0 -0
- package/dist/esm/utils.js +13 -0
- package/dist/esm/window.js +43 -0
- package/dist/types/lib/app.d.ts +2 -0
- package/dist/types/lib/auditThrottler.d.ts +29 -0
- package/dist/types/lib/config.d.ts +25 -0
- package/dist/types/lib/frame.d.ts +10 -0
- package/dist/types/lib/history.d.ts +2 -0
- package/dist/types/lib/host.d.ts +42 -0
- package/dist/types/lib/index.d.ts +2 -0
- package/dist/types/lib/loader.d.ts +9 -0
- package/dist/types/lib/logRecords.d.ts +14 -0
- package/dist/types/lib/logger.d.ts +1 -0
- package/dist/types/lib/manifestLoader.d.ts +7 -0
- package/dist/types/lib/scriptLoader.d.ts +6 -0
- package/dist/types/lib/styleLoader.d.ts +5 -0
- package/dist/types/lib/tests/auditThrottler.test.d.ts +1 -0
- package/dist/types/lib/tests/loader.test.d.ts +1 -0
- package/dist/types/lib/tests/loan/latest/index.d.ts +0 -0
- package/dist/types/lib/tests/server.d.ts +1 -0
- package/dist/types/lib/tests/serverHandlers.d.ts +1 -0
- package/dist/types/lib/tests/task/latest/index.d.ts +0 -0
- package/dist/types/lib/typings/guest.d.ts +67 -0
- package/dist/types/lib/typings/host.d.ts +60 -0
- package/dist/types/lib/typings/index.d.ts +3 -0
- package/dist/types/lib/typings/microapp.d.ts +17 -0
- package/dist/types/lib/utils.d.ts +3 -0
- package/dist/types/lib/window.d.ts +27 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -3
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { rest } from "msw";
|
|
2
|
+
import { readFile } from "fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import appConfig from "../app.config.json";
|
|
5
|
+
import loanAppManifest from "./loan/latest/manifest.json";
|
|
6
|
+
const sendJS = async (res, ctx, filePath) => {
|
|
7
|
+
const fileContent = await readFile(path.join(__dirname, filePath), "utf-8");
|
|
8
|
+
return res(
|
|
9
|
+
ctx.status(200),
|
|
10
|
+
ctx.set("Content-Type", "application/javascript"),
|
|
11
|
+
ctx.body(fileContent)
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
const serverHandlers = [
|
|
15
|
+
rest.get(
|
|
16
|
+
"https://www.google-analytics.com/analytics.js",
|
|
17
|
+
(req, res, ctx) => res(
|
|
18
|
+
ctx.status(200),
|
|
19
|
+
ctx.set("Content-Type", "application/javascript"),
|
|
20
|
+
ctx.body("")
|
|
21
|
+
)
|
|
22
|
+
),
|
|
23
|
+
rest.get(
|
|
24
|
+
"/latest/app.config.json",
|
|
25
|
+
(req, res, ctx) => res(ctx.json(appConfig))
|
|
26
|
+
),
|
|
27
|
+
// frame html
|
|
28
|
+
rest.get("/frame.html", async (req, res, ctx) => {
|
|
29
|
+
const fileContent = await readFile(
|
|
30
|
+
path.join(__dirname, "../frame.html"),
|
|
31
|
+
"utf-8"
|
|
32
|
+
);
|
|
33
|
+
return res(
|
|
34
|
+
ctx.status(200),
|
|
35
|
+
ctx.set("Content-Type", "text/html"),
|
|
36
|
+
ctx.body(fileContent)
|
|
37
|
+
);
|
|
38
|
+
}),
|
|
39
|
+
rest.get("/loan/latest/index.js", async (req, res, ctx) => {
|
|
40
|
+
const newRes = await sendJS(res, ctx, "./loan/latest/index.js");
|
|
41
|
+
return newRes;
|
|
42
|
+
}),
|
|
43
|
+
// loan microapp handler
|
|
44
|
+
rest.get(
|
|
45
|
+
"/loan/latest/manifest.json",
|
|
46
|
+
(req, res, ctx) => res(ctx.json(loanAppManifest))
|
|
47
|
+
)
|
|
48
|
+
];
|
|
49
|
+
export {
|
|
50
|
+
serverHandlers
|
|
51
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
const appId = "taskapp";
|
|
3
|
+
const appName = "Task App";
|
|
4
|
+
const appElementId = `pui-app-container-${appId}`;
|
|
5
|
+
const pipelinePath = "/pipeline";
|
|
6
|
+
const pipelineLinkText = "Pipeline";
|
|
7
|
+
const getWindow = () => {
|
|
8
|
+
try {
|
|
9
|
+
window.parent.document;
|
|
10
|
+
return window.parent;
|
|
11
|
+
} catch (err) {
|
|
12
|
+
return window;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
let host = null;
|
|
16
|
+
let parentHistory = null;
|
|
17
|
+
let logger = null;
|
|
18
|
+
const browserWindow = getWindow();
|
|
19
|
+
browserWindow.emui = browserWindow.emui || {};
|
|
20
|
+
browserWindow.emui[appId] = browserWindow.emui[appId] || {};
|
|
21
|
+
browserWindow.emui[appId].init = async (options) => {
|
|
22
|
+
host = options.host;
|
|
23
|
+
parentHistory = options.history;
|
|
24
|
+
logger = options.logger;
|
|
25
|
+
};
|
|
26
|
+
browserWindow.emui[appId].mount = async () => {
|
|
27
|
+
const appContainer = document.getElementById(appElementId);
|
|
28
|
+
if (appContainer) {
|
|
29
|
+
const mainElement = document.createElement("main");
|
|
30
|
+
appContainer.appendChild(mainElement);
|
|
31
|
+
const pageHeaderEle = document.createElement("h1");
|
|
32
|
+
pageHeaderEle.textContent = appName;
|
|
33
|
+
mainElement.appendChild(pageHeaderEle);
|
|
34
|
+
const contentEle = document.createElement("p");
|
|
35
|
+
contentEle.textContent = "Go to ";
|
|
36
|
+
mainElement.appendChild(contentEle);
|
|
37
|
+
const linkEle = document.createElement("a");
|
|
38
|
+
linkEle.href = "#";
|
|
39
|
+
linkEle.onclick = () => {
|
|
40
|
+
parentHistory?.push?.(pipelinePath);
|
|
41
|
+
};
|
|
42
|
+
linkEle.textContent = pipelineLinkText;
|
|
43
|
+
contentEle.appendChild(linkEle);
|
|
44
|
+
} else {
|
|
45
|
+
throw new Error(
|
|
46
|
+
`App container element with id ${appElementId} not found`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
browserWindow.emui[appId].unmount = () => {
|
|
51
|
+
const appContainer = document.getElementById(appElementId);
|
|
52
|
+
if (appContainer) {
|
|
53
|
+
appContainer.removeChild(appContainer.getElementsByTagName("main")[0]);
|
|
54
|
+
}
|
|
55
|
+
return Promise.resolve();
|
|
56
|
+
};
|
|
57
|
+
})();
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CMicroAppHost } from "./host.js";
|
|
2
|
+
const isHost = () => CMicroAppHost.isInitialized();
|
|
3
|
+
const removeDoubleSlash = (url) => url.replace(/([^:]\/)\/+/g, "$1");
|
|
4
|
+
const getAbsoluteUrl = (url) => {
|
|
5
|
+
const a = document.createElement("a");
|
|
6
|
+
a.href = url;
|
|
7
|
+
return a.href;
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
getAbsoluteUrl,
|
|
11
|
+
isHost,
|
|
12
|
+
removeDoubleSlash
|
|
13
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { getDefaultTheme } from "@elliemae/pui-theme";
|
|
2
|
+
const getWindow = () => {
|
|
3
|
+
try {
|
|
4
|
+
window.parent.document;
|
|
5
|
+
return window.parent;
|
|
6
|
+
} catch (err) {
|
|
7
|
+
return window;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
const getViewportSize = () => ({
|
|
11
|
+
width: Math.max(
|
|
12
|
+
document.documentElement.clientWidth || 0,
|
|
13
|
+
window.innerWidth || 0
|
|
14
|
+
),
|
|
15
|
+
height: Math.max(
|
|
16
|
+
document.documentElement.clientHeight || 0,
|
|
17
|
+
window.innerHeight || 0
|
|
18
|
+
)
|
|
19
|
+
});
|
|
20
|
+
const convertBreakpointToNumber = (breakpoint) => Number(breakpoint.replace("px", ""));
|
|
21
|
+
const getCurrentBreakpoint = () => {
|
|
22
|
+
const { width } = getViewportSize();
|
|
23
|
+
const { breakpoints } = getDefaultTheme();
|
|
24
|
+
if (width <= convertBreakpointToNumber(breakpoints.small)) return "small";
|
|
25
|
+
if (width <= convertBreakpointToNumber(breakpoints.medium)) return "medium";
|
|
26
|
+
return "large";
|
|
27
|
+
};
|
|
28
|
+
const getAssetPath = () => window?.emui?._ASSET_PATH || "latest/";
|
|
29
|
+
const isCrossDomain = () => {
|
|
30
|
+
try {
|
|
31
|
+
window.parent.document;
|
|
32
|
+
return false;
|
|
33
|
+
} catch (ex) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
getAssetPath,
|
|
39
|
+
getCurrentBreakpoint,
|
|
40
|
+
getViewportSize,
|
|
41
|
+
getWindow,
|
|
42
|
+
isCrossDomain
|
|
43
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Logger, LogRecord } from '@elliemae/pui-diagnostics';
|
|
2
|
+
export type AuditThrottlerOptions = {
|
|
3
|
+
logger: Logger;
|
|
4
|
+
/** When `true`, high-frequency operations are logged at `audit` level. @default true */
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
/** Throttle window (ms). Same operation key is audited at most once per window. @default 10000 */
|
|
7
|
+
throttleMs?: number;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Controls whether high-frequency operations are logged at `audit` level
|
|
11
|
+
* (sent to Splunk) or `debug` level (local only).
|
|
12
|
+
*
|
|
13
|
+
* When enabled, a per-key throttle window prevents the same operation from
|
|
14
|
+
* flooding Splunk. Operations outside the window or with throttling disabled
|
|
15
|
+
* (`throttleMs === 0`) go straight to `audit`.
|
|
16
|
+
*/
|
|
17
|
+
export declare class AuditThrottler {
|
|
18
|
+
#private;
|
|
19
|
+
static readonly DEFAULT_THROTTLE_MS = 10000;
|
|
20
|
+
constructor(options: AuditThrottlerOptions);
|
|
21
|
+
get enabled(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Log a high-frequency operation. When audit is enabled and the throttle
|
|
24
|
+
* window allows it the payload is sent at `audit` level; otherwise `debug`.
|
|
25
|
+
* @param {string} key - dedup key for throttling (e.g. `invoke:loan.getField`)
|
|
26
|
+
* @param {LogRecord} payload - structured log payload
|
|
27
|
+
*/
|
|
28
|
+
log(key: string, payload: LogRecord): void;
|
|
29
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
interface ServiceEndpoints {
|
|
2
|
+
api?: string;
|
|
3
|
+
idp?: string;
|
|
4
|
+
logger?: string;
|
|
5
|
+
}
|
|
6
|
+
interface Env {
|
|
7
|
+
serviceEndpoints?: ServiceEndpoints;
|
|
8
|
+
}
|
|
9
|
+
export interface AppConfig {
|
|
10
|
+
appId: string;
|
|
11
|
+
brand?: string;
|
|
12
|
+
activeEnv: string;
|
|
13
|
+
sessionTimeoutWarnInterval?: string;
|
|
14
|
+
sessionTimeoutInterval?: string;
|
|
15
|
+
serviceEndpoints: ServiceEndpoints;
|
|
16
|
+
env: {
|
|
17
|
+
[key: string]: Env;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export declare const setAppConfig: (config: AppConfig) => void;
|
|
21
|
+
export declare const getAppConfigValue: <Type>(key?: string, defaultValue?: unknown) => Type;
|
|
22
|
+
export declare const setAppConfigValue: <Type>(key: string, value: Type) => AppConfig;
|
|
23
|
+
export declare const hasItem: (key?: string) => boolean;
|
|
24
|
+
export declare const loadAppConfig: (assetPath?: string) => Promise<void>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type FrameOptions = {
|
|
2
|
+
id: string;
|
|
3
|
+
sandbox?: string;
|
|
4
|
+
src?: string;
|
|
5
|
+
style?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const FRAME_CONTAINER_ID_PREFIX = "pui-iframe-container-";
|
|
8
|
+
export declare const FRAME_APP_CONTAINER_ID_PREFIX = "pui-app-container-";
|
|
9
|
+
export declare const createFrame: (options: FrameOptions) => Promise<HTMLIFrameElement>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { History } from 'history';
|
|
2
|
+
import { DefaultTheme } from 'styled-components';
|
|
3
|
+
import { Logger } from '@elliemae/pui-diagnostics';
|
|
4
|
+
import { IMicroAppHost, SubscriptionListener, AppWindowSize } from './typings/host.js';
|
|
5
|
+
type HostOptions = {
|
|
6
|
+
systemVersion: string;
|
|
7
|
+
history: History;
|
|
8
|
+
theme: DefaultTheme;
|
|
9
|
+
};
|
|
10
|
+
export type OnInitCallback = (options: HostOptions) => void;
|
|
11
|
+
type ConstructorParams = {
|
|
12
|
+
logger?: Logger;
|
|
13
|
+
history?: History;
|
|
14
|
+
version?: string;
|
|
15
|
+
theme?: DefaultTheme;
|
|
16
|
+
scriptingObjects?: Record<string, any>;
|
|
17
|
+
onRenewSessionTimer?: () => void;
|
|
18
|
+
onInit?: OnInitCallback;
|
|
19
|
+
};
|
|
20
|
+
export declare class CMicroAppHost implements IMicroAppHost {
|
|
21
|
+
private static instance;
|
|
22
|
+
private readonly logger;
|
|
23
|
+
private readonly appId;
|
|
24
|
+
private props;
|
|
25
|
+
activeGuests: Record<string, unknown>;
|
|
26
|
+
private readonly onInit?;
|
|
27
|
+
private readonly onRenewSessionTimer?;
|
|
28
|
+
scriptingObjects: Record<string, any>;
|
|
29
|
+
private constructor();
|
|
30
|
+
static getInstance(params?: ConstructorParams): CMicroAppHost;
|
|
31
|
+
static isInitialized(): boolean;
|
|
32
|
+
getProps(this: CMicroAppHost): HostOptions;
|
|
33
|
+
getLogger(this: CMicroAppHost): Logger;
|
|
34
|
+
getObject<T>(name: string): Promise<T>;
|
|
35
|
+
getGuests(this: CMicroAppHost): Record<string, unknown>;
|
|
36
|
+
getGuest<T>(id: string): T | null;
|
|
37
|
+
setAppWindowSize(appSize: AppWindowSize): void;
|
|
38
|
+
publish<Type>(eventId: string | symbol, data?: Type): boolean;
|
|
39
|
+
subscribe<T>(eventId: string | symbol, listener: SubscriptionListener<T>): string;
|
|
40
|
+
unsubscribe(token: string): void;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -12,3 +12,5 @@ export type { ISSFGuest, ConnectParam } from './guest.js';
|
|
|
12
12
|
export { ScriptingObjectManager, SecurityContext, } from './scriptingObjectManager.js';
|
|
13
13
|
export type { AddScriptingObjectParams, CallContext, CallerInfo, GetObjectParams, GuestContext, } from './scriptingObjectManager.js';
|
|
14
14
|
export { ScriptingObjectProxy, isScriptingObjectProxy } from './proxy.js';
|
|
15
|
+
export { AuditThrottler } from './auditThrottler.js';
|
|
16
|
+
export type { AuditThrottlerOptions } from './auditThrottler.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MicroAppConfig } from './typings/microapp.js';
|
|
2
|
+
export declare const mountApp: ({ id, name }: MicroAppConfig) => Promise<void>;
|
|
3
|
+
export declare const unmountApp: ({ id, name }: MicroAppConfig) => Promise<void | null>;
|
|
4
|
+
export declare const loadApp: (appConfig: MicroAppConfig) => Promise<void>;
|
|
5
|
+
export declare const unloadApp: ({ id, hostUrl, documentEle, }: {
|
|
6
|
+
id: string;
|
|
7
|
+
hostUrl?: string;
|
|
8
|
+
documentEle: Document;
|
|
9
|
+
}) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { LogRecord } from '@elliemae/pui-diagnostics';
|
|
2
|
+
export declare const logRecords: {
|
|
3
|
+
APP_CONFIG_LOAD_FAILED: {
|
|
4
|
+
code: string;
|
|
5
|
+
message: string;
|
|
6
|
+
};
|
|
7
|
+
ASSET_NOT_FOUND_IN_MANIFEST: (assetName: string) => LogRecord;
|
|
8
|
+
APP_INIT_FAILED: (appId: string, errMsg: string) => LogRecord;
|
|
9
|
+
APP_LOADING: (appId: string) => LogRecord;
|
|
10
|
+
APP_LOADING_COMPLETE: (appId: string) => LogRecord;
|
|
11
|
+
APP_UNLOADING: (appId: string) => LogRecord;
|
|
12
|
+
APP_UNLOADING_COMPLETE: (appId: string) => LogRecord;
|
|
13
|
+
SSF_HOST_OBJECT_NOT_FOUND: (name: string) => LogRecord;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const logger: import("@elliemae/pui-diagnostics").Logger;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type Manifest = Record<string, string>;
|
|
2
|
+
export declare const getAppManifest: ({ hostUrl, manifestPath, }: {
|
|
3
|
+
hostUrl?: string;
|
|
4
|
+
manifestPath?: string;
|
|
5
|
+
}) => Promise<Manifest>;
|
|
6
|
+
export declare const getFullFileNameofAssetsFromManifest: (manifest: Record<string, string>, assetNames?: Array<string>) => Array<string>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MicroAppConfig } from './typings/microapp.js';
|
|
2
|
+
export declare const APP_SCRIPT_ID_PREFIX = "emui-script-";
|
|
3
|
+
export declare const addScriptToDOM: ({ name, hostUrl, documentEle }: MicroAppConfig, fileName: string, index: number) => Promise<string>;
|
|
4
|
+
export declare const removeScriptFromDOM: (elementId?: string, documentEle?: Document) => Promise<void>;
|
|
5
|
+
export declare const removeDynamicImportedScripts: (hostUrl: string, documentEle: HTMLDocument) => void;
|
|
6
|
+
export declare const removePrefetchLinks: (hostUrl: string, documentEle: HTMLDocument) => void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { MicroAppConfig } from './typings/microapp.js';
|
|
2
|
+
export declare const APP_STYLE_ID_PREFIX = "emui-style-";
|
|
3
|
+
export declare const addStylesToDOM: ({ name, hostUrl, documentEle }: MicroAppConfig, fileName: string, index: number) => Promise<string>;
|
|
4
|
+
export declare const removeStyleFromDOM: (elementId?: string, documentEle?: Document) => Promise<void>;
|
|
5
|
+
export declare const removeDynamicImportedStyles: (hostUrl: string, documentEle: Document) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const initServer: () => import("msw/lib/glossary-2792c6da").K;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const serverHandlers: import("msw").RestHandler<import("msw").MockedRequest<import("msw").DefaultBodyType>>[];
|
|
File without changes
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { History, To } from 'history';
|
|
2
|
+
import { DefaultTheme } from 'styled-components';
|
|
3
|
+
import { Logger } from '@elliemae/pui-diagnostics';
|
|
4
|
+
import { BreakPoint } from '@elliemae/pui-theme';
|
|
5
|
+
import { IMicroAppHost } from './host.js';
|
|
6
|
+
import { JSONValue } from './index.js';
|
|
7
|
+
type ViewportSize = {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* options to initialize the guest app
|
|
13
|
+
*/
|
|
14
|
+
export type InitOptions = {
|
|
15
|
+
host?: IMicroAppHost;
|
|
16
|
+
hostName?: string;
|
|
17
|
+
hostUrl?: string;
|
|
18
|
+
manifestPath?: string;
|
|
19
|
+
homeRoute?: string;
|
|
20
|
+
prevState?: JSONValue;
|
|
21
|
+
history?: History;
|
|
22
|
+
theme?: DefaultTheme;
|
|
23
|
+
hostBreakpoint?: BreakPoint;
|
|
24
|
+
hostViewportSize?: ViewportSize;
|
|
25
|
+
logger?: Logger;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* options to mount the guest app
|
|
29
|
+
*/
|
|
30
|
+
export type MountOptions = {
|
|
31
|
+
containerId: string;
|
|
32
|
+
hostBreakpoint?: BreakPoint;
|
|
33
|
+
hostViewportSize?: ViewportSize;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Interface to connect and communicate with microfrontend guest application
|
|
37
|
+
*/
|
|
38
|
+
export interface IMicroAppGuest {
|
|
39
|
+
/**
|
|
40
|
+
* initialize the guest application
|
|
41
|
+
* @param options guest initailization options
|
|
42
|
+
*/
|
|
43
|
+
init(options: InitOptions): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* mount application to the window DOM
|
|
46
|
+
* @param options application dom mount options
|
|
47
|
+
*/
|
|
48
|
+
mount(options: MountOptions): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* unmount application from the window DOM
|
|
51
|
+
* @param options DOM unmount options
|
|
52
|
+
* @returns application state serialized as JSON
|
|
53
|
+
*/
|
|
54
|
+
unmount(options: MountOptions): Promise<JSONValue>;
|
|
55
|
+
/**
|
|
56
|
+
* Get scripting object exposed from guest application
|
|
57
|
+
* @returns scripting object
|
|
58
|
+
*/
|
|
59
|
+
getObject<T>(): T | null;
|
|
60
|
+
/**
|
|
61
|
+
* navigate to a route
|
|
62
|
+
* @param url url to navigate the guest application to
|
|
63
|
+
* @param state state to pass to the guest application
|
|
64
|
+
*/
|
|
65
|
+
navigate(url: To, state?: any): void;
|
|
66
|
+
}
|
|
67
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ScriptingObjectTypes } from '@elliemae/pui-scripting-object';
|
|
2
|
+
/**
|
|
3
|
+
* event listner callback function
|
|
4
|
+
*/
|
|
5
|
+
export type SubscriptionListener<T> = (message: string, data?: T) => void;
|
|
6
|
+
export type AppWindowSize = {
|
|
7
|
+
appId: string;
|
|
8
|
+
size: {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Interface to connect and communicate with parent host
|
|
15
|
+
*/
|
|
16
|
+
export interface IMicroAppHost {
|
|
17
|
+
/**
|
|
18
|
+
* Get reference to the scripting object (or proxy) by name
|
|
19
|
+
* @param name unique name of the scripting object
|
|
20
|
+
* @returns scripting object (or its proxy) reference
|
|
21
|
+
*/
|
|
22
|
+
getObject<T extends keyof ScriptingObjectTypes>(name: T): Promise<ScriptingObjectTypes[T]>;
|
|
23
|
+
/**
|
|
24
|
+
* Get lists of all guests attached to the host
|
|
25
|
+
* @returns list of guests
|
|
26
|
+
*/
|
|
27
|
+
getGuests(): Record<string, unknown>;
|
|
28
|
+
/**
|
|
29
|
+
* Get reference to the guest by name
|
|
30
|
+
* @param id unique id of the guest
|
|
31
|
+
* @returns guest reference
|
|
32
|
+
*/
|
|
33
|
+
getGuest<T>(id: string): T | null;
|
|
34
|
+
/**
|
|
35
|
+
* set the size of the guest application iframe window
|
|
36
|
+
* @param appSize window size of the application
|
|
37
|
+
*/
|
|
38
|
+
setAppWindowSize(appSize: AppWindowSize): void;
|
|
39
|
+
/**
|
|
40
|
+
* emit event to all subscribers
|
|
41
|
+
* @param eventId unique id of the event. The format is <scripting object name>.<event name>
|
|
42
|
+
* @param data data to be sent to the subscribers of the event
|
|
43
|
+
* @returns true if event is published successfully
|
|
44
|
+
*/
|
|
45
|
+
publish<Type>(eventId: string | symbol, data?: Type): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* subscribe to an scripting object event
|
|
48
|
+
* @param eventId unique id of the event. The format is <scripting object name>.<event name>
|
|
49
|
+
* @param listener callback function to be called when the event is fired
|
|
50
|
+
* @returns token to be used to unsubscribe
|
|
51
|
+
*/
|
|
52
|
+
subscribe<T>(eventId: string | symbol, listener: SubscriptionListener<T>): string;
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* @param token unique token returned by subscribe
|
|
56
|
+
* @param objectId scripting object name
|
|
57
|
+
* @param eventName event name
|
|
58
|
+
*/
|
|
59
|
+
unsubscribe(token: string, eventId?: string): void;
|
|
60
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { InitOptions } from './guest.js';
|
|
2
|
+
type EnvConfig = {
|
|
3
|
+
files: Array<string>;
|
|
4
|
+
};
|
|
5
|
+
export type MicroAppConfig = {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
mode?: string;
|
|
9
|
+
hostUrl?: string;
|
|
10
|
+
manifestPath?: string;
|
|
11
|
+
homeRoute: string;
|
|
12
|
+
files?: Array<string>;
|
|
13
|
+
development?: EnvConfig;
|
|
14
|
+
production?: EnvConfig;
|
|
15
|
+
documentEle: Document;
|
|
16
|
+
} & InitOptions;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BreakPoint } from '@elliemae/pui-theme';
|
|
2
|
+
import { Logger } from '@elliemae/pui-diagnostics';
|
|
3
|
+
import { IMicroAppGuest } from './typings/guest.js';
|
|
4
|
+
import { IMicroAppHost } from './typings/host.js';
|
|
5
|
+
export type EMUI = {
|
|
6
|
+
[key: string]: IMicroAppGuest;
|
|
7
|
+
} & {
|
|
8
|
+
_BASE_PATH: string;
|
|
9
|
+
_ASSET_PATH: string;
|
|
10
|
+
version: string;
|
|
11
|
+
MicroAppHost?: IMicroAppHost;
|
|
12
|
+
logger?: Logger;
|
|
13
|
+
appId?: string;
|
|
14
|
+
};
|
|
15
|
+
declare global {
|
|
16
|
+
interface Window {
|
|
17
|
+
emui: EMUI;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export declare const getWindow: () => Window;
|
|
21
|
+
export declare const getViewportSize: () => {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
};
|
|
25
|
+
export declare const getCurrentBreakpoint: () => BreakPoint;
|
|
26
|
+
export declare const getAssetPath: () => string;
|
|
27
|
+
export declare const isCrossDomain: () => boolean;
|