@typed/router 0.31.0 → 1.0.0-beta.0

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.
Files changed (88) hide show
  1. package/README.md +111 -2
  2. package/dist/AST.d.ts +96 -0
  3. package/dist/AST.d.ts.map +1 -0
  4. package/dist/AST.js +32 -0
  5. package/dist/CurrentRoute.d.ts +18 -0
  6. package/dist/CurrentRoute.d.ts.map +1 -0
  7. package/dist/CurrentRoute.js +18 -0
  8. package/dist/Matcher.d.ts +191 -0
  9. package/dist/Matcher.d.ts.map +1 -0
  10. package/dist/Matcher.js +597 -0
  11. package/dist/Parser.d.ts +96 -0
  12. package/dist/Parser.d.ts.map +1 -0
  13. package/dist/Parser.js +1 -0
  14. package/dist/Path.d.ts +216 -0
  15. package/dist/Path.d.ts.map +1 -0
  16. package/dist/Path.js +248 -0
  17. package/dist/Route.d.ts +57 -0
  18. package/dist/Route.d.ts.map +1 -0
  19. package/dist/Route.js +151 -0
  20. package/dist/Router.d.ts +9 -0
  21. package/dist/Router.d.ts.map +1 -0
  22. package/dist/Router.js +8 -0
  23. package/dist/Uri.d.ts +115 -0
  24. package/dist/Uri.d.ts.map +1 -0
  25. package/dist/Uri.js +1 -0
  26. package/dist/index.d.ts +5 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +4 -0
  29. package/package.json +25 -69
  30. package/src/AST.ts +166 -0
  31. package/src/CurrentRoute.ts +30 -331
  32. package/src/Matcher.test.ts +476 -0
  33. package/src/Matcher.ts +1269 -328
  34. package/src/Parser.ts +282 -0
  35. package/src/Path.test.ts +318 -0
  36. package/src/Path.ts +691 -0
  37. package/src/Route.test.ts +268 -0
  38. package/src/Route.ts +316 -0
  39. package/src/Router.ts +31 -0
  40. package/src/Uri.ts +214 -0
  41. package/src/index.ts +4 -28
  42. package/tsconfig.json +6 -0
  43. package/CurrentRoute/package.json +0 -6
  44. package/LICENSE +0 -21
  45. package/MatchInput/package.json +0 -6
  46. package/Matcher/package.json +0 -6
  47. package/RouteGuard/package.json +0 -6
  48. package/RouteMatch/package.json +0 -6
  49. package/dist/cjs/CurrentRoute.js +0 -170
  50. package/dist/cjs/CurrentRoute.js.map +0 -1
  51. package/dist/cjs/MatchInput.js +0 -96
  52. package/dist/cjs/MatchInput.js.map +0 -1
  53. package/dist/cjs/Matcher.js +0 -138
  54. package/dist/cjs/Matcher.js.map +0 -1
  55. package/dist/cjs/RouteGuard.js +0 -78
  56. package/dist/cjs/RouteGuard.js.map +0 -1
  57. package/dist/cjs/RouteMatch.js +0 -49
  58. package/dist/cjs/RouteMatch.js.map +0 -1
  59. package/dist/cjs/index.js +0 -53
  60. package/dist/cjs/index.js.map +0 -1
  61. package/dist/dts/CurrentRoute.d.ts +0 -94
  62. package/dist/dts/CurrentRoute.d.ts.map +0 -1
  63. package/dist/dts/MatchInput.d.ts +0 -135
  64. package/dist/dts/MatchInput.d.ts.map +0 -1
  65. package/dist/dts/Matcher.d.ts +0 -121
  66. package/dist/dts/Matcher.d.ts.map +0 -1
  67. package/dist/dts/RouteGuard.d.ts +0 -94
  68. package/dist/dts/RouteGuard.d.ts.map +0 -1
  69. package/dist/dts/RouteMatch.d.ts +0 -50
  70. package/dist/dts/RouteMatch.d.ts.map +0 -1
  71. package/dist/dts/index.d.ts +0 -24
  72. package/dist/dts/index.d.ts.map +0 -1
  73. package/dist/esm/CurrentRoute.js +0 -152
  74. package/dist/esm/CurrentRoute.js.map +0 -1
  75. package/dist/esm/MatchInput.js +0 -79
  76. package/dist/esm/MatchInput.js.map +0 -1
  77. package/dist/esm/Matcher.js +0 -130
  78. package/dist/esm/Matcher.js.map +0 -1
  79. package/dist/esm/RouteGuard.js +0 -57
  80. package/dist/esm/RouteGuard.js.map +0 -1
  81. package/dist/esm/RouteMatch.js +0 -29
  82. package/dist/esm/RouteMatch.js.map +0 -1
  83. package/dist/esm/index.js +0 -24
  84. package/dist/esm/index.js.map +0 -1
  85. package/dist/esm/package.json +0 -4
  86. package/src/MatchInput.ts +0 -282
  87. package/src/RouteGuard.ts +0 -217
  88. package/src/RouteMatch.ts +0 -104
