@solidjs/router 2.0.0-next.36 → 2.0.0-next.37
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 +30 -7
- package/dist/claims.d.ts +5 -3
- package/dist/claims.js +14 -14
- package/dist/data/events.js +9 -5
- package/dist/index.d.ts +2 -1
- package/dist/index.js +231 -109
- package/dist/index.jsx +1 -0
- package/dist/pending.d.ts +25 -0
- package/dist/pending.js +67 -0
- package/dist/routers/components.jsx +7 -4
- package/dist/routers/factory.d.ts +17 -2
- package/dist/routers/factory.jsx +22 -13
- package/dist/routers/scrollRestoration.d.ts +29 -5
- package/dist/routers/scrollRestoration.js +77 -32
- package/dist/routing.d.ts +7 -1
- package/dist/routing.js +28 -38
- package/dist/serverRouteComponent.js +5 -4
- package/dist/types.d.ts +27 -10
- package/package.json +6 -6
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// // before: a client component exists only to make the call
|
|
9
9
|
// const getStory = query(storyView, "story");
|
|
10
10
|
// component: props => {
|
|
11
|
-
// const View =
|
|
11
|
+
// const View = dynamicComponent(() => getStory(props.params.id));
|
|
12
12
|
// return <View>{props.children}</View>;
|
|
13
13
|
// }
|
|
14
14
|
// // after
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
// A server component that takes other client positions — handlers, refs,
|
|
37
37
|
// named slots — has a client half, and that half is a client component; the
|
|
38
38
|
// helper does not pretend otherwise. Write the wrapper for that route.
|
|
39
|
-
import {
|
|
39
|
+
import { dynamicComponent } from "@solidjs/web";
|
|
40
40
|
import { createComponent, DEV } from "solid-js";
|
|
41
41
|
import { SERVER_ROUTE } from "./serverRouteShared.js";
|
|
42
42
|
/**
|
|
@@ -77,8 +77,9 @@ source) {
|
|
|
77
77
|
};
|
|
78
78
|
function render(args, routeProps) {
|
|
79
79
|
// The source may answer a component, a promise of one, or (a live query)
|
|
80
|
-
// successive components; `
|
|
81
|
-
|
|
80
|
+
// successive components; `dynamicComponent`'s memo lands each the same
|
|
81
|
+
// way. Never a tag, so the element runtime `dynamic` retains stays out.
|
|
82
|
+
const View = dynamicComponent(() => call(args()));
|
|
82
83
|
return createComponent(View, {
|
|
83
84
|
get children() {
|
|
84
85
|
return routeProps.children;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Component, Signal } from "solid-js";
|
|
1
|
+
import type { Component, Owner, Signal } from "solid-js";
|
|
2
2
|
import type { JSX, ResponseEnvelope } from "@solidjs/web";
|
|
3
3
|
declare module "@solidjs/web" {
|
|
4
4
|
interface RequestEvent {
|
|
@@ -118,13 +118,13 @@ export interface LocationWrite<S = unknown> extends Omit<LocationChange<S>, "val
|
|
|
118
118
|
export interface RouterIntegration {
|
|
119
119
|
signal: [get: () => LocationChange, set: (next: LocationWrite) => void];
|
|
120
120
|
/**
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* in
|
|
124
|
-
* guard redirecting as the held route
|
|
125
|
-
*
|
|
121
|
+
* Whether a navigation write's settle has run: Solid's `onSettled`,
|
|
122
|
+
* registered beside the write, fired for the transition that carried it.
|
|
123
|
+
* Until then the write is in flight: its destination was never shown, so a
|
|
124
|
+
* `navigate()` issued meanwhile (a guard redirecting as the held route
|
|
125
|
+
* lands) is a hop of that navigation rather than a new one.
|
|
126
126
|
*/
|
|
127
|
-
|
|
127
|
+
settled?: (write: LocationChange) => boolean;
|
|
128
128
|
utils?: Partial<RouterUtils>;
|
|
129
129
|
}
|
|
130
130
|
export type Intent = "initial" | "native" | "navigate" | "preload";
|
|
@@ -330,11 +330,12 @@ export interface RouterContext {
|
|
|
330
330
|
params: Params;
|
|
331
331
|
wrapParams: (getParams: () => Params) => Params;
|
|
332
332
|
navigatorFactory: NavigatorFactory;
|
|
333
|
-
isRouting: () => boolean;
|
|
334
333
|
/** @internal Intent of the in-flight canonical location transition. */
|
|
335
334
|
intent?: () => Intent | undefined;
|
|
336
|
-
/** The
|
|
337
|
-
|
|
335
|
+
/** @internal The integration's location signal: the last flushed write. */
|
|
336
|
+
_source: () => LocationChange;
|
|
337
|
+
/** @internal The owner the router's own computations live under. */
|
|
338
|
+
_owner: Owner | null;
|
|
338
339
|
matches: () => RouteMatch[];
|
|
339
340
|
renderPath(path: string): string;
|
|
340
341
|
parsePath(str: string): string;
|
|
@@ -343,6 +344,22 @@ export interface RouterContext {
|
|
|
343
344
|
singleFlight: boolean;
|
|
344
345
|
submissions: Signal<Submission<any, any>[]>;
|
|
345
346
|
}
|
|
347
|
+
/**
|
|
348
|
+
* A plugin for the router's `links` option that extends the state it writes
|
|
349
|
+
* onto claimed anchors. Built once per router with its base path. The router
|
|
350
|
+
* ships `pendingLinks`, which adds `data-pending`.
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* ```ts
|
|
354
|
+
* const Router = createRouter({ routes, links: pendingLinks });
|
|
355
|
+
* ```
|
|
356
|
+
*/
|
|
357
|
+
export type LinksPlugin = (router: RouterContext, base: string) => {
|
|
358
|
+
/** The reactive read the claims sweep re-runs on. */
|
|
359
|
+
track(): unknown;
|
|
360
|
+
/** Whether an anchor resolving to `target` is the in-flight destination; read when `track()` is truthy. */
|
|
361
|
+
pending(target: string | undefined): boolean;
|
|
362
|
+
};
|
|
346
363
|
export interface BeforeLeaveEventArgs {
|
|
347
364
|
from: Location;
|
|
348
365
|
to: string | number;
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"Ryan Turnquist"
|
|
7
7
|
],
|
|
8
8
|
"license": "MIT",
|
|
9
|
-
"version": "2.0.0-next.
|
|
9
|
+
"version": "2.0.0-next.37",
|
|
10
10
|
"homepage": "https://github.com/solidjs/solid-router#readme",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
@@ -37,23 +37,23 @@
|
|
|
37
37
|
"@rollup/plugin-babel": "6.0.4",
|
|
38
38
|
"@rollup/plugin-node-resolve": "15.3.0",
|
|
39
39
|
"@rollup/plugin-terser": "0.4.4",
|
|
40
|
-
"@solidjs/vite-plugin": "3.0.0-next.
|
|
41
|
-
"@solidjs/web": "^2.0.0-rc.
|
|
40
|
+
"@solidjs/vite-plugin": "3.0.0-next.47",
|
|
41
|
+
"@solidjs/web": "^2.0.0-rc.14",
|
|
42
42
|
"@types/jest": "^29.5.14",
|
|
43
43
|
"@types/node": "^22.10.0",
|
|
44
44
|
"babel-preset-solid": "^2.0.0-rc.2",
|
|
45
45
|
"jsdom": "^25.0.1",
|
|
46
46
|
"prettier": "^3.4.1",
|
|
47
47
|
"rollup": "^4.27.4",
|
|
48
|
-
"solid-js": "^2.0.0-rc.
|
|
48
|
+
"solid-js": "^2.0.0-rc.14",
|
|
49
49
|
"typescript": "^5.7.2",
|
|
50
50
|
"vite": "^8.2.2",
|
|
51
51
|
"vitest": "^4.1.11"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@solidjs/web": "^2.0.0-rc.
|
|
54
|
+
"@solidjs/web": "^2.0.0-rc.14",
|
|
55
55
|
"filesystem-routing": ">=0.4.0",
|
|
56
|
-
"solid-js": "^2.0.0-rc.
|
|
56
|
+
"solid-js": "^2.0.0-rc.14"
|
|
57
57
|
},
|
|
58
58
|
"peerDependenciesMeta": {
|
|
59
59
|
"filesystem-routing": {
|