@equinor/echo-framework 0.7.4 → 0.7.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/__tests__/realTimeDataHooks.test.d.ts +1 -0
- package/dist/__tests__/realTimeDataUtils.test.d.ts +1 -0
- package/dist/_virtual/_tslib.js +14 -0
- package/dist/components/errorBoundary/errorBoundary.d.ts +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/realTimeData/RealTimePopoverButton.d.ts +18 -0
- package/dist/components/realTimeData/components/IMSDropdown/RealTimeIMSDropdown.d.ts +7 -0
- package/dist/components/realTimeData/components/IMSDropdown/index.d.ts +1 -0
- package/dist/components/realTimeData/components/connectorForIMSTag/RealTimeConnectorForIMSTag.d.ts +6 -0
- package/dist/components/realTimeData/components/connectorForIMSTag/index.d.ts +1 -0
- package/dist/components/realTimeData/components/contextButton/RealTimeContextButton.d.ts +6 -0
- package/dist/components/realTimeData/components/contextButton/index.d.ts +1 -0
- package/dist/components/realTimeData/components/contextPopover/Popover.d.ts +6 -0
- package/dist/components/realTimeData/components/contextPopover/index.d.ts +1 -0
- package/dist/components/realTimeData/components/index.d.ts +4 -0
- package/dist/components/realTimeData/hooks/index.d.ts +3 -0
- package/dist/components/realTimeData/hooks/useRealTimeHub.d.ts +13 -0
- package/dist/components/realTimeData/hooks/useSignalR.d.ts +9 -0
- package/dist/components/realTimeData/hooks/useSignalRListener.d.ts +4 -0
- package/dist/components/realTimeData/index.d.ts +1 -0
- package/dist/node_modules/@microsoft/signalr/dist/esm/AbortController.js +54 -0
- package/dist/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js +96 -0
- package/dist/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js +47 -0
- package/dist/node_modules/@microsoft/signalr/dist/esm/Errors.js +287 -0
- package/dist/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js +281 -0
- package/dist/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js +86 -0
- package/dist/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js +20 -0
- package/dist/node_modules/@microsoft/signalr/dist/esm/HttpClient.js +82 -0
- package/dist/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js +1167 -0
- package/dist/node_modules/@microsoft/signalr/dist/esm/HubConnection.js +1342 -0
- package/dist/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js +165 -0
- package/dist/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js +33 -0
- package/dist/node_modules/@microsoft/signalr/dist/esm/ILogger.js +37 -0
- package/dist/node_modules/@microsoft/signalr/dist/esm/ITransport.js +37 -0
- package/dist/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js +179 -0
- package/dist/node_modules/@microsoft/signalr/dist/esm/Loggers.js +35 -0
- package/dist/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js +444 -0
- package/dist/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js +235 -0
- package/dist/node_modules/@microsoft/signalr/dist/esm/Subject.js +99 -0
- package/dist/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js +45 -0
- package/dist/node_modules/@microsoft/signalr/dist/esm/Utils.js +433 -0
- package/dist/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js +263 -0
- package/dist/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js +133 -0
- package/dist/services/api/api-realtimedata.d.ts +2 -0
- package/dist/src/components/realTimeData/RealTimePopoverButton.js +136 -0
- package/dist/src/components/realTimeData/components/IMSDropdown/RealTimeIMSDropdown.js +81 -0
- package/dist/src/components/realTimeData/components/IMSDropdown/RealTimeIMSDropdown.module.css.js +15 -0
- package/dist/src/components/realTimeData/components/connectorForIMSTag/IMSConnector.module.css.js +16 -0
- package/dist/src/components/realTimeData/components/connectorForIMSTag/RealTimeConnectorForIMSTag.js +110 -0
- package/dist/src/components/realTimeData/components/contextButton/RealTimeContextButton.js +75 -0
- package/dist/src/components/realTimeData/components/contextButton/RealTimeContextButton.module.css.js +15 -0
- package/dist/src/components/realTimeData/components/contextPopover/Popover.js +37 -0
- package/dist/src/components/realTimeData/components/contextPopover/Popover.module.css.js +15 -0
- package/dist/src/components/realTimeData/hooks/useRealTimeHub.js +122 -0
- package/dist/src/components/realTimeData/hooks/useSignalR.js +159 -0
- package/dist/src/components/realTimeData/hooks/useSignalRListener.js +22 -0
- package/dist/src/index.js +3 -0
- package/dist/src/services/api/api-realtimedata.js +42 -0
- package/dist/types/realtimedata.d.ts +18 -0
- package/package.json +23 -20
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
|
|
7
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
|
|
9
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
+
|
|
11
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
|
+
|
|
13
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
14
|
+
|
|
15
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
16
|
+
|
|
17
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
18
|
+
|
|
19
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
|
+
|
|
21
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
22
|
+
|
|
23
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
24
|
+
|
|
25
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
26
|
+
|
|
27
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
28
|
+
|
|
29
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
30
|
+
|
|
31
|
+
Object.defineProperty(exports, '__esModule', {
|
|
32
|
+
value: true
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
var HeaderNames = require('./HeaderNames.js');
|
|
36
|
+
|
|
37
|
+
var ILogger = require('./ILogger.js');
|
|
38
|
+
|
|
39
|
+
var ITransport = require('./ITransport.js');
|
|
40
|
+
|
|
41
|
+
var Utils = require('./Utils.js'); // Licensed to the .NET Foundation under one or more agreements.
|
|
42
|
+
|
|
43
|
+
/** @private */
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
var WebSocketTransport = /*#__PURE__*/function () {
|
|
47
|
+
function WebSocketTransport(httpClient, accessTokenFactory, logger, logMessageContent, webSocketConstructor, headers) {
|
|
48
|
+
_classCallCheck(this, WebSocketTransport);
|
|
49
|
+
|
|
50
|
+
this._logger = logger;
|
|
51
|
+
this._accessTokenFactory = accessTokenFactory;
|
|
52
|
+
this._logMessageContent = logMessageContent;
|
|
53
|
+
this._webSocketConstructor = webSocketConstructor;
|
|
54
|
+
this._httpClient = httpClient;
|
|
55
|
+
this.onreceive = null;
|
|
56
|
+
this.onclose = null;
|
|
57
|
+
this._headers = headers;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
_createClass(WebSocketTransport, [{
|
|
61
|
+
key: "connect",
|
|
62
|
+
value: function () {
|
|
63
|
+
var _connect = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(url, transferFormat) {
|
|
64
|
+
var _this = this;
|
|
65
|
+
|
|
66
|
+
var token;
|
|
67
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
68
|
+
while (1) {
|
|
69
|
+
switch (_context.prev = _context.next) {
|
|
70
|
+
case 0:
|
|
71
|
+
Utils.Arg.isRequired(url, "url");
|
|
72
|
+
Utils.Arg.isRequired(transferFormat, "transferFormat");
|
|
73
|
+
Utils.Arg.isIn(transferFormat, ITransport.TransferFormat, "transferFormat");
|
|
74
|
+
|
|
75
|
+
this._logger.log(ILogger.LogLevel.Trace, "(WebSockets transport) Connecting.");
|
|
76
|
+
|
|
77
|
+
if (!this._accessTokenFactory) {
|
|
78
|
+
_context.next = 9;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
_context.next = 7;
|
|
83
|
+
return this._accessTokenFactory();
|
|
84
|
+
|
|
85
|
+
case 7:
|
|
86
|
+
token = _context.sent;
|
|
87
|
+
|
|
88
|
+
if (token) {
|
|
89
|
+
url += (url.indexOf("?") < 0 ? "?" : "&") + "access_token=".concat(encodeURIComponent(token));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
case 9:
|
|
93
|
+
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
|
94
|
+
url = url.replace(/^http/, "ws");
|
|
95
|
+
var webSocket;
|
|
96
|
+
|
|
97
|
+
var cookies = _this._httpClient.getCookieString(url);
|
|
98
|
+
|
|
99
|
+
var opened = false;
|
|
100
|
+
|
|
101
|
+
if (Utils.Platform.isNode) {
|
|
102
|
+
var headers = {};
|
|
103
|
+
|
|
104
|
+
var _Utils$getUserAgentHe = Utils.getUserAgentHeader(),
|
|
105
|
+
_Utils$getUserAgentHe2 = _slicedToArray(_Utils$getUserAgentHe, 2),
|
|
106
|
+
name = _Utils$getUserAgentHe2[0],
|
|
107
|
+
value = _Utils$getUserAgentHe2[1];
|
|
108
|
+
|
|
109
|
+
headers[name] = value;
|
|
110
|
+
|
|
111
|
+
if (cookies) {
|
|
112
|
+
headers[HeaderNames.HeaderNames.Cookie] = "".concat(cookies);
|
|
113
|
+
} // Only pass headers when in non-browser environments
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
// Only pass headers when in non-browser environments
|
|
117
|
+
webSocket = new _this._webSocketConstructor(url, undefined, {
|
|
118
|
+
headers: _objectSpread(_objectSpread({}, headers), _this._headers)
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (!webSocket) {
|
|
123
|
+
// Chrome is not happy with passing 'undefined' as protocol
|
|
124
|
+
webSocket = new _this._webSocketConstructor(url);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (transferFormat === ITransport.TransferFormat.Binary) {
|
|
128
|
+
webSocket.binaryType = "arraybuffer";
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
webSocket.onopen = function (_event) {
|
|
132
|
+
_this._logger.log(ILogger.LogLevel.Information, "WebSocket connected to ".concat(url, "."));
|
|
133
|
+
|
|
134
|
+
_this._webSocket = webSocket;
|
|
135
|
+
opened = true;
|
|
136
|
+
resolve();
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
webSocket.onerror = function (event) {
|
|
140
|
+
var error = null; // ErrorEvent is a browser only type we need to check if the type exists before using it
|
|
141
|
+
|
|
142
|
+
// ErrorEvent is a browser only type we need to check if the type exists before using it
|
|
143
|
+
if (typeof ErrorEvent !== "undefined" && event instanceof ErrorEvent) {
|
|
144
|
+
error = event.error;
|
|
145
|
+
} else {
|
|
146
|
+
error = "There was an error with the transport";
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
_this._logger.log(ILogger.LogLevel.Information, "(WebSockets transport) ".concat(error, "."));
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
webSocket.onmessage = function (message) {
|
|
153
|
+
_this._logger.log(ILogger.LogLevel.Trace, "(WebSockets transport) data received. ".concat(Utils.getDataDetail(message.data, _this._logMessageContent), "."));
|
|
154
|
+
|
|
155
|
+
if (_this.onreceive) {
|
|
156
|
+
try {
|
|
157
|
+
_this.onreceive(message.data);
|
|
158
|
+
} catch (error) {
|
|
159
|
+
_this._close(error);
|
|
160
|
+
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
webSocket.onclose = function (event) {
|
|
167
|
+
// Don't call close handler if connection was never established
|
|
168
|
+
// We'll reject the connect call instead
|
|
169
|
+
if (opened) {
|
|
170
|
+
_this._close(event);
|
|
171
|
+
} else {
|
|
172
|
+
var error = null; // ErrorEvent is a browser only type we need to check if the type exists before using it
|
|
173
|
+
|
|
174
|
+
// ErrorEvent is a browser only type we need to check if the type exists before using it
|
|
175
|
+
if (typeof ErrorEvent !== "undefined" && event instanceof ErrorEvent) {
|
|
176
|
+
error = event.error;
|
|
177
|
+
} else {
|
|
178
|
+
error = "WebSocket failed to connect. The connection could not be found on the server," + " either the endpoint may not be a SignalR endpoint," + " the connection ID is not present on the server, or there is a proxy blocking WebSockets." + " If you have multiple servers check that sticky sessions are enabled.";
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
reject(new Error(error));
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
}));
|
|
185
|
+
|
|
186
|
+
case 10:
|
|
187
|
+
case "end":
|
|
188
|
+
return _context.stop();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}, _callee, this);
|
|
192
|
+
}));
|
|
193
|
+
|
|
194
|
+
function connect(_x, _x2) {
|
|
195
|
+
return _connect.apply(this, arguments);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return connect;
|
|
199
|
+
}()
|
|
200
|
+
}, {
|
|
201
|
+
key: "send",
|
|
202
|
+
value: function send(data) {
|
|
203
|
+
if (this._webSocket && this._webSocket.readyState === this._webSocketConstructor.OPEN) {
|
|
204
|
+
this._logger.log(ILogger.LogLevel.Trace, "(WebSockets transport) sending data. ".concat(Utils.getDataDetail(data, this._logMessageContent), "."));
|
|
205
|
+
|
|
206
|
+
this._webSocket.send(data);
|
|
207
|
+
|
|
208
|
+
return Promise.resolve();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return Promise.reject("WebSocket is not in the OPEN state");
|
|
212
|
+
}
|
|
213
|
+
}, {
|
|
214
|
+
key: "stop",
|
|
215
|
+
value: function stop() {
|
|
216
|
+
if (this._webSocket) {
|
|
217
|
+
// Manually invoke onclose callback inline so we know the HttpConnection was closed properly before returning
|
|
218
|
+
// This also solves an issue where websocket.onclose could take 18+ seconds to trigger during network disconnects
|
|
219
|
+
this._close(undefined);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return Promise.resolve();
|
|
223
|
+
}
|
|
224
|
+
}, {
|
|
225
|
+
key: "_close",
|
|
226
|
+
value: function _close(event) {
|
|
227
|
+
// webSocket will be null if the transport did not start successfully
|
|
228
|
+
if (this._webSocket) {
|
|
229
|
+
// Clear websocket handlers because we are considering the socket closed now
|
|
230
|
+
this._webSocket.onclose = function () {};
|
|
231
|
+
|
|
232
|
+
this._webSocket.onmessage = function () {};
|
|
233
|
+
|
|
234
|
+
this._webSocket.onerror = function () {};
|
|
235
|
+
|
|
236
|
+
this._webSocket.close();
|
|
237
|
+
|
|
238
|
+
this._webSocket = undefined;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
this._logger.log(ILogger.LogLevel.Trace, "(WebSockets transport) socket closed.");
|
|
242
|
+
|
|
243
|
+
if (this.onclose) {
|
|
244
|
+
if (this._isCloseEvent(event) && (event.wasClean === false || event.code !== 1000)) {
|
|
245
|
+
this.onclose(new Error("WebSocket closed with status code: ".concat(event.code, " (").concat(event.reason || "no reason given", ").")));
|
|
246
|
+
} else if (event instanceof Error) {
|
|
247
|
+
this.onclose(event);
|
|
248
|
+
} else {
|
|
249
|
+
this.onclose();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}, {
|
|
254
|
+
key: "_isCloseEvent",
|
|
255
|
+
value: function _isCloseEvent(event) {
|
|
256
|
+
return event && typeof event.wasClean === "boolean" && typeof event.code === "number";
|
|
257
|
+
}
|
|
258
|
+
}]);
|
|
259
|
+
|
|
260
|
+
return WebSocketTransport;
|
|
261
|
+
}();
|
|
262
|
+
|
|
263
|
+
exports.WebSocketTransport = WebSocketTransport;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
+
|
|
7
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
8
|
+
|
|
9
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
10
|
+
|
|
11
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
12
|
+
|
|
13
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
14
|
+
|
|
15
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
16
|
+
|
|
17
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
18
|
+
|
|
19
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
20
|
+
|
|
21
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
22
|
+
|
|
23
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
24
|
+
|
|
25
|
+
Object.defineProperty(exports, '__esModule', {
|
|
26
|
+
value: true
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
var Errors = require('./Errors.js');
|
|
30
|
+
|
|
31
|
+
var HttpClient = require('./HttpClient.js');
|
|
32
|
+
|
|
33
|
+
var ILogger = require('./ILogger.js'); // Licensed to the .NET Foundation under one or more agreements.
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
var XhrHttpClient = /*#__PURE__*/function (_HttpClient$HttpClien) {
|
|
37
|
+
_inherits(XhrHttpClient, _HttpClient$HttpClien);
|
|
38
|
+
|
|
39
|
+
var _super = _createSuper(XhrHttpClient);
|
|
40
|
+
|
|
41
|
+
function XhrHttpClient(logger) {
|
|
42
|
+
var _this;
|
|
43
|
+
|
|
44
|
+
_classCallCheck(this, XhrHttpClient);
|
|
45
|
+
|
|
46
|
+
_this = _super.call(this);
|
|
47
|
+
_this._logger = logger;
|
|
48
|
+
return _this;
|
|
49
|
+
}
|
|
50
|
+
/** @inheritDoc */
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
_createClass(XhrHttpClient, [{
|
|
54
|
+
key: "send",
|
|
55
|
+
value: function send(request) {
|
|
56
|
+
var _this2 = this;
|
|
57
|
+
|
|
58
|
+
// Check that abort was not signaled before calling send
|
|
59
|
+
if (request.abortSignal && request.abortSignal.aborted) {
|
|
60
|
+
return Promise.reject(new Errors.AbortError());
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!request.method) {
|
|
64
|
+
return Promise.reject(new Error("No method defined."));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (!request.url) {
|
|
68
|
+
return Promise.reject(new Error("No url defined."));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return new Promise(function (resolve, reject) {
|
|
72
|
+
var xhr = new XMLHttpRequest();
|
|
73
|
+
xhr.open(request.method, request.url, true);
|
|
74
|
+
xhr.withCredentials = request.withCredentials === undefined ? true : request.withCredentials;
|
|
75
|
+
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); // Explicitly setting the Content-Type header for React Native on Android platform.
|
|
76
|
+
|
|
77
|
+
xhr.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
|
|
78
|
+
var headers = request.headers;
|
|
79
|
+
|
|
80
|
+
if (headers) {
|
|
81
|
+
Object.keys(headers).forEach(function (header) {
|
|
82
|
+
xhr.setRequestHeader(header, headers[header]);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (request.responseType) {
|
|
87
|
+
xhr.responseType = request.responseType;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (request.abortSignal) {
|
|
91
|
+
request.abortSignal.onabort = function () {
|
|
92
|
+
xhr.abort();
|
|
93
|
+
reject(new Errors.AbortError());
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (request.timeout) {
|
|
98
|
+
xhr.timeout = request.timeout;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
xhr.onload = function () {
|
|
102
|
+
if (request.abortSignal) {
|
|
103
|
+
request.abortSignal.onabort = null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
107
|
+
resolve(new HttpClient.HttpResponse(xhr.status, xhr.statusText, xhr.response || xhr.responseText));
|
|
108
|
+
} else {
|
|
109
|
+
reject(new Errors.HttpError(xhr.response || xhr.responseText || xhr.statusText, xhr.status));
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
xhr.onerror = function () {
|
|
114
|
+
_this2._logger.log(ILogger.LogLevel.Warning, "Error from HTTP request. ".concat(xhr.status, ": ").concat(xhr.statusText, "."));
|
|
115
|
+
|
|
116
|
+
reject(new Errors.HttpError(xhr.statusText, xhr.status));
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
xhr.ontimeout = function () {
|
|
120
|
+
_this2._logger.log(ILogger.LogLevel.Warning, "Timeout from HTTP request.");
|
|
121
|
+
|
|
122
|
+
reject(new Errors.TimeoutError());
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
xhr.send(request.content || "");
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}]);
|
|
129
|
+
|
|
130
|
+
return XhrHttpClient;
|
|
131
|
+
}(HttpClient.HttpClient);
|
|
132
|
+
|
|
133
|
+
exports.XhrHttpClient = XhrHttpClient;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
+
|
|
5
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
+
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
|
|
9
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
10
|
+
|
|
11
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
12
|
+
|
|
13
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
+
|
|
15
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
16
|
+
|
|
17
|
+
Object.defineProperty(exports, '__esModule', {
|
|
18
|
+
value: true
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
var _tslib = require('../../../_virtual/_tslib.js');
|
|
22
|
+
|
|
23
|
+
var React = require('react');
|
|
24
|
+
|
|
25
|
+
var echoSearch = require('@equinor/echo-search');
|
|
26
|
+
|
|
27
|
+
var EchoUtils = require('@equinor/echo-utils');
|
|
28
|
+
|
|
29
|
+
require('@equinor/eds-core-react');
|
|
30
|
+
|
|
31
|
+
require('@equinor/echo-components');
|
|
32
|
+
|
|
33
|
+
require('./components/connectorForIMSTag/IMSConnector.module.css.js');
|
|
34
|
+
|
|
35
|
+
require('@equinor/echo-core');
|
|
36
|
+
|
|
37
|
+
require('../../services/api/api-manager.js');
|
|
38
|
+
|
|
39
|
+
var RealTimeContextButton = require('./components/contextButton/RealTimeContextButton.js');
|
|
40
|
+
|
|
41
|
+
require('./components/contextPopover/Popover.module.css.js');
|
|
42
|
+
|
|
43
|
+
var RealTimeIMSDropdown = require('./components/IMSDropdown/RealTimeIMSDropdown.js');
|
|
44
|
+
|
|
45
|
+
function _interopDefaultLegacy(e) {
|
|
46
|
+
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
47
|
+
'default': e
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
52
|
+
|
|
53
|
+
var EchoUtils__default = /*#__PURE__*/_interopDefaultLegacy(EchoUtils);
|
|
54
|
+
/**
|
|
55
|
+
* ContextMenu button for displaying Real-Time-Data from connected sensors.
|
|
56
|
+
* @param {RTDProps} {
|
|
57
|
+
* tagNo: The tagNo to check for connected IMS tags.
|
|
58
|
+
* onOpen: Optional callback for whenever RTD popover is being opened
|
|
59
|
+
* }
|
|
60
|
+
* @return {*}
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
function RealTimePopoverButton(_ref) {
|
|
65
|
+
var _this = this;
|
|
66
|
+
|
|
67
|
+
var tagNo = _ref.tagNo,
|
|
68
|
+
onOpen = _ref.onOpen;
|
|
69
|
+
|
|
70
|
+
var _React$useState = React.useState(false),
|
|
71
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
72
|
+
isVisible = _React$useState2[0],
|
|
73
|
+
setIsVisible = _React$useState2[1];
|
|
74
|
+
|
|
75
|
+
var _React$useState3 = React.useState([]),
|
|
76
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
77
|
+
imsFields = _React$useState4[0],
|
|
78
|
+
setImsFields = _React$useState4[1];
|
|
79
|
+
|
|
80
|
+
EchoUtils__default["default"].Hooks.useEffectAsync(function (signal) {
|
|
81
|
+
return _tslib.__awaiter(_this, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
82
|
+
var response, _imsFields;
|
|
83
|
+
|
|
84
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
85
|
+
while (1) {
|
|
86
|
+
switch (_context.prev = _context.next) {
|
|
87
|
+
case 0:
|
|
88
|
+
_context.next = 2;
|
|
89
|
+
return echoSearch.Search.Tags.getTagDetailsAsync(tagNo);
|
|
90
|
+
|
|
91
|
+
case 2:
|
|
92
|
+
response = _context.sent;
|
|
93
|
+
|
|
94
|
+
if (response.value) {
|
|
95
|
+
_imsFields = response.value.additionalFields.filter(function (field) {
|
|
96
|
+
return field.type === 'IMS';
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
if (!signal.aborted) {
|
|
100
|
+
// we have IMS sensors connected to this tag.
|
|
101
|
+
if (_imsFields.length > 0) {
|
|
102
|
+
setIsVisible(true);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
setImsFields(_imsFields);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return _context.abrupt("return", function () {
|
|
110
|
+
if (!signal.aborted) {
|
|
111
|
+
setIsVisible(false);
|
|
112
|
+
setImsFields([]);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
case 5:
|
|
117
|
+
case "end":
|
|
118
|
+
return _context.stop();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}, _callee);
|
|
122
|
+
}));
|
|
123
|
+
}, [tagNo]);
|
|
124
|
+
|
|
125
|
+
if (!isVisible) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return /*#__PURE__*/React__default["default"].createElement(RealTimeContextButton.RealTimeContextButton, {
|
|
130
|
+
onOpen: onOpen
|
|
131
|
+
}, /*#__PURE__*/React__default["default"].createElement(RealTimeIMSDropdown.RealTimeIMSDropdown, {
|
|
132
|
+
imsFields: imsFields
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
exports.RealTimePopoverButton = RealTimePopoverButton;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
+
|
|
5
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
+
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
|
|
9
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
10
|
+
|
|
11
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
12
|
+
|
|
13
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
+
|
|
15
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
16
|
+
|
|
17
|
+
Object.defineProperty(exports, '__esModule', {
|
|
18
|
+
value: true
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
var React = require('react');
|
|
22
|
+
|
|
23
|
+
var edsCoreReact = require('@equinor/eds-core-react');
|
|
24
|
+
|
|
25
|
+
var RealTimeConnectorForIMSTag = require('../connectorForIMSTag/RealTimeConnectorForIMSTag.js');
|
|
26
|
+
|
|
27
|
+
var RealTimeIMSDropdown_module = require('./RealTimeIMSDropdown.module.css.js');
|
|
28
|
+
|
|
29
|
+
function _interopDefaultLegacy(e) {
|
|
30
|
+
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
31
|
+
'default': e
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
36
|
+
|
|
37
|
+
function RealTimeIMSDropdown(_ref) {
|
|
38
|
+
var imsFields = _ref.imsFields;
|
|
39
|
+
|
|
40
|
+
var _a;
|
|
41
|
+
|
|
42
|
+
var _React$useState = React.useState(undefined),
|
|
43
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
44
|
+
selected = _React$useState2[0],
|
|
45
|
+
setSelected = _React$useState2[1];
|
|
46
|
+
|
|
47
|
+
var items = React.useMemo(function () {
|
|
48
|
+
return imsFields.map(function (ims) {
|
|
49
|
+
return ims.description;
|
|
50
|
+
});
|
|
51
|
+
}, [imsFields]);
|
|
52
|
+
|
|
53
|
+
function onSelect(item) {
|
|
54
|
+
var selected;
|
|
55
|
+
|
|
56
|
+
if (item) {
|
|
57
|
+
selected = imsFields.find(function (ims) {
|
|
58
|
+
return ims.description === item;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
setSelected(selected);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
66
|
+
className: RealTimeIMSDropdown_module["default"].popoverContent
|
|
67
|
+
}, /*#__PURE__*/React__default["default"].createElement(edsCoreReact.SingleSelect, {
|
|
68
|
+
className: RealTimeIMSDropdown_module["default"].select,
|
|
69
|
+
label: "Select sensor",
|
|
70
|
+
items: items,
|
|
71
|
+
handleSelectedItemChange: function handleSelectedItemChange(_ref2) {
|
|
72
|
+
var selectedItem = _ref2.selectedItem;
|
|
73
|
+
return onSelect(selectedItem);
|
|
74
|
+
},
|
|
75
|
+
selectedOption: (_a = selected === null || selected === void 0 ? void 0 : selected.description) !== null && _a !== void 0 ? _a : ''
|
|
76
|
+
}), selected && /*#__PURE__*/React__default["default"].createElement(RealTimeConnectorForIMSTag.RealTimeConnectorForIMSTag, {
|
|
77
|
+
ims: selected.value
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
exports.RealTimeIMSDropdown = RealTimeIMSDropdown;
|
package/dist/src/components/realTimeData/components/IMSDropdown/RealTimeIMSDropdown.module.css.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var styleInject_es = require('../../../../../node_modules/style-inject/dist/style-inject.es.js');
|
|
8
|
+
|
|
9
|
+
var css_248z = ".RealTimeIMSDropdown-module_popoverContent__9-qpz{align-items:center;background-color:#fff;border-color:grey;border-radius:4px;box-shadow:0 1px 3px rgba(0,0,0,.12),0 1px 2px rgba(0,0,0,.24);display:flex;flex-direction:column;margin-top:1rem;padding:1rem;width:100%}.RealTimeIMSDropdown-module_select__i9xTJ{width:100%}";
|
|
10
|
+
var style = {
|
|
11
|
+
"popoverContent": "RealTimeIMSDropdown-module_popoverContent__9-qpz",
|
|
12
|
+
"select": "RealTimeIMSDropdown-module_select__i9xTJ"
|
|
13
|
+
};
|
|
14
|
+
styleInject_es["default"](css_248z);
|
|
15
|
+
exports["default"] = style;
|
package/dist/src/components/realTimeData/components/connectorForIMSTag/IMSConnector.module.css.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var styleInject_es = require('../../../../../node_modules/style-inject/dist/style-inject.es.js');
|
|
8
|
+
|
|
9
|
+
var css_248z = ".IMSConnector-module_wrapper__CvKvm{align-items:center;display:grid;gap:1rem;grid-row:1fr;grid-template-columns:1fr 1fr;justify-items:center;margin-top:1rem}.IMSConnector-module_experimentalWarning__7Vv3z{grid-template-columns:auto 1fr;margin-top:0}.IMSConnector-module_message__w8j1M{margin-top:1rem;width:100%}";
|
|
10
|
+
var style = {
|
|
11
|
+
"wrapper": "IMSConnector-module_wrapper__CvKvm",
|
|
12
|
+
"experimentalWarning": "IMSConnector-module_experimentalWarning__7Vv3z IMSConnector-module_wrapper__CvKvm",
|
|
13
|
+
"message": "IMSConnector-module_message__w8j1M"
|
|
14
|
+
};
|
|
15
|
+
styleInject_es["default"](css_248z);
|
|
16
|
+
exports["default"] = style;
|