@launchdarkly/react-native-client-sdk 10.7.0 → 10.8.1-beta.1
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/CHANGELOG.md +20 -0
- package/dist/package.json +2 -3
- package/dist/src/MobileDataManager.d.ts +4 -4
- package/dist/src/MobileDataManager.d.ts.map +1 -1
- package/dist/src/MobileDataManager.js +18 -16
- package/dist/src/MobileDataManager.js.map +1 -1
- package/dist/src/RNStateDetector.js +6 -6
- package/dist/src/RNStateDetector.js.map +1 -1
- package/dist/src/ReactNativeLDClient.d.ts +1 -1
- package/dist/src/ReactNativeLDClient.d.ts.map +1 -1
- package/dist/src/ReactNativeLDClient.js +11 -3
- package/dist/src/ReactNativeLDClient.js.map +1 -1
- package/dist/src/fromExternal/react-native-sse/EventSource.d.ts +21 -21
- package/dist/src/fromExternal/react-native-sse/EventSource.d.ts.map +1 -1
- package/dist/src/fromExternal/react-native-sse/EventSource.js +104 -104
- package/dist/src/fromExternal/react-native-sse/EventSource.js.map +1 -1
- package/dist/src/platform/ConnectionManager.js +41 -41
- package/dist/src/platform/ConnectionManager.js.map +1 -1
- package/dist/src/platform/PlatformInfo.d.ts +2 -2
- package/dist/src/platform/PlatformInfo.d.ts.map +1 -1
- package/dist/src/platform/PlatformInfo.js +4 -4
- package/dist/src/platform/PlatformInfo.js.map +1 -1
- package/dist/src/platform/PlatformRequests.d.ts +2 -2
- package/dist/src/platform/PlatformRequests.d.ts.map +1 -1
- package/dist/src/platform/PlatformRequests.js +3 -3
- package/dist/src/platform/PlatformRequests.js.map +1 -1
- package/dist/src/platform/PlatformStorage.d.ts +2 -2
- package/dist/src/platform/PlatformStorage.d.ts.map +1 -1
- package/dist/src/platform/PlatformStorage.js +4 -4
- package/dist/src/platform/PlatformStorage.js.map +1 -1
- package/dist/src/platform/crypto/PlatformHasher.d.ts +1 -1
- package/dist/src/platform/crypto/PlatformHasher.d.ts.map +1 -1
- package/dist/src/platform/crypto/PlatformHasher.js +4 -4
- package/dist/src/platform/crypto/PlatformHasher.js.map +1 -1
- package/dist/src/polyfills/btoa.d.ts.map +1 -1
- package/dist/src/polyfills/btoa.js +3 -8
- package/dist/src/polyfills/btoa.js.map +1 -1
- package/dist/src/polyfills/toUtf8Array.d.ts +2 -0
- package/dist/src/polyfills/toUtf8Array.d.ts.map +1 -0
- package/dist/src/polyfills/toUtf8Array.js +48 -0
- package/dist/src/polyfills/toUtf8Array.js.map +1 -0
- package/package.json +2 -3
|
@@ -24,151 +24,151 @@ export default class EventSource {
|
|
|
24
24
|
this.CONNECTING = 0;
|
|
25
25
|
this.OPEN = 1;
|
|
26
26
|
this.CLOSED = 2;
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
29
|
-
this.
|
|
27
|
+
this._lastIndexProcessed = 0;
|
|
28
|
+
this._status = this.CONNECTING;
|
|
29
|
+
this._eventHandlers = {
|
|
30
30
|
open: [],
|
|
31
31
|
message: [],
|
|
32
32
|
error: [],
|
|
33
33
|
close: [],
|
|
34
34
|
};
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
35
|
+
this._xhr = new XMLHttpRequest();
|
|
36
|
+
this._initialRetryDelayMillis = 1000;
|
|
37
|
+
this._retryCount = 0;
|
|
38
38
|
const opts = Object.assign(Object.assign({}, defaultOptions), options);
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
41
|
-
this.
|
|
42
|
-
this.
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
48
|
-
this.
|
|
39
|
+
this._url = url;
|
|
40
|
+
this._method = opts.method;
|
|
41
|
+
this._timeout = opts.timeout;
|
|
42
|
+
this._withCredentials = opts.withCredentials;
|
|
43
|
+
this._headers = opts.headers;
|
|
44
|
+
this._body = opts.body;
|
|
45
|
+
this._retryAndHandleError = opts.retryAndHandleError;
|
|
46
|
+
this._initialRetryDelayMillis = opts.initialRetryDelayMillis;
|
|
47
|
+
this._logger = opts.logger;
|
|
48
|
+
this._tryConnect(true);
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
const delay = jitter(backoff(this.
|
|
52
|
-
this.
|
|
50
|
+
_getNextRetryDelay() {
|
|
51
|
+
const delay = jitter(backoff(this._initialRetryDelayMillis, this._retryCount));
|
|
52
|
+
this._retryCount += 1;
|
|
53
53
|
return delay;
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
_tryConnect(initialConnection = false) {
|
|
56
56
|
var _a, _b;
|
|
57
|
-
let delay = initialConnection ? 0 : this.
|
|
57
|
+
let delay = initialConnection ? 0 : this._getNextRetryDelay();
|
|
58
58
|
if (initialConnection) {
|
|
59
|
-
(_a = this.
|
|
59
|
+
(_a = this._logger) === null || _a === void 0 ? void 0 : _a.debug(`[EventSource] opening new connection.`);
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
62
|
-
(_b = this.
|
|
62
|
+
(_b = this._logger) === null || _b === void 0 ? void 0 : _b.debug(`[EventSource] Will open new connection in ${delay} ms.`);
|
|
63
63
|
this.dispatch('retry', { type: 'retry', delayMillis: delay });
|
|
64
64
|
}
|
|
65
|
-
this.
|
|
65
|
+
this._connectTimer = setTimeout(() => {
|
|
66
66
|
if (!initialConnection) {
|
|
67
67
|
this.close();
|
|
68
68
|
}
|
|
69
|
-
this.
|
|
69
|
+
this._open();
|
|
70
70
|
}, delay);
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
_open() {
|
|
73
73
|
try {
|
|
74
|
-
this.
|
|
75
|
-
this.
|
|
76
|
-
this.
|
|
77
|
-
if (this.
|
|
78
|
-
this.
|
|
74
|
+
this._lastIndexProcessed = 0;
|
|
75
|
+
this._status = this.CONNECTING;
|
|
76
|
+
this._xhr.open(this._method, this._url, true);
|
|
77
|
+
if (this._withCredentials) {
|
|
78
|
+
this._xhr.withCredentials = true;
|
|
79
79
|
}
|
|
80
|
-
this.
|
|
81
|
-
this.
|
|
82
|
-
this.
|
|
83
|
-
if (this.
|
|
84
|
-
Object.entries(this.
|
|
85
|
-
this.
|
|
80
|
+
this._xhr.setRequestHeader('Accept', 'text/event-stream');
|
|
81
|
+
this._xhr.setRequestHeader('Cache-Control', 'no-cache');
|
|
82
|
+
this._xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
|
83
|
+
if (this._headers) {
|
|
84
|
+
Object.entries(this._headers).forEach(([key, value]) => {
|
|
85
|
+
this._xhr.setRequestHeader(key, value);
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
-
if (typeof this.
|
|
89
|
-
this.
|
|
88
|
+
if (typeof this._lastEventId !== 'undefined') {
|
|
89
|
+
this._xhr.setRequestHeader('Last-Event-ID', this._lastEventId);
|
|
90
90
|
}
|
|
91
|
-
this.
|
|
92
|
-
this.
|
|
91
|
+
this._xhr.timeout = this._timeout;
|
|
92
|
+
this._xhr.onreadystatechange = () => {
|
|
93
93
|
var _a, _b, _c, _d;
|
|
94
|
-
if (this.
|
|
94
|
+
if (this._status === this.CLOSED) {
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
|
-
(_a = this.
|
|
98
|
-
if (this.
|
|
99
|
-
this.
|
|
97
|
+
(_a = this._logger) === null || _a === void 0 ? void 0 : _a.debug(`[EventSource][onreadystatechange] ReadyState: ${XMLReadyStateMap[this._xhr.readyState] || 'Unknown'}(${this._xhr.readyState}), status: ${this._xhr.status}`);
|
|
98
|
+
if (this._xhr.readyState !== XMLHttpRequest.DONE &&
|
|
99
|
+
this._xhr.readyState !== XMLHttpRequest.LOADING) {
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
|
-
if (this.
|
|
103
|
-
if (this.
|
|
104
|
-
this.
|
|
105
|
-
this.
|
|
102
|
+
if (this._xhr.status >= 200 && this._xhr.status < 400) {
|
|
103
|
+
if (this._status === this.CONNECTING) {
|
|
104
|
+
this._retryCount = 0;
|
|
105
|
+
this._status = this.OPEN;
|
|
106
106
|
this.dispatch('open', { type: 'open' });
|
|
107
|
-
(_b = this.
|
|
107
|
+
(_b = this._logger) === null || _b === void 0 ? void 0 : _b.debug('[EventSource][onreadystatechange][OPEN] Connection opened.');
|
|
108
108
|
}
|
|
109
109
|
// retry from server gets set here
|
|
110
|
-
this.
|
|
111
|
-
if (this.
|
|
112
|
-
(_c = this.
|
|
113
|
-
this.
|
|
110
|
+
this._handleEvent(this._xhr.responseText || '');
|
|
111
|
+
if (this._xhr.readyState === XMLHttpRequest.DONE) {
|
|
112
|
+
(_c = this._logger) === null || _c === void 0 ? void 0 : _c.debug('[EventSource][onreadystatechange][DONE] Operation done.');
|
|
113
|
+
this._tryConnect();
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
else {
|
|
117
|
-
this.
|
|
117
|
+
this._status = this.ERROR;
|
|
118
118
|
this.dispatch('error', {
|
|
119
119
|
type: 'error',
|
|
120
|
-
message: this.
|
|
121
|
-
xhrStatus: this.
|
|
122
|
-
xhrState: this.
|
|
120
|
+
message: this._xhr.responseText,
|
|
121
|
+
xhrStatus: this._xhr.status,
|
|
122
|
+
xhrState: this._xhr.readyState,
|
|
123
123
|
});
|
|
124
|
-
if (this.
|
|
125
|
-
(_d = this.
|
|
126
|
-
if (!this.
|
|
124
|
+
if (this._xhr.readyState === XMLHttpRequest.DONE) {
|
|
125
|
+
(_d = this._logger) === null || _d === void 0 ? void 0 : _d.debug('[EventSource][onreadystatechange][ERROR] Response status error.');
|
|
126
|
+
if (!this._retryAndHandleError) {
|
|
127
127
|
// by default just try and reconnect if there's an error.
|
|
128
|
-
this.
|
|
128
|
+
this._tryConnect();
|
|
129
129
|
}
|
|
130
130
|
else {
|
|
131
131
|
// custom retry logic taking into account status codes.
|
|
132
|
-
const shouldRetry = this.
|
|
133
|
-
status: this.
|
|
134
|
-
message: this.
|
|
132
|
+
const shouldRetry = this._retryAndHandleError({
|
|
133
|
+
status: this._xhr.status,
|
|
134
|
+
message: this._xhr.responseText,
|
|
135
135
|
});
|
|
136
136
|
if (shouldRetry) {
|
|
137
|
-
this.
|
|
137
|
+
this._tryConnect();
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
this.
|
|
144
|
-
if (this.
|
|
143
|
+
this._xhr.onerror = () => {
|
|
144
|
+
if (this._status === this.CLOSED) {
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
|
-
this.
|
|
147
|
+
this._status = this.ERROR;
|
|
148
148
|
this.dispatch('error', {
|
|
149
149
|
type: 'error',
|
|
150
|
-
message: this.
|
|
151
|
-
xhrStatus: this.
|
|
152
|
-
xhrState: this.
|
|
150
|
+
message: this._xhr.responseText,
|
|
151
|
+
xhrStatus: this._xhr.status,
|
|
152
|
+
xhrState: this._xhr.readyState,
|
|
153
153
|
});
|
|
154
154
|
};
|
|
155
|
-
if (this.
|
|
156
|
-
this.
|
|
155
|
+
if (this._body) {
|
|
156
|
+
this._xhr.send(this._body);
|
|
157
157
|
}
|
|
158
158
|
else {
|
|
159
|
-
this.
|
|
159
|
+
this._xhr.send();
|
|
160
160
|
}
|
|
161
|
-
if (this.
|
|
161
|
+
if (this._timeout > 0) {
|
|
162
162
|
setTimeout(() => {
|
|
163
|
-
if (this.
|
|
163
|
+
if (this._xhr.readyState === XMLHttpRequest.LOADING) {
|
|
164
164
|
this.dispatch('error', { type: 'timeout' });
|
|
165
165
|
this.close();
|
|
166
166
|
}
|
|
167
|
-
}, this.
|
|
167
|
+
}, this._timeout);
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
catch (e) {
|
|
171
|
-
this.
|
|
171
|
+
this._status = this.ERROR;
|
|
172
172
|
this.dispatch('error', {
|
|
173
173
|
type: 'exception',
|
|
174
174
|
message: e.message,
|
|
@@ -176,11 +176,11 @@ export default class EventSource {
|
|
|
176
176
|
});
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
-
|
|
180
|
-
const parts = response.slice(this.
|
|
179
|
+
_handleEvent(response) {
|
|
180
|
+
const parts = response.slice(this._lastIndexProcessed).split('\n');
|
|
181
181
|
const indexOfDoubleNewline = response.lastIndexOf('\n\n');
|
|
182
182
|
if (indexOfDoubleNewline !== -1) {
|
|
183
|
-
this.
|
|
183
|
+
this._lastIndexProcessed = indexOfDoubleNewline + 2;
|
|
184
184
|
}
|
|
185
185
|
let data = [];
|
|
186
186
|
let retry = 0;
|
|
@@ -189,7 +189,7 @@ export default class EventSource {
|
|
|
189
189
|
for (let i = 0; i < parts.length; i++) {
|
|
190
190
|
line = parts[i].replace(/^(\s|\u00A0)+|(\s|\u00A0)+$/g, '');
|
|
191
191
|
if (line.indexOf('event') === 0) {
|
|
192
|
-
this.
|
|
192
|
+
this._eventType = line.replace(/event:?\s*/, '');
|
|
193
193
|
}
|
|
194
194
|
else if (line.indexOf('retry') === 0) {
|
|
195
195
|
retry = parseInt(line.replace(/retry:?\s*/, ''), 10);
|
|
@@ -202,55 +202,55 @@ export default class EventSource {
|
|
|
202
202
|
data.push(line.replace(/data:?\s*/, ''));
|
|
203
203
|
}
|
|
204
204
|
else if (line.indexOf('id:') === 0) {
|
|
205
|
-
this.
|
|
205
|
+
this._lastEventId = line.replace(/id:?\s*/, '');
|
|
206
206
|
}
|
|
207
207
|
else if (line.indexOf('id') === 0) {
|
|
208
|
-
this.
|
|
208
|
+
this._lastEventId = undefined;
|
|
209
209
|
}
|
|
210
210
|
else if (line === '') {
|
|
211
211
|
if (data.length > 0) {
|
|
212
|
-
const eventType = this.
|
|
212
|
+
const eventType = this._eventType || 'message';
|
|
213
213
|
const event = {
|
|
214
214
|
type: eventType,
|
|
215
215
|
data: data.join('\n'),
|
|
216
|
-
url: this.
|
|
217
|
-
lastEventId: this.
|
|
216
|
+
url: this._url,
|
|
217
|
+
lastEventId: this._lastEventId,
|
|
218
218
|
};
|
|
219
219
|
this.dispatch(eventType, event);
|
|
220
220
|
data = [];
|
|
221
|
-
this.
|
|
221
|
+
this._eventType = undefined;
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
addEventListener(type, listener) {
|
|
227
|
-
if (this.
|
|
228
|
-
this.
|
|
227
|
+
if (this._eventHandlers[type] === undefined) {
|
|
228
|
+
this._eventHandlers[type] = [];
|
|
229
229
|
}
|
|
230
|
-
this.
|
|
230
|
+
this._eventHandlers[type].push(listener);
|
|
231
231
|
}
|
|
232
232
|
removeEventListener(type, listener) {
|
|
233
|
-
if (this.
|
|
234
|
-
this.
|
|
233
|
+
if (this._eventHandlers[type] !== undefined) {
|
|
234
|
+
this._eventHandlers[type] = this._eventHandlers[type].filter((handler) => handler !== listener);
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
removeAllEventListeners(type) {
|
|
238
|
-
const availableTypes = Object.keys(this.
|
|
238
|
+
const availableTypes = Object.keys(this._eventHandlers);
|
|
239
239
|
if (type === undefined) {
|
|
240
240
|
availableTypes.forEach((eventType) => {
|
|
241
|
-
this.
|
|
241
|
+
this._eventHandlers[eventType] = [];
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
244
|
else {
|
|
245
245
|
if (!availableTypes.includes(type)) {
|
|
246
246
|
throw Error(`[EventSource] '${type}' type is not supported event type.`);
|
|
247
247
|
}
|
|
248
|
-
this.
|
|
248
|
+
this._eventHandlers[type] = [];
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
251
|
dispatch(type, data) {
|
|
252
252
|
var _a, _b;
|
|
253
|
-
(_a = this.
|
|
253
|
+
(_a = this._eventHandlers[type]) === null || _a === void 0 ? void 0 : _a.forEach((handler) => handler(data));
|
|
254
254
|
switch (type) {
|
|
255
255
|
case 'open':
|
|
256
256
|
this.onopen();
|
|
@@ -259,7 +259,7 @@ export default class EventSource {
|
|
|
259
259
|
this.onclose();
|
|
260
260
|
break;
|
|
261
261
|
case 'error':
|
|
262
|
-
(_b = this.
|
|
262
|
+
(_b = this._logger) === null || _b === void 0 ? void 0 : _b.debug(`[EventSource][dispatch][ERROR]: ${JSON.stringify(data)}`);
|
|
263
263
|
this.onerror(data);
|
|
264
264
|
break;
|
|
265
265
|
case 'retry':
|
|
@@ -270,15 +270,15 @@ export default class EventSource {
|
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
272
|
close() {
|
|
273
|
-
this.
|
|
274
|
-
clearTimeout(this.
|
|
275
|
-
if (this.
|
|
276
|
-
this.
|
|
273
|
+
this._status = this.CLOSED;
|
|
274
|
+
clearTimeout(this._connectTimer);
|
|
275
|
+
if (this._xhr) {
|
|
276
|
+
this._xhr.abort();
|
|
277
277
|
}
|
|
278
278
|
this.dispatch('close', { type: 'close' });
|
|
279
279
|
}
|
|
280
280
|
getStatus() {
|
|
281
|
-
return this.
|
|
281
|
+
return this._status;
|
|
282
282
|
}
|
|
283
283
|
onopen() { }
|
|
284
284
|
onclose() { }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventSource.js","sourceRoot":"","sources":["../../../../src/fromExternal/react-native-sse/EventSource.ts"],"names":[],"mappings":"AAUA,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;AAErF,MAAM,cAAc,GAAuB;IACzC,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,EAAE;IACX,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,CAAC;IACV,eAAe,EAAE,KAAK;IACtB,mBAAmB,EAAE,SAAS;IAC9B,uBAAuB,EAAE,IAAI;IAC7B,MAAM,EAAE,SAAS;CAClB,CAAC;AAEF,MAAM,aAAa,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,kCAAkC;AACnE,MAAM,WAAW,GAAG,GAAG,CAAC,CAAC,+CAA+C;AAExE,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,UAAkB;IACtD,MAAM,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IAC7C,OAAO,IAAI,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O;gBACV,MAAA,IAAI,CAAC,OAAO,0CAAE,KAAK,CAAC,mCAAmC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAC/E,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACnB,MAAM;YACR,KAAK,OAAO;gBACV,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;gBACtB,MAAM;YACR;gBACE,MAAM;SACT;IACH,CAAC;IAED,KAAK;QACH,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACjC,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;SACnB;QAED,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,MAAM,KAAI,CAAC;IACX,OAAO,KAAI,CAAC;IACZ,OAAO,CAAC,IAAS,IAAG,CAAC;IACrB,UAAU,CAAC,EAAO,IAAG,CAAC;CACvB"}
|
|
@@ -26,53 +26,53 @@ export var NetworkState;
|
|
|
26
26
|
* @internal
|
|
27
27
|
*/
|
|
28
28
|
export class ConnectionManager {
|
|
29
|
-
constructor(
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
this.
|
|
41
|
-
this.
|
|
29
|
+
constructor(_logger, _config, _destination, _detector) {
|
|
30
|
+
this._logger = _logger;
|
|
31
|
+
this._config = _config;
|
|
32
|
+
this._destination = _destination;
|
|
33
|
+
this._detector = _detector;
|
|
34
|
+
this._applicationState = ApplicationState.Foreground;
|
|
35
|
+
this._networkState = NetworkState.Available;
|
|
36
|
+
this._offline = false;
|
|
37
|
+
this._currentConnectionMode = _config.initialConnectionMode;
|
|
38
|
+
if (_config.automaticBackgroundHandling) {
|
|
39
|
+
_detector.setApplicationStateListener((state) => {
|
|
40
|
+
this._applicationState = state;
|
|
41
|
+
this._handleState();
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
44
|
+
if (_config.automaticNetworkHandling) {
|
|
45
|
+
_detector.setNetworkStateListener((state) => {
|
|
46
|
+
this._networkState = state;
|
|
47
|
+
this._handleState();
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
setOffline(offline) {
|
|
52
|
-
this.
|
|
53
|
-
this.
|
|
52
|
+
this._offline = offline;
|
|
53
|
+
this._handleState();
|
|
54
54
|
}
|
|
55
55
|
setConnectionMode(mode) {
|
|
56
|
-
this.
|
|
57
|
-
this.
|
|
56
|
+
this._currentConnectionMode = mode;
|
|
57
|
+
this._handleState();
|
|
58
58
|
}
|
|
59
59
|
close() {
|
|
60
|
-
this.
|
|
60
|
+
this._detector.stopListening();
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
this.
|
|
64
|
-
switch (this.
|
|
62
|
+
_handleState() {
|
|
63
|
+
this._logger.debug(`Handling state: ${this._applicationState}:${this._networkState}`);
|
|
64
|
+
switch (this._networkState) {
|
|
65
65
|
case NetworkState.Unavailable:
|
|
66
|
-
this.
|
|
66
|
+
this._destination.setNetworkAvailability(false);
|
|
67
67
|
break;
|
|
68
68
|
case NetworkState.Available:
|
|
69
|
-
this.
|
|
70
|
-
switch (this.
|
|
69
|
+
this._destination.setNetworkAvailability(true);
|
|
70
|
+
switch (this._applicationState) {
|
|
71
71
|
case ApplicationState.Foreground:
|
|
72
|
-
this.
|
|
72
|
+
this._setForegroundAvailable();
|
|
73
73
|
break;
|
|
74
74
|
case ApplicationState.Background:
|
|
75
|
-
this.
|
|
75
|
+
this._setBackgroundAvailable();
|
|
76
76
|
break;
|
|
77
77
|
default:
|
|
78
78
|
break;
|
|
@@ -82,29 +82,29 @@ export class ConnectionManager {
|
|
|
82
82
|
break;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
|
|
86
|
-
if (this.
|
|
87
|
-
this.
|
|
85
|
+
_setForegroundAvailable() {
|
|
86
|
+
if (this._offline) {
|
|
87
|
+
this._destination.setConnectionMode('offline');
|
|
88
88
|
// Don't attempt to flush. If the user wants to flush when entering offline
|
|
89
89
|
// mode, then they can do that directly.
|
|
90
|
-
this.
|
|
90
|
+
this._destination.setEventSendingEnabled(false, false);
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
93
|
// Currently the foreground mode will always be whatever the last active
|
|
94
94
|
// connection mode was.
|
|
95
|
-
this.
|
|
96
|
-
this.
|
|
95
|
+
this._destination.setConnectionMode(this._currentConnectionMode);
|
|
96
|
+
this._destination.setEventSendingEnabled(true, false);
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
if (!this.
|
|
100
|
-
this.
|
|
101
|
-
this.
|
|
98
|
+
_setBackgroundAvailable() {
|
|
99
|
+
if (!this._config.runInBackground) {
|
|
100
|
+
this._destination.setConnectionMode('offline');
|
|
101
|
+
this._destination.setEventSendingEnabled(false, true);
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
104
|
// This SDK doesn't currently support automatic background polling.
|
|
105
105
|
// If connections in the background are allowed, then use the same mode
|
|
106
106
|
// as is configured for the foreground.
|
|
107
|
-
this.
|
|
107
|
+
this._setForegroundAvailable();
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
//# sourceMappingURL=ConnectionManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionManager.js","sourceRoot":"","sources":["../../../src/platform/ConnectionManager.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAN,IAAY,gBASX;AATD,WAAY,gBAAgB;IAC1B,yCAAyC;IACzC,6CAAyB,CAAA;IAEzB,yCAAyC;IACzC,GAAG;IACH,yEAAyE;IACzE,oEAAoE;IACpE,6CAAyB,CAAA;AAC3B,CAAC,EATW,gBAAgB,KAAhB,gBAAgB,QAS3B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,YAOX;AAPD,WAAY,YAAY;IACtB,qDAAqD;IACrD,2CAA2B,CAAA;IAE3B,uEAAuE;IACvE,sBAAsB;IACtB,uCAAuB,CAAA;AACzB,CAAC,EAPW,YAAY,KAAZ,YAAY,QAOvB;AAgDD;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAM5B,YACmB,
|
|
1
|
+
{"version":3,"file":"ConnectionManager.js","sourceRoot":"","sources":["../../../src/platform/ConnectionManager.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAN,IAAY,gBASX;AATD,WAAY,gBAAgB;IAC1B,yCAAyC;IACzC,6CAAyB,CAAA;IAEzB,yCAAyC;IACzC,GAAG;IACH,yEAAyE;IACzE,oEAAoE;IACpE,6CAAyB,CAAA;AAC3B,CAAC,EATW,gBAAgB,KAAhB,gBAAgB,QAS3B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,YAOX;AAPD,WAAY,YAAY;IACtB,qDAAqD;IACrD,2CAA2B,CAAA;IAE3B,uEAAuE;IACvE,sBAAsB;IACtB,uCAAuB,CAAA;AACzB,CAAC,EAPW,YAAY,KAAZ,YAAY,QAOvB;AAgDD;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAM5B,YACmB,OAAiB,EACjB,OAAgC,EAChC,YAAmC,EACnC,SAAwB;QAHxB,YAAO,GAAP,OAAO,CAAU;QACjB,YAAO,GAAP,OAAO,CAAyB;QAChC,iBAAY,GAAZ,YAAY,CAAuB;QACnC,cAAS,GAAT,SAAS,CAAe;QATnC,sBAAiB,GAAqB,gBAAgB,CAAC,UAAU,CAAC;QAClE,kBAAa,GAAiB,YAAY,CAAC,S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,iBAAiB,EAAE;oBAC9B,KAAK,gBAAgB,CAAC,UAAU;wBAC9B,IAAI,CAAC,uBAAuB,EAAE,CAAC;wBAC/B,MAAM;oBACR,KAAK,gBAAgB,CAAC,UAAU;wBAC9B,IAAI,CAAC,uBAAuB,EAAE,CAAC;wBAC/B,MAAM;oBACR;wBACE,MAAM;iBACT;gBACD,MAAM;YACR;gBACE,MAAM;SACT;IACH,CAAC;IAEO,uBAAuB;QAC7B,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;YAC/C,2EAA2E;YAC3E,wCAAwC;YACxC,IAAI,CAAC,YAAY,CAAC,sBAAsB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACvD,OAAO;SACR;QAED,wEAAwE;QACxE,uBAAuB;QACvB,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACjE,IAAI,CAAC,YAAY,CAAC,sBAAsB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC;IAEO,uBAAuB;QAC7B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE;YACjC,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;YAC/C,IAAI,CAAC,YAAY,CAAC,sBAAsB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YACtD,OAAO;SACR;QAED,mEAAmE;QAEnE,uEAAuE;QACvE,uCAAuC;QACvC,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Info, LDLogger, PlatformData, SdkData } from '@launchdarkly/js-client-sdk-common';
|
|
2
2
|
export default class PlatformInfo implements Info {
|
|
3
|
-
private readonly
|
|
4
|
-
constructor(
|
|
3
|
+
private readonly _logger;
|
|
4
|
+
constructor(_logger: LDLogger);
|
|
5
5
|
platformData(): PlatformData;
|
|
6
6
|
sdkData(): SdkData;
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformInfo.d.ts","sourceRoot":"","sources":["../../../src/platform/PlatformInfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAKhG,MAAM,CAAC,OAAO,OAAO,YAAa,YAAW,IAAI;IACnC,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"PlatformInfo.d.ts","sourceRoot":"","sources":["../../../src/platform/PlatformInfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAKhG,MAAM,CAAC,OAAO,OAAO,YAAa,YAAW,IAAI;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,QAAQ;IAE9C,YAAY,IAAI,YAAY;IAW5B,OAAO,IAAI,OAAO;CAUnB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { name, version } from '../../package.json';
|
|
2
2
|
import { ldApplication, ldDevice } from './autoEnv';
|
|
3
3
|
export default class PlatformInfo {
|
|
4
|
-
constructor(
|
|
5
|
-
this.
|
|
4
|
+
constructor(_logger) {
|
|
5
|
+
this._logger = _logger;
|
|
6
6
|
}
|
|
7
7
|
platformData() {
|
|
8
8
|
const data = {
|
|
@@ -10,7 +10,7 @@ export default class PlatformInfo {
|
|
|
10
10
|
ld_application: ldApplication,
|
|
11
11
|
ld_device: ldDevice,
|
|
12
12
|
};
|
|
13
|
-
this.
|
|
13
|
+
this._logger.debug(`platformData: ${JSON.stringify(data, null, 2)}`);
|
|
14
14
|
return data;
|
|
15
15
|
}
|
|
16
16
|
sdkData() {
|
|
@@ -19,7 +19,7 @@ export default class PlatformInfo {
|
|
|
19
19
|
version,
|
|
20
20
|
userAgentBase: 'ReactNativeClient',
|
|
21
21
|
};
|
|
22
|
-
this.
|
|
22
|
+
this._logger.debug(`sdkData: ${JSON.stringify(data, null, 2)}`);
|
|
23
23
|
return data;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformInfo.js","sourceRoot":"","sources":["../../../src/platform/PlatformInfo.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEpD,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,YAA6B,
|
|
1
|
+
{"version":3,"file":"PlatformInfo.js","sourceRoot":"","sources":["../../../src/platform/PlatformInfo.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEpD,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,YAA6B,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;IAAG,CAAC;IAElD,YAAY;QACV,MAAM,IAAI,GAAG;YACX,IAAI,EAAE,cAAc;YACpB,cAAc,EAAE,aAAa;YAC7B,SAAS,EAAE,QAAQ;SACpB,CAAC;QAEF,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,iBAAiB,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACrE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,MAAM,IAAI,GAAG;YACX,IAAI;YACJ,OAAO;YACP,aAAa,EAAE,mBAAmB;SACnC,CAAC;QAEF,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QAChE,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { EventSource, EventSourceCapabilities, EventSourceInitDict, LDLogger, Options, Requests, Response } from '@launchdarkly/js-client-sdk-common';
|
|
2
2
|
export default class PlatformRequests implements Requests {
|
|
3
|
-
private readonly
|
|
4
|
-
constructor(
|
|
3
|
+
private readonly _logger;
|
|
4
|
+
constructor(_logger: LDLogger);
|
|
5
5
|
createEventSource(url: string, eventSourceInitDict: EventSourceInitDict): EventSource;
|
|
6
6
|
getEventSourceCapabilities(): EventSourceCapabilities;
|
|
7
7
|
fetch(url: string, options?: Options): Promise<Response>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformRequests.d.ts","sourceRoot":"","sources":["../../../src/platform/PlatformRequests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EACX,uBAAuB,EACvB,mBAAmB,EACnB,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,QAAQ,EACT,MAAM,oCAAoC,CAAC;AAI5C,MAAM,CAAC,OAAO,OAAO,gBAAiB,YAAW,QAAQ;IAC3C,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"PlatformRequests.d.ts","sourceRoot":"","sources":["../../../src/platform/PlatformRequests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EACX,uBAAuB,EACvB,mBAAmB,EACnB,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,QAAQ,EACT,MAAM,oCAAoC,CAAC;AAI5C,MAAM,CAAC,OAAO,OAAO,gBAAiB,YAAW,QAAQ;IAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,QAAQ;IAE9C,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,GAAG,WAAW;IAUrF,0BAA0B,IAAI,uBAAuB;IAQrD,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;CAIzD"}
|