@payloadcms/tanstack-start 4.0.0-beta.2 → 4.0.0-beta.4

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.
Files changed (88) hide show
  1. package/dist/adapters/handleServerFunctions.d.ts +2 -1
  2. package/dist/adapters/handleServerFunctions.d.ts.map +1 -1
  3. package/dist/adapters/handleServerFunctions.js +12 -4
  4. package/dist/adapters/handleServerFunctions.js.map +1 -1
  5. package/dist/adapters/layout/RootProviders/index.d.ts +9 -0
  6. package/dist/adapters/layout/RootProviders/index.d.ts.map +1 -0
  7. package/dist/adapters/layout/RootProviders/index.js +21 -0
  8. package/dist/adapters/layout/RootProviders/index.js.map +1 -0
  9. package/dist/adapters/layout/index.d.ts +7 -4
  10. package/dist/adapters/layout/index.d.ts.map +1 -1
  11. package/dist/adapters/layout/index.js +3 -1
  12. package/dist/adapters/layout/index.js.map +1 -1
  13. package/dist/adapters/layout/lazy.d.ts +1 -5
  14. package/dist/adapters/layout/lazy.d.ts.map +1 -1
  15. package/dist/adapters/layout/lazy.js +9 -15
  16. package/dist/adapters/layout/lazy.js.map +1 -1
  17. package/dist/adapters/layout/outlet.d.ts +4 -0
  18. package/dist/adapters/layout/outlet.d.ts.map +1 -0
  19. package/dist/adapters/layout/outlet.js +9 -0
  20. package/dist/adapters/layout/outlet.js.map +1 -0
  21. package/dist/adapters/layout/server.d.ts +7 -13
  22. package/dist/adapters/layout/server.d.ts.map +1 -1
  23. package/dist/adapters/layout/server.js +18 -16
  24. package/dist/adapters/layout/server.js.map +1 -1
  25. package/dist/adapters/router.d.ts.map +1 -1
  26. package/dist/adapters/router.js +17 -13
  27. package/dist/adapters/router.js.map +1 -1
  28. package/dist/adapters/views/index.d.ts +5 -2
  29. package/dist/adapters/views/index.d.ts.map +1 -1
  30. package/dist/adapters/views/index.js +29 -8
  31. package/dist/adapters/views/index.js.map +1 -1
  32. package/dist/adapters/views/lazy.d.ts.map +1 -1
  33. package/dist/adapters/views/lazy.js +5 -4
  34. package/dist/adapters/views/lazy.js.map +1 -1
  35. package/dist/adapters/views/server.d.ts +5 -2
  36. package/dist/adapters/views/server.d.ts.map +1 -1
  37. package/dist/adapters/views/server.js +12 -3
  38. package/dist/adapters/views/server.js.map +1 -1
  39. package/dist/auth/login.js.map +1 -1
  40. package/dist/exports/client/layout.d.ts +2 -0
  41. package/dist/exports/client/layout.d.ts.map +1 -0
  42. package/dist/exports/client/layout.js +4 -0
  43. package/dist/exports/client/layout.js.map +1 -0
  44. package/dist/exports/client.d.ts +1 -1
  45. package/dist/exports/client.d.ts.map +1 -1
  46. package/dist/exports/client.js +1 -1
  47. package/dist/exports/client.js.map +1 -1
  48. package/dist/exports/routes.d.ts +2 -0
  49. package/dist/exports/routes.d.ts.map +1 -0
  50. package/dist/exports/routes.js +3 -0
  51. package/dist/exports/routes.js.map +1 -0
  52. package/dist/exports/server.d.ts +0 -3
  53. package/dist/exports/server.d.ts.map +1 -1
  54. package/dist/exports/server.js +0 -3
  55. package/dist/exports/server.js.map +1 -1
  56. package/dist/routes/rest/handler.server.d.ts +1 -0
  57. package/dist/routes/rest/handler.server.d.ts.map +1 -1
  58. package/dist/routes/rest/handler.server.js +1 -0
  59. package/dist/routes/rest/handler.server.js.map +1 -1
  60. package/dist/routes/rest/index.d.ts +4 -3
  61. package/dist/routes/rest/index.d.ts.map +1 -1
  62. package/dist/routes/rest/index.js +4 -3
  63. package/dist/routes/rest/index.js.map +1 -1
  64. package/dist/utilities/devConfigReload.server.js +2 -4
  65. package/dist/utilities/devConfigReload.server.js.map +1 -1
  66. package/dist/utilities/serverFunctionClient.d.ts +2 -23
  67. package/dist/utilities/serverFunctionClient.d.ts.map +1 -1
  68. package/dist/utilities/serverFunctionClient.js +12 -106
  69. package/dist/utilities/serverFunctionClient.js.map +1 -1
  70. package/dist/withPayload/config/external.d.ts +6 -16
  71. package/dist/withPayload/config/external.d.ts.map +1 -1
  72. package/dist/withPayload/config/external.js +18 -26
  73. package/dist/withPayload/config/external.js.map +1 -1
  74. package/dist/withPayload/importProtection.js +1 -1
  75. package/dist/withPayload/importProtection.js.map +1 -1
  76. package/dist/withPayload/index.d.ts +3 -1
  77. package/dist/withPayload/index.d.ts.map +1 -1
  78. package/dist/withPayload/index.js +14 -6
  79. package/dist/withPayload/index.js.map +1 -1
  80. package/package.json +25 -22
  81. package/dist/utilities/serializeForRsc.d.ts +0 -26
  82. package/dist/utilities/serializeForRsc.d.ts.map +0 -1
  83. package/dist/utilities/serializeForRsc.js +0 -127
  84. package/dist/utilities/serializeForRsc.js.map +0 -1
  85. package/dist/utilities/toSerializable.d.ts +0 -11
  86. package/dist/utilities/toSerializable.d.ts.map +0 -1
  87. package/dist/utilities/toSerializable.js +0 -127
  88. package/dist/utilities/toSerializable.js.map +0 -1
