@renr/parcel-rsc-router 1.0.0-alpha.7 → 1.0.0-alpha.8
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/esm/Router.d.mts +2 -2
- package/dist/esm/Router.d.mts.map +1 -1
- package/dist/esm/index.d.mts +2 -2
- package/dist/esm/types.d.mts +28 -8
- package/dist/esm/types.d.mts.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +13 -3
package/dist/esm/Router.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RouteData
|
|
1
|
+
import { RouteData } from "./types.mjs";
|
|
2
2
|
import * as React$1 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/Router.d.ts
|
|
@@ -9,7 +9,7 @@ declare function useLocation(): Location;
|
|
|
9
9
|
declare function useCurrentRoute(): {
|
|
10
10
|
rsc: `${string}.rsc`;
|
|
11
11
|
url: string;
|
|
12
|
-
path:
|
|
12
|
+
path: string;
|
|
13
13
|
slug: string;
|
|
14
14
|
html: `${string}.html`;
|
|
15
15
|
} | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Router.d.mts","names":[],"sources":["../../src/Router.tsx"],"mappings":";;;;iBAuBgB,SAAA,CAAA;EAAS,QAAA,GAHZ,EAAA;AAAA;AAAA,iBAaG,WAAA,CAAA,GAAW,QAAA;AAAA,iBAQX,eAAA,CAAA
|
|
1
|
+
{"version":3,"file":"Router.d.mts","names":[],"sources":["../../src/Router.tsx"],"mappings":";;;;iBAuBgB,SAAA,CAAA;EAAS,QAAA,GAHZ,EAAA;AAAA;AAAA,iBAaG,WAAA,CAAA,GAAW,QAAA;AAAA,iBAQX,eAAA,CAAA;;;;;;;cAeH,cAAA;EAAkB,QAAA;EAAA;AAAA;EAI7B,QAAA,EAAU,OAAA,CAAM,SAAA;EAChB,MAAA,EAAQ,SAAA;AAAA,MACT,OAAA,CAAA,GAAA,CAAA,OAAA"}
|
package/dist/esm/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { App, RouteData, RouteNode, RoutePath } from "./types.mjs";
|
|
1
|
+
import { App, Page, PageProps, RouteData, RouteHtml, RouteNode, RoutePath, RouteRsc, TocNode } from "./types.mjs";
|
|
2
2
|
import { Link } from "./Link.mjs";
|
|
3
3
|
import { RouterProvider, useCurrentRoute, useLocation, useRouter } from "./Router.mjs";
|
|
4
|
-
export { type App, Link, type RouteData, type RouteNode, type RoutePath, RouterProvider, useCurrentRoute, useLocation, useRouter };
|
|
4
|
+
export { type App, Link, type Page, type PageProps, type RouteData, type RouteHtml, type RouteNode, type RoutePath, type RouteRsc, RouterProvider, type TocNode, useCurrentRoute, useLocation, useRouter };
|
package/dist/esm/types.d.mts
CHANGED
|
@@ -1,17 +1,37 @@
|
|
|
1
|
+
import { Page, TocNode } from "@parcel/rsc";
|
|
2
|
+
|
|
1
3
|
//#region src/types.d.ts
|
|
2
4
|
declare namespace App {
|
|
3
5
|
interface Routes {}
|
|
4
6
|
}
|
|
5
7
|
type RoutePath = keyof App.Routes extends never ? string : keyof App.Routes;
|
|
6
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Union of all valid HTML route paths, e.g. "/index.html" | "/components/button.html"
|
|
10
|
+
*/
|
|
11
|
+
type RouteHtml = keyof App.Routes extends never ? `${string}.html` : App.Routes[keyof App.Routes]["html"];
|
|
12
|
+
type RouteRsc = keyof App.Routes extends never ? `${string}.rsc` : App.Routes[keyof App.Routes]["rsc"];
|
|
13
|
+
type RouteData<TPath extends string = RoutePath, THtml extends string = RouteHtml, TRsc extends string = RouteRsc> = Omit<RouteNode<TPath, THtml, TRsc>, "children">;
|
|
7
14
|
type RoutePathToSlug<T extends string> = T extends `/` ? "index" : T extends `${infer _Prefix}/${infer Slug}` ? RoutePathToSlug<Slug> : T;
|
|
8
|
-
interface RouteNode {
|
|
9
|
-
children: RouteNode[];
|
|
10
|
-
path:
|
|
11
|
-
slug: RoutePathToSlug<
|
|
12
|
-
rsc:
|
|
13
|
-
html:
|
|
15
|
+
interface RouteNode<TPath extends string = RoutePath, THtml extends string = RouteHtml, TRsc extends string = RouteRsc> {
|
|
16
|
+
children: RouteNode<TPath, THtml, TRsc>[];
|
|
17
|
+
path: TPath;
|
|
18
|
+
slug: RoutePathToSlug<TPath>;
|
|
19
|
+
rsc: TRsc;
|
|
20
|
+
html: THtml;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Enhanced Page interface where `url` is typed with generated HTML route URLs.
|
|
24
|
+
*/
|
|
25
|
+
interface Page$1<TUrl extends string = RouteHtml> extends Omit<Page, "url"> {
|
|
26
|
+
url: TUrl;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Enhanced PageProps where `pages` and `currentPage` have typed `url`s.
|
|
30
|
+
*/
|
|
31
|
+
interface PageProps<TUrl extends string = RouteHtml> {
|
|
32
|
+
pages: Page$1<RouteHtml>[];
|
|
33
|
+
currentPage: Page$1<TUrl>;
|
|
14
34
|
}
|
|
15
35
|
//#endregion
|
|
16
|
-
export { App, RouteData, RouteNode, RoutePath };
|
|
36
|
+
export { App, Page$1 as Page, PageProps, RouteData, RouteHtml, RouteNode, RoutePath, RouteRsc, type TocNode };
|
|
17
37
|
//# sourceMappingURL=types.d.mts.map
|
package/dist/esm/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/types.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/types.ts"],"mappings":";;;kBAIiB,GAAA;EAAA,UACE,MAAA;AAAA;AAAA,KAGP,SAAA,SAAkB,GAAA,CAAI,MAAA,gCAExB,GAAA,CAAI,MAAA;;AAFd;;KAOY,SAAA,SAAkB,GAAA,CAAI,MAAA,oCAE9B,GAAA,CAAI,MAAA,OAAa,GAAA,CAAI,MAAA;AAAA,KAEb,QAAA,SAAiB,GAAA,CAAI,MAAA,mCAE7B,GAAA,CAAI,MAAA,OAAa,GAAA,CAAI,MAAA;AAAA,KAEb,SAAA,wBACa,SAAA,yBACA,SAAA,wBACD,QAAA,IACpB,IAAA,CAAK,SAAA,CAAU,KAAA,EAAO,KAAA,EAAO,IAAA;AAAA,KAE5B,eAAA,qBAAoC,CAAA,yBAErC,CAAA,4CACE,eAAA,CAAgB,IAAA,IAChB,CAAA;AAAA,UAEW,SAAA,wBACQ,SAAA,yBACA,SAAA,wBACD,QAAA;EAEtB,QAAA,EAAU,SAAA,CAAU,KAAA,EAAO,KAAA,EAAO,IAAA;EAClC,IAAA,EAAM,KAAA;EACN,IAAA,EAAM,eAAA,CAAgB,KAAA;EACtB,GAAA,EAAK,IAAA;EACL,IAAA,EAAM,KAAA;AAAA;;;;UAMS,MAAA,uBAA2B,SAAA,UAAmB,IAAA,CAC7D,IAAA;EAGA,GAAA,EAAK,IAAA;AAAA;;;;UAMU,SAAA,uBAAgC,SAAA;EAC/C,KAAA,EAAO,MAAA,CAAK,SAAA;EACZ,WAAA,EAAa,MAAA,CAAK,IAAA;AAAA"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
export type {
|
|
1
|
+
export type {
|
|
2
|
+
App,
|
|
3
|
+
Page,
|
|
4
|
+
PageProps,
|
|
5
|
+
RouteData,
|
|
6
|
+
RouteHtml,
|
|
7
|
+
RouteNode,
|
|
8
|
+
RoutePath,
|
|
9
|
+
RouteRsc,
|
|
10
|
+
TocNode,
|
|
11
|
+
} from "./types.js";
|
|
2
12
|
export { Link } from "./Link.js";
|
|
3
13
|
export {
|
|
4
14
|
RouterProvider,
|
|
5
|
-
useRouter,
|
|
6
|
-
useLocation,
|
|
7
15
|
useCurrentRoute,
|
|
16
|
+
useLocation,
|
|
17
|
+
useRouter,
|
|
8
18
|
} from "./Router.js";
|