@equinor/echo-framework 0.7.3 → 0.7.6

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.
Files changed (78) hide show
  1. package/dist/__tests__/realTimeDataHooks.test.d.ts +1 -0
  2. package/dist/__tests__/realTimeDataUtils.test.d.ts +1 -0
  3. package/dist/_virtual/_tslib.js +14 -0
  4. package/dist/components/errorBoundary/errorBoundary.d.ts +1 -0
  5. package/dist/components/index.d.ts +1 -0
  6. package/dist/components/panel/corePanelLeft.d.ts +4 -1
  7. package/dist/components/panel/corePanelRight.d.ts +4 -1
  8. package/dist/components/realTimeData/RealTimePopoverButton.d.ts +18 -0
  9. package/dist/components/realTimeData/components/IMSDropdown/RealTimeIMSDropdown.d.ts +7 -0
  10. package/dist/components/realTimeData/components/IMSDropdown/index.d.ts +1 -0
  11. package/dist/components/realTimeData/components/connectorForIMSTag/RealTimeConnectorForIMSTag.d.ts +6 -0
  12. package/dist/components/realTimeData/components/connectorForIMSTag/index.d.ts +1 -0
  13. package/dist/components/realTimeData/components/contextButton/RealTimeContextButton.d.ts +6 -0
  14. package/dist/components/realTimeData/components/contextButton/index.d.ts +1 -0
  15. package/dist/components/realTimeData/components/contextPopover/Popover.d.ts +6 -0
  16. package/dist/components/realTimeData/components/contextPopover/index.d.ts +1 -0
  17. package/dist/components/realTimeData/components/index.d.ts +4 -0
  18. package/dist/components/realTimeData/hooks/index.d.ts +3 -0
  19. package/dist/components/realTimeData/hooks/useRealTimeHub.d.ts +13 -0
  20. package/dist/components/realTimeData/hooks/useSignalR.d.ts +9 -0
  21. package/dist/components/realTimeData/hooks/useSignalRListener.d.ts +4 -0
  22. package/dist/components/realTimeData/index.d.ts +1 -0
  23. package/dist/coreApplication/EchoBarComponent.d.ts +6 -0
  24. package/dist/coreApplication/EchoContent.d.ts +1 -0
  25. package/dist/coreApplication/index.d.ts +1 -0
  26. package/dist/hooks/index.d.ts +1 -0
  27. package/dist/hooks/useIsLandscape.d.ts +1 -0
  28. package/dist/index.d.ts +2 -1
  29. package/dist/node_modules/@microsoft/signalr/dist/esm/AbortController.js +54 -0
  30. package/dist/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js +96 -0
  31. package/dist/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js +47 -0
  32. package/dist/node_modules/@microsoft/signalr/dist/esm/Errors.js +287 -0
  33. package/dist/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js +281 -0
  34. package/dist/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js +86 -0
  35. package/dist/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js +20 -0
  36. package/dist/node_modules/@microsoft/signalr/dist/esm/HttpClient.js +82 -0
  37. package/dist/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js +1167 -0
  38. package/dist/node_modules/@microsoft/signalr/dist/esm/HubConnection.js +1342 -0
  39. package/dist/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js +165 -0
  40. package/dist/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js +33 -0
  41. package/dist/node_modules/@microsoft/signalr/dist/esm/ILogger.js +37 -0
  42. package/dist/node_modules/@microsoft/signalr/dist/esm/ITransport.js +37 -0
  43. package/dist/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js +179 -0
  44. package/dist/node_modules/@microsoft/signalr/dist/esm/Loggers.js +35 -0
  45. package/dist/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js +444 -0
  46. package/dist/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js +235 -0
  47. package/dist/node_modules/@microsoft/signalr/dist/esm/Subject.js +99 -0
  48. package/dist/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js +45 -0
  49. package/dist/node_modules/@microsoft/signalr/dist/esm/Utils.js +433 -0
  50. package/dist/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js +263 -0
  51. package/dist/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js +133 -0
  52. package/dist/services/api/api-realtimedata.d.ts +2 -0
  53. package/dist/src/components/containers/layout.module.css.js +4 -1
  54. package/dist/src/components/containers/layouts.js +38 -8
  55. package/dist/src/components/panel/corePanelLeft.js +5 -2
  56. package/dist/src/components/panel/corePanelLeft.module.css.js +1 -1
  57. package/dist/src/components/panel/corePanelRight.js +4 -2
  58. package/dist/src/components/panel/corePanelRight.module.css.js +1 -1
  59. package/dist/src/components/projectSelector/ProcosysProjectSelector.js +1 -1
  60. package/dist/src/components/realTimeData/RealTimePopoverButton.js +136 -0
  61. package/dist/src/components/realTimeData/components/IMSDropdown/RealTimeIMSDropdown.js +81 -0
  62. package/dist/src/components/realTimeData/components/IMSDropdown/RealTimeIMSDropdown.module.css.js +15 -0
  63. package/dist/src/components/realTimeData/components/connectorForIMSTag/IMSConnector.module.css.js +16 -0
  64. package/dist/src/components/realTimeData/components/connectorForIMSTag/RealTimeConnectorForIMSTag.js +110 -0
  65. package/dist/src/components/realTimeData/components/contextButton/RealTimeContextButton.js +75 -0
  66. package/dist/src/components/realTimeData/components/contextButton/RealTimeContextButton.module.css.js +15 -0
  67. package/dist/src/components/realTimeData/components/contextPopover/Popover.js +37 -0
  68. package/dist/src/components/realTimeData/components/contextPopover/Popover.module.css.js +15 -0
  69. package/dist/src/components/realTimeData/hooks/useRealTimeHub.js +122 -0
  70. package/dist/src/components/realTimeData/hooks/useSignalR.js +159 -0
  71. package/dist/src/components/realTimeData/hooks/useSignalRListener.js +22 -0
  72. package/dist/src/coreApplication/EchoBarComponent.js +113 -0
  73. package/dist/src/coreApplication/EchoContent.js +7 -2
  74. package/dist/src/hooks/useIsLandscape.js +52 -0
  75. package/dist/src/index.js +9 -0
  76. package/dist/src/services/api/api-realtimedata.js +42 -0
  77. package/dist/types/realtimedata.d.ts +18 -0
  78. package/package.json +30 -27
