@remix-run/router 0.0.0-experimental-e960cf1a → 0.0.0-experimental-a0888892
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/CHANGELOG.md +211 -8
- package/dist/index.d.ts +2 -2
- package/dist/router.cjs.js +306 -272
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +2 -1
- package/dist/router.js +295 -259
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +306 -272
- package/dist/router.umd.js.map +1 -1
- package/dist/router.umd.min.js +2 -2
- package/dist/router.umd.min.js.map +1 -1
- package/dist/utils.d.ts +21 -21
- package/history.ts +4 -0
- package/index.ts +1 -3
- package/package.json +1 -1
- package/router.ts +467 -406
- package/utils.ts +60 -63
package/dist/utils.d.ts
CHANGED
|
@@ -17,8 +17,7 @@ export declare enum ResultType {
|
|
|
17
17
|
export interface SuccessResult {
|
|
18
18
|
type: ResultType.data;
|
|
19
19
|
data: any;
|
|
20
|
-
|
|
21
|
-
headers?: Headers;
|
|
20
|
+
response?: Response;
|
|
22
21
|
}
|
|
23
22
|
/**
|
|
24
23
|
* Successful defer() result from a loader or action
|
|
@@ -34,10 +33,7 @@ export interface DeferredResult {
|
|
|
34
33
|
*/
|
|
35
34
|
export interface RedirectResult {
|
|
36
35
|
type: ResultType.redirect;
|
|
37
|
-
|
|
38
|
-
location: string;
|
|
39
|
-
revalidate: boolean;
|
|
40
|
-
reloadDocument?: boolean;
|
|
36
|
+
response: Response;
|
|
41
37
|
}
|
|
42
38
|
/**
|
|
43
39
|
* Unsuccessful result from a loader or action
|
|
@@ -45,12 +41,19 @@ export interface RedirectResult {
|
|
|
45
41
|
export interface ErrorResult {
|
|
46
42
|
type: ResultType.error;
|
|
47
43
|
error: any;
|
|
48
|
-
|
|
44
|
+
response?: Response;
|
|
49
45
|
}
|
|
50
46
|
/**
|
|
51
47
|
* Result from a loader or action - potentially successful or unsuccessful
|
|
52
48
|
*/
|
|
53
49
|
export type DataResult = SuccessResult | DeferredResult | RedirectResult | ErrorResult;
|
|
50
|
+
/**
|
|
51
|
+
* Result from a loader or action called via dataStrategy
|
|
52
|
+
*/
|
|
53
|
+
export interface HandlerResult {
|
|
54
|
+
type: ResultType.data | ResultType.error;
|
|
55
|
+
result: any;
|
|
56
|
+
}
|
|
54
57
|
type LowerCaseFormMethod = "get" | "post" | "put" | "patch" | "delete";
|
|
55
58
|
type UpperCaseFormMethod = Uppercase<LowerCaseFormMethod>;
|
|
56
59
|
/**
|
|
@@ -132,11 +135,12 @@ export interface ActionFunctionArgs<Context = any> extends DataFunctionArgs<Cont
|
|
|
132
135
|
* and will ease any future migration to Remix
|
|
133
136
|
*/
|
|
134
137
|
type DataFunctionValue = Response | NonNullable<unknown> | null;
|
|
138
|
+
type DataFunctionReturnValue = Promise<DataFunctionValue> | DataFunctionValue;
|
|
135
139
|
/**
|
|
136
140
|
* Route loader function signature
|
|
137
141
|
*/
|
|
138
142
|
export type LoaderFunction<Context = any> = {
|
|
139
|
-
(args: LoaderFunctionArgs<Context
|
|
143
|
+
(args: LoaderFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
|
|
140
144
|
} & {
|
|
141
145
|
hydrate?: boolean;
|
|
142
146
|
};
|
|
@@ -144,7 +148,7 @@ export type LoaderFunction<Context = any> = {
|
|
|
144
148
|
* Route action function signature
|
|
145
149
|
*/
|
|
146
150
|
export interface ActionFunction<Context = any> {
|
|
147
|
-
(args: ActionFunctionArgs<Context
|
|
151
|
+
(args: ActionFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
|
|
148
152
|
}
|
|
149
153
|
/**
|
|
150
154
|
* Arguments passed to shouldRevalidate function
|
|
@@ -182,14 +186,14 @@ export interface ShouldRevalidateFunction {
|
|
|
182
186
|
export interface DetectErrorBoundaryFunction {
|
|
183
187
|
(route: AgnosticRouteObject): boolean;
|
|
184
188
|
}
|
|
185
|
-
export interface
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
189
|
+
export interface DataStrategyMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
|
|
190
|
+
bikeshed_loadRoute: (handlerOverride?: (handler: (ctx?: unknown) => DataFunctionReturnValue) => DataFunctionReturnValue) => Promise<HandlerResult>;
|
|
191
|
+
}
|
|
192
|
+
export interface DataStrategyFunctionArgs<Context = any> extends DataFunctionArgs<Context> {
|
|
193
|
+
matches: DataStrategyMatch[];
|
|
190
194
|
}
|
|
191
195
|
export interface DataStrategyFunction {
|
|
192
|
-
(args: DataStrategyFunctionArgs): Promise<
|
|
196
|
+
(args: DataStrategyFunctionArgs): Promise<HandlerResult[]>;
|
|
193
197
|
}
|
|
194
198
|
/**
|
|
195
199
|
* Function provided by the framework-aware layers to set any framework-specific
|
|
@@ -224,8 +228,8 @@ type AgnosticBaseRouteObject = {
|
|
|
224
228
|
caseSensitive?: boolean;
|
|
225
229
|
path?: string;
|
|
226
230
|
id?: string;
|
|
227
|
-
loader?: LoaderFunction;
|
|
228
|
-
action?: ActionFunction;
|
|
231
|
+
loader?: LoaderFunction | boolean;
|
|
232
|
+
action?: ActionFunction | boolean;
|
|
229
233
|
hasErrorBoundary?: boolean;
|
|
230
234
|
shouldRevalidate?: ShouldRevalidateFunction;
|
|
231
235
|
handle?: any;
|
|
@@ -305,10 +309,6 @@ export interface AgnosticRouteMatch<ParamKey extends string = string, RouteObjec
|
|
|
305
309
|
}
|
|
306
310
|
export interface AgnosticDataRouteMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
|
|
307
311
|
}
|
|
308
|
-
export type LazyRoutePromise = PromiseLike<AgnosticDataRouteObject> & AgnosticDataRouteObject;
|
|
309
|
-
export interface AgnosticDataStrategyMatch extends Omit<AgnosticRouteMatch<string, AgnosticDataRouteObject>, "route"> {
|
|
310
|
-
route: LazyRoutePromise;
|
|
311
|
-
}
|
|
312
312
|
export declare function convertRoutesToDataRoutes(routes: AgnosticRouteObject[], mapRouteProperties: MapRoutePropertiesFunction, parentPath?: number[], manifest?: RouteManifest): AgnosticDataRouteObject[];
|
|
313
313
|
/**
|
|
314
314
|
* Matches the given routes to a location and returns the match data.
|
package/history.ts
CHANGED
|
@@ -690,6 +690,10 @@ function getUrlBasedHistory(
|
|
|
690
690
|
: window.location.href;
|
|
691
691
|
|
|
692
692
|
let href = typeof to === "string" ? to : createPath(to);
|
|
693
|
+
// Treating this as a full URL will strip any trailing spaces so we need to
|
|
694
|
+
// pre-encode them since they might be part of a matching splat param from
|
|
695
|
+
// an ancestor route
|
|
696
|
+
href = href.replace(/ $/, "%20");
|
|
693
697
|
invariant(
|
|
694
698
|
base,
|
|
695
699
|
`No window.location.(origin|href) available to create URL for href: ${href}`
|
package/index.ts
CHANGED
|
@@ -5,14 +5,13 @@ export type {
|
|
|
5
5
|
AgnosticDataNonIndexRouteObject,
|
|
6
6
|
AgnosticDataRouteMatch,
|
|
7
7
|
AgnosticDataRouteObject,
|
|
8
|
-
AgnosticDataStrategyMatch,
|
|
9
8
|
AgnosticIndexRouteObject,
|
|
10
9
|
AgnosticNonIndexRouteObject,
|
|
11
10
|
AgnosticRouteMatch,
|
|
12
11
|
AgnosticRouteObject,
|
|
13
|
-
DataResult,
|
|
14
12
|
DataStrategyFunction,
|
|
15
13
|
DataStrategyFunctionArgs,
|
|
14
|
+
DataStrategyMatch,
|
|
16
15
|
ErrorResponse,
|
|
17
16
|
FormEncType,
|
|
18
17
|
FormMethod,
|
|
@@ -49,7 +48,6 @@ export {
|
|
|
49
48
|
redirectDocument,
|
|
50
49
|
resolvePath,
|
|
51
50
|
resolveTo,
|
|
52
|
-
ResultType,
|
|
53
51
|
stripBasename,
|
|
54
52
|
} from "./utils";
|
|
55
53
|
|