@flopflip/http-adapter 12.5.3 → 12.5.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/flopflip-http-adapter.cjs.dev.js +187 -201
- package/dist/flopflip-http-adapter.cjs.prod.js +187 -201
- package/dist/flopflip-http-adapter.esm.js +187 -201
- package/package.json +6 -6
|
@@ -66,46 +66,44 @@ var HttpAdapter = /*#__PURE__*/function () {
|
|
|
66
66
|
var _value = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(cacheIdentifier) {
|
|
67
67
|
var cacheModule, createCache, cache;
|
|
68
68
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
69
|
-
while (1) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return _context.stop();
|
|
108
|
-
}
|
|
69
|
+
while (1) switch (_context.prev = _context.next) {
|
|
70
|
+
case 0:
|
|
71
|
+
_context.t0 = cacheIdentifier;
|
|
72
|
+
_context.next = _context.t0 === cacheIdentifiers.local ? 3 : _context.t0 === cacheIdentifiers.session ? 7 : 11;
|
|
73
|
+
break;
|
|
74
|
+
case 3:
|
|
75
|
+
_context.next = 5;
|
|
76
|
+
return import('@flopflip/localstorage-cache');
|
|
77
|
+
case 5:
|
|
78
|
+
cacheModule = _context.sent;
|
|
79
|
+
return _context.abrupt("break", 12);
|
|
80
|
+
case 7:
|
|
81
|
+
_context.next = 9;
|
|
82
|
+
return import('@flopflip/sessionstorage-cache');
|
|
83
|
+
case 9:
|
|
84
|
+
cacheModule = _context.sent;
|
|
85
|
+
return _context.abrupt("break", 12);
|
|
86
|
+
case 11:
|
|
87
|
+
return _context.abrupt("break", 12);
|
|
88
|
+
case 12:
|
|
89
|
+
createCache = cacheModule.default;
|
|
90
|
+
cache = createCache({
|
|
91
|
+
prefix: STORAGE_SLICE
|
|
92
|
+
});
|
|
93
|
+
return _context.abrupt("return", {
|
|
94
|
+
set: function set(flags) {
|
|
95
|
+
return cache.set('flags', flags);
|
|
96
|
+
},
|
|
97
|
+
get: function get() {
|
|
98
|
+
return cache.get('flags');
|
|
99
|
+
},
|
|
100
|
+
unset: function unset() {
|
|
101
|
+
return cache.unset('flags');
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
case 15:
|
|
105
|
+
case "end":
|
|
106
|
+
return _context.stop();
|
|
109
107
|
}
|
|
110
108
|
}, _callee);
|
|
111
109
|
}));
|
|
@@ -129,18 +127,16 @@ var HttpAdapter = /*#__PURE__*/function () {
|
|
|
129
127
|
var _value2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(adapterArgs) {
|
|
130
128
|
var flags;
|
|
131
129
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
132
|
-
while (1) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return _context2.stop();
|
|
143
|
-
}
|
|
130
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
131
|
+
case 0:
|
|
132
|
+
_context2.next = 2;
|
|
133
|
+
return adapterArgs.execute();
|
|
134
|
+
case 2:
|
|
135
|
+
flags = _context2.sent;
|
|
136
|
+
return _context2.abrupt("return", flags);
|
|
137
|
+
case 4:
|
|
138
|
+
case "end":
|
|
139
|
+
return _context2.stop();
|
|
144
140
|
}
|
|
145
141
|
}, _callee2);
|
|
146
142
|
}));
|
|
@@ -158,39 +154,37 @@ var HttpAdapter = /*#__PURE__*/function () {
|
|
|
158
154
|
setInterval( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
159
155
|
var nextFlags, cache;
|
|
160
156
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
161
|
-
while (1) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
return _context3.stop();
|
|
193
|
-
}
|
|
157
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
158
|
+
case 0:
|
|
159
|
+
if (_classPrivateFieldLooseBase(_this, _getIsAdapterUnsubscribed)[_getIsAdapterUnsubscribed]()) {
|
|
160
|
+
_context3.next = 14;
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
_context3.t0 = normalizeFlags;
|
|
164
|
+
_context3.next = 4;
|
|
165
|
+
return _classPrivateFieldLooseBase(_this, _fetchFlags)[_fetchFlags](adapterArgs);
|
|
166
|
+
case 4:
|
|
167
|
+
_context3.t1 = _context3.sent;
|
|
168
|
+
nextFlags = (0, _context3.t0)(_context3.t1);
|
|
169
|
+
if (!_classPrivateFieldLooseBase(_this, _didFlagsChange)[_didFlagsChange](nextFlags)) {
|
|
170
|
+
_context3.next = 14;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
if (!adapterArgs.cacheIdentifier) {
|
|
174
|
+
_context3.next = 12;
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
_context3.next = 10;
|
|
178
|
+
return _classPrivateFieldLooseBase(_this, _getCache)[_getCache](adapterArgs.cacheIdentifier);
|
|
179
|
+
case 10:
|
|
180
|
+
cache = _context3.sent;
|
|
181
|
+
cache.set(nextFlags);
|
|
182
|
+
case 12:
|
|
183
|
+
_classPrivateFieldLooseBase(_this, _adapterState)[_adapterState].flags = nextFlags;
|
|
184
|
+
_classPrivateFieldLooseBase(_this, _adapterState)[_adapterState].emitter.emit('flagsStateChange', nextFlags);
|
|
185
|
+
case 14:
|
|
186
|
+
case "end":
|
|
187
|
+
return _context3.stop();
|
|
194
188
|
}
|
|
195
189
|
}, _callee3);
|
|
196
190
|
})), pollingInteralMs);
|
|
@@ -242,82 +236,78 @@ var HttpAdapter = /*#__PURE__*/function () {
|
|
|
242
236
|
var _this2 = this;
|
|
243
237
|
var handleFlagsChange, handleStatusChange;
|
|
244
238
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
245
|
-
while (1) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
_context4.next = 6;
|
|
274
|
-
break;
|
|
275
|
-
}
|
|
276
|
-
_context4.next = 3;
|
|
277
|
-
return _classPrivateFieldLooseBase(_this2, _getCache)[_getCache](adapterArgs.cacheIdentifier);
|
|
278
|
-
case 3:
|
|
279
|
-
cache = _context4.sent;
|
|
280
|
-
cachedFlags = cache.get();
|
|
281
|
-
if (cachedFlags) {
|
|
282
|
-
_classPrivateFieldLooseBase(_this2, _adapterState)[_adapterState].flags = cachedFlags;
|
|
283
|
-
_classPrivateFieldLooseBase(_this2, _adapterState)[_adapterState].emitter.emit('flagsStateChange', cachedFlags);
|
|
284
|
-
}
|
|
285
|
-
case 6:
|
|
286
|
-
_this2.setConfigurationStatus(AdapterConfigurationStatus.Configured);
|
|
287
|
-
_context4.t0 = normalizeFlags;
|
|
288
|
-
_context4.next = 10;
|
|
289
|
-
return _classPrivateFieldLooseBase(_this2, _fetchFlags)[_fetchFlags](adapterArgs);
|
|
290
|
-
case 10:
|
|
291
|
-
_context4.t1 = _context4.sent;
|
|
292
|
-
flags = (0, _context4.t0)(_context4.t1);
|
|
293
|
-
_classPrivateFieldLooseBase(_this2, _adapterState)[_adapterState].flags = flags;
|
|
294
|
-
if (!adapterArgs.cacheIdentifier) {
|
|
295
|
-
_context4.next = 18;
|
|
296
|
-
break;
|
|
297
|
-
}
|
|
298
|
-
_context4.next = 16;
|
|
299
|
-
return _classPrivateFieldLooseBase(_this2, _getCache)[_getCache](adapterArgs.cacheIdentifier);
|
|
300
|
-
case 16:
|
|
301
|
-
_cache = _context4.sent;
|
|
302
|
-
_cache.set(flags);
|
|
303
|
-
case 18:
|
|
304
|
-
_classPrivateFieldLooseBase(_this2, _adapterState)[_adapterState].emitter.emit('flagsStateChange', flags);
|
|
305
|
-
_classPrivateFieldLooseBase(_this2, _adapterState)[_adapterState].emitter.emit(_classPrivateFieldLooseBase(_this2, _internalConfiguredStatusChange__)[_internalConfiguredStatusChange__]);
|
|
306
|
-
_classPrivateFieldLooseBase(_this2, _subscribeToFlagsChanges)[_subscribeToFlagsChanges](adapterArgs);
|
|
307
|
-
return _context4.abrupt("return", {
|
|
308
|
-
initializationStatus: AdapterInitializationStatus.Succeeded
|
|
309
|
-
});
|
|
310
|
-
case 22:
|
|
311
|
-
case "end":
|
|
312
|
-
return _context4.stop();
|
|
239
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
240
|
+
case 0:
|
|
241
|
+
handleFlagsChange = function handleFlagsChange(nextFlags) {
|
|
242
|
+
if (_classPrivateFieldLooseBase(_this2, _getIsAdapterUnsubscribed)[_getIsAdapterUnsubscribed]()) return;
|
|
243
|
+
adapterEventHandlers.onFlagsStateChange({
|
|
244
|
+
flags: nextFlags,
|
|
245
|
+
id: _this2.id
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
handleStatusChange = function handleStatusChange(nextStatus) {
|
|
249
|
+
if (_classPrivateFieldLooseBase(_this2, _getIsAdapterUnsubscribed)[_getIsAdapterUnsubscribed]()) return;
|
|
250
|
+
adapterEventHandlers.onStatusStateChange({
|
|
251
|
+
status: nextStatus,
|
|
252
|
+
id: _this2.id
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
_classPrivateFieldLooseBase(this, _adapterState)[_adapterState].emitter.on('flagsStateChange', handleFlagsChange);
|
|
256
|
+
_classPrivateFieldLooseBase(this, _adapterState)[_adapterState].emitter.on('statusStateChange', handleStatusChange);
|
|
257
|
+
this.setConfigurationStatus(AdapterConfigurationStatus.Configuring);
|
|
258
|
+
_classPrivateFieldLooseBase(this, _adapterState)[_adapterState].user = adapterArgs.user;
|
|
259
|
+
return _context5.abrupt("return", Promise.resolve().then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
260
|
+
var cachedFlags, cache, flags, _cache;
|
|
261
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
262
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
263
|
+
case 0:
|
|
264
|
+
if (!adapterArgs.cacheIdentifier) {
|
|
265
|
+
_context4.next = 6;
|
|
266
|
+
break;
|
|
313
267
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
268
|
+
_context4.next = 3;
|
|
269
|
+
return _classPrivateFieldLooseBase(_this2, _getCache)[_getCache](adapterArgs.cacheIdentifier);
|
|
270
|
+
case 3:
|
|
271
|
+
cache = _context4.sent;
|
|
272
|
+
cachedFlags = cache.get();
|
|
273
|
+
if (cachedFlags) {
|
|
274
|
+
_classPrivateFieldLooseBase(_this2, _adapterState)[_adapterState].flags = cachedFlags;
|
|
275
|
+
_classPrivateFieldLooseBase(_this2, _adapterState)[_adapterState].emitter.emit('flagsStateChange', cachedFlags);
|
|
276
|
+
}
|
|
277
|
+
case 6:
|
|
278
|
+
_this2.setConfigurationStatus(AdapterConfigurationStatus.Configured);
|
|
279
|
+
_context4.t0 = normalizeFlags;
|
|
280
|
+
_context4.next = 10;
|
|
281
|
+
return _classPrivateFieldLooseBase(_this2, _fetchFlags)[_fetchFlags](adapterArgs);
|
|
282
|
+
case 10:
|
|
283
|
+
_context4.t1 = _context4.sent;
|
|
284
|
+
flags = (0, _context4.t0)(_context4.t1);
|
|
285
|
+
_classPrivateFieldLooseBase(_this2, _adapterState)[_adapterState].flags = flags;
|
|
286
|
+
if (!adapterArgs.cacheIdentifier) {
|
|
287
|
+
_context4.next = 18;
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
_context4.next = 16;
|
|
291
|
+
return _classPrivateFieldLooseBase(_this2, _getCache)[_getCache](adapterArgs.cacheIdentifier);
|
|
292
|
+
case 16:
|
|
293
|
+
_cache = _context4.sent;
|
|
294
|
+
_cache.set(flags);
|
|
295
|
+
case 18:
|
|
296
|
+
_classPrivateFieldLooseBase(_this2, _adapterState)[_adapterState].emitter.emit('flagsStateChange', flags);
|
|
297
|
+
_classPrivateFieldLooseBase(_this2, _adapterState)[_adapterState].emitter.emit(_classPrivateFieldLooseBase(_this2, _internalConfiguredStatusChange__)[_internalConfiguredStatusChange__]);
|
|
298
|
+
_classPrivateFieldLooseBase(_this2, _subscribeToFlagsChanges)[_subscribeToFlagsChanges](adapterArgs);
|
|
299
|
+
return _context4.abrupt("return", {
|
|
300
|
+
initializationStatus: AdapterInitializationStatus.Succeeded
|
|
301
|
+
});
|
|
302
|
+
case 22:
|
|
303
|
+
case "end":
|
|
304
|
+
return _context4.stop();
|
|
305
|
+
}
|
|
306
|
+
}, _callee4);
|
|
307
|
+
}))));
|
|
308
|
+
case 7:
|
|
309
|
+
case "end":
|
|
310
|
+
return _context5.stop();
|
|
321
311
|
}
|
|
322
312
|
}, _callee5, this);
|
|
323
313
|
}));
|
|
@@ -332,36 +322,34 @@ var HttpAdapter = /*#__PURE__*/function () {
|
|
|
332
322
|
var _reconfigure = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(adapterArgs, _adapterEventHandlers) {
|
|
333
323
|
var cache, nextUser;
|
|
334
324
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
335
|
-
while (1) {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
return _context6.stop();
|
|
364
|
-
}
|
|
325
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
326
|
+
case 0:
|
|
327
|
+
if (this.getIsConfigurationStatus(AdapterConfigurationStatus.Configured)) {
|
|
328
|
+
_context6.next = 2;
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
return _context6.abrupt("return", Promise.reject(new Error('@flopflip/http-adapter: please configure adapter before reconfiguring.')));
|
|
332
|
+
case 2:
|
|
333
|
+
_classPrivateFieldLooseBase(this, _adapterState)[_adapterState].flags = {};
|
|
334
|
+
if (!adapterArgs.cacheIdentifier) {
|
|
335
|
+
_context6.next = 8;
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
_context6.next = 6;
|
|
339
|
+
return _classPrivateFieldLooseBase(this, _getCache)[_getCache](adapterArgs.cacheIdentifier);
|
|
340
|
+
case 6:
|
|
341
|
+
cache = _context6.sent;
|
|
342
|
+
cache.unset();
|
|
343
|
+
case 8:
|
|
344
|
+
nextUser = adapterArgs.user;
|
|
345
|
+
_classPrivateFieldLooseBase(this, _adapterState)[_adapterState].user = nextUser;
|
|
346
|
+
_classPrivateFieldLooseBase(this, _adapterState)[_adapterState].emitter.emit('flagsStateChange', {});
|
|
347
|
+
return _context6.abrupt("return", Promise.resolve({
|
|
348
|
+
initializationStatus: AdapterInitializationStatus.Succeeded
|
|
349
|
+
}));
|
|
350
|
+
case 12:
|
|
351
|
+
case "end":
|
|
352
|
+
return _context6.stop();
|
|
365
353
|
}
|
|
366
354
|
}, _callee6, this);
|
|
367
355
|
}));
|
|
@@ -376,16 +364,14 @@ var HttpAdapter = /*#__PURE__*/function () {
|
|
|
376
364
|
var _waitUntilConfigured = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
377
365
|
var _this3 = this;
|
|
378
366
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
379
|
-
while (1) {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
return _context7.stop();
|
|
388
|
-
}
|
|
367
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
368
|
+
case 0:
|
|
369
|
+
return _context7.abrupt("return", new Promise(function (resolve) {
|
|
370
|
+
if (_this3.getIsConfigurationStatus(AdapterConfigurationStatus.Configured)) resolve();else _classPrivateFieldLooseBase(_this3, _adapterState)[_adapterState].emitter.on(_classPrivateFieldLooseBase(_this3, _internalConfiguredStatusChange__)[_internalConfiguredStatusChange__], resolve);
|
|
371
|
+
}));
|
|
372
|
+
case 1:
|
|
373
|
+
case "end":
|
|
374
|
+
return _context7.stop();
|
|
389
375
|
}
|
|
390
376
|
}, _callee7);
|
|
391
377
|
}));
|
|
@@ -419,6 +405,6 @@ var HttpAdapter = /*#__PURE__*/function () {
|
|
|
419
405
|
var adapter = new HttpAdapter();
|
|
420
406
|
exposeGlobally(adapter);
|
|
421
407
|
|
|
422
|
-
var version = "12.5.
|
|
408
|
+
var version = "12.5.5";
|
|
423
409
|
|
|
424
410
|
export { adapter as default, version };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flopflip/http-adapter",
|
|
3
|
-
"version": "12.5.
|
|
3
|
+
"version": "12.5.5",
|
|
4
4
|
"description": "An HTTP adapter for flipflop",
|
|
5
5
|
"main": "dist/flopflip-http-adapter.cjs.js",
|
|
6
6
|
"module": "dist/flopflip-http-adapter.esm.js",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"client"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@babel/runtime": "7.20.
|
|
33
|
-
"@flopflip/adapter-utilities": "12.5.
|
|
34
|
-
"@flopflip/localstorage-cache": "12.5.
|
|
35
|
-
"@flopflip/sessionstorage-cache": "12.5.
|
|
36
|
-
"@flopflip/types": "12.5.
|
|
32
|
+
"@babel/runtime": "7.20.7",
|
|
33
|
+
"@flopflip/adapter-utilities": "12.5.5",
|
|
34
|
+
"@flopflip/localstorage-cache": "12.5.5",
|
|
35
|
+
"@flopflip/sessionstorage-cache": "12.5.5",
|
|
36
|
+
"@flopflip/types": "12.5.5",
|
|
37
37
|
"lodash": "4.17.21",
|
|
38
38
|
"mitt": "3.0.0",
|
|
39
39
|
"tiny-warning": "1.0.3"
|