@payloadcms/tanstack-start 4.0.0-internal.9726517 → 4.0.0-internal.add4c47

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,20 +1,2 @@
1
- import type { ServerFunctionHandler } from 'payload';
2
- /**
3
- * Server function dispatcher for TanStack Start.
4
- *
5
- * Mirrors `packages/next/src/utilities/handleServerFunctions.ts` and uses the
6
- * exact same set of handlers — both adapters share `sharedServerFunctions`
7
- * plus the small set of RSC-only handlers re-exported by `@payloadcms/ui`.
8
- *
9
- * Pipes the result through `serializeForRsc`, which converts any React
10
- * elements left in the response (e.g. `state[path].customComponents.Field`
11
- * produced by `buildFormState`, the `List` / `Document` nodes returned by
12
- * `render-list` / `render-document`) into RSC "renderable handles" via
13
- * `renderServerComponent` from `@tanstack/react-start/rsc`. TanStack Start's
14
- * `$RSC` serialization adapter then ships those handles to the client as
15
- * Flight payloads — so this dispatcher must be invoked from a context that
16
- * uses TanStack's wire format (e.g. `createServerFn`), not raw
17
- * `JSON.stringify`.
18
- */
19
- export declare const handleServerFunctions: ServerFunctionHandler;
1
+ export declare const handleServerFunctions: import("payload").ServerFunctionHandler;
20
2
  //# sourceMappingURL=handleServerFunctions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handleServerFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/handleServerFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA6C,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAwB/F;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,qBAAqB,EAAE,qBAkCnC,CAAA"}
1
+ {"version":3,"file":"handleServerFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/handleServerFunctions.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,qBAAqB,yCAGhC,CAAA"}
@@ -1,60 +1,12 @@
1
- import { renderTabHandler } from '@payloadcms/ui/elements/Nav/SidebarTabs/renderTabServerFn';
2
- import { _internal_renderFieldHandler } from '@payloadcms/ui/rsc';
3
- import { sharedServerFunctions } from '@payloadcms/ui/utilities/serverFunctionRegistry';
4
- import { getDefaultLayoutHandler } from '@payloadcms/ui/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn';
5
- import { renderWidgetHandler } from '@payloadcms/ui/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn';
6
- import { renderDocumentSlotsHandler } from '@payloadcms/ui/views/Document/renderDocumentSlots';
7
- import { RenderRSCComponent } from '../rsc/renderPayloadRSC.js';
1
+ import { createServerFunctionHandler } from '@payloadcms/ui/utilities/handleServerFunctions';
8
2
  import { initReq } from './initReq.server.js';
9
3
  import { serializeForRsc } from './serializeForRsc.js';
10
- import { switchLanguageHandler } from './serverFunctionHandlers.js';
11
- const baseServerFunctions = {
12
- ...sharedServerFunctions,
13
- 'get-default-layout': getDefaultLayoutHandler,
14
- 'render-document-slots': renderDocumentSlotsHandler,
15
- 'render-field': _internal_renderFieldHandler,
16
- 'render-tab': renderTabHandler,
17
- 'render-widget': renderWidgetHandler,
18
- 'switch-language': switchLanguageHandler
19
- };
20
- /**
21
- * Server function dispatcher for TanStack Start.
22
- *
23
- * Mirrors `packages/next/src/utilities/handleServerFunctions.ts` and uses the
24
- * exact same set of handlers — both adapters share `sharedServerFunctions`
25
- * plus the small set of RSC-only handlers re-exported by `@payloadcms/ui`.
26
- *
27
- * Pipes the result through `serializeForRsc`, which converts any React
28
- * elements left in the response (e.g. `state[path].customComponents.Field`
29
- * produced by `buildFormState`, the `List` / `Document` nodes returned by
30
- * `render-list` / `render-document`) into RSC "renderable handles" via
31
- * `renderServerComponent` from `@tanstack/react-start/rsc`. TanStack Start's
32
- * `$RSC` serialization adapter then ships those handles to the client as
33
- * Flight payloads — so this dispatcher must be invoked from a context that
34
- * uses TanStack's wire format (e.g. `createServerFn`), not raw
35
- * `JSON.stringify`.
36
- */ export const handleServerFunctions = async (args)=>{
37
- const { name: fnKey, args: fnArgs, config: configPromise, importMap, serverFunctions: extraServerFunctions } = args;
38
- const { cookies, locale, permissions, req } = await initReq({
39
- configPromise,
40
- importMap
41
- });
42
- const augmentedArgs = {
43
- ...fnArgs,
44
- cookies,
45
- importMap,
46
- locale,
47
- mode: 'rsc',
48
- permissions,
49
- renderComponent: RenderRSCComponent,
50
- req
51
- };
52
- const fn = extraServerFunctions?.[fnKey] || baseServerFunctions[fnKey];
53
- if (!fn) {
54
- throw new Error(`Unknown Server Function: ${fnKey}`);
55
- }
56
- const result = await fn(augmentedArgs);
57
- return await serializeForRsc(result);
58
- };
4
+ export const handleServerFunctions = createServerFunctionHandler({
5
+ initReq: ({ configPromise, importMap })=>initReq({
6
+ configPromise,
7
+ importMap
8
+ }),
9
+ transformResult: serializeForRsc
10
+ });
59
11
 
