@elliemae/microfe-common 2.0.0-next.30
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.config.json +17 -0
- package/dist/cjs/common.js +16 -0
- package/dist/cjs/event.js +67 -0
- package/dist/cjs/eventManager.js +201 -0
- package/dist/cjs/guest.js +16 -0
- package/dist/cjs/index.html +12 -0
- package/dist/cjs/index.js +35 -0
- package/dist/cjs/messageType.js +37 -0
- package/dist/cjs/package.json +4 -0
- package/dist/cjs/remoting.js +386 -0
- package/dist/cjs/remotingEventMessage.js +16 -0
- package/dist/cjs/scriptingObject.js +119 -0
- package/dist/cjs/tests/scriptingObjects/appraisalServiceModule.js +101 -0
- package/dist/cjs/tests/scriptingObjects/constant.js +26 -0
- package/dist/cjs/tests/scriptingObjects/global.js +61 -0
- package/dist/esm/app.config.json +17 -0
- package/dist/esm/common.js +0 -0
- package/dist/esm/event.js +47 -0
- package/dist/esm/eventManager.js +182 -0
- package/dist/esm/guest.js +0 -0
- package/dist/esm/index.html +12 -0
- package/dist/esm/index.js +15 -0
- package/dist/esm/messageType.js +17 -0
- package/dist/esm/package.json +4 -0
- package/dist/esm/remoting.js +367 -0
- package/dist/esm/remotingEventMessage.js +0 -0
- package/dist/esm/scriptingObject.js +100 -0
- package/dist/esm/tests/scriptingObjects/appraisalServiceModule.js +82 -0
- package/dist/esm/tests/scriptingObjects/constant.js +6 -0
- package/dist/esm/tests/scriptingObjects/global.js +42 -0
- package/dist/types/common.d.ts +35 -0
- package/dist/types/event.d.ts +82 -0
- package/dist/types/eventManager.d.ts +125 -0
- package/dist/types/guest.d.ts +90 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/messageType.d.ts +13 -0
- package/dist/types/remoting.d.ts +237 -0
- package/dist/types/remotingEventMessage.d.ts +26 -0
- package/dist/types/scriptingObject.d.ts +37 -0
- package/dist/types/tests/eventManager.test.d.ts +1 -0
- package/dist/types/tests/scriptingObjects/appraisalServiceModule.d.ts +33 -0
- package/dist/types/tests/scriptingObjects/constant.d.ts +2 -0
- package/dist/types/tests/scriptingObjects/global.d.ts +10 -0
- package/package.json +62 -0
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var __publicField = (obj, key, value) => {
|
|
21
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
|
+
return value;
|
|
23
|
+
};
|
|
24
|
+
var __accessCheck = (obj, member, msg) => {
|
|
25
|
+
if (!member.has(obj))
|
|
26
|
+
throw TypeError("Cannot " + msg);
|
|
27
|
+
};
|
|
28
|
+
var __privateGet = (obj, member, getter) => {
|
|
29
|
+
__accessCheck(obj, member, "read from private field");
|
|
30
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
31
|
+
};
|
|
32
|
+
var __privateAdd = (obj, member, value) => {
|
|
33
|
+
if (member.has(obj))
|
|
34
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
35
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
36
|
+
};
|
|
37
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
38
|
+
__accessCheck(obj, member, "write to private field");
|
|
39
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
40
|
+
return value;
|
|
41
|
+
};
|
|
42
|
+
var remoting_exports = {};
|
|
43
|
+
__export(remoting_exports, {
|
|
44
|
+
Remoting: () => Remoting,
|
|
45
|
+
sendMessage: () => sendMessage
|
|
46
|
+
});
|
|
47
|
+
module.exports = __toCommonJS(remoting_exports);
|
|
48
|
+
var import_uuid = require("uuid");
|
|
49
|
+
var _correlationId, _logger, _listeners, _invocations, _timeoutMonitorHandle, _allowedSenders, _evaluateTimeouts, _startResponseMonitor, _stopResponseMonitor, _popInvocation, _processResponse, _processException, _receive, _processMessage;
|
|
50
|
+
const MESSAGE_SOURCE = "elli:remoting";
|
|
51
|
+
const RESPONSE_MESSAGE_TYPE = "elli:remoting:response";
|
|
52
|
+
const EXCEPTION_MESSAGE_TYPE = "elli:remoting:exception";
|
|
53
|
+
const createMessage = ({
|
|
54
|
+
messageType,
|
|
55
|
+
messageBody,
|
|
56
|
+
onewayMsg = false
|
|
57
|
+
}) => ({
|
|
58
|
+
requestId: !onewayMsg ? (0, import_uuid.v4)() : null,
|
|
59
|
+
source: MESSAGE_SOURCE,
|
|
60
|
+
type: messageType,
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
62
|
+
body: messageBody
|
|
63
|
+
});
|
|
64
|
+
const sendMessage = (param) => {
|
|
65
|
+
const { targetWin, targetOrigin, messageType, messageBody } = param;
|
|
66
|
+
const msg = createMessage({ messageType, messageBody });
|
|
67
|
+
targetWin.postMessage(msg, targetOrigin);
|
|
68
|
+
};
|
|
69
|
+
class Remoting {
|
|
70
|
+
/**
|
|
71
|
+
* Create a new instance of the Remoting class
|
|
72
|
+
*
|
|
73
|
+
* @param logger pui-diagnostic logger
|
|
74
|
+
* @param correlationId unique id for the current session
|
|
75
|
+
*/
|
|
76
|
+
constructor(logger, correlationId) {
|
|
77
|
+
__privateAdd(this, _correlationId, void 0);
|
|
78
|
+
__privateAdd(this, _logger, void 0);
|
|
79
|
+
/**
|
|
80
|
+
* set of listeners that are registered
|
|
81
|
+
*/
|
|
82
|
+
__privateAdd(this, _listeners, /* @__PURE__ */ new Map());
|
|
83
|
+
/**
|
|
84
|
+
* Represents the set of invocations that are waiting for a response
|
|
85
|
+
*/
|
|
86
|
+
__privateAdd(this, _invocations, /* @__PURE__ */ new Map());
|
|
87
|
+
/**
|
|
88
|
+
* The handle to the timeout monitor
|
|
89
|
+
*/
|
|
90
|
+
__privateAdd(this, _timeoutMonitorHandle, null);
|
|
91
|
+
/**
|
|
92
|
+
* The set of windows that are allowed to send messages to this window
|
|
93
|
+
*/
|
|
94
|
+
__privateAdd(this, _allowedSenders, /* @__PURE__ */ new Map());
|
|
95
|
+
// Evaluates the timeouts on any waiting invocations
|
|
96
|
+
__privateAdd(this, _evaluateTimeouts, () => {
|
|
97
|
+
const ts = Date.now();
|
|
98
|
+
const canceledItems = [];
|
|
99
|
+
__privateGet(this, _invocations).forEach((eventData, key) => {
|
|
100
|
+
const { requestId, cancelTime } = eventData;
|
|
101
|
+
__privateGet(this, _logger).debug(
|
|
102
|
+
`Checking response timeout for requestId: ${requestId}) @ ${cancelTime ?? ""}`
|
|
103
|
+
);
|
|
104
|
+
if (eventData.cancelTime && eventData.cancelTime < ts) {
|
|
105
|
+
__privateGet(this, _logger).debug(
|
|
106
|
+
`Detected response timeout for requestId: ${requestId}...`
|
|
107
|
+
);
|
|
108
|
+
canceledItems.push(key);
|
|
109
|
+
eventData.resolve();
|
|
110
|
+
__privateGet(this, _logger).debug(
|
|
111
|
+
`Aborted waiting for response to requestid: ${requestId})`
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
canceledItems.forEach((key) => {
|
|
116
|
+
__privateGet(this, _logger).debug(
|
|
117
|
+
`removing invocations with requestId ${key} from cache since response time has expired`
|
|
118
|
+
);
|
|
119
|
+
__privateGet(this, _invocations).delete(key);
|
|
120
|
+
});
|
|
121
|
+
if (__privateGet(this, _invocations).size === 0) {
|
|
122
|
+
__privateGet(this, _logger).debug(`stopping response monitor`);
|
|
123
|
+
__privateGet(this, _stopResponseMonitor).call(this);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
// Set a timer interval to catch any invocations that didn't respond in a timely manner
|
|
127
|
+
__privateAdd(this, _startResponseMonitor, () => {
|
|
128
|
+
if (__privateGet(this, _timeoutMonitorHandle) === null) {
|
|
129
|
+
__privateGet(this, _logger).debug("Staring response timeout evaluator");
|
|
130
|
+
__privateSet(this, _timeoutMonitorHandle, window.setInterval(
|
|
131
|
+
__privateGet(this, _evaluateTimeouts),
|
|
132
|
+
200
|
|
133
|
+
));
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
// Stops the timeout monitor interval
|
|
137
|
+
__privateAdd(this, _stopResponseMonitor, () => {
|
|
138
|
+
if (__privateGet(this, _timeoutMonitorHandle) !== null) {
|
|
139
|
+
window.clearInterval(__privateGet(this, _timeoutMonitorHandle));
|
|
140
|
+
__privateSet(this, _timeoutMonitorHandle, null);
|
|
141
|
+
__privateGet(this, _logger).debug("Stopped response timeout evaluator");
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
// Pops an invocation from the incovation list
|
|
145
|
+
__privateAdd(this, _popInvocation, (requestId) => {
|
|
146
|
+
const e = __privateGet(this, _invocations).get(requestId);
|
|
147
|
+
__privateGet(this, _logger).debug(`serving requestId: ${requestId}`);
|
|
148
|
+
__privateGet(this, _invocations).delete(requestId);
|
|
149
|
+
return e;
|
|
150
|
+
});
|
|
151
|
+
// Handles a response to a prior cross-frame invocation
|
|
152
|
+
__privateAdd(this, _processResponse, (message) => {
|
|
153
|
+
const { requestId } = message;
|
|
154
|
+
__privateGet(this, _logger).debug(
|
|
155
|
+
`Response received for invocation requestId: ${requestId}`
|
|
156
|
+
);
|
|
157
|
+
const eventData = __privateGet(this, _popInvocation).call(this, requestId);
|
|
158
|
+
if (!eventData) {
|
|
159
|
+
__privateGet(this, _logger).warn(
|
|
160
|
+
`Received response to stale/invalid request with requestId: ${requestId}`
|
|
161
|
+
);
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
eventData.resolve(message.body);
|
|
165
|
+
return true;
|
|
166
|
+
});
|
|
167
|
+
// Handles a response to a prior cross-frame invocation
|
|
168
|
+
__privateAdd(this, _processException, (message) => {
|
|
169
|
+
__privateGet(this, _logger).debug(
|
|
170
|
+
`Exception received for invocation (requestId = ${message.requestId})`
|
|
171
|
+
);
|
|
172
|
+
const eventData = __privateGet(this, _popInvocation).call(this, message.requestId);
|
|
173
|
+
if (!eventData) {
|
|
174
|
+
__privateGet(this, _logger).warn(
|
|
175
|
+
`Received exception for stale/invalid request (requestId = ${message.requestId})`
|
|
176
|
+
);
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
eventData.reject(new Error(message.body));
|
|
180
|
+
return true;
|
|
181
|
+
});
|
|
182
|
+
// Receives a message from another window and invokes any event handlers
|
|
183
|
+
__privateAdd(this, _receive, ({
|
|
184
|
+
sourceWin,
|
|
185
|
+
sourceOrigin,
|
|
186
|
+
message
|
|
187
|
+
}) => {
|
|
188
|
+
__privateGet(this, _logger).debug(`Received message of type "${message.type}"`);
|
|
189
|
+
const callbacks = __privateGet(this, _listeners).get(message.type);
|
|
190
|
+
if (!callbacks)
|
|
191
|
+
return false;
|
|
192
|
+
callbacks.forEach((callback) => {
|
|
193
|
+
__privateGet(this, _logger).debug(`Invoking message handler ${callback.name}`);
|
|
194
|
+
callback({
|
|
195
|
+
sourceWin,
|
|
196
|
+
sourceOrigin,
|
|
197
|
+
requestId: message.requestId,
|
|
198
|
+
type: message.type,
|
|
199
|
+
body: message.body
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
return true;
|
|
203
|
+
});
|
|
204
|
+
// Processes a message received thru the window's message event
|
|
205
|
+
__privateAdd(this, _processMessage, (message) => {
|
|
206
|
+
__privateGet(this, _logger).debug(
|
|
207
|
+
`Remoting: Received message ${JSON.stringify(message.data)}`
|
|
208
|
+
);
|
|
209
|
+
if (__privateGet(this, _allowedSenders).size === 0)
|
|
210
|
+
return false;
|
|
211
|
+
if (!message.source)
|
|
212
|
+
return false;
|
|
213
|
+
const senderOrigin = __privateGet(this, _allowedSenders).get(message.source);
|
|
214
|
+
if (!senderOrigin)
|
|
215
|
+
return false;
|
|
216
|
+
if (message?.data?.source !== MESSAGE_SOURCE)
|
|
217
|
+
return false;
|
|
218
|
+
if (message.data.type === RESPONSE_MESSAGE_TYPE)
|
|
219
|
+
__privateGet(this, _processResponse).call(this, message.data);
|
|
220
|
+
else if (message.data.type === EXCEPTION_MESSAGE_TYPE)
|
|
221
|
+
__privateGet(this, _processException).call(this, message.data);
|
|
222
|
+
else
|
|
223
|
+
__privateGet(this, _receive).call(this, {
|
|
224
|
+
sourceWin: message.source,
|
|
225
|
+
sourceOrigin: senderOrigin,
|
|
226
|
+
message: message.data
|
|
227
|
+
});
|
|
228
|
+
return true;
|
|
229
|
+
});
|
|
230
|
+
/**
|
|
231
|
+
* Adds window and its origin list of allowed senders
|
|
232
|
+
*
|
|
233
|
+
* @param {AddSenderParam} param - The sender to add
|
|
234
|
+
*/
|
|
235
|
+
__publicField(this, "addSender", (param) => {
|
|
236
|
+
const { origin, window: window2 } = param;
|
|
237
|
+
if (!origin)
|
|
238
|
+
throw new Error("origin is required");
|
|
239
|
+
if (!window2)
|
|
240
|
+
throw new Error("window is required");
|
|
241
|
+
__privateGet(this, _allowedSenders).set(window2, origin);
|
|
242
|
+
});
|
|
243
|
+
/**
|
|
244
|
+
* Initializes the remoting service for a window
|
|
245
|
+
*
|
|
246
|
+
* @param win The window to initialize remoting for
|
|
247
|
+
*/
|
|
248
|
+
__publicField(this, "initialize", (win) => {
|
|
249
|
+
win.removeEventListener("message", __privateGet(this, _processMessage));
|
|
250
|
+
win.addEventListener("message", __privateGet(this, _processMessage));
|
|
251
|
+
__privateGet(this, _logger).debug(`initialized remoting id: ${__privateGet(this, _correlationId)}`);
|
|
252
|
+
});
|
|
253
|
+
/**
|
|
254
|
+
* Closes the remoting service for a window
|
|
255
|
+
*/
|
|
256
|
+
__publicField(this, "close", () => {
|
|
257
|
+
window.removeEventListener("message", __privateGet(this, _processMessage));
|
|
258
|
+
__privateGet(this, _logger).debug(`closed remoting id: ${__privateGet(this, _correlationId)}`);
|
|
259
|
+
});
|
|
260
|
+
/**
|
|
261
|
+
* Sends an invocation which generates a Promise to be used to get a response
|
|
262
|
+
*
|
|
263
|
+
* @param {InvokeParam} param The parameters for the invocation
|
|
264
|
+
* @returns promisifyed response
|
|
265
|
+
*/
|
|
266
|
+
__publicField(this, "invoke", (param) => {
|
|
267
|
+
const {
|
|
268
|
+
targetWin,
|
|
269
|
+
targetOrigin,
|
|
270
|
+
messageType,
|
|
271
|
+
messageBody,
|
|
272
|
+
responseTimeoutMs
|
|
273
|
+
} = param;
|
|
274
|
+
return new Promise((resolve, reject) => {
|
|
275
|
+
const msg = createMessage({ messageType, messageBody });
|
|
276
|
+
__privateGet(this, _invocations).set(msg.requestId, {
|
|
277
|
+
requestId: msg.requestId,
|
|
278
|
+
resolve,
|
|
279
|
+
reject,
|
|
280
|
+
cancelTime: responseTimeoutMs ? Date.now() + Number.parseInt(responseTimeoutMs, 10) : null
|
|
281
|
+
});
|
|
282
|
+
targetWin.postMessage(msg, targetOrigin);
|
|
283
|
+
const { requestId } = msg;
|
|
284
|
+
__privateGet(this, _logger).debug(
|
|
285
|
+
`Posted invocation message of type ${messageType} requestId: ${requestId || ""}`
|
|
286
|
+
);
|
|
287
|
+
if (responseTimeoutMs) {
|
|
288
|
+
__privateGet(this, _logger).debug(
|
|
289
|
+
`starting response monitor for requestId: ${requestId || ""} for ${responseTimeoutMs} ms`
|
|
290
|
+
);
|
|
291
|
+
__privateGet(this, _startResponseMonitor).call(this);
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
/**
|
|
296
|
+
* Setup callback for a specific message type
|
|
297
|
+
*
|
|
298
|
+
* @param {ListenParam<T>} param The parameters for the listener
|
|
299
|
+
*/
|
|
300
|
+
__publicField(this, "listen", (param) => {
|
|
301
|
+
const { messageType, callback } = param;
|
|
302
|
+
const items = __privateGet(this, _listeners).get(messageType) || [];
|
|
303
|
+
items.push(callback);
|
|
304
|
+
__privateGet(this, _listeners).set(messageType, items);
|
|
305
|
+
});
|
|
306
|
+
/**
|
|
307
|
+
* Send a message without any form of response. Fire and forget
|
|
308
|
+
*
|
|
309
|
+
* @param {SendParam} param The parameters for the send
|
|
310
|
+
*/
|
|
311
|
+
__publicField(this, "send", (param) => {
|
|
312
|
+
const { targetWin, targetOrigin, messageType, messageBody } = param;
|
|
313
|
+
const msg = createMessage({
|
|
314
|
+
messageType,
|
|
315
|
+
messageBody,
|
|
316
|
+
onewayMsg: true
|
|
317
|
+
});
|
|
318
|
+
targetWin.postMessage(msg, targetOrigin);
|
|
319
|
+
__privateGet(this, _logger).debug(`Posted one-way message of type "${messageType}"`);
|
|
320
|
+
});
|
|
321
|
+
/**
|
|
322
|
+
* Removes a window from the list of allowed senders
|
|
323
|
+
*
|
|
324
|
+
* @param {AddSenderParam} param - The sender to remove
|
|
325
|
+
*/
|
|
326
|
+
__publicField(this, "removeSender", (param) => {
|
|
327
|
+
const { window: window2 } = param;
|
|
328
|
+
if (window2)
|
|
329
|
+
__privateGet(this, _allowedSenders).delete(window2);
|
|
330
|
+
});
|
|
331
|
+
/**
|
|
332
|
+
* Send a response message to a window
|
|
333
|
+
*
|
|
334
|
+
* @param {RespondParam} param The parameters for the response
|
|
335
|
+
*/
|
|
336
|
+
__publicField(this, "respond", (param) => {
|
|
337
|
+
const { targetWin, targetOrigin, requestId, response } = param;
|
|
338
|
+
const msg = createMessage({
|
|
339
|
+
messageType: RESPONSE_MESSAGE_TYPE,
|
|
340
|
+
messageBody: response
|
|
341
|
+
});
|
|
342
|
+
msg.requestId = requestId;
|
|
343
|
+
targetWin.postMessage(msg, targetOrigin);
|
|
344
|
+
__privateGet(this, _logger).debug(
|
|
345
|
+
`Response sent to caller for invocation requestId: ${requestId}`
|
|
346
|
+
);
|
|
347
|
+
});
|
|
348
|
+
/**
|
|
349
|
+
* Send an exception message to a window
|
|
350
|
+
*
|
|
351
|
+
* @param {RaiseExceptionParam} param The parameters for the exception
|
|
352
|
+
*/
|
|
353
|
+
__publicField(this, "raiseException", (param) => {
|
|
354
|
+
const { targetWin, targetOrigin, requestId, ex } = param;
|
|
355
|
+
const msg = createMessage({
|
|
356
|
+
messageType: EXCEPTION_MESSAGE_TYPE,
|
|
357
|
+
messageBody: ex
|
|
358
|
+
});
|
|
359
|
+
msg.requestId = requestId;
|
|
360
|
+
targetWin.postMessage(msg, targetOrigin);
|
|
361
|
+
__privateGet(this, _logger).debug(
|
|
362
|
+
`Exception sent to caller for invocation. requestId: ${requestId}`
|
|
363
|
+
);
|
|
364
|
+
});
|
|
365
|
+
if (!logger)
|
|
366
|
+
throw new Error("logger is required");
|
|
367
|
+
if (!correlationId)
|
|
368
|
+
throw new Error("correlationId is required");
|
|
369
|
+
__privateSet(this, _correlationId, correlationId);
|
|
370
|
+
__privateSet(this, _logger, logger);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
_correlationId = new WeakMap();
|
|
374
|
+
_logger = new WeakMap();
|
|
375
|
+
_listeners = new WeakMap();
|
|
376
|
+
_invocations = new WeakMap();
|
|
377
|
+
_timeoutMonitorHandle = new WeakMap();
|
|
378
|
+
_allowedSenders = new WeakMap();
|
|
379
|
+
_evaluateTimeouts = new WeakMap();
|
|
380
|
+
_startResponseMonitor = new WeakMap();
|
|
381
|
+
_stopResponseMonitor = new WeakMap();
|
|
382
|
+
_popInvocation = new WeakMap();
|
|
383
|
+
_processResponse = new WeakMap();
|
|
384
|
+
_processException = new WeakMap();
|
|
385
|
+
_receive = new WeakMap();
|
|
386
|
+
_processMessage = new WeakMap();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var remotingEventMessage_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(remotingEventMessage_exports);
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var __publicField = (obj, key, value) => {
|
|
21
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
|
+
return value;
|
|
23
|
+
};
|
|
24
|
+
var __accessCheck = (obj, member, msg) => {
|
|
25
|
+
if (!member.has(obj))
|
|
26
|
+
throw TypeError("Cannot " + msg);
|
|
27
|
+
};
|
|
28
|
+
var __privateGet = (obj, member, getter) => {
|
|
29
|
+
__accessCheck(obj, member, "read from private field");
|
|
30
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
31
|
+
};
|
|
32
|
+
var __privateAdd = (obj, member, value) => {
|
|
33
|
+
if (member.has(obj))
|
|
34
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
35
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
36
|
+
};
|
|
37
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
38
|
+
__accessCheck(obj, member, "write to private field");
|
|
39
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
40
|
+
return value;
|
|
41
|
+
};
|
|
42
|
+
var scriptingObject_exports = {};
|
|
43
|
+
__export(scriptingObject_exports, {
|
|
44
|
+
ScriptingObject: () => ScriptingObject
|
|
45
|
+
});
|
|
46
|
+
module.exports = __toCommonJS(scriptingObject_exports);
|
|
47
|
+
var import_event = require("./event.js");
|
|
48
|
+
var _id, _objectType;
|
|
49
|
+
const FUNCTION = "function";
|
|
50
|
+
const isPublicFunction = (value, fnName) => typeof value === FUNCTION && !!fnName && !fnName.startsWith("_");
|
|
51
|
+
class ScriptingObject {
|
|
52
|
+
/**
|
|
53
|
+
* Creates an instance of ScriptingObject.
|
|
54
|
+
*
|
|
55
|
+
* @param objectId unique id of the scripting object
|
|
56
|
+
* @param objectType type of the scripting object
|
|
57
|
+
*/
|
|
58
|
+
constructor(objectId, objectType) {
|
|
59
|
+
/**
|
|
60
|
+
* unique id of the scripting object
|
|
61
|
+
*/
|
|
62
|
+
__privateAdd(this, _id, void 0);
|
|
63
|
+
/**
|
|
64
|
+
* type of the scripting object
|
|
65
|
+
*/
|
|
66
|
+
__privateAdd(this, _objectType, "Object");
|
|
67
|
+
/**
|
|
68
|
+
* transform the scripting object to a format suitable for transmitting over window.postMessage
|
|
69
|
+
*
|
|
70
|
+
* @returns marshalled scripting object
|
|
71
|
+
*/
|
|
72
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
73
|
+
__publicField(this, "_toJSON", () => {
|
|
74
|
+
const functions = [];
|
|
75
|
+
const events = [];
|
|
76
|
+
Object.keys(this).forEach((property) => {
|
|
77
|
+
const value = this[property];
|
|
78
|
+
if ((0, import_event.isEvent)(value)) {
|
|
79
|
+
events.push(property);
|
|
80
|
+
} else if (isPublicFunction(value, property)) {
|
|
81
|
+
functions.push(property);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return {
|
|
85
|
+
objectId: __privateGet(this, _id),
|
|
86
|
+
objectType: __privateGet(this, _objectType),
|
|
87
|
+
functions,
|
|
88
|
+
events
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
/**
|
|
92
|
+
* dispose the scripting object
|
|
93
|
+
*/
|
|
94
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
95
|
+
__publicField(this, "_dispose", () => {
|
|
96
|
+
});
|
|
97
|
+
/**
|
|
98
|
+
* dispose the scripting object
|
|
99
|
+
*/
|
|
100
|
+
__publicField(this, "dispose", () => {
|
|
101
|
+
});
|
|
102
|
+
__privateSet(this, _id, objectId);
|
|
103
|
+
__privateSet(this, _objectType, objectType || __privateGet(this, _objectType));
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* get unique id of the scripting object
|
|
107
|
+
*/
|
|
108
|
+
get id() {
|
|
109
|
+
return __privateGet(this, _id);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* get type of the scripting object
|
|
113
|
+
*/
|
|
114
|
+
get objectType() {
|
|
115
|
+
return __privateGet(this, _objectType);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
_id = new WeakMap();
|
|
119
|
+
_objectType = new WeakMap();
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var __publicField = (obj, key, value) => {
|
|
21
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
|
+
return value;
|
|
23
|
+
};
|
|
24
|
+
var __accessCheck = (obj, member, msg) => {
|
|
25
|
+
if (!member.has(obj))
|
|
26
|
+
throw TypeError("Cannot " + msg);
|
|
27
|
+
};
|
|
28
|
+
var __privateGet = (obj, member, getter) => {
|
|
29
|
+
__accessCheck(obj, member, "read from private field");
|
|
30
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
31
|
+
};
|
|
32
|
+
var __privateAdd = (obj, member, value) => {
|
|
33
|
+
if (member.has(obj))
|
|
34
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
35
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
36
|
+
};
|
|
37
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
38
|
+
__accessCheck(obj, member, "write to private field");
|
|
39
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
40
|
+
return value;
|
|
41
|
+
};
|
|
42
|
+
var appraisalServiceModule_exports = {};
|
|
43
|
+
__export(appraisalServiceModule_exports, {
|
|
44
|
+
AppraisalService: () => AppraisalService
|
|
45
|
+
});
|
|
46
|
+
module.exports = __toCommonJS(appraisalServiceModule_exports);
|
|
47
|
+
var import__ = require("../../index.js");
|
|
48
|
+
var import_constant = require("./constant.js");
|
|
49
|
+
var _loanId, _creditScore;
|
|
50
|
+
class AppraisalService extends import__.ScriptingObject {
|
|
51
|
+
constructor({
|
|
52
|
+
loanId,
|
|
53
|
+
creditScore
|
|
54
|
+
}) {
|
|
55
|
+
super(import_constant.OBJECT_NAME);
|
|
56
|
+
__privateAdd(this, _loanId, void 0);
|
|
57
|
+
__privateAdd(this, _creditScore, void 0);
|
|
58
|
+
__publicField(this, "Unloading", new import__.Event({
|
|
59
|
+
name: "Unloading",
|
|
60
|
+
requiresFeedback: false,
|
|
61
|
+
so: this
|
|
62
|
+
}));
|
|
63
|
+
__publicField(this, "onPreCommit", new import__.Event({
|
|
64
|
+
name: "onPreCommit",
|
|
65
|
+
requiresFeedback: true,
|
|
66
|
+
so: this
|
|
67
|
+
}));
|
|
68
|
+
__publicField(this, "onSaved", new import__.Event({
|
|
69
|
+
name: "onSaved",
|
|
70
|
+
requiresFeedback: false,
|
|
71
|
+
so: this
|
|
72
|
+
}));
|
|
73
|
+
__publicField(this, "getCapabilities", () => Promise.resolve({
|
|
74
|
+
isAdmin: true,
|
|
75
|
+
los: "Encompass"
|
|
76
|
+
}));
|
|
77
|
+
__publicField(this, "getParameters", () => Promise.resolve({
|
|
78
|
+
loanId: __privateGet(this, _loanId),
|
|
79
|
+
creditScore: __privateGet(this, _creditScore)
|
|
80
|
+
}));
|
|
81
|
+
__publicField(this, "setCreditScore", (creditScore) => {
|
|
82
|
+
__privateSet(this, _creditScore, creditScore);
|
|
83
|
+
return Promise.resolve();
|
|
84
|
+
});
|
|
85
|
+
__publicField(this, "saveLoan", () => Promise.resolve());
|
|
86
|
+
__publicField(this, "commit", () => new Promise((resolve) => {
|
|
87
|
+
setTimeout(() => {
|
|
88
|
+
resolve({ loanId: __privateGet(this, _loanId) });
|
|
89
|
+
}, 1e3);
|
|
90
|
+
}));
|
|
91
|
+
__publicField(this, "delete", () => {
|
|
92
|
+
throw new Error("Not implemented");
|
|
93
|
+
});
|
|
94
|
+
__publicField(this, "unload", async () => {
|
|
95
|
+
});
|
|
96
|
+
__privateSet(this, _loanId, loanId);
|
|
97
|
+
__privateSet(this, _creditScore, creditScore);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
_loanId = new WeakMap();
|
|
101
|
+
_creditScore = new WeakMap();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var constant_exports = {};
|
|
20
|
+
__export(constant_exports, {
|
|
21
|
+
OBJECT_NAME: () => OBJECT_NAME,
|
|
22
|
+
UNLOADING_EVENT_NAME: () => UNLOADING_EVENT_NAME
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(constant_exports);
|
|
25
|
+
const OBJECT_NAME = "AppraisalService";
|
|
26
|
+
const UNLOADING_EVENT_NAME = "Unloading";
|