package/src/Uri.ts ADDED
@@ -0,0 +1,214 @@
1
+ import type { Arg0, Call1W, Identity, Pipe, TypeLambda, TypeLambda1 } from "hkt-core";
2
+
3
+ /**
4
+ * @since 1.0.0
5
+ */
6
+ export type ParseUri<Input extends string, BaseUri extends string = never> =
7
+ Pipe<
8
+ Input,
9
+ ParseUriLambda,
10
+ [BaseUri] extends [never] ? Identity : ApplyBaseUriLambda<ParseUri<BaseUri>>
11
+ > extends infer R
12
+ ? Uri<
13
+ GetUriKey<R, "protocol">,
14
+ GetUriKey<R, "username">,
15
+ GetUriKey<R, "password">,
16
+ GetUriKey<R, "hostname">,
17
+ GetUriKey<R, "port">,
18
+ GetUriKey<R, "pathname">,
19
+ GetUriKey<R, "query">,
20
+ GetUriKey<R, "hash">
21
+ >
22
+ : never;
23
+
24
+ /**
25
+ * @since 1.0.0
26
+ */
27
+ export interface Uri<
28
+ Protocol extends string = string,
29
+ Username extends string = "",
30
+ Password extends string = "",
31
+ Hostname extends string = string,
32
+ Port extends number | "" = "",
33
+ Pathname extends string = "/",
34
+ Query extends string = "",
35
+ Hash extends string = "",
36
+ > {
37
+ readonly protocol: Protocol;
38
+ readonly username: Username;
39
+ readonly password: Password;
40
+ readonly hostname: Hostname;
41
+ readonly port: Port;
42
+ readonly pathname: Pathname;
43
+ readonly query: Query;
44
+ readonly hash: Hash;
45
+ }
46
+
47
+ /**
48
+ * @since 1.0.0
49
+ */
50
+ export declare namespace Uri {
51
+ export type Any = Uri<string, string, string, string, number | "", string, string, string>;
52
+ }
53
+
54
+ /**
55
+ * @since 1.0.0
56
+ */
57
+ export type FormatUri<Uri extends Uri.Any, BaseUri extends string = never> = Call1W<
58
+ FormatUrlLambda,
59
+ [BaseUri] extends [never] ? Uri : Call1W<ApplyBaseUriLambda<ParseUri<BaseUri>>, Uri>
60
+ >;
61
+
62
+ // Internal
63
+
64
+ interface FormatUrlLambda extends TypeLambda1 {
65
+ readonly return: Arg0<this> extends infer Uri extends Uri.Any
66
+ ? StringJoin<
67
+ [
68
+ FormatProtocol<Uri["protocol"]>,
69
+ FormatAuthentication<Uri["username"], Uri["password"]>,
70
+ FormatHostname<Uri["hostname"]>,
71
+ FormatPort<Uri["port"]>,
72
+ FormatPathname<Uri["pathname"]>,
73
+ FormatQuery<Uri["query"]>,
74
+ FormatHash<Uri["hash"]>,
75
+ ]
76
+ >
77
+ : never;
78
+ }
79
+
80
+ type IfNotEmpty<T, Then> = IsEmpty<T> extends 1 ? "" : Then;
81
+
82
+ type FormatProtocol<Protocol extends string> = IfNotEmpty<
83
+ Protocol,
84
+ EnsureEndsWithDoubleSlash<EnsureEndsWithColon<Protocol>>
85
+ >;
86
+
87
+ type EnsureEndsWithColon<T extends string> = `${T extends `${infer Rest}:` ? Rest : T}:`;
88
+ type EnsureEndsWithDoubleSlash<T extends string> = T extends `${infer Rest}//`
89
+ ? Rest
90
+ : T extends `${infer Rest}/`
91
+ ? `${Rest}//`
92
+ : `${T}//`;
93
+
94
+ type FormatAuthentication<Username extends string, Password extends string> = {
95
+ 0: `${Username}:${Password}@`;
96
+ 1: "";
97
+ }[IsEmpty<Username> & IsEmpty<Password>];
98
+
99
+ type FormatHostname<Hostname extends string> = IfNotEmpty<Hostname, Hostname>;
100
+
101
+ type FormatPort<Port extends number | ""> = IfNotEmpty<Port, EnsureStartsWithColon<`${Port}`>>;
102
+
103
+ type EnsureStartsWithColon<T extends string> = T extends `:${infer _}` ? T : `:${T}`;
104
+
105
+ type FormatPathname<Pathname extends string> = IfNotEmpty<
106
+ Pathname,
107
+ EnsureStartsWithSlash<`${Pathname}`>
108
+ >;
109
+
110
+ type EnsureStartsWithSlash<T extends string> = T extends `/${infer _}` ? T : `/${T}`;
111
+
112
+ type FormatQuery<Query extends string> = IfNotEmpty<
113
+ Query,
114
+ EnsureStartsWithQuestionMark<`${Query}`>
115
+ >;
116
+
117
+ type EnsureStartsWithQuestionMark<T extends string> = T extends `?${infer _}` ? T : `?${T}`;
118
+
119
+ type FormatHash<Hash extends string> = IfNotEmpty<Hash, EnsureStartsWithHash<`${Hash}`>>;
120
+
121
+ type EnsureStartsWithHash<T extends string> = T extends `#${infer _}` ? T : `#${T}`;
122
+
123
+ type IsEmpty<T> = [T] extends [""] ? 1 : [T] extends [never] ? 1 : 0;
124
+
125
+ type GetUriKey<UriLike, Key extends keyof Uri> = Key extends keyof UriLike
126
+ ? UriLike[Key] extends Uri.Any[Key]
127
+ ? UriLike[Key]
128
+ : Uri[Key]
129
+ : Uri[Key];
130
+
131
+ interface ParseUriLambda extends TypeLambda<[uri: string], Uri> {
132
+ return: Arg0<this> extends infer R
133
+ ? Pipe<
134
+ [{}, R],
135
+ UriParserReducerLambda<ParseHashLambda>,
136
+ UriParserReducerLambda<ParseQueryLambda>,
137
+ UriParserReducerLambda<ParseProtocolLambda>,
138
+ UriParserReducerLambda<ParseAuthenticationLambda>,
139
+ UriParserReducerLambda<ParsePathnamePortPathnameLambda>
140
+ > extends readonly [infer Result, infer Remaining extends string]
141
+ ? Remaining extends ""
142
+ ? Result
143
+ : `Failed to parse URI: ${Arg0<this>}`
144
+ : never
145
+ : never;
146
+ }
147
+
148
+ interface UriParserReducerLambda<F extends TypeLambda> extends TypeLambda {
149
+ return: Arg0<this> extends readonly [infer State, infer Input extends string]
150
+ ? Pipe<Input, F> extends readonly [infer NextState, infer Remaining extends string]
151
+ ? [NextState & State, Remaining]
152
+ : never
153
+ : never;
154
+ }
155
+
156
+ interface ParseProtocolLambda extends TypeLambda {
157
+ readonly return: Arg0<this> extends `${infer Protocol}//${infer Rest}`
158
+ ? [{ readonly protocol: Protocol }, Rest]
159
+ : [unknown, Arg0<this>];
160
+ }
161
+
162
+ interface ParseHashLambda extends TypeLambda {
163
+ readonly return: Arg0<this> extends `${infer Rest}#${infer Hash}`
164
+ ? [{ readonly hash: Hash }, Rest]
165
+ : [unknown, Arg0<this>];
166
+ }
167
+
168
+ interface ParseQueryLambda extends TypeLambda {
169
+ readonly return: Arg0<this> extends `${infer Rest}?${infer Query}`
170
+ ? [{ readonly query: Query }, Rest]
171
+ : [unknown, Arg0<this>];
172
+ }
173
+
174
+ interface ParseAuthenticationLambda extends TypeLambda {
175
+ readonly return: Arg0<this> extends `${infer Username}:${infer Password}@${infer Rest}`
176
+ ? [{ readonly username: Username; readonly password: Password }, Rest]
177
+ : [unknown, Arg0<this>];
178
+ }
179
+
180
+ interface ParsePathnamePortPathnameLambda extends TypeLambda {
181
+ readonly return: Arg0<this> extends `${infer Hostname}:${infer Port extends number}/${infer Pathname}`
182
+ ? [{ readonly hostname: Hostname; readonly port: Port; readonly pathname: Pathname }, ""]
183
+ : Arg0<this> extends `${infer Hostname}:${infer Port extends number}`
184
+ ? [{ readonly hostname: Hostname; readonly port: Port }, ""]
185
+ : Arg0<this> extends `${infer Hostname}/${infer Pathname}`
186
+ ? "" extends Hostname
187
+ ? [{ readonly pathname: Pathname }, ""]
188
+ : [{ readonly hostname: Hostname; readonly pathname: Pathname }, ""]
189
+ : Arg0<this> extends `${infer Hostname}`
190
+ ? [{ readonly hostname: Hostname }, ""]
191
+ : [unknown, Arg0<this>];
192
+ }
193
+
194
+ interface ApplyBaseUriLambda<BaseUri extends Uri.Any> extends TypeLambda1<Uri.Any, Uri.Any> {
195
+ readonly return: Arg0<this> extends infer R extends Uri.Any
196
+ ? Uri<
197
+ GetUriKey<BaseUri, "protocol">,
198
+ GetUriKey<BaseUri, "username">,
199
+ GetUriKey<BaseUri, "password">,
200
+ GetUriKey<BaseUri, "hostname">,
201
+ GetUriKey<BaseUri, "port">,
202
+ GetUriKey<R, "pathname">,
203
+ GetUriKey<R, "query">,
204
+ GetUriKey<R, "hash">
205
+ >
206
+ : never;
207
+ }
208
+
209
+ type StringJoin<
210
+ Input extends ReadonlyArray<string>,
211
+ R extends string = "",
212
+ > = Input extends readonly [infer A extends string, ...infer Rest extends ReadonlyArray<string>]
213
+ ? StringJoin<Rest, `${R}${A}`>
214
+ : R;
package/src/index.ts CHANGED
@@ -1,28 +1,4 @@
1
- /**
2
- * @since 1.0.0
3
- */
4
-
5
- /**
6
- * @since 1.0.0
7
- */
8
- export * from "./CurrentRoute.js"
9
-
10
- /**
11
- * @since 1.0.0
12
- */
13
- export * from "./Matcher.js"
14
-
15
- /**
16
- * @since 1.0.0
17
- */
18
- export * from "./MatchInput.js"
19
-
20
- /**
21
- * @since 1.0.0
22
- */
23
- export * as RouteGuard from "./RouteGuard.js"
24
-
25
- /**
26
- * @since 1.0.0
27
- */
28
- export * as RouteMatch from "./RouteMatch.js"
1
+ export * from "./CurrentRoute.js";
2
+ export * from "./Matcher.js";
3
+ export * from "./Route.js";
4
+ export * from "./Router.js";
package/tsconfig.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": { "rootDir": "src", "outDir": "dist" },
4
+ "include": ["src"],
5
+ "exclude": ["**/*.test.ts"]
6
+ }
@@ -1,6 +0,0 @@
1
- {
2
- "main": "../dist/cjs/CurrentRoute.js",
3
- "module": "../dist/esm/CurrentRoute.js",
4
- "types": "../dist/dts/CurrentRoute.d.ts",
5
- "sideEffects": []
6
- }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023-present The Contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,6 +0,0 @@
1
- {
2
- "main": "../dist/cjs/MatchInput.js",
3
- "module": "../dist/esm/MatchInput.js",
4
- "types": "../dist/dts/MatchInput.d.ts",
5
- "sideEffects": []
6
- }
@@ -1,6 +0,0 @@
1
- {
2
- "main": "../dist/cjs/Matcher.js",
3
- "module": "../dist/esm/Matcher.js",
4
- "types": "../dist/dts/Matcher.d.ts",
5
- "sideEffects": []
6
- }
@@ -1,6 +0,0 @@
1
- {
2
- "main": "../dist/cjs/RouteGuard.js",
3
- "module": "../dist/esm/RouteGuard.js",
4
- "types": "../dist/dts/RouteGuard.d.ts",
5
- "sideEffects": []
6
- }
@@ -1,6 +0,0 @@
1
- {
2
- "main": "../dist/cjs/RouteMatch.js",
3
- "module": "../dist/esm/RouteMatch.js",
4
- "types": "../dist/dts/RouteMatch.d.ts",
5
- "sideEffects": []
6
- }
@@ -1,170 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.browser = exports.CurrentState = exports.CurrentSearchParams = exports.CurrentRoute = exports.CurrentParams = void 0;
7
- exports.decode = decode;
8
- exports.isActive = isActive;
9
- exports.layer = layer;
10
- exports.makeCurrentRoute = makeCurrentRoute;
11
- exports.makeHref = makeHref;
12
- exports.withCurrentRoute = exports.server = exports.navigate = void 0;
13
- var Context = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@typed/context"));
14
- var Document = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@typed/dom/Document"));
15
- var RefSubject = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@typed/fx/RefSubject"));
16
- var Navigation = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@typed/navigation"));
17
- var Route = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@typed/route"));
18
- var Effect = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Effect"));
19
- var _Function = /*#__PURE__*/require("effect/Function");
20
- var Option = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Option"));
21
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
22
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
23
- /**
24
- * @since 1.0.0
25
- */
26
-
27
- /**
28
- * @since 1.0.0
29
- */
30
- const CurrentRoute = exports.CurrentRoute = /*#__PURE__*/Context.Tagged("@typed/router/CurrentRoute");
31
- /**
32
- * @since 1.0.0
33
- */
34
- function makeCurrentRoute(route, parent = Option.none()) {
35
- return {
36
- route,
37
- parent
38
- };
39
- }
40
- /**
41
- * @since 1.0.0
42
- */
43
- function layer(route, parent = Option.none()) {
44
- return CurrentRoute.layer(makeCurrentRoute(route, parent));
45
- }
46
- /**
47
- * @since 1.0.0
48
- */
49
- const CurrentParams = exports.CurrentParams = /*#__PURE__*/RefSubject.filteredFromTag(Navigation.Navigation, nav => RefSubject.filterMapEffect(nav.currentEntry, e => CurrentRoute.with(({
50
- route
51
- }) => route.match(Navigation.getCurrentPathFromUrl(e.url)))));
52
- /**
53
- * @since 1.0.0
54
- */
55
- const withCurrentRoute = exports.withCurrentRoute = /*#__PURE__*/(0, _Function.dual)(2, (effect, route) => Effect.contextWithEffect(ctx => {
56
- const parent = Context.getOption(ctx, CurrentRoute);
57
- if (Option.isNone(parent)) {
58
- return (0, _Function.pipe)(effect, CurrentRoute.provide(makeCurrentRoute(route)));
59
- }
60
- return (0, _Function.pipe)(effect, CurrentRoute.provide(makeCurrentRoute(parent.value.route.concat(route), parent)));
61
- }));
62
- const makeHref_ = (currentPath, currentRoute, route, params = {}) => {
63
- const currentMatch = currentRoute.match(currentPath);
64
- if (Option.isNone(currentMatch)) return Option.none();
65
- const fullRoute = currentRoute.concat(route);
66
- const fullParams = {
67
- ...currentMatch.value,
68
- ...params
69
- };
70
- return Option.some(fullRoute.interpolate(fullParams));
71
- };
72
- function makeHref(route, ...[params]) {
73
- return RefSubject.filterMapEffect(Navigation.CurrentPath, currentPath => Effect.map(CurrentRoute, currentRoute => makeHref_(currentPath, currentRoute.route, route, params)));
74
- }
75
- const isActive_ = (currentPath, currentRoute, route, params = {}) => {
76
- const currentMatch = currentRoute.match(currentPath);
77
- if (Option.isNone(currentMatch)) return false;
78
- const fullRoute = currentRoute.concat(route);
79
- const fullParams = {
80
- ...currentMatch.value,
81
- ...params
82
- };
83
- const href = fullRoute.interpolate(fullParams);
84
- const [currentPathname, currentQuery] = splitByQuery(currentPath);
85
- const [hrefPathname, hrefQuery] = splitByQuery(href);
86
- return (fullRoute.routeOptions.end ? currentPathname === hrefPathname : currentPathname.startsWith(hrefPathname)) && compareQueries(currentQuery, hrefQuery);
87
- };
88
- function compareQueries(currentQuery, hrefQuery) {
89
- // if hrefQuery is empty, it means that the href is a pathname only
90
- if (!hrefQuery) return true;
91
- // if currentQuery is empty, there is no match at this point
92
- if (!currentQuery) return false;
93
- // if the queries are equal, there is a match
94
- if (currentQuery === hrefQuery) return true;
95
- const currentQueryParams = new URLSearchParams(currentQuery);
96
- const hrefQueryParams = new URLSearchParams(hrefQuery);
97
- for (const key of hrefQueryParams.keys()) {
98
- const a = currentQueryParams.getAll(key).sort();
99
- const b = hrefQueryParams.getAll(key).sort();
100
- if (a.length !== b.length || !b.every((bx, i) => a[i] === bx)) return false;
101
- }
102
- return true;
103
- }
104
- function splitByQuery(path) {
105
- const queryIndex = path.indexOf("?");
106
- if (queryIndex > -1) {
107
- const pathname = path.slice(0, queryIndex);
108
- const query = path.slice(queryIndex + 1).trim();
109
- return [pathname, query];
110
- }
111
- return [path, ""];
112
- }
113
- function isActive(route, ...[params]) {
114
- return RefSubject.mapEffect(Navigation.CurrentPath, currentPath => CurrentRoute.with(currentRoute => isActive_(currentPath, currentRoute.route, route, params)));
115
- }
116
- /**
117
- * @since 1.0.0
118
- */
119
- function decode(route) {
120
- return RefSubject.filteredFromTag(Navigation.Navigation, nav => RefSubject.filterMapEffect(nav.currentEntry, e => Effect.flatMap(CurrentRoute, ({
121
- route: parent
122
- }) => Effect.optionFromOptional(Route.decode(parent.concat(route), Navigation.getCurrentPathFromUrl(e.url))))));
123
- }
124
- /**
125
- * @since 1.0.0
126
- */
127
- const browser = exports.browser = /*#__PURE__*/CurrentRoute.layer( /*#__PURE__*/Effect.gen(function* () {
128
- const document = yield* Document.Document;
129
- const base = document.querySelector("base");
130
- const baseHref = base ? getBasePathname(base.href) : "/";
131
- return {
132
- route: Route.parse(baseHref),
133
- parent: Option.none()
134
- };
135
- }));
136
- function getBasePathname(base) {
137
- try {
138
- const url = new URL(base);
139
- return url.pathname;
140
- } catch {
141
- return base;
142
- }
143
- }
144
- /**
145
- * @since 1.0.0
146
- */
147
- const server = (base = "/") => CurrentRoute.layer({
148
- route: Route.parse(base),
149
- parent: Option.none()
150
- });
151
- exports.server = server;
152
- const getSearchParams = destination => destination.url.searchParams;
153
- /**
154
- * @since 1.0.0
155
- */
156
- const CurrentSearchParams = exports.CurrentSearchParams = /*#__PURE__*/RefSubject.map(Navigation.CurrentEntry, getSearchParams);
157
- /**
158
- * @since 1.0.0
159
- */
160
- const CurrentState = exports.CurrentState = /*#__PURE__*/RefSubject.computedFromTag(Navigation.Navigation, n => RefSubject.map(n.currentEntry, e => e.state));
161
- /**
162
- * @since 1.0.0
163
- */
164
- const navigate = (route, ...[options]) => Effect.gen(function* (_) {
165
- const params = options?.params ?? {};
166
- const path = options?.relative === false ? route.interpolate(params) : yield* _(makeHref(route, params));
167
- return yield* _(Navigation.navigate(path));
168
- });
169
- exports.navigate = navigate;
170
- //# sourceMappingURL=CurrentRoute.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CurrentRoute.js","names":["Context","_interopRequireWildcard","require","Document","RefSubject","Navigation","Route","Effect","_Function","Option","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","CurrentRoute","exports","Tagged","makeCurrentRoute","route","parent","none","layer","CurrentParams","filteredFromTag","nav","filterMapEffect","currentEntry","with","match","getCurrentPathFromUrl","url","withCurrentRoute","dual","effect","contextWithEffect","ctx","getOption","isNone","pipe","provide","value","concat","makeHref_","currentPath","currentRoute","params","currentMatch","fullRoute","fullParams","some","interpolate","makeHref","CurrentPath","map","isActive_","href","currentPathname","currentQuery","splitByQuery","hrefPathname","hrefQuery","routeOptions","end","startsWith","compareQueries","currentQueryParams","URLSearchParams","hrefQueryParams","key","keys","getAll","sort","b","length","every","bx","path","queryIndex","indexOf","pathname","slice","query","trim","isActive","mapEffect","decode","flatMap","optionFromOptional","browser","gen","document","base","querySelector","baseHref","getBasePathname","parse","URL","server","getSearchParams","destination","searchParams","CurrentSearchParams","CurrentEntry","CurrentState","computedFromTag","state","navigate","options","_","relative"],"sources":["../../src/CurrentRoute.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;AAIA,IAAAA,OAAA,gBAAAC,uBAAA,eAAAC,OAAA;AACA,IAAAC,QAAA,gBAAAF,uBAAA,eAAAC,OAAA;AAE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CAACiE,GAAG,CAAChE,UAAU,CAACiH,YAAY,EAAEJ,eAAe,CAAC;AAE5D;;;AAGO,MAAMK,YAAY,GAAAxF,OAAA,CAAAwF,YAAA,gBAAGnH,UAAU,CAACoH,eAAe,CACpDnH,UAAU,CAACA,UAAU,EACpBc,CAAC,IAAKf,UAAU,CAACiE,GAAG,CAAClD,CAAC,CAACuB,YAAY,EAAG/B,CAAC,IAAKA,CAAC,CAAC8G,KAAK,CAAC,CACtD;AAoBD;;;AAGO,MAAMC,QAAQ,GAAGA,CACtBxF,KAAQ,EACR,GAAG,CAACyF,OAAO,CAAqB,KAMhCpH,MAAM,CAACkG,GAAG,CAAC,WAAUmB,CAAC;EACpB,MAAM/D,MAAM,GAAG8D,OAAO,EAAE9D,MAAM,IAAK,EAA4B;EAC/D,MAAM+B,IAAI,GAAG+B,OAAO,EAAEE,QAAQ,KAAK,KAAK,GACpC3F,KAAK,CAACgC,WAAW,CAACL,MAAM,CAAC,GACzB,OAAO+D,CAAC,CAACzD,QAAQ,CAAIjC,KAAK,EAAE2B,MAAM,CAAC,CAAC;EACxC,OAAO,OAAO+D,CAAC,CAACvH,UAAU,CAACqH,QAAQ,CAAC9B,IAAI,CAAC,CAAC;AAC5C,CAAC,CAAC;AAAA7D,OAAA,CAAA2F,QAAA,GAAAA,QAAA","ignoreList":[]}
@@ -1,96 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.asRouteGuard = asRouteGuard;
7
- exports.concat = concat;
8
- exports.flatMap = exports.filterMap = exports.filter = void 0;
9
- exports.getPath = getPath;
10
- exports.getPathSchema = getPathSchema;
11
- exports.getQuerySchema = getQuerySchema;
12
- exports.getRoute = getRoute;
13
- exports.getSchema = getSchema;
14
- exports.mapEffect = exports.map = void 0;
15
- var Route = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@typed/route"));
16
- var _Function = /*#__PURE__*/require("effect/Function");
17
- var RouteGuard = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./RouteGuard.js"));
18
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
19
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
20
- /**
21
- * @since 1.0.0
22
- */
23
-
24
- /**
25
- * @since 1.0.0
26
- */
27
- function asRouteGuard(input) {
28
- return Route.isRoute(input) ? RouteGuard.fromRoute(input) : input;
29
- }
30
- /**
31
- * @since 1.0.0
32
- */
33
- const map = exports.map = /*#__PURE__*/(0, _Function.dual)(2, function map(input, f) {
34
- return RouteGuard.map(asRouteGuard(input), f);
35
- });
36
- /**
37
- * @since 1.0.0
38
- */
39
- const mapEffect = exports.mapEffect = /*#__PURE__*/(0, _Function.dual)(2, function mapEffect(input, f) {
40
- return RouteGuard.mapEffect(asRouteGuard(input), f);
41
- });
42
- /**
43
- * @since 1.0.0
44
- */
45
- const filter = exports.filter = /*#__PURE__*/(0, _Function.dual)(2, function filter(input, f) {
46
- return RouteGuard.filter(asRouteGuard(input), f);
47
- });
48
- /**
49
- * @since 1.0.0
50
- */
51
- const filterMap = exports.filterMap = /*#__PURE__*/(0, _Function.dual)(2, function filterMap(input, f) {
52
- return RouteGuard.filterMap(asRouteGuard(input), f);
53
- });
54
- /**
55
- * @since 1.0.0
56
- */
57
- const flatMap = exports.flatMap = /*#__PURE__*/(0, _Function.dual)(2, function flatMap(input, guard) {
58
- return RouteGuard.flatMap(asRouteGuard(input), guard);
59
- });
60
- /**
61
- * @since 1.0.0
62
- */
63
- function concat(left, right) {
64
- return RouteGuard.concat(asRouteGuard(left), asRouteGuard(right));
65
- }
66
- /**
67
- * @since 1.0.0
68
- */
69
- function getRoute(input) {
70
- return asRouteGuard(input).route;
71
- }
72
- /**
73
- * @since 1.0.0
74
- */
75
- function getSchema(input) {
76
- return asRouteGuard(input).route.schema;
77
- }
78
- /**
79
- * @since 1.0.0
80
- */
81
- function getPathSchema(input) {
82
- return asRouteGuard(input).route.pathSchema;
83
- }
84
- /**
85
- * @since 1.0.0
86
- */
87
- function getQuerySchema(input) {
88
- return asRouteGuard(input).route.querySchema;
89
- }
90
- /**
91
- * @since 1.0.0
92
- */
93
- function getPath(input) {
94
- return asRouteGuard(input).route.path;
95
- }
96
- //# sourceMappingURL=MatchInput.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MatchInput.js","names":["Route","_interopRequireWildcard","require","_Function","RouteGuard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","asRouteGuard","input","isRoute","fromRoute","map","exports","dual","f","mapEffect","filter","filterMap","flatMap","guard","concat","left","right","getRoute","route","getSchema","schema","getPathSchema","pathSchema","getQuerySchema","querySchema","getPath","path"],"sources":["../../src/MatchInput.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;AAOA,IAAAA,KAAA,gBAAAC,uBAAA,eAAAC,OAAA;AAEA,IAAAC,SAAA,gBAAAD,OAAA;AAEA,IAAAE,UAAA,gBAAAH,uBAAA,eAAAC,OAAA;AAA6C,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAL,wBAAAK,C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