60
12
  //# sourceMappingURL=handleServerFunctions.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/handleServerFunctions.ts"],"sourcesContent":["import type { DefaultServerFunctionArgs, ServerFunction, ServerFunctionHandler } from 'payload'\n\nimport { renderTabHandler } from '@payloadcms/ui/elements/Nav/SidebarTabs/renderTabServerFn'\nimport { _internal_renderFieldHandler } from '@payloadcms/ui/rsc'\nimport { sharedServerFunctions } from '@payloadcms/ui/utilities/serverFunctionRegistry'\nimport { getDefaultLayoutHandler } from '@payloadcms/ui/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn'\nimport { renderWidgetHandler } from '@payloadcms/ui/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn'\nimport { renderDocumentSlotsHandler } from '@payloadcms/ui/views/Document/renderDocumentSlots'\n\nimport { RenderRSCComponent } from '../rsc/renderPayloadRSC.js'\nimport { initReq } from './initReq.server.js'\nimport { serializeForRsc } from './serializeForRsc.js'\nimport { switchLanguageHandler } from './serverFunctionHandlers.js'\n\nconst baseServerFunctions: Record<string, ServerFunction<any, any>> = {\n ...sharedServerFunctions,\n 'get-default-layout': getDefaultLayoutHandler,\n 'render-document-slots': renderDocumentSlotsHandler,\n 'render-field': _internal_renderFieldHandler,\n 'render-tab': renderTabHandler,\n 'render-widget': renderWidgetHandler,\n 'switch-language': switchLanguageHandler,\n}\n\n/**\n * Server function dispatcher for TanStack Start.\n *\n * Mirrors `packages/next/src/utilities/handleServerFunctions.ts` and uses the\n * exact same set of handlers — both adapters share `sharedServerFunctions`\n * plus the small set of RSC-only handlers re-exported by `@payloadcms/ui`.\n *\n * Pipes the result through `serializeForRsc`, which converts any React\n * elements left in the response (e.g. `state[path].customComponents.Field`\n * produced by `buildFormState`, the `List` / `Document` nodes returned by\n * `render-list` / `render-document`) into RSC \"renderable handles\" via\n * `renderServerComponent` from `@tanstack/react-start/rsc`. TanStack Start's\n * `$RSC` serialization adapter then ships those handles to the client as\n * Flight payloads — so this dispatcher must be invoked from a context that\n * uses TanStack's wire format (e.g. `createServerFn`), not raw\n * `JSON.stringify`.\n */\nexport const handleServerFunctions: ServerFunctionHandler = async (args) => {\n const {\n name: fnKey,\n args: fnArgs,\n config: configPromise,\n importMap,\n serverFunctions: extraServerFunctions,\n } = args\n\n const { cookies, locale, permissions, req } = await initReq({\n configPromise,\n importMap,\n })\n\n const augmentedArgs: DefaultServerFunctionArgs = {\n ...fnArgs,\n cookies,\n importMap,\n locale,\n mode: 'rsc',\n permissions,\n renderComponent: RenderRSCComponent,\n req,\n }\n\n const fn = extraServerFunctions?.[fnKey] || baseServerFunctions[fnKey]\n\n if (!fn) {\n throw new Error(`Unknown Server Function: ${fnKey}`)\n }\n\n const result = await fn(augmentedArgs)\n\n return await serializeForRsc(result)\n}\n"],"names":["renderTabHandler","_internal_renderFieldHandler","sharedServerFunctions","getDefaultLayoutHandler","renderWidgetHandler","renderDocumentSlotsHandler","RenderRSCComponent","initReq","serializeForRsc","switchLanguageHandler","baseServerFunctions","handleServerFunctions","args","name","fnKey","fnArgs","config","configPromise","importMap","serverFunctions","extraServerFunctions","cookies","locale","permissions","req","augmentedArgs","mode","renderComponent","fn","Error","result"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,4DAA2D;AAC5F,SAASC,4BAA4B,QAAQ,qBAAoB;AACjE,SAASC,qBAAqB,QAAQ,kDAAiD;AACvF,SAASC,uBAAuB,QAAQ,gGAA+F;AACvI,SAASC,mBAAmB,QAAQ,4FAA2F;AAC/H,SAASC,0BAA0B,QAAQ,oDAAmD;AAE9F,SAASC,kBAAkB,QAAQ,6BAA4B;AAC/D,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,qBAAqB,QAAQ,8BAA6B;AAEnE,MAAMC,sBAAgE;IACpE,GAAGR,qBAAqB;IACxB,sBAAsBC;IACtB,yBAAyBE;IACzB,gBAAgBJ;IAChB,cAAcD;IACd,iBAAiBI;IACjB,mBAAmBK;AACrB;AAEA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAME,wBAA+C,OAAOC;IACjE,MAAM,EACJC,MAAMC,KAAK,EACXF,MAAMG,MAAM,EACZC,QAAQC,aAAa,EACrBC,SAAS,EACTC,iBAAiBC,oBAAoB,EACtC,GAAGR;IAEJ,MAAM,EAAES,OAAO,EAAEC,MAAM,EAAEC,WAAW,EAAEC,GAAG,EAAE,GAAG,MAAMjB,QAAQ;QAC1DU;QACAC;IACF;IAEA,MAAMO,gBAA2C;QAC/C,GAAGV,MAAM;QACTM;QACAH;QACAI;QACAI,MAAM;QACNH;QACAI,iBAAiBrB;QACjBkB;IACF;IAEA,MAAMI,KAAKR,sBAAsB,CAACN,MAAM,IAAIJ,mBAAmB,CAACI,MAAM;IAEtE,IAAI,CAACc,IAAI;QACP,MAAM,IAAIC,MAAM,CAAC,yBAAyB,EAAEf,OAAO;IACrD;IAEA,MAAMgB,SAAS,MAAMF,GAAGH;IAExB,OAAO,MAAMjB,gBAAgBsB;AAC/B,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/handleServerFunctions.ts"],"sourcesContent":["import { createServerFunctionHandler } from '@payloadcms/ui/utilities/handleServerFunctions'\n\nimport { initReq } from './initReq.server.js'\nimport { serializeForRsc } from './serializeForRsc.js'\n\nexport const handleServerFunctions = createServerFunctionHandler({\n initReq: ({ configPromise, importMap }) => initReq({ configPromise, importMap }),\n transformResult: serializeForRsc,\n})\n"],"names":["createServerFunctionHandler","initReq","serializeForRsc","handleServerFunctions","configPromise","importMap","transformResult"],"mappings":"AAAA,SAASA,2BAA2B,QAAQ,iDAAgD;AAE5F,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,eAAe,QAAQ,uBAAsB;AAEtD,OAAO,MAAMC,wBAAwBH,4BAA4B;IAC/DC,SAAS,CAAC,EAAEG,aAAa,EAAEC,SAAS,EAAE,GAAKJ,QAAQ;YAAEG;YAAeC;QAAU;IAC9EC,iBAAiBJ;AACnB,GAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/tanstack-start",
