soseki 0.0.5 → 0.0.7

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 (352) hide show
  1. package/LICENSE +21 -0
  2. package/dist/src/components/browser-router.d.ts +19 -0
  3. package/dist/src/components/browser-router.d.ts.map +1 -0
  4. package/dist/src/components/browser-router.jsx +15 -0
  5. package/dist/src/components/outlet.d.ts +8 -0
  6. package/dist/src/components/outlet.d.ts.map +1 -0
  7. package/dist/src/components/outlet.jsx +15 -0
  8. package/dist/src/components/router.d.ts +21 -0
  9. package/dist/src/components/router.d.ts.map +1 -0
  10. package/dist/src/components/router.jsx +138 -0
  11. package/dist/src/contexts/route-context.d.ts +19 -0
  12. package/dist/src/contexts/route-context.d.ts.map +1 -0
  13. package/dist/src/contexts/route-context.js +6 -0
  14. package/dist/src/contexts/router-context.d.ts +55 -0
  15. package/dist/src/contexts/router-context.d.ts.map +1 -0
  16. package/dist/src/contexts/router-context.js +8 -0
  17. package/dist/src/core/_compare-route-paths.d.ts +11 -0
  18. package/dist/src/core/_compare-route-paths.d.ts.map +1 -0
  19. package/dist/src/core/_compare-route-paths.js +92 -0
  20. package/dist/src/core/_match-route-path.d.ts +22 -0
  21. package/dist/src/core/_match-route-path.d.ts.map +1 -0
  22. package/dist/src/core/_match-route-path.js +26 -0
  23. package/dist/src/core/_process-routes.d.ts +14 -0
  24. package/dist/src/core/_process-routes.d.ts.map +1 -0
  25. package/dist/src/core/_process-routes.js +45 -0
  26. package/dist/src/core/_singleton.d.ts +12 -0
  27. package/dist/src/core/_singleton.d.ts.map +1 -0
  28. package/dist/src/core/_singleton.js +18 -0
  29. package/dist/src/core/_unreachable.d.ts +16 -0
  30. package/dist/src/core/_unreachable.d.ts.map +1 -0
  31. package/dist/src/core/_unreachable.js +8 -0
  32. package/dist/src/core/_valibot.d.ts +25 -0
  33. package/dist/src/core/_valibot.d.ts.map +1 -0
  34. package/dist/src/core/_valibot.js +30 -0
  35. package/dist/src/core/errors.d.ts +182 -0
  36. package/dist/src/core/errors.d.ts.map +1 -0
  37. package/dist/src/core/errors.js +166 -0
  38. package/dist/src/core/expect-history-entry.d.ts +59 -0
  39. package/dist/src/core/expect-history-entry.d.ts.map +1 -0
  40. package/dist/src/core/expect-history-entry.js +42 -0
  41. package/dist/src/core/form-data-to-html-form-element.d.ts +11 -0
  42. package/dist/src/core/form-data-to-html-form-element.d.ts.map +1 -0
  43. package/dist/src/core/form-data-to-html-form-element.js +31 -0
  44. package/dist/src/core/history-entry-id-schema.d.ts +17 -0
  45. package/dist/src/core/history-entry-id-schema.d.ts.map +1 -0
  46. package/dist/src/core/history-entry-id-schema.js +9 -0
  47. package/dist/src/core/history-entry-url-schema.d.ts +18 -0
  48. package/dist/src/core/history-entry-url-schema.d.ts.map +1 -0
  49. package/dist/src/core/history-entry-url-schema.js +20 -0
  50. package/dist/src/core/init-loaders.d.ts +28 -0
  51. package/dist/src/core/init-loaders.d.ts.map +1 -0
  52. package/dist/src/core/init-loaders.js +30 -0
  53. package/dist/src/core/match-routes.d.ts +28 -0
  54. package/dist/src/core/match-routes.d.ts.map +1 -0
  55. package/dist/src/core/match-routes.js +31 -0
  56. package/dist/src/core/readonly-form-data.types.d.ts +74 -0
  57. package/dist/src/core/readonly-form-data.types.d.ts.map +1 -0
  58. package/dist/src/core/readonly-url.types.d.ts +164 -0
  59. package/dist/src/core/readonly-url.types.d.ts.map +1 -0
  60. package/dist/src/core/redirect-response.d.ts +37 -0
  61. package/dist/src/core/redirect-response.d.ts.map +1 -0
  62. package/dist/src/core/redirect-response.js +19 -0
  63. package/dist/src/core/route-path.d.ts +57 -0
  64. package/dist/src/core/route-path.d.ts.map +1 -0
  65. package/dist/src/core/route-path.js +93 -0
  66. package/dist/src/core/route-request.d.ts +149 -0
  67. package/dist/src/core/route-request.d.ts.map +1 -0
  68. package/dist/src/core/route-request.js +41 -0
  69. package/dist/src/core/route.types.d.ts +296 -0
  70. package/dist/src/core/route.types.d.ts.map +1 -0
  71. package/dist/src/core/start-action.d.ts +53 -0
  72. package/dist/src/core/start-action.d.ts.map +1 -0
  73. package/dist/src/core/start-action.js +95 -0
  74. package/dist/src/core/start-loaders.d.ts +63 -0
  75. package/dist/src/core/start-loaders.d.ts.map +1 -0
  76. package/dist/src/core/start-loaders.js +138 -0
  77. package/dist/{core.d.ts → src/core.d.ts} +7 -11
  78. package/dist/src/core.d.ts.map +1 -0
  79. package/dist/{core.js → src/core.js} +2 -4
  80. package/dist/src/engines/engine.types.d.ts +216 -0
  81. package/dist/src/engines/engine.types.d.ts.map +1 -0
  82. package/dist/src/engines/navigation-api-engine.d.ts +50 -0
  83. package/dist/src/engines/navigation-api-engine.d.ts.map +1 -0
  84. package/dist/src/engines/navigation-api-engine.js +411 -0
  85. package/dist/src/engines.d.ts +4 -0
  86. package/dist/src/engines.d.ts.map +1 -0
  87. package/dist/src/engines.js +1 -0
  88. package/dist/src/hooks/_use-singleton.d.ts +11 -0
  89. package/dist/src/hooks/_use-singleton.d.ts.map +1 -0
  90. package/dist/src/hooks/_use-singleton.js +26 -0
  91. package/dist/src/hooks/use-action-data.d.ts +17 -0
  92. package/dist/src/hooks/use-action-data.d.ts.map +1 -0
  93. package/dist/src/hooks/use-action-data.js +16 -0
  94. package/dist/src/hooks/use-form-action.d.ts +7 -0
  95. package/dist/src/hooks/use-form-action.d.ts.map +1 -0
  96. package/dist/src/hooks/use-form-action.js +9 -0
  97. package/dist/src/hooks/use-loader-data.d.ts +9 -0
  98. package/dist/src/hooks/use-loader-data.d.ts.map +1 -0
  99. package/dist/src/hooks/use-loader-data.js +20 -0
  100. package/dist/src/hooks/use-navigate.d.ts +53 -0
  101. package/dist/src/hooks/use-navigate.d.ts.map +1 -0
  102. package/dist/src/hooks/use-navigate.js +43 -0
  103. package/dist/{hooks → src/hooks}/use-params.d.ts +2 -2
  104. package/dist/src/hooks/use-params.d.ts.map +1 -0
  105. package/dist/{hooks → src/hooks}/use-params.js +1 -1
  106. package/dist/src/hooks/use-route-context.d.ts +10 -0
  107. package/dist/src/hooks/use-route-context.d.ts.map +1 -0
  108. package/dist/src/hooks/use-route-context.js +17 -0
  109. package/dist/src/hooks/use-router-context.d.ts +12 -0
  110. package/dist/src/hooks/use-router-context.d.ts.map +1 -0
  111. package/dist/src/hooks/use-router-context.js +20 -0
  112. package/dist/src/hooks/use-submit.d.ts +59 -0
  113. package/dist/src/hooks/use-submit.d.ts.map +1 -0
  114. package/dist/src/hooks/use-submit.js +38 -0
  115. package/dist/src/soseki.d.ts +31 -0
  116. package/dist/src/soseki.d.ts.map +1 -0
  117. package/dist/src/soseki.js +12 -0
  118. package/dist/src/utils/redirect.d.ts +11 -0
  119. package/dist/src/utils/redirect.d.ts.map +1 -0
  120. package/dist/src/utils/redirect.js +12 -0
  121. package/package.json +47 -40
  122. package/src/components/browser-router.tsx +8 -11
  123. package/src/components/outlet.tsx +3 -2
  124. package/src/components/router.tsx +139 -145
  125. package/src/contexts/route-context.ts +6 -5
  126. package/src/contexts/router-context.ts +36 -19
  127. package/src/core/_compare-route-paths.ts +48 -34
  128. package/src/core/_match-route-path.ts +21 -15
  129. package/src/core/_process-routes.ts +44 -46
  130. package/src/core/_singleton.ts +13 -38
  131. package/src/core/_unreachable.ts +12 -7
  132. package/src/core/_valibot.ts +19 -116
  133. package/src/core/errors.ts +150 -495
  134. package/src/core/expect-history-entry.ts +40 -41
  135. package/src/core/form-data-to-html-form-element.ts +37 -0
  136. package/src/core/history-entry-id-schema.ts +6 -11
  137. package/src/core/history-entry-url-schema.ts +25 -18
  138. package/src/core/init-loaders.ts +35 -57
  139. package/src/core/match-routes.ts +33 -65
  140. package/src/core/readonly-form-data.types.ts +48 -28
  141. package/src/core/readonly-url.types.ts +57 -28
  142. package/src/core/redirect-response.ts +26 -15
  143. package/src/core/route-path.ts +114 -0
  144. package/src/core/route-request.ts +144 -32
  145. package/src/core/route.types.ts +250 -226
  146. package/src/core/start-action.ts +164 -0
  147. package/src/core/start-loaders.ts +190 -212
  148. package/src/core.ts +8 -15
  149. package/src/engines/engine.types.ts +204 -166
  150. package/src/engines/navigation-api-engine.ts +332 -233
  151. package/src/engines.ts +4 -0
  152. package/src/hooks/_use-singleton.ts +30 -0
  153. package/src/hooks/use-action-data.ts +21 -26
  154. package/src/hooks/use-form-action.ts +4 -5
  155. package/src/hooks/use-loader-data.ts +16 -18
  156. package/src/hooks/use-navigate.ts +69 -28
  157. package/src/hooks/use-params.ts +4 -4
  158. package/src/hooks/use-route-context.ts +20 -0
  159. package/src/hooks/use-router-context.ts +25 -0
  160. package/src/hooks/use-submit.ts +48 -53
  161. package/src/soseki.ts +27 -34
  162. package/src/utils/redirect.ts +5 -5
  163. package/dist/components/action-id.d.ts +0 -19
  164. package/dist/components/action-id.d.ts.map +0 -1
  165. package/dist/components/action-id.jsx +0 -14
  166. package/dist/components/browser-router.d.ts +0 -17
  167. package/dist/components/browser-router.d.ts.map +0 -1
  168. package/dist/components/browser-router.jsx +0 -13
  169. package/dist/components/hidden-input.d.ts +0 -20
  170. package/dist/components/hidden-input.d.ts.map +0 -1
  171. package/dist/components/hidden-input.jsx +0 -8
  172. package/dist/components/outlet.d.ts +0 -8
  173. package/dist/components/outlet.d.ts.map +0 -1
  174. package/dist/components/outlet.jsx +0 -15
  175. package/dist/components/router.d.ts +0 -23
  176. package/dist/components/router.d.ts.map +0 -1
  177. package/dist/components/router.jsx +0 -128
  178. package/dist/contexts/route-context.d.ts +0 -19
  179. package/dist/contexts/route-context.d.ts.map +0 -1
  180. package/dist/contexts/route-context.js +0 -6
  181. package/dist/contexts/router-context.d.ts +0 -46
  182. package/dist/contexts/router-context.d.ts.map +0 -1
  183. package/dist/contexts/router-context.js +0 -8
  184. package/dist/core/_action-id-registry.d.ts +0 -10
  185. package/dist/core/_action-id-registry.d.ts.map +0 -1
  186. package/dist/core/_action-id-registry.js +0 -8
  187. package/dist/core/_capture-stack-trace.d.ts +0 -8
  188. package/dist/core/_capture-stack-trace.d.ts.map +0 -1
  189. package/dist/core/_capture-stack-trace.js +0 -12
  190. package/dist/core/_compare-route-paths.d.ts +0 -11
  191. package/dist/core/_compare-route-paths.d.ts.map +0 -1
  192. package/dist/core/_compare-route-paths.js +0 -80
  193. package/dist/core/_create-html-form-element-form-form-data.d.ts +0 -9
  194. package/dist/core/_create-html-form-element-form-form-data.d.ts.map +0 -1
  195. package/dist/core/_create-html-form-element-form-form-data.js +0 -27
  196. package/dist/core/_encode-pathname.d.ts +0 -10
  197. package/dist/core/_encode-pathname.d.ts.map +0 -1
  198. package/dist/core/_encode-pathname.js +0 -16
  199. package/dist/core/_is-error.d.ts +0 -3
  200. package/dist/core/_is-error.d.ts.map +0 -1
  201. package/dist/core/_is-error.js +0 -13
  202. package/dist/core/_is-promise-like.d.ts +0 -8
  203. package/dist/core/_is-promise-like.d.ts.map +0 -1
  204. package/dist/core/_is-promise-like.js +0 -12
  205. package/dist/core/_match-route-path.d.ts +0 -19
  206. package/dist/core/_match-route-path.d.ts.map +0 -1
  207. package/dist/core/_match-route-path.js +0 -22
  208. package/dist/core/_process-routes.d.ts +0 -9
  209. package/dist/core/_process-routes.d.ts.map +0 -1
  210. package/dist/core/_process-routes.js +0 -47
  211. package/dist/core/_singleton.d.ts +0 -18
  212. package/dist/core/_singleton.d.ts.map +0 -1
  213. package/dist/core/_singleton.js +0 -37
  214. package/dist/core/_unreachable.d.ts +0 -12
  215. package/dist/core/_unreachable.d.ts.map +0 -1
  216. package/dist/core/_unreachable.js +0 -8
  217. package/dist/core/_use-singleton.d.ts +0 -11
  218. package/dist/core/_use-singleton.d.ts.map +0 -1
  219. package/dist/core/_use-singleton.js +0 -21
  220. package/dist/core/_valibot.d.ts +0 -52
  221. package/dist/core/_valibot.d.ts.map +0 -1
  222. package/dist/core/_valibot.js +0 -107
  223. package/dist/core/_weak-id-registry.d.ts +0 -76
  224. package/dist/core/_weak-id-registry.d.ts.map +0 -1
  225. package/dist/core/_weak-id-registry.js +0 -67
  226. package/dist/core/constants.d.ts +0 -5
  227. package/dist/core/constants.d.ts.map +0 -1
  228. package/dist/core/constants.js +0 -4
  229. package/dist/core/data-map.types.d.ts +0 -23
  230. package/dist/core/data-map.types.d.ts.map +0 -1
  231. package/dist/core/data-map.types.js +0 -1
  232. package/dist/core/data-store.types.d.ts +0 -22
  233. package/dist/core/data-store.types.d.ts.map +0 -1
  234. package/dist/core/data-store.types.js +0 -1
  235. package/dist/core/deferred-promise.d.ts +0 -203
  236. package/dist/core/deferred-promise.d.ts.map +0 -1
  237. package/dist/core/deferred-promise.js +0 -200
  238. package/dist/core/errors.d.ts +0 -303
  239. package/dist/core/errors.d.ts.map +0 -1
  240. package/dist/core/errors.js +0 -400
  241. package/dist/core/expect-history-entry.d.ts +0 -52
  242. package/dist/core/expect-history-entry.d.ts.map +0 -1
  243. package/dist/core/expect-history-entry.js +0 -38
  244. package/dist/core/history-entry-id-schema.d.ts +0 -17
  245. package/dist/core/history-entry-id-schema.d.ts.map +0 -1
  246. package/dist/core/history-entry-id-schema.js +0 -9
  247. package/dist/core/history-entry-url-schema.d.ts +0 -20
  248. package/dist/core/history-entry-url-schema.d.ts.map +0 -1
  249. package/dist/core/history-entry-url-schema.js +0 -16
  250. package/dist/core/init-loaders.d.ts +0 -37
  251. package/dist/core/init-loaders.d.ts.map +0 -1
  252. package/dist/core/init-loaders.js +0 -38
  253. package/dist/core/match-routes.d.ts +0 -31
  254. package/dist/core/match-routes.d.ts.map +0 -1
  255. package/dist/core/match-routes.js +0 -54
  256. package/dist/core/readonly-form-data.types.d.ts +0 -32
  257. package/dist/core/readonly-form-data.types.d.ts.map +0 -1
  258. package/dist/core/readonly-url.types.d.ts +0 -135
  259. package/dist/core/readonly-url.types.d.ts.map +0 -1
  260. package/dist/core/redirect-response.d.ts +0 -29
  261. package/dist/core/redirect-response.d.ts.map +0 -1
  262. package/dist/core/redirect-response.js +0 -17
  263. package/dist/core/route-request.d.ts +0 -52
  264. package/dist/core/route-request.d.ts.map +0 -1
  265. package/dist/core/route-request.js +0 -26
  266. package/dist/core/route.types.d.ts +0 -309
  267. package/dist/core/route.types.d.ts.map +0 -1
  268. package/dist/core/start-actions.d.ts +0 -60
  269. package/dist/core/start-actions.d.ts.map +0 -1
  270. package/dist/core/start-actions.js +0 -186
  271. package/dist/core/start-loaders.d.ts +0 -69
  272. package/dist/core/start-loaders.d.ts.map +0 -1
  273. package/dist/core/start-loaders.js +0 -154
  274. package/dist/core.d.ts.map +0 -1
  275. package/dist/engines/engine.types.d.ts +0 -190
  276. package/dist/engines/engine.types.d.ts.map +0 -1
  277. package/dist/engines/navigation-api-engine.d.ts +0 -48
  278. package/dist/engines/navigation-api-engine.d.ts.map +0 -1
  279. package/dist/engines/navigation-api-engine.js +0 -332
  280. package/dist/hooks/_use-route-context.d.ts +0 -10
  281. package/dist/hooks/_use-route-context.d.ts.map +0 -1
  282. package/dist/hooks/_use-route-context.js +0 -17
  283. package/dist/hooks/_use-router-context.d.ts +0 -10
  284. package/dist/hooks/_use-router-context.d.ts.map +0 -1
  285. package/dist/hooks/_use-router-context.js +0 -18
  286. package/dist/hooks/use-action-data.d.ts +0 -23
  287. package/dist/hooks/use-action-data.d.ts.map +0 -1
  288. package/dist/hooks/use-action-data.js +0 -16
  289. package/dist/hooks/use-form-action.d.ts +0 -7
  290. package/dist/hooks/use-form-action.d.ts.map +0 -1
  291. package/dist/hooks/use-form-action.js +0 -10
  292. package/dist/hooks/use-loader-data.d.ts +0 -11
  293. package/dist/hooks/use-loader-data.d.ts.map +0 -1
  294. package/dist/hooks/use-loader-data.js +0 -19
  295. package/dist/hooks/use-navigate.d.ts +0 -39
  296. package/dist/hooks/use-navigate.d.ts.map +0 -1
  297. package/dist/hooks/use-navigate.js +0 -26
  298. package/dist/hooks/use-params.d.ts.map +0 -1
  299. package/dist/hooks/use-pathname.d.ts +0 -7
  300. package/dist/hooks/use-pathname.d.ts.map +0 -1
  301. package/dist/hooks/use-pathname.js +0 -9
  302. package/dist/hooks/use-submit.d.ts +0 -66
  303. package/dist/hooks/use-submit.d.ts.map +0 -1
  304. package/dist/hooks/use-submit.js +0 -35
  305. package/dist/soseki.d.ts +0 -42
  306. package/dist/soseki.d.ts.map +0 -1
  307. package/dist/soseki.js +0 -19
  308. package/dist/utils/get-action-id.d.ts +0 -8
  309. package/dist/utils/get-action-id.d.ts.map +0 -1
  310. package/dist/utils/get-action-id.js +0 -11
  311. package/dist/utils/href.d.ts +0 -11
  312. package/dist/utils/href.d.ts.map +0 -1
  313. package/dist/utils/href.js +0 -12
  314. package/dist/utils/redirect.d.ts +0 -11
  315. package/dist/utils/redirect.d.ts.map +0 -1
  316. package/dist/utils/redirect.js +0 -12
  317. package/dist/utils/route-index.d.ts +0 -41
  318. package/dist/utils/route-index.d.ts.map +0 -1
  319. package/dist/utils/route-index.js +0 -12
  320. package/dist/utils/route-route.d.ts +0 -62
  321. package/dist/utils/route-route.d.ts.map +0 -1
  322. package/dist/utils/route-route.js +0 -25
  323. package/dist/utils/set-action-id.d.ts +0 -9
  324. package/dist/utils/set-action-id.d.ts.map +0 -1
  325. package/dist/utils/set-action-id.js +0 -12
  326. package/src/components/action-id.tsx +0 -35
  327. package/src/components/hidden-input.tsx +0 -39
  328. package/src/core/_action-id-registry.ts +0 -11
  329. package/src/core/_capture-stack-trace.ts +0 -12
  330. package/src/core/_create-html-form-element-form-form-data.ts +0 -32
  331. package/src/core/_encode-pathname.ts +0 -17
  332. package/src/core/_is-error.ts +0 -16
  333. package/src/core/_is-promise-like.ts +0 -14
  334. package/src/core/_use-singleton.ts +0 -24
  335. package/src/core/_weak-id-registry.ts +0 -125
  336. package/src/core/constants.ts +0 -4
  337. package/src/core/data-map.types.ts +0 -28
  338. package/src/core/data-store.types.ts +0 -25
  339. package/src/core/deferred-promise.ts +0 -408
  340. package/src/core/start-actions.ts +0 -274
  341. package/src/hooks/_use-route-context.ts +0 -19
  342. package/src/hooks/_use-router-context.ts +0 -25
  343. package/src/hooks/use-pathname.ts +0 -10
  344. package/src/utils/get-action-id.ts +0 -12
  345. package/src/utils/href.ts +0 -17
  346. package/src/utils/route-index.ts +0 -70
  347. package/src/utils/route-route.ts +0 -111
  348. package/src/utils/set-action-id.ts +0 -14
  349. /package/dist/{core → src/core}/readonly-form-data.types.js +0 -0
  350. /package/dist/{core → src/core}/readonly-url.types.js +0 -0
  351. /package/dist/{core → src/core}/route.types.js +0 -0
  352. /package/dist/{engines → src/engines}/engine.types.js +0 -0
