@k8ordo/router 2.3.1 → 3.0.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.
@@ -7,6 +7,7 @@ import { Position } from "./left-at.mjs";
7
7
  */
8
8
  export type NavigationFacts = Pick<NavigateEvent, 'canIntercept' | 'hashChange' | 'downloadRequest' | 'navigationType'> & {
9
9
  readonly formData: FormData | null;
10
+ readonly destination: Pick<NavigationDestination, 'sameDocument'>;
10
11
  };
11
12
  /**
12
13
  * Whether this navigation is the application's to handle at all.
@@ -2,7 +2,7 @@
2
2
  import { decodeOrKeep, normalizePathname } from "./paths.mjs";
3
3
  import { leftAt, rememberLeftAt, restoreLeftAt } from "./left-at.mjs";
4
4
  import { appPathname } from "./location.mjs";
5
- import { addTransitionType, createContext, startTransition, useDeferredValue, useEffect, useEffectEvent, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
5
+ import { addTransitionType, createContext, startTransition, useDeferredValue, useEffectEvent, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
6
6
  // src/navigation.ts
7
7
  /**
8
8
  * Whether this navigation is the application's to handle at all.
@@ -13,7 +13,7 @@ import { addTransitionType, createContext, startTransition, useDeferredValue, us
13
13
  * has no `formData`, so the search-shaped navigations `@k8ordo/state` builds
14
14
  * still come through here.
15
15
  */
16
- const isOurs = (event) => event.canIntercept && !event.hashChange && event.downloadRequest === null && event.navigationType !== "reload" && event.formData === null;
16
+ const isOurs = (event) => event.canIntercept && !(event.hashChange && event.destination.sameDocument) && event.downloadRequest === null && event.navigationType !== "reload" && event.formData === null;
17
17
  const scrollPlanFor = (navigationType, hash, left) => {
18
18
  if (navigationType === "traverse" && left !== void 0) return {
19
19
  kind: "position",
@@ -171,7 +171,7 @@ function useInterceptedNavigation(handler) {
171
171
  const latest = useRef(-1);
172
172
  const applying = useRef(null);
173
173
  const onScreenEntry = useRef(null);
174
- useEffect(() => {
174
+ useLayoutEffect(() => {
175
175
  shown.current = normalizePathname(location.pathname);
176
176
  restoreLeftAt();
177
177
  const steps = reloadOnUnannouncedSteps((url) => normalizePathname(url.pathname) === shown.current && pendingPathname === null && !refresh(url));
package/docs/GUIDE.md CHANGED
@@ -138,9 +138,11 @@ in the browser; the rest is left alone, so a real document load — and a real
138
138
  nothing rather than guessing.
139
139
 
140
140
  Four kinds of navigation are never the application's, whatever the table says:
141
- a reload, a form submitted with a body (POST), a download, and a fragment-only
142
- change — nor is any navigation the platform does not let a page intercept,
143
- such as one to another origin. Intercepting any of the four would silently do
141
+ a reload, a form submitted with a body (POST), a download, and a move to a
142
+ fragment within the document — nor is any navigation the platform does not
143
+ let a page intercept, such as one to another origin. A move that drops the
144
+ fragment (`/docs#api` to `/docs`) is not a move to a fragment: the platform
145
+ loads a document for it, so it is the application's like any other. Intercepting any of the four would silently do
144
146
  nothing where the platform would have done the obvious thing — a POST body
145
147
  only the server can act on, an `F5` that stops reloading. A GET form carries
146
148
  no body, so the search-shaped submissions `@k8ordo/state` builds still come
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k8ordo/router",
3
- "version": "2.3.1",
3
+ "version": "3.0.0",
4
4
  "description": "The pathname axis of the URL, owned. One route table derives the types, the matching, the links, and the navigation, over the Navigation API and URLPattern.",
5
5
  "keywords": [
6
6
  "navigation-api",
@@ -42,16 +42,16 @@
42
42
  "@arethetypeswrong/cli": "0.18.5",
43
43
  "@types/react": "19.3.0",
44
44
  "@types/react-dom": "19.3.0",
45
- "@vitejs/plugin-react": "6.1.2",
46
- "@vitest/browser-playwright": "5.0.5",
47
- "playwright": "1.63.0",
45
+ "@vitejs/plugin-react": "6.2.1",
46
+ "@vitest/browser-playwright": "5.1.0",
47
+ "playwright": "1.65.0",
48
48
  "publint": "0.3.25",
49
49
  "react": "19.3.1",
50
50
  "react-dom": "19.3.1",
51
51
  "typescript": "7.0.2",
52
52
  "vite": "npm:@voidzero-dev/vite-plus-core@1.4.0",
53
53
  "vite-plus": "1.4.0",
54
- "vitest": "5.0.5",
54
+ "vitest": "5.1.0",
55
55
  "vitest-browser-react": "2.3.0"
56
56
  },
57
57
  "peerDependencies": {