novo-elements 9.2.0-next.1 → 9.2.0-next.3
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/esm2020/utils/app-bridge/AppBridge.mjs +183 -180
- package/esm2020/utils/app-bridge/index.mjs +2 -1
- package/esm2020/utils/app-bridge/interfaces.mjs +38 -0
- package/fesm2015/novo-elements-utils.mjs +184 -143
- package/fesm2015/novo-elements-utils.mjs.map +1 -1
- package/fesm2020/novo-elements-utils.mjs +182 -142
- package/fesm2020/novo-elements-utils.mjs.map +1 -1
- package/package.json +1 -1
- package/utils/app-bridge/AppBridge.d.ts +30 -37
- package/utils/app-bridge/index.d.ts +1 -0
- package/utils/app-bridge/interfaces.d.ts +58 -0
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export * from './AppBridge';
|
|
2
|
-
|
|
2
|
+
export * from './interfaces';
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy9ub3ZvLWVsZW1lbnRzL3NyYy91dGlscy9hcHAtYnJpZGdlL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsYUFBYSxDQUFDO0FBQzVCLGNBQWMsY0FBYyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnLi9BcHBCcmlkZ2UnO1xuZXhwb3J0ICogZnJvbSAnLi9pbnRlcmZhY2VzJztcbiJdfQ==
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export var AppBridgeHandler;
|
|
2
|
+
(function (AppBridgeHandler) {
|
|
3
|
+
AppBridgeHandler[AppBridgeHandler["HTTP"] = 0] = "HTTP";
|
|
4
|
+
AppBridgeHandler[AppBridgeHandler["OPEN"] = 1] = "OPEN";
|
|
5
|
+
AppBridgeHandler[AppBridgeHandler["OPEN_LIST"] = 2] = "OPEN_LIST";
|
|
6
|
+
AppBridgeHandler[AppBridgeHandler["CLOSE"] = 3] = "CLOSE";
|
|
7
|
+
AppBridgeHandler[AppBridgeHandler["REFRESH"] = 4] = "REFRESH";
|
|
8
|
+
AppBridgeHandler[AppBridgeHandler["PIN"] = 5] = "PIN";
|
|
9
|
+
AppBridgeHandler[AppBridgeHandler["REGISTER"] = 6] = "REGISTER";
|
|
10
|
+
AppBridgeHandler[AppBridgeHandler["UPDATE"] = 7] = "UPDATE";
|
|
11
|
+
AppBridgeHandler[AppBridgeHandler["REQUEST_DATA"] = 8] = "REQUEST_DATA";
|
|
12
|
+
AppBridgeHandler[AppBridgeHandler["CALLBACK"] = 9] = "CALLBACK";
|
|
13
|
+
AppBridgeHandler[AppBridgeHandler["PING"] = 10] = "PING";
|
|
14
|
+
})(AppBridgeHandler || (AppBridgeHandler = {}));
|
|
15
|
+
export const HTTP_VERBS = {
|
|
16
|
+
GET: 'get',
|
|
17
|
+
POST: 'post',
|
|
18
|
+
PUT: 'put',
|
|
19
|
+
DELETE: 'delete',
|
|
20
|
+
};
|
|
21
|
+
export const MESSAGE_TYPES = {
|
|
22
|
+
REGISTER: 'register',
|
|
23
|
+
OPEN: 'open',
|
|
24
|
+
OPEN_LIST: 'openList',
|
|
25
|
+
CLOSE: 'close',
|
|
26
|
+
REFRESH: 'refresh',
|
|
27
|
+
PIN: 'pin',
|
|
28
|
+
PING: 'ping',
|
|
29
|
+
UPDATE: 'update',
|
|
30
|
+
HTTP_GET: 'httpGET',
|
|
31
|
+
HTTP_POST: 'httpPOST',
|
|
32
|
+
HTTP_PUT: 'httpPUT',
|
|
33
|
+
HTTP_DELETE: 'httpDELETE',
|
|
34
|
+
CUSTOM_EVENT: 'customEvent',
|
|
35
|
+
REQUEST_DATA: 'requestData',
|
|
36
|
+
CALLBACK: 'callback',
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=data:application/json;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FxuICBDVVNUT01fRVZFTlQ6ICdjdXN0b21FdmVudCcsXG4gIFJFUVVFU1RfREFUQTogJ3JlcXVlc3REYXRhJyxcbiAgQ0FMTEJBQ0s6ICdjYWxsYmFjaycsXG59OyJdfQ==
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __awaiter } from 'tslib';
|
|
1
2
|
import { isDate, format, addDays, addWeeks, addMonths, startOfMinute, startOfDay, startOfWeek, startOfMonth, endOfDay, endOfWeek, endOfMonth, isSameDay, isSameMonth, isSameSecond, differenceInSeconds, differenceInCalendarDays, differenceInDays, isWithinInterval, getMonth, getYear, setMinutes, setHours, isBefore, isAfter, addMinutes, getDay, differenceInMinutes, addHours } from 'date-fns';
|
|
2
3
|
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
|
3
4
|
import * as i0 from '@angular/core';
|
|
@@ -40,6 +41,7 @@ const MESSAGE_TYPES = {
|
|
|
40
41
|
REQUEST_DATA: 'requestData',
|
|
41
42
|
CALLBACK: 'callback',
|
|
42
43
|
};
|
|
44
|
+
|
|
43
45
|
class AppBridgeService {
|
|
44
46
|
create(name) {
|
|
45
47
|
return new AppBridge(name);
|
|
@@ -55,15 +57,16 @@ class DevAppBridgeService {
|
|
|
55
57
|
}
|
|
56
58
|
class AppBridge {
|
|
57
59
|
// Type?
|
|
58
|
-
constructor(traceName = 'AppBridge') {
|
|
60
|
+
constructor(traceName = 'AppBridge', postRobotRef) {
|
|
59
61
|
this.id = `${Date.now()}`;
|
|
60
62
|
this._registeredFrames = [];
|
|
61
63
|
this._handlers = {};
|
|
62
64
|
this._tracing = false;
|
|
63
65
|
this._eventListeners = {};
|
|
64
66
|
this.traceName = traceName;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
this.postRobot = postRobotRef || /* global */ postRobot;
|
|
68
|
+
if (this.postRobot) {
|
|
69
|
+
this.postRobot.CONFIG.LOG_LEVEL = 'error';
|
|
67
70
|
try {
|
|
68
71
|
this._setupHandlers();
|
|
69
72
|
}
|
|
@@ -84,122 +87,152 @@ class AppBridge {
|
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
_setupHandlers() {
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
// map an object for all handlers, so that we can run some other actions before each of them
|
|
91
|
+
const defaultMsgHandlers = {
|
|
92
|
+
// Register
|
|
93
|
+
[MESSAGE_TYPES.REGISTER]: (event) => __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
this._registeredFrames.push(event);
|
|
95
|
+
const windowName = yield this.register(event.data);
|
|
92
96
|
return { windowName };
|
|
97
|
+
}),
|
|
98
|
+
// Update
|
|
99
|
+
[MESSAGE_TYPES.UPDATE]: (event) => {
|
|
100
|
+
return this.update(event.data).then((success) => {
|
|
101
|
+
return { success };
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
// Open
|
|
105
|
+
[MESSAGE_TYPES.OPEN]: (event) => {
|
|
106
|
+
return this.open(event.data).then((success) => {
|
|
107
|
+
return { success };
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
[MESSAGE_TYPES.OPEN_LIST]: (event) => {
|
|
111
|
+
return this.openList(event.data).then((success) => {
|
|
112
|
+
return { success };
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
// Close
|
|
116
|
+
[MESSAGE_TYPES.CLOSE]: (event) => {
|
|
117
|
+
const index = this._registeredFrames.findIndex((frame) => frame.data.id === event.data.id);
|
|
118
|
+
if (index !== -1) {
|
|
119
|
+
this._registeredFrames.splice(index, 1);
|
|
120
|
+
}
|
|
121
|
+
return this.close(event.data).then(success => ({ success }));
|
|
122
|
+
},
|
|
123
|
+
// Refresh
|
|
124
|
+
[MESSAGE_TYPES.REFRESH]: (event) => {
|
|
125
|
+
return this.refresh(event.data).then((success) => {
|
|
126
|
+
return { success };
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
// PIN
|
|
130
|
+
[MESSAGE_TYPES.PIN]: (event) => {
|
|
131
|
+
return this.pin(event.data).then((success) => {
|
|
132
|
+
return { success };
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
// PING
|
|
136
|
+
[MESSAGE_TYPES.PING]: (event) => {
|
|
137
|
+
return this.httpGET('ping', undefined, event.data.origin).then((result) => {
|
|
138
|
+
return { data: result.data, error: result.error };
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
// REQUEST_DATA
|
|
142
|
+
[MESSAGE_TYPES.REQUEST_DATA]: (event) => {
|
|
143
|
+
return this.requestData(event.data).then((result) => {
|
|
144
|
+
return { data: result.data, error: result.error };
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
// CALLBACKS
|
|
148
|
+
[MESSAGE_TYPES.CALLBACK]: (event) => {
|
|
149
|
+
return this.callback(event.data).then((success) => {
|
|
150
|
+
return { success };
|
|
151
|
+
});
|
|
152
|
+
},
|
|
153
|
+
// HTTP-GET
|
|
154
|
+
[MESSAGE_TYPES.HTTP_GET]: (event) => {
|
|
155
|
+
return this.httpGET(event.data.relativeURL, undefined, event.data.origin).then((result) => {
|
|
156
|
+
return { data: result.data, error: result.error };
|
|
157
|
+
});
|
|
158
|
+
},
|
|
159
|
+
// HTTP-POST
|
|
160
|
+
[MESSAGE_TYPES.HTTP_POST]: (event) => {
|
|
161
|
+
return this.httpPOST(event.data.relativeURL, event.data.data, undefined, event.data.origin).then((result) => {
|
|
162
|
+
return { data: result.data, error: result.error };
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
// HTTP-PUT
|
|
166
|
+
[MESSAGE_TYPES.HTTP_PUT]: (event) => {
|
|
167
|
+
return this.httpPUT(event.data.relativeURL, event.data.data, undefined, event.data.origin).then((result) => {
|
|
168
|
+
return { data: result.data, error: result.error };
|
|
169
|
+
});
|
|
170
|
+
},
|
|
171
|
+
// HTTP-DELETE
|
|
172
|
+
[MESSAGE_TYPES.HTTP_DELETE]: (event) => {
|
|
173
|
+
return this.httpDELETE(event.data.relativeURL, undefined, event.data.origin).then((result) => {
|
|
174
|
+
return { data: result.data, error: result.error };
|
|
175
|
+
});
|
|
176
|
+
},
|
|
177
|
+
// Custom Events
|
|
178
|
+
[MESSAGE_TYPES.CUSTOM_EVENT]: (event) => __awaiter(this, void 0, void 0, function* () {
|
|
179
|
+
if (this._eventListeners[event.data.event]) {
|
|
180
|
+
this._eventListeners[event.data.event].forEach((listener) => {
|
|
181
|
+
listener(event.data.data);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
if (this._registeredFrames.length > 0) {
|
|
185
|
+
this._registeredFrames.forEach((frame) => {
|
|
186
|
+
// TODO: Should this make sure it doesn't echo the custom event back to the author?
|
|
187
|
+
this.postRobot.send(frame.source, MESSAGE_TYPES.CUSTOM_EVENT, event.data);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
})
|
|
191
|
+
};
|
|
192
|
+
Object.keys(defaultMsgHandlers).forEach(msgType => {
|
|
193
|
+
this.postRobot.on(msgType, event => {
|
|
194
|
+
this._trace(msgType, event);
|
|
195
|
+
const origin = Array.isArray(event.data.origin) ? event.data.origin : [];
|
|
196
|
+
if (event.origin !== this.windowOrigin()) {
|
|
197
|
+
origin.unshift(event.origin);
|
|
198
|
+
}
|
|
199
|
+
else if (origin.indexOf(event.data.originTraceName) === -1) {
|
|
200
|
+
origin.unshift(event.data.originTraceName);
|
|
201
|
+
}
|
|
202
|
+
event.data.origin = origin;
|
|
203
|
+
event.data.source = event.source;
|
|
204
|
+
return defaultMsgHandlers[msgType](event);
|
|
93
205
|
});
|
|
94
206
|
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
postRobot.on(MESSAGE_TYPES.OPEN_LIST, (event) => {
|
|
110
|
-
this._trace(MESSAGE_TYPES.OPEN_LIST, event);
|
|
111
|
-
return this.openList(event.data).then((success) => {
|
|
112
|
-
return { success };
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
// Close
|
|
116
|
-
postRobot.on(MESSAGE_TYPES.CLOSE, (event) => {
|
|
117
|
-
this._trace(MESSAGE_TYPES.CLOSE, event);
|
|
118
|
-
const index = this._registeredFrames.findIndex((frame) => frame.data.id === event.data.id);
|
|
119
|
-
if (index !== -1) {
|
|
120
|
-
this._registeredFrames.splice(index, 1);
|
|
121
|
-
}
|
|
122
|
-
return this.close(event.data).then((success) => {
|
|
123
|
-
return { success };
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
// Refresh
|
|
127
|
-
postRobot.on(MESSAGE_TYPES.REFRESH, (event) => {
|
|
128
|
-
this._trace(MESSAGE_TYPES.REFRESH, event);
|
|
129
|
-
return this.refresh(event.data).then((success) => {
|
|
130
|
-
return { success };
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
// PIN
|
|
134
|
-
postRobot.on(MESSAGE_TYPES.PIN, (event) => {
|
|
135
|
-
this._trace(MESSAGE_TYPES.PIN, event);
|
|
136
|
-
return this.pin(event.data).then((success) => {
|
|
137
|
-
return { success };
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
// PING
|
|
141
|
-
postRobot.on(MESSAGE_TYPES.PING, (event) => {
|
|
142
|
-
this._trace(MESSAGE_TYPES.PING, event);
|
|
143
|
-
return this.httpGET('ping').then((result) => {
|
|
144
|
-
return { data: result.data, error: result.error };
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
// REQUEST_DATA
|
|
148
|
-
postRobot.on(MESSAGE_TYPES.REQUEST_DATA, (event) => {
|
|
149
|
-
this._trace(MESSAGE_TYPES.REQUEST_DATA, event);
|
|
150
|
-
return this.requestData(event.data).then((result) => {
|
|
151
|
-
return { data: result.data, error: result.error };
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
// CALLBACKS
|
|
155
|
-
postRobot.on(MESSAGE_TYPES.CALLBACK, (event) => {
|
|
156
|
-
this._trace(MESSAGE_TYPES.CALLBACK, event);
|
|
157
|
-
return this.callback(event.data).then((success) => {
|
|
158
|
-
return { success };
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
// HTTP-GET
|
|
162
|
-
postRobot.on(MESSAGE_TYPES.HTTP_GET, (event) => {
|
|
163
|
-
this._trace(MESSAGE_TYPES.HTTP_GET, event);
|
|
164
|
-
return this.httpGET(event.data.relativeURL).then((result) => {
|
|
165
|
-
return { data: result.data, error: result.error };
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
// HTTP-POST
|
|
169
|
-
postRobot.on(MESSAGE_TYPES.HTTP_POST, (event) => {
|
|
170
|
-
this._trace(MESSAGE_TYPES.HTTP_POST, event);
|
|
171
|
-
return this.httpPOST(event.data.relativeURL, event.data.data).then((result) => {
|
|
172
|
-
return { data: result.data, error: result.error };
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
// HTTP-PUT
|
|
176
|
-
postRobot.on(MESSAGE_TYPES.HTTP_PUT, (event) => {
|
|
177
|
-
this._trace(MESSAGE_TYPES.HTTP_PUT, event);
|
|
178
|
-
return this.httpPUT(event.data.relativeURL, event.data.data).then((result) => {
|
|
179
|
-
return { data: result.data, error: result.error };
|
|
207
|
+
}
|
|
208
|
+
windowOrigin() {
|
|
209
|
+
return window.location.origin;
|
|
210
|
+
}
|
|
211
|
+
handleMessage({ msgType, handler, packet, echoPacket, resolveEventData }) {
|
|
212
|
+
let returnPromise;
|
|
213
|
+
if (this._handlers[handler]) {
|
|
214
|
+
// Should be directly returning a promise. However, as a fallback, provide callback arguments
|
|
215
|
+
let callbackSuccess, callbackFail;
|
|
216
|
+
returnPromise = new Promise((s, f) => {
|
|
217
|
+
callbackSuccess = s;
|
|
218
|
+
callbackFail = f;
|
|
180
219
|
});
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
220
|
+
const handlerResult = this._handlers[handler](packet, callbackArg => {
|
|
221
|
+
if (callbackArg) {
|
|
222
|
+
callbackSuccess(true);
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
callbackFail(false);
|
|
226
|
+
}
|
|
187
227
|
});
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
postRobot.on(MESSAGE_TYPES.CUSTOM_EVENT, (event) => {
|
|
191
|
-
this._trace(MESSAGE_TYPES.CUSTOM_EVENT, event);
|
|
192
|
-
if (this._eventListeners[event.data.event]) {
|
|
193
|
-
this._eventListeners[event.data.event].forEach((listener) => {
|
|
194
|
-
listener(event.data.data);
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
if (this._registeredFrames.length > 0) {
|
|
198
|
-
this._registeredFrames.forEach((frame) => {
|
|
199
|
-
postRobot.send(frame.source, MESSAGE_TYPES.CUSTOM_EVENT, event.data);
|
|
200
|
-
});
|
|
228
|
+
if (handlerResult && 'then' in handlerResult) {
|
|
229
|
+
returnPromise = handlerResult;
|
|
201
230
|
}
|
|
202
|
-
|
|
231
|
+
return returnPromise.then(result => true, () => false);
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
return this.postRobot.sendToParent(msgType, echoPacket || packet);
|
|
235
|
+
}
|
|
203
236
|
}
|
|
204
237
|
/**
|
|
205
238
|
* Fires or responds to an open event
|
|
@@ -219,7 +252,7 @@ class AppBridge {
|
|
|
219
252
|
}
|
|
220
253
|
else {
|
|
221
254
|
Object.assign(packet, { id: this.id, windowName: this.windowName });
|
|
222
|
-
postRobot
|
|
255
|
+
this.postRobot
|
|
223
256
|
.sendToParent(MESSAGE_TYPES.OPEN, packet)
|
|
224
257
|
.then((event) => {
|
|
225
258
|
this._trace(`${MESSAGE_TYPES.OPEN} (callback)`, event);
|
|
@@ -255,7 +288,7 @@ class AppBridge {
|
|
|
255
288
|
else {
|
|
256
289
|
const openListPacket = {};
|
|
257
290
|
Object.assign(openListPacket, { type: 'List', entityType: packet.type, keywords: packet.keywords, criteria: packet.criteria });
|
|
258
|
-
postRobot
|
|
291
|
+
this.postRobot
|
|
259
292
|
.sendToParent(MESSAGE_TYPES.OPEN_LIST, packet)
|
|
260
293
|
.then((event) => {
|
|
261
294
|
this._trace(`${MESSAGE_TYPES.OPEN_LIST} (callback)`, event);
|
|
@@ -290,7 +323,7 @@ class AppBridge {
|
|
|
290
323
|
}
|
|
291
324
|
else {
|
|
292
325
|
Object.assign(packet, { id: this.id, windowName: this.windowName });
|
|
293
|
-
postRobot
|
|
326
|
+
this.postRobot
|
|
294
327
|
.sendToParent(MESSAGE_TYPES.UPDATE, packet)
|
|
295
328
|
.then((event) => {
|
|
296
329
|
this._trace(`${MESSAGE_TYPES.UPDATE} (callback)`, event);
|
|
@@ -327,7 +360,7 @@ class AppBridge {
|
|
|
327
360
|
console.info('[AppBridge] - close(packet) is deprecated! Please just use close()!'); // tslint:disable-line
|
|
328
361
|
}
|
|
329
362
|
const realPacket = { id: this.id, windowName: this.windowName };
|
|
330
|
-
postRobot
|
|
363
|
+
this.postRobot
|
|
331
364
|
.sendToParent(MESSAGE_TYPES.CLOSE, realPacket)
|
|
332
365
|
.then((event) => {
|
|
333
366
|
this._trace(`${MESSAGE_TYPES.CLOSE} (callback)`, event);
|
|
@@ -364,7 +397,7 @@ class AppBridge {
|
|
|
364
397
|
console.info('[AppBridge] - refresh(packet) is deprecated! Please just use refresh()!'); // tslint:disable-line
|
|
365
398
|
}
|
|
366
399
|
const realPacket = { id: this.id, windowName: this.windowName };
|
|
367
|
-
postRobot
|
|
400
|
+
this.postRobot
|
|
368
401
|
.sendToParent(MESSAGE_TYPES.REFRESH, realPacket)
|
|
369
402
|
.then((event) => {
|
|
370
403
|
this._trace(`${MESSAGE_TYPES.REFRESH} (callback)`, event);
|
|
@@ -389,7 +422,7 @@ class AppBridge {
|
|
|
389
422
|
});
|
|
390
423
|
}
|
|
391
424
|
else {
|
|
392
|
-
postRobot
|
|
425
|
+
this.postRobot
|
|
393
426
|
.sendToParent(MESSAGE_TYPES.PING, {})
|
|
394
427
|
.then((event) => {
|
|
395
428
|
resolve({ data: event.data.data, error: event.data.error });
|
|
@@ -420,7 +453,7 @@ class AppBridge {
|
|
|
420
453
|
console.info('[AppBridge] - pin(packet) is deprecated! Please just use pin()!'); // tslint:disable-line
|
|
421
454
|
}
|
|
422
455
|
const realPacket = { id: this.id, windowName: this.windowName };
|
|
423
|
-
postRobot
|
|
456
|
+
this.postRobot
|
|
424
457
|
.sendToParent(MESSAGE_TYPES.PIN, realPacket)
|
|
425
458
|
.then((event) => {
|
|
426
459
|
this._trace(`${MESSAGE_TYPES.PIN} (callback)`, event);
|
|
@@ -455,7 +488,7 @@ class AppBridge {
|
|
|
455
488
|
}
|
|
456
489
|
else {
|
|
457
490
|
Object.assign(packet, { id: this.id, windowName: this.windowName });
|
|
458
|
-
postRobot
|
|
491
|
+
this.postRobot
|
|
459
492
|
.sendToParent(MESSAGE_TYPES.REQUEST_DATA, packet)
|
|
460
493
|
.then((event) => {
|
|
461
494
|
this._trace(`${MESSAGE_TYPES.REQUEST_DATA} (callback)`, event);
|
|
@@ -490,7 +523,7 @@ class AppBridge {
|
|
|
490
523
|
}
|
|
491
524
|
else {
|
|
492
525
|
Object.assign(packet, { id: this.id, windowName: this.windowName });
|
|
493
|
-
postRobot
|
|
526
|
+
this.postRobot
|
|
494
527
|
.sendToParent(MESSAGE_TYPES.CALLBACK, packet)
|
|
495
528
|
.then((event) => {
|
|
496
529
|
this._trace(`${MESSAGE_TYPES.CALLBACK} (callback)`, event);
|
|
@@ -525,7 +558,7 @@ class AppBridge {
|
|
|
525
558
|
}
|
|
526
559
|
else {
|
|
527
560
|
Object.assign(packet, { id: this.id });
|
|
528
|
-
postRobot
|
|
561
|
+
this.postRobot
|
|
529
562
|
.sendToParent(MESSAGE_TYPES.REGISTER, packet)
|
|
530
563
|
.then((event) => {
|
|
531
564
|
this._trace(`${MESSAGE_TYPES.REGISTER} (callback)`, event);
|
|
@@ -547,17 +580,19 @@ class AppBridge {
|
|
|
547
580
|
/**
|
|
548
581
|
* Fires or responds to an HTTP_GET event
|
|
549
582
|
* @param packet any - packet of data to send with the event
|
|
583
|
+
* @param timeout - how long to attempt the request before reporting an error
|
|
584
|
+
* @param originStack - the domain of the previous frame(s) the request originated from
|
|
550
585
|
*/
|
|
551
|
-
httpGET(relativeURL, timeout = 10000) {
|
|
586
|
+
httpGET(relativeURL, timeout = 10000, originStack) {
|
|
552
587
|
return new Promise((resolve, reject) => {
|
|
553
588
|
if (this._handlers[AppBridgeHandler.HTTP]) {
|
|
554
|
-
this._handlers[AppBridgeHandler.HTTP]({ verb: HTTP_VERBS.GET, relativeURL }, (data, error) => {
|
|
589
|
+
this._handlers[AppBridgeHandler.HTTP]({ verb: HTTP_VERBS.GET, relativeURL, origin: originStack || [this.traceName] }, (data, error) => {
|
|
555
590
|
resolve({ data, error });
|
|
556
591
|
});
|
|
557
592
|
}
|
|
558
593
|
else {
|
|
559
|
-
postRobot
|
|
560
|
-
.sendToParent(MESSAGE_TYPES.HTTP_GET, { relativeURL }, { timeout })
|
|
594
|
+
this.postRobot
|
|
595
|
+
.sendToParent(MESSAGE_TYPES.HTTP_GET, { relativeURL, origin: originStack, originTraceName: this.traceName }, { timeout })
|
|
561
596
|
.then((event) => {
|
|
562
597
|
resolve({ data: event.data.data, error: event.data.error });
|
|
563
598
|
})
|
|
@@ -570,17 +605,19 @@ class AppBridge {
|
|
|
570
605
|
/**
|
|
571
606
|
* Fires or responds to an HTTP_POST event
|
|
572
607
|
* @param packet any - packet of data to send with the event
|
|
608
|
+
* @param timeout - how long to attempt the request before reporting an error
|
|
609
|
+
* @param originStack - the domain of the previous frame(s) the request originated from
|
|
573
610
|
*/
|
|
574
|
-
httpPOST(relativeURL, postData, timeout = 10000) {
|
|
611
|
+
httpPOST(relativeURL, postData, timeout = 10000, originStack) {
|
|
575
612
|
return new Promise((resolve, reject) => {
|
|
576
613
|
if (this._handlers[AppBridgeHandler.HTTP]) {
|
|
577
|
-
this._handlers[AppBridgeHandler.HTTP]({ verb: HTTP_VERBS.POST, relativeURL, data: postData }, (data, error) => {
|
|
614
|
+
this._handlers[AppBridgeHandler.HTTP]({ verb: HTTP_VERBS.POST, relativeURL, data: postData, origin: originStack || [this.traceName] }, (data, error) => {
|
|
578
615
|
resolve({ data, error });
|
|
579
616
|
});
|
|
580
617
|
}
|
|
581
618
|
else {
|
|
582
|
-
postRobot
|
|
583
|
-
.sendToParent(MESSAGE_TYPES.HTTP_POST, { relativeURL, data: postData }, { timeout })
|
|
619
|
+
this.postRobot
|
|
620
|
+
.sendToParent(MESSAGE_TYPES.HTTP_POST, { relativeURL, data: postData, origin: originStack, originTraceName: this.traceName }, { timeout })
|
|
584
621
|
.then((event) => {
|
|
585
622
|
resolve({ data: event.data.data, error: event.data.error });
|
|
586
623
|
})
|
|
@@ -593,17 +630,19 @@ class AppBridge {
|
|
|
593
630
|
/**
|
|
594
631
|
* Fires or responds to an HTTP_PUT event
|
|
595
632
|
* @param packet any - packet of data to send with the event
|
|
633
|
+
* @param timeout - how long to attempt the request before reporting an error
|
|
634
|
+
* @param originStack - the domain of the previous frame(s) the request originated from
|
|
596
635
|
*/
|
|
597
|
-
httpPUT(relativeURL, putData, timeout = 10000) {
|
|
636
|
+
httpPUT(relativeURL, putData, timeout = 10000, originStack) {
|
|
598
637
|
return new Promise((resolve, reject) => {
|
|
599
638
|
if (this._handlers[AppBridgeHandler.HTTP]) {
|
|
600
|
-
this._handlers[AppBridgeHandler.HTTP]({ verb: HTTP_VERBS.PUT, relativeURL, data: putData }, (data, error) => {
|
|
639
|
+
this._handlers[AppBridgeHandler.HTTP]({ verb: HTTP_VERBS.PUT, relativeURL, data: putData, origin: originStack || [this.traceName] }, (data, error) => {
|
|
601
640
|
resolve({ data, error });
|
|
602
641
|
});
|
|
603
642
|
}
|
|
604
643
|
else {
|
|
605
|
-
postRobot
|
|
606
|
-
.sendToParent(MESSAGE_TYPES.HTTP_PUT, { relativeURL, data: putData }, { timeout })
|
|
644
|
+
this.postRobot
|
|
645
|
+
.sendToParent(MESSAGE_TYPES.HTTP_PUT, { relativeURL, data: putData, origin: originStack, originTraceName: this.traceName }, { timeout })
|
|
607
646
|
.then((event) => {
|
|
608
647
|
resolve({ data: event.data.data, error: event.data.error });
|
|
609
648
|
})
|
|
@@ -616,17 +655,19 @@ class AppBridge {
|
|
|
616
655
|
/**
|
|
617
656
|
* Fires or responds to an HTTP_DELETE event
|
|
618
657
|
* @param packet any - packet of data to send with the event
|
|
658
|
+
* @param timeout - how long to attempt the request before reporting an error
|
|
659
|
+
* @param originStack - the domain of the previous frame(s) the request originated from
|
|
619
660
|
*/
|
|
620
|
-
httpDELETE(relativeURL, timeout = 10000) {
|
|
661
|
+
httpDELETE(relativeURL, timeout = 10000, originStack) {
|
|
621
662
|
return new Promise((resolve, reject) => {
|
|
622
663
|
if (this._handlers[AppBridgeHandler.HTTP]) {
|
|
623
|
-
this._handlers[AppBridgeHandler.HTTP]({ verb: HTTP_VERBS.DELETE, relativeURL }, (data, error) => {
|
|
664
|
+
this._handlers[AppBridgeHandler.HTTP]({ verb: HTTP_VERBS.DELETE, relativeURL, origin: originStack || [this.traceName] }, (data, error) => {
|
|
624
665
|
resolve({ data, error });
|
|
625
666
|
});
|
|
626
667
|
}
|
|
627
668
|
else {
|
|
628
|
-
postRobot
|
|
629
|
-
.sendToParent(MESSAGE_TYPES.HTTP_DELETE, { relativeURL }, { timeout })
|
|
669
|
+
this.postRobot
|
|
670
|
+
.sendToParent(MESSAGE_TYPES.HTTP_DELETE, { relativeURL, origin: originStack, originTraceName: this.traceName }, { timeout })
|
|
630
671
|
.then((event) => {
|
|
631
672
|
resolve({ data: event.data.data, error: event.data.error });
|
|
632
673
|
})
|
|
@@ -643,7 +684,7 @@ class AppBridge {
|
|
|
643
684
|
*/
|
|
644
685
|
fireEvent(event, data) {
|
|
645
686
|
return new Promise((resolve, reject) => {
|
|
646
|
-
postRobot
|
|
687
|
+
this.postRobot
|
|
647
688
|
.sendToParent(MESSAGE_TYPES.CUSTOM_EVENT, { event, data })
|
|
648
689
|
.then((e) => {
|
|
649
690
|
resolve(e);
|
|
@@ -661,7 +702,7 @@ class AppBridge {
|
|
|
661
702
|
fireEventToChildren(event, data) {
|
|
662
703
|
if (this._registeredFrames.length > 0) {
|
|
663
704
|
this._registeredFrames.forEach((frame) => {
|
|
664
|
-
postRobot.send(frame.source, MESSAGE_TYPES.CUSTOM_EVENT, {
|
|
705
|
+
this.postRobot.send(frame.source, MESSAGE_TYPES.CUSTOM_EVENT, {
|
|
665
706
|
event,
|
|
666
707
|
eventType: event,
|
|
667
708
|
data,
|
|
@@ -679,7 +720,7 @@ class AppBridge {
|
|
|
679
720
|
if (source instanceof HTMLIFrameElement) {
|
|
680
721
|
source = source.contentWindow;
|
|
681
722
|
}
|
|
682
|
-
postRobot.send(source, MESSAGE_TYPES.CUSTOM_EVENT, { event, data });
|
|
723
|
+
this.postRobot.send(source, MESSAGE_TYPES.CUSTOM_EVENT, { event, data });
|
|
683
724
|
}
|
|
684
725
|
/**
|
|
685
726
|
* Adds an event listener to a custom event
|
|
@@ -20080,5 +20121,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
20080
20121
|
* Generated bundle index. Do not edit.
|
|
20081
20122
|
*/
|
|
20082
20123
|
|
|
20083
|
-
export { AppBridge, AppBridgeHandler, AppBridgeService, BooleanInput, COUNTRIES, CalendarEventResponse, Can, Color, DateRange, DateUtil, Deferred, DevAppBridge, DevAppBridgeService, Helpers, KeyCodes, OutsideClick, binarySearch, can, convertTokens, findByCountryCode, findByCountryId, findByCountryName, formatZonedTime, getCountries, getDayView, getDayViewHourGrid, getMonthView, getStateObjects, getStates, getWeekView, getWeekViewEventOffset, getWeekViewHeader, isAlphaNumeric, legacyParse, notify };
|
|
20124
|
+
export { AppBridge, AppBridgeHandler, AppBridgeService, BooleanInput, COUNTRIES, CalendarEventResponse, Can, Color, DateRange, DateUtil, Deferred, DevAppBridge, DevAppBridgeService, HTTP_VERBS, Helpers, KeyCodes, MESSAGE_TYPES, OutsideClick, binarySearch, can, convertTokens, findByCountryCode, findByCountryId, findByCountryName, formatZonedTime, getCountries, getDayView, getDayViewHourGrid, getMonthView, getStateObjects, getStates, getWeekView, getWeekViewEventOffset, getWeekViewHeader, isAlphaNumeric, legacyParse, notify };
|
|
20084
20125
|
//# sourceMappingURL=novo-elements-utils.mjs.map
|