@bleedingdev/modern-js-plugin-tanstack 3.5.0-ultramodern.30 → 3.5.0-ultramodern.32

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 (221) hide show
  1. package/dist/cjs/cli/artifacts.js +157 -0
  2. package/dist/cjs/cli/index.js +6 -103
  3. package/dist/cjs/cli/tanstackTypes/canonicalRoutes.js +113 -0
  4. package/dist/cjs/cli/tanstackTypes/shared.js +130 -0
  5. package/dist/cjs/cli/tanstackTypes/source.js +251 -0
  6. package/dist/cjs/cli/tanstackTypes.js +4 -350
  7. package/dist/cjs/runtime/blockingSubscribe.js +64 -0
  8. package/dist/cjs/runtime/{pluginCore.js → clientBasepath.js} +12 -19
  9. package/dist/cjs/runtime/clientHydration.js +129 -0
  10. package/dist/cjs/runtime/dataMutation.js +11 -176
  11. package/dist/cjs/runtime/formData.js +116 -0
  12. package/dist/cjs/runtime/loaderBridge.js +4 -1
  13. package/dist/cjs/runtime/plugin.js +21 -125
  14. package/dist/cjs/runtime/plugin.node.js +38 -119
  15. package/dist/cjs/runtime/pluginShared.js +90 -0
  16. package/dist/cjs/runtime/routeTree/components.js +102 -0
  17. package/dist/cjs/runtime/routeTree/construction.js +152 -0
  18. package/dist/cjs/runtime/routeTree/index.js +47 -0
  19. package/dist/cjs/runtime/routeTree/loaders.js +158 -0
  20. package/dist/cjs/runtime/routeTree/paths.js +57 -0
  21. package/dist/cjs/runtime/routeTree/staticData.js +63 -0
  22. package/dist/cjs/runtime/routeTree/tanstackRoutes.js +57 -0
  23. package/dist/cjs/runtime/routeTree/types.js +18 -0
  24. package/dist/cjs/runtime/routeTree.js +7 -320
  25. package/dist/cjs/runtime/rsc/CompositeComponent.js +18 -13
  26. package/dist/cjs/runtime/rsc/RscNodeRenderer.js +5 -16
  27. package/dist/cjs/runtime/rsc/client.js +8 -25
  28. package/dist/cjs/runtime/rsc/flightSerialization.js +132 -0
  29. package/dist/cjs/runtime/rsc/payloadErrors.js +99 -0
  30. package/dist/cjs/runtime/rsc/payloadFetch.js +117 -0
  31. package/dist/cjs/runtime/rsc/payloadRouter.js +21 -142
  32. package/dist/cjs/runtime/rsc/payloadRoutes.js +106 -0
  33. package/dist/cjs/runtime/rsc/payloadStorage.js +58 -0
  34. package/dist/cjs/runtime/rsc/server.js +14 -18
  35. package/dist/cjs/runtime/rsc/shared.js +71 -0
  36. package/dist/cjs/runtime/rsc/treeGetter.js +72 -0
  37. package/dist/cjs/runtime/ssrManagedTags.js +103 -0
  38. package/dist/cjs/runtime/ssrPreload.js +89 -0
  39. package/dist/cjs/runtime/ssrTypes.js +18 -0
  40. package/dist/cjs/runtime/submitAction.js +161 -0
  41. package/dist/cjs/runtime/utils.js +49 -86
  42. package/dist/esm/cli/artifacts.mjs +103 -0
  43. package/dist/esm/cli/index.mjs +4 -101
  44. package/dist/esm/cli/tanstackTypes/canonicalRoutes.mjs +75 -0
  45. package/dist/esm/cli/tanstackTypes/shared.mjs +68 -0
  46. package/dist/esm/cli/tanstackTypes/source.mjs +203 -0
  47. package/dist/esm/cli/tanstackTypes.mjs +2 -339
  48. package/dist/esm/runtime/blockingSubscribe.mjs +19 -0
  49. package/dist/esm/runtime/clientBasepath.mjs +10 -0
  50. package/dist/esm/runtime/clientHydration.mjs +70 -0
  51. package/dist/esm/runtime/dataMutation.mjs +2 -167
  52. package/dist/esm/runtime/formData.mjs +63 -0
  53. package/dist/esm/runtime/loaderBridge.mjs +4 -1
  54. package/dist/esm/runtime/plugin.mjs +14 -118
  55. package/dist/esm/runtime/plugin.node.mjs +33 -114
  56. package/dist/esm/runtime/pluginShared.mjs +40 -0
  57. package/dist/esm/runtime/routeTree/components.mjs +55 -0
  58. package/dist/esm/runtime/routeTree/construction.mjs +111 -0
  59. package/dist/esm/runtime/routeTree/index.mjs +2 -0
  60. package/dist/esm/runtime/routeTree/loaders.mjs +117 -0
  61. package/dist/esm/runtime/routeTree/paths.mjs +16 -0
  62. package/dist/esm/runtime/routeTree/staticData.mjs +22 -0
  63. package/dist/esm/runtime/routeTree/tanstackRoutes.mjs +13 -0
  64. package/dist/esm/runtime/routeTree/types.mjs +0 -0
  65. package/dist/esm/runtime/routeTree.mjs +1 -318
  66. package/dist/esm/runtime/rsc/CompositeComponent.mjs +18 -13
  67. package/dist/esm/runtime/rsc/RscNodeRenderer.mjs +4 -15
  68. package/dist/esm/runtime/rsc/client.mjs +6 -26
  69. package/dist/esm/runtime/rsc/flightSerialization.mjs +88 -0
  70. package/dist/esm/runtime/rsc/payloadErrors.mjs +49 -0
  71. package/dist/esm/runtime/rsc/payloadFetch.mjs +61 -0
  72. package/dist/esm/runtime/rsc/payloadRouter.mjs +12 -133
  73. package/dist/esm/runtime/rsc/payloadRoutes.mjs +50 -0
  74. package/dist/esm/runtime/rsc/payloadStorage.mjs +14 -0
  75. package/dist/esm/runtime/rsc/server.mjs +17 -21
  76. package/dist/esm/runtime/rsc/shared.mjs +21 -0
  77. package/dist/esm/runtime/rsc/treeGetter.mjs +34 -0
  78. package/dist/esm/runtime/ssrManagedTags.mjs +53 -0
  79. package/dist/esm/runtime/ssrPreload.mjs +51 -0
  80. package/dist/esm/runtime/ssrTypes.mjs +0 -0
  81. package/dist/esm/runtime/submitAction.mjs +120 -0
  82. package/dist/esm/runtime/utils.mjs +47 -75
  83. package/dist/esm-node/cli/artifacts.mjs +104 -0
  84. package/dist/esm-node/cli/index.mjs +4 -101
  85. package/dist/esm-node/cli/tanstackTypes/canonicalRoutes.mjs +76 -0
  86. package/dist/esm-node/cli/tanstackTypes/shared.mjs +69 -0
  87. package/dist/esm-node/cli/tanstackTypes/source.mjs +204 -0
  88. package/dist/esm-node/cli/tanstackTypes.mjs +2 -339
  89. package/dist/esm-node/runtime/blockingSubscribe.mjs +20 -0
  90. package/dist/esm-node/runtime/clientBasepath.mjs +11 -0
  91. package/dist/esm-node/runtime/clientHydration.mjs +71 -0
  92. package/dist/esm-node/runtime/dataMutation.mjs +2 -167
  93. package/dist/esm-node/runtime/formData.mjs +64 -0
  94. package/dist/esm-node/runtime/loaderBridge.mjs +4 -1
  95. package/dist/esm-node/runtime/plugin.mjs +14 -118
  96. package/dist/esm-node/runtime/plugin.node.mjs +33 -114
  97. package/dist/esm-node/runtime/pluginShared.mjs +41 -0
  98. package/dist/esm-node/runtime/routeTree/components.mjs +56 -0
  99. package/dist/esm-node/runtime/routeTree/construction.mjs +112 -0
  100. package/dist/esm-node/runtime/routeTree/index.mjs +3 -0
  101. package/dist/esm-node/runtime/routeTree/loaders.mjs +118 -0
  102. package/dist/esm-node/runtime/routeTree/paths.mjs +17 -0
  103. package/dist/esm-node/runtime/routeTree/staticData.mjs +23 -0
  104. package/dist/esm-node/runtime/routeTree/tanstackRoutes.mjs +14 -0
  105. package/dist/esm-node/runtime/routeTree/types.mjs +1 -0
  106. package/dist/esm-node/runtime/routeTree.mjs +1 -318
  107. package/dist/esm-node/runtime/rsc/CompositeComponent.mjs +18 -13
  108. package/dist/esm-node/runtime/rsc/RscNodeRenderer.mjs +4 -15
  109. package/dist/esm-node/runtime/rsc/client.mjs +6 -26
  110. package/dist/esm-node/runtime/rsc/flightSerialization.mjs +89 -0
  111. package/dist/esm-node/runtime/rsc/payloadErrors.mjs +50 -0
  112. package/dist/esm-node/runtime/rsc/payloadFetch.mjs +62 -0
  113. package/dist/esm-node/runtime/rsc/payloadRouter.mjs +12 -133
  114. package/dist/esm-node/runtime/rsc/payloadRoutes.mjs +51 -0
  115. package/dist/esm-node/runtime/rsc/payloadStorage.mjs +15 -0
  116. package/dist/esm-node/runtime/rsc/server.mjs +17 -21
  117. package/dist/esm-node/runtime/rsc/shared.mjs +22 -0
  118. package/dist/esm-node/runtime/rsc/treeGetter.mjs +35 -0
  119. package/dist/esm-node/runtime/ssrManagedTags.mjs +54 -0
  120. package/dist/esm-node/runtime/ssrPreload.mjs +52 -0
  121. package/dist/esm-node/runtime/ssrTypes.mjs +1 -0
  122. package/dist/esm-node/runtime/submitAction.mjs +121 -0
  123. package/dist/esm-node/runtime/utils.mjs +47 -75
  124. package/dist/types/cli/artifacts.d.ts +33 -0
  125. package/dist/types/cli/index.d.ts +2 -33
  126. package/dist/types/cli/tanstackTypes/canonicalRoutes.d.ts +22 -0
  127. package/dist/types/cli/tanstackTypes/shared.d.ts +20 -0
  128. package/dist/types/cli/tanstackTypes/source.d.ts +10 -0
  129. package/dist/types/cli/tanstackTypes.d.ts +3 -31
  130. package/dist/types/runtime/blockingSubscribe.d.ts +3 -0
  131. package/dist/types/runtime/clientBasepath.d.ts +1 -0
  132. package/dist/types/runtime/clientHydration.d.ts +19 -0
  133. package/dist/types/runtime/dataMutation.d.ts +3 -12
  134. package/dist/types/runtime/formData.d.ts +23 -0
  135. package/dist/types/runtime/plugin.d.ts +1 -1
  136. package/dist/types/runtime/plugin.node.d.ts +1 -1
  137. package/dist/types/runtime/{pluginCore.d.ts → pluginShared.d.ts} +14 -0
  138. package/dist/types/runtime/routeTree/components.d.ts +7 -0
  139. package/dist/types/runtime/routeTree/construction.d.ts +5 -0
  140. package/dist/types/runtime/routeTree/index.d.ts +2 -0
  141. package/dist/types/runtime/routeTree/loaders.d.ts +4 -0
  142. package/dist/types/runtime/routeTree/paths.d.ts +3 -0
  143. package/dist/types/runtime/routeTree/staticData.d.ts +19 -0
  144. package/dist/types/runtime/routeTree/tanstackRoutes.d.ts +4 -0
  145. package/dist/types/runtime/routeTree/types.d.ts +75 -0
  146. package/dist/types/runtime/routeTree.d.ts +1 -9
  147. package/dist/types/runtime/rsc/CompositeComponent.d.ts +1 -2
  148. package/dist/types/runtime/rsc/RscNodeRenderer.d.ts +2 -3
  149. package/dist/types/runtime/rsc/client.d.ts +2 -0
  150. package/dist/types/runtime/rsc/flightSerialization.d.ts +3 -0
  151. package/dist/types/runtime/rsc/payloadErrors.d.ts +6 -0
  152. package/dist/types/runtime/rsc/payloadFetch.d.ts +10 -0
  153. package/dist/types/runtime/rsc/payloadRouter.d.ts +2 -10
  154. package/dist/types/runtime/rsc/payloadRoutes.d.ts +43 -0
  155. package/dist/types/runtime/rsc/payloadStorage.d.ts +5 -0
  156. package/dist/types/runtime/rsc/shared.d.ts +19 -0
  157. package/dist/types/runtime/rsc/treeGetter.d.ts +1 -0
  158. package/dist/types/runtime/ssrManagedTags.d.ts +7 -0
  159. package/dist/types/runtime/ssrPreload.d.ts +2 -0
  160. package/dist/types/runtime/ssrTypes.d.ts +43 -0
  161. package/dist/types/runtime/state.d.ts +1 -1
  162. package/dist/types/runtime/submitAction.d.ts +14 -0
  163. package/dist/types/runtime/types.d.ts +3 -46
  164. package/dist/types/runtime/utils.d.ts +1 -22
  165. package/package.json +30 -9
  166. package/rstest.config.mts +1 -0
  167. package/src/cli/artifacts.ts +255 -0
  168. package/src/cli/index.ts +6 -246
  169. package/src/cli/tanstackTypes/canonicalRoutes.ts +157 -0
  170. package/src/cli/tanstackTypes/shared.ts +119 -0
  171. package/src/cli/tanstackTypes/source.ts +405 -0
  172. package/src/cli/tanstackTypes.ts +4 -647
  173. package/src/runtime/blockingSubscribe.ts +48 -0
  174. package/src/runtime/clientBasepath.ts +12 -0
  175. package/src/runtime/clientHydration.ts +151 -0
  176. package/src/runtime/dataMutation.tsx +9 -306
  177. package/src/runtime/formData.ts +153 -0
  178. package/src/runtime/loaderBridge.ts +8 -3
  179. package/src/runtime/plugin.node.tsx +60 -284
  180. package/src/runtime/plugin.tsx +21 -257
  181. package/src/runtime/pluginShared.ts +112 -0
  182. package/src/runtime/routeTree/components.ts +130 -0
  183. package/src/runtime/routeTree/construction.ts +238 -0
  184. package/src/runtime/routeTree/index.ts +7 -0
  185. package/src/runtime/routeTree/loaders.ts +232 -0
  186. package/src/runtime/routeTree/paths.ts +36 -0
  187. package/src/runtime/routeTree/staticData.ts +66 -0
  188. package/src/runtime/routeTree/tanstackRoutes.ts +36 -0
  189. package/src/runtime/routeTree/types.ts +87 -0
  190. package/src/runtime/routeTree.ts +5 -750
  191. package/src/runtime/rsc/CompositeComponent.tsx +29 -20
  192. package/src/runtime/rsc/RscNodeRenderer.tsx +9 -27
  193. package/src/runtime/rsc/client.tsx +12 -40
  194. package/src/runtime/rsc/flightSerialization.ts +158 -0
  195. package/src/runtime/rsc/payloadErrors.ts +73 -0
  196. package/src/runtime/rsc/payloadFetch.ts +97 -0
  197. package/src/runtime/rsc/payloadRouter.ts +29 -234
  198. package/src/runtime/rsc/payloadRoutes.ts +122 -0
  199. package/src/runtime/rsc/payloadStorage.ts +35 -0
  200. package/src/runtime/rsc/server.tsx +20 -29
  201. package/src/runtime/rsc/shared.ts +70 -0
  202. package/src/runtime/rsc/treeGetter.tsx +52 -0
  203. package/src/runtime/ssrManagedTags.ts +107 -0
  204. package/src/runtime/ssrPreload.ts +125 -0
  205. package/src/runtime/ssrTypes.ts +51 -0
  206. package/src/runtime/state.ts +4 -2
  207. package/src/runtime/submitAction.ts +194 -0
  208. package/src/runtime/types.ts +14 -51
  209. package/src/runtime/utils.tsx +72 -108
  210. package/src/types/react-server-dom-rspack.d.ts +56 -0
  211. package/tests/castRatchet.test.ts +85 -0
  212. package/tests/router/dataMutation.test.tsx +59 -0
  213. package/tests/router/fixtures/router-gen.golden.txt +72 -0
  214. package/tests/router/loaderBridge.test.ts +21 -0
  215. package/tests/router/routeTree.test.ts +51 -11
  216. package/tests/router/rsc.test.tsx +189 -0
  217. package/tests/router/ssrPreload.test.ts +30 -0
  218. package/tests/router/tanstackTypes.test.ts +254 -1
  219. package/dist/esm/runtime/pluginCore.mjs +0 -14
  220. package/dist/esm-node/runtime/pluginCore.mjs +0 -15
  221. package/src/runtime/pluginCore.ts +0 -56
