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