Skip to content

Commit a283098

Browse files
committed
fix: follow solid-js rc.10 attribution API (NavigationRef, history(type)); peer ^2.0.0-rc.10
1 parent 4658036 commit a283098

6 files changed

Lines changed: 43 additions & 38 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/router": patch
3+
---
4+
5+
Follow solid-js 2.0.0-rc.10: `NavigationRef` is imported from `solid-js`, navigation history reads `attribution.history("navigation")`; peer range now `^2.0.0-rc.10`.

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ const isRouting = useIsRouting();
850850
return <div classList={{ "grey-out": isRouting() }}>...</div>;
851851
```
852852

853-
In Solid's dev and observe builds the router also declares every navigation to the attribution engine (`solid-js/attribution`): holds and re-runs caused by a navigation are named after the route pattern (`navigation to /users/:id`), timed from the user event that started it, and redirect hops fold onto the navigation they belong to. `attribution.navigations()` and `feedback().navigations` list them; nothing of this exists in production builds.
853+
In Solid's dev and observe builds the router also declares every navigation to the attribution engine (`solid-js/attribution`): holds and re-runs caused by a navigation are named after the route pattern (`navigation to /users/:id`), timed from the user event that started it, and redirect hops fold onto the navigation they belong to. `attribution.history("navigation")` and `feedback().navigations` list them; nothing of this exists in production builds.
854854

855855
### useMatch
856856

‎package.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,22 @@
4848
"@rollup/plugin-node-resolve": "15.3.0",
4949
"@rollup/plugin-terser": "0.4.4",
5050
"@solidjs/vite-plugin": "3.0.0-next.35",
51-
"@solidjs/web": "^2.0.0-rc.9",
51+
"@solidjs/web": "^2.0.0-rc.11",
5252
"@types/jest": "^29.5.14",
5353
"@types/node": "^22.10.0",
5454
"babel-preset-solid": "^2.0.0-rc.2",
5555
"jsdom": "^25.0.1",
5656
"prettier": "^3.4.1",
5757
"rollup": "^4.27.4",
58-
"solid-js": "^2.0.0-rc.9",
58+
"solid-js": "^2.0.0-rc.11",
5959
"typescript": "^5.7.2",
6060
"vite": "^8.2.2",
6161
"vitest": "^4.1.11"
6262
},
6363
"peerDependencies": {
64-
"@solidjs/web": "^2.0.0-rc.9",
64+
"@solidjs/web": "^2.0.0-rc.10",
6565
"filesystem-routing": ">=0.4.0",
66-
"solid-js": "^2.0.0-rc.9"
66+
"solid-js": "^2.0.0-rc.10"
6767
},
6868
"peerDependenciesMeta": {
6969
"filesystem-routing": {

‎pnpm-lock.yaml‎

Lines changed: 23 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/routers/factory.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
// `OBSERVE` outside its observe/dev builds, so app bundlers fold the
1515
// `DEV &&` diagnostics and the `OBSERVE &&` attribution out of shipped bundles
1616
import { DEV, OBSERVE } from "solid-js";
17-
import type { NavigationRef } from "solid-js/attribution";
17+
import type { NavigationRef } from "solid-js";
1818
import { getRequestEvent, isServer } from "@solidjs/web";
1919
import type { JSX } from "@solidjs/web";
2020
import { setupLinkClaims } from "../claims.js";

‎test/observe-navigation.spec.tsx‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function mount(Router: (props: any) => any) {
3939
};
4040
}
4141

42-
const last = () => attribution.navigations()[attribution.navigations().length - 1];
42+
const last = () => attribution.history("navigation")[attribution.history("navigation").length - 1];
4343

4444
describe("observe tier: navigations declared to attribution", () => {
4545
const originalScrollTo = window.scrollTo;
@@ -76,12 +76,12 @@ describe("observe tier: navigations declared to attribution", () => {
7676

7777
const { div, cleanup } = mount(Router);
7878
try {
79-
const before = attribution.navigations().length;
79+
const before = attribution.history("navigation").length;
8080
navigate("/users/42");
8181
await settle();
8282
expect(div.querySelector('[data-route="user"]')?.textContent).toBe("42");
8383

84-
expect(attribution.navigations().length).toBe(before + 1);
84+
expect(attribution.history("navigation").length).toBe(before + 1);
8585
const nav = last();
8686
expect(nav.name).toBe("/users/:id");
8787
expect(nav.to).toBe("/users/42");
@@ -147,13 +147,13 @@ describe("observe tier: navigations declared to attribution", () => {
147147

148148
const { div, cleanup } = mount(Router);
149149
try {
150-
const before = attribution.navigations().length;
150+
const before = attribution.history("navigation").length;
151151
navigate("/files");
152152
await settle(60);
153153
expect(div.querySelector('[data-route="login"]')).toBeTruthy();
154154

155155
// one navigation, two writes, the abandoned destination recorded as a hop
156-
expect(attribution.navigations().length).toBe(before + 1);
156+
expect(attribution.history("navigation").length).toBe(before + 1);
157157
const nav = last();
158158
expect(nav.name).toBe("/login");
159159
expect(nav.to).toBe("/login");
@@ -204,12 +204,12 @@ describe("observe tier: navigations declared to attribution", () => {
204204

205205
const { div, cleanup } = mount(Router);
206206
try {
207-
const before = attribution.navigations().length;
207+
const before = attribution.history("navigation").length;
208208
navigate("/private");
209209
await settle(60);
210210
expect(div.querySelector('[data-route="login"]')).toBeTruthy();
211211

212-
expect(attribution.navigations().length).toBe(before + 1);
212+
expect(attribution.history("navigation").length).toBe(before + 1);
213213
const nav = last();
214214
expect(nav.name).toBe("/login");
215215
expect(nav.from).toBe("/");
@@ -290,11 +290,11 @@ describe("observe tier: navigations declared to attribution", () => {
290290
await settle();
291291
expect(div.querySelector('[data-route="user"]')).toBeTruthy();
292292

293-
const before = attribution.navigations().length;
293+
const before = attribution.history("navigation").length;
294294
history.go(-1);
295295
await settle();
296296
expect(div.querySelector('[data-route="home"]')).toBeTruthy();
297-
expect(attribution.navigations().length).toBe(before + 1);
297+
expect(attribution.history("navigation").length).toBe(before + 1);
298298
const nav = last();
299299
expect(nav.name).toBe("/");
300300
expect(nav.from).toBe("/users/1");

0 commit comments

Comments
 (0)