react-native-onyx 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +187 -0
- package/LICENSE.md +21 -0
- package/README.md +258 -0
- package/dist/web.development.js +3289 -0
- package/dist/web.development.js.map +1 -0
- package/dist/web.min.js +2 -0
- package/dist/web.min.js.map +1 -0
- package/lib/Logger.js +35 -0
- package/lib/MDTable.js +69 -0
- package/lib/Onyx.js +901 -0
- package/lib/OnyxCache.js +195 -0
- package/lib/SyncQueue.js +51 -0
- package/lib/compose.js +29 -0
- package/lib/createDeferredTask.js +16 -0
- package/lib/index.js +5 -0
- package/lib/metrics/index.native.js +263 -0
- package/lib/metrics/index.web.js +13 -0
- package/lib/storage/NativeStorage.js +3 -0
- package/lib/storage/WebStorage.js +56 -0
- package/lib/storage/__mocks__/index.native.js +8 -0
- package/lib/storage/index.native.js +8 -0
- package/lib/storage/index.web.js +3 -0
- package/lib/storage/providers/AsyncStorage.js +83 -0
- package/lib/storage/providers/LocalForage.js +111 -0
- package/lib/withOnyx.js +200 -0
- package/native.js +11 -0
- package/package.json +109 -0
- package/web.js +12 -0
|
@@ -0,0 +1,3289 @@
|
|
|
1
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
+
module.exports = factory(require("underscore"), require("expensify-common/lib/str"), require("lodash/merge"), require("localforage"), require("react"));
|
|
4
|
+
else if(typeof define === 'function' && define.amd)
|
|
5
|
+
define(["underscore", "expensify-common/lib/str", "lodash/merge", "localforage", "react"], factory);
|
|
6
|
+
else if(typeof exports === 'object')
|
|
7
|
+
exports["react-native-onyx/web"] = factory(require("underscore"), require("expensify-common/lib/str"), require("lodash/merge"), require("localforage"), require("react"));
|
|
8
|
+
else
|
|
9
|
+
root["react-native-onyx/web"] = factory(root["underscore"], root["expensify-common/lib/str"], root["lodash/merge"], root["localforage"], root["react"]);
|
|
10
|
+
})(self, (__WEBPACK_EXTERNAL_MODULE_underscore__, __WEBPACK_EXTERNAL_MODULE_expensify_common_lib_str__, __WEBPACK_EXTERNAL_MODULE_lodash_merge__, __WEBPACK_EXTERNAL_MODULE_localforage__, __WEBPACK_EXTERNAL_MODULE_react__) => {
|
|
11
|
+
return /******/ (() => { // webpackBootstrap
|
|
12
|
+
/******/ var __webpack_modules__ = ({
|
|
13
|
+
|
|
14
|
+
/***/ "./node_modules/@babel/runtime/helpers/arrayLikeToArray.js":
|
|
15
|
+
/*!*****************************************************************!*\
|
|
16
|
+
!*** ./node_modules/@babel/runtime/helpers/arrayLikeToArray.js ***!
|
|
17
|
+
\*****************************************************************/
|
|
18
|
+
/***/ ((module) => {
|
|
19
|
+
|
|
20
|
+
function _arrayLikeToArray(arr, len) {
|
|
21
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
22
|
+
|
|
23
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
24
|
+
arr2[i] = arr[i];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return arr2;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
module.exports = _arrayLikeToArray;
|
|
31
|
+
|
|
32
|
+
/***/ }),
|
|
33
|
+
|
|
34
|
+
/***/ "./node_modules/@babel/runtime/helpers/arrayWithHoles.js":
|
|
35
|
+
/*!***************************************************************!*\
|
|
36
|
+
!*** ./node_modules/@babel/runtime/helpers/arrayWithHoles.js ***!
|
|
37
|
+
\***************************************************************/
|
|
38
|
+
/***/ ((module) => {
|
|
39
|
+
|
|
40
|
+
function _arrayWithHoles(arr) {
|
|
41
|
+
if (Array.isArray(arr)) return arr;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = _arrayWithHoles;
|
|
45
|
+
|
|
46
|
+
/***/ }),
|
|
47
|
+
|
|
48
|
+
/***/ "./node_modules/@babel/runtime/helpers/arrayWithoutHoles.js":
|
|
49
|
+
/*!******************************************************************!*\
|
|
50
|
+
!*** ./node_modules/@babel/runtime/helpers/arrayWithoutHoles.js ***!
|
|
51
|
+
\******************************************************************/
|
|
52
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
53
|
+
|
|
54
|
+
var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray */ "./node_modules/@babel/runtime/helpers/arrayLikeToArray.js");
|
|
55
|
+
|
|
56
|
+
function _arrayWithoutHoles(arr) {
|
|
57
|
+
if (Array.isArray(arr)) return arrayLikeToArray(arr);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
module.exports = _arrayWithoutHoles;
|
|
61
|
+
|
|
62
|
+
/***/ }),
|
|
63
|
+
|
|
64
|
+
/***/ "./node_modules/@babel/runtime/helpers/assertThisInitialized.js":
|
|
65
|
+
/*!**********************************************************************!*\
|
|
66
|
+
!*** ./node_modules/@babel/runtime/helpers/assertThisInitialized.js ***!
|
|
67
|
+
\**********************************************************************/
|
|
68
|
+
/***/ ((module) => {
|
|
69
|
+
|
|
70
|
+
function _assertThisInitialized(self) {
|
|
71
|
+
if (self === void 0) {
|
|
72
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return self;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
module.exports = _assertThisInitialized;
|
|
79
|
+
|
|
80
|
+
/***/ }),
|
|
81
|
+
|
|
82
|
+
/***/ "./node_modules/@babel/runtime/helpers/classCallCheck.js":
|
|
83
|
+
/*!***************************************************************!*\
|
|
84
|
+
!*** ./node_modules/@babel/runtime/helpers/classCallCheck.js ***!
|
|
85
|
+
\***************************************************************/
|
|
86
|
+
/***/ ((module) => {
|
|
87
|
+
|
|
88
|
+
function _classCallCheck(instance, Constructor) {
|
|
89
|
+
if (!(instance instanceof Constructor)) {
|
|
90
|
+
throw new TypeError("Cannot call a class as a function");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
module.exports = _classCallCheck;
|
|
95
|
+
|
|
96
|
+
/***/ }),
|
|
97
|
+
|
|
98
|
+
/***/ "./node_modules/@babel/runtime/helpers/createClass.js":
|
|
99
|
+
/*!************************************************************!*\
|
|
100
|
+
!*** ./node_modules/@babel/runtime/helpers/createClass.js ***!
|
|
101
|
+
\************************************************************/
|
|
102
|
+
/***/ ((module) => {
|
|
103
|
+
|
|
104
|
+
function _defineProperties(target, props) {
|
|
105
|
+
for (var i = 0; i < props.length; i++) {
|
|
106
|
+
var descriptor = props[i];
|
|
107
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
108
|
+
descriptor.configurable = true;
|
|
109
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
110
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
115
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
116
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
117
|
+
return Constructor;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
module.exports = _createClass;
|
|
121
|
+
|
|
122
|
+
/***/ }),
|
|
123
|
+
|
|
124
|
+
/***/ "./node_modules/@babel/runtime/helpers/defineProperty.js":
|
|
125
|
+
/*!***************************************************************!*\
|
|
126
|
+
!*** ./node_modules/@babel/runtime/helpers/defineProperty.js ***!
|
|
127
|
+
\***************************************************************/
|
|
128
|
+
/***/ ((module) => {
|
|
129
|
+
|
|
130
|
+
function _defineProperty(obj, key, value) {
|
|
131
|
+
if (key in obj) {
|
|
132
|
+
Object.defineProperty(obj, key, {
|
|
133
|
+
value: value,
|
|
134
|
+
enumerable: true,
|
|
135
|
+
configurable: true,
|
|
136
|
+
writable: true
|
|
137
|
+
});
|
|
138
|
+
} else {
|
|
139
|
+
obj[key] = value;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return obj;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
module.exports = _defineProperty;
|
|
146
|
+
|
|
147
|
+
/***/ }),
|
|
148
|
+
|
|
149
|
+
/***/ "./node_modules/@babel/runtime/helpers/extends.js":
|
|
150
|
+
/*!********************************************************!*\
|
|
151
|
+
!*** ./node_modules/@babel/runtime/helpers/extends.js ***!
|
|
152
|
+
\********************************************************/
|
|
153
|
+
/***/ ((module) => {
|
|
154
|
+
|
|
155
|
+
function _extends() {
|
|
156
|
+
module.exports = _extends = Object.assign || function (target) {
|
|
157
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
158
|
+
var source = arguments[i];
|
|
159
|
+
|
|
160
|
+
for (var key in source) {
|
|
161
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
162
|
+
target[key] = source[key];
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return target;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
return _extends.apply(this, arguments);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
module.exports = _extends;
|
|
174
|
+
|
|
175
|
+
/***/ }),
|
|
176
|
+
|
|
177
|
+
/***/ "./node_modules/@babel/runtime/helpers/getPrototypeOf.js":
|
|
178
|
+
/*!***************************************************************!*\
|
|
179
|
+
!*** ./node_modules/@babel/runtime/helpers/getPrototypeOf.js ***!
|
|
180
|
+
\***************************************************************/
|
|
181
|
+
/***/ ((module) => {
|
|
182
|
+
|
|
183
|
+
function _getPrototypeOf(o) {
|
|
184
|
+
module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
185
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
186
|
+
};
|
|
187
|
+
return _getPrototypeOf(o);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
module.exports = _getPrototypeOf;
|
|
191
|
+
|
|
192
|
+
/***/ }),
|
|
193
|
+
|
|
194
|
+
/***/ "./node_modules/@babel/runtime/helpers/inherits.js":
|
|
195
|
+
/*!*********************************************************!*\
|
|
196
|
+
!*** ./node_modules/@babel/runtime/helpers/inherits.js ***!
|
|
197
|
+
\*********************************************************/
|
|
198
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
199
|
+
|
|
200
|
+
var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf */ "./node_modules/@babel/runtime/helpers/setPrototypeOf.js");
|
|
201
|
+
|
|
202
|
+
function _inherits(subClass, superClass) {
|
|
203
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
204
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
208
|
+
constructor: {
|
|
209
|
+
value: subClass,
|
|
210
|
+
writable: true,
|
|
211
|
+
configurable: true
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
if (superClass) setPrototypeOf(subClass, superClass);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
module.exports = _inherits;
|
|
218
|
+
|
|
219
|
+
/***/ }),
|
|
220
|
+
|
|
221
|
+
/***/ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js":
|
|
222
|
+
/*!**********************************************************************!*\
|
|
223
|
+
!*** ./node_modules/@babel/runtime/helpers/interopRequireDefault.js ***!
|
|
224
|
+
\**********************************************************************/
|
|
225
|
+
/***/ ((module) => {
|
|
226
|
+
|
|
227
|
+
function _interopRequireDefault(obj) {
|
|
228
|
+
return obj && obj.__esModule ? obj : {
|
|
229
|
+
"default": obj
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
module.exports = _interopRequireDefault;
|
|
234
|
+
|
|
235
|
+
/***/ }),
|
|
236
|
+
|
|
237
|
+
/***/ "./node_modules/@babel/runtime/helpers/iterableToArray.js":
|
|
238
|
+
/*!****************************************************************!*\
|
|
239
|
+
!*** ./node_modules/@babel/runtime/helpers/iterableToArray.js ***!
|
|
240
|
+
\****************************************************************/
|
|
241
|
+
/***/ ((module) => {
|
|
242
|
+
|
|
243
|
+
function _iterableToArray(iter) {
|
|
244
|
+
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
module.exports = _iterableToArray;
|
|
248
|
+
|
|
249
|
+
/***/ }),
|
|
250
|
+
|
|
251
|
+
/***/ "./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js":
|
|
252
|
+
/*!*********************************************************************!*\
|
|
253
|
+
!*** ./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***!
|
|
254
|
+
\*********************************************************************/
|
|
255
|
+
/***/ ((module) => {
|
|
256
|
+
|
|
257
|
+
function _iterableToArrayLimit(arr, i) {
|
|
258
|
+
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
|
259
|
+
var _arr = [];
|
|
260
|
+
var _n = true;
|
|
261
|
+
var _d = false;
|
|
262
|
+
var _e = undefined;
|
|
263
|
+
|
|
264
|
+
try {
|
|
265
|
+
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
266
|
+
_arr.push(_s.value);
|
|
267
|
+
|
|
268
|
+
if (i && _arr.length === i) break;
|
|
269
|
+
}
|
|
270
|
+
} catch (err) {
|
|
271
|
+
_d = true;
|
|
272
|
+
_e = err;
|
|
273
|
+
} finally {
|
|
274
|
+
try {
|
|
275
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
276
|
+
} finally {
|
|
277
|
+
if (_d) throw _e;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return _arr;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
module.exports = _iterableToArrayLimit;
|
|
285
|
+
|
|
286
|
+
/***/ }),
|
|
287
|
+
|
|
288
|
+
/***/ "./node_modules/@babel/runtime/helpers/nonIterableRest.js":
|
|
289
|
+
/*!****************************************************************!*\
|
|
290
|
+
!*** ./node_modules/@babel/runtime/helpers/nonIterableRest.js ***!
|
|
291
|
+
\****************************************************************/
|
|
292
|
+
/***/ ((module) => {
|
|
293
|
+
|
|
294
|
+
function _nonIterableRest() {
|
|
295
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
module.exports = _nonIterableRest;
|
|
299
|
+
|
|
300
|
+
/***/ }),
|
|
301
|
+
|
|
302
|
+
/***/ "./node_modules/@babel/runtime/helpers/nonIterableSpread.js":
|
|
303
|
+
/*!******************************************************************!*\
|
|
304
|
+
!*** ./node_modules/@babel/runtime/helpers/nonIterableSpread.js ***!
|
|
305
|
+
\******************************************************************/
|
|
306
|
+
/***/ ((module) => {
|
|
307
|
+
|
|
308
|
+
function _nonIterableSpread() {
|
|
309
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
module.exports = _nonIterableSpread;
|
|
313
|
+
|
|
314
|
+
/***/ }),
|
|
315
|
+
|
|
316
|
+
/***/ "./node_modules/@babel/runtime/helpers/possibleConstructorReturn.js":
|
|
317
|
+
/*!**************************************************************************!*\
|
|
318
|
+
!*** ./node_modules/@babel/runtime/helpers/possibleConstructorReturn.js ***!
|
|
319
|
+
\**************************************************************************/
|
|
320
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
321
|
+
|
|
322
|
+
var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
|
|
323
|
+
|
|
324
|
+
var assertThisInitialized = __webpack_require__(/*! ./assertThisInitialized */ "./node_modules/@babel/runtime/helpers/assertThisInitialized.js");
|
|
325
|
+
|
|
326
|
+
function _possibleConstructorReturn(self, call) {
|
|
327
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
328
|
+
return call;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
return assertThisInitialized(self);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
module.exports = _possibleConstructorReturn;
|
|
335
|
+
|
|
336
|
+
/***/ }),
|
|
337
|
+
|
|
338
|
+
/***/ "./node_modules/@babel/runtime/helpers/setPrototypeOf.js":
|
|
339
|
+
/*!***************************************************************!*\
|
|
340
|
+
!*** ./node_modules/@babel/runtime/helpers/setPrototypeOf.js ***!
|
|
341
|
+
\***************************************************************/
|
|
342
|
+
/***/ ((module) => {
|
|
343
|
+
|
|
344
|
+
function _setPrototypeOf(o, p) {
|
|
345
|
+
module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
346
|
+
o.__proto__ = p;
|
|
347
|
+
return o;
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
return _setPrototypeOf(o, p);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
module.exports = _setPrototypeOf;
|
|
354
|
+
|
|
355
|
+
/***/ }),
|
|
356
|
+
|
|
357
|
+
/***/ "./node_modules/@babel/runtime/helpers/slicedToArray.js":
|
|
358
|
+
/*!**************************************************************!*\
|
|
359
|
+
!*** ./node_modules/@babel/runtime/helpers/slicedToArray.js ***!
|
|
360
|
+
\**************************************************************/
|
|
361
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
362
|
+
|
|
363
|
+
var arrayWithHoles = __webpack_require__(/*! ./arrayWithHoles */ "./node_modules/@babel/runtime/helpers/arrayWithHoles.js");
|
|
364
|
+
|
|
365
|
+
var iterableToArrayLimit = __webpack_require__(/*! ./iterableToArrayLimit */ "./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js");
|
|
366
|
+
|
|
367
|
+
var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray */ "./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js");
|
|
368
|
+
|
|
369
|
+
var nonIterableRest = __webpack_require__(/*! ./nonIterableRest */ "./node_modules/@babel/runtime/helpers/nonIterableRest.js");
|
|
370
|
+
|
|
371
|
+
function _slicedToArray(arr, i) {
|
|
372
|
+
return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
module.exports = _slicedToArray;
|
|
376
|
+
|
|
377
|
+
/***/ }),
|
|
378
|
+
|
|
379
|
+
/***/ "./node_modules/@babel/runtime/helpers/toConsumableArray.js":
|
|
380
|
+
/*!******************************************************************!*\
|
|
381
|
+
!*** ./node_modules/@babel/runtime/helpers/toConsumableArray.js ***!
|
|
382
|
+
\******************************************************************/
|
|
383
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
384
|
+
|
|
385
|
+
var arrayWithoutHoles = __webpack_require__(/*! ./arrayWithoutHoles */ "./node_modules/@babel/runtime/helpers/arrayWithoutHoles.js");
|
|
386
|
+
|
|
387
|
+
var iterableToArray = __webpack_require__(/*! ./iterableToArray */ "./node_modules/@babel/runtime/helpers/iterableToArray.js");
|
|
388
|
+
|
|
389
|
+
var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray */ "./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js");
|
|
390
|
+
|
|
391
|
+
var nonIterableSpread = __webpack_require__(/*! ./nonIterableSpread */ "./node_modules/@babel/runtime/helpers/nonIterableSpread.js");
|
|
392
|
+
|
|
393
|
+
function _toConsumableArray(arr) {
|
|
394
|
+
return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
module.exports = _toConsumableArray;
|
|
398
|
+
|
|
399
|
+
/***/ }),
|
|
400
|
+
|
|
401
|
+
/***/ "./node_modules/@babel/runtime/helpers/typeof.js":
|
|
402
|
+
/*!*******************************************************!*\
|
|
403
|
+
!*** ./node_modules/@babel/runtime/helpers/typeof.js ***!
|
|
404
|
+
\*******************************************************/
|
|
405
|
+
/***/ ((module) => {
|
|
406
|
+
|
|
407
|
+
function _typeof(obj) {
|
|
408
|
+
"@babel/helpers - typeof";
|
|
409
|
+
|
|
410
|
+
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
411
|
+
module.exports = _typeof = function _typeof(obj) {
|
|
412
|
+
return typeof obj;
|
|
413
|
+
};
|
|
414
|
+
} else {
|
|
415
|
+
module.exports = _typeof = function _typeof(obj) {
|
|
416
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
return _typeof(obj);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
module.exports = _typeof;
|
|
424
|
+
|
|
425
|
+
/***/ }),
|
|
426
|
+
|
|
427
|
+
/***/ "./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js":
|
|
428
|
+
/*!***************************************************************************!*\
|
|
429
|
+
!*** ./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***!
|
|
430
|
+
\***************************************************************************/
|
|
431
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
432
|
+
|
|
433
|
+
var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray */ "./node_modules/@babel/runtime/helpers/arrayLikeToArray.js");
|
|
434
|
+
|
|
435
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
436
|
+
if (!o) return;
|
|
437
|
+
if (typeof o === "string") return arrayLikeToArray(o, minLen);
|
|
438
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
439
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
440
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
441
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
module.exports = _unsupportedIterableToArray;
|
|
445
|
+
|
|
446
|
+
/***/ }),
|
|
447
|
+
|
|
448
|
+
/***/ "./lib/Logger.js":
|
|
449
|
+
/*!***********************!*\
|
|
450
|
+
!*** ./lib/Logger.js ***!
|
|
451
|
+
\***********************/
|
|
452
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
453
|
+
|
|
454
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));exports.registerLogger = registerLogger;exports.logInfo = logInfo;exports.logAlert = logAlert; // Logging callback
|
|
455
|
+
var logger = function logger() {};
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Register the logging callback
|
|
459
|
+
*
|
|
460
|
+
* @param {Function} callback
|
|
461
|
+
*/
|
|
462
|
+
function registerLogger(callback) {
|
|
463
|
+
logger = callback;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Send an alert message to the logger
|
|
468
|
+
*
|
|
469
|
+
* @param {String} message
|
|
470
|
+
*/
|
|
471
|
+
function logAlert(message) {
|
|
472
|
+
logger({ message: "[Onyx] " + message, level: 'alert' });
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Send an info message to the logger
|
|
477
|
+
*
|
|
478
|
+
* @param {String} message
|
|
479
|
+
*/
|
|
480
|
+
function logInfo(message) {
|
|
481
|
+
logger({ message: "[Onyx] " + message, level: 'info' });
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/***/ }),
|
|
485
|
+
|
|
486
|
+
/***/ "./lib/Onyx.js":
|
|
487
|
+
/*!*********************!*\
|
|
488
|
+
!*** ./lib/Onyx.js ***!
|
|
489
|
+
\*********************/
|
|
490
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
491
|
+
|
|
492
|
+
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 _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "./node_modules/@babel/runtime/helpers/slicedToArray.js"));var _toConsumableArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/toConsumableArray */ "./node_modules/@babel/runtime/helpers/toConsumableArray.js"));var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "./node_modules/@babel/runtime/helpers/defineProperty.js"));var _extends4 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/extends */ "./node_modules/@babel/runtime/helpers/extends.js"));var _underscore = _interopRequireDefault(__webpack_require__(/*! underscore */ "underscore"));
|
|
493
|
+
var _str = _interopRequireDefault(__webpack_require__(/*! expensify-common/lib/str */ "expensify-common/lib/str"));
|
|
494
|
+
var _merge = _interopRequireDefault(__webpack_require__(/*! lodash/merge */ "lodash/merge"));
|
|
495
|
+
var _storage = _interopRequireDefault(__webpack_require__(/*! ./storage */ "./lib/storage/index.web.js"));
|
|
496
|
+
|
|
497
|
+
var _Logger = __webpack_require__(/*! ./Logger */ "./lib/Logger.js");
|
|
498
|
+
var _OnyxCache = _interopRequireDefault(__webpack_require__(/*! ./OnyxCache */ "./lib/OnyxCache.js"));
|
|
499
|
+
var _createDeferredTask = _interopRequireDefault(__webpack_require__(/*! ./createDeferredTask */ "./lib/createDeferredTask.js"));
|
|
500
|
+
|
|
501
|
+
// Keeps track of the last connectionID that was used so we can keep incrementing it
|
|
502
|
+
var lastConnectionID = 0;
|
|
503
|
+
|
|
504
|
+
// Holds a mapping of all the react components that want their state subscribed to a store key
|
|
505
|
+
var callbackToStateMapping = {};
|
|
506
|
+
|
|
507
|
+
// Stores all of the keys that Onyx can use. Must be defined in init().
|
|
508
|
+
var onyxKeys = {};
|
|
509
|
+
|
|
510
|
+
// Holds a list of keys that have been directly subscribed to or recently modified from least to most recent
|
|
511
|
+
var recentlyAccessedKeys = [];
|
|
512
|
+
|
|
513
|
+
// Holds a list of keys that are safe to remove when we reach max storage. If a key does not match with
|
|
514
|
+
// whatever appears in this list it will NEVER be a candidate for eviction.
|
|
515
|
+
var evictionAllowList = [];
|
|
516
|
+
|
|
517
|
+
// Holds a map of keys and connectionID arrays whose keys will never be automatically evicted as
|
|
518
|
+
// long as we have at least one subscriber that returns false for the canEvict property.
|
|
519
|
+
var evictionBlocklist = {};
|
|
520
|
+
|
|
521
|
+
// Optional user-provided key value states set when Onyx initializes or clears
|
|
522
|
+
var defaultKeyStates = {};
|
|
523
|
+
|
|
524
|
+
// Connections can be made before `Onyx.init`. They would wait for this task before resolving
|
|
525
|
+
var deferredInitTask = (0, _createDeferredTask.default)();
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Get some data from the store
|
|
529
|
+
*
|
|
530
|
+
* @private
|
|
531
|
+
* @param {string} key
|
|
532
|
+
* @returns {Promise<*>}
|
|
533
|
+
*/
|
|
534
|
+
function get(key) {
|
|
535
|
+
// When we already have the value in cache - resolve right away
|
|
536
|
+
if (_OnyxCache.default.hasCacheForKey(key)) {
|
|
537
|
+
return Promise.resolve(_OnyxCache.default.getValue(key));
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
var taskName = "get:" + key;
|
|
541
|
+
|
|
542
|
+
// When a value retrieving task for this key is still running hook to it
|
|
543
|
+
if (_OnyxCache.default.hasPendingTask(taskName)) {
|
|
544
|
+
return _OnyxCache.default.getTaskPromise(taskName);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// Otherwise retrieve the value from storage and capture a promise to aid concurrent usages
|
|
548
|
+
var promise = _storage.default.getItem(key).
|
|
549
|
+
then(function (val) {
|
|
550
|
+
_OnyxCache.default.set(key, val);
|
|
551
|
+
return val;
|
|
552
|
+
}).
|
|
553
|
+
catch(function (err) {return (0, _Logger.logInfo)("Unable to get item from persistent storage. Key: " + key + " Error: " + err);});
|
|
554
|
+
|
|
555
|
+
return _OnyxCache.default.captureTask(taskName, promise);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Returns current key names stored in persisted storage
|
|
560
|
+
* @private
|
|
561
|
+
* @returns {Promise<string[]>}
|
|
562
|
+
*/
|
|
563
|
+
function getAllKeys() {
|
|
564
|
+
// When we've already read stored keys, resolve right away
|
|
565
|
+
var storedKeys = _OnyxCache.default.getAllKeys();
|
|
566
|
+
if (storedKeys.length > 0) {
|
|
567
|
+
return Promise.resolve(storedKeys);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
var taskName = 'getAllKeys';
|
|
571
|
+
|
|
572
|
+
// When a value retrieving task for all keys is still running hook to it
|
|
573
|
+
if (_OnyxCache.default.hasPendingTask(taskName)) {
|
|
574
|
+
return _OnyxCache.default.getTaskPromise(taskName);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// Otherwise retrieve the keys from storage and capture a promise to aid concurrent usages
|
|
578
|
+
var promise = _storage.default.getAllKeys().
|
|
579
|
+
then(function (keys) {
|
|
580
|
+
_underscore.default.each(keys, function (key) {return _OnyxCache.default.addKey(key);});
|
|
581
|
+
return keys;
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
return _OnyxCache.default.captureTask(taskName, promise);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Checks to see if the a subscriber's supplied key
|
|
589
|
+
* is associated with a collection of keys.
|
|
590
|
+
*
|
|
591
|
+
* @private
|
|
592
|
+
* @param {String} key
|
|
593
|
+
* @returns {Boolean}
|
|
594
|
+
*/
|
|
595
|
+
function isCollectionKey(key) {
|
|
596
|
+
return _underscore.default.contains(_underscore.default.values(onyxKeys.COLLECTION), key);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* Checks to see if a given key matches with the
|
|
601
|
+
* configured key of our connected subscriber
|
|
602
|
+
*
|
|
603
|
+
* @private
|
|
604
|
+
* @param {String} configKey
|
|
605
|
+
* @param {String} key
|
|
606
|
+
* @return {Boolean}
|
|
607
|
+
*/
|
|
608
|
+
function isKeyMatch(configKey, key) {
|
|
609
|
+
return isCollectionKey(configKey) ?
|
|
610
|
+
_str.default.startsWith(key, configKey) :
|
|
611
|
+
configKey === key;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Checks to see if this key has been flagged as
|
|
616
|
+
* safe for removal.
|
|
617
|
+
*
|
|
618
|
+
* @private
|
|
619
|
+
* @param {String} testKey
|
|
620
|
+
* @returns {Boolean}
|
|
621
|
+
*/
|
|
622
|
+
function isSafeEvictionKey(testKey) {
|
|
623
|
+
return _underscore.default.some(evictionAllowList, function (key) {return isKeyMatch(key, testKey);});
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* Remove a key from the recently accessed key list.
|
|
628
|
+
*
|
|
629
|
+
* @private
|
|
630
|
+
* @param {String} key
|
|
631
|
+
*/
|
|
632
|
+
function removeLastAccessedKey(key) {
|
|
633
|
+
recentlyAccessedKeys = _underscore.default.without(recentlyAccessedKeys, key);
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Add a key to the list of recently accessed keys. The least
|
|
638
|
+
* recently accessed key should be at the head and the most
|
|
639
|
+
* recently accessed key at the tail.
|
|
640
|
+
*
|
|
641
|
+
* @private
|
|
642
|
+
* @param {String} key
|
|
643
|
+
*/
|
|
644
|
+
function addLastAccessedKey(key) {
|
|
645
|
+
// Only specific keys belong in this list since we cannot remove an entire collection.
|
|
646
|
+
if (isCollectionKey(key) || !isSafeEvictionKey(key)) {
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
removeLastAccessedKey(key);
|
|
651
|
+
recentlyAccessedKeys.push(key);
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* Removes a key previously added to this list
|
|
656
|
+
* which will enable it to be deleted again.
|
|
657
|
+
*
|
|
658
|
+
* @private
|
|
659
|
+
* @param {String} key
|
|
660
|
+
* @param {Number} connectionID
|
|
661
|
+
*/
|
|
662
|
+
function removeFromEvictionBlockList(key, connectionID) {
|
|
663
|
+
evictionBlocklist[key] = _underscore.default.without(evictionBlocklist[key] || [], connectionID);
|
|
664
|
+
|
|
665
|
+
// Remove the key if there are no more subscribers
|
|
666
|
+
if (evictionBlocklist[key].length === 0) {
|
|
667
|
+
delete evictionBlocklist[key];
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Keys added to this list can never be deleted.
|
|
673
|
+
*
|
|
674
|
+
* @private
|
|
675
|
+
* @param {String} key
|
|
676
|
+
* @param {Number} connectionID
|
|
677
|
+
*/
|
|
678
|
+
function addToEvictionBlockList(key, connectionID) {
|
|
679
|
+
removeFromEvictionBlockList(key, connectionID);
|
|
680
|
+
|
|
681
|
+
if (!evictionBlocklist[key]) {
|
|
682
|
+
evictionBlocklist[key] = [];
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
evictionBlocklist[key].push(connectionID);
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Take all the keys that are safe to evict and add them to
|
|
690
|
+
* the recently accessed list when initializing the app. This
|
|
691
|
+
* enables keys that have not recently been accessed to be
|
|
692
|
+
* removed.
|
|
693
|
+
*
|
|
694
|
+
* @private
|
|
695
|
+
* @returns {Promise}
|
|
696
|
+
*/
|
|
697
|
+
function addAllSafeEvictionKeysToRecentlyAccessedList() {
|
|
698
|
+
return getAllKeys().
|
|
699
|
+
then(function (keys) {
|
|
700
|
+
_underscore.default.each(evictionAllowList, function (safeEvictionKey) {
|
|
701
|
+
_underscore.default.each(keys, function (key) {
|
|
702
|
+
if (isKeyMatch(safeEvictionKey, key)) {
|
|
703
|
+
addLastAccessedKey(key);
|
|
704
|
+
}
|
|
705
|
+
});
|
|
706
|
+
});
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* @private
|
|
712
|
+
* @param {String} collectionKey
|
|
713
|
+
* @returns {Object}
|
|
714
|
+
*/
|
|
715
|
+
function getCachedCollection(collectionKey) {
|
|
716
|
+
var collectionMemberKeys = _underscore.default.filter(_OnyxCache.default.getAllKeys(),
|
|
717
|
+
function (storedKey) {return isKeyMatch(collectionKey, storedKey);});
|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
return _underscore.default.reduce(collectionMemberKeys, function (prev, curr) {
|
|
721
|
+
var cachedValue = _OnyxCache.default.getValue(curr);
|
|
722
|
+
if (!cachedValue) {
|
|
723
|
+
return prev;
|
|
724
|
+
}
|
|
725
|
+
return (0, _extends4.default)({},
|
|
726
|
+
prev, (0, _defineProperty2.default)({},
|
|
727
|
+
curr, cachedValue));
|
|
728
|
+
|
|
729
|
+
}, {});
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* When a collection of keys change, search for any callbacks matching the collection key and trigger those callbacks
|
|
734
|
+
*
|
|
735
|
+
* @private
|
|
736
|
+
* @param {String} collectionKey
|
|
737
|
+
* @param {Object} collection
|
|
738
|
+
*/
|
|
739
|
+
function keysChanged(collectionKey, collection) {
|
|
740
|
+
// Find all subscribers that were added with connect() and trigger the callback or setState() with the new data
|
|
741
|
+
_underscore.default.each(callbackToStateMapping, function (subscriber) {
|
|
742
|
+
if (!subscriber) {
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
var isSubscribedToCollectionKey = isKeyMatch(subscriber.key, collectionKey) &&
|
|
747
|
+
isCollectionKey(subscriber.key);
|
|
748
|
+
var isSubscribedToCollectionMemberKey = subscriber.key.startsWith(collectionKey);
|
|
749
|
+
|
|
750
|
+
if (isSubscribedToCollectionKey) {
|
|
751
|
+
if (_underscore.default.isFunction(subscriber.callback)) {
|
|
752
|
+
// eslint-disable-next-line no-use-before-define
|
|
753
|
+
var cachedCollection = getCachedCollection(collectionKey);
|
|
754
|
+
_underscore.default.each(collection, function (data, dataKey) {
|
|
755
|
+
subscriber.callback(cachedCollection[dataKey], dataKey);
|
|
756
|
+
});
|
|
757
|
+
} else if (subscriber.withOnyxInstance) {
|
|
758
|
+
subscriber.withOnyxInstance.setState(function (prevState) {
|
|
759
|
+
var finalCollection = _underscore.default.clone(prevState[subscriber.statePropertyName] || {});
|
|
760
|
+
_underscore.default.each(collection, function (data, dataKey) {
|
|
761
|
+
if (finalCollection[dataKey]) {
|
|
762
|
+
(0, _merge.default)(finalCollection[dataKey], data);
|
|
763
|
+
} else {
|
|
764
|
+
finalCollection[dataKey] = data;
|
|
765
|
+
}
|
|
766
|
+
});
|
|
767
|
+
|
|
768
|
+
return (0, _defineProperty2.default)({},
|
|
769
|
+
subscriber.statePropertyName, finalCollection);
|
|
770
|
+
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
} else if (isSubscribedToCollectionMemberKey) {
|
|
774
|
+
var dataFromCollection = collection[subscriber.key];
|
|
775
|
+
|
|
776
|
+
// If `dataFromCollection` happens to not exist, then return early so that there are no unnecessary
|
|
777
|
+
// re-renderings of the component
|
|
778
|
+
if (_underscore.default.isUndefined(dataFromCollection)) {
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
subscriber.withOnyxInstance.setState(function (prevState) {return (0, _defineProperty2.default)({},
|
|
783
|
+
subscriber.statePropertyName, _underscore.default.isObject(dataFromCollection) ? (0, _extends4.default)({},
|
|
784
|
+
|
|
785
|
+
prevState[subscriber.statePropertyName],
|
|
786
|
+
dataFromCollection) :
|
|
787
|
+
|
|
788
|
+
dataFromCollection);});
|
|
789
|
+
|
|
790
|
+
}
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* When a key change happens, search for any callbacks matching the key or collection key and trigger those callbacks
|
|
796
|
+
*
|
|
797
|
+
* @private
|
|
798
|
+
* @param {String} key
|
|
799
|
+
* @param {*} data
|
|
800
|
+
*/
|
|
801
|
+
function keyChanged(key, data) {
|
|
802
|
+
// Add or remove this key from the recentlyAccessedKeys lists
|
|
803
|
+
if (!_underscore.default.isNull(data)) {
|
|
804
|
+
addLastAccessedKey(key);
|
|
805
|
+
} else {
|
|
806
|
+
removeLastAccessedKey(key);
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
// Find all subscribers that were added with connect() and trigger the callback or setState() with the new data
|
|
810
|
+
_underscore.default.each(callbackToStateMapping, function (subscriber) {
|
|
811
|
+
if (subscriber && isKeyMatch(subscriber.key, key)) {
|
|
812
|
+
if (_underscore.default.isFunction(subscriber.callback)) {
|
|
813
|
+
subscriber.callback(data, key);
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
if (!subscriber.withOnyxInstance) {
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
// Check if we are subscribing to a collection key and add this item as a collection
|
|
821
|
+
if (isCollectionKey(subscriber.key)) {
|
|
822
|
+
subscriber.withOnyxInstance.setState(function (prevState) {
|
|
823
|
+
var collection = _underscore.default.clone(prevState[subscriber.statePropertyName] || {});
|
|
824
|
+
collection[key] = data;
|
|
825
|
+
return (0, _defineProperty2.default)({},
|
|
826
|
+
subscriber.statePropertyName, collection);
|
|
827
|
+
|
|
828
|
+
});
|
|
829
|
+
} else {
|
|
830
|
+
subscriber.withOnyxInstance.setState((0, _defineProperty2.default)({},
|
|
831
|
+
subscriber.statePropertyName, data));
|
|
832
|
+
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* Sends the data obtained from the keys to the connection. It either:
|
|
840
|
+
* - sets state on the withOnyxInstances
|
|
841
|
+
* - triggers the callback function
|
|
842
|
+
*
|
|
843
|
+
* @private
|
|
844
|
+
* @param {object} config
|
|
845
|
+
* @param {object} [config.withOnyxInstance]
|
|
846
|
+
* @param {string} [config.statePropertyName]
|
|
847
|
+
* @param {function} [config.callback]
|
|
848
|
+
* @param {*|null} val
|
|
849
|
+
* @param {String} key
|
|
850
|
+
*/
|
|
851
|
+
function sendDataToConnection(config, val, key) {
|
|
852
|
+
// If the mapping no longer exists then we should not send any data.
|
|
853
|
+
// This means our subscriber disconnected or withOnyx wrapped component unmounted.
|
|
854
|
+
if (!callbackToStateMapping[config.connectionID]) {
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
if (config.withOnyxInstance) {
|
|
859
|
+
config.withOnyxInstance.setWithOnyxState(config.statePropertyName, val);
|
|
860
|
+
} else if (_underscore.default.isFunction(config.callback)) {
|
|
861
|
+
config.callback(val, key);
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
/**
|
|
866
|
+
* Subscribes a react component's state directly to a store key
|
|
867
|
+
*
|
|
868
|
+
* @example
|
|
869
|
+
* const connectionID = Onyx.connect({
|
|
870
|
+
* key: ONYXKEYS.SESSION,
|
|
871
|
+
* callback: onSessionChange,
|
|
872
|
+
* });
|
|
873
|
+
*
|
|
874
|
+
* @param {Object} mapping the mapping information to connect Onyx to the components state
|
|
875
|
+
* @param {String} mapping.key ONYXKEY to subscribe to
|
|
876
|
+
* @param {String} [mapping.statePropertyName] the name of the property in the state to connect the data to
|
|
877
|
+
* @param {Object} [mapping.withOnyxInstance] whose setState() method will be called with any changed data
|
|
878
|
+
* This is used by React components to connect to Onyx
|
|
879
|
+
* @param {Function} [mapping.callback] a method that will be called with changed data
|
|
880
|
+
* This is used by any non-React code to connect to Onyx
|
|
881
|
+
* @param {Boolean} [mapping.initWithStoredValues] If set to false, then no data will be prefilled into the
|
|
882
|
+
* component
|
|
883
|
+
* @returns {Number} an ID to use when calling disconnect
|
|
884
|
+
*/
|
|
885
|
+
function connect(mapping) {
|
|
886
|
+
var connectionID = lastConnectionID++;
|
|
887
|
+
callbackToStateMapping[connectionID] = mapping;
|
|
888
|
+
callbackToStateMapping[connectionID].connectionID = connectionID;
|
|
889
|
+
|
|
890
|
+
if (mapping.initWithStoredValues === false) {
|
|
891
|
+
return connectionID;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
// Commit connection only after init passes
|
|
895
|
+
deferredInitTask.promise.
|
|
896
|
+
then(function () {
|
|
897
|
+
// Check to see if this key is flagged as a safe eviction key and add it to the recentlyAccessedKeys list
|
|
898
|
+
if (isSafeEvictionKey(mapping.key)) {
|
|
899
|
+
// Try to free some cache whenever we connect to a safe eviction key
|
|
900
|
+
_OnyxCache.default.removeLeastRecentlyUsedKeys();
|
|
901
|
+
|
|
902
|
+
if (mapping.withOnyxInstance && !isCollectionKey(mapping.key)) {
|
|
903
|
+
// All React components subscribing to a key flagged as a safe eviction
|
|
904
|
+
// key must implement the canEvict property.
|
|
905
|
+
if (_underscore.default.isUndefined(mapping.canEvict)) {
|
|
906
|
+
throw new Error("Cannot subscribe to safe eviction key '" +
|
|
907
|
+
mapping.key + "' without providing a canEvict value.");
|
|
908
|
+
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
addLastAccessedKey(mapping.key);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
}).
|
|
915
|
+
then(getAllKeys).
|
|
916
|
+
then(function (keys) {
|
|
917
|
+
// Find all the keys matched by the config key
|
|
918
|
+
var matchingKeys = _underscore.default.filter(keys, function (key) {return isKeyMatch(mapping.key, key);});
|
|
919
|
+
|
|
920
|
+
// If the key being connected to does not exist, initialize the value with null
|
|
921
|
+
if (matchingKeys.length === 0) {
|
|
922
|
+
sendDataToConnection(mapping, null);
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
// When using a callback subscriber we will trigger the callback
|
|
927
|
+
// for each key we find. It's up to the subscriber to know whether
|
|
928
|
+
// to expect a single key or multiple keys in the case of a collection.
|
|
929
|
+
// React components are an exception since we'll want to send their
|
|
930
|
+
// initial data as a single object when using collection keys.
|
|
931
|
+
if (mapping.withOnyxInstance && isCollectionKey(mapping.key)) {
|
|
932
|
+
Promise.all(_underscore.default.map(matchingKeys, function (key) {return get(key);})).
|
|
933
|
+
then(function (values) {return _underscore.default.reduce(values, function (finalObject, value, i) {return (0, _extends4.default)({},
|
|
934
|
+
finalObject, (0, _defineProperty2.default)({},
|
|
935
|
+
matchingKeys[i], value));},
|
|
936
|
+
{});}).
|
|
937
|
+
then(function (val) {return sendDataToConnection(mapping, val);});
|
|
938
|
+
} else {
|
|
939
|
+
_underscore.default.each(matchingKeys, function (key) {
|
|
940
|
+
get(key).then(function (val) {return sendDataToConnection(mapping, val, key);});
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
});
|
|
944
|
+
|
|
945
|
+
return connectionID;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
* Remove the listener for a react component
|
|
950
|
+
* @example
|
|
951
|
+
* Onyx.disconnect(connectionID);
|
|
952
|
+
*
|
|
953
|
+
* @param {Number} connectionID unique id returned by call to Onyx.connect()
|
|
954
|
+
* @param {String} [keyToRemoveFromEvictionBlocklist]
|
|
955
|
+
*/
|
|
956
|
+
function disconnect(connectionID, keyToRemoveFromEvictionBlocklist) {
|
|
957
|
+
if (!callbackToStateMapping[connectionID]) {
|
|
958
|
+
return;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
// Remove this key from the eviction block list as we are no longer
|
|
962
|
+
// subscribing to it and it should be safe to delete again
|
|
963
|
+
if (keyToRemoveFromEvictionBlocklist) {
|
|
964
|
+
removeFromEvictionBlockList(keyToRemoveFromEvictionBlocklist, connectionID);
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
delete callbackToStateMapping[connectionID];
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
/**
|
|
971
|
+
* Remove a key from Onyx and update the subscribers
|
|
972
|
+
*
|
|
973
|
+
* @private
|
|
974
|
+
* @param {String} key
|
|
975
|
+
* @return {Promise}
|
|
976
|
+
*/
|
|
977
|
+
function remove(key) {
|
|
978
|
+
// Cache the fact that the value was removed
|
|
979
|
+
_OnyxCache.default.set(key, null);
|
|
980
|
+
|
|
981
|
+
// Optimistically inform subscribers on the next tick
|
|
982
|
+
Promise.resolve().then(function () {return keyChanged(key, null);});
|
|
983
|
+
|
|
984
|
+
return _storage.default.removeItem(key);
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
/**
|
|
988
|
+
* If we fail to set or merge we must handle this by
|
|
989
|
+
* evicting some data from Onyx and then retrying to do
|
|
990
|
+
* whatever it is we attempted to do.
|
|
991
|
+
*
|
|
992
|
+
* @private
|
|
993
|
+
* @param {Error} error
|
|
994
|
+
* @param {Function} onyxMethod
|
|
995
|
+
* @param {...any} args
|
|
996
|
+
* @return {Promise}
|
|
997
|
+
*/
|
|
998
|
+
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];}
|
|
999
|
+
(0, _Logger.logInfo)("Handled error: " + error);
|
|
1000
|
+
|
|
1001
|
+
if (error && _str.default.startsWith(error.message, 'Failed to execute \'put\' on \'IDBObjectStore\'')) {
|
|
1002
|
+
(0, _Logger.logAlert)('Attempted to set invalid data set in Onyx. Please ensure all data is serializable.');
|
|
1003
|
+
throw error;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
// Find the first key that we can remove that has no subscribers in our blocklist
|
|
1007
|
+
var keyForRemoval = _underscore.default.find(recentlyAccessedKeys, function (key) {return !evictionBlocklist[key];});
|
|
1008
|
+
|
|
1009
|
+
if (!keyForRemoval) {
|
|
1010
|
+
(0, _Logger.logAlert)('Out of storage. But found no acceptable keys to remove.');
|
|
1011
|
+
throw error;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
// Remove the least recently viewed key that is not currently being accessed and retry.
|
|
1015
|
+
(0, _Logger.logInfo)("Out of storage. Evicting least recently accessed key (" + keyForRemoval + ") and retrying.");
|
|
1016
|
+
return remove(keyForRemoval).
|
|
1017
|
+
then(function () {return onyxMethod.apply(void 0, args);});
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
/**
|
|
1021
|
+
* Write a value to our store with the given key
|
|
1022
|
+
*
|
|
1023
|
+
* @param {String} key ONYXKEY to set
|
|
1024
|
+
* @param {*} value value to store
|
|
1025
|
+
*
|
|
1026
|
+
* @returns {Promise}
|
|
1027
|
+
*/
|
|
1028
|
+
function set(key, value) {
|
|
1029
|
+
// Logging properties only since values could be sensitive things we don't want to log
|
|
1030
|
+
(0, _Logger.logInfo)("set() called for key: " + key + (_underscore.default.isObject(value) ? " properties: " + _underscore.default.keys(value).join(',') : ''));
|
|
1031
|
+
|
|
1032
|
+
// eslint-disable-next-line no-use-before-define
|
|
1033
|
+
if (hasPendingMergeForKey(key)) {
|
|
1034
|
+
// eslint-disable-next-line max-len
|
|
1035
|
+
(0, _Logger.logAlert)("Onyx.set() called after Onyx.merge() for key: " + key + ". It is recommended to use set() or merge() not both.");
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
// Adds the key to cache when it's not available
|
|
1039
|
+
_OnyxCache.default.set(key, value);
|
|
1040
|
+
|
|
1041
|
+
// Optimistically inform subscribers on the next tick
|
|
1042
|
+
Promise.resolve().then(function () {return keyChanged(key, value);});
|
|
1043
|
+
|
|
1044
|
+
// Write the thing to persistent storage, which will trigger a storage event for any other tabs open on this domain
|
|
1045
|
+
return _storage.default.setItem(key, value).
|
|
1046
|
+
catch(function (error) {return evictStorageAndRetry(error, set, key, value);});
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
/**
|
|
1050
|
+
* Storage expects array like: [["@MyApp_user", value_1], ["@MyApp_key", value_2]]
|
|
1051
|
+
* This method transforms an object like {'@MyApp_user': myUserValue, '@MyApp_key': myKeyValue}
|
|
1052
|
+
* to an array of key-value pairs in the above format
|
|
1053
|
+
* @private
|
|
1054
|
+
* @param {Record} data
|
|
1055
|
+
* @return {Array} an array of key - value pairs <[key, value]>
|
|
1056
|
+
*/
|
|
1057
|
+
function prepareKeyValuePairsForStorage(data) {
|
|
1058
|
+
return _underscore.default.map(data, function (value, key) {return [key, value];});
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
/**
|
|
1062
|
+
* Sets multiple keys and values
|
|
1063
|
+
*
|
|
1064
|
+
* @example Onyx.multiSet({'key1': 'a', 'key2': 'b'});
|
|
1065
|
+
*
|
|
1066
|
+
* @param {Object} data object keyed by ONYXKEYS and the values to set
|
|
1067
|
+
* @returns {Promise}
|
|
1068
|
+
*/
|
|
1069
|
+
function multiSet(data) {
|
|
1070
|
+
var keyValuePairs = prepareKeyValuePairsForStorage(data);
|
|
1071
|
+
|
|
1072
|
+
_underscore.default.each(data, function (val, key) {
|
|
1073
|
+
// Update cache and optimistically inform subscribers on the next tick
|
|
1074
|
+
_OnyxCache.default.set(key, val);
|
|
1075
|
+
Promise.resolve().then(function () {return keyChanged(key, val);});
|
|
1076
|
+
});
|
|
1077
|
+
|
|
1078
|
+
return _storage.default.multiSet(keyValuePairs).
|
|
1079
|
+
catch(function (error) {return evictStorageAndRetry(error, multiSet, data);});
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
// Key/value store of Onyx key and arrays of values to merge
|
|
1083
|
+
var mergeQueue = {};
|
|
1084
|
+
|
|
1085
|
+
/**
|
|
1086
|
+
* @private
|
|
1087
|
+
* @param {String} key
|
|
1088
|
+
* @returns {Boolean}
|
|
1089
|
+
*/
|
|
1090
|
+
function hasPendingMergeForKey(key) {
|
|
1091
|
+
return Boolean(mergeQueue[key]);
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
/**
|
|
1095
|
+
* Given an Onyx key and value this method will combine all queued
|
|
1096
|
+
* value updates and return a single value. Merge attempts are
|
|
1097
|
+
* batched. They must occur after a single call to get() so we
|
|
1098
|
+
* can avoid race conditions.
|
|
1099
|
+
*
|
|
1100
|
+
* @private
|
|
1101
|
+
* @param {String} key
|
|
1102
|
+
* @param {*} data
|
|
1103
|
+
*
|
|
1104
|
+
* @returns {*}
|
|
1105
|
+
*/
|
|
1106
|
+
function applyMerge(key, data) {
|
|
1107
|
+
var mergeValues = mergeQueue[key];
|
|
1108
|
+
if (_underscore.default.isArray(data) || _underscore.default.every(mergeValues, _underscore.default.isArray)) {
|
|
1109
|
+
// Array values will always just concatenate
|
|
1110
|
+
// more items onto the end of the array
|
|
1111
|
+
return _underscore.default.reduce(mergeValues, function (modifiedData, mergeValue) {return [].concat((0, _toConsumableArray2.default)(
|
|
1112
|
+
modifiedData), (0, _toConsumableArray2.default)(
|
|
1113
|
+
mergeValue));},
|
|
1114
|
+
data || []);
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
if (_underscore.default.isObject(data) || _underscore.default.every(mergeValues, _underscore.default.isObject)) {
|
|
1118
|
+
// Object values are merged one after the other
|
|
1119
|
+
return _underscore.default.reduce(mergeValues, function (modifiedData, mergeValue) {
|
|
1120
|
+
var newData = (0, _merge.default)({}, modifiedData, mergeValue);
|
|
1121
|
+
|
|
1122
|
+
// We will also delete any object keys that are undefined or null.
|
|
1123
|
+
// Deleting keys is not supported by AsyncStorage so we do it this way.
|
|
1124
|
+
// Remove all first level keys that are explicitly set to null.
|
|
1125
|
+
return _underscore.default.omit(newData, function (value, finalObjectKey) {return _underscore.default.isNull(mergeValue[finalObjectKey]);});
|
|
1126
|
+
}, data || {});
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
// If we have anything else we can't merge it so we'll
|
|
1130
|
+
// simply return the last value that was queued
|
|
1131
|
+
return _underscore.default.last(mergeValues);
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* Merge a new value into an existing value at a key.
|
|
1136
|
+
*
|
|
1137
|
+
* The types of values that can be merged are `Object` and `Array`. To set another type of value use `Onyx.set()`. Merge
|
|
1138
|
+
* behavior uses lodash/merge under the hood for `Object` and simple concatenation for `Array`. However, it's important
|
|
1139
|
+
* to note that if you have an array value property on an `Object` that the default behavior of lodash/merge is not to
|
|
1140
|
+
* concatenate. See here: https://github.com/lodash/lodash/issues/2872
|
|
1141
|
+
*
|
|
1142
|
+
* Calls to `Onyx.merge()` are batched so that any calls performed in a single tick will stack in a queue and get
|
|
1143
|
+
* applied in the order they were called. Note: `Onyx.set()` calls do not work this way so use caution when mixing
|
|
1144
|
+
* `Onyx.merge()` and `Onyx.set()`.
|
|
1145
|
+
*
|
|
1146
|
+
* @example
|
|
1147
|
+
* Onyx.merge(ONYXKEYS.EMPLOYEE_LIST, ['Joe']); // -> ['Joe']
|
|
1148
|
+
* Onyx.merge(ONYXKEYS.EMPLOYEE_LIST, ['Jack']); // -> ['Joe', 'Jack']
|
|
1149
|
+
* Onyx.merge(ONYXKEYS.POLICY, {id: 1}); // -> {id: 1}
|
|
1150
|
+
* Onyx.merge(ONYXKEYS.POLICY, {name: 'My Workspace'}); // -> {id: 1, name: 'My Workspace'}
|
|
1151
|
+
*
|
|
1152
|
+
* @param {String} key ONYXKEYS key
|
|
1153
|
+
* @param {(Object|Array)} value Object or Array value to merge
|
|
1154
|
+
* @returns {Promise}
|
|
1155
|
+
*/
|
|
1156
|
+
function merge(key, value) {
|
|
1157
|
+
if (mergeQueue[key]) {
|
|
1158
|
+
mergeQueue[key].push(value);
|
|
1159
|
+
return Promise.resolve();
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
mergeQueue[key] = [value];
|
|
1163
|
+
return get(key).
|
|
1164
|
+
then(function (data) {
|
|
1165
|
+
try {
|
|
1166
|
+
var modifiedData = applyMerge(key, data);
|
|
1167
|
+
|
|
1168
|
+
// Clean up the write queue so we
|
|
1169
|
+
// don't apply these changes again
|
|
1170
|
+
delete mergeQueue[key];
|
|
1171
|
+
|
|
1172
|
+
return set(key, modifiedData);
|
|
1173
|
+
} catch (error) {
|
|
1174
|
+
(0, _Logger.logAlert)("An error occurred while applying merge for key: " + key + ", Error: " + error);
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
return Promise.resolve();
|
|
1178
|
+
});
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
/**
|
|
1182
|
+
* Merge user provided default key value pairs.
|
|
1183
|
+
* @private
|
|
1184
|
+
* @returns {Promise}
|
|
1185
|
+
*/
|
|
1186
|
+
function initializeWithDefaultKeyStates() {
|
|
1187
|
+
return _storage.default.multiGet(_underscore.default.keys(defaultKeyStates)).
|
|
1188
|
+
then(function (pairs) {
|
|
1189
|
+
var asObject = _underscore.default.object(pairs);
|
|
1190
|
+
|
|
1191
|
+
var merged = (0, _merge.default)(asObject, defaultKeyStates);
|
|
1192
|
+
_OnyxCache.default.merge(merged);
|
|
1193
|
+
_underscore.default.each(merged, function (val, key) {return keyChanged(key, val);});
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
/**
|
|
1198
|
+
* Clear out all the data in the store
|
|
1199
|
+
*
|
|
1200
|
+
* @returns {Promise<void>}
|
|
1201
|
+
*/
|
|
1202
|
+
function clear() {
|
|
1203
|
+
return getAllKeys().
|
|
1204
|
+
then(function (keys) {
|
|
1205
|
+
_underscore.default.each(keys, function (key) {
|
|
1206
|
+
keyChanged(key, null);
|
|
1207
|
+
_OnyxCache.default.set(key, null);
|
|
1208
|
+
});
|
|
1209
|
+
}).
|
|
1210
|
+
then(_storage.default.clear).
|
|
1211
|
+
then(initializeWithDefaultKeyStates);
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
/**
|
|
1215
|
+
* Merges a collection based on their keys
|
|
1216
|
+
*
|
|
1217
|
+
* @example
|
|
1218
|
+
*
|
|
1219
|
+
* Onyx.mergeCollection(ONYXKEYS.COLLECTION.REPORT, {
|
|
1220
|
+
* [`${ONYXKEYS.COLLECTION.REPORT}1`]: report1,
|
|
1221
|
+
* [`${ONYXKEYS.COLLECTION.REPORT}2`]: report2,
|
|
1222
|
+
* });
|
|
1223
|
+
*
|
|
1224
|
+
* @param {String} collectionKey e.g. `ONYXKEYS.COLLECTION.REPORT`
|
|
1225
|
+
* @param {Object} collection Object collection keyed by individual collection member keys and values
|
|
1226
|
+
* @returns {Promise}
|
|
1227
|
+
*/
|
|
1228
|
+
function mergeCollection(collectionKey, collection) {
|
|
1229
|
+
// Confirm all the collection keys belong to the same parent
|
|
1230
|
+
_underscore.default.each(collection, function (data, dataKey) {
|
|
1231
|
+
if (!isKeyMatch(collectionKey, dataKey)) {
|
|
1232
|
+
// eslint-disable-next-line max-len
|
|
1233
|
+
throw new Error("Provided collection does not have all its data belonging to the same parent. CollectionKey: " + collectionKey + ", DataKey: " + dataKey);
|
|
1234
|
+
}
|
|
1235
|
+
});
|
|
1236
|
+
|
|
1237
|
+
return getAllKeys().
|
|
1238
|
+
then(function (persistedKeys) {
|
|
1239
|
+
// Split to keys that exist in storage and keys that don't
|
|
1240
|
+
var _$chain$keys$partitio = _underscore.default.chain(collection).
|
|
1241
|
+
keys().
|
|
1242
|
+
partition(function (key) {return persistedKeys.includes(key);}).
|
|
1243
|
+
value(),_$chain$keys$partitio2 = (0, _slicedToArray2.default)(_$chain$keys$partitio, 2),existingKeys = _$chain$keys$partitio2[0],newKeys = _$chain$keys$partitio2[1];
|
|
1244
|
+
|
|
1245
|
+
var existingKeyCollection = _underscore.default.pick(collection, existingKeys);
|
|
1246
|
+
var newCollection = _underscore.default.pick(collection, newKeys);
|
|
1247
|
+
var keyValuePairsForExistingCollection = prepareKeyValuePairsForStorage(existingKeyCollection);
|
|
1248
|
+
var keyValuePairsForNewCollection = prepareKeyValuePairsForStorage(newCollection);
|
|
1249
|
+
|
|
1250
|
+
var promises = [];
|
|
1251
|
+
|
|
1252
|
+
// New keys will be added via multiSet while existing keys will be updated using multiMerge
|
|
1253
|
+
// This is because setting a key that doesn't exist yet with multiMerge will throw errors
|
|
1254
|
+
if (keyValuePairsForExistingCollection.length > 0) {
|
|
1255
|
+
promises.push(_storage.default.multiMerge(keyValuePairsForExistingCollection));
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
if (keyValuePairsForNewCollection.length > 0) {
|
|
1259
|
+
promises.push(_storage.default.multiSet(keyValuePairsForNewCollection));
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
// Prefill cache if necessary by calling get() on any existing keys and then merge original data to cache
|
|
1263
|
+
// and update all subscribers
|
|
1264
|
+
Promise.all(_underscore.default.map(existingKeys, get)).then(function () {
|
|
1265
|
+
_OnyxCache.default.merge(collection);
|
|
1266
|
+
keysChanged(collectionKey, collection);
|
|
1267
|
+
});
|
|
1268
|
+
|
|
1269
|
+
return Promise.all(promises).
|
|
1270
|
+
catch(function (error) {return evictStorageAndRetry(error, mergeCollection, collection);});
|
|
1271
|
+
});
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* Initialize the store with actions and listening for storage events
|
|
1276
|
+
*
|
|
1277
|
+
* @param {Object} [options={}] config object
|
|
1278
|
+
* @param {Object} [options.keys={}] `ONYXKEYS` constants object
|
|
1279
|
+
* @param {Object} [options.initialKeyStates={}] initial data to set when `init()` and `clear()` is called
|
|
1280
|
+
* @param {String[]} [options.safeEvictionKeys=[]] This is an array of keys
|
|
1281
|
+
* (individual or collection patterns) that when provided to Onyx are flagged
|
|
1282
|
+
* as "safe" for removal. Any components subscribing to these keys must also
|
|
1283
|
+
* implement a canEvict option. See the README for more info.
|
|
1284
|
+
* @param {Number} [options.maxCachedKeysCount=55] Sets how many recent keys should we try to keep in cache
|
|
1285
|
+
* Setting this to 0 would practically mean no cache
|
|
1286
|
+
* We try to free cache when we connect to a safe eviction key
|
|
1287
|
+
* @param {Boolean} [options.captureMetrics] Enables Onyx benchmarking and exposes the get/print/reset functions
|
|
1288
|
+
* @param {Boolean} [options.shouldSyncMultipleInstances] Auto synchronize storage events between multiple instances
|
|
1289
|
+
* of Onyx running in different tabs/windows. Defaults to true for platforms that support local storage (web/desktop)
|
|
1290
|
+
* @param {String[]} [option.keysToDisableSyncEvents=[]] Contains keys for which
|
|
1291
|
+
* we want to disable sync event across tabs.
|
|
1292
|
+
* @example
|
|
1293
|
+
* Onyx.init({
|
|
1294
|
+
* keys: ONYXKEYS,
|
|
1295
|
+
* initialKeyStates: {
|
|
1296
|
+
* [ONYXKEYS.SESSION]: {loading: false},
|
|
1297
|
+
* },
|
|
1298
|
+
* });
|
|
1299
|
+
*/
|
|
1300
|
+
function init()
|
|
1301
|
+
|
|
1302
|
+
|
|
1303
|
+
|
|
1304
|
+
|
|
1305
|
+
|
|
1306
|
+
|
|
1307
|
+
|
|
1308
|
+
{var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},_ref4$keys = _ref4.keys,keys = _ref4$keys === void 0 ? {} : _ref4$keys,_ref4$initialKeyState = _ref4.initialKeyStates,initialKeyStates = _ref4$initialKeyState === void 0 ? {} : _ref4$initialKeyState,_ref4$safeEvictionKey = _ref4.safeEvictionKeys,safeEvictionKeys = _ref4$safeEvictionKey === void 0 ? [] : _ref4$safeEvictionKey,_ref4$maxCachedKeysCo = _ref4.maxCachedKeysCount,maxCachedKeysCount = _ref4$maxCachedKeysCo === void 0 ? 1000 : _ref4$maxCachedKeysCo,_ref4$captureMetrics = _ref4.captureMetrics,captureMetrics = _ref4$captureMetrics === void 0 ? false : _ref4$captureMetrics,_ref4$shouldSyncMulti = _ref4.shouldSyncMultipleInstances,shouldSyncMultipleInstances = _ref4$shouldSyncMulti === void 0 ? Boolean(__webpack_require__.g.localStorage) : _ref4$shouldSyncMulti,_ref4$keysToDisableSy = _ref4.keysToDisableSyncEvents,keysToDisableSyncEvents = _ref4$keysToDisableSy === void 0 ? [] : _ref4$keysToDisableSy;
|
|
1309
|
+
if (captureMetrics) {
|
|
1310
|
+
// The code here is only bundled and applied when the captureMetrics is set
|
|
1311
|
+
// eslint-disable-next-line no-use-before-define
|
|
1312
|
+
applyDecorators();
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
if (maxCachedKeysCount > 0) {
|
|
1316
|
+
_OnyxCache.default.setRecentKeysLimit(maxCachedKeysCount);
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
// Let Onyx know about all of our keys
|
|
1320
|
+
onyxKeys = keys;
|
|
1321
|
+
|
|
1322
|
+
// Set our default key states to use when initializing and clearing Onyx data
|
|
1323
|
+
defaultKeyStates = initialKeyStates;
|
|
1324
|
+
|
|
1325
|
+
// Let Onyx know about which keys are safe to evict
|
|
1326
|
+
evictionAllowList = safeEvictionKeys;
|
|
1327
|
+
|
|
1328
|
+
// Initialize all of our keys with data provided then give green light to any pending connections
|
|
1329
|
+
Promise.all([
|
|
1330
|
+
addAllSafeEvictionKeysToRecentlyAccessedList(),
|
|
1331
|
+
initializeWithDefaultKeyStates()]).
|
|
1332
|
+
|
|
1333
|
+
then(deferredInitTask.resolve);
|
|
1334
|
+
|
|
1335
|
+
if (shouldSyncMultipleInstances && _underscore.default.isFunction(_storage.default.keepInstancesSync)) {
|
|
1336
|
+
_storage.default.keepInstancesSync(keysToDisableSyncEvents, function (key, value) {
|
|
1337
|
+
_OnyxCache.default.set(key, value);
|
|
1338
|
+
keyChanged(key, value);
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
var Onyx = {
|
|
1344
|
+
connect: connect,
|
|
1345
|
+
disconnect: disconnect,
|
|
1346
|
+
set: set,
|
|
1347
|
+
multiSet: multiSet,
|
|
1348
|
+
merge: merge,
|
|
1349
|
+
mergeCollection: mergeCollection,
|
|
1350
|
+
clear: clear,
|
|
1351
|
+
init: init,
|
|
1352
|
+
registerLogger: _Logger.registerLogger,
|
|
1353
|
+
addToEvictionBlockList: addToEvictionBlockList,
|
|
1354
|
+
removeFromEvictionBlockList: removeFromEvictionBlockList,
|
|
1355
|
+
isSafeEvictionKey: isSafeEvictionKey };
|
|
1356
|
+
|
|
1357
|
+
|
|
1358
|
+
/**
|
|
1359
|
+
* Apply calls statistic decorators to benchmark Onyx
|
|
1360
|
+
*
|
|
1361
|
+
* @private
|
|
1362
|
+
*/
|
|
1363
|
+
function applyDecorators() {
|
|
1364
|
+
// We're requiring the script dynamically here so that it's only evaluated when decorators are used
|
|
1365
|
+
var decorate = __webpack_require__(/*! ./metrics */ "./lib/metrics/index.web.js");
|
|
1366
|
+
|
|
1367
|
+
// Re-assign with decorated functions
|
|
1368
|
+
/* eslint-disable no-func-assign */
|
|
1369
|
+
get = decorate.decorateWithMetrics(get, 'Onyx:get');
|
|
1370
|
+
set = decorate.decorateWithMetrics(set, 'Onyx:set');
|
|
1371
|
+
multiSet = decorate.decorateWithMetrics(multiSet, 'Onyx:multiSet');
|
|
1372
|
+
clear = decorate.decorateWithMetrics(clear, 'Onyx:clear');
|
|
1373
|
+
merge = decorate.decorateWithMetrics(merge, 'Onyx:merge');
|
|
1374
|
+
mergeCollection = decorate.decorateWithMetrics(mergeCollection, 'Onyx:mergeCollection');
|
|
1375
|
+
getAllKeys = decorate.decorateWithMetrics(getAllKeys, 'Onyx:getAllKeys');
|
|
1376
|
+
initializeWithDefaultKeyStates = decorate.decorateWithMetrics(initializeWithDefaultKeyStates, 'Onyx:defaults');
|
|
1377
|
+
/* eslint-enable */
|
|
1378
|
+
|
|
1379
|
+
// Re-expose decorated methods
|
|
1380
|
+
Onyx.set = set;
|
|
1381
|
+
Onyx.multiSet = multiSet;
|
|
1382
|
+
Onyx.clear = clear;
|
|
1383
|
+
Onyx.merge = merge;
|
|
1384
|
+
Onyx.mergeCollection = mergeCollection;
|
|
1385
|
+
|
|
1386
|
+
// Expose stats methods on Onyx
|
|
1387
|
+
Onyx.getMetrics = decorate.getMetrics;
|
|
1388
|
+
Onyx.resetMetrics = decorate.resetMetrics;
|
|
1389
|
+
Onyx.printMetrics = decorate.printMetrics;
|
|
1390
|
+
}var _default =
|
|
1391
|
+
|
|
1392
|
+
Onyx;exports["default"] = _default;
|
|
1393
|
+
|
|
1394
|
+
/***/ }),
|
|
1395
|
+
|
|
1396
|
+
/***/ "./lib/OnyxCache.js":
|
|
1397
|
+
/*!**************************!*\
|
|
1398
|
+
!*** ./lib/OnyxCache.js ***!
|
|
1399
|
+
\**************************/
|
|
1400
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1401
|
+
|
|
1402
|
+
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"));
|
|
1403
|
+
var _merge = _interopRequireDefault(__webpack_require__(/*! lodash/merge */ "lodash/merge"));
|
|
1404
|
+
|
|
1405
|
+
|
|
1406
|
+
var isDefined = _underscore.default.negate(_underscore.default.isUndefined);
|
|
1407
|
+
|
|
1408
|
+
/**
|
|
1409
|
+
* In memory cache providing data by reference
|
|
1410
|
+
* Encapsulates Onyx cache related functionality
|
|
1411
|
+
*/var
|
|
1412
|
+
OnyxCache = /*#__PURE__*/function () {
|
|
1413
|
+
function OnyxCache() {(0, _classCallCheck2.default)(this, OnyxCache);
|
|
1414
|
+
/**
|
|
1415
|
+
* @private
|
|
1416
|
+
* Cache of all the storage keys available in persistent storage
|
|
1417
|
+
* @type {Set<string>}
|
|
1418
|
+
*/
|
|
1419
|
+
this.storageKeys = new Set();
|
|
1420
|
+
|
|
1421
|
+
/**
|
|
1422
|
+
* @private
|
|
1423
|
+
* Unique list of keys maintained in access order (most recent at the end)
|
|
1424
|
+
* @type {Set<string>}
|
|
1425
|
+
*/
|
|
1426
|
+
this.recentKeys = new Set();
|
|
1427
|
+
|
|
1428
|
+
/**
|
|
1429
|
+
* @private
|
|
1430
|
+
* A map of cached values
|
|
1431
|
+
* @type {Record<string, *>}
|
|
1432
|
+
*/
|
|
1433
|
+
this.storageMap = {};
|
|
1434
|
+
|
|
1435
|
+
/**
|
|
1436
|
+
* @private
|
|
1437
|
+
* Captured pending tasks for already running storage methods
|
|
1438
|
+
* @type {Record<string, Promise>}
|
|
1439
|
+
*/
|
|
1440
|
+
this.pendingPromises = {};
|
|
1441
|
+
|
|
1442
|
+
// bind all public methods to prevent problems with `this`
|
|
1443
|
+
_underscore.default.bindAll(
|
|
1444
|
+
this,
|
|
1445
|
+
'getAllKeys', 'getValue', 'hasCacheForKey', 'addKey', 'set', 'drop', 'merge',
|
|
1446
|
+
'hasPendingTask', 'getTaskPromise', 'captureTask', 'removeLeastRecentlyUsedKeys',
|
|
1447
|
+
'setRecentKeysLimit');
|
|
1448
|
+
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
/**
|
|
1452
|
+
* Get all the storage keys
|
|
1453
|
+
* @returns {string[]}
|
|
1454
|
+
*/(0, _createClass2.default)(OnyxCache, [{ key: "getAllKeys", value: function getAllKeys()
|
|
1455
|
+
{
|
|
1456
|
+
return Array.from(this.storageKeys);
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
/**
|
|
1460
|
+
* Get a cached value from storage
|
|
1461
|
+
* @param {string} key
|
|
1462
|
+
* @returns {*}
|
|
1463
|
+
*/ }, { key: "getValue", value: function getValue(
|
|
1464
|
+
key) {
|
|
1465
|
+
this.addToAccessedKeys(key);
|
|
1466
|
+
return this.storageMap[key];
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
/**
|
|
1470
|
+
* Check whether cache has data for the given key
|
|
1471
|
+
* @param {string} key
|
|
1472
|
+
* @returns {boolean}
|
|
1473
|
+
*/ }, { key: "hasCacheForKey", value: function hasCacheForKey(
|
|
1474
|
+
key) {
|
|
1475
|
+
return isDefined(this.storageMap[key]);
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
/**
|
|
1479
|
+
* Saves a key in the storage keys list
|
|
1480
|
+
* Serves to keep the result of `getAllKeys` up to date
|
|
1481
|
+
* @param {string} key
|
|
1482
|
+
*/ }, { key: "addKey", value: function addKey(
|
|
1483
|
+
key) {
|
|
1484
|
+
this.storageKeys.add(key);
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
/**
|
|
1488
|
+
* Set's a key value in cache
|
|
1489
|
+
* Adds the key to the storage keys list as well
|
|
1490
|
+
* @param {string} key
|
|
1491
|
+
* @param {*} value
|
|
1492
|
+
* @returns {*} value - returns the cache value
|
|
1493
|
+
*/ }, { key: "set", value: function set(
|
|
1494
|
+
key, value) {
|
|
1495
|
+
this.addKey(key);
|
|
1496
|
+
this.addToAccessedKeys(key);
|
|
1497
|
+
this.storageMap[key] = value;
|
|
1498
|
+
|
|
1499
|
+
return value;
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
/**
|
|
1503
|
+
* Forget the cached value for the given key
|
|
1504
|
+
* @param {string} key
|
|
1505
|
+
*/ }, { key: "drop", value: function drop(
|
|
1506
|
+
key) {
|
|
1507
|
+
delete this.storageMap[key];
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
/**
|
|
1511
|
+
* Deep merge data to cache, any non existing keys will be created
|
|
1512
|
+
* @param {Record<string, *>} data - a map of (cache) key - values
|
|
1513
|
+
*/ }, { key: "merge", value: function merge(
|
|
1514
|
+
data) {var _this = this;
|
|
1515
|
+
this.storageMap = (0, _merge.default)({}, this.storageMap, data);
|
|
1516
|
+
|
|
1517
|
+
var storageKeys = this.getAllKeys();
|
|
1518
|
+
var mergedKeys = _underscore.default.keys(data);
|
|
1519
|
+
this.storageKeys = new Set([].concat((0, _toConsumableArray2.default)(storageKeys), (0, _toConsumableArray2.default)(mergedKeys)));
|
|
1520
|
+
_underscore.default.each(mergedKeys, function (key) {return _this.addToAccessedKeys(key);});
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
/**
|
|
1524
|
+
* Check whether the given task is already running
|
|
1525
|
+
* @param {string} taskName - unique name given for the task
|
|
1526
|
+
* @returns {*}
|
|
1527
|
+
*/ }, { key: "hasPendingTask", value: function hasPendingTask(
|
|
1528
|
+
taskName) {
|
|
1529
|
+
return isDefined(this.pendingPromises[taskName]);
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
/**
|
|
1533
|
+
* Use this method to prevent concurrent calls for the same thing
|
|
1534
|
+
* Instead of calling the same task again use the existing promise
|
|
1535
|
+
* provided from this function
|
|
1536
|
+
* @template T
|
|
1537
|
+
* @param {string} taskName - unique name given for the task
|
|
1538
|
+
* @returns {Promise<T>}
|
|
1539
|
+
*/ }, { key: "getTaskPromise", value: function getTaskPromise(
|
|
1540
|
+
taskName) {
|
|
1541
|
+
return this.pendingPromises[taskName];
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
/**
|
|
1545
|
+
* Capture a promise for a given task so other caller can
|
|
1546
|
+
* hook up to the promise if it's still pending
|
|
1547
|
+
* @template T
|
|
1548
|
+
* @param {string} taskName - unique name for the task
|
|
1549
|
+
* @param {Promise<T>} promise
|
|
1550
|
+
* @returns {Promise<T>}
|
|
1551
|
+
*/ }, { key: "captureTask", value: function captureTask(
|
|
1552
|
+
taskName, promise) {var _this2 = this;
|
|
1553
|
+
this.pendingPromises[taskName] = promise.finally(function () {
|
|
1554
|
+
delete _this2.pendingPromises[taskName];
|
|
1555
|
+
});
|
|
1556
|
+
|
|
1557
|
+
return this.pendingPromises[taskName];
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
/**
|
|
1561
|
+
* @private
|
|
1562
|
+
* Adds a key to the top of the recently accessed keys
|
|
1563
|
+
* @param {string} key
|
|
1564
|
+
*/ }, { key: "addToAccessedKeys", value: function addToAccessedKeys(
|
|
1565
|
+
key) {
|
|
1566
|
+
// Removing and re-adding a key ensures it's at the end of the list
|
|
1567
|
+
this.recentKeys.delete(key);
|
|
1568
|
+
this.recentKeys.add(key);
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
/**
|
|
1572
|
+
* Remove keys that don't fall into the range of recently used keys
|
|
1573
|
+
*/ }, { key: "removeLeastRecentlyUsedKeys", value: function removeLeastRecentlyUsedKeys()
|
|
1574
|
+
{
|
|
1575
|
+
if (this.recentKeys.size > this.maxRecentKeysSize) {
|
|
1576
|
+
// Get the last N keys by doing a negative slice
|
|
1577
|
+
var recentlyAccessed = (0, _toConsumableArray2.default)(this.recentKeys).slice(-this.maxRecentKeysSize);
|
|
1578
|
+
var storageKeys = _underscore.default.keys(this.storageMap);
|
|
1579
|
+
var keysToRemove = _underscore.default.difference(storageKeys, recentlyAccessed);
|
|
1580
|
+
|
|
1581
|
+
_underscore.default.each(keysToRemove, this.drop);
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
/**
|
|
1586
|
+
* Set the recent keys list size
|
|
1587
|
+
* @param {number} limit
|
|
1588
|
+
*/ }, { key: "setRecentKeysLimit", value: function setRecentKeysLimit(
|
|
1589
|
+
limit) {
|
|
1590
|
+
this.maxRecentKeysSize = limit;
|
|
1591
|
+
} }]);return OnyxCache;}();
|
|
1592
|
+
|
|
1593
|
+
|
|
1594
|
+
var instance = new OnyxCache();var _default =
|
|
1595
|
+
|
|
1596
|
+
instance;exports["default"] = _default;
|
|
1597
|
+
|
|
1598
|
+
/***/ }),
|
|
1599
|
+
|
|
1600
|
+
/***/ "./lib/SyncQueue.js":
|
|
1601
|
+
/*!**************************!*\
|
|
1602
|
+
!*** ./lib/SyncQueue.js ***!
|
|
1603
|
+
\**************************/
|
|
1604
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1605
|
+
|
|
1606
|
+
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 _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")); /**
|
|
1607
|
+
* Synchronous queue that can be used to ensure promise based tasks are run in sequence.
|
|
1608
|
+
* Pass to the constructor a function that returns a promise to run the task then add data.
|
|
1609
|
+
*
|
|
1610
|
+
* @example
|
|
1611
|
+
*
|
|
1612
|
+
* const queue = new SyncQueue(({key, val}) => {
|
|
1613
|
+
* return someAsyncProcess(key, val);
|
|
1614
|
+
* });
|
|
1615
|
+
*
|
|
1616
|
+
* queue.push({key: 1, val: '1'});
|
|
1617
|
+
* queue.push({key: 2, val: '2'});
|
|
1618
|
+
*/var
|
|
1619
|
+
SyncQueue = /*#__PURE__*/function () {
|
|
1620
|
+
/**
|
|
1621
|
+
* @param {Function} run - must return a promise
|
|
1622
|
+
*/
|
|
1623
|
+
function SyncQueue(run) {(0, _classCallCheck2.default)(this, SyncQueue);
|
|
1624
|
+
this.queue = [];
|
|
1625
|
+
this.isProcessing = false;
|
|
1626
|
+
this.run = run;
|
|
1627
|
+
}(0, _createClass2.default)(SyncQueue, [{ key: "process", value: function process()
|
|
1628
|
+
|
|
1629
|
+
{var _this = this;
|
|
1630
|
+
if (this.isProcessing || this.queue.length === 0) {
|
|
1631
|
+
return;
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
this.isProcessing = true;var _this$queue$shift =
|
|
1635
|
+
|
|
1636
|
+
this.queue.shift(),data = _this$queue$shift.data,resolve = _this$queue$shift.resolve,reject = _this$queue$shift.reject;
|
|
1637
|
+
this.run(data).
|
|
1638
|
+
then(resolve).
|
|
1639
|
+
catch(reject).
|
|
1640
|
+
finally(function () {
|
|
1641
|
+
_this.isProcessing = false;
|
|
1642
|
+
_this.process();
|
|
1643
|
+
});
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
/**
|
|
1647
|
+
* @param {*} data
|
|
1648
|
+
* @returns {Promise}
|
|
1649
|
+
*/ }, { key: "push", value: function push(
|
|
1650
|
+
data) {var _this2 = this;
|
|
1651
|
+
return new Promise(function (resolve, reject) {
|
|
1652
|
+
_this2.queue.push({ resolve: resolve, reject: reject, data: data });
|
|
1653
|
+
_this2.process();
|
|
1654
|
+
});
|
|
1655
|
+
} }]);return SyncQueue;}();exports["default"] = SyncQueue;
|
|
1656
|
+
|
|
1657
|
+
/***/ }),
|
|
1658
|
+
|
|
1659
|
+
/***/ "./lib/createDeferredTask.js":
|
|
1660
|
+
/*!***********************************!*\
|
|
1661
|
+
!*** ./lib/createDeferredTask.js ***!
|
|
1662
|
+
\***********************************/
|
|
1663
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
1664
|
+
|
|
1665
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));exports["default"] = createDeferredTask; /**
|
|
1666
|
+
* Create a deferred task that can be resolved when we call `resolve()`
|
|
1667
|
+
* The returned promise will complete when we call `resolve`
|
|
1668
|
+
* Useful when we want to wait for a tasks that is resolved from an external action
|
|
1669
|
+
*
|
|
1670
|
+
* @template T
|
|
1671
|
+
* @returns {{ resolve: function(*), promise: Promise<T|void> }}
|
|
1672
|
+
*/
|
|
1673
|
+
function createDeferredTask() {
|
|
1674
|
+
var deferred = {};
|
|
1675
|
+
deferred.promise = new Promise(function (res) {
|
|
1676
|
+
deferred.resolve = res;
|
|
1677
|
+
});
|
|
1678
|
+
|
|
1679
|
+
return deferred;
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
/***/ }),
|
|
1683
|
+
|
|
1684
|
+
/***/ "./lib/metrics/index.web.js":
|
|
1685
|
+
/*!**********************************!*\
|
|
1686
|
+
!*** ./lib/metrics/index.web.js ***!
|
|
1687
|
+
\**********************************/
|
|
1688
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
1689
|
+
|
|
1690
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));exports.decorateWithMetrics = decorateWithMetrics;exports.getMetrics = getMetrics;exports.resetMetrics = resetMetrics;exports.printMetrics = printMetrics; // For web-only implementations of Onyx, this module will just be a no-op
|
|
1691
|
+
|
|
1692
|
+
function decorateWithMetrics() {}
|
|
1693
|
+
function getMetrics() {}
|
|
1694
|
+
function printMetrics() {}
|
|
1695
|
+
function resetMetrics() {}
|
|
1696
|
+
|
|
1697
|
+
/***/ }),
|
|
1698
|
+
|
|
1699
|
+
/***/ "./lib/storage/WebStorage.js":
|
|
1700
|
+
/*!***********************************!*\
|
|
1701
|
+
!*** ./lib/storage/WebStorage.js ***!
|
|
1702
|
+
\***********************************/
|
|
1703
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1704
|
+
|
|
1705
|
+
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 _extends2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/extends */ "./node_modules/@babel/runtime/helpers/extends.js"));var _underscore = _interopRequireDefault(__webpack_require__(/*! underscore */ "underscore"));
|
|
1706
|
+
var _LocalForage = _interopRequireDefault(__webpack_require__(/*! ./providers/LocalForage */ "./lib/storage/providers/LocalForage.js"));
|
|
1707
|
+
|
|
1708
|
+
var SYNC_ONYX = 'SYNC_ONYX';
|
|
1709
|
+
|
|
1710
|
+
/**
|
|
1711
|
+
* Raise an event thorough `localStorage` to let other tabs know a value changed
|
|
1712
|
+
* @param {String} onyxKey
|
|
1713
|
+
*/
|
|
1714
|
+
function raiseStorageSyncEvent(onyxKey) {
|
|
1715
|
+
__webpack_require__.g.localStorage.setItem(SYNC_ONYX, onyxKey);
|
|
1716
|
+
__webpack_require__.g.localStorage.removeItem(SYNC_ONYX, onyxKey);
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
var webStorage = (0, _extends2.default)({},
|
|
1720
|
+
_LocalForage.default, {
|
|
1721
|
+
|
|
1722
|
+
/**
|
|
1723
|
+
* Contains keys for which we want to disable sync event across tabs.
|
|
1724
|
+
* @param {String[]} keysToDisableSyncEvents
|
|
1725
|
+
* Storage synchronization mechanism keeping all opened tabs in sync
|
|
1726
|
+
* @param {function(key: String, data: *)} onStorageKeyChanged
|
|
1727
|
+
*/
|
|
1728
|
+
keepInstancesSync: function keepInstancesSync(keysToDisableSyncEvents, onStorageKeyChanged) {var _this = this;
|
|
1729
|
+
// Override set, remove and clear to raise storage events that we intercept in other tabs
|
|
1730
|
+
this.setItem = function (key, value) {return _LocalForage.default.setItem(key, value).
|
|
1731
|
+
then(function () {return raiseStorageSyncEvent(key);});};
|
|
1732
|
+
|
|
1733
|
+
this.removeItem = function (key) {return _LocalForage.default.removeItem(key).
|
|
1734
|
+
then(function () {return raiseStorageSyncEvent(key);});};
|
|
1735
|
+
|
|
1736
|
+
// If we just call Storage.clear other tabs will have no idea which keys were available previously
|
|
1737
|
+
// so that they can call keysChanged for them. That's why we iterate and remove keys one by one
|
|
1738
|
+
this.clear = function () {return _LocalForage.default.getAllKeys().
|
|
1739
|
+
then(function (keys) {return _underscore.default.map(keys, function (key) {return _this.removeItem(key);});}).
|
|
1740
|
+
then(function (tasks) {return Promise.all(tasks);});};
|
|
1741
|
+
|
|
1742
|
+
// This listener will only be triggered by events coming from other tabs
|
|
1743
|
+
__webpack_require__.g.addEventListener('storage', function (event) {
|
|
1744
|
+
// Ignore events that don't originate from the SYNC_ONYX logic
|
|
1745
|
+
if (event.key !== SYNC_ONYX || !event.newValue) {
|
|
1746
|
+
return;
|
|
1747
|
+
}
|
|
1748
|
+
|
|
1749
|
+
var onyxKey = event.newValue;
|
|
1750
|
+
if (_underscore.default.contains(keysToDisableSyncEvents, onyxKey)) {
|
|
1751
|
+
return;
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
_LocalForage.default.getItem(onyxKey).
|
|
1755
|
+
then(function (value) {return onStorageKeyChanged(onyxKey, value);});
|
|
1756
|
+
});
|
|
1757
|
+
} });var _default =
|
|
1758
|
+
|
|
1759
|
+
|
|
1760
|
+
webStorage;exports["default"] = _default;
|
|
1761
|
+
|
|
1762
|
+
/***/ }),
|
|
1763
|
+
|
|
1764
|
+
/***/ "./lib/storage/index.web.js":
|
|
1765
|
+
/*!**********************************!*\
|
|
1766
|
+
!*** ./lib/storage/index.web.js ***!
|
|
1767
|
+
\**********************************/
|
|
1768
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1769
|
+
|
|
1770
|
+
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 =
|
|
1771
|
+
|
|
1772
|
+
_WebStorage.default;exports["default"] = _default;
|
|
1773
|
+
|
|
1774
|
+
/***/ }),
|
|
1775
|
+
|
|
1776
|
+
/***/ "./lib/storage/providers/LocalForage.js":
|
|
1777
|
+
/*!**********************************************!*\
|
|
1778
|
+
!*** ./lib/storage/providers/LocalForage.js ***!
|
|
1779
|
+
\**********************************************/
|
|
1780
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1781
|
+
|
|
1782
|
+
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 _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "./node_modules/@babel/runtime/helpers/slicedToArray.js"));
|
|
1783
|
+
|
|
1784
|
+
|
|
1785
|
+
|
|
1786
|
+
|
|
1787
|
+
|
|
1788
|
+
var _localforage = _interopRequireDefault(__webpack_require__(/*! localforage */ "localforage"));
|
|
1789
|
+
var _underscore = _interopRequireDefault(__webpack_require__(/*! underscore */ "underscore"));
|
|
1790
|
+
var _merge = _interopRequireDefault(__webpack_require__(/*! lodash/merge */ "lodash/merge"));
|
|
1791
|
+
var _SyncQueue = _interopRequireDefault(__webpack_require__(/*! ../../SyncQueue */ "./lib/SyncQueue.js")); /**
|
|
1792
|
+
* @file
|
|
1793
|
+
* The storage provider based on localforage allows us to store most anything in its
|
|
1794
|
+
* natural form in the underlying DB without having to stringify or de-stringify it
|
|
1795
|
+
*/_localforage.default.config({ name: 'OnyxDB' });
|
|
1796
|
+
|
|
1797
|
+
var provider = {
|
|
1798
|
+
/**
|
|
1799
|
+
* Writing very quickly to IndexedDB causes performance issues and can lock up the page and lead to jank.
|
|
1800
|
+
* So, we are slowing this process down by waiting until one write is complete before moving on
|
|
1801
|
+
* to the next.
|
|
1802
|
+
*/
|
|
1803
|
+
setItemQueue: new _SyncQueue.default(function (_ref) {var key = _ref.key,value = _ref.value,shouldMerge = _ref.shouldMerge;
|
|
1804
|
+
if (shouldMerge) {
|
|
1805
|
+
return _localforage.default.getItem(key).
|
|
1806
|
+
then(function (existingValue) {
|
|
1807
|
+
var newValue = _underscore.default.isObject(existingValue) ?
|
|
1808
|
+
(0, _merge.default)({}, existingValue, value) :
|
|
1809
|
+
value;
|
|
1810
|
+
return _localforage.default.setItem(key, newValue);
|
|
1811
|
+
});
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
return _localforage.default.setItem(key, value);
|
|
1815
|
+
}),
|
|
1816
|
+
|
|
1817
|
+
/**
|
|
1818
|
+
* Get multiple key-value pairs for the give array of keys in a batch
|
|
1819
|
+
* @param {String[]} keys
|
|
1820
|
+
* @return {Promise<Array<[key, value]>>}
|
|
1821
|
+
*/
|
|
1822
|
+
multiGet: function multiGet(keys) {
|
|
1823
|
+
var pairs = _underscore.default.map(
|
|
1824
|
+
keys,
|
|
1825
|
+
function (key) {return _localforage.default.getItem(key).
|
|
1826
|
+
then(function (value) {return [key, value];});});
|
|
1827
|
+
|
|
1828
|
+
|
|
1829
|
+
return Promise.all(pairs);
|
|
1830
|
+
},
|
|
1831
|
+
|
|
1832
|
+
/**
|
|
1833
|
+
* Multiple merging of existing and new values in a batch
|
|
1834
|
+
* @param {Array<[key, value]>} pairs
|
|
1835
|
+
* @return {Promise<void>}
|
|
1836
|
+
*/
|
|
1837
|
+
multiMerge: function multiMerge(pairs) {var _this = this;
|
|
1838
|
+
var tasks = _underscore.default.map(pairs, function (_ref2) {var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),key = _ref3[0],value = _ref3[1];return _this.setItemQueue.push({ key: key, value: value, shouldMerge: true });});
|
|
1839
|
+
|
|
1840
|
+
// We're returning Promise.resolve, otherwise the array of task results will be returned to the caller
|
|
1841
|
+
return Promise.all(tasks).then(function () {return Promise.resolve();});
|
|
1842
|
+
},
|
|
1843
|
+
|
|
1844
|
+
/**
|
|
1845
|
+
* Stores multiple key-value pairs in a batch
|
|
1846
|
+
* @param {Array<[key, value]>} pairs
|
|
1847
|
+
* @return {Promise<void>}
|
|
1848
|
+
*/
|
|
1849
|
+
multiSet: function multiSet(pairs) {var _this2 = this;
|
|
1850
|
+
// We're returning Promise.resolve, otherwise the array of task results will be returned to the caller
|
|
1851
|
+
var tasks = _underscore.default.map(pairs, function (_ref4) {var _ref5 = (0, _slicedToArray2.default)(_ref4, 2),key = _ref5[0],value = _ref5[1];return _this2.setItem(key, value);});
|
|
1852
|
+
return Promise.all(tasks).then(function () {return Promise.resolve();});
|
|
1853
|
+
},
|
|
1854
|
+
|
|
1855
|
+
/**
|
|
1856
|
+
* Clear absolutely everything from storage
|
|
1857
|
+
* @returns {Promise<void>}
|
|
1858
|
+
*/
|
|
1859
|
+
clear: _localforage.default.clear,
|
|
1860
|
+
|
|
1861
|
+
/**
|
|
1862
|
+
* Returns all keys available in storage
|
|
1863
|
+
* @returns {Promise<String[]>}
|
|
1864
|
+
*/
|
|
1865
|
+
getAllKeys: _localforage.default.keys,
|
|
1866
|
+
|
|
1867
|
+
/**
|
|
1868
|
+
* Get the value of a given key or return `null` if it's not available in storage
|
|
1869
|
+
* @param {String} key
|
|
1870
|
+
* @return {Promise<*>}
|
|
1871
|
+
*/
|
|
1872
|
+
getItem: _localforage.default.getItem,
|
|
1873
|
+
|
|
1874
|
+
/**
|
|
1875
|
+
* Remove given key and it's value from storage
|
|
1876
|
+
* @param {String} key
|
|
1877
|
+
* @returns {Promise<void>}
|
|
1878
|
+
*/
|
|
1879
|
+
removeItem: _localforage.default.removeItem,
|
|
1880
|
+
|
|
1881
|
+
/**
|
|
1882
|
+
* Sets the value for a given key. The only requirement is that the value should be serializable to JSON string
|
|
1883
|
+
* @param {String} key
|
|
1884
|
+
* @param {*} value
|
|
1885
|
+
* @return {Promise<void>}
|
|
1886
|
+
*/
|
|
1887
|
+
setItem: function setItem(key, value) {
|
|
1888
|
+
return this.setItemQueue.push({ key: key, value: value });
|
|
1889
|
+
} };var _default =
|
|
1890
|
+
|
|
1891
|
+
|
|
1892
|
+
provider;exports["default"] = _default;
|
|
1893
|
+
|
|
1894
|
+
/***/ }),
|
|
1895
|
+
|
|
1896
|
+
/***/ "./lib/withOnyx.js":
|
|
1897
|
+
/*!*************************!*\
|
|
1898
|
+
!*** ./lib/withOnyx.js ***!
|
|
1899
|
+
\*************************/
|
|
1900
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1901
|
+
|
|
1902
|
+
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 _extends2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/extends */ "./node_modules/@babel/runtime/helpers/extends.js"));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"));
|
|
1903
|
+
|
|
1904
|
+
|
|
1905
|
+
|
|
1906
|
+
|
|
1907
|
+
var _react = _interopRequireDefault(__webpack_require__(/*! react */ "react"));
|
|
1908
|
+
var _underscore = _interopRequireDefault(__webpack_require__(/*! underscore */ "underscore"));
|
|
1909
|
+
var _propTypes = _interopRequireDefault(__webpack_require__(/*! prop-types */ "./node_modules/prop-types/index.js"));
|
|
1910
|
+
var _str = _interopRequireDefault(__webpack_require__(/*! expensify-common/lib/str */ "expensify-common/lib/str"));
|
|
1911
|
+
var _Onyx = _interopRequireDefault(__webpack_require__(/*! ./Onyx */ "./lib/Onyx.js"));var _jsxFileName = "/Users/andrew/Expensidev/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;}}
|
|
1912
|
+
|
|
1913
|
+
/**
|
|
1914
|
+
* Returns the display name of a component
|
|
1915
|
+
*
|
|
1916
|
+
* @param {object} component
|
|
1917
|
+
* @returns {string}
|
|
1918
|
+
*/
|
|
1919
|
+
function getDisplayName(component) {
|
|
1920
|
+
return component.displayName || component.name || 'Component';
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
function _default(mapOnyxToState) {var _this = this;
|
|
1924
|
+
// A list of keys that must be present in tempState before we can render the WrappedComponent
|
|
1925
|
+
var requiredKeysForInit = _underscore.default.chain(mapOnyxToState).
|
|
1926
|
+
omit(function (config) {return config.initWithStoredValues === false;}).
|
|
1927
|
+
keys().
|
|
1928
|
+
value();
|
|
1929
|
+
|
|
1930
|
+
return function (WrappedComponent) {var
|
|
1931
|
+
withOnyx = /*#__PURE__*/function (_React$Component) {(0, _inherits2.default)(withOnyx, _React$Component);var _super = _createSuper(withOnyx);
|
|
1932
|
+
function withOnyx(props) {var _this2;(0, _classCallCheck2.default)(this, withOnyx);
|
|
1933
|
+
_this2 = _super.call(this, props);
|
|
1934
|
+
|
|
1935
|
+
_this2.setWithOnyxState = _this2.setWithOnyxState.bind((0, _assertThisInitialized2.default)(_this2));
|
|
1936
|
+
|
|
1937
|
+
// This stores all the Onyx connection IDs to be used when the component unmounts so everything can be
|
|
1938
|
+
// disconnected. It is a key value store with the format {[mapping.key]: connectionID}.
|
|
1939
|
+
_this2.activeConnectionIDs = {};
|
|
1940
|
+
|
|
1941
|
+
// Object holding the temporary initial state for the component while we load the various Onyx keys
|
|
1942
|
+
_this2.tempState = {};
|
|
1943
|
+
|
|
1944
|
+
_this2.state = {
|
|
1945
|
+
// If there are no required keys for init then we can render the wrapped component immediately
|
|
1946
|
+
loading: requiredKeysForInit.length > 0 };return _this2;
|
|
1947
|
+
|
|
1948
|
+
}(0, _createClass2.default)(withOnyx, [{ key: "componentDidMount", value: function componentDidMount()
|
|
1949
|
+
|
|
1950
|
+
{var _this3 = this;
|
|
1951
|
+
// Subscribe each of the state properties to the proper Onyx key
|
|
1952
|
+
_underscore.default.each(mapOnyxToState, function (mapping, propertyName) {
|
|
1953
|
+
_this3.connectMappingToOnyx(mapping, propertyName);
|
|
1954
|
+
});
|
|
1955
|
+
this.checkEvictableKeys();
|
|
1956
|
+
} }, { key: "componentDidUpdate", value: function componentDidUpdate(
|
|
1957
|
+
|
|
1958
|
+
prevProps) {var _this4 = this;
|
|
1959
|
+
// If any of the mappings use data from the props, then when the props change, all the
|
|
1960
|
+
// connections need to be reconnected with the new props
|
|
1961
|
+
_underscore.default.each(mapOnyxToState, function (mapping, propertyName) {
|
|
1962
|
+
var previousKey = _str.default.result(mapping.key, prevProps);
|
|
1963
|
+
var newKey = _str.default.result(mapping.key, _this4.props);
|
|
1964
|
+
|
|
1965
|
+
if (previousKey !== newKey) {
|
|
1966
|
+
_Onyx.default.disconnect(_this4.activeConnectionIDs[previousKey], previousKey);
|
|
1967
|
+
delete _this4.activeConnectionIDs[previousKey];
|
|
1968
|
+
_this4.connectMappingToOnyx(mapping, propertyName);
|
|
1969
|
+
}
|
|
1970
|
+
});
|
|
1971
|
+
this.checkEvictableKeys();
|
|
1972
|
+
} }, { key: "componentWillUnmount", value: function componentWillUnmount()
|
|
1973
|
+
|
|
1974
|
+
{var _this5 = this;
|
|
1975
|
+
// Disconnect everything from Onyx
|
|
1976
|
+
_underscore.default.each(mapOnyxToState, function (mapping) {
|
|
1977
|
+
var key = _str.default.result(mapping.key, _this5.props);
|
|
1978
|
+
var connectionID = _this5.activeConnectionIDs[key];
|
|
1979
|
+
_Onyx.default.disconnect(connectionID, key);
|
|
1980
|
+
});
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
/**
|
|
1984
|
+
* This method is used externally by sendDataToConnection to prevent unnecessary renders while a component
|
|
1985
|
+
* still in a loading state. The temporary initial state is saved to the component instance and setState()
|
|
1986
|
+
* only called once all the necessary data has been collected.
|
|
1987
|
+
*
|
|
1988
|
+
* @param {String} statePropertyName
|
|
1989
|
+
* @param {*} val
|
|
1990
|
+
*/ }, { key: "setWithOnyxState", value: function setWithOnyxState(
|
|
1991
|
+
statePropertyName, val) {var _this6 = this;
|
|
1992
|
+
if (!this.state.loading) {
|
|
1993
|
+
this.setState((0, _defineProperty2.default)({}, statePropertyName, val));
|
|
1994
|
+
return;
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1997
|
+
this.tempState[statePropertyName] = val;
|
|
1998
|
+
|
|
1999
|
+
// All state keys should exist and at least have a value of null
|
|
2000
|
+
if (_underscore.default.some(requiredKeysForInit, function (key) {return _underscore.default.isUndefined(_this6.tempState[key]);})) {
|
|
2001
|
+
return;
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
this.setState((0, _extends2.default)({}, this.tempState, { loading: false }));
|
|
2005
|
+
delete this.tempState;
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
/**
|
|
2009
|
+
* Makes sure each Onyx key we requested has been set to state with a value of some kind.
|
|
2010
|
+
* We are doing this so that the wrapped component will only render when all the data
|
|
2011
|
+
* it needs is available to it.
|
|
2012
|
+
*/ }, { key: "checkEvictableKeys", value: function checkEvictableKeys()
|
|
2013
|
+
{var _this7 = this;
|
|
2014
|
+
// We will add this key to our list of recently accessed keys
|
|
2015
|
+
// if the canEvict function returns true. This is necessary criteria
|
|
2016
|
+
// we MUST use to specify if a key can be removed or not.
|
|
2017
|
+
_underscore.default.each(mapOnyxToState, function (mapping) {
|
|
2018
|
+
if (_underscore.default.isUndefined(mapping.canEvict)) {
|
|
2019
|
+
return;
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
var canEvict = _str.default.result(mapping.canEvict, _this7.props);
|
|
2023
|
+
var key = _str.default.result(mapping.key, _this7.props);
|
|
2024
|
+
|
|
2025
|
+
if (!_Onyx.default.isSafeEvictionKey(key)) {
|
|
2026
|
+
// eslint-disable-next-line max-len
|
|
2027
|
+
throw new Error("canEvict cannot be used on key '" + key + "'. This key must explicitly be flagged as safe for removal by adding it to Onyx.init({safeEvictionKeys: []}).");
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
if (canEvict) {
|
|
2031
|
+
_Onyx.default.removeFromEvictionBlockList(key, mapping.connectionID);
|
|
2032
|
+
} else {
|
|
2033
|
+
_Onyx.default.addToEvictionBlockList(key, mapping.connectionID);
|
|
2034
|
+
}
|
|
2035
|
+
});
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
/**
|
|
2039
|
+
* Takes a single mapping and binds the state of the component to the store
|
|
2040
|
+
*
|
|
2041
|
+
* @param {object} mapping
|
|
2042
|
+
* @param {string|function} mapping.key key to connect to. can be a string or a
|
|
2043
|
+
* function that takes this.props as an argument and returns a string
|
|
2044
|
+
* @param {string} statePropertyName the name of the state property that Onyx will add the data to
|
|
2045
|
+
* @param {boolean} [mapping.initWithStoredValues] If set to false, then no data will be prefilled into the
|
|
2046
|
+
* component
|
|
2047
|
+
*/ }, { key: "connectMappingToOnyx", value: function connectMappingToOnyx(
|
|
2048
|
+
mapping, statePropertyName) {
|
|
2049
|
+
var key = _str.default.result(mapping.key, this.props);
|
|
2050
|
+
|
|
2051
|
+
this.activeConnectionIDs[key] = _Onyx.default.connect((0, _extends2.default)({},
|
|
2052
|
+
mapping, {
|
|
2053
|
+
key: key,
|
|
2054
|
+
statePropertyName: statePropertyName,
|
|
2055
|
+
withOnyxInstance: this }));
|
|
2056
|
+
|
|
2057
|
+
} }, { key: "render", value: function render()
|
|
2058
|
+
|
|
2059
|
+
{
|
|
2060
|
+
if (this.state.loading) {
|
|
2061
|
+
return null;
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2064
|
+
// Remove any internal state properties used by withOnyx
|
|
2065
|
+
// that should not be passed to a wrapped component
|
|
2066
|
+
var stateToPass = _underscore.default.omit(this.state, 'loading');
|
|
2067
|
+
stateToPass = _underscore.default.omit(stateToPass, function (value) {return _underscore.default.isNull(value);});
|
|
2068
|
+
|
|
2069
|
+
// Remove any null values so that React replaces them with default props
|
|
2070
|
+
var propsToPass = _underscore.default.omit(this.props, function (value) {return _underscore.default.isNull(value);});
|
|
2071
|
+
|
|
2072
|
+
// Spreading props and state is necessary in an HOC where the data cannot be predicted
|
|
2073
|
+
return /*#__PURE__*/(
|
|
2074
|
+
_react.default.createElement(WrappedComponent
|
|
2075
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
2076
|
+
, (0, _extends2.default)({}, propsToPass,
|
|
2077
|
+
|
|
2078
|
+
stateToPass, {
|
|
2079
|
+
ref: this.props.forwardedRef, __self: this, __source: { fileName: _jsxFileName, lineNumber: 173, columnNumber: 21 } })));
|
|
2080
|
+
|
|
2081
|
+
|
|
2082
|
+
} }]);return withOnyx;}(_react.default.Component);
|
|
2083
|
+
|
|
2084
|
+
|
|
2085
|
+
withOnyx.propTypes = {
|
|
2086
|
+
forwardedRef: _propTypes.default.oneOfType([
|
|
2087
|
+
_propTypes.default.func,
|
|
2088
|
+
_propTypes.default.shape({ current: _propTypes.default.instanceOf(_react.default.Component) })]) };
|
|
2089
|
+
|
|
2090
|
+
|
|
2091
|
+
withOnyx.defaultProps = {
|
|
2092
|
+
forwardedRef: undefined };
|
|
2093
|
+
|
|
2094
|
+
withOnyx.displayName = "withOnyx(" + getDisplayName(WrappedComponent) + ")";
|
|
2095
|
+
return _react.default.forwardRef(function (props, ref) {
|
|
2096
|
+
var Component = withOnyx;
|
|
2097
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
2098
|
+
return /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({}, props, { forwardedRef: ref, __self: _this, __source: { fileName: _jsxFileName, lineNumber: 197, columnNumber: 20 } }));
|
|
2099
|
+
});
|
|
2100
|
+
};
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2103
|
+
/***/ }),
|
|
2104
|
+
|
|
2105
|
+
/***/ "./node_modules/object-assign/index.js":
|
|
2106
|
+
/*!*********************************************!*\
|
|
2107
|
+
!*** ./node_modules/object-assign/index.js ***!
|
|
2108
|
+
\*********************************************/
|
|
2109
|
+
/***/ ((module) => {
|
|
2110
|
+
|
|
2111
|
+
"use strict";
|
|
2112
|
+
/*
|
|
2113
|
+
object-assign
|
|
2114
|
+
(c) Sindre Sorhus
|
|
2115
|
+
@license MIT
|
|
2116
|
+
*/
|
|
2117
|
+
|
|
2118
|
+
|
|
2119
|
+
/* eslint-disable no-unused-vars */
|
|
2120
|
+
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
2121
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
2122
|
+
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
2123
|
+
|
|
2124
|
+
function toObject(val) {
|
|
2125
|
+
if (val === null || val === undefined) {
|
|
2126
|
+
throw new TypeError('Object.assign cannot be called with null or undefined');
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
return Object(val);
|
|
2130
|
+
}
|
|
2131
|
+
|
|
2132
|
+
function shouldUseNative() {
|
|
2133
|
+
try {
|
|
2134
|
+
if (!Object.assign) {
|
|
2135
|
+
return false;
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2138
|
+
// Detect buggy property enumeration order in older V8 versions.
|
|
2139
|
+
|
|
2140
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
|
|
2141
|
+
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
|
|
2142
|
+
test1[5] = 'de';
|
|
2143
|
+
if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
|
2144
|
+
return false;
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2147
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
2148
|
+
var test2 = {};
|
|
2149
|
+
for (var i = 0; i < 10; i++) {
|
|
2150
|
+
test2['_' + String.fromCharCode(i)] = i;
|
|
2151
|
+
}
|
|
2152
|
+
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
|
2153
|
+
return test2[n];
|
|
2154
|
+
});
|
|
2155
|
+
if (order2.join('') !== '0123456789') {
|
|
2156
|
+
return false;
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
2160
|
+
var test3 = {};
|
|
2161
|
+
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
|
2162
|
+
test3[letter] = letter;
|
|
2163
|
+
});
|
|
2164
|
+
if (Object.keys(Object.assign({}, test3)).join('') !==
|
|
2165
|
+
'abcdefghijklmnopqrst') {
|
|
2166
|
+
return false;
|
|
2167
|
+
}
|
|
2168
|
+
|
|
2169
|
+
return true;
|
|
2170
|
+
} catch (err) {
|
|
2171
|
+
// We don't expect any of the above to throw, but better to be safe.
|
|
2172
|
+
return false;
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
|
|
2176
|
+
module.exports = shouldUseNative() ? Object.assign : function (target, source) {
|
|
2177
|
+
var from;
|
|
2178
|
+
var to = toObject(target);
|
|
2179
|
+
var symbols;
|
|
2180
|
+
|
|
2181
|
+
for (var s = 1; s < arguments.length; s++) {
|
|
2182
|
+
from = Object(arguments[s]);
|
|
2183
|
+
|
|
2184
|
+
for (var key in from) {
|
|
2185
|
+
if (hasOwnProperty.call(from, key)) {
|
|
2186
|
+
to[key] = from[key];
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
|
|
2190
|
+
if (getOwnPropertySymbols) {
|
|
2191
|
+
symbols = getOwnPropertySymbols(from);
|
|
2192
|
+
for (var i = 0; i < symbols.length; i++) {
|
|
2193
|
+
if (propIsEnumerable.call(from, symbols[i])) {
|
|
2194
|
+
to[symbols[i]] = from[symbols[i]];
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
|
|
2200
|
+
return to;
|
|
2201
|
+
};
|
|
2202
|
+
|
|
2203
|
+
|
|
2204
|
+
/***/ }),
|
|
2205
|
+
|
|
2206
|
+
/***/ "./node_modules/prop-types/checkPropTypes.js":
|
|
2207
|
+
/*!***************************************************!*\
|
|
2208
|
+
!*** ./node_modules/prop-types/checkPropTypes.js ***!
|
|
2209
|
+
\***************************************************/
|
|
2210
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
2211
|
+
|
|
2212
|
+
"use strict";
|
|
2213
|
+
/**
|
|
2214
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
2215
|
+
*
|
|
2216
|
+
* This source code is licensed under the MIT license found in the
|
|
2217
|
+
* LICENSE file in the root directory of this source tree.
|
|
2218
|
+
*/
|
|
2219
|
+
|
|
2220
|
+
|
|
2221
|
+
|
|
2222
|
+
var printWarning = function() {};
|
|
2223
|
+
|
|
2224
|
+
if (true) {
|
|
2225
|
+
var ReactPropTypesSecret = __webpack_require__(/*! ./lib/ReactPropTypesSecret */ "./node_modules/prop-types/lib/ReactPropTypesSecret.js");
|
|
2226
|
+
var loggedTypeFailures = {};
|
|
2227
|
+
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
2228
|
+
|
|
2229
|
+
printWarning = function(text) {
|
|
2230
|
+
var message = 'Warning: ' + text;
|
|
2231
|
+
if (typeof console !== 'undefined') {
|
|
2232
|
+
console.error(message);
|
|
2233
|
+
}
|
|
2234
|
+
try {
|
|
2235
|
+
// --- Welcome to debugging React ---
|
|
2236
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
2237
|
+
// to find the callsite that caused this warning to fire.
|
|
2238
|
+
throw new Error(message);
|
|
2239
|
+
} catch (x) {}
|
|
2240
|
+
};
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
/**
|
|
2244
|
+
* Assert that the values match with the type specs.
|
|
2245
|
+
* Error messages are memorized and will only be shown once.
|
|
2246
|
+
*
|
|
2247
|
+
* @param {object} typeSpecs Map of name to a ReactPropType
|
|
2248
|
+
* @param {object} values Runtime values that need to be type-checked
|
|
2249
|
+
* @param {string} location e.g. "prop", "context", "child context"
|
|
2250
|
+
* @param {string} componentName Name of the component for error messages.
|
|
2251
|
+
* @param {?Function} getStack Returns the component stack.
|
|
2252
|
+
* @private
|
|
2253
|
+
*/
|
|
2254
|
+
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
2255
|
+
if (true) {
|
|
2256
|
+
for (var typeSpecName in typeSpecs) {
|
|
2257
|
+
if (has(typeSpecs, typeSpecName)) {
|
|
2258
|
+
var error;
|
|
2259
|
+
// Prop type validation may throw. In case they do, we don't want to
|
|
2260
|
+
// fail the render phase where it didn't fail before. So we log it.
|
|
2261
|
+
// After these have been cleaned up, we'll let them throw.
|
|
2262
|
+
try {
|
|
2263
|
+
// This is intentionally an invariant that gets caught. It's the same
|
|
2264
|
+
// behavior as without this statement except with a better message.
|
|
2265
|
+
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
2266
|
+
var err = Error(
|
|
2267
|
+
(componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
|
|
2268
|
+
'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
|
|
2269
|
+
);
|
|
2270
|
+
err.name = 'Invariant Violation';
|
|
2271
|
+
throw err;
|
|
2272
|
+
}
|
|
2273
|
+
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
|
2274
|
+
} catch (ex) {
|
|
2275
|
+
error = ex;
|
|
2276
|
+
}
|
|
2277
|
+
if (error && !(error instanceof Error)) {
|
|
2278
|
+
printWarning(
|
|
2279
|
+
(componentName || 'React class') + ': type specification of ' +
|
|
2280
|
+
location + ' `' + typeSpecName + '` is invalid; the type checker ' +
|
|
2281
|
+
'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
|
|
2282
|
+
'You may have forgotten to pass an argument to the type checker ' +
|
|
2283
|
+
'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
|
2284
|
+
'shape all require an argument).'
|
|
2285
|
+
);
|
|
2286
|
+
}
|
|
2287
|
+
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
2288
|
+
// Only monitor this failure once because there tends to be a lot of the
|
|
2289
|
+
// same error.
|
|
2290
|
+
loggedTypeFailures[error.message] = true;
|
|
2291
|
+
|
|
2292
|
+
var stack = getStack ? getStack() : '';
|
|
2293
|
+
|
|
2294
|
+
printWarning(
|
|
2295
|
+
'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
|
|
2296
|
+
);
|
|
2297
|
+
}
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2303
|
+
/**
|
|
2304
|
+
* Resets warning cache when testing.
|
|
2305
|
+
*
|
|
2306
|
+
* @private
|
|
2307
|
+
*/
|
|
2308
|
+
checkPropTypes.resetWarningCache = function() {
|
|
2309
|
+
if (true) {
|
|
2310
|
+
loggedTypeFailures = {};
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2314
|
+
module.exports = checkPropTypes;
|
|
2315
|
+
|
|
2316
|
+
|
|
2317
|
+
/***/ }),
|
|
2318
|
+
|
|
2319
|
+
/***/ "./node_modules/prop-types/factoryWithTypeCheckers.js":
|
|
2320
|
+
/*!************************************************************!*\
|
|
2321
|
+
!*** ./node_modules/prop-types/factoryWithTypeCheckers.js ***!
|
|
2322
|
+
\************************************************************/
|
|
2323
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
2324
|
+
|
|
2325
|
+
"use strict";
|
|
2326
|
+
/**
|
|
2327
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
2328
|
+
*
|
|
2329
|
+
* This source code is licensed under the MIT license found in the
|
|
2330
|
+
* LICENSE file in the root directory of this source tree.
|
|
2331
|
+
*/
|
|
2332
|
+
|
|
2333
|
+
|
|
2334
|
+
|
|
2335
|
+
var ReactIs = __webpack_require__(/*! react-is */ "./node_modules/react-is/index.js");
|
|
2336
|
+
var assign = __webpack_require__(/*! object-assign */ "./node_modules/object-assign/index.js");
|
|
2337
|
+
|
|
2338
|
+
var ReactPropTypesSecret = __webpack_require__(/*! ./lib/ReactPropTypesSecret */ "./node_modules/prop-types/lib/ReactPropTypesSecret.js");
|
|
2339
|
+
var checkPropTypes = __webpack_require__(/*! ./checkPropTypes */ "./node_modules/prop-types/checkPropTypes.js");
|
|
2340
|
+
|
|
2341
|
+
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
2342
|
+
var printWarning = function() {};
|
|
2343
|
+
|
|
2344
|
+
if (true) {
|
|
2345
|
+
printWarning = function(text) {
|
|
2346
|
+
var message = 'Warning: ' + text;
|
|
2347
|
+
if (typeof console !== 'undefined') {
|
|
2348
|
+
console.error(message);
|
|
2349
|
+
}
|
|
2350
|
+
try {
|
|
2351
|
+
// --- Welcome to debugging React ---
|
|
2352
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
2353
|
+
// to find the callsite that caused this warning to fire.
|
|
2354
|
+
throw new Error(message);
|
|
2355
|
+
} catch (x) {}
|
|
2356
|
+
};
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
function emptyFunctionThatReturnsNull() {
|
|
2360
|
+
return null;
|
|
2361
|
+
}
|
|
2362
|
+
|
|
2363
|
+
module.exports = function(isValidElement, throwOnDirectAccess) {
|
|
2364
|
+
/* global Symbol */
|
|
2365
|
+
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
2366
|
+
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
|
|
2367
|
+
|
|
2368
|
+
/**
|
|
2369
|
+
* Returns the iterator method function contained on the iterable object.
|
|
2370
|
+
*
|
|
2371
|
+
* Be sure to invoke the function with the iterable as context:
|
|
2372
|
+
*
|
|
2373
|
+
* var iteratorFn = getIteratorFn(myIterable);
|
|
2374
|
+
* if (iteratorFn) {
|
|
2375
|
+
* var iterator = iteratorFn.call(myIterable);
|
|
2376
|
+
* ...
|
|
2377
|
+
* }
|
|
2378
|
+
*
|
|
2379
|
+
* @param {?object} maybeIterable
|
|
2380
|
+
* @return {?function}
|
|
2381
|
+
*/
|
|
2382
|
+
function getIteratorFn(maybeIterable) {
|
|
2383
|
+
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
|
2384
|
+
if (typeof iteratorFn === 'function') {
|
|
2385
|
+
return iteratorFn;
|
|
2386
|
+
}
|
|
2387
|
+
}
|
|
2388
|
+
|
|
2389
|
+
/**
|
|
2390
|
+
* Collection of methods that allow declaration and validation of props that are
|
|
2391
|
+
* supplied to React components. Example usage:
|
|
2392
|
+
*
|
|
2393
|
+
* var Props = require('ReactPropTypes');
|
|
2394
|
+
* var MyArticle = React.createClass({
|
|
2395
|
+
* propTypes: {
|
|
2396
|
+
* // An optional string prop named "description".
|
|
2397
|
+
* description: Props.string,
|
|
2398
|
+
*
|
|
2399
|
+
* // A required enum prop named "category".
|
|
2400
|
+
* category: Props.oneOf(['News','Photos']).isRequired,
|
|
2401
|
+
*
|
|
2402
|
+
* // A prop named "dialog" that requires an instance of Dialog.
|
|
2403
|
+
* dialog: Props.instanceOf(Dialog).isRequired
|
|
2404
|
+
* },
|
|
2405
|
+
* render: function() { ... }
|
|
2406
|
+
* });
|
|
2407
|
+
*
|
|
2408
|
+
* A more formal specification of how these methods are used:
|
|
2409
|
+
*
|
|
2410
|
+
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
|
|
2411
|
+
* decl := ReactPropTypes.{type}(.isRequired)?
|
|
2412
|
+
*
|
|
2413
|
+
* Each and every declaration produces a function with the same signature. This
|
|
2414
|
+
* allows the creation of custom validation functions. For example:
|
|
2415
|
+
*
|
|
2416
|
+
* var MyLink = React.createClass({
|
|
2417
|
+
* propTypes: {
|
|
2418
|
+
* // An optional string or URI prop named "href".
|
|
2419
|
+
* href: function(props, propName, componentName) {
|
|
2420
|
+
* var propValue = props[propName];
|
|
2421
|
+
* if (propValue != null && typeof propValue !== 'string' &&
|
|
2422
|
+
* !(propValue instanceof URI)) {
|
|
2423
|
+
* return new Error(
|
|
2424
|
+
* 'Expected a string or an URI for ' + propName + ' in ' +
|
|
2425
|
+
* componentName
|
|
2426
|
+
* );
|
|
2427
|
+
* }
|
|
2428
|
+
* }
|
|
2429
|
+
* },
|
|
2430
|
+
* render: function() {...}
|
|
2431
|
+
* });
|
|
2432
|
+
*
|
|
2433
|
+
* @internal
|
|
2434
|
+
*/
|
|
2435
|
+
|
|
2436
|
+
var ANONYMOUS = '<<anonymous>>';
|
|
2437
|
+
|
|
2438
|
+
// Important!
|
|
2439
|
+
// Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
|
|
2440
|
+
var ReactPropTypes = {
|
|
2441
|
+
array: createPrimitiveTypeChecker('array'),
|
|
2442
|
+
bool: createPrimitiveTypeChecker('boolean'),
|
|
2443
|
+
func: createPrimitiveTypeChecker('function'),
|
|
2444
|
+
number: createPrimitiveTypeChecker('number'),
|
|
2445
|
+
object: createPrimitiveTypeChecker('object'),
|
|
2446
|
+
string: createPrimitiveTypeChecker('string'),
|
|
2447
|
+
symbol: createPrimitiveTypeChecker('symbol'),
|
|
2448
|
+
|
|
2449
|
+
any: createAnyTypeChecker(),
|
|
2450
|
+
arrayOf: createArrayOfTypeChecker,
|
|
2451
|
+
element: createElementTypeChecker(),
|
|
2452
|
+
elementType: createElementTypeTypeChecker(),
|
|
2453
|
+
instanceOf: createInstanceTypeChecker,
|
|
2454
|
+
node: createNodeChecker(),
|
|
2455
|
+
objectOf: createObjectOfTypeChecker,
|
|
2456
|
+
oneOf: createEnumTypeChecker,
|
|
2457
|
+
oneOfType: createUnionTypeChecker,
|
|
2458
|
+
shape: createShapeTypeChecker,
|
|
2459
|
+
exact: createStrictShapeTypeChecker,
|
|
2460
|
+
};
|
|
2461
|
+
|
|
2462
|
+
/**
|
|
2463
|
+
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
2464
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
2465
|
+
*/
|
|
2466
|
+
/*eslint-disable no-self-compare*/
|
|
2467
|
+
function is(x, y) {
|
|
2468
|
+
// SameValue algorithm
|
|
2469
|
+
if (x === y) {
|
|
2470
|
+
// Steps 1-5, 7-10
|
|
2471
|
+
// Steps 6.b-6.e: +0 != -0
|
|
2472
|
+
return x !== 0 || 1 / x === 1 / y;
|
|
2473
|
+
} else {
|
|
2474
|
+
// Step 6.a: NaN == NaN
|
|
2475
|
+
return x !== x && y !== y;
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
/*eslint-enable no-self-compare*/
|
|
2479
|
+
|
|
2480
|
+
/**
|
|
2481
|
+
* We use an Error-like object for backward compatibility as people may call
|
|
2482
|
+
* PropTypes directly and inspect their output. However, we don't use real
|
|
2483
|
+
* Errors anymore. We don't inspect their stack anyway, and creating them
|
|
2484
|
+
* is prohibitively expensive if they are created too often, such as what
|
|
2485
|
+
* happens in oneOfType() for any type before the one that matched.
|
|
2486
|
+
*/
|
|
2487
|
+
function PropTypeError(message) {
|
|
2488
|
+
this.message = message;
|
|
2489
|
+
this.stack = '';
|
|
2490
|
+
}
|
|
2491
|
+
// Make `instanceof Error` still work for returned errors.
|
|
2492
|
+
PropTypeError.prototype = Error.prototype;
|
|
2493
|
+
|
|
2494
|
+
function createChainableTypeChecker(validate) {
|
|
2495
|
+
if (true) {
|
|
2496
|
+
var manualPropTypeCallCache = {};
|
|
2497
|
+
var manualPropTypeWarningCount = 0;
|
|
2498
|
+
}
|
|
2499
|
+
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
|
|
2500
|
+
componentName = componentName || ANONYMOUS;
|
|
2501
|
+
propFullName = propFullName || propName;
|
|
2502
|
+
|
|
2503
|
+
if (secret !== ReactPropTypesSecret) {
|
|
2504
|
+
if (throwOnDirectAccess) {
|
|
2505
|
+
// New behavior only for users of `prop-types` package
|
|
2506
|
+
var err = new Error(
|
|
2507
|
+
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
|
2508
|
+
'Use `PropTypes.checkPropTypes()` to call them. ' +
|
|
2509
|
+
'Read more at http://fb.me/use-check-prop-types'
|
|
2510
|
+
);
|
|
2511
|
+
err.name = 'Invariant Violation';
|
|
2512
|
+
throw err;
|
|
2513
|
+
} else if ( true && typeof console !== 'undefined') {
|
|
2514
|
+
// Old behavior for people using React.PropTypes
|
|
2515
|
+
var cacheKey = componentName + ':' + propName;
|
|
2516
|
+
if (
|
|
2517
|
+
!manualPropTypeCallCache[cacheKey] &&
|
|
2518
|
+
// Avoid spamming the console because they are often not actionable except for lib authors
|
|
2519
|
+
manualPropTypeWarningCount < 3
|
|
2520
|
+
) {
|
|
2521
|
+
printWarning(
|
|
2522
|
+
'You are manually calling a React.PropTypes validation ' +
|
|
2523
|
+
'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
|
|
2524
|
+
'and will throw in the standalone `prop-types` package. ' +
|
|
2525
|
+
'You may be seeing this warning due to a third-party PropTypes ' +
|
|
2526
|
+
'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
|
|
2527
|
+
);
|
|
2528
|
+
manualPropTypeCallCache[cacheKey] = true;
|
|
2529
|
+
manualPropTypeWarningCount++;
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
if (props[propName] == null) {
|
|
2534
|
+
if (isRequired) {
|
|
2535
|
+
if (props[propName] === null) {
|
|
2536
|
+
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
|
|
2537
|
+
}
|
|
2538
|
+
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
|
|
2539
|
+
}
|
|
2540
|
+
return null;
|
|
2541
|
+
} else {
|
|
2542
|
+
return validate(props, propName, componentName, location, propFullName);
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2545
|
+
|
|
2546
|
+
var chainedCheckType = checkType.bind(null, false);
|
|
2547
|
+
chainedCheckType.isRequired = checkType.bind(null, true);
|
|
2548
|
+
|
|
2549
|
+
return chainedCheckType;
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2552
|
+
function createPrimitiveTypeChecker(expectedType) {
|
|
2553
|
+
function validate(props, propName, componentName, location, propFullName, secret) {
|
|
2554
|
+
var propValue = props[propName];
|
|
2555
|
+
var propType = getPropType(propValue);
|
|
2556
|
+
if (propType !== expectedType) {
|
|
2557
|
+
// `propValue` being instance of, say, date/regexp, pass the 'object'
|
|
2558
|
+
// check, but we can offer a more precise error message here rather than
|
|
2559
|
+
// 'of type `object`'.
|
|
2560
|
+
var preciseType = getPreciseType(propValue);
|
|
2561
|
+
|
|
2562
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
|
|
2563
|
+
}
|
|
2564
|
+
return null;
|
|
2565
|
+
}
|
|
2566
|
+
return createChainableTypeChecker(validate);
|
|
2567
|
+
}
|
|
2568
|
+
|
|
2569
|
+
function createAnyTypeChecker() {
|
|
2570
|
+
return createChainableTypeChecker(emptyFunctionThatReturnsNull);
|
|
2571
|
+
}
|
|
2572
|
+
|
|
2573
|
+
function createArrayOfTypeChecker(typeChecker) {
|
|
2574
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
2575
|
+
if (typeof typeChecker !== 'function') {
|
|
2576
|
+
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
|
|
2577
|
+
}
|
|
2578
|
+
var propValue = props[propName];
|
|
2579
|
+
if (!Array.isArray(propValue)) {
|
|
2580
|
+
var propType = getPropType(propValue);
|
|
2581
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
|
2582
|
+
}
|
|
2583
|
+
for (var i = 0; i < propValue.length; i++) {
|
|
2584
|
+
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
|
|
2585
|
+
if (error instanceof Error) {
|
|
2586
|
+
return error;
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
return null;
|
|
2590
|
+
}
|
|
2591
|
+
return createChainableTypeChecker(validate);
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2594
|
+
function createElementTypeChecker() {
|
|
2595
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
2596
|
+
var propValue = props[propName];
|
|
2597
|
+
if (!isValidElement(propValue)) {
|
|
2598
|
+
var propType = getPropType(propValue);
|
|
2599
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
|
|
2600
|
+
}
|
|
2601
|
+
return null;
|
|
2602
|
+
}
|
|
2603
|
+
return createChainableTypeChecker(validate);
|
|
2604
|
+
}
|
|
2605
|
+
|
|
2606
|
+
function createElementTypeTypeChecker() {
|
|
2607
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
2608
|
+
var propValue = props[propName];
|
|
2609
|
+
if (!ReactIs.isValidElementType(propValue)) {
|
|
2610
|
+
var propType = getPropType(propValue);
|
|
2611
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
|
|
2612
|
+
}
|
|
2613
|
+
return null;
|
|
2614
|
+
}
|
|
2615
|
+
return createChainableTypeChecker(validate);
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
function createInstanceTypeChecker(expectedClass) {
|
|
2619
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
2620
|
+
if (!(props[propName] instanceof expectedClass)) {
|
|
2621
|
+
var expectedClassName = expectedClass.name || ANONYMOUS;
|
|
2622
|
+
var actualClassName = getClassName(props[propName]);
|
|
2623
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
|
|
2624
|
+
}
|
|
2625
|
+
return null;
|
|
2626
|
+
}
|
|
2627
|
+
return createChainableTypeChecker(validate);
|
|
2628
|
+
}
|
|
2629
|
+
|
|
2630
|
+
function createEnumTypeChecker(expectedValues) {
|
|
2631
|
+
if (!Array.isArray(expectedValues)) {
|
|
2632
|
+
if (true) {
|
|
2633
|
+
if (arguments.length > 1) {
|
|
2634
|
+
printWarning(
|
|
2635
|
+
'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
|
|
2636
|
+
'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
|
|
2637
|
+
);
|
|
2638
|
+
} else {
|
|
2639
|
+
printWarning('Invalid argument supplied to oneOf, expected an array.');
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2642
|
+
return emptyFunctionThatReturnsNull;
|
|
2643
|
+
}
|
|
2644
|
+
|
|
2645
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
2646
|
+
var propValue = props[propName];
|
|
2647
|
+
for (var i = 0; i < expectedValues.length; i++) {
|
|
2648
|
+
if (is(propValue, expectedValues[i])) {
|
|
2649
|
+
return null;
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2653
|
+
var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
|
|
2654
|
+
var type = getPreciseType(value);
|
|
2655
|
+
if (type === 'symbol') {
|
|
2656
|
+
return String(value);
|
|
2657
|
+
}
|
|
2658
|
+
return value;
|
|
2659
|
+
});
|
|
2660
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
|
2661
|
+
}
|
|
2662
|
+
return createChainableTypeChecker(validate);
|
|
2663
|
+
}
|
|
2664
|
+
|
|
2665
|
+
function createObjectOfTypeChecker(typeChecker) {
|
|
2666
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
2667
|
+
if (typeof typeChecker !== 'function') {
|
|
2668
|
+
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
|
|
2669
|
+
}
|
|
2670
|
+
var propValue = props[propName];
|
|
2671
|
+
var propType = getPropType(propValue);
|
|
2672
|
+
if (propType !== 'object') {
|
|
2673
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
|
2674
|
+
}
|
|
2675
|
+
for (var key in propValue) {
|
|
2676
|
+
if (has(propValue, key)) {
|
|
2677
|
+
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
|
2678
|
+
if (error instanceof Error) {
|
|
2679
|
+
return error;
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
return null;
|
|
2684
|
+
}
|
|
2685
|
+
return createChainableTypeChecker(validate);
|
|
2686
|
+
}
|
|
2687
|
+
|
|
2688
|
+
function createUnionTypeChecker(arrayOfTypeCheckers) {
|
|
2689
|
+
if (!Array.isArray(arrayOfTypeCheckers)) {
|
|
2690
|
+
true ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : 0;
|
|
2691
|
+
return emptyFunctionThatReturnsNull;
|
|
2692
|
+
}
|
|
2693
|
+
|
|
2694
|
+
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
2695
|
+
var checker = arrayOfTypeCheckers[i];
|
|
2696
|
+
if (typeof checker !== 'function') {
|
|
2697
|
+
printWarning(
|
|
2698
|
+
'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
|
|
2699
|
+
'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
|
|
2700
|
+
);
|
|
2701
|
+
return emptyFunctionThatReturnsNull;
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
|
|
2705
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
2706
|
+
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
2707
|
+
var checker = arrayOfTypeCheckers[i];
|
|
2708
|
+
if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) {
|
|
2709
|
+
return null;
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
2712
|
+
|
|
2713
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
|
|
2714
|
+
}
|
|
2715
|
+
return createChainableTypeChecker(validate);
|
|
2716
|
+
}
|
|
2717
|
+
|
|
2718
|
+
function createNodeChecker() {
|
|
2719
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
2720
|
+
if (!isNode(props[propName])) {
|
|
2721
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
|
|
2722
|
+
}
|
|
2723
|
+
return null;
|
|
2724
|
+
}
|
|
2725
|
+
return createChainableTypeChecker(validate);
|
|
2726
|
+
}
|
|
2727
|
+
|
|
2728
|
+
function createShapeTypeChecker(shapeTypes) {
|
|
2729
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
2730
|
+
var propValue = props[propName];
|
|
2731
|
+
var propType = getPropType(propValue);
|
|
2732
|
+
if (propType !== 'object') {
|
|
2733
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
2734
|
+
}
|
|
2735
|
+
for (var key in shapeTypes) {
|
|
2736
|
+
var checker = shapeTypes[key];
|
|
2737
|
+
if (!checker) {
|
|
2738
|
+
continue;
|
|
2739
|
+
}
|
|
2740
|
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
|
2741
|
+
if (error) {
|
|
2742
|
+
return error;
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
return null;
|
|
2746
|
+
}
|
|
2747
|
+
return createChainableTypeChecker(validate);
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2750
|
+
function createStrictShapeTypeChecker(shapeTypes) {
|
|
2751
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
2752
|
+
var propValue = props[propName];
|
|
2753
|
+
var propType = getPropType(propValue);
|
|
2754
|
+
if (propType !== 'object') {
|
|
2755
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
2756
|
+
}
|
|
2757
|
+
// We need to check all keys in case some are required but missing from
|
|
2758
|
+
// props.
|
|
2759
|
+
var allKeys = assign({}, props[propName], shapeTypes);
|
|
2760
|
+
for (var key in allKeys) {
|
|
2761
|
+
var checker = shapeTypes[key];
|
|
2762
|
+
if (!checker) {
|
|
2763
|
+
return new PropTypeError(
|
|
2764
|
+
'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
|
|
2765
|
+
'\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
|
|
2766
|
+
'\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
|
|
2767
|
+
);
|
|
2768
|
+
}
|
|
2769
|
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
|
2770
|
+
if (error) {
|
|
2771
|
+
return error;
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
return null;
|
|
2775
|
+
}
|
|
2776
|
+
|
|
2777
|
+
return createChainableTypeChecker(validate);
|
|
2778
|
+
}
|
|
2779
|
+
|
|
2780
|
+
function isNode(propValue) {
|
|
2781
|
+
switch (typeof propValue) {
|
|
2782
|
+
case 'number':
|
|
2783
|
+
case 'string':
|
|
2784
|
+
case 'undefined':
|
|
2785
|
+
return true;
|
|
2786
|
+
case 'boolean':
|
|
2787
|
+
return !propValue;
|
|
2788
|
+
case 'object':
|
|
2789
|
+
if (Array.isArray(propValue)) {
|
|
2790
|
+
return propValue.every(isNode);
|
|
2791
|
+
}
|
|
2792
|
+
if (propValue === null || isValidElement(propValue)) {
|
|
2793
|
+
return true;
|
|
2794
|
+
}
|
|
2795
|
+
|
|
2796
|
+
var iteratorFn = getIteratorFn(propValue);
|
|
2797
|
+
if (iteratorFn) {
|
|
2798
|
+
var iterator = iteratorFn.call(propValue);
|
|
2799
|
+
var step;
|
|
2800
|
+
if (iteratorFn !== propValue.entries) {
|
|
2801
|
+
while (!(step = iterator.next()).done) {
|
|
2802
|
+
if (!isNode(step.value)) {
|
|
2803
|
+
return false;
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2806
|
+
} else {
|
|
2807
|
+
// Iterator will provide entry [k,v] tuples rather than values.
|
|
2808
|
+
while (!(step = iterator.next()).done) {
|
|
2809
|
+
var entry = step.value;
|
|
2810
|
+
if (entry) {
|
|
2811
|
+
if (!isNode(entry[1])) {
|
|
2812
|
+
return false;
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2816
|
+
}
|
|
2817
|
+
} else {
|
|
2818
|
+
return false;
|
|
2819
|
+
}
|
|
2820
|
+
|
|
2821
|
+
return true;
|
|
2822
|
+
default:
|
|
2823
|
+
return false;
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2826
|
+
|
|
2827
|
+
function isSymbol(propType, propValue) {
|
|
2828
|
+
// Native Symbol.
|
|
2829
|
+
if (propType === 'symbol') {
|
|
2830
|
+
return true;
|
|
2831
|
+
}
|
|
2832
|
+
|
|
2833
|
+
// falsy value can't be a Symbol
|
|
2834
|
+
if (!propValue) {
|
|
2835
|
+
return false;
|
|
2836
|
+
}
|
|
2837
|
+
|
|
2838
|
+
// 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
|
|
2839
|
+
if (propValue['@@toStringTag'] === 'Symbol') {
|
|
2840
|
+
return true;
|
|
2841
|
+
}
|
|
2842
|
+
|
|
2843
|
+
// Fallback for non-spec compliant Symbols which are polyfilled.
|
|
2844
|
+
if (typeof Symbol === 'function' && propValue instanceof Symbol) {
|
|
2845
|
+
return true;
|
|
2846
|
+
}
|
|
2847
|
+
|
|
2848
|
+
return false;
|
|
2849
|
+
}
|
|
2850
|
+
|
|
2851
|
+
// Equivalent of `typeof` but with special handling for array and regexp.
|
|
2852
|
+
function getPropType(propValue) {
|
|
2853
|
+
var propType = typeof propValue;
|
|
2854
|
+
if (Array.isArray(propValue)) {
|
|
2855
|
+
return 'array';
|
|
2856
|
+
}
|
|
2857
|
+
if (propValue instanceof RegExp) {
|
|
2858
|
+
// Old webkits (at least until Android 4.0) return 'function' rather than
|
|
2859
|
+
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/
|
|
2860
|
+
// passes PropTypes.object.
|
|
2861
|
+
return 'object';
|
|
2862
|
+
}
|
|
2863
|
+
if (isSymbol(propType, propValue)) {
|
|
2864
|
+
return 'symbol';
|
|
2865
|
+
}
|
|
2866
|
+
return propType;
|
|
2867
|
+
}
|
|
2868
|
+
|
|
2869
|
+
// This handles more types than `getPropType`. Only used for error messages.
|
|
2870
|
+
// See `createPrimitiveTypeChecker`.
|
|
2871
|
+
function getPreciseType(propValue) {
|
|
2872
|
+
if (typeof propValue === 'undefined' || propValue === null) {
|
|
2873
|
+
return '' + propValue;
|
|
2874
|
+
}
|
|
2875
|
+
var propType = getPropType(propValue);
|
|
2876
|
+
if (propType === 'object') {
|
|
2877
|
+
if (propValue instanceof Date) {
|
|
2878
|
+
return 'date';
|
|
2879
|
+
} else if (propValue instanceof RegExp) {
|
|
2880
|
+
return 'regexp';
|
|
2881
|
+
}
|
|
2882
|
+
}
|
|
2883
|
+
return propType;
|
|
2884
|
+
}
|
|
2885
|
+
|
|
2886
|
+
// Returns a string that is postfixed to a warning about an invalid type.
|
|
2887
|
+
// For example, "undefined" or "of type array"
|
|
2888
|
+
function getPostfixForTypeWarning(value) {
|
|
2889
|
+
var type = getPreciseType(value);
|
|
2890
|
+
switch (type) {
|
|
2891
|
+
case 'array':
|
|
2892
|
+
case 'object':
|
|
2893
|
+
return 'an ' + type;
|
|
2894
|
+
case 'boolean':
|
|
2895
|
+
case 'date':
|
|
2896
|
+
case 'regexp':
|
|
2897
|
+
return 'a ' + type;
|
|
2898
|
+
default:
|
|
2899
|
+
return type;
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
|
|
2903
|
+
// Returns class name of the object, if any.
|
|
2904
|
+
function getClassName(propValue) {
|
|
2905
|
+
if (!propValue.constructor || !propValue.constructor.name) {
|
|
2906
|
+
return ANONYMOUS;
|
|
2907
|
+
}
|
|
2908
|
+
return propValue.constructor.name;
|
|
2909
|
+
}
|
|
2910
|
+
|
|
2911
|
+
ReactPropTypes.checkPropTypes = checkPropTypes;
|
|
2912
|
+
ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
|
|
2913
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
2914
|
+
|
|
2915
|
+
return ReactPropTypes;
|
|
2916
|
+
};
|
|
2917
|
+
|
|
2918
|
+
|
|
2919
|
+
/***/ }),
|
|
2920
|
+
|
|
2921
|
+
/***/ "./node_modules/prop-types/index.js":
|
|
2922
|
+
/*!******************************************!*\
|
|
2923
|
+
!*** ./node_modules/prop-types/index.js ***!
|
|
2924
|
+
\******************************************/
|
|
2925
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
2926
|
+
|
|
2927
|
+
/**
|
|
2928
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
2929
|
+
*
|
|
2930
|
+
* This source code is licensed under the MIT license found in the
|
|
2931
|
+
* LICENSE file in the root directory of this source tree.
|
|
2932
|
+
*/
|
|
2933
|
+
|
|
2934
|
+
if (true) {
|
|
2935
|
+
var ReactIs = __webpack_require__(/*! react-is */ "./node_modules/react-is/index.js");
|
|
2936
|
+
|
|
2937
|
+
// By explicitly using `prop-types` you are opting into new development behavior.
|
|
2938
|
+
// http://fb.me/prop-types-in-prod
|
|
2939
|
+
var throwOnDirectAccess = true;
|
|
2940
|
+
module.exports = __webpack_require__(/*! ./factoryWithTypeCheckers */ "./node_modules/prop-types/factoryWithTypeCheckers.js")(ReactIs.isElement, throwOnDirectAccess);
|
|
2941
|
+
} else {}
|
|
2942
|
+
|
|
2943
|
+
|
|
2944
|
+
/***/ }),
|
|
2945
|
+
|
|
2946
|
+
/***/ "./node_modules/prop-types/lib/ReactPropTypesSecret.js":
|
|
2947
|
+
/*!*************************************************************!*\
|
|
2948
|
+
!*** ./node_modules/prop-types/lib/ReactPropTypesSecret.js ***!
|
|
2949
|
+
\*************************************************************/
|
|
2950
|
+
/***/ ((module) => {
|
|
2951
|
+
|
|
2952
|
+
"use strict";
|
|
2953
|
+
/**
|
|
2954
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
2955
|
+
*
|
|
2956
|
+
* This source code is licensed under the MIT license found in the
|
|
2957
|
+
* LICENSE file in the root directory of this source tree.
|
|
2958
|
+
*/
|
|
2959
|
+
|
|
2960
|
+
|
|
2961
|
+
|
|
2962
|
+
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
2963
|
+
|
|
2964
|
+
module.exports = ReactPropTypesSecret;
|
|
2965
|
+
|
|
2966
|
+
|
|
2967
|
+
/***/ }),
|
|
2968
|
+
|
|
2969
|
+
/***/ "./node_modules/react-is/cjs/react-is.development.js":
|
|
2970
|
+
/*!***********************************************************!*\
|
|
2971
|
+
!*** ./node_modules/react-is/cjs/react-is.development.js ***!
|
|
2972
|
+
\***********************************************************/
|
|
2973
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
2974
|
+
|
|
2975
|
+
"use strict";
|
|
2976
|
+
/** @license React v16.13.1
|
|
2977
|
+
* react-is.development.js
|
|
2978
|
+
*
|
|
2979
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
2980
|
+
*
|
|
2981
|
+
* This source code is licensed under the MIT license found in the
|
|
2982
|
+
* LICENSE file in the root directory of this source tree.
|
|
2983
|
+
*/
|
|
2984
|
+
|
|
2985
|
+
|
|
2986
|
+
|
|
2987
|
+
|
|
2988
|
+
|
|
2989
|
+
if (true) {
|
|
2990
|
+
(function() {
|
|
2991
|
+
'use strict';
|
|
2992
|
+
|
|
2993
|
+
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
2994
|
+
// nor polyfill, then a plain number is used for performance.
|
|
2995
|
+
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
2996
|
+
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
2997
|
+
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
|
2998
|
+
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
|
2999
|
+
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
|
3000
|
+
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
|
3001
|
+
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
3002
|
+
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
|
|
3003
|
+
// (unstable) APIs that have been removed. Can we remove the symbols?
|
|
3004
|
+
|
|
3005
|
+
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
|
3006
|
+
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
|
3007
|
+
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
3008
|
+
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
|
3009
|
+
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
|
3010
|
+
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
|
3011
|
+
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
|
3012
|
+
var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
|
|
3013
|
+
var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
|
|
3014
|
+
var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
|
|
3015
|
+
var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
|
|
3016
|
+
|
|
3017
|
+
function isValidElementType(type) {
|
|
3018
|
+
return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
|
3019
|
+
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (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 || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
|
|
3020
|
+
}
|
|
3021
|
+
|
|
3022
|
+
function typeOf(object) {
|
|
3023
|
+
if (typeof object === 'object' && object !== null) {
|
|
3024
|
+
var $$typeof = object.$$typeof;
|
|
3025
|
+
|
|
3026
|
+
switch ($$typeof) {
|
|
3027
|
+
case REACT_ELEMENT_TYPE:
|
|
3028
|
+
var type = object.type;
|
|
3029
|
+
|
|
3030
|
+
switch (type) {
|
|
3031
|
+
case REACT_ASYNC_MODE_TYPE:
|
|
3032
|
+
case REACT_CONCURRENT_MODE_TYPE:
|
|
3033
|
+
case REACT_FRAGMENT_TYPE:
|
|
3034
|
+
case REACT_PROFILER_TYPE:
|
|
3035
|
+
case REACT_STRICT_MODE_TYPE:
|
|
3036
|
+
case REACT_SUSPENSE_TYPE:
|
|
3037
|
+
return type;
|
|
3038
|
+
|
|
3039
|
+
default:
|
|
3040
|
+
var $$typeofType = type && type.$$typeof;
|
|
3041
|
+
|
|
3042
|
+
switch ($$typeofType) {
|
|
3043
|
+
case REACT_CONTEXT_TYPE:
|
|
3044
|
+
case REACT_FORWARD_REF_TYPE:
|
|
3045
|
+
case REACT_LAZY_TYPE:
|
|
3046
|
+
case REACT_MEMO_TYPE:
|
|
3047
|
+
case REACT_PROVIDER_TYPE:
|
|
3048
|
+
return $$typeofType;
|
|
3049
|
+
|
|
3050
|
+
default:
|
|
3051
|
+
return $$typeof;
|
|
3052
|
+
}
|
|
3053
|
+
|
|
3054
|
+
}
|
|
3055
|
+
|
|
3056
|
+
case REACT_PORTAL_TYPE:
|
|
3057
|
+
return $$typeof;
|
|
3058
|
+
}
|
|
3059
|
+
}
|
|
3060
|
+
|
|
3061
|
+
return undefined;
|
|
3062
|
+
} // AsyncMode is deprecated along with isAsyncMode
|
|
3063
|
+
|
|
3064
|
+
var AsyncMode = REACT_ASYNC_MODE_TYPE;
|
|
3065
|
+
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
|
3066
|
+
var ContextConsumer = REACT_CONTEXT_TYPE;
|
|
3067
|
+
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
3068
|
+
var Element = REACT_ELEMENT_TYPE;
|
|
3069
|
+
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
3070
|
+
var Fragment = REACT_FRAGMENT_TYPE;
|
|
3071
|
+
var Lazy = REACT_LAZY_TYPE;
|
|
3072
|
+
var Memo = REACT_MEMO_TYPE;
|
|
3073
|
+
var Portal = REACT_PORTAL_TYPE;
|
|
3074
|
+
var Profiler = REACT_PROFILER_TYPE;
|
|
3075
|
+
var StrictMode = REACT_STRICT_MODE_TYPE;
|
|
3076
|
+
var Suspense = REACT_SUSPENSE_TYPE;
|
|
3077
|
+
var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
|
|
3078
|
+
|
|
3079
|
+
function isAsyncMode(object) {
|
|
3080
|
+
{
|
|
3081
|
+
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
|
3082
|
+
hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
|
|
3083
|
+
|
|
3084
|
+
console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
|
|
3085
|
+
}
|
|
3086
|
+
}
|
|
3087
|
+
|
|
3088
|
+
return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
|
|
3089
|
+
}
|
|
3090
|
+
function isConcurrentMode(object) {
|
|
3091
|
+
return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
|
|
3092
|
+
}
|
|
3093
|
+
function isContextConsumer(object) {
|
|
3094
|
+
return typeOf(object) === REACT_CONTEXT_TYPE;
|
|
3095
|
+
}
|
|
3096
|
+
function isContextProvider(object) {
|
|
3097
|
+
return typeOf(object) === REACT_PROVIDER_TYPE;
|
|
3098
|
+
}
|
|
3099
|
+
function isElement(object) {
|
|
3100
|
+
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
3101
|
+
}
|
|
3102
|
+
function isForwardRef(object) {
|
|
3103
|
+
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
3104
|
+
}
|
|
3105
|
+
function isFragment(object) {
|
|
3106
|
+
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
|
3107
|
+
}
|
|
3108
|
+
function isLazy(object) {
|
|
3109
|
+
return typeOf(object) === REACT_LAZY_TYPE;
|
|
3110
|
+
}
|
|
3111
|
+
function isMemo(object) {
|
|
3112
|
+
return typeOf(object) === REACT_MEMO_TYPE;
|
|
3113
|
+
}
|
|
3114
|
+
function isPortal(object) {
|
|
3115
|
+
return typeOf(object) === REACT_PORTAL_TYPE;
|
|
3116
|
+
}
|
|
3117
|
+
function isProfiler(object) {
|
|
3118
|
+
return typeOf(object) === REACT_PROFILER_TYPE;
|
|
3119
|
+
}
|
|
3120
|
+
function isStrictMode(object) {
|
|
3121
|
+
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
|
3122
|
+
}
|
|
3123
|
+
function isSuspense(object) {
|
|
3124
|
+
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
|
3125
|
+
}
|
|
3126
|
+
|
|
3127
|
+
exports.AsyncMode = AsyncMode;
|
|
3128
|
+
exports.ConcurrentMode = ConcurrentMode;
|
|
3129
|
+
exports.ContextConsumer = ContextConsumer;
|
|
3130
|
+
exports.ContextProvider = ContextProvider;
|
|
3131
|
+
exports.Element = Element;
|
|
3132
|
+
exports.ForwardRef = ForwardRef;
|
|
3133
|
+
exports.Fragment = Fragment;
|
|
3134
|
+
exports.Lazy = Lazy;
|
|
3135
|
+
exports.Memo = Memo;
|
|
3136
|
+
exports.Portal = Portal;
|
|
3137
|
+
exports.Profiler = Profiler;
|
|
3138
|
+
exports.StrictMode = StrictMode;
|
|
3139
|
+
exports.Suspense = Suspense;
|
|
3140
|
+
exports.isAsyncMode = isAsyncMode;
|
|
3141
|
+
exports.isConcurrentMode = isConcurrentMode;
|
|
3142
|
+
exports.isContextConsumer = isContextConsumer;
|
|
3143
|
+
exports.isContextProvider = isContextProvider;
|
|
3144
|
+
exports.isElement = isElement;
|
|
3145
|
+
exports.isForwardRef = isForwardRef;
|
|
3146
|
+
exports.isFragment = isFragment;
|
|
3147
|
+
exports.isLazy = isLazy;
|
|
3148
|
+
exports.isMemo = isMemo;
|
|
3149
|
+
exports.isPortal = isPortal;
|
|
3150
|
+
exports.isProfiler = isProfiler;
|
|
3151
|
+
exports.isStrictMode = isStrictMode;
|
|
3152
|
+
exports.isSuspense = isSuspense;
|
|
3153
|
+
exports.isValidElementType = isValidElementType;
|
|
3154
|
+
exports.typeOf = typeOf;
|
|
3155
|
+
})();
|
|
3156
|
+
}
|
|
3157
|
+
|
|
3158
|
+
|
|
3159
|
+
/***/ }),
|
|
3160
|
+
|
|
3161
|
+
/***/ "./node_modules/react-is/index.js":
|
|
3162
|
+
/*!****************************************!*\
|
|
3163
|
+
!*** ./node_modules/react-is/index.js ***!
|
|
3164
|
+
\****************************************/
|
|
3165
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
3166
|
+
|
|
3167
|
+
"use strict";
|
|
3168
|
+
|
|
3169
|
+
|
|
3170
|
+
if (false) {} else {
|
|
3171
|
+
module.exports = __webpack_require__(/*! ./cjs/react-is.development.js */ "./node_modules/react-is/cjs/react-is.development.js");
|
|
3172
|
+
}
|
|
3173
|
+
|
|
3174
|
+
|
|
3175
|
+
/***/ }),
|
|
3176
|
+
|
|
3177
|
+
/***/ "expensify-common/lib/str":
|
|
3178
|
+
/*!*******************************************!*\
|
|
3179
|
+
!*** external "expensify-common/lib/str" ***!
|
|
3180
|
+
\*******************************************/
|
|
3181
|
+
/***/ ((module) => {
|
|
3182
|
+
|
|
3183
|
+
"use strict";
|
|
3184
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_expensify_common_lib_str__;
|
|
3185
|
+
|
|
3186
|
+
/***/ }),
|
|
3187
|
+
|
|
3188
|
+
/***/ "localforage":
|
|
3189
|
+
/*!******************************!*\
|
|
3190
|
+
!*** external "localforage" ***!
|
|
3191
|
+
\******************************/
|
|
3192
|
+
/***/ ((module) => {
|
|
3193
|
+
|
|
3194
|
+
"use strict";
|
|
3195
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_localforage__;
|
|
3196
|
+
|
|
3197
|
+
/***/ }),
|
|
3198
|
+
|
|
3199
|
+
/***/ "lodash/merge":
|
|
3200
|
+
/*!*******************************!*\
|
|
3201
|
+
!*** external "lodash/merge" ***!
|
|
3202
|
+
\*******************************/
|
|
3203
|
+
/***/ ((module) => {
|
|
3204
|
+
|
|
3205
|
+
"use strict";
|
|
3206
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_lodash_merge__;
|
|
3207
|
+
|
|
3208
|
+
/***/ }),
|
|
3209
|
+
|
|
3210
|
+
/***/ "react":
|
|
3211
|
+
/*!************************!*\
|
|
3212
|
+
!*** external "react" ***!
|
|
3213
|
+
\************************/
|
|
3214
|
+
/***/ ((module) => {
|
|
3215
|
+
|
|
3216
|
+
"use strict";
|
|
3217
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_react__;
|
|
3218
|
+
|
|
3219
|
+
/***/ }),
|
|
3220
|
+
|
|
3221
|
+
/***/ "underscore":
|
|
3222
|
+
/*!*****************************!*\
|
|
3223
|
+
!*** external "underscore" ***!
|
|
3224
|
+
\*****************************/
|
|
3225
|
+
/***/ ((module) => {
|
|
3226
|
+
|
|
3227
|
+
"use strict";
|
|
3228
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_underscore__;
|
|
3229
|
+
|
|
3230
|
+
/***/ })
|
|
3231
|
+
|
|
3232
|
+
/******/ });
|
|
3233
|
+
/************************************************************************/
|
|
3234
|
+
/******/ // The module cache
|
|
3235
|
+
/******/ var __webpack_module_cache__ = {};
|
|
3236
|
+
/******/
|
|
3237
|
+
/******/ // The require function
|
|
3238
|
+
/******/ function __webpack_require__(moduleId) {
|
|
3239
|
+
/******/ // Check if module is in cache
|
|
3240
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
3241
|
+
/******/ if (cachedModule !== undefined) {
|
|
3242
|
+
/******/ return cachedModule.exports;
|
|
3243
|
+
/******/ }
|
|
3244
|
+
/******/ // Create a new module (and put it into the cache)
|
|
3245
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
3246
|
+
/******/ // no module.id needed
|
|
3247
|
+
/******/ // no module.loaded needed
|
|
3248
|
+
/******/ exports: {}
|
|
3249
|
+
/******/ };
|
|
3250
|
+
/******/
|
|
3251
|
+
/******/ // Execute the module function
|
|
3252
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
3253
|
+
/******/
|
|
3254
|
+
/******/ // Return the exports of the module
|
|
3255
|
+
/******/ return module.exports;
|
|
3256
|
+
/******/ }
|
|
3257
|
+
/******/
|
|
3258
|
+
/************************************************************************/
|
|
3259
|
+
/******/ /* webpack/runtime/global */
|
|
3260
|
+
/******/ (() => {
|
|
3261
|
+
/******/ __webpack_require__.g = (function() {
|
|
3262
|
+
/******/ if (typeof globalThis === 'object') return globalThis;
|
|
3263
|
+
/******/ try {
|
|
3264
|
+
/******/ return this || new Function('return this')();
|
|
3265
|
+
/******/ } catch (e) {
|
|
3266
|
+
/******/ if (typeof window === 'object') return window;
|
|
3267
|
+
/******/ }
|
|
3268
|
+
/******/ })();
|
|
3269
|
+
/******/ })();
|
|
3270
|
+
/******/
|
|
3271
|
+
/************************************************************************/
|
|
3272
|
+
var __webpack_exports__ = {};
|
|
3273
|
+
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
3274
|
+
(() => {
|
|
3275
|
+
var exports = __webpack_exports__;
|
|
3276
|
+
/*!**********************!*\
|
|
3277
|
+
!*** ./lib/index.js ***!
|
|
3278
|
+
\**********************/
|
|
3279
|
+
var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");Object.defineProperty(exports, "__esModule", ({ value: true }));Object.defineProperty(exports, "withOnyx", ({ enumerable: true, get: function get() {return _withOnyx.default;} }));exports["default"] = void 0;var _Onyx = _interopRequireDefault(__webpack_require__(/*! ./Onyx */ "./lib/Onyx.js"));
|
|
3280
|
+
var _withOnyx = _interopRequireDefault(__webpack_require__(/*! ./withOnyx */ "./lib/withOnyx.js"));var _default =
|
|
3281
|
+
|
|
3282
|
+
_Onyx.default;exports["default"] = _default;
|
|
3283
|
+
})();
|
|
3284
|
+
|
|
3285
|
+
/******/ return __webpack_exports__;
|
|
3286
|
+
/******/ })()
|
|
3287
|
+
;
|
|
3288
|
+
});
|
|
3289
|
+
//# sourceMappingURL=web.development.js.map
|