@benjavicente/router-core 1.168.9

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 (380) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -0
  3. package/bin/intent.js +25 -0
  4. package/dist/cjs/Matches.cjs +17 -0
  5. package/dist/cjs/Matches.cjs.map +1 -0
  6. package/dist/cjs/Matches.d.cts +139 -0
  7. package/dist/cjs/RouterProvider.d.cts +27 -0
  8. package/dist/cjs/config.cjs +11 -0
  9. package/dist/cjs/config.cjs.map +1 -0
  10. package/dist/cjs/config.d.cts +17 -0
  11. package/dist/cjs/defer.cjs +41 -0
  12. package/dist/cjs/defer.cjs.map +1 -0
  13. package/dist/cjs/defer.d.cts +37 -0
  14. package/dist/cjs/fileRoute.d.cts +24 -0
  15. package/dist/cjs/global.d.cts +7 -0
  16. package/dist/cjs/hash-scroll.cjs +20 -0
  17. package/dist/cjs/hash-scroll.cjs.map +1 -0
  18. package/dist/cjs/hash-scroll.d.cts +7 -0
  19. package/dist/cjs/history.d.cts +8 -0
  20. package/dist/cjs/index.cjs +96 -0
  21. package/dist/cjs/index.d.cts +53 -0
  22. package/dist/cjs/invariant.cjs +8 -0
  23. package/dist/cjs/invariant.cjs.map +1 -0
  24. package/dist/cjs/invariant.d.cts +1 -0
  25. package/dist/cjs/isServer/client.cjs +7 -0
  26. package/dist/cjs/isServer/client.cjs.map +1 -0
  27. package/dist/cjs/isServer/client.d.cts +1 -0
  28. package/dist/cjs/isServer/development.cjs +7 -0
  29. package/dist/cjs/isServer/development.cjs.map +1 -0
  30. package/dist/cjs/isServer/development.d.cts +1 -0
  31. package/dist/cjs/isServer/server.cjs +7 -0
  32. package/dist/cjs/isServer/server.cjs.map +1 -0
  33. package/dist/cjs/isServer/server.d.cts +1 -0
  34. package/dist/cjs/link.cjs +6 -0
  35. package/dist/cjs/link.cjs.map +1 -0
  36. package/dist/cjs/link.d.cts +221 -0
  37. package/dist/cjs/load-matches.cjs +659 -0
  38. package/dist/cjs/load-matches.cjs.map +1 -0
  39. package/dist/cjs/load-matches.d.cts +18 -0
  40. package/dist/cjs/location.d.cts +50 -0
  41. package/dist/cjs/lru-cache.cjs +70 -0
  42. package/dist/cjs/lru-cache.cjs.map +1 -0
  43. package/dist/cjs/lru-cache.d.cts +6 -0
  44. package/dist/cjs/manifest.cjs +18 -0
  45. package/dist/cjs/manifest.cjs.map +1 -0
  46. package/dist/cjs/manifest.d.cts +35 -0
  47. package/dist/cjs/new-process-route-tree.cjs +754 -0
  48. package/dist/cjs/new-process-route-tree.cjs.map +1 -0
  49. package/dist/cjs/new-process-route-tree.d.cts +236 -0
  50. package/dist/cjs/not-found.cjs +26 -0
  51. package/dist/cjs/not-found.cjs.map +1 -0
  52. package/dist/cjs/not-found.d.cts +32 -0
  53. package/dist/cjs/path.cjs +252 -0
  54. package/dist/cjs/path.cjs.map +1 -0
  55. package/dist/cjs/path.d.cts +56 -0
  56. package/dist/cjs/qss.cjs +70 -0
  57. package/dist/cjs/qss.cjs.map +1 -0
  58. package/dist/cjs/qss.d.cts +33 -0
  59. package/dist/cjs/redirect.cjs +56 -0
  60. package/dist/cjs/redirect.cjs.map +1 -0
  61. package/dist/cjs/redirect.d.cts +77 -0
  62. package/dist/cjs/rewrite.cjs +68 -0
  63. package/dist/cjs/rewrite.cjs.map +1 -0
  64. package/dist/cjs/rewrite.d.cts +30 -0
  65. package/dist/cjs/root.cjs +7 -0
  66. package/dist/cjs/root.cjs.map +1 -0
  67. package/dist/cjs/root.d.cts +3 -0
  68. package/dist/cjs/route.cjs +100 -0
  69. package/dist/cjs/route.cjs.map +1 -0
  70. package/dist/cjs/route.d.cts +552 -0
  71. package/dist/cjs/routeInfo.d.cts +54 -0
  72. package/dist/cjs/router.cjs +1173 -0
  73. package/dist/cjs/router.cjs.map +1 -0
  74. package/dist/cjs/router.d.cts +734 -0
  75. package/dist/cjs/scroll-restoration-inline.cjs +6 -0
  76. package/dist/cjs/scroll-restoration-inline.cjs.map +1 -0
  77. package/dist/cjs/scroll-restoration-inline.d.cts +6 -0
  78. package/dist/cjs/scroll-restoration-script/client.cjs +9 -0
  79. package/dist/cjs/scroll-restoration-script/client.cjs.map +1 -0
  80. package/dist/cjs/scroll-restoration-script/client.d.cts +2 -0
  81. package/dist/cjs/scroll-restoration-script/server.cjs +30 -0
  82. package/dist/cjs/scroll-restoration-script/server.cjs.map +1 -0
  83. package/dist/cjs/scroll-restoration-script/server.d.cts +2 -0
  84. package/dist/cjs/scroll-restoration.cjs +191 -0
  85. package/dist/cjs/scroll-restoration.cjs.map +1 -0
  86. package/dist/cjs/scroll-restoration.d.cts +38 -0
  87. package/dist/cjs/searchMiddleware.cjs +55 -0
  88. package/dist/cjs/searchMiddleware.cjs.map +1 -0
  89. package/dist/cjs/searchMiddleware.d.cts +25 -0
  90. package/dist/cjs/searchParams.cjs +65 -0
  91. package/dist/cjs/searchParams.cjs.map +1 -0
  92. package/dist/cjs/searchParams.d.cts +31 -0
  93. package/dist/cjs/ssr/client.cjs +7 -0
  94. package/dist/cjs/ssr/client.d.cts +6 -0
  95. package/dist/cjs/ssr/constants.cjs +8 -0
  96. package/dist/cjs/ssr/constants.cjs.map +1 -0
  97. package/dist/cjs/ssr/constants.d.cts +3 -0
  98. package/dist/cjs/ssr/createRequestHandler.cjs +44 -0
  99. package/dist/cjs/ssr/createRequestHandler.cjs.map +1 -0
  100. package/dist/cjs/ssr/createRequestHandler.d.cts +9 -0
  101. package/dist/cjs/ssr/handlerCallback.cjs +8 -0
  102. package/dist/cjs/ssr/handlerCallback.cjs.map +1 -0
  103. package/dist/cjs/ssr/handlerCallback.d.cts +9 -0
  104. package/dist/cjs/ssr/headers.cjs +21 -0
  105. package/dist/cjs/ssr/headers.cjs.map +1 -0
  106. package/dist/cjs/ssr/headers.d.cts +3 -0
  107. package/dist/cjs/ssr/json.cjs +11 -0
  108. package/dist/cjs/ssr/json.cjs.map +1 -0
  109. package/dist/cjs/ssr/json.d.cts +10 -0
  110. package/dist/cjs/ssr/serializer/RawStream.cjs +287 -0
  111. package/dist/cjs/ssr/serializer/RawStream.cjs.map +1 -0
  112. package/dist/cjs/ssr/serializer/RawStream.d.cts +64 -0
  113. package/dist/cjs/ssr/serializer/ShallowErrorPlugin.cjs +32 -0
  114. package/dist/cjs/ssr/serializer/ShallowErrorPlugin.cjs.map +1 -0
  115. package/dist/cjs/ssr/serializer/ShallowErrorPlugin.d.cts +9 -0
  116. package/dist/cjs/ssr/serializer/seroval-plugins.cjs +13 -0
  117. package/dist/cjs/ssr/serializer/seroval-plugins.cjs.map +1 -0
  118. package/dist/cjs/ssr/serializer/seroval-plugins.d.cts +2 -0
  119. package/dist/cjs/ssr/serializer/transformer.cjs +53 -0
  120. package/dist/cjs/ssr/serializer/transformer.cjs.map +1 -0
  121. package/dist/cjs/ssr/serializer/transformer.d.cts +91 -0
  122. package/dist/cjs/ssr/server.cjs +13 -0
  123. package/dist/cjs/ssr/server.d.cts +6 -0
  124. package/dist/cjs/ssr/ssr-client.cjs +183 -0
  125. package/dist/cjs/ssr/ssr-client.cjs.map +1 -0
  126. package/dist/cjs/ssr/ssr-client.d.cts +10 -0
  127. package/dist/cjs/ssr/ssr-match-id.cjs +12 -0
  128. package/dist/cjs/ssr/ssr-match-id.cjs.map +1 -0
  129. package/dist/cjs/ssr/ssr-match-id.d.cts +2 -0
  130. package/dist/cjs/ssr/ssr-server.cjs +279 -0
  131. package/dist/cjs/ssr/ssr-server.cjs.map +1 -0
  132. package/dist/cjs/ssr/ssr-server.d.cts +42 -0
  133. package/dist/cjs/ssr/transformStreamWithRouter.cjs +327 -0
  134. package/dist/cjs/ssr/transformStreamWithRouter.cjs.map +1 -0
  135. package/dist/cjs/ssr/transformStreamWithRouter.d.cts +11 -0
  136. package/dist/cjs/ssr/tsrScript.cjs +6 -0
  137. package/dist/cjs/ssr/tsrScript.cjs.map +1 -0
  138. package/dist/cjs/ssr/tsrScript.d.cts +1 -0
  139. package/dist/cjs/ssr/types.d.cts +30 -0
  140. package/dist/cjs/stores.cjs +148 -0
  141. package/dist/cjs/stores.cjs.map +1 -0
  142. package/dist/cjs/stores.d.cts +70 -0
  143. package/dist/cjs/structuralSharing.d.cts +4 -0
  144. package/dist/cjs/typePrimitives.d.cts +65 -0
  145. package/dist/cjs/useLoaderData.d.cts +5 -0
  146. package/dist/cjs/useLoaderDeps.d.cts +5 -0
  147. package/dist/cjs/useNavigate.d.cts +3 -0
  148. package/dist/cjs/useParams.d.cts +5 -0
  149. package/dist/cjs/useRouteContext.d.cts +9 -0
  150. package/dist/cjs/useSearch.d.cts +5 -0
  151. package/dist/cjs/utils.cjs +339 -0
  152. package/dist/cjs/utils.cjs.map +1 -0
  153. package/dist/cjs/utils.d.cts +178 -0
  154. package/dist/cjs/validators.d.cts +51 -0
  155. package/dist/esm/Matches.d.ts +139 -0
  156. package/dist/esm/Matches.js +17 -0
  157. package/dist/esm/Matches.js.map +1 -0
  158. package/dist/esm/RouterProvider.d.ts +27 -0
  159. package/dist/esm/config.d.ts +17 -0
  160. package/dist/esm/config.js +11 -0
  161. package/dist/esm/config.js.map +1 -0
  162. package/dist/esm/defer.d.ts +37 -0
  163. package/dist/esm/defer.js +40 -0
  164. package/dist/esm/defer.js.map +1 -0
  165. package/dist/esm/fileRoute.d.ts +24 -0
  166. package/dist/esm/global.d.ts +7 -0
  167. package/dist/esm/hash-scroll.d.ts +7 -0
  168. package/dist/esm/hash-scroll.js +20 -0
  169. package/dist/esm/hash-scroll.js.map +1 -0
  170. package/dist/esm/history.d.ts +8 -0
  171. package/dist/esm/index.d.ts +53 -0
  172. package/dist/esm/index.js +24 -0
  173. package/dist/esm/invariant.d.ts +1 -0
  174. package/dist/esm/invariant.js +8 -0
  175. package/dist/esm/invariant.js.map +1 -0
  176. package/dist/esm/isServer/client.d.ts +1 -0
  177. package/dist/esm/isServer/client.js +6 -0
  178. package/dist/esm/isServer/client.js.map +1 -0
  179. package/dist/esm/isServer/development.d.ts +1 -0
  180. package/dist/esm/isServer/development.js +6 -0
  181. package/dist/esm/isServer/development.js.map +1 -0
  182. package/dist/esm/isServer/server.d.ts +1 -0
  183. package/dist/esm/isServer/server.js +6 -0
  184. package/dist/esm/isServer/server.js.map +1 -0
  185. package/dist/esm/link.d.ts +221 -0
  186. package/dist/esm/link.js +6 -0
  187. package/dist/esm/link.js.map +1 -0
  188. package/dist/esm/load-matches.d.ts +18 -0
  189. package/dist/esm/load-matches.js +657 -0
  190. package/dist/esm/load-matches.js.map +1 -0
  191. package/dist/esm/location.d.ts +50 -0
  192. package/dist/esm/lru-cache.d.ts +6 -0
  193. package/dist/esm/lru-cache.js +70 -0
  194. package/dist/esm/lru-cache.js.map +1 -0
  195. package/dist/esm/manifest.d.ts +35 -0
  196. package/dist/esm/manifest.js +17 -0
  197. package/dist/esm/manifest.js.map +1 -0
  198. package/dist/esm/new-process-route-tree.d.ts +236 -0
  199. package/dist/esm/new-process-route-tree.js +749 -0
  200. package/dist/esm/new-process-route-tree.js.map +1 -0
  201. package/dist/esm/not-found.d.ts +32 -0
  202. package/dist/esm/not-found.js +25 -0
  203. package/dist/esm/not-found.js.map +1 -0
  204. package/dist/esm/path.d.ts +56 -0
  205. package/dist/esm/path.js +243 -0
  206. package/dist/esm/path.js.map +1 -0
  207. package/dist/esm/qss.d.ts +33 -0
  208. package/dist/esm/qss.js +69 -0
  209. package/dist/esm/qss.js.map +1 -0
  210. package/dist/esm/redirect.d.ts +77 -0
  211. package/dist/esm/redirect.js +53 -0
  212. package/dist/esm/redirect.js.map +1 -0
  213. package/dist/esm/rewrite.d.ts +30 -0
  214. package/dist/esm/rewrite.js +65 -0
  215. package/dist/esm/rewrite.js.map +1 -0
  216. package/dist/esm/root.d.ts +3 -0
  217. package/dist/esm/root.js +7 -0
  218. package/dist/esm/root.js.map +1 -0
  219. package/dist/esm/route.d.ts +552 -0
  220. package/dist/esm/route.js +98 -0
  221. package/dist/esm/route.js.map +1 -0
  222. package/dist/esm/routeInfo.d.ts +54 -0
  223. package/dist/esm/router.d.ts +734 -0
  224. package/dist/esm/router.js +1165 -0
  225. package/dist/esm/router.js.map +1 -0
  226. package/dist/esm/scroll-restoration-inline.d.ts +6 -0
  227. package/dist/esm/scroll-restoration-inline.js +6 -0
  228. package/dist/esm/scroll-restoration-inline.js.map +1 -0
  229. package/dist/esm/scroll-restoration-script/client.d.ts +2 -0
  230. package/dist/esm/scroll-restoration-script/client.js +8 -0
  231. package/dist/esm/scroll-restoration-script/client.js.map +1 -0
  232. package/dist/esm/scroll-restoration-script/server.d.ts +2 -0
  233. package/dist/esm/scroll-restoration-script/server.js +29 -0
  234. package/dist/esm/scroll-restoration-script/server.js.map +1 -0
  235. package/dist/esm/scroll-restoration.d.ts +38 -0
  236. package/dist/esm/scroll-restoration.js +187 -0
  237. package/dist/esm/scroll-restoration.js.map +1 -0
  238. package/dist/esm/searchMiddleware.d.ts +25 -0
  239. package/dist/esm/searchMiddleware.js +54 -0
  240. package/dist/esm/searchMiddleware.js.map +1 -0
  241. package/dist/esm/searchParams.d.ts +31 -0
  242. package/dist/esm/searchParams.js +62 -0
  243. package/dist/esm/searchParams.js.map +1 -0
  244. package/dist/esm/ssr/client.d.ts +6 -0
  245. package/dist/esm/ssr/client.js +4 -0
  246. package/dist/esm/ssr/constants.d.ts +3 -0
  247. package/dist/esm/ssr/constants.js +7 -0
  248. package/dist/esm/ssr/constants.js.map +1 -0
  249. package/dist/esm/ssr/createRequestHandler.d.ts +9 -0
  250. package/dist/esm/ssr/createRequestHandler.js +44 -0
  251. package/dist/esm/ssr/createRequestHandler.js.map +1 -0
  252. package/dist/esm/ssr/handlerCallback.d.ts +9 -0
  253. package/dist/esm/ssr/handlerCallback.js +8 -0
  254. package/dist/esm/ssr/handlerCallback.js.map +1 -0
  255. package/dist/esm/ssr/headers.d.ts +3 -0
  256. package/dist/esm/ssr/headers.js +21 -0
  257. package/dist/esm/ssr/headers.js.map +1 -0
  258. package/dist/esm/ssr/json.d.ts +10 -0
  259. package/dist/esm/ssr/json.js +11 -0
  260. package/dist/esm/ssr/json.js.map +1 -0
  261. package/dist/esm/ssr/serializer/RawStream.d.ts +64 -0
  262. package/dist/esm/ssr/serializer/RawStream.js +282 -0
  263. package/dist/esm/ssr/serializer/RawStream.js.map +1 -0
  264. package/dist/esm/ssr/serializer/ShallowErrorPlugin.d.ts +9 -0
  265. package/dist/esm/ssr/serializer/ShallowErrorPlugin.js +33 -0
  266. package/dist/esm/ssr/serializer/ShallowErrorPlugin.js.map +1 -0
  267. package/dist/esm/ssr/serializer/seroval-plugins.d.ts +2 -0
  268. package/dist/esm/ssr/serializer/seroval-plugins.js +13 -0
  269. package/dist/esm/ssr/serializer/seroval-plugins.js.map +1 -0
  270. package/dist/esm/ssr/serializer/transformer.d.ts +91 -0
  271. package/dist/esm/ssr/serializer/transformer.js +51 -0
  272. package/dist/esm/ssr/serializer/transformer.js.map +1 -0
  273. package/dist/esm/ssr/server.d.ts +6 -0
  274. package/dist/esm/ssr/server.js +5 -0
  275. package/dist/esm/ssr/ssr-client.d.ts +10 -0
  276. package/dist/esm/ssr/ssr-client.js +183 -0
  277. package/dist/esm/ssr/ssr-client.js.map +1 -0
  278. package/dist/esm/ssr/ssr-match-id.d.ts +2 -0
  279. package/dist/esm/ssr/ssr-match-id.js +11 -0
  280. package/dist/esm/ssr/ssr-match-id.js.map +1 -0
  281. package/dist/esm/ssr/ssr-server.d.ts +42 -0
  282. package/dist/esm/ssr/ssr-server.js +277 -0
  283. package/dist/esm/ssr/ssr-server.js.map +1 -0
  284. package/dist/esm/ssr/transformStreamWithRouter.d.ts +11 -0
  285. package/dist/esm/ssr/transformStreamWithRouter.js +325 -0
  286. package/dist/esm/ssr/transformStreamWithRouter.js.map +1 -0
  287. package/dist/esm/ssr/tsrScript.d.ts +0 -0
  288. package/dist/esm/ssr/tsrScript.js +6 -0
  289. package/dist/esm/ssr/tsrScript.js.map +1 -0
  290. package/dist/esm/ssr/types.d.ts +30 -0
  291. package/dist/esm/stores.d.ts +70 -0
  292. package/dist/esm/stores.js +146 -0
  293. package/dist/esm/stores.js.map +1 -0
  294. package/dist/esm/structuralSharing.d.ts +4 -0
  295. package/dist/esm/typePrimitives.d.ts +65 -0
  296. package/dist/esm/useLoaderData.d.ts +5 -0
  297. package/dist/esm/useLoaderDeps.d.ts +5 -0
  298. package/dist/esm/useNavigate.d.ts +3 -0
  299. package/dist/esm/useParams.d.ts +5 -0
  300. package/dist/esm/useRouteContext.d.ts +9 -0
  301. package/dist/esm/useSearch.d.ts +5 -0
  302. package/dist/esm/utils.d.ts +178 -0
  303. package/dist/esm/utils.js +322 -0
  304. package/dist/esm/utils.js.map +1 -0
  305. package/dist/esm/validators.d.ts +51 -0
  306. package/package.json +200 -0
  307. package/skills/router-core/SKILL.md +139 -0
  308. package/skills/router-core/auth-and-guards/SKILL.md +458 -0
  309. package/skills/router-core/code-splitting/SKILL.md +322 -0
  310. package/skills/router-core/data-loading/SKILL.md +485 -0
  311. package/skills/router-core/navigation/SKILL.md +448 -0
  312. package/skills/router-core/not-found-and-errors/SKILL.md +435 -0
  313. package/skills/router-core/path-params/SKILL.md +382 -0
  314. package/skills/router-core/search-params/SKILL.md +349 -0
  315. package/skills/router-core/search-params/references/validation-patterns.md +379 -0
  316. package/skills/router-core/ssr/SKILL.md +437 -0
  317. package/skills/router-core/type-safety/SKILL.md +497 -0
  318. package/src/Matches.ts +291 -0
  319. package/src/RouterProvider.ts +47 -0
  320. package/src/config.ts +42 -0
  321. package/src/defer.ts +69 -0
  322. package/src/fileRoute.ts +164 -0
  323. package/src/global.ts +9 -0
  324. package/src/hash-scroll.ts +21 -0
  325. package/src/history.ts +9 -0
  326. package/src/index.ts +471 -0
  327. package/src/invariant.ts +3 -0
  328. package/src/isServer/client.ts +1 -0
  329. package/src/isServer/development.ts +2 -0
  330. package/src/isServer/server.ts +1 -0
  331. package/src/link.ts +704 -0
  332. package/src/load-matches.ts +1281 -0
  333. package/src/location.ts +51 -0
  334. package/src/lru-cache.ts +74 -0
  335. package/src/manifest.ts +68 -0
  336. package/src/new-process-route-tree.ts +1387 -0
  337. package/src/not-found.ts +41 -0
  338. package/src/path.ts +436 -0
  339. package/src/qss.ts +81 -0
  340. package/src/redirect.ts +179 -0
  341. package/src/rewrite.ts +93 -0
  342. package/src/root.ts +3 -0
  343. package/src/route.ts +2235 -0
  344. package/src/routeInfo.ts +235 -0
  345. package/src/router.ts +3207 -0
  346. package/src/scroll-restoration-inline.ts +81 -0
  347. package/src/scroll-restoration-script/client.ts +5 -0
  348. package/src/scroll-restoration-script/server.ts +64 -0
  349. package/src/scroll-restoration.ts +357 -0
  350. package/src/searchMiddleware.ts +76 -0
  351. package/src/searchParams.ts +90 -0
  352. package/src/ssr/client.ts +6 -0
  353. package/src/ssr/constants.ts +3 -0
  354. package/src/ssr/createRequestHandler.ts +98 -0
  355. package/src/ssr/handlerCallback.ts +15 -0
  356. package/src/ssr/headers.ts +40 -0
  357. package/src/ssr/json.ts +16 -0
  358. package/src/ssr/serializer/RawStream.ts +464 -0
  359. package/src/ssr/serializer/ShallowErrorPlugin.ts +43 -0
  360. package/src/ssr/serializer/seroval-plugins.ts +12 -0
  361. package/src/ssr/serializer/transformer.ts +312 -0
  362. package/src/ssr/server.ts +14 -0
  363. package/src/ssr/ssr-client.ts +313 -0
  364. package/src/ssr/ssr-match-id.ts +7 -0
  365. package/src/ssr/ssr-server.ts +425 -0
  366. package/src/ssr/transformStreamWithRouter.ts +493 -0
  367. package/src/ssr/tsrScript.ts +20 -0
  368. package/src/ssr/types.ts +41 -0
  369. package/src/stores.ts +342 -0
  370. package/src/structuralSharing.ts +7 -0
  371. package/src/typePrimitives.ts +181 -0
  372. package/src/useLoaderData.ts +20 -0
  373. package/src/useLoaderDeps.ts +13 -0
  374. package/src/useNavigate.ts +13 -0
  375. package/src/useParams.ts +20 -0
  376. package/src/useRouteContext.ts +39 -0
  377. package/src/useSearch.ts +20 -0
  378. package/src/utils.ts +708 -0
  379. package/src/validators.ts +121 -0
  380. package/src/vite-env.d.ts +4 -0
