docs-i18n 0.7.3 → 0.7.5

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.
@@ -0,0 +1,51 @@
1
+ //#region ../../node_modules/.bun/@tanstack+router-core@1.168.2/node_modules/@tanstack/router-core/dist/esm/redirect.js
2
+ /**
3
+ * Create a redirect Response understood by TanStack Router.
4
+ *
5
+ * Use from route `loader`/`beforeLoad` or server functions to trigger a
6
+ * navigation. If `throw: true` is set, the redirect is thrown instead of
7
+ * returned. When an absolute `href` is supplied and `reloadDocument` is not
8
+ * set, a full-document navigation is inferred.
9
+ *
10
+ * @param opts Options for the redirect. Common fields:
11
+ * - `href`: absolute URL for external redirects; infers `reloadDocument`.
12
+ * - `statusCode`: HTTP status code to use (defaults to 307).
13
+ * - `headers`: additional headers to include on the Response.
14
+ * - Standard navigation options like `to`, `params`, `search`, `replace`,
15
+ * and `reloadDocument` for internal redirects.
16
+ * @returns A Response augmented with router navigation options.
17
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/redirectFunction
18
+ */
19
+ function redirect(opts) {
20
+ opts.statusCode = opts.statusCode || opts.code || 307;
21
+ if (!opts._builtLocation && !opts.reloadDocument && typeof opts.href === "string") try {
22
+ new URL(opts.href);
23
+ opts.reloadDocument = true;
24
+ } catch {}
25
+ const headers = new Headers(opts.headers);
26
+ if (opts.href && headers.get("Location") === null) headers.set("Location", opts.href);
27
+ const response = new Response(null, {
28
+ status: opts.statusCode,
29
+ headers
30
+ });
31
+ response.options = opts;
32
+ if (opts.throw) throw response;
33
+ return response;
34
+ }
35
+ /** Check whether a value is a TanStack Router redirect Response. */
36
+ /** Check whether a value is a TanStack Router redirect Response. */
37
+ function isRedirect(obj) {
38
+ return obj instanceof Response && !!obj.options;
39
+ }
40
+ /** True if value is a redirect with a resolved `href` location. */
41
+ /** True if value is a redirect with a resolved `href` location. */
42
+ function isResolvedRedirect(obj) {
43
+ return isRedirect(obj) && !!obj.options.href;
44
+ }
45
+ /** Parse a serialized redirect object back into a redirect Response. */
46
+ /** Parse a serialized redirect object back into a redirect Response. */
47
+ function parseRedirect(obj) {
48
+ if (obj !== null && typeof obj === "object" && obj.isSerializedRedirect) return redirect(obj);
49
+ }
50
+ //#endregion
51
+ export { redirect as i, isResolvedRedirect as n, parseRedirect as r, isRedirect as t };