@remix-run/router 1.0.3 → 1.0.4-pre.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/CHANGELOG.md +16 -0
- package/dist/history.d.ts +3 -3
- package/dist/router.cjs.js +262 -166
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +14 -2
- package/dist/router.js +262 -166
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +262 -166
- 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 +7 -3
- package/history.ts +12 -8
- package/package.json +1 -1
- package/router.ts +292 -183
- package/utils.ts +21 -5
package/dist/utils.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export interface RedirectResult {
|
|
|
35
35
|
status: number;
|
|
36
36
|
location: string;
|
|
37
37
|
revalidate: boolean;
|
|
38
|
+
external: boolean;
|
|
38
39
|
}
|
|
39
40
|
/**
|
|
40
41
|
* Unsuccessful result from a loader or action
|
|
@@ -48,7 +49,8 @@ export interface ErrorResult {
|
|
|
48
49
|
* Result from a loader or action - potentially successful or unsuccessful
|
|
49
50
|
*/
|
|
50
51
|
export declare type DataResult = SuccessResult | DeferredResult | RedirectResult | ErrorResult;
|
|
51
|
-
export declare type
|
|
52
|
+
export declare type SubmissionFormMethod = "post" | "put" | "patch" | "delete";
|
|
53
|
+
export declare type FormMethod = "get" | SubmissionFormMethod;
|
|
52
54
|
export declare type FormEncType = "application/x-www-form-urlencoded" | "multipart/form-data";
|
|
53
55
|
/**
|
|
54
56
|
* @private
|
|
@@ -56,7 +58,7 @@ export declare type FormEncType = "application/x-www-form-urlencoded" | "multipa
|
|
|
56
58
|
* external consumption
|
|
57
59
|
*/
|
|
58
60
|
export interface Submission {
|
|
59
|
-
formMethod:
|
|
61
|
+
formMethod: SubmissionFormMethod;
|
|
60
62
|
formAction: string;
|
|
61
63
|
formEncType: FormEncType;
|
|
62
64
|
formData: FormData;
|
|
@@ -373,7 +375,9 @@ export declare class ErrorResponse {
|
|
|
373
375
|
status: number;
|
|
374
376
|
statusText: string;
|
|
375
377
|
data: any;
|
|
376
|
-
|
|
378
|
+
error?: Error;
|
|
379
|
+
internal: boolean;
|
|
380
|
+
constructor(status: number, statusText: string | undefined, data: any, internal?: boolean);
|
|
377
381
|
}
|
|
378
382
|
/**
|
|
379
383
|
* Check if the given error is an ErrorResponse generated from a 4xx/5xx
|
package/history.ts
CHANGED
|
@@ -127,12 +127,12 @@ export interface History {
|
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
129
|
* Encode a location the same way window.history would do (no-op for memory
|
|
130
|
-
* history) so we ensure our PUSH/
|
|
130
|
+
* history) so we ensure our PUSH/REPLACE navigations for data routers
|
|
131
131
|
* behave the same as POP
|
|
132
132
|
*
|
|
133
|
-
* @param
|
|
133
|
+
* @param to Unencoded path
|
|
134
134
|
*/
|
|
135
|
-
encodeLocation(
|
|
135
|
+
encodeLocation(to: To): Path;
|
|
136
136
|
|
|
137
137
|
/**
|
|
138
138
|
* Pushes a new location onto the history stack, increasing its length by one.
|
|
@@ -268,8 +268,13 @@ export function createMemoryHistory(
|
|
|
268
268
|
createHref(to) {
|
|
269
269
|
return typeof to === "string" ? to : createPath(to);
|
|
270
270
|
},
|
|
271
|
-
encodeLocation(
|
|
272
|
-
|
|
271
|
+
encodeLocation(to: To) {
|
|
272
|
+
let path = typeof to === "string" ? parsePath(to) : to;
|
|
273
|
+
return {
|
|
274
|
+
pathname: path.pathname || "",
|
|
275
|
+
search: path.search || "",
|
|
276
|
+
hash: path.hash || "",
|
|
277
|
+
};
|
|
273
278
|
},
|
|
274
279
|
push(to, state) {
|
|
275
280
|
action = Action.Push;
|
|
@@ -636,11 +641,10 @@ function getUrlBasedHistory(
|
|
|
636
641
|
createHref(to) {
|
|
637
642
|
return createHref(window, to);
|
|
638
643
|
},
|
|
639
|
-
encodeLocation(
|
|
644
|
+
encodeLocation(to) {
|
|
640
645
|
// Encode a Location the same way window.location would
|
|
641
|
-
let url = createURL(createPath(
|
|
646
|
+
let url = createURL(typeof to === "string" ? to : createPath(to));
|
|
642
647
|
return {
|
|
643
|
-
...location,
|
|
644
648
|
pathname: url.pathname,
|
|
645
649
|
search: url.search,
|
|
646
650
|
hash: url.hash,
|