@@ -1,339 +1,2 @@
1
- import { getPathWithoutExt, makeLegalIdentifier } from "@modern-js/runtime/cli";
2
- import { findExists, formatImportPath, slash } from "@modern-js/utils";
3
- import path from "path";
4
- const JS_OR_TS_EXTS = [
5
- '.js',
6
- '.jsx',
7
- '.ts',
8
- '.tsx',
9
- '.mjs',
10
- '.mts',
11
- '.cjs',
12
- '.cts'
13
- ];
14
- function toTanstackPath(pathname) {
15
- return pathname.split('/').map((segment)=>{
16
- if (!segment) return segment;
17
- if ('*' === segment) return '$';
18
- if (segment.startsWith(':')) {
19
- const name = segment.slice(1);
20
- if (name.endsWith('?')) return `{-$${name.slice(0, -1)}}`;
21
- return `$${name}`;
22
- }
23
- return segment;
24
- }).join('/');
25
- }
26
- async function resolveFileNoExt(inputNoExtPath) {
27
- const file = findExists(JS_OR_TS_EXTS.map((ext)=>`${inputNoExtPath}${ext}`));
28
- return file ? getPathWithoutExt(file) : null;
29
- }
30
- function quote(str) {
31
- return JSON.stringify(str);
32
- }
33
- function normalizeRelativeImport(p) {
34
- const normalized = formatImportPath(slash(p));
35
- if (normalized.startsWith('.')) return normalized;
36
- return `./${normalized}`;
37
- }
38
- function pickModernLoaderModule(route) {
39
- const loaderPath = route.data || route.loader;
40
- if (!loaderPath || 'string' != typeof loaderPath) return null;
41
- const inline = Boolean(route.data);
42
- return {
43
- loaderPath,
44
- inline
45
- };
46
- }
47
- function pickRouteSearchContractModules(route) {
48
- const validateSearchPath = route.validateSearch;
49
- const loaderDepsPath = route.loaderDeps;
50
- return {
51
- validateSearchPath: 'string' == typeof validateSearchPath ? validateSearchPath : null,
52
- loaderDepsPath: 'string' == typeof loaderDepsPath ? loaderDepsPath : null
53
- };
54
- }
55
- function isPathlessLayout(route) {
56
- return 'nested' === route.type && 'boolean' != typeof route.index && void 0 === route.path;
57
- }
58
- function isIndexRoute(route) {
59
- return 'nested' === route.type && Boolean(route.index);
60
- }
61
- function createRouteStaticDataSnippet(opts) {
62
- const staticDataLines = [];
63
- if (opts.modernRouteId) staticDataLines.push(`modernRouteId: ${quote(opts.modernRouteId)},`);
64
- if (opts.loaderName) staticDataLines.push(`modernRouteLoader: ${opts.loaderName},`);
65
- if (opts.actionName) staticDataLines.push(`modernRouteAction: ${opts.actionName},`);
66
- if (!staticDataLines.length) return null;
67
- return `staticData: createRouteStaticData({\n ${staticDataLines.join('\n ')}\n }),`;
68
- }
69
- const LOCALE_PARAM_SEGMENTS = new Set([
70
- ':lang',
71
- ':locale',
72
- ':language',
73
- '$lang',
74
- '$locale',
75
- '$language'
76
- ]);
77
- function paramsTypeForCanonicalPath(canonicalPath) {
78
- const fields = [];
79
- for (const segment of canonicalPath.split('/'))if (segment) {
80
- if ('*' === segment || '$' === segment) {
81
- fields.push("'_splat'?: string");
82
- continue;
83
- }
84
- if (segment.startsWith('{-$') && segment.endsWith('}')) {
85
- fields.push(`${JSON.stringify(segment.slice(3, -1))}?: string`);
86
- continue;
87
- }
88
- if (segment.startsWith('$')) {
89
- fields.push(`${JSON.stringify(segment.slice(1))}: string`);
90
- continue;
91
- }
92
- if (segment.startsWith(':')) {
93
- const optional = segment.endsWith('?');
94
- const name = segment.slice(1, optional ? void 0 : segment.length);
95
- fields.push(`${JSON.stringify(optional ? name.slice(0, -1) : name)}${optional ? '?' : ''}: string`);
96
- }
97
- }
98
- return fields.length > 0 ? `{ ${fields.join('; ')} }` : 'Record<string, never>';
99
- }
100
- function collectCanonicalRoutesForEntry(routes, options = {}) {
101
- const { localeParamHeuristic = true } = options;
102
- const canonicalParams = new Map();
103
- let hasI18nSurface = false;
104
- const normalizeJoined = (joined)=>{
105
- const collapsed = joined.replace(/\/+/g, '/');
106
- const withLeading = collapsed.startsWith('/') ? collapsed : `/${collapsed}`;
107
- return withLeading.length > 1 ? withLeading.replace(/\/+$/, '') : withLeading;
108
- };
109
- const record = (canonicalPath)=>{
110
- const normalized = normalizeJoined(canonicalPath || '/');
111
- const key = toTanstackPath(normalized);
112
- if (!canonicalParams.has(key)) canonicalParams.set(key, paramsTypeForCanonicalPath(normalized));
113
- };
114
- const visit = (route, parentPath)=>{
115
- let currentPath = parentPath;
116
- if ('string' == typeof route.modernCanonicalPath) {
117
- hasI18nSurface = true;
118
- currentPath = normalizeJoined(route.modernCanonicalPath);
119
- } else if ('string' == typeof route.path && route.path.length > 0) {
120
- const segments = route.path.replace(/\[(.+?)\]/g, ':$1').split('/').filter(Boolean);
121
- if (localeParamHeuristic && '' === parentPath && LOCALE_PARAM_SEGMENTS.has(segments[0])) {
122
- hasI18nSurface = true;
123
- segments.shift();
124
- }
125
- currentPath = segments.length ? normalizeJoined(`${parentPath}/${segments.join('/')}`) : parentPath;
126
- }
127
- const children = route.children;
128
- if (children && children.length > 0) {
129
- for (const child of children)visit(child, currentPath);
130
- return;
131
- }
132
- record(currentPath || '/');
133
- };
134
- const rootModern = routes.find((route)=>route.isRoot);
135
- const topLevel = rootModern ? rootModern.children ?? [] : routes;
136
- for (const route of topLevel)visit(route, '');
137
- if (!hasI18nSurface || 0 === canonicalParams.size) return null;
138
- return Object.fromEntries([
139
- ...canonicalParams.entries()
140
- ].sort(([a], [b])=>a.localeCompare(b)));
141
- }
142
- async function generateTanstackRouterTypesSourceForEntry(opts) {
143
- const { appContext, entryName, generatedDirName = 'modern-tanstack', routes } = opts;
144
- const outDir = path.join(appContext.srcDirectory, generatedDirName, entryName);
145
- const rootModern = routes.find((r)=>r && 'nested' === r.type && r.isRoot);
146
- const topLevel = rootModern ? rootModern.children || [] : routes;
147
- const imports = [];
148
- const statements = [];
149
- const loaderImportMap = new Map();
150
- const componentImportMap = new Map();
151
- const searchContractImportMap = new Map();
152
- const usedRouteVarNames = new Set();
153
- let loaderIndex = 0;
154
- let componentIndex = 0;
155
- let validateSearchIndex = 0;
156
- let loaderDepsIndex = 0;
157
- let routeIndex = 0;
158
- const getImportNameForComponent = (componentPath)=>{
159
- if ('string' != typeof componentPath || 0 === componentPath.length) return Promise.resolve(null);
160
- let pendingImportName = componentImportMap.get(componentPath);
161
- if (!pendingImportName) {
162
- pendingImportName = (async ()=>{
163
- const resolvedNoExt = await resolveRouteModuleNoExt(componentPath);
164
- if (!resolvedNoExt) return null;
165
- const relImport = normalizeRelativeImport(path.relative(outDir, resolvedNoExt));
166
- const componentName = `component_${componentIndex++}`;
167
- imports.push(`import ${componentName} from ${quote(relImport)};`);
168
- return componentName;
169
- })();
170
- componentImportMap.set(componentPath, pendingImportName);
171
- }
172
- return pendingImportName;
173
- };
174
- const resolveRouteModuleNoExt = async (aliasedNoExtPath)=>{
175
- const prefix = `${appContext.internalSrcAlias}/`;
176
- let absNoExt;
177
- if (aliasedNoExtPath.startsWith(prefix)) {
178
- const rel = aliasedNoExtPath.slice(prefix.length);
179
- absNoExt = path.join(appContext.srcDirectory, rel);
180
- } else absNoExt = path.isAbsolute(aliasedNoExtPath) ? aliasedNoExtPath : path.join(appContext.srcDirectory, aliasedNoExtPath);
181
- return resolveFileNoExt(absNoExt);
182
- };
183
- const getImportNamesForLoader = async (aliasedNoExtPath, inline, hasAction)=>{
184
- const key = `${inline ? 'inline' : 'default'}:${hasAction ? 'action' : 'loader'}:${aliasedNoExtPath}`;
185
- const existing = loaderImportMap.get(key);
186
- if (existing) return {
187
- loaderName: existing,
188
- actionName: hasAction ? existing.replace(/^loader_/, 'action_') : null
189
- };
190
- const resolvedNoExt = await resolveRouteModuleNoExt(aliasedNoExtPath);
191
- if (!resolvedNoExt) return null;
192
- const relImport = normalizeRelativeImport(path.relative(outDir, resolvedNoExt));
193
- const importName = `loader_${loaderIndex++}`;
194
- const actionName = hasAction ? importName.replace(/^loader_/, 'action_') : null;
195
- if (inline) {
196
- const specifiers = [
197
- `loader as ${importName}`
198
- ];
199
- if (actionName) specifiers.push(`action as ${actionName}`);
200
- imports.push(`import { ${specifiers.join(', ')} } from ${quote(relImport)};`);
201
- } else imports.push(`import ${importName} from ${quote(relImport)};`);
202
- loaderImportMap.set(key, importName);
203
- return {
204
- loaderName: importName,
205
- actionName
206
- };
207
- };
208
- const getImportNameForSearchContract = async (aliasedNoExtPath, exportName)=>{
209
- const key = `${exportName}:${aliasedNoExtPath}`;
210
- const existing = searchContractImportMap.get(key);
211
- if (existing) return existing;
212
- const resolvedNoExt = await resolveRouteModuleNoExt(aliasedNoExtPath);
213
- if (!resolvedNoExt) return null;
214
- const relImport = normalizeRelativeImport(path.relative(outDir, resolvedNoExt));
215
- const importName = 'validateSearch' === exportName ? `validateSearch_${validateSearchIndex++}` : `loaderDeps_${loaderDepsIndex++}`;
216
- imports.push(`import { ${exportName} as ${importName} } from ${quote(relImport)};`);
217
- searchContractImportMap.set(key, importName);
218
- return importName;
219
- };
220
- const reserveRouteVarName = (preferred)=>{
221
- let candidate = preferred;
222
- let suffix = 1;
223
- while(usedRouteVarNames.has(candidate))candidate = `${preferred}_${suffix++}`;
224
- usedRouteVarNames.add(candidate);
225
- return candidate;
226
- };
227
- const createRouteVarName = (route)=>{
228
- const id = route.id;
229
- const base = id ? makeLegalIdentifier(id) : `r_${routeIndex++}`;
230
- return reserveRouteVarName(`route_${base}`);
231
- };
232
- const buildRoute = async (opts)=>{
233
- const { parentVar, route } = opts;
234
- const varName = createRouteVarName(route);
235
- const loaderInfo = pickModernLoaderModule(route);
236
- const routeAction = route.action;
237
- const loaderImports = loaderInfo ? await getImportNamesForLoader(loaderInfo.loaderPath, loaderInfo.inline, Boolean(loaderInfo.inline && routeAction === loaderInfo.loaderPath)) : null;
238
- const loaderName = loaderImports?.loaderName || null;
239
- const actionName = loaderImports?.actionName || null;
240
- const searchContractInfo = pickRouteSearchContractModules(route);
241
- const validateSearchName = searchContractInfo.validateSearchPath ? await getImportNameForSearchContract(searchContractInfo.validateSearchPath, 'validateSearch') : null;
242
- const loaderDepsName = searchContractInfo.loaderDepsPath ? await getImportNameForSearchContract(searchContractInfo.loaderDepsPath, 'loaderDeps') : null;
243
- const rawPath = route.path;
244
- const hasSplat = 'string' == typeof rawPath && rawPath.includes('*');
245
- const routeOpts = [
246
- `getParentRoute: () => ${parentVar},`
247
- ];
248
- const componentName = await getImportNameForComponent(route._component);
249
- if (componentName) routeOpts.push(`component: ${componentName},`);
250
- if (isPathlessLayout(route)) {
251
- const id = route.id;
252
- routeOpts.push(`id: ${quote(id || 'pathless')},`);
253
- } else {
254
- const p = isIndexRoute(route) ? '/' : toTanstackPath(rawPath || '');
255
- routeOpts.push(`path: ${quote(p)},`);
256
- }
257
- if (loaderName) routeOpts.push(`loader: modernLoaderToTanstack({ hasSplat: ${hasSplat} }, ${loaderName}),`);
258
- if (validateSearchName) routeOpts.push(`validateSearch: ${validateSearchName},`);
259
- if (loaderDepsName) routeOpts.push(`loaderDeps: ${loaderDepsName},`);
260
- const staticDataSnippet = createRouteStaticDataSnippet({
261
- modernRouteId: route.id,
262
- loaderName,
263
- actionName
264
- });
265
- if (staticDataSnippet) routeOpts.push(staticDataSnippet);
266
- const children = route.children;
267
- const hasChildren = Boolean(children && children.length > 0);
268
- const routeCtorVarName = hasChildren ? reserveRouteVarName(`${varName}__base`) : varName;
269
- statements.push(`const ${routeCtorVarName} = createRoute({\n ${routeOpts.join('\n ')}\n});`);
270
- if (children && children.length > 0) {
271
- const childVars = await Promise.all(children.map((child)=>buildRoute({
272
- parentVar: routeCtorVarName,
273
- route: child
274
- })));
275
- statements.push(`const ${varName} = ${routeCtorVarName}.addChildren([${childVars.join(', ')}]);`);
276
- }
277
- return varName;
278
- };
279
- const rootLoaderInfo = rootModern ? pickModernLoaderModule(rootModern) : null;
280
- const rootAction = rootModern?.action;
281
- const rootLoaderImports = rootLoaderInfo?.loaderPath ? await getImportNamesForLoader(rootLoaderInfo.loaderPath, rootLoaderInfo.inline, Boolean(rootLoaderInfo.inline && rootAction === rootLoaderInfo.loaderPath)) : null;
282
- const rootLoaderName = rootLoaderImports?.loaderName || null;
283
- const rootActionName = rootLoaderImports?.actionName || null;
284
- const rootSearchContractInfo = rootModern ? pickRouteSearchContractModules(rootModern) : null;
285
- const rootValidateSearchName = rootSearchContractInfo?.validateSearchPath ? await getImportNameForSearchContract(rootSearchContractInfo.validateSearchPath, 'validateSearch') : null;
286
- const rootLoaderDepsName = rootSearchContractInfo?.loaderDepsPath ? await getImportNameForSearchContract(rootSearchContractInfo.loaderDepsPath, 'loaderDeps') : null;
287
- const topLevelVars = await Promise.all(topLevel.map((route)=>buildRoute({
288
- parentVar: 'rootRoute',
289
- route
290
- })));
291
- const rootOpts = [];
292
- const rootComponentName = await getImportNameForComponent(rootModern?._component);
293
- if (rootComponentName) rootOpts.push(`component: ${rootComponentName},`);
294
- if (rootLoaderName) rootOpts.push(`loader: modernLoaderToTanstack({ hasSplat: false }, ${rootLoaderName}),`);
295
- if (rootValidateSearchName) rootOpts.push(`validateSearch: ${rootValidateSearchName},`);
296
- if (rootLoaderDepsName) rootOpts.push(`loaderDeps: ${rootLoaderDepsName},`);
297
- const routerGenTs = `/* eslint-disable */
298
- // This file is auto-generated by Modern.js. Do not edit manually.
299
-
300
- import {
301
- createMemoryHistory,
302
- createRootRouteWithContext,
303
- createRoute,
304
- createRouter,
305
- createRouteStaticData,
306
- type ModernRouterContext,
307
- modernLoaderToTanstack,
308
- modernTanstackRouterFastDefaults,
309
- } from '@modern-js/plugin-tanstack/runtime';
310
-
311
- ${imports.join('\n')}
312
-
313
- export const rootRoute = createRootRouteWithContext<ModernRouterContext>()({
314
- ${rootOpts.join('\n ')}
315
- ${createRouteStaticDataSnippet({
316
- modernRouteId: rootModern?.id,
317
- loaderName: rootLoaderName,
318
- actionName: rootActionName
319
- }) || ''}
320
- });
321
-
322
- ${statements.join('\n\n')}
323
-
324
- export const routeTree = rootRoute.addChildren([${topLevelVars.join(', ')}]);
325
-
326
- export const router = createRouter({
327
- ...modernTanstackRouterFastDefaults,
328
- routeTree,
329
- history: createMemoryHistory({
330
- initialEntries: ['/'],
331
- }),
332
- context: {} as ModernRouterContext,
333
- });
334
- `;
335
- return {
336
- routerGenTs
337
- };
338
- }
339
- export { collectCanonicalRoutesForEntry, generateTanstackRouterTypesSourceForEntry };
1
+ export { collectCanonicalRoutesForEntry } from "./tanstackTypes/canonicalRoutes.mjs";
2
+ export { generateTanstackRouterTypesSourceForEntry } from "./tanstackTypes/source.mjs";
@@ -0,0 +1,19 @@
1
+ const BLOCKING_SUBSCRIBE_SYMBOL = Symbol.for('@modern-js/plugin-tanstack:blocking-subscribe');
2
+ const BLOCKING_STATE_SYMBOL = Symbol.for('@modern-js/plugin-tanstack:blocking-state');
3
+ function wrapRouterSubscribeWithBlockState(router, getBlockNavState) {
4
+ if (!router || 'object' != typeof router) return;
5
+ const target = router;
6
+ target[BLOCKING_STATE_SYMBOL] = getBlockNavState;
7
+ if (target[BLOCKING_SUBSCRIBE_SYMBOL] || 'function' != typeof target.subscribe) return;
8
+ const originSubscribe = target.subscribe.bind(target);
9
+ target.subscribe = (eventType, listener)=>{
10
+ const wrappedListener = (...args)=>{
11
+ const blockRoute = target[BLOCKING_STATE_SYMBOL]?.() || false;
12
+ if (blockRoute) return;
13
+ return listener(...args);
14
+ };
15
+ return originSubscribe(eventType, wrappedListener);
16
+ };
17
+ target[BLOCKING_SUBSCRIBE_SYMBOL] = true;
18
+ }
19
+ export { BLOCKING_STATE_SYMBOL, BLOCKING_SUBSCRIBE_SYMBOL, wrapRouterSubscribeWithBlockState };
@@ -0,0 +1,10 @@
1
+ function normalizeBase(b) {
2
+ if (b.length > 1 && b.endsWith('/')) return b.slice(0, -1);
3
+ return b || '/';
4
+ }
5
+ function isSegmentPrefix(pathname, base) {
6
+ const b = normalizeBase(base);
7
+ const p = pathname || '/';
8
+ return p === b || p.startsWith(`${b}/`);
9
+ }
10
+ export { isSegmentPrefix };
@@ -0,0 +1,70 @@
1
+ import { RouterProvider } from "@tanstack/react-router";
2
+ import { createElement } from "react";
3
+ import { withModernRouteMatchContext } from "./outlet.mjs";
4
+ import { pickRouteModuleComponent } from "./routeTree.mjs";
5
+ const routerHydrationRecords = new WeakMap();
6
+ const routeModulesKey = '_routeModules';
7
+ function getCachedRouteModule(routeId) {
8
+ if ("u" < typeof window) return;
9
+ return window[routeModulesKey]?.[routeId];
10
+ }
11
+ function preloadHydratedRouteComponents(router) {
12
+ const preloadableRouter = router;
13
+ const routesById = preloadableRouter.routesById || {};
14
+ const matches = preloadableRouter.stores.matches.get();
15
+ return Promise.all(matches.map((match)=>{
16
+ if (void 0 === match.routeId || '' === match.routeId) return;
17
+ const route = routesById[match.routeId];
18
+ const component = route?.options?.component;
19
+ const preload = component?.load || component?.preload;
20
+ if ('function' != typeof preload) return;
21
+ return Promise.resolve(preload.call(component)).then((routeModule)=>{
22
+ const modernRouteId = route?.options?.staticData?.modernRouteId;
23
+ const cachedRouteModule = 'string' == typeof modernRouteId && '' !== modernRouteId ? getCachedRouteModule(modernRouteId) : void 0;
24
+ const resolvedComponent = pickRouteModuleComponent(cachedRouteModule ?? routeModule);
25
+ if (void 0 !== resolvedComponent && 'string' == typeof modernRouteId && '' !== modernRouteId) route.options.component = withModernRouteMatchContext(resolvedComponent, modernRouteId);
26
+ });
27
+ })).then(()=>void 0);
28
+ }
29
+ function hydrateTanstackRouter(router) {
30
+ return import("@tanstack/react-router/ssr/client").then(({ hydrate })=>hydrate(router));
31
+ }
32
+ function getTanstackSsrHydrationRecord(router) {
33
+ const existingHydrationRecord = routerHydrationRecords.get(router);
34
+ if (void 0 !== existingHydrationRecord) return existingHydrationRecord;
35
+ const hydrationRecord = {
36
+ promise: Promise.resolve(),
37
+ status: 'pending'
38
+ };
39
+ routerHydrationRecords.set(router, hydrationRecord);
40
+ try {
41
+ hydrationRecord.promise = hydrateTanstackRouter(router).then((value)=>preloadHydratedRouteComponents(router).then(()=>value)).then((value)=>{
42
+ hydrationRecord.status = 'fulfilled';
43
+ return value;
44
+ }, (error)=>{
45
+ hydrationRecord.status = 'rejected';
46
+ hydrationRecord.error = error;
47
+ throw error;
48
+ });
49
+ } catch (error) {
50
+ hydrationRecord.status = 'rejected';
51
+ hydrationRecord.error = error;
52
+ hydrationRecord.promise = Promise.reject(error);
53
+ hydrationRecord.promise.catch(()=>{});
54
+ }
55
+ return hydrationRecord;
56
+ }
57
+ function getTanstackSsrHydrationPromise(router) {
58
+ return getTanstackSsrHydrationRecord(router).promise;
59
+ }
60
+ function hasTanstackSsrHydrationRecord(router) {
61
+ return routerHydrationRecords.has(router);
62
+ }
63
+ function ModernRouterClient({ router }) {
64
+ const hydrationRecord = getTanstackSsrHydrationRecord(router);
65
+ if ('rejected' === hydrationRecord.status) throw hydrationRecord.error;
66
+ return createElement(RouterProvider, {
67
+ router
68
+ });
69
+ }
70
+ export { ModernRouterClient, getCachedRouteModule, getTanstackSsrHydrationPromise, getTanstackSsrHydrationRecord, hasTanstackSsrHydrationRecord, hydrateTanstackRouter, preloadHydratedRouteComponents, routerHydrationRecords };
@@ -1,173 +1,8 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { useRouter } from "@tanstack/react-router";
3
3
  import { useCallback, useRef, useState } from "react";