@@ -0,0 +1,287 @@
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 _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); } }
6
+
7
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
8
+
9
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
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 _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); }; }
14
+
15
+ 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); }
16
+
17
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
18
+
19
+ function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
20
+
21
+ function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
22
+
23
+ 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; } }
24
+
25
+ function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
26
+
27
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
28
+
29
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
30
+
31
+ Object.defineProperty(exports, '__esModule', {
32
+ value: true
33
+ }); // Licensed to the .NET Foundation under one or more agreements.
34
+ // The .NET Foundation licenses this file to you under the MIT license.
35
+
36
+ /** Error thrown when an HTTP request fails. */
37
+
38
+ var HttpError = /*#__PURE__*/function (_Error) {
39
+ _inherits(HttpError, _Error);
40
+
41
+ var _super = _createSuper(HttpError);
42
+
43
+ /** Constructs a new instance of {@link @microsoft/signalr.HttpError}.
44
+ *
45
+ * @param {string} errorMessage A descriptive error message.
46
+ * @param {number} statusCode The HTTP status code represented by this error.
47
+ */
48
+ function HttpError(errorMessage, statusCode) {
49
+ var _this;
50
+
51
+ _classCallCheck(this, HttpError);
52
+
53
+ var trueProto = (this instanceof HttpError ? this.constructor : void 0).prototype;
54
+ _this = _super.call(this, "".concat(errorMessage, ": Status code '").concat(statusCode, "'"));
55
+ _this.statusCode = statusCode; // Workaround issue in Typescript compiler
56
+ // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
57
+
58
+ _this.__proto__ = trueProto;
59
+ return _this;
60
+ }
61
+
62
+ return _createClass(HttpError);
63
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
64
+ /** Error thrown when a timeout elapses. */
65
+
66
+
67
+ var TimeoutError = /*#__PURE__*/function (_Error2) {
68
+ _inherits(TimeoutError, _Error2);
69
+
70
+ var _super2 = _createSuper(TimeoutError);
71
+
72
+ /** Constructs a new instance of {@link @microsoft/signalr.TimeoutError}.
73
+ *
74
+ * @param {string} errorMessage A descriptive error message.
75
+ */
76
+ function TimeoutError() {
77
+ var _this2;
78
+
79
+ var errorMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "A timeout occurred.";
80
+
81
+ _classCallCheck(this, TimeoutError);
82
+
83
+ var trueProto = (this instanceof TimeoutError ? this.constructor : void 0).prototype;
84
+ _this2 = _super2.call(this, errorMessage); // Workaround issue in Typescript compiler
85
+ // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
86
+
87
+ _this2.__proto__ = trueProto;
88
+ return _this2;
89
+ }
90
+
91
+ return _createClass(TimeoutError);
92
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
93
+ /** Error thrown when an action is aborted. */
94
+
95
+
96
+ var AbortError = /*#__PURE__*/function (_Error3) {
97
+ _inherits(AbortError, _Error3);
98
+
99
+ var _super3 = _createSuper(AbortError);
100
+
101
+ /** Constructs a new instance of {@link AbortError}.
102
+ *
103
+ * @param {string} errorMessage A descriptive error message.
104
+ */
105
+ function AbortError() {
106
+ var _this3;
107
+
108
+ var errorMessage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "An abort occurred.";
109
+
110
+ _classCallCheck(this, AbortError);
111
+
112
+ var trueProto = (this instanceof AbortError ? this.constructor : void 0).prototype;
113
+ _this3 = _super3.call(this, errorMessage); // Workaround issue in Typescript compiler
114
+ // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
115
+
116
+ _this3.__proto__ = trueProto;
117
+ return _this3;
118
+ }
119
+
120
+ return _createClass(AbortError);
121
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
122
+ /** Error thrown when the selected transport is unsupported by the browser. */
123
+
124
+ /** @private */
125
+
126
+
127
+ var UnsupportedTransportError = /*#__PURE__*/function (_Error4) {
128
+ _inherits(UnsupportedTransportError, _Error4);
129
+
130
+ var _super4 = _createSuper(UnsupportedTransportError);
131
+
132
+ /** Constructs a new instance of {@link @microsoft/signalr.UnsupportedTransportError}.
133
+ *
134
+ * @param {string} message A descriptive error message.
135
+ * @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occured on.
136
+ */
137
+ function UnsupportedTransportError(message, transport) {
138
+ var _this4;
139
+
140
+ _classCallCheck(this, UnsupportedTransportError);
141
+
142
+ var trueProto = (this instanceof UnsupportedTransportError ? this.constructor : void 0).prototype;
143
+ _this4 = _super4.call(this, message);
144
+ _this4.transport = transport;
145
+ _this4.errorType = 'UnsupportedTransportError'; // Workaround issue in Typescript compiler
146
+ // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
147
+
148
+ _this4.__proto__ = trueProto;
149
+ return _this4;
150
+ }
151
+
152
+ return _createClass(UnsupportedTransportError);
153
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
154
+ /** Error thrown when the selected transport is disabled by the browser. */
155
+
156
+ /** @private */
157
+
158
+
159
+ var DisabledTransportError = /*#__PURE__*/function (_Error5) {
160
+ _inherits(DisabledTransportError, _Error5);
161
+
162
+ var _super5 = _createSuper(DisabledTransportError);
163
+
164
+ /** Constructs a new instance of {@link @microsoft/signalr.DisabledTransportError}.
165
+ *
166
+ * @param {string} message A descriptive error message.
167
+ * @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occured on.
168
+ */
169
+ function DisabledTransportError(message, transport) {
170
+ var _this5;
171
+
172
+ _classCallCheck(this, DisabledTransportError);
173
+
174
+ var trueProto = (this instanceof DisabledTransportError ? this.constructor : void 0).prototype;
175
+ _this5 = _super5.call(this, message);
176
+ _this5.transport = transport;
177
+ _this5.errorType = 'DisabledTransportError'; // Workaround issue in Typescript compiler
178
+ // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
179
+
180
+ _this5.__proto__ = trueProto;
181
+ return _this5;
182
+ }
183
+
184
+ return _createClass(DisabledTransportError);
185
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
186
+ /** Error thrown when the selected transport cannot be started. */
187
+
188
+ /** @private */
189
+
190
+
191
+ var FailedToStartTransportError = /*#__PURE__*/function (_Error6) {
192
+ _inherits(FailedToStartTransportError, _Error6);
193
+
194
+ var _super6 = _createSuper(FailedToStartTransportError);
195
+
196
+ /** Constructs a new instance of {@link @microsoft/signalr.FailedToStartTransportError}.
197
+ *
198
+ * @param {string} message A descriptive error message.
199
+ * @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occured on.
200
+ */
201
+ function FailedToStartTransportError(message, transport) {
202
+ var _this6;
203
+
204
+ _classCallCheck(this, FailedToStartTransportError);
205
+
206
+ var trueProto = (this instanceof FailedToStartTransportError ? this.constructor : void 0).prototype;
207
+ _this6 = _super6.call(this, message);
208
+ _this6.transport = transport;
209
+ _this6.errorType = 'FailedToStartTransportError'; // Workaround issue in Typescript compiler
210
+ // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
211
+
212
+ _this6.__proto__ = trueProto;
213
+ return _this6;
214
+ }
215
+
216
+ return _createClass(FailedToStartTransportError);
217
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
218
+ /** Error thrown when the negotiation with the server failed to complete. */
219
+
220
+ /** @private */
221
+
222
+
223
+ var FailedToNegotiateWithServerError = /*#__PURE__*/function (_Error7) {
224
+ _inherits(FailedToNegotiateWithServerError, _Error7);
225
+
226
+ var _super7 = _createSuper(FailedToNegotiateWithServerError);
227
+
228
+ /** Constructs a new instance of {@link @microsoft/signalr.FailedToNegotiateWithServerError}.
229
+ *
230
+ * @param {string} message A descriptive error message.
231
+ */
232
+ function FailedToNegotiateWithServerError(message) {
233
+ var _this7;
234
+
235
+ _classCallCheck(this, FailedToNegotiateWithServerError);
236
+
237
+ var trueProto = (this instanceof FailedToNegotiateWithServerError ? this.constructor : void 0).prototype;
238
+ _this7 = _super7.call(this, message);
239
+ _this7.errorType = 'FailedToNegotiateWithServerError'; // Workaround issue in Typescript compiler
240
+ // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
241
+
242
+ _this7.__proto__ = trueProto;
243
+ return _this7;
244
+ }
245
+
246
+ return _createClass(FailedToNegotiateWithServerError);
247
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
248
+ /** Error thrown when multiple errors have occured. */
249
+
250
+ /** @private */
251
+
252
+
253
+ var AggregateErrors = /*#__PURE__*/function (_Error8) {
254
+ _inherits(AggregateErrors, _Error8);
255
+
256
+ var _super8 = _createSuper(AggregateErrors);
257
+
258
+ /** Constructs a new instance of {@link @microsoft/signalr.AggregateErrors}.
259
+ *
260
+ * @param {string} message A descriptive error message.
261
+ * @param {Error[]} innerErrors The collection of errors this error is aggregating.
262
+ */
263
+ function AggregateErrors(message, innerErrors) {
264
+ var _this8;
265
+
266
+ _classCallCheck(this, AggregateErrors);
267
+
268
+ var trueProto = (this instanceof AggregateErrors ? this.constructor : void 0).prototype;
269
+ _this8 = _super8.call(this, message);
270
+ _this8.innerErrors = innerErrors; // Workaround issue in Typescript compiler
271
+ // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
272
+
273
+ _this8.__proto__ = trueProto;
274
+ return _this8;
275
+ }
276
+
277
+ return _createClass(AggregateErrors);
278
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
279
+
280
+ exports.AbortError = AbortError;
281
+ exports.AggregateErrors = AggregateErrors;
282
+ exports.DisabledTransportError = DisabledTransportError;
283
+ exports.FailedToNegotiateWithServerError = FailedToNegotiateWithServerError;
284
+ exports.FailedToStartTransportError = FailedToStartTransportError;
285
+ exports.HttpError = HttpError;
286
+ exports.TimeoutError = TimeoutError;
287
+ exports.UnsupportedTransportError = UnsupportedTransportError;
@@ -0,0 +1,281 @@
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 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; }
6
+
7
+ 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; }
8
+
9
+ 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; }
10
+
11
+ 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); } }
12
+
13
+ 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); }); }; }
14
+
15
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16
+
17
+ 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); } }
18
+
19
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
20
+
21
+ 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); }
22
+
23
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
24
+
25
+ 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); }; }
26
+
27
+ 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); }
28
+
29
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
30
+
31
+ 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; } }
32
+
33
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
34
+
35
+ Object.defineProperty(exports, '__esModule', {
36
+ value: true
37
+ });
38
+
39
+ var Errors = require('./Errors.js');
40
+
41
+ var HttpClient = require('./HttpClient.js');
42
+
43
+ var ILogger = require('./ILogger.js');
44
+
45
+ var Utils = require('./Utils.js'); // Licensed to the .NET Foundation under one or more agreements.
46
+
47
+
48
+ var FetchHttpClient = /*#__PURE__*/function (_HttpClient$HttpClien) {
49
+ _inherits(FetchHttpClient, _HttpClient$HttpClien);
50
+
51
+ var _super = _createSuper(FetchHttpClient);
52
+
53
+ function FetchHttpClient(logger) {
54
+ var _this;
55
+
56
+ _classCallCheck(this, FetchHttpClient);
57
+
58
+ _this = _super.call(this);
59
+ _this._logger = logger;
60
+
61
+ if (typeof fetch === "undefined") {
62
+ // In order to ignore the dynamic require in webpack builds we need to do this magic
63
+ // @ts-ignore: TS doesn't know about these names
64
+ var requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : require; // Cookies aren't automatically handled in Node so we need to add a CookieJar to preserve cookies across requests
65
+
66
+ _this._jar = new (requireFunc("tough-cookie").CookieJar)();
67
+ _this._fetchType = requireFunc("node-fetch"); // node-fetch doesn't have a nice API for getting and setting cookies
68
+ // fetch-cookie will wrap a fetch implementation with a default CookieJar or a provided one
69
+
70
+ _this._fetchType = requireFunc("fetch-cookie")(_this._fetchType, _this._jar);
71
+ } else {
72
+ _this._fetchType = fetch.bind(Utils.getGlobalThis());
73
+ }
74
+
75
+ if (typeof AbortController === "undefined") {
76
+ // In order to ignore the dynamic require in webpack builds we need to do this magic
77
+ // @ts-ignore: TS doesn't know about these names
78
+ var _requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : require; // Node needs EventListener methods on AbortController which our custom polyfill doesn't provide
79
+
80
+
81
+ _this._abortControllerType = _requireFunc("abort-controller");
82
+ } else {
83
+ _this._abortControllerType = AbortController;
84
+ }
85
+
86
+ return _this;
87
+ }
88
+ /** @inheritDoc */
89
+
90
+
91
+ _createClass(FetchHttpClient, [{
92
+ key: "send",
93
+ value: function () {
94
+ var _send = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(request) {
95
+ var _this2 = this;
96
+
97
+ var abortController, error, timeoutId, msTimeout, response, errorMessage, content, payload;
98
+ return regeneratorRuntime.wrap(function _callee$(_context) {
99
+ while (1) {
100
+ switch (_context.prev = _context.next) {
101
+ case 0:
102
+ if (!(request.abortSignal && request.abortSignal.aborted)) {
103
+ _context.next = 2;
104
+ break;
105
+ }
106
+
107
+ throw new Errors.AbortError();
108
+
109
+ case 2:
110
+ if (request.method) {
111
+ _context.next = 4;
112
+ break;
113
+ }
114
+
115
+ throw new Error("No method defined.");
116
+
117
+ case 4:
118
+ if (request.url) {
119
+ _context.next = 6;
120
+ break;
121
+ }
122
+
123
+ throw new Error("No url defined.");
124
+
125
+ case 6:
126
+ abortController = new this._abortControllerType();
127
+
128
+ // Hook our abortSignal into the abort controller
129
+ if (request.abortSignal) {
130
+ request.abortSignal.onabort = function () {
131
+ abortController.abort();
132
+ error = new Errors.AbortError();
133
+ };
134
+ } // If a timeout has been passed in, setup a timeout to call abort
135
+ // Type needs to be any to fit window.setTimeout and NodeJS.setTimeout
136
+
137
+
138
+ timeoutId = null;
139
+
140
+ if (request.timeout) {
141
+ msTimeout = request.timeout;
142
+ timeoutId = setTimeout(function () {
143
+ abortController.abort();
144
+
145
+ _this2._logger.log(ILogger.LogLevel.Warning, "Timeout from HTTP request.");
146
+
147
+ error = new Errors.TimeoutError();
148
+ }, msTimeout);
149
+ }
150
+
151
+ _context.prev = 10;
152
+ _context.next = 13;
153
+ return this._fetchType(request.url, {
154
+ body: request.content,
155
+ cache: "no-cache",
156
+ credentials: request.withCredentials === true ? "include" : "same-origin",
157
+ headers: _objectSpread({
158
+ "Content-Type": "text/plain;charset=UTF-8",
159
+ "X-Requested-With": "XMLHttpRequest"
160
+ }, request.headers),
161
+ method: request.method,
162
+ mode: "cors",
163
+ redirect: "follow",
164
+ signal: abortController.signal
165
+ });
166
+
167
+ case 13:
168
+ response = _context.sent;
169
+ _context.next = 22;
170
+ break;
171
+
172
+ case 16:
173
+ _context.prev = 16;
174
+ _context.t0 = _context["catch"](10);
175
+
176
+ if (!error) {
177
+ _context.next = 20;
178
+ break;
179
+ }
180
+
181
+ throw error;
182
+
183
+ case 20:
184
+ this._logger.log(ILogger.LogLevel.Warning, "Error from HTTP request. ".concat(_context.t0, "."));
185
+
186
+ throw _context.t0;
187
+
188
+ case 22:
189
+ _context.prev = 22;
190
+
191
+ if (timeoutId) {
192
+ clearTimeout(timeoutId);
193
+ }
194
+
195
+ if (request.abortSignal) {
196
+ request.abortSignal.onabort = null;
197
+ }
198
+
199
+ return _context.finish(22);
200
+
201
+ case 26:
202
+ if (response.ok) {
203
+ _context.next = 31;
204
+ break;
205
+ }
206
+
207
+ _context.next = 29;
208
+ return deserializeContent(response, "text");
209
+
210
+ case 29:
211
+ errorMessage = _context.sent;
212
+ throw new Errors.HttpError(errorMessage || response.statusText, response.status);
213
+
214
+ case 31:
215
+ content = deserializeContent(response, request.responseType);
216
+ _context.next = 34;
217
+ return content;
218
+
219
+ case 34:
220
+ payload = _context.sent;
221
+ return _context.abrupt("return", new HttpClient.HttpResponse(response.status, response.statusText, payload));
222
+
223
+ case 36:
224
+ case "end":
225
+ return _context.stop();
226
+ }
227
+ }
228
+ }, _callee, this, [[10, 16, 22, 26]]);
229
+ }));
230
+
231
+ function send(_x) {
232
+ return _send.apply(this, arguments);
233
+ }
234
+
235
+ return send;
236
+ }()
237
+ }, {
238
+ key: "getCookieString",
239
+ value: function getCookieString(url) {
240
+ var cookies = "";
241
+
242
+ if (Utils.Platform.isNode && this._jar) {
243
+ // @ts-ignore: unused variable
244
+ this._jar.getCookies(url, function (e, c) {
245
+ return cookies = c.join("; ");
246
+ });
247
+ }
248
+
249
+ return cookies;
250
+ }
251
+ }]);
252
+
253
+ return FetchHttpClient;
254
+ }(HttpClient.HttpClient);
255
+
256
+ function deserializeContent(response, responseType) {
257
+ var content;
258
+
259
+ switch (responseType) {
260
+ case "arraybuffer":
261
+ content = response.arrayBuffer();
262
+ break;
263
+
264
+ case "text":
265
+ content = response.text();
266
+ break;
267
+
268
+ case "blob":
269
+ case "document":
270
+ case "json":
271
+ throw new Error("".concat(responseType, " is not supported."));
272
+
273
+ default:
274
+ content = response.text();
275
+ break;
276
+ }
277
+
278
+ return content;
279
+ }
280
+
281
+ exports.FetchHttpClient = FetchHttpClient;
@@ -0,0 +1,86 @@
1
+ 'use strict';
2
+
3
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
+
5
+ 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); } }
6
+
7
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
8
+
9
+ Object.defineProperty(exports, '__esModule', {
10
+ value: true
11
+ });
12
+
13
+ var TextMessageFormat = require('./TextMessageFormat.js');
14
+
15
+ var Utils = require('./Utils.js'); // Licensed to the .NET Foundation under one or more agreements.
16
+
17
+ /** @private */
18
+
19
+
20
+ var HandshakeProtocol = /*#__PURE__*/function () {
21
+ function HandshakeProtocol() {
22
+ _classCallCheck(this, HandshakeProtocol);
23
+ }
24
+
25
+ _createClass(HandshakeProtocol, [{
26
+ key: "writeHandshakeRequest",
27
+ value: // Handshake request is always JSON
28
+ function writeHandshakeRequest(handshakeRequest) {
29
+ return TextMessageFormat.TextMessageFormat.write(JSON.stringify(handshakeRequest));
30
+ }
31
+ }, {
32
+ key: "parseHandshakeResponse",
33
+ value: function parseHandshakeResponse(data) {
34
+ var messageData;
35
+ var remainingData;
36
+
37
+ if (Utils.isArrayBuffer(data)) {
38
+ // Format is binary but still need to read JSON text from handshake response
39
+ var binaryData = new Uint8Array(data);
40
+ var separatorIndex = binaryData.indexOf(TextMessageFormat.TextMessageFormat.RecordSeparatorCode);
41
+
42
+ if (separatorIndex === -1) {
43
+ throw new Error("Message is incomplete.");
44
+ } // content before separator is handshake response
45
+ // optional content after is additional messages
46
+
47
+
48
+ var responseLength = separatorIndex + 1;
49
+ messageData = String.fromCharCode.apply(null, Array.prototype.slice.call(binaryData.slice(0, responseLength)));
50
+ remainingData = binaryData.byteLength > responseLength ? binaryData.slice(responseLength).buffer : null;
51
+ } else {
52
+ var textData = data;
53
+
54
+ var _separatorIndex = textData.indexOf(TextMessageFormat.TextMessageFormat.RecordSeparator);
55
+
56
+ if (_separatorIndex === -1) {
57
+ throw new Error("Message is incomplete.");
58
+ } // content before separator is handshake response
59
+ // optional content after is additional messages
60
+
61
+
62
+ var _responseLength = _separatorIndex + 1;
63
+
64
+ messageData = textData.substring(0, _responseLength);
65
+ remainingData = textData.length > _responseLength ? textData.substring(_responseLength) : null;
66
+ } // At this point we should have just the single handshake message
67
+
68
+
69
+ var messages = TextMessageFormat.TextMessageFormat.parse(messageData);
70
+ var response = JSON.parse(messages[0]);
71
+
72
+ if (response.type) {
73
+ throw new Error("Expected a handshake response from the server.");
74
+ }
75
+
76
+ var responseMessage = response; // multiple messages could have arrived with handshake
77
+ // return additional data to be parsed as usual, or null if all parsed
78
+
79
+ return [remainingData, responseMessage];
80
+ }
81
+ }]);
82
+
83
+ return HandshakeProtocol;
84
+ }();
85
+
86
+ exports.HandshakeProtocol = HandshakeProtocol;
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ 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); } }
4
+
5
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
6
+
7
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
+
9
+ Object.defineProperty(exports, '__esModule', {
10
+ value: true
11
+ }); // Licensed to the .NET Foundation under one or more agreements.
12
+ // The .NET Foundation licenses this file to you under the MIT license.
13
+
14
+ var HeaderNames = /*#__PURE__*/_createClass(function HeaderNames() {
15
+ _classCallCheck(this, HeaderNames);
16
+ });
17
+
18
+ HeaderNames.Authorization = "Authorization";
19
+ HeaderNames.Cookie = "Cookie";
20
+ exports.HeaderNames = HeaderNames;