neouter 0.1.0 → 0.1.2

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 ADDED
@@ -0,0 +1,55 @@
1
+ # neouter
2
+
3
+ neouter($/njuːtər/$, ニョーター) is type-safe router for minimalists! (になる予定)
4
+
5
+ **This project is still under development and may be unstable. PLEASE DO NOT USE IT IN PRODUCTION ENVIRONMENTS!!**
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm i neouter
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ### Defining Routes
16
+
17
+ ```tsx
18
+ import { useCreateRoutes } from "neouter";
19
+
20
+ const routes = {
21
+ "/": {
22
+ component: () => <div>Hello!</div>,
23
+ },
24
+ "/about": {
25
+ component: () => <div>About</div>,
26
+ },
27
+ };
28
+
29
+ export const App = () => {
30
+ const { Router } = useCreateRoutes({ routes });
31
+ return <Router />;
32
+ };
33
+ ```
34
+
35
+ ### Link
36
+
37
+ ```tsx
38
+ import { Link } from "neouter";
39
+
40
+ export const Page = () => {
41
+ return (
42
+ <div>
43
+ <p>
44
+ neouter is a routing library for people who are obsessed with
45
+ simplicity😄
46
+ </p>
47
+ <Link href="/learn">Learn more</Link>
48
+ </div>
49
+ );
50
+ };
51
+ ```
52
+
53
+ ## Contributing
54
+
55
+ See [CONTRIBUTING.md](./CONTRIBUTING.md)
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ComponentProps, ComponentType } from "react";
2
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
2
3
 
3
4
  //#region src/types.d.ts
4
5
  type Path$1 = string;
@@ -29,7 +30,7 @@ declare const BaseLink: ({
29
30
  ...props
30
31
  }: ComponentProps<"a"> & {
31
32
  href: Path$1;
32
- }) => any;
33
+ }) => react_jsx_runtime0.JSX.Element;
33
34
  //#endregion
34
35
  //#region src/hooks/useCreateRoutes.d.ts
35
36
  declare const useCreateRoutes: ({
@@ -38,7 +39,15 @@ declare const useCreateRoutes: ({
38
39
  }: {
39
40
  routes: Routes;
40
41
  notFoundComponent?: React.ComponentType;
41
- }) => any;
42
+ }) => {
43
+ paths: string[];
44
+ RouterProvider: ({
45
+ children
46
+ }: {
47
+ children: React.ReactNode;
48
+ }) => react_jsx_runtime0.JSX.Element;
49
+ Router: () => react_jsx_runtime0.JSX.Element;
50
+ };
42
51
  //#endregion
43
52
  //#region src/hooks/usePathParams.d.ts
44
53
  declare const usePathParams: <Path extends string>() => ParamsObject<Path> | null;
@@ -47,10 +56,10 @@ declare const usePathParams: <Path extends string>() => ParamsObject<Path> | nul
47
56
  type Options = {
48
57
  noThrowError?: boolean;
49
58
  };
50
- declare const useQueryParams: <T extends Record<string, QueryParamsValueType>>(expectedTypes: T, options?: Options) => any;
59
+ declare const useQueryParams: <T extends Record<string, QueryParamsValueType>>(expectedTypes: T, options?: Options) => Partial<{ [K in keyof T]: T[K] extends "number" ? number : string }>;
51
60
  //#endregion
52
61
  //#region src/hooks/useRouter.d.ts
53
- declare const useRouter: () => readonly [any, any];
62
+ declare const useRouter: () => readonly [string, (path: string) => void];
54
63
  //#endregion
55
64
  //#region src/libs/extractParams.d.ts
56
65
  declare const extractParams: <Path extends string, Params extends string = ExtractParams<Path>>(pathPattern: Path, actualPath: string) => Record<Params, string>;
@@ -62,6 +71,6 @@ declare const getMatchedPath: (routes: Routes, path: string) => Path$1 | null;
62
71
  declare function lazyImport<U extends string, T$1 extends { [P in U]: ComponentType }>(factory: () => Promise<T$1>, name: U): T$1;
63
72
  //#endregion
64
73
  //#region src/libs/redirect.d.ts
65
- declare const redirect: <T extends Path$1>(path: T) => () => any;
74
+ declare const redirect: <T extends Path$1>(path: T) => () => react_jsx_runtime0.JSX.Element;
66
75
  //#endregion
67
76
  export { type AssertPathType, BaseLink, type ExtractParams, type ParamsObject, type Path$1 as Path, type QueryParamsValueType, type Routes, type WithQueryAndHash, extractParams, getMatchedPath, lazyImport, redirect, useCreateRoutes, usePathParams, useQueryParams, useRouter };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neouter",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "author": "avaice <avaice@ymail.ne.jp>",
5
5
  "license": "ISC",
6
6
  "description": "A type-safe router for minimalists",