@tanstack/react-start-client 1.127.3 → 1.127.7

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.
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const react = require("react");
3
+ const React = require("react");
4
4
  const invariant = require("tiny-invariant");
5
5
  function renderRsc(input) {
6
- if (react.isValidElement(input)) {
6
+ if (React.isValidElement(input)) {
7
7
  return input;
8
8
  }
9
9
  if (typeof input === "object" && !input.state) {
@@ -1,24 +1,45 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const React = require("react");
3
4
  const routerCore = require("@tanstack/router-core");
4
5
  const reactRouter = require("@tanstack/react-router");
6
+ function _interopNamespaceDefault(e) {
7
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
8
+ if (e) {
9
+ for (const k in e) {
10
+ if (k !== "default") {
11
+ const d = Object.getOwnPropertyDescriptor(e, k);
12
+ Object.defineProperty(n, k, d.get ? d : {
13
+ enumerable: true,
14
+ get: () => e[k]
15
+ });
16
+ }
17
+ }
18
+ }
19
+ n.default = e;
20
+ return Object.freeze(n);
21
+ }
22
+ const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
5
23
  function useServerFn(serverFn) {
6
24
  const router = reactRouter.useRouter();
7
- return async (...args) => {
8
- try {
9
- const res = await serverFn(...args);
10
- if (routerCore.isRedirect(res)) {
11
- throw res;
25
+ return React__namespace.useCallback(
26
+ async (...args) => {
27
+ try {
28
+ const res = await serverFn(...args);
29
+ if (routerCore.isRedirect(res)) {
30
+ throw res;
31
+ }
32
+ return res;
33
+ } catch (err) {
34
+ if (routerCore.isRedirect(err)) {
35
+ err.options._fromLocation = router.state.location;
36
+ return router.navigate(router.resolveRedirect(err).options);
37
+ }
38
+ throw err;
12
39
  }
13
- return res;
14
- } catch (err) {
15
- if (routerCore.isRedirect(err)) {
16
- err.options._fromLocation = router.state.location;
17
- return router.navigate(router.resolveRedirect(err).options);
18
- }
19
- throw err;
20
- }
21
- };
40
+ },
41
+ [router, serverFn]
42
+ );
22
43
  }
23
44
  exports.useServerFn = useServerFn;
24
45
  //# sourceMappingURL=useServerFn.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useServerFn.cjs","sources":["../../src/useServerFn.ts"],"sourcesContent":["import { isRedirect } from '@tanstack/router-core'\nimport { useRouter } from '@tanstack/react-router'\n\nexport function useServerFn<T extends (...deps: Array<any>) => Promise<any>>(\n serverFn: T,\n): (...args: Parameters<T>) => ReturnType<T> {\n const router = useRouter()\n\n return (async (...args: Array<any>) => {\n try {\n const res = await serverFn(...args)\n\n if (isRedirect(res)) {\n throw res\n }\n\n return res\n } catch (err) {\n if (isRedirect(err)) {\n err.options._fromLocation = router.state.location\n return router.navigate(router.resolveRedirect(err).options)\n }\n\n throw err\n }\n }) as any\n}\n"],"names":["useRouter","isRedirect"],"mappings":";;;;AAGO,SAAS,YACd,UAC2C;AAC3C,QAAM,SAASA,YAAAA,UAAU;AAEzB,SAAQ,UAAU,SAAqB;AACjC,QAAA;AACF,YAAM,MAAM,MAAM,SAAS,GAAG,IAAI;AAE9B,UAAAC,WAAAA,WAAW,GAAG,GAAG;AACb,cAAA;AAAA,MAAA;AAGD,aAAA;AAAA,aACA,KAAK;AACR,UAAAA,WAAAA,WAAW,GAAG,GAAG;AACf,YAAA,QAAQ,gBAAgB,OAAO,MAAM;AACzC,eAAO,OAAO,SAAS,OAAO,gBAAgB,GAAG,EAAE,OAAO;AAAA,MAAA;AAGtD,YAAA;AAAA,IAAA;AAAA,EAEV;AACF;;"}
1
+ {"version":3,"file":"useServerFn.cjs","sources":["../../src/useServerFn.ts"],"sourcesContent":["import * as React from 'react'\nimport { isRedirect } from '@tanstack/router-core'\nimport { useRouter } from '@tanstack/react-router'\n\nexport function useServerFn<T extends (...deps: Array<any>) => Promise<any>>(\n serverFn: T,\n): (...args: Parameters<T>) => ReturnType<T> {\n const router = useRouter()\n\n return React.useCallback(\n async (...args: Array<any>) => {\n try {\n const res = await serverFn(...args)\n\n if (isRedirect(res)) {\n throw res\n }\n\n return res\n } catch (err) {\n if (isRedirect(err)) {\n err.options._fromLocation = router.state.location\n return router.navigate(router.resolveRedirect(err).options)\n }\n\n throw err\n }\n },\n [router, serverFn],\n ) as any\n}\n"],"names":["useRouter","React","isRedirect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,YACd,UAC2C;AAC3C,QAAM,SAASA,YAAAA,UAAU;AAEzB,SAAOC,iBAAM;AAAA,IACX,UAAU,SAAqB;AACzB,UAAA;AACF,cAAM,MAAM,MAAM,SAAS,GAAG,IAAI;AAE9B,YAAAC,WAAAA,WAAW,GAAG,GAAG;AACb,gBAAA;AAAA,QAAA;AAGD,eAAA;AAAA,eACA,KAAK;AACR,YAAAA,WAAAA,WAAW,GAAG,GAAG;AACf,cAAA,QAAQ,gBAAgB,OAAO,MAAM;AACzC,iBAAO,OAAO,SAAS,OAAO,gBAAgB,GAAG,EAAE,OAAO;AAAA,QAAA;AAGtD,cAAA;AAAA,MAAA;AAAA,IAEV;AAAA,IACA,CAAC,QAAQ,QAAQ;AAAA,EACnB;AACF;;"}
@@ -1,22 +1,26 @@
1
+ import * as React from "react";
1
2
  import { isRedirect } from "@tanstack/router-core";
2
3
  import { useRouter } from "@tanstack/react-router";
3
4
  function useServerFn(serverFn) {
4
5
  const router = useRouter();
5
- return async (...args) => {
6
- try {
7
- const res = await serverFn(...args);
8
- if (isRedirect(res)) {
9
- throw res;
6
+ return React.useCallback(
7
+ async (...args) => {
8
+ try {
9
+ const res = await serverFn(...args);
10
+ if (isRedirect(res)) {
11
+ throw res;
12
+ }
13
+ return res;
14
+ } catch (err) {
15
+ if (isRedirect(err)) {
16
+ err.options._fromLocation = router.state.location;
17
+ return router.navigate(router.resolveRedirect(err).options);
18
+ }
19
+ throw err;
10
20
  }
11
- return res;
12
- } catch (err) {
13
- if (isRedirect(err)) {
14
- err.options._fromLocation = router.state.location;
15
- return router.navigate(router.resolveRedirect(err).options);
16
- }
17
- throw err;
18
- }
19
- };
21
+ },
22
+ [router, serverFn]
23
+ );
20
24
  }
21
25
  export {
22
26
  useServerFn
@@ -1 +1 @@
1
- {"version":3,"file":"useServerFn.js","sources":["../../src/useServerFn.ts"],"sourcesContent":["import { isRedirect } from '@tanstack/router-core'\nimport { useRouter } from '@tanstack/react-router'\n\nexport function useServerFn<T extends (...deps: Array<any>) => Promise<any>>(\n serverFn: T,\n): (...args: Parameters<T>) => ReturnType<T> {\n const router = useRouter()\n\n return (async (...args: Array<any>) => {\n try {\n const res = await serverFn(...args)\n\n if (isRedirect(res)) {\n throw res\n }\n\n return res\n } catch (err) {\n if (isRedirect(err)) {\n err.options._fromLocation = router.state.location\n return router.navigate(router.resolveRedirect(err).options)\n }\n\n throw err\n }\n }) as any\n}\n"],"names":[],"mappings":";;AAGO,SAAS,YACd,UAC2C;AAC3C,QAAM,SAAS,UAAU;AAEzB,SAAQ,UAAU,SAAqB;AACjC,QAAA;AACF,YAAM,MAAM,MAAM,SAAS,GAAG,IAAI;AAE9B,UAAA,WAAW,GAAG,GAAG;AACb,cAAA;AAAA,MAAA;AAGD,aAAA;AAAA,aACA,KAAK;AACR,UAAA,WAAW,GAAG,GAAG;AACf,YAAA,QAAQ,gBAAgB,OAAO,MAAM;AACzC,eAAO,OAAO,SAAS,OAAO,gBAAgB,GAAG,EAAE,OAAO;AAAA,MAAA;AAGtD,YAAA;AAAA,IAAA;AAAA,EAEV;AACF;"}
1
+ {"version":3,"file":"useServerFn.js","sources":["../../src/useServerFn.ts"],"sourcesContent":["import * as React from 'react'\nimport { isRedirect } from '@tanstack/router-core'\nimport { useRouter } from '@tanstack/react-router'\n\nexport function useServerFn<T extends (...deps: Array<any>) => Promise<any>>(\n serverFn: T,\n): (...args: Parameters<T>) => ReturnType<T> {\n const router = useRouter()\n\n return React.useCallback(\n async (...args: Array<any>) => {\n try {\n const res = await serverFn(...args)\n\n if (isRedirect(res)) {\n throw res\n }\n\n return res\n } catch (err) {\n if (isRedirect(err)) {\n err.options._fromLocation = router.state.location\n return router.navigate(router.resolveRedirect(err).options)\n }\n\n throw err\n }\n },\n [router, serverFn],\n ) as any\n}\n"],"names":[],"mappings":";;;AAIO,SAAS,YACd,UAC2C;AAC3C,QAAM,SAAS,UAAU;AAEzB,SAAO,MAAM;AAAA,IACX,UAAU,SAAqB;AACzB,UAAA;AACF,cAAM,MAAM,MAAM,SAAS,GAAG,IAAI;AAE9B,YAAA,WAAW,GAAG,GAAG;AACb,gBAAA;AAAA,QAAA;AAGD,eAAA;AAAA,eACA,KAAK;AACR,YAAA,WAAW,GAAG,GAAG;AACf,cAAA,QAAQ,gBAAgB,OAAO,MAAM;AACzC,iBAAO,OAAO,SAAS,OAAO,gBAAgB,GAAG,EAAE,OAAO;AAAA,QAAA;AAGtD,cAAA;AAAA,MAAA;AAAA,IAEV;AAAA,IACA,CAAC,QAAQ,QAAQ;AAAA,EACnB;AACF;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-start-client",
3
- "version": "1.127.3",
3
+ "version": "1.127.7",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -1,3 +1,4 @@
1
+ import * as React from 'react'
1
2
  import { isRedirect } from '@tanstack/router-core'
2
3
  import { useRouter } from '@tanstack/react-router'
3
4
 
@@ -6,22 +7,25 @@ export function useServerFn<T extends (...deps: Array<any>) => Promise<any>>(
6
7
  ): (...args: Parameters<T>) => ReturnType<T> {
7
8
  const router = useRouter()
8
9
 
9
- return (async (...args: Array<any>) => {
10
- try {
11
- const res = await serverFn(...args)
10
+ return React.useCallback(
11
+ async (...args: Array<any>) => {
12
+ try {
13
+ const res = await serverFn(...args)
12
14
 
13
- if (isRedirect(res)) {
14
- throw res
15
- }
15
+ if (isRedirect(res)) {
16
+ throw res
17
+ }
16
18
 
17
- return res
18
- } catch (err) {
19
- if (isRedirect(err)) {
20
- err.options._fromLocation = router.state.location
21
- return router.navigate(router.resolveRedirect(err).options)
22
- }
19
+ return res
20
+ } catch (err) {
21
+ if (isRedirect(err)) {
22
+ err.options._fromLocation = router.state.location
23
+ return router.navigate(router.resolveRedirect(err).options)
24
+ }
23
25
 
24
- throw err
25
- }
26
- }) as any
26
+ throw err
27
+ }
28
+ },
29
+ [router, serverFn],
30
+ ) as any
27
31
  }