package/package.json CHANGED
@@ -1,13 +1,8 @@
1
1
  {
2
2
  "name": "@payloadcms/tanstack-start",
3
- "version": "4.0.0-beta.2",
3
+ "version": "4.0.0-beta.4",
4
4
  "description": "TanStack Start framework adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/payloadcms/payload.git",
9
- "directory": "packages/tanstack-start"
10
- },
11
6
  "license": "MIT",
12
7
  "author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
13
8
  "maintainers": [
@@ -17,7 +12,17 @@
17
12
  "url": "https://payloadcms.com"
18
13
  }
19
14
  ],
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/payloadcms/payload.git",
18
+ "directory": "packages/tanstack-start"
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
20
23
  "type": "module",
24
+ "main": "./dist/index.js",
25
+ "types": "./dist/index.d.ts",
21
26
  "exports": {
22
27
  ".": {
23
28
  "import": "./dist/index.js",
@@ -34,6 +39,11 @@
34
39
  "types": "./dist/exports/server.d.ts",
35
40
  "default": "./dist/exports/server.js"
36
41
  },
42
+ "./routes": {
43
+ "import": "./dist/exports/routes.js",
44
+ "types": "./dist/exports/routes.d.ts",
45
+ "default": "./dist/exports/routes.js"
46
+ },
37
47
  "./shared": {
38
48
  "import": "./dist/exports/shared.js",
39
49
  "types": "./dist/exports/shared.d.ts",
@@ -51,17 +61,12 @@
51
61
  "default": "./dist/exports/rsc.js"
52
62
  }
53
63
  },
54
- "main": "./dist/index.js",
55
- "types": "./dist/index.d.ts",
56
- "files": [
57
- "dist"
58
- ],
59
64
  "dependencies": {
65
+ "@payloadcms/graphql": "4.0.0-beta.4",
66
+ "@payloadcms/translations": "4.0.0-beta.4",
67
+ "@payloadcms/ui": "4.0.0-beta.4",
60
68
  "graphql-http": "1.22.4",
61
- "qs-esm": "^7.0.2",
62
- "@payloadcms/graphql": "4.0.0-beta.2",
63
- "@payloadcms/translations": "4.0.0-beta.2",
64
- "@payloadcms/ui": "4.0.0-beta.2"
69
+ "qs-esm": "^7.0.2"
65
70
  },
66
71
  "devDependencies": {
67
72
  "@tanstack/react-router": "^1.170.44",
@@ -70,10 +75,10 @@
70
75
  "@types/react-dom": "^19.0.0",
71
76
  "@vitejs/plugin-react": "^6.0.0",
72
77
  "@vitejs/plugin-rsc": "^0.5.21",
78
+ "payload": "4.0.0-beta.4",
73
79
  "react": "19.3.1",
74
80
  "react-dom": "19.3.1",
75
- "vite": ">=8.0.0",
76
- "payload": "4.0.0-beta.2"
81
+ "vite": ">=8.0.0"
77
82
  },