package/src/engines.ts ADDED
@@ -0,0 +1,4 @@
1
+ export type * from "./engines/engine.types.js";
2
+
3
+ export type * from "./engines/navigation-api-engine.js";
4
+ export { default as NavigationApiEngine } from "./engines/navigation-api-engine.js";
@@ -0,0 +1,30 @@
1
+ import * as React from "react";
2
+
3
+ /**
4
+ * 初期化前(未初期化状態)であることを安全に判定するための、値が空の内部専用ユニークオブジェクトです。
5
+ */
6
+ const nil = {};
7
+
8
+ /**
9
+ * コンポーネントのライフサイクルにおいて、渡されたファクトリー関数を最初のレンダリング時に一度だけ実行し、その結果を以降の再レンダリング間で永続的に共有・保持するためのカスタムフックです。
10
+ *
11
+ * `React.useMemo` と異なり、React の内部都合によるキャッシュの不意な破棄・再計算が発生しないことが保証されます。
12
+ *
13
+ * @template T ファクトリー関数が生成するオブジェクトの型定義です。
14
+ * @param fn 初回レンダリング時にのみ呼び出される、オブジェクト生成用の初期化関数です。
15
+ * @returns 初回実行時に生成され、保持され続けている型 `T` のシングルトンインスタンスを返します。
16
+ */
17
+ export default function useSingleton<T>(fn: () => T): T {
18
+ // 生成されたオブジェクトをコンポーネントの生存期間中保持するために useRef を使用します。
19
+ // 初期値として、未初期化の目印である nil オブジェクトを型アサーションして流し込みます。
20
+ const ref = React.useRef<T>(nil as T);
21
+
22
+ // 参照している中身がマッピングされたオブジェクト(nil)のままであれば、まだ一度も初期化されていないと判定します。
23
+ if (ref.current === nil) {
24
+ // 初期化関数を実行し、生成された実体を現在の参照へと上書きします。
25
+ // この処理は初回のレンダリングパスの中で完全に同期的に実行されます。
26
+ ref.current = fn();
27
+ }
28
+
29
+ return ref.current;
30
+ }
@@ -1,37 +1,32 @@
1
- import type DeferredPromise from "../core/deferred-promise.js";
1
+ import type { NinjaPromise } from "ninja-promise";
2
+
2
3
  import type RedirectResponse from "../core/redirect-response.js";
