next-nprogress-bar
Advanced tools
Comparing version 2.0.1 to 2.0.2
import React from 'react'; | ||
import { ProgressBarProps } from '.'; | ||
import { NavigateOptions } from 'next/dist/shared/lib/app-router-context'; | ||
export declare const AppProgressBar: React.MemoExoticComponent<({ color, height, options, shallowRouting, delay, style, }: ProgressBarProps) => React.JSX.Element>; | ||
export declare function useRouter(): { | ||
push: (href: string, options?: NavigateOptions) => void; | ||
back(): void; | ||
forward(): void; | ||
refresh(): void; | ||
replace(href: string, options?: NavigateOptions | undefined): void; | ||
prefetch(href: string, options?: import("next/dist/shared/lib/app-router-context").PrefetchOptions | undefined): void; | ||
}; |
@@ -18,3 +18,2 @@ export interface NProgressOptions { | ||
options?: Partial<NProgressOptions>; | ||
appDirectory?: boolean; | ||
shallowRouting?: boolean; | ||
@@ -28,3 +27,2 @@ delay?: number; | ||
* @param options NProgress options. @default undefined | ||
* @param appDirectory If your are in the app directory - @default false | ||
* @param shallowRouting If the progress bar is not displayed when you use shallow routing - @default false | ||
@@ -34,4 +32,3 @@ * @param delay When the page loads faster than the progress bar, it does not display - @default 0 | ||
*/ | ||
export { AppProgressBar } from './appDir'; | ||
export { useRouter } from './appRouter'; | ||
export { AppProgressBar, useRouter } from './appDir'; | ||
export { PagesProgressBar } from './pagesDir'; |
@@ -8,2 +8,30 @@ 'use strict'; | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
/* global Reflect, Promise */ | ||
var __assign = function() { | ||
__assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
function isSameURL(target, current) { | ||
@@ -41,5 +69,7 @@ var cleanTarget = target.protocol + '//' + target.host + target.pathname; | ||
var currentUrl = new URL(location.href); | ||
if (!shallowRouting || !isSameURL(targetUrl, currentUrl)) { | ||
startProgress(); | ||
} | ||
if (shallowRouting && isSameURL(targetUrl, currentUrl)) | ||
return; | ||
if ((targetUrl === null || targetUrl === void 0 ? void 0 : targetUrl.href) === (currentUrl === null || currentUrl === void 0 ? void 0 : currentUrl.href)) | ||
return; | ||
startProgress(); | ||
}; | ||
@@ -63,12 +93,10 @@ var handleMutation = function () { | ||
}, function () { return true; }); | ||
var useRouter = function () { | ||
function useRouter() { | ||
var router = navigation.useRouter(); | ||
var push = router.push; | ||
router.push = function (href, options) { | ||
function push(href, options) { | ||
NProgress.start(); | ||
push(href, options); | ||
}; | ||
return router; | ||
}; | ||
return router.push(href, options); | ||
} | ||
return __assign(__assign({}, router), { push: push }); | ||
} | ||
@@ -75,0 +103,0 @@ var PagesProgressBar = React.memo(function (_a) { |
{ | ||
"name": "next-nprogress-bar", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "NextJS progress bar compatible with new app directory", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36516
186