78
83
  "peerDependencies": {
79
84
  "@tanstack/react-router": "^1.170.44",
@@ -81,10 +86,10 @@
81
86
  "@vitejs/plugin-react": "^6.0.0",
82
87
  "@vitejs/plugin-rsc": "^0.5.21",
83
88
  "graphql": "^16.8.1",
89
+ "payload": "4.0.0-beta.4",
84
90
  "react": "^19.0.0",
85
91
  "react-dom": "^19.0.0",
86
- "vite": ">=8.0.0",
87
- "payload": "4.0.0-beta.2"
92
+ "vite": ">=8.0.0"
88
93
  },
89
94
  "peerDependenciesMeta": {
90
95
  "@vitejs/plugin-react": {
@@ -98,7 +103,7 @@
98
103
  }
99
104
  },
100
105
  "engines": {
101
- "node": "^18.20.2 || >=20.9.0"
106
+ "node": ">=24.22.1"
102
107
  },
103
108
  "scripts": {
104
109
  "build": "pnpm build:types && pnpm test:types && pnpm build:swc",
@@ -107,8 +112,6 @@
107
112
  "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
108
113
  "build:types": "tsc --emitDeclarationOnly --outDir dist",
109
114
  "clean": "rimraf {dist,*.tsbuildinfo}",
110
- "lint": "eslint .",
111
- "lint:fix": "eslint . --fix",
112
115
  "test:types": "tsc --project test/tsconfig.json"
113
116
  }
114
117
  }