3
- import type { IAction } from "../core/route.types.js";
4
- import useRouterContext from "./_use-router-context.js";
4
+ import useRouteContext from "./use-route-context.js";
5
+ import useRouterContext from "./use-router-context.js";
5
6
 
6
7
  /**
7
- * アクションの実行結果を推論するためのユーティリティー型です。
8
- *
9
- * 結果が `RedirectResponse` の場合は `undefined` を返し、それ以外の場合はそのままの型を返します。
8
+ * アクション関数の戻り値の型から、リダイレクト応答を除外して正規化するユーティリティー型です。
10
9
  *
11
- * @template TResult 推論対象となる型です。
10
+ * アクションがリダイレクトを返した場合、フレームワークの内部仕様によって実際の値は `undefined` に置換されるため、型定義においてもその挙動を忠実に表現します。
12
11
  */
13
- // dprint-ignore
14
- type $InferResult<TResult> = TResult extends RedirectResponse
15
- ? undefined
16
- : TResult;
12
+ type ActionResult<TResult> = TResult extends RedirectResponse ? undefined : TResult;
17
13
 
18
14
  /**
19
- * 特定のアクションに関連付けられたデータ(実行結果)をルーターのストアから取得するカスタムフックです。
15
+ * 現在の階層のルートに紐づくアクション関数の最新の実行結果を購読・取得するためのカスタムフックです。
20
16
  *
21
- * 現在の履歴エントリーに対応するアクションデータを返します。
22
- *
23
- * @template TAction 対象となるアクションの型です。
24
- * @param action データを取得したいアクションの定義です。
25
- * @returns アクションの実行結果を含む `DeferredPromise` を返します。データが存在しない場合は `undefined` を返します。
17
+ * @template TData アクション関数そのものの型、またはアクションが返すことが期待されるデータ構造の型定義です。関数型が渡された場合は、自動的にその戻り値の型(推論結果)が解凍されます。
18
+ * @returns アクションが実行済み、または実行中であれば結果を内包した `NinjaPromise` を返し、一度も実行されていないか対象のアクションが存在しない場合は `undefined` を返します。
26
19
  */
