@simonbackx/vue-app-navigation 2.14.0 → 2.15.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.
package/dist/index.js CHANGED
@@ -384,7 +384,11 @@ class HistoryManagerStatic {
384
384
  state.title = title;
385
385
  } else {
386
386
  const state = this.states[index];
387
- if (!state || state.index !== index) {
387
+ if (!state) {
388
+ console.error("Search state with index ", index, "not found");
389
+ return;
390
+ }
391
+ if (state.index !== index) {
388
392
  console.error("Search state with index ", index, "but received state with index", state.index);
389
393
  return;
390
394
  }
@@ -1846,13 +1850,21 @@ function addCheckRoutesMountedHandler() {
1846
1850
  return;
1847
1851
  }
1848
1852
  instance._didAddCheckRoutesMountedHandler = true;
1853
+ let doDeactivate = false;
1854
+ onBeforeUnmount(() => {
1855
+ if (component && doDeactivate) {
1856
+ component.checkRoutes = false;
1857
+ }
1858
+ });
1849
1859
  onMounted(async () => {
1850
1860
  if (component && component.checkRoutes) {
1851
- component.checkRoutes = false;
1861
+ doDeactivate = true;
1852
1862
  if ("_navigationCheckRoutesHandlers" in instance && Array.isArray(instance._navigationCheckRoutesHandlers)) {
1853
1863
  for (const handler of instance._navigationCheckRoutesHandlers) {
1854
1864
  if (typeof handler === "function") {
1855
- await handler();
1865
+ if (await handler() === true) {
1866
+ return;
1867
+ }
1856
1868
  } else {
1857
1869
  console.error("Invalid checkRoutes handler", handler);
1858
1870
  }
@@ -1862,7 +1874,9 @@ function addCheckRoutesMountedHandler() {
1862
1874
  if ("_navigationNotCheckRoutesHandlers" in instance && Array.isArray(instance._navigationNotCheckRoutesHandlers)) {
1863
1875
  for (const handler of instance._navigationNotCheckRoutesHandlers) {
1864
1876
  if (typeof handler === "function") {
1865
- await handler();
1877
+ if (await handler() === true) {
1878
+ return;
1879
+ }
1866
1880
  } else {
1867
1881
  console.error("Invalid not checkRoutes handler", handler);
1868
1882
  }
@@ -67,7 +67,10 @@ export type NavigationOptions<T> = {
67
67
  export declare function usePop(): (options?: PopOptions) => Promise<void> | undefined;
68
68
  export declare function useNavigate(): <Params extends Record<string, unknown>>(prop1: string | Route<Params>, prop2?: RouteNavigationOptions<Params>) => Promise<void>;
69
69
  export type DefaultRouteHandler = () => Promise<boolean>;
70
- export type OnCheckRoutesHandler = () => Promise<void> | void;
70
+ /**
71
+ * Return true when the route has been handled and other route checks should not be executed.
72
+ */
73
+ export type OnCheckRoutesHandler = () => Promise<void | boolean> | void | boolean;
71
74
  export declare function onCheckRoutes(handler: OnCheckRoutesHandler): void;
72
75
  export declare function onNotCheckRoutes(handler: OnCheckRoutesHandler): void;
73
76
  export declare function defineRoutes(routes: (Route<any>[]) | (() => Promise<boolean | (Route<any>[])>)): void;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@simonbackx/vue-app-navigation",
3
3
  "main": "./dist/index.js",
4
4
  "types": "./dist/index.d.ts",
5
- "version": "2.14.0",
5
+ "version": "2.15.0",
6
6
  "exports": {
7
7
  ".": {
8
8
  "import": "./dist/index.js",