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