@@ -1,26 +0,0 @@
1
- /**
2
- * Recursively walk a server-function return value and prepare it for transit
3
- * to the client as an RSC payload.
4
- *
5
- * Mirrors `toSerializable`'s walk (Maps, Sets, Dates, typed arrays, circular
6
- * refs) with two key differences:
7
- *
8
- * 1. React elements are NOT stripped. They are passed through
9
- * `renderServerComponent` from `@tanstack/react-start/rsc` to produce a
10
- * "renderable RSC handle". TanStack Start's `$RSC` serialization adapter
11
- * streams the underlying Flight payload to the client, where it is
12
- * decoded back into a renderable React node. This matches the way
13
- * Next.js's RSC payload format ships React elements over server actions
14
- * and lets server-rendered custom field components (e.g. those returned
15
- * by `buildFormState` / `RenderServerComponent`) survive a `form-state`
16
- * round trip.
17
- *
18
- * 2. Functions, Symbols, and RegExps are still stripped — TanStack's seroval
19
- * transport cannot handle them, and Payload doesn't intentionally include
20
- * them in server-function return values.
21
- *
22
- * Use this in `createServerFn` handlers that return Payload form/view state
23
- * containing React elements (e.g. `state[path].customComponents.Field`).
24
- */
25
- export declare function serializeForRsc<T>(value: T): Promise<T>;
26
- //# sourceMappingURL=serializeForRsc.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serializeForRsc.d.ts","sourceRoot":"","sources":["../../src/utilities/serializeForRsc.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAE7D"}
@@ -1,127 +0,0 @@
1
- import { renderServerComponent } from '@tanstack/react-start/rsc';
2
- import { setOwnProperty } from 'payload/shared';
3
- import { createElement, Fragment } from 'react';
4
- /**
5
- * Recursively walk a server-function return value and prepare it for transit
6
- * to the client as an RSC payload.
7
- *
8
- * Mirrors `toSerializable`'s walk (Maps, Sets, Dates, typed arrays, circular
9
- * refs) with two key differences:
10
- *
11
- * 1. React elements are NOT stripped. They are passed through
12
- * `renderServerComponent` from `@tanstack/react-start/rsc` to produce a
13
- * "renderable RSC handle". TanStack Start's `$RSC` serialization adapter
14
- * streams the underlying Flight payload to the client, where it is
15
- * decoded back into a renderable React node. This matches the way
16
- * Next.js's RSC payload format ships React elements over server actions
17
- * and lets server-rendered custom field components (e.g. those returned
18
- * by `buildFormState` / `RenderServerComponent`) survive a `form-state`
19
- * round trip.
20
- *
21
- * 2. Functions, Symbols, and RegExps are still stripped — TanStack's seroval
22
- * transport cannot handle them, and Payload doesn't intentionally include
23
- * them in server-function return values.
24
- *
25
- * Use this in `createServerFn` handlers that return Payload form/view state
26
- * containing React elements (e.g. `state[path].customComponents.Field`).
27
- */ export async function serializeForRsc(value) {
28
- return await walk(value, new WeakMap(), new WeakSet());
29
- }
30
- async function walk(value, cache, ancestors) {
31
- if (value === null || value === undefined) {
32
- return value;
33
- }
34
- const t = typeof value;
35
- if (t === 'function' || t === 'symbol') {
36
- return undefined;
37
- }
38
- if (t !== 'object') {
39
- return value;
40
- }
41
- const obj = value;
42
- if (typeof obj.$$typeof === 'symbol') {
43
- return await renderServerComponent(value);
44
- }
45
- if (ancestors.has(obj)) {
46
- return undefined;
47
- }
48
- if (cache.has(obj)) {
49
- return cache.get(obj);
50
- }
51
- if (obj instanceof Date) {
52
- return obj;
53
- }
54
- if (obj instanceof RegExp) {
55
- return undefined;
56
- }
57
- ancestors.add(obj);
58
- if (obj instanceof Map) {
59
- const cleaned = new Map();
60
- cache.set(obj, cleaned);
61
- for (const [k, v] of obj){
62
- const cv = await walk(v, cache, ancestors);
63
- if (cv !== undefined) {
64
- cleaned.set(k, cv);
65
- }
66
- }
67
- ancestors.delete(obj);
68
- return cleaned;
69
- }
70
- if (obj instanceof Set) {
71
- const cleaned = new Set();
72
- cache.set(obj, cleaned);
73
- for (const v of obj){
74
- const cv = await walk(v, cache, ancestors);
75
- if (cv !== undefined) {
76
- cleaned.add(cv);
77
- }
78
- }
79
- ancestors.delete(obj);
80
- return cleaned;
81
- }
82
- if (Array.isArray(obj)) {
83
- // An array consisting entirely of React elements (e.g. a field's
84
- // `beforeInput` / `afterInput` component list, produced by
85
- // `RenderServerComponent`) must be rendered as a SINGLE RSC handle.
86
- // Converting each element individually below turns every item into its own
87
- // `renderServerComponent` handle, which drops the element's React `key` —
88
- // the client then renders `{[handle, handle]}` as unkeyed array children
89
- // and React warns "Each child in a list should have a unique key prop".
90
- // Payload always renders these component arrays wholesale (`{BeforeInput}`),
91
- // so collapsing them into one Fragment-rendered handle is render-equivalent
92
- // and keeps the per-element keys intact inside the single Flight payload.
93
- const items = obj.filter((item)=>item !== null && item !== undefined);
94
- const isReactElementArray = items.length > 0 && items.every((item)=>typeof item === 'object' && typeof item.$$typeof === 'symbol');
95
- if (isReactElementArray) {
96
- ancestors.delete(obj);
97
- return await renderServerComponent(createElement(Fragment, null, ...obj));
98
- }
99
- const arr = [];
100
- cache.set(obj, arr);
101
- for (const item of obj){
102
- arr.push(await walk(item, cache, ancestors));
103
- }
104
- ancestors.delete(obj);
105
- return arr;
106
- }
107
- if (ArrayBuffer.isView(obj)) {
108
- ancestors.delete(obj);
109
- return obj;
110
- }
111
- const result = {};
112
- cache.set(obj, result);
113
- for (const key of Object.keys(obj)){
114
- const v = await walk(obj[key], cache, ancestors);
115
- if (v !== undefined) {
116
- setOwnProperty({
117
- key,
118
- target: result,
119
- value: v
120
- });
121
- }
122
- }
123
- ancestors.delete(obj);
124
- return result;
125
- }
126
-
127
- //# sourceMappingURL=serializeForRsc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utilities/serializeForRsc.ts"],"sourcesContent":["import type React from 'react'\n\nimport { renderServerComponent } from '@tanstack/react-start/rsc'\nimport { setOwnProperty } from 'payload/shared'\nimport { createElement, Fragment } from 'react'\n\n/**\n * Recursively walk a server-function return value and prepare it for transit\n * to the client as an RSC payload.\n *\n * Mirrors `toSerializable`'s walk (Maps, Sets, Dates, typed arrays, circular\n * refs) with two key differences:\n *\n * 1. React elements are NOT stripped. They are passed through\n * `renderServerComponent` from `@tanstack/react-start/rsc` to produce a\n * \"renderable RSC handle\". TanStack Start's `$RSC` serialization adapter\n * streams the underlying Flight payload to the client, where it is\n * decoded back into a renderable React node. This matches the way\n * Next.js's RSC payload format ships React elements over server actions\n * and lets server-rendered custom field components (e.g. those returned\n * by `buildFormState` / `RenderServerComponent`) survive a `form-state`\n * round trip.\n *\n * 2. Functions, Symbols, and RegExps are still stripped — TanStack's seroval\n * transport cannot handle them, and Payload doesn't intentionally include\n * them in server-function return values.\n *\n * Use this in `createServerFn` handlers that return Payload form/view state\n * containing React elements (e.g. `state[path].customComponents.Field`).\n */\nexport async function serializeForRsc<T>(value: T): Promise<T> {\n return (await walk(value, new WeakMap<object, unknown>(), new WeakSet<object>())) as T\n}\n\nasync function walk(\n value: unknown,\n cache: WeakMap<object, unknown>,\n ancestors: WeakSet<object>,\n): Promise<unknown> {\n if (value === null || value === undefined) {\n return value\n }\n\n const t = typeof value\n if (t === 'function' || t === 'symbol') {\n return undefined\n }\n if (t !== 'object') {\n return value\n }\n\n const obj = value as Record<string, unknown>\n\n if (typeof obj.$$typeof === 'symbol') {\n return await renderServerComponent(value as React.ReactElement)\n }\n\n if (ancestors.has(obj)) {\n return undefined\n }\n\n if (cache.has(obj)) {\n return cache.get(obj)\n }\n\n if (obj instanceof Date) {\n return obj\n }\n\n if (obj instanceof RegExp) {\n return undefined\n }\n\n ancestors.add(obj)\n\n if (obj instanceof Map) {\n const cleaned = new Map()\n cache.set(obj, cleaned)\n for (const [k, v] of obj) {\n const cv = await walk(v, cache, ancestors)\n if (cv !== undefined) {\n cleaned.set(k, cv)\n }\n }\n ancestors.delete(obj)\n return cleaned\n }\n\n if (obj instanceof Set) {\n const cleaned = new Set()\n cache.set(obj, cleaned)\n for (const v of obj) {\n const cv = await walk(v, cache, ancestors)\n if (cv !== undefined) {\n cleaned.add(cv)\n }\n }\n ancestors.delete(obj)\n return cleaned\n }\n\n if (Array.isArray(obj)) {\n // An array consisting entirely of React elements (e.g. a field's\n // `beforeInput` / `afterInput` component list, produced by\n // `RenderServerComponent`) must be rendered as a SINGLE RSC handle.\n // Converting each element individually below turns every item into its own\n // `renderServerComponent` handle, which drops the element's React `key` —\n // the client then renders `{[handle, handle]}` as unkeyed array children\n // and React warns \"Each child in a list should have a unique key prop\".\n // Payload always renders these component arrays wholesale (`{BeforeInput}`),\n // so collapsing them into one Fragment-rendered handle is render-equivalent\n // and keeps the per-element keys intact inside the single Flight payload.\n const items = obj.filter((item) => item !== null && item !== undefined)\n const isReactElementArray =\n items.length > 0 &&\n items.every(\n (item) =>\n typeof item === 'object' && typeof (item as { $$typeof?: unknown }).$$typeof === 'symbol',\n )\n if (isReactElementArray) {\n ancestors.delete(obj)\n return await renderServerComponent(\n createElement(Fragment, null, ...(obj as React.ReactNode[])),\n )\n }\n\n const arr: unknown[] = []\n cache.set(obj, arr)\n for (const item of obj) {\n arr.push(await walk(item, cache, ancestors))\n }\n ancestors.delete(obj)\n return arr\n }\n\n if (ArrayBuffer.isView(obj)) {\n ancestors.delete(obj)\n return obj\n }\n\n const result: Record<string, unknown> = {}\n cache.set(obj, result)\n for (const key of Object.keys(obj)) {\n const v = await walk(obj[key], cache, ancestors)\n if (v !== undefined) {\n setOwnProperty({ key, target: result, value: v })\n }\n }\n ancestors.delete(obj)\n return result\n}\n"],"names":["renderServerComponent","setOwnProperty","createElement","Fragment","serializeForRsc","value","walk","WeakMap","WeakSet","cache","ancestors","undefined","t","obj","$$typeof","has","get","Date","RegExp","add","Map","cleaned","set","k","v","cv","delete","Set","Array","isArray","items","filter","item","isReactElementArray","length","every","arr","push","ArrayBuffer","isView","result","key","Object","keys","target"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,4BAA2B;AACjE,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,SAASC,aAAa,EAAEC,QAAQ,QAAQ,QAAO;AAE/C;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GACD,OAAO,eAAeC,gBAAmBC,KAAQ;IAC/C,OAAQ,MAAMC,KAAKD,OAAO,IAAIE,WAA4B,IAAIC;AAChE;AAEA,eAAeF,KACbD,KAAc,EACdI,KAA+B,EAC/BC,SAA0B;IAE1B,IAAIL,UAAU,QAAQA,UAAUM,WAAW;QACzC,OAAON;IACT;IAEA,MAAMO,IAAI,OAAOP;IACjB,IAAIO,MAAM,cAAcA,MAAM,UAAU;QACtC,OAAOD;IACT;IACA,IAAIC,MAAM,UAAU;QAClB,OAAOP;IACT;IAEA,MAAMQ,MAAMR;IAEZ,IAAI,OAAOQ,IAAIC,QAAQ,KAAK,UAAU;QACpC,OAAO,MAAMd,sBAAsBK;IACrC;IAEA,IAAIK,UAAUK,GAAG,CAACF,MAAM;QACtB,OAAOF;IACT;IAEA,IAAIF,MAAMM,GAAG,CAACF,MAAM;QAClB,OAAOJ,MAAMO,GAAG,CAACH;IACnB;IAEA,IAAIA,eAAeI,MAAM;QACvB,OAAOJ;IACT;IAEA,IAAIA,eAAeK,QAAQ;QACzB,OAAOP;IACT;IAEAD,UAAUS,GAAG,CAACN;IAEd,IAAIA,eAAeO,KAAK;QACtB,MAAMC,UAAU,IAAID;QACpBX,MAAMa,GAAG,CAACT,KAAKQ;QACf,KAAK,MAAM,CAACE,GAAGC,EAAE,IAAIX,IAAK;YACxB,MAAMY,KAAK,MAAMnB,KAAKkB,GAAGf,OAAOC;YAChC,IAAIe,OAAOd,WAAW;gBACpBU,QAAQC,GAA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C,OAAOC,OAAOC,IAAI,CAAC9B,KAAM;QAClC,MAAMW,IAAI,MAAMlB,KAAKO,GAAG,CAAC4B,IAAI,EAAEhC,OAAOC;QACtC,IAAIc,MAAMb,WAAW;YACnBV,eAAe;gBAAEwC;gBAAKG,QAAQJ;gBAAQnC,OAAOmB;YAAE;QACjD;IACF;IACAd,UAAUgB,MAAM,CAACb;IACjB,OAAO2B;AACT"}
@@ -1,11 +0,0 @@
1
- import type { Serializable, SerializableExtensions } from '@tanstack/react-router';
2
- /** A record sanitized for TanStack's server-function transport. */
3
- export type SerializableRecord = Record<string, unknown> & SerializableExtensions['TsrSerializable'];
4
- /**
5
- * Removes values unsupported by TanStack's serializer. Trusted serializable
6
- * additions are merged afterward so opaque handles such as RSC payloads are
7
- * preserved while the source record is sanitized.
8
- */
9
- export declare function toSerializable<T>(value: T): T;
10
- export declare function toSerializable(value: Record<string, unknown>, additions: Record<string, Serializable>): SerializableRecord;
11
- //# sourceMappingURL=toSerializable.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toSerializable.d.ts","sourceRoot":"","sources":["../../src/utilities/toSerializable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAIlF,mEAAmE;AACnE,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,sBAAsB,CAAC,iBAAiB,CAAC,CAAA;AA+HpG;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAA;AAC9C,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GACtC,kBAAkB,CAAA"}
@@ -1,127 +0,0 @@
1
- import { setOwnProperty } from 'payload/shared';
2
- /**
3
- * Recursively strip values that seroval cannot serialize (React elements,
4
- * functions, Symbols) while preserving Maps, Sets, Dates, typed arrays, etc.
5
- *
6
- * TanStack Start uses seroval to transfer server function return values to
7
- * the client. Payload's `getClientConfig` / `getLayoutData` may include
8
- * callback functions or RegExp instances that seroval chokes on. Running
9
- * the data through this function before returning from a `createServerFn`
10
- * handler keeps the transfer safe.
11
- *
12
- * For server functions whose payloads contain React elements (e.g. the
13
- * shared `form-state` / `render-list` / `render-document` handlers), use
14
- * `serializeForRsc` instead — it converts elements into RSC handles rather
15
- * than stripping them.
16
- *
17
- * Uses a WeakMap cache so that shared object references (e.g. the same array
18
- * referenced by both `doc.hasMany` and `formState.hasMany.value`) are
19
- * returned correctly instead of being dropped as "already seen".
20
- *
21
- * A separate `ancestors` WeakSet tracks objects currently being recursed into.
22
- * If an object is encountered while it is still on the recursion stack, the
23
- * reference is circular and is replaced with `undefined` to keep the output
24
- * JSON-safe. Once recursion completes the object is removed from `ancestors`,
25
- * so sibling/cousin references to the same (fully-processed) object still
26
- * resolve to the cached clone.
27
- */ function stripUnserializable(value, cache = new WeakMap(), ancestors = new WeakSet()) {
28
- if (value === null || value === undefined) {
29
- return value;
30
- }
31
- const t = typeof value;
32
- if (t === 'function' || t === 'symbol') {
33
- return undefined;
34
- }
35
- if (t !== 'object') {
36
- return value;
37
- }
38
- const obj = value;
39
- if (typeof obj.$$typeof === 'symbol') {
40
- return undefined;
41
- }
42
- if (ancestors.has(obj)) {
43
- return undefined;
44
- }
45
- if (cache.has(obj)) {
46
- return cache.get(obj);
47
- }
48
- if (obj instanceof Date) {
49
- return obj;
50
- }
51
- // RegExp: seroval's SSR bootstrap emits regex literals with broken escape
52
- // sequences (e.g. `/!\\[.../` instead of `/!\[.../`), crashing the client
53
- // script that populates `window.$_TSR` and preventing hydration. Rich-text
54
- // feature transformer regexes aren't needed on the client (they drive
55
- // server-side markdown import/export), so strip them here.
56
- if (obj instanceof RegExp) {
57
- return undefined;
58
- }
59
- ancestors.add(obj);
60
- if (obj instanceof Map) {
61
- const cleaned = new Map();
62
- cache.set(obj, cleaned);
63
- for (const [k, v] of obj){
64
- const cv = stripUnserializable(v, cache, ancestors);
65
- if (cv !== undefined) {
66
- cleaned.set(k, cv);
67
- }
68
- }
69
- ancestors.delete(obj);
70
- return cleaned;
71
- }
72
- if (obj instanceof Set) {
73
- const cleaned = new Set();
74
- cache.set(obj, cleaned);
75
- for (const v of obj){
76
- const cv = stripUnserializable(v, cache, ancestors);
77
- if (cv !== undefined) {
78
- cleaned.add(cv);
79
- }
80
- }
81
- ancestors.delete(obj);
82
- return cleaned;
83
- }
84
- if (Array.isArray(obj)) {
85
- const arr = [];
86
- cache.set(obj, arr);
87
- for (const item of obj){
88
- arr.push(stripUnserializable(item, cache, ancestors));
89
- }
90
- ancestors.delete(obj);
91
- return arr;
92
- }
93
- if (ArrayBuffer.isView(obj)) {
94
- ancestors.delete(obj);
95
- return obj;
96
- }
97
- const result = {};
98
- cache.set(obj, result);
99
- for (const key of Object.keys(obj)){
100
- const v = stripUnserializable(obj[key], cache, ancestors);
101
- if (v !== undefined) {
102
- setOwnProperty({
103
- key,
104
- target: result,
105
- value: v
106
- });
107
- }
108
- }
109
- ancestors.delete(obj);
110
- return result;
111
- }
112
- export function toSerializable(value, additions) {
113
- const serialized = stripUnserializable(value);
114
- if (additions) {
115
- if (typeof serialized !== 'object' || serialized === null || Array.isArray(serialized)) {
116
- throw new TypeError('Serializable additions require an object source');
117
- }
118
- const result = {
119
- ...serialized,
120
- ...additions
121
- };
122
- return result;
123
- }
124
- return serialized;
125
- }
126
-
127
- //# sourceMappingURL=toSerializable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utilities/toSerializable.ts"],"sourcesContent":["import type { Serializable, SerializableExtensions } from '@tanstack/react-router'\n\nimport { setOwnProperty } from 'payload/shared'\n\n/** A record sanitized for TanStack's server-function transport. */\nexport type SerializableRecord = Record<string, unknown> & SerializableExtensions['TsrSerializable']\n\n/**\n * Recursively strip values that seroval cannot serialize (React elements,\n * functions, Symbols) while preserving Maps, Sets, Dates, typed arrays, etc.\n *\n * TanStack Start uses seroval to transfer server function return values to\n * the client. Payload's `getClientConfig` / `getLayoutData` may include\n * callback functions or RegExp instances that seroval chokes on. Running\n * the data through this function before returning from a `createServerFn`\n * handler keeps the transfer safe.\n *\n * For server functions whose payloads contain React elements (e.g. the\n * shared `form-state` / `render-list` / `render-document` handlers), use\n * `serializeForRsc` instead — it converts elements into RSC handles rather\n * than stripping them.\n *\n * Uses a WeakMap cache so that shared object references (e.g. the same array\n * referenced by both `doc.hasMany` and `formState.hasMany.value`) are\n * returned correctly instead of being dropped as \"already seen\".\n *\n * A separate `ancestors` WeakSet tracks objects currently being recursed into.\n * If an object is encountered while it is still on the recursion stack, the\n * reference is circular and is replaced with `undefined` to keep the output\n * JSON-safe. Once recursion completes the object is removed from `ancestors`,\n * so sibling/cousin references to the same (fully-processed) object still\n * resolve to the cached clone.\n */\nfunction stripUnserializable(\n value: unknown,\n cache = new WeakMap<object, unknown>(),\n ancestors = new WeakSet<object>(),\n): unknown {\n if (value === null || value === undefined) {\n return value\n }\n\n const t = typeof value\n if (t === 'function' || t === 'symbol') {\n return undefined\n }\n if (t !== 'object') {\n return value\n }\n\n const obj = value as Record<string, unknown>\n\n if (typeof obj.$$typeof === 'symbol') {\n return undefined\n }\n\n if (ancestors.has(obj)) {\n return undefined\n }\n\n if (cache.has(obj)) {\n return cache.get(obj)\n }\n\n if (obj instanceof Date) {\n return obj\n }\n\n // RegExp: seroval's SSR bootstrap emits regex literals with broken escape\n // sequences (e.g. `/!\\\\[.../` instead of `/!\\[.../`), crashing the client\n // script that populates `window.$_TSR` and preventing hydration. Rich-text\n // feature transformer regexes aren't needed on the client (they drive\n // server-side markdown import/export), so strip them here.\n if (obj instanceof RegExp) {\n return undefined\n }\n\n ancestors.add(obj)\n\n if (obj instanceof Map) {\n const cleaned = new Map()\n cache.set(obj, cleaned)\n for (const [k, v] of obj) {\n const cv = stripUnserializable(v, cache, ancestors)\n if (cv !== undefined) {\n cleaned.set(k, cv)\n }\n }\n ancestors.delete(obj)\n return cleaned\n }\n\n if (obj instanceof Set) {\n const cleaned = new Set()\n cache.set(obj, cleaned)\n for (const v of obj) {\n const cv = stripUnserializable(v, cache, ancestors)\n if (cv !== undefined) {\n cleaned.add(cv)\n }\n }\n ancestors.delete(obj)\n return cleaned\n }\n\n if (Array.isArray(obj)) {\n const arr: unknown[] = []\n cache.set(obj, arr)\n for (const item of obj) {\n arr.push(stripUnserializable(item, cache, ancestors))\n }\n ancestors.delete(obj)\n return arr\n }\n\n if (ArrayBuffer.isView(obj)) {\n ancestors.delete(obj)\n return obj\n }\n\n const result: Record<string, unknown> = {}\n cache.set(obj, result)\n for (const key of Object.keys(obj)) {\n const v = stripUnserializable(obj[key], cache, ancestors)\n if (v !== undefined) {\n setOwnProperty({ key, target: result, value: v })\n }\n }\n ancestors.delete(obj)\n return result\n}\n\n/**\n * Removes values unsupported by TanStack's serializer. Trusted serializable\n * additions are merged afterward so opaque handles such as RSC payloads are\n * preserved while the source record is sanitized.\n */\nexport function toSerializable<T>(value: T): T\nexport function toSerializable(\n value: Record<string, unknown>,\n additions: Record<string, Serializable>,\n): SerializableRecord\nexport function toSerializable(value: unknown, additions?: Record<string, Serializable>): unknown {\n const serialized = stripUnserializable(value)\n\n if (additions) {\n if (typeof serialized !== 'object' || serialized === null || Array.isArray(serialized)) {\n throw new TypeError('Serializable additions require an object source')\n }\n\n const result = { ...serialized, ...additions } satisfies Record<string, unknown>\n\n return result as SerializableRecord\n }\n\n return serialized\n}\n"],"names":["setOwnProperty","stripUnserializable","value","cache","WeakMap","ancestors","WeakSet","undefined","t","obj","$$typeof","has","get","Date","RegExp","add","Map","cleaned","set","k","v","cv","delete","Set","Array","isArray","arr","item","push","ArrayBuffer","isView","result","key","Object","keys","target","toSerializable","additions","serialized","TypeError"],"mappings":"AAEA,SAASA,cAAc,QAAQ,iBAAgB;AAK/C;;;;;;;;;;;;;;;;;;;;;;;;;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