3
- "version": "4.0.0-internal.9726517",
3
+ "version": "4.0.0-internal.add4c47",
4
4
  "description": "TanStack Start framework adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -58,8 +58,8 @@
58
58
  ],
59
59
  "dependencies": {
60
60
  "qs-esm": "^7.0.2",
61
- "@payloadcms/translations": "4.0.0-internal.9726517",
62
- "@payloadcms/ui": "4.0.0-internal.9726517"
61
+ "@payloadcms/translations": "4.0.0-internal.add4c47",
62
+ "@payloadcms/ui": "4.0.0-internal.add4c47"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@tanstack/react-router": "^1.120.0",
@@ -71,7 +71,7 @@
71
71
  "react": "^19.0.0",
72
72
  "react-dom": "^19.0.0",
73
73
  "vite": ">=8.0.0",
74
- "payload": "4.0.0-internal.9726517"
74
+ "payload": "4.0.0-internal.add4c47"
75
75
  },
76
76
  "peerDependencies": {
77
77
  "@tanstack/react-router": "^1.120.0",
@@ -81,7 +81,7 @@
81
81
  "react": "^19.0.0",
82
82
  "react-dom": "^19.0.0",
83
83
  "vite": ">=8.0.0",
84
- "payload": "4.0.0-internal.9726517"
84
+ "payload": "4.0.0-internal.add4c47"
85
85
  },
