use-tus 0.2.5 → 0.5.0
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/README.md +201 -14
- package/dist/TusClientProvider/TusClientProvider.d.ts +4 -4
- package/dist/TusClientProvider/TusController.d.ts +4 -4
- package/dist/TusClientProvider/index.d.ts +2 -2
- package/dist/__stories__/Basic.stories.d.ts +5 -0
- package/dist/__stories__/CacheKey.stories.d.ts +5 -0
- package/dist/__stories__/DefaultOptions.stories.d.ts +5 -0
- package/dist/__stories__/components/BasicButton/BasicButton.d.ts +9 -0
- package/dist/__stories__/components/BasicButton/index.d.ts +1 -0
- package/dist/__stories__/components/LoadingCircle/LoadingCircle.d.ts +2 -0
- package/dist/__stories__/components/LoadingCircle/index.d.ts +1 -0
- package/dist/__stories__/components/ProgressBar/ProgressBar.d.ts +7 -0
- package/dist/__stories__/components/ProgressBar/index.d.ts +1 -0
- package/dist/__stories__/components/UploadIcon/UploadIcon.d.ts +2 -0
- package/dist/__stories__/components/UploadIcon/index.d.ts +1 -0
- package/dist/__stories__/constants.d.ts +1 -0
- package/dist/__tests__/TusClientProvider.test.d.ts +1 -0
- package/dist/__tests__/useTus.test.d.ts +1 -0
- package/dist/__tests__/utils/getBlob.d.ts +1 -0
- package/dist/__tests__/utils/mock.d.ts +5 -0
- package/dist/core/constants.d.ts +4 -4
- package/dist/core/contexts.d.ts +7 -7
- package/dist/core/tucClientActions.d.ts +50 -47
- package/dist/core/tusClientReducer.d.ts +18 -18
- package/dist/core/tusHandler.d.ts +17 -11
- package/dist/core/types.d.ts +8 -8
- package/dist/index.cjs.js +64 -1432
- package/dist/index.d.ts +4 -3
- package/dist/index.esm.js +51 -1416
- package/dist/index.js +385 -0
- package/dist/useTus/index.d.ts +2 -2
- package/dist/useTus/types.d.ts +15 -15
- package/dist/useTus/useTus.d.ts +2 -2
- package/dist/useTus/utils.d.ts +16 -16
- package/dist/useTusClient/index.d.ts +1 -0
- package/dist/useTusClient/useTusClient.d.ts +7 -0
- package/dist/utils/uid.d.ts +1 -1
- package/package.json +7 -7
package/dist/index.cjs.js
CHANGED
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var react = require('react');
|
|
6
6
|
var tus = require('tus-js-client');
|
|
7
7
|
|
|
8
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
-
|
|
10
8
|
function _interopNamespace(e) {
|
|
11
9
|
if (e && e.__esModule) return e;
|
|
12
10
|
var n = Object.create(null);
|
|
@@ -27,25 +25,8 @@ function _interopNamespace(e) {
|
|
|
27
25
|
return Object.freeze(n);
|
|
28
26
|
}
|
|
29
27
|
|
|
30
|
-
var f__default = /*#__PURE__*/_interopDefaultLegacy(f);
|
|
31
28
|
var tus__namespace = /*#__PURE__*/_interopNamespace(tus);
|
|
32
29
|
|
|
33
|
-
function _typeof(obj) {
|
|
34
|
-
"@babel/helpers - typeof";
|
|
35
|
-
|
|
36
|
-
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
37
|
-
_typeof = function (obj) {
|
|
38
|
-
return typeof obj;
|
|
39
|
-
};
|
|
40
|
-
} else {
|
|
41
|
-
_typeof = function (obj) {
|
|
42
|
-
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return _typeof(obj);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
30
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
50
31
|
try {
|
|
51
32
|
var info = gen[key](arg);
|
|
@@ -214,27 +195,27 @@ var ERROR_MESSAGES = {
|
|
|
214
195
|
tusIsNotSupported: 'This browser does not support uploads. Please use a modern browser instead.'
|
|
215
196
|
};
|
|
216
197
|
|
|
217
|
-
var TusClientStateContext =
|
|
218
|
-
var TusClientDispatchContext =
|
|
198
|
+
var TusClientStateContext = react.createContext(undefined);
|
|
199
|
+
var TusClientDispatchContext = react.createContext(undefined);
|
|
219
200
|
var useTusClientState = function useTusClientState() {
|
|
220
|
-
var tusClientState =
|
|
201
|
+
var tusClientState = react.useContext(TusClientStateContext);
|
|
221
202
|
|
|
222
203
|
if (!tusClientState && process.env.NODE_ENV !== 'production') {
|
|
223
204
|
throw new Error(ERROR_MESSAGES.tusClientHasNotFounded);
|
|
224
205
|
}
|
|
225
206
|
|
|
226
|
-
return
|
|
207
|
+
return react.useMemo(function () {
|
|
227
208
|
return tusClientState;
|
|
228
209
|
}, [tusClientState]);
|
|
229
210
|
};
|
|
230
211
|
var useTusClientDispatch = function useTusClientDispatch() {
|
|
231
|
-
var tusClientDispatch =
|
|
212
|
+
var tusClientDispatch = react.useContext(TusClientDispatchContext);
|
|
232
213
|
|
|
233
214
|
if (!tusClientDispatch && process.env.NODE_ENV !== 'production') {
|
|
234
215
|
throw new Error(ERROR_MESSAGES.tusClientHasNotFounded);
|
|
235
216
|
}
|
|
236
217
|
|
|
237
|
-
return
|
|
218
|
+
return react.useMemo(function () {
|
|
238
219
|
return tusClientDispatch;
|
|
239
220
|
}, [tusClientDispatch]);
|
|
240
221
|
};
|
|
@@ -374,8 +355,8 @@ var createUpload = function createUpload(file, options, _ref2) {
|
|
|
374
355
|
dispatchIsAborted(false);
|
|
375
356
|
};
|
|
376
357
|
|
|
377
|
-
var abort =
|
|
378
|
-
var _ref3 = _asyncToGenerator(
|
|
358
|
+
var abort = function () {
|
|
359
|
+
var _ref3 = _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
|
|
379
360
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
380
361
|
while (1) {
|
|
381
362
|
switch (_context.prev = _context.next) {
|
|
@@ -418,7 +399,7 @@ var useTus = function useTus(useTusOptions) {
|
|
|
418
399
|
autoAbort = _defaultUseTusOptions.autoAbort,
|
|
419
400
|
autoStart = _defaultUseTusOptions.autoStart;
|
|
420
401
|
|
|
421
|
-
var _useState =
|
|
402
|
+
var _useState = react.useState(initialUseTusState),
|
|
422
403
|
_useState2 = _slicedToArray(_useState, 2),
|
|
423
404
|
internalTusState = _useState2[0],
|
|
424
405
|
setInternalTusState = _useState2[1];
|
|
@@ -426,7 +407,7 @@ var useTus = function useTus(useTusOptions) {
|
|
|
426
407
|
var tusClientState = useTusClientState();
|
|
427
408
|
var tusClientDispatch = useTusClientDispatch();
|
|
428
409
|
var tus = tusClientState.tusHandler.getTus;
|
|
429
|
-
var setUpload =
|
|
410
|
+
var setUpload = react.useCallback(function (file) {
|
|
430
411
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
431
412
|
var dispatcher = {
|
|
432
413
|
cacheKey: cacheKey,
|
|
@@ -434,14 +415,16 @@ var useTus = function useTus(useTusOptions) {
|
|
|
434
415
|
internalDispatch: setInternalTusState
|
|
435
416
|
};
|
|
436
417
|
|
|
418
|
+
var targetOptions = _objectSpread2(_objectSpread2({}, tus.defaultOptions(file)), options);
|
|
419
|
+
|
|
437
420
|
var _createOptionHandler = createOptionHandler({
|
|
438
|
-
onError:
|
|
439
|
-
onSuccess:
|
|
421
|
+
onError: targetOptions.onError,
|
|
422
|
+
onSuccess: targetOptions.onSuccess
|
|
440
423
|
}, dispatcher),
|
|
441
424
|
onSuccess = _createOptionHandler.onSuccess,
|
|
442
425
|
onError = _createOptionHandler.onError;
|
|
443
426
|
|
|
444
|
-
var uploadOptions = _objectSpread2(_objectSpread2(
|
|
427
|
+
var uploadOptions = _objectSpread2(_objectSpread2({}, targetOptions), {}, {
|
|
445
428
|
onSuccess: onSuccess,
|
|
446
429
|
onError: onError
|
|
447
430
|
});
|
|
@@ -461,10 +444,10 @@ var useTus = function useTus(useTusOptions) {
|
|
|
461
444
|
upload: upload
|
|
462
445
|
}));
|
|
463
446
|
}, [tusClientDispatch, cacheKey, tus, autoStart]);
|
|
464
|
-
var targetTusState =
|
|
447
|
+
var targetTusState = react.useMemo(function () {
|
|
465
448
|
return cacheKey ? tusClientState.uploads[cacheKey] : internalTusState;
|
|
466
449
|
}, [cacheKey, tusClientState, internalTusState]);
|
|
467
|
-
var remove =
|
|
450
|
+
var remove = react.useCallback(function () {
|
|
468
451
|
var _targetTusState$uploa;
|
|
469
452
|
|
|
470
453
|
targetTusState === null || targetTusState === void 0 ? void 0 : (_targetTusState$uploa = targetTusState.upload) === null || _targetTusState$uploa === void 0 ? void 0 : _targetTusState$uploa.abort();
|
|
@@ -476,7 +459,7 @@ var useTus = function useTus(useTusOptions) {
|
|
|
476
459
|
|
|
477
460
|
tusClientDispatch(removeUploadInstance(cacheKey));
|
|
478
461
|
}, [targetTusState, tusClientDispatch, cacheKey]);
|
|
479
|
-
var tusResult =
|
|
462
|
+
var tusResult = react.useMemo(function () {
|
|
480
463
|
var _targetTusState$isSuc, _targetTusState$isAbo;
|
|
481
464
|
|
|
482
465
|
return {
|
|
@@ -487,11 +470,10 @@ var useTus = function useTus(useTusOptions) {
|
|
|
487
470
|
setUpload: setUpload,
|
|
488
471
|
remove: remove
|
|
489
472
|
};
|
|
490
|
-
}, [targetTusState, setUpload, remove]);
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
473
|
+
}, [targetTusState, setUpload, remove]);
|
|
474
|
+
react.useEffect(function () {
|
|
475
|
+
var abortUploading = function () {
|
|
476
|
+
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
|
|
495
477
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
496
478
|
while (1) {
|
|
497
479
|
switch (_context.prev = _context.next) {
|
|
@@ -531,1362 +513,10 @@ var useTus = function useTus(useTusOptions) {
|
|
|
531
513
|
return tusResult;
|
|
532
514
|
};
|
|
533
515
|
|
|
534
|
-
function
|
|
535
|
-
|
|
536
|
-
return fn(module, module.exports), module.exports;
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
/*
|
|
540
|
-
object-assign
|
|
541
|
-
(c) Sindre Sorhus
|
|
542
|
-
@license MIT
|
|
543
|
-
*/
|
|
544
|
-
/* eslint-disable no-unused-vars */
|
|
545
|
-
|
|
546
|
-
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
547
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
548
|
-
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
549
|
-
|
|
550
|
-
function toObject(val) {
|
|
551
|
-
if (val === null || val === undefined) {
|
|
552
|
-
throw new TypeError('Object.assign cannot be called with null or undefined');
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
return Object(val);
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
function shouldUseNative() {
|
|
559
|
-
try {
|
|
560
|
-
if (!Object.assign) {
|
|
561
|
-
return false;
|
|
562
|
-
} // Detect buggy property enumeration order in older V8 versions.
|
|
563
|
-
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
|
|
567
|
-
|
|
568
|
-
test1[5] = 'de';
|
|
569
|
-
|
|
570
|
-
if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
|
571
|
-
return false;
|
|
572
|
-
} // https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
var test2 = {};
|
|
576
|
-
|
|
577
|
-
for (var i = 0; i < 10; i++) {
|
|
578
|
-
test2['_' + String.fromCharCode(i)] = i;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
|
582
|
-
return test2[n];
|
|
583
|
-
});
|
|
584
|
-
|
|
585
|
-
if (order2.join('') !== '0123456789') {
|
|
586
|
-
return false;
|
|
587
|
-
} // https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
var test3 = {};
|
|
591
|
-
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
|
592
|
-
test3[letter] = letter;
|
|
593
|
-
});
|
|
594
|
-
|
|
595
|
-
if (Object.keys(Object.assign({}, test3)).join('') !== 'abcdefghijklmnopqrst') {
|
|
596
|
-
return false;
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
return true;
|
|
600
|
-
} catch (err) {
|
|
601
|
-
// We don't expect any of the above to throw, but better to be safe.
|
|
602
|
-
return false;
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
|
|
607
|
-
var from;
|
|
608
|
-
var to = toObject(target);
|
|
609
|
-
var symbols;
|
|
610
|
-
|
|
611
|
-
for (var s = 1; s < arguments.length; s++) {
|
|
612
|
-
from = Object(arguments[s]);
|
|
613
|
-
|
|
614
|
-
for (var key in from) {
|
|
615
|
-
if (hasOwnProperty.call(from, key)) {
|
|
616
|
-
to[key] = from[key];
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
if (getOwnPropertySymbols) {
|
|
621
|
-
symbols = getOwnPropertySymbols(from);
|
|
622
|
-
|
|
623
|
-
for (var i = 0; i < symbols.length; i++) {
|
|
624
|
-
if (propIsEnumerable.call(from, symbols[i])) {
|
|
625
|
-
to[symbols[i]] = from[symbols[i]];
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
return to;
|
|
516
|
+
var initialDefaultOptions = function initialDefaultOptions() {
|
|
517
|
+
return tus__namespace.defaultOptions;
|
|
632
518
|
};
|
|
633
|
-
|
|
634
|
-
/** @license React v17.0.2
|
|
635
|
-
* react-jsx-runtime.production.min.js
|
|
636
|
-
*
|
|
637
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
638
|
-
*
|
|
639
|
-
* This source code is licensed under the MIT license found in the
|
|
640
|
-
* LICENSE file in the root directory of this source tree.
|
|
641
|
-
*/
|
|
642
|
-
var reactJsxRuntime_production_min = createCommonjsModule(function (module, exports) {
|
|
643
|
-
|
|
644
|
-
var g = 60103;
|
|
645
|
-
exports.Fragment = 60107;
|
|
646
|
-
|
|
647
|
-
if ("function" === typeof Symbol && Symbol["for"]) {
|
|
648
|
-
var h = Symbol["for"];
|
|
649
|
-
g = h("react.element");
|
|
650
|
-
exports.Fragment = h("react.fragment");
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
var m = f__default['default'].__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,
|
|
654
|
-
n = Object.prototype.hasOwnProperty,
|
|
655
|
-
p = {
|
|
656
|
-
key: !0,
|
|
657
|
-
ref: !0,
|
|
658
|
-
__self: !0,
|
|
659
|
-
__source: !0
|
|
660
|
-
};
|
|
661
|
-
|
|
662
|
-
function q(c, a, k) {
|
|
663
|
-
var b,
|
|
664
|
-
d = {},
|
|
665
|
-
e = null,
|
|
666
|
-
l = null;
|
|
667
|
-
void 0 !== k && (e = "" + k);
|
|
668
|
-
void 0 !== a.key && (e = "" + a.key);
|
|
669
|
-
void 0 !== a.ref && (l = a.ref);
|
|
670
|
-
|
|
671
|
-
for (b in a) {
|
|
672
|
-
n.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
if (c && c.defaultProps) for (b in a = c.defaultProps, a) {
|
|
676
|
-
void 0 === d[b] && (d[b] = a[b]);
|
|
677
|
-
}
|
|
678
|
-
return {
|
|
679
|
-
$$typeof: g,
|
|
680
|
-
type: c,
|
|
681
|
-
key: e,
|
|
682
|
-
ref: l,
|
|
683
|
-
props: d,
|
|
684
|
-
_owner: m.current
|
|
685
|
-
};
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
exports.jsx = q;
|
|
689
|
-
exports.jsxs = q;
|
|
690
|
-
});
|
|
691
|
-
|
|
692
|
-
var reactJsxRuntime_development = createCommonjsModule(function (module, exports) {
|
|
693
|
-
|
|
694
|
-
if (process.env.NODE_ENV !== "production") {
|
|
695
|
-
(function () {
|
|
696
|
-
|
|
697
|
-
var React = f__default['default'];
|
|
698
|
-
var _assign = objectAssign; // ATTENTION
|
|
699
|
-
// When adding new symbols to this file,
|
|
700
|
-
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
|
701
|
-
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
702
|
-
// nor polyfill, then a plain number is used for performance.
|
|
703
|
-
|
|
704
|
-
var REACT_ELEMENT_TYPE = 0xeac7;
|
|
705
|
-
var REACT_PORTAL_TYPE = 0xeaca;
|
|
706
|
-
exports.Fragment = 0xeacb;
|
|
707
|
-
var REACT_STRICT_MODE_TYPE = 0xeacc;
|
|
708
|
-
var REACT_PROFILER_TYPE = 0xead2;
|
|
709
|
-
var REACT_PROVIDER_TYPE = 0xeacd;
|
|
710
|
-
var REACT_CONTEXT_TYPE = 0xeace;
|
|
711
|
-
var REACT_FORWARD_REF_TYPE = 0xead0;
|
|
712
|
-
var REACT_SUSPENSE_TYPE = 0xead1;
|
|
713
|
-
var REACT_SUSPENSE_LIST_TYPE = 0xead8;
|
|
714
|
-
var REACT_MEMO_TYPE = 0xead3;
|
|
715
|
-
var REACT_LAZY_TYPE = 0xead4;
|
|
716
|
-
var REACT_BLOCK_TYPE = 0xead9;
|
|
717
|
-
var REACT_SERVER_BLOCK_TYPE = 0xeada;
|
|
718
|
-
var REACT_FUNDAMENTAL_TYPE = 0xead5;
|
|
719
|
-
var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
|
|
720
|
-
var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
|
|
721
|
-
|
|
722
|
-
if (typeof Symbol === 'function' && Symbol["for"]) {
|
|
723
|
-
var symbolFor = Symbol["for"];
|
|
724
|
-
REACT_ELEMENT_TYPE = symbolFor('react.element');
|
|
725
|
-
REACT_PORTAL_TYPE = symbolFor('react.portal');
|
|
726
|
-
exports.Fragment = symbolFor('react.fragment');
|
|
727
|
-
REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
|
|
728
|
-
REACT_PROFILER_TYPE = symbolFor('react.profiler');
|
|
729
|
-
REACT_PROVIDER_TYPE = symbolFor('react.provider');
|
|
730
|
-
REACT_CONTEXT_TYPE = symbolFor('react.context');
|
|
731
|
-
REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
|
|
732
|
-
REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
|
|
733
|
-
REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
|
|
734
|
-
REACT_MEMO_TYPE = symbolFor('react.memo');
|
|
735
|
-
REACT_LAZY_TYPE = symbolFor('react.lazy');
|
|
736
|
-
REACT_BLOCK_TYPE = symbolFor('react.block');
|
|
737
|
-
REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
|
|
738
|
-
REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
|
|
739
|
-
symbolFor('react.scope');
|
|
740
|
-
symbolFor('react.opaque.id');
|
|
741
|
-
REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
|
|
742
|
-
symbolFor('react.offscreen');
|
|
743
|
-
REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
747
|
-
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
|
748
|
-
|
|
749
|
-
function getIteratorFn(maybeIterable) {
|
|
750
|
-
if (maybeIterable === null || _typeof(maybeIterable) !== 'object') {
|
|
751
|
-
return null;
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
|
755
|
-
|
|
756
|
-
if (typeof maybeIterator === 'function') {
|
|
757
|
-
return maybeIterator;
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
return null;
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
764
|
-
|
|
765
|
-
function error(format) {
|
|
766
|
-
{
|
|
767
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
768
|
-
args[_key2 - 1] = arguments[_key2];
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
printWarning('error', format, args);
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
function printWarning(level, format, args) {
|
|
776
|
-
// When changing this logic, you might want to also
|
|
777
|
-
// update consoleWithStackDev.www.js as well.
|
|
778
|
-
{
|
|
779
|
-
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
780
|
-
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
781
|
-
|
|
782
|
-
if (stack !== '') {
|
|
783
|
-
format += '%s';
|
|
784
|
-
args = args.concat([stack]);
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
var argsWithFormat = args.map(function (item) {
|
|
788
|
-
return '' + item;
|
|
789
|
-
}); // Careful: RN currently depends on this prefix
|
|
790
|
-
|
|
791
|
-
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
792
|
-
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
793
|
-
// eslint-disable-next-line react-internal/no-production-logging
|
|
794
|
-
|
|
795
|
-
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
796
|
-
}
|
|
797
|
-
} // Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
var enableScopeAPI = false; // Experimental Create Event Handle API.
|
|
801
|
-
|
|
802
|
-
function isValidElementType(type) {
|
|
803
|
-
if (typeof type === 'string' || typeof type === 'function') {
|
|
804
|
-
return true;
|
|
805
|
-
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
if (type === exports.Fragment || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI) {
|
|
809
|
-
return true;
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
if (_typeof(type) === 'object' && type !== null) {
|
|
813
|
-
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
|
|
814
|
-
return true;
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
return false;
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
function getWrappedName(outerType, innerType, wrapperName) {
|
|
822
|
-
var functionName = innerType.displayName || innerType.name || '';
|
|
823
|
-
return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
function getContextName(type) {
|
|
827
|
-
return type.displayName || 'Context';
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
function getComponentName(type) {
|
|
831
|
-
if (type == null) {
|
|
832
|
-
// Host root, text node or just invalid type.
|
|
833
|
-
return null;
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
{
|
|
837
|
-
if (typeof type.tag === 'number') {
|
|
838
|
-
error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
if (typeof type === 'function') {
|
|
843
|
-
return type.displayName || type.name || null;
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
if (typeof type === 'string') {
|
|
847
|
-
return type;
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
switch (type) {
|
|
851
|
-
case exports.Fragment:
|
|
852
|
-
return 'Fragment';
|
|
853
|
-
|
|
854
|
-
case REACT_PORTAL_TYPE:
|
|
855
|
-
return 'Portal';
|
|
856
|
-
|
|
857
|
-
case REACT_PROFILER_TYPE:
|
|
858
|
-
return 'Profiler';
|
|
859
|
-
|
|
860
|
-
case REACT_STRICT_MODE_TYPE:
|
|
861
|
-
return 'StrictMode';
|
|
862
|
-
|
|
863
|
-
case REACT_SUSPENSE_TYPE:
|
|
864
|
-
return 'Suspense';
|
|
865
|
-
|
|
866
|
-
case REACT_SUSPENSE_LIST_TYPE:
|
|
867
|
-
return 'SuspenseList';
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
if (_typeof(type) === 'object') {
|
|
871
|
-
switch (type.$$typeof) {
|
|
872
|
-
case REACT_CONTEXT_TYPE:
|
|
873
|
-
var context = type;
|
|
874
|
-
return getContextName(context) + '.Consumer';
|
|
875
|
-
|
|
876
|
-
case REACT_PROVIDER_TYPE:
|
|
877
|
-
var provider = type;
|
|
878
|
-
return getContextName(provider._context) + '.Provider';
|
|
879
|
-
|
|
880
|
-
case REACT_FORWARD_REF_TYPE:
|
|
881
|
-
return getWrappedName(type, type.render, 'ForwardRef');
|
|
882
|
-
|
|
883
|
-
case REACT_MEMO_TYPE:
|
|
884
|
-
return getComponentName(type.type);
|
|
885
|
-
|
|
886
|
-
case REACT_BLOCK_TYPE:
|
|
887
|
-
return getComponentName(type._render);
|
|
888
|
-
|
|
889
|
-
case REACT_LAZY_TYPE:
|
|
890
|
-
{
|
|
891
|
-
var lazyComponent = type;
|
|
892
|
-
var payload = lazyComponent._payload;
|
|
893
|
-
var init = lazyComponent._init;
|
|
894
|
-
|
|
895
|
-
try {
|
|
896
|
-
return getComponentName(init(payload));
|
|
897
|
-
} catch (x) {
|
|
898
|
-
return null;
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
return null;
|
|
905
|
-
} // Helpers to patch console.logs to avoid logging during side-effect free
|
|
906
|
-
// replaying on render function. This currently only patches the object
|
|
907
|
-
// lazily which won't cover if the log function was extracted eagerly.
|
|
908
|
-
// We could also eagerly patch the method.
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
var disabledDepth = 0;
|
|
912
|
-
var prevLog;
|
|
913
|
-
var prevInfo;
|
|
914
|
-
var prevWarn;
|
|
915
|
-
var prevError;
|
|
916
|
-
var prevGroup;
|
|
917
|
-
var prevGroupCollapsed;
|
|
918
|
-
var prevGroupEnd;
|
|
919
|
-
|
|
920
|
-
function disabledLog() {}
|
|
921
|
-
|
|
922
|
-
disabledLog.__reactDisabledLog = true;
|
|
923
|
-
|
|
924
|
-
function disableLogs() {
|
|
925
|
-
{
|
|
926
|
-
if (disabledDepth === 0) {
|
|
927
|
-
/* eslint-disable react-internal/no-production-logging */
|
|
928
|
-
prevLog = console.log;
|
|
929
|
-
prevInfo = console.info;
|
|
930
|
-
prevWarn = console.warn;
|
|
931
|
-
prevError = console.error;
|
|
932
|
-
prevGroup = console.group;
|
|
933
|
-
prevGroupCollapsed = console.groupCollapsed;
|
|
934
|
-
prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
|
|
935
|
-
|
|
936
|
-
var props = {
|
|
937
|
-
configurable: true,
|
|
938
|
-
enumerable: true,
|
|
939
|
-
value: disabledLog,
|
|
940
|
-
writable: true
|
|
941
|
-
}; // $FlowFixMe Flow thinks console is immutable.
|
|
942
|
-
|
|
943
|
-
Object.defineProperties(console, {
|
|
944
|
-
info: props,
|
|
945
|
-
log: props,
|
|
946
|
-
warn: props,
|
|
947
|
-
error: props,
|
|
948
|
-
group: props,
|
|
949
|
-
groupCollapsed: props,
|
|
950
|
-
groupEnd: props
|
|
951
|
-
});
|
|
952
|
-
/* eslint-enable react-internal/no-production-logging */
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
disabledDepth++;
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
function reenableLogs() {
|
|
960
|
-
{
|
|
961
|
-
disabledDepth--;
|
|
962
|
-
|
|
963
|
-
if (disabledDepth === 0) {
|
|
964
|
-
/* eslint-disable react-internal/no-production-logging */
|
|
965
|
-
var props = {
|
|
966
|
-
configurable: true,
|
|
967
|
-
enumerable: true,
|
|
968
|
-
writable: true
|
|
969
|
-
}; // $FlowFixMe Flow thinks console is immutable.
|
|
970
|
-
|
|
971
|
-
Object.defineProperties(console, {
|
|
972
|
-
log: _assign({}, props, {
|
|
973
|
-
value: prevLog
|
|
974
|
-
}),
|
|
975
|
-
info: _assign({}, props, {
|
|
976
|
-
value: prevInfo
|
|
977
|
-
}),
|
|
978
|
-
warn: _assign({}, props, {
|
|
979
|
-
value: prevWarn
|
|
980
|
-
}),
|
|
981
|
-
error: _assign({}, props, {
|
|
982
|
-
value: prevError
|
|
983
|
-
}),
|
|
984
|
-
group: _assign({}, props, {
|
|
985
|
-
value: prevGroup
|
|
986
|
-
}),
|
|
987
|
-
groupCollapsed: _assign({}, props, {
|
|
988
|
-
value: prevGroupCollapsed
|
|
989
|
-
}),
|
|
990
|
-
groupEnd: _assign({}, props, {
|
|
991
|
-
value: prevGroupEnd
|
|
992
|
-
})
|
|
993
|
-
});
|
|
994
|
-
/* eslint-enable react-internal/no-production-logging */
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
if (disabledDepth < 0) {
|
|
998
|
-
error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
|
1004
|
-
var prefix;
|
|
1005
|
-
|
|
1006
|
-
function describeBuiltInComponentFrame(name, source, ownerFn) {
|
|
1007
|
-
{
|
|
1008
|
-
if (prefix === undefined) {
|
|
1009
|
-
// Extract the VM specific prefix used by each line.
|
|
1010
|
-
try {
|
|
1011
|
-
throw Error();
|
|
1012
|
-
} catch (x) {
|
|
1013
|
-
var match = x.stack.trim().match(/\n( *(at )?)/);
|
|
1014
|
-
prefix = match && match[1] || '';
|
|
1015
|
-
}
|
|
1016
|
-
} // We use the prefix to ensure our stacks line up with native stack frames.
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
return '\n' + prefix + name;
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
var reentry = false;
|
|
1024
|
-
var componentFrameCache;
|
|
1025
|
-
{
|
|
1026
|
-
var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
|
|
1027
|
-
componentFrameCache = new PossiblyWeakMap();
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
function describeNativeComponentFrame(fn, construct) {
|
|
1031
|
-
// If something asked for a stack inside a fake render, it should get ignored.
|
|
1032
|
-
if (!fn || reentry) {
|
|
1033
|
-
return '';
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
{
|
|
1037
|
-
var frame = componentFrameCache.get(fn);
|
|
1038
|
-
|
|
1039
|
-
if (frame !== undefined) {
|
|
1040
|
-
return frame;
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
var control;
|
|
1044
|
-
reentry = true;
|
|
1045
|
-
var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
|
|
1046
|
-
|
|
1047
|
-
Error.prepareStackTrace = undefined;
|
|
1048
|
-
var previousDispatcher;
|
|
1049
|
-
{
|
|
1050
|
-
previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function
|
|
1051
|
-
// for warnings.
|
|
1052
|
-
|
|
1053
|
-
ReactCurrentDispatcher.current = null;
|
|
1054
|
-
disableLogs();
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
try {
|
|
1058
|
-
// This should throw.
|
|
1059
|
-
if (construct) {
|
|
1060
|
-
// Something should be setting the props in the constructor.
|
|
1061
|
-
var Fake = function Fake() {
|
|
1062
|
-
throw Error();
|
|
1063
|
-
}; // $FlowFixMe
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
Object.defineProperty(Fake.prototype, 'props', {
|
|
1067
|
-
set: function set() {
|
|
1068
|
-
// We use a throwing setter instead of frozen or non-writable props
|
|
1069
|
-
// because that won't throw in a non-strict mode function.
|
|
1070
|
-
throw Error();
|
|
1071
|
-
}
|
|
1072
|
-
});
|
|
1073
|
-
|
|
1074
|
-
if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === 'object' && Reflect.construct) {
|
|
1075
|
-
// We construct a different control for this case to include any extra
|
|
1076
|
-
// frames added by the construct call.
|
|
1077
|
-
try {
|
|
1078
|
-
Reflect.construct(Fake, []);
|
|
1079
|
-
} catch (x) {
|
|
1080
|
-
control = x;
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
Reflect.construct(fn, [], Fake);
|
|
1084
|
-
} else {
|
|
1085
|
-
try {
|
|
1086
|
-
Fake.call();
|
|
1087
|
-
} catch (x) {
|
|
1088
|
-
control = x;
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
fn.call(Fake.prototype);
|
|
1092
|
-
}
|
|
1093
|
-
} else {
|
|
1094
|
-
try {
|
|
1095
|
-
throw Error();
|
|
1096
|
-
} catch (x) {
|
|
1097
|
-
control = x;
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
fn();
|
|
1101
|
-
}
|
|
1102
|
-
} catch (sample) {
|
|
1103
|
-
// This is inlined manually because closure doesn't do it for us.
|
|
1104
|
-
if (sample && control && typeof sample.stack === 'string') {
|
|
1105
|
-
// This extracts the first frame from the sample that isn't also in the control.
|
|
1106
|
-
// Skipping one frame that we assume is the frame that calls the two.
|
|
1107
|
-
var sampleLines = sample.stack.split('\n');
|
|
1108
|
-
var controlLines = control.stack.split('\n');
|
|
1109
|
-
var s = sampleLines.length - 1;
|
|
1110
|
-
var c = controlLines.length - 1;
|
|
1111
|
-
|
|
1112
|
-
while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
|
|
1113
|
-
// We expect at least one stack frame to be shared.
|
|
1114
|
-
// Typically this will be the root most one. However, stack frames may be
|
|
1115
|
-
// cut off due to maximum stack limits. In this case, one maybe cut off
|
|
1116
|
-
// earlier than the other. We assume that the sample is longer or the same
|
|
1117
|
-
// and there for cut off earlier. So we should find the root most frame in
|
|
1118
|
-
// the sample somewhere in the control.
|
|
1119
|
-
c--;
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
for (; s >= 1 && c >= 0; s--, c--) {
|
|
1123
|
-
// Next we find the first one that isn't the same which should be the
|
|
1124
|
-
// frame that called our sample function and the control.
|
|
1125
|
-
if (sampleLines[s] !== controlLines[c]) {
|
|
1126
|
-
// In V8, the first line is describing the message but other VMs don't.
|
|
1127
|
-
// If we're about to return the first line, and the control is also on the same
|
|
1128
|
-
// line, that's a pretty good indicator that our sample threw at same line as
|
|
1129
|
-
// the control. I.e. before we entered the sample frame. So we ignore this result.
|
|
1130
|
-
// This can happen if you passed a class to function component, or non-function.
|
|
1131
|
-
if (s !== 1 || c !== 1) {
|
|
1132
|
-
do {
|
|
1133
|
-
s--;
|
|
1134
|
-
c--; // We may still have similar intermediate frames from the construct call.
|
|
1135
|
-
// The next one that isn't the same should be our match though.
|
|
1136
|
-
|
|
1137
|
-
if (c < 0 || sampleLines[s] !== controlLines[c]) {
|
|
1138
|
-
// V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
|
|
1139
|
-
var _frame = '\n' + sampleLines[s].replace(' at new ', ' at ');
|
|
1140
|
-
|
|
1141
|
-
{
|
|
1142
|
-
if (typeof fn === 'function') {
|
|
1143
|
-
componentFrameCache.set(fn, _frame);
|
|
1144
|
-
}
|
|
1145
|
-
} // Return the line we found.
|
|
1146
|
-
|
|
1147
|
-
return _frame;
|
|
1148
|
-
}
|
|
1149
|
-
} while (s >= 1 && c >= 0);
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
break;
|
|
1153
|
-
}
|
|
1154
|
-
}
|
|
1155
|
-
}
|
|
1156
|
-
} finally {
|
|
1157
|
-
reentry = false;
|
|
1158
|
-
{
|
|
1159
|
-
ReactCurrentDispatcher.current = previousDispatcher;
|
|
1160
|
-
reenableLogs();
|
|
1161
|
-
}
|
|
1162
|
-
Error.prepareStackTrace = previousPrepareStackTrace;
|
|
1163
|
-
} // Fallback to just using the name if we couldn't make it throw.
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
var name = fn ? fn.displayName || fn.name : '';
|
|
1167
|
-
var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
|
|
1168
|
-
{
|
|
1169
|
-
if (typeof fn === 'function') {
|
|
1170
|
-
componentFrameCache.set(fn, syntheticFrame);
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1173
|
-
return syntheticFrame;
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
function describeFunctionComponentFrame(fn, source, ownerFn) {
|
|
1177
|
-
{
|
|
1178
|
-
return describeNativeComponentFrame(fn, false);
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
|
|
1182
|
-
function shouldConstruct(Component) {
|
|
1183
|
-
var prototype = Component.prototype;
|
|
1184
|
-
return !!(prototype && prototype.isReactComponent);
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
|
|
1188
|
-
if (type == null) {
|
|
1189
|
-
return '';
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
if (typeof type === 'function') {
|
|
1193
|
-
{
|
|
1194
|
-
return describeNativeComponentFrame(type, shouldConstruct(type));
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
|
-
if (typeof type === 'string') {
|
|
1199
|
-
return describeBuiltInComponentFrame(type);
|
|
1200
|
-
}
|
|
1201
|
-
|
|
1202
|
-
switch (type) {
|
|
1203
|
-
case REACT_SUSPENSE_TYPE:
|
|
1204
|
-
return describeBuiltInComponentFrame('Suspense');
|
|
1205
|
-
|
|
1206
|
-
case REACT_SUSPENSE_LIST_TYPE:
|
|
1207
|
-
return describeBuiltInComponentFrame('SuspenseList');
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
if (_typeof(type) === 'object') {
|
|
1211
|
-
switch (type.$$typeof) {
|
|
1212
|
-
case REACT_FORWARD_REF_TYPE:
|
|
1213
|
-
return describeFunctionComponentFrame(type.render);
|
|
1214
|
-
|
|
1215
|
-
case REACT_MEMO_TYPE:
|
|
1216
|
-
// Memo may contain any component type so we recursively resolve it.
|
|
1217
|
-
return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
|
|
1218
|
-
|
|
1219
|
-
case REACT_BLOCK_TYPE:
|
|
1220
|
-
return describeFunctionComponentFrame(type._render);
|
|
1221
|
-
|
|
1222
|
-
case REACT_LAZY_TYPE:
|
|
1223
|
-
{
|
|
1224
|
-
var lazyComponent = type;
|
|
1225
|
-
var payload = lazyComponent._payload;
|
|
1226
|
-
var init = lazyComponent._init;
|
|
1227
|
-
|
|
1228
|
-
try {
|
|
1229
|
-
// Lazy may contain any component type so we recursively resolve it.
|
|
1230
|
-
return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
|
|
1231
|
-
} catch (x) {}
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
|
-
return '';
|
|
1237
|
-
}
|
|
1238
|
-
|
|
1239
|
-
var loggedTypeFailures = {};
|
|
1240
|
-
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
1241
|
-
|
|
1242
|
-
function setCurrentlyValidatingElement(element) {
|
|
1243
|
-
{
|
|
1244
|
-
if (element) {
|
|
1245
|
-
var owner = element._owner;
|
|
1246
|
-
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
|
1247
|
-
ReactDebugCurrentFrame.setExtraStackFrame(stack);
|
|
1248
|
-
} else {
|
|
1249
|
-
ReactDebugCurrentFrame.setExtraStackFrame(null);
|
|
1250
|
-
}
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
|
|
1254
|
-
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
|
1255
|
-
{
|
|
1256
|
-
// $FlowFixMe This is okay but Flow doesn't know it.
|
|
1257
|
-
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
1258
|
-
|
|
1259
|
-
for (var typeSpecName in typeSpecs) {
|
|
1260
|
-
if (has(typeSpecs, typeSpecName)) {
|
|
1261
|
-
var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
|
|
1262
|
-
// fail the render phase where it didn't fail before. So we log it.
|
|
1263
|
-
// After these have been cleaned up, we'll let them throw.
|
|
1264
|
-
|
|
1265
|
-
try {
|
|
1266
|
-
// This is intentionally an invariant that gets caught. It's the same
|
|
1267
|
-
// behavior as without this statement except with a better message.
|
|
1268
|
-
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
1269
|
-
var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + _typeof(typeSpecs[typeSpecName]) + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
|
|
1270
|
-
err.name = 'Invariant Violation';
|
|
1271
|
-
throw err;
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
|
|
1275
|
-
} catch (ex) {
|
|
1276
|
-
error$1 = ex;
|
|
1277
|
-
}
|
|
1278
|
-
|
|
1279
|
-
if (error$1 && !(error$1 instanceof Error)) {
|
|
1280
|
-
setCurrentlyValidatingElement(element);
|
|
1281
|
-
error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, _typeof(error$1));
|
|
1282
|
-
setCurrentlyValidatingElement(null);
|
|
1283
|
-
}
|
|
1284
|
-
|
|
1285
|
-
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
|
1286
|
-
// Only monitor this failure once because there tends to be a lot of the
|
|
1287
|
-
// same error.
|
|
1288
|
-
loggedTypeFailures[error$1.message] = true;
|
|
1289
|
-
setCurrentlyValidatingElement(element);
|
|
1290
|
-
error('Failed %s type: %s', location, error$1.message);
|
|
1291
|
-
setCurrentlyValidatingElement(null);
|
|
1292
|
-
}
|
|
1293
|
-
}
|
|
1294
|
-
}
|
|
1295
|
-
}
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
|
-
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
|
1299
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
1300
|
-
var RESERVED_PROPS = {
|
|
1301
|
-
key: true,
|
|
1302
|
-
ref: true,
|
|
1303
|
-
__self: true,
|
|
1304
|
-
__source: true
|
|
1305
|
-
};
|
|
1306
|
-
var specialPropKeyWarningShown;
|
|
1307
|
-
var specialPropRefWarningShown;
|
|
1308
|
-
var didWarnAboutStringRefs;
|
|
1309
|
-
{
|
|
1310
|
-
didWarnAboutStringRefs = {};
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
function hasValidRef(config) {
|
|
1314
|
-
{
|
|
1315
|
-
if (hasOwnProperty.call(config, 'ref')) {
|
|
1316
|
-
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
|
1317
|
-
|
|
1318
|
-
if (getter && getter.isReactWarning) {
|
|
1319
|
-
return false;
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
return config.ref !== undefined;
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
function hasValidKey(config) {
|
|
1327
|
-
{
|
|
1328
|
-
if (hasOwnProperty.call(config, 'key')) {
|
|
1329
|
-
var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
|
1330
|
-
|
|
1331
|
-
if (getter && getter.isReactWarning) {
|
|
1332
|
-
return false;
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1336
|
-
return config.key !== undefined;
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
|
-
function warnIfStringRefCannotBeAutoConverted(config, self) {
|
|
1340
|
-
{
|
|
1341
|
-
if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {
|
|
1342
|
-
var componentName = getComponentName(ReactCurrentOwner.current.type);
|
|
1343
|
-
|
|
1344
|
-
if (!didWarnAboutStringRefs[componentName]) {
|
|
1345
|
-
error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', getComponentName(ReactCurrentOwner.current.type), config.ref);
|
|
1346
|
-
didWarnAboutStringRefs[componentName] = true;
|
|
1347
|
-
}
|
|
1348
|
-
}
|
|
1349
|
-
}
|
|
1350
|
-
}
|
|
1351
|
-
|
|
1352
|
-
function defineKeyPropWarningGetter(props, displayName) {
|
|
1353
|
-
{
|
|
1354
|
-
var warnAboutAccessingKey = function warnAboutAccessingKey() {
|
|
1355
|
-
if (!specialPropKeyWarningShown) {
|
|
1356
|
-
specialPropKeyWarningShown = true;
|
|
1357
|
-
error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
|
1358
|
-
}
|
|
1359
|
-
};
|
|
1360
|
-
|
|
1361
|
-
warnAboutAccessingKey.isReactWarning = true;
|
|
1362
|
-
Object.defineProperty(props, 'key', {
|
|
1363
|
-
get: warnAboutAccessingKey,
|
|
1364
|
-
configurable: true
|
|
1365
|
-
});
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1368
|
-
|
|
1369
|
-
function defineRefPropWarningGetter(props, displayName) {
|
|
1370
|
-
{
|
|
1371
|
-
var warnAboutAccessingRef = function warnAboutAccessingRef() {
|
|
1372
|
-
if (!specialPropRefWarningShown) {
|
|
1373
|
-
specialPropRefWarningShown = true;
|
|
1374
|
-
error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
|
1375
|
-
}
|
|
1376
|
-
};
|
|
1377
|
-
|
|
1378
|
-
warnAboutAccessingRef.isReactWarning = true;
|
|
1379
|
-
Object.defineProperty(props, 'ref', {
|
|
1380
|
-
get: warnAboutAccessingRef,
|
|
1381
|
-
configurable: true
|
|
1382
|
-
});
|
|
1383
|
-
}
|
|
1384
|
-
}
|
|
1385
|
-
/**
|
|
1386
|
-
* Factory method to create a new React element. This no longer adheres to
|
|
1387
|
-
* the class pattern, so do not use new to call it. Also, instanceof check
|
|
1388
|
-
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
|
|
1389
|
-
* if something is a React Element.
|
|
1390
|
-
*
|
|
1391
|
-
* @param {*} type
|
|
1392
|
-
* @param {*} props
|
|
1393
|
-
* @param {*} key
|
|
1394
|
-
* @param {string|object} ref
|
|
1395
|
-
* @param {*} owner
|
|
1396
|
-
* @param {*} self A *temporary* helper to detect places where `this` is
|
|
1397
|
-
* different from the `owner` when React.createElement is called, so that we
|
|
1398
|
-
* can warn. We want to get rid of owner and replace string `ref`s with arrow
|
|
1399
|
-
* functions, and as long as `this` and owner are the same, there will be no
|
|
1400
|
-
* change in behavior.
|
|
1401
|
-
* @param {*} source An annotation object (added by a transpiler or otherwise)
|
|
1402
|
-
* indicating filename, line number, and/or other information.
|
|
1403
|
-
* @internal
|
|
1404
|
-
*/
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
var ReactElement = function ReactElement(type, key, ref, self, source, owner, props) {
|
|
1408
|
-
var element = {
|
|
1409
|
-
// This tag allows us to uniquely identify this as a React Element
|
|
1410
|
-
$$typeof: REACT_ELEMENT_TYPE,
|
|
1411
|
-
// Built-in properties that belong on the element
|
|
1412
|
-
type: type,
|
|
1413
|
-
key: key,
|
|
1414
|
-
ref: ref,
|
|
1415
|
-
props: props,
|
|
1416
|
-
// Record the component responsible for creating this element.
|
|
1417
|
-
_owner: owner
|
|
1418
|
-
};
|
|
1419
|
-
{
|
|
1420
|
-
// The validation flag is currently mutative. We put it on
|
|
1421
|
-
// an external backing store so that we can freeze the whole object.
|
|
1422
|
-
// This can be replaced with a WeakMap once they are implemented in
|
|
1423
|
-
// commonly used development environments.
|
|
1424
|
-
element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
|
|
1425
|
-
// the validation flag non-enumerable (where possible, which should
|
|
1426
|
-
// include every environment we run tests in), so the test framework
|
|
1427
|
-
// ignores it.
|
|
1428
|
-
|
|
1429
|
-
Object.defineProperty(element._store, 'validated', {
|
|
1430
|
-
configurable: false,
|
|
1431
|
-
enumerable: false,
|
|
1432
|
-
writable: true,
|
|
1433
|
-
value: false
|
|
1434
|
-
}); // self and source are DEV only properties.
|
|
1435
|
-
|
|
1436
|
-
Object.defineProperty(element, '_self', {
|
|
1437
|
-
configurable: false,
|
|
1438
|
-
enumerable: false,
|
|
1439
|
-
writable: false,
|
|
1440
|
-
value: self
|
|
1441
|
-
}); // Two elements created in two different places should be considered
|
|
1442
|
-
// equal for testing purposes and therefore we hide it from enumeration.
|
|
1443
|
-
|
|
1444
|
-
Object.defineProperty(element, '_source', {
|
|
1445
|
-
configurable: false,
|
|
1446
|
-
enumerable: false,
|
|
1447
|
-
writable: false,
|
|
1448
|
-
value: source
|
|
1449
|
-
});
|
|
1450
|
-
|
|
1451
|
-
if (Object.freeze) {
|
|
1452
|
-
Object.freeze(element.props);
|
|
1453
|
-
Object.freeze(element);
|
|
1454
|
-
}
|
|
1455
|
-
}
|
|
1456
|
-
return element;
|
|
1457
|
-
};
|
|
1458
|
-
/**
|
|
1459
|
-
* https://github.com/reactjs/rfcs/pull/107
|
|
1460
|
-
* @param {*} type
|
|
1461
|
-
* @param {object} props
|
|
1462
|
-
* @param {string} key
|
|
1463
|
-
*/
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
function jsxDEV(type, config, maybeKey, source, self) {
|
|
1467
|
-
{
|
|
1468
|
-
var propName; // Reserved names are extracted
|
|
1469
|
-
|
|
1470
|
-
var props = {};
|
|
1471
|
-
var key = null;
|
|
1472
|
-
var ref = null; // Currently, key can be spread in as a prop. This causes a potential
|
|
1473
|
-
// issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
|
|
1474
|
-
// or <div key="Hi" {...props} /> ). We want to deprecate key spread,
|
|
1475
|
-
// but as an intermediary step, we will use jsxDEV for everything except
|
|
1476
|
-
// <div {...props} key="Hi" />, because we aren't currently able to tell if
|
|
1477
|
-
// key is explicitly declared to be undefined or not.
|
|
1478
|
-
|
|
1479
|
-
if (maybeKey !== undefined) {
|
|
1480
|
-
key = '' + maybeKey;
|
|
1481
|
-
}
|
|
1482
|
-
|
|
1483
|
-
if (hasValidKey(config)) {
|
|
1484
|
-
key = '' + config.key;
|
|
1485
|
-
}
|
|
1486
|
-
|
|
1487
|
-
if (hasValidRef(config)) {
|
|
1488
|
-
ref = config.ref;
|
|
1489
|
-
warnIfStringRefCannotBeAutoConverted(config, self);
|
|
1490
|
-
} // Remaining properties are added to a new props object
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
for (propName in config) {
|
|
1494
|
-
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
1495
|
-
props[propName] = config[propName];
|
|
1496
|
-
}
|
|
1497
|
-
} // Resolve default props
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
if (type && type.defaultProps) {
|
|
1501
|
-
var defaultProps = type.defaultProps;
|
|
1502
|
-
|
|
1503
|
-
for (propName in defaultProps) {
|
|
1504
|
-
if (props[propName] === undefined) {
|
|
1505
|
-
props[propName] = defaultProps[propName];
|
|
1506
|
-
}
|
|
1507
|
-
}
|
|
1508
|
-
}
|
|
1509
|
-
|
|
1510
|
-
if (key || ref) {
|
|
1511
|
-
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
|
1512
|
-
|
|
1513
|
-
if (key) {
|
|
1514
|
-
defineKeyPropWarningGetter(props, displayName);
|
|
1515
|
-
}
|
|
1516
|
-
|
|
1517
|
-
if (ref) {
|
|
1518
|
-
defineRefPropWarningGetter(props, displayName);
|
|
1519
|
-
}
|
|
1520
|
-
}
|
|
1521
|
-
|
|
1522
|
-
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
|
1523
|
-
}
|
|
1524
|
-
}
|
|
1525
|
-
|
|
1526
|
-
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
|
|
1527
|
-
var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
1528
|
-
|
|
1529
|
-
function setCurrentlyValidatingElement$1(element) {
|
|
1530
|
-
{
|
|
1531
|
-
if (element) {
|
|
1532
|
-
var owner = element._owner;
|
|
1533
|
-
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
|
1534
|
-
ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
|
|
1535
|
-
} else {
|
|
1536
|
-
ReactDebugCurrentFrame$1.setExtraStackFrame(null);
|
|
1537
|
-
}
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1540
|
-
|
|
1541
|
-
var propTypesMisspellWarningShown;
|
|
1542
|
-
{
|
|
1543
|
-
propTypesMisspellWarningShown = false;
|
|
1544
|
-
}
|
|
1545
|
-
/**
|
|
1546
|
-
* Verifies the object is a ReactElement.
|
|
1547
|
-
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
|
1548
|
-
* @param {?object} object
|
|
1549
|
-
* @return {boolean} True if `object` is a ReactElement.
|
|
1550
|
-
* @final
|
|
1551
|
-
*/
|
|
1552
|
-
|
|
1553
|
-
function isValidElement(object) {
|
|
1554
|
-
{
|
|
1555
|
-
return _typeof(object) === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
1556
|
-
}
|
|
1557
|
-
}
|
|
1558
|
-
|
|
1559
|
-
function getDeclarationErrorAddendum() {
|
|
1560
|
-
{
|
|
1561
|
-
if (ReactCurrentOwner$1.current) {
|
|
1562
|
-
var name = getComponentName(ReactCurrentOwner$1.current.type);
|
|
1563
|
-
|
|
1564
|
-
if (name) {
|
|
1565
|
-
return '\n\nCheck the render method of `' + name + '`.';
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
|
-
|
|
1569
|
-
return '';
|
|
1570
|
-
}
|
|
1571
|
-
}
|
|
1572
|
-
|
|
1573
|
-
function getSourceInfoErrorAddendum(source) {
|
|
1574
|
-
{
|
|
1575
|
-
if (source !== undefined) {
|
|
1576
|
-
var fileName = source.fileName.replace(/^.*[\\\/]/, '');
|
|
1577
|
-
var lineNumber = source.lineNumber;
|
|
1578
|
-
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
|
|
1579
|
-
}
|
|
1580
|
-
|
|
1581
|
-
return '';
|
|
1582
|
-
}
|
|
1583
|
-
}
|
|
1584
|
-
/**
|
|
1585
|
-
* Warn if there's no key explicitly set on dynamic arrays of children or
|
|
1586
|
-
* object keys are not valid. This allows us to keep track of children between
|
|
1587
|
-
* updates.
|
|
1588
|
-
*/
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
var ownerHasKeyUseWarning = {};
|
|
1592
|
-
|
|
1593
|
-
function getCurrentComponentErrorInfo(parentType) {
|
|
1594
|
-
{
|
|
1595
|
-
var info = getDeclarationErrorAddendum();
|
|
1596
|
-
|
|
1597
|
-
if (!info) {
|
|
1598
|
-
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
|
1599
|
-
|
|
1600
|
-
if (parentName) {
|
|
1601
|
-
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
|
1602
|
-
}
|
|
1603
|
-
}
|
|
1604
|
-
|
|
1605
|
-
return info;
|
|
1606
|
-
}
|
|
1607
|
-
}
|
|
1608
|
-
/**
|
|
1609
|
-
* Warn if the element doesn't have an explicit key assigned to it.
|
|
1610
|
-
* This element is in an array. The array could grow and shrink or be
|
|
1611
|
-
* reordered. All children that haven't already been validated are required to
|
|
1612
|
-
* have a "key" property assigned to it. Error statuses are cached so a warning
|
|
1613
|
-
* will only be shown once.
|
|
1614
|
-
*
|
|
1615
|
-
* @internal
|
|
1616
|
-
* @param {ReactElement} element Element that requires a key.
|
|
1617
|
-
* @param {*} parentType element's parent's type.
|
|
1618
|
-
*/
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
function validateExplicitKey(element, parentType) {
|
|
1622
|
-
{
|
|
1623
|
-
if (!element._store || element._store.validated || element.key != null) {
|
|
1624
|
-
return;
|
|
1625
|
-
}
|
|
1626
|
-
|
|
1627
|
-
element._store.validated = true;
|
|
1628
|
-
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
|
1629
|
-
|
|
1630
|
-
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
|
1631
|
-
return;
|
|
1632
|
-
}
|
|
1633
|
-
|
|
1634
|
-
ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
|
|
1635
|
-
// property, it may be the creator of the child that's responsible for
|
|
1636
|
-
// assigning it a key.
|
|
1637
|
-
|
|
1638
|
-
var childOwner = '';
|
|
1639
|
-
|
|
1640
|
-
if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
|
|
1641
|
-
// Give the component that originally created this child.
|
|
1642
|
-
childOwner = " It was passed a child from " + getComponentName(element._owner.type) + ".";
|
|
1643
|
-
}
|
|
1644
|
-
|
|
1645
|
-
setCurrentlyValidatingElement$1(element);
|
|
1646
|
-
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
|
1647
|
-
setCurrentlyValidatingElement$1(null);
|
|
1648
|
-
}
|
|
1649
|
-
}
|
|
1650
|
-
/**
|
|
1651
|
-
* Ensure that every element either is passed in a static location, in an
|
|
1652
|
-
* array with an explicit keys property defined, or in an object literal
|
|
1653
|
-
* with valid key property.
|
|
1654
|
-
*
|
|
1655
|
-
* @internal
|
|
1656
|
-
* @param {ReactNode} node Statically passed child of any type.
|
|
1657
|
-
* @param {*} parentType node's parent's type.
|
|
1658
|
-
*/
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
function validateChildKeys(node, parentType) {
|
|
1662
|
-
{
|
|
1663
|
-
if (_typeof(node) !== 'object') {
|
|
1664
|
-
return;
|
|
1665
|
-
}
|
|
1666
|
-
|
|
1667
|
-
if (Array.isArray(node)) {
|
|
1668
|
-
for (var i = 0; i < node.length; i++) {
|
|
1669
|
-
var child = node[i];
|
|
1670
|
-
|
|
1671
|
-
if (isValidElement(child)) {
|
|
1672
|
-
validateExplicitKey(child, parentType);
|
|
1673
|
-
}
|
|
1674
|
-
}
|
|
1675
|
-
} else if (isValidElement(node)) {
|
|
1676
|
-
// This element was passed in a valid location.
|
|
1677
|
-
if (node._store) {
|
|
1678
|
-
node._store.validated = true;
|
|
1679
|
-
}
|
|
1680
|
-
} else if (node) {
|
|
1681
|
-
var iteratorFn = getIteratorFn(node);
|
|
1682
|
-
|
|
1683
|
-
if (typeof iteratorFn === 'function') {
|
|
1684
|
-
// Entry iterators used to provide implicit keys,
|
|
1685
|
-
// but now we print a separate warning for them later.
|
|
1686
|
-
if (iteratorFn !== node.entries) {
|
|
1687
|
-
var iterator = iteratorFn.call(node);
|
|
1688
|
-
var step;
|
|
1689
|
-
|
|
1690
|
-
while (!(step = iterator.next()).done) {
|
|
1691
|
-
if (isValidElement(step.value)) {
|
|
1692
|
-
validateExplicitKey(step.value, parentType);
|
|
1693
|
-
}
|
|
1694
|
-
}
|
|
1695
|
-
}
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1698
|
-
}
|
|
1699
|
-
}
|
|
1700
|
-
/**
|
|
1701
|
-
* Given an element, validate that its props follow the propTypes definition,
|
|
1702
|
-
* provided by the type.
|
|
1703
|
-
*
|
|
1704
|
-
* @param {ReactElement} element
|
|
1705
|
-
*/
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
function validatePropTypes(element) {
|
|
1709
|
-
{
|
|
1710
|
-
var type = element.type;
|
|
1711
|
-
|
|
1712
|
-
if (type === null || type === undefined || typeof type === 'string') {
|
|
1713
|
-
return;
|
|
1714
|
-
}
|
|
1715
|
-
|
|
1716
|
-
var propTypes;
|
|
1717
|
-
|
|
1718
|
-
if (typeof type === 'function') {
|
|
1719
|
-
propTypes = type.propTypes;
|
|
1720
|
-
} else if (_typeof(type) === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
|
|
1721
|
-
// Inner props are checked in the reconciler.
|
|
1722
|
-
type.$$typeof === REACT_MEMO_TYPE)) {
|
|
1723
|
-
propTypes = type.propTypes;
|
|
1724
|
-
} else {
|
|
1725
|
-
return;
|
|
1726
|
-
}
|
|
1727
|
-
|
|
1728
|
-
if (propTypes) {
|
|
1729
|
-
// Intentionally inside to avoid triggering lazy initializers:
|
|
1730
|
-
var name = getComponentName(type);
|
|
1731
|
-
checkPropTypes(propTypes, element.props, 'prop', name, element);
|
|
1732
|
-
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
|
1733
|
-
propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
|
|
1734
|
-
|
|
1735
|
-
var _name = getComponentName(type);
|
|
1736
|
-
|
|
1737
|
-
error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
|
|
1738
|
-
}
|
|
1739
|
-
|
|
1740
|
-
if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
|
|
1741
|
-
error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
|
|
1742
|
-
}
|
|
1743
|
-
}
|
|
1744
|
-
}
|
|
1745
|
-
/**
|
|
1746
|
-
* Given a fragment, validate that it can only be provided with fragment props
|
|
1747
|
-
* @param {ReactElement} fragment
|
|
1748
|
-
*/
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
function validateFragmentProps(fragment) {
|
|
1752
|
-
{
|
|
1753
|
-
var keys = Object.keys(fragment.props);
|
|
1754
|
-
|
|
1755
|
-
for (var i = 0; i < keys.length; i++) {
|
|
1756
|
-
var key = keys[i];
|
|
1757
|
-
|
|
1758
|
-
if (key !== 'children' && key !== 'key') {
|
|
1759
|
-
setCurrentlyValidatingElement$1(fragment);
|
|
1760
|
-
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
|
1761
|
-
setCurrentlyValidatingElement$1(null);
|
|
1762
|
-
break;
|
|
1763
|
-
}
|
|
1764
|
-
}
|
|
1765
|
-
|
|
1766
|
-
if (fragment.ref !== null) {
|
|
1767
|
-
setCurrentlyValidatingElement$1(fragment);
|
|
1768
|
-
error('Invalid attribute `ref` supplied to `React.Fragment`.');
|
|
1769
|
-
setCurrentlyValidatingElement$1(null);
|
|
1770
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
}
|
|
1773
|
-
|
|
1774
|
-
function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
|
|
1775
|
-
{
|
|
1776
|
-
var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
|
|
1777
|
-
// succeed and there will likely be errors in render.
|
|
1778
|
-
|
|
1779
|
-
if (!validType) {
|
|
1780
|
-
var info = '';
|
|
1781
|
-
|
|
1782
|
-
if (type === undefined || _typeof(type) === 'object' && type !== null && Object.keys(type).length === 0) {
|
|
1783
|
-
info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
|
|
1784
|
-
}
|
|
1785
|
-
|
|
1786
|
-
var sourceInfo = getSourceInfoErrorAddendum(source);
|
|
1787
|
-
|
|
1788
|
-
if (sourceInfo) {
|
|
1789
|
-
info += sourceInfo;
|
|
1790
|
-
} else {
|
|
1791
|
-
info += getDeclarationErrorAddendum();
|
|
1792
|
-
}
|
|
1793
|
-
|
|
1794
|
-
var typeString;
|
|
1795
|
-
|
|
1796
|
-
if (type === null) {
|
|
1797
|
-
typeString = 'null';
|
|
1798
|
-
} else if (Array.isArray(type)) {
|
|
1799
|
-
typeString = 'array';
|
|
1800
|
-
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
|
1801
|
-
typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
|
|
1802
|
-
info = ' Did you accidentally export a JSX literal instead of a component?';
|
|
1803
|
-
} else {
|
|
1804
|
-
typeString = _typeof(type);
|
|
1805
|
-
}
|
|
1806
|
-
|
|
1807
|
-
error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
|
|
1808
|
-
}
|
|
1809
|
-
|
|
1810
|
-
var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
|
|
1811
|
-
// TODO: Drop this when these are no longer allowed as the type argument.
|
|
1812
|
-
|
|
1813
|
-
if (element == null) {
|
|
1814
|
-
return element;
|
|
1815
|
-
} // Skip key warning if the type isn't valid since our key validation logic
|
|
1816
|
-
// doesn't expect a non-string/function type and can throw confusing errors.
|
|
1817
|
-
// We don't want exception behavior to differ between dev and prod.
|
|
1818
|
-
// (Rendering will throw with a helpful message and as soon as the type is
|
|
1819
|
-
// fixed, the key warnings will appear.)
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
if (validType) {
|
|
1823
|
-
var children = props.children;
|
|
1824
|
-
|
|
1825
|
-
if (children !== undefined) {
|
|
1826
|
-
if (isStaticChildren) {
|
|
1827
|
-
if (Array.isArray(children)) {
|
|
1828
|
-
for (var i = 0; i < children.length; i++) {
|
|
1829
|
-
validateChildKeys(children[i], type);
|
|
1830
|
-
}
|
|
1831
|
-
|
|
1832
|
-
if (Object.freeze) {
|
|
1833
|
-
Object.freeze(children);
|
|
1834
|
-
}
|
|
1835
|
-
} else {
|
|
1836
|
-
error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
|
|
1837
|
-
}
|
|
1838
|
-
} else {
|
|
1839
|
-
validateChildKeys(children, type);
|
|
1840
|
-
}
|
|
1841
|
-
}
|
|
1842
|
-
}
|
|
1843
|
-
|
|
1844
|
-
if (type === exports.Fragment) {
|
|
1845
|
-
validateFragmentProps(element);
|
|
1846
|
-
} else {
|
|
1847
|
-
validatePropTypes(element);
|
|
1848
|
-
}
|
|
1849
|
-
|
|
1850
|
-
return element;
|
|
1851
|
-
}
|
|
1852
|
-
} // These two functions exist to still get child warnings in dev
|
|
1853
|
-
// even with the prod transform. This means that jsxDEV is purely
|
|
1854
|
-
// opt-in behavior for better messages but that we won't stop
|
|
1855
|
-
// giving you warnings if you use production apis.
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
function jsxWithValidationStatic(type, props, key) {
|
|
1859
|
-
{
|
|
1860
|
-
return jsxWithValidation(type, props, key, true);
|
|
1861
|
-
}
|
|
1862
|
-
}
|
|
1863
|
-
|
|
1864
|
-
function jsxWithValidationDynamic(type, props, key) {
|
|
1865
|
-
{
|
|
1866
|
-
return jsxWithValidation(type, props, key, false);
|
|
1867
|
-
}
|
|
1868
|
-
}
|
|
1869
|
-
|
|
1870
|
-
var jsx = jsxWithValidationDynamic; // we may want to special case jsxs internally to take advantage of static children.
|
|
1871
|
-
// for now we can ship identical prod functions
|
|
1872
|
-
|
|
1873
|
-
var jsxs = jsxWithValidationStatic;
|
|
1874
|
-
exports.jsx = jsx;
|
|
1875
|
-
exports.jsxs = jsxs;
|
|
1876
|
-
})();
|
|
1877
|
-
}
|
|
1878
|
-
});
|
|
1879
|
-
|
|
1880
|
-
var jsxRuntime = createCommonjsModule(function (module) {
|
|
1881
|
-
|
|
1882
|
-
if (process.env.NODE_ENV === 'production') {
|
|
1883
|
-
module.exports = reactJsxRuntime_production_min;
|
|
1884
|
-
} else {
|
|
1885
|
-
module.exports = reactJsxRuntime_development;
|
|
1886
|
-
}
|
|
1887
|
-
});
|
|
1888
|
-
|
|
1889
|
-
var TusHandler = /*#__PURE__*/function () {
|
|
519
|
+
var TusHandler = function () {
|
|
1890
520
|
function TusHandler(tusConfigs) {
|
|
1891
521
|
_classCallCheck(this, TusHandler);
|
|
1892
522
|
|
|
@@ -1894,7 +524,7 @@ var TusHandler = /*#__PURE__*/function () {
|
|
|
1894
524
|
_ref$canStoreURLs = _ref.canStoreURLs,
|
|
1895
525
|
canStoreURLs = _ref$canStoreURLs === void 0 ? tus__namespace.canStoreURLs : _ref$canStoreURLs,
|
|
1896
526
|
_ref$defaultOptions = _ref.defaultOptions,
|
|
1897
|
-
defaultOptions = _ref$defaultOptions === void 0 ?
|
|
527
|
+
defaultOptions = _ref$defaultOptions === void 0 ? initialDefaultOptions : _ref$defaultOptions;
|
|
1898
528
|
|
|
1899
529
|
this.tus = _objectSpread2(_objectSpread2({}, tus__namespace), {}, {
|
|
1900
530
|
canStoreURLs: canStoreURLs,
|
|
@@ -1917,24 +547,24 @@ var tusClientReducer = function tusClientReducer(state, actions) {
|
|
|
1917
547
|
case 'INSERT_UPLOAD_INSTANCE':
|
|
1918
548
|
{
|
|
1919
549
|
var _actions$payload = actions.payload,
|
|
1920
|
-
|
|
550
|
+
_cacheKey = _actions$payload.cacheKey,
|
|
1921
551
|
uploadState = _actions$payload.uploadState;
|
|
1922
552
|
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
1923
|
-
uploads: _objectSpread2(_objectSpread2({}, state.uploads), {}, _defineProperty({},
|
|
553
|
+
uploads: _objectSpread2(_objectSpread2({}, state.uploads), {}, _defineProperty({}, _cacheKey, uploadState))
|
|
1924
554
|
});
|
|
1925
555
|
}
|
|
1926
556
|
|
|
1927
557
|
case 'UPDATE_SUCCESS_UPLOAD':
|
|
1928
558
|
{
|
|
1929
|
-
var
|
|
1930
|
-
var target = state.uploads[
|
|
559
|
+
var _cacheKey2 = actions.payload.cacheKey;
|
|
560
|
+
var target = state.uploads[_cacheKey2];
|
|
1931
561
|
|
|
1932
562
|
if (!target) {
|
|
1933
563
|
return state;
|
|
1934
564
|
}
|
|
1935
565
|
|
|
1936
566
|
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
1937
|
-
uploads: _objectSpread2(_objectSpread2({}, state.uploads), {}, _defineProperty({},
|
|
567
|
+
uploads: _objectSpread2(_objectSpread2({}, state.uploads), {}, _defineProperty({}, _cacheKey2, _objectSpread2(_objectSpread2({}, target || {}), {}, {
|
|
1938
568
|
isSuccess: true
|
|
1939
569
|
})))
|
|
1940
570
|
});
|
|
@@ -1943,16 +573,16 @@ var tusClientReducer = function tusClientReducer(state, actions) {
|
|
|
1943
573
|
case 'UPDATE_ERROR_UPLOAD':
|
|
1944
574
|
{
|
|
1945
575
|
var _actions$payload2 = actions.payload,
|
|
1946
|
-
|
|
576
|
+
_cacheKey3 = _actions$payload2.cacheKey,
|
|
1947
577
|
error = _actions$payload2.error;
|
|
1948
|
-
var _target = state.uploads[
|
|
578
|
+
var _target = state.uploads[_cacheKey3];
|
|
1949
579
|
|
|
1950
580
|
if (!_target) {
|
|
1951
581
|
return state;
|
|
1952
582
|
}
|
|
1953
583
|
|
|
1954
584
|
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
1955
|
-
uploads: _objectSpread2(_objectSpread2({}, state.uploads), {}, _defineProperty({},
|
|
585
|
+
uploads: _objectSpread2(_objectSpread2({}, state.uploads), {}, _defineProperty({}, _cacheKey3, _objectSpread2(_objectSpread2({}, _target), {}, {
|
|
1956
586
|
error: error
|
|
1957
587
|
})))
|
|
1958
588
|
});
|
|
@@ -1961,16 +591,16 @@ var tusClientReducer = function tusClientReducer(state, actions) {
|
|
|
1961
591
|
case 'UPDATE_IS_ABORTED_UPLOAD':
|
|
1962
592
|
{
|
|
1963
593
|
var _actions$payload3 = actions.payload,
|
|
1964
|
-
|
|
594
|
+
_cacheKey4 = _actions$payload3.cacheKey,
|
|
1965
595
|
isAborted = _actions$payload3.isAborted;
|
|
1966
|
-
var _target2 = state.uploads[
|
|
596
|
+
var _target2 = state.uploads[_cacheKey4];
|
|
1967
597
|
|
|
1968
598
|
if (!_target2) {
|
|
1969
599
|
return state;
|
|
1970
600
|
}
|
|
1971
601
|
|
|
1972
602
|
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
1973
|
-
uploads: _objectSpread2(_objectSpread2({}, state.uploads), {}, _defineProperty({},
|
|
603
|
+
uploads: _objectSpread2(_objectSpread2({}, state.uploads), {}, _defineProperty({}, _cacheKey4, _objectSpread2(_objectSpread2({}, _target2), {}, {
|
|
1974
604
|
isAborted: isAborted
|
|
1975
605
|
})))
|
|
1976
606
|
});
|
|
@@ -1978,14 +608,22 @@ var tusClientReducer = function tusClientReducer(state, actions) {
|
|
|
1978
608
|
|
|
1979
609
|
case 'REMOVE_UPLOAD_INSTANCE':
|
|
1980
610
|
{
|
|
1981
|
-
var
|
|
611
|
+
var _cacheKey5 = actions.payload.cacheKey;
|
|
1982
612
|
var newUploads = state.uploads;
|
|
1983
|
-
delete newUploads[
|
|
613
|
+
delete newUploads[_cacheKey5];
|
|
1984
614
|
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
1985
615
|
uploads: newUploads
|
|
1986
616
|
});
|
|
1987
617
|
}
|
|
1988
618
|
|
|
619
|
+
case 'RESET_CLIENT':
|
|
620
|
+
{
|
|
621
|
+
return {
|
|
622
|
+
tusHandler: new TusHandler(),
|
|
623
|
+
uploads: {}
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
|
|
1989
627
|
case 'UPDATE_TUS_HANDLER_OPTIONS':
|
|
1990
628
|
{
|
|
1991
629
|
var _actions$payload4 = actions.payload,
|
|
@@ -2010,7 +648,8 @@ var tusClientInitialState = {
|
|
|
2010
648
|
|
|
2011
649
|
var TusController = function TusController(_ref) {
|
|
2012
650
|
var canStoreURLs = _ref.canStoreURLs,
|
|
2013
|
-
defaultOptions = _ref.defaultOptions,
|
|
651
|
+
_ref$defaultOptions = _ref.defaultOptions,
|
|
652
|
+
defaultOptions = _ref$defaultOptions === void 0 ? initialDefaultOptions : _ref$defaultOptions,
|
|
2014
653
|
children = _ref.children;
|
|
2015
654
|
|
|
2016
655
|
var _useTusClientState = useTusClientState(),
|
|
@@ -2018,15 +657,14 @@ var TusController = function TusController(_ref) {
|
|
|
2018
657
|
|
|
2019
658
|
var tus = tusHandler.getTus;
|
|
2020
659
|
var tusClientDispatch = useTusClientDispatch();
|
|
2021
|
-
|
|
660
|
+
react.useEffect(function () {
|
|
2022
661
|
if (tusHandler.getTus.isSupported || process.env.NODE_ENV === 'production') {
|
|
2023
662
|
return;
|
|
2024
|
-
}
|
|
2025
|
-
|
|
663
|
+
}
|
|
2026
664
|
|
|
2027
665
|
console.error(ERROR_MESSAGES.tusIsNotSupported);
|
|
2028
666
|
}, [tusHandler.getTus.isSupported]);
|
|
2029
|
-
|
|
667
|
+
react.useEffect(function () {
|
|
2030
668
|
if (tus.defaultOptions === defaultOptions && tus.canStoreURLs === canStoreURLs) {
|
|
2031
669
|
return;
|
|
2032
670
|
}
|
|
@@ -2036,9 +674,7 @@ var TusController = function TusController(_ref) {
|
|
|
2036
674
|
defaultOptions: defaultOptions
|
|
2037
675
|
}));
|
|
2038
676
|
}, [tusClientDispatch, canStoreURLs, defaultOptions, tus.canStoreURLs, tus.defaultOptions]);
|
|
2039
|
-
return
|
|
2040
|
-
children: children
|
|
2041
|
-
}, void 0);
|
|
677
|
+
return react.createElement(react.Fragment, {}, children);
|
|
2042
678
|
};
|
|
2043
679
|
|
|
2044
680
|
var TusClientProvider = function TusClientProvider(_ref) {
|
|
@@ -2046,7 +682,7 @@ var TusClientProvider = function TusClientProvider(_ref) {
|
|
|
2046
682
|
defaultOptions = _ref.defaultOptions,
|
|
2047
683
|
children = _ref.children;
|
|
2048
684
|
|
|
2049
|
-
var _useReducer =
|
|
685
|
+
var _useReducer = react.useReducer(tusClientReducer, _objectSpread2(_objectSpread2({}, tusClientInitialState), {}, {
|
|
2050
686
|
tusHandler: new TusHandler({
|
|
2051
687
|
canStoreURLs: canStoreURLs,
|
|
2052
688
|
defaultOptions: defaultOptions
|
|
@@ -2056,20 +692,16 @@ var TusClientProvider = function TusClientProvider(_ref) {
|
|
|
2056
692
|
tusClientState = _useReducer2[0],
|
|
2057
693
|
tusClientDispatch = _useReducer2[1];
|
|
2058
694
|
|
|
2059
|
-
|
|
695
|
+
var tusControllerElement = react.createElement(TusController, {
|
|
696
|
+
canStoreURLs: canStoreURLs,
|
|
697
|
+
defaultOptions: defaultOptions
|
|
698
|
+
}, children);
|
|
699
|
+
var tusClientDispatchContextProviderElement = react.createElement(TusClientDispatchContext.Provider, {
|
|
700
|
+
value: tusClientDispatch
|
|
701
|
+
}, tusControllerElement);
|
|
702
|
+
return react.createElement(TusClientStateContext.Provider, {
|
|
2060
703
|
value: tusClientState
|
|
2061
|
-
},
|
|
2062
|
-
children: jsxRuntime.jsx(TusClientDispatchContext.Provider, Object.assign({
|
|
2063
|
-
value: tusClientDispatch
|
|
2064
|
-
}, {
|
|
2065
|
-
children: jsxRuntime.jsx(TusController, Object.assign({
|
|
2066
|
-
canStoreURLs: canStoreURLs,
|
|
2067
|
-
defaultOptions: defaultOptions
|
|
2068
|
-
}, {
|
|
2069
|
-
children: children
|
|
2070
|
-
}), void 0)
|
|
2071
|
-
}), void 0)
|
|
2072
|
-
}), void 0);
|
|
704
|
+
}, tusClientDispatchContextProviderElement);
|
|
2073
705
|
};
|
|
2074
706
|
|
|
2075
707
|
exports.TusClientProvider = TusClientProvider;
|