@tanem/react-nprogress 3.0.79 → 4.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
3
3
  typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.NProgress = {}, global.React));
5
- }(this, (function (exports, React) { 'use strict';
5
+ })(this, (function (exports, React) { 'use strict';
6
6
 
7
7
  function _interopNamespace(e) {
8
8
  if (e && e.__esModule) return e;
@@ -13,14 +13,12 @@
13
13
  var d = Object.getOwnPropertyDescriptor(e, k);
14
14
  Object.defineProperty(n, k, d.get ? d : {
15
15
  enumerable: true,
16
- get: function () {
17
- return e[k];
18
- }
16
+ get: function () { return e[k]; }
19
17
  });
20
18
  }
21
19
  });
22
20
  }
23
- n['default'] = e;
21
+ n["default"] = e;
24
22
  return Object.freeze(n);
25
23
  }
26
24
 
@@ -50,8 +48,7 @@
50
48
  return target;
51
49
  }
52
50
 
53
- module.exports = _objectWithoutPropertiesLoose;
54
- module.exports["default"] = module.exports, module.exports.__esModule = true;
51
+ module.exports = _objectWithoutPropertiesLoose, module.exports.__esModule = true, module.exports["default"] = module.exports;
55
52
  });
56
53
 
57
54
  var _objectWithoutPropertiesLoose = unwrapExports(objectWithoutPropertiesLoose);
@@ -70,14 +67,11 @@
70
67
  }
71
68
 
72
69
  return target;
73
- };
74
-
75
- module.exports["default"] = module.exports, module.exports.__esModule = true;
70
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports;
76
71
  return _extends.apply(this, arguments);
77
72
  }
78
73
 
79
- module.exports = _extends;
80
- module.exports["default"] = module.exports, module.exports.__esModule = true;
74
+ module.exports = _extends, module.exports.__esModule = true, module.exports["default"] = module.exports;
81
75
  });
82
76
 
83
77
  var _extends = unwrapExports(_extends_1);
@@ -186,73 +180,90 @@
186
180
  return clamp(progress + amount, 0, 0.994);
187
181
  };
188
182
 
