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