@tanstack/start-server-core 1.147.3 → 1.149.1
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/esm/createServerRpc.d.ts +4 -3
- package/dist/esm/createServerRpc.js +4 -2
- package/dist/esm/createServerRpc.js.map +1 -1
- package/dist/esm/createSsrRpc.d.ts +2 -2
- package/dist/esm/createSsrRpc.js +2 -1
- package/dist/esm/createSsrRpc.js.map +1 -1
- package/dist/esm/serializer/ServerFunctionSerializationAdapter.d.ts +3 -1
- package/dist/esm/serializer/ServerFunctionSerializationAdapter.js +2 -3
- package/dist/esm/serializer/ServerFunctionSerializationAdapter.js.map +1 -1
- package/package.json +4 -4
- package/src/createServerRpc.ts +6 -2
- package/src/createSsrRpc.ts +4 -1
- package/src/serializer/ServerFunctionSerializationAdapter.ts +3 -4
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { TSS_SERVER_FUNCTION } from '@tanstack/start-client-core';
|
|
2
|
-
export declare const createServerRpc: (
|
|
3
|
-
|
|
1
|
+
import { TSS_SERVER_FUNCTION, ServerFnMeta } from '@tanstack/start-client-core';
|
|
2
|
+
export declare const createServerRpc: (serverFnMeta: ServerFnMeta, splitImportFn: (...args: any) => any) => ((...args: any) => any) & {
|
|
3
|
+
url: string;
|
|
4
|
+
serverFnMeta: ServerFnMeta;
|
|
4
5
|
[TSS_SERVER_FUNCTION]: boolean;
|
|
5
6
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { TSS_SERVER_FUNCTION } from "@tanstack/start-client-core";
|
|
2
|
-
const createServerRpc = (
|
|
2
|
+
const createServerRpc = (serverFnMeta, splitImportFn) => {
|
|
3
|
+
const url = process.env.TSS_SERVER_FN_BASE + serverFnMeta.id;
|
|
3
4
|
return Object.assign(splitImportFn, {
|
|
4
|
-
|
|
5
|
+
url,
|
|
6
|
+
serverFnMeta,
|
|
5
7
|
[TSS_SERVER_FUNCTION]: true
|
|
6
8
|
});
|
|
7
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createServerRpc.js","sources":["../../src/createServerRpc.ts"],"sourcesContent":["import { TSS_SERVER_FUNCTION } from '@tanstack/start-client-core'\n\nexport const createServerRpc = (\n
|
|
1
|
+
{"version":3,"file":"createServerRpc.js","sources":["../../src/createServerRpc.ts"],"sourcesContent":["import { TSS_SERVER_FUNCTION } from '@tanstack/start-client-core'\nimport type { ServerFnMeta } from '@tanstack/start-client-core'\n\nexport const createServerRpc = (\n serverFnMeta: ServerFnMeta,\n splitImportFn: (...args: any) => any,\n) => {\n const url = process.env.TSS_SERVER_FN_BASE + serverFnMeta.id\n\n return Object.assign(splitImportFn, {\n url,\n serverFnMeta,\n [TSS_SERVER_FUNCTION]: true,\n })\n}\n"],"names":[],"mappings":";AAGO,MAAM,kBAAkB,CAC7B,cACA,kBACG;AACH,QAAM,MAAM,QAAQ,IAAI,qBAAqB,aAAa;AAE1D,SAAO,OAAO,OAAO,eAAe;AAAA,IAClC;AAAA,IACA;AAAA,IACA,CAAC,mBAAmB,GAAG;AAAA,EAAA,CACxB;AACH;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { TSS_SERVER_FUNCTION } from '@tanstack/start-client-core';
|
|
1
|
+
import { TSS_SERVER_FUNCTION, ClientFnMeta } from '@tanstack/start-client-core';
|
|
2
2
|
import { ServerFn } from '#tanstack-start-server-fn-resolver';
|
|
3
3
|
export type SsrRpcImporter = () => Promise<ServerFn>;
|
|
4
4
|
export declare const createSsrRpc: (functionId: string, importer?: SsrRpcImporter) => ((...args: Array<any>) => Promise<any>) & {
|
|
5
5
|
url: string;
|
|
6
|
-
|
|
6
|
+
serverFnMeta: ClientFnMeta;
|
|
7
7
|
[TSS_SERVER_FUNCTION]: boolean;
|
|
8
8
|
};
|
package/dist/esm/createSsrRpc.js
CHANGED
|
@@ -2,13 +2,14 @@ import { TSS_SERVER_FUNCTION } from "@tanstack/start-client-core";
|
|
|
2
2
|
import { getServerFnById } from "#tanstack-start-server-fn-resolver";
|
|
3
3
|
const createSsrRpc = (functionId, importer) => {
|
|
4
4
|
const url = process.env.TSS_SERVER_FN_BASE + functionId;
|
|
5
|
+
const serverFnMeta = { id: functionId };
|
|
5
6
|
const fn = async (...args) => {
|
|
6
7
|
const serverFn = importer ? await importer() : await getServerFnById(functionId);
|
|
7
8
|
return serverFn(...args);
|
|
8
9
|
};
|
|
9
10
|
return Object.assign(fn, {
|
|
10
11
|
url,
|
|
11
|
-
|
|
12
|
+
serverFnMeta,
|
|
12
13
|
[TSS_SERVER_FUNCTION]: true
|
|
13
14
|
});
|
|
14
15
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSsrRpc.js","sources":["../../src/createSsrRpc.ts"],"sourcesContent":["import { TSS_SERVER_FUNCTION } from '@tanstack/start-client-core'\nimport { getServerFnById } from './getServerFnById'\nimport type { ServerFn } from '#tanstack-start-server-fn-resolver'\n\nexport type SsrRpcImporter = () => Promise<ServerFn>\n\nexport const createSsrRpc = (functionId: string, importer?: SsrRpcImporter) => {\n const url = process.env.TSS_SERVER_FN_BASE + functionId\n const fn = async (...args: Array<any>): Promise<any> => {\n // If an importer is provided, use it directly (server-to-server call within the SSR environment)\n // Otherwise, fall back to manifest lookup (client-to-server call, server functions that are only referenced on the server or if the provider environment is not SSR)\n const serverFn = importer\n ? await importer()\n : await getServerFnById(functionId)\n return serverFn(...args)\n }\n\n return Object.assign(fn, {\n url,\n
|
|
1
|
+
{"version":3,"file":"createSsrRpc.js","sources":["../../src/createSsrRpc.ts"],"sourcesContent":["import { TSS_SERVER_FUNCTION } from '@tanstack/start-client-core'\nimport { getServerFnById } from './getServerFnById'\nimport type { ClientFnMeta } from '@tanstack/start-client-core'\nimport type { ServerFn } from '#tanstack-start-server-fn-resolver'\n\nexport type SsrRpcImporter = () => Promise<ServerFn>\n\nexport const createSsrRpc = (functionId: string, importer?: SsrRpcImporter) => {\n const url = process.env.TSS_SERVER_FN_BASE + functionId\n const serverFnMeta: ClientFnMeta = { id: functionId }\n\n const fn = async (...args: Array<any>): Promise<any> => {\n // If an importer is provided, use it directly (server-to-server call within the SSR environment)\n // Otherwise, fall back to manifest lookup (client-to-server call, server functions that are only referenced on the server or if the provider environment is not SSR)\n const serverFn = importer\n ? await importer()\n : await getServerFnById(functionId)\n return serverFn(...args)\n }\n\n return Object.assign(fn, {\n url,\n serverFnMeta,\n [TSS_SERVER_FUNCTION]: true,\n })\n}\n"],"names":[],"mappings":";;AAOO,MAAM,eAAe,CAAC,YAAoB,aAA8B;AAC7E,QAAM,MAAM,QAAQ,IAAI,qBAAqB;AAC7C,QAAM,eAA6B,EAAE,IAAI,WAAA;AAEzC,QAAM,KAAK,UAAU,SAAmC;AAGtD,UAAM,WAAW,WACb,MAAM,aACN,MAAM,gBAAgB,UAAU;AACpC,WAAO,SAAS,GAAG,IAAI;AAAA,EACzB;AAEA,SAAO,OAAO,OAAO,IAAI;AAAA,IACvB;AAAA,IACA;AAAA,IACA,CAAC,mBAAmB,GAAG;AAAA,EAAA,CACxB;AACH;"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createSerializationAdapter } from "@tanstack/router-core";
|
|
2
2
|
import { TSS_SERVER_FUNCTION } from "@tanstack/start-client-core";
|
|
3
|
-
import { createServerRpc } from "../createServerRpc.js";
|
|
4
3
|
import { getServerFnById } from "#tanstack-start-server-fn-resolver";
|
|
5
4
|
const ServerFunctionSerializationAdapter = createSerializationAdapter({
|
|
6
5
|
key: "$TSS/serverfn",
|
|
@@ -9,14 +8,14 @@ const ServerFunctionSerializationAdapter = createSerializationAdapter({
|
|
|
9
8
|
if (!(TSS_SERVER_FUNCTION in v)) return false;
|
|
10
9
|
return !!v[TSS_SERVER_FUNCTION];
|
|
11
10
|
},
|
|
12
|
-
toSerializable: ({
|
|
11
|
+
toSerializable: ({ serverFnMeta }) => ({ functionId: serverFnMeta.id }),
|
|
13
12
|
fromSerializable: ({ functionId }) => {
|
|
14
13
|
const fn = async (opts, signal) => {
|
|
15
14
|
const serverFn = await getServerFnById(functionId, { fromClient: true });
|
|
16
15
|
const result = await serverFn(opts ?? {}, signal);
|
|
17
16
|
return result.result;
|
|
18
17
|
};
|
|
19
|
-
return
|
|
18
|
+
return fn;
|
|
20
19
|
}
|
|
21
20
|
});
|
|
22
21
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServerFunctionSerializationAdapter.js","sources":["../../../src/serializer/ServerFunctionSerializationAdapter.ts"],"sourcesContent":["import { createSerializationAdapter } from '@tanstack/router-core'\nimport { TSS_SERVER_FUNCTION } from '@tanstack/start-client-core'\nimport {
|
|
1
|
+
{"version":3,"file":"ServerFunctionSerializationAdapter.js","sources":["../../../src/serializer/ServerFunctionSerializationAdapter.ts"],"sourcesContent":["import { createSerializationAdapter } from '@tanstack/router-core'\nimport { TSS_SERVER_FUNCTION } from '@tanstack/start-client-core'\nimport { getServerFnById } from '../getServerFnById'\n\nexport const ServerFunctionSerializationAdapter = createSerializationAdapter({\n key: '$TSS/serverfn',\n test: (v): v is { serverFnMeta: { id: string } } => {\n if (typeof v !== 'function') return false\n\n if (!(TSS_SERVER_FUNCTION in v)) return false\n\n return !!v[TSS_SERVER_FUNCTION]\n },\n toSerializable: ({ serverFnMeta }) => ({ functionId: serverFnMeta.id }),\n fromSerializable: ({ functionId }) => {\n const fn = async (opts: any, signal: any): Promise<any> => {\n // When a function ID is received through serialization (e.g., as a parameter\n // to another server function), it originates from the client and must be\n // validated the same way as direct HTTP calls to server functions.\n const serverFn = await getServerFnById(functionId, { fromClient: true })\n const result = await serverFn(opts ?? {}, signal)\n return result.result\n }\n return fn as never\n },\n})\n"],"names":[],"mappings":";;;AAIO,MAAM,qCAAqC,2BAA2B;AAAA,EAC3E,KAAK;AAAA,EACL,MAAM,CAAC,MAA6C;AAClD,QAAI,OAAO,MAAM,WAAY,QAAO;AAEpC,QAAI,EAAE,uBAAuB,GAAI,QAAO;AAExC,WAAO,CAAC,CAAC,EAAE,mBAAmB;AAAA,EAChC;AAAA,EACA,gBAAgB,CAAC,EAAE,aAAA,OAAoB,EAAE,YAAY,aAAa;EAClE,kBAAkB,CAAC,EAAE,iBAAiB;AACpC,UAAM,KAAK,OAAO,MAAW,WAA8B;AAIzD,YAAM,WAAW,MAAM,gBAAgB,YAAY,EAAE,YAAY,MAAM;AACvE,YAAM,SAAS,MAAM,SAAS,QAAQ,CAAA,GAAI,MAAM;AAChD,aAAO,OAAO;AAAA,IAChB;AACA,WAAO;AAAA,EACT;AACF,CAAC;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/start-server-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.149.1",
|
|
4
4
|
"description": "Modern and scalable routing for React applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
"seroval": "^1.4.1",
|
|
65
65
|
"tiny-invariant": "^1.3.3",
|
|
66
66
|
"@tanstack/history": "1.145.7",
|
|
67
|
-
"@tanstack/
|
|
68
|
-
"@tanstack/start-
|
|
69
|
-
"@tanstack/
|
|
67
|
+
"@tanstack/router-core": "1.147.1",
|
|
68
|
+
"@tanstack/start-client-core": "1.149.1",
|
|
69
|
+
"@tanstack/start-storage-context": "1.147.1"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@standard-schema/spec": "^1.0.0",
|
package/src/createServerRpc.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { TSS_SERVER_FUNCTION } from '@tanstack/start-client-core'
|
|
2
|
+
import type { ServerFnMeta } from '@tanstack/start-client-core'
|
|
2
3
|
|
|
3
4
|
export const createServerRpc = (
|
|
4
|
-
|
|
5
|
+
serverFnMeta: ServerFnMeta,
|
|
5
6
|
splitImportFn: (...args: any) => any,
|
|
6
7
|
) => {
|
|
8
|
+
const url = process.env.TSS_SERVER_FN_BASE + serverFnMeta.id
|
|
9
|
+
|
|
7
10
|
return Object.assign(splitImportFn, {
|
|
8
|
-
|
|
11
|
+
url,
|
|
12
|
+
serverFnMeta,
|
|
9
13
|
[TSS_SERVER_FUNCTION]: true,
|
|
10
14
|
})
|
|
11
15
|
}
|
package/src/createSsrRpc.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { TSS_SERVER_FUNCTION } from '@tanstack/start-client-core'
|
|
2
2
|
import { getServerFnById } from './getServerFnById'
|
|
3
|
+
import type { ClientFnMeta } from '@tanstack/start-client-core'
|
|
3
4
|
import type { ServerFn } from '#tanstack-start-server-fn-resolver'
|
|
4
5
|
|
|
5
6
|
export type SsrRpcImporter = () => Promise<ServerFn>
|
|
6
7
|
|
|
7
8
|
export const createSsrRpc = (functionId: string, importer?: SsrRpcImporter) => {
|
|
8
9
|
const url = process.env.TSS_SERVER_FN_BASE + functionId
|
|
10
|
+
const serverFnMeta: ClientFnMeta = { id: functionId }
|
|
11
|
+
|
|
9
12
|
const fn = async (...args: Array<any>): Promise<any> => {
|
|
10
13
|
// If an importer is provided, use it directly (server-to-server call within the SSR environment)
|
|
11
14
|
// Otherwise, fall back to manifest lookup (client-to-server call, server functions that are only referenced on the server or if the provider environment is not SSR)
|
|
@@ -17,7 +20,7 @@ export const createSsrRpc = (functionId: string, importer?: SsrRpcImporter) => {
|
|
|
17
20
|
|
|
18
21
|
return Object.assign(fn, {
|
|
19
22
|
url,
|
|
20
|
-
|
|
23
|
+
serverFnMeta,
|
|
21
24
|
[TSS_SERVER_FUNCTION]: true,
|
|
22
25
|
})
|
|
23
26
|
}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { createSerializationAdapter } from '@tanstack/router-core'
|
|
2
2
|
import { TSS_SERVER_FUNCTION } from '@tanstack/start-client-core'
|
|
3
|
-
import { createServerRpc } from '../createServerRpc'
|
|
4
3
|
import { getServerFnById } from '../getServerFnById'
|
|
5
4
|
|
|
6
5
|
export const ServerFunctionSerializationAdapter = createSerializationAdapter({
|
|
7
6
|
key: '$TSS/serverfn',
|
|
8
|
-
test: (v): v is {
|
|
7
|
+
test: (v): v is { serverFnMeta: { id: string } } => {
|
|
9
8
|
if (typeof v !== 'function') return false
|
|
10
9
|
|
|
11
10
|
if (!(TSS_SERVER_FUNCTION in v)) return false
|
|
12
11
|
|
|
13
12
|
return !!v[TSS_SERVER_FUNCTION]
|
|
14
13
|
},
|
|
15
|
-
toSerializable: ({
|
|
14
|
+
toSerializable: ({ serverFnMeta }) => ({ functionId: serverFnMeta.id }),
|
|
16
15
|
fromSerializable: ({ functionId }) => {
|
|
17
16
|
const fn = async (opts: any, signal: any): Promise<any> => {
|
|
18
17
|
// When a function ID is received through serialization (e.g., as a parameter
|
|
@@ -22,6 +21,6 @@ export const ServerFunctionSerializationAdapter = createSerializationAdapter({
|
|
|
22
21
|
const result = await serverFn(opts ?? {}, signal)
|
|
23
22
|
return result.result
|
|
24
23
|
}
|
|
25
|
-
return
|
|
24
|
+
return fn as never
|
|
26
25
|
},
|
|
27
26
|
})
|