189
- var isRunning = false;
190
- var pending = [];
183
+ var createQueue = function createQueue() {
184
+ var isRunning = false;
185
+ var pending = [];
191
186
 
192
- var next = function next() {
193
- isRunning = true;
194
- var cb = pending.shift();
187
+ var next = function next() {
188
+ isRunning = true;
189
+ var cb = pending.shift();
195
190
 
196
- if (cb) {
197
- return cb(next);
198
- }
191
+ if (cb) {
192
+ return cb(next);
193
+ }
199
194
 
200
- isRunning = false;
201
- };
195
+ isRunning = false;
196
+ };
202
197
 
203
- var clear = function clear() {
204
- isRunning = false;
205
- pending = [];
206
- };
207
- var queue = function queue(cb) {
208
- pending.push(cb);
198
+ var clear = function clear() {
199
+ isRunning = false;
200
+ pending = [];
201
+ };
209
202
 
210
- if (!isRunning && pending.length === 1) {
211
- next();
212
- }
213
- };
203
+ var queue = function queue(cb) {
204
+ pending.push(cb);
214
205
 
215
- var handle;
216
- var cancel = function cancel() {
217
- if (handle) {
218
- window.cancelAnimationFrame(handle);
219
- }
206
+ if (!isRunning && pending.length === 1) {
207
+ next();
208
+ }
209
+ };
210
+
211
+ return {
212
+ clear: clear,
213
+ queue: queue
214
+ };
220
215
  };
221
- var timeout = function timeout(callback, delay) {
222
- var deltaTime;
223
- var start;
224
216
 
225
- var frame = function frame(time) {
226
- start = start || time;
227
- deltaTime = time - start;
217
+ var createTimeout = function createTimeout() {
218
+ var handle;
228
219
 
229
- if (deltaTime > delay) {
230
- callback();
231
- return;
220
+ var cancel = function cancel() {
221
+ console.log('cancel');
222
+
223
+ if (handle) {
224
+ window.cancelAnimationFrame(handle);
232
225
  }
226
+ };
227
+
228
+ var timeout = function timeout(callback, delay) {
229
+ var deltaTime;
230
+ var start;
231
+
232
+ var frame = function frame(time) {
233
+ start = start || time;
234
+ deltaTime = time - start;
235
+
236
+ if (deltaTime > delay) {
237
+ callback();
238
+ return;
239
+ }
240
+
241
+ handle = window.requestAnimationFrame(frame);
242
+ };
233
243
 
234
244
  handle = window.requestAnimationFrame(frame);
235
245
  };
236
246
 
237
- handle = window.requestAnimationFrame(frame);
247
+ return {
248
+ cancel: cancel,
249
+ timeout: timeout
250
+ };
238
251
  };
239
252
 
240
253
  /* istanbul ignore next */
241
254
 
242
255
  var noop = function noop() {
243
256
  return undefined;
244
- };
257
+ }; // const initialState: State = {
258
+ // isFinished: true,
259
+ // progress: 0,
260
+ // sideEffect: noop,
261
+ // }
262
+ // const cleanup = () => {
263
+ // cancelCurrentTimeout()
264
+ // clearQueue()
265
+ // }
245
266
 
246
- var initialState = {
247
- isFinished: true,
248
- progress: 0,
249
- sideEffect: noop
250
- };
251
-
252
- var cleanup = function cleanup() {
253
- cancel();
254
- clear();
255
- };
256
267
 
257
268
  var useNProgress = function useNProgress(_temp) {
258
269
  var _ref = _temp === void 0 ? {} : _temp,
@@ -265,10 +276,29 @@
265
276
  _ref$minimum = _ref.minimum,
266
277
  minimum = _ref$minimum === void 0 ? 0.08 : _ref$minimum;
267
278
 
279
+ var initialState = {
280
+ isFinished: true,
281
+ progress: 0,
282
+ sideEffect: noop
283
+ };
284
+
268
285
  var _useGetSetState = useGetSetState$1(initialState),
269
286
  get = _useGetSetState[0],
270
287
  setState = _useGetSetState[1];
271
288
 
289
+ var _createQueue = createQueue(),
290
+ clearQueue = _createQueue.clear,
291
+ queue = _createQueue.queue;
292
+
293
+ var _createTimeout = createTimeout(),
294
+ cancelCurrentTimeout = _createTimeout.cancel,
295
+ timeout = _createTimeout.timeout;
296
+
297
+ var cleanup = function cleanup() {
298
+ cancelCurrentTimeout();
299
+ clearQueue();
300
+ };
301
+
272
302
  var set = React.useCallback(function (n) {
273
303
  n = clamp(n, minimum, 1);
274
304
 
@@ -357,45 +387,6 @@
357
387
  return children(renderProps);
358
388
  };
359
389
 
360
- var reactIs_production_min = createCommonjsModule(function (module, exports) {
361
- Object.defineProperty(exports,"__esModule",{value:!0});
362
- var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?Symbol.for("react.suspense_list"):
363
- 60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.fundamental"):60117,w=b?Symbol.for("react.responder"):60118,x=b?Symbol.for("react.scope"):60119;function y(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function z(a){return y(a)===m}
364
- exports.typeOf=y;exports.AsyncMode=l;exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;exports.Fragment=e;exports.Lazy=t;exports.Memo=r;exports.Portal=d;exports.Profiler=g;exports.StrictMode=f;exports.Suspense=p;
365
- exports.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===v||a.$$typeof===w||a.$$typeof===x)};exports.isAsyncMode=function(a){return z(a)||y(a)===l};exports.isConcurrentMode=z;exports.isContextConsumer=function(a){return y(a)===k};exports.isContextProvider=function(a){return y(a)===h};
366
- exports.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return y(a)===n};exports.isFragment=function(a){return y(a)===e};exports.isLazy=function(a){return y(a)===t};exports.isMemo=function(a){return y(a)===r};exports.isPortal=function(a){return y(a)===d};exports.isProfiler=function(a){return y(a)===g};exports.isStrictMode=function(a){return y(a)===f};exports.isSuspense=function(a){return y(a)===p};
367
- });
368
-
369
- unwrapExports(reactIs_production_min);
370
- reactIs_production_min.typeOf;
371
- reactIs_production_min.AsyncMode;
372
- reactIs_production_min.ConcurrentMode;
373
- reactIs_production_min.ContextConsumer;
374
- reactIs_production_min.ContextProvider;
375
- reactIs_production_min.Element;
376
- reactIs_production_min.ForwardRef;
377
- reactIs_production_min.Fragment;
378
- reactIs_production_min.Lazy;
379
- reactIs_production_min.Memo;
380
- reactIs_production_min.Portal;
381
- reactIs_production_min.Profiler;
382
- reactIs_production_min.StrictMode;
383
- reactIs_production_min.Suspense;
384
- reactIs_production_min.isValidElementType;
385
- reactIs_production_min.isAsyncMode;
386
- reactIs_production_min.isConcurrentMode;
387
- reactIs_production_min.isContextConsumer;
388
- reactIs_production_min.isContextProvider;
389
- reactIs_production_min.isElement;
390
- reactIs_production_min.isForwardRef;
391
- reactIs_production_min.isFragment;
392
- reactIs_production_min.isLazy;
393
- reactIs_production_min.isMemo;
394
- reactIs_production_min.isPortal;
395
- reactIs_production_min.isProfiler;
396
- reactIs_production_min.isStrictMode;
397
- reactIs_production_min.isSuspense;
398
-
399
390
  var reactIs_development = createCommonjsModule(function (module, exports) {
400
391
 
401
392
 
@@ -403,8 +394,6 @@
403
394
  {
404
395
  (function() {
405
396
 
406
- Object.defineProperty(exports, '__esModule', { value: true });
407
-
408
397
  // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
409
398
  // nor polyfill, then a plain number is used for performance.
410
399
  var hasSymbol = typeof Symbol === 'function' && Symbol.for;
@@ -424,70 +413,16 @@
424
413
  var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
425
414
  var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
426
415
  var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
416
+ var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
427
417
  var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
428
418
  var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
429
419
  var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
430
420
 
431
421
  function isValidElementType(type) {
432
422
  return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
433
- type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE);
434
- }
435
-
436
- /**
437
- * Forked from fbjs/warning:
438
- * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
439
- *
440
- * Only change is we use console.warn instead of console.error,
441
- * and do nothing when 'console' is not supported.
442
- * This really simplifies the code.
443
- * ---
444
- * Similar to invariant but only logs a warning if the condition is not met.
445
- * This can be used to log issues in development environments in critical
446
- * paths. Removing the logging code for production environments will keep the
447
- * same logic and follow the same code paths.
448
- */
449
- var lowPriorityWarningWithoutStack = function () {};
450
-
451
- {
452
- var printWarning = function (format) {
453
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
454
- args[_key - 1] = arguments[_key];
455
- }
456
-
457
- var argIndex = 0;
458
- var message = 'Warning: ' + format.replace(/%s/g, function () {
459
- return args[argIndex++];
460
- });
461
-
462
- if (typeof console !== 'undefined') {
463
- console.warn(message);
464
- }
465
-
466
- try {
467
- // --- Welcome to debugging React ---
468
- // This error was thrown as a convenience so that you can use this stack
469
- // to find the callsite that caused this warning to fire.
470
- throw new Error(message);
471
- } catch (x) {}
472
- };
473
-
474
- lowPriorityWarningWithoutStack = function (condition, format) {
475
- if (format === undefined) {
476
- throw new Error('`lowPriorityWarningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
477
- }
478
-
479
- if (!condition) {
480
- for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
481
- args[_key2 - 2] = arguments[_key2];
482
- }
483
-
484
- printWarning.apply(void 0, [format].concat(args));
485
- }
486
- };
423
+ type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
487
424
  }
488
425
 
489
- var lowPriorityWarningWithoutStack$1 = lowPriorityWarningWithoutStack;
490
-
491
426
  function typeOf(object) {
492
427
  if (typeof object === 'object' && object !== null) {
493
428
  var $$typeof = object.$$typeof;
@@ -548,8 +483,9 @@
548
483
  function isAsyncMode(object) {
549
484
  {
550
485
  if (!hasWarnedAboutDeprecatedIsAsyncMode) {
551
- hasWarnedAboutDeprecatedIsAsyncMode = true;
552
- lowPriorityWarningWithoutStack$1(false, 'The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
486
+ hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
487
+
488
+ console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
553
489
  }
554
490
  }
555
491
 
@@ -592,7 +528,6 @@
592
528
  return typeOf(object) === REACT_SUSPENSE_TYPE;
593
529
  }
594
530
 
595
- exports.typeOf = typeOf;
596
531
  exports.AsyncMode = AsyncMode;
597
532
  exports.ConcurrentMode = ConcurrentMode;
598
533
  exports.ContextConsumer = ContextConsumer;
@@ -606,7 +541,6 @@
606
541
  exports.Profiler = Profiler;
607
542
  exports.StrictMode = StrictMode;
608
543
  exports.Suspense = Suspense;
609
- exports.isValidElementType = isValidElementType;
610
544
  exports.isAsyncMode = isAsyncMode;
611
545
  exports.isConcurrentMode = isConcurrentMode;
612
546
  exports.isContextConsumer = isContextConsumer;
@@ -620,12 +554,11 @@
620
554
  exports.isProfiler = isProfiler;
621
555
  exports.isStrictMode = isStrictMode;
622
556
  exports.isSuspense = isSuspense;
557
+ exports.isValidElementType = isValidElementType;
558
+ exports.typeOf = typeOf;
623
559
  })();
624
560
  }
625
561
  });
626
-
627
- unwrapExports(reactIs_development);
628
- reactIs_development.typeOf;
629
562
  reactIs_development.AsyncMode;
630
563
  reactIs_development.ConcurrentMode;
631
564
  reactIs_development.ContextConsumer;
@@ -639,7 +572,6 @@
639
572
  reactIs_development.Profiler;
640
573
  reactIs_development.StrictMode;
641
574
  reactIs_development.Suspense;
642
- reactIs_development.isValidElementType;
643
575
  reactIs_development.isAsyncMode;
644
576
  reactIs_development.isConcurrentMode;
645
577
  reactIs_development.isContextConsumer;
@@ -653,6 +585,8 @@
653
585
  reactIs_development.isProfiler;
654
586
  reactIs_development.isStrictMode;
655
587
  reactIs_development.isSuspense;
588
+ reactIs_development.isValidElementType;
589
+ reactIs_development.typeOf;
656
590
 
657
591
  var reactIs = createCommonjsModule(function (module) {
658
592
 
@@ -777,5 +711,5 @@
777
711
 
778
712
  Object.defineProperty(exports, '__esModule', { value: true });
779
713
 
780
- })));
714
+ }));
781
715
  //# sourceMappingURL=react-nprogress.umd.development.js.map