27
- export default function useActionData<TAction extends IAction>(
28
- action: TAction,
29
- ): DeferredPromise<$InferResult<Awaited<ReturnType<TAction>>>> | undefined {
30
- return useRouterContext((router): DeferredPromise<any> | undefined => {
31
- const {
32
- currentEntry,
33
- actionDataStore,
34
- } = router;
35
- return actionDataStore.get(currentEntry.id)?.get(action);
20
+ export default function useActionData<TData = unknown>():
21
+ | NinjaPromise<
22
+ ActionResult<Awaited<TData extends (...args: any) => infer TReturn ? TReturn : TData>>
23
+ >
24
+ | undefined {
25
+ const { action } = useRouteContext();
26
+ const actionData = useRouterContext((router) => {
27
+ const { currentEntry, actionDataStore } = router;
28
+ return actionDataStore.get(currentEntry.id)?.get(action!);
36
29
  });
30
+
31
+ return actionData satisfies NinjaPromise<unknown> | undefined as NinjaPromise<any> | undefined;
37
32
  }
@@ -1,11 +1,10 @@
1
- import useRouteContext from "./_use-route-context.js";
1
+ import useRouteContext from "./use-route-context.js";
2
2
 
3
3
  /**
4
- * フォームの送信先となるアクション URL を取得するためのカスタムフックです。
4
+ * 現在の階層のルートに紐づく、動的パラメーターが具現化された実際の URL パス文字列を取得するカスタムフックです。
5
5
  *
6
- * @returns 現在のルートコンテキストから抽出された URL パスを返します。
6
+ * @returns 現在のルートに対応する具現化済みの URL パス文字列(例: `"/items/123"`)を返します。
7
7
  */
8
8
  export default function useFormAction(): string {
9
- const { urlPath } = useRouteContext();
10
- return urlPath;
9
+ return useRouteContext().urlPath;
11
10
  }
@@ -1,28 +1,26 @@
1
- import type DeferredPromise from "../core/deferred-promise.js";
1
+ import type { NinjaPromise } from "ninja-promise";
2
+
2
3
  import { LoaderDataNotFoundError } from "../core/errors.js";
3
- import type { ILoader } from "../core/route.types.js";
4
- import useRouterContext from "./_use-router-context.js";
4
+ import useRouteContext from "./use-route-context.js";
5
+ import useRouterContext from "./use-router-context.js";
5
6
 
6
7
  /**
7
- * 指定されたローダーに関連付けられたデータを取得するためのカスタムフックです。
8
+ * 現在の階層のルートに紐づくローダー関数の実行結果を購読・取得するためのカスタムフックです。
8
9
  *
9
- * @template TLoader 対象となるローダーの型です。
10
- * @param loader データを取得したいローダーの定義です。
11
- * @returns ローダーの実行結果を含む `DeferredPromise` を返します。
10
+ * @template TData ローダー関数そのものの型、またはローダーが返すことが期待されるデータ構造の型定義です。関数型が渡された場合は、自動的にその非同期戻り値の型(非同期の解凍結果)が推論されます。
11
+ * @returns ローダーの実行状態を管理している `NinjaPromise` を返します。
12
12
  */
13
- export default function useLoaderData<TLoader extends ILoader>(
14
- loader: TLoader,
15
- ): DeferredPromise<Awaited<ReturnType<TLoader>>> {
16
- const loaderData = useRouterContext((router): DeferredPromise<any> | undefined => {
17
- const {
18
- currentEntry,
19
- loaderDataStore,
20
- } = router;
21
- return loaderDataStore.get(currentEntry.id)?.get(loader);
13
+ export default function useLoaderData<TData = unknown>(): NinjaPromise<
14
+ Awaited<TData extends (...args: any) => infer TReturn ? TReturn : TData>
15
+ > {
16
+ const { loader } = useRouteContext();
17
+ const loaderData = useRouterContext((router) => {
18
+ const { currentEntry, loaderDataStore } = router;
19
+ return loaderDataStore.get(currentEntry.id)?.get(loader!);
22
20
  });
23
21
  if (!loaderData) {
24
- throw new LoaderDataNotFoundError(loader);
22
+ throw new LoaderDataNotFoundError({ loader });
25
23
  }
26
24
 
27
- return loaderData;
25
+ return loaderData satisfies NinjaPromise<unknown> as NinjaPromise<any>;
28
26
  }
@@ -1,64 +1,105 @@
1
1
  import * as React from "react";
2
- import type { NavigateTo } from "../engines/engine.types.js";
3
- import useRouterContext from "./_use-router-context.js";
2
+
3
+ import type {} from "../engines/engine.types.js";
4
+ import useRouterContext from "./use-router-context.js";
5
+
6
+ /**
7
+ * 遷移先のアドレスを指定するための表現型です。
8
+ *
9
+ * 完全な URL パス文字列か、またはパスの各コンポーネントを部分的にパッチするためのオブジェクトのいずれかを受け入れます。
10
+ */
11
+ export type NavigateTo =
12
+ | string
13
+ | {
14
+ /**
15
+ * 遷移先のドメイン以下のリクエストパス(例: `"/dashboard"`)です。
16
+ */
17
+ readonly pathname?: string | undefined;
18
+
19
+ /**
20
+ * 遷移先に付与する検索クエリー文字列(例: `"?id=foo"`)です。
21
+ */
22
+ readonly search?: string | undefined;
23
+
24
+ /**
25
+ * 遷移先に付与するハッシュフラグメント(例: `"#profile"`)です。
26
+ */
27
+ readonly hash?: string | undefined;
28
+ };
4
29
 
5
30
  /**
6
- * 遷移(ナビゲート)を実行する際のオプション設定です。
31
+ * 画面遷移の挙動をカスタマイズするためのオプション型です。
7
32
  */
8
33
  export type NavigateOptions = {
9
34
  /**
10
- * 履歴を置き換えるかどうかを指定します。
11
- *
12
- * `true` の場合は現在のエントリーを置換し、`false` または未定義の場合は新しいエントリーを追加します。
35
+ * 履歴スタックへの追加方法を制御します。`true` の場合は現在の履歴を上書きし、`false` または省略時は新規追加します。
13
36
  */
14
37
  readonly replace?: boolean | undefined;
15
38
  };
16
39
 
17
40
  /**
18
- * 指定されたパスへ遷移するための関数インターフェースです。
41
+ * プログラムから命令的に画面遷移を実行する、`NavigateFunction` 関数のオーバーロードインターフェース定義です。
19
42
  */
20
- export interface INavigate {
43
+ export interface NavigateFunction {
21
44
  /**
22
- * ナビゲーションを実行します。
45
+ * 指定されたアドレスへ画面を遷移させます。
23
46
  *
24
- * @param to 遷移先です。
25
- * @param options 遷移時のオプション設定です。
47
+ * @param to 遷移先の対象となるデータ表現です。
48
+ * @param options 履歴のスタック方法などを制御するオプションです。
26
49
  */
27
- (to: NavigateTo, options?: NavigateOptions | undefined): void;
50
+ (to: NavigateTo, options?: NavigateOptions): void;
28
51
 
29
52
  /**
30
- * ナビゲーションを実行します。
53
+ * ブラウザーのセッション履歴スタック内を、現在地を基準に相対移動させます。
31
54
  *
32
- * @param delta 履歴スタックの相対位置です。
55
+ * @param delta 移動する履歴のステップ数(例: `-1` で1つ戻る、`1` で1つ進む)です。
33
56
  */
34
57
  (delta: number): void;
35
58
  }
36
59
 
37
60
  /**
38
- * プログラムによる遷移(ナビゲート)を行うための関数を取得するカスタムフックです。
39
- *
40
- * コンポーネント内でこのフックを使用することで、ボタンのクリックイベントなどで任意のパスへ移動できるようになります。
61
+ * リンクなどを介さない、ボタンのクリックハンドラーや非同期処理の完了時などから、プログラムによって命令的に画面遷移や履歴移動をトリガーするための関数を取得するカスタムフックです。
41
62
  *
42
- * @returns 遷移を実行するための関数である `INavigate` を返します。
63
+ * @returns `NavigateFunction` 関数です。
43
64
  */
44
- export default function useNavigate(): INavigate {
45
- const call = useRouterContext(router => router.navigate);
65
+ export default function useNavigate(): NavigateFunction {
66
+ const routerNavigate = useRouterContext((router) => router.navigate);
67
+
68
+ // レンダリング毎に関数の参照が変わって子コンポーネントが不要に再描画されるのを防ぐため、useCallback でラップします。
46
69
  return React.useCallback(
47
70
  function navigate(...args: [NavigateTo, options?: NavigateOptions | undefined] | [number]) {
48
71
  if (typeof args[0] === "number") {
49
72
  const [delta] = args;
50
- return call({ delta });
73
+
74
+ return routerNavigate({
75
+ type: "MOVE",
76
+ delta,
77
+ });
51
78
  }
52
79
 
53
80
  const [to, options = {}] = args;
54
81
  const { replace = false } = options;
55
- return call({
56
- to,
57
- history: replace
58
- ? "replace"
59
- : "push",
60
- });
82
+ const history = replace ? "replace" : "push";
83
+ if (typeof to === "string") {
84
+ return routerNavigate({
85
+ to: {
86
+ path: to,
87
+ type: "PATH",
88
+ },
89
+ type: "LINK",
90
+ history,
91
+ });
92
+ } else {
93
+ return routerNavigate({
94
+ to: {
95
+ ...to,
96
+ type: "PARTIAL",
97
+ },
98
+ type: "LINK",
99
+ history,
100
+ });
101
+ }
61
102
  },
62
- [call],
103
+ [routerNavigate],
63
104
  );
64
105
  }
@@ -1,11 +1,11 @@
1
- import type { PathParams } from "../core/route.types.js";
2
- import useRouteContext from "./_use-route-context.js";
1
+ import type { RoutePathParams } from "../core/route.types.js";
2
+ import useRouteContext from "./use-route-context.js";
3
3
 
4
4
  /**
5
5
  * 現在のルートにマッチしたパスパラメーターを取得するためのカスタムフックです。
6
6
  *
7
7
  * @returns 現在のパスパラメーターを含むオブジェクトを返します。
8
8
  */
9
- export default function useParams<TPath extends string = string>(): PathParams<TPath> {
10
- return useRouteContext().params as PathParams<TPath>;
9
+ export default function useParams<TPath extends string = string>(): RoutePathParams<TPath> {
10
+ return useRouteContext().params as RoutePathParams<TPath>;
11
11
  }
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+
3
+ import RouteContext, { type RouteContextValue } from "../contexts/route-context.js";
4
+ import { RouteContextMissingError } from "../core/errors.js";
5
+
6
+ /**
7
+ * React のコンポーネントツリーから、現在の階層に紐づいているルートの文脈情報を安全に取得するためのカスタムフックです。
8
+ *
9
+ * コンテキストが供給されていない状況を検知した場合はエラーを投げます。
10
+ *
11
+ * @returns 現在の階層で確定している型 `RouteContextValue` のルートコンテキストデータを返します。
12
+ */
13
+ export default function useRouteContext(): RouteContextValue {
14
+ const routeContext = React.use(RouteContext);
15
+ if (!routeContext) {
16
+ throw new RouteContextMissingError();
17
+ }
18
+
19
+ return routeContext;
20
+ }
@@ -0,0 +1,25 @@
1
+ import * as React from "react";
2
+
3
+ import RouterContext, { type RouterRef } from "../contexts/router-context.js";
4
+ import { RouterContextMissingError } from "../core/errors.js";
5
+
6
+ /**
7
+ * グローバルなルーターの状態)ら、必要なデータの一部(スライス)をセレクター関数を介して選択的・効率的に購読するためのカスタムフックです。
8
+ *
9
+ * ルーターコンポーネントの配下で実行されていない場合はエラーを投げます。
10
+ *
11
+ * @template TSlice セレクター関数によって抽出される、コンポーネントが必要とする部分データの型定義です。
12
+ * @param selector ルーターの内部実体を受け取り、必要なプロパティーや状態を抽出して返す純粋関数です。
13
+ * @returns 選択され、外部ストアと同期された最新のスライスデータを返します。
14
+ */
15
+ export default function useRouterContext<TSlice>(
16
+ selector: (router: RouterRef["current"]) => TSlice,
17
+ ): TSlice {
18
+ const routerContext = React.use(RouterContext);
19
+ if (!routerContext) {
20
+ throw new RouterContextMissingError();
21
+ }
22
+
23
+ const { routerRef, subscribe } = routerContext;
24
+ return React.useSyncExternalStore(subscribe, () => selector(routerRef.current));
25
+ }
@@ -1,111 +1,106 @@
1
1
  import * as React from "react";
2
+
2
3
  import type { ReadonlyFormData } from "../core/readonly-form-data.types.js";
3
4
  import type { ReadonlyURLSearchParams } from "../core/readonly-url.types.js";
4
- import type { IAction } from "../core/route.types.js";
5
- import useRouterContext from "./_use-router-context.js";
6
5
  import useFormAction from "./use-form-action.js";
6
+ import useRouterContext from "./use-router-context.js";
7
7
 
8
8
  /**
9
- * GET メソッドによる送信時のオプションです。
9
+ * クエリーパラメーター送信(HTTP GET 相当)のサブミット処理をカスタマイズするためのオプション型です。
10
10
  */
11
11
  export type SubmitGetOptions = {
12
12
  /**
13
- * 送信先のパスです。
13
+ * 送信先(遷移先)のベースとなる URL パスを明示的に上書き指定します。省略時は現在のフォームアクションパスが使用されます。
14
14
  */
15
15
  readonly action?: string | undefined;
16
16
 
17
17
  /**
18
- * 現在の履歴エントリーを置き換えるかどうかを指定します。
18
+ * 履歴スタックへの追加方法を制御します。`true` の場合は現在の履歴を上書きし、`false` または省略時は新規追加します。
19
19
  */
20
20
  readonly replace?: boolean | undefined;
21
21
  };
22
22
 
23
23
  /**
24
- * POST メソッドによる送信時のオプションです。
24
+ * フォームデータ送信(HTTP POST 相当)のサブミット処理をカスタマイズするためのオプション型です。
25
25
  */
26
26
  export type SubmitPostOptions = {
27
27
  /**
28
- * 送信先のパスです。
28
+ * 送信先(アクション実行先)の URL パスを明示的に上書き指定します。省略時は現在のフォームアクションパスが使用されます。
29
29
  */
30
30
  readonly action?: string | undefined;
31
-
32
- /**
33
- * 実行するアクションの定義です。
34
- */
35
- readonly actionId?: IAction | undefined;
36
31
  };
37
32
 
38
33
  /**
39
- * 送信処理に使用するオプションの連合型です。
40
- */
41
- export type SubmitOptions = SubmitGetOptions | SubmitPostOptions;
42
-
43
- /**
44
- * データを送信するための関数インターフェースです。
34
+ * プログラムから命令的にデータ送信および画面遷移を実行する、`submit` 関数のオーバーロードインターフェース定義です。
45
35
  */
46
- export interface ISubmit {
36
+ export interface SubmitFunction {
47
37
  /**
48
- * フォーム データを送信します。
38
+ * 不変のフォームデータを引き渡して、HTTP POST 相当のアクション処理をトリガーします。
49
39
  *
50
- * @param target 送信対象のフォームデータです。
51
- * @param options 送信時のオプションです。
40
+ * @param target 送信するフォームデータです。
41
+ * @param options POST 送信用のオプションです。
52
42
  */
53
- (target: ReadonlyFormData, options?: SubmitPostOptions | undefined): void;
43
+ (target: ReadonlyFormData, options?: SubmitPostOptions): void;
54
44
 
55
45
  /**
56
- * URL クエリーパラメーターを送信します。
46
+ * 不変のクエリーパラメーターを引き渡して、HTTP GET 相当の検索条件の更新をトリガーします。
57
47
  *
58
- * @param target 送信対象の URL クエリーパラメーターです。
59
- * @param options 送信時のオプションです。
48
+ * @param target 送信する検索クエリーです。
49
+ * @param options GET 送信用のオプションです。
60
50
  */
61
- (target: ReadonlyURLSearchParams, options?: SubmitGetOptions | undefined): void;
51
+ (target: ReadonlyURLSearchParams, options?: SubmitGetOptions): void;
62
52
 
63
53
  /**
64
- * フォーム データまたは URL クエリーパラメーターを送信します。
54
+ * 内部実装および包括的なユースケースに対応する汎用シグニチャーです。
65
55
  *
66
- * @param target 送信対象のデータです。
67
- * @param options 送信時のオプションです。
56
+ * @param target 送信愛用です。
57
+ * @param options オプションです。
68
58
  */
69
- (target: ReadonlyURLSearchParams | ReadonlyFormData, options?: SubmitOptions | undefined): void;
59
+ (
60
+ target: ReadonlyURLSearchParams | ReadonlyFormData,
61
+ options?: SubmitGetOptions | SubmitPostOptions,
62
+ ): void;
70
63
  }
71
64
 
72
65
  /**
73
- * 命令的にデータを送信するための submit 関数を提供するフックです。
66
+ * ユーザーのクリックイベントや、特定のロジックに基づくタイミングで、プログラムから宣言的・命令的にサブミット処理(データ送信および遷移)を実行するための関数を取得するカスタムフックです。
74
67
  *
75
- * @returns データを送信するための ISubmit 関数を返します。
68
+ * 渡されたペイロードが `FormData` であるか `URLSearchParams` であるかをランタイムで自動判定し、適切なルーティングエンジンメソッドへと送信されます。
69
+ *
70
+ * @returns 依存関係が最適化され、同一参照が保証された `submit` 関数を返します。
76
71
  */
77
- export default function useSubmit(): ISubmit {
72
+ export default function useSubmit(): SubmitFunction {
78
73
  const formAction = useFormAction();
79
- const call = useRouterContext(router => router.submit);
74
+ const routerSubmit = useRouterContext((router) => router.submit);
75
+
76
+ // レンダリング毎に関数の参照が変わって子コンポーネントが不要に再描画されるのを防ぐため、useCallback でラップします。
80
77
  return React.useCallback(
81
78
  function submit(target, options = {}) {
82
79
  if (target instanceof FormData) {
83
- const {
84
- action = formAction,
85
- actionId,
86
- } = options as SubmitPostOptions;
87
- return call({
80
+ // 分岐 1: データ実体がフォームデータである場合 = 副作用を伴うデータ変更処理(POST / Action 契機)
81
+
82
+ const { action = formAction } = options as SubmitPostOptions;
83
+
84
+ // エンジンに対して「FORM_DATA」タイプとしてのサブミットタスクを発行します。
85
+ return routerSubmit({
86
+ type: "FORM_DATA",
88
87
  target,
89
88
  action,
90
- actionId,
91
89
  });
92
90
  } else {
93
- const {
94
- action = formAction,
95
- replace,
96
- } = options as SubmitGetOptions;
97
- return call({
91
+ // 分岐 2: データ実体がクエリーパラメーターである場合 = 読み取り専用の条件更新処理(GET / Loader 契機)
92
+
93
+ const { action = formAction, replace } = options as SubmitGetOptions;
94
+
95
+ return routerSubmit({
96
+ type: "URL_SEARCH_PARAMS",
98
97
  target: target as URLSearchParams,
99
98
  action,
100
- history: replace
101
- ? "replace"
102
- : "push",
99
+ // replace の真偽値に基づき、ブラウザー履歴の追加方法(push / replace)を明示的にマッピングします。
100
+ history: replace ? "replace" : "push",
103
101
  });
104
102
  }
105
103
  },
106
- [
107
- call,
108
- formAction,
109
- ],
104
+ [routerSubmit, formAction],
110
105
  );
111
106
  }
package/src/soseki.ts CHANGED
@@ -1,46 +1,55 @@
1
- export type * from "./components/action-id.jsx";
2
- export { default as ActionId } from "./components/action-id.jsx";
3
-
4
1
  export type * from "./components/browser-router.jsx";
5
2
  export { default as BrowserRouter } from "./components/browser-router.jsx";
6
3
 
7
- export type * from "./components/hidden-input.jsx";
8
- export { default as HiddenInput } from "./components/hidden-input.jsx";
9
-
10
4
  export type * from "./components/outlet.jsx";
11
5
  export { default as Outlet } from "./components/outlet.jsx";
12
6
 
13
- export type * from "./core/deferred-promise.js";
14
- export { default as DeferredPromise } from "./core/deferred-promise.js";
15
-
16
- export type { ErrorMeta, ErrorOptions, ISosekiErrorConstructor, Issue } from "./core/errors.js";
7
+ /**************************************************************************************************/
8
+
9
+ export type {
10
+ Issue,
11
+ UnreachableErrorArgs,
12
+ UnreachableErrorMeta,
13
+ LoaderConditionErrorArgs,
14
+ LoaderConditionErrorMeta,
15
+ LoaderDataNotFoundErrorArgs,
16
+ LoaderDataNotFoundErrorMeta,
17
+ UnexpectedValidationErrorArgs,
18
+ UnexpectedValidationErrorMeta,
19
+ } from "./core/errors.js";
17
20
  export {
18
- ActionConditionError,
19
- ActionExecutionError,
20
21
  ErrorBase,
22
+ setErrorMessage,
23
+ UnreachableError,
24
+ ValidationErrorBase,
21
25
  LoaderConditionError,
22
- MultipleRedirectError,
23
- NavigationApiNotSupportedError,
26
+ LoaderDataNotFoundError,
24
27
  RouteContextMissingError,
25
28
  RouterContextMissingError,
26
- setErrorMessage,
27
29
  UnexpectedValidationError,
28
- UnreachableError,
29
- ValidationErrorBase,
30
+ NavigationApiNotSupportedError,
30
31
  } from "./core/errors.js";
31
32
 
32
33
  export type * from "./core/readonly-form-data.types.js";
33
34
 
34
35
  export type * from "./core/readonly-url.types.js";
35
36
 
37
+ export type * from "./core/redirect-response.js";
38
+ export { default as RedirectResponse } from "./core/redirect-response.js";
39
+
36
40
  export type * from "./core/route-request.js";
37
41
  export { default as RouteRequest } from "./core/route-request.js";
38
42
 
39
43
  export type * from "./core/route.types.js";
40
44
 
45
+ /**************************************************************************************************/
46
+
41
47
  export type * from "./hooks/use-action-data.js";
42
48
  export { default as useActionData } from "./hooks/use-action-data.js";
43
49
 
50
+ export type * from "./hooks/use-form-action.js";
51
+ export { default as useFormAction } from "./hooks/use-form-action.js";
52
+
44
53
  export type * from "./hooks/use-loader-data.js";
45
54
  export { default as useLoaderData } from "./hooks/use-loader-data.js";
46
55
 
@@ -50,26 +59,10 @@ export { default as useNavigate } from "./hooks/use-navigate.js";
50
59
  export type * from "./hooks/use-params.js";
51
60
  export { default as useParams } from "./hooks/use-params.js";
52
61
 
53
- export type * from "./hooks/use-pathname.js";
54
- export { default as usePathname } from "./hooks/use-pathname.js";
55
-
56
62
  export type * from "./hooks/use-submit.js";
57
63
  export { default as useSubmit } from "./hooks/use-submit.js";
58
64
 
59
- export type * from "./utils/get-action-id.js";
60
- export { default as getActionId } from "./utils/get-action-id.js";
61
-
62
- export type * from "./utils/href.js";
63
- export { default as href } from "./utils/href.js";
65
+ /**************************************************************************************************/
64
66
 
65
67
  export type * from "./utils/redirect.js";
66
68
  export { default as redirect } from "./utils/redirect.js";
67
-
68
- export type * from "./utils/route-index.js";
69
- export { default as index } from "./utils/route-index.js";
70
-
71
- export type * from "./utils/route-route.js";
72
- export { default as route } from "./utils/route-route.js";
73
-
74
- export type * from "./utils/set-action-id.js";
75
- export { default as setActionId } from "./utils/set-action-id.js";
@@ -1,13 +1,13 @@
1
1
  import RedirectResponse from "../core/redirect-response.js";
2
2
 
3
3
  /**
4
- * 指定されたパスネームへのリダイレクトを表すレスポンスオブジェクトを生成します。
4
+ * 指定された URL パスへのリダイレクトを表すレスポンスオブジェクトを作成します。
5
5
  *
6
6
  * アクションの中で、別のページへ遷移させるために使用されます。
7
7
  *
8
- * @param pathname リダイレクト先のパスネームです。
9
- * @returns 生成された `RedirectResponse` オブジェクトを返します。
8
+ * @param destination リダイレクト先の URL パスです。
9
+ * @returns 作成された `RedirectResponse` オブジェクトです。
10
10
  */
11
- export default function redirect(pathname: string): RedirectResponse {
12
- return new RedirectResponse(pathname);
11
+ export default function redirect(destination: string): RedirectResponse {
12
+ return new RedirectResponse(destination);
13
13
  }