@lowentry/react-redux 1.10.7 → 1.11.2
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/build/LeRed.d.ts +107 -0
- package/build/index.d.ts +1 -0
- package/index.js +155 -148
- package/index.js.map +1 -1
- package/jest.config.js +10 -0
- package/package.json +10 -7
- package/src/LeRed.jsx +6 -2
- package/tests/example.test.js +10 -0
- package/tsconfig.d.ts +3 -0
- package/tsconfig.json +44 -0
package/build/LeRed.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
export namespace LeRed {
|
|
2
|
+
function set(key: any, value: any): void;
|
|
3
|
+
function setAll(obj: any, optionalSkipHasOwnPropertyCheck?: boolean): void;
|
|
4
|
+
function configureStore(storeData: any): any;
|
|
5
|
+
function createAction(id: any): RTK.ActionCreatorWithoutPayload<string>;
|
|
6
|
+
function createSelector(selectorsGenerator: any): (stateOfSlice: any) => any;
|
|
7
|
+
function createCachedSelector(selectorsGenerator: any, equalsComparator: any): ((stateOfSlice: any) => any) | undefined;
|
|
8
|
+
function createSlice(slice: any): any;
|
|
9
|
+
function createFastSlice(slice: any): any;
|
|
10
|
+
function current(obj: any): any;
|
|
11
|
+
function useConfigureStore(storeData: any): any;
|
|
12
|
+
function useSelector(selector: any, equalsComparator: any): unknown;
|
|
13
|
+
function useEffect(callable: any, comparingValues: any, equalsComparator: any): any;
|
|
14
|
+
function useEffectInterval(callable: any, comparingValues: any, intervalMs: any, fireImmediately: any, equalsComparator: any): any;
|
|
15
|
+
function useEffectAnimationFrameInterval(callable: any, comparingValues: any, intervalFrames: any, fireImmediately: any, equalsComparator: any): any;
|
|
16
|
+
function useEffectGenerator(callable: any, comparingValues: any, intervalMs: any, fireImmediately: any, equalsComparator: any): any;
|
|
17
|
+
function useEffectGeneratorLoop(callable: any, comparingValues: any, intervalMs: any, fireImmediately: any, equalsComparator: any): any;
|
|
18
|
+
function useEffectShutdown(callable: any, comparingValues: any, equalsComparator: any): any;
|
|
19
|
+
function useEffectPageFocusLost(callable: any, comparingValues: any, equalsComparator: any): any;
|
|
20
|
+
function memo(component: any, equalsComparator: any): any;
|
|
21
|
+
function useMemo(callable: any, comparingValues: any, equalsComparator: any): any;
|
|
22
|
+
function useCallback(callable: any, comparingValues: any, equalsComparator: any): any;
|
|
23
|
+
function usePrevious(value: any, initialValue: any): any;
|
|
24
|
+
function useFont(font: any): any;
|
|
25
|
+
/**
|
|
26
|
+
* Adds a <script> tag to the <head> of the document.
|
|
27
|
+
* Only for development and testing purposes.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} url The URL of the js file to include.
|
|
30
|
+
* @param {object} props Additional props of the <script> tag.
|
|
31
|
+
*/
|
|
32
|
+
function useScript(url: string, props?: object): any;
|
|
33
|
+
function mergeRefs(...refs: any[]): any;
|
|
34
|
+
function useTriggerable(event: any): any;
|
|
35
|
+
function trigger(event: any, value: any): void;
|
|
36
|
+
/**
|
|
37
|
+
* A useState() hook that automatically resets to the defaultValue after the given duration.
|
|
38
|
+
*
|
|
39
|
+
* Example:
|
|
40
|
+
*
|
|
41
|
+
* ```js
|
|
42
|
+
* const [value, setValue] = LeRed.useTempState(true, 2000);
|
|
43
|
+
* // somewhere in your code:
|
|
44
|
+
* setValue(false); // value is now false, after 2 seconds it will be reset to true
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* Repeated calls cause the timer to reset, meaning each set value will always remain for the full given duration.
|
|
48
|
+
*/
|
|
49
|
+
function useTempState(defaultValue: any, duration: any): any[];
|
|
50
|
+
function useHistory(onForward: any, onBack: any): (() => void)[];
|
|
51
|
+
/**
|
|
52
|
+
* Similar to {@link LeRed.useHistory}, but this is specifically for toggling a boolean state between true and false. For example, for a modal, which you'd like to be closed when the user goes back in history.
|
|
53
|
+
*
|
|
54
|
+
* Example:
|
|
55
|
+
*
|
|
56
|
+
* ```js
|
|
57
|
+
* const [isModalOpen, openModal, closeModal] = LeRed.useHistoryState(false); // you'd open it programmatically using openModal(), afterwards, if the user goes back in history, it will close again
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* or, if you'd like it to be true by default:
|
|
61
|
+
*
|
|
62
|
+
* ```js
|
|
63
|
+
* const [isModalOpen, openModal, closeModal] = LeRed.useHistoryState(true); // you'd close it programmatically using closeModal(), afterwards, if the user goes back in history, it will open again
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
function useHistoryState(initialState: any): any[];
|
|
67
|
+
/**
|
|
68
|
+
* Allows you to easily create an <pre><img></pre> url and onError handler that will automatically retry loading the image if it fails.
|
|
69
|
+
*/
|
|
70
|
+
function useRetryingImageUrl(url: any, options: any): any[];
|
|
71
|
+
/**
|
|
72
|
+
* Allows you to easily convert promises to react hooks.
|
|
73
|
+
*
|
|
74
|
+
* The given callable should return promises. The returned promises can be an array, an object, or even a single promise. The returned data of this hook will match the promises it has operated on.
|
|
75
|
+
*
|
|
76
|
+
* The given comparingValues can be anything, this is used to detect whether the given promises have changed or not, and so whether new promises have to be generated and executed again.
|
|
77
|
+
*/
|
|
78
|
+
function usePromises(callable: any, comparingValues: any): any[];
|
|
79
|
+
/**
|
|
80
|
+
* Allows you to easily obtain external data.
|
|
81
|
+
*/
|
|
82
|
+
function useExternal(url: any, options: any, responseFunction: any): any[];
|
|
83
|
+
/**
|
|
84
|
+
* Allows you to easily obtain external JSON data.
|
|
85
|
+
*/
|
|
86
|
+
function useExternalJson(url: any, options: any): any[];
|
|
87
|
+
/**
|
|
88
|
+
* Allows you to easily obtain external Blob data.
|
|
89
|
+
*/
|
|
90
|
+
function useExternalBlob(url: any, options: any): any[];
|
|
91
|
+
/**
|
|
92
|
+
* Allows you to easily obtain external ArrayBuffer data.
|
|
93
|
+
*/
|
|
94
|
+
function useExternalArrayBuffer(url: any, options: any): any[];
|
|
95
|
+
/**
|
|
96
|
+
* Allows you to easily obtain external string data.
|
|
97
|
+
*/
|
|
98
|
+
function useExternalString(url: any, options: any): any[];
|
|
99
|
+
/**
|
|
100
|
+
* Allows you to easily obtain external form data.
|
|
101
|
+
*/
|
|
102
|
+
function useExternalFormData(url: any, options: any): any[];
|
|
103
|
+
let Root: any;
|
|
104
|
+
function PreloadComponent(load: any): any;
|
|
105
|
+
let LoadComponent: any;
|
|
106
|
+
}
|
|
107
|
+
import * as RTK from '@reduxjs/toolkit';
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LeRed } from "./LeRed.jsx";
|
package/index.js
CHANGED
|
@@ -71,10 +71,10 @@ var LeRed = function () {
|
|
|
71
71
|
LeRed.effects.delayFrames = function () {
|
|
72
72
|
var frames = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
73
73
|
return /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
74
|
-
return _regeneratorRuntime.wrap(function
|
|
74
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
75
75
|
while (1) switch (_context.prev = _context.next) {
|
|
76
76
|
case 0:
|
|
77
|
-
_context.next =
|
|
77
|
+
_context.next = 1;
|
|
78
78
|
return LeRed.effects.call(function () {
|
|
79
79
|
return new Promise(function (resolve, reject) {
|
|
80
80
|
try {
|
|
@@ -84,7 +84,7 @@ var LeRed = function () {
|
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
86
|
});
|
|
87
|
-
case
|
|
87
|
+
case 1:
|
|
88
88
|
case "end":
|
|
89
89
|
return _context.stop();
|
|
90
90
|
}
|
|
@@ -92,8 +92,8 @@ var LeRed = function () {
|
|
|
92
92
|
})();
|
|
93
93
|
};
|
|
94
94
|
LeRed.effects.interval = /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(callback, intervalMs) {
|
|
95
|
-
var channel, stop;
|
|
96
|
-
return _regeneratorRuntime.wrap(function
|
|
95
|
+
var channel, stop, _t, _t2;
|
|
96
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
97
97
|
while (1) switch (_context2.prev = _context2.next) {
|
|
98
98
|
case 0:
|
|
99
99
|
channel = LeRed.eventChannel(function (emitter) {
|
|
@@ -114,53 +114,53 @@ var LeRed = function () {
|
|
|
114
114
|
console.error(e);
|
|
115
115
|
}
|
|
116
116
|
};
|
|
117
|
-
case
|
|
117
|
+
case 1:
|
|
118
118
|
if (!(channel !== null)) {
|
|
119
|
-
_context2.next =
|
|
119
|
+
_context2.next = 13;
|
|
120
120
|
break;
|
|
121
121
|
}
|
|
122
|
-
_context2.prev =
|
|
123
|
-
_context2.next =
|
|
122
|
+
_context2.prev = 2;
|
|
123
|
+
_context2.next = 3;
|
|
124
124
|
return LeRed.effects.take(channel);
|
|
125
|
-
case
|
|
126
|
-
_context2.next =
|
|
125
|
+
case 3:
|
|
126
|
+
_context2.next = 4;
|
|
127
127
|
return callback(stop);
|
|
128
|
-
case
|
|
129
|
-
_context2.next =
|
|
128
|
+
case 4:
|
|
129
|
+
_context2.next = 6;
|
|
130
130
|
break;
|
|
131
|
-
case
|
|
132
|
-
_context2.prev =
|
|
133
|
-
|
|
134
|
-
console.error(
|
|
135
|
-
case
|
|
136
|
-
_context2.prev =
|
|
137
|
-
_context2.prev =
|
|
138
|
-
_context2.next =
|
|
131
|
+
case 5:
|
|
132
|
+
_context2.prev = 5;
|
|
133
|
+
_t = _context2["catch"](2);
|
|
134
|
+
console.error(_t);
|
|
135
|
+
case 6:
|
|
136
|
+
_context2.prev = 6;
|
|
137
|
+
_context2.prev = 7;
|
|
138
|
+
_context2.next = 8;
|
|
139
139
|
return LeRed.effects.cancelled();
|
|
140
|
-
case
|
|
140
|
+
case 8:
|
|
141
141
|
if (!_context2.sent) {
|
|
142
|
-
_context2.next =
|
|
142
|
+
_context2.next = 9;
|
|
143
143
|
break;
|
|
144
144
|
}
|
|
145
145
|
channel.close();
|
|
146
146
|
channel = null;
|
|
147
|
-
case
|
|
148
|
-
_context2.next =
|
|
147
|
+
case 9:
|
|
148
|
+
_context2.next = 11;
|
|
149
149
|
break;
|
|
150
|
-
case
|
|
151
|
-
_context2.prev =
|
|
152
|
-
|
|
153
|
-
console.error(
|
|
154
|
-
case
|
|
155
|
-
return _context2.finish(
|
|
156
|
-
case
|
|
157
|
-
_context2.next =
|
|
150
|
+
case 10:
|
|
151
|
+
_context2.prev = 10;
|
|
152
|
+
_t2 = _context2["catch"](7);
|
|
153
|
+
console.error(_t2);
|
|
154
|
+
case 11:
|
|
155
|
+
return _context2.finish(6);
|
|
156
|
+
case 12:
|
|
157
|
+
_context2.next = 1;
|
|
158
158
|
break;
|
|
159
|
-
case
|
|
159
|
+
case 13:
|
|
160
160
|
case "end":
|
|
161
161
|
return _context2.stop();
|
|
162
162
|
}
|
|
163
|
-
}, _callee2, null, [[
|
|
163
|
+
}, _callee2, null, [[2, 5, 6, 12], [7, 10]]);
|
|
164
164
|
});
|
|
165
165
|
} catch (e) {
|
|
166
166
|
console.error(e);
|
|
@@ -238,6 +238,8 @@ var LeRed = function () {
|
|
|
238
238
|
});
|
|
239
239
|
});
|
|
240
240
|
});
|
|
241
|
+
|
|
242
|
+
/** @type {object|*} */
|
|
241
243
|
var reducers = {};
|
|
242
244
|
LeUtils.each(reducerArrays, function (reducerArray, reducerName) {
|
|
243
245
|
reducerArray = LeUtils.flattenArray(reducerArray);
|
|
@@ -283,6 +285,8 @@ var LeRed = function () {
|
|
|
283
285
|
var _getDefaultMiddleware;
|
|
284
286
|
return (_getDefaultMiddleware = getDefaultMiddleware()).concat.apply(_getDefaultMiddleware, _toConsumableArray(middleware));
|
|
285
287
|
};
|
|
288
|
+
|
|
289
|
+
/** @type {RTK.EnhancedStore|*} */
|
|
286
290
|
var store = RTK.configureStore(storeData);
|
|
287
291
|
store.__lowentry_store__ = true;
|
|
288
292
|
store.state = function () {
|
|
@@ -305,12 +309,12 @@ var LeRed = function () {
|
|
|
305
309
|
};
|
|
306
310
|
if (sagaMiddleware !== null) {
|
|
307
311
|
sagaMiddleware.run(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
308
|
-
return _regeneratorRuntime.wrap(function
|
|
312
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
309
313
|
while (1) switch (_context3.prev = _context3.next) {
|
|
310
314
|
case 0:
|
|
311
|
-
_context3.next =
|
|
315
|
+
_context3.next = 1;
|
|
312
316
|
return ReduxSagaEffects.all(sagaListeners);
|
|
313
|
-
case
|
|
317
|
+
case 1:
|
|
314
318
|
case "end":
|
|
315
319
|
return _context3.stop();
|
|
316
320
|
}
|
|
@@ -394,18 +398,20 @@ var LeRed = function () {
|
|
|
394
398
|
LeUtils.each(LeUtils.flattenArray(reducer), function (reducer) {
|
|
395
399
|
if (LeUtils.isGeneratorFunction(reducer)) {
|
|
396
400
|
var sagaListener = /*#__PURE__*/_regeneratorRuntime.mark(function sagaListener() {
|
|
397
|
-
return _regeneratorRuntime.wrap(function
|
|
401
|
+
return _regeneratorRuntime.wrap(function (_context5) {
|
|
398
402
|
while (1) switch (_context5.prev = _context5.next) {
|
|
399
403
|
case 0:
|
|
400
|
-
_context5.next =
|
|
401
|
-
return ReduxSagaEffects.takeEvery(reducerAction, /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(action) {
|
|
402
|
-
var promiseResolve, promiseReject, promise, result;
|
|
403
|
-
return _regeneratorRuntime.wrap(function
|
|
404
|
+
_context5.next = 1;
|
|
405
|
+
return ReduxSagaEffects.takeEvery(reducerAction, /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(/** @type {RTK.Action|*} */action) {
|
|
406
|
+
var promiseResolve, promiseReject, promise, result, _t3;
|
|
407
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
404
408
|
while (1) switch (_context4.prev = _context4.next) {
|
|
405
409
|
case 0:
|
|
410
|
+
/** @type {((value:*)=>void)|null|*} */
|
|
406
411
|
promiseResolve = null;
|
|
412
|
+
/** @type {((reason:*)=>void)|null|*} */
|
|
407
413
|
promiseReject = null;
|
|
408
|
-
_context4.prev =
|
|
414
|
+
_context4.prev = 1;
|
|
409
415
|
if (action.__lowentry_dispatch__ === true) {
|
|
410
416
|
promise = new Promise(function (resolve, reject) {
|
|
411
417
|
promiseResolve = resolve;
|
|
@@ -419,34 +425,34 @@ var LeRed = function () {
|
|
|
419
425
|
action.__lowentry_dispatch_result__ = promise;
|
|
420
426
|
}
|
|
421
427
|
}
|
|
422
|
-
_context4.next =
|
|
428
|
+
_context4.next = 2;
|
|
423
429
|
return reducer.apply(slice, [action.payload]);
|
|
424
|
-
case
|
|
430
|
+
case 2:
|
|
425
431
|
result = _context4.sent;
|
|
426
432
|
if (promiseResolve !== null) {
|
|
427
433
|
promiseResolve(result);
|
|
428
434
|
}
|
|
429
|
-
_context4.next =
|
|
435
|
+
_context4.next = 4;
|
|
430
436
|
break;
|
|
431
|
-
case
|
|
432
|
-
_context4.prev =
|
|
433
|
-
|
|
437
|
+
case 3:
|
|
438
|
+
_context4.prev = 3;
|
|
439
|
+
_t3 = _context4["catch"](1);
|
|
434
440
|
console.error('an error was thrown by your LeRed.createSlice(...) code, by slice "' + slice.name + '", action "' + reducerName + '":');
|
|
435
|
-
console.error(
|
|
441
|
+
console.error(_t3);
|
|
436
442
|
if (promiseReject !== null) {
|
|
437
443
|
try {
|
|
438
|
-
promiseReject(
|
|
444
|
+
promiseReject(_t3);
|
|
439
445
|
} catch (e2) {
|
|
440
446
|
console.error(e2);
|
|
441
447
|
}
|
|
442
448
|
}
|
|
443
|
-
case
|
|
449
|
+
case 4:
|
|
444
450
|
case "end":
|
|
445
451
|
return _context4.stop();
|
|
446
452
|
}
|
|
447
|
-
}, _callee4, null, [[
|
|
453
|
+
}, _callee4, null, [[1, 3]]);
|
|
448
454
|
}));
|
|
449
|
-
case
|
|
455
|
+
case 1:
|
|
450
456
|
case "end":
|
|
451
457
|
return _context5.stop();
|
|
452
458
|
}
|
|
@@ -618,52 +624,52 @@ var LeRed = function () {
|
|
|
618
624
|
return LeRed.useEffect(function () {
|
|
619
625
|
var stop = false;
|
|
620
626
|
_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
621
|
-
var _iterator, _step, promise;
|
|
622
|
-
return _regeneratorRuntime.wrap(function
|
|
627
|
+
var _iterator, _step, promise, _t4;
|
|
628
|
+
return _regeneratorRuntime.wrap(function (_context6) {
|
|
623
629
|
while (1) switch (_context6.prev = _context6.next) {
|
|
624
630
|
case 0:
|
|
625
631
|
_iterator = _createForOfIteratorHelper(callable());
|
|
626
632
|
_context6.prev = 1;
|
|
627
633
|
_iterator.s();
|
|
628
|
-
case
|
|
634
|
+
case 2:
|
|
629
635
|
if ((_step = _iterator.n()).done) {
|
|
630
|
-
_context6.next =
|
|
636
|
+
_context6.next = 6;
|
|
631
637
|
break;
|
|
632
638
|
}
|
|
633
639
|
promise = _step.value;
|
|
634
640
|
if (!stop) {
|
|
635
|
-
_context6.next =
|
|
641
|
+
_context6.next = 3;
|
|
636
642
|
break;
|
|
637
643
|
}
|
|
638
644
|
return _context6.abrupt("return");
|
|
639
|
-
case
|
|
640
|
-
_context6.next =
|
|
645
|
+
case 3:
|
|
646
|
+
_context6.next = 4;
|
|
641
647
|
return promise;
|
|
642
|
-
case
|
|
648
|
+
case 4:
|
|
643
649
|
if (!stop) {
|
|
644
|
-
_context6.next =
|
|
650
|
+
_context6.next = 5;
|
|
645
651
|
break;
|
|
646
652
|
}
|
|
647
653
|
return _context6.abrupt("return");
|
|
648
|
-
case
|
|
649
|
-
_context6.next =
|
|
654
|
+
case 5:
|
|
655
|
+
_context6.next = 2;
|
|
650
656
|
break;
|
|
651
|
-
case
|
|
652
|
-
_context6.next =
|
|
657
|
+
case 6:
|
|
658
|
+
_context6.next = 8;
|
|
653
659
|
break;
|
|
654
|
-
case
|
|
655
|
-
_context6.prev =
|
|
656
|
-
|
|
657
|
-
_iterator.e(
|
|
658
|
-
case
|
|
659
|
-
_context6.prev =
|
|
660
|
+
case 7:
|
|
661
|
+
_context6.prev = 7;
|
|
662
|
+
_t4 = _context6["catch"](1);
|
|
663
|
+
_iterator.e(_t4);
|
|
664
|
+
case 8:
|
|
665
|
+
_context6.prev = 8;
|
|
660
666
|
_iterator.f();
|
|
661
|
-
return _context6.finish(
|
|
662
|
-
case
|
|
667
|
+
return _context6.finish(8);
|
|
668
|
+
case 9:
|
|
663
669
|
case "end":
|
|
664
670
|
return _context6.stop();
|
|
665
671
|
}
|
|
666
|
-
}, _callee5, null, [[1,
|
|
672
|
+
}, _callee5, null, [[1, 7, 8, 9]]);
|
|
667
673
|
}))();
|
|
668
674
|
return function () {
|
|
669
675
|
stop = true;
|
|
@@ -674,59 +680,59 @@ var LeRed = function () {
|
|
|
674
680
|
return LeRed.useEffect(function () {
|
|
675
681
|
var stop = false;
|
|
676
682
|
_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
677
|
-
var _iterator2, _step2, promise;
|
|
678
|
-
return _regeneratorRuntime.wrap(function
|
|
683
|
+
var _iterator2, _step2, promise, _t5;
|
|
684
|
+
return _regeneratorRuntime.wrap(function (_context7) {
|
|
679
685
|
while (1) switch (_context7.prev = _context7.next) {
|
|
680
686
|
case 0:
|
|
681
687
|
if (stop) {
|
|
682
|
-
_context7.next =
|
|
688
|
+
_context7.next = 10;
|
|
683
689
|
break;
|
|
684
690
|
}
|
|
685
691
|
_iterator2 = _createForOfIteratorHelper(callable());
|
|
686
|
-
_context7.prev =
|
|
692
|
+
_context7.prev = 1;
|
|
687
693
|
_iterator2.s();
|
|
688
|
-
case
|
|
694
|
+
case 2:
|
|
689
695
|
if ((_step2 = _iterator2.n()).done) {
|
|
690
|
-
_context7.next =
|
|
696
|
+
_context7.next = 6;
|
|
691
697
|
break;
|
|
692
698
|
}
|
|
693
699
|
promise = _step2.value;
|
|
694
700
|
if (!stop) {
|
|
695
|
-
_context7.next =
|
|
701
|
+
_context7.next = 3;
|
|
696
702
|
break;
|
|
697
703
|
}
|
|
698
704
|
return _context7.abrupt("return");
|
|
699
|
-
case
|
|
700
|
-
_context7.next =
|
|
705
|
+
case 3:
|
|
706
|
+
_context7.next = 4;
|
|
701
707
|
return promise;
|
|
702
|
-
case
|
|
708
|
+
case 4:
|
|
703
709
|
if (!stop) {
|
|
704
|
-
_context7.next =
|
|
710
|
+
_context7.next = 5;
|
|
705
711
|
break;
|
|
706
712
|
}
|
|
707
713
|
return _context7.abrupt("return");
|
|
708
|
-
case
|
|
709
|
-
_context7.next =
|
|
714
|
+
case 5:
|
|
715
|
+
_context7.next = 2;
|
|
710
716
|
break;
|
|
711
|
-
case
|
|
712
|
-
_context7.next =
|
|
717
|
+
case 6:
|
|
718
|
+
_context7.next = 8;
|
|
713
719
|
break;
|
|
714
|
-
case
|
|
715
|
-
_context7.prev =
|
|
716
|
-
|
|
717
|
-
_iterator2.e(
|
|
718
|
-
case
|
|
719
|
-
_context7.prev =
|
|
720
|
+
case 7:
|
|
721
|
+
_context7.prev = 7;
|
|
722
|
+
_t5 = _context7["catch"](1);
|
|
723
|
+
_iterator2.e(_t5);
|
|
724
|
+
case 8:
|
|
725
|
+
_context7.prev = 8;
|
|
720
726
|
_iterator2.f();
|
|
721
|
-
return _context7.finish(
|
|
722
|
-
case
|
|
727
|
+
return _context7.finish(8);
|
|
728
|
+
case 9:
|
|
723
729
|
_context7.next = 0;
|
|
724
730
|
break;
|
|
725
|
-
case
|
|
731
|
+
case 10:
|
|
726
732
|
case "end":
|
|
727
733
|
return _context7.stop();
|
|
728
734
|
}
|
|
729
|
-
}, _callee6, null, [[
|
|
735
|
+
}, _callee6, null, [[1, 7, 8, 9]]);
|
|
730
736
|
}))();
|
|
731
737
|
return function () {
|
|
732
738
|
stop = true;
|
|
@@ -1078,9 +1084,9 @@ var LeRed = function () {
|
|
|
1078
1084
|
url = STRING(url);
|
|
1079
1085
|
var urlHasQ = url.includes('?');
|
|
1080
1086
|
var _LeRed$useState9 = LeRed.useState(url),
|
|
1081
|
-
_LeRed$
|
|
1082
|
-
imageUrl = _LeRed$
|
|
1083
|
-
setImageUrl = _LeRed$
|
|
1087
|
+
_LeRed$useState0 = _slicedToArray(_LeRed$useState9, 2),
|
|
1088
|
+
imageUrl = _LeRed$useState0[0],
|
|
1089
|
+
setImageUrl = _LeRed$useState0[1];
|
|
1084
1090
|
var retries = LeRed.useRef(0);
|
|
1085
1091
|
var timeout = LeRed.useRef({
|
|
1086
1092
|
remove: function remove() {
|
|
@@ -1120,18 +1126,18 @@ var LeRed = function () {
|
|
|
1120
1126
|
var comparingValuesRef = LeRed.useRef(comparingValuesClone);
|
|
1121
1127
|
var latestComparingValuesRef = LeRed.useRef();
|
|
1122
1128
|
latestComparingValuesRef.current = comparingValuesClone;
|
|
1123
|
-
var _LeRed$
|
|
1129
|
+
var _LeRed$useState1 = LeRed.useState(null),
|
|
1130
|
+
_LeRed$useState10 = _slicedToArray(_LeRed$useState1, 2),
|
|
1131
|
+
data = _LeRed$useState10[0],
|
|
1132
|
+
setData = _LeRed$useState10[1];
|
|
1133
|
+
var _LeRed$useState11 = LeRed.useState(true),
|
|
1124
1134
|
_LeRed$useState12 = _slicedToArray(_LeRed$useState11, 2),
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
var _LeRed$useState13 = LeRed.useState(
|
|
1135
|
+
loading = _LeRed$useState12[0],
|
|
1136
|
+
setLoading = _LeRed$useState12[1];
|
|
1137
|
+
var _LeRed$useState13 = LeRed.useState(null),
|
|
1128
1138
|
_LeRed$useState14 = _slicedToArray(_LeRed$useState13, 2),
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
var _LeRed$useState15 = LeRed.useState(null),
|
|
1132
|
-
_LeRed$useState16 = _slicedToArray(_LeRed$useState15, 2),
|
|
1133
|
-
error = _LeRed$useState16[0],
|
|
1134
|
-
setError = _LeRed$useState16[1];
|
|
1139
|
+
error = _LeRed$useState14[0],
|
|
1140
|
+
setError = _LeRed$useState14[1];
|
|
1135
1141
|
LeRed.useEffect(function () {
|
|
1136
1142
|
setLoading(true);
|
|
1137
1143
|
setData(null);
|
|
@@ -1160,7 +1166,7 @@ var LeRed = function () {
|
|
|
1160
1166
|
key = _ref3.key;
|
|
1161
1167
|
wrappedPromises.push(promise.then(/*#__PURE__*/function () {
|
|
1162
1168
|
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(result) {
|
|
1163
|
-
return _regeneratorRuntime.wrap(function
|
|
1169
|
+
return _regeneratorRuntime.wrap(function (_context8) {
|
|
1164
1170
|
while (1) switch (_context8.prev = _context8.next) {
|
|
1165
1171
|
case 0:
|
|
1166
1172
|
return _context8.abrupt("return", {
|
|
@@ -1263,22 +1269,22 @@ var LeRed = function () {
|
|
|
1263
1269
|
}, options !== null && options !== void 0 ? options : {})).then(/*#__PURE__*/function () {
|
|
1264
1270
|
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(response) {
|
|
1265
1271
|
var data;
|
|
1266
|
-
return _regeneratorRuntime.wrap(function
|
|
1272
|
+
return _regeneratorRuntime.wrap(function (_context9) {
|
|
1267
1273
|
while (1) switch (_context9.prev = _context9.next) {
|
|
1268
1274
|
case 0:
|
|
1269
|
-
_context9.next =
|
|
1275
|
+
_context9.next = 1;
|
|
1270
1276
|
return responseFunction(response);
|
|
1271
|
-
case
|
|
1277
|
+
case 1:
|
|
1272
1278
|
data = _context9.sent;
|
|
1273
1279
|
if (!(typeof (options === null || options === void 0 ? void 0 : options.verify) === 'function')) {
|
|
1274
|
-
_context9.next =
|
|
1280
|
+
_context9.next = 2;
|
|
1275
1281
|
break;
|
|
1276
1282
|
}
|
|
1277
|
-
_context9.next =
|
|
1283
|
+
_context9.next = 2;
|
|
1278
1284
|
return options.verify(data, response);
|
|
1279
|
-
case
|
|
1285
|
+
case 2:
|
|
1280
1286
|
return _context9.abrupt("return", data);
|
|
1281
|
-
case
|
|
1287
|
+
case 3:
|
|
1282
1288
|
case "end":
|
|
1283
1289
|
return _context9.stop();
|
|
1284
1290
|
}
|
|
@@ -1363,8 +1369,9 @@ var LeRed = function () {
|
|
|
1363
1369
|
if (ISSET(store)) {
|
|
1364
1370
|
store = LeRed.configureStore(store);
|
|
1365
1371
|
return /*#__PURE__*/React.createElement(ReactRedux.Provider, _extends({
|
|
1366
|
-
store: store
|
|
1367
|
-
|
|
1372
|
+
store: store,
|
|
1373
|
+
children: children
|
|
1374
|
+
}, other));
|
|
1368
1375
|
}
|
|
1369
1376
|
return children;
|
|
1370
1377
|
});
|
|
@@ -1381,44 +1388,44 @@ var LeRed = function () {
|
|
|
1381
1388
|
var loading = _ref9.loading,
|
|
1382
1389
|
load = _ref9.load,
|
|
1383
1390
|
other = _objectWithoutProperties(_ref9, _excluded2);
|
|
1384
|
-
var _LeRed$
|
|
1385
|
-
_LeRed$
|
|
1386
|
-
Component = _LeRed$
|
|
1387
|
-
setComponent = _LeRed$
|
|
1391
|
+
var _LeRed$useState15 = LeRed.useState(loading !== null && loading !== void 0 ? loading : null),
|
|
1392
|
+
_LeRed$useState16 = _slicedToArray(_LeRed$useState15, 2),
|
|
1393
|
+
Component = _LeRed$useState16[0],
|
|
1394
|
+
setComponent = _LeRed$useState16[1];
|
|
1388
1395
|
LeRed.useEffect(function () {
|
|
1389
1396
|
_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
|
|
1390
|
-
var LoadedComponent;
|
|
1391
|
-
return _regeneratorRuntime.wrap(function
|
|
1392
|
-
while (1) switch (
|
|
1397
|
+
var LoadedComponent, _t6;
|
|
1398
|
+
return _regeneratorRuntime.wrap(function (_context0) {
|
|
1399
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
1393
1400
|
case 0:
|
|
1394
1401
|
if (!(typeof load === 'function')) {
|
|
1395
|
-
|
|
1402
|
+
_context0.next = 2;
|
|
1396
1403
|
break;
|
|
1397
1404
|
}
|
|
1398
|
-
|
|
1405
|
+
_context0.next = 1;
|
|
1399
1406
|
return load();
|
|
1400
|
-
case
|
|
1401
|
-
|
|
1402
|
-
|
|
1407
|
+
case 1:
|
|
1408
|
+
_t6 = _context0.sent;
|
|
1409
|
+
_context0.next = 4;
|
|
1403
1410
|
break;
|
|
1404
|
-
case
|
|
1405
|
-
|
|
1411
|
+
case 2:
|
|
1412
|
+
_context0.next = 3;
|
|
1406
1413
|
return load;
|
|
1407
|
-
case
|
|
1408
|
-
|
|
1409
|
-
case
|
|
1410
|
-
LoadedComponent =
|
|
1414
|
+
case 3:
|
|
1415
|
+
_t6 = _context0.sent;
|
|
1416
|
+
case 4:
|
|
1417
|
+
LoadedComponent = _t6;
|
|
1411
1418
|
if (LoadedComponent) {
|
|
1412
|
-
|
|
1419
|
+
_context0.next = 5;
|
|
1413
1420
|
break;
|
|
1414
1421
|
}
|
|
1415
1422
|
setComponent(null);
|
|
1416
|
-
return
|
|
1417
|
-
case
|
|
1423
|
+
return _context0.abrupt("return");
|
|
1424
|
+
case 5:
|
|
1418
1425
|
setComponent(/*#__PURE__*/React.createElement(LoadedComponent, other));
|
|
1419
|
-
case
|
|
1426
|
+
case 6:
|
|
1420
1427
|
case "end":
|
|
1421
|
-
return
|
|
1428
|
+
return _context0.stop();
|
|
1422
1429
|
}
|
|
1423
1430
|
}, _callee9);
|
|
1424
1431
|
}))();
|