react-router 0.0.0-experimental-63b6834e → 0.0.0-experimental-cf9637ce

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/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import type { ActionFunction, ActionFunctionArgs, Blocker, BlockerFunction, Fetcher, HydrationState, JsonFunction, LoaderFunction, LoaderFunctionArgs, Location, Navigation, Params, ParamParseKey, Path, PathMatch, PathPattern, RedirectFunction, Router as RemixRouter, ShouldRevalidateFunction, To, InitialEntry, LazyRouteFunction } from "@remix-run/router";
1
+ import type { ActionFunction, ActionFunctionArgs, Blocker, BlockerFunction, Fetcher, HydrationState, JsonFunction, LoaderFunction, LoaderFunctionArgs, Location, Navigation, Params, ParamParseKey, Path, PathMatch, PathPattern, RedirectFunction, Router as RemixRouter, ShouldRevalidateFunction, To, InitialEntry } from "@remix-run/router";
2
2
  import { AbortedDeferredError, Action as NavigationType, createPath, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, resolvePath } from "@remix-run/router";
3
3
  import type { AwaitProps, MemoryRouterProps, NavigateProps, OutletProps, RouteProps, PathRouteProps, LayoutRouteProps, IndexRouteProps, RouterProps, RoutesProps, RouterProviderProps } from "./lib/components";
4
- import { createRoutesFromChildren, renderMatches, Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes } from "./lib/components";
4
+ import { enhanceManualRouteObjects, createRoutesFromChildren, renderMatches, Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes } from "./lib/components";
5
5
  import type { DataRouteMatch, DataRouteObject, IndexRouteObject, Navigator, NavigateOptions, NonIndexRouteObject, RouteMatch, RouteObject, RelativeRoutingType } from "./lib/context";
6
6
  import { DataRouterContext, DataRouterStateContext, LocationContext, NavigationContext, RouteContext } from "./lib/context";
7
7
  import type { NavigateFunction } from "./lib/hooks";
@@ -9,16 +9,13 @@ import { useBlocker, useHref, useInRouterContext, useLocation, useMatch, useNavi
9
9
  declare type Hash = string;
10
10
  declare type Pathname = string;
11
11
  declare type Search = string;
12
- export type { ActionFunction, ActionFunctionArgs, AwaitProps, Blocker as unstable_Blocker, BlockerFunction as unstable_BlockerFunction, DataRouteMatch, DataRouteObject, Fetcher, Hash, IndexRouteObject, IndexRouteProps, JsonFunction, LazyRouteFunction, LayoutRouteProps, LoaderFunction, LoaderFunctionArgs, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigation, Navigator, NonIndexRouteObject, OutletProps, Params, ParamParseKey, Path, PathMatch, Pathname, PathPattern, PathRouteProps, RedirectFunction, RelativeRoutingType, RouteMatch, RouteObject, RouteProps, RouterProps, RouterProviderProps, RoutesProps, Search, ShouldRevalidateFunction, To, };
12
+ export type { ActionFunction, ActionFunctionArgs, AwaitProps, Blocker as unstable_Blocker, BlockerFunction as unstable_BlockerFunction, DataRouteMatch, DataRouteObject, Fetcher, Hash, IndexRouteObject, IndexRouteProps, JsonFunction, LayoutRouteProps, LoaderFunction, LoaderFunctionArgs, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigation, Navigator, NonIndexRouteObject, OutletProps, Params, ParamParseKey, Path, PathMatch, Pathname, PathPattern, PathRouteProps, RedirectFunction, RelativeRoutingType, RouteMatch, RouteObject, RouteProps, RouterProps, RouterProviderProps, RoutesProps, Search, ShouldRevalidateFunction, To, };
13
13
  export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, createPath, createRoutesFromChildren, createRoutesFromChildren as createRoutesFromElements, defer, isRouteErrorResponse, generatePath, json, matchPath, matchRoutes, parsePath, redirect, renderMatches, resolvePath, useActionData, useAsyncError, useAsyncValue, useBlocker as unstable_useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, };
14
14
  export declare function createMemoryRouter(routes: RouteObject[], opts?: {
15
15
  basename?: string;
16
16
  hydrationData?: HydrationState;
17
17
  initialEntries?: InitialEntry[];
18
18
  initialIndex?: number;
19
- onInitialize?: (args: {
20
- router: RemixRouter;
21
- }) => void;
22
19
  }): RemixRouter;
23
20
  /** @internal */
