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
@@ -1,400 +0,0 @@
1
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2
- import getTypeName from "type-name";
3
- import { getGlobalConfig } from "valibot";
4
- import isPromiseLike from "./_is-promise-like.js";
5
- import singleton from "./_singleton.js";
6
- /***************************************************************************************************
7
- *
8
- * ユーティリティー
9
- *
10
- **************************************************************************************************/
11
- /**
12
- * エラーコンストラクターと言語ごとのエラーメッセージ作成関数のマップを取得します。
13
- *
14
- * @returns エラーコンストラクターと言語ごとのエラーメッセージ作成関数のマップです。
15
- */
16
- function getMessage() {
17
- return singleton("errors__message", () => new WeakMap());
18
- }
19
- /**
20
- * エラーコンストラクター内でメッセージプロパティーを初期化します。
21
- *
22
- * @template TInstance エラーオブジェクトの型です。
23
- * @param instance エラーオブジェクトです。
24
- * @param message エラーメッセージです。
25
- */
26
- function initMessage(instance, message) {
27
- const reference = instance.constructor;
28
- const { lang = "en" } = getGlobalConfig();
29
- const msg = getMessage();
30
- const store = msg.get(reference);
31
- const genMessage = store?.get(lang) ?? message;
32
- instance.message = genMessage(instance);
33
- }
34
- /**
35
- * soseki のエラーに特定の言語でエラーメッセージを設定します。
36
- *
37
- * @template TReference soseki のエラーコンストラクターの型です。
38
- * @param reference soseki のエラーコンストラクターです。
39
- * @param message エラーメッセージです。
40
- * @param lang 言語です。
41
- * @example
42
- * ```ts
43
- * setErrorMessage(
44
- * TypeError,
45
- * ({ meta }) => `${meta.expected} を期待しましたが、${meta.actual} を得ました`,
46
- * "ja",
47
- * );
48
- * ```
49
- */
50
- export function setErrorMessage(reference, message, lang) {
51
- const msg = getMessage();
52
- let store = msg.get(reference);
53
- if (store === undefined) {
54
- store = new Map();
55
- msg.set(reference, store);
56
- }
57
- store.set(lang, message);
58
- }
59
- /**
60
- * あらゆる値を文字列に整形します。
61
- *
62
- * @param value 文字列に整形する値です。
63
- * @returns 文字列に整形された値です。
64
- */
65
- function formatErrorValue(value) {
66
- try {
67
- return JSON.stringify(value);
68
- }
69
- catch {
70
- return String(value);
71
- }
72
- }
73
- /***************************************************************************************************
74
- *
75
- * エラークラス
76
- *
77
- **************************************************************************************************/
78
- /**
79
- * soseki エラーの基底クラスです。
80
- *
81
- * @template TMeta エラーに紐づくメタデータです。
82
- */
83
- export class ErrorBase extends Error {
84
- /**
85
- * @internal
86
- */
87
- constructor(options, meta) {
88
- super("", options);
89
- if (!("cause" in this) && options && "cause" in options) {
90
- this.cause = options.cause;
91
- }
92
- this.meta = meta;
93
- }
94
- }
95
- /**************************************************************************************************/
96
- /**
97
- * 到達不能なコードに到達した場合に投げられるエラーです。
98
- */
99
- export class UnreachableError extends ErrorBase {
100
- /**
101
- * `UnreachableError` クラスの新しいインスタンスを初期化します。
102
- *
103
- * @param args 到達しないはずの値があれば指定します。
104
- * @param options エラーのオプションです。
105
- */
106
- constructor(args, options) {
107
- super(options, args.length > 0 ? { value: args[0] } : {});
108
- initMessage(this, ({ meta }) => ("value" in meta
109
- ? "Encountered impossible value: " + formatErrorValue(meta.value)
110
- : "Unreachable code reached"));
111
- }
112
- }
113
- _a = UnreachableError;
114
- (() => {
115
- _a.prototype.name = "SosekiUnreachableError";
116
- })();
117
- /*#__PURE__*/ setErrorMessage(UnreachableError, ({ meta }) => ("value" in meta
118
- ? "不可能な値に遭遇しました: " + formatErrorValue(meta.value)
119
- : "到達できないコードに到達しました"), "ja");
120
- /**************************************************************************************************/
121
- /**
122
- * 検証エラーの基底クラスです。
123
- *
124
- * @template TMeta エラーに紐づくメタデータです。
125
- */
126
- export class ValidationErrorBase extends ErrorBase {
127
- /**
128
- * @internal
129
- */
130
- constructor(options, meta) {
131
- super(options, meta);
132
- }
133
- }
134
- /**************************************************************************************************/
135
- // /**
136
- // * 入力値検証エラーの基底クラスです。
137
- // *
138
- // * @template TMeta エラーに紐づくメタデータです。
139
- // */
140
- // export class InvalidInputErrorBase<TMeta extends ErrorMeta> extends ValidationErrorBase<TMeta> {
141
- // /**
142
- // * @internal
143
- // */
144
- // public constructor(options: ErrorOptions | undefined, meta: TMeta) {
145
- // super(options, meta);
146
- // }
147
- // }
148
- /**************************************************************************************************/
149
- // /**
150
- // * 入力値の検証に失敗した場合に投げられるエラーです。
151
- // */
152
- // export class InvalidInputError extends InvalidInputErrorBase<{
153
- // /**
154
- // * 検証エラーの問題点です。
155
- // */
156
- // issues: [Issue, ...Issue[]];
157
- // /**
158
- // * 検証した入力値です。
159
- // */
160
- // input: unknown;
161
- // }> {
162
- // static {
163
- // this.prototype.name = "SosekiInvalidInputError";
164
- // }
165
- // /**
166
- // * `InvalidInputError` クラスの新しいインスタンスを初期化します。
167
- // *
168
- // * @param issues 検証エラーの問題点です。
169
- // * @param input 検証した入力値です。
170
- // * @param options エラーのオプションです。
171
- // */
172
- // public constructor(
173
- // issues: [Issue, ...Issue[]],
174
- // input: unknown,
175
- // options?: ErrorOptions | undefined,
176
- // ) {
177
- // super(options, { issues, input });
178
- // this.message = issues.map(issue => issue.message).join(": ");
179
- // }
180
- // }
181
- /**************************************************************************************************/
182
- /**
183
- * 予期しない値に遭遇した場合に投げられるエラーです。
184
- */
185
- export class UnexpectedValidationError extends ValidationErrorBase {
186
- /**
187
- * `UnexpectedValidationError` クラスの新しいインスタンスを初期化します。
188
- *
189
- * @param issues 検証エラーの問題点です。
190
- * @param value 予期しない値です。
191
- * @param options エラーのオプションです。
192
- */
193
- constructor(issues, value, options) {
194
- super(options, { issues, value });
195
- this.message = issues.map(issue => issue.message).join(": ");
196
- }
197
- }
198
- _b = UnexpectedValidationError;
199
- (() => {
200
- _b.prototype.name = "SosekiUnexpectedValidationError";
201
- })();
202
- /**************************************************************************************************/
203
- /**
204
- * shouldAction が不正な値を返した場合に投げられるエラーです。
205
- */
206
- export class ActionConditionError extends ErrorBase {
207
- /**
208
- * `ActionConditionError` クラスの新しいインスタンスを初期化します。
209
- *
210
- * @param url ルートの URL です。
211
- * @param shouldAction shouldAction 関数です。
212
- * @param returnValue shouldAction が返した値です。
213
- * @param options エラーのオプションです。
214
- */
215
- constructor(url, shouldAction, returnValue, options) {
216
- super(options, {
217
- url,
218
- returnValue,
219
- shouldAction,
220
- });
221
- initMessage(this, ({ meta }) => isPromiseLike(meta.returnValue)
222
- ? "shouldAction must return a boolean value synchronously"
223
- : `Expected boolean, but got ${getTypeName(meta.returnValue) || "unknown"}`);
224
- }
225
- }
226
- _c = ActionConditionError;
227
- (() => {
228
- _c.prototype.name = "SosekiActionConditionError";
229
- })();
230
- /*#__PURE__*/ setErrorMessage(ActionConditionError, ({ meta }) => isPromiseLike(meta.returnValue)
231
- ? "shouldAction は同期的に真偽値を返す必要があります"
232
- : `真偽値を期待しましたが、${getTypeName(meta.returnValue) || "unknown"} を得ました`, "ja");
233
- /**************************************************************************************************/
234
- /**
235
- * 1 つ以上のアクションが失敗した際に投げられるエラーです。
236
- */
237
- export class ActionExecutionError extends ErrorBase {
238
- /**
239
- * `ActionExecutionError` クラスの新しいインスタンスを初期化します。
240
- *
241
- * @param url ルートの URL です。
242
- * @param errors エラーのリストです。
243
- * @param options エラーのオプションです。
244
- */
245
- constructor(url, errors, options) {
246
- super(options, {
247
- url,
248
- errors,
249
- });
250
- initMessage(this, ({ meta }) => `Errors occurred in ${meta.errors.length} action(s)`);
251
- }
252
- }
253
- _d = ActionExecutionError;
254
- (() => {
255
- _d.prototype.name = "SosekiActionExecutionError";
256
- })();
257
- /*#__PURE__*/ setErrorMessage(ActionExecutionError, ({ meta }) => `${meta.errors.length} 個のアクションでエラーが発生しました。`, "ja");
258
- /**************************************************************************************************/
259
- /**
260
- * 複数のアクションからリダイレクトが返された際に投げられるエラーです。
261
- */
262
- export class MultipleRedirectError extends ErrorBase {
263
- /**
264
- * `MultipleRedirectError` クラスの新しいインスタンスを初期化します。
265
- *
266
- * @param url ルートの URL です。
267
- * @param redirects リダイレクト先パスのリストです。
268
- * @param options エラーのオプションです。
269
- */
270
- constructor(url, redirects, options) {
271
- super(options, {
272
- url,
273
- redirects,
274
- });
275
- initMessage(this, ({ meta }) => `Multiple redirects detected: ${meta.redirects.join(", ")}`);
276
- }
277
- }
278
- _e = MultipleRedirectError;
279
- (() => {
280
- _e.prototype.name = "SosekiMultipleRedirectError";
281
- })();
282
- /*#__PURE__*/ setErrorMessage(MultipleRedirectError, ({ meta }) => `複数のリダイレクトが検出されました: ${meta.redirects.join(", ")}`, "ja");
283
- /**************************************************************************************************/
284
- /**
285
- * shouldLoader が不正な値を返した場合に投げられるエラーです。
286
- */
287
- export class LoaderConditionError extends ErrorBase {
288
- /**
289
- * `LoaderConditionError` クラスの新しいインスタンスを初期化します。
290
- *
291
- * @param url ルートの URL です。
292
- * @param shouldLoader shouldLoader 関数です。
293
- * @param returnValue shouldLoader が返した値です。
294
- * @param options エラーのオプションです。
295
- */
296
- constructor(url, shouldLoader, returnValue, options) {
297
- super(options, {
298
- url,
299
- returnValue,
300
- shouldLoader,
301
- });
302
- initMessage(this, ({ meta }) => isPromiseLike(meta.returnValue)
303
- ? "shouldLoader must return a boolean value synchronously"
304
- : `Expected boolean, but got ${getTypeName(meta.returnValue) || "unknown"}`);
305
- }
306
- }
307
- _f = LoaderConditionError;
308
- (() => {
309
- _f.prototype.name = "SosekiLoaderConditionError";
310
- })();
311
- /*#__PURE__*/ setErrorMessage(LoaderConditionError, ({ meta }) => isPromiseLike(meta.returnValue)
312
- ? "shouldLoader は同期的に真偽値を返す必要があります"
313
- : `真偽値を期待しましたが、${getTypeName(meta.returnValue) || "unknown"} を得ました`, "ja");
314
- /**************************************************************************************************/
315
- /**
316
- * Navigation API が現在の環境でサポートされていない場合に投げられるエラーです。
317
- */
318
- export class NavigationApiNotSupportedError extends ErrorBase {
319
- /**
320
- * `NavigationApiNotSupportedError` クラスの新しいインスタンスを初期化します。
321
- *
322
- * @param options エラーのオプションです。
323
- */
324
- constructor(options) {
325
- super(options, {
326
- userAgent: typeof window !== "undefined"
327
- ? window.navigator.userAgent
328
- : "unknown",
329
- });
330
- initMessage(this, () => "The Navigation API is not supported in this environment");
331
- }
332
- }
333
- _g = NavigationApiNotSupportedError;
334
- (() => {
335
- _g.prototype.name = "SosekiNavigationApiNotSupportedError";
336
- })();
337
- /*#__PURE__*/ setErrorMessage(NavigationApiNotSupportedError, () => "現在の環境では Navigation API がサポートされていません", "ja");
338
- /**************************************************************************************************/
339
- /**
340
- * RouteContext が供給されていない場合に投げられるエラーです。
341
- */
342
- export class RouteContextMissingError extends ErrorBase {
343
- /**
344
- * `RouteContextMissingError` クラスの新しいインスタンスを初期化します。
345
- *
346
- * @param options エラーのオプションです。
347
- */
348
- constructor(options) {
349
- // メタデータは不要なため undefined を渡す
350
- super(options, undefined);
351
- initMessage(this, () => "RouteContext not found. Did you forget to wrap your app in <Router />?");
352
- }
353
- }
354
- _h = RouteContextMissingError;
355
- (() => {
356
- _h.prototype.name = "SosekiRouteContextMissingError";
357
- })();
358
- /*#__PURE__*/ setErrorMessage(RouteContextMissingError, () => "RouteContext が見つかりません。アプリを <Router /> で囲むのを忘れていませんか?", "ja");
359
- /**************************************************************************************************/
360
- /**
361
- * RouterContext が供給されていない場合に投げられるエラーです。
362
- */
363
- export class RouterContextMissingError extends ErrorBase {
364
- /**
365
- * `RouterContextMissingError` クラスの新しいインスタンスを初期化します。
366
- *
367
- * @param options エラーのオプションです。
368
- */
369
- constructor(options) {
370
- // メタデータは不要なため undefined を渡す
371
- super(options, undefined);
372
- initMessage(this, () => "RouterContext not found. Did you forget to wrap your app in <Router />?");
373
- }
374
- }
375
- _j = RouterContextMissingError;
376
- (() => {
377
- _j.prototype.name = "SosekiRouterContextMissingError";
378
- })();
379
- /*#__PURE__*/ setErrorMessage(RouterContextMissingError, () => "RouterContext が見つかりません。アプリを <Router /> で囲むのを忘れていませんか?", "ja");
380
- /**************************************************************************************************/
381
- /**
382
- * ローダーに紐づくデータが見つからない場合に投げられるエラーです。
383
- */
384
- export class LoaderDataNotFoundError extends ErrorBase {
385
- /**
386
- * `LoaderDataNotFoundError` クラスの新しいインスタンスを初期化します。
387
- *
388
- * @param loader データが見つからなかった loader 関数です。
389
- * @param options エラーのオプションです。
390
- */
391
- constructor(loader, options) {
392
- super(options, { loader });
393
- initMessage(this, ({ meta }) => `Loader data not found (Loader: ${meta.loader.name || "anonymous"})`);
394
- }
395
- }
396
- _k = LoaderDataNotFoundError;
397
- (() => {
398
- _k.prototype.name = "SosekiLoaderDataNotFoundError";
399
- })();
400
- /*#__PURE__*/ setErrorMessage(LoaderDataNotFoundError, ({ meta }) => `ローダーデータが見つかりません(Loader: ${meta.loader.name || "匿名"})`, "ja");
@@ -1,52 +0,0 @@
1
- import * as v from "./_valibot.js";
2
- import { type HistoryEntryId } from "./history-entry-id-schema.js";
3
- import { type HistoryEntryUrl } from "./history-entry-url-schema.js";
4
- /**
5
- * 履歴エントリーのバリデーションスキーマを生成、または取得します。
6
- *
7
- * 識別子、URL、および 0 以上の整数であるインデックスを持つオブジェクト構造を定義します。
8
- *
9
- * @returns 履歴エントリーのスキーマです。
10
- */
11
- declare const HistoryEntrySchema: () => import("valibot").ObjectSchema<{
12
- readonly id: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").UuidAction<string, undefined>, import("valibot").BrandAction<string, "HistoryEntryId">]>;
13
- readonly url: import("valibot").NullableSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").UrlAction<string, undefined>, import("valibot").RawTransformAction<string, import("./readonly-url.types.js").ReadonlyURL>]>, undefined>;
14
- readonly index: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").SafeIntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>]>;
15
- }, undefined>;
16
- /**
17
- * 履歴エントリーとして受け入れ可能な入力型の定義です。
18
- */
19
- export type HistoryEntryLike = Readonly<v.InferInput<ReturnType<typeof HistoryEntrySchema>>>;
20
- /**
21
- * バリデーション済みの履歴エントリーを表す型定義です。
22
- */
23
- export type HistoryEntry = {
24
- /**
25
- * 履歴エントリーを一意に識別する ID です。
26
- */
27
- readonly id: HistoryEntryId;
28
- /**
29
- * 正規化済みの URL オブジェクトです。
30
- */
31
- readonly url: HistoryEntryUrl;
32
- /**
33
- * 0 以上の整数で表される履歴のインデックスです。
34
- */
35
- readonly index: number;
36
- };
37
- /**
38
- * 入力値が履歴エントリーの形式を満たしているか検証します。
39
- *
40
- * @param entry 検証対象のオブジェクトです。
41
- * @returns バリデーション済み、かつ URL が存在する履歴エントリーです。
42
- */
43
- declare function expectHistoryEntry(entry: HistoryEntryLike): HistoryEntry;
44
- /**
45
- * 入力値が履歴エントリーの形式を満たしているか検証します。
46
- *
47
- * @param entry 検証対象のオブジェクト、または null 系値です。
48
- * @returns 検証に成功した場合は履歴エントリーを、入力が null もしくは URL が欠損している場合は null を返します。
49
- */
50
- declare function expectHistoryEntry(entry: HistoryEntryLike | null | undefined): HistoryEntry | null;
51
- export default expectHistoryEntry;
52
- //# sourceMappingURL=expect-history-entry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"expect-history-entry.d.ts","sourceRoot":"","sources":["../../src/core/expect-history-entry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,eAAe,CAAC;AACnC,OAA6B,EAAE,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACzF,OAA8B,EAAE,KAAK,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAE5F;;;;;;GAMG;AACH,QAAA,MAAM,kBAAkB;;;;aAUrB,CAAC;AAEJ;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC;AAE7F;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,eAAe,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;GAKG;AACH,iBAAS,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,GAAG,YAAY,CAAC;AAEnE;;;;;GAKG;AACH,iBAAS,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,GAAG,SAAS,GAAG,YAAY,GAAG,IAAI,CAAC;AA+B7F,eAAe,kBAAkB,CAAC"}
@@ -1,38 +0,0 @@
1
- import singleton from "./_singleton.js";
2
- import * as v from "./_valibot.js";
3
- import HistoryEntryIdSchema from "./history-entry-id-schema.js";
4
- import HistoryEntryUrlSchema from "./history-entry-url-schema.js";
5
- /**
6
- * 履歴エントリーのバリデーションスキーマを生成、または取得します。
7
- *
8
- * 識別子、URL、および 0 以上の整数であるインデックスを持つオブジェクト構造を定義します。
9
- *
10
- * @returns 履歴エントリーのスキーマです。
11
- */
12
- const HistoryEntrySchema = () => (singleton("HistoryEntrySchema", () => (v.object({
13
- id: HistoryEntryIdSchema(),
14
- url: v.nullable(HistoryEntryUrlSchema()),
15
- index: v.pipe(v.number(), v.safeInteger(), v.minValue(0)),
16
- }))));
17
- /**
18
- * 入力値が履歴エントリーの形式を満たしているか検証します。
19
- *
20
- * @param entry 検証対象のデータです。
21
- * @returns 検証結果に基づく履歴エントリー、または null です。
22
- */
23
- function expectHistoryEntry(entry) {
24
- if (entry == null) {
25
- return null;
26
- }
27
- const { id, url, index, } = v.expect(HistoryEntrySchema(), entry);
28
- // URL が nullable として定義されていますが、この関数では URL が存在することを必須とします。
29
- if (!url) {
30
- return null;
31
- }
32
- return {
33
- id,
34
- url,
35
- index,
36
- };
37
- }
38
- export default expectHistoryEntry;
@@ -1,17 +0,0 @@
1
- import * as v from "./_valibot.js";
2
- /**
3
- * 履歴エントリー ID のバリデーションスキーマを作成、または取得します。
4
- *
5
- * @returns 履歴エントリー ID のスキーマです。
6
- */
7
- declare const HistoryEntryIdSchema: () => import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").UuidAction<string, undefined>, import("valibot").BrandAction<string, "HistoryEntryId">]>;
8
- /**
9
- * 履歴エントリー ID として受け入れ可能な入力型の定義です(バリデーション前の文字列など)。
10
- */
11
- export type HistoryEntryIdLike = v.InferInput<ReturnType<typeof HistoryEntryIdSchema>>;
12
- /**
13
- * バリデーション済みでブランド化された、履歴エントリー ID の出力型の定義です。
14
- */
15
- export type HistoryEntryId = v.InferOutput<ReturnType<typeof HistoryEntryIdSchema>>;
16
- export default HistoryEntryIdSchema;
17
- //# sourceMappingURL=history-entry-id-schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"history-entry-id-schema.d.ts","sourceRoot":"","sources":["../../src/core/history-entry-id-schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,eAAe,CAAC;AAEnC;;;;GAIG;AACH,QAAA,MAAM,oBAAoB,wMAMvB,CAAC;AAEJ;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC;AAEvF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC;AAEpF,eAAe,oBAAoB,CAAC"}
@@ -1,9 +0,0 @@
1
- import singleton from "./_singleton.js";
2
- import * as v from "./_valibot.js";
3
- /**
4
- * 履歴エントリー ID のバリデーションスキーマを作成、または取得します。
5
- *
6
- * @returns 履歴エントリー ID のスキーマです。
7
- */
8
- const HistoryEntryIdSchema = () => (singleton("HistoryEntryIdSchema", () => (v.pipe(v.string(), v.uuid(), v.brand("HistoryEntryId")))));
9
- export default HistoryEntryIdSchema;
@@ -1,20 +0,0 @@
1
- import * as v from "./_valibot.js";
2
- import type { ReadonlyURL } from "./readonly-url.types.js";
3
- /**
4
- * 履歴エントリー URL のバリデーションおよび変換スキーマを作成、または取得します。
5
- *
6
- * 文字列が有効な URL であるかを確認し、クエリーパラメーターをソートして正規化した `ReadonlyURL` オブジェクトを返します。
7
- *
8
- * @returns 履歴エントリー URL のスキーマです。
9
- */
10
- declare const HistoryEntryUrlSchema: () => import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").UrlAction<string, undefined>, import("valibot").RawTransformAction<string, ReadonlyURL>]>;
11
- /**
12
- * 履歴エントリー URL として受け入れ可能な入力型の定義です(バリデーション前の文字列など)。
13
- */
14
- export type HistoryEntryUrlLike = v.InferInput<ReturnType<typeof HistoryEntryUrlSchema>>;
15
- /**
16
- * バリデーションおよび正規化が行われた後の、履歴エントリー URL の出力型の定義です。
17
- */
18
- export type HistoryEntryUrl = v.InferOutput<ReturnType<typeof HistoryEntryUrlSchema>>;
19
- export default HistoryEntryUrlSchema;
20
- //# sourceMappingURL=history-entry-url-schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"history-entry-url-schema.d.ts","sourceRoot":"","sources":["../../src/core/history-entry-url-schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,eAAe,CAAC;AACnC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;;;;;GAMG;AACH,QAAA,MAAM,qBAAqB,yMAWxB,CAAC;AAEJ;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAAC;AAEzF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAAC;AAEtF,eAAe,qBAAqB,CAAC"}
@@ -1,16 +0,0 @@
1
- import singleton from "./_singleton.js";
2
- import * as v from "./_valibot.js";
3
- /**
4
- * 履歴エントリー URL のバリデーションおよび変換スキーマを作成、または取得します。
5
- *
6
- * 文字列が有効な URL であるかを確認し、クエリーパラメーターをソートして正規化した `ReadonlyURL` オブジェクトを返します。
7
- *
8
- * @returns 履歴エントリー URL のスキーマです。
9
- */
10
- const HistoryEntryUrlSchema = () => (singleton("HistoryEntryUrlSchema", () => (v.pipe(v.string(), v.url(), v.transform(function createNormalizedUrl(s) {
11
- const u = new URL(s);
12
- // 同一の URL として比較しやすくするため、クエリーパラメーターを昇順にソートします。
13
- u.searchParams.sort();
14
- return u;
15
- })))));
16
- export default HistoryEntryUrlSchema;
@@ -1,37 +0,0 @@
1
- import type { IDataStore } from "./data-store.types.js";
2
- import type { HistoryEntry } from "./expect-history-entry.js";
3
- import type { MatchedRoute } from "./match-routes.js";
4
- import type { ILoader } from "./route.types.js";
5
- /**
6
- * ローダーの初期化に使用するパラメーターの型定義です。
7
- */
8
- export type InitLoadersParams = {
9
- /**
10
- * マッチしたルート情報のリストです。パラメーターとデータ関数を含みます。
11
- */
12
- readonly routes: readonly Pick<MatchedRoute, "params" | "dataFuncs">[];
13
- /**
14
- * 履歴エントリーの情報です。 ID と URL を含みます。
15
- */
16
- readonly entry: Pick<HistoryEntry, "id" | "url">;
17
- /**
18
- * データを永続化するためのデータストアです。
19
- */
20
- readonly dataStore: IDataStore<ILoader>;
21
- /**
22
- * 非同期処理を中断するためのシグナルです。
23
- */
24
- readonly signal: AbortSignal;
25
- };
26
- /**
27
- * ルートに定義されたローダーを初期化し、実行します。
28
- *
29
- * 各ローダーの実行結果はデータストアに格納され、すべての実行開始を待機します。
30
- *
31
- * @param params ローダーの初期化に必要なパラメーターオブジェクトです。
32
- * @returns すべてのローダーの処理が開始(Settled)されるまで待機する Promise です。
33
- */
34
- export default function initLoaders(params: InitLoadersParams): {
35
- (): Promise<void>;
36
- };
37
- //# sourceMappingURL=init-loaders.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"init-loaders.d.ts","sourceRoot":"","sources":["../../src/core/init-loaders.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,SAAS,IAAI,CAAC,YAAY,EAAE,QAAQ,GAAG,WAAW,CAAC,EAAE,CAAC;IAEvE;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,GAAG,KAAK,CAAC,CAAC;IAEjD;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAExC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;CAC9B,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG;IAC9D,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACnB,CAmCA"}
@@ -1,38 +0,0 @@
1
- import DeferredPromise from "./deferred-promise.js";
2
- import RouteRequest from "./route-request.js";
3
- /**
4
- * ルートに定義されたローダーを初期化し、実行します。
5
- *
6
- * 各ローダーの実行結果はデータストアに格納され、すべての実行開始を待機します。
7
- *
8
- * @param params ローダーの初期化に必要なパラメーターオブジェクトです。
9
- * @returns すべてのローダーの処理が開始(Settled)されるまで待機する Promise です。
10
- */
11
- export default function initLoaders(params) {
12
- const { entry, routes, signal, dataStore, } = params;
13
- const dataMap = new Map();
14
- const request = new RouteRequest("GET", entry.url, signal);
15
- // 各ルートおよびそのデータ関数に含まれるローダーを走査します。
16
- for (const route of routes) {
17
- for (const { loader } of route.dataFuncs) {
18
- if (!loader) {
19
- continue;
20
- }
21
- // ローダーの実行を遅延評価としてラップします。
22
- const data = DeferredPromise.try(function executeLoader() {
23
- return loader({
24
- params: route.params,
25
- request,
26
- });
27
- });
28
- // ローダーの結果を待機、エラーハンドリングする処理は、この結果を参照するコンポーネントに任せます。
29
- dataMap.set(loader, data);
30
- }
31
- }
32
- // 生成されたデータマップを履歴エントリーの ID に紐付けて保存します。
33
- dataStore.set(entry.id, dataMap);
34
- return async function waitForLoadersComplete() {
35
- // すべてのローダーの Promise が確定するまで待機します。
36
- await Promise.allSettled(dataMap.values());
37
- };
38
- }