@typed/router 0.32.0 → 1.0.0-beta.1
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 +129 -2
- package/dist/AST.d.ts +96 -0
- package/dist/AST.d.ts.map +1 -0
- package/dist/AST.js +32 -0
- package/dist/CurrentRoute.d.ts +18 -0
- package/dist/CurrentRoute.d.ts.map +1 -0
- package/dist/CurrentRoute.js +18 -0
- package/dist/Matcher.d.ts +209 -0
- package/dist/Matcher.d.ts.map +1 -0
- package/dist/Matcher.js +633 -0
- package/dist/Parser.d.ts +92 -0
- package/dist/Parser.d.ts.map +1 -0
- package/dist/Parser.js +1 -0
- package/dist/Path.d.ts +216 -0
- package/dist/Path.d.ts.map +1 -0
- package/dist/Path.js +248 -0
- package/dist/Route.d.ts +57 -0
- package/dist/Route.d.ts.map +1 -0
- package/dist/Route.js +151 -0
- package/dist/Router.d.ts +9 -0
- package/dist/Router.d.ts.map +1 -0
- package/dist/Router.js +8 -0
- package/dist/Uri.d.ts +115 -0
- package/dist/Uri.d.ts.map +1 -0
- package/dist/Uri.js +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/package.json +32 -73
- package/src/AST.ts +166 -0
- package/src/CurrentRoute.ts +30 -331
- package/src/Matcher.test.ts +496 -0
- package/src/Matcher.ts +1375 -325
- package/src/Parser.ts +276 -0
- package/src/Path.test.ts +318 -0
- package/src/Path.ts +691 -0
- package/src/Route.test.ts +268 -0
- package/src/Route.ts +316 -0
- package/src/Router.ts +33 -0
- package/src/Uri.ts +214 -0
- package/src/index.ts +4 -28
- package/CurrentRoute/package.json +0 -6
- package/LICENSE +0 -21
- package/MatchInput/package.json +0 -6
- package/Matcher/package.json +0 -6
- package/RouteGuard/package.json +0 -6
- package/RouteMatch/package.json +0 -6
- package/dist/cjs/CurrentRoute.js +0 -170
- package/dist/cjs/CurrentRoute.js.map +0 -1
- package/dist/cjs/MatchInput.js +0 -96
- package/dist/cjs/MatchInput.js.map +0 -1
- package/dist/cjs/Matcher.js +0 -138
- package/dist/cjs/Matcher.js.map +0 -1
- package/dist/cjs/RouteGuard.js +0 -78
- package/dist/cjs/RouteGuard.js.map +0 -1
- package/dist/cjs/RouteMatch.js +0 -49
- package/dist/cjs/RouteMatch.js.map +0 -1
- package/dist/cjs/index.js +0 -53
- package/dist/cjs/index.js.map +0 -1
- package/dist/dts/CurrentRoute.d.ts +0 -94
- package/dist/dts/CurrentRoute.d.ts.map +0 -1
- package/dist/dts/MatchInput.d.ts +0 -143
- package/dist/dts/MatchInput.d.ts.map +0 -1
- package/dist/dts/Matcher.d.ts +0 -121
- package/dist/dts/Matcher.d.ts.map +0 -1
- package/dist/dts/RouteGuard.d.ts +0 -94
- package/dist/dts/RouteGuard.d.ts.map +0 -1
- package/dist/dts/RouteMatch.d.ts +0 -50
- package/dist/dts/RouteMatch.d.ts.map +0 -1
- package/dist/dts/index.d.ts +0 -24
- package/dist/dts/index.d.ts.map +0 -1
- package/dist/esm/CurrentRoute.js +0 -152
- package/dist/esm/CurrentRoute.js.map +0 -1
- package/dist/esm/MatchInput.js +0 -79
- package/dist/esm/MatchInput.js.map +0 -1
- package/dist/esm/Matcher.js +0 -130
- package/dist/esm/Matcher.js.map +0 -1
- package/dist/esm/RouteGuard.js +0 -57
- package/dist/esm/RouteGuard.js.map +0 -1
- package/dist/esm/RouteMatch.js +0 -29
- package/dist/esm/RouteMatch.js.map +0 -1
- package/dist/esm/index.js +0 -24
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/package.json +0 -4
- package/src/MatchInput.ts +0 -303
- package/src/RouteGuard.ts +0 -217
- package/src/RouteMatch.ts +0 -104
package/dist/Route.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type Pipeable } from "effect/Pipeable";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import type { Simplify } from "effect/Types";
|
|
4
|
+
import * as AST from "./AST.js";
|
|
5
|
+
import * as Path from "./Path.js";
|
|
6
|
+
export interface Route<P extends string, S extends Schema.Codec<any, Path.Params<P>, any, any> = Schema.Codec<Path.Params<P>>> extends Pipeable {
|
|
7
|
+
readonly ast: AST.RouteAst;
|
|
8
|
+
readonly path: P;
|
|
9
|
+
readonly paramsSchema: S;
|
|
10
|
+
readonly pathSchema: Schema.Codec<Path.PathParams<P>>;
|
|
11
|
+
readonly querySchema: Schema.Codec<Path.QueryParams<P>>;
|
|
12
|
+
}
|
|
13
|
+
export declare namespace Route {
|
|
14
|
+
type Any = Route<any, any>;
|
|
15
|
+
type Path<T> = T extends Route<infer P, any> ? P : never;
|
|
16
|
+
type Schema<T> = T extends Route<any, infer S> ? S : never;
|
|
17
|
+
type Type<T> = T extends Route<any, infer S> ? S["Type"] : never;
|
|
18
|
+
type Params<T> = T extends Route<infer P, infer _S> ? Path.Params<P> : never;
|
|
19
|
+
type DecodingServices<T> = T extends Route<any, infer S> ? S["DecodingServices"] : never;
|
|
20
|
+
type EncodingServices<T> = T extends Route<any, infer S> ? S["EncodingServices"] : never;
|
|
21
|
+
type PathType<T extends Any> = T["pathSchema"]["Type"];
|
|
22
|
+
type QueryType<T extends Any> = T["querySchema"]["Type"];
|
|
23
|
+
}
|
|
24
|
+
export declare function make<const P extends string, S extends Schema.Codec<any, Path.Params<P>, any, any> = Schema.Codec<Path.Params<P>>>(ast: AST.RouteAst): Route<P, S>;
|
|
25
|
+
export declare const Parse: <const P extends string>(path: P) => Route<Path.Join<Path.ParseAsts<P>>>;
|
|
26
|
+
export declare const Slash: Route<"/", Schema.Codec<{}, {}, never, never>>;
|
|
27
|
+
export declare const Wildcard: Route<"*", Schema.Codec<{
|
|
28
|
+
readonly "*": string;
|
|
29
|
+
}, {
|
|
30
|
+
readonly "*": string;
|
|
31
|
+
}, never, never>>;
|
|
32
|
+
export declare const Param: <const P extends string>(paramName: P) => Route<`/:${P}`>;
|
|
33
|
+
export declare const ParamWithSchema: <const P extends string, S extends Schema.Codec<any, string, any, any> = Schema.Codec<string>>(paramName: P, schema: S) => Route<`/:${P}`, Schema.Codec<{ readonly [K in P]: S["Type"]; }, Path.Params<`/:${P}`>, S["DecodingServices"], S["EncodingServices"]>>;
|
|
34
|
+
export declare const Number: <const P extends string>(paramName: P) => Route<`/:${P}`, Schema.Codec<{ readonly [K in P]: number; }, Path.Params<`/:${P}`>>>;
|
|
35
|
+
export declare const Int: <const P extends string>(paramName: P) => Route<`/:${P}`, Schema.Codec<{ readonly [K in P]: number; }, Path.Params<`/:${P}`>>>;
|
|
36
|
+
export type Join<Routes extends ReadonlyArray<Route<any, any>>> = [
|
|
37
|
+
Route<RouteJoinPath<Routes>, Schema.Codec<Simplify<UnionToIntersection<Routes[number]["paramsSchema"]["Type"]>>, Path.Params<RouteJoinPath<Routes>>, Routes[number]["paramsSchema"]["DecodingServices"], Routes[number]["paramsSchema"]["EncodingServices"]>>
|
|
38
|
+
] extends [Route<infer Path, infer Schema>] ? Route<Path, Schema> : never;
|
|
39
|
+
type AnyRoutes = ReadonlyArray<Route<any, any> | ReadonlyArray<Route<any, any>>>;
|
|
40
|
+
type FlattenRoutes<T extends AnyRoutes> = T extends readonly [
|
|
41
|
+
infer Head extends Route<any, any> | ReadonlyArray<Route<any, any>>,
|
|
42
|
+
...infer Tail extends AnyRoutes
|
|
43
|
+
] ? readonly [
|
|
44
|
+
...(Head extends ReadonlyArray<Route<any, any>> ? FlattenRoutes<Head> : [Head]),
|
|
45
|
+
...FlattenRoutes<Tail>
|
|
46
|
+
] : [];
|
|
47
|
+
export declare const Join: <const Routes extends AnyRoutes>(...routes: Routes) => Join<FlattenRoutes<Routes>>;
|
|
48
|
+
type UnionToIntersection<T> = (T extends any ? (x: T) => any : never) extends (x: infer R) => any ? R : never;
|
|
49
|
+
type RouteJoinPath<Routes extends ReadonlyArray<Route<any, any>>, R extends string = ""> = Routes extends readonly [
|
|
50
|
+
infer First extends Route<any, any>,
|
|
51
|
+
...infer Rest extends ReadonlyArray<Route<any, any>>
|
|
52
|
+
] ? RouteJoinPath<Rest, `${R}/${StripSlashes<First["path"]>}`> : R;
|
|
53
|
+
type StripSlashes<T extends string> = StripTrailingSlash<StripLeadingSlash<T>>;
|
|
54
|
+
type StripLeadingSlash<T extends string> = T extends `/${infer Rest}` ? StripLeadingSlash<Rest> : T;
|
|
55
|
+
type StripTrailingSlash<T extends string> = T extends `/${infer Rest}` ? StripTrailingSlash<Rest> : T;
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=Route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Route.d.ts","sourceRoot":"","sources":["../src/Route.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,QAAQ,EAAiB,MAAM,iBAAiB,CAAC;AAE/D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,MAAM,WAAW,KAAK,CACpB,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CACpF,SAAQ,QAAQ;IAChB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAEjB,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC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,CAAC;AACN,KAAK,YAAY,CAAC,CAAC,SAAS,MAAM,IAAI,kBAAkB,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/E,KAAK,iBAAiB,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,EAAE,GAAG,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACpG,KAAK,kBAAkB,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,EAAE,GAClE,kBAAkB,CAAC,IAAI,CAAC,GACxB,CAAC,CAAC"}
|
package/dist/Route.js
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/* eslint-disable no-restricted-syntax */
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import { pipeArguments } from "effect/Pipeable";
|
|
4
|
+
import { singleton } from "effect/Record";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
import * as Parser from "effect/SchemaParser";
|
|
7
|
+
import * as Transformation from "effect/SchemaTransformation";
|
|
8
|
+
import * as AST from "./AST.js";
|
|
9
|
+
import * as Path from "./Path.js";
|
|
10
|
+
export function make(ast) {
|
|
11
|
+
const getParts = once(() => getPathAst(ast));
|
|
12
|
+
const path = once(() => Path.join(getParts()));
|
|
13
|
+
const paramsSchema = once(() => getParamsSchema(ast));
|
|
14
|
+
const pathSchema = once(() => getPathSchema(ast));
|
|
15
|
+
const querySchema = once(() => getQuerySchema(ast));
|
|
16
|
+
return {
|
|
17
|
+
ast,
|
|
18
|
+
get path() {
|
|
19
|
+
return path();
|
|
20
|
+
},
|
|
21
|
+
get paramsSchema() {
|
|
22
|
+
return paramsSchema();
|
|
23
|
+
},
|
|
24
|
+
get pathSchema() {
|
|
25
|
+
return pathSchema();
|
|
26
|
+
},
|
|
27
|
+
get querySchema() {
|
|
28
|
+
return querySchema();
|
|
29
|
+
},
|
|
30
|
+
pipe() {
|
|
31
|
+
return pipeArguments(this, arguments);
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function once(fn) {
|
|
36
|
+
let memoized = [];
|
|
37
|
+
return () => {
|
|
38
|
+
if (memoized.length === 1) {
|
|
39
|
+
return memoized[0];
|
|
40
|
+
}
|
|
41
|
+
const result = fn();
|
|
42
|
+
memoized = [result];
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function getPathAst(ast) {
|
|
47
|
+
switch (ast.type) {
|
|
48
|
+
case "path":
|
|
49
|
+
return [ast.path];
|
|
50
|
+
case "transform":
|
|
51
|
+
return getPathAst(ast.from);
|
|
52
|
+
case "join": {
|
|
53
|
+
const result = [];
|
|
54
|
+
for (let i = 0; i < ast.parts.length; i++) {
|
|
55
|
+
if (i > 0) {
|
|
56
|
+
result.push(AST.slash());
|
|
57
|
+
}
|
|
58
|
+
result.push(...getPathAst(ast.parts[i]));
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function getParamsSchema(ast) {
|
|
65
|
+
switch (ast.type) {
|
|
66
|
+
case "path": {
|
|
67
|
+
const { paramsSchema } = Path.getSchemas(getPathAst(ast));
|
|
68
|
+
return paramsSchema;
|
|
69
|
+
}
|
|
70
|
+
case "transform": {
|
|
71
|
+
const { paramsSchema } = Path.getSchemas(getPathAst(ast.from));
|
|
72
|
+
return paramsSchema.pipe(Schema.decodeTo(ast.to, ast.transformation));
|
|
73
|
+
}
|
|
74
|
+
case "join": {
|
|
75
|
+
const parts = ast.parts.map((part) => Path.getSchemaFields(getPathAst(part)));
|
|
76
|
+
const requiredFields = [];
|
|
77
|
+
const optionalFields = [];
|
|
78
|
+
const queryParams = [];
|
|
79
|
+
for (const part of parts) {
|
|
80
|
+
requiredFields.push(...part.requiredFields);
|
|
81
|
+
optionalFields.push(...part.optionalFields);
|
|
82
|
+
queryParams.push(...part.queryParams);
|
|
83
|
+
}
|
|
84
|
+
const pathFields = Object.fromEntries(requiredFields);
|
|
85
|
+
const queryFields = Object.fromEntries(queryParams.map(([name, { optionalFields, requiredFields }]) => [
|
|
86
|
+
name,
|
|
87
|
+
Schema.StructWithRest(Schema.Struct(Object.fromEntries(requiredFields)), optionalFields.map(([key, value]) => Schema.Record(key, value))),
|
|
88
|
+
]));
|
|
89
|
+
const paramsSchema = Schema.StructWithRest(Schema.Struct({ ...pathFields, ...queryFields }), optionalFields.map(([key, value]) => Schema.Record(key, value)));
|
|
90
|
+
return paramsSchema;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function getPathSchema(ast) {
|
|
95
|
+
if (ast.type !== "join")
|
|
96
|
+
return Path.getSchemas(getPathAst(ast)).pathSchema;
|
|
97
|
+
const parts = ast.parts.map((part) => Path.getSchemaFields(getPathAst(part)));
|
|
98
|
+
const requiredFields = [];
|
|
99
|
+
const optionalFields = [];
|
|
100
|
+
for (const part of parts) {
|
|
101
|
+
requiredFields.push(...part.requiredFields);
|
|
102
|
+
optionalFields.push(...part.optionalFields);
|
|
103
|
+
}
|
|
104
|
+
const pathFields = Object.fromEntries(requiredFields);
|
|
105
|
+
return Schema.StructWithRest(Schema.Struct(pathFields), optionalFields.map(([key, value]) => Schema.Record(key, value)));
|
|
106
|
+
}
|
|
107
|
+
function getQuerySchema(ast) {
|
|
108
|
+
if (ast.type !== "join")
|
|
109
|
+
return Path.getSchemas(getPathAst(ast)).querySchema;
|
|
110
|
+
const parts = ast.parts.map((part) => Path.getSchemaFields(getPathAst(part)));
|
|
111
|
+
const queryParams = [];
|
|
112
|
+
for (const part of parts) {
|
|
113
|
+
queryParams.push(...part.queryParams);
|
|
114
|
+
}
|
|
115
|
+
const queryFields = Object.fromEntries(queryParams.map(([name, { optionalFields, requiredFields }]) => [
|
|
116
|
+
name,
|
|
117
|
+
Schema.StructWithRest(Schema.Struct(Object.fromEntries(requiredFields)), optionalFields.map(([key, value]) => Schema.Record(key, value))),
|
|
118
|
+
]));
|
|
119
|
+
return Schema.Struct(queryFields);
|
|
120
|
+
}
|
|
121
|
+
export const Parse = (path) => {
|
|
122
|
+
const asts = Path.parse(path);
|
|
123
|
+
if (asts.length === 0)
|
|
124
|
+
return Slash;
|
|
125
|
+
if (asts.length === 1)
|
|
126
|
+
return make(AST.path(asts[0]));
|
|
127
|
+
return Join(...asts.map((ast) => make(AST.path(ast))));
|
|
128
|
+
};
|
|
129
|
+
export const Slash = make(AST.path(AST.literal("")));
|
|
130
|
+
export const Wildcard = make(AST.path(AST.wildcard()));
|
|
131
|
+
export const Param = (paramName) => make(AST.path(AST.parameter(paramName)));
|
|
132
|
+
export const ParamWithSchema = (paramName, schema) => {
|
|
133
|
+
const decode = Parser.decodeEffect(schema);
|
|
134
|
+
const encode = Parser.encodeEffect(schema);
|
|
135
|
+
return make(AST.transform(AST.path(AST.parameter(paramName)), Schema.Struct(singleton(paramName, schema.Type)), Transformation.transformOrFail({
|
|
136
|
+
decode: (input) => Effect.map(decode(input[paramName]), (decoded) => singleton(paramName, decoded)),
|
|
137
|
+
encode: (output) => Effect.map(encode(output[paramName]), (encoded) => singleton(paramName, encoded)),
|
|
138
|
+
})));
|
|
139
|
+
};
|
|
140
|
+
export const Number = (paramName) => ParamWithSchema(paramName, Schema.NumberFromString);
|
|
141
|
+
export const Int = (paramName) => ParamWithSchema(paramName, Schema.NumberFromString.pipe(Schema.decodeTo(Schema.Int)));
|
|
142
|
+
const removeSlash = (ast) => {
|
|
143
|
+
if (ast.type === "path" && ast.path.type === "slash")
|
|
144
|
+
return [];
|
|
145
|
+
return [ast];
|
|
146
|
+
};
|
|
147
|
+
export const Join = (...routes) => make(AST.join(routes.flatMap((route) => {
|
|
148
|
+
if (Array.isArray(route))
|
|
149
|
+
return route.flatMap(removeSlash);
|
|
150
|
+
return removeSlash(route.ast);
|
|
151
|
+
})));
|
package/dist/Router.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as Layer from "effect/Layer";
|
|
2
|
+
import { type InitialMemoryOptions, type MemoryOptions } from "@typed/navigation/memory";
|
|
3
|
+
import type { Navigation } from "@typed/navigation/Navigation";
|
|
4
|
+
import { CurrentRoute } from "./CurrentRoute.js";
|
|
5
|
+
export type Router = CurrentRoute | Navigation;
|
|
6
|
+
export declare const BrowserRouter: (window?: Window) => Layer.Layer<Router>;
|
|
7
|
+
export declare const ServerRouter: (options: MemoryOptions | InitialMemoryOptions) => Layer.Layer<Router>;
|
|
8
|
+
export declare const TestRouter: (options: (MemoryOptions | InitialMemoryOptions) & {}) => Layer.Layer<Router>;
|
|
9
|
+
//# sourceMappingURL=Router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../src/Router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,EAEL,KAAK,oBAAoB,EAEzB,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,MAAM,MAAM,MAAM,GAAG,YAAY,GAAG,UAAU,CAAC;AAE/C,eAAO,MAAM,aAAa,GAAI,SAAS,MAAM,KAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAI/D,CAAC;AAEJ,eAAO,MAAM,YAAY,GAAI,SAAS,aAAa,GAAG,oBAAoB,KAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAI5F,CAAC;AAEJ,eAAO,MAAM,UAAU,GACrB,SAAS,CAAC,aAAa,GAAG,oBAAoB,CAAC,GAAG,EAAE,KACnD,KAAK,CAAC,KAAK,CAAC,MAAM,CAIlB,CAAC"}
|
package/dist/Router.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as Layer from "effect/Layer";
|
|
2
|
+
import { fromWindow } from "@typed/navigation/fromWindow";
|
|
3
|
+
import { initialMemory, memory, } from "@typed/navigation/memory";
|
|
4
|
+
import { CurrentRoute } from "./CurrentRoute.js";
|
|
5
|
+
import { Ids } from "@typed/id";
|
|
6
|
+
export const BrowserRouter = (window) => CurrentRoute.Default.pipe(Layer.provideMerge(fromWindow(window)), Layer.provideMerge(Ids.Default));
|
|
7
|
+
export const ServerRouter = (options) => CurrentRoute.Default.pipe(Layer.provideMerge("url" in options ? initialMemory(options) : memory(options)), Layer.provideMerge(Ids.Default));
|
|
8
|
+
export const TestRouter = (options) => CurrentRoute.Default.pipe(Layer.provideMerge("url" in options ? initialMemory(options) : memory(options)), Layer.provideMerge(Ids.Test()));
|
package/dist/Uri.d.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { Arg0, Call1W, Identity, Pipe, TypeLambda, TypeLambda1 } from "hkt-core";
|
|
2
|
+
/**
|
|
3
|
+
* @since 1.0.0
|
|
4
|
+
*/
|
|
5
|
+
export type ParseUri<Input extends string, BaseUri extends string = never> = Pipe<Input, ParseUriLambda, [
|
|
6
|
+
BaseUri
|
|
7
|
+
] extends [never] ? Identity : ApplyBaseUriLambda<ParseUri<BaseUri>>> extends infer R ? Uri<GetUriKey<R, "protocol">, GetUriKey<R, "username">, GetUriKey<R, "password">, GetUriKey<R, "hostname">, GetUriKey<R, "port">, GetUriKey<R, "pathname">, GetUriKey<R, "query">, GetUriKey<R, "hash">> : never;
|
|
8
|
+
/**
|
|
9
|
+
* @since 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
export interface Uri<Protocol extends string = string, Username extends string = "", Password extends string = "", Hostname extends string = string, Port extends number | "" = "", Pathname extends string = "/", Query extends string = "", Hash extends string = ""> {
|
|
12
|
+
readonly protocol: Protocol;
|
|
13
|
+
readonly username: Username;
|
|
14
|
+
readonly password: Password;
|
|
15
|
+
readonly hostname: Hostname;
|
|
16
|
+
readonly port: Port;
|
|
17
|
+
readonly pathname: Pathname;
|
|
18
|
+
readonly query: Query;
|
|
19
|
+
readonly hash: Hash;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @since 1.0.0
|
|
23
|
+
*/
|
|
24
|
+
export declare namespace Uri {
|
|
25
|
+
type Any = Uri<string, string, string, string, number | "", string, string, string>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @since 1.0.0
|
|
29
|
+
*/
|
|
30
|
+
export type FormatUri<Uri extends Uri.Any, BaseUri extends string = never> = Call1W<FormatUrlLambda, [
|
|
31
|
+
BaseUri
|
|
32
|
+
] extends [never] ? Uri : Call1W<ApplyBaseUriLambda<ParseUri<BaseUri>>, Uri>>;
|
|
33
|
+
interface FormatUrlLambda extends TypeLambda1 {
|
|
34
|
+
readonly return: Arg0<this> extends infer Uri extends Uri.Any ? StringJoin<[
|
|
35
|
+
FormatProtocol<Uri["protocol"]>,
|
|
36
|
+
FormatAuthentication<Uri["username"], Uri["password"]>,
|
|
37
|
+
FormatHostname<Uri["hostname"]>,
|
|
38
|
+
FormatPort<Uri["port"]>,
|
|
39
|
+
FormatPathname<Uri["pathname"]>,
|
|
40
|
+
FormatQuery<Uri["query"]>,
|
|
41
|
+
FormatHash<Uri["hash"]>
|
|
42
|
+
]> : never;
|
|
43
|
+
}
|
|
44
|
+
type IfNotEmpty<T, Then> = IsEmpty<T> extends 1 ? "" : Then;
|
|
45
|
+
type FormatProtocol<Protocol extends string> = IfNotEmpty<Protocol, EnsureEndsWithDoubleSlash<EnsureEndsWithColon<Protocol>>>;
|
|
46
|
+
type EnsureEndsWithColon<T extends string> = `${T extends `${infer Rest}:` ? Rest : T}:`;
|
|
47
|
+
type EnsureEndsWithDoubleSlash<T extends string> = T extends `${infer Rest}//` ? Rest : T extends `${infer Rest}/` ? `${Rest}//` : `${T}//`;
|
|
48
|
+
type FormatAuthentication<Username extends string, Password extends string> = {
|
|
49
|
+
0: `${Username}:${Password}@`;
|
|
50
|
+
1: "";
|
|
51
|
+
}[IsEmpty<Username> & IsEmpty<Password>];
|
|
52
|
+
type FormatHostname<Hostname extends string> = IfNotEmpty<Hostname, Hostname>;
|
|
53
|
+
type FormatPort<Port extends number | ""> = IfNotEmpty<Port, EnsureStartsWithColon<`${Port}`>>;
|
|
54
|
+
type EnsureStartsWithColon<T extends string> = T extends `:${infer _}` ? T : `:${T}`;
|
|
55
|
+
type FormatPathname<Pathname extends string> = IfNotEmpty<Pathname, EnsureStartsWithSlash<`${Pathname}`>>;
|
|
56
|
+
type EnsureStartsWithSlash<T extends string> = T extends `/${infer _}` ? T : `/${T}`;
|
|
57
|
+
type FormatQuery<Query extends string> = IfNotEmpty<Query, EnsureStartsWithQuestionMark<`${Query}`>>;
|
|
58
|
+
type EnsureStartsWithQuestionMark<T extends string> = T extends `?${infer _}` ? T : `?${T}`;
|
|
59
|
+
type FormatHash<Hash extends string> = IfNotEmpty<Hash, EnsureStartsWithHash<`${Hash}`>>;
|
|
60
|
+
type EnsureStartsWithHash<T extends string> = T extends `#${infer _}` ? T : `#${T}`;
|
|
61
|
+
type IsEmpty<T> = [T] extends [""] ? 1 : [T] extends [never] ? 1 : 0;
|
|
62
|
+
type GetUriKey<UriLike, Key extends keyof Uri> = Key extends keyof UriLike ? UriLike[Key] extends Uri.Any[Key] ? UriLike[Key] : Uri[Key] : Uri[Key];
|
|
63
|
+
interface ParseUriLambda extends TypeLambda<[uri: string], Uri> {
|
|
64
|
+
return: Arg0<this> extends infer R ? Pipe<[
|
|
65
|
+
{},
|
|
66
|
+
R
|
|
67
|
+
], UriParserReducerLambda<ParseHashLambda>, UriParserReducerLambda<ParseQueryLambda>, UriParserReducerLambda<ParseProtocolLambda>, UriParserReducerLambda<ParseAuthenticationLambda>, UriParserReducerLambda<ParsePathnamePortPathnameLambda>> extends readonly [infer Result, infer Remaining extends string] ? Remaining extends "" ? Result : `Failed to parse URI: ${Arg0<this>}` : never : never;
|
|
68
|
+
}
|
|
69
|
+
interface UriParserReducerLambda<F extends TypeLambda> extends TypeLambda {
|
|
70
|
+
return: Arg0<this> extends readonly [infer State, infer Input extends string] ? Pipe<Input, F> extends readonly [infer NextState, infer Remaining extends string] ? [NextState & State, Remaining] : never : never;
|
|
71
|
+
}
|
|
72
|
+
interface ParseProtocolLambda extends TypeLambda {
|
|
73
|
+
readonly return: Arg0<this> extends `${infer Protocol}//${infer Rest}` ? [{
|
|
74
|
+
readonly protocol: Protocol;
|
|
75
|
+
}, Rest] : [unknown, Arg0<this>];
|
|
76
|
+
}
|
|
77
|
+
interface ParseHashLambda extends TypeLambda {
|
|
78
|
+
readonly return: Arg0<this> extends `${infer Rest}#${infer Hash}` ? [{
|
|
79
|
+
readonly hash: Hash;
|
|
80
|
+
}, Rest] : [unknown, Arg0<this>];
|
|
81
|
+
}
|
|
82
|
+
interface ParseQueryLambda extends TypeLambda {
|
|
83
|
+
readonly return: Arg0<this> extends `${infer Rest}?${infer Query}` ? [{
|
|
84
|
+
readonly query: Query;
|
|
85
|
+
}, Rest] : [unknown, Arg0<this>];
|
|
86
|
+
}
|
|
87
|
+
interface ParseAuthenticationLambda extends TypeLambda {
|
|
88
|
+
readonly return: Arg0<this> extends `${infer Username}:${infer Password}@${infer Rest}` ? [{
|
|
89
|
+
readonly username: Username;
|
|
90
|
+
readonly password: Password;
|
|
91
|
+
}, Rest] : [unknown, Arg0<this>];
|
|
92
|
+
}
|
|
93
|
+
interface ParsePathnamePortPathnameLambda extends TypeLambda {
|
|
94
|
+
readonly return: Arg0<this> extends `${infer Hostname}:${infer Port extends number}/${infer Pathname}` ? [{
|
|
95
|
+
readonly hostname: Hostname;
|
|
96
|
+
readonly port: Port;
|
|
97
|
+
readonly pathname: Pathname;
|
|
98
|
+
}, ""] : Arg0<this> extends `${infer Hostname}:${infer Port extends number}` ? [{
|
|
99
|
+
readonly hostname: Hostname;
|
|
100
|
+
readonly port: Port;
|
|
101
|
+
}, ""] : Arg0<this> extends `${infer Hostname}/${infer Pathname}` ? "" extends Hostname ? [{
|
|
102
|
+
readonly pathname: Pathname;
|
|
103
|
+
}, ""] : [{
|
|
104
|
+
readonly hostname: Hostname;
|
|
105
|
+
readonly pathname: Pathname;
|
|
106
|
+
}, ""] : Arg0<this> extends `${infer Hostname}` ? [{
|
|
107
|
+
readonly hostname: Hostname;
|
|
108
|
+
}, ""] : [unknown, Arg0<this>];
|
|
109
|
+
}
|
|
110
|
+
interface ApplyBaseUriLambda<BaseUri extends Uri.Any> extends TypeLambda1<Uri.Any, Uri.Any> {
|
|
111
|
+
readonly return: Arg0<this> extends infer R extends Uri.Any ? Uri<GetUriKey<BaseUri, "protocol">, GetUriKey<BaseUri, "username">, GetUriKey<BaseUri, "password">, GetUriKey<BaseUri, "hostname">, GetUriKey<BaseUri, "port">, GetUriKey<R, "pathname">, GetUriKey<R, "query">, GetUriKey<R, "hash">> : never;
|
|
112
|
+
}
|
|
113
|
+
type StringJoin<Input extends ReadonlyArray<string>, R extends string = ""> = Input extends readonly [infer A extends string, ...infer Rest extends ReadonlyArray<string>] ? StringJoin<Rest, `${R}${A}`> : R;
|
|
114
|
+
export {};
|
|
115
|
+
//# sourceMappingURL=Uri.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Uri.d.ts","sourceRoot":"","sources":["../src/Uri.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEtF;;GAEG;AACH,MAAM,MAAM,QAAQ,CAAC,KAAK,SAAS,MAAM,EAAE,OAAO,SAAS,MAAM,GAAG,KAAK,IACvE,IAAI,CACF,KAAK,EACL,cAAc,EACd;IAAC,OAAO;CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,QAAQ,GAAG,kBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAC7E,SAAS,MAAM,CAAC,GACb,GAAG,CACD,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,EACx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dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
package/dist/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,80 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typed/router",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "https://github.com/tylors/typed.git"
|
|
9
|
-
},
|
|
10
|
-
"sideEffects": [],
|
|
11
|
-
"author": "Typed contributors",
|
|
12
|
-
"homepage": "https://github.com/tylors/typed",
|
|
13
|
-
"dependencies": {
|
|
14
|
-
"@effect/schema": "^0.74.1",
|
|
15
|
-
"effect": "^3.8.4",
|
|
16
|
-
"@typed/context": "0.30.0",
|
|
17
|
-
"@typed/dom": "18.0.0",
|
|
18
|
-
"@typed/environment": "0.11.0",
|
|
19
|
-
"@typed/fx": "1.32.0",
|
|
20
|
-
"@typed/guard": "0.6.0",
|
|
21
|
-
"@typed/navigation": "0.18.0",
|
|
22
|
-
"@typed/path": "0.15.0",
|
|
23
|
-
"@typed/route": "9.0.0"
|
|
24
|
-
},
|
|
25
|
-
"main": "./dist/cjs/index.js",
|
|
26
|
-
"module": "./dist/esm/index.js",
|
|
27
|
-
"types": "./dist/dts/index.d.ts",
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
|
+
"type": "module",
|
|
28
5
|
"exports": {
|
|
29
|
-
"./package.json": "./package.json",
|
|
30
6
|
".": {
|
|
31
|
-
"types": "./dist/
|
|
32
|
-
"import": "./dist/
|
|
33
|
-
"default": "./dist/cjs/index.js"
|
|
34
|
-
},
|
|
35
|
-
"./CurrentRoute": {
|
|
36
|
-
"types": "./dist/dts/CurrentRoute.d.ts",
|
|
37
|
-
"import": "./dist/esm/CurrentRoute.js",
|
|
38
|
-
"default": "./dist/cjs/CurrentRoute.js"
|
|
39
|
-
},
|
|
40
|
-
"./MatchInput": {
|
|
41
|
-
"types": "./dist/dts/MatchInput.d.ts",
|
|
42
|
-
"import": "./dist/esm/MatchInput.js",
|
|
43
|
-
"default": "./dist/cjs/MatchInput.js"
|
|
44
|
-
},
|
|
45
|
-
"./Matcher": {
|
|
46
|
-
"types": "./dist/dts/Matcher.d.ts",
|
|
47
|
-
"import": "./dist/esm/Matcher.js",
|
|
48
|
-
"default": "./dist/cjs/Matcher.js"
|
|
49
|
-
},
|
|
50
|
-
"./RouteGuard": {
|
|
51
|
-
"types": "./dist/dts/RouteGuard.d.ts",
|
|
52
|
-
"import": "./dist/esm/RouteGuard.js",
|
|
53
|
-
"default": "./dist/cjs/RouteGuard.js"
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"import": "./dist/index.js"
|
|
54
9
|
},
|
|
55
|
-
"
|
|
56
|
-
"types": "./dist
|
|
57
|
-
"import": "./dist
|
|
58
|
-
"default": "./dist/cjs/RouteMatch.js"
|
|
10
|
+
"./*": {
|
|
11
|
+
"types": "./dist/*.d.ts",
|
|
12
|
+
"import": "./dist/*.js"
|
|
59
13
|
}
|
|
60
14
|
},
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "[ -d dist ] || rm -f tsconfig.tsbuildinfo; tsc",
|
|
20
|
+
"test": "vitest run --passWithNoTests"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@typed/fx": "workspace:*",
|
|
24
|
+
"@typed/guard": "workspace:*",
|
|
25
|
+
"@typed/id": "workspace:*",
|
|
26
|
+
"@typed/navigation": "workspace:*",
|
|
27
|
+
"effect": "catalog:",
|
|
28
|
+
"find-my-way-ts": "0.1.6",
|
|
29
|
+
"hkt-core": "1.3.4"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"typescript": "catalog:",
|
|
33
|
+
"vitest": "catalog:"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"src"
|
|
38
|
+
]
|
|
39
|
+
}
|