@remix-run/react
Advanced tools
Comparing version 0.0.0-experimental-ab9dac4f to 0.0.0-experimental-b697c4f3
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -49,4 +49,4 @@ * Copyright (c) Remix Software Inc. | ||
entryContext.componentDidCatchEmulator.trackBoundaries = false; | ||
entryContext.componentDidCatchEmulator.trackCatchBoundaries = false; | ||
entryContext.appState.trackBoundaries = false; | ||
entryContext.appState.trackCatchBoundaries = false; | ||
return /*#__PURE__*/React__default["default"].createElement(components.RemixEntry, { | ||
@@ -53,0 +53,0 @@ context: entryContext, |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -41,4 +41,4 @@ * Copyright (c) Remix Software Inc. | ||
entryContext.componentDidCatchEmulator.trackBoundaries = false; | ||
entryContext.componentDidCatchEmulator.trackCatchBoundaries = false; | ||
entryContext.appState.trackBoundaries = false; | ||
entryContext.appState.trackCatchBoundaries = false; | ||
return /*#__PURE__*/React__default.createElement(RemixEntry, { | ||
@@ -45,0 +45,0 @@ context: entryContext, |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -13,3 +13,3 @@ * Copyright (c) Remix Software Inc. | ||
import React__default from 'react'; | ||
import { useHref, NavLink as NavLink$1, Link as Link$1, useLocation, useResolvedPath, useNavigate, Router, useRoutes } from 'react-router-dom'; | ||
import { useHref, NavLink as NavLink$1, Link as Link$1, useLocation, useResolvedPath, useNavigate, Outlet as Outlet$1, Router, useRoutes } from 'react-router-dom'; | ||
import { RemixErrorBoundary, RemixRootDefaultErrorBoundary, RemixCatchBoundary, RemixRootDefaultCatchBoundary } from './errorBoundaries.js'; | ||
@@ -23,4 +23,2 @@ import invariant from './invariant.js'; | ||
// RemixEntry | ||
const RemixEntryContext = /*#__PURE__*/React__default.createContext(undefined); | ||
@@ -47,3 +45,3 @@ | ||
serverHandoffString, | ||
componentDidCatchEmulator: entryComponentDidCatchEmulator | ||
appState: entryComponentDidCatchEmulator | ||
} = entryContext; | ||
@@ -113,3 +111,3 @@ let clientRoutes = React__default.useMemo(() => createClientRoutes(manifest.routes, routeModules, RemixRoute), [manifest, routeModules]); | ||
manifest, | ||
componentDidCatchEmulator: clientState, | ||
appState: clientState, | ||
routeModules, | ||
@@ -178,3 +176,3 @@ serverHandoffString, | ||
routeModules, | ||
componentDidCatchEmulator | ||
appState | ||
} = useRemixEntryContext(); | ||
@@ -198,8 +196,8 @@ let data = routeData[id]; | ||
// and pass it to the ErrorBoundary to emulate `componentDidCatch` | ||
let maybeServerCaught = componentDidCatchEmulator.catch && componentDidCatchEmulator.catchBoundaryRouteId === id ? componentDidCatchEmulator.catch : undefined; // This needs to run after we check for the error from a previous render, | ||
let maybeServerCaught = appState.catch && appState.catchBoundaryRouteId === id ? appState.catch : undefined; // This needs to run after we check for the error from a previous render, | ||
// otherwise we will incorrectly render this boundary for a loader error | ||
// deeper in the tree. | ||
if (componentDidCatchEmulator.trackCatchBoundaries) { | ||
componentDidCatchEmulator.catchBoundaryRouteId = id; | ||
if (appState.trackCatchBoundaries) { | ||
appState.catchBoundaryRouteId = id; | ||
} | ||
@@ -242,8 +240,8 @@ | ||
// and pass it to the ErrorBoundary to emulate `componentDidCatch` | ||
let maybeServerRenderError = componentDidCatchEmulator.error && (componentDidCatchEmulator.renderBoundaryRouteId === id || componentDidCatchEmulator.loaderBoundaryRouteId === id) ? deserializeError(componentDidCatchEmulator.error) : undefined; // This needs to run after we check for the error from a previous render, | ||
let maybeServerRenderError = appState.error && (appState.renderBoundaryRouteId === id || appState.loaderBoundaryRouteId === id) ? deserializeError(appState.error) : undefined; // This needs to run after we check for the error from a previous render, | ||
// otherwise we will incorrectly render this boundary for a loader error | ||
// deeper in the tree. | ||
if (componentDidCatchEmulator.trackBoundaries) { | ||
componentDidCatchEmulator.renderBoundaryRouteId = id; | ||
if (appState.trackBoundaries) { | ||
appState.renderBoundaryRouteId = id; | ||
} | ||
@@ -746,7 +744,7 @@ | ||
for (let [name, value] of target) { | ||
formData.set(name, value); | ||
formData.append(name, value); | ||
} | ||
} else if (target != null) { | ||
for (let name of Object.keys(target)) { | ||
formData.set(name, target[name]); | ||
formData.append(name, target[name]); | ||
} | ||
@@ -766,3 +764,3 @@ } | ||
if (typeof value === "string") { | ||
url.searchParams.set(name, value); | ||
url.searchParams.append(name, value); | ||
} else { | ||
@@ -991,2 +989,15 @@ throw new Error(`Cannot submit binary form data using GET`); | ||
export { Form, FormImpl, Link, Links, LiveReload, Meta, NavLink, PrefetchPageLinks, RemixEntry, RemixRoute, Scripts, composeEventHandlers, useActionData, useBeforeUnload, useFetcher, useFetchers, useFormAction, useLoaderData, useMatches, useSubmit, useSubmitImpl, useTransition }; | ||
let OutletContext = /*#__PURE__*/React__default.createContext(null); | ||
function Outlet({ | ||
context | ||
}) { | ||
return /*#__PURE__*/React__default.createElement(OutletContext.Provider, { | ||
value: context | ||
}, /*#__PURE__*/React__default.createElement(Outlet$1, null)); | ||
} | ||
function useOutletContext() { | ||
let context = React__default.useContext(OutletContext); | ||
return context; | ||
} | ||
export { Form, FormImpl, Link, Links, LiveReload, Meta, NavLink, Outlet, PrefetchPageLinks, RemixEntry, RemixRoute, Scripts, composeEventHandlers, useActionData, useBeforeUnload, useFetcher, useFetchers, useFormAction, useLoaderData, useMatches, useOutletContext, useSubmit, useSubmitImpl, useTransition }; |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -59,12 +59,16 @@ * Copyright (c) Remix Software Inc. | ||
} = submission; | ||
let headers = undefined; | ||
let body = formData; | ||
if (encType !== "application/x-www-form-urlencoded") { | ||
throw new Error(`Only "application/x-www-form-urlencoded" forms are supported right now.`); | ||
} | ||
if (encType === "application/x-www-form-urlencoded") { | ||
body = new URLSearchParams(); | ||
let body = new URLSearchParams(); | ||
for (let [key, value] of formData) { | ||
invariant(typeof value === "string", `File inputs are not supported with encType "application/x-www-form-urlencoded", please use "multipart/form-data" instead.`); | ||
body.append(key, value); | ||
} | ||
for (let [key, value] of formData) { | ||
invariant(typeof value === "string", "File inputs are not supported right now"); | ||
body.append(key, value); | ||
headers = { | ||
"Content-Type": encType | ||
}; | ||
} | ||
@@ -74,8 +78,6 @@ | ||
method, | ||
body: body.toString(), | ||
body, | ||
signal, | ||
credentials: "same-origin", | ||
headers: { | ||
"Content-Type": encType | ||
} | ||
headers | ||
}; | ||
@@ -82,0 +84,0 @@ } |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -43,5 +43,12 @@ * Copyright (c) Remix Software Inc. | ||
}; | ||
} | ||
} // If we're not changing locations, preserve the location but still surface | ||
// any new errors that may come through. We retain the existing error, we do | ||
// this because the error provided from the app state may be cleared without | ||
// the location changing. | ||
return state; | ||
return { | ||
error: props.error || state.error, | ||
location: state.location | ||
}; | ||
} | ||
@@ -108,3 +115,3 @@ | ||
/** | ||
* When app's don't provide a root level ErrorBoundary, we default to this. | ||
* When app's don't provide a root level CatchBoundary, we default to this. | ||
*/ | ||
@@ -111,0 +118,0 @@ |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -12,6 +12,6 @@ * Copyright (c) Remix Software Inc. | ||
export { RemixBrowser } from './browser.js'; | ||
export { Outlet, useHref, useLocation, useNavigate, useNavigationType, useOutlet, useParams, useResolvedPath, useSearchParams } from 'react-router-dom'; | ||
export { Form, Link, Links, LiveReload, Meta, NavLink, PrefetchPageLinks, Scripts, useActionData, useBeforeUnload, useFetcher, useFetchers, useFormAction, useLoaderData, useMatches, useSubmit, useTransition } from './components.js'; | ||
export { useHref, useLocation, useNavigate, useNavigationType, useOutlet, useParams, useResolvedPath, useSearchParams } from 'react-router-dom'; | ||
export { Form, Link, Links, LiveReload, Meta, NavLink, Outlet, PrefetchPageLinks, Scripts, useActionData, useBeforeUnload, useFetcher, useFetchers, useFormAction, useLoaderData, useMatches, useOutletContext, useSubmit, useTransition } from './components.js'; | ||
export { useCatch } from './errorBoundaries.js'; | ||
export { ScrollRestoration } from './scroll-restoration.js'; | ||
export { RemixServer } from './server.js'; | ||
export { ScrollRestoration } from './scroll-restoration.js'; |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -95,10 +95,19 @@ * Copyright (c) Remix Software Inc. | ||
})); | ||
return links.flat(1).filter(isHtmlLinkDescriptor).filter(link => link.rel === "stylesheet").map(({ | ||
return links.flat(1).filter(isHtmlLinkDescriptor).filter(link => link.rel === "stylesheet" || link.rel === "preload").map(({ | ||
rel, | ||
...attrs | ||
}) => ({ | ||
rel: "prefetch", | ||
as: "style", | ||
...attrs | ||
})); | ||
}) => { | ||
if (rel === "preload") { | ||
return { | ||
rel: "prefetch", | ||
...attrs | ||
}; | ||
} | ||
return { | ||
rel: "prefetch", | ||
as: "style", | ||
...attrs | ||
}; | ||
}); | ||
} // This is ridiculously identical to transition.ts `filterMatchesToLoad` | ||
@@ -105,0 +114,0 @@ |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -82,4 +82,3 @@ * Copyright (c) Remix Software Inc. | ||
let data = await extractData(result); | ||
return data; | ||
return extractData(result); | ||
} else { | ||
@@ -107,2 +106,5 @@ await loadRouteModuleWithBlockingLinks(route, routeModules); | ||
let redirect = await checkRedirect(result); | ||
if (redirect) return redirect; | ||
if (isCatchResponse(result)) { | ||
@@ -112,4 +114,2 @@ throw new CatchValue(result.status, result.statusText, await extractData(result.clone())); | ||
let redirect = await checkRedirect(result); | ||
if (redirect) return redirect; | ||
return extractData(result); | ||
@@ -116,0 +116,0 @@ }; |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -266,3 +266,3 @@ * Copyright (c) Remix Software Inc. | ||
let hrefToLoad = createHref(state.transition.location || state.location); | ||
let results = await callLoaders(state, createUrl(hrefToLoad), matchesToLoad, controller.signal, maybeActionErrorResult, maybeActionCatchResult, submission, loadFetcher); | ||
let results = await callLoaders(state, createUrl(hrefToLoad), matchesToLoad, controller.signal, maybeActionErrorResult, maybeActionCatchResult, submission, match.route.id, loadFetcher); | ||
@@ -592,3 +592,3 @@ if (controller.signal.aborted) { | ||
}); | ||
await loadPageData(location, matches, submission, result); | ||
await loadPageData(location, matches, submission, leafMatch.route.id, result); | ||
} | ||
@@ -723,3 +723,3 @@ | ||
async function loadPageData(location, matches, submission, actionResult) { | ||
async function loadPageData(location, matches, submission, submissionRouteId, actionResult) { | ||
let maybeActionErrorResult = actionResult && isErrorResult(actionResult) ? actionResult : undefined; | ||
@@ -730,3 +730,3 @@ let maybeActionCatchResult = actionResult && isCatchResult(actionResult) ? actionResult : undefined; | ||
navigationLoadId = ++incrementingLoadId; | ||
let results = await callLoaders(state, createUrl(createHref(location)), matches, controller.signal, maybeActionErrorResult, maybeActionCatchResult, submission); | ||
let results = await callLoaders(state, createUrl(createHref(location)), matches, controller.signal, maybeActionErrorResult, maybeActionCatchResult, submission, submissionRouteId); | ||
@@ -828,4 +828,4 @@ if (controller.signal.aborted) { | ||
async function callLoaders(state, url, matches, signal, actionErrorResult, actionCatchResult, submission, fetcher) { | ||
let matchesToLoad = filterMatchesToLoad(state, url, matches, actionErrorResult, actionCatchResult, submission, fetcher); | ||
async function callLoaders(state, url, matches, signal, actionErrorResult, actionCatchResult, submission, submissionRouteId, fetcher) { | ||
let matchesToLoad = filterMatchesToLoad(state, url, matches, actionErrorResult, actionCatchResult, submission, submissionRouteId, fetcher); | ||
return Promise.all(matchesToLoad.map(match => callLoader(match, url, signal))); | ||
@@ -882,3 +882,21 @@ } | ||
function filterMatchesToLoad(state, url, matches, actionErrorResult, actionCatchResult, submission, fetcher) { | ||
function filterMatchesToLoad(state, url, matches, actionErrorResult, actionCatchResult, submission, submissionRouteId, fetcher) { | ||
// Filter out all routes below the problematic route as they aren't going | ||
// to render so we don't need to load them. | ||
if (submissionRouteId && (actionCatchResult || actionErrorResult)) { | ||
let foundProblematicRoute = false; | ||
matches = matches.filter(match => { | ||
if (foundProblematicRoute) { | ||
return false; | ||
} | ||
if (match.route.id === submissionRouteId) { | ||
foundProblematicRoute = true; | ||
return false; | ||
} | ||
return true; | ||
}); | ||
} | ||
let isNew = (match, index) => { | ||
@@ -885,0 +903,0 @@ // [a] -> [a, b] |
@@ -12,3 +12,2 @@ import type { Action, Location } from "history"; | ||
import type { Transition, Fetcher } from "./transition"; | ||
export { ScrollRestoration } from "./scroll-restoration"; | ||
export declare function RemixEntry({ context: entryContext, action, location: historyLocation, navigator: _navigator, static: staticProp }: { | ||
@@ -206,1 +205,6 @@ context: EntryContext; | ||
}): JSX.Element | null; | ||
export declare function Outlet<ContextData>({ context }: { | ||
context?: ContextData; | ||
}): JSX.Element; | ||
export declare function useOutletContext<ContextData>(): ContextData; | ||
export {}; |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -30,4 +30,2 @@ * Copyright (c) Remix Software Inc. | ||
// RemixEntry | ||
const RemixEntryContext = /*#__PURE__*/React__default["default"].createContext(undefined); | ||
@@ -54,3 +52,3 @@ | ||
serverHandoffString, | ||
componentDidCatchEmulator: entryComponentDidCatchEmulator | ||
appState: entryComponentDidCatchEmulator | ||
} = entryContext; | ||
@@ -120,3 +118,3 @@ let clientRoutes = React__default["default"].useMemo(() => routes.createClientRoutes(manifest.routes, routeModules, RemixRoute), [manifest, routeModules]); | ||
manifest, | ||
componentDidCatchEmulator: clientState, | ||
appState: clientState, | ||
routeModules, | ||
@@ -185,3 +183,3 @@ serverHandoffString, | ||
routeModules, | ||
componentDidCatchEmulator | ||
appState | ||
} = useRemixEntryContext(); | ||
@@ -205,8 +203,8 @@ let data = routeData[id]; | ||
// and pass it to the ErrorBoundary to emulate `componentDidCatch` | ||
let maybeServerCaught = componentDidCatchEmulator.catch && componentDidCatchEmulator.catchBoundaryRouteId === id ? componentDidCatchEmulator.catch : undefined; // This needs to run after we check for the error from a previous render, | ||
let maybeServerCaught = appState.catch && appState.catchBoundaryRouteId === id ? appState.catch : undefined; // This needs to run after we check for the error from a previous render, | ||
// otherwise we will incorrectly render this boundary for a loader error | ||
// deeper in the tree. | ||
if (componentDidCatchEmulator.trackCatchBoundaries) { | ||
componentDidCatchEmulator.catchBoundaryRouteId = id; | ||
if (appState.trackCatchBoundaries) { | ||
appState.catchBoundaryRouteId = id; | ||
} | ||
@@ -249,8 +247,8 @@ | ||
// and pass it to the ErrorBoundary to emulate `componentDidCatch` | ||
let maybeServerRenderError = componentDidCatchEmulator.error && (componentDidCatchEmulator.renderBoundaryRouteId === id || componentDidCatchEmulator.loaderBoundaryRouteId === id) ? deserializeError(componentDidCatchEmulator.error) : undefined; // This needs to run after we check for the error from a previous render, | ||
let maybeServerRenderError = appState.error && (appState.renderBoundaryRouteId === id || appState.loaderBoundaryRouteId === id) ? deserializeError(appState.error) : undefined; // This needs to run after we check for the error from a previous render, | ||
// otherwise we will incorrectly render this boundary for a loader error | ||
// deeper in the tree. | ||
if (componentDidCatchEmulator.trackBoundaries) { | ||
componentDidCatchEmulator.renderBoundaryRouteId = id; | ||
if (appState.trackBoundaries) { | ||
appState.renderBoundaryRouteId = id; | ||
} | ||
@@ -753,7 +751,7 @@ | ||
for (let [name, value] of target) { | ||
formData.set(name, value); | ||
formData.append(name, value); | ||
} | ||
} else if (target != null) { | ||
for (let name of Object.keys(target)) { | ||
formData.set(name, target[name]); | ||
formData.append(name, target[name]); | ||
} | ||
@@ -773,3 +771,3 @@ } | ||
if (typeof value === "string") { | ||
url.searchParams.set(name, value); | ||
url.searchParams.append(name, value); | ||
} else { | ||
@@ -998,2 +996,15 @@ throw new Error(`Cannot submit binary form data using GET`); | ||
let OutletContext = /*#__PURE__*/React__default["default"].createContext(null); | ||
function Outlet({ | ||
context | ||
}) { | ||
return /*#__PURE__*/React__default["default"].createElement(OutletContext.Provider, { | ||
value: context | ||
}, /*#__PURE__*/React__default["default"].createElement(reactRouterDom.Outlet, null)); | ||
} | ||
function useOutletContext() { | ||
let context = React__default["default"].useContext(OutletContext); | ||
return context; | ||
} | ||
exports.Form = Form; | ||
@@ -1006,2 +1017,3 @@ exports.FormImpl = FormImpl; | ||
exports.NavLink = NavLink; | ||
exports.Outlet = Outlet; | ||
exports.PrefetchPageLinks = PrefetchPageLinks; | ||
@@ -1019,4 +1031,5 @@ exports.RemixEntry = RemixEntry; | ||
exports.useMatches = useMatches; | ||
exports.useOutletContext = useOutletContext; | ||
exports.useSubmit = useSubmit; | ||
exports.useSubmitImpl = useSubmitImpl; | ||
exports.useTransition = useTransition; |
26
data.js
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -63,12 +63,16 @@ * Copyright (c) Remix Software Inc. | ||
} = submission; | ||
let headers = undefined; | ||
let body = formData; | ||
if (encType !== "application/x-www-form-urlencoded") { | ||
throw new Error(`Only "application/x-www-form-urlencoded" forms are supported right now.`); | ||
} | ||
if (encType === "application/x-www-form-urlencoded") { | ||
body = new URLSearchParams(); | ||
let body = new URLSearchParams(); | ||
for (let [key, value] of formData) { | ||
invariant(typeof value === "string", `File inputs are not supported with encType "application/x-www-form-urlencoded", please use "multipart/form-data" instead.`); | ||
body.append(key, value); | ||
} | ||
for (let [key, value] of formData) { | ||
invariant(typeof value === "string", "File inputs are not supported right now"); | ||
body.append(key, value); | ||
headers = { | ||
"Content-Type": encType | ||
}; | ||
} | ||
@@ -78,8 +82,6 @@ | ||
method, | ||
body: body.toString(), | ||
body, | ||
signal, | ||
credentials: "same-origin", | ||
headers: { | ||
"Content-Type": encType | ||
} | ||
headers | ||
}; | ||
@@ -86,0 +88,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import type { ComponentDidCatchEmulator } from "./errors"; | ||
import type { AppState } from "./errors"; | ||
import type { RouteManifest, EntryRoute } from "./routes"; | ||
@@ -7,3 +7,3 @@ import type { RouteData } from "./routeData"; | ||
export interface EntryContext { | ||
componentDidCatchEmulator: ComponentDidCatchEmulator; | ||
appState: AppState; | ||
manifest: AssetsManifest; | ||
@@ -10,0 +10,0 @@ matches: RouteMatch<EntryRoute>[]; |
@@ -19,3 +19,6 @@ import type { Location } from "history"; | ||
}; | ||
static getDerivedStateFromProps(props: RemixErrorBoundaryProps, state: RemixErrorBoundaryState): RemixErrorBoundaryState; | ||
static getDerivedStateFromProps(props: RemixErrorBoundaryProps, state: RemixErrorBoundaryState): { | ||
error: Error | null; | ||
location: Location; | ||
}; | ||
render(): React.ReactNode; | ||
@@ -37,5 +40,5 @@ } | ||
/** | ||
* When app's don't provide a root level ErrorBoundary, we default to this. | ||
* When app's don't provide a root level CatchBoundary, we default to this. | ||
*/ | ||
export declare function RemixRootDefaultCatchBoundary(): JSX.Element; | ||
export {}; |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -51,5 +51,12 @@ * Copyright (c) Remix Software Inc. | ||
}; | ||
} | ||
} // If we're not changing locations, preserve the location but still surface | ||
// any new errors that may come through. We retain the existing error, we do | ||
// this because the error provided from the app state may be cleared without | ||
// the location changing. | ||
return state; | ||
return { | ||
error: props.error || state.error, | ||
location: state.location | ||
}; | ||
} | ||
@@ -116,3 +123,3 @@ | ||
/** | ||
* When app's don't provide a root level ErrorBoundary, we default to this. | ||
* When app's don't provide a root level CatchBoundary, we default to this. | ||
*/ | ||
@@ -119,0 +126,0 @@ |
import type { AppData } from "./data"; | ||
export interface ComponentDidCatchEmulator { | ||
export interface AppState { | ||
error?: SerializedError; | ||
@@ -4,0 +4,0 @@ catch?: ThrownResponse; |
export type { RemixBrowserProps } from "./browser"; | ||
export { RemixBrowser } from "./browser"; | ||
export { Outlet, useHref, useLocation, useNavigate, useNavigationType, useOutlet, useParams, useResolvedPath, useSearchParams } from "react-router-dom"; | ||
export { useHref, useLocation, useNavigate, useNavigationType, useOutlet, useParams, useResolvedPath, useSearchParams } from "react-router-dom"; | ||
export type { FormProps, SubmitOptions, SubmitFunction, RemixNavLinkProps as NavLinkProps, RemixLinkProps as LinkProps } from "./components"; | ||
export { Meta, Links, Scripts, Link, NavLink, Form, PrefetchPageLinks, ScrollRestoration, LiveReload, useFormAction, useSubmit, useTransition, useFetcher, useFetchers, useLoaderData, useActionData, useBeforeUnload, useMatches } from "./components"; | ||
export { Meta, Links, Scripts, Link, NavLink, Form, PrefetchPageLinks, LiveReload, useFormAction, useSubmit, useTransition, useFetcher, useFetchers, useLoaderData, useActionData, useBeforeUnload, useMatches, Outlet, useOutletContext } from "./components"; | ||
export type { FormMethod, FormEncType } from "./data"; | ||
@@ -11,3 +11,4 @@ export type { ThrownResponse } from "./errors"; | ||
export type { ShouldReloadFunction, HtmlMetaDescriptor } from "./routeModules"; | ||
export { ScrollRestoration } from "./scroll-restoration"; | ||
export type { RemixServerProps } from "./server"; | ||
export { RemixServer } from "./server"; |
12
index.js
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -19,4 +19,4 @@ * Copyright (c) Remix Software Inc. | ||
var errorBoundaries = require('./errorBoundaries.js'); | ||
var scrollRestoration = require('./scroll-restoration.js'); | ||
var server = require('./server.js'); | ||
var scrollRestoration = require('./scroll-restoration.js'); | ||
@@ -26,6 +26,2 @@ | ||
exports.RemixBrowser = browser.RemixBrowser; | ||
Object.defineProperty(exports, 'Outlet', { | ||
enumerable: true, | ||
get: function () { return reactRouterDom.Outlet; } | ||
}); | ||
Object.defineProperty(exports, 'useHref', { | ||
@@ -69,2 +65,3 @@ enumerable: true, | ||
exports.NavLink = components.NavLink; | ||
exports.Outlet = components.Outlet; | ||
exports.PrefetchPageLinks = components.PrefetchPageLinks; | ||
@@ -79,6 +76,7 @@ exports.Scripts = components.Scripts; | ||
exports.useMatches = components.useMatches; | ||
exports.useOutletContext = components.useOutletContext; | ||
exports.useSubmit = components.useSubmit; | ||
exports.useTransition = components.useTransition; | ||
exports.useCatch = errorBoundaries.useCatch; | ||
exports.ScrollRestoration = scrollRestoration.ScrollRestoration; | ||
exports.RemixServer = server.RemixServer; | ||
exports.ScrollRestoration = scrollRestoration.ScrollRestoration; |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
@@ -129,4 +129,7 @@ import type { Location } from "history"; | ||
imagesizes?: string | undefined; | ||
as: string; | ||
/** | ||
* Potential destination for a preload request (for rel="preload" and rel="modulepreload") | ||
*/ | ||
as?: string | undefined; | ||
/** | ||
* Color to use when customizing a site's icon (for rel="mask-icon") | ||
@@ -133,0 +136,0 @@ */ |
23
links.js
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -99,10 +99,19 @@ * Copyright (c) Remix Software Inc. | ||
})); | ||
return links.flat(1).filter(isHtmlLinkDescriptor).filter(link => link.rel === "stylesheet").map(({ | ||
return links.flat(1).filter(isHtmlLinkDescriptor).filter(link => link.rel === "stylesheet" || link.rel === "preload").map(({ | ||
rel, | ||
...attrs | ||
}) => ({ | ||
rel: "prefetch", | ||
as: "style", | ||
...attrs | ||
})); | ||
}) => { | ||
if (rel === "preload") { | ||
return { | ||
rel: "prefetch", | ||
...attrs | ||
}; | ||
} | ||
return { | ||
rel: "prefetch", | ||
as: "style", | ||
...attrs | ||
}; | ||
}); | ||
} // This is ridiculously identical to transition.ts `filterMatchesToLoad` | ||
@@ -109,0 +118,0 @@ |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -11,2 +11,2 @@ * Copyright (c) Remix Software Inc. | ||
*/ | ||
export { Form, Link, Links, LiveReload, Meta, NavLink, Outlet, PrefetchPageLinks, RemixBrowser, RemixServer, Scripts, ScrollRestoration, useActionData, useBeforeUnload, useCatch, useFetcher, useFetchers, useFormAction, useHref, useLoaderData, useLocation, useMatches, useNavigate, useNavigationType, useOutlet, useParams, useResolvedPath, useSearchParams, useSubmit, useTransition } from '@remix-run/react'; | ||
export { Form, Link, Links, LiveReload, Meta, NavLink, Outlet, PrefetchPageLinks, RemixBrowser, RemixServer, Scripts, ScrollRestoration, useActionData, useBeforeUnload, useCatch, useFetcher, useFetchers, useFormAction, useHref, useLoaderData, useLocation, useMatches, useNavigate, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useSearchParams, useSubmit, useTransition } from '@remix-run/react'; |
export type { RemixBrowserProps, FormProps, SubmitOptions, SubmitFunction, FormMethod, FormEncType, RemixServerProps, ShouldReloadFunction, ThrownResponse, LinkProps, NavLinkProps } from "@remix-run/react"; | ||
export { RemixBrowser, Meta, Links, Scripts, Link, NavLink, Form, PrefetchPageLinks, ScrollRestoration, LiveReload, useFormAction, useSubmit, useTransition, useFetcher, useFetchers, useCatch, useLoaderData, useActionData, useBeforeUnload, useMatches, RemixServer } from "@remix-run/react"; | ||
export { Outlet, useHref, useLocation, useNavigate, useNavigationType, useOutlet, useParams, useResolvedPath, useSearchParams } from "@remix-run/react"; | ||
export { Outlet, useHref, useLocation, useNavigate, useNavigationType, useOutlet, useParams, useResolvedPath, useSearchParams, useOutletContext } from "@remix-run/react"; |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -119,2 +119,6 @@ * Copyright (c) Remix Software Inc. | ||
}); | ||
Object.defineProperty(exports, 'useOutletContext', { | ||
enumerable: true, | ||
get: function () { return react.useOutletContext; } | ||
}); | ||
Object.defineProperty(exports, 'useParams', { | ||
@@ -121,0 +125,0 @@ enumerable: true, |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
{ | ||
"name": "@remix-run/react", | ||
"description": "React DOM bindings for Remix", | ||
"version": "0.0.0-experimental-ab9dac4f", | ||
"version": "0.0.0-experimental-b697c4f3", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "repository": { |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -90,4 +90,3 @@ * Copyright (c) Remix Software Inc. | ||
let data$1 = await data.extractData(result); | ||
return data$1; | ||
return data.extractData(result); | ||
} else { | ||
@@ -115,2 +114,5 @@ await loadRouteModuleWithBlockingLinks(route, routeModules); | ||
let redirect = await checkRedirect(result); | ||
if (redirect) return redirect; | ||
if (data.isCatchResponse(result)) { | ||
@@ -120,4 +122,2 @@ throw new transition.CatchValue(result.status, result.statusText, await data.extractData(result.clone())); | ||
let redirect = await checkRedirect(result); | ||
if (redirect) return redirect; | ||
return data.extractData(result); | ||
@@ -124,0 +124,0 @@ }; |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/react v0.0.0-experimental-ab9dac4f | ||
* @remix-run/react v0.0.0-experimental-b697c4f3 | ||
* | ||
@@ -270,3 +270,3 @@ * Copyright (c) Remix Software Inc. | ||
let hrefToLoad = createHref(state.transition.location || state.location); | ||
let results = await callLoaders(state, createUrl(hrefToLoad), matchesToLoad, controller.signal, maybeActionErrorResult, maybeActionCatchResult, submission, loadFetcher); | ||
let results = await callLoaders(state, createUrl(hrefToLoad), matchesToLoad, controller.signal, maybeActionErrorResult, maybeActionCatchResult, submission, match.route.id, loadFetcher); | ||
@@ -596,3 +596,3 @@ if (controller.signal.aborted) { | ||
}); | ||
await loadPageData(location, matches, submission, result); | ||
await loadPageData(location, matches, submission, leafMatch.route.id, result); | ||
} | ||
@@ -727,3 +727,3 @@ | ||
async function loadPageData(location, matches, submission, actionResult) { | ||
async function loadPageData(location, matches, submission, submissionRouteId, actionResult) { | ||
let maybeActionErrorResult = actionResult && isErrorResult(actionResult) ? actionResult : undefined; | ||
@@ -734,3 +734,3 @@ let maybeActionCatchResult = actionResult && isCatchResult(actionResult) ? actionResult : undefined; | ||
navigationLoadId = ++incrementingLoadId; | ||
let results = await callLoaders(state, createUrl(createHref(location)), matches, controller.signal, maybeActionErrorResult, maybeActionCatchResult, submission); | ||
let results = await callLoaders(state, createUrl(createHref(location)), matches, controller.signal, maybeActionErrorResult, maybeActionCatchResult, submission, submissionRouteId); | ||
@@ -832,4 +832,4 @@ if (controller.signal.aborted) { | ||
async function callLoaders(state, url, matches, signal, actionErrorResult, actionCatchResult, submission, fetcher) { | ||
let matchesToLoad = filterMatchesToLoad(state, url, matches, actionErrorResult, actionCatchResult, submission, fetcher); | ||
async function callLoaders(state, url, matches, signal, actionErrorResult, actionCatchResult, submission, submissionRouteId, fetcher) { | ||
let matchesToLoad = filterMatchesToLoad(state, url, matches, actionErrorResult, actionCatchResult, submission, submissionRouteId, fetcher); | ||
return Promise.all(matchesToLoad.map(match => callLoader(match, url, signal))); | ||
@@ -886,3 +886,21 @@ } | ||
function filterMatchesToLoad(state, url, matches, actionErrorResult, actionCatchResult, submission, fetcher) { | ||
function filterMatchesToLoad(state, url, matches, actionErrorResult, actionCatchResult, submission, submissionRouteId, fetcher) { | ||
// Filter out all routes below the problematic route as they aren't going | ||
// to render so we don't need to load them. | ||
if (submissionRouteId && (actionCatchResult || actionErrorResult)) { | ||
let foundProblematicRoute = false; | ||
matches = matches.filter(match => { | ||
if (foundProblematicRoute) { | ||
return false; | ||
} | ||
if (match.route.id === submissionRouteId) { | ||
foundProblematicRoute = true; | ||
return false; | ||
} | ||
return true; | ||
}); | ||
} | ||
let isNew = (match, index) => { | ||
@@ -889,0 +907,0 @@ // [a] -> [a, b] |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
238655
6696