@elliemae/microfe-common 2.9.11 → 2.16.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.
- package/dist/cjs/event.js +29 -15
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/messageType.js +7 -6
- package/dist/cjs/proxy.js +53 -0
- package/dist/cjs/scriptingObject.js +2 -1
- package/dist/cjs/scriptingObjectManager.js +12 -37
- package/dist/esm/event.js +29 -15
- package/dist/esm/index.js +5 -1
- package/dist/esm/messageType.js +7 -6
- package/dist/esm/proxy.js +33 -0
- package/dist/esm/scriptingObject.js +2 -1
- package/dist/esm/scriptingObjectManager.js +12 -37
- package/dist/types/lib/event.d.ts +119 -22
- package/dist/types/lib/guest.d.ts +8 -39
- package/dist/types/lib/index.d.ts +5 -3
- package/dist/types/lib/messageType.d.ts +7 -6
- package/dist/types/lib/proxy.d.ts +25 -0
- package/dist/types/lib/scriptingObject.d.ts +6 -0
- package/dist/types/lib/scriptingObjectManager.d.ts +6 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
package/dist/cjs/event.js
CHANGED
|
@@ -26,10 +26,6 @@ __export(event_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(event_exports);
|
|
27
27
|
class Event {
|
|
28
28
|
/* eslint-enable indent */
|
|
29
|
-
/**
|
|
30
|
-
* scripting object that owns this event
|
|
31
|
-
*/
|
|
32
|
-
scriptingObject;
|
|
33
29
|
/**
|
|
34
30
|
* name of the event
|
|
35
31
|
*/
|
|
@@ -38,10 +34,6 @@ class Event {
|
|
|
38
34
|
* scripting object id that owns this event
|
|
39
35
|
*/
|
|
40
36
|
objectId;
|
|
41
|
-
/**
|
|
42
|
-
* flag indicating this event requires feedback from all of the listeners
|
|
43
|
-
*/
|
|
44
|
-
requiresFeedback;
|
|
45
37
|
/**
|
|
46
38
|
* unique id of the event
|
|
47
39
|
*/
|
|
@@ -51,14 +43,12 @@ class Event {
|
|
|
51
43
|
* @param {EventParam} param - parameters for creating an event
|
|
52
44
|
*/
|
|
53
45
|
constructor(param) {
|
|
54
|
-
const { name,
|
|
46
|
+
const { name, objectId } = param;
|
|
55
47
|
if (!name) throw new Error("Event name is required");
|
|
56
|
-
if (!
|
|
57
|
-
this.
|
|
58
|
-
this.objectId = so.id;
|
|
48
|
+
if (!objectId) throw new Error("Scripting object id is required");
|
|
49
|
+
this.objectId = objectId;
|
|
59
50
|
this.name = name;
|
|
60
51
|
this.id = `${this.objectId}.${this.name}`.toLowerCase();
|
|
61
|
-
this.requiresFeedback = requiresFeedback;
|
|
62
52
|
}
|
|
63
53
|
}
|
|
64
54
|
class ProxyEvent {
|
|
@@ -70,7 +60,11 @@ class ProxyEvent {
|
|
|
70
60
|
static [Symbol.hasInstance](obj) {
|
|
71
61
|
return obj.getType?.() === "ProxyEvent";
|
|
72
62
|
}
|
|
73
|
-
/* eslint-
|
|
63
|
+
/* eslint-enbale indent */
|
|
64
|
+
/**
|
|
65
|
+
* module that owns this event management. SSF Guest or App Bridge host
|
|
66
|
+
*/
|
|
67
|
+
#eventSrc;
|
|
74
68
|
/**
|
|
75
69
|
* unique id of scripting object
|
|
76
70
|
*/
|
|
@@ -95,11 +89,31 @@ class ProxyEvent {
|
|
|
95
89
|
* @param {ProxyEventParam} param - parameter for the constructor
|
|
96
90
|
*/
|
|
97
91
|
constructor(param) {
|
|
98
|
-
const { name, objectId } = param;
|
|
92
|
+
const { name, objectId, eventSrc } = param;
|
|
99
93
|
this.objectId = objectId;
|
|
100
94
|
this.name = name;
|
|
95
|
+
this.#eventSrc = eventSrc;
|
|
101
96
|
this.id = `${this.objectId}.${this.name}`.toLowerCase();
|
|
102
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* subscribe to an scripting object event
|
|
100
|
+
* @param callback event listener
|
|
101
|
+
* @returns subscription token
|
|
102
|
+
*/
|
|
103
|
+
subscribe = (callback) => this.#eventSrc.subscribe({
|
|
104
|
+
eventId: this.id,
|
|
105
|
+
callback
|
|
106
|
+
});
|
|
107
|
+
/**
|
|
108
|
+
* unsubscribe from an scripting object event
|
|
109
|
+
* @param token subscription token
|
|
110
|
+
*/
|
|
111
|
+
unsubscribe = (token) => {
|
|
112
|
+
this.#eventSrc.unsubscribe({
|
|
113
|
+
eventId: this.id,
|
|
114
|
+
token
|
|
115
|
+
});
|
|
116
|
+
};
|
|
103
117
|
}
|
|
104
118
|
const isEvent = (value) => value instanceof Event;
|
|
105
119
|
const getEventId = (objectId, eventName) => `${objectId.toLowerCase()}.${eventName.toLowerCase()}`;
|
package/dist/cjs/index.js
CHANGED
|
@@ -24,7 +24,10 @@ __export(index_exports, {
|
|
|
24
24
|
Remoting: () => import_remoting.Remoting,
|
|
25
25
|
ScriptingObject: () => import_scriptingObject.ScriptingObject,
|
|
26
26
|
ScriptingObjectManager: () => import_scriptingObjectManager.ScriptingObjectManager,
|
|
27
|
+
ScriptingObjectProxy: () => import_proxy.ScriptingObjectProxy,
|
|
27
28
|
getEventId: () => import_event.getEventId,
|
|
29
|
+
isPublicFunction: () => import_scriptingObject.isPublicFunction,
|
|
30
|
+
isScriptingObjectProxy: () => import_proxy.isScriptingObjectProxy,
|
|
28
31
|
sendMessage: () => import_remoting.sendMessage
|
|
29
32
|
});
|
|
30
33
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -34,3 +37,4 @@ var import_event2 = require("./event.js");
|
|
|
34
37
|
var import_scriptingObject = require("./scriptingObject.js");
|
|
35
38
|
var import_messageType = require("./messageType.js");
|
|
36
39
|
var import_scriptingObjectManager = require("./scriptingObjectManager.js");
|
|
40
|
+
var import_proxy = require("./proxy.js");
|
package/dist/cjs/messageType.js
CHANGED
|
@@ -22,17 +22,18 @@ __export(messageType_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(messageType_exports);
|
|
24
24
|
var MessageType = /* @__PURE__ */ ((MessageType2) => {
|
|
25
|
-
MessageType2["GuestReady"] = "guest:ready";
|
|
26
25
|
MessageType2["GuestClose"] = "guest:close";
|
|
26
|
+
MessageType2["GuestFocus"] = "guest:focus";
|
|
27
|
+
MessageType2["GuestReady"] = "guest:ready";
|
|
27
28
|
MessageType2["GuestReadyComplete"] = "guest:readyComplete";
|
|
28
29
|
MessageType2["GuestResize"] = "guest:resize";
|
|
29
|
-
MessageType2["GuestFocus"] = "guest:focus";
|
|
30
30
|
MessageType2["HandShake"] = "handshake";
|
|
31
31
|
MessageType2["HandShakeAck"] = "handshake:ack";
|
|
32
|
-
MessageType2["ObjectInvoke"] = "object:invoke";
|
|
33
|
-
MessageType2["ObjectGet"] = "object:get";
|
|
34
|
-
MessageType2["ObjectEvent"] = "object:event";
|
|
35
|
-
MessageType2["HostConfig"] = "host:config";
|
|
36
32
|
MessageType2["HostClose"] = "host:close";
|
|
33
|
+
MessageType2["HostConfig"] = "host:config";
|
|
34
|
+
MessageType2["ListObjects"] = "list:objects";
|
|
35
|
+
MessageType2["ObjectEvent"] = "object:event";
|
|
36
|
+
MessageType2["ObjectGet"] = "object:get";
|
|
37
|
+
MessageType2["ObjectInvoke"] = "object:invoke";
|
|
37
38
|
return MessageType2;
|
|
38
39
|
})(MessageType || {});
|
|
@@ -0,0 +1,53 @@
|
|
|
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 proxy_exports = {};
|
|
20
|
+
__export(proxy_exports, {
|
|
21
|
+
ScriptingObjectProxy: () => ScriptingObjectProxy,
|
|
22
|
+
isScriptingObjectProxy: () => isScriptingObjectProxy
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(proxy_exports);
|
|
25
|
+
class ScriptingObjectProxy {
|
|
26
|
+
/**
|
|
27
|
+
* proxy type
|
|
28
|
+
*/
|
|
29
|
+
__TYPE__ = "Proxy";
|
|
30
|
+
/**
|
|
31
|
+
* unique id of scripting object
|
|
32
|
+
*/
|
|
33
|
+
id;
|
|
34
|
+
/**
|
|
35
|
+
* type of scripting object
|
|
36
|
+
*/
|
|
37
|
+
objectType;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a new instance of the Scripting Object Proxy
|
|
40
|
+
* @param objectId unique id of scripting object
|
|
41
|
+
* @param objectType type of scripting object
|
|
42
|
+
*/
|
|
43
|
+
constructor(objectId, objectType) {
|
|
44
|
+
this.id = objectId;
|
|
45
|
+
this.objectType = objectType;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const isScriptingObjectProxy = (value) => (
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
50
|
+
value?.constructor?.name === "Proxy" || // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
51
|
+
value?.constructor?.name === "ScriptingObjectProxy" || // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-underscore-dangle
|
|
52
|
+
value?.__TYPE__ === "Proxy"
|
|
53
|
+
);
|
|
@@ -18,7 +18,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var scriptingObject_exports = {};
|
|
20
20
|
__export(scriptingObject_exports, {
|
|
21
|
-
ScriptingObject: () => ScriptingObject
|
|
21
|
+
ScriptingObject: () => ScriptingObject,
|
|
22
|
+
isPublicFunction: () => isPublicFunction
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(scriptingObject_exports);
|
|
24
25
|
var import_event = require("./event.js");
|
|
@@ -108,34 +108,6 @@ class ScriptingObjectManager {
|
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
|
-
/**
|
|
112
|
-
* attach guest context to the scripting object methods
|
|
113
|
-
* @param root0
|
|
114
|
-
* @param root0.so
|
|
115
|
-
* @param root0.guest
|
|
116
|
-
* @returns proxies scripting object that has call context set to the guest
|
|
117
|
-
*/
|
|
118
|
-
#attachCallContext = ({
|
|
119
|
-
so,
|
|
120
|
-
guest
|
|
121
|
-
}) => new Proxy(so, {
|
|
122
|
-
get(target, prop, receiver) {
|
|
123
|
-
const value = target[prop];
|
|
124
|
-
if (value instanceof Function && prop !== "constructor") {
|
|
125
|
-
return function(...args) {
|
|
126
|
-
const proxyRef = this;
|
|
127
|
-
Object.defineProperty(value, "callContext", {
|
|
128
|
-
value: guest,
|
|
129
|
-
configurable: true,
|
|
130
|
-
enumerable: true,
|
|
131
|
-
writable: true
|
|
132
|
-
});
|
|
133
|
-
return value.apply(proxyRef === receiver ? target : proxyRef, args);
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
return value;
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
111
|
/**
|
|
140
112
|
* registers scripting object to the host
|
|
141
113
|
* @param so scripting object to register
|
|
@@ -174,15 +146,18 @@ class ScriptingObjectManager {
|
|
|
174
146
|
soInfo = soInfo ?? this.#scriptingObjects.get(id) ?? null;
|
|
175
147
|
const { so } = soInfo || {};
|
|
176
148
|
if (!so) return null;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
149
|
+
return so;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* list name of scripting objects for the given guest
|
|
153
|
+
* @param guestId unique id of the guest
|
|
154
|
+
* @returns name of scripting objects for the given guest
|
|
155
|
+
*/
|
|
156
|
+
listScriptingObjects = (guestId) => {
|
|
157
|
+
let objects = Array.from(this.#scriptingObjects.keys());
|
|
158
|
+
const guestSOs = this.#guestScriptingObjects.get(guestId);
|
|
159
|
+
objects = guestSOs ? objects.concat(Array.from(guestSOs.keys())) : objects;
|
|
160
|
+
return Array.from(new Set(objects));
|
|
186
161
|
};
|
|
187
162
|
/**
|
|
188
163
|
* removes scripting object
|
package/dist/esm/event.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
class Event {
|
|
2
2
|
/* eslint-enable indent */
|
|
3
|
-
/**
|
|
4
|
-
* scripting object that owns this event
|
|
5
|
-
*/
|
|
6
|
-
scriptingObject;
|
|
7
3
|
/**
|
|
8
4
|
* name of the event
|
|
9
5
|
*/
|
|
@@ -12,10 +8,6 @@ class Event {
|
|
|
12
8
|
* scripting object id that owns this event
|
|
13
9
|
*/
|
|
14
10
|
objectId;
|
|
15
|
-
/**
|
|
16
|
-
* flag indicating this event requires feedback from all of the listeners
|
|
17
|
-
*/
|
|
18
|
-
requiresFeedback;
|
|
19
11
|
/**
|
|
20
12
|
* unique id of the event
|
|
21
13
|
*/
|
|
@@ -25,14 +17,12 @@ class Event {
|
|
|
25
17
|
* @param {EventParam} param - parameters for creating an event
|
|
26
18
|
*/
|
|
27
19
|
constructor(param) {
|
|
28
|
-
const { name,
|
|
20
|
+
const { name, objectId } = param;
|
|
29
21
|
if (!name) throw new Error("Event name is required");
|
|
30
|
-
if (!
|
|
31
|
-
this.
|
|
32
|
-
this.objectId = so.id;
|
|
22
|
+
if (!objectId) throw new Error("Scripting object id is required");
|
|
23
|
+
this.objectId = objectId;
|
|
33
24
|
this.name = name;
|
|
34
25
|
this.id = `${this.objectId}.${this.name}`.toLowerCase();
|
|
35
|
-
this.requiresFeedback = requiresFeedback;
|
|
36
26
|
}
|
|
37
27
|
}
|
|
38
28
|
class ProxyEvent {
|
|
@@ -44,7 +34,11 @@ class ProxyEvent {
|
|
|
44
34
|
static [Symbol.hasInstance](obj) {
|
|
45
35
|
return obj.getType?.() === "ProxyEvent";
|
|
46
36
|
}
|
|
47
|
-
/* eslint-
|
|
37
|
+
/* eslint-enbale indent */
|
|
38
|
+
/**
|
|
39
|
+
* module that owns this event management. SSF Guest or App Bridge host
|
|
40
|
+
*/
|
|
41
|
+
#eventSrc;
|
|
48
42
|
/**
|
|
49
43
|
* unique id of scripting object
|
|
50
44
|
*/
|
|
@@ -69,11 +63,31 @@ class ProxyEvent {
|
|
|
69
63
|
* @param {ProxyEventParam} param - parameter for the constructor
|
|
70
64
|
*/
|
|
71
65
|
constructor(param) {
|
|
72
|
-
const { name, objectId } = param;
|
|
66
|
+
const { name, objectId, eventSrc } = param;
|
|
73
67
|
this.objectId = objectId;
|
|
74
68
|
this.name = name;
|
|
69
|
+
this.#eventSrc = eventSrc;
|
|
75
70
|
this.id = `${this.objectId}.${this.name}`.toLowerCase();
|
|
76
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* subscribe to an scripting object event
|
|
74
|
+
* @param callback event listener
|
|
75
|
+
* @returns subscription token
|
|
76
|
+
*/
|
|
77
|
+
subscribe = (callback) => this.#eventSrc.subscribe({
|
|
78
|
+
eventId: this.id,
|
|
79
|
+
callback
|
|
80
|
+
});
|
|
81
|
+
/**
|
|
82
|
+
* unsubscribe from an scripting object event
|
|
83
|
+
* @param token subscription token
|
|
84
|
+
*/
|
|
85
|
+
unsubscribe = (token) => {
|
|
86
|
+
this.#eventSrc.unsubscribe({
|
|
87
|
+
eventId: this.id,
|
|
88
|
+
token
|
|
89
|
+
});
|
|
90
|
+
};
|
|
77
91
|
}
|
|
78
92
|
const isEvent = (value) => value instanceof Event;
|
|
79
93
|
const getEventId = (objectId, eventName) => `${objectId.toLowerCase()}.${eventName.toLowerCase()}`;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Remoting, sendMessage } from "./remoting.js";
|
|
2
2
|
import { getEventId, ProxyEvent } from "./event.js";
|
|
3
3
|
import { Event } from "./event.js";
|
|
4
|
-
import { ScriptingObject } from "./scriptingObject.js";
|
|
4
|
+
import { ScriptingObject, isPublicFunction } from "./scriptingObject.js";
|
|
5
5
|
import { MessageType } from "./messageType.js";
|
|
6
6
|
import { ScriptingObjectManager } from "./scriptingObjectManager.js";
|
|
7
|
+
import { ScriptingObjectProxy, isScriptingObjectProxy } from "./proxy.js";
|
|
7
8
|
export {
|
|
8
9
|
Event,
|
|
9
10
|
MessageType,
|
|
@@ -11,6 +12,9 @@ export {
|
|
|
11
12
|
Remoting,
|
|
12
13
|
ScriptingObject,
|
|
13
14
|
ScriptingObjectManager,
|
|
15
|
+
ScriptingObjectProxy,
|
|
14
16
|
getEventId,
|
|
17
|
+
isPublicFunction,
|
|
18
|
+
isScriptingObjectProxy,
|
|
15
19
|
sendMessage
|
|
16
20
|
};
|
package/dist/esm/messageType.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
var MessageType = /* @__PURE__ */ ((MessageType2) => {
|
|
2
|
-
MessageType2["GuestReady"] = "guest:ready";
|
|
3
2
|
MessageType2["GuestClose"] = "guest:close";
|
|
3
|
+
MessageType2["GuestFocus"] = "guest:focus";
|
|
4
|
+
MessageType2["GuestReady"] = "guest:ready";
|
|
4
5
|
MessageType2["GuestReadyComplete"] = "guest:readyComplete";
|
|
5
6
|
MessageType2["GuestResize"] = "guest:resize";
|
|
6
|
-
MessageType2["GuestFocus"] = "guest:focus";
|
|
7
7
|
MessageType2["HandShake"] = "handshake";
|
|
8
8
|
MessageType2["HandShakeAck"] = "handshake:ack";
|
|
9
|
-
MessageType2["ObjectInvoke"] = "object:invoke";
|
|
10
|
-
MessageType2["ObjectGet"] = "object:get";
|
|
11
|
-
MessageType2["ObjectEvent"] = "object:event";
|
|
12
|
-
MessageType2["HostConfig"] = "host:config";
|
|
13
9
|
MessageType2["HostClose"] = "host:close";
|
|
10
|
+
MessageType2["HostConfig"] = "host:config";
|
|
11
|
+
MessageType2["ListObjects"] = "list:objects";
|
|
12
|
+
MessageType2["ObjectEvent"] = "object:event";
|
|
13
|
+
MessageType2["ObjectGet"] = "object:get";
|
|
14
|
+
MessageType2["ObjectInvoke"] = "object:invoke";
|
|
14
15
|
return MessageType2;
|
|
15
16
|
})(MessageType || {});
|
|
16
17
|
export {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
class ScriptingObjectProxy {
|
|
2
|
+
/**
|
|
3
|
+
* proxy type
|
|
4
|
+
*/
|
|
5
|
+
__TYPE__ = "Proxy";
|
|
6
|
+
/**
|
|
7
|
+
* unique id of scripting object
|
|
8
|
+
*/
|
|
9
|
+
id;
|
|
10
|
+
/**
|
|
11
|
+
* type of scripting object
|
|
12
|
+
*/
|
|
13
|
+
objectType;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new instance of the Scripting Object Proxy
|
|
16
|
+
* @param objectId unique id of scripting object
|
|
17
|
+
* @param objectType type of scripting object
|
|
18
|
+
*/
|
|
19
|
+
constructor(objectId, objectType) {
|
|
20
|
+
this.id = objectId;
|
|
21
|
+
this.objectType = objectType;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const isScriptingObjectProxy = (value) => (
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
26
|
+
value?.constructor?.name === "Proxy" || // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
27
|
+
value?.constructor?.name === "ScriptingObjectProxy" || // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-underscore-dangle
|
|
28
|
+
value?.__TYPE__ === "Proxy"
|
|
29
|
+
);
|
|
30
|
+
export {
|
|
31
|
+
ScriptingObjectProxy,
|
|
32
|
+
isScriptingObjectProxy
|
|
33
|
+
};
|
|
@@ -83,34 +83,6 @@ class ScriptingObjectManager {
|
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
|
-
/**
|
|
87
|
-
* attach guest context to the scripting object methods
|
|
88
|
-
* @param root0
|
|
89
|
-
* @param root0.so
|
|
90
|
-
* @param root0.guest
|
|
91
|
-
* @returns proxies scripting object that has call context set to the guest
|
|
92
|
-
*/
|
|
93
|
-
#attachCallContext = ({
|
|
94
|
-
so,
|
|
95
|
-
guest
|
|
96
|
-
}) => new Proxy(so, {
|
|
97
|
-
get(target, prop, receiver) {
|
|
98
|
-
const value = target[prop];
|
|
99
|
-
if (value instanceof Function && prop !== "constructor") {
|
|
100
|
-
return function(...args) {
|
|
101
|
-
const proxyRef = this;
|
|
102
|
-
Object.defineProperty(value, "callContext", {
|
|
103
|
-
value: guest,
|
|
104
|
-
configurable: true,
|
|
105
|
-
enumerable: true,
|
|
106
|
-
writable: true
|
|
107
|
-
});
|
|
108
|
-
return value.apply(proxyRef === receiver ? target : proxyRef, args);
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
return value;
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
86
|
/**
|
|
115
87
|
* registers scripting object to the host
|
|
116
88
|
* @param so scripting object to register
|
|
@@ -149,15 +121,18 @@ class ScriptingObjectManager {
|
|
|
149
121
|
soInfo = soInfo ?? this.#scriptingObjects.get(id) ?? null;
|
|
150
122
|
const { so } = soInfo || {};
|
|
151
123
|
if (!so) return null;
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
124
|
+
return so;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* list name of scripting objects for the given guest
|
|
128
|
+
* @param guestId unique id of the guest
|
|
129
|
+
* @returns name of scripting objects for the given guest
|
|
130
|
+
*/
|
|
131
|
+
listScriptingObjects = (guestId) => {
|
|
132
|
+
let objects = Array.from(this.#scriptingObjects.keys());
|
|
133
|
+
const guestSOs = this.#guestScriptingObjects.get(guestId);
|
|
134
|
+
objects = guestSOs ? objects.concat(Array.from(guestSOs.keys())) : objects;
|
|
135
|
+
return Array.from(new Set(objects));
|
|
161
136
|
};
|
|
162
137
|
/**
|
|
163
138
|
* removes scripting object
|
|
@@ -1,5 +1,44 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { EventListeners } from './common.js';
|
|
1
|
+
import type { IEvent, Events } from '@elliemae/pui-scripting-object';
|
|
2
|
+
import { EventListeners, Listener } from './common.js';
|
|
3
|
+
/**
|
|
4
|
+
* parameters for subscribing to an event
|
|
5
|
+
*/
|
|
6
|
+
export type SubscribeParam<EventId, EventListener extends Listener<any, any, any, any>> = {
|
|
7
|
+
/**
|
|
8
|
+
* unique id of the event
|
|
9
|
+
*/
|
|
10
|
+
eventId: EventId;
|
|
11
|
+
/**
|
|
12
|
+
* event listener
|
|
13
|
+
*/
|
|
14
|
+
callback: EventListener;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* parameters for unsubscribing from an event
|
|
18
|
+
*/
|
|
19
|
+
export type UnsubscribeParam<EventId> = {
|
|
20
|
+
/**
|
|
21
|
+
* unique id of the event
|
|
22
|
+
*/
|
|
23
|
+
eventId: EventId;
|
|
24
|
+
/**
|
|
25
|
+
* subscription token
|
|
26
|
+
*/
|
|
27
|
+
token: string;
|
|
28
|
+
};
|
|
29
|
+
export interface IEventManager<AppEvents extends EventListeners = Events> {
|
|
30
|
+
/**
|
|
31
|
+
* subscribe to an scripting object event
|
|
32
|
+
* @param {SubscribeParam<EventId, AppEvents[EventId]>} param - parameters for subscribing to an event
|
|
33
|
+
* @returns subscription token
|
|
34
|
+
*/
|
|
35
|
+
subscribe: <EventId extends Extract<keyof AppEvents, string>>(param: SubscribeParam<EventId, AppEvents[EventId]>) => string;
|
|
36
|
+
/**
|
|
37
|
+
* unsubscribe from an scripting object event
|
|
38
|
+
* @param {UnsubscribeParam<EventId>} param - parameters for unsubscribing from an event
|
|
39
|
+
*/
|
|
40
|
+
unsubscribe: <EventId extends Extract<keyof AppEvents, string>>(param: UnsubscribeParam<EventId>) => void;
|
|
41
|
+
}
|
|
3
42
|
/**
|
|
4
43
|
* Interface for scripting object proxy events
|
|
5
44
|
*/
|
|
@@ -22,26 +61,18 @@ export interface IScriptingObjectProxyEvent<EventsList extends EventListeners =
|
|
|
22
61
|
*/
|
|
23
62
|
export type EventParam = {
|
|
24
63
|
/**
|
|
25
|
-
*
|
|
26
|
-
*/
|
|
27
|
-
name: string;
|
|
28
|
-
/**
|
|
29
|
-
* flag indicating this event requires feedback from all of the listeners
|
|
64
|
+
* scripting object id that owns this event
|
|
30
65
|
*/
|
|
31
|
-
|
|
66
|
+
objectId: string;
|
|
32
67
|
/**
|
|
33
|
-
*
|
|
68
|
+
* name of the event
|
|
34
69
|
*/
|
|
35
|
-
|
|
70
|
+
name: string;
|
|
36
71
|
};
|
|
37
72
|
/**
|
|
38
73
|
* Base class for all events
|
|
39
74
|
*/
|
|
40
|
-
export declare class Event<
|
|
41
|
-
/**
|
|
42
|
-
* scripting object that owns this event
|
|
43
|
-
*/
|
|
44
|
-
readonly scriptingObject: IScriptingObject;
|
|
75
|
+
export declare class Event<AppEvents extends EventListeners = Events> implements IEvent {
|
|
45
76
|
/**
|
|
46
77
|
* name of the event
|
|
47
78
|
*/
|
|
@@ -50,14 +81,10 @@ export declare class Event<EventsList extends EventListeners = Events> implement
|
|
|
50
81
|
* scripting object id that owns this event
|
|
51
82
|
*/
|
|
52
83
|
readonly objectId: string;
|
|
53
|
-
/**
|
|
54
|
-
* flag indicating this event requires feedback from all of the listeners
|
|
55
|
-
*/
|
|
56
|
-
readonly requiresFeedback: boolean;
|
|
57
84
|
/**
|
|
58
85
|
* unique id of the event
|
|
59
86
|
*/
|
|
60
|
-
readonly id: Extract<keyof
|
|
87
|
+
readonly id: Extract<keyof AppEvents, string>;
|
|
61
88
|
/**
|
|
62
89
|
* Create an event object
|
|
63
90
|
* @param {EventParam} param - parameters for creating an event
|
|
@@ -67,7 +94,7 @@ export declare class Event<EventsList extends EventListeners = Events> implement
|
|
|
67
94
|
/**
|
|
68
95
|
* ProxyEvent constructor parameter
|
|
69
96
|
*/
|
|
70
|
-
export type ProxyEventParam = {
|
|
97
|
+
export type ProxyEventParam<AppEvents extends EventListeners = Events> = {
|
|
71
98
|
/**
|
|
72
99
|
* name of the event
|
|
73
100
|
*/
|
|
@@ -76,12 +103,17 @@ export type ProxyEventParam = {
|
|
|
76
103
|
* unique id of scripting object
|
|
77
104
|
*/
|
|
78
105
|
objectId: string;
|
|
106
|
+
/**
|
|
107
|
+
* module that owns this event management. SSF Guest or App Bridge host
|
|
108
|
+
*/
|
|
109
|
+
eventSrc: IEventManager<AppEvents>;
|
|
79
110
|
};
|
|
80
111
|
/**
|
|
81
112
|
* Scripting Object Proxy Event implementation
|
|
82
113
|
* @typeParam AppEvents - type of the events that the scripting object supports
|
|
83
114
|
*/
|
|
84
115
|
export declare class ProxyEvent<AppEvents extends EventListeners = Events> implements IScriptingObjectProxyEvent<AppEvents> {
|
|
116
|
+
#private;
|
|
85
117
|
/**
|
|
86
118
|
* check if given object is an instance of ProxyEvent
|
|
87
119
|
* @param obj object to be compared
|
|
@@ -109,7 +141,18 @@ export declare class ProxyEvent<AppEvents extends EventListeners = Events> imple
|
|
|
109
141
|
* Create a new instance of the Scripting Object Proxy Event
|
|
110
142
|
* @param {ProxyEventParam} param - parameter for the constructor
|
|
111
143
|
*/
|
|
112
|
-
constructor(param: ProxyEventParam);
|
|
144
|
+
constructor(param: ProxyEventParam<AppEvents>);
|
|
145
|
+
/**
|
|
146
|
+
* subscribe to an scripting object event
|
|
147
|
+
* @param callback event listener
|
|
148
|
+
* @returns subscription token
|
|
149
|
+
*/
|
|
150
|
+
subscribe: <EventListener extends Listener<any, any, any, any>>(callback: EventListener) => string;
|
|
151
|
+
/**
|
|
152
|
+
* unsubscribe from an scripting object event
|
|
153
|
+
* @param token subscription token
|
|
154
|
+
*/
|
|
155
|
+
unsubscribe: (token: string) => void;
|
|
113
156
|
}
|
|
114
157
|
/**
|
|
115
158
|
* Check given object is an event
|
|
@@ -124,3 +167,57 @@ export declare const isEvent: (value: any) => value is Event;
|
|
|
124
167
|
* @returns normalized event ID
|
|
125
168
|
*/
|
|
126
169
|
export declare const getEventId: (objectId: string, eventName: string) => string;
|
|
170
|
+
/**
|
|
171
|
+
* event properties
|
|
172
|
+
*/
|
|
173
|
+
export type EventOptions = {
|
|
174
|
+
/**
|
|
175
|
+
* unique id of the guest to send the event to
|
|
176
|
+
*/
|
|
177
|
+
guestId?: string;
|
|
178
|
+
/**
|
|
179
|
+
* guest window to send the event to
|
|
180
|
+
*/
|
|
181
|
+
window?: Window;
|
|
182
|
+
/**
|
|
183
|
+
* time in milliseconds to wait for the guest to respond back for the event
|
|
184
|
+
*/
|
|
185
|
+
timeout?: number;
|
|
186
|
+
/**
|
|
187
|
+
* global function that handles the event on the guest
|
|
188
|
+
*/
|
|
189
|
+
eventHandler?: string;
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* parameters for dispatching an event
|
|
193
|
+
*/
|
|
194
|
+
export type DispatchEventParam<EventId, Params, Options extends EventOptions> = {
|
|
195
|
+
/**
|
|
196
|
+
* event details
|
|
197
|
+
*/
|
|
198
|
+
event: {
|
|
199
|
+
/**
|
|
200
|
+
* unique id of the event in the format objectId.eventName
|
|
201
|
+
* @example 'loan.sync'
|
|
202
|
+
*/
|
|
203
|
+
id: EventId;
|
|
204
|
+
/**
|
|
205
|
+
* name of the event
|
|
206
|
+
* @example 'sync'
|
|
207
|
+
*/
|
|
208
|
+
name: string;
|
|
209
|
+
/**
|
|
210
|
+
* scripting object id that owns this event
|
|
211
|
+
* @example 'loan'
|
|
212
|
+
*/
|
|
213
|
+
objectId?: string;
|
|
214
|
+
};
|
|
215
|
+
/**
|
|
216
|
+
* event parameters
|
|
217
|
+
*/
|
|
218
|
+
eventParams: Params;
|
|
219
|
+
/**
|
|
220
|
+
* additional options for the event
|
|
221
|
+
*/
|
|
222
|
+
eventOptions?: Options;
|
|
223
|
+
};
|