24
- export { NavigationContext as UNSAFE_NavigationContext, LocationContext as UNSAFE_LocationContext, RouteContext as UNSAFE_RouteContext, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, };
21
+ export { NavigationContext as UNSAFE_NavigationContext, LocationContext as UNSAFE_LocationContext, RouteContext as UNSAFE_RouteContext, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, enhanceManualRouteObjects as UNSAFE_enhanceManualRouteObjects, };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router v0.0.0-experimental-63b6834e
2
+ * React Router v0.0.0-experimental-cf9637ce
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -12,6 +12,23 @@ import { invariant, joinPaths, matchPath, UNSAFE_getPathContributingMatches, war
12
12
  export { AbortedDeferredError, Action as NavigationType, createPath, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, resolvePath } from '@remix-run/router';
13
13
  import * as React from 'react';
14
14
 
15
+ function _extends() {
16
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
17
+ for (var i = 1; i < arguments.length; i++) {
18
+ var source = arguments[i];
19
+
20
+ for (var key in source) {
21
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
22
+ target[key] = source[key];
23
+ }
24
+ }
25
+ }
26
+
27
+ return target;
28
+ };
29
+ return _extends.apply(this, arguments);
30
+ }
31
+
15
32
  /**
16
33
  * Copyright (c) Facebook, Inc. and its affiliates.
17
34
  *
@@ -235,23 +252,6 @@ if (process.env.NODE_ENV !== "production") {
235
252
  RouteErrorContext.displayName = "RouteError";
236
253
  }
237
254
 
238
- function _extends() {
239
- _extends = Object.assign ? Object.assign.bind() : function (target) {
240
- for (var i = 1; i < arguments.length; i++) {
241
- var source = arguments[i];
242
-
243
- for (var key in source) {
244
- if (Object.prototype.hasOwnProperty.call(source, key)) {
245
- target[key] = source[key];
246
- }
247
- }
248
- }
249
-
250
- return target;
251
- };
252
- return _extends.apply(this, arguments);
253
- }
254
-
255
255
  /**
256
256
  * Returns the full href for the given "to" value. This is useful for building
257
257
  * custom links that are also accessible and preserve right-click behavior.
@@ -1341,8 +1341,7 @@ function createRoutesFromChildren(children, parentPath) {
1341
1341
  errorElement: element.props.errorElement,
1342
1342
  hasErrorBoundary: element.props.errorElement != null,
1343
1343
  shouldRevalidate: element.props.shouldRevalidate,
1344
- handle: element.props.handle,
1345
- lazy: element.props.lazy
1344
+ handle: element.props.handle
1346
1345
  };
1347
1346
 
1348
1347
  if (element.props.children) {
@@ -1360,6 +1359,27 @@ function createRoutesFromChildren(children, parentPath) {
1360
1359
  function renderMatches(matches) {
1361
1360
  return _renderMatches(matches);
1362
1361
  }
1362
+ /**
1363
+ * @private
1364
+ * Walk the route tree and add hasErrorBoundary if it's not provided, so that
1365
+ * users providing manual route arrays can just specify errorElement
1366
+ */
1367
+
1368
+ function enhanceManualRouteObjects(routes) {
1369
+ return routes.map(route => {
1370
+ let routeClone = _extends({}, route);
1371
+
1372
+ if (routeClone.hasErrorBoundary == null) {
1373
+ routeClone.hasErrorBoundary = routeClone.errorElement != null;
1374
+ }
1375
+
1376
+ if (routeClone.children) {
1377
+ routeClone.children = enhanceManualRouteObjects(routeClone.children);
1378
+ }
1379
+
1380
+ return routeClone;
1381
+ });
1382
+ }
1363
1383
 
1364
1384
  function createMemoryRouter(routes, opts) {
1365
1385
  return createRouter({
@@ -1369,11 +1389,9 @@ function createMemoryRouter(routes, opts) {
1369
1389
  initialIndex: opts == null ? void 0 : opts.initialIndex
1370
1390
  }),
1371
1391
  hydrationData: opts == null ? void 0 : opts.hydrationData,
1372
- routes,
1373
- hasErrorBoundary: route => Boolean(route.errorElement),
1374
- onInitialize: opts == null ? void 0 : opts.onInitialize
1392
+ routes: enhanceManualRouteObjects(routes)
1375
1393
  }).initialize();
1376
1394
  } ///////////////////////////////////////////////////////////////////////////////
1377
1395
 
1378
- export { Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RouteContext as UNSAFE_RouteContext, createMemoryRouter, createRoutesFromChildren, createRoutesFromChildren as createRoutesFromElements, renderMatches, useBlocker as unstable_useBlocker, useActionData, useAsyncError, useAsyncValue, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };
1396
+ export { Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RouteContext as UNSAFE_RouteContext, enhanceManualRouteObjects as UNSAFE_enhanceManualRouteObjects, createMemoryRouter, createRoutesFromChildren, createRoutesFromChildren as createRoutesFromElements, renderMatches, useBlocker as unstable_useBlocker, useActionData, useAsyncError, useAsyncValue, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };
1379
1397
  //# sourceMappingURL=index.js.map