4
- class RouteActionResponseError extends Error {
5
- constructor(response, data){
6
- super(`Route action failed with status ${response.status}`);
7
- this.name = 'RouteActionResponseError';
8
- this.response = response;
9
- this.data = data;
10
- }
11
- }
12
- function formDataToUrlSearchParams(formData) {
13
- const searchParams = new URLSearchParams();
14
- formData.forEach((value, key)=>{
15
- if ('string' == typeof value) searchParams.append(key, value);
16
- });
17
- return searchParams;
18
- }
19
- function formDataToTextPlain(formData) {
20
- return Array.from(formData.entries()).map(([key, value])=>`${key}=${String(value)}`).join('\n');
21
- }
22
- function toFormData(target) {
23
- if (target instanceof HTMLFormElement) return new FormData(target);
24
- if (target instanceof FormData) return target;
25
- if (target instanceof URLSearchParams) {
26
- const formData = new FormData();
27
- target.forEach((value, key)=>{
28
- formData.append(key, value);
29
- });
30
- return formData;
31
- }
32
- const formData = new FormData();
33
- Object.entries(target).forEach(([key, value])=>{
34
- if (null == value) return;
35
- formData.append(key, String(value));
36
- });
37
- return formData;
38
- }
39
- function getSubmitter(event) {
40
- const nativeEvent = event.nativeEvent;
41
- const submitter = nativeEvent?.submitter;
42
- if (submitter instanceof HTMLButtonElement || submitter instanceof HTMLInputElement) return submitter;
43
- return null;
44
- }
45
- function createFormDataFromSubmit({ form, submitter }) {
46
- if (submitter) try {
47
- return new FormData(form, submitter);
48
- } catch {}
49
- return new FormData(form);
50
- }
51
- function resolveSubmitOptionsFromForm({ form, submitter, action, method, encType }) {
52
- const resolvedAction = submitter?.getAttribute('formaction') || action || form.getAttribute('action') || '.';
53
- const resolvedMethod = (submitter?.getAttribute('formmethod') || method || form.getAttribute('method') || 'get').toLowerCase();
54
- const resolvedEncType = submitter?.getAttribute('formenctype') || encType || form.getAttribute('enctype') || 'application/x-www-form-urlencoded';
55
- return {
56
- action: resolvedAction,
57
- method: resolvedMethod,
58
- encType: resolvedEncType
59
- };
60
- }
61
- function resolveRouteHandlers(router, actionTo) {
62
- const builtLocation = router.buildLocation({
63
- to: actionTo
64
- });
65
- const href = router.getParsedLocationHref(builtLocation);
66
- const matchedRoutes = router.getMatchedRoutes(builtLocation.pathname);
67
- const routeStaticData = matchedRoutes.foundRoute?.options?.staticData;
68
- const action = routeStaticData?.modernRouteAction;
69
- const loader = routeStaticData?.modernRouteLoader;
70
- return {
71
- action,
72
- loader,
73
- href,
74
- params: matchedRoutes.routeParams || {}
75
- };
76
- }
77
- function isRedirectResponse(value) {
78
- if (!(value instanceof Response)) return false;
79
- return [
80
- 301,
81
- 302,
82
- 303,
83
- 307,
84
- 308
85
- ].includes(value.status);
86
- }
87
- async function parseResponseData(response) {
88
- if (204 === response.status) return null;
89
- const contentType = response.headers.get('Content-Type') || '';
90
- if (contentType.includes('application/json')) return response.json();
91
- return response.text();
92
- }
93
- async function parseResponseResultOrThrow(response) {
94
- const parsed = await parseResponseData(response);
95
- if (!response.ok) throw new RouteActionResponseError(response, parsed);
96
- return parsed;
97
- }
98
- async function submitRouteAction({ router, target, options = {}, isFetcher = false, onInvalidateStart }) {
99
- const method = (options.method || 'post').toLowerCase();
100
- const encType = options.encType || 'application/x-www-form-urlencoded';
101
- const actionTo = options.action || '.';
102
- const formData = toFormData(target);
103
- const resolved = resolveRouteHandlers(router, actionTo);
104
- if ('get' === method) {
105
- const search = formDataToUrlSearchParams(formData).toString();
106
- const requestUrl = new URL(resolved.href, window.location.origin);
107
- requestUrl.search = search;
108
- if (isFetcher && resolved.loader) {
109
- const result = await resolved.loader({
110
- request: new Request(requestUrl, {
111
- method: 'GET'
112
- }),
113
- params: resolved.params
114
- });
115
- if (result instanceof Response) {
116
- const redirectTo = result.headers.get('X-Modernjs-Redirect') || result.headers.get('Location');
117
- if (redirectTo || isRedirectResponse(result)) {
118
- await router.navigate({
119
- to: redirectTo || '/'
120
- });
121
- return parseResponseData(result);
122
- }
123
- return parseResponseResultOrThrow(result);
124
- }
125
- return result;
126
- }
127
- await router.navigate({
128
- href: search ? `${resolved.href}?${search}` : resolved.href
129
- });
130
- return;
131
- }
132
- if (!resolved.action) throw new Error(`No route action found for "${actionTo}"`);
133
- const headers = new Headers();
134
- let body = null;
135
- if (encType.includes('application/json')) {
136
- headers.set('Content-Type', 'application/json');
137
- body = JSON.stringify(Object.fromEntries(formDataToUrlSearchParams(formData).entries()));
138
- } else if (encType.includes('text/plain')) {
139
- headers.set('Content-Type', 'text/plain;charset=UTF-8');
140
- body = formDataToTextPlain(formData);
141
- } else if (encType.includes('application/x-www-form-urlencoded')) {
142
- headers.set('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
143
- body = formDataToUrlSearchParams(formData);
144
- } else body = formData;
145
- const request = new Request(new URL(resolved.href, window.location.origin), {
146
- method: method.toUpperCase(),
147
- headers,
148
- body
149
- });
150
- const result = await resolved.action({
151
- request,
152
- params: resolved.params
153
- });
154
- if (result instanceof Response) {
155
- const redirectTo = result.headers.get('X-Modernjs-Redirect') || result.headers.get('Location');
156
- if (redirectTo || isRedirectResponse(result)) {
157
- await router.navigate({
158
- to: redirectTo || '/'
159
- });
160
- return parseResponseData(result);
161
- }
162
- const parsed = isFetcher ? await parseResponseResultOrThrow(result) : await parseResponseData(result);
163
- onInvalidateStart?.();
164
- await router.invalidate();
165
- return parsed;
166
- }
167
- onInvalidateStart?.();
168
- await router.invalidate();
169
- return result;
170
- }
4
+ import { createFormDataFromSubmit, getSubmitter, resolveSubmitOptionsFromForm } from "./formData.mjs";
5
+ import { RouteActionResponseError, submitRouteAction } from "./submitAction.mjs";
171
6
  function Form({ action, method = 'get', encType, reloadDocument, onSubmit, ...rest }) {
172
7
  const router = useRouter();
173
8
  const handleSubmit = useCallback(async (event)=>{
@@ -0,0 +1,63 @@
1
+ function formDataToUrlSearchParams(formData) {
2
+ const searchParams = new URLSearchParams();
3
+ formData.forEach((value, key)=>{
4
+ if ('string' == typeof value) searchParams.append(key, value);
5
+ });
6
+ return searchParams;
7
+ }
8
+ function formDataToTextPlain(formData) {
9
+ return Array.from(formData.entries()).map(([key, value])=>`${key}=${String(value)}`).join('\n');
10
+ }
11
+ function toFormData(target) {
12
+ if (target instanceof HTMLFormElement) return new FormData(target);
13
+ if (target instanceof FormData) return target;
14
+ if (target instanceof URLSearchParams) {
15
+ const formData = new FormData();
16
+ target.forEach((value, key)=>{
17
+ formData.append(key, value);
18
+ });
19
+ return formData;
20
+ }
21
+ const formData = new FormData();
22
+ Object.entries(target).forEach(([key, value])=>{
23
+ if (null == value) return;
24
+ formData.append(key, String(value));
25
+ });
26
+ return formData;
27
+ }
28
+ function getSubmitter(event) {
29
+ const nativeEvent = event.nativeEvent;
30
+ const submitter = nativeEvent?.submitter;
31
+ if (submitter instanceof HTMLButtonElement || submitter instanceof HTMLInputElement) return submitter;
32
+ return null;
33
+ }
34
+ function appendSubmitterValue(formData, form, submitter) {
35
+ if (submitter.form !== form || submitter.disabled) return;
36
+ if (submitter instanceof HTMLInputElement && 'image' === submitter.type) {
37
+ const namePrefix = submitter.name ? `${submitter.name}.` : '';
38
+ formData.append(`${namePrefix}x`, '0');
39
+ formData.append(`${namePrefix}y`, '0');
40
+ return;
41
+ }
42
+ if (!submitter.name || 'button' === submitter.type || 'reset' === submitter.type) return;
43
+ formData.append(submitter.name, submitter.value);
44
+ }
45
+ function createFormDataFromSubmit({ form, submitter }) {
46
+ if (submitter) try {
47
+ return new FormData(form, submitter);
48
+ } catch {}
49
+ const formData = new FormData(form);
50
+ if (submitter) appendSubmitterValue(formData, form, submitter);
51
+ return formData;
52
+ }
53
+ function resolveSubmitOptionsFromForm({ form, submitter, action, method, encType }) {
54
+ const resolvedAction = submitter?.getAttribute('formaction') || action || form.getAttribute('action') || '.';
55
+ const resolvedMethod = (submitter?.getAttribute('formmethod') || method || form.getAttribute('method') || 'get').toLowerCase();
56
+ const resolvedEncType = submitter?.getAttribute('formenctype') || encType || form.getAttribute('enctype') || 'application/x-www-form-urlencoded';
57
+ return {
58
+ action: resolvedAction,
59
+ method: resolvedMethod,
60
+ encType: resolvedEncType
61
+ };
62
+ }
63
+ export { createFormDataFromSubmit, formDataToTextPlain, formDataToUrlSearchParams, getSubmitter, resolveSubmitOptionsFromForm, toFormData };