@@ -0,0 +1,65 @@
1
+ import { FromPathOption, NavigateOptions, PathParamOptions, SearchParamOptions, ToPathOption } from './link.js';
2
+ import { RedirectOptions } from './redirect.js';
3
+ import { RouteIds } from './routeInfo.js';
4
+ import { AnyRouter, RegisteredRouter } from './router.js';
5
+ import { UseParamsResult } from './useParams.js';
6
+ import { UseSearchResult } from './useSearch.js';
7
+ import { Constrain, ConstrainLiteral } from './utils.js';
8
+ export type ValidateFromPath<TRouter extends AnyRouter = RegisteredRouter, TFrom = string> = FromPathOption<TRouter, TFrom>;
9
+ export type ValidateToPath<TRouter extends AnyRouter = RegisteredRouter, TTo extends string | undefined = undefined, TFrom extends string = string> = ToPathOption<TRouter, TFrom, TTo>;
10
+ export type ValidateSearch<TRouter extends AnyRouter = RegisteredRouter, TTo extends string | undefined = undefined, TFrom extends string = string> = SearchParamOptions<TRouter, TFrom, TTo>;
11
+ export type ValidateParams<TRouter extends AnyRouter = RegisteredRouter, TTo extends string | undefined = undefined, TFrom extends string = string> = PathParamOptions<TRouter, TFrom, TTo>;
12
+ /**
13
+ * @private
14
+ */
15
+ export type InferFrom<TOptions, TDefaultFrom extends string = string> = TOptions extends {
16
+ from: infer TFrom extends string;
17
+ } ? TFrom : TDefaultFrom;
18
+ /**
19
+ * @private
20
+ */
21
+ export type InferTo<TOptions> = TOptions extends {
22
+ to: infer TTo extends string;
23
+ } ? TTo : undefined;
24
+ /**
25
+ * @private
26
+ */
27
+ export type InferMaskTo<TOptions> = TOptions extends {
28
+ mask: {
29
+ to: infer TTo extends string;
30
+ };
31
+ } ? TTo : '';
32
+ export type InferMaskFrom<TOptions> = TOptions extends {
33
+ mask: {
34
+ from: infer TFrom extends string;
35
+ };
36
+ } ? TFrom : string;
37
+ export type ValidateNavigateOptions<TRouter extends AnyRouter = RegisteredRouter, TOptions = unknown, TDefaultFrom extends string = string> = Constrain<TOptions, NavigateOptions<TRouter, InferFrom<TOptions, TDefaultFrom>, InferTo<TOptions>, InferMaskFrom<TOptions>, InferMaskTo<TOptions>>>;
38
+ export type ValidateNavigateOptionsArray<TRouter extends AnyRouter = RegisteredRouter, TOptions extends ReadonlyArray<any> = ReadonlyArray<unknown>, TDefaultFrom extends string = string> = {
39
+ [K in keyof TOptions]: ValidateNavigateOptions<TRouter, TOptions[K], TDefaultFrom>;
40
+ };
41
+ export type ValidateRedirectOptions<TRouter extends AnyRouter = RegisteredRouter, TOptions = unknown, TDefaultFrom extends string = string> = Constrain<TOptions, RedirectOptions<TRouter, InferFrom<TOptions, TDefaultFrom>, InferTo<TOptions>, InferMaskFrom<TOptions>, InferMaskTo<TOptions>>>;
42
+ export type ValidateRedirectOptionsArray<TRouter extends AnyRouter = RegisteredRouter, TOptions extends ReadonlyArray<any> = ReadonlyArray<unknown>, TDefaultFrom extends string = string> = {
43
+ [K in keyof TOptions]: ValidateRedirectOptions<TRouter, TOptions[K], TDefaultFrom>;
44
+ };
45
+ export type ValidateId<TRouter extends AnyRouter = RegisteredRouter, TId extends string = string> = ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>;
46
+ /**
47
+ * @private
48
+ */
49
+ export type InferStrict<TOptions> = TOptions extends {
50
+ strict: infer TStrict extends boolean;
51
+ } ? TStrict : true;
52
+ /**
53
+ * @private
54
+ */
55
+ export type InferShouldThrow<TOptions> = TOptions extends {
56
+ shouldThrow: infer TShouldThrow extends boolean;
57
+ } ? TShouldThrow : true;
58
+ /**
59
+ * @private
60
+ */
61
+ export type InferSelected<TOptions> = TOptions extends {
62
+ select: (...args: Array<any>) => infer TSelected;
63
+ } ? TSelected : unknown;
64
+ export type ValidateUseSearchResult<TOptions, TRouter extends AnyRouter = RegisteredRouter> = UseSearchResult<TRouter, InferFrom<TOptions>, InferStrict<TOptions>, InferSelected<TOptions>>;
65
+ export type ValidateUseParamsResult<TOptions, TRouter extends AnyRouter = RegisteredRouter> = Constrain<TOptions, UseParamsResult<TRouter, InferFrom<TOptions>, InferStrict<TOptions>, InferSelected<TOptions>>>;
@@ -0,0 +1,5 @@
1
+ import { AllLoaderData, RouteById } from './routeInfo.js';
2
+ import { AnyRouter } from './router.js';
3
+ import { Expand } from './utils.js';
4
+ export type ResolveUseLoaderData<TRouter extends AnyRouter, TFrom, TStrict extends boolean> = TStrict extends false ? AllLoaderData<TRouter['routeTree']> : Expand<RouteById<TRouter['routeTree'], TFrom>['types']['loaderData']>;
5
+ export type UseLoaderDataResult<TRouter extends AnyRouter, TFrom, TStrict extends boolean, TSelected> = unknown extends TSelected ? ResolveUseLoaderData<TRouter, TFrom, TStrict> : TSelected;
@@ -0,0 +1,5 @@
1
+ import { RouteById } from './routeInfo.js';
2
+ import { AnyRouter } from './router.js';
3
+ import { Expand } from './utils.js';
4
+ export type ResolveUseLoaderDeps<TRouter extends AnyRouter, TFrom> = Expand<RouteById<TRouter['routeTree'], TFrom>['types']['loaderDeps']>;
5
+ export type UseLoaderDepsResult<TRouter extends AnyRouter, TFrom, TSelected> = unknown extends TSelected ? ResolveUseLoaderDeps<TRouter, TFrom> : TSelected;
@@ -0,0 +1,3 @@
1
+ import { NavigateOptions } from './link.js';
2
+ import { RegisteredRouter } from './router.js';
3
+ export type UseNavigateResult<TDefaultFrom extends string> = <TRouter extends RegisteredRouter, TTo extends string | undefined, TFrom extends string = TDefaultFrom, TMaskFrom extends string = TFrom, TMaskTo extends string = ''>({ from, ...rest }: NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>) => Promise<void>;
@@ -0,0 +1,5 @@
1
+ import { AllParams, RouteById } from './routeInfo.js';
2
+ import { AnyRouter } from './router.js';
3
+ import { Expand } from './utils.js';
4
+ export type ResolveUseParams<TRouter extends AnyRouter, TFrom, TStrict extends boolean> = TStrict extends false ? AllParams<TRouter['routeTree']> : Expand<RouteById<TRouter['routeTree'], TFrom>['types']['allParams']>;
5
+ export type UseParamsResult<TRouter extends AnyRouter, TFrom, TStrict extends boolean, TSelected> = unknown extends TSelected ? ResolveUseParams<TRouter, TFrom, TStrict> : TSelected;
@@ -0,0 +1,9 @@
1
+ import { AllContext, RouteById } from './routeInfo.js';
2
+ import { AnyRouter } from './router.js';
3
+ import { Expand, StrictOrFrom } from './utils.js';
4
+ export interface UseRouteContextBaseOptions<TRouter extends AnyRouter, TFrom, TStrict extends boolean, TSelected> {
5
+ select?: (search: ResolveUseRouteContext<TRouter, TFrom, TStrict>) => TSelected;
6
+ }
7
+ export type UseRouteContextOptions<TRouter extends AnyRouter, TFrom extends string | undefined, TStrict extends boolean, TSelected> = StrictOrFrom<TRouter, TFrom, TStrict> & UseRouteContextBaseOptions<TRouter, TFrom, TStrict, TSelected>;
8
+ export type ResolveUseRouteContext<TRouter extends AnyRouter, TFrom, TStrict extends boolean> = TStrict extends false ? AllContext<TRouter['routeTree']> : Expand<RouteById<TRouter['routeTree'], TFrom>['types']['allContext']>;
9
+ export type UseRouteContextResult<TRouter extends AnyRouter, TFrom, TStrict extends boolean, TSelected> = unknown extends TSelected ? ResolveUseRouteContext<TRouter, TFrom, TStrict> : TSelected;
@@ -0,0 +1,5 @@
1
+ import { FullSearchSchema, RouteById } from './routeInfo.js';
2
+ import { AnyRouter } from './router.js';
3
+ import { Expand } from './utils.js';
4
+ export type UseSearchResult<TRouter extends AnyRouter, TFrom, TStrict extends boolean, TSelected> = unknown extends TSelected ? ResolveUseSearch<TRouter, TFrom, TStrict> : TSelected;
5
+ export type ResolveUseSearch<TRouter extends AnyRouter, TFrom, TStrict extends boolean> = TStrict extends false ? FullSearchSchema<TRouter['routeTree']> : Expand<RouteById<TRouter['routeTree'], TFrom>['types']['fullSearchSchema']>;
@@ -0,0 +1,178 @@
1
+ import { RouteIds } from './routeInfo.js';
2
+ import { AnyRouter } from './router.js';
3
+ export type Awaitable<T> = T | Promise<T>;
4
+ export type NoInfer<T> = [T][T extends any ? 0 : never];
5
+ export type IsAny<TValue, TYesResult, TNoResult = TValue> = 1 extends 0 & TValue ? TYesResult : TNoResult;
6
+ export type PickAsRequired<TValue, TKey extends keyof TValue> = Omit<TValue, TKey> & Required<Pick<TValue, TKey>>;
7
+ export type PickRequired<T> = {
8
+ [K in keyof T as undefined extends T[K] ? never : K]: T[K];
9
+ };
10
+ export type PickOptional<T> = {
11
+ [K in keyof T as undefined extends T[K] ? K : never]: T[K];
12
+ };
13
+ export type WithoutEmpty<T> = T extends any ? ({} extends T ? never : T) : never;
14
+ export type Expand<T> = T extends object ? T extends infer O ? O extends Function ? O : {
15
+ [K in keyof O]: O[K];
16
+ } : never : T;
17
+ export type DeepPartial<T> = T extends object ? {
18
+ [P in keyof T]?: DeepPartial<T[P]>;
19
+ } : T;
20
+ export type MakeDifferenceOptional<TLeft, TRight> = keyof TLeft & keyof TRight extends never ? TRight : Omit<TRight, keyof TLeft & keyof TRight> & {
21
+ [K in keyof TLeft & keyof TRight]?: TRight[K];
22
+ };
23
+ export type IsUnion<T, U extends T = T> = (T extends any ? (U extends T ? false : true) : never) extends false ? false : true;
24
+ export type IsNonEmptyObject<T> = T extends object ? keyof T extends never ? false : true : false;
25
+ export type Assign<TLeft, TRight> = TLeft extends any ? TRight extends any ? IsNonEmptyObject<TLeft> extends false ? TRight : IsNonEmptyObject<TRight> extends false ? TLeft : keyof TLeft & keyof TRight extends never ? TLeft & TRight : Omit<TLeft, keyof TRight> & TRight : never : never;
26
+ export type IntersectAssign<TLeft, TRight> = TLeft extends any ? TRight extends any ? IsNonEmptyObject<TLeft> extends false ? TRight : IsNonEmptyObject<TRight> extends false ? TLeft : TRight & TLeft : never : never;
27
+ export type Timeout = ReturnType<typeof setTimeout>;
28
+ export type Updater<TPrevious, TResult = TPrevious> = TResult | ((prev?: TPrevious) => TResult);
29
+ export type NonNullableUpdater<TPrevious, TResult = TPrevious> = TResult | ((prev: TPrevious) => TResult);
30
+ export type ExtractObjects<TUnion> = TUnion extends MergeAllPrimitive ? never : TUnion;
31
+ export type PartialMergeAllObject<TUnion> = ExtractObjects<TUnion> extends infer TObj ? [TObj] extends [never] ? never : {
32
+ [TKey in TObj extends any ? keyof TObj : never]?: TObj extends any ? TKey extends keyof TObj ? TObj[TKey] : never : never;
33
+ } : never;
34
+ export type MergeAllPrimitive = ReadonlyArray<any> | number | string | bigint | boolean | symbol | undefined | null;
35
+ export type ExtractPrimitives<TUnion> = TUnion extends MergeAllPrimitive ? TUnion : TUnion extends object ? never : TUnion;
36
+ export type PartialMergeAll<TUnion> = ExtractPrimitives<TUnion> | PartialMergeAllObject<TUnion>;
37
+ export type Constrain<T, TConstraint, TDefault = TConstraint> = (T extends TConstraint ? T : never) | TDefault;
38
+ export type ConstrainLiteral<T, TConstraint, TDefault = TConstraint> = (T & TConstraint) | TDefault;
39
+ /**
40
+ * To be added to router types
41
+ */
42
+ export type UnionToIntersection<T> = (T extends any ? (arg: T) => any : never) extends (arg: infer T) => any ? T : never;
43
+ /**
44
+ * Merges everything in a union into one object.
45
+ * This mapped type is homomorphic which means it preserves stuff! :)
46
+ */
47
+ export type MergeAllObjects<TUnion, TIntersected = UnionToIntersection<ExtractObjects<TUnion>>> = [keyof TIntersected] extends [never] ? never : {
48
+ [TKey in keyof TIntersected]: TUnion extends any ? TUnion[TKey & keyof TUnion] : never;
49
+ };
50
+ export type MergeAll<TUnion> = MergeAllObjects<TUnion> | ExtractPrimitives<TUnion>;
51
+ export type ValidateJSON<T> = ((...args: Array<any>) => any) extends T ? unknown extends T ? never : 'Function is not serializable' : {
52
+ [K in keyof T]: ValidateJSON<T[K]>;
53
+ };
54
+ export type LooseReturnType<T> = T extends (...args: Array<any>) => infer TReturn ? TReturn : never;
55
+ export type LooseAsyncReturnType<T> = T extends (...args: Array<any>) => infer TReturn ? TReturn extends Promise<infer TReturn> ? TReturn : TReturn : never;
56
+ /**
57
+ * Return the last element of an array.
58
+ * Intended for non-empty arrays used within router internals.
59
+ */
60
+ export declare function last<T>(arr: ReadonlyArray<T>): T | undefined;
61
+ /**
62
+ * Apply a value-or-updater to a previous value.
63
+ * Accepts either a literal value or a function of the previous value.
64
+ */
65
+ export declare function functionalUpdate<TPrevious, TResult = TPrevious>(updater: Updater<TPrevious, TResult> | NonNullableUpdater<TPrevious, TResult>, previous: TPrevious): TResult;
66
+ export declare const nullReplaceEqualDeep: typeof replaceEqualDeep;
67
+ /**
68
+ * This function returns `prev` if `_next` is deeply equal.
69
+ * If not, it will replace any deeply equal children of `b` with those of `a`.
70
+ * This can be used for structural sharing between immutable JSON values for example.
71
+ * Do not use this with signals
72
+ */
73
+ export declare function replaceEqualDeep<T>(prev: any, _next: T, _makeObj?: () => {}, _depth?: number): T;
74
+ export declare function isPlainObject(o: any): boolean;
75
+ /**
76
+ * Check if a value is a "plain" array (no extra enumerable keys).
77
+ */
78
+ export declare function isPlainArray(value: unknown): value is Array<unknown>;
79
+ /**
80
+ * Perform a deep equality check with options for partial comparison and
81
+ * ignoring `undefined` values. Optimized for router state comparisons.
82
+ */
83
+ export declare function deepEqual(a: any, b: any, opts?: {
84
+ partial?: boolean;
85
+ ignoreUndefined?: boolean;
86
+ }): boolean;
87
+ export type StringLiteral<T> = T extends string ? string extends T ? string : T : never;
88
+ export type ThrowOrOptional<T, TThrow extends boolean> = TThrow extends true ? T : T | undefined;
89
+ export type StrictOrFrom<TRouter extends AnyRouter, TFrom, TStrict extends boolean = true> = TStrict extends false ? {
90
+ from?: never;
91
+ strict: TStrict;
92
+ } : {
93
+ from: ConstrainLiteral<TFrom, RouteIds<TRouter['routeTree']>>;
94
+ strict?: TStrict;
95
+ };
96
+ export type ThrowConstraint<TStrict extends boolean, TThrow extends boolean> = TStrict extends false ? (TThrow extends true ? never : TThrow) : TThrow;
97
+ export type ControlledPromise<T> = Promise<T> & {
98
+ resolve: (value: T) => void;
99
+ reject: (value: any) => void;
100
+ status: 'pending' | 'resolved' | 'rejected';
101
+ value?: T;
102
+ };
103
+ /**
104
+ * Create a promise with exposed resolve/reject and status fields.
105
+ * Useful for coordinating async router lifecycle operations.
106
+ */
107
+ export declare function createControlledPromise<T>(onResolve?: (value: T) => void): ControlledPromise<T>;
108
+ /**
109
+ * Heuristically detect dynamic import "module not found" errors
110
+ * across major browsers for lazy route component handling.
111
+ */
112
+ export declare function isModuleNotFoundError(error: any): boolean;
113
+ export declare function isPromise<T>(value: Promise<Awaited<T>> | T): value is Promise<Awaited<T>>;
114
+ export declare function findLast<T>(array: ReadonlyArray<T>, predicate: (item: T) => boolean): T | undefined;
115
+ /**
116
+ * Default list of URL protocols to allow in links, redirects, and navigation.
117
+ * Any absolute URL protocol not in this list is treated as dangerous by default.
118
+ */
119
+ export declare const DEFAULT_PROTOCOL_ALLOWLIST: string[];
120
+ /**
121
+ * Check if a URL string uses a protocol that is not in the allowlist.
122
+ * Returns true for blocked protocols like javascript:, blob:, data:, etc.
123
+ *
124
+ * The URL constructor correctly normalizes:
125
+ * - Mixed case (JavaScript: → javascript:)
126
+ * - Whitespace/control characters (java\nscript: → javascript:)
127
+ * - Leading whitespace
128
+ *
129
+ * For relative URLs (no protocol), returns false (safe).
130
+ *
131
+ * @param url - The URL string to check
132
+ * @param allowlist - Set of protocols to allow
133
+ * @returns true if the URL uses a protocol that is not allowed
134
+ */
135
+ export declare function isDangerousProtocol(url: string, allowlist: Set<string>): boolean;
136
+ /**
137
+ * Escape HTML special characters in a string to prevent XSS attacks
138
+ * when embedding strings in script tags during SSR.
139
+ *
140
+ * This is essential for preventing XSS vulnerabilities when user-controlled
141
+ * content is embedded in inline scripts.
142
+ */
143
+ export declare function escapeHtml(str: string): string;
144
+ export declare function decodePath(path: string): {
145
+ path: string;
146
+ handledProtocolRelativeURL: boolean;
147
+ };
148
+ /**
149
+ * Encodes a path the same way `new URL()` would, but without the overhead of full URL parsing.
150
+ *
151
+ * This function encodes:
152
+ * - Whitespace characters (spaces → %20, tabs → %09, etc.)
153
+ * - Non-ASCII/Unicode characters (emojis, accented characters, etc.)
154
+ *
155
+ * It preserves:
156
+ * - Already percent-encoded sequences (won't double-encode %2F, %25, etc.)
157
+ * - ASCII special characters valid in URL paths (@, $, &, +, etc.)
158
+ * - Forward slashes as path separators
159
+ *
160
+ * Used to generate proper href values for SSR without constructing URL objects.
161
+ *
162
+ * @example
163
+ * encodePathLikeUrl('/path/file name.pdf') // '/path/file%20name.pdf'
164
+ * encodePathLikeUrl('/path/日本語') // '/path/%E6%97%A5%E6%9C%AC%E8%AA%9E'
165
+ * encodePathLikeUrl('/path/already%20encoded') // '/path/already%20encoded' (preserved)
166
+ */
167
+ export declare function encodePathLikeUrl(path: string): string;
168
+ /**
169
+ * Builds the dev-mode CSS styles URL for route-scoped CSS collection.
170
+ * Used by HeadContent components in all framework implementations to construct
171
+ * the URL for the `/@tanstack-start/styles.css` endpoint.
172
+ *
173
+ * @param basepath - The router's basepath (may or may not have leading slash)
174
+ * @param routeIds - Array of matched route IDs to include in the CSS collection
175
+ * @returns The full URL path for the dev styles CSS endpoint
176
+ */
177
+ export declare function buildDevStylesUrl(basepath: string, routeIds: Array<string>): string;
178
+ export declare function arraysEqual<T>(a: Array<T>, b: Array<T>): boolean;
@@ -0,0 +1,322 @@
1
+ import { isServer } from "@benjavicente/router-core/isServer";
2
+ //#region src/utils.ts
3
+ /**
4
+ * Return the last element of an array.
5
+ * Intended for non-empty arrays used within router internals.
6
+ */
7
+ function last(arr) {
8
+ return arr[arr.length - 1];
9
+ }
10
+ function isFunction(d) {
11
+ return typeof d === "function";
12
+ }
13
+ /**
14
+ * Apply a value-or-updater to a previous value.
15
+ * Accepts either a literal value or a function of the previous value.
16
+ */
17
+ function functionalUpdate(updater, previous) {
18
+ if (isFunction(updater)) return updater(previous);
19
+ return updater;
20
+ }
21
+ var hasOwn = Object.prototype.hasOwnProperty;
22
+ var isEnumerable = Object.prototype.propertyIsEnumerable;
23
+ var createNull = () => Object.create(null);
24
+ var nullReplaceEqualDeep = (prev, next) => replaceEqualDeep(prev, next, createNull);
25
+ /**
26
+ * This function returns `prev` if `_next` is deeply equal.
27
+ * If not, it will replace any deeply equal children of `b` with those of `a`.
28
+ * This can be used for structural sharing between immutable JSON values for example.
29
+ * Do not use this with signals
30
+ */
31
+ function replaceEqualDeep(prev, _next, _makeObj = () => ({}), _depth = 0) {
32
+ if (isServer) return _next;
33
+ if (prev === _next) return prev;
34
+ if (_depth > 500) return _next;
35
+ const next = _next;
36
+ const array = isPlainArray(prev) && isPlainArray(next);
37
+ if (!array && !(isPlainObject(prev) && isPlainObject(next))) return next;
38
+ const prevItems = array ? prev : getEnumerableOwnKeys(prev);
39
+ if (!prevItems) return next;
40
+ const nextItems = array ? next : getEnumerableOwnKeys(next);
41
+ if (!nextItems) return next;
42
+ const prevSize = prevItems.length;
43
+ const nextSize = nextItems.length;
44
+ const copy = array ? new Array(nextSize) : _makeObj();
45
+ let equalItems = 0;
46
+ for (let i = 0; i < nextSize; i++) {
47
+ const key = array ? i : nextItems[i];
48
+ const p = prev[key];
49
+ const n = next[key];
50
+ if (p === n) {
51
+ copy[key] = p;
52
+ if (array ? i < prevSize : hasOwn.call(prev, key)) equalItems++;
53
+ continue;
54
+ }
55
+ if (p === null || n === null || typeof p !== "object" || typeof n !== "object") {
56
+ copy[key] = n;
57
+ continue;
58
+ }
59
+ const v = replaceEqualDeep(p, n, _makeObj, _depth + 1);
60
+ copy[key] = v;
61
+ if (v === p) equalItems++;
62
+ }
63
+ return prevSize === nextSize && equalItems === prevSize ? prev : copy;
64
+ }
65
+ /**
66
+ * Equivalent to `Reflect.ownKeys`, but ensures that objects are "clone-friendly":
67
+ * will return false if object has any non-enumerable properties.
68
+ *
69
+ * Optimized for the common case where objects have no symbol properties.
70
+ */
71
+ function getEnumerableOwnKeys(o) {
72
+ const names = Object.getOwnPropertyNames(o);
73
+ for (const name of names) if (!isEnumerable.call(o, name)) return false;
74
+ const symbols = Object.getOwnPropertySymbols(o);
75
+ if (symbols.length === 0) return names;
76
+ const keys = names;
77
+ for (const symbol of symbols) {
78
+ if (!isEnumerable.call(o, symbol)) return false;
79
+ keys.push(symbol);
80
+ }
81
+ return keys;
82
+ }
83
+ function isPlainObject(o) {
84
+ if (!hasObjectPrototype(o)) return false;
85
+ const ctor = o.constructor;
86
+ if (typeof ctor === "undefined") return true;
87
+ const prot = ctor.prototype;
88
+ if (!hasObjectPrototype(prot)) return false;
89
+ if (!prot.hasOwnProperty("isPrototypeOf")) return false;
90
+ return true;
91
+ }
92
+ function hasObjectPrototype(o) {
93
+ return Object.prototype.toString.call(o) === "[object Object]";
94
+ }
95
+ /**
96
+ * Check if a value is a "plain" array (no extra enumerable keys).
97
+ */
98
+ function isPlainArray(value) {
99
+ return Array.isArray(value) && value.length === Object.keys(value).length;
100
+ }
101
+ /**
102
+ * Perform a deep equality check with options for partial comparison and
103
+ * ignoring `undefined` values. Optimized for router state comparisons.
104
+ */
105
+ function deepEqual(a, b, opts) {
106
+ if (a === b) return true;
107
+ if (typeof a !== typeof b) return false;
108
+ if (Array.isArray(a) && Array.isArray(b)) {
109
+ if (a.length !== b.length) return false;
110
+ for (let i = 0, l = a.length; i < l; i++) if (!deepEqual(a[i], b[i], opts)) return false;
111
+ return true;
112
+ }
113
+ if (isPlainObject(a) && isPlainObject(b)) {
114
+ const ignoreUndefined = opts?.ignoreUndefined ?? true;
115
+ if (opts?.partial) {
116
+ for (const k in b) if (!ignoreUndefined || b[k] !== void 0) {
117
+ if (!deepEqual(a[k], b[k], opts)) return false;
118
+ }
119
+ return true;
120
+ }
121
+ let aCount = 0;
122
+ if (!ignoreUndefined) aCount = Object.keys(a).length;
123
+ else for (const k in a) if (a[k] !== void 0) aCount++;
124
+ let bCount = 0;
125
+ for (const k in b) if (!ignoreUndefined || b[k] !== void 0) {
126
+ bCount++;
127
+ if (bCount > aCount || !deepEqual(a[k], b[k], opts)) return false;
128
+ }
129
+ return aCount === bCount;
130
+ }
131
+ return false;
132
+ }
133
+ /**
134
+ * Create a promise with exposed resolve/reject and status fields.
135
+ * Useful for coordinating async router lifecycle operations.
136
+ */
137
+ function createControlledPromise(onResolve) {
138
+ let resolveLoadPromise;
139
+ let rejectLoadPromise;
140
+ const controlledPromise = new Promise((resolve, reject) => {
141
+ resolveLoadPromise = resolve;
142
+ rejectLoadPromise = reject;
143
+ });
144
+ controlledPromise.status = "pending";
145
+ controlledPromise.resolve = (value) => {
146
+ controlledPromise.status = "resolved";
147
+ controlledPromise.value = value;
148
+ resolveLoadPromise(value);
149
+ onResolve?.(value);
150
+ };
151
+ controlledPromise.reject = (e) => {
152
+ controlledPromise.status = "rejected";
153
+ rejectLoadPromise(e);
154
+ };
155
+ return controlledPromise;
156
+ }
157
+ /**
158
+ * Heuristically detect dynamic import "module not found" errors
159
+ * across major browsers for lazy route component handling.
160
+ */
161
+ function isModuleNotFoundError(error) {
162
+ if (typeof error?.message !== "string") return false;
163
+ return error.message.startsWith("Failed to fetch dynamically imported module") || error.message.startsWith("error loading dynamically imported module") || error.message.startsWith("Importing a module script failed");
164
+ }
165
+ function isPromise(value) {
166
+ return Boolean(value && typeof value === "object" && typeof value.then === "function");
167
+ }
168
+ function findLast(array, predicate) {
169
+ for (let i = array.length - 1; i >= 0; i--) {
170
+ const item = array[i];
171
+ if (predicate(item)) return item;
172
+ }
173
+ }
174
+ /**
175
+ * Remove control characters that can cause open redirect vulnerabilities.
176
+ * Characters like \r (CR) and \n (LF) can trick URL parsers into interpreting
177
+ * paths like "/\r/evil.com" as "http://evil.com".
178
+ */
179
+ function sanitizePathSegment(segment) {
180
+ return segment.replace(/[\x00-\x1f\x7f]/g, "");
181
+ }
182
+ function decodeSegment(segment) {
183
+ let decoded;
184
+ try {
185
+ decoded = decodeURI(segment);
186
+ } catch {
187
+ decoded = segment.replaceAll(/%[0-9A-F]{2}/gi, (match) => {
188
+ try {
189
+ return decodeURI(match);
190
+ } catch {
191
+ return match;
192
+ }
193
+ });
194
+ }
195
+ return sanitizePathSegment(decoded);
196
+ }
197
+ /**
198
+ * Default list of URL protocols to allow in links, redirects, and navigation.
199
+ * Any absolute URL protocol not in this list is treated as dangerous by default.
200
+ */
201
+ var DEFAULT_PROTOCOL_ALLOWLIST = [
202
+ "http:",
203
+ "https:",
204
+ "mailto:",
205
+ "tel:"
206
+ ];
207
+ /**
208
+ * Check if a URL string uses a protocol that is not in the allowlist.
209
+ * Returns true for blocked protocols like javascript:, blob:, data:, etc.
210
+ *
211
+ * The URL constructor correctly normalizes:
212
+ * - Mixed case (JavaScript: → javascript:)
213
+ * - Whitespace/control characters (java\nscript: → javascript:)
214
+ * - Leading whitespace
215
+ *
216
+ * For relative URLs (no protocol), returns false (safe).
217
+ *
218
+ * @param url - The URL string to check
219
+ * @param allowlist - Set of protocols to allow
220
+ * @returns true if the URL uses a protocol that is not allowed
221
+ */
222
+ function isDangerousProtocol(url, allowlist) {
223
+ if (!url) return false;
224
+ try {
225
+ const parsed = new URL(url);
226
+ return !allowlist.has(parsed.protocol);
227
+ } catch {
228
+ return false;
229
+ }
230
+ }
231
+ var HTML_ESCAPE_LOOKUP = {
232
+ "&": "\\u0026",
233
+ ">": "\\u003e",
234
+ "<": "\\u003c",
235
+ "\u2028": "\\u2028",
236
+ "\u2029": "\\u2029"
237
+ };
238
+ var HTML_ESCAPE_REGEX = /[&><\u2028\u2029]/g;
239
+ /**
240
+ * Escape HTML special characters in a string to prevent XSS attacks
241
+ * when embedding strings in script tags during SSR.
242
+ *
243
+ * This is essential for preventing XSS vulnerabilities when user-controlled
244
+ * content is embedded in inline scripts.
245
+ */
246
+ function escapeHtml(str) {
247
+ return str.replace(HTML_ESCAPE_REGEX, (match) => HTML_ESCAPE_LOOKUP[match]);
248
+ }
249
+ function decodePath(path) {
250
+ if (!path) return {
251
+ path,
252
+ handledProtocolRelativeURL: false
253
+ };
254
+ if (!/[%\\\x00-\x1f\x7f]/.test(path) && !path.startsWith("//")) return {
255
+ path,
256
+ handledProtocolRelativeURL: false
257
+ };
258
+ const re = /%25|%5C/gi;
259
+ let cursor = 0;
260
+ let result = "";
261
+ let match;
262
+ while (null !== (match = re.exec(path))) {
263
+ result += decodeSegment(path.slice(cursor, match.index)) + match[0];
264
+ cursor = re.lastIndex;
265
+ }
266
+ result = result + decodeSegment(cursor ? path.slice(cursor) : path);
267
+ let handledProtocolRelativeURL = false;
268
+ if (result.startsWith("//")) {
269
+ handledProtocolRelativeURL = true;
270
+ result = "/" + result.replace(/^\/+/, "");
271
+ }
272
+ return {
273
+ path: result,
274
+ handledProtocolRelativeURL
275
+ };
276
+ }
277
+ /**
278
+ * Encodes a path the same way `new URL()` would, but without the overhead of full URL parsing.
279
+ *
280
+ * This function encodes:
281
+ * - Whitespace characters (spaces → %20, tabs → %09, etc.)
282
+ * - Non-ASCII/Unicode characters (emojis, accented characters, etc.)
283
+ *
284
+ * It preserves:
285
+ * - Already percent-encoded sequences (won't double-encode %2F, %25, etc.)
286
+ * - ASCII special characters valid in URL paths (@, $, &, +, etc.)
287
+ * - Forward slashes as path separators
288
+ *
289
+ * Used to generate proper href values for SSR without constructing URL objects.
290
+ *
291
+ * @example
292
+ * encodePathLikeUrl('/path/file name.pdf') // '/path/file%20name.pdf'
293
+ * encodePathLikeUrl('/path/日本語') // '/path/%E6%97%A5%E6%9C%AC%E8%AA%9E'
294
+ * encodePathLikeUrl('/path/already%20encoded') // '/path/already%20encoded' (preserved)
295
+ */
296
+ function encodePathLikeUrl(path) {
297
+ if (!/\s|[^\u0000-\u007F]/.test(path)) return path;
298
+ return path.replace(/\s|[^\u0000-\u007F]/gu, encodeURIComponent);
299
+ }
300
+ /**
301
+ * Builds the dev-mode CSS styles URL for route-scoped CSS collection.
302
+ * Used by HeadContent components in all framework implementations to construct
303
+ * the URL for the `/@tanstack-start/styles.css` endpoint.
304
+ *
305
+ * @param basepath - The router's basepath (may or may not have leading slash)
306
+ * @param routeIds - Array of matched route IDs to include in the CSS collection
307
+ * @returns The full URL path for the dev styles CSS endpoint
308
+ */
309
+ function buildDevStylesUrl(basepath, routeIds) {
310
+ const trimmedBasepath = basepath.replace(/^\/+|\/+$/g, "");
311
+ return `${trimmedBasepath === "" ? "" : `/${trimmedBasepath}`}/@tanstack-start/styles.css?routes=${encodeURIComponent(routeIds.join(","))}`;
312
+ }
313
+ function arraysEqual(a, b) {
314
+ if (a === b) return true;
315
+ if (a.length !== b.length) return false;
316
+ for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
317
+ return true;
318
+ }
319
+ //#endregion
320
+ export { DEFAULT_PROTOCOL_ALLOWLIST, arraysEqual, buildDevStylesUrl, createControlledPromise, decodePath, deepEqual, encodePathLikeUrl, escapeHtml, findLast, functionalUpdate, isDangerousProtocol, isModuleNotFoundError, isPlainArray, isPlainObject, isPromise, last, nullReplaceEqualDeep, replaceEqualDeep };
321
+
322
+ //# sourceMappingURL=utils.js.map