@solidjs/router 0.17.0-next.6 → 1.0.0-next.11
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 +526 -716
- package/dist/claims.d.ts +21 -0
- package/dist/claims.js +115 -0
- package/dist/data/action.d.ts +15 -0
- package/dist/data/action.js +165 -25
- package/dist/data/events.d.ts +8 -0
- package/dist/data/events.js +23 -22
- package/dist/data/flash.d.ts +1 -5
- package/dist/data/flash.js +10 -18
- package/dist/data/flashCookie.d.ts +7 -0
- package/dist/data/flashCookie.js +20 -0
- package/dist/data/serverForms.d.ts +1 -0
- package/dist/data/serverForms.js +5 -0
- package/dist/fs.d.ts +53 -0
- package/dist/fs.js +30 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +1896 -1156
- package/dist/index.jsx +2 -2
- package/dist/lifecycle.d.ts +29 -4
- package/dist/lifecycle.js +40 -37
- package/dist/paths.d.ts +117 -0
- package/dist/paths.js +41 -0
- package/dist/routers/components.d.ts +10 -21
- package/dist/routers/components.jsx +29 -51
- package/dist/routers/factory.d.ts +66 -0
- package/dist/routers/factory.jsx +151 -0
- package/dist/routers/history.d.ts +26 -0
- package/dist/routers/history.js +180 -0
- package/dist/routers/index.d.ts +4 -11
- package/dist/routers/index.js +2 -6
- package/dist/routers/scrollRestoration.d.ts +41 -0
- package/dist/routers/scrollRestoration.js +134 -0
- package/dist/routing.d.ts +79 -52
- package/dist/routing.js +304 -128
- package/dist/server.d.ts +31 -17
- package/dist/server.js +68 -12
- package/dist/types.d.ts +74 -5
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +2 -0
- package/package.json +8 -7
- package/dist/components.d.ts +0 -31
- package/dist/components.jsx +0 -46
- package/dist/routers/HashRouter.d.ts +0 -9
- package/dist/routers/HashRouter.js +0 -41
- package/dist/routers/MemoryRouter.d.ts +0 -24
- package/dist/routers/MemoryRouter.js +0 -57
- package/dist/routers/Router.d.ts +0 -9
- package/dist/routers/Router.js +0 -45
- package/dist/routers/StaticRouter.d.ts +0 -6
- package/dist/routers/StaticRouter.js +0 -15
- package/dist/routers/createRouter.d.ts +0 -10
- package/dist/routers/createRouter.js +0 -40
package/dist/fs.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { RouteSectionComponent } from "./types.js";
|
|
2
|
+
/** A code-split module ref: delivered as a dynamic import. */
|
|
3
|
+
export interface FileRouteLazyRef<M = Record<string, unknown>> {
|
|
4
|
+
src: string;
|
|
5
|
+
import(): Promise<M>;
|
|
6
|
+
}
|
|
7
|
+
/** An eager module ref: its picked exports are imported statically. */
|
|
8
|
+
export interface FileRouteEagerRef<M = Record<string, unknown>> {
|
|
9
|
+
require(): M;
|
|
10
|
+
}
|
|
11
|
+
/** The shape of a nested route-manifest entry the adapter consumes. */
|
|
12
|
+
export interface FileRouteEntry {
|
|
13
|
+
path: string;
|
|
14
|
+
page?: boolean;
|
|
15
|
+
$component?: FileRouteLazyRef<any> | undefined;
|
|
16
|
+
$$route?: FileRouteEagerRef<any> | undefined;
|
|
17
|
+
children?: readonly FileRouteEntry[] | undefined;
|
|
18
|
+
}
|
|
19
|
+
type RouteConfigOf<E> = E extends {
|
|
20
|
+
$$route: {
|
|
21
|
+
require(): {
|
|
22
|
+
route: infer R;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
} ? R : {};
|
|
26
|
+
/**
|
|
27
|
+
* One manifest entry as a route definition. `children` is a required key on
|
|
28
|
+
* purpose: an optional key infers as `C | undefined`, and that union
|
|
29
|
+
* distributes `RoutePaths` into an uncallable shape.
|
|
30
|
+
*/
|
|
31
|
+
export type FileRouteFrom<E> = RouteConfigOf<E> & {
|
|
32
|
+
path: E extends {
|
|
33
|
+
path: infer P extends string;
|
|
34
|
+
} ? P : never;
|
|
35
|
+
component: E extends {
|
|
36
|
+
$component: object;
|
|
37
|
+
} ? RouteSectionComponent : undefined;
|
|
38
|
+
children: E extends {
|
|
39
|
+
children: infer C extends readonly FileRouteEntry[];
|
|
40
|
+
} ? FileRoutesFrom<C> : undefined;
|
|
41
|
+
};
|
|
42
|
+
export type FileRoutesFrom<T extends readonly FileRouteEntry[]> = {
|
|
43
|
+
[K in keyof T]: FileRouteFrom<T[K]>;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Converts the nested page entries of a file-system route manifest into
|
|
47
|
+
* route definitions: `$component` refs become code-split `lazy` components
|
|
48
|
+
* (their `src` doubles as the `moduleUrl` core resolves assets and islands
|
|
49
|
+
* against), and each entry's `route` config export is spread into its
|
|
50
|
+
* definition. Pass the result to `createRouter({ routes })`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function fileRoutes<const T extends readonly FileRouteEntry[]>(entries: T): FileRoutesFrom<T>;
|
|
53
|
+
export {};
|
package/dist/fs.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { lazy } from "solid-js";
|
|
2
|
+
/**
|
|
3
|
+
* Converts the nested page entries of a file-system route manifest into
|
|
4
|
+
* route definitions: `$component` refs become code-split `lazy` components
|
|
5
|
+
* (their `src` doubles as the `moduleUrl` core resolves assets and islands
|
|
6
|
+
* against), and each entry's `route` config export is spread into its
|
|
7
|
+
* definition. Pass the result to `createRouter({ routes })`.
|
|
8
|
+
*/
|
|
9
|
+
export function fileRoutes(entries) {
|
|
10
|
+
const components = new Map();
|
|
11
|
+
const componentOf = (ref) => {
|
|
12
|
+
let component = components.get(ref.src);
|
|
13
|
+
if (!component) {
|
|
14
|
+
component = lazy(ref.import, ref.src);
|
|
15
|
+
components.set(ref.src, component);
|
|
16
|
+
}
|
|
17
|
+
return component;
|
|
18
|
+
};
|
|
19
|
+
const toRoute = (entry) => {
|
|
20
|
+
const config = (entry.$$route?.require().route ?? {});
|
|
21
|
+
return {
|
|
22
|
+
...config,
|
|
23
|
+
path: entry.path,
|
|
24
|
+
component: entry.$component ? componentOf(entry.$component) : undefined,
|
|
25
|
+
info: { ...config.info, filesystem: true },
|
|
26
|
+
children: entry.children ? entry.children.map(toRoute) : undefined
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
return entries.map(toRoute);
|
|
30
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from "./routers/index.js";
|
|
2
|
-
export * from "./components.jsx";
|
|
3
2
|
export * from "./lifecycle.js";
|
|
4
|
-
export { useHref, useIsRouting, useLocation, useMatch,
|
|
3
|
+
export { useHref, useIsRouting, useLinkState, useLocation, useMatch, useNavigate, usePreloadRoute, useParams, useResolvedPath, useRouteMatches, useSearchParams, RouterContextObj as RouterContext } from "./routing.js";
|
|
4
|
+
export type { LinkState } from "./routing.js";
|
|
5
5
|
export { mergeSearchString as _mergeSearchString } from "./utils.js";
|
|
6
|
+
export { int } from "./paths.js";
|
|
7
|
+
export type { RoutePaths, PathParamsOf, PathEnd, TypedMatchFilter, DefaultSearchTypes } from "./paths.js";
|
|
6
8
|
export * from "./data/index.js";
|
|
7
|
-
export type { Location, LocationChange, SearchParams, MatchFilter, MatchFilters, NavigateOptions, Navigator, OutputMatch, Params, PathMatch, RouteSectionProps, RoutePreloadFunc, RoutePreloadFuncArgs, RouteDefinition, RouteDescription, RouteMatch, RouterIntegration, RouterUtils, SetParams, Submission, BeforeLeaveEventArgs } from "./types.js";
|
|
9
|
+
export type { Location, LocationChange, SearchParams, MatchFilter, MatchFilters, NavigateOptions, Navigator, OutputMatch, Params, PathMatch, RouteSectionProps, RoutePreloadFunc, RoutePreloadFuncArgs, RouteDefinition, RouteDescription, RouteMatch, RouterIntegration, RouterUtils, SetParams, SetSearchParams, Submission, BeforeLeaveEventArgs, TypedPath, TypedSearchPath, StandardSchemaV1 } from "./types.js";
|