@tanem/react-nprogress 4.0.0-beta.2 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -96,6 +96,7 @@ render(<Enhanced isAnimating />, document.getElementById('root'))
96
96
 
97
97
  - HOC: [Source](https://github.com/tanem/react-nprogress/tree/master/examples/hoc) | [Sandbox](https://codesandbox.io/s/github/tanem/react-nprogress/tree/master/examples/hoc)
98
98
  - Material UI: [Source](https://github.com/tanem/react-nprogress/tree/master/examples/material-ui) | [Sandbox](https://codesandbox.io/s/github/tanem/react-nprogress/tree/master/examples/material-ui)
99
+ - Multiple Instances: [Source](https://github.com/tanem/react-nprogress/tree/master/examples/multiple-instances) | [Sandbox](https://codesandbox.io/s/github/tanem/react-nprogress/tree/master/examples/multiple-instances)
99
100
  - Next Router: [Source](https://github.com/tanem/react-nprogress/tree/master/examples/next-router) | [Sandbox](https://codesandbox.io/s/github/tanem/react-nprogress/tree/master/examples/next-router)
100
101
  - Original Design: [Source](https://github.com/tanem/react-nprogress/tree/master/examples/original-design) | [Sandbox](https://codesandbox.io/s/github/tanem/react-nprogress/tree/master/examples/original-design)
101
102
  - Plain JS: [Source](https://github.com/tanem/react-nprogress/tree/master/examples/plain-js) | [Sandbox](https://codesandbox.io/s/github/tanem/react-nprogress/tree/master/examples/plain-js)
@@ -2,6 +2,6 @@ declare type Next = () => void;
2
2
  declare type Callback = (next: Next) => void;
3
3
  export declare const createQueue: () => {
4
4
  clear: () => void;
5
- queue: (cb: Callback) => void;
5
+ enqueue: (cb: Callback) => void;
6
6
  };
7
7
  export {};
@@ -1,4 +1,4 @@
1
1
  export declare const createTimeout: () => {
2
2
  cancel: () => void;
3
- timeout: (callback: () => void, delay: number) => void;
3
+ schedule: (callback: () => void, delay: number) => void;
4
4
  };
@@ -5,7 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var _objectWithoutPropertiesLoose = require('@babel/runtime/helpers/objectWithoutPropertiesLoose');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
- var reactUse = require('react-use');
9
8
  var hoistNonReactStatics = require('hoist-non-react-statics');
10
9
 
11
10
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -39,22 +38,6 @@ var clamp = function clamp(num, lower, upper) {
39
38
  return num;
40
39
  };
41
40
 
42
- var increment = function increment(progress) {
43
- var amount = 0;
44
-
45
- if (progress >= 0 && progress < 0.2) {
46
- amount = 0.1;
47
- } else if (progress >= 0.2 && progress < 0.5) {
48
- amount = 0.04;
49
- } else if (progress >= 0.5 && progress < 0.8) {
50
- amount = 0.02;
51
- } else if (progress >= 0.8 && progress < 0.99) {
52
- amount = 0.005;
53
- }
54
-
55
- return clamp(progress + amount, 0, 0.994);
56
- };
57
-
58
41
  var createQueue = function createQueue() {
59
42
  var isRunning = false;
60
43
  var pending = [];
@@ -75,7 +58,7 @@ var createQueue = function createQueue() {
75
58
  pending = [];
76
59
  };
77
60
 
78
- var queue = function queue(cb) {
61
+ var enqueue = function enqueue(cb) {
79
62
  pending.push(cb);
80
63
 
81
64
  if (!isRunning && pending.length === 1) {
@@ -85,7 +68,7 @@ var createQueue = function createQueue() {
85
68
 
86
69
  return {
87
70
  clear: clear,
88
- queue: queue
71
+ enqueue: enqueue
89
72
  };
90
73
  };
91
74
 
@@ -93,14 +76,12 @@ var createTimeout = function createTimeout() {
93
76
  var handle;
94
77
 
95
78
  var cancel = function cancel() {
96
- console.log('cancel');
97
-
98
79
  if (handle) {
99
80
  window.cancelAnimationFrame(handle);
100
81
  }
101
82
  };
102
83
 
103
- var timeout = function timeout(callback, delay) {
84
+ var schedule = function schedule(callback, delay) {
104
85
  var deltaTime;
105
86
  var start;
106
87
 
@@ -121,25 +102,102 @@ var createTimeout = function createTimeout() {
121
102
 
122
103
  return {
123
104
  cancel: cancel,
124
- timeout: timeout
105
+ schedule: schedule
125
106
  };
126
107
  };
127
108
 
109
+ var increment = function increment(progress) {
110
+ var amount = 0;
111
+
112
+ if (progress >= 0 && progress < 0.2) {
113
+ amount = 0.1;
114
+ } else if (progress >= 0.2 && progress < 0.5) {
115
+ amount = 0.04;
116
+ } else if (progress >= 0.5 && progress < 0.8) {
117
+ amount = 0.02;
118
+ } else if (progress >= 0.8 && progress < 0.99) {
119
+ amount = 0.005;
120
+ }
121
+
122
+ return clamp(progress + amount, 0, 0.994);
123
+ };
124
+
125
+ // Hat-tip:
126
+ var useEffectOnce = function useEffectOnce(effect) {
127
+ // eslint-disable-next-line react-hooks/exhaustive-deps
128
+ React.useEffect(effect, []);
129
+ };
130
+
131
+ var incrementParameter = function incrementParameter(num) {
132
+ return ++num % 1000000;
133
+ };
134
+
135
+ var useUpdate = function useUpdate() {
136
+ var _useState = React.useState(0),
137
+ setState = _useState[1];
138
+
139
+ return React.useCallback(function () {
140
+ return setState(incrementParameter);
141
+ }, []);
142
+ };
143
+
144
+ var useGetSetState = function useGetSetState(
145
+ /* istanbul ignore next */
146
+ initialState) {
147
+ if (initialState === void 0) {
148
+ initialState = {};
149
+ }
150
+
151
+ var update = useUpdate();
152
+ var state = React.useRef(_extends__default["default"]({}, initialState));
153
+ var get = React.useCallback(function () {
154
+ return state.current;
155
+ }, []);
156
+ var set = React.useCallback(function (patch) {
157
+ if (!patch) {
158
+ return;
159
+ }
160
+
161
+ Object.assign(state.current, patch);
162
+ update(); // eslint-disable-next-line react-hooks/exhaustive-deps
163
+ }, []);
164
+ return [get, set];
165
+ };
166
+
167
+ // Hat-tip:
168
+
169
+ var useFirstMountState = function useFirstMountState() {
170
+ var isFirst = React.useRef(true);
171
+
172
+ if (isFirst.current) {
173
+ isFirst.current = false;
174
+ return true;
175
+ }
176
+
177
+ return isFirst.current;
178
+ };
179
+
180
+ var useUpdateEffect = function useUpdateEffect(effect, deps) {
181
+ var isFirstMount = useFirstMountState();
182
+ React.useEffect(function () {
183
+ if (!isFirstMount) {
184
+ return effect();
185
+ } // eslint-disable-next-line react-hooks/exhaustive-deps
186
+
187
+ }, deps);
188
+ };
189
+
128
190
  /* istanbul ignore next */
129
191
 
130
192
  var noop = function noop() {
131
193
  return undefined;
132
- }; // const initialState: State = {
133
- // isFinished: true,
134
- // progress: 0,
135
- // sideEffect: noop,
136
- // }
137
- // const cleanup = () => {
138
- // cancelCurrentTimeout()
139
- // clearQueue()
140
- // }
141
-
194
+ };
142
195
 
196
+ var initialState = {
197
+ isFinished: true,
198
+ progress: 0,
199
+ sideEffect: noop
200
+ };
143
201
  var useNProgress = function useNProgress(_temp) {
144
202
  var _ref = _temp === void 0 ? {} : _temp,
145
203
  _ref$animationDuratio = _ref.animationDuration,
@@ -151,43 +209,42 @@ var useNProgress = function useNProgress(_temp) {
151
209
  _ref$minimum = _ref.minimum,
152
210
  minimum = _ref$minimum === void 0 ? 0.08 : _ref$minimum;
153
211
 
154
- var initialState = {
155
- isFinished: true,
156
- progress: 0,
157
- sideEffect: noop
158
- };
159
-
160
- var _useGetSetState = reactUse.useGetSetState(initialState),
212
+ var _useGetSetState = useGetSetState(initialState),
161
213
  get = _useGetSetState[0],
162
214
  setState = _useGetSetState[1];
163
215
 
164
- var _createQueue = createQueue(),
165
- clearQueue = _createQueue.clear,
166
- queue = _createQueue.queue;
167
-
168
- var _createTimeout = createTimeout(),
169
- cancelCurrentTimeout = _createTimeout.cancel,
170
- timeout = _createTimeout.timeout;
171
-
172
- var cleanup = function cleanup() {
173
- cancelCurrentTimeout();
174
- clearQueue();
175
- };
216
+ var queue = React.useRef(null);
217
+ var timeout = React.useRef(null);
218
+ useEffectOnce(function () {
219
+ queue.current = createQueue();
220
+ timeout.current = createTimeout();
221
+ });
222
+ var cleanup = React.useCallback(function () {
223
+ var _timeout$current, _queue$current;
176
224
 
225
+ (_timeout$current = timeout.current) == null ? void 0 : _timeout$current.cancel();
226
+ (_queue$current = queue.current) == null ? void 0 : _queue$current.clear();
227
+ }, []);
177
228
  var set = React.useCallback(function (n) {
229
+ var _queue$current4;
230
+
178
231
  n = clamp(n, minimum, 1);
179
232
 
180
233
  if (n === 1) {
234
+ var _queue$current2, _queue$current3;
235
+
181
236
  cleanup();
182
- queue(function (next) {
237
+ (_queue$current2 = queue.current) == null ? void 0 : _queue$current2.enqueue(function (next) {
183
238
  setState({
184
239
  progress: n,
185
240
  sideEffect: function sideEffect() {
186
- return timeout(next, animationDuration);
241
+ var _timeout$current2;
242
+
243
+ return (_timeout$current2 = timeout.current) == null ? void 0 : _timeout$current2.schedule(next, animationDuration);
187
244
  }
188
245
  });
189
246
  });
190
- queue(function () {
247
+ (_queue$current3 = queue.current) == null ? void 0 : _queue$current3.enqueue(function () {
191
248
  setState({
192
249
  isFinished: true,
193
250
  sideEffect: cleanup
@@ -196,24 +253,30 @@ var useNProgress = function useNProgress(_temp) {
196
253
  return;
197
254
  }
198
255
 
199
- queue(function (next) {
256
+ (_queue$current4 = queue.current) == null ? void 0 : _queue$current4.enqueue(function (next) {
200
257
  setState({
201
258
  isFinished: false,
202
259
  progress: n,
203
260
  sideEffect: function sideEffect() {
204
- return timeout(next, animationDuration);
261
+ var _timeout$current3;
262
+
263
+ return (_timeout$current3 = timeout.current) == null ? void 0 : _timeout$current3.schedule(next, animationDuration);
205
264
  }
206
265
  });
207
266
  });
208
- }, [animationDuration, minimum, setState]);
267
+ }, [animationDuration, cleanup, minimum, queue, setState, timeout]);
209
268
  var trickle = React.useCallback(function () {
210
269
  set(increment(get().progress));
211
270
  }, [get, set]);
212
271
  var start = React.useCallback(function () {
213
272
  var work = function work() {
273
+ var _queue$current5;
274
+
214
275
  trickle();
215
- queue(function (next) {
216
- timeout(function () {
276
+ (_queue$current5 = queue.current) == null ? void 0 : _queue$current5.enqueue(function (next) {
277
+ var _timeout$current4;
278
+
279
+ (_timeout$current4 = timeout.current) == null ? void 0 : _timeout$current4.schedule(function () {
217
280
  work();
218
281
  next();
219
282
  }, incrementDuration);
@@ -221,23 +284,23 @@ var useNProgress = function useNProgress(_temp) {
221
284
  };
222
285
 
223
286
  work();
224
- }, [incrementDuration, trickle]);
287
+ }, [incrementDuration, queue, timeout, trickle]);
225
288
  var savedTrickle = React.useRef(noop);
226
289
  var sideEffect = get().sideEffect;
227
290
  React.useEffect(function () {
228
291
  savedTrickle.current = trickle;
229
292
  });
230
- reactUse.useEffectOnce(function () {
293
+ useEffectOnce(function () {
231
294
  if (isAnimating) {
232
295
  start();
233
296
  }
234
297
 
235
298
  return cleanup;
236
299
  });
237
- reactUse.useUpdateEffect(function () {
300
+ useUpdateEffect(function () {
238
301
  get().sideEffect();
239
302
  }, [get, sideEffect]);
240
- reactUse.useUpdateEffect(function () {
303
+ useUpdateEffect(function () {
241
304
  if (!isAnimating) {
242
305
  set(1);
243
306
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"react-nprogress.cjs.development.js","sources":["../compiled/clamp.js","../compiled/increment.js","../compiled/queue.js","../compiled/timeout.js","../compiled/useNProgress.js","../compiled/NProgress.js","../compiled/withNProgress.js"],"sourcesContent":["export const clamp = (num, lower, upper) => {\n num = num <= upper ? num : upper;\n num = num >= lower ? num : lower;\n return num;\n};\n","import { clamp } from './clamp';\nexport const increment = (progress) => {\n let amount = 0;\n if (progress >= 0 && progress < 0.2) {\n amount = 0.1;\n }\n else if (progress >= 0.2 && progress < 0.5) {\n amount = 0.04;\n }\n else if (progress >= 0.5 && progress < 0.8) {\n amount = 0.02;\n }\n else if (progress >= 0.8 && progress < 0.99) {\n amount = 0.005;\n }\n return clamp(progress + amount, 0, 0.994);\n};\n","export const createQueue = () => {\n let isRunning = false;\n let pending = [];\n const next = () => {\n isRunning = true;\n const cb = pending.shift();\n if (cb) {\n return cb(next);\n }\n isRunning = false;\n };\n const clear = () => {\n isRunning = false;\n pending = [];\n };\n const queue = (cb) => {\n pending.push(cb);\n if (!isRunning && pending.length === 1) {\n next();\n }\n };\n return {\n clear,\n queue,\n };\n};\n","export const createTimeout = () => {\n let handle;\n const cancel = () => {\n console.log('cancel');\n if (handle) {\n window.cancelAnimationFrame(handle);\n }\n };\n const timeout = (callback, delay) => {\n let deltaTime;\n let start;\n const frame = (time) => {\n start = start || time;\n deltaTime = time - start;\n if (deltaTime > delay) {\n callback();\n return;\n }\n handle = window.requestAnimationFrame(frame);\n };\n handle = window.requestAnimationFrame(frame);\n };\n return {\n cancel,\n timeout,\n };\n};\n","import { useCallback, useEffect, useRef } from 'react';\nimport { useEffectOnce, useGetSetState, useUpdateEffect } from 'react-use';\nimport { clamp } from './clamp';\nimport { increment } from './increment';\n// import { clear as clearQueue, queue } from './queue'\nimport { createQueue } from './queue';\n// import { cancel as cancelCurrentTimeout, timeout } from './timeout'\nimport { createTimeout } from './timeout';\n/* istanbul ignore next */\nconst noop = () => undefined;\n// const initialState: State = {\n// isFinished: true,\n// progress: 0,\n// sideEffect: noop,\n// }\n// const cleanup = () => {\n// cancelCurrentTimeout()\n// clearQueue()\n// }\nexport const useNProgress = ({ animationDuration = 200, incrementDuration = 800, isAnimating = false, minimum = 0.08, } = {}) => {\n const initialState = {\n isFinished: true,\n progress: 0,\n sideEffect: noop,\n };\n const [get, setState] = useGetSetState(initialState);\n const { clear: clearQueue, queue } = createQueue();\n const { cancel: cancelCurrentTimeout, timeout } = createTimeout();\n const cleanup = () => {\n cancelCurrentTimeout();\n clearQueue();\n };\n const set = useCallback((n) => {\n n = clamp(n, minimum, 1);\n if (n === 1) {\n cleanup();\n queue((next) => {\n setState({\n progress: n,\n sideEffect: () => timeout(next, animationDuration),\n });\n });\n queue(() => {\n setState({ isFinished: true, sideEffect: cleanup });\n });\n return;\n }\n queue((next) => {\n setState({\n isFinished: false,\n progress: n,\n sideEffect: () => timeout(next, animationDuration),\n });\n });\n }, [animationDuration, minimum, setState]);\n const trickle = useCallback(() => {\n set(increment(get().progress));\n }, [get, set]);\n const start = useCallback(() => {\n const work = () => {\n trickle();\n queue((next) => {\n timeout(() => {\n work();\n next();\n }, incrementDuration);\n });\n };\n work();\n }, [incrementDuration, trickle]);\n const savedTrickle = useRef(noop);\n const sideEffect = get().sideEffect;\n useEffect(() => {\n savedTrickle.current = trickle;\n });\n useEffectOnce(() => {\n if (isAnimating) {\n start();\n }\n return cleanup;\n });\n useUpdateEffect(() => {\n get().sideEffect();\n }, [get, sideEffect]);\n useUpdateEffect(() => {\n if (!isAnimating) {\n set(1);\n }\n else {\n setState({\n ...initialState,\n sideEffect: start,\n });\n }\n }, [isAnimating, set, setState, start]);\n return {\n animationDuration,\n isFinished: get().isFinished,\n progress: get().progress,\n };\n};\n","import { useNProgress } from './useNProgress';\nexport const NProgress = ({ children, ...restProps }) => {\n const renderProps = useNProgress(restProps);\n return children(renderProps);\n};\n","import hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\nimport { useNProgress } from './useNProgress';\nexport function withNProgress(BaseComponent) {\n const WithNProgress = (props) => {\n const hookProps = useNProgress(props);\n return React.createElement(BaseComponent, { ...props, ...hookProps });\n };\n hoistNonReactStatics(WithNProgress, BaseComponent);\n return WithNProgress;\n}\n"],"names":["clamp","num","lower","upper","increment","progress","amount","createQueue","isRunning","pending","next","cb","shift","clear","queue","push","length","createTimeout","handle","cancel","console","log","window","cancelAnimationFrame","timeout","callback","delay","deltaTime","start","frame","time","requestAnimationFrame","noop","undefined","useNProgress","animationDuration","incrementDuration","isAnimating","minimum","initialState","isFinished","sideEffect","useGetSetState","get","setState","clearQueue","cancelCurrentTimeout","cleanup","set","useCallback","n","trickle","work","savedTrickle","useRef","useEffect","current","useEffectOnce","useUpdateEffect","NProgress","children","restProps","renderProps","withNProgress","BaseComponent","WithNProgress","props","hookProps","React","createElement","hoistNonReactStatics"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAMA,KAAK,GAAG,SAARA,KAAQ,CAACC,GAAD,EAAMC,KAAN,EAAaC,KAAb,EAAuB;AACxCF,EAAAA,GAAG,GAAGA,GAAG,IAAIE,KAAP,GAAeF,GAAf,GAAqBE,KAA3B;AACAF,EAAAA,GAAG,GA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BD,aAAhB,CAApB;AACA,SAAOC,aAAP;AACH;;;;;;"}
1
+ {"version":3,"file":"react-nprogress.cjs.development.js","sources":["../compiled/clamp.js","../compiled/createQueue.js","../compiled/createTimeout.js","../compiled/increment.js","../compiled/useEffectOnce.js","../compiled/useGetSetState.js","../compiled/useUpdateEffect.js","../compiled/useNProgress.js","../compiled/NProgress.js","../compiled/withNProgress.js"],"sourcesContent":["export const clamp = (num, lower, upper) => {\n num = num <= upper ? num : upper;\n num = num >= lower ? num : lower;\n return num;\n};\n","export const createQueue = () => {\n let isRunning = false;\n let pending = [];\n const next = () => {\n isRunning = true;\n const cb = pending.shift();\n if (cb) {\n return cb(next);\n }\n isRunning = false;\n };\n const clear = () => {\n isRunning = false;\n pending = [];\n };\n const enqueue = (cb) => {\n pending.push(cb);\n if (!isRunning && pending.length === 1) {\n next();\n }\n };\n return {\n clear,\n enqueue,\n };\n};\n","export const createTimeout = () => {\n let handle;\n const cancel = () => {\n if (handle) {\n window.cancelAnimationFrame(handle);\n }\n };\n const schedule = (callback, delay) => {\n let deltaTime;\n let start;\n const frame = (time) => {\n start = start || time;\n deltaTime = time - start;\n if (deltaTime > delay) {\n callback();\n return;\n }\n handle = window.requestAnimationFrame(frame);\n };\n handle = window.requestAnimationFrame(frame);\n };\n return {\n cancel,\n schedule,\n };\n};\n","import { clamp } from './clamp';\nexport const increment = (progress) => {\n let amount = 0;\n if (progress >= 0 && progress < 0.2) {\n amount = 0.1;\n }\n else if (progress >= 0.2 && progress < 0.5) {\n amount = 0.04;\n }\n else if (progress >= 0.5 && progress < 0.8) {\n amount = 0.02;\n }\n else if (progress >= 0.8 && progress < 0.99) {\n amount = 0.005;\n }\n return clamp(progress + amount, 0, 0.994);\n};\n","// Hat-tip:\n// https://github.com/streamich/react-use/blob/master/src/useEffectOnce.ts.\n//\n// `react-use` appears to be unmaintained, so moving the required code into\n// this project for now.\nimport { useEffect } from 'react';\nexport const useEffectOnce = (effect) => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useEffect(effect, []);\n};\n","// Hat-tip:\n// https://github.com/streamich/react-use/blob/master/src/useGetSetState.ts.\n//\n// `react-use` appears to be unmaintained, so moving the required code into\n// this project for now.\nimport { useCallback, useRef, useState } from 'react';\nconst incrementParameter = (num) => ++num % 1_000_000;\nconst useUpdate = () => {\n const [, setState] = useState(0);\n return useCallback(() => setState(incrementParameter), []);\n};\nexport const useGetSetState = (\n/* istanbul ignore next */\ninitialState = {}) => {\n const update = useUpdate();\n const state = useRef({ ...initialState });\n const get = useCallback(() => state.current, []);\n const set = useCallback((patch) => {\n if (!patch) {\n return;\n }\n Object.assign(state.current, patch);\n update();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n return [get, set];\n};\n","// Hat-tip:\n// https://github.com/streamich/react-use/blob/master/src/useUpdateEffect.ts.\n//\n// `react-use` appears to be unmaintained, so moving the required code into\n// this project for now.\nimport { useEffect, useRef } from 'react';\nconst useFirstMountState = () => {\n const isFirst = useRef(true);\n if (isFirst.current) {\n isFirst.current = false;\n return true;\n }\n return isFirst.current;\n};\nexport const useUpdateEffect = (effect, deps) => {\n const isFirstMount = useFirstMountState();\n useEffect(() => {\n if (!isFirstMount) {\n return effect();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n};\n","import { useCallback, useEffect, useRef } from 'react';\nimport { clamp } from './clamp';\nimport { createQueue } from './createQueue';\nimport { createTimeout } from './createTimeout';\nimport { increment } from './increment';\nimport { useEffectOnce } from './useEffectOnce';\nimport { useGetSetState } from './useGetSetState';\nimport { useUpdateEffect } from './useUpdateEffect';\n/* istanbul ignore next */\nconst noop = () => undefined;\nconst initialState = {\n isFinished: true,\n progress: 0,\n sideEffect: noop,\n};\nexport const useNProgress = ({ animationDuration = 200, incrementDuration = 800, isAnimating = false, minimum = 0.08, } = {}) => {\n const [get, setState] = useGetSetState(initialState);\n const queue = useRef(null);\n const timeout = useRef(null);\n useEffectOnce(() => {\n queue.current = createQueue();\n timeout.current = createTimeout();\n });\n const cleanup = useCallback(() => {\n timeout.current?.cancel();\n queue.current?.clear();\n }, []);\n const set = useCallback((n) => {\n n = clamp(n, minimum, 1);\n if (n === 1) {\n cleanup();\n queue.current?.enqueue((next) => {\n setState({\n progress: n,\n sideEffect: () => timeout.current?.schedule(next, animationDuration),\n });\n });\n queue.current?.enqueue(() => {\n setState({ isFinished: true, sideEffect: cleanup });\n });\n return;\n }\n queue.current?.enqueue((next) => {\n setState({\n isFinished: false,\n progress: n,\n sideEffect: () => timeout.current?.schedule(next, animationDuration),\n });\n });\n }, [animationDuration, cleanup, minimum, queue, setState, timeout]);\n const trickle = useCallback(() => {\n set(increment(get().progress));\n }, [get, set]);\n const start = useCallback(() => {\n const work = () => {\n trickle();\n queue.current?.enqueue((next) => {\n timeout.current?.schedule(() => {\n work();\n next();\n }, incrementDuration);\n });\n };\n work();\n }, [incrementDuration, queue, timeout, trickle]);\n const savedTrickle = useRef(noop);\n const sideEffect = get().sideEffect;\n useEffect(() => {\n savedTrickle.current = trickle;\n });\n useEffectOnce(() => {\n if (isAnimating) {\n start();\n }\n return cleanup;\n });\n useUpdateEffect(() => {\n get().sideEffect();\n }, [get, sideEffect]);\n useUpdateEffect(() => {\n if (!isAnimating) {\n set(1);\n }\n else {\n setState({\n ...initialState,\n sideEffect: start,\n });\n }\n }, [isAnimating, set, setState, start]);\n return {\n animationDuration,\n isFinished: get().isFinished,\n progress: get().progress,\n };\n};\n","import { useNProgress } from './useNProgress';\nexport const NProgress = ({ children, ...restProps }) => {\n const renderProps = useNProgress(restProps);\n return children(renderProps);\n};\n","import hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\nimport { useNProgress } from './useNProgress';\nexport function withNProgress(BaseComponent) {\n const WithNProgress = (props) => {\n const hookProps = useNProgress(props);\n return React.createElement(BaseComponent, { ...props, ...hookProps });\n };\n hoistNonReactStatics(WithNProgress, BaseComponent);\n return WithNProgress;\n}\n"],"names":["clamp","num","lower","upper","createQueue","isRunning","pending","next","cb","shift","clear","enqueue","push","length","createTimeout","handle","cancel","window","cancelAnimationFrame","schedule","callback","delay","deltaTime","start","frame","time","requestAnimationFrame","increment","progress","amount","useEffectOnce","effect","useEffect","incrementParameter","useUpdate","useState","setState","useCallback","useGetSetState","initialState","update","state","useRef","get","current","set","patch","Object","assign","useFirstMountState","isFirst","useUpdateEffect","deps","isFirstMount","noop","undefined","isFinished","sideEffect","useNProgress","animationDuration","incrementDuration","isAnimating","minimum","queue","timeout","cleanup","n","trickle","work","savedTrickle","NProgress","children","restProps","renderProps","withNProgress","BaseComponent","WithNProgress","props","hookProps","React","createElement","hoistNonReactStatics"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAMA,KAAK,GAAG,SAARA,KAAQ,CAACC,GAAD,EAAMC,KAAN,EAAaC,KAAb,EAAuB;AACxCF,EAAAA,GAAG,GAAGA,GAAG,IAAIE,KAAP,GAAeF,GAAf,GAAqBE,KAA3B;AACAF,EAAAA,GAAG,GAAGA,GAAG,IAAIC,KAAP,GAAeD,GAAf,GAAqBC,KAA3B;AACA,SAAOD,GAAP;AACH,CAJM;;ACAA,IAAMG,WAAW,GAAG,SAAdA,WAAc,GAAM;AAC7B,MAAIC,SAAS,GAAG,KAAhB;AACA,MAAIC,OAAO,GAAG,EAAd;;AACA,MAAMC,IAAI,GAAG,SAAPA,IAAO,GAAM;AACfF,IAAAA,SAAS,GAAG,IAAZ;AACA,QAAMG,EAAE,GAAGF,OAAO,CAACG,KAAR,EAAX;;AACA,QAAID,EAAJ,EAAQ;AACJ,aAAOA,EAAE,CAACD,IAAD,CAAT;AACH;;AACDF,IAAAA,SAAS,GAAG,KAAZ;AACH,GAPD;;AAQA,MAAMK,KAAK,GAAG,SAARA,KAAQ,GAAM;AAChBL,IAAAA,SAAS,GAAG,KAAZ;AACAC,IAAAA,OAAO,GAAG,EAAV;AACH,GAHD;;AAIA,MAAMK,OAAO,GAAG,SAAVA,OAAU,CAACH,EAA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B,YAAY,CAACmB,KAAD,CAA9B;AACA,wBAAOE,gBAAK,CAACC,aAAN,CAAoBL,aAApB,mCAAwCE,KAAxC,EAAkDC,SAAlD,EAAP;AACH,GAHD;;AAIAG,EAAAA,wCAAoB,CAACL,aAAD,EAAgBD,aAAhB,CAApB;AACA,SAAOC,aAAP;AACH;;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _objectWithoutPropertiesLoose=require("@babel/runtime/helpers/objectWithoutPropertiesLoose"),_extends=require("@babel/runtime/helpers/extends"),React=require("react"),reactUse=require("react-use"),hoistNonReactStatics=require("hoist-non-react-statics");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var _objectWithoutPropertiesLoose__default=_interopDefaultLegacy(_objectWithoutPropertiesLoose),_extends__default=_interopDefaultLegacy(_extends),React__namespace=_interopNamespace(React),hoistNonReactStatics__default=_interopDefaultLegacy(hoistNonReactStatics),clamp=function(e,t,n){return e=(e=e<=n?e:n)>=t?e:t},increment=function(e){var t=0;return e>=0&&e<.2?t=.1:e>=.2&&e<.5?t=.04:e>=.5&&e<.8?t=.02:e>=.8&&e<.99&&(t=.005),clamp(e+t,0,.994)},createQueue=function(){var e=!1,t=[],n=function n(){e=!0;var r=t.shift();if(r)return r(n);e=!1};return{clear:function(){e=!1,t=[]},queue:function(r){t.push(r),e||1!==t.length||n()}}},createTimeout=function(){var e;return{cancel:function(){console.log("cancel"),e&&window.cancelAnimationFrame(e)},timeout:function(t,n){var r;e=window.requestAnimationFrame((function i(o){o-(r=r||o)>n?t():e=window.requestAnimationFrame(i)}))}}},noop=function(){},useNProgress=function(e){var t=void 0===e?{}:e,n=t.animationDuration,r=void 0===n?200:n,i=t.incrementDuration,o=void 0===i?800:i,c=t.isAnimating,u=void 0!==c&&c,s=t.minimum,a=void 0===s?.08:s,f={isFinished:!0,progress:0,sideEffect:noop},d=reactUse.useGetSetState(f),l=d[0],p=d[1],_=createQueue(),m=_.clear,g=_.queue,h=createTimeout(),b=h.cancel,v=h.timeout,P=function(){b(),m()},N=React.useCallback((function(e){if(1===(e=clamp(e,a,1)))return P(),g((function(t){p({progress:e,sideEffect:function(){return v(t,r)}})})),void g((function(){p({isFinished:!0,sideEffect:P})}));g((function(t){p({isFinished:!1,progress:e,sideEffect:function(){return v(t,r)}})}))}),[r,a,p]),R=React.useCallback((function(){N(increment(l().progress))}),[l,N]),E=React.useCallback((function(){!function e(){R(),g((function(t){v((function(){e(),t()}),o)}))}()}),[o,R]),j=React.useRef(noop),x=l().sideEffect;return React.useEffect((function(){j.current=R})),reactUse.useEffectOnce((function(){return u&&E(),P})),reactUse.useUpdateEffect((function(){l().sideEffect()}),[l,x]),reactUse.useUpdateEffect((function(){u?p(_extends__default.default({},f,{sideEffect:E})):N(1)}),[u,N,p,E]),{animationDuration:r,isFinished:l().isFinished,progress:l().progress}},_excluded=["children"],NProgress=function(e){var t=e.children,n=_objectWithoutPropertiesLoose__default.default(e,_excluded);return t(useNProgress(n))};function withNProgress(e){var t=function(t){var n=useNProgress(t);return React__namespace.createElement(e,_extends__default.default({},t,n))};return hoistNonReactStatics__default.default(t,e),t}exports.NProgress=NProgress,exports.useNProgress=useNProgress,exports.withNProgress=withNProgress;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _objectWithoutPropertiesLoose=require("@babel/runtime/helpers/objectWithoutPropertiesLoose"),_extends=require("@babel/runtime/helpers/extends"),React=require("react"),hoistNonReactStatics=require("hoist-non-react-statics");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var _objectWithoutPropertiesLoose__default=_interopDefaultLegacy(_objectWithoutPropertiesLoose),_extends__default=_interopDefaultLegacy(_extends),React__namespace=_interopNamespace(React),hoistNonReactStatics__default=_interopDefaultLegacy(hoistNonReactStatics),clamp=function(e,t,n){return e=(e=e<=n?e:n)>=t?e:t},createQueue=function(){var e=!1,t=[],n=function n(){e=!0;var r=t.shift();if(r)return r(n);e=!1};return{clear:function(){e=!1,t=[]},enqueue:function(r){t.push(r),e||1!==t.length||n()}}},createTimeout=function(){var e;return{cancel:function(){e&&window.cancelAnimationFrame(e)},schedule:function(t,n){var r;e=window.requestAnimationFrame((function u(c){c-(r=r||c)>n?t():e=window.requestAnimationFrame(u)}))}}},increment=function(e){var t=0;return e>=0&&e<.2?t=.1:e>=.2&&e<.5?t=.04:e>=.5&&e<.8?t=.02:e>=.8&&e<.99&&(t=.005),clamp(e+t,0,.994)},useEffectOnce=function(e){React.useEffect(e,[])},incrementParameter=function(e){return++e%1e6},useUpdate=function(){var e=React.useState(0)[1];return React.useCallback((function(){return e(incrementParameter)}),[])},useGetSetState=function(e){void 0===e&&(e={});var t=useUpdate(),n=React.useRef(_extends__default.default({},e));return[React.useCallback((function(){return n.current}),[]),React.useCallback((function(e){e&&(Object.assign(n.current,e),t())}),[])]},useFirstMountState=function(){var e=React.useRef(!0);return e.current?(e.current=!1,!0):e.current},useUpdateEffect=function(e,t){var n=useFirstMountState();React.useEffect((function(){if(!n)return e()}),t)},noop=function(){},initialState={isFinished:!0,progress:0,sideEffect:noop},useNProgress=function(e){var t=void 0===e?{}:e,n=t.animationDuration,r=void 0===n?200:n,u=t.incrementDuration,c=void 0===u?800:u,i=t.isAnimating,a=void 0!==i&&i,o=t.minimum,s=void 0===o?.08:o,f=useGetSetState(initialState),l=f[0],d=f[1],p=React.useRef(null),_=React.useRef(null);useEffectOnce((function(){p.current=createQueue(),_.current=createTimeout()}));var v=React.useCallback((function(){var e,t;null==(e=_.current)||e.cancel(),null==(t=p.current)||t.clear()}),[]),m=React.useCallback((function(e){var t,n,u;if(1===(e=clamp(e,s,1)))return v(),null==(n=p.current)||n.enqueue((function(t){d({progress:e,sideEffect:function(){var e;return null==(e=_.current)?void 0:e.schedule(t,r)}})})),void(null==(u=p.current)||u.enqueue((function(){d({isFinished:!0,sideEffect:v})})));null==(t=p.current)||t.enqueue((function(t){d({isFinished:!1,progress:e,sideEffect:function(){var e;return null==(e=_.current)?void 0:e.schedule(t,r)}})}))}),[r,v,s,p,d,_]),h=React.useCallback((function(){m(increment(l().progress))}),[l,m]),R=React.useCallback((function(){!function e(){var t;h(),null==(t=p.current)||t.enqueue((function(t){var n;null==(n=_.current)||n.schedule((function(){e(),t()}),c)}))}()}),[c,p,_,h]),g=React.useRef(noop),b=l().sideEffect;return React.useEffect((function(){g.current=h})),useEffectOnce((function(){return a&&R(),v})),useUpdateEffect((function(){l().sideEffect()}),[l,b]),useUpdateEffect((function(){a?d(_extends__default.default({},initialState,{sideEffect:R})):m(1)}),[a,m,d,R]),{animationDuration:r,isFinished:l().isFinished,progress:l().progress}},_excluded=["children"],NProgress=function(e){var t=e.children,n=_objectWithoutPropertiesLoose__default.default(e,_excluded);return t(useNProgress(n))};function withNProgress(e){var t=function(t){var n=useNProgress(t);return React__namespace.createElement(e,_extends__default.default({},t,n))};return hoistNonReactStatics__default.default(t,e),t}exports.NProgress=NProgress,exports.useNProgress=useNProgress,exports.withNProgress=withNProgress;
2
2
  //# sourceMappingURL=react-nprogress.cjs.production.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-nprogress.cjs.production.js","sources":["../compiled/clamp.js","../compiled/increment.js","../compiled/queue.js","../compiled/timeout.js","../compiled/useNProgress.js","../compiled/NProgress.js","../compiled/withNProgress.js"],"sourcesContent":["export const clamp = (num, lower, upper) => {\n num = num <= upper ? num : upper;\n num = num >= lower ? num : lower;\n return num;\n};\n","import { clamp } from './clamp';\nexport const increment = (progress) => {\n let amount = 0;\n if (progress >= 0 && progress < 0.2) {\n amount = 0.1;\n }\n else if (progress >= 0.2 && progress < 0.5) {\n amount = 0.04;\n }\n else if (progress >= 0.5 && progress < 0.8) {\n amount = 0.02;\n }\n else if (progress >= 0.8 && progress < 0.99) {\n amount = 0.005;\n }\n return clamp(progress + amount, 0, 0.994);\n};\n","export const createQueue = () => {\n let isRunning = false;\n let pending = [];\n const next = () => {\n isRunning = true;\n const cb = pending.shift();\n if (cb) {\n return cb(next);\n }\n isRunning = false;\n };\n const clear = () => {\n isRunning = false;\n pending = [];\n };\n const queue = (cb) => {\n pending.push(cb);\n if (!isRunning && pending.length === 1) {\n next();\n }\n };\n return {\n clear,\n queue,\n };\n};\n","export const createTimeout = () => {\n let handle;\n const cancel = () => {\n console.log('cancel');\n if (handle) {\n window.cancelAnimationFrame(handle);\n }\n };\n const timeout = (callback, delay) => {\n let deltaTime;\n let start;\n const frame = (time) => {\n start = start || time;\n deltaTime = time - start;\n if (deltaTime > delay) {\n callback();\n return;\n }\n handle = window.requestAnimationFrame(frame);\n };\n handle = window.requestAnimationFrame(frame);\n };\n return {\n cancel,\n timeout,\n };\n};\n","import { useCallback, useEffect, useRef } from 'react';\nimport { useEffectOnce, useGetSetState, useUpdateEffect } from 'react-use';\nimport { clamp } from './clamp';\nimport { increment } from './increment';\n// import { clear as clearQueue, queue } from './queue'\nimport { createQueue } from './queue';\n// import { cancel as cancelCurrentTimeout, timeout } from './timeout'\nimport { createTimeout } from './timeout';\n/* istanbul ignore next */\nconst noop = () => undefined;\n// const initialState: State = {\n// isFinished: true,\n// progress: 0,\n// sideEffect: noop,\n// }\n// const cleanup = () => {\n// cancelCurrentTimeout()\n// clearQueue()\n// }\nexport const useNProgress = ({ animationDuration = 200, incrementDuration = 800, isAnimating = false, minimum = 0.08, } = {}) => {\n const initialState = {\n isFinished: true,\n progress: 0,\n sideEffect: noop,\n };\n const [get, setState] = useGetSetState(initialState);\n const { clear: clearQueue, queue } = createQueue();\n const { cancel: cancelCurrentTimeout, timeout } = createTimeout();\n const cleanup = () => {\n cancelCurrentTimeout();\n clearQueue();\n };\n const set = useCallback((n) => {\n n = clamp(n, minimum, 1);\n if (n === 1) {\n cleanup();\n queue((next) => {\n setState({\n progress: n,\n sideEffect: () => timeout(next, animationDuration),\n });\n });\n queue(() => {\n setState({ isFinished: true, sideEffect: cleanup });\n });\n return;\n }\n queue((next) => {\n setState({\n isFinished: false,\n progress: n,\n sideEffect: () => timeout(next, animationDuration),\n });\n });\n }, [animationDuration, minimum, setState]);\n const trickle = useCallback(() => {\n set(increment(get().progress));\n }, [get, set]);\n const start = useCallback(() => {\n const work = () => {\n trickle();\n queue((next) => {\n timeout(() => {\n work();\n next();\n }, incrementDuration);\n });\n };\n work();\n }, [incrementDuration, trickle]);\n const savedTrickle = useRef(noop);\n const sideEffect = get().sideEffect;\n useEffect(() => {\n savedTrickle.current = trickle;\n });\n useEffectOnce(() => {\n if (isAnimating) {\n start();\n }\n return cleanup;\n });\n useUpdateEffect(() => {\n get().sideEffect();\n }, [get, sideEffect]);\n useUpdateEffect(() => {\n if (!isAnimating) {\n set(1);\n }\n else {\n setState({\n ...initialState,\n sideEffect: start,\n });\n }\n }, [isAnimating, set, setState, start]);\n return {\n animationDuration,\n isFinished: get().isFinished,\n progress: get().progress,\n };\n};\n","import { useNProgress } from './useNProgress';\nexport const NProgress = ({ children, ...restProps }) => {\n const renderProps = useNProgress(restProps);\n return children(renderProps);\n};\n","import hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\nimport { useNProgress } from './useNProgress';\nexport function withNProgress(BaseComponent) {\n const WithNProgress = (props) => {\n const hookProps = useNProgress(props);\n return React.createElement(BaseComponent, { ...props, ...hookProps });\n };\n hoistNonReactStatics(WithNProgress, BaseComponent);\n return WithNProgress;\n}\n"],"names":["clamp","num","lower","upper","increment","progress","amount","createQueue","isRunning","pending","next","cb","shift","clear","queue","push","length","createTimeout","handle","cancel","console","log","window","cancelAnimationFrame","timeout","callback","delay","start","requestAnimationFrame","frame","time","noop","useNProgress","animationDuration","incrementDuration","isAnimating","minimum","initialState","isFinished","sideEffect","useGetSetState","get","setState","clearQueue","cancelCurrentTimeout","cleanup","set","useCallback","n","trickle","work","savedTrickle","useRef","useEffect","current","useEffectOnce","useUpdateEffect","NProgress","children","restProps","withNProgress","BaseComponent","WithNProgress","props","hookProps","React","createElement","hoistNonReactStatics"],"mappings":"s9BAAaA,MAAQ,SAACC,EAAKC,EAAOC,UAE9BF,GADAA,EAAMA,GAAOE,EAAQF,EAAME,IACdD,EAAQD,EAAMC,GCDlBE,UAAY,SAACC,OAClBC,EAAS,SACTD,GAAY,GAAKA,EAAW,GAC5BC,EAAS,GAEJD,GAAY,IAAOA,EAAW,GACnCC,EAAS,IAEJD,GAAY,IAAOA,EAAW,GACnCC,EAAS,IAEJD,GAAY,IAAOA,EAAW,MACnCC,EAAS,MAENN,MAAMK,EAAWC,EAAQ,EAAG,OCf1BC,YAAc,eACnBC,GAAY,EACZC,EAAU,GACRC,EAAO,SAAPA,IACFF,GAAY,MACNG,EAAKF,EAAQG,WACfD,SACOA,EAAGD,GAEdF,GAAY,SAYT,CACHK,MAXU,WACVL,GAAY,EACZC,EAAU,IAUVK,MARU,SAACH,GACXF,EAAQM,KAAKJ,GACRH,GAAgC,IAAnBC,EAAQO,QACtBN,OClBCO,cAAgB,eACrBC,QAqBG,CACHC,OArBW,WACXC,QAAQC,IAAI,UACRH,GACAI,OAAOC,qBAAqBL,IAmBhCM,QAhBY,SAACC,EAAUC,OAEnBC,EAUJT,EAASI,OAAOM,uBATF,SAARC,EAASC,GAECA,GADZH,EAAQA,GAASG,GAEDJ,EACZD,IAGJP,EAASI,OAAOM,sBAAsBC,SCT5CE,KAAO,aAUAC,aAAe,6BAA8F,SAA3FC,kBAAAA,aAAoB,UAAKC,kBAAAA,aAAoB,UAAKC,YAAAA,oBAAq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E,iBAAMC,cAAcL,+BAAoBE,EAAUC,YAE7DG,sCAAqBL,EAAeD,GAC7BC"}
1
+ {"version":3,"file":"react-nprogress.cjs.production.js","sources":["../compiled/clamp.js","../compiled/createQueue.js","../compiled/createTimeout.js","../compiled/increment.js","../compiled/useEffectOnce.js","../compiled/useGetSetState.js","../compiled/useUpdateEffect.js","../compiled/useNProgress.js","../compiled/NProgress.js","../compiled/withNProgress.js"],"sourcesContent":["export const clamp = (num, lower, upper) => {\n num = num <= upper ? num : upper;\n num = num >= lower ? num : lower;\n return num;\n};\n","export const createQueue = () => {\n let isRunning = false;\n let pending = [];\n const next = () => {\n isRunning = true;\n const cb = pending.shift();\n if (cb) {\n return cb(next);\n }\n isRunning = false;\n };\n const clear = () => {\n isRunning = false;\n pending = [];\n };\n const enqueue = (cb) => {\n pending.push(cb);\n if (!isRunning && pending.length === 1) {\n next();\n }\n };\n return {\n clear,\n enqueue,\n };\n};\n","export const createTimeout = () => {\n let handle;\n const cancel = () => {\n if (handle) {\n window.cancelAnimationFrame(handle);\n }\n };\n const schedule = (callback, delay) => {\n let deltaTime;\n let start;\n const frame = (time) => {\n start = start || time;\n deltaTime = time - start;\n if (deltaTime > delay) {\n callback();\n return;\n }\n handle = window.requestAnimationFrame(frame);\n };\n handle = window.requestAnimationFrame(frame);\n };\n return {\n cancel,\n schedule,\n };\n};\n","import { clamp } from './clamp';\nexport const increment = (progress) => {\n let amount = 0;\n if (progress >= 0 && progress < 0.2) {\n amount = 0.1;\n }\n else if (progress >= 0.2 && progress < 0.5) {\n amount = 0.04;\n }\n else if (progress >= 0.5 && progress < 0.8) {\n amount = 0.02;\n }\n else if (progress >= 0.8 && progress < 0.99) {\n amount = 0.005;\n }\n return clamp(progress + amount, 0, 0.994);\n};\n","// Hat-tip:\n// https://github.com/streamich/react-use/blob/master/src/useEffectOnce.ts.\n//\n// `react-use` appears to be unmaintained, so moving the required code into\n// this project for now.\nimport { useEffect } from 'react';\nexport const useEffectOnce = (effect) => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useEffect(effect, []);\n};\n","// Hat-tip:\n// https://github.com/streamich/react-use/blob/master/src/useGetSetState.ts.\n//\n// `react-use` appears to be unmaintained, so moving the required code into\n// this project for now.\nimport { useCallback, useRef, useState } from 'react';\nconst incrementParameter = (num) => ++num % 1_000_000;\nconst useUpdate = () => {\n const [, setState] = useState(0);\n return useCallback(() => setState(incrementParameter), []);\n};\nexport const useGetSetState = (\n/* istanbul ignore next */\ninitialState = {}) => {\n const update = useUpdate();\n const state = useRef({ ...initialState });\n const get = useCallback(() => state.current, []);\n const set = useCallback((patch) => {\n if (!patch) {\n return;\n }\n Object.assign(state.current, patch);\n update();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n return [get, set];\n};\n","// Hat-tip:\n// https://github.com/streamich/react-use/blob/master/src/useUpdateEffect.ts.\n//\n// `react-use` appears to be unmaintained, so moving the required code into\n// this project for now.\nimport { useEffect, useRef } from 'react';\nconst useFirstMountState = () => {\n const isFirst = useRef(true);\n if (isFirst.current) {\n isFirst.current = false;\n return true;\n }\n return isFirst.current;\n};\nexport const useUpdateEffect = (effect, deps) => {\n const isFirstMount = useFirstMountState();\n useEffect(() => {\n if (!isFirstMount) {\n return effect();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n};\n","import { useCallback, useEffect, useRef } from 'react';\nimport { clamp } from './clamp';\nimport { createQueue } from './createQueue';\nimport { createTimeout } from './createTimeout';\nimport { increment } from './increment';\nimport { useEffectOnce } from './useEffectOnce';\nimport { useGetSetState } from './useGetSetState';\nimport { useUpdateEffect } from './useUpdateEffect';\n/* istanbul ignore next */\nconst noop = () => undefined;\nconst initialState = {\n isFinished: true,\n progress: 0,\n sideEffect: noop,\n};\nexport const useNProgress = ({ animationDuration = 200, incrementDuration = 800, isAnimating = false, minimum = 0.08, } = {}) => {\n const [get, setState] = useGetSetState(initialState);\n const queue = useRef(null);\n const timeout = useRef(null);\n useEffectOnce(() => {\n queue.current = createQueue();\n timeout.current = createTimeout();\n });\n const cleanup = useCallback(() => {\n timeout.current?.cancel();\n queue.current?.clear();\n }, []);\n const set = useCallback((n) => {\n n = clamp(n, minimum, 1);\n if (n === 1) {\n cleanup();\n queue.current?.enqueue((next) => {\n setState({\n progress: n,\n sideEffect: () => timeout.current?.schedule(next, animationDuration),\n });\n });\n queue.current?.enqueue(() => {\n setState({ isFinished: true, sideEffect: cleanup });\n });\n return;\n }\n queue.current?.enqueue((next) => {\n setState({\n isFinished: false,\n progress: n,\n sideEffect: () => timeout.current?.schedule(next, animationDuration),\n });\n });\n }, [animationDuration, cleanup, minimum, queue, setState, timeout]);\n const trickle = useCallback(() => {\n set(increment(get().progress));\n }, [get, set]);\n const start = useCallback(() => {\n const work = () => {\n trickle();\n queue.current?.enqueue((next) => {\n timeout.current?.schedule(() => {\n work();\n next();\n }, incrementDuration);\n });\n };\n work();\n }, [incrementDuration, queue, timeout, trickle]);\n const savedTrickle = useRef(noop);\n const sideEffect = get().sideEffect;\n useEffect(() => {\n savedTrickle.current = trickle;\n });\n useEffectOnce(() => {\n if (isAnimating) {\n start();\n }\n return cleanup;\n });\n useUpdateEffect(() => {\n get().sideEffect();\n }, [get, sideEffect]);\n useUpdateEffect(() => {\n if (!isAnimating) {\n set(1);\n }\n else {\n setState({\n ...initialState,\n sideEffect: start,\n });\n }\n }, [isAnimating, set, setState, start]);\n return {\n animationDuration,\n isFinished: get().isFinished,\n progress: get().progress,\n };\n};\n","import { useNProgress } from './useNProgress';\nexport const NProgress = ({ children, ...restProps }) => {\n const renderProps = useNProgress(restProps);\n return children(renderProps);\n};\n","import hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\nimport { useNProgress } from './useNProgress';\nexport function withNProgress(BaseComponent) {\n const WithNProgress = (props) => {\n const hookProps = useNProgress(props);\n return React.createElement(BaseComponent, { ...props, ...hookProps });\n };\n hoistNonReactStatics(WithNProgress, BaseComponent);\n return WithNProgress;\n}\n"],"names":["clamp","num","lower","upper","createQueue","isRunning","pending","next","cb","shift","clear","enqueue","push","length","createTimeout","handle","cancel","window","cancelAnimationFrame","schedule","callback","delay","start","requestAnimationFrame","frame","time","increment","progress","amount","useEffectOnce","effect","useEffect","incrementParameter","useUpdate","setState","useState","useCallback","useGetSetState","initialState","update","state","useRef","current","patch","Object","assign","useFirstMountState","isFirst","useUpdateEffect","deps","isFirstMount","noop","isFinished","sideEffect","useNProgress","animationDuration","incrementDuration","isAnimating","minimum","get","queue","timeout","cleanup","set","n","_timeout$current2","_timeout$current3","trickle","work","savedTrickle","NProgress","children","restProps","withNProgress","BaseComponent","WithNProgress","props","hookProps","React","createElement","hoistNonReactStatics"],"mappings":"w7BAAaA,MAAQ,SAACC,EAAKC,EAAOC,UAE9BF,GADAA,EAAMA,GAAOE,EAAQF,EAAME,IACdD,EAAQD,EAAMC,GCFlBE,YAAc,eACnBC,GAAY,EACZC,EAAU,GACRC,EAAO,SAAPA,IACFF,GAAY,MACNG,EAAKF,EAAQG,WACfD,SACOA,EAAGD,GAEdF,GAAY,SAYT,CACHK,MAXU,WACVL,GAAY,EACZC,EAAU,IAUVK,QARY,SAACH,GACbF,EAAQM,KAAKJ,GACRH,GAAgC,IAAnBC,EAAQO,QACtBN,OClBCO,cAAgB,eACrBC,QAoBG,CACHC,OApBW,WACPD,GACAE,OAAOC,qBAAqBH,IAmBhCI,SAhBa,SAACC,EAAUC,OAEpBC,EAUJP,EAASE,OAAOM,uBATF,SAARC,EAASC,GAECA,GADZH,EAAQA,GAASG,GAEDJ,EACZD,IAGJL,EAASE,OAAOM,sBAAsBC,SChBrCE,UAAY,SAACC,OAClBC,EAAS,SACTD,GAAY,GAAKA,EAAW,GAC5BC,EAAS,GAEJD,GAAY,IAAOA,EAAW,GACnCC,EAAS,IAEJD,GAAY,IAAOA,EAAW,GACnCC,EAAS,IAEJD,GAAY,IAAOA,EAAW,MACnCC,EAAS,MAEN5B,MAAM2B,EAAWC,EAAQ,EAAG,OCT1BC,cAA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