react-native-onyx 1.0.35 → 1.0.37
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/web.development.js
CHANGED
|
@@ -15,10 +15,17 @@ return /******/ (() => { // webpackBootstrap
|
|
|
15
15
|
/*!***********************!*\
|
|
16
16
|
!*** ./lib/Logger.js ***!
|
|
17
17
|
\***********************/
|
|
18
|
-
/***/ ((__unused_webpack_module,
|
|
18
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
"use strict";
|
|
21
|
+
__webpack_require__.r(__webpack_exports__);
|
|
22
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
23
|
+
/* harmony export */ "logAlert": () => (/* binding */ logAlert),
|
|
24
|
+
/* harmony export */ "logInfo": () => (/* binding */ logInfo),
|
|
25
|
+
/* harmony export */ "registerLogger": () => (/* binding */ registerLogger)
|
|
26
|
+
/* harmony export */ });
|
|
27
|
+
// Logging callback
|
|
28
|
+
let logger = () => {};
|
|
22
29
|
|
|
23
30
|
/**
|
|
24
31
|
* Register the logging callback
|
|
@@ -35,7 +42,7 @@ function registerLogger(callback) {
|
|
|
35
42
|
* @param {String} message
|
|
36
43
|
*/
|
|
37
44
|
function logAlert(message) {
|
|
38
|
-
logger({ message:
|
|
45
|
+
logger({ message: `[Onyx] ${message}`, level: 'alert' });
|
|
39
46
|
}
|
|
40
47
|
|
|
41
48
|
/**
|
|
@@ -44,31 +51,52 @@ function logAlert(message) {
|
|
|
44
51
|
* @param {String} message
|
|
45
52
|
*/
|
|
46
53
|
function logInfo(message) {
|
|
47
|
-
logger({ message:
|
|
54
|
+
logger({ message: `[Onyx] ${message}`, level: 'info' });
|
|
48
55
|
}
|
|
49
56
|
|
|
57
|
+
|
|
58
|
+
|
|
50
59
|
/***/ }),
|
|
51
60
|
|
|
52
61
|
/***/ "./lib/Onyx.js":
|
|
53
62
|
/*!*********************!*\
|
|
54
63
|
!*** ./lib/Onyx.js ***!
|
|
55
64
|
\*********************/
|
|
56
|
-
/***/ ((__unused_webpack_module,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
var
|
|
64
|
-
var
|
|
65
|
-
var
|
|
66
|
-
var
|
|
67
|
-
var
|
|
68
|
-
|
|
65
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
66
|
+
|
|
67
|
+
"use strict";
|
|
68
|
+
__webpack_require__.r(__webpack_exports__);
|
|
69
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
70
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
71
|
+
/* harmony export */ });
|
|
72
|
+
/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! underscore */ "underscore");
|
|
73
|
+
/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(underscore__WEBPACK_IMPORTED_MODULE_0__);
|
|
74
|
+
/* harmony import */ var expensify_common_lib_str__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! expensify-common/lib/str */ "expensify-common/lib/str");
|
|
75
|
+
/* harmony import */ var expensify_common_lib_str__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(expensify_common_lib_str__WEBPACK_IMPORTED_MODULE_1__);
|
|
76
|
+
/* harmony import */ var fast_equals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! fast-equals */ "fast-equals");
|
|
77
|
+
/* harmony import */ var fast_equals__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(fast_equals__WEBPACK_IMPORTED_MODULE_2__);
|
|
78
|
+
/* harmony import */ var lodash_get__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! lodash/get */ "lodash/get");
|
|
79
|
+
/* harmony import */ var lodash_get__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(lodash_get__WEBPACK_IMPORTED_MODULE_3__);
|
|
80
|
+
/* harmony import */ var _storage__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./storage */ "./lib/storage/index.web.js");
|
|
81
|
+
/* harmony import */ var _Logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Logger */ "./lib/Logger.js");
|
|
82
|
+
/* harmony import */ var _OnyxCache__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./OnyxCache */ "./lib/OnyxCache.js");
|
|
83
|
+
/* harmony import */ var _createDeferredTask__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./createDeferredTask */ "./lib/createDeferredTask.js");
|
|
84
|
+
/* harmony import */ var _fastMerge__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./fastMerge */ "./lib/fastMerge.js");
|
|
85
|
+
/* harmony import */ var _metrics_PerformanceUtils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./metrics/PerformanceUtils */ "./lib/metrics/PerformanceUtils.js");
|
|
86
|
+
/* eslint-disable no-continue */
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
69
97
|
|
|
70
98
|
// Method constants
|
|
71
|
-
|
|
99
|
+
const METHOD = {
|
|
72
100
|
SET: 'set',
|
|
73
101
|
MERGE: 'merge',
|
|
74
102
|
MERGE_COLLECTION: 'mergecollection',
|
|
@@ -76,30 +104,30 @@ var METHOD = {
|
|
|
76
104
|
};
|
|
77
105
|
|
|
78
106
|
// Keeps track of the last connectionID that was used so we can keep incrementing it
|
|
79
|
-
|
|
107
|
+
let lastConnectionID = 0;
|
|
80
108
|
|
|
81
109
|
// Holds a mapping of all the react components that want their state subscribed to a store key
|
|
82
|
-
|
|
110
|
+
const callbackToStateMapping = {};
|
|
83
111
|
|
|
84
112
|
// Stores all of the keys that Onyx can use. Must be defined in init().
|
|
85
|
-
|
|
113
|
+
let onyxKeys = {};
|
|
86
114
|
|
|
87
115
|
// Holds a list of keys that have been directly subscribed to or recently modified from least to most recent
|
|
88
|
-
|
|
116
|
+
let recentlyAccessedKeys = [];
|
|
89
117
|
|
|
90
118
|
// Holds a list of keys that are safe to remove when we reach max storage. If a key does not match with
|
|
91
119
|
// whatever appears in this list it will NEVER be a candidate for eviction.
|
|
92
|
-
|
|
120
|
+
let evictionAllowList = [];
|
|
93
121
|
|
|
94
122
|
// Holds a map of keys and connectionID arrays whose keys will never be automatically evicted as
|
|
95
123
|
// long as we have at least one subscriber that returns false for the canEvict property.
|
|
96
|
-
|
|
124
|
+
const evictionBlocklist = {};
|
|
97
125
|
|
|
98
126
|
// Optional user-provided key value states set when Onyx initializes or clears
|
|
99
|
-
|
|
127
|
+
let defaultKeyStates = {};
|
|
100
128
|
|
|
101
129
|
// Connections can be made before `Onyx.init`. They would wait for this task before resolving
|
|
102
|
-
|
|
130
|
+
const deferredInitTask = (0,_createDeferredTask__WEBPACK_IMPORTED_MODULE_4__["default"])();
|
|
103
131
|
|
|
104
132
|
/**
|
|
105
133
|
* Uses a selector string or function to return a simplified version of sourceData
|
|
@@ -109,9 +137,9 @@ var deferredInitTask = (0, _createDeferredTask.default)();
|
|
|
109
137
|
* If it's a function, it is passed the sourceData and it should return the simplified data
|
|
110
138
|
* @returns {Mixed}
|
|
111
139
|
*/
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
140
|
+
const getSubsetOfData = (sourceData, selector) => underscore__WEBPACK_IMPORTED_MODULE_0___default().isFunction(selector) ?
|
|
141
|
+
selector(sourceData) :
|
|
142
|
+
lodash_get__WEBPACK_IMPORTED_MODULE_3___default()(sourceData, selector);
|
|
115
143
|
|
|
116
144
|
/**
|
|
117
145
|
* Takes a collection of items (eg. {testKey_1:{a:'a'}, testKey_2:{b:'b'}})
|
|
@@ -121,12 +149,12 @@ var getSubsetOfData = function getSubsetOfData(sourceData, selector) {return _un
|
|
|
121
149
|
* @param {String|Function} selector (see method docs for getSubsetOfData() for full details)
|
|
122
150
|
* @returns {Object}
|
|
123
151
|
*/
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
152
|
+
const reduceCollectionWithSelector = (collection, selector) => underscore__WEBPACK_IMPORTED_MODULE_0___default().reduce(collection, (finalCollection, item, key) => {
|
|
153
|
+
// eslint-disable-next-line no-param-reassign
|
|
154
|
+
finalCollection[key] = getSubsetOfData(item, selector);
|
|
127
155
|
|
|
128
|
-
|
|
129
|
-
|
|
156
|
+
return finalCollection;
|
|
157
|
+
}, {});
|
|
130
158
|
|
|
131
159
|
/**
|
|
132
160
|
* Get some data from the store
|
|
@@ -137,26 +165,26 @@ var reduceCollectionWithSelector = function reduceCollectionWithSelector(collect
|
|
|
137
165
|
*/
|
|
138
166
|
function get(key) {
|
|
139
167
|
// When we already have the value in cache - resolve right away
|
|
140
|
-
if (
|
|
141
|
-
return Promise.resolve(
|
|
168
|
+
if (_OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].hasCacheForKey(key)) {
|
|
169
|
+
return Promise.resolve(_OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].getValue(key));
|
|
142
170
|
}
|
|
143
171
|
|
|
144
|
-
|
|
172
|
+
const taskName = `get:${key}`;
|
|
145
173
|
|
|
146
174
|
// When a value retrieving task for this key is still running hook to it
|
|
147
|
-
if (
|
|
148
|
-
return
|
|
175
|
+
if (_OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].hasPendingTask(taskName)) {
|
|
176
|
+
return _OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].getTaskPromise(taskName);
|
|
149
177
|
}
|
|
150
178
|
|
|
151
179
|
// Otherwise retrieve the value from storage and capture a promise to aid concurrent usages
|
|
152
|
-
|
|
153
|
-
then(
|
|
154
|
-
|
|
180
|
+
const promise = _storage__WEBPACK_IMPORTED_MODULE_6__["default"].getItem(key).
|
|
181
|
+
then((val) => {
|
|
182
|
+
_OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].set(key, val);
|
|
155
183
|
return val;
|
|
156
184
|
}).
|
|
157
|
-
catch(
|
|
185
|
+
catch((err) => _Logger__WEBPACK_IMPORTED_MODULE_7__.logInfo(`Unable to get item from persistent storage. Key: ${key} Error: ${err}`));
|
|
158
186
|
|
|
159
|
-
return
|
|
187
|
+
return _OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].captureTask(taskName, promise);
|
|
160
188
|
}
|
|
161
189
|
|
|
162
190
|
/**
|
|
@@ -166,26 +194,26 @@ function get(key) {
|
|
|
166
194
|
*/
|
|
167
195
|
function getAllKeys() {
|
|
168
196
|
// When we've already read stored keys, resolve right away
|
|
169
|
-
|
|
197
|
+
const storedKeys = _OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].getAllKeys();
|
|
170
198
|
if (storedKeys.length > 0) {
|
|
171
199
|
return Promise.resolve(storedKeys);
|
|
172
200
|
}
|
|
173
201
|
|
|
174
|
-
|
|
202
|
+
const taskName = 'getAllKeys';
|
|
175
203
|
|
|
176
204
|
// When a value retrieving task for all keys is still running hook to it
|
|
177
|
-
if (
|
|
178
|
-
return
|
|
205
|
+
if (_OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].hasPendingTask(taskName)) {
|
|
206
|
+
return _OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].getTaskPromise(taskName);
|
|
179
207
|
}
|
|
180
208
|
|
|
181
209
|
// Otherwise retrieve the keys from storage and capture a promise to aid concurrent usages
|
|
182
|
-
|
|
183
|
-
then(
|
|
184
|
-
|
|
210
|
+
const promise = _storage__WEBPACK_IMPORTED_MODULE_6__["default"].getAllKeys().
|
|
211
|
+
then((keys) => {
|
|
212
|
+
underscore__WEBPACK_IMPORTED_MODULE_0___default().each(keys, (key) => _OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].addKey(key));
|
|
185
213
|
return keys;
|
|
186
214
|
});
|
|
187
215
|
|
|
188
|
-
return
|
|
216
|
+
return _OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].captureTask(taskName, promise);
|
|
189
217
|
}
|
|
190
218
|
|
|
191
219
|
/**
|
|
@@ -197,7 +225,7 @@ function getAllKeys() {
|
|
|
197
225
|
* @returns {Boolean}
|
|
198
226
|
*/
|
|
199
227
|
function isCollectionKey(key) {
|
|
200
|
-
return
|
|
228
|
+
return underscore__WEBPACK_IMPORTED_MODULE_0___default().contains(underscore__WEBPACK_IMPORTED_MODULE_0___default().values(onyxKeys.COLLECTION), key);
|
|
201
229
|
}
|
|
202
230
|
|
|
203
231
|
/**
|
|
@@ -206,7 +234,7 @@ function isCollectionKey(key) {
|
|
|
206
234
|
* @returns {Boolean}
|
|
207
235
|
*/
|
|
208
236
|
function isCollectionMemberKey(collectionKey, key) {
|
|
209
|
-
return
|
|
237
|
+
return expensify_common_lib_str__WEBPACK_IMPORTED_MODULE_1___default().startsWith(key, collectionKey) && key.length > collectionKey.length;
|
|
210
238
|
}
|
|
211
239
|
|
|
212
240
|
/**
|
|
@@ -220,7 +248,7 @@ function isCollectionMemberKey(collectionKey, key) {
|
|
|
220
248
|
*/
|
|
221
249
|
function isKeyMatch(configKey, key) {
|
|
222
250
|
return isCollectionKey(configKey) ?
|
|
223
|
-
|
|
251
|
+
expensify_common_lib_str__WEBPACK_IMPORTED_MODULE_1___default().startsWith(key, configKey) :
|
|
224
252
|
configKey === key;
|
|
225
253
|
}
|
|
226
254
|
|
|
@@ -233,7 +261,7 @@ function isKeyMatch(configKey, key) {
|
|
|
233
261
|
* @returns {Boolean}
|
|
234
262
|
*/
|
|
235
263
|
function isSafeEvictionKey(testKey) {
|
|
236
|
-
return
|
|
264
|
+
return underscore__WEBPACK_IMPORTED_MODULE_0___default().some(evictionAllowList, (key) => isKeyMatch(key, testKey));
|
|
237
265
|
}
|
|
238
266
|
|
|
239
267
|
/**
|
|
@@ -243,7 +271,7 @@ function isSafeEvictionKey(testKey) {
|
|
|
243
271
|
* @param {String} key
|
|
244
272
|
*/
|
|
245
273
|
function removeLastAccessedKey(key) {
|
|
246
|
-
recentlyAccessedKeys =
|
|
274
|
+
recentlyAccessedKeys = underscore__WEBPACK_IMPORTED_MODULE_0___default().without(recentlyAccessedKeys, key);
|
|
247
275
|
}
|
|
248
276
|
|
|
249
277
|
/**
|
|
@@ -273,7 +301,7 @@ function addLastAccessedKey(key) {
|
|
|
273
301
|
* @param {Number} connectionID
|
|
274
302
|
*/
|
|
275
303
|
function removeFromEvictionBlockList(key, connectionID) {
|
|
276
|
-
evictionBlocklist[key] =
|
|
304
|
+
evictionBlocklist[key] = underscore__WEBPACK_IMPORTED_MODULE_0___default().without(evictionBlocklist[key] || [], connectionID);
|
|
277
305
|
|
|
278
306
|
// Remove the key if there are no more subscribers
|
|
279
307
|
if (evictionBlocklist[key].length === 0) {
|
|
@@ -309,9 +337,9 @@ function addToEvictionBlockList(key, connectionID) {
|
|
|
309
337
|
*/
|
|
310
338
|
function addAllSafeEvictionKeysToRecentlyAccessedList() {
|
|
311
339
|
return getAllKeys().
|
|
312
|
-
then(
|
|
313
|
-
|
|
314
|
-
|
|
340
|
+
then((keys) => {
|
|
341
|
+
underscore__WEBPACK_IMPORTED_MODULE_0___default().each(evictionAllowList, (safeEvictionKey) => {
|
|
342
|
+
underscore__WEBPACK_IMPORTED_MODULE_0___default().each(keys, (key) => {
|
|
315
343
|
if (!isKeyMatch(safeEvictionKey, key)) {
|
|
316
344
|
return;
|
|
317
345
|
}
|
|
@@ -327,12 +355,12 @@ function addAllSafeEvictionKeysToRecentlyAccessedList() {
|
|
|
327
355
|
* @returns {Object}
|
|
328
356
|
*/
|
|
329
357
|
function getCachedCollection(collectionKey) {
|
|
330
|
-
|
|
331
|
-
|
|
358
|
+
const collectionMemberKeys = underscore__WEBPACK_IMPORTED_MODULE_0___default().filter(_OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].getAllKeys(),
|
|
359
|
+
(storedKey) => isCollectionMemberKey(collectionKey, storedKey));
|
|
332
360
|
|
|
333
361
|
|
|
334
|
-
return
|
|
335
|
-
|
|
362
|
+
return underscore__WEBPACK_IMPORTED_MODULE_0___default().reduce(collectionMemberKeys, (prev, curr) => {
|
|
363
|
+
const cachedValue = _OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].getValue(curr);
|
|
336
364
|
if (!cachedValue) {
|
|
337
365
|
return prev;
|
|
338
366
|
}
|
|
@@ -354,60 +382,60 @@ function keysChanged(collectionKey, partialCollection) {
|
|
|
354
382
|
// We are iterating over all subscribers similar to keyChanged(). However, we are looking for subscribers who are subscribing to either a collection key or
|
|
355
383
|
// individual collection key member for the collection that is being updated. It is important to note that the collection parameter cane be a PARTIAL collection
|
|
356
384
|
// and does not represent all of the combined keys and values for a collection key. It is just the "new" data that was merged in via mergeCollection().
|
|
357
|
-
|
|
358
|
-
i) {
|
|
359
|
-
|
|
385
|
+
const stateMappingKeys = underscore__WEBPACK_IMPORTED_MODULE_0___default().keys(callbackToStateMapping);
|
|
386
|
+
for (let i = 0; i < stateMappingKeys.length; i++) {
|
|
387
|
+
const subscriber = callbackToStateMapping[stateMappingKeys[i]];
|
|
360
388
|
if (!subscriber) {
|
|
361
|
-
|
|
389
|
+
continue;
|
|
362
390
|
}
|
|
363
391
|
|
|
364
392
|
// Skip iteration if we do not have a collection key or a collection member key on this subscriber
|
|
365
|
-
if (!
|
|
366
|
-
|
|
393
|
+
if (!expensify_common_lib_str__WEBPACK_IMPORTED_MODULE_1___default().startsWith(subscriber.key, collectionKey)) {
|
|
394
|
+
continue;
|
|
367
395
|
}
|
|
368
396
|
|
|
369
397
|
/**
|
|
370
398
|
* e.g. Onyx.connect({key: ONYXKEYS.COLLECTION.REPORT, callback: ...});
|
|
371
399
|
*/
|
|
372
|
-
|
|
400
|
+
const isSubscribedToCollectionKey = subscriber.key === collectionKey;
|
|
373
401
|
|
|
374
402
|
/**
|
|
375
403
|
* e.g. Onyx.connect({key: `${ONYXKEYS.COLLECTION.REPORT}{reportID}`, callback: ...});
|
|
376
404
|
*/
|
|
377
|
-
|
|
405
|
+
const isSubscribedToCollectionMemberKey = isCollectionMemberKey(collectionKey, subscriber.key);
|
|
378
406
|
|
|
379
407
|
// We prepare the "cached collection" which is the entire collection + the new partial data that
|
|
380
408
|
// was merged in via mergeCollection().
|
|
381
|
-
|
|
409
|
+
const cachedCollection = getCachedCollection(collectionKey);
|
|
382
410
|
|
|
383
411
|
// Regular Onyx.connect() subscriber found.
|
|
384
|
-
if (
|
|
412
|
+
if (underscore__WEBPACK_IMPORTED_MODULE_0___default().isFunction(subscriber.callback)) {
|
|
385
413
|
// If they are subscribed to the collection key and using waitForCollectionCallback then we'll
|
|
386
414
|
// send the whole cached collection.
|
|
387
415
|
if (isSubscribedToCollectionKey) {
|
|
388
416
|
if (subscriber.waitForCollectionCallback) {
|
|
389
417
|
subscriber.callback(cachedCollection);
|
|
390
|
-
|
|
418
|
+
continue;
|
|
391
419
|
}
|
|
392
420
|
|
|
393
421
|
// If they are not using waitForCollectionCallback then we notify the subscriber with
|
|
394
422
|
// the new merged data but only for any keys in the partial collection.
|
|
395
|
-
|
|
396
|
-
for (
|
|
397
|
-
|
|
423
|
+
const dataKeys = underscore__WEBPACK_IMPORTED_MODULE_0___default().keys(partialCollection);
|
|
424
|
+
for (let j = 0; j < dataKeys.length; j++) {
|
|
425
|
+
const dataKey = dataKeys[j];
|
|
398
426
|
subscriber.callback(cachedCollection[dataKey], dataKey);
|
|
399
427
|
}
|
|
400
|
-
|
|
428
|
+
continue;
|
|
401
429
|
}
|
|
402
430
|
|
|
403
431
|
// And if the subscriber is specifically only tracking a particular collection member key then we will
|
|
404
432
|
// notify them with the cached data for that key only.
|
|
405
433
|
if (isSubscribedToCollectionMemberKey) {
|
|
406
434
|
subscriber.callback(cachedCollection[subscriber.key], subscriber.key);
|
|
407
|
-
|
|
435
|
+
continue;
|
|
408
436
|
}
|
|
409
437
|
|
|
410
|
-
|
|
438
|
+
continue;
|
|
411
439
|
}
|
|
412
440
|
|
|
413
441
|
// React component subscriber found.
|
|
@@ -418,78 +446,78 @@ function keysChanged(collectionKey, partialCollection) {
|
|
|
418
446
|
// If the subscriber has a selector, then the component's state must only be updated with the data
|
|
419
447
|
// returned by the selector.
|
|
420
448
|
if (subscriber.selector) {
|
|
421
|
-
subscriber.withOnyxInstance.setState(
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
if (!(0,
|
|
426
|
-
return
|
|
427
|
-
|
|
428
|
-
|
|
449
|
+
subscriber.withOnyxInstance.setState((prevState) => {
|
|
450
|
+
const previousData = reduceCollectionWithSelector(prevState[subscriber.statePropertyName], subscriber.selector);
|
|
451
|
+
const newData = reduceCollectionWithSelector(cachedCollection, subscriber.selector);
|
|
452
|
+
|
|
453
|
+
if (!(0,fast_equals__WEBPACK_IMPORTED_MODULE_2__.deepEqual)(previousData, newData)) {
|
|
454
|
+
return {
|
|
455
|
+
[subscriber.statePropertyName]: newData
|
|
456
|
+
};
|
|
429
457
|
}
|
|
430
458
|
return null;
|
|
431
459
|
});
|
|
432
|
-
|
|
460
|
+
continue;
|
|
433
461
|
}
|
|
434
462
|
|
|
435
|
-
subscriber.withOnyxInstance.setState(
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
for (
|
|
439
|
-
|
|
440
|
-
finalCollection[
|
|
463
|
+
subscriber.withOnyxInstance.setState((prevState) => {
|
|
464
|
+
const finalCollection = underscore__WEBPACK_IMPORTED_MODULE_0___default().clone(prevState[subscriber.statePropertyName] || {});
|
|
465
|
+
const dataKeys = underscore__WEBPACK_IMPORTED_MODULE_0___default().keys(partialCollection);
|
|
466
|
+
for (let j = 0; j < dataKeys.length; j++) {
|
|
467
|
+
const dataKey = dataKeys[j];
|
|
468
|
+
finalCollection[dataKey] = cachedCollection[dataKey];
|
|
441
469
|
}
|
|
442
470
|
|
|
443
|
-
|
|
444
|
-
return
|
|
445
|
-
|
|
446
|
-
|
|
471
|
+
_metrics_PerformanceUtils__WEBPACK_IMPORTED_MODULE_8__.logSetStateCall(subscriber, prevState[subscriber.statePropertyName], finalCollection, 'keysChanged', collectionKey);
|
|
472
|
+
return {
|
|
473
|
+
[subscriber.statePropertyName]: finalCollection
|
|
474
|
+
};
|
|
447
475
|
});
|
|
448
|
-
|
|
476
|
+
continue;
|
|
449
477
|
}
|
|
450
478
|
|
|
451
479
|
// If a React component is only interested in a single key then we can set the cached value directly to the state name.
|
|
452
480
|
if (isSubscribedToCollectionMemberKey) {
|
|
453
481
|
// However, we only want to update this subscriber if the partial data contains a change.
|
|
454
482
|
// Otherwise, we would update them with a value they already have and trigger an unnecessary re-render.
|
|
455
|
-
|
|
456
|
-
if (
|
|
457
|
-
|
|
483
|
+
const dataFromCollection = partialCollection[subscriber.key];
|
|
484
|
+
if (underscore__WEBPACK_IMPORTED_MODULE_0___default().isUndefined(dataFromCollection)) {
|
|
485
|
+
continue;
|
|
458
486
|
}
|
|
459
487
|
|
|
460
488
|
// If the subscriber has a selector, then the component's state must only be updated with the data
|
|
461
489
|
// returned by the selector and the state should only change when the subset of data changes from what
|
|
462
490
|
// it was previously.
|
|
463
491
|
if (subscriber.selector) {
|
|
464
|
-
subscriber.withOnyxInstance.setState(
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
if (!(0,
|
|
468
|
-
|
|
469
|
-
return
|
|
470
|
-
|
|
471
|
-
|
|
492
|
+
subscriber.withOnyxInstance.setState((prevState) => {
|
|
493
|
+
const prevData = prevState[subscriber.statePropertyName];
|
|
494
|
+
const newData = getSubsetOfData(cachedCollection[subscriber.key], subscriber.selector);
|
|
495
|
+
if (!(0,fast_equals__WEBPACK_IMPORTED_MODULE_2__.deepEqual)(prevData, newData)) {
|
|
496
|
+
_metrics_PerformanceUtils__WEBPACK_IMPORTED_MODULE_8__.logSetStateCall(subscriber, prevData, newData, 'keysChanged', collectionKey);
|
|
497
|
+
return {
|
|
498
|
+
[subscriber.statePropertyName]: newData
|
|
499
|
+
};
|
|
472
500
|
}
|
|
473
501
|
|
|
474
502
|
return null;
|
|
475
503
|
});
|
|
476
|
-
|
|
504
|
+
continue;
|
|
477
505
|
}
|
|
478
506
|
|
|
479
|
-
subscriber.withOnyxInstance.setState(
|
|
480
|
-
|
|
481
|
-
|
|
507
|
+
subscriber.withOnyxInstance.setState((prevState) => {
|
|
508
|
+
const data = cachedCollection[subscriber.key];
|
|
509
|
+
const previousData = prevState[subscriber.statePropertyName];
|
|
482
510
|
if (data === previousData) {
|
|
483
511
|
return null;
|
|
484
512
|
}
|
|
485
513
|
|
|
486
|
-
|
|
487
|
-
return
|
|
488
|
-
|
|
489
|
-
|
|
514
|
+
_metrics_PerformanceUtils__WEBPACK_IMPORTED_MODULE_8__.logSetStateCall(subscriber, previousData, data, 'keysChanged', collectionKey);
|
|
515
|
+
return {
|
|
516
|
+
[subscriber.statePropertyName]: data
|
|
517
|
+
};
|
|
490
518
|
});
|
|
491
519
|
}
|
|
492
|
-
}
|
|
520
|
+
}
|
|
493
521
|
}
|
|
494
522
|
}
|
|
495
523
|
|
|
@@ -506,7 +534,7 @@ function keysChanged(collectionKey, partialCollection) {
|
|
|
506
534
|
*/
|
|
507
535
|
function keyChanged(key, data, canUpdateSubscriber) {
|
|
508
536
|
// Add or remove this key from the recentlyAccessedKeys lists
|
|
509
|
-
if (!
|
|
537
|
+
if (!underscore__WEBPACK_IMPORTED_MODULE_0___default().isNull(data)) {
|
|
510
538
|
addLastAccessedKey(key);
|
|
511
539
|
} else {
|
|
512
540
|
removeLastAccessedKey(key);
|
|
@@ -515,24 +543,24 @@ function keyChanged(key, data, canUpdateSubscriber) {
|
|
|
515
543
|
// We are iterating over all subscribers to see if they are interested in the key that has just changed. If the subscriber's key is a collection key then we will
|
|
516
544
|
// notify them if the key that changed is a collection member. Or if it is a regular key notify them when there is an exact match. Depending on whether the subscriber
|
|
517
545
|
// was connected via withOnyx we will call setState() directly on the withOnyx instance. If it is a regular connection we will pass the data to the provided callback.
|
|
518
|
-
|
|
519
|
-
i) {
|
|
520
|
-
|
|
521
|
-
if (!subscriber || !isKeyMatch(subscriber.key, key) ||
|
|
522
|
-
|
|
546
|
+
const stateMappingKeys = underscore__WEBPACK_IMPORTED_MODULE_0___default().keys(callbackToStateMapping);
|
|
547
|
+
for (let i = 0; i < stateMappingKeys.length; i++) {
|
|
548
|
+
const subscriber = callbackToStateMapping[stateMappingKeys[i]];
|
|
549
|
+
if (!subscriber || !isKeyMatch(subscriber.key, key) || underscore__WEBPACK_IMPORTED_MODULE_0___default().isFunction(canUpdateSubscriber) && !canUpdateSubscriber(subscriber)) {
|
|
550
|
+
continue;
|
|
523
551
|
}
|
|
524
552
|
|
|
525
553
|
// Subscriber is a regular call to connect() and provided a callback
|
|
526
|
-
if (
|
|
554
|
+
if (underscore__WEBPACK_IMPORTED_MODULE_0___default().isFunction(subscriber.callback)) {
|
|
527
555
|
if (isCollectionKey(subscriber.key) && subscriber.waitForCollectionCallback) {
|
|
528
|
-
|
|
556
|
+
const cachedCollection = getCachedCollection(subscriber.key);
|
|
529
557
|
cachedCollection[key] = data;
|
|
530
558
|
subscriber.callback(cachedCollection);
|
|
531
|
-
|
|
559
|
+
continue;
|
|
532
560
|
}
|
|
533
561
|
|
|
534
562
|
subscriber.callback(data, key);
|
|
535
|
-
|
|
563
|
+
continue;
|
|
536
564
|
}
|
|
537
565
|
|
|
538
566
|
// Subscriber connected via withOnyx() HOC
|
|
@@ -542,72 +570,72 @@ function keyChanged(key, data, canUpdateSubscriber) {
|
|
|
542
570
|
// If the subscriber has a selector, then the consumer of this data must only be given the data
|
|
543
571
|
// returned by the selector and only when the selected data has changed.
|
|
544
572
|
if (subscriber.selector) {
|
|
545
|
-
subscriber.withOnyxInstance.setState(
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
if (!(0,
|
|
555
|
-
|
|
556
|
-
return
|
|
557
|
-
|
|
558
|
-
|
|
573
|
+
subscriber.withOnyxInstance.setState((prevState) => {
|
|
574
|
+
const prevData = prevState[subscriber.statePropertyName];
|
|
575
|
+
const newData = {
|
|
576
|
+
[key]: getSubsetOfData(data, subscriber.selector)
|
|
577
|
+
};
|
|
578
|
+
const prevDataWithNewData = {
|
|
579
|
+
...prevData,
|
|
580
|
+
[key]: getSubsetOfData(data, subscriber.selector)
|
|
581
|
+
};
|
|
582
|
+
if (!(0,fast_equals__WEBPACK_IMPORTED_MODULE_2__.deepEqual)(prevData, prevDataWithNewData)) {
|
|
583
|
+
_metrics_PerformanceUtils__WEBPACK_IMPORTED_MODULE_8__.logSetStateCall(subscriber, prevData, newData, 'keyChanged', key);
|
|
584
|
+
return {
|
|
585
|
+
[subscriber.statePropertyName]: prevDataWithNewData
|
|
586
|
+
};
|
|
559
587
|
}
|
|
560
588
|
return null;
|
|
561
589
|
});
|
|
562
|
-
|
|
590
|
+
continue;
|
|
563
591
|
}
|
|
564
592
|
|
|
565
|
-
subscriber.withOnyxInstance.setState(
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
return
|
|
573
|
-
|
|
574
|
-
|
|
593
|
+
subscriber.withOnyxInstance.setState((prevState) => {
|
|
594
|
+
const collection = prevState[subscriber.statePropertyName] || {};
|
|
595
|
+
const newCollection = {
|
|
596
|
+
...collection,
|
|
597
|
+
[key]: data
|
|
598
|
+
};
|
|
599
|
+
_metrics_PerformanceUtils__WEBPACK_IMPORTED_MODULE_8__.logSetStateCall(subscriber, collection, newCollection, 'keyChanged', key);
|
|
600
|
+
return {
|
|
601
|
+
[subscriber.statePropertyName]: newCollection
|
|
602
|
+
};
|
|
575
603
|
});
|
|
576
|
-
|
|
604
|
+
continue;
|
|
577
605
|
}
|
|
578
606
|
|
|
579
607
|
// If the subscriber has a selector, then the component's state must only be updated with the data
|
|
580
608
|
// returned by the selector and only if the selected data has changed.
|
|
581
609
|
if (subscriber.selector) {
|
|
582
|
-
subscriber.withOnyxInstance.setState(
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
if (!(0,
|
|
586
|
-
return
|
|
587
|
-
|
|
588
|
-
|
|
610
|
+
subscriber.withOnyxInstance.setState((prevState) => {
|
|
611
|
+
const previousValue = getSubsetOfData(prevState[subscriber.statePropertyName], subscriber.selector);
|
|
612
|
+
const newValue = getSubsetOfData(data, subscriber.selector);
|
|
613
|
+
if (!(0,fast_equals__WEBPACK_IMPORTED_MODULE_2__.deepEqual)(previousValue, newValue)) {
|
|
614
|
+
return {
|
|
615
|
+
[subscriber.statePropertyName]: newValue
|
|
616
|
+
};
|
|
589
617
|
}
|
|
590
618
|
return null;
|
|
591
619
|
});
|
|
592
|
-
|
|
620
|
+
continue;
|
|
593
621
|
}
|
|
594
622
|
|
|
595
623
|
// If we did not match on a collection key then we just set the new data to the state property
|
|
596
|
-
subscriber.withOnyxInstance.setState(
|
|
597
|
-
|
|
624
|
+
subscriber.withOnyxInstance.setState((prevState) => {
|
|
625
|
+
const previousData = prevState[subscriber.statePropertyName];
|
|
598
626
|
if (previousData === data) {
|
|
599
627
|
return null;
|
|
600
628
|
}
|
|
601
629
|
|
|
602
|
-
|
|
603
|
-
return
|
|
604
|
-
|
|
605
|
-
|
|
630
|
+
_metrics_PerformanceUtils__WEBPACK_IMPORTED_MODULE_8__.logSetStateCall(subscriber, previousData, data, 'keyChanged', key);
|
|
631
|
+
return {
|
|
632
|
+
[subscriber.statePropertyName]: data
|
|
633
|
+
};
|
|
606
634
|
});
|
|
607
|
-
|
|
635
|
+
continue;
|
|
608
636
|
}
|
|
609
637
|
|
|
610
|
-
console.error('Warning: Found a matching subscriber to a key that changed, but no callback or withOnyxInstance could be found.');
|
|
638
|
+
console.error('Warning: Found a matching subscriber to a key that changed, but no callback or withOnyxInstance could be found.');
|
|
611
639
|
}
|
|
612
640
|
}
|
|
613
641
|
|
|
@@ -633,7 +661,7 @@ function sendDataToConnection(mapping, val, matchedKey) {
|
|
|
633
661
|
}
|
|
634
662
|
|
|
635
663
|
if (mapping.withOnyxInstance) {
|
|
636
|
-
|
|
664
|
+
let newData = val;
|
|
637
665
|
|
|
638
666
|
// If the mapping has a selector, then the component's state must only be updated with the data
|
|
639
667
|
// returned by the selector.
|
|
@@ -645,12 +673,12 @@ function sendDataToConnection(mapping, val, matchedKey) {
|
|
|
645
673
|
}
|
|
646
674
|
}
|
|
647
675
|
|
|
648
|
-
|
|
676
|
+
_metrics_PerformanceUtils__WEBPACK_IMPORTED_MODULE_8__.logSetStateCall(mapping, null, newData, 'sendDataToConnection');
|
|
649
677
|
mapping.withOnyxInstance.setWithOnyxState(mapping.statePropertyName, newData);
|
|
650
678
|
return;
|
|
651
679
|
}
|
|
652
680
|
|
|
653
|
-
if (
|
|
681
|
+
if (underscore__WEBPACK_IMPORTED_MODULE_0___default().isFunction(mapping.callback)) {
|
|
654
682
|
mapping.callback(val, matchedKey);
|
|
655
683
|
}
|
|
656
684
|
}
|
|
@@ -668,13 +696,13 @@ function addKeyToRecentlyAccessedIfNeeded(mapping) {
|
|
|
668
696
|
}
|
|
669
697
|
|
|
670
698
|
// Try to free some cache whenever we connect to a safe eviction key
|
|
671
|
-
|
|
699
|
+
_OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].removeLeastRecentlyUsedKeys();
|
|
672
700
|
|
|
673
701
|
if (mapping.withOnyxInstance && !isCollectionKey(mapping.key)) {
|
|
674
702
|
// All React components subscribing to a key flagged as a safe eviction key must implement the canEvict property.
|
|
675
|
-
if (
|
|
676
|
-
throw new Error(
|
|
677
|
-
mapping.key
|
|
703
|
+
if (underscore__WEBPACK_IMPORTED_MODULE_0___default().isUndefined(mapping.canEvict)) {
|
|
704
|
+
throw new Error(
|
|
705
|
+
`Cannot subscribe to safe eviction key '${mapping.key}' without providing a canEvict value.`);
|
|
678
706
|
|
|
679
707
|
}
|
|
680
708
|
|
|
@@ -690,13 +718,13 @@ function addKeyToRecentlyAccessedIfNeeded(mapping) {
|
|
|
690
718
|
* @param {Object} mapping
|
|
691
719
|
*/
|
|
692
720
|
function getCollectionDataAndSendAsObject(matchingKeys, mapping) {
|
|
693
|
-
Promise.all(
|
|
694
|
-
then(
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
then(
|
|
721
|
+
Promise.all(underscore__WEBPACK_IMPORTED_MODULE_0___default().map(matchingKeys, (key) => get(key))).
|
|
722
|
+
then((values) => underscore__WEBPACK_IMPORTED_MODULE_0___default().reduce(values, (finalObject, value, i) => {
|
|
723
|
+
// eslint-disable-next-line no-param-reassign
|
|
724
|
+
finalObject[matchingKeys[i]] = value;
|
|
725
|
+
return finalObject;
|
|
726
|
+
}, {})).
|
|
727
|
+
then((val) => sendDataToConnection(mapping, val));
|
|
700
728
|
}
|
|
701
729
|
|
|
702
730
|
/**
|
|
@@ -725,7 +753,7 @@ function getCollectionDataAndSendAsObject(matchingKeys, mapping) {
|
|
|
725
753
|
* @returns {Number} an ID to use when calling disconnect
|
|
726
754
|
*/
|
|
727
755
|
function connect(mapping) {
|
|
728
|
-
|
|
756
|
+
const connectionID = lastConnectionID++;
|
|
729
757
|
callbackToStateMapping[connectionID] = mapping;
|
|
730
758
|
callbackToStateMapping[connectionID].connectionID = connectionID;
|
|
731
759
|
|
|
@@ -735,13 +763,13 @@ function connect(mapping) {
|
|
|
735
763
|
|
|
736
764
|
// Commit connection only after init passes
|
|
737
765
|
deferredInitTask.promise.
|
|
738
|
-
then(
|
|
766
|
+
then(() => addKeyToRecentlyAccessedIfNeeded(mapping)).
|
|
739
767
|
then(getAllKeys).
|
|
740
|
-
then(
|
|
768
|
+
then((keys) => {
|
|
741
769
|
// We search all the keys in storage to see if any are a "match" for the subscriber we are connecting so that we
|
|
742
770
|
// can send data back to the subscriber. Note that multiple keys can match as a subscriber could either be
|
|
743
771
|
// subscribed to a "collection key" or a single key.
|
|
744
|
-
|
|
772
|
+
const matchingKeys = underscore__WEBPACK_IMPORTED_MODULE_0___default().filter(keys, (key) => isKeyMatch(mapping.key, key));
|
|
745
773
|
|
|
746
774
|
// If the key being connected to does not exist we initialize the value with null. For subscribers that connected
|
|
747
775
|
// directly via connect() they will simply get a null value sent to them without any information about which key matched
|
|
@@ -755,7 +783,7 @@ function connect(mapping) {
|
|
|
755
783
|
// When using a callback subscriber we will either trigger the provided callback for each key we find or combine all values
|
|
756
784
|
// into an object and just make a single call. The latter behavior is enabled by providing a waitForCollectionCallback key
|
|
757
785
|
// combined with a subscription to a collection key.
|
|
758
|
-
if (
|
|
786
|
+
if (underscore__WEBPACK_IMPORTED_MODULE_0___default().isFunction(mapping.callback)) {
|
|
759
787
|
if (isCollectionKey(mapping.key)) {
|
|
760
788
|
if (mapping.waitForCollectionCallback) {
|
|
761
789
|
getCollectionDataAndSendAsObject(matchingKeys, mapping);
|
|
@@ -763,14 +791,14 @@ function connect(mapping) {
|
|
|
763
791
|
}
|
|
764
792
|
|
|
765
793
|
// We did not opt into using waitForCollectionCallback mode so the callback is called for every matching key.
|
|
766
|
-
|
|
767
|
-
get(matchingKeys[i]).then(
|
|
794
|
+
for (let i = 0; i < matchingKeys.length; i++) {
|
|
795
|
+
get(matchingKeys[i]).then((val) => sendDataToConnection(mapping, val, matchingKeys[i]));
|
|
768
796
|
}
|
|
769
797
|
return;
|
|
770
798
|
}
|
|
771
799
|
|
|
772
800
|
// If we are not subscribed to a collection key then there's only a single key to send an update for.
|
|
773
|
-
get(mapping.key).then(
|
|
801
|
+
get(mapping.key).then((val) => sendDataToConnection(mapping, val, mapping.key));
|
|
774
802
|
return;
|
|
775
803
|
}
|
|
776
804
|
|
|
@@ -783,7 +811,7 @@ function connect(mapping) {
|
|
|
783
811
|
}
|
|
784
812
|
|
|
785
813
|
// If the subscriber is not using a collection key then we just send a single value back to the subscriber
|
|
786
|
-
get(mapping.key).then(
|
|
814
|
+
get(mapping.key).then((val) => sendDataToConnection(mapping, val, mapping.key));
|
|
787
815
|
return;
|
|
788
816
|
}
|
|
789
817
|
|
|
@@ -832,7 +860,7 @@ function disconnect(connectionID, keyToRemoveFromEvictionBlocklist) {
|
|
|
832
860
|
*/
|
|
833
861
|
// eslint-disable-next-line rulesdir/no-negated-variables
|
|
834
862
|
function notifySubscribersOnNextTick(key, value, canUpdateSubscriber) {
|
|
835
|
-
Promise.resolve().then(
|
|
863
|
+
Promise.resolve().then(() => keyChanged(key, value, canUpdateSubscriber));
|
|
836
864
|
}
|
|
837
865
|
|
|
838
866
|
/**
|
|
@@ -845,7 +873,7 @@ function notifySubscribersOnNextTick(key, value, canUpdateSubscriber) {
|
|
|
845
873
|
*/
|
|
846
874
|
// eslint-disable-next-line rulesdir/no-negated-variables
|
|
847
875
|
function notifyCollectionSubscribersOnNextTick(key, value) {
|
|
848
|
-
Promise.resolve().then(
|
|
876
|
+
Promise.resolve().then(() => keysChanged(key, value));
|
|
849
877
|
}
|
|
850
878
|
|
|
851
879
|
/**
|
|
@@ -856,9 +884,9 @@ function notifyCollectionSubscribersOnNextTick(key, value) {
|
|
|
856
884
|
* @return {Promise}
|
|
857
885
|
*/
|
|
858
886
|
function remove(key) {
|
|
859
|
-
|
|
887
|
+
_OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].drop(key);
|
|
860
888
|
notifySubscribersOnNextTick(key, null);
|
|
861
|
-
return
|
|
889
|
+
return _storage__WEBPACK_IMPORTED_MODULE_6__["default"].removeItem(key);
|
|
862
890
|
}
|
|
863
891
|
|
|
864
892
|
/**
|
|
@@ -873,25 +901,25 @@ function remove(key) {
|
|
|
873
901
|
* @return {Promise}
|
|
874
902
|
*/
|
|
875
903
|
function evictStorageAndRetry(error, onyxMethod) {for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {args[_key - 2] = arguments[_key];}
|
|
876
|
-
|
|
904
|
+
_Logger__WEBPACK_IMPORTED_MODULE_7__.logInfo(`Handled error: ${error}`);
|
|
877
905
|
|
|
878
|
-
if (error &&
|
|
879
|
-
|
|
906
|
+
if (error && expensify_common_lib_str__WEBPACK_IMPORTED_MODULE_1___default().startsWith(error.message, 'Failed to execute \'put\' on \'IDBObjectStore\'')) {
|
|
907
|
+
_Logger__WEBPACK_IMPORTED_MODULE_7__.logAlert('Attempted to set invalid data set in Onyx. Please ensure all data is serializable.');
|
|
880
908
|
throw error;
|
|
881
909
|
}
|
|
882
910
|
|
|
883
911
|
// Find the first key that we can remove that has no subscribers in our blocklist
|
|
884
|
-
|
|
912
|
+
const keyForRemoval = underscore__WEBPACK_IMPORTED_MODULE_0___default().find(recentlyAccessedKeys, (key) => !evictionBlocklist[key]);
|
|
885
913
|
|
|
886
914
|
if (!keyForRemoval) {
|
|
887
|
-
|
|
915
|
+
_Logger__WEBPACK_IMPORTED_MODULE_7__.logAlert('Out of storage. But found no acceptable keys to remove.');
|
|
888
916
|
throw error;
|
|
889
917
|
}
|
|
890
918
|
|
|
891
919
|
// Remove the least recently viewed key that is not currently being accessed and retry.
|
|
892
|
-
|
|
920
|
+
_Logger__WEBPACK_IMPORTED_MODULE_7__.logInfo(`Out of storage. Evicting least recently accessed key (${keyForRemoval}) and retrying.`);
|
|
893
921
|
return remove(keyForRemoval).
|
|
894
|
-
then(
|
|
922
|
+
then(() => onyxMethod(...args));
|
|
895
923
|
}
|
|
896
924
|
|
|
897
925
|
/**
|
|
@@ -903,30 +931,30 @@ function evictStorageAndRetry(error, onyxMethod) {for (var _len = arguments.leng
|
|
|
903
931
|
* @returns {Promise}
|
|
904
932
|
*/
|
|
905
933
|
function set(key, value) {
|
|
906
|
-
if (
|
|
934
|
+
if (underscore__WEBPACK_IMPORTED_MODULE_0___default().isNull(value)) {
|
|
907
935
|
return remove(key);
|
|
908
936
|
}
|
|
909
937
|
|
|
910
938
|
// eslint-disable-next-line no-use-before-define
|
|
911
939
|
if (hasPendingMergeForKey(key)) {
|
|
912
|
-
|
|
940
|
+
_Logger__WEBPACK_IMPORTED_MODULE_7__.logAlert(`Onyx.set() called after Onyx.merge() for key: ${key}. It is recommended to use set() or merge() not both.`);
|
|
913
941
|
}
|
|
914
942
|
|
|
915
943
|
// If the value in the cache is the same as what we have then do not update subscribers unless they
|
|
916
944
|
// have initWithStoredValues: false then they MUST get all updates even if nothing has changed.
|
|
917
|
-
if (!
|
|
918
|
-
|
|
919
|
-
notifySubscribersOnNextTick(key, value,
|
|
945
|
+
if (!_OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].hasValueChanged(key, value)) {
|
|
946
|
+
_OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].addToAccessedKeys(key);
|
|
947
|
+
notifySubscribersOnNextTick(key, value, (subscriber) => subscriber.initWithStoredValues === false);
|
|
920
948
|
return Promise.resolve();
|
|
921
949
|
}
|
|
922
950
|
|
|
923
951
|
// Adds the key to cache when it's not available
|
|
924
|
-
|
|
952
|
+
_OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].set(key, value);
|
|
925
953
|
notifySubscribersOnNextTick(key, value);
|
|
926
954
|
|
|
927
955
|
// Write the thing to persistent storage, which will trigger a storage event for any other tabs open on this domain
|
|
928
|
-
return
|
|
929
|
-
catch(
|
|
956
|
+
return _storage__WEBPACK_IMPORTED_MODULE_6__["default"].setItem(key, value).
|
|
957
|
+
catch((error) => evictStorageAndRetry(error, set, key, value));
|
|
930
958
|
}
|
|
931
959
|
|
|
932
960
|
/**
|
|
@@ -938,7 +966,7 @@ function set(key, value) {
|
|
|
938
966
|
* @return {Array} an array of key - value pairs <[key, value]>
|
|
939
967
|
*/
|
|
940
968
|
function prepareKeyValuePairsForStorage(data) {
|
|
941
|
-
return
|
|
969
|
+
return underscore__WEBPACK_IMPORTED_MODULE_0___default().map(data, (value, key) => [key, value]);
|
|
942
970
|
}
|
|
943
971
|
|
|
944
972
|
/**
|
|
@@ -950,20 +978,20 @@ function prepareKeyValuePairsForStorage(data) {
|
|
|
950
978
|
* @returns {Promise}
|
|
951
979
|
*/
|
|
952
980
|
function multiSet(data) {
|
|
953
|
-
|
|
981
|
+
const keyValuePairs = prepareKeyValuePairsForStorage(data);
|
|
954
982
|
|
|
955
|
-
|
|
983
|
+
underscore__WEBPACK_IMPORTED_MODULE_0___default().each(data, (val, key) => {
|
|
956
984
|
// Update cache and optimistically inform subscribers on the next tick
|
|
957
|
-
|
|
985
|
+
_OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].set(key, val);
|
|
958
986
|
notifySubscribersOnNextTick(key, val);
|
|
959
987
|
});
|
|
960
988
|
|
|
961
|
-
return
|
|
962
|
-
catch(
|
|
989
|
+
return _storage__WEBPACK_IMPORTED_MODULE_6__["default"].multiSet(keyValuePairs).
|
|
990
|
+
catch((error) => evictStorageAndRetry(error, multiSet, data));
|
|
963
991
|
}
|
|
964
992
|
|
|
965
993
|
// Key/value store of Onyx key and arrays of values to merge
|
|
966
|
-
|
|
994
|
+
const mergeQueue = {};
|
|
967
995
|
|
|
968
996
|
/**
|
|
969
997
|
* @private
|
|
@@ -987,33 +1015,33 @@ function hasPendingMergeForKey(key) {
|
|
|
987
1015
|
* @returns {*}
|
|
988
1016
|
*/
|
|
989
1017
|
function applyMerge(key, data) {
|
|
990
|
-
|
|
991
|
-
if (
|
|
1018
|
+
const mergeValues = mergeQueue[key];
|
|
1019
|
+
if (underscore__WEBPACK_IMPORTED_MODULE_0___default().isArray(data) || underscore__WEBPACK_IMPORTED_MODULE_0___default().every(mergeValues, (underscore__WEBPACK_IMPORTED_MODULE_0___default().isArray))) {
|
|
992
1020
|
// Array values will always just concatenate
|
|
993
1021
|
// more items onto the end of the array
|
|
994
|
-
return
|
|
995
|
-
|
|
996
|
-
|
|
1022
|
+
return underscore__WEBPACK_IMPORTED_MODULE_0___default().reduce(mergeValues, (modifiedData, mergeValue) => [
|
|
1023
|
+
...modifiedData,
|
|
1024
|
+
...mergeValue],
|
|
997
1025
|
data || []);
|
|
998
1026
|
}
|
|
999
1027
|
|
|
1000
|
-
if (
|
|
1028
|
+
if (underscore__WEBPACK_IMPORTED_MODULE_0___default().isObject(data) || underscore__WEBPACK_IMPORTED_MODULE_0___default().every(mergeValues, (underscore__WEBPACK_IMPORTED_MODULE_0___default().isObject))) {
|
|
1001
1029
|
// Object values are merged one after the other
|
|
1002
|
-
return
|
|
1030
|
+
return underscore__WEBPACK_IMPORTED_MODULE_0___default().reduce(mergeValues, (modifiedData, mergeValue) => {
|
|
1003
1031
|
// lodash adds a small overhead so we don't use it here
|
|
1004
1032
|
// eslint-disable-next-line prefer-object-spread, rulesdir/prefer-underscore-method
|
|
1005
|
-
|
|
1033
|
+
const newData = Object.assign({}, (0,_fastMerge__WEBPACK_IMPORTED_MODULE_9__["default"])(modifiedData, mergeValue));
|
|
1006
1034
|
|
|
1007
1035
|
// We will also delete any object keys that are undefined or null.
|
|
1008
1036
|
// Deleting keys is not supported by AsyncStorage so we do it this way.
|
|
1009
1037
|
// Remove all first level keys that are explicitly set to null.
|
|
1010
|
-
return
|
|
1038
|
+
return underscore__WEBPACK_IMPORTED_MODULE_0___default().omit(newData, (value, finalObjectKey) => underscore__WEBPACK_IMPORTED_MODULE_0___default().isNull(mergeValue[finalObjectKey]));
|
|
1011
1039
|
}, data || {});
|
|
1012
1040
|
}
|
|
1013
1041
|
|
|
1014
1042
|
// If we have anything else we can't merge it so we'll
|
|
1015
1043
|
// simply return the last value that was queued
|
|
1016
|
-
return
|
|
1044
|
+
return underscore__WEBPACK_IMPORTED_MODULE_0___default().last(mergeValues);
|
|
1017
1045
|
}
|
|
1018
1046
|
|
|
1019
1047
|
/**
|
|
@@ -1046,9 +1074,9 @@ function merge(key, value) {
|
|
|
1046
1074
|
|
|
1047
1075
|
mergeQueue[key] = [value];
|
|
1048
1076
|
return get(key).
|
|
1049
|
-
then(
|
|
1077
|
+
then((data) => {
|
|
1050
1078
|
try {
|
|
1051
|
-
|
|
1079
|
+
const modifiedData = applyMerge(key, data);
|
|
1052
1080
|
|
|
1053
1081
|
// Clean up the write queue so we
|
|
1054
1082
|
// don't apply these changes again
|
|
@@ -1056,7 +1084,7 @@ function merge(key, value) {
|
|
|
1056
1084
|
|
|
1057
1085
|
return set(key, modifiedData);
|
|
1058
1086
|
} catch (error) {
|
|
1059
|
-
|
|
1087
|
+
_Logger__WEBPACK_IMPORTED_MODULE_7__.logAlert(`An error occurred while applying merge for key: ${key}, Error: ${error}`);
|
|
1060
1088
|
}
|
|
1061
1089
|
|
|
1062
1090
|
return Promise.resolve();
|
|
@@ -1069,13 +1097,13 @@ function merge(key, value) {
|
|
|
1069
1097
|
* @returns {Promise}
|
|
1070
1098
|
*/
|
|
1071
1099
|
function initializeWithDefaultKeyStates() {
|
|
1072
|
-
return
|
|
1073
|
-
then(
|
|
1074
|
-
|
|
1100
|
+
return _storage__WEBPACK_IMPORTED_MODULE_6__["default"].multiGet(underscore__WEBPACK_IMPORTED_MODULE_0___default().keys(defaultKeyStates)).
|
|
1101
|
+
then((pairs) => {
|
|
1102
|
+
const asObject = underscore__WEBPACK_IMPORTED_MODULE_0___default().object(pairs);
|
|
1075
1103
|
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1104
|
+
const merged = (0,_fastMerge__WEBPACK_IMPORTED_MODULE_9__["default"])(asObject, defaultKeyStates);
|
|
1105
|
+
_OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].merge(merged);
|
|
1106
|
+
underscore__WEBPACK_IMPORTED_MODULE_0___default().each(merged, (val, key) => keyChanged(key, val));
|
|
1079
1107
|
});
|
|
1080
1108
|
}
|
|
1081
1109
|
|
|
@@ -1101,49 +1129,49 @@ function initializeWithDefaultKeyStates() {
|
|
|
1101
1129
|
* @param {Array} keysToPreserve is a list of ONYXKEYS that should not be cleared with the rest of the data
|
|
1102
1130
|
* @returns {Promise<void>}
|
|
1103
1131
|
*/
|
|
1104
|
-
function clear() {
|
|
1132
|
+
function clear() {let keysToPreserve = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1105
1133
|
return getAllKeys().
|
|
1106
|
-
then(
|
|
1107
|
-
|
|
1108
|
-
|
|
1134
|
+
then((keys) => {
|
|
1135
|
+
const keyValuesToReset = [];
|
|
1136
|
+
const defaultKeys = underscore__WEBPACK_IMPORTED_MODULE_0___default().keys(defaultKeyStates);
|
|
1109
1137
|
|
|
1110
1138
|
// Get all the values for the keys that need to be preserved. These key/value pairs will be set
|
|
1111
1139
|
// in Onyx after the database is cleared().
|
|
1112
|
-
|
|
1140
|
+
const keyValuesToPreserve = underscore__WEBPACK_IMPORTED_MODULE_0___default().map(keysToPreserve, (key) => [key, _OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].getValue(key)]);
|
|
1113
1141
|
|
|
1114
1142
|
// The only keys that should not be cleared are:
|
|
1115
1143
|
// 1. Anything specifically passed in keysToPreserve (because some keys like language preferences, offline
|
|
1116
1144
|
// status, or activeClients need to remain in Onyx even when signed out)
|
|
1117
1145
|
// 2. Any keys with a default state (because they need to remain in Onyx as their default, and setting them
|
|
1118
1146
|
// to null would cause unknown behavior)
|
|
1119
|
-
|
|
1120
|
-
keyValuesToReset.push
|
|
1147
|
+
const keysToClear = underscore__WEBPACK_IMPORTED_MODULE_0___default().difference(keys, keysToPreserve, defaultKeys);
|
|
1148
|
+
keyValuesToReset.push(...underscore__WEBPACK_IMPORTED_MODULE_0___default().map(keysToClear, (key) => [key, null]));
|
|
1121
1149
|
|
|
1122
1150
|
// Remove any keysToPreserve from the defaultKeyStates because if they are passed in it has been explicitly
|
|
1123
1151
|
// called out to preserve those values instead of resetting them back
|
|
1124
1152
|
// to the default.
|
|
1125
|
-
|
|
1153
|
+
const defaultKeyValuePairs = underscore__WEBPACK_IMPORTED_MODULE_0___default().pairs(underscore__WEBPACK_IMPORTED_MODULE_0___default().omit(defaultKeyStates, ...keysToPreserve));
|
|
1126
1154
|
|
|
1127
1155
|
// Add the default key value pairs to the keyValuesToReset so that they get set back to their default values
|
|
1128
1156
|
// when we clear Onyx
|
|
1129
|
-
keyValuesToReset.push
|
|
1157
|
+
keyValuesToReset.push(...defaultKeyValuePairs);
|
|
1130
1158
|
|
|
1131
1159
|
// We now have all the key/values that need to be reset, but we're not done yet!
|
|
1132
1160
|
// There will be two groups of key/values and they each need to be updated a little bit differently.
|
|
1133
1161
|
// Collection keys need to be notified differently than non collection keys
|
|
1134
|
-
|
|
1135
|
-
|
|
1162
|
+
const keyValuesToResetAsCollection = {};
|
|
1163
|
+
const keyValuesToResetIndividually = {};
|
|
1136
1164
|
|
|
1137
1165
|
// Make sure that we also reset the cache values before clearing the values from storage.
|
|
1138
1166
|
// We do this before clearing Storage so that any call to clear() followed by merge() on a key with a
|
|
1139
1167
|
// default state results in the merged value getting saved, since the update from the merge() call would
|
|
1140
1168
|
// happen on the tick after the update from this clear()
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1169
|
+
underscore__WEBPACK_IMPORTED_MODULE_0___default().each(keyValuesToReset, (keyValue) => {
|
|
1170
|
+
const key = keyValue[0];
|
|
1171
|
+
const value = keyValue[1];
|
|
1172
|
+
_OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].set(key, value);
|
|
1145
1173
|
|
|
1146
|
-
|
|
1174
|
+
const collectionKey = key.substring(0, key.indexOf('_') + 1);
|
|
1147
1175
|
if (collectionKey) {
|
|
1148
1176
|
if (!keyValuesToResetAsCollection[collectionKey]) {
|
|
1149
1177
|
keyValuesToResetAsCollection[collectionKey] = {};
|
|
@@ -1156,18 +1184,18 @@ function clear() {var keysToPreserve = arguments.length > 0 && arguments[0] !==
|
|
|
1156
1184
|
});
|
|
1157
1185
|
|
|
1158
1186
|
// Notify the subscribers for each key/value group so they can receive the new values
|
|
1159
|
-
|
|
1187
|
+
underscore__WEBPACK_IMPORTED_MODULE_0___default().each(keyValuesToResetIndividually, (value, key) => {
|
|
1160
1188
|
notifySubscribersOnNextTick(key, value);
|
|
1161
1189
|
});
|
|
1162
|
-
|
|
1190
|
+
underscore__WEBPACK_IMPORTED_MODULE_0___default().each(keyValuesToResetAsCollection, (value, key) => {
|
|
1163
1191
|
notifyCollectionSubscribersOnNextTick(key, value);
|
|
1164
1192
|
});
|
|
1165
1193
|
|
|
1166
1194
|
// Call clear() and make sure that the default key/values and the key/values from the parameter
|
|
1167
1195
|
// are preserved in storage. This makes sure to always leave storage in a state that contains
|
|
1168
1196
|
// all the default values and any additional values that we want to remain after the database is cleared.
|
|
1169
|
-
return
|
|
1170
|
-
then(
|
|
1197
|
+
return _storage__WEBPACK_IMPORTED_MODULE_6__["default"].clear().
|
|
1198
|
+
then(() => _storage__WEBPACK_IMPORTED_MODULE_6__["default"].multiSet([...defaultKeyValuePairs, ...keyValuesToPreserve]));
|
|
1171
1199
|
});
|
|
1172
1200
|
}
|
|
1173
1201
|
|
|
@@ -1186,54 +1214,54 @@ function clear() {var keysToPreserve = arguments.length > 0 && arguments[0] !==
|
|
|
1186
1214
|
* @returns {Promise}
|
|
1187
1215
|
*/
|
|
1188
1216
|
function mergeCollection(collectionKey, collection) {
|
|
1189
|
-
if (!
|
|
1190
|
-
|
|
1217
|
+
if (!underscore__WEBPACK_IMPORTED_MODULE_0___default().isObject(collection) || underscore__WEBPACK_IMPORTED_MODULE_0___default().isArray(collection) || underscore__WEBPACK_IMPORTED_MODULE_0___default().isEmpty(collection)) {
|
|
1218
|
+
_Logger__WEBPACK_IMPORTED_MODULE_7__.logInfo('mergeCollection() called with invalid or empty value. Skipping this update.');
|
|
1191
1219
|
return Promise.resolve();
|
|
1192
1220
|
}
|
|
1193
1221
|
|
|
1194
1222
|
// Confirm all the collection keys belong to the same parent
|
|
1195
|
-
|
|
1223
|
+
underscore__WEBPACK_IMPORTED_MODULE_0___default().each(collection, (_data, dataKey) => {
|
|
1196
1224
|
if (isKeyMatch(collectionKey, dataKey)) {
|
|
1197
1225
|
return;
|
|
1198
1226
|
}
|
|
1199
1227
|
|
|
1200
|
-
throw new Error(
|
|
1228
|
+
throw new Error(`Provided collection doesn't have all its data belonging to the same parent. CollectionKey: ${collectionKey}, DataKey: ${dataKey}`);
|
|
1201
1229
|
});
|
|
1202
1230
|
|
|
1203
1231
|
return getAllKeys().
|
|
1204
|
-
then(
|
|
1232
|
+
then((persistedKeys) => {
|
|
1205
1233
|
// Split to keys that exist in storage and keys that don't
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1234
|
+
const [existingKeys, newKeys] = underscore__WEBPACK_IMPORTED_MODULE_0___default().chain(collection).
|
|
1235
|
+
keys().
|
|
1236
|
+
partition((key) => persistedKeys.includes(key)).
|
|
1237
|
+
value();
|
|
1210
1238
|
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1239
|
+
const existingKeyCollection = underscore__WEBPACK_IMPORTED_MODULE_0___default().pick(collection, existingKeys);
|
|
1240
|
+
const newCollection = underscore__WEBPACK_IMPORTED_MODULE_0___default().pick(collection, newKeys);
|
|
1241
|
+
const keyValuePairsForExistingCollection = prepareKeyValuePairsForStorage(existingKeyCollection);
|
|
1242
|
+
const keyValuePairsForNewCollection = prepareKeyValuePairsForStorage(newCollection);
|
|
1215
1243
|
|
|
1216
|
-
|
|
1244
|
+
const promises = [];
|
|
1217
1245
|
|
|
1218
1246
|
// New keys will be added via multiSet while existing keys will be updated using multiMerge
|
|
1219
1247
|
// This is because setting a key that doesn't exist yet with multiMerge will throw errors
|
|
1220
1248
|
if (keyValuePairsForExistingCollection.length > 0) {
|
|
1221
|
-
promises.push(
|
|
1249
|
+
promises.push(_storage__WEBPACK_IMPORTED_MODULE_6__["default"].multiMerge(keyValuePairsForExistingCollection));
|
|
1222
1250
|
}
|
|
1223
1251
|
|
|
1224
1252
|
if (keyValuePairsForNewCollection.length > 0) {
|
|
1225
|
-
promises.push(
|
|
1253
|
+
promises.push(_storage__WEBPACK_IMPORTED_MODULE_6__["default"].multiSet(keyValuePairsForNewCollection));
|
|
1226
1254
|
}
|
|
1227
1255
|
|
|
1228
1256
|
// Prefill cache if necessary by calling get() on any existing keys and then merge original data to cache
|
|
1229
1257
|
// and update all subscribers
|
|
1230
|
-
Promise.all(
|
|
1231
|
-
|
|
1258
|
+
Promise.all(underscore__WEBPACK_IMPORTED_MODULE_0___default().map(existingKeys, get)).then(() => {
|
|
1259
|
+
_OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].merge(collection);
|
|
1232
1260
|
keysChanged(collectionKey, collection);
|
|
1233
1261
|
});
|
|
1234
1262
|
|
|
1235
1263
|
return Promise.all(promises).
|
|
1236
|
-
catch(
|
|
1264
|
+
catch((error) => evictStorageAndRetry(error, mergeCollection, collection));
|
|
1237
1265
|
});
|
|
1238
1266
|
}
|
|
1239
1267
|
|
|
@@ -1245,18 +1273,18 @@ function mergeCollection(collectionKey, collection) {
|
|
|
1245
1273
|
*/
|
|
1246
1274
|
function update(data) {
|
|
1247
1275
|
// First, validate the Onyx object is in the format we expect
|
|
1248
|
-
|
|
1249
|
-
if (!
|
|
1250
|
-
throw new Error(
|
|
1276
|
+
underscore__WEBPACK_IMPORTED_MODULE_0___default().each(data, (_ref) => {let { onyxMethod, key } = _ref;
|
|
1277
|
+
if (!underscore__WEBPACK_IMPORTED_MODULE_0___default().contains([METHOD.CLEAR, METHOD.SET, METHOD.MERGE, METHOD.MERGE_COLLECTION], onyxMethod)) {
|
|
1278
|
+
throw new Error(`Invalid onyxMethod ${onyxMethod} in Onyx update.`);
|
|
1251
1279
|
}
|
|
1252
|
-
if (onyxMethod !== METHOD.CLEAR && !
|
|
1253
|
-
throw new Error(
|
|
1280
|
+
if (onyxMethod !== METHOD.CLEAR && !underscore__WEBPACK_IMPORTED_MODULE_0___default().isString(key)) {
|
|
1281
|
+
throw new Error(`Invalid ${typeof key} key provided in Onyx update. Onyx key must be of type string.`);
|
|
1254
1282
|
}
|
|
1255
1283
|
});
|
|
1256
1284
|
|
|
1257
|
-
|
|
1285
|
+
const promises = [];
|
|
1258
1286
|
|
|
1259
|
-
|
|
1287
|
+
underscore__WEBPACK_IMPORTED_MODULE_0___default().each(data, (_ref2) => {let { onyxMethod, key, value } = _ref2;
|
|
1260
1288
|
switch (onyxMethod) {
|
|
1261
1289
|
case METHOD.SET:
|
|
1262
1290
|
promises.push(set(key, value));
|
|
@@ -1311,7 +1339,7 @@ function init()
|
|
|
1311
1339
|
|
|
1312
1340
|
|
|
1313
1341
|
|
|
1314
|
-
{
|
|
1342
|
+
{let { keys = {}, initialKeyStates = {}, safeEvictionKeys = [], maxCachedKeysCount = 1000, captureMetrics = false, shouldSyncMultipleInstances = Boolean(__webpack_require__.g.localStorage), debugSetState = false } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1315
1343
|
if (captureMetrics) {
|
|
1316
1344
|
// The code here is only bundled and applied when the captureMetrics is set
|
|
1317
1345
|
// eslint-disable-next-line no-use-before-define
|
|
@@ -1319,11 +1347,11 @@ function init()
|
|
|
1319
1347
|
}
|
|
1320
1348
|
|
|
1321
1349
|
if (debugSetState) {
|
|
1322
|
-
|
|
1350
|
+
_metrics_PerformanceUtils__WEBPACK_IMPORTED_MODULE_8__.setShouldDebugSetState(true);
|
|
1323
1351
|
}
|
|
1324
1352
|
|
|
1325
1353
|
if (maxCachedKeysCount > 0) {
|
|
1326
|
-
|
|
1354
|
+
_OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].setRecentKeysLimit(maxCachedKeysCount);
|
|
1327
1355
|
}
|
|
1328
1356
|
|
|
1329
1357
|
// Let Onyx know about all of our keys
|
|
@@ -1342,30 +1370,30 @@ function init()
|
|
|
1342
1370
|
|
|
1343
1371
|
then(deferredInitTask.resolve);
|
|
1344
1372
|
|
|
1345
|
-
if (shouldSyncMultipleInstances &&
|
|
1346
|
-
|
|
1347
|
-
|
|
1373
|
+
if (shouldSyncMultipleInstances && underscore__WEBPACK_IMPORTED_MODULE_0___default().isFunction(_storage__WEBPACK_IMPORTED_MODULE_6__["default"].keepInstancesSync)) {
|
|
1374
|
+
_storage__WEBPACK_IMPORTED_MODULE_6__["default"].keepInstancesSync((key, value) => {
|
|
1375
|
+
_OnyxCache__WEBPACK_IMPORTED_MODULE_5__["default"].set(key, value);
|
|
1348
1376
|
keyChanged(key, value);
|
|
1349
1377
|
});
|
|
1350
1378
|
}
|
|
1351
1379
|
}
|
|
1352
1380
|
|
|
1353
|
-
|
|
1354
|
-
connect
|
|
1355
|
-
disconnect
|
|
1356
|
-
set
|
|
1357
|
-
multiSet
|
|
1358
|
-
merge
|
|
1359
|
-
mergeCollection
|
|
1360
|
-
update
|
|
1361
|
-
clear
|
|
1362
|
-
getAllKeys
|
|
1363
|
-
init
|
|
1364
|
-
registerLogger:
|
|
1365
|
-
addToEvictionBlockList
|
|
1366
|
-
removeFromEvictionBlockList
|
|
1367
|
-
isSafeEvictionKey
|
|
1368
|
-
METHOD
|
|
1381
|
+
const Onyx = {
|
|
1382
|
+
connect,
|
|
1383
|
+
disconnect,
|
|
1384
|
+
set,
|
|
1385
|
+
multiSet,
|
|
1386
|
+
merge,
|
|
1387
|
+
mergeCollection,
|
|
1388
|
+
update,
|
|
1389
|
+
clear,
|
|
1390
|
+
getAllKeys,
|
|
1391
|
+
init,
|
|
1392
|
+
registerLogger: _Logger__WEBPACK_IMPORTED_MODULE_7__.registerLogger,
|
|
1393
|
+
addToEvictionBlockList,
|
|
1394
|
+
removeFromEvictionBlockList,
|
|
1395
|
+
isSafeEvictionKey,
|
|
1396
|
+
METHOD
|
|
1369
1397
|
};
|
|
1370
1398
|
|
|
1371
1399
|
/**
|
|
@@ -1375,7 +1403,7 @@ var Onyx = {
|
|
|
1375
1403
|
*/
|
|
1376
1404
|
function applyDecorators() {
|
|
1377
1405
|
// We're requiring the script dynamically here so that it's only evaluated when decorators are used
|
|
1378
|
-
|
|
1406
|
+
const decorate = __webpack_require__(/*! ./metrics */ "./lib/metrics/index.web.js");
|
|
1379
1407
|
|
|
1380
1408
|
// Re-assign with decorated functions
|
|
1381
1409
|
/* eslint-disable no-func-assign */
|
|
@@ -1404,9 +1432,9 @@ function applyDecorators() {
|
|
|
1404
1432
|
Onyx.getMetrics = decorate.getMetrics;
|
|
1405
1433
|
Onyx.resetMetrics = decorate.resetMetrics;
|
|
1406
1434
|
Onyx.printMetrics = decorate.printMetrics;
|
|
1407
|
-
}
|
|
1435
|
+
}
|
|
1408
1436
|
|
|
1409
|
-
|
|
1437
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Onyx);
|
|
1410
1438
|
|
|
1411
1439
|
/***/ }),
|
|
1412
1440
|
|
|
@@ -1414,20 +1442,30 @@ Onyx;exports["default"] = _default;
|
|
|
1414
1442
|
/*!**************************!*\
|
|
1415
1443
|
!*** ./lib/OnyxCache.js ***!
|
|
1416
1444
|
\**************************/
|
|
1417
|
-
/***/ ((__unused_webpack_module,
|
|
1445
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1446
|
+
|
|
1447
|
+
"use strict";
|
|
1448
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1449
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1450
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
1451
|
+
/* harmony export */ });
|
|
1452
|
+
/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! underscore */ "underscore");
|
|
1453
|
+
/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(underscore__WEBPACK_IMPORTED_MODULE_0__);
|
|
1454
|
+
/* harmony import */ var fast_equals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! fast-equals */ "fast-equals");
|
|
1455
|
+
/* harmony import */ var fast_equals__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fast_equals__WEBPACK_IMPORTED_MODULE_1__);
|
|
1456
|
+
/* harmony import */ var _fastMerge__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./fastMerge */ "./lib/fastMerge.js");
|
|
1457
|
+
|
|
1458
|
+
|
|
1418
1459
|
|
|
1419
|
-
var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");Object.defineProperty(exports, "__esModule", ({ value: true }));exports["default"] = void 0;var _toConsumableArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/toConsumableArray */ "./node_modules/@babel/runtime/helpers/toConsumableArray.js"));var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "./node_modules/@babel/runtime/helpers/classCallCheck.js"));var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "./node_modules/@babel/runtime/helpers/createClass.js"));var _underscore = _interopRequireDefault(__webpack_require__(/*! underscore */ "underscore"));
|
|
1420
|
-
var _fastEquals = __webpack_require__(/*! fast-equals */ "fast-equals");
|
|
1421
|
-
var _fastMerge = _interopRequireDefault(__webpack_require__(/*! ./fastMerge */ "./lib/fastMerge.js"));
|
|
1422
1460
|
|
|
1423
|
-
|
|
1461
|
+
const isDefined = underscore__WEBPACK_IMPORTED_MODULE_0___default().negate((underscore__WEBPACK_IMPORTED_MODULE_0___default().isUndefined));
|
|
1424
1462
|
|
|
1425
1463
|
/**
|
|
1426
1464
|
* In memory cache providing data by reference
|
|
1427
1465
|
* Encapsulates Onyx cache related functionality
|
|
1428
|
-
*/
|
|
1429
|
-
OnyxCache
|
|
1430
|
-
|
|
1466
|
+
*/
|
|
1467
|
+
class OnyxCache {
|
|
1468
|
+
constructor() {
|
|
1431
1469
|
/**
|
|
1432
1470
|
* @private
|
|
1433
1471
|
* Cache of all the storage keys available in persistent storage
|
|
@@ -1457,7 +1495,7 @@ OnyxCache = /*#__PURE__*/function () {
|
|
|
1457
1495
|
this.pendingPromises = {};
|
|
1458
1496
|
|
|
1459
1497
|
// bind all public methods to prevent problems with `this`
|
|
1460
|
-
|
|
1498
|
+
underscore__WEBPACK_IMPORTED_MODULE_0___default().bindAll(
|
|
1461
1499
|
this,
|
|
1462
1500
|
'getAllKeys', 'getValue', 'hasCacheForKey', 'addKey', 'set', 'drop', 'merge',
|
|
1463
1501
|
'hasPendingTask', 'getTaskPromise', 'captureTask', 'removeLeastRecentlyUsedKeys',
|
|
@@ -1468,168 +1506,168 @@ OnyxCache = /*#__PURE__*/function () {
|
|
|
1468
1506
|
/**
|
|
1469
1507
|
* Get all the storage keys
|
|
1470
1508
|
* @returns {string[]}
|
|
1471
|
-
*/
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
/**
|
|
1477
|
-
* Get a cached value from storage
|
|
1478
|
-
* @param {string} key
|
|
1479
|
-
* @returns {*}
|
|
1480
|
-
*/ }, { key: "getValue", value:
|
|
1481
|
-
function getValue(key) {
|
|
1482
|
-
this.addToAccessedKeys(key);
|
|
1483
|
-
return this.storageMap[key];
|
|
1484
|
-
}
|
|
1509
|
+
*/
|
|
1510
|
+
getAllKeys() {
|
|
1511
|
+
return Array.from(this.storageKeys);
|
|
1512
|
+
}
|
|
1485
1513
|
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1514
|
+
/**
|
|
1515
|
+
* Get a cached value from storage
|
|
1516
|
+
* @param {string} key
|
|
1517
|
+
* @returns {*}
|
|
1518
|
+
*/
|
|
1519
|
+
getValue(key) {
|
|
1520
|
+
this.addToAccessedKeys(key);
|
|
1521
|
+
return this.storageMap[key];
|
|
1522
|
+
}
|
|
1494
1523
|
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1524
|
+
/**
|
|
1525
|
+
* Check whether cache has data for the given key
|
|
1526
|
+
* @param {string} key
|
|
1527
|
+
* @returns {boolean}
|
|
1528
|
+
*/
|
|
1529
|
+
hasCacheForKey(key) {
|
|
1530
|
+
return isDefined(this.storageMap[key]);
|
|
1531
|
+
}
|
|
1503
1532
|
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
this.addKey(key);
|
|
1513
|
-
this.addToAccessedKeys(key);
|
|
1514
|
-
this.storageMap[key] = value;
|
|
1515
|
-
|
|
1516
|
-
return value;
|
|
1517
|
-
}
|
|
1533
|
+
/**
|
|
1534
|
+
* Saves a key in the storage keys list
|
|
1535
|
+
* Serves to keep the result of `getAllKeys` up to date
|
|
1536
|
+
* @param {string} key
|
|
1537
|
+
*/
|
|
1538
|
+
addKey(key) {
|
|
1539
|
+
this.storageKeys.add(key);
|
|
1540
|
+
}
|
|
1518
1541
|
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1542
|
+
/**
|
|
1543
|
+
* Set's a key value in cache
|
|
1544
|
+
* Adds the key to the storage keys list as well
|
|
1545
|
+
* @param {string} key
|
|
1546
|
+
* @param {*} value
|
|
1547
|
+
* @returns {*} value - returns the cache value
|
|
1548
|
+
*/
|
|
1549
|
+
set(key, value) {
|
|
1550
|
+
this.addKey(key);
|
|
1551
|
+
this.addToAccessedKeys(key);
|
|
1552
|
+
this.storageMap[key] = value;
|
|
1528
1553
|
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
* @param {Record<string, *>} data - a map of (cache) key - values
|
|
1532
|
-
*/ }, { key: "merge", value:
|
|
1533
|
-
function merge(data) {var _this = this;
|
|
1534
|
-
if (!_underscore.default.isObject(data) || _underscore.default.isArray(data)) {
|
|
1535
|
-
throw new Error('data passed to cache.merge() must be an Object of onyx key/value pairs');
|
|
1536
|
-
}
|
|
1554
|
+
return value;
|
|
1555
|
+
}
|
|
1537
1556
|
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1557
|
+
/**
|
|
1558
|
+
* Forget the cached value for the given key
|
|
1559
|
+
* @param {string} key
|
|
1560
|
+
*/
|
|
1561
|
+
drop(key) {
|
|
1562
|
+
delete this.storageMap[key];
|
|
1563
|
+
this.storageKeys.delete(key);
|
|
1564
|
+
this.recentKeys.delete(key);
|
|
1565
|
+
}
|
|
1541
1566
|
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1567
|
+
/**
|
|
1568
|
+
* Deep merge data to cache, any non existing keys will be created
|
|
1569
|
+
* @param {Record<string, *>} data - a map of (cache) key - values
|
|
1570
|
+
*/
|
|
1571
|
+
merge(data) {
|
|
1572
|
+
if (!underscore__WEBPACK_IMPORTED_MODULE_0___default().isObject(data) || underscore__WEBPACK_IMPORTED_MODULE_0___default().isArray(data)) {
|
|
1573
|
+
throw new Error('data passed to cache.merge() must be an Object of onyx key/value pairs');
|
|
1546
1574
|
}
|
|
1547
1575
|
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
* @returns {*}
|
|
1552
|
-
*/ }, { key: "hasPendingTask", value:
|
|
1553
|
-
function hasPendingTask(taskName) {
|
|
1554
|
-
return isDefined(this.pendingPromises[taskName]);
|
|
1555
|
-
}
|
|
1576
|
+
// lodash adds a small overhead so we don't use it here
|
|
1577
|
+
// eslint-disable-next-line prefer-object-spread, rulesdir/prefer-underscore-method
|
|
1578
|
+
this.storageMap = Object.assign({}, (0,_fastMerge__WEBPACK_IMPORTED_MODULE_2__["default"])(this.storageMap, data));
|
|
1556
1579
|
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
* @param {string} taskName - unique name given for the task
|
|
1563
|
-
* @returns {Promise<T>}
|
|
1564
|
-
*/ }, { key: "getTaskPromise", value:
|
|
1565
|
-
function getTaskPromise(taskName) {
|
|
1566
|
-
return this.pendingPromises[taskName];
|
|
1567
|
-
}
|
|
1580
|
+
const storageKeys = this.getAllKeys();
|
|
1581
|
+
const mergedKeys = underscore__WEBPACK_IMPORTED_MODULE_0___default().keys(data);
|
|
1582
|
+
this.storageKeys = new Set([...storageKeys, ...mergedKeys]);
|
|
1583
|
+
underscore__WEBPACK_IMPORTED_MODULE_0___default().each(mergedKeys, (key) => this.addToAccessedKeys(key));
|
|
1584
|
+
}
|
|
1568
1585
|
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
function captureTask(taskName, promise) {var _this2 = this;
|
|
1578
|
-
this.pendingPromises[taskName] = promise.finally(function () {
|
|
1579
|
-
delete _this2.pendingPromises[taskName];
|
|
1580
|
-
});
|
|
1586
|
+
/**
|
|
1587
|
+
* Check whether the given task is already running
|
|
1588
|
+
* @param {string} taskName - unique name given for the task
|
|
1589
|
+
* @returns {*}
|
|
1590
|
+
*/
|
|
1591
|
+
hasPendingTask(taskName) {
|
|
1592
|
+
return isDefined(this.pendingPromises[taskName]);
|
|
1593
|
+
}
|
|
1581
1594
|
|
|
1582
|
-
|
|
1583
|
-
|
|
1595
|
+
/**
|
|
1596
|
+
* Use this method to prevent concurrent calls for the same thing
|
|
1597
|
+
* Instead of calling the same task again use the existing promise
|
|
1598
|
+
* provided from this function
|
|
1599
|
+
* @template T
|
|
1600
|
+
* @param {string} taskName - unique name given for the task
|
|
1601
|
+
* @returns {Promise<T>}
|
|
1602
|
+
*/
|
|
1603
|
+
getTaskPromise(taskName) {
|
|
1604
|
+
return this.pendingPromises[taskName];
|
|
1605
|
+
}
|
|
1584
1606
|
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1607
|
+
/**
|
|
1608
|
+
* Capture a promise for a given task so other caller can
|
|
1609
|
+
* hook up to the promise if it's still pending
|
|
1610
|
+
* @template T
|
|
1611
|
+
* @param {string} taskName - unique name for the task
|
|
1612
|
+
* @param {Promise<T>} promise
|
|
1613
|
+
* @returns {Promise<T>}
|
|
1614
|
+
*/
|
|
1615
|
+
captureTask(taskName, promise) {
|
|
1616
|
+
this.pendingPromises[taskName] = promise.finally(() => {
|
|
1617
|
+
delete this.pendingPromises[taskName];
|
|
1618
|
+
});
|
|
1595
1619
|
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
*/ }, { key: "removeLeastRecentlyUsedKeys", value:
|
|
1599
|
-
function removeLeastRecentlyUsedKeys() {
|
|
1600
|
-
if (this.recentKeys.size <= this.maxRecentKeysSize) {
|
|
1601
|
-
return;
|
|
1602
|
-
}
|
|
1620
|
+
return this.pendingPromises[taskName];
|
|
1621
|
+
}
|
|
1603
1622
|
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1623
|
+
/**
|
|
1624
|
+
* @private
|
|
1625
|
+
* Adds a key to the top of the recently accessed keys
|
|
1626
|
+
* @param {string} key
|
|
1627
|
+
*/
|
|
1628
|
+
addToAccessedKeys(key) {
|
|
1629
|
+
// Removing and re-adding a key ensures it's at the end of the list
|
|
1630
|
+
this.recentKeys.delete(key);
|
|
1631
|
+
this.recentKeys.add(key);
|
|
1632
|
+
}
|
|
1608
1633
|
|
|
1609
|
-
|
|
1634
|
+
/**
|
|
1635
|
+
* Remove keys that don't fall into the range of recently used keys
|
|
1636
|
+
*/
|
|
1637
|
+
removeLeastRecentlyUsedKeys() {
|
|
1638
|
+
if (this.recentKeys.size <= this.maxRecentKeysSize) {
|
|
1639
|
+
return;
|
|
1610
1640
|
}
|
|
1611
1641
|
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
function setRecentKeysLimit(limit) {
|
|
1617
|
-
this.maxRecentKeysSize = limit;
|
|
1618
|
-
}
|
|
1642
|
+
// Get the last N keys by doing a negative slice
|
|
1643
|
+
const recentlyAccessed = [...this.recentKeys].slice(-this.maxRecentKeysSize);
|
|
1644
|
+
const storageKeys = underscore__WEBPACK_IMPORTED_MODULE_0___default().keys(this.storageMap);
|
|
1645
|
+
const keysToRemove = underscore__WEBPACK_IMPORTED_MODULE_0___default().difference(storageKeys, recentlyAccessed);
|
|
1619
1646
|
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
* @param {*} value
|
|
1623
|
-
* @returns {Boolean}
|
|
1624
|
-
*/ }, { key: "hasValueChanged", value:
|
|
1625
|
-
function hasValueChanged(key, value) {
|
|
1626
|
-
return !(0, _fastEquals.deepEqual)(this.storageMap[key], value);
|
|
1627
|
-
} }]);return OnyxCache;}();
|
|
1647
|
+
underscore__WEBPACK_IMPORTED_MODULE_0___default().each(keysToRemove, this.drop);
|
|
1648
|
+
}
|
|
1628
1649
|
|
|
1650
|
+
/**
|
|
1651
|
+
* Set the recent keys list size
|
|
1652
|
+
* @param {number} limit
|
|
1653
|
+
*/
|
|
1654
|
+
setRecentKeysLimit(limit) {
|
|
1655
|
+
this.maxRecentKeysSize = limit;
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
/**
|
|
1659
|
+
* @param {String} key
|
|
1660
|
+
* @param {*} value
|
|
1661
|
+
* @returns {Boolean}
|
|
1662
|
+
*/
|
|
1663
|
+
hasValueChanged(key, value) {
|
|
1664
|
+
return !(0,fast_equals__WEBPACK_IMPORTED_MODULE_1__.deepEqual)(this.storageMap[key], value);
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1629
1667
|
|
|
1630
|
-
|
|
1668
|
+
const instance = new OnyxCache();
|
|
1631
1669
|
|
|
1632
|
-
|
|
1670
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (instance);
|
|
1633
1671
|
|
|
1634
1672
|
/***/ }),
|
|
1635
1673
|
|
|
@@ -1637,9 +1675,14 @@ instance;exports["default"] = _default;
|
|
|
1637
1675
|
/*!**************************!*\
|
|
1638
1676
|
!*** ./lib/SyncQueue.js ***!
|
|
1639
1677
|
\**************************/
|
|
1640
|
-
/***/ ((__unused_webpack_module,
|
|
1678
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1641
1679
|
|
|
1642
|
-
|
|
1680
|
+
"use strict";
|
|
1681
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1682
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1683
|
+
/* harmony export */ "default": () => (/* binding */ SyncQueue)
|
|
1684
|
+
/* harmony export */ });
|
|
1685
|
+
/**
|
|
1643
1686
|
* Synchronous queue that can be used to ensure promise based tasks are run in sequence.
|
|
1644
1687
|
* Pass to the constructor a function that returns a promise to run the task then add data.
|
|
1645
1688
|
*
|
|
@@ -1651,12 +1694,12 @@ var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/inte
|
|
|
1651
1694
|
*
|
|
1652
1695
|
* queue.push({key: 1, val: '1'});
|
|
1653
1696
|
* queue.push({key: 2, val: '2'});
|
|
1654
|
-
*/
|
|
1655
|
-
SyncQueue
|
|
1697
|
+
*/
|
|
1698
|
+
class SyncQueue {
|
|
1656
1699
|
/**
|
|
1657
1700
|
* @param {Function} run - must return a promise
|
|
1658
1701
|
*/
|
|
1659
|
-
|
|
1702
|
+
constructor(run) {
|
|
1660
1703
|
this.queue = [];
|
|
1661
1704
|
this.isProcessing = false;
|
|
1662
1705
|
this.run = run;
|
|
@@ -1664,39 +1707,40 @@ SyncQueue = /*#__PURE__*/function () {
|
|
|
1664
1707
|
|
|
1665
1708
|
/**
|
|
1666
1709
|
* Stop the queue from being processed and clear out any existing tasks
|
|
1667
|
-
*/
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1710
|
+
*/
|
|
1711
|
+
abort() {
|
|
1712
|
+
this.queue = [];
|
|
1713
|
+
this.isProcessing = false;
|
|
1714
|
+
}
|
|
1672
1715
|
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1716
|
+
process() {
|
|
1717
|
+
if (this.isProcessing || this.queue.length === 0) {
|
|
1718
|
+
return;
|
|
1719
|
+
}
|
|
1677
1720
|
|
|
1678
|
-
|
|
1721
|
+
this.isProcessing = true;
|
|
1679
1722
|
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1723
|
+
const { data, resolve, reject } = this.queue.shift();
|
|
1724
|
+
this.run(data).
|
|
1725
|
+
then(resolve).
|
|
1726
|
+
catch(reject).
|
|
1727
|
+
finally(() => {
|
|
1728
|
+
this.isProcessing = false;
|
|
1729
|
+
this.process();
|
|
1730
|
+
});
|
|
1731
|
+
}
|
|
1689
1732
|
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1733
|
+
/**
|
|
1734
|
+
* @param {*} data
|
|
1735
|
+
* @returns {Promise}
|
|
1736
|
+
*/
|
|
1737
|
+
push(data) {
|
|
1738
|
+
return new Promise((resolve, reject) => {
|
|
1739
|
+
this.queue.push({ resolve, reject, data });
|
|
1740
|
+
this.process();
|
|
1741
|
+
});
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1700
1744
|
|
|
1701
1745
|
/***/ }),
|
|
1702
1746
|
|
|
@@ -1704,9 +1748,14 @@ SyncQueue = /*#__PURE__*/function () {
|
|
|
1704
1748
|
/*!***********************************!*\
|
|
1705
1749
|
!*** ./lib/createDeferredTask.js ***!
|
|
1706
1750
|
\***********************************/
|
|
1707
|
-
/***/ ((__unused_webpack_module,
|
|
1751
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1708
1752
|
|
|
1709
|
-
|
|
1753
|
+
"use strict";
|
|
1754
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1755
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1756
|
+
/* harmony export */ "default": () => (/* binding */ createDeferredTask)
|
|
1757
|
+
/* harmony export */ });
|
|
1758
|
+
/**
|
|
1710
1759
|
* Create a deferred task that can be resolved when we call `resolve()`
|
|
1711
1760
|
* The returned promise will complete when we call `resolve`
|
|
1712
1761
|
* Useful when we want to wait for a tasks that is resolved from an external action
|
|
@@ -1715,8 +1764,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));exports["default
|
|
|
1715
1764
|
* @returns {{ resolve: function(*), promise: Promise<T|void> }}
|
|
1716
1765
|
*/
|
|
1717
1766
|
function createDeferredTask() {
|
|
1718
|
-
|
|
1719
|
-
deferred.promise = new Promise(
|
|
1767
|
+
const deferred = {};
|
|
1768
|
+
deferred.promise = new Promise((res) => {
|
|
1720
1769
|
deferred.resolve = res;
|
|
1721
1770
|
});
|
|
1722
1771
|
|
|
@@ -1729,16 +1778,21 @@ function createDeferredTask() {
|
|
|
1729
1778
|
/*!**************************!*\
|
|
1730
1779
|
!*** ./lib/fastMerge.js ***!
|
|
1731
1780
|
\**************************/
|
|
1732
|
-
/***/ ((__unused_webpack_module,
|
|
1781
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1733
1782
|
|
|
1734
|
-
|
|
1783
|
+
"use strict";
|
|
1784
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1785
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1786
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
1787
|
+
/* harmony export */ });
|
|
1788
|
+
// Mostly copied from https://medium.com/@lubaka.a/how-to-remove-lodash-performance-improvement-b306669ad0e1
|
|
1735
1789
|
|
|
1736
1790
|
/**
|
|
1737
1791
|
* @param {mixed} val
|
|
1738
1792
|
* @returns {boolean}
|
|
1739
1793
|
*/
|
|
1740
1794
|
function isMergeableObject(val) {
|
|
1741
|
-
|
|
1795
|
+
const nonNullObject = val != null ? typeof val === 'object' : false;
|
|
1742
1796
|
return nonNullObject &&
|
|
1743
1797
|
Object.prototype.toString.call(val) !== '[object RegExp]' &&
|
|
1744
1798
|
Object.prototype.toString.call(val) !== '[object Date]';
|
|
@@ -1750,31 +1804,31 @@ function isMergeableObject(val) {
|
|
|
1750
1804
|
* @returns {Object}
|
|
1751
1805
|
*/
|
|
1752
1806
|
function mergeObject(target, source) {
|
|
1753
|
-
|
|
1807
|
+
const destination = {};
|
|
1754
1808
|
if (isMergeableObject(target)) {
|
|
1755
1809
|
// lodash adds a small overhead so we don't use it here
|
|
1756
1810
|
// eslint-disable-next-line rulesdir/prefer-underscore-method
|
|
1757
|
-
|
|
1758
|
-
for (
|
|
1759
|
-
|
|
1811
|
+
const targetKeys = Object.keys(target);
|
|
1812
|
+
for (let i = 0; i < targetKeys.length; ++i) {
|
|
1813
|
+
const key = targetKeys[i];
|
|
1760
1814
|
destination[key] = target[key];
|
|
1761
1815
|
}
|
|
1762
1816
|
}
|
|
1763
1817
|
|
|
1764
1818
|
// lodash adds a small overhead so we don't use it here
|
|
1765
1819
|
// eslint-disable-next-line rulesdir/prefer-underscore-method
|
|
1766
|
-
|
|
1767
|
-
for (
|
|
1768
|
-
|
|
1769
|
-
if (source[
|
|
1820
|
+
const sourceKeys = Object.keys(source);
|
|
1821
|
+
for (let i = 0; i < sourceKeys.length; ++i) {
|
|
1822
|
+
const key = sourceKeys[i];
|
|
1823
|
+
if (source[key] === undefined) {
|
|
1770
1824
|
// eslint-disable-next-line no-continue
|
|
1771
1825
|
continue;
|
|
1772
1826
|
}
|
|
1773
|
-
if (!isMergeableObject(source[
|
|
1774
|
-
destination[
|
|
1827
|
+
if (!isMergeableObject(source[key]) || !target[key]) {
|
|
1828
|
+
destination[key] = source[key];
|
|
1775
1829
|
} else {
|
|
1776
1830
|
// eslint-disable-next-line no-use-before-define
|
|
1777
|
-
destination[
|
|
1831
|
+
destination[key] = fastMerge(target[key], source[key]);
|
|
1778
1832
|
}
|
|
1779
1833
|
}
|
|
1780
1834
|
|
|
@@ -1789,14 +1843,14 @@ function mergeObject(target, source) {
|
|
|
1789
1843
|
function fastMerge(target, source) {
|
|
1790
1844
|
// lodash adds a small overhead so we don't use it here
|
|
1791
1845
|
// eslint-disable-next-line rulesdir/prefer-underscore-method
|
|
1792
|
-
|
|
1846
|
+
const array = Array.isArray(source);
|
|
1793
1847
|
if (array) {
|
|
1794
1848
|
return source;
|
|
1795
1849
|
}
|
|
1796
1850
|
return mergeObject(target, source);
|
|
1797
|
-
}
|
|
1851
|
+
}
|
|
1798
1852
|
|
|
1799
|
-
|
|
1853
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (fastMerge);
|
|
1800
1854
|
|
|
1801
1855
|
/***/ }),
|
|
1802
1856
|
|
|
@@ -1804,12 +1858,22 @@ fastMerge;exports["default"] = _default;
|
|
|
1804
1858
|
/*!*****************************************!*\
|
|
1805
1859
|
!*** ./lib/metrics/PerformanceUtils.js ***!
|
|
1806
1860
|
\*****************************************/
|
|
1807
|
-
/***/ ((__unused_webpack_module,
|
|
1861
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1862
|
+
|
|
1863
|
+
"use strict";
|
|
1864
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1865
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1866
|
+
/* harmony export */ "logSetStateCall": () => (/* binding */ logSetStateCall),
|
|
1867
|
+
/* harmony export */ "setShouldDebugSetState": () => (/* binding */ setShouldDebugSetState)
|
|
1868
|
+
/* harmony export */ });
|
|
1869
|
+
/* harmony import */ var lodash_transform__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lodash/transform */ "lodash/transform");
|
|
1870
|
+
/* harmony import */ var lodash_transform__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_transform__WEBPACK_IMPORTED_MODULE_0__);
|
|
1871
|
+
/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! underscore */ "underscore");
|
|
1872
|
+
/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(underscore__WEBPACK_IMPORTED_MODULE_1__);
|
|
1808
1873
|
|
|
1809
|
-
var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");Object.defineProperty(exports, "__esModule", ({ value: true }));exports.logSetStateCall = logSetStateCall;exports.setShouldDebugSetState = setShouldDebugSetState;var _transform = _interopRequireDefault(__webpack_require__(/*! lodash/transform */ "lodash/transform"));
|
|
1810
|
-
var _underscore = _interopRequireDefault(__webpack_require__(/*! underscore */ "underscore"));
|
|
1811
1874
|
|
|
1812
|
-
|
|
1875
|
+
|
|
1876
|
+
let debugSetState = false;
|
|
1813
1877
|
|
|
1814
1878
|
/**
|
|
1815
1879
|
* @param {Boolean} debug
|
|
@@ -1828,13 +1892,13 @@ function setShouldDebugSetState(debug) {
|
|
|
1828
1892
|
*/
|
|
1829
1893
|
function diffObject(object, base) {
|
|
1830
1894
|
function changes(obj, comparisonObject) {
|
|
1831
|
-
return (
|
|
1832
|
-
if (
|
|
1895
|
+
return lodash_transform__WEBPACK_IMPORTED_MODULE_0___default()(obj, (result, value, key) => {
|
|
1896
|
+
if (underscore__WEBPACK_IMPORTED_MODULE_1___default().isEqual(value, comparisonObject[key])) {
|
|
1833
1897
|
return;
|
|
1834
1898
|
}
|
|
1835
1899
|
|
|
1836
1900
|
// eslint-disable-next-line no-param-reassign
|
|
1837
|
-
result[key] =
|
|
1901
|
+
result[key] = underscore__WEBPACK_IMPORTED_MODULE_1___default().isObject(value) && underscore__WEBPACK_IMPORTED_MODULE_1___default().isObject(comparisonObject[key]) ?
|
|
1838
1902
|
changes(value, comparisonObject[key]) :
|
|
1839
1903
|
value;
|
|
1840
1904
|
});
|
|
@@ -1856,54 +1920,74 @@ function logSetStateCall(mapping, previousValue, newValue, caller, keyThatChange
|
|
|
1856
1920
|
return;
|
|
1857
1921
|
}
|
|
1858
1922
|
|
|
1859
|
-
|
|
1923
|
+
const logParams = {};
|
|
1860
1924
|
if (keyThatChanged) {
|
|
1861
1925
|
logParams.keyThatChanged = keyThatChanged;
|
|
1862
1926
|
}
|
|
1863
|
-
if (
|
|
1927
|
+
if (underscore__WEBPACK_IMPORTED_MODULE_1___default().isObject(newValue) && underscore__WEBPACK_IMPORTED_MODULE_1___default().isObject(previousValue)) {
|
|
1864
1928
|
logParams.difference = diffObject(previousValue, newValue);
|
|
1865
1929
|
} else {
|
|
1866
1930
|
logParams.previousValue = previousValue;
|
|
1867
1931
|
logParams.newValue = newValue;
|
|
1868
1932
|
}
|
|
1869
1933
|
|
|
1870
|
-
console.debug(
|
|
1934
|
+
console.debug(`[Onyx-Debug] ${mapping.displayName} setState() called. Subscribed to key '${mapping.key}' (${caller})`, logParams);
|
|
1871
1935
|
}
|
|
1872
1936
|
|
|
1937
|
+
|
|
1938
|
+
|
|
1873
1939
|
/***/ }),
|
|
1874
1940
|
|
|
1875
1941
|
/***/ "./lib/metrics/index.web.js":
|
|
1876
1942
|
/*!**********************************!*\
|
|
1877
1943
|
!*** ./lib/metrics/index.web.js ***!
|
|
1878
1944
|
\**********************************/
|
|
1879
|
-
/***/ ((__unused_webpack_module,
|
|
1945
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1880
1946
|
|
|
1881
|
-
|
|
1947
|
+
"use strict";
|
|
1948
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1949
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1950
|
+
/* harmony export */ "decorateWithMetrics": () => (/* binding */ decorateWithMetrics),
|
|
1951
|
+
/* harmony export */ "getMetrics": () => (/* binding */ getMetrics),
|
|
1952
|
+
/* harmony export */ "printMetrics": () => (/* binding */ printMetrics),
|
|
1953
|
+
/* harmony export */ "resetMetrics": () => (/* binding */ resetMetrics)
|
|
1954
|
+
/* harmony export */ });
|
|
1955
|
+
// For web-only implementations of Onyx, this module will just be a no-op
|
|
1882
1956
|
|
|
1883
1957
|
function decorateWithMetrics(func) {return func;}
|
|
1884
1958
|
function getMetrics() {}
|
|
1885
1959
|
function printMetrics() {}
|
|
1886
1960
|
function resetMetrics() {}
|
|
1887
1961
|
|
|
1962
|
+
|
|
1963
|
+
|
|
1888
1964
|
/***/ }),
|
|
1889
1965
|
|
|
1890
1966
|
/***/ "./lib/storage/WebStorage.js":
|
|
1891
1967
|
/*!***********************************!*\
|
|
1892
1968
|
!*** ./lib/storage/WebStorage.js ***!
|
|
1893
1969
|
\***********************************/
|
|
1894
|
-
/***/ ((__unused_webpack_module,
|
|
1970
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1895
1971
|
|
|
1896
|
-
|
|
1972
|
+
"use strict";
|
|
1973
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1974
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1975
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
1976
|
+
/* harmony export */ });
|
|
1977
|
+
/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! underscore */ "underscore");
|
|
1978
|
+
/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(underscore__WEBPACK_IMPORTED_MODULE_0__);
|
|
1979
|
+
/* harmony import */ var _providers_LocalForage__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./providers/LocalForage */ "./lib/storage/providers/LocalForage.js");
|
|
1980
|
+
/**
|
|
1981
|
+
* This file is here to wrap LocalForage with a layer that provides data-changed events like the ones that exist
|
|
1982
|
+
* when using LocalStorage APIs in the browser. These events are great because multiple tabs can listen for when
|
|
1983
|
+
* data changes and then stay up-to-date with everything happening in Onyx.
|
|
1984
|
+
*/
|
|
1897
1985
|
|
|
1898
1986
|
|
|
1899
1987
|
|
|
1988
|
+
const SYNC_ONYX = 'SYNC_ONYX';
|
|
1900
1989
|
|
|
1901
|
-
|
|
1902
|
-
var _LocalForage = _interopRequireDefault(__webpack_require__(/*! ./providers/LocalForage */ "./lib/storage/providers/LocalForage.js")); /**
|
|
1903
|
-
* This file is here to wrap LocalForage with a layer that provides data-changed events like the ones that exist
|
|
1904
|
-
* when using LocalStorage APIs in the browser. These events are great because multiple tabs can listen for when
|
|
1905
|
-
* data changes and then stay up-to-date with everything happening in Onyx.
|
|
1906
|
-
*/var SYNC_ONYX = 'SYNC_ONYX'; /**
|
|
1990
|
+
/**
|
|
1907
1991
|
* Raise an event thorough `localStorage` to let other tabs know a value changed
|
|
1908
1992
|
* @param {String} onyxKey
|
|
1909
1993
|
*/
|
|
@@ -1912,54 +1996,54 @@ function raiseStorageSyncEvent(onyxKey) {
|
|
|
1912
1996
|
__webpack_require__.g.localStorage.removeItem(SYNC_ONYX, onyxKey);
|
|
1913
1997
|
}
|
|
1914
1998
|
|
|
1915
|
-
|
|
1916
|
-
|
|
1999
|
+
const webStorage = {
|
|
2000
|
+
..._providers_LocalForage__WEBPACK_IMPORTED_MODULE_1__["default"],
|
|
1917
2001
|
|
|
1918
2002
|
/**
|
|
1919
2003
|
* @param {Function} onStorageKeyChanged Storage synchronization mechanism keeping all opened tabs in sync
|
|
1920
2004
|
*/
|
|
1921
|
-
keepInstancesSync
|
|
2005
|
+
keepInstancesSync(onStorageKeyChanged) {
|
|
1922
2006
|
// Override set, remove and clear to raise storage events that we intercept in other tabs
|
|
1923
|
-
this.setItem =
|
|
1924
|
-
|
|
2007
|
+
this.setItem = (key, value) => _providers_LocalForage__WEBPACK_IMPORTED_MODULE_1__["default"].setItem(key, value).
|
|
2008
|
+
then(() => raiseStorageSyncEvent(key));
|
|
1925
2009
|
|
|
1926
|
-
this.removeItem =
|
|
1927
|
-
|
|
2010
|
+
this.removeItem = (key) => _providers_LocalForage__WEBPACK_IMPORTED_MODULE_1__["default"].removeItem(key).
|
|
2011
|
+
then(() => raiseStorageSyncEvent(key));
|
|
1928
2012
|
|
|
1929
2013
|
// If we just call Storage.clear other tabs will have no idea which keys were available previously
|
|
1930
2014
|
// so that they can call keysChanged for them. That's why we iterate over every key and raise a storage sync
|
|
1931
2015
|
// event for each one
|
|
1932
|
-
this.clear =
|
|
1933
|
-
|
|
2016
|
+
this.clear = () => {
|
|
2017
|
+
let allKeys;
|
|
1934
2018
|
|
|
1935
2019
|
// They keys must be retreived before storage is cleared or else the list of keys would be empty
|
|
1936
|
-
return
|
|
1937
|
-
then(
|
|
2020
|
+
return _providers_LocalForage__WEBPACK_IMPORTED_MODULE_1__["default"].getAllKeys().
|
|
2021
|
+
then((keys) => {
|
|
1938
2022
|
allKeys = keys;
|
|
1939
2023
|
}).
|
|
1940
|
-
then(
|
|
1941
|
-
then(
|
|
2024
|
+
then(() => _providers_LocalForage__WEBPACK_IMPORTED_MODULE_1__["default"].clear()).
|
|
2025
|
+
then(() => {
|
|
1942
2026
|
// Now that storage is cleared, the storage sync event can happen which is a more atomic action
|
|
1943
2027
|
// for other browser tabs
|
|
1944
|
-
|
|
2028
|
+
underscore__WEBPACK_IMPORTED_MODULE_0___default().each(allKeys, raiseStorageSyncEvent);
|
|
1945
2029
|
});
|
|
1946
2030
|
};
|
|
1947
2031
|
|
|
1948
2032
|
// This listener will only be triggered by events coming from other tabs
|
|
1949
|
-
__webpack_require__.g.addEventListener('storage',
|
|
2033
|
+
__webpack_require__.g.addEventListener('storage', (event) => {
|
|
1950
2034
|
// Ignore events that don't originate from the SYNC_ONYX logic
|
|
1951
2035
|
if (event.key !== SYNC_ONYX || !event.newValue) {
|
|
1952
2036
|
return;
|
|
1953
2037
|
}
|
|
1954
2038
|
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
then(
|
|
2039
|
+
const onyxKey = event.newValue;
|
|
2040
|
+
_providers_LocalForage__WEBPACK_IMPORTED_MODULE_1__["default"].getItem(onyxKey).
|
|
2041
|
+
then((value) => onStorageKeyChanged(onyxKey, value));
|
|
1958
2042
|
});
|
|
1959
|
-
}
|
|
1960
|
-
|
|
2043
|
+
}
|
|
2044
|
+
};
|
|
1961
2045
|
|
|
1962
|
-
|
|
2046
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (webStorage);
|
|
1963
2047
|
|
|
1964
2048
|
/***/ }),
|
|
1965
2049
|
|
|
@@ -1967,11 +2051,17 @@ webStorage;exports["default"] = _default;
|
|
|
1967
2051
|
/*!**********************************!*\
|
|
1968
2052
|
!*** ./lib/storage/index.web.js ***!
|
|
1969
2053
|
\**********************************/
|
|
1970
|
-
/***/ ((__unused_webpack_module,
|
|
2054
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2055
|
+
|
|
2056
|
+
"use strict";
|
|
2057
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2058
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2059
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
2060
|
+
/* harmony export */ });
|
|
2061
|
+
/* harmony import */ var _WebStorage__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./WebStorage */ "./lib/storage/WebStorage.js");
|
|
1971
2062
|
|
|
1972
|
-
var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");Object.defineProperty(exports, "__esModule", ({ value: true }));exports["default"] = void 0;var _WebStorage = _interopRequireDefault(__webpack_require__(/*! ./WebStorage */ "./lib/storage/WebStorage.js"));var _default =
|
|
1973
2063
|
|
|
1974
|
-
|
|
2064
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_WebStorage__WEBPACK_IMPORTED_MODULE_0__["default"]);
|
|
1975
2065
|
|
|
1976
2066
|
/***/ }),
|
|
1977
2067
|
|
|
@@ -1979,44 +2069,55 @@ _WebStorage.default;exports["default"] = _default;
|
|
|
1979
2069
|
/*!**********************************************!*\
|
|
1980
2070
|
!*** ./lib/storage/providers/LocalForage.js ***!
|
|
1981
2071
|
\**********************************************/
|
|
1982
|
-
/***/ ((__unused_webpack_module,
|
|
2072
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1983
2073
|
|
|
1984
|
-
|
|
2074
|
+
"use strict";
|
|
2075
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2076
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2077
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
2078
|
+
/* harmony export */ });
|
|
2079
|
+
/* harmony import */ var localforage__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! localforage */ "localforage");
|
|
2080
|
+
/* harmony import */ var localforage__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(localforage__WEBPACK_IMPORTED_MODULE_0__);
|
|
2081
|
+
/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! underscore */ "underscore");
|
|
2082
|
+
/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(underscore__WEBPACK_IMPORTED_MODULE_1__);
|
|
2083
|
+
/* harmony import */ var _SyncQueue__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../SyncQueue */ "./lib/SyncQueue.js");
|
|
2084
|
+
/* harmony import */ var _fastMerge__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../fastMerge */ "./lib/fastMerge.js");
|
|
2085
|
+
/**
|
|
2086
|
+
* @file
|
|
2087
|
+
* The storage provider based on localforage allows us to store most anything in its
|
|
2088
|
+
* natural form in the underlying DB without having to stringify or de-stringify it
|
|
2089
|
+
*/
|
|
1985
2090
|
|
|
1986
2091
|
|
|
1987
2092
|
|
|
1988
2093
|
|
|
1989
2094
|
|
|
1990
|
-
var _localforage = _interopRequireDefault(__webpack_require__(/*! localforage */ "localforage"));
|
|
1991
|
-
var _underscore = _interopRequireDefault(__webpack_require__(/*! underscore */ "underscore"));
|
|
1992
|
-
var _SyncQueue = _interopRequireDefault(__webpack_require__(/*! ../../SyncQueue */ "./lib/SyncQueue.js"));
|
|
1993
|
-
var _fastMerge = _interopRequireDefault(__webpack_require__(/*! ../../fastMerge */ "./lib/fastMerge.js")); /**
|
|
1994
|
-
* @file
|
|
1995
|
-
* The storage provider based on localforage allows us to store most anything in its
|
|
1996
|
-
* natural form in the underlying DB without having to stringify or de-stringify it
|
|
1997
|
-
*/_localforage.default.config({ name: 'OnyxDB' });
|
|
1998
2095
|
|
|
1999
|
-
|
|
2096
|
+
localforage__WEBPACK_IMPORTED_MODULE_0___default().config({
|
|
2097
|
+
name: 'OnyxDB'
|
|
2098
|
+
});
|
|
2099
|
+
|
|
2100
|
+
const provider = {
|
|
2000
2101
|
/**
|
|
2001
2102
|
* Writing very quickly to IndexedDB causes performance issues and can lock up the page and lead to jank.
|
|
2002
2103
|
* So, we are slowing this process down by waiting until one write is complete before moving on
|
|
2003
2104
|
* to the next.
|
|
2004
2105
|
*/
|
|
2005
|
-
setItemQueue: new
|
|
2106
|
+
setItemQueue: new _SyncQueue__WEBPACK_IMPORTED_MODULE_2__["default"]((_ref) => {let { key, value, shouldMerge } = _ref;
|
|
2006
2107
|
if (shouldMerge) {
|
|
2007
|
-
return
|
|
2008
|
-
then(
|
|
2009
|
-
|
|
2108
|
+
return localforage__WEBPACK_IMPORTED_MODULE_0___default().getItem(key).
|
|
2109
|
+
then((existingValue) => {
|
|
2110
|
+
const newValue = underscore__WEBPACK_IMPORTED_MODULE_1___default().isObject(existingValue)
|
|
2010
2111
|
|
|
2011
2112
|
// lodash adds a small overhead so we don't use it here
|
|
2012
2113
|
// eslint-disable-next-line prefer-object-spread, rulesdir/prefer-underscore-method
|
|
2013
|
-
? Object.assign({}, (0,
|
|
2114
|
+
? Object.assign({}, (0,_fastMerge__WEBPACK_IMPORTED_MODULE_3__["default"])(existingValue, value)) :
|
|
2014
2115
|
value;
|
|
2015
|
-
return
|
|
2116
|
+
return localforage__WEBPACK_IMPORTED_MODULE_0___default().setItem(key, newValue);
|
|
2016
2117
|
});
|
|
2017
2118
|
}
|
|
2018
2119
|
|
|
2019
|
-
return
|
|
2120
|
+
return localforage__WEBPACK_IMPORTED_MODULE_0___default().setItem(key, value);
|
|
2020
2121
|
}),
|
|
2021
2122
|
|
|
2022
2123
|
/**
|
|
@@ -2024,11 +2125,11 @@ var provider = {
|
|
|
2024
2125
|
* @param {String[]} keys
|
|
2025
2126
|
* @return {Promise<Array<[key, value]>>}
|
|
2026
2127
|
*/
|
|
2027
|
-
multiGet
|
|
2028
|
-
|
|
2128
|
+
multiGet(keys) {
|
|
2129
|
+
const pairs = underscore__WEBPACK_IMPORTED_MODULE_1___default().map(
|
|
2029
2130
|
keys,
|
|
2030
|
-
|
|
2031
|
-
|
|
2131
|
+
(key) => localforage__WEBPACK_IMPORTED_MODULE_0___default().getItem(key).
|
|
2132
|
+
then((value) => [key, value]));
|
|
2032
2133
|
|
|
2033
2134
|
|
|
2034
2135
|
return Promise.all(pairs);
|
|
@@ -2039,11 +2140,11 @@ var provider = {
|
|
|
2039
2140
|
* @param {Array<[key, value]>} pairs
|
|
2040
2141
|
* @return {Promise<void>}
|
|
2041
2142
|
*/
|
|
2042
|
-
multiMerge
|
|
2043
|
-
|
|
2143
|
+
multiMerge(pairs) {
|
|
2144
|
+
const tasks = underscore__WEBPACK_IMPORTED_MODULE_1___default().map(pairs, (_ref2) => {let [key, value] = _ref2;return this.setItemQueue.push({ key, value, shouldMerge: true });});
|
|
2044
2145
|
|
|
2045
2146
|
// We're returning Promise.resolve, otherwise the array of task results will be returned to the caller
|
|
2046
|
-
return Promise.all(tasks).then(
|
|
2147
|
+
return Promise.all(tasks).then(() => Promise.resolve());
|
|
2047
2148
|
},
|
|
2048
2149
|
|
|
2049
2150
|
/**
|
|
@@ -2051,40 +2152,40 @@ var provider = {
|
|
|
2051
2152
|
* @param {Array<[key, value]>} pairs
|
|
2052
2153
|
* @return {Promise<void>}
|
|
2053
2154
|
*/
|
|
2054
|
-
multiSet
|
|
2155
|
+
multiSet(pairs) {
|
|
2055
2156
|
// We're returning Promise.resolve, otherwise the array of task results will be returned to the caller
|
|
2056
|
-
|
|
2057
|
-
return Promise.all(tasks).then(
|
|
2157
|
+
const tasks = underscore__WEBPACK_IMPORTED_MODULE_1___default().map(pairs, (_ref3) => {let [key, value] = _ref3;return this.setItem(key, value);});
|
|
2158
|
+
return Promise.all(tasks).then(() => Promise.resolve());
|
|
2058
2159
|
},
|
|
2059
2160
|
|
|
2060
2161
|
/**
|
|
2061
2162
|
* Clear everything from storage and also stops the SyncQueue from adding anything more to storage
|
|
2062
2163
|
* @returns {Promise<void>}
|
|
2063
2164
|
*/
|
|
2064
|
-
clear
|
|
2165
|
+
clear() {
|
|
2065
2166
|
this.setItemQueue.abort();
|
|
2066
|
-
return
|
|
2167
|
+
return localforage__WEBPACK_IMPORTED_MODULE_0___default().clear();
|
|
2067
2168
|
},
|
|
2068
2169
|
|
|
2069
2170
|
/**
|
|
2070
2171
|
* Returns all keys available in storage
|
|
2071
2172
|
* @returns {Promise<String[]>}
|
|
2072
2173
|
*/
|
|
2073
|
-
getAllKeys:
|
|
2174
|
+
getAllKeys: (localforage__WEBPACK_IMPORTED_MODULE_0___default().keys),
|
|
2074
2175
|
|
|
2075
2176
|
/**
|
|
2076
2177
|
* Get the value of a given key or return `null` if it's not available in storage
|
|
2077
2178
|
* @param {String} key
|
|
2078
2179
|
* @return {Promise<*>}
|
|
2079
2180
|
*/
|
|
2080
|
-
getItem:
|
|
2181
|
+
getItem: (localforage__WEBPACK_IMPORTED_MODULE_0___default().getItem),
|
|
2081
2182
|
|
|
2082
2183
|
/**
|
|
2083
2184
|
* Remove given key and it's value from storage
|
|
2084
2185
|
* @param {String} key
|
|
2085
2186
|
* @returns {Promise<void>}
|
|
2086
2187
|
*/
|
|
2087
|
-
removeItem:
|
|
2188
|
+
removeItem: (localforage__WEBPACK_IMPORTED_MODULE_0___default().removeItem),
|
|
2088
2189
|
|
|
2089
2190
|
/**
|
|
2090
2191
|
* Sets the value for a given key. The only requirement is that the value should be serializable to JSON string
|
|
@@ -2092,12 +2193,12 @@ var provider = {
|
|
|
2092
2193
|
* @param {*} value
|
|
2093
2194
|
* @return {Promise<void>}
|
|
2094
2195
|
*/
|
|
2095
|
-
setItem
|
|
2096
|
-
return this.setItemQueue.push({ key
|
|
2196
|
+
setItem(key, value) {
|
|
2197
|
+
return this.setItemQueue.push({ key, value });
|
|
2097
2198
|
}
|
|
2098
|
-
};
|
|
2199
|
+
};
|
|
2099
2200
|
|
|
2100
|
-
|
|
2201
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (provider);
|
|
2101
2202
|
|
|
2102
2203
|
/***/ }),
|
|
2103
2204
|
|
|
@@ -2105,18 +2206,32 @@ provider;exports["default"] = _default;
|
|
|
2105
2206
|
/*!*************************!*\
|
|
2106
2207
|
!*** ./lib/withOnyx.js ***!
|
|
2107
2208
|
\*************************/
|
|
2108
|
-
/***/ ((__unused_webpack_module,
|
|
2209
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2210
|
+
|
|
2211
|
+
"use strict";
|
|
2212
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2213
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2214
|
+
/* harmony export */ "default": () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__)
|
|
2215
|
+
/* harmony export */ });
|
|
2216
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
2217
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
2218
|
+
/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! underscore */ "underscore");
|
|
2219
|
+
/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(underscore__WEBPACK_IMPORTED_MODULE_1__);
|
|
2220
|
+
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! prop-types */ "./node_modules/prop-types/index.js");
|
|
2221
|
+
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_2__);
|
|
2222
|
+
/* harmony import */ var expensify_common_lib_str__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! expensify-common/lib/str */ "expensify-common/lib/str");
|
|
2223
|
+
/* harmony import */ var expensify_common_lib_str__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(expensify_common_lib_str__WEBPACK_IMPORTED_MODULE_3__);
|
|
2224
|
+
/* harmony import */ var _Onyx__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Onyx */ "./lib/Onyx.js");
|
|
2225
|
+
function _extends() {_extends = Object.assign || function (target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i];for (var key in source) {if (Object.prototype.hasOwnProperty.call(source, key)) {target[key] = source[key];}}}return target;};return _extends.apply(this, arguments);} /**
|
|
2226
|
+
* This is a higher order component that provides the ability to map a state property directly to
|
|
2227
|
+
* something in Onyx (a key/value store). That way, as soon as data in Onyx changes, the state will be set and the view
|
|
2228
|
+
* will automatically change to reflect the new data.
|
|
2229
|
+
*/
|
|
2109
2230
|
|
|
2110
|
-
var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");Object.defineProperty(exports, "__esModule", ({ value: true }));exports["default"] = _default;var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "./node_modules/@babel/runtime/helpers/defineProperty.js"));var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "./node_modules/@babel/runtime/helpers/classCallCheck.js"));var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "./node_modules/@babel/runtime/helpers/createClass.js"));var _assertThisInitialized2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/assertThisInitialized */ "./node_modules/@babel/runtime/helpers/assertThisInitialized.js"));var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "./node_modules/@babel/runtime/helpers/inherits.js"));var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "./node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "./node_modules/@babel/runtime/helpers/getPrototypeOf.js"));var _jsxRuntime = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js");
|
|
2111
2231
|
|
|
2112
2232
|
|
|
2113
2233
|
|
|
2114
2234
|
|
|
2115
|
-
var _react = _interopRequireDefault(__webpack_require__(/*! react */ "react"));
|
|
2116
|
-
var _underscore = _interopRequireDefault(__webpack_require__(/*! underscore */ "underscore"));
|
|
2117
|
-
var _propTypes = _interopRequireDefault(__webpack_require__(/*! prop-types */ "./node_modules/prop-types/index.js"));
|
|
2118
|
-
var _str = _interopRequireDefault(__webpack_require__(/*! expensify-common/lib/str */ "expensify-common/lib/str"));
|
|
2119
|
-
var _Onyx = _interopRequireDefault(__webpack_require__(/*! ./Onyx */ "./lib/Onyx.js"));var _jsxFileName = "/home/runner/work/react-native-onyx/react-native-onyx/lib/withOnyx.js";function _createSuper(Derived) {var hasNativeReflectConstruct = _isNativeReflectConstruct();return function _createSuperInternal() {var Super = (0, _getPrototypeOf2.default)(Derived),result;if (hasNativeReflectConstruct) {var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;result = Reflect.construct(Super, arguments, NewTarget);} else {result = Super.apply(this, arguments);}return (0, _possibleConstructorReturn2.default)(this, result);};}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;}}
|
|
2120
2235
|
|
|
2121
2236
|
/**
|
|
2122
2237
|
* Returns the display name of a component
|
|
@@ -2128,183 +2243,183 @@ function getDisplayName(component) {
|
|
|
2128
2243
|
return component.displayName || component.name || 'Component';
|
|
2129
2244
|
}
|
|
2130
2245
|
|
|
2131
|
-
function
|
|
2246
|
+
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(mapOnyxToState) {
|
|
2132
2247
|
// A list of keys that must be present in tempState before we can render the WrappedComponent
|
|
2133
|
-
|
|
2134
|
-
omit(
|
|
2248
|
+
const requiredKeysForInit = underscore__WEBPACK_IMPORTED_MODULE_1___default().chain(mapOnyxToState).
|
|
2249
|
+
omit((config) => config.initWithStoredValues === false).
|
|
2135
2250
|
keys().
|
|
2136
2251
|
value();
|
|
2137
|
-
return
|
|
2138
|
-
|
|
2139
|
-
withOnyx
|
|
2140
|
-
|
|
2141
|
-
|
|
2252
|
+
return (WrappedComponent) => {
|
|
2253
|
+
const displayName = getDisplayName(WrappedComponent);
|
|
2254
|
+
class withOnyx extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component) {
|
|
2255
|
+
constructor(props) {
|
|
2256
|
+
super(props);
|
|
2142
2257
|
|
|
2143
|
-
|
|
2258
|
+
this.setWithOnyxState = this.setWithOnyxState.bind(this);
|
|
2144
2259
|
|
|
2145
2260
|
// This stores all the Onyx connection IDs to be used when the component unmounts so everything can be
|
|
2146
2261
|
// disconnected. It is a key value store with the format {[mapping.key]: connectionID}.
|
|
2147
|
-
|
|
2262
|
+
this.activeConnectionIDs = {};
|
|
2148
2263
|
|
|
2149
2264
|
// Object holding the temporary initial state for the component while we load the various Onyx keys
|
|
2150
|
-
|
|
2265
|
+
this.tempState = {};
|
|
2151
2266
|
|
|
2152
|
-
|
|
2267
|
+
this.state = {
|
|
2153
2268
|
// If there are no required keys for init then we can render the wrapped component immediately
|
|
2154
2269
|
loading: requiredKeysForInit.length > 0
|
|
2155
|
-
};
|
|
2156
|
-
}
|
|
2157
|
-
|
|
2158
|
-
function componentDidMount() {var _this3 = this;
|
|
2159
|
-
// Subscribe each of the state properties to the proper Onyx key
|
|
2160
|
-
_underscore.default.each(mapOnyxToState, function (mapping, propertyName) {
|
|
2161
|
-
_this3.connectMappingToOnyx(mapping, propertyName);
|
|
2162
|
-
});
|
|
2163
|
-
this.checkEvictableKeys();
|
|
2164
|
-
} }, { key: "componentDidUpdate", value:
|
|
2165
|
-
|
|
2166
|
-
function componentDidUpdate(prevProps) {var _this4 = this;
|
|
2167
|
-
// If any of the mappings use data from the props, then when the props change, all the
|
|
2168
|
-
// connections need to be reconnected with the new props
|
|
2169
|
-
_underscore.default.each(mapOnyxToState, function (mapping, propertyName) {
|
|
2170
|
-
var previousKey = _str.default.result(mapping.key, prevProps);
|
|
2171
|
-
var newKey = _str.default.result(mapping.key, _this4.props);
|
|
2172
|
-
|
|
2173
|
-
if (previousKey !== newKey) {
|
|
2174
|
-
_Onyx.default.disconnect(_this4.activeConnectionIDs[previousKey], previousKey);
|
|
2175
|
-
delete _this4.activeConnectionIDs[previousKey];
|
|
2176
|
-
_this4.connectMappingToOnyx(mapping, propertyName);
|
|
2177
|
-
}
|
|
2178
|
-
});
|
|
2179
|
-
this.checkEvictableKeys();
|
|
2180
|
-
} }, { key: "componentWillUnmount", value:
|
|
2181
|
-
|
|
2182
|
-
function componentWillUnmount() {var _this5 = this;
|
|
2183
|
-
// Disconnect everything from Onyx
|
|
2184
|
-
_underscore.default.each(mapOnyxToState, function (mapping) {
|
|
2185
|
-
var key = _str.default.result(mapping.key, _this5.props);
|
|
2186
|
-
var connectionID = _this5.activeConnectionIDs[key];
|
|
2187
|
-
_Onyx.default.disconnect(connectionID, key);
|
|
2188
|
-
});
|
|
2189
|
-
}
|
|
2270
|
+
};
|
|
2271
|
+
}
|
|
2190
2272
|
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
*/ }, { key: "setWithOnyxState", value:
|
|
2199
|
-
function setWithOnyxState(statePropertyName, val) {var _this6 = this;
|
|
2200
|
-
if (!this.state.loading) {
|
|
2201
|
-
this.setState((0, _defineProperty2.default)({}, statePropertyName, val));
|
|
2202
|
-
return;
|
|
2203
|
-
}
|
|
2273
|
+
componentDidMount() {
|
|
2274
|
+
// Subscribe each of the state properties to the proper Onyx key
|
|
2275
|
+
underscore__WEBPACK_IMPORTED_MODULE_1___default().each(mapOnyxToState, (mapping, propertyName) => {
|
|
2276
|
+
this.connectMappingToOnyx(mapping, propertyName);
|
|
2277
|
+
});
|
|
2278
|
+
this.checkEvictableKeys();
|
|
2279
|
+
}
|
|
2204
2280
|
|
|
2205
|
-
|
|
2281
|
+
componentDidUpdate(prevProps) {
|
|
2282
|
+
// If any of the mappings use data from the props, then when the props change, all the
|
|
2283
|
+
// connections need to be reconnected with the new props
|
|
2284
|
+
underscore__WEBPACK_IMPORTED_MODULE_1___default().each(mapOnyxToState, (mapping, propertyName) => {
|
|
2285
|
+
const previousKey = expensify_common_lib_str__WEBPACK_IMPORTED_MODULE_3___default().result(mapping.key, prevProps);
|
|
2286
|
+
const newKey = expensify_common_lib_str__WEBPACK_IMPORTED_MODULE_3___default().result(mapping.key, this.props);
|
|
2206
2287
|
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2288
|
+
if (previousKey !== newKey) {
|
|
2289
|
+
_Onyx__WEBPACK_IMPORTED_MODULE_4__["default"].disconnect(this.activeConnectionIDs[previousKey], previousKey);
|
|
2290
|
+
delete this.activeConnectionIDs[previousKey];
|
|
2291
|
+
this.connectMappingToOnyx(mapping, propertyName);
|
|
2210
2292
|
}
|
|
2293
|
+
});
|
|
2294
|
+
this.checkEvictableKeys();
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
componentWillUnmount() {
|
|
2298
|
+
// Disconnect everything from Onyx
|
|
2299
|
+
underscore__WEBPACK_IMPORTED_MODULE_1___default().each(mapOnyxToState, (mapping) => {
|
|
2300
|
+
const key = expensify_common_lib_str__WEBPACK_IMPORTED_MODULE_3___default().result(mapping.key, this.props);
|
|
2301
|
+
const connectionID = this.activeConnectionIDs[key];
|
|
2302
|
+
_Onyx__WEBPACK_IMPORTED_MODULE_4__["default"].disconnect(connectionID, key);
|
|
2303
|
+
});
|
|
2304
|
+
}
|
|
2211
2305
|
|
|
2212
|
-
|
|
2213
|
-
|
|
2306
|
+
/**
|
|
2307
|
+
* This method is used externally by sendDataToConnection to prevent unnecessary renders while a component
|
|
2308
|
+
* still in a loading state. The temporary initial state is saved to the component instance and setState()
|
|
2309
|
+
* only called once all the necessary data has been collected.
|
|
2310
|
+
*
|
|
2311
|
+
* @param {String} statePropertyName
|
|
2312
|
+
* @param {*} val
|
|
2313
|
+
*/
|
|
2314
|
+
setWithOnyxState(statePropertyName, val) {
|
|
2315
|
+
if (!this.state.loading) {
|
|
2316
|
+
this.setState({ [statePropertyName]: val });
|
|
2317
|
+
return;
|
|
2214
2318
|
}
|
|
2215
2319
|
|
|
2216
|
-
|
|
2217
|
-
* Makes sure each Onyx key we requested has been set to state with a value of some kind.
|
|
2218
|
-
* We are doing this so that the wrapped component will only render when all the data
|
|
2219
|
-
* it needs is available to it.
|
|
2220
|
-
*/ }, { key: "checkEvictableKeys", value:
|
|
2221
|
-
function checkEvictableKeys() {var _this7 = this;
|
|
2222
|
-
// We will add this key to our list of recently accessed keys
|
|
2223
|
-
// if the canEvict function returns true. This is necessary criteria
|
|
2224
|
-
// we MUST use to specify if a key can be removed or not.
|
|
2225
|
-
_underscore.default.each(mapOnyxToState, function (mapping) {
|
|
2226
|
-
if (_underscore.default.isUndefined(mapping.canEvict)) {
|
|
2227
|
-
return;
|
|
2228
|
-
}
|
|
2320
|
+
this.tempState[statePropertyName] = val;
|
|
2229
2321
|
|
|
2230
|
-
|
|
2231
|
-
|
|
2322
|
+
// All state keys should exist and at least have a value of null
|
|
2323
|
+
if (underscore__WEBPACK_IMPORTED_MODULE_1___default().some(requiredKeysForInit, (key) => underscore__WEBPACK_IMPORTED_MODULE_1___default().isUndefined(this.tempState[key]))) {
|
|
2324
|
+
return;
|
|
2325
|
+
}
|
|
2232
2326
|
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2327
|
+
this.setState({ ...this.tempState, loading: false });
|
|
2328
|
+
delete this.tempState;
|
|
2329
|
+
}
|
|
2330
|
+
|
|
2331
|
+
/**
|
|
2332
|
+
* Makes sure each Onyx key we requested has been set to state with a value of some kind.
|
|
2333
|
+
* We are doing this so that the wrapped component will only render when all the data
|
|
2334
|
+
* it needs is available to it.
|
|
2335
|
+
*/
|
|
2336
|
+
checkEvictableKeys() {
|
|
2337
|
+
// We will add this key to our list of recently accessed keys
|
|
2338
|
+
// if the canEvict function returns true. This is necessary criteria
|
|
2339
|
+
// we MUST use to specify if a key can be removed or not.
|
|
2340
|
+
underscore__WEBPACK_IMPORTED_MODULE_1___default().each(mapOnyxToState, (mapping) => {
|
|
2341
|
+
if (underscore__WEBPACK_IMPORTED_MODULE_1___default().isUndefined(mapping.canEvict)) {
|
|
2342
|
+
return;
|
|
2343
|
+
}
|
|
2236
2344
|
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
} else {
|
|
2240
|
-
_Onyx.default.addToEvictionBlockList(key, mapping.connectionID);
|
|
2241
|
-
}
|
|
2242
|
-
});
|
|
2243
|
-
}
|
|
2345
|
+
const canEvict = expensify_common_lib_str__WEBPACK_IMPORTED_MODULE_3___default().result(mapping.canEvict, this.props);
|
|
2346
|
+
const key = expensify_common_lib_str__WEBPACK_IMPORTED_MODULE_3___default().result(mapping.key, this.props);
|
|
2244
2347
|
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
* component
|
|
2254
|
-
*/ }, { key: "connectMappingToOnyx", value:
|
|
2255
|
-
function connectMappingToOnyx(mapping, statePropertyName) {
|
|
2256
|
-
var key = _str.default.result(mapping.key, this.props);
|
|
2257
|
-
|
|
2258
|
-
// eslint-disable-next-line rulesdir/prefer-onyx-connect-in-libs
|
|
2259
|
-
this.activeConnectionIDs[key] = _Onyx.default.connect(Object.assign({},
|
|
2260
|
-
mapping, {
|
|
2261
|
-
key: key,
|
|
2262
|
-
statePropertyName: statePropertyName,
|
|
2263
|
-
withOnyxInstance: this,
|
|
2264
|
-
displayName: displayName }));
|
|
2265
|
-
|
|
2266
|
-
} }, { key: "render", value:
|
|
2267
|
-
|
|
2268
|
-
function render() {
|
|
2269
|
-
if (this.state.loading) {
|
|
2270
|
-
return null;
|
|
2348
|
+
if (!_Onyx__WEBPACK_IMPORTED_MODULE_4__["default"].isSafeEvictionKey(key)) {
|
|
2349
|
+
throw new Error(`canEvict can't be used on key '${key}'. This key must explicitly be flagged as safe for removal by adding it to Onyx.init({safeEvictionKeys: []}).`);
|
|
2350
|
+
}
|
|
2351
|
+
|
|
2352
|
+
if (canEvict) {
|
|
2353
|
+
_Onyx__WEBPACK_IMPORTED_MODULE_4__["default"].removeFromEvictionBlockList(key, mapping.connectionID);
|
|
2354
|
+
} else {
|
|
2355
|
+
_Onyx__WEBPACK_IMPORTED_MODULE_4__["default"].addToEvictionBlockList(key, mapping.connectionID);
|
|
2271
2356
|
}
|
|
2357
|
+
});
|
|
2358
|
+
}
|
|
2272
2359
|
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2360
|
+
/**
|
|
2361
|
+
* Takes a single mapping and binds the state of the component to the store
|
|
2362
|
+
*
|
|
2363
|
+
* @param {object} mapping
|
|
2364
|
+
* @param {string|function} mapping.key key to connect to. can be a string or a
|
|
2365
|
+
* function that takes this.props as an argument and returns a string
|
|
2366
|
+
* @param {string} statePropertyName the name of the state property that Onyx will add the data to
|
|
2367
|
+
* @param {boolean} [mapping.initWithStoredValues] If set to false, then no data will be prefilled into the
|
|
2368
|
+
* component
|
|
2369
|
+
*/
|
|
2370
|
+
connectMappingToOnyx(mapping, statePropertyName) {
|
|
2371
|
+
const key = expensify_common_lib_str__WEBPACK_IMPORTED_MODULE_3___default().result(mapping.key, this.props);
|
|
2372
|
+
|
|
2373
|
+
// eslint-disable-next-line rulesdir/prefer-onyx-connect-in-libs
|
|
2374
|
+
this.activeConnectionIDs[key] = _Onyx__WEBPACK_IMPORTED_MODULE_4__["default"].connect({
|
|
2375
|
+
...mapping,
|
|
2376
|
+
key,
|
|
2377
|
+
statePropertyName,
|
|
2378
|
+
withOnyxInstance: this,
|
|
2379
|
+
displayName
|
|
2380
|
+
});
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
render() {
|
|
2384
|
+
if (this.state.loading) {
|
|
2385
|
+
return null;
|
|
2386
|
+
}
|
|
2277
2387
|
|
|
2278
|
-
|
|
2279
|
-
|
|
2388
|
+
// Remove any internal state properties used by withOnyx
|
|
2389
|
+
// that should not be passed to a wrapped component
|
|
2390
|
+
let stateToPass = underscore__WEBPACK_IMPORTED_MODULE_1___default().omit(this.state, 'loading');
|
|
2391
|
+
stateToPass = underscore__WEBPACK_IMPORTED_MODULE_1___default().omit(stateToPass, (value) => underscore__WEBPACK_IMPORTED_MODULE_1___default().isNull(value));
|
|
2280
2392
|
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
(0, _jsxRuntime.jsx)(WrappedComponent
|
|
2284
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
2285
|
-
, Object.assign({}, propsToPass,
|
|
2393
|
+
// Remove any null values so that React replaces them with default props
|
|
2394
|
+
const propsToPass = underscore__WEBPACK_IMPORTED_MODULE_1___default().omit(this.props, (value) => underscore__WEBPACK_IMPORTED_MODULE_1___default().isNull(value));
|
|
2286
2395
|
|
|
2287
|
-
|
|
2288
|
-
|
|
2396
|
+
// Spreading props and state is necessary in an HOC where the data cannot be predicted
|
|
2397
|
+
return /*#__PURE__*/(
|
|
2398
|
+
react__WEBPACK_IMPORTED_MODULE_0___default().createElement(WrappedComponent
|
|
2399
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
2400
|
+
, _extends({}, propsToPass,
|
|
2289
2401
|
|
|
2402
|
+
stateToPass, {
|
|
2403
|
+
ref: this.props.forwardedRef })));
|
|
2290
2404
|
|
|
2291
|
-
} }]);return withOnyx;}(_react.default.Component);
|
|
2292
2405
|
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2293
2408
|
|
|
2294
2409
|
withOnyx.propTypes = {
|
|
2295
|
-
forwardedRef:
|
|
2296
|
-
|
|
2297
|
-
|
|
2410
|
+
forwardedRef: prop_types__WEBPACK_IMPORTED_MODULE_2___default().oneOfType([
|
|
2411
|
+
(prop_types__WEBPACK_IMPORTED_MODULE_2___default().func),
|
|
2412
|
+
prop_types__WEBPACK_IMPORTED_MODULE_2___default().shape({ current: prop_types__WEBPACK_IMPORTED_MODULE_2___default().instanceOf((react__WEBPACK_IMPORTED_MODULE_0___default().Component)) })])
|
|
2298
2413
|
|
|
2299
2414
|
};
|
|
2300
2415
|
withOnyx.defaultProps = {
|
|
2301
2416
|
forwardedRef: undefined
|
|
2302
2417
|
};
|
|
2303
|
-
withOnyx.displayName =
|
|
2304
|
-
return
|
|
2305
|
-
|
|
2418
|
+
withOnyx.displayName = `withOnyx(${displayName})`;
|
|
2419
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().forwardRef((props, ref) => {
|
|
2420
|
+
const Component = withOnyx;
|
|
2306
2421
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
2307
|
-
return /*#__PURE__*/(
|
|
2422
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(Component, _extends({}, props, { forwardedRef: ref }));
|
|
2308
2423
|
});
|
|
2309
2424
|
};
|
|
2310
2425
|
}
|
|
@@ -3383,1355 +3498,16 @@ if (false) {} else {
|
|
|
3383
3498
|
|
|
3384
3499
|
/***/ }),
|
|
3385
3500
|
|
|
3386
|
-
/***/ "
|
|
3387
|
-
|
|
3388
|
-
!***
|
|
3389
|
-
|
|
3390
|
-
/***/ ((
|
|
3501
|
+
/***/ "expensify-common/lib/str":
|
|
3502
|
+
/*!*******************************************!*\
|
|
3503
|
+
!*** external "expensify-common/lib/str" ***!
|
|
3504
|
+
\*******************************************/
|
|
3505
|
+
/***/ ((module) => {
|
|
3391
3506
|
|
|
3392
3507
|
"use strict";
|
|
3393
|
-
|
|
3394
|
-
* @license React
|
|
3395
|
-
* react-jsx-runtime.development.js
|
|
3396
|
-
*
|
|
3397
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3398
|
-
*
|
|
3399
|
-
* This source code is licensed under the MIT license found in the
|
|
3400
|
-
* LICENSE file in the root directory of this source tree.
|
|
3401
|
-
*/
|
|
3402
|
-
|
|
3508
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_expensify_common_lib_str__;
|
|
3403
3509
|
|
|
3404
|
-
|
|
3405
|
-
if (true) {
|
|
3406
|
-
(function() {
|
|
3407
|
-
'use strict';
|
|
3408
|
-
|
|
3409
|
-
var React = __webpack_require__(/*! react */ "react");
|
|
3410
|
-
|
|
3411
|
-
// -----------------------------------------------------------------------------
|
|
3412
|
-
|
|
3413
|
-
var enableScopeAPI = false; // Experimental Create Event Handle API.
|
|
3414
|
-
var enableCacheElement = false;
|
|
3415
|
-
var enableTransitionTracing = false; // No known bugs, but needs performance testing
|
|
3416
|
-
|
|
3417
|
-
var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber
|
|
3418
|
-
// stuff. Intended to enable React core members to more easily debug scheduling
|
|
3419
|
-
// issues in DEV builds.
|
|
3420
|
-
|
|
3421
|
-
var enableDebugTracing = false; // Track which Fiber(s) schedule render work.
|
|
3422
|
-
|
|
3423
|
-
// ATTENTION
|
|
3424
|
-
|
|
3425
|
-
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
|
3426
|
-
var REACT_PORTAL_TYPE = Symbol.for('react.portal');
|
|
3427
|
-
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
|
|
3428
|
-
var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
|
|
3429
|
-
var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
|
|
3430
|
-
var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
|
|
3431
|
-
var REACT_CONTEXT_TYPE = Symbol.for('react.context');
|
|
3432
|
-
var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
|
|
3433
|
-
var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
|
|
3434
|
-
var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
|
|
3435
|
-
var REACT_MEMO_TYPE = Symbol.for('react.memo');
|
|
3436
|
-
var REACT_LAZY_TYPE = Symbol.for('react.lazy');
|
|
3437
|
-
var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');
|
|
3438
|
-
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
|
3439
|
-
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
|
3440
|
-
function getIteratorFn(maybeIterable) {
|
|
3441
|
-
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
|
3442
|
-
return null;
|
|
3443
|
-
}
|
|
3444
|
-
|
|
3445
|
-
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
|
3446
|
-
|
|
3447
|
-
if (typeof maybeIterator === 'function') {
|
|
3448
|
-
return maybeIterator;
|
|
3449
|
-
}
|
|
3450
|
-
|
|
3451
|
-
return null;
|
|
3452
|
-
}
|
|
3453
|
-
|
|
3454
|
-
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
3455
|
-
|
|
3456
|
-
function error(format) {
|
|
3457
|
-
{
|
|
3458
|
-
{
|
|
3459
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
3460
|
-
args[_key2 - 1] = arguments[_key2];
|
|
3461
|
-
}
|
|
3462
|
-
|
|
3463
|
-
printWarning('error', format, args);
|
|
3464
|
-
}
|
|
3465
|
-
}
|
|
3466
|
-
}
|
|
3467
|
-
|
|
3468
|
-
function printWarning(level, format, args) {
|
|
3469
|
-
// When changing this logic, you might want to also
|
|
3470
|
-
// update consoleWithStackDev.www.js as well.
|
|
3471
|
-
{
|
|
3472
|
-
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
3473
|
-
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
3474
|
-
|
|
3475
|
-
if (stack !== '') {
|
|
3476
|
-
format += '%s';
|
|
3477
|
-
args = args.concat([stack]);
|
|
3478
|
-
} // eslint-disable-next-line react-internal/safe-string-coercion
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
var argsWithFormat = args.map(function (item) {
|
|
3482
|
-
return String(item);
|
|
3483
|
-
}); // Careful: RN currently depends on this prefix
|
|
3484
|
-
|
|
3485
|
-
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
3486
|
-
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
3487
|
-
// eslint-disable-next-line react-internal/no-production-logging
|
|
3488
|
-
|
|
3489
|
-
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
3490
|
-
}
|
|
3491
|
-
}
|
|
3492
|
-
|
|
3493
|
-
var REACT_MODULE_REFERENCE;
|
|
3494
|
-
|
|
3495
|
-
{
|
|
3496
|
-
REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');
|
|
3497
|
-
}
|
|
3498
|
-
|
|
3499
|
-
function isValidElementType(type) {
|
|
3500
|
-
if (typeof type === 'string' || typeof type === 'function') {
|
|
3501
|
-
return true;
|
|
3502
|
-
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {
|
|
3506
|
-
return true;
|
|
3507
|
-
}
|
|
3508
|
-
|
|
3509
|
-
if (typeof type === 'object' && type !== null) {
|
|
3510
|
-
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
|
|
3511
|
-
// types supported by any Flight configuration anywhere since
|
|
3512
|
-
// we don't know which Flight build this will end up being used
|
|
3513
|
-
// with.
|
|
3514
|
-
type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
|
|
3515
|
-
return true;
|
|
3516
|
-
}
|
|
3517
|
-
}
|
|
3518
|
-
|
|
3519
|
-
return false;
|
|
3520
|
-
}
|
|
3521
|
-
|
|
3522
|
-
function getWrappedName(outerType, innerType, wrapperName) {
|
|
3523
|
-
var displayName = outerType.displayName;
|
|
3524
|
-
|
|
3525
|
-
if (displayName) {
|
|
3526
|
-
return displayName;
|
|
3527
|
-
}
|
|
3528
|
-
|
|
3529
|
-
var functionName = innerType.displayName || innerType.name || '';
|
|
3530
|
-
return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName;
|
|
3531
|
-
} // Keep in sync with react-reconciler/getComponentNameFromFiber
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
function getContextName(type) {
|
|
3535
|
-
return type.displayName || 'Context';
|
|
3536
|
-
} // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
function getComponentNameFromType(type) {
|
|
3540
|
-
if (type == null) {
|
|
3541
|
-
// Host root, text node or just invalid type.
|
|
3542
|
-
return null;
|
|
3543
|
-
}
|
|
3544
|
-
|
|
3545
|
-
{
|
|
3546
|
-
if (typeof type.tag === 'number') {
|
|
3547
|
-
error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');
|
|
3548
|
-
}
|
|
3549
|
-
}
|
|
3550
|
-
|
|
3551
|
-
if (typeof type === 'function') {
|
|
3552
|
-
return type.displayName || type.name || null;
|
|
3553
|
-
}
|
|
3554
|
-
|
|
3555
|
-
if (typeof type === 'string') {
|
|
3556
|
-
return type;
|
|
3557
|
-
}
|
|
3558
|
-
|
|
3559
|
-
switch (type) {
|
|
3560
|
-
case REACT_FRAGMENT_TYPE:
|
|
3561
|
-
return 'Fragment';
|
|
3562
|
-
|
|
3563
|
-
case REACT_PORTAL_TYPE:
|
|
3564
|
-
return 'Portal';
|
|
3565
|
-
|
|
3566
|
-
case REACT_PROFILER_TYPE:
|
|
3567
|
-
return 'Profiler';
|
|
3568
|
-
|
|
3569
|
-
case REACT_STRICT_MODE_TYPE:
|
|
3570
|
-
return 'StrictMode';
|
|
3571
|
-
|
|
3572
|
-
case REACT_SUSPENSE_TYPE:
|
|
3573
|
-
return 'Suspense';
|
|
3574
|
-
|
|
3575
|
-
case REACT_SUSPENSE_LIST_TYPE:
|
|
3576
|
-
return 'SuspenseList';
|
|
3577
|
-
|
|
3578
|
-
}
|
|
3579
|
-
|
|
3580
|
-
if (typeof type === 'object') {
|
|
3581
|
-
switch (type.$$typeof) {
|
|
3582
|
-
case REACT_CONTEXT_TYPE:
|
|
3583
|
-
var context = type;
|
|
3584
|
-
return getContextName(context) + '.Consumer';
|
|
3585
|
-
|
|
3586
|
-
case REACT_PROVIDER_TYPE:
|
|
3587
|
-
var provider = type;
|
|
3588
|
-
return getContextName(provider._context) + '.Provider';
|
|
3589
|
-
|
|
3590
|
-
case REACT_FORWARD_REF_TYPE:
|
|
3591
|
-
return getWrappedName(type, type.render, 'ForwardRef');
|
|
3592
|
-
|
|
3593
|
-
case REACT_MEMO_TYPE:
|
|
3594
|
-
var outerName = type.displayName || null;
|
|
3595
|
-
|
|
3596
|
-
if (outerName !== null) {
|
|
3597
|
-
return outerName;
|
|
3598
|
-
}
|
|
3599
|
-
|
|
3600
|
-
return getComponentNameFromType(type.type) || 'Memo';
|
|
3601
|
-
|
|
3602
|
-
case REACT_LAZY_TYPE:
|
|
3603
|
-
{
|
|
3604
|
-
var lazyComponent = type;
|
|
3605
|
-
var payload = lazyComponent._payload;
|
|
3606
|
-
var init = lazyComponent._init;
|
|
3607
|
-
|
|
3608
|
-
try {
|
|
3609
|
-
return getComponentNameFromType(init(payload));
|
|
3610
|
-
} catch (x) {
|
|
3611
|
-
return null;
|
|
3612
|
-
}
|
|
3613
|
-
}
|
|
3614
|
-
|
|
3615
|
-
// eslint-disable-next-line no-fallthrough
|
|
3616
|
-
}
|
|
3617
|
-
}
|
|
3618
|
-
|
|
3619
|
-
return null;
|
|
3620
|
-
}
|
|
3621
|
-
|
|
3622
|
-
var assign = Object.assign;
|
|
3623
|
-
|
|
3624
|
-
// Helpers to patch console.logs to avoid logging during side-effect free
|
|
3625
|
-
// replaying on render function. This currently only patches the object
|
|
3626
|
-
// lazily which won't cover if the log function was extracted eagerly.
|
|
3627
|
-
// We could also eagerly patch the method.
|
|
3628
|
-
var disabledDepth = 0;
|
|
3629
|
-
var prevLog;
|
|
3630
|
-
var prevInfo;
|
|
3631
|
-
var prevWarn;
|
|
3632
|
-
var prevError;
|
|
3633
|
-
var prevGroup;
|
|
3634
|
-
var prevGroupCollapsed;
|
|
3635
|
-
var prevGroupEnd;
|
|
3636
|
-
|
|
3637
|
-
function disabledLog() {}
|
|
3638
|
-
|
|
3639
|
-
disabledLog.__reactDisabledLog = true;
|
|
3640
|
-
function disableLogs() {
|
|
3641
|
-
{
|
|
3642
|
-
if (disabledDepth === 0) {
|
|
3643
|
-
/* eslint-disable react-internal/no-production-logging */
|
|
3644
|
-
prevLog = console.log;
|
|
3645
|
-
prevInfo = console.info;
|
|
3646
|
-
prevWarn = console.warn;
|
|
3647
|
-
prevError = console.error;
|
|
3648
|
-
prevGroup = console.group;
|
|
3649
|
-
prevGroupCollapsed = console.groupCollapsed;
|
|
3650
|
-
prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
|
|
3651
|
-
|
|
3652
|
-
var props = {
|
|
3653
|
-
configurable: true,
|
|
3654
|
-
enumerable: true,
|
|
3655
|
-
value: disabledLog,
|
|
3656
|
-
writable: true
|
|
3657
|
-
}; // $FlowFixMe Flow thinks console is immutable.
|
|
3658
|
-
|
|
3659
|
-
Object.defineProperties(console, {
|
|
3660
|
-
info: props,
|
|
3661
|
-
log: props,
|
|
3662
|
-
warn: props,
|
|
3663
|
-
error: props,
|
|
3664
|
-
group: props,
|
|
3665
|
-
groupCollapsed: props,
|
|
3666
|
-
groupEnd: props
|
|
3667
|
-
});
|
|
3668
|
-
/* eslint-enable react-internal/no-production-logging */
|
|
3669
|
-
}
|
|
3670
|
-
|
|
3671
|
-
disabledDepth++;
|
|
3672
|
-
}
|
|
3673
|
-
}
|
|
3674
|
-
function reenableLogs() {
|
|
3675
|
-
{
|
|
3676
|
-
disabledDepth--;
|
|
3677
|
-
|
|
3678
|
-
if (disabledDepth === 0) {
|
|
3679
|
-
/* eslint-disable react-internal/no-production-logging */
|
|
3680
|
-
var props = {
|
|
3681
|
-
configurable: true,
|
|
3682
|
-
enumerable: true,
|
|
3683
|
-
writable: true
|
|
3684
|
-
}; // $FlowFixMe Flow thinks console is immutable.
|
|
3685
|
-
|
|
3686
|
-
Object.defineProperties(console, {
|
|
3687
|
-
log: assign({}, props, {
|
|
3688
|
-
value: prevLog
|
|
3689
|
-
}),
|
|
3690
|
-
info: assign({}, props, {
|
|
3691
|
-
value: prevInfo
|
|
3692
|
-
}),
|
|
3693
|
-
warn: assign({}, props, {
|
|
3694
|
-
value: prevWarn
|
|
3695
|
-
}),
|
|
3696
|
-
error: assign({}, props, {
|
|
3697
|
-
value: prevError
|
|
3698
|
-
}),
|
|
3699
|
-
group: assign({}, props, {
|
|
3700
|
-
value: prevGroup
|
|
3701
|
-
}),
|
|
3702
|
-
groupCollapsed: assign({}, props, {
|
|
3703
|
-
value: prevGroupCollapsed
|
|
3704
|
-
}),
|
|
3705
|
-
groupEnd: assign({}, props, {
|
|
3706
|
-
value: prevGroupEnd
|
|
3707
|
-
})
|
|
3708
|
-
});
|
|
3709
|
-
/* eslint-enable react-internal/no-production-logging */
|
|
3710
|
-
}
|
|
3711
|
-
|
|
3712
|
-
if (disabledDepth < 0) {
|
|
3713
|
-
error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
|
|
3714
|
-
}
|
|
3715
|
-
}
|
|
3716
|
-
}
|
|
3717
|
-
|
|
3718
|
-
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
|
3719
|
-
var prefix;
|
|
3720
|
-
function describeBuiltInComponentFrame(name, source, ownerFn) {
|
|
3721
|
-
{
|
|
3722
|
-
if (prefix === undefined) {
|
|
3723
|
-
// Extract the VM specific prefix used by each line.
|
|
3724
|
-
try {
|
|
3725
|
-
throw Error();
|
|
3726
|
-
} catch (x) {
|
|
3727
|
-
var match = x.stack.trim().match(/\n( *(at )?)/);
|
|
3728
|
-
prefix = match && match[1] || '';
|
|
3729
|
-
}
|
|
3730
|
-
} // We use the prefix to ensure our stacks line up with native stack frames.
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
return '\n' + prefix + name;
|
|
3734
|
-
}
|
|
3735
|
-
}
|
|
3736
|
-
var reentry = false;
|
|
3737
|
-
var componentFrameCache;
|
|
3738
|
-
|
|
3739
|
-
{
|
|
3740
|
-
var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
|
|
3741
|
-
componentFrameCache = new PossiblyWeakMap();
|
|
3742
|
-
}
|
|
3743
|
-
|
|
3744
|
-
function describeNativeComponentFrame(fn, construct) {
|
|
3745
|
-
// If something asked for a stack inside a fake render, it should get ignored.
|
|
3746
|
-
if ( !fn || reentry) {
|
|
3747
|
-
return '';
|
|
3748
|
-
}
|
|
3749
|
-
|
|
3750
|
-
{
|
|
3751
|
-
var frame = componentFrameCache.get(fn);
|
|
3752
|
-
|
|
3753
|
-
if (frame !== undefined) {
|
|
3754
|
-
return frame;
|
|
3755
|
-
}
|
|
3756
|
-
}
|
|
3757
|
-
|
|
3758
|
-
var control;
|
|
3759
|
-
reentry = true;
|
|
3760
|
-
var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
|
|
3761
|
-
|
|
3762
|
-
Error.prepareStackTrace = undefined;
|
|
3763
|
-
var previousDispatcher;
|
|
3764
|
-
|
|
3765
|
-
{
|
|
3766
|
-
previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function
|
|
3767
|
-
// for warnings.
|
|
3768
|
-
|
|
3769
|
-
ReactCurrentDispatcher.current = null;
|
|
3770
|
-
disableLogs();
|
|
3771
|
-
}
|
|
3772
|
-
|
|
3773
|
-
try {
|
|
3774
|
-
// This should throw.
|
|
3775
|
-
if (construct) {
|
|
3776
|
-
// Something should be setting the props in the constructor.
|
|
3777
|
-
var Fake = function () {
|
|
3778
|
-
throw Error();
|
|
3779
|
-
}; // $FlowFixMe
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
Object.defineProperty(Fake.prototype, 'props', {
|
|
3783
|
-
set: function () {
|
|
3784
|
-
// We use a throwing setter instead of frozen or non-writable props
|
|
3785
|
-
// because that won't throw in a non-strict mode function.
|
|
3786
|
-
throw Error();
|
|
3787
|
-
}
|
|
3788
|
-
});
|
|
3789
|
-
|
|
3790
|
-
if (typeof Reflect === 'object' && Reflect.construct) {
|
|
3791
|
-
// We construct a different control for this case to include any extra
|
|
3792
|
-
// frames added by the construct call.
|
|
3793
|
-
try {
|
|
3794
|
-
Reflect.construct(Fake, []);
|
|
3795
|
-
} catch (x) {
|
|
3796
|
-
control = x;
|
|
3797
|
-
}
|
|
3798
|
-
|
|
3799
|
-
Reflect.construct(fn, [], Fake);
|
|
3800
|
-
} else {
|
|
3801
|
-
try {
|
|
3802
|
-
Fake.call();
|
|
3803
|
-
} catch (x) {
|
|
3804
|
-
control = x;
|
|
3805
|
-
}
|
|
3806
|
-
|
|
3807
|
-
fn.call(Fake.prototype);
|
|
3808
|
-
}
|
|
3809
|
-
} else {
|
|
3810
|
-
try {
|
|
3811
|
-
throw Error();
|
|
3812
|
-
} catch (x) {
|
|
3813
|
-
control = x;
|
|
3814
|
-
}
|
|
3815
|
-
|
|
3816
|
-
fn();
|
|
3817
|
-
}
|
|
3818
|
-
} catch (sample) {
|
|
3819
|
-
// This is inlined manually because closure doesn't do it for us.
|
|
3820
|
-
if (sample && control && typeof sample.stack === 'string') {
|
|
3821
|
-
// This extracts the first frame from the sample that isn't also in the control.
|
|
3822
|
-
// Skipping one frame that we assume is the frame that calls the two.
|
|
3823
|
-
var sampleLines = sample.stack.split('\n');
|
|
3824
|
-
var controlLines = control.stack.split('\n');
|
|
3825
|
-
var s = sampleLines.length - 1;
|
|
3826
|
-
var c = controlLines.length - 1;
|
|
3827
|
-
|
|
3828
|
-
while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
|
|
3829
|
-
// We expect at least one stack frame to be shared.
|
|
3830
|
-
// Typically this will be the root most one. However, stack frames may be
|
|
3831
|
-
// cut off due to maximum stack limits. In this case, one maybe cut off
|
|
3832
|
-
// earlier than the other. We assume that the sample is longer or the same
|
|
3833
|
-
// and there for cut off earlier. So we should find the root most frame in
|
|
3834
|
-
// the sample somewhere in the control.
|
|
3835
|
-
c--;
|
|
3836
|
-
}
|
|
3837
|
-
|
|
3838
|
-
for (; s >= 1 && c >= 0; s--, c--) {
|
|
3839
|
-
// Next we find the first one that isn't the same which should be the
|
|
3840
|
-
// frame that called our sample function and the control.
|
|
3841
|
-
if (sampleLines[s] !== controlLines[c]) {
|
|
3842
|
-
// In V8, the first line is describing the message but other VMs don't.
|
|
3843
|
-
// If we're about to return the first line, and the control is also on the same
|
|
3844
|
-
// line, that's a pretty good indicator that our sample threw at same line as
|
|
3845
|
-
// the control. I.e. before we entered the sample frame. So we ignore this result.
|
|
3846
|
-
// This can happen if you passed a class to function component, or non-function.
|
|
3847
|
-
if (s !== 1 || c !== 1) {
|
|
3848
|
-
do {
|
|
3849
|
-
s--;
|
|
3850
|
-
c--; // We may still have similar intermediate frames from the construct call.
|
|
3851
|
-
// The next one that isn't the same should be our match though.
|
|
3852
|
-
|
|
3853
|
-
if (c < 0 || sampleLines[s] !== controlLines[c]) {
|
|
3854
|
-
// V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
|
|
3855
|
-
var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "<anonymous>"
|
|
3856
|
-
// but we have a user-provided "displayName"
|
|
3857
|
-
// splice it in to make the stack more readable.
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
if (fn.displayName && _frame.includes('<anonymous>')) {
|
|
3861
|
-
_frame = _frame.replace('<anonymous>', fn.displayName);
|
|
3862
|
-
}
|
|
3863
|
-
|
|
3864
|
-
{
|
|
3865
|
-
if (typeof fn === 'function') {
|
|
3866
|
-
componentFrameCache.set(fn, _frame);
|
|
3867
|
-
}
|
|
3868
|
-
} // Return the line we found.
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
return _frame;
|
|
3872
|
-
}
|
|
3873
|
-
} while (s >= 1 && c >= 0);
|
|
3874
|
-
}
|
|
3875
|
-
|
|
3876
|
-
break;
|
|
3877
|
-
}
|
|
3878
|
-
}
|
|
3879
|
-
}
|
|
3880
|
-
} finally {
|
|
3881
|
-
reentry = false;
|
|
3882
|
-
|
|
3883
|
-
{
|
|
3884
|
-
ReactCurrentDispatcher.current = previousDispatcher;
|
|
3885
|
-
reenableLogs();
|
|
3886
|
-
}
|
|
3887
|
-
|
|
3888
|
-
Error.prepareStackTrace = previousPrepareStackTrace;
|
|
3889
|
-
} // Fallback to just using the name if we couldn't make it throw.
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
var name = fn ? fn.displayName || fn.name : '';
|
|
3893
|
-
var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
|
|
3894
|
-
|
|
3895
|
-
{
|
|
3896
|
-
if (typeof fn === 'function') {
|
|
3897
|
-
componentFrameCache.set(fn, syntheticFrame);
|
|
3898
|
-
}
|
|
3899
|
-
}
|
|
3900
|
-
|
|
3901
|
-
return syntheticFrame;
|
|
3902
|
-
}
|
|
3903
|
-
function describeFunctionComponentFrame(fn, source, ownerFn) {
|
|
3904
|
-
{
|
|
3905
|
-
return describeNativeComponentFrame(fn, false);
|
|
3906
|
-
}
|
|
3907
|
-
}
|
|
3908
|
-
|
|
3909
|
-
function shouldConstruct(Component) {
|
|
3910
|
-
var prototype = Component.prototype;
|
|
3911
|
-
return !!(prototype && prototype.isReactComponent);
|
|
3912
|
-
}
|
|
3913
|
-
|
|
3914
|
-
function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
|
|
3915
|
-
|
|
3916
|
-
if (type == null) {
|
|
3917
|
-
return '';
|
|
3918
|
-
}
|
|
3919
|
-
|
|
3920
|
-
if (typeof type === 'function') {
|
|
3921
|
-
{
|
|
3922
|
-
return describeNativeComponentFrame(type, shouldConstruct(type));
|
|
3923
|
-
}
|
|
3924
|
-
}
|
|
3925
|
-
|
|
3926
|
-
if (typeof type === 'string') {
|
|
3927
|
-
return describeBuiltInComponentFrame(type);
|
|
3928
|
-
}
|
|
3929
|
-
|
|
3930
|
-
switch (type) {
|
|
3931
|
-
case REACT_SUSPENSE_TYPE:
|
|
3932
|
-
return describeBuiltInComponentFrame('Suspense');
|
|
3933
|
-
|
|
3934
|
-
case REACT_SUSPENSE_LIST_TYPE:
|
|
3935
|
-
return describeBuiltInComponentFrame('SuspenseList');
|
|
3936
|
-
}
|
|
3937
|
-
|
|
3938
|
-
if (typeof type === 'object') {
|
|
3939
|
-
switch (type.$$typeof) {
|
|
3940
|
-
case REACT_FORWARD_REF_TYPE:
|
|
3941
|
-
return describeFunctionComponentFrame(type.render);
|
|
3942
|
-
|
|
3943
|
-
case REACT_MEMO_TYPE:
|
|
3944
|
-
// Memo may contain any component type so we recursively resolve it.
|
|
3945
|
-
return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
|
|
3946
|
-
|
|
3947
|
-
case REACT_LAZY_TYPE:
|
|
3948
|
-
{
|
|
3949
|
-
var lazyComponent = type;
|
|
3950
|
-
var payload = lazyComponent._payload;
|
|
3951
|
-
var init = lazyComponent._init;
|
|
3952
|
-
|
|
3953
|
-
try {
|
|
3954
|
-
// Lazy may contain any component type so we recursively resolve it.
|
|
3955
|
-
return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
|
|
3956
|
-
} catch (x) {}
|
|
3957
|
-
}
|
|
3958
|
-
}
|
|
3959
|
-
}
|
|
3960
|
-
|
|
3961
|
-
return '';
|
|
3962
|
-
}
|
|
3963
|
-
|
|
3964
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
3965
|
-
|
|
3966
|
-
var loggedTypeFailures = {};
|
|
3967
|
-
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
3968
|
-
|
|
3969
|
-
function setCurrentlyValidatingElement(element) {
|
|
3970
|
-
{
|
|
3971
|
-
if (element) {
|
|
3972
|
-
var owner = element._owner;
|
|
3973
|
-
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
|
3974
|
-
ReactDebugCurrentFrame.setExtraStackFrame(stack);
|
|
3975
|
-
} else {
|
|
3976
|
-
ReactDebugCurrentFrame.setExtraStackFrame(null);
|
|
3977
|
-
}
|
|
3978
|
-
}
|
|
3979
|
-
}
|
|
3980
|
-
|
|
3981
|
-
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
|
3982
|
-
{
|
|
3983
|
-
// $FlowFixMe This is okay but Flow doesn't know it.
|
|
3984
|
-
var has = Function.call.bind(hasOwnProperty);
|
|
3985
|
-
|
|
3986
|
-
for (var typeSpecName in typeSpecs) {
|
|
3987
|
-
if (has(typeSpecs, typeSpecName)) {
|
|
3988
|
-
var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
|
|
3989
|
-
// fail the render phase where it didn't fail before. So we log it.
|
|
3990
|
-
// After these have been cleaned up, we'll let them throw.
|
|
3991
|
-
|
|
3992
|
-
try {
|
|
3993
|
-
// This is intentionally an invariant that gets caught. It's the same
|
|
3994
|
-
// behavior as without this statement except with a better message.
|
|
3995
|
-
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
3996
|
-
// eslint-disable-next-line react-internal/prod-error-codes
|
|
3997
|
-
var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
|
|
3998
|
-
err.name = 'Invariant Violation';
|
|
3999
|
-
throw err;
|
|
4000
|
-
}
|
|
4001
|
-
|
|
4002
|
-
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
|
|
4003
|
-
} catch (ex) {
|
|
4004
|
-
error$1 = ex;
|
|
4005
|
-
}
|
|
4006
|
-
|
|
4007
|
-
if (error$1 && !(error$1 instanceof Error)) {
|
|
4008
|
-
setCurrentlyValidatingElement(element);
|
|
4009
|
-
|
|
4010
|
-
error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
|
|
4011
|
-
|
|
4012
|
-
setCurrentlyValidatingElement(null);
|
|
4013
|
-
}
|
|
4014
|
-
|
|
4015
|
-
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
|
4016
|
-
// Only monitor this failure once because there tends to be a lot of the
|
|
4017
|
-
// same error.
|
|
4018
|
-
loggedTypeFailures[error$1.message] = true;
|
|
4019
|
-
setCurrentlyValidatingElement(element);
|
|
4020
|
-
|
|
4021
|
-
error('Failed %s type: %s', location, error$1.message);
|
|
4022
|
-
|
|
4023
|
-
setCurrentlyValidatingElement(null);
|
|
4024
|
-
}
|
|
4025
|
-
}
|
|
4026
|
-
}
|
|
4027
|
-
}
|
|
4028
|
-
}
|
|
4029
|
-
|
|
4030
|
-
var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
|
|
4031
|
-
|
|
4032
|
-
function isArray(a) {
|
|
4033
|
-
return isArrayImpl(a);
|
|
4034
|
-
}
|
|
4035
|
-
|
|
4036
|
-
/*
|
|
4037
|
-
* The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol
|
|
4038
|
-
* and Temporal.* types. See https://github.com/facebook/react/pull/22064.
|
|
4039
|
-
*
|
|
4040
|
-
* The functions in this module will throw an easier-to-understand,
|
|
4041
|
-
* easier-to-debug exception with a clear errors message message explaining the
|
|
4042
|
-
* problem. (Instead of a confusing exception thrown inside the implementation
|
|
4043
|
-
* of the `value` object).
|
|
4044
|
-
*/
|
|
4045
|
-
// $FlowFixMe only called in DEV, so void return is not possible.
|
|
4046
|
-
function typeName(value) {
|
|
4047
|
-
{
|
|
4048
|
-
// toStringTag is needed for namespaced types like Temporal.Instant
|
|
4049
|
-
var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;
|
|
4050
|
-
var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';
|
|
4051
|
-
return type;
|
|
4052
|
-
}
|
|
4053
|
-
} // $FlowFixMe only called in DEV, so void return is not possible.
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
function willCoercionThrow(value) {
|
|
4057
|
-
{
|
|
4058
|
-
try {
|
|
4059
|
-
testStringCoercion(value);
|
|
4060
|
-
return false;
|
|
4061
|
-
} catch (e) {
|
|
4062
|
-
return true;
|
|
4063
|
-
}
|
|
4064
|
-
}
|
|
4065
|
-
}
|
|
4066
|
-
|
|
4067
|
-
function testStringCoercion(value) {
|
|
4068
|
-
// If you ended up here by following an exception call stack, here's what's
|
|
4069
|
-
// happened: you supplied an object or symbol value to React (as a prop, key,
|
|
4070
|
-
// DOM attribute, CSS property, string ref, etc.) and when React tried to
|
|
4071
|
-
// coerce it to a string using `'' + value`, an exception was thrown.
|
|
4072
|
-
//
|
|
4073
|
-
// The most common types that will cause this exception are `Symbol` instances
|
|
4074
|
-
// and Temporal objects like `Temporal.Instant`. But any object that has a
|
|
4075
|
-
// `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
|
|
4076
|
-
// exception. (Library authors do this to prevent users from using built-in
|
|
4077
|
-
// numeric operators like `+` or comparison operators like `>=` because custom
|
|
4078
|
-
// methods are needed to perform accurate arithmetic or comparison.)
|
|
4079
|
-
//
|
|
4080
|
-
// To fix the problem, coerce this object or symbol value to a string before
|
|
4081
|
-
// passing it to React. The most reliable way is usually `String(value)`.
|
|
4082
|
-
//
|
|
4083
|
-
// To find which value is throwing, check the browser or debugger console.
|
|
4084
|
-
// Before this exception was thrown, there should be `console.error` output
|
|
4085
|
-
// that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
|
|
4086
|
-
// problem and how that type was used: key, atrribute, input value prop, etc.
|
|
4087
|
-
// In most cases, this console output also shows the component and its
|
|
4088
|
-
// ancestor components where the exception happened.
|
|
4089
|
-
//
|
|
4090
|
-
// eslint-disable-next-line react-internal/safe-string-coercion
|
|
4091
|
-
return '' + value;
|
|
4092
|
-
}
|
|
4093
|
-
function checkKeyStringCoercion(value) {
|
|
4094
|
-
{
|
|
4095
|
-
if (willCoercionThrow(value)) {
|
|
4096
|
-
error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));
|
|
4097
|
-
|
|
4098
|
-
return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
|
|
4099
|
-
}
|
|
4100
|
-
}
|
|
4101
|
-
}
|
|
4102
|
-
|
|
4103
|
-
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
|
4104
|
-
var RESERVED_PROPS = {
|
|
4105
|
-
key: true,
|
|
4106
|
-
ref: true,
|
|
4107
|
-
__self: true,
|
|
4108
|
-
__source: true
|
|
4109
|
-
};
|
|
4110
|
-
var specialPropKeyWarningShown;
|
|
4111
|
-
var specialPropRefWarningShown;
|
|
4112
|
-
var didWarnAboutStringRefs;
|
|
4113
|
-
|
|
4114
|
-
{
|
|
4115
|
-
didWarnAboutStringRefs = {};
|
|
4116
|
-
}
|
|
4117
|
-
|
|
4118
|
-
function hasValidRef(config) {
|
|
4119
|
-
{
|
|
4120
|
-
if (hasOwnProperty.call(config, 'ref')) {
|
|
4121
|
-
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
|
4122
|
-
|
|
4123
|
-
if (getter && getter.isReactWarning) {
|
|
4124
|
-
return false;
|
|
4125
|
-
}
|
|
4126
|
-
}
|
|
4127
|
-
}
|
|
4128
|
-
|
|
4129
|
-
return config.ref !== undefined;
|
|
4130
|
-
}
|
|
4131
|
-
|
|
4132
|
-
function hasValidKey(config) {
|
|
4133
|
-
{
|
|
4134
|
-
if (hasOwnProperty.call(config, 'key')) {
|
|
4135
|
-
var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
|
4136
|
-
|
|
4137
|
-
if (getter && getter.isReactWarning) {
|
|
4138
|
-
return false;
|
|
4139
|
-
}
|
|
4140
|
-
}
|
|
4141
|
-
}
|
|
4142
|
-
|
|
4143
|
-
return config.key !== undefined;
|
|
4144
|
-
}
|
|
4145
|
-
|
|
4146
|
-
function warnIfStringRefCannotBeAutoConverted(config, self) {
|
|
4147
|
-
{
|
|
4148
|
-
if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {
|
|
4149
|
-
var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
|
|
4150
|
-
|
|
4151
|
-
if (!didWarnAboutStringRefs[componentName]) {
|
|
4152
|
-
error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', getComponentNameFromType(ReactCurrentOwner.current.type), config.ref);
|
|
4153
|
-
|
|
4154
|
-
didWarnAboutStringRefs[componentName] = true;
|
|
4155
|
-
}
|
|
4156
|
-
}
|
|
4157
|
-
}
|
|
4158
|
-
}
|
|
4159
|
-
|
|
4160
|
-
function defineKeyPropWarningGetter(props, displayName) {
|
|
4161
|
-
{
|
|
4162
|
-
var warnAboutAccessingKey = function () {
|
|
4163
|
-
if (!specialPropKeyWarningShown) {
|
|
4164
|
-
specialPropKeyWarningShown = true;
|
|
4165
|
-
|
|
4166
|
-
error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
|
4167
|
-
}
|
|
4168
|
-
};
|
|
4169
|
-
|
|
4170
|
-
warnAboutAccessingKey.isReactWarning = true;
|
|
4171
|
-
Object.defineProperty(props, 'key', {
|
|
4172
|
-
get: warnAboutAccessingKey,
|
|
4173
|
-
configurable: true
|
|
4174
|
-
});
|
|
4175
|
-
}
|
|
4176
|
-
}
|
|
4177
|
-
|
|
4178
|
-
function defineRefPropWarningGetter(props, displayName) {
|
|
4179
|
-
{
|
|
4180
|
-
var warnAboutAccessingRef = function () {
|
|
4181
|
-
if (!specialPropRefWarningShown) {
|
|
4182
|
-
specialPropRefWarningShown = true;
|
|
4183
|
-
|
|
4184
|
-
error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
|
4185
|
-
}
|
|
4186
|
-
};
|
|
4187
|
-
|
|
4188
|
-
warnAboutAccessingRef.isReactWarning = true;
|
|
4189
|
-
Object.defineProperty(props, 'ref', {
|
|
4190
|
-
get: warnAboutAccessingRef,
|
|
4191
|
-
configurable: true
|
|
4192
|
-
});
|
|
4193
|
-
}
|
|
4194
|
-
}
|
|
4195
|
-
/**
|
|
4196
|
-
* Factory method to create a new React element. This no longer adheres to
|
|
4197
|
-
* the class pattern, so do not use new to call it. Also, instanceof check
|
|
4198
|
-
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
|
|
4199
|
-
* if something is a React Element.
|
|
4200
|
-
*
|
|
4201
|
-
* @param {*} type
|
|
4202
|
-
* @param {*} props
|
|
4203
|
-
* @param {*} key
|
|
4204
|
-
* @param {string|object} ref
|
|
4205
|
-
* @param {*} owner
|
|
4206
|
-
* @param {*} self A *temporary* helper to detect places where `this` is
|
|
4207
|
-
* different from the `owner` when React.createElement is called, so that we
|
|
4208
|
-
* can warn. We want to get rid of owner and replace string `ref`s with arrow
|
|
4209
|
-
* functions, and as long as `this` and owner are the same, there will be no
|
|
4210
|
-
* change in behavior.
|
|
4211
|
-
* @param {*} source An annotation object (added by a transpiler or otherwise)
|
|
4212
|
-
* indicating filename, line number, and/or other information.
|
|
4213
|
-
* @internal
|
|
4214
|
-
*/
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
4218
|
-
var element = {
|
|
4219
|
-
// This tag allows us to uniquely identify this as a React Element
|
|
4220
|
-
$$typeof: REACT_ELEMENT_TYPE,
|
|
4221
|
-
// Built-in properties that belong on the element
|
|
4222
|
-
type: type,
|
|
4223
|
-
key: key,
|
|
4224
|
-
ref: ref,
|
|
4225
|
-
props: props,
|
|
4226
|
-
// Record the component responsible for creating this element.
|
|
4227
|
-
_owner: owner
|
|
4228
|
-
};
|
|
4229
|
-
|
|
4230
|
-
{
|
|
4231
|
-
// The validation flag is currently mutative. We put it on
|
|
4232
|
-
// an external backing store so that we can freeze the whole object.
|
|
4233
|
-
// This can be replaced with a WeakMap once they are implemented in
|
|
4234
|
-
// commonly used development environments.
|
|
4235
|
-
element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
|
|
4236
|
-
// the validation flag non-enumerable (where possible, which should
|
|
4237
|
-
// include every environment we run tests in), so the test framework
|
|
4238
|
-
// ignores it.
|
|
4239
|
-
|
|
4240
|
-
Object.defineProperty(element._store, 'validated', {
|
|
4241
|
-
configurable: false,
|
|
4242
|
-
enumerable: false,
|
|
4243
|
-
writable: true,
|
|
4244
|
-
value: false
|
|
4245
|
-
}); // self and source are DEV only properties.
|
|
4246
|
-
|
|
4247
|
-
Object.defineProperty(element, '_self', {
|
|
4248
|
-
configurable: false,
|
|
4249
|
-
enumerable: false,
|
|
4250
|
-
writable: false,
|
|
4251
|
-
value: self
|
|
4252
|
-
}); // Two elements created in two different places should be considered
|
|
4253
|
-
// equal for testing purposes and therefore we hide it from enumeration.
|
|
4254
|
-
|
|
4255
|
-
Object.defineProperty(element, '_source', {
|
|
4256
|
-
configurable: false,
|
|
4257
|
-
enumerable: false,
|
|
4258
|
-
writable: false,
|
|
4259
|
-
value: source
|
|
4260
|
-
});
|
|
4261
|
-
|
|
4262
|
-
if (Object.freeze) {
|
|
4263
|
-
Object.freeze(element.props);
|
|
4264
|
-
Object.freeze(element);
|
|
4265
|
-
}
|
|
4266
|
-
}
|
|
4267
|
-
|
|
4268
|
-
return element;
|
|
4269
|
-
};
|
|
4270
|
-
/**
|
|
4271
|
-
* https://github.com/reactjs/rfcs/pull/107
|
|
4272
|
-
* @param {*} type
|
|
4273
|
-
* @param {object} props
|
|
4274
|
-
* @param {string} key
|
|
4275
|
-
*/
|
|
4276
|
-
|
|
4277
|
-
function jsxDEV(type, config, maybeKey, source, self) {
|
|
4278
|
-
{
|
|
4279
|
-
var propName; // Reserved names are extracted
|
|
4280
|
-
|
|
4281
|
-
var props = {};
|
|
4282
|
-
var key = null;
|
|
4283
|
-
var ref = null; // Currently, key can be spread in as a prop. This causes a potential
|
|
4284
|
-
// issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
|
|
4285
|
-
// or <div key="Hi" {...props} /> ). We want to deprecate key spread,
|
|
4286
|
-
// but as an intermediary step, we will use jsxDEV for everything except
|
|
4287
|
-
// <div {...props} key="Hi" />, because we aren't currently able to tell if
|
|
4288
|
-
// key is explicitly declared to be undefined or not.
|
|
4289
|
-
|
|
4290
|
-
if (maybeKey !== undefined) {
|
|
4291
|
-
{
|
|
4292
|
-
checkKeyStringCoercion(maybeKey);
|
|
4293
|
-
}
|
|
4294
|
-
|
|
4295
|
-
key = '' + maybeKey;
|
|
4296
|
-
}
|
|
4297
|
-
|
|
4298
|
-
if (hasValidKey(config)) {
|
|
4299
|
-
{
|
|
4300
|
-
checkKeyStringCoercion(config.key);
|
|
4301
|
-
}
|
|
4302
|
-
|
|
4303
|
-
key = '' + config.key;
|
|
4304
|
-
}
|
|
4305
|
-
|
|
4306
|
-
if (hasValidRef(config)) {
|
|
4307
|
-
ref = config.ref;
|
|
4308
|
-
warnIfStringRefCannotBeAutoConverted(config, self);
|
|
4309
|
-
} // Remaining properties are added to a new props object
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
for (propName in config) {
|
|
4313
|
-
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
4314
|
-
props[propName] = config[propName];
|
|
4315
|
-
}
|
|
4316
|
-
} // Resolve default props
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
if (type && type.defaultProps) {
|
|
4320
|
-
var defaultProps = type.defaultProps;
|
|
4321
|
-
|
|
4322
|
-
for (propName in defaultProps) {
|
|
4323
|
-
if (props[propName] === undefined) {
|
|
4324
|
-
props[propName] = defaultProps[propName];
|
|
4325
|
-
}
|
|
4326
|
-
}
|
|
4327
|
-
}
|
|
4328
|
-
|
|
4329
|
-
if (key || ref) {
|
|
4330
|
-
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
|
4331
|
-
|
|
4332
|
-
if (key) {
|
|
4333
|
-
defineKeyPropWarningGetter(props, displayName);
|
|
4334
|
-
}
|
|
4335
|
-
|
|
4336
|
-
if (ref) {
|
|
4337
|
-
defineRefPropWarningGetter(props, displayName);
|
|
4338
|
-
}
|
|
4339
|
-
}
|
|
4340
|
-
|
|
4341
|
-
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
|
4342
|
-
}
|
|
4343
|
-
}
|
|
4344
|
-
|
|
4345
|
-
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
|
|
4346
|
-
var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
4347
|
-
|
|
4348
|
-
function setCurrentlyValidatingElement$1(element) {
|
|
4349
|
-
{
|
|
4350
|
-
if (element) {
|
|
4351
|
-
var owner = element._owner;
|
|
4352
|
-
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
|
4353
|
-
ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
|
|
4354
|
-
} else {
|
|
4355
|
-
ReactDebugCurrentFrame$1.setExtraStackFrame(null);
|
|
4356
|
-
}
|
|
4357
|
-
}
|
|
4358
|
-
}
|
|
4359
|
-
|
|
4360
|
-
var propTypesMisspellWarningShown;
|
|
4361
|
-
|
|
4362
|
-
{
|
|
4363
|
-
propTypesMisspellWarningShown = false;
|
|
4364
|
-
}
|
|
4365
|
-
/**
|
|
4366
|
-
* Verifies the object is a ReactElement.
|
|
4367
|
-
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
|
4368
|
-
* @param {?object} object
|
|
4369
|
-
* @return {boolean} True if `object` is a ReactElement.
|
|
4370
|
-
* @final
|
|
4371
|
-
*/
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
function isValidElement(object) {
|
|
4375
|
-
{
|
|
4376
|
-
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
4377
|
-
}
|
|
4378
|
-
}
|
|
4379
|
-
|
|
4380
|
-
function getDeclarationErrorAddendum() {
|
|
4381
|
-
{
|
|
4382
|
-
if (ReactCurrentOwner$1.current) {
|
|
4383
|
-
var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);
|
|
4384
|
-
|
|
4385
|
-
if (name) {
|
|
4386
|
-
return '\n\nCheck the render method of `' + name + '`.';
|
|
4387
|
-
}
|
|
4388
|
-
}
|
|
4389
|
-
|
|
4390
|
-
return '';
|
|
4391
|
-
}
|
|
4392
|
-
}
|
|
4393
|
-
|
|
4394
|
-
function getSourceInfoErrorAddendum(source) {
|
|
4395
|
-
{
|
|
4396
|
-
if (source !== undefined) {
|
|
4397
|
-
var fileName = source.fileName.replace(/^.*[\\\/]/, '');
|
|
4398
|
-
var lineNumber = source.lineNumber;
|
|
4399
|
-
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
|
|
4400
|
-
}
|
|
4401
|
-
|
|
4402
|
-
return '';
|
|
4403
|
-
}
|
|
4404
|
-
}
|
|
4405
|
-
/**
|
|
4406
|
-
* Warn if there's no key explicitly set on dynamic arrays of children or
|
|
4407
|
-
* object keys are not valid. This allows us to keep track of children between
|
|
4408
|
-
* updates.
|
|
4409
|
-
*/
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
var ownerHasKeyUseWarning = {};
|
|
4413
|
-
|
|
4414
|
-
function getCurrentComponentErrorInfo(parentType) {
|
|
4415
|
-
{
|
|
4416
|
-
var info = getDeclarationErrorAddendum();
|
|
4417
|
-
|
|
4418
|
-
if (!info) {
|
|
4419
|
-
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
|
4420
|
-
|
|
4421
|
-
if (parentName) {
|
|
4422
|
-
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
|
4423
|
-
}
|
|
4424
|
-
}
|
|
4425
|
-
|
|
4426
|
-
return info;
|
|
4427
|
-
}
|
|
4428
|
-
}
|
|
4429
|
-
/**
|
|
4430
|
-
* Warn if the element doesn't have an explicit key assigned to it.
|
|
4431
|
-
* This element is in an array. The array could grow and shrink or be
|
|
4432
|
-
* reordered. All children that haven't already been validated are required to
|
|
4433
|
-
* have a "key" property assigned to it. Error statuses are cached so a warning
|
|
4434
|
-
* will only be shown once.
|
|
4435
|
-
*
|
|
4436
|
-
* @internal
|
|
4437
|
-
* @param {ReactElement} element Element that requires a key.
|
|
4438
|
-
* @param {*} parentType element's parent's type.
|
|
4439
|
-
*/
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
function validateExplicitKey(element, parentType) {
|
|
4443
|
-
{
|
|
4444
|
-
if (!element._store || element._store.validated || element.key != null) {
|
|
4445
|
-
return;
|
|
4446
|
-
}
|
|
4447
|
-
|
|
4448
|
-
element._store.validated = true;
|
|
4449
|
-
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
|
4450
|
-
|
|
4451
|
-
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
|
4452
|
-
return;
|
|
4453
|
-
}
|
|
4454
|
-
|
|
4455
|
-
ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
|
|
4456
|
-
// property, it may be the creator of the child that's responsible for
|
|
4457
|
-
// assigning it a key.
|
|
4458
|
-
|
|
4459
|
-
var childOwner = '';
|
|
4460
|
-
|
|
4461
|
-
if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
|
|
4462
|
-
// Give the component that originally created this child.
|
|
4463
|
-
childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
|
|
4464
|
-
}
|
|
4465
|
-
|
|
4466
|
-
setCurrentlyValidatingElement$1(element);
|
|
4467
|
-
|
|
4468
|
-
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
|
4469
|
-
|
|
4470
|
-
setCurrentlyValidatingElement$1(null);
|
|
4471
|
-
}
|
|
4472
|
-
}
|
|
4473
|
-
/**
|
|
4474
|
-
* Ensure that every element either is passed in a static location, in an
|
|
4475
|
-
* array with an explicit keys property defined, or in an object literal
|
|
4476
|
-
* with valid key property.
|
|
4477
|
-
*
|
|
4478
|
-
* @internal
|
|
4479
|
-
* @param {ReactNode} node Statically passed child of any type.
|
|
4480
|
-
* @param {*} parentType node's parent's type.
|
|
4481
|
-
*/
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
function validateChildKeys(node, parentType) {
|
|
4485
|
-
{
|
|
4486
|
-
if (typeof node !== 'object') {
|
|
4487
|
-
return;
|
|
4488
|
-
}
|
|
4489
|
-
|
|
4490
|
-
if (isArray(node)) {
|
|
4491
|
-
for (var i = 0; i < node.length; i++) {
|
|
4492
|
-
var child = node[i];
|
|
4493
|
-
|
|
4494
|
-
if (isValidElement(child)) {
|
|
4495
|
-
validateExplicitKey(child, parentType);
|
|
4496
|
-
}
|
|
4497
|
-
}
|
|
4498
|
-
} else if (isValidElement(node)) {
|
|
4499
|
-
// This element was passed in a valid location.
|
|
4500
|
-
if (node._store) {
|
|
4501
|
-
node._store.validated = true;
|
|
4502
|
-
}
|
|
4503
|
-
} else if (node) {
|
|
4504
|
-
var iteratorFn = getIteratorFn(node);
|
|
4505
|
-
|
|
4506
|
-
if (typeof iteratorFn === 'function') {
|
|
4507
|
-
// Entry iterators used to provide implicit keys,
|
|
4508
|
-
// but now we print a separate warning for them later.
|
|
4509
|
-
if (iteratorFn !== node.entries) {
|
|
4510
|
-
var iterator = iteratorFn.call(node);
|
|
4511
|
-
var step;
|
|
4512
|
-
|
|
4513
|
-
while (!(step = iterator.next()).done) {
|
|
4514
|
-
if (isValidElement(step.value)) {
|
|
4515
|
-
validateExplicitKey(step.value, parentType);
|
|
4516
|
-
}
|
|
4517
|
-
}
|
|
4518
|
-
}
|
|
4519
|
-
}
|
|
4520
|
-
}
|
|
4521
|
-
}
|
|
4522
|
-
}
|
|
4523
|
-
/**
|
|
4524
|
-
* Given an element, validate that its props follow the propTypes definition,
|
|
4525
|
-
* provided by the type.
|
|
4526
|
-
*
|
|
4527
|
-
* @param {ReactElement} element
|
|
4528
|
-
*/
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
function validatePropTypes(element) {
|
|
4532
|
-
{
|
|
4533
|
-
var type = element.type;
|
|
4534
|
-
|
|
4535
|
-
if (type === null || type === undefined || typeof type === 'string') {
|
|
4536
|
-
return;
|
|
4537
|
-
}
|
|
4538
|
-
|
|
4539
|
-
var propTypes;
|
|
4540
|
-
|
|
4541
|
-
if (typeof type === 'function') {
|
|
4542
|
-
propTypes = type.propTypes;
|
|
4543
|
-
} else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
|
|
4544
|
-
// Inner props are checked in the reconciler.
|
|
4545
|
-
type.$$typeof === REACT_MEMO_TYPE)) {
|
|
4546
|
-
propTypes = type.propTypes;
|
|
4547
|
-
} else {
|
|
4548
|
-
return;
|
|
4549
|
-
}
|
|
4550
|
-
|
|
4551
|
-
if (propTypes) {
|
|
4552
|
-
// Intentionally inside to avoid triggering lazy initializers:
|
|
4553
|
-
var name = getComponentNameFromType(type);
|
|
4554
|
-
checkPropTypes(propTypes, element.props, 'prop', name, element);
|
|
4555
|
-
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
|
4556
|
-
propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
|
|
4557
|
-
|
|
4558
|
-
var _name = getComponentNameFromType(type);
|
|
4559
|
-
|
|
4560
|
-
error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
|
|
4561
|
-
}
|
|
4562
|
-
|
|
4563
|
-
if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
|
|
4564
|
-
error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
|
|
4565
|
-
}
|
|
4566
|
-
}
|
|
4567
|
-
}
|
|
4568
|
-
/**
|
|
4569
|
-
* Given a fragment, validate that it can only be provided with fragment props
|
|
4570
|
-
* @param {ReactElement} fragment
|
|
4571
|
-
*/
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
function validateFragmentProps(fragment) {
|
|
4575
|
-
{
|
|
4576
|
-
var keys = Object.keys(fragment.props);
|
|
4577
|
-
|
|
4578
|
-
for (var i = 0; i < keys.length; i++) {
|
|
4579
|
-
var key = keys[i];
|
|
4580
|
-
|
|
4581
|
-
if (key !== 'children' && key !== 'key') {
|
|
4582
|
-
setCurrentlyValidatingElement$1(fragment);
|
|
4583
|
-
|
|
4584
|
-
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
|
4585
|
-
|
|
4586
|
-
setCurrentlyValidatingElement$1(null);
|
|
4587
|
-
break;
|
|
4588
|
-
}
|
|
4589
|
-
}
|
|
4590
|
-
|
|
4591
|
-
if (fragment.ref !== null) {
|
|
4592
|
-
setCurrentlyValidatingElement$1(fragment);
|
|
4593
|
-
|
|
4594
|
-
error('Invalid attribute `ref` supplied to `React.Fragment`.');
|
|
4595
|
-
|
|
4596
|
-
setCurrentlyValidatingElement$1(null);
|
|
4597
|
-
}
|
|
4598
|
-
}
|
|
4599
|
-
}
|
|
4600
|
-
|
|
4601
|
-
function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
|
|
4602
|
-
{
|
|
4603
|
-
var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
|
|
4604
|
-
// succeed and there will likely be errors in render.
|
|
4605
|
-
|
|
4606
|
-
if (!validType) {
|
|
4607
|
-
var info = '';
|
|
4608
|
-
|
|
4609
|
-
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
|
4610
|
-
info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
|
|
4611
|
-
}
|
|
4612
|
-
|
|
4613
|
-
var sourceInfo = getSourceInfoErrorAddendum(source);
|
|
4614
|
-
|
|
4615
|
-
if (sourceInfo) {
|
|
4616
|
-
info += sourceInfo;
|
|
4617
|
-
} else {
|
|
4618
|
-
info += getDeclarationErrorAddendum();
|
|
4619
|
-
}
|
|
4620
|
-
|
|
4621
|
-
var typeString;
|
|
4622
|
-
|
|
4623
|
-
if (type === null) {
|
|
4624
|
-
typeString = 'null';
|
|
4625
|
-
} else if (isArray(type)) {
|
|
4626
|
-
typeString = 'array';
|
|
4627
|
-
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
|
4628
|
-
typeString = "<" + (getComponentNameFromType(type.type) || 'Unknown') + " />";
|
|
4629
|
-
info = ' Did you accidentally export a JSX literal instead of a component?';
|
|
4630
|
-
} else {
|
|
4631
|
-
typeString = typeof type;
|
|
4632
|
-
}
|
|
4633
|
-
|
|
4634
|
-
error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
|
|
4635
|
-
}
|
|
4636
|
-
|
|
4637
|
-
var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
|
|
4638
|
-
// TODO: Drop this when these are no longer allowed as the type argument.
|
|
4639
|
-
|
|
4640
|
-
if (element == null) {
|
|
4641
|
-
return element;
|
|
4642
|
-
} // Skip key warning if the type isn't valid since our key validation logic
|
|
4643
|
-
// doesn't expect a non-string/function type and can throw confusing errors.
|
|
4644
|
-
// We don't want exception behavior to differ between dev and prod.
|
|
4645
|
-
// (Rendering will throw with a helpful message and as soon as the type is
|
|
4646
|
-
// fixed, the key warnings will appear.)
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
if (validType) {
|
|
4650
|
-
var children = props.children;
|
|
4651
|
-
|
|
4652
|
-
if (children !== undefined) {
|
|
4653
|
-
if (isStaticChildren) {
|
|
4654
|
-
if (isArray(children)) {
|
|
4655
|
-
for (var i = 0; i < children.length; i++) {
|
|
4656
|
-
validateChildKeys(children[i], type);
|
|
4657
|
-
}
|
|
4658
|
-
|
|
4659
|
-
if (Object.freeze) {
|
|
4660
|
-
Object.freeze(children);
|
|
4661
|
-
}
|
|
4662
|
-
} else {
|
|
4663
|
-
error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
|
|
4664
|
-
}
|
|
4665
|
-
} else {
|
|
4666
|
-
validateChildKeys(children, type);
|
|
4667
|
-
}
|
|
4668
|
-
}
|
|
4669
|
-
}
|
|
4670
|
-
|
|
4671
|
-
if (type === REACT_FRAGMENT_TYPE) {
|
|
4672
|
-
validateFragmentProps(element);
|
|
4673
|
-
} else {
|
|
4674
|
-
validatePropTypes(element);
|
|
4675
|
-
}
|
|
4676
|
-
|
|
4677
|
-
return element;
|
|
4678
|
-
}
|
|
4679
|
-
} // These two functions exist to still get child warnings in dev
|
|
4680
|
-
// even with the prod transform. This means that jsxDEV is purely
|
|
4681
|
-
// opt-in behavior for better messages but that we won't stop
|
|
4682
|
-
// giving you warnings if you use production apis.
|
|
4683
|
-
|
|
4684
|
-
function jsxWithValidationStatic(type, props, key) {
|
|
4685
|
-
{
|
|
4686
|
-
return jsxWithValidation(type, props, key, true);
|
|
4687
|
-
}
|
|
4688
|
-
}
|
|
4689
|
-
function jsxWithValidationDynamic(type, props, key) {
|
|
4690
|
-
{
|
|
4691
|
-
return jsxWithValidation(type, props, key, false);
|
|
4692
|
-
}
|
|
4693
|
-
}
|
|
4694
|
-
|
|
4695
|
-
var jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.
|
|
4696
|
-
// for now we can ship identical prod functions
|
|
4697
|
-
|
|
4698
|
-
var jsxs = jsxWithValidationStatic ;
|
|
4699
|
-
|
|
4700
|
-
exports.Fragment = REACT_FRAGMENT_TYPE;
|
|
4701
|
-
exports.jsx = jsx;
|
|
4702
|
-
exports.jsxs = jsxs;
|
|
4703
|
-
})();
|
|
4704
|
-
}
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
/***/ }),
|
|
4708
|
-
|
|
4709
|
-
/***/ "./node_modules/react/jsx-runtime.js":
|
|
4710
|
-
/*!*******************************************!*\
|
|
4711
|
-
!*** ./node_modules/react/jsx-runtime.js ***!
|
|
4712
|
-
\*******************************************/
|
|
4713
|
-
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
4714
|
-
|
|
4715
|
-
"use strict";
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
if (false) {} else {
|
|
4719
|
-
module.exports = __webpack_require__(/*! ./cjs/react-jsx-runtime.development.js */ "./node_modules/react/cjs/react-jsx-runtime.development.js");
|
|
4720
|
-
}
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
/***/ }),
|
|
4724
|
-
|
|
4725
|
-
/***/ "expensify-common/lib/str":
|
|
4726
|
-
/*!*******************************************!*\
|
|
4727
|
-
!*** external "expensify-common/lib/str" ***!
|
|
4728
|
-
\*******************************************/
|
|
4729
|
-
/***/ ((module) => {
|
|
4730
|
-
|
|
4731
|
-
"use strict";
|
|
4732
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_expensify_common_lib_str__;
|
|
4733
|
-
|
|
4734
|
-
/***/ }),
|
|
3510
|
+
/***/ }),
|
|
4735
3511
|
|
|
4736
3512
|
/***/ "fast-equals":
|
|
4737
3513
|
/*!******************************!*\
|
|
@@ -4797,371 +3573,6 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_react__;
|
|
|
4797
3573
|
"use strict";
|
|
4798
3574
|
module.exports = __WEBPACK_EXTERNAL_MODULE_underscore__;
|
|
4799
3575
|
|
|
4800
|
-
/***/ }),
|
|
4801
|
-
|
|
4802
|
-
/***/ "./node_modules/@babel/runtime/helpers/arrayLikeToArray.js":
|
|
4803
|
-
/*!*****************************************************************!*\
|
|
4804
|
-
!*** ./node_modules/@babel/runtime/helpers/arrayLikeToArray.js ***!
|
|
4805
|
-
\*****************************************************************/
|
|
4806
|
-
/***/ ((module) => {
|
|
4807
|
-
|
|
4808
|
-
function _arrayLikeToArray(arr, len) {
|
|
4809
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
4810
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
4811
|
-
arr2[i] = arr[i];
|
|
4812
|
-
}
|
|
4813
|
-
return arr2;
|
|
4814
|
-
}
|
|
4815
|
-
module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
4816
|
-
|
|
4817
|
-
/***/ }),
|
|
4818
|
-
|
|
4819
|
-
/***/ "./node_modules/@babel/runtime/helpers/arrayWithHoles.js":
|
|
4820
|
-
/*!***************************************************************!*\
|
|
4821
|
-
!*** ./node_modules/@babel/runtime/helpers/arrayWithHoles.js ***!
|
|
4822
|
-
\***************************************************************/
|
|
4823
|
-
/***/ ((module) => {
|
|
4824
|
-
|
|
4825
|
-
function _arrayWithHoles(arr) {
|
|
4826
|
-
if (Array.isArray(arr)) return arr;
|
|
4827
|
-
}
|
|
4828
|
-
module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
4829
|
-
|
|
4830
|
-
/***/ }),
|
|
4831
|
-
|
|
4832
|
-
/***/ "./node_modules/@babel/runtime/helpers/arrayWithoutHoles.js":
|
|
4833
|
-
/*!******************************************************************!*\
|
|
4834
|
-
!*** ./node_modules/@babel/runtime/helpers/arrayWithoutHoles.js ***!
|
|
4835
|
-
\******************************************************************/
|
|
4836
|
-
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
4837
|
-
|
|
4838
|
-
var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ "./node_modules/@babel/runtime/helpers/arrayLikeToArray.js");
|
|
4839
|
-
function _arrayWithoutHoles(arr) {
|
|
4840
|
-
if (Array.isArray(arr)) return arrayLikeToArray(arr);
|
|
4841
|
-
}
|
|
4842
|
-
module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
4843
|
-
|
|
4844
|
-
/***/ }),
|
|
4845
|
-
|
|
4846
|
-
/***/ "./node_modules/@babel/runtime/helpers/assertThisInitialized.js":
|
|
4847
|
-
/*!**********************************************************************!*\
|
|
4848
|
-
!*** ./node_modules/@babel/runtime/helpers/assertThisInitialized.js ***!
|
|
4849
|
-
\**********************************************************************/
|
|
4850
|
-
/***/ ((module) => {
|
|
4851
|
-
|
|
4852
|
-
function _assertThisInitialized(self) {
|
|
4853
|
-
if (self === void 0) {
|
|
4854
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
4855
|
-
}
|
|
4856
|
-
return self;
|
|
4857
|
-
}
|
|
4858
|
-
module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
4859
|
-
|
|
4860
|
-
/***/ }),
|
|
4861
|
-
|
|
4862
|
-
/***/ "./node_modules/@babel/runtime/helpers/classCallCheck.js":
|
|
4863
|
-
/*!***************************************************************!*\
|
|
4864
|
-
!*** ./node_modules/@babel/runtime/helpers/classCallCheck.js ***!
|
|
4865
|
-
\***************************************************************/
|
|
4866
|
-
/***/ ((module) => {
|
|
4867
|
-
|
|
4868
|
-
function _classCallCheck(instance, Constructor) {
|
|
4869
|
-
if (!(instance instanceof Constructor)) {
|
|
4870
|
-
throw new TypeError("Cannot call a class as a function");
|
|
4871
|
-
}
|
|
4872
|
-
}
|
|
4873
|
-
module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
4874
|
-
|
|
4875
|
-
/***/ }),
|
|
4876
|
-
|
|
4877
|
-
/***/ "./node_modules/@babel/runtime/helpers/createClass.js":
|
|
4878
|
-
/*!************************************************************!*\
|
|
4879
|
-
!*** ./node_modules/@babel/runtime/helpers/createClass.js ***!
|
|
4880
|
-
\************************************************************/
|
|
4881
|
-
/***/ ((module) => {
|
|
4882
|
-
|
|
4883
|
-
function _defineProperties(target, props) {
|
|
4884
|
-
for (var i = 0; i < props.length; i++) {
|
|
4885
|
-
var descriptor = props[i];
|
|
4886
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
4887
|
-
descriptor.configurable = true;
|
|
4888
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
4889
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
4890
|
-
}
|
|
4891
|
-
}
|
|
4892
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
4893
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
4894
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
4895
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
4896
|
-
writable: false
|
|
4897
|
-
});
|
|
4898
|
-
return Constructor;
|
|
4899
|
-
}
|
|
4900
|
-
module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
4901
|
-
|
|
4902
|
-
/***/ }),
|
|
4903
|
-
|
|
4904
|
-
/***/ "./node_modules/@babel/runtime/helpers/defineProperty.js":
|
|
4905
|
-
/*!***************************************************************!*\
|
|
4906
|
-
!*** ./node_modules/@babel/runtime/helpers/defineProperty.js ***!
|
|
4907
|
-
\***************************************************************/
|
|
4908
|
-
/***/ ((module) => {
|
|
4909
|
-
|
|
4910
|
-
function _defineProperty(obj, key, value) {
|
|
4911
|
-
if (key in obj) {
|
|
4912
|
-
Object.defineProperty(obj, key, {
|
|
4913
|
-
value: value,
|
|
4914
|
-
enumerable: true,
|
|
4915
|
-
configurable: true,
|
|
4916
|
-
writable: true
|
|
4917
|
-
});
|
|
4918
|
-
} else {
|
|
4919
|
-
obj[key] = value;
|
|
4920
|
-
}
|
|
4921
|
-
return obj;
|
|
4922
|
-
}
|
|
4923
|
-
module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
4924
|
-
|
|
4925
|
-
/***/ }),
|
|
4926
|
-
|
|
4927
|
-
/***/ "./node_modules/@babel/runtime/helpers/getPrototypeOf.js":
|
|
4928
|
-
/*!***************************************************************!*\
|
|
4929
|
-
!*** ./node_modules/@babel/runtime/helpers/getPrototypeOf.js ***!
|
|
4930
|
-
\***************************************************************/
|
|
4931
|
-
/***/ ((module) => {
|
|
4932
|
-
|
|
4933
|
-
function _getPrototypeOf(o) {
|
|
4934
|
-
module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
4935
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
4936
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
4937
|
-
return _getPrototypeOf(o);
|
|
4938
|
-
}
|
|
4939
|
-
module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
4940
|
-
|
|
4941
|
-
/***/ }),
|
|
4942
|
-
|
|
4943
|
-
/***/ "./node_modules/@babel/runtime/helpers/inherits.js":
|
|
4944
|
-
/*!*********************************************************!*\
|
|
4945
|
-
!*** ./node_modules/@babel/runtime/helpers/inherits.js ***!
|
|
4946
|
-
\*********************************************************/
|
|
4947
|
-
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
4948
|
-
|
|
4949
|
-
var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "./node_modules/@babel/runtime/helpers/setPrototypeOf.js");
|
|
4950
|
-
function _inherits(subClass, superClass) {
|
|
4951
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
4952
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
4953
|
-
}
|
|
4954
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
4955
|
-
constructor: {
|
|
4956
|
-
value: subClass,
|
|
4957
|
-
writable: true,
|
|
4958
|
-
configurable: true
|
|
4959
|
-
}
|
|
4960
|
-
});
|
|
4961
|
-
Object.defineProperty(subClass, "prototype", {
|
|
4962
|
-
writable: false
|
|
4963
|
-
});
|
|
4964
|
-
if (superClass) setPrototypeOf(subClass, superClass);
|
|
4965
|
-
}
|
|
4966
|
-
module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
4967
|
-
|
|
4968
|
-
/***/ }),
|
|
4969
|
-
|
|
4970
|
-
/***/ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js":
|
|
4971
|
-
/*!**********************************************************************!*\
|
|
4972
|
-
!*** ./node_modules/@babel/runtime/helpers/interopRequireDefault.js ***!
|
|
4973
|
-
\**********************************************************************/
|
|
4974
|
-
/***/ ((module) => {
|
|
4975
|
-
|
|
4976
|
-
function _interopRequireDefault(obj) {
|
|
4977
|
-
return obj && obj.__esModule ? obj : {
|
|
4978
|
-
"default": obj
|
|
4979
|
-
};
|
|
4980
|
-
}
|
|
4981
|
-
module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
4982
|
-
|
|
4983
|
-
/***/ }),
|
|
4984
|
-
|
|
4985
|
-
/***/ "./node_modules/@babel/runtime/helpers/iterableToArray.js":
|
|
4986
|
-
/*!****************************************************************!*\
|
|
4987
|
-
!*** ./node_modules/@babel/runtime/helpers/iterableToArray.js ***!
|
|
4988
|
-
\****************************************************************/
|
|
4989
|
-
/***/ ((module) => {
|
|
4990
|
-
|
|
4991
|
-
function _iterableToArray(iter) {
|
|
4992
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
4993
|
-
}
|
|
4994
|
-
module.exports = _iterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
4995
|
-
|
|
4996
|
-
/***/ }),
|
|
4997
|
-
|
|
4998
|
-
/***/ "./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js":
|
|
4999
|
-
/*!*********************************************************************!*\
|
|
5000
|
-
!*** ./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***!
|
|
5001
|
-
\*********************************************************************/
|
|
5002
|
-
/***/ ((module) => {
|
|
5003
|
-
|
|
5004
|
-
function _iterableToArrayLimit(arr, i) {
|
|
5005
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
5006
|
-
if (_i == null) return;
|
|
5007
|
-
var _arr = [];
|
|
5008
|
-
var _n = true;
|
|
5009
|
-
var _d = false;
|
|
5010
|
-
var _s, _e;
|
|
5011
|
-
try {
|
|
5012
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
5013
|
-
_arr.push(_s.value);
|
|
5014
|
-
if (i && _arr.length === i) break;
|
|
5015
|
-
}
|
|
5016
|
-
} catch (err) {
|
|
5017
|
-
_d = true;
|
|
5018
|
-
_e = err;
|
|
5019
|
-
} finally {
|
|
5020
|
-
try {
|
|
5021
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
5022
|
-
} finally {
|
|
5023
|
-
if (_d) throw _e;
|
|
5024
|
-
}
|
|
5025
|
-
}
|
|
5026
|
-
return _arr;
|
|
5027
|
-
}
|
|
5028
|
-
module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
5029
|
-
|
|
5030
|
-
/***/ }),
|
|
5031
|
-
|
|
5032
|
-
/***/ "./node_modules/@babel/runtime/helpers/nonIterableRest.js":
|
|
5033
|
-
/*!****************************************************************!*\
|
|
5034
|
-
!*** ./node_modules/@babel/runtime/helpers/nonIterableRest.js ***!
|
|
5035
|
-
\****************************************************************/
|
|
5036
|
-
/***/ ((module) => {
|
|
5037
|
-
|
|
5038
|
-
function _nonIterableRest() {
|
|
5039
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
5040
|
-
}
|
|
5041
|
-
module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
5042
|
-
|
|
5043
|
-
/***/ }),
|
|
5044
|
-
|
|
5045
|
-
/***/ "./node_modules/@babel/runtime/helpers/nonIterableSpread.js":
|
|
5046
|
-
/*!******************************************************************!*\
|
|
5047
|
-
!*** ./node_modules/@babel/runtime/helpers/nonIterableSpread.js ***!
|
|
5048
|
-
\******************************************************************/
|
|
5049
|
-
/***/ ((module) => {
|
|
5050
|
-
|
|
5051
|
-
function _nonIterableSpread() {
|
|
5052
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
5053
|
-
}
|
|
5054
|
-
module.exports = _nonIterableSpread, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
5055
|
-
|
|
5056
|
-
/***/ }),
|
|
5057
|
-
|
|
5058
|
-
/***/ "./node_modules/@babel/runtime/helpers/possibleConstructorReturn.js":
|
|
5059
|
-
/*!**************************************************************************!*\
|
|
5060
|
-
!*** ./node_modules/@babel/runtime/helpers/possibleConstructorReturn.js ***!
|
|
5061
|
-
\**************************************************************************/
|
|
5062
|
-
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
5063
|
-
|
|
5064
|
-
var _typeof = (__webpack_require__(/*! ./typeof.js */ "./node_modules/@babel/runtime/helpers/typeof.js")["default"]);
|
|
5065
|
-
var assertThisInitialized = __webpack_require__(/*! ./assertThisInitialized.js */ "./node_modules/@babel/runtime/helpers/assertThisInitialized.js");
|
|
5066
|
-
function _possibleConstructorReturn(self, call) {
|
|
5067
|
-
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
5068
|
-
return call;
|
|
5069
|
-
} else if (call !== void 0) {
|
|
5070
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
5071
|
-
}
|
|
5072
|
-
return assertThisInitialized(self);
|
|
5073
|
-
}
|
|
5074
|
-
module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
5075
|
-
|
|
5076
|
-
/***/ }),
|
|
5077
|
-
|
|
5078
|
-
/***/ "./node_modules/@babel/runtime/helpers/setPrototypeOf.js":
|
|
5079
|
-
/*!***************************************************************!*\
|
|
5080
|
-
!*** ./node_modules/@babel/runtime/helpers/setPrototypeOf.js ***!
|
|
5081
|
-
\***************************************************************/
|
|
5082
|
-
/***/ ((module) => {
|
|
5083
|
-
|
|
5084
|
-
function _setPrototypeOf(o, p) {
|
|
5085
|
-
module.exports = _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
5086
|
-
o.__proto__ = p;
|
|
5087
|
-
return o;
|
|
5088
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
5089
|
-
return _setPrototypeOf(o, p);
|
|
5090
|
-
}
|
|
5091
|
-
module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
5092
|
-
|
|
5093
|
-
/***/ }),
|
|
5094
|
-
|
|
5095
|
-
/***/ "./node_modules/@babel/runtime/helpers/slicedToArray.js":
|
|
5096
|
-
/*!**************************************************************!*\
|
|
5097
|
-
!*** ./node_modules/@babel/runtime/helpers/slicedToArray.js ***!
|
|
5098
|
-
\**************************************************************/
|
|
5099
|
-
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
5100
|
-
|
|
5101
|
-
var arrayWithHoles = __webpack_require__(/*! ./arrayWithHoles.js */ "./node_modules/@babel/runtime/helpers/arrayWithHoles.js");
|
|
5102
|
-
var iterableToArrayLimit = __webpack_require__(/*! ./iterableToArrayLimit.js */ "./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js");
|
|
5103
|
-
var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray.js */ "./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js");
|
|
5104
|
-
var nonIterableRest = __webpack_require__(/*! ./nonIterableRest.js */ "./node_modules/@babel/runtime/helpers/nonIterableRest.js");
|
|
5105
|
-
function _slicedToArray(arr, i) {
|
|
5106
|
-
return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();
|
|
5107
|
-
}
|
|
5108
|
-
module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
5109
|
-
|
|
5110
|
-
/***/ }),
|
|
5111
|
-
|
|
5112
|
-
/***/ "./node_modules/@babel/runtime/helpers/toConsumableArray.js":
|
|
5113
|
-
/*!******************************************************************!*\
|
|
5114
|
-
!*** ./node_modules/@babel/runtime/helpers/toConsumableArray.js ***!
|
|
5115
|
-
\******************************************************************/
|
|
5116
|
-
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
5117
|
-
|
|
5118
|
-
var arrayWithoutHoles = __webpack_require__(/*! ./arrayWithoutHoles.js */ "./node_modules/@babel/runtime/helpers/arrayWithoutHoles.js");
|
|
5119
|
-
var iterableToArray = __webpack_require__(/*! ./iterableToArray.js */ "./node_modules/@babel/runtime/helpers/iterableToArray.js");
|
|
5120
|
-
var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray.js */ "./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js");
|
|
5121
|
-
var nonIterableSpread = __webpack_require__(/*! ./nonIterableSpread.js */ "./node_modules/@babel/runtime/helpers/nonIterableSpread.js");
|
|
5122
|
-
function _toConsumableArray(arr) {
|
|
5123
|
-
return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();
|
|
5124
|
-
}
|
|
5125
|
-
module.exports = _toConsumableArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
5126
|
-
|
|
5127
|
-
/***/ }),
|
|
5128
|
-
|
|
5129
|
-
/***/ "./node_modules/@babel/runtime/helpers/typeof.js":
|
|
5130
|
-
/*!*******************************************************!*\
|
|
5131
|
-
!*** ./node_modules/@babel/runtime/helpers/typeof.js ***!
|
|
5132
|
-
\*******************************************************/
|
|
5133
|
-
/***/ ((module) => {
|
|
5134
|
-
|
|
5135
|
-
function _typeof(obj) {
|
|
5136
|
-
"@babel/helpers - typeof";
|
|
5137
|
-
|
|
5138
|
-
return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
5139
|
-
return typeof obj;
|
|
5140
|
-
} : function (obj) {
|
|
5141
|
-
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
5142
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
|
|
5143
|
-
}
|
|
5144
|
-
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
5145
|
-
|
|
5146
|
-
/***/ }),
|
|
5147
|
-
|
|
5148
|
-
/***/ "./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js":
|
|
5149
|
-
/*!***************************************************************************!*\
|
|
5150
|
-
!*** ./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***!
|
|
5151
|
-
\***************************************************************************/
|
|
5152
|
-
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
5153
|
-
|
|
5154
|
-
var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ "./node_modules/@babel/runtime/helpers/arrayLikeToArray.js");
|
|
5155
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
5156
|
-
if (!o) return;
|
|
5157
|
-
if (typeof o === "string") return arrayLikeToArray(o, minLen);
|
|
5158
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
5159
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
5160
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
5161
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);
|
|
5162
|
-
}
|
|
5163
|
-
module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
5164
|
-
|
|
5165
3576
|
/***/ })
|
|
5166
3577
|
|
|
5167
3578
|
/******/ });
|
|
@@ -5191,6 +3602,30 @@ module.exports = _unsupportedIterableToArray, module.exports.__esModule = true,
|
|
|
5191
3602
|
/******/ }
|
|
5192
3603
|
/******/
|
|
5193
3604
|
/************************************************************************/
|
|
3605
|
+
/******/ /* webpack/runtime/compat get default export */
|
|
3606
|
+
/******/ (() => {
|
|
3607
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
3608
|
+
/******/ __webpack_require__.n = (module) => {
|
|
3609
|
+
/******/ var getter = module && module.__esModule ?
|
|
3610
|
+
/******/ () => (module['default']) :
|
|
3611
|
+
/******/ () => (module);
|
|
3612
|
+
/******/ __webpack_require__.d(getter, { a: getter });
|
|
3613
|
+
/******/ return getter;
|
|
3614
|
+
/******/ };
|
|
3615
|
+
/******/ })();
|
|
3616
|
+
/******/
|
|
3617
|
+
/******/ /* webpack/runtime/define property getters */
|
|
3618
|
+
/******/ (() => {
|
|
3619
|
+
/******/ // define getter functions for harmony exports
|
|
3620
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
3621
|
+
/******/ for(var key in definition) {
|
|
3622
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
3623
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
3624
|
+
/******/ }
|
|
3625
|
+
/******/ }
|
|
3626
|
+
/******/ };
|
|
3627
|
+
/******/ })();
|
|
3628
|
+
/******/
|
|
5194
3629
|
/******/ /* webpack/runtime/global */
|
|
5195
3630
|
/******/ (() => {
|
|
5196
3631
|
/******/ __webpack_require__.g = (function() {
|
|
@@ -5203,18 +3638,42 @@ module.exports = _unsupportedIterableToArray, module.exports.__esModule = true,
|
|
|
5203
3638
|
/******/ })();
|
|
5204
3639
|
/******/ })();
|
|
5205
3640
|
/******/
|
|
3641
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
3642
|
+
/******/ (() => {
|
|
3643
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
3644
|
+
/******/ })();
|
|
3645
|
+
/******/
|
|
3646
|
+
/******/ /* webpack/runtime/make namespace object */
|
|
3647
|
+
/******/ (() => {
|
|
3648
|
+
/******/ // define __esModule on exports
|
|
3649
|
+
/******/ __webpack_require__.r = (exports) => {
|
|
3650
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
3651
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3652
|
+
/******/ }
|
|
3653
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
3654
|
+
/******/ };
|
|
3655
|
+
/******/ })();
|
|
3656
|
+
/******/
|
|
5206
3657
|
/************************************************************************/
|
|
5207
3658
|
var __webpack_exports__ = {};
|
|
5208
|
-
// This entry need to be wrapped in an IIFE because it need to be
|
|
3659
|
+
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
|
|
5209
3660
|
(() => {
|
|
5210
|
-
|
|
3661
|
+
"use strict";
|
|
5211
3662
|
/*!**********************!*\
|
|
5212
3663
|
!*** ./lib/index.js ***!
|
|
5213
3664
|
\**********************/
|
|
5214
|
-
|
|
5215
|
-
|
|
3665
|
+
__webpack_require__.r(__webpack_exports__);
|
|
3666
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3667
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
|
|
3668
|
+
/* harmony export */ "withOnyx": () => (/* reexport safe */ _withOnyx__WEBPACK_IMPORTED_MODULE_1__["default"])
|
|
3669
|
+
/* harmony export */ });
|
|
3670
|
+
/* harmony import */ var _Onyx__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Onyx */ "./lib/Onyx.js");
|
|
3671
|
+
/* harmony import */ var _withOnyx__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./withOnyx */ "./lib/withOnyx.js");
|
|
3672
|
+
|
|
3673
|
+
|
|
3674
|
+
|
|
3675
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_Onyx__WEBPACK_IMPORTED_MODULE_0__["default"]);
|
|
5216
3676
|
|
|
5217
|
-
_Onyx.default;exports["default"] = _default;
|
|
5218
3677
|
})();
|
|
5219
3678
|
|
|
5220
3679
|
/******/ return __webpack_exports__;
|