86
86
  "peerDependenciesMeta": {
87
87
  "@vitejs/plugin-react": {
@@ -1,18 +0,0 @@
1
- import type { ServerFunction } from 'payload';
2
- /**
3
- * Framework-agnostic server-function handlers the TanStack Start dispatcher
4
- * registers to reach parity with the Next.js adapter
5
- * (`packages/next/src/utilities/handleServerFunctions.ts`).
6
- */
7
- type SwitchLanguageArgs = {
8
- lang: string;
9
- };
10
- /**
11
- * Dispatched from `TranslationProvider` when the user switches the admin
12
- * language. Writes the `<cookiePrefix>-lng` cookie via the request's
13
- * `ServerAdapter` (wired up in `initReq`) so the next render — triggered by
14
- * the provider's `router.refresh()` — reads the new language.
15
- */
16
- export declare const switchLanguageHandler: ServerFunction<SwitchLanguageArgs, Promise<void>>;
17
- export {};
18
- //# sourceMappingURL=serverFunctionHandlers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serverFunctionHandlers.d.ts","sourceRoot":"","sources":["../../src/utilities/serverFunctionHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C;;;;GAIG;AAEH,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,cAAc,CAAC,kBAAkB,EAAE,OAAO,CAAC,IAAI,CAAC,CAcnF,CAAA"}
@@ -1,17 +0,0 @@
1
- /**
2
- * Dispatched from `TranslationProvider` when the user switches the admin
3
- * language. Writes the `<cookiePrefix>-lng` cookie via the request's
4
- * `ServerAdapter` (wired up in `initReq`) so the next render — triggered by
5
- * the provider's `router.refresh()` — reads the new language.
6
- */ export const switchLanguageHandler = async ({ lang, req })=>{
7
- if (!req.server) {
8
- throw new Error('switch-language requires a ServerAdapter on the request');
9
- }
10
- const cookieName = `${req.payload.config.cookiePrefix || 'payload'}-lng`;
11
- await req.server.setCookie(cookieName, lang, {
12
- maxAge: 60 * 60 * 24 * 365,
13
- path: '/'
14
- });
15
- };
16
-
17
- //# sourceMappingURL=serverFunctionHandlers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utilities/serverFunctionHandlers.ts"],"sourcesContent":["import type { ServerFunction } from 'payload'\n\n/**\n * Framework-agnostic server-function handlers the TanStack Start dispatcher\n * registers to reach parity with the Next.js adapter\n * (`packages/next/src/utilities/handleServerFunctions.ts`).\n */\n\ntype SwitchLanguageArgs = {\n lang: string\n}\n\n/**\n * Dispatched from `TranslationProvider` when the user switches the admin\n * language. Writes the `<cookiePrefix>-lng` cookie via the request's\n * `ServerAdapter` (wired up in `initReq`) so the next render — triggered by\n * the provider's `router.refresh()` — reads the new language.\n */\nexport const switchLanguageHandler: ServerFunction<SwitchLanguageArgs, Promise<void>> = async ({\n lang,\n req,\n}) => {\n if (!req.server) {\n throw new Error('switch-language requires a ServerAdapter on the request')\n }\n\n const cookieName = `${req.payload.config.cookiePrefix || 'payload'}-lng`\n\n await req.server.setCookie(cookieName, lang, {\n maxAge: 60 * 60 * 24 * 365,\n path: '/',\n })\n}\n"],"names":["switchLanguageHandler","lang","req","server","Error","cookieName","payload","config","cookiePrefix","setCookie","maxAge","path"],"mappings":"AAYA;;;;;CAKC,GACD,OAAO,MAAMA,wBAA2E,OAAO,EAC7FC,IAAI,EACJC,GAAG,EACJ;IACC,IAAI,CAACA,IAAIC,MAAM,EAAE;QACf,MAAM,IAAIC,MAAM;IAClB;IAEA,MAAMC,aAAa,GAAGH,IAAII,OAAO,CAACC,MAAM,CAACC,YAAY,IAAI,UAAU,IAAI,CAAC;IAExE,MAAMN,IAAIC,MAAM,CAACM,SAAS,CAACJ,YAAYJ,MAAM;QAC3CS,QAAQ,KAAK,KAAK,KAAK;QACvBC,MAAM;IACR;AACF,EAAC"}