@remix-run/router 0.0.0-experimental-e1311612e → 0.0.0-experimental-cffa549a1

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,5 +1,5 @@
1
1
  export type { ActionFunction, ActionFunctionArgs, AgnosticDataIndexRouteObject, AgnosticDataNonIndexRouteObject, AgnosticDataRouteMatch, AgnosticDataRouteObject, AgnosticIndexRouteObject, AgnosticNonIndexRouteObject, AgnosticRouteMatch, AgnosticRouteObject, DataStrategyFunction as unstable_DataStrategyFunction, DataStrategyFunctionArgs as unstable_DataStrategyFunctionArgs, DataStrategyMatch as unstable_DataStrategyMatch, ErrorResponse, FormEncType, FormMethod, HandlerResult as unstable_HandlerResult, HTMLFormMethod, JsonFunction, LazyRouteFunction, LoaderFunction, LoaderFunctionArgs, ParamParseKey, Params, AgnosticPatchRoutesOnMissFunction as unstable_AgnosticPatchRoutesOnMissFunction, PathMatch, PathParam, PathPattern, RedirectFunction, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, TrackedPromise, UIMatch, V7_FormMethod, } from "./utils";
2
- export { AbortedDeferredError, defer, generatePath, getToPathname, isRouteErrorResponse, joinPaths, json, matchPath, matchRoutes, normalizePathname, redirect, redirectDocument, resolvePath, resolveTo, stripBasename, } from "./utils";
2
+ export { AbortedDeferredError, defer, generatePath, getToPathname, isRouteErrorResponse, joinPaths, json, matchPath, matchRoutes, normalizePathname, redirect, redirectDocument, replace, resolvePath, resolveTo, stripBasename, } from "./utils";
3
3
  export type { BrowserHistory, BrowserHistoryOptions, HashHistory, HashHistoryOptions, History, InitialEntry, Location, MemoryHistory, MemoryHistoryOptions, Path, To, } from "./history";
4
4
  export { Action, createBrowserHistory, createHashHistory, createMemoryHistory, createPath, parsePath, } from "./history";
5
5
  export * from "./router";
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @remix-run/router v0.0.0-experimental-e1311612e
2
+ * @remix-run/router v0.0.0-experimental-cffa549a1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1509,6 +1509,18 @@ const redirectDocument = (url, init) => {
1509
1509
  response.headers.set("X-Remix-Reload-Document", "true");
1510
1510
  return response;
1511
1511
  };
1512
+
1513
+ /**
1514
+ * A redirect response that will perform a `history.replaceState` instead of a
1515
+ * `history.pushState` for client-side navigation redirects.
1516
+ * Sets the status code and the `Location` header.
1517
+ * Defaults to "302 Found".
1518
+ */
1519
+ const replace = (url, init) => {
1520
+ let response = redirect(url, init);
1521
+ response.headers.set("X-Remix-Replace", "true");
1522
+ return response;
1523
+ };
1512
1524
  /**
1513
1525
  * @private
1514
1526
  * Utility class we use to hold auto-unwrapped 4xx/5xx Response bodies
@@ -3141,7 +3153,7 @@ function createRouter(init) {
3141
3153
  // There's no need to abort on redirects, since we don't detect the
3142
3154
  // redirect until the action/loaders have settled
3143
3155
  pendingNavigationController = null;
3144
- let redirectHistoryAction = replace === true ? Action.Replace : Action.Push;
3156
+ let redirectHistoryAction = replace === true || redirect.response.headers.has("X-Remix-Replace") ? Action.Replace : Action.Push;
3145
3157
 
3146
3158
  // Use the incoming submission if provided, fallback on the active one in
3147
3159
  // state.navigation
@@ -5434,6 +5446,7 @@ exports.normalizePathname = normalizePathname;
5434
5446
  exports.parsePath = parsePath;
5435
5447
  exports.redirect = redirect;
5436
5448
  exports.redirectDocument = redirectDocument;
5449
+ exports.replace = replace;
5437
5450
  exports.resolvePath = resolvePath;
5438
5451
  exports.resolveTo = resolveTo;
5439
5452
  exports.stripBasename = stripBasename;