@remix-run/router 1.5.0 → 1.6.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.
package/dist/utils.d.ts CHANGED
@@ -101,17 +101,23 @@ export interface LoaderFunctionArgs extends DataFunctionArgs {
101
101
  */
102
102
  export interface ActionFunctionArgs extends DataFunctionArgs {
103
103
  }
104
+ /**
105
+ * Loaders and actions can return anything except `undefined` (`null` is a
106
+ * valid return value if there is no data to return). Responses are preferred
107
+ * and will ease any future migration to Remix
108
+ */
109
+ declare type DataFunctionValue = Response | NonNullable<unknown> | null;
104
110
  /**
105
111
  * Route loader function signature
106
112
  */
107
113
  export interface LoaderFunction {
108
- (args: LoaderFunctionArgs): Promise<Response> | Response | Promise<any> | any;
114
+ (args: LoaderFunctionArgs): Promise<DataFunctionValue> | DataFunctionValue;
109
115
  }
110
116
  /**
111
117
  * Route action function signature
112
118
  */
113
119
  export interface ActionFunction {
114
- (args: ActionFunctionArgs): Promise<Response> | Response | Promise<any> | any;
120
+ (args: ActionFunctionArgs): Promise<DataFunctionValue> | DataFunctionValue;
115
121
  }
116
122
  /**
117
123
  * Route shouldRevalidate function signature. This runs after any submission
@@ -137,10 +143,21 @@ export interface ShouldRevalidateFunction {
137
143
  /**
138
144
  * Function provided by the framework-aware layers to set `hasErrorBoundary`
139
145
  * from the framework-aware `errorElement` prop
146
+ *
147
+ * @deprecated Use `mapRouteProperties` instead
140
148
  */
141
149
  export interface DetectErrorBoundaryFunction {
142
150
  (route: AgnosticRouteObject): boolean;
143
151
  }
152
+ /**
153
+ * Function provided by the framework-aware layers to set any framework-specific
154
+ * properties from framework-agnostic properties
155
+ */
156
+ export interface MapRoutePropertiesFunction {
157
+ (route: AgnosticRouteObject): {
158
+ hasErrorBoundary: boolean;
159
+ } & Record<string, any>;
160
+ }
144
161
  /**
145
162
  * Keys we cannot change from within a lazy() function. We spread all other keys
146
163
  * onto the route. Either they're meaningful to the router, or they'll get
@@ -243,7 +260,7 @@ export interface AgnosticRouteMatch<ParamKey extends string = string, RouteObjec
243
260
  }
244
261
  export interface AgnosticDataRouteMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
245
262
  }
246
- export declare function convertRoutesToDataRoutes(routes: AgnosticRouteObject[], detectErrorBoundary: DetectErrorBoundaryFunction, parentPath?: number[], manifest?: RouteManifest): AgnosticDataRouteObject[];
263
+ export declare function convertRoutesToDataRoutes(routes: AgnosticRouteObject[], mapRouteProperties: MapRoutePropertiesFunction, parentPath?: number[], manifest?: RouteManifest): AgnosticDataRouteObject[];
247
264
  /**
248
265
  * Matches the given routes to a location and returns the match data.
249
266
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remix-run/router",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "Nested/Data-driven/Framework-agnostic Routing",
5
5
  "keywords": [
6
6
  "remix",