@softistx/alxia-react-router 0.0.0-stage → 0.83.1

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 (609) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2085 -2
  3. package/dist/api-keys/api-keys.d.ts +93 -0
  4. package/dist/api-keys/api-keys.d.ts.map +1 -0
  5. package/dist/api-keys/index.d.ts +9 -0
  6. package/dist/api-keys/index.d.ts.map +1 -0
  7. package/dist/api-keys/index.js +66 -0
  8. package/dist/api-keys/index.js.map +10 -0
  9. package/dist/assets.d.ts +14 -0
  10. package/dist/assets.d.ts.map +1 -0
  11. package/dist/chunks/index-0786n4qe.js +25 -0
  12. package/dist/chunks/index-0786n4qe.js.map +10 -0
  13. package/dist/chunks/index-1nw5yeek.js +169 -0
  14. package/dist/chunks/index-1nw5yeek.js.map +11 -0
  15. package/dist/chunks/index-59vhfj6n.js +10 -0
  16. package/dist/chunks/index-59vhfj6n.js.map +10 -0
  17. package/dist/chunks/index-5gqcpyyg.js +34 -0
  18. package/dist/chunks/index-5gqcpyyg.js.map +10 -0
  19. package/dist/chunks/index-6jf7zpxz.js +119 -0
  20. package/dist/chunks/index-6jf7zpxz.js.map +11 -0
  21. package/dist/chunks/index-8as4j8m3.js +340 -0
  22. package/dist/chunks/index-8as4j8m3.js.map +16 -0
  23. package/dist/chunks/index-9xv2a8et.js +108 -0
  24. package/dist/chunks/index-9xv2a8et.js.map +11 -0
  25. package/dist/chunks/index-ajtvyq35.js +16 -0
  26. package/dist/chunks/index-ajtvyq35.js.map +10 -0
  27. package/dist/chunks/index-c55hxgr5.js +124 -0
  28. package/dist/chunks/index-c55hxgr5.js.map +14 -0
  29. package/dist/chunks/index-d42p3mdp.js +19 -0
  30. package/dist/chunks/index-d42p3mdp.js.map +10 -0
  31. package/dist/chunks/index-gac44rs5.js +42 -0
  32. package/dist/chunks/index-gac44rs5.js.map +11 -0
  33. package/dist/chunks/index-j4ktpcke.js +62 -0
  34. package/dist/chunks/index-j4ktpcke.js.map +10 -0
  35. package/dist/chunks/index-mscfme4r.js +12 -0
  36. package/dist/chunks/index-mscfme4r.js.map +10 -0
  37. package/dist/chunks/index-pghmb2dm.js +30 -0
  38. package/dist/chunks/index-pghmb2dm.js.map +10 -0
  39. package/dist/chunks/index-rfr02vg4.js +40 -0
  40. package/dist/chunks/index-rfr02vg4.js.map +10 -0
  41. package/dist/chunks/index-sfhshxqz.js +31 -0
  42. package/dist/chunks/index-sfhshxqz.js.map +10 -0
  43. package/dist/chunks/index-skwypsjz.js +357 -0
  44. package/dist/chunks/index-skwypsjz.js.map +12 -0
  45. package/dist/chunks/index-sxh06ged.js +118 -0
  46. package/dist/chunks/index-sxh06ged.js.map +11 -0
  47. package/dist/chunks/index-t2ph23wk.js +96 -0
  48. package/dist/chunks/index-t2ph23wk.js.map +13 -0
  49. package/dist/chunks/index-thyabr5n.js +19 -0
  50. package/dist/chunks/index-thyabr5n.js.map +10 -0
  51. package/dist/chunks/index-tx36swjx.js +134 -0
  52. package/dist/chunks/index-tx36swjx.js.map +11 -0
  53. package/dist/chunks/index-v2z5k640.js +54 -0
  54. package/dist/chunks/index-v2z5k640.js.map +11 -0
  55. package/dist/chunks/index-vr82typq.js +23 -0
  56. package/dist/chunks/index-vr82typq.js.map +11 -0
  57. package/dist/chunks/index-whj6h5eg.js +9 -0
  58. package/dist/chunks/index-whj6h5eg.js.map +10 -0
  59. package/dist/chunks/index-wyypkfdv.js +130 -0
  60. package/dist/chunks/index-wyypkfdv.js.map +13 -0
  61. package/dist/chunks/index-xd5aqy3g.js +90 -0
  62. package/dist/chunks/index-xd5aqy3g.js.map +10 -0
  63. package/dist/chunks/index-zdbqzcjp.js +97 -0
  64. package/dist/chunks/index-zdbqzcjp.js.map +12 -0
  65. package/dist/chunks/index-zyg8amjc.js +23 -0
  66. package/dist/chunks/index-zyg8amjc.js.map +10 -0
  67. package/dist/cli/index.d.ts +3 -0
  68. package/dist/cli/index.d.ts.map +1 -0
  69. package/dist/cli/index.js +215 -0
  70. package/dist/cli/index.js.map +13 -0
  71. package/dist/cli/main.d.ts +13 -0
  72. package/dist/cli/main.d.ts.map +1 -0
  73. package/dist/cli/reveal.d.ts +18 -0
  74. package/dist/cli/reveal.d.ts.map +1 -0
  75. package/dist/cli/template.d.ts +8 -0
  76. package/dist/cli/template.d.ts.map +1 -0
  77. package/dist/context.d.ts +104 -0
  78. package/dist/context.d.ts.map +1 -0
  79. package/dist/document/index.d.ts +11 -0
  80. package/dist/document/index.d.ts.map +1 -0
  81. package/dist/document/index.js +19 -0
  82. package/dist/document/index.js.map +9 -0
  83. package/dist/document/inline-script.d.ts +27 -0
  84. package/dist/document/inline-script.d.ts.map +1 -0
  85. package/dist/document/language-store.d.ts +8 -0
  86. package/dist/document/language-store.d.ts.map +1 -0
  87. package/dist/document/nonce.d.ts +34 -0
  88. package/dist/document/nonce.d.ts.map +1 -0
  89. package/dist/document/page-language.d.ts +39 -0
  90. package/dist/document/page-language.d.ts.map +1 -0
  91. package/dist/document/text-direction.d.ts +10 -0
  92. package/dist/document/text-direction.d.ts.map +1 -0
  93. package/dist/entry/abort.d.ts +21 -0
  94. package/dist/entry/abort.d.ts.map +1 -0
  95. package/dist/entry/create-entry.d.ts +41 -0
  96. package/dist/entry/create-entry.d.ts.map +1 -0
  97. package/dist/entry/index.d.ts +8 -0
  98. package/dist/entry/index.d.ts.map +1 -0
  99. package/dist/entry/index.js +154 -0
  100. package/dist/entry/index.js.map +13 -0
  101. package/dist/entry/root-data.d.ts +27 -0
  102. package/dist/entry/root-data.d.ts.map +1 -0
  103. package/dist/entry/whole-page.d.ts +10 -0
  104. package/dist/entry/whole-page.d.ts.map +1 -0
  105. package/dist/errors/api-error.d.ts +117 -0
  106. package/dist/errors/api-error.d.ts.map +1 -0
  107. package/dist/errors/api-errors.d.ts +122 -0
  108. package/dist/errors/api-errors.d.ts.map +1 -0
  109. package/dist/errors/call-failure.d.ts +45 -0
  110. package/dist/errors/call-failure.d.ts.map +1 -0
  111. package/dist/errors/catalogue-check.d.ts +24 -0
  112. package/dist/errors/catalogue-check.d.ts.map +1 -0
  113. package/dist/errors/catalogue-read.d.ts +33 -0
  114. package/dist/errors/catalogue-read.d.ts.map +1 -0
  115. package/dist/errors/catalogue.d.ts +59 -0
  116. package/dist/errors/catalogue.d.ts.map +1 -0
  117. package/dist/errors/code-resolver.d.ts +44 -0
  118. package/dist/errors/code-resolver.d.ts.map +1 -0
  119. package/dist/errors/cross-site.d.ts +8 -0
  120. package/dist/errors/cross-site.d.ts.map +1 -0
  121. package/dist/errors/describe-refusal.d.ts +6 -0
  122. package/dist/errors/describe-refusal.d.ts.map +1 -0
  123. package/dist/errors/describe.d.ts +3 -0
  124. package/dist/errors/describe.d.ts.map +1 -0
  125. package/dist/errors/fetcher-result.d.ts +33 -0
  126. package/dist/errors/fetcher-result.d.ts.map +1 -0
  127. package/dist/errors/field-placement.d.ts +12 -0
  128. package/dist/errors/field-placement.d.ts.map +1 -0
  129. package/dist/errors/form-errors.d.ts +8 -0
  130. package/dist/errors/form-errors.d.ts.map +1 -0
  131. package/dist/errors/form-refusal.d.ts +25 -0
  132. package/dist/errors/form-refusal.d.ts.map +1 -0
  133. package/dist/errors/index.d.ts +21 -0
  134. package/dist/errors/index.d.ts.map +1 -0
  135. package/dist/errors/index.js +588 -0
  136. package/dist/errors/index.js.map +26 -0
  137. package/dist/errors/json-actions.d.ts +38 -0
  138. package/dist/errors/json-actions.d.ts.map +1 -0
  139. package/dist/errors/log.d.ts +8 -0
  140. package/dist/errors/log.d.ts.map +1 -0
  141. package/dist/errors/message-values.d.ts +11 -0
  142. package/dist/errors/message-values.d.ts.map +1 -0
  143. package/dist/errors/messages.d.ts +63 -0
  144. package/dist/errors/messages.d.ts.map +1 -0
  145. package/dist/errors/page-path.d.ts +9 -0
  146. package/dist/errors/page-path.d.ts.map +1 -0
  147. package/dist/errors/problem-error.d.ts +50 -0
  148. package/dist/errors/problem-error.d.ts.map +1 -0
  149. package/dist/errors/provider.d.ts +20 -0
  150. package/dist/errors/provider.d.ts.map +1 -0
  151. package/dist/errors/request-id.d.ts +5 -0
  152. package/dist/errors/request-id.d.ts.map +1 -0
  153. package/dist/errors/route-error.d.ts +33 -0
  154. package/dist/errors/route-error.d.ts.map +1 -0
  155. package/dist/errors/route-refusal.d.ts +20 -0
  156. package/dist/errors/route-refusal.d.ts.map +1 -0
  157. package/dist/errors/same-site.d.ts +49 -0
  158. package/dist/errors/same-site.d.ts.map +1 -0
  159. package/dist/errors/section-action.d.ts +46 -0
  160. package/dist/errors/section-action.d.ts.map +1 -0
  161. package/dist/errors/standard-schema.d.ts +34 -0
  162. package/dist/errors/standard-schema.d.ts.map +1 -0
  163. package/dist/errors/submit-form.d.ts +16 -0
  164. package/dist/errors/submit-form.d.ts.map +1 -0
  165. package/dist/errors/upstream-headers.d.ts +18 -0
  166. package/dist/errors/upstream-headers.d.ts.map +1 -0
  167. package/dist/errors/use-json-fetcher.d.ts +18 -0
  168. package/dist/errors/use-json-fetcher.d.ts.map +1 -0
  169. package/dist/fetcher/auth-refusal.d.ts +29 -0
  170. package/dist/fetcher/auth-refusal.d.ts.map +1 -0
  171. package/dist/fetcher/index.d.ts +20 -0
  172. package/dist/fetcher/index.d.ts.map +1 -0
  173. package/dist/fetcher/index.js +392 -0
  174. package/dist/fetcher/index.js.map +21 -0
  175. package/dist/fetcher/section-form.d.ts +24 -0
  176. package/dist/fetcher/section-form.d.ts.map +1 -0
  177. package/dist/fetcher/section-reload.d.ts +17 -0
  178. package/dist/fetcher/section-reload.d.ts.map +1 -0
  179. package/dist/fetcher/section-save.d.ts +29 -0
  180. package/dist/fetcher/section-save.d.ts.map +1 -0
  181. package/dist/fetcher/use-debounced-fetcher.d.ts +57 -0
  182. package/dist/fetcher/use-debounced-fetcher.d.ts.map +1 -0
  183. package/dist/fetcher/use-fetcher-answer.d.ts +16 -0
  184. package/dist/fetcher/use-fetcher-answer.d.ts.map +1 -0
  185. package/dist/fetcher/use-fetcher-done.d.ts +15 -0
  186. package/dist/fetcher/use-fetcher-done.d.ts.map +1 -0
  187. package/dist/fetcher/use-fetcher-promise.d.ts +48 -0
  188. package/dist/fetcher/use-fetcher-promise.d.ts.map +1 -0
  189. package/dist/fetcher/use-form-refusal.d.ts +20 -0
  190. package/dist/fetcher/use-form-refusal.d.ts.map +1 -0
  191. package/dist/fetcher/use-revalidate-on-focus.d.ts +20 -0
  192. package/dist/fetcher/use-revalidate-on-focus.d.ts.map +1 -0
  193. package/dist/fetcher/use-row-save.d.ts +32 -0
  194. package/dist/fetcher/use-row-save.d.ts.map +1 -0
  195. package/dist/fetcher/use-section-save.d.ts +46 -0
  196. package/dist/fetcher/use-section-save.d.ts.map +1 -0
  197. package/dist/fetcher/use-visible-interval.d.ts +24 -0
  198. package/dist/fetcher/use-visible-interval.d.ts.map +1 -0
  199. package/dist/fetcher/use-visible-revalidation.d.ts +10 -0
  200. package/dist/fetcher/use-visible-revalidation.d.ts.map +1 -0
  201. package/dist/health.d.ts +21 -0
  202. package/dist/health.d.ts.map +1 -0
  203. package/dist/help/check/check.d.ts +35 -0
  204. package/dist/help/check/check.d.ts.map +1 -0
  205. package/dist/help/check/index.d.ts +8 -0
  206. package/dist/help/check/index.d.ts.map +1 -0
  207. package/dist/help/check/index.js +17 -0
  208. package/dist/help/check/index.js.map +9 -0
  209. package/dist/help/check/routes.d.ts +22 -0
  210. package/dist/help/check/routes.d.ts.map +1 -0
  211. package/dist/help/guide.d.ts +33 -0
  212. package/dist/help/guide.d.ts.map +1 -0
  213. package/dist/help/index.d.ts +16 -0
  214. package/dist/help/index.d.ts.map +1 -0
  215. package/dist/help/index.js +192 -0
  216. package/dist/help/index.js.map +14 -0
  217. package/dist/help/load.d.ts +39 -0
  218. package/dist/help/load.d.ts.map +1 -0
  219. package/dist/help/panel.d.ts +69 -0
  220. package/dist/help/panel.d.ts.map +1 -0
  221. package/dist/help/parse-flow.d.ts +27 -0
  222. package/dist/help/parse-flow.d.ts.map +1 -0
  223. package/dist/help/react.d.ts +12 -0
  224. package/dist/help/react.d.ts.map +1 -0
  225. package/dist/help/resolve.d.ts +24 -0
  226. package/dist/help/resolve.d.ts.map +1 -0
  227. package/dist/help/types.d.ts +50 -0
  228. package/dist/help/types.d.ts.map +1 -0
  229. package/dist/help/yaml.d.ts +18 -0
  230. package/dist/help/yaml.d.ts.map +1 -0
  231. package/dist/index.d.ts +7 -0
  232. package/dist/index.d.ts.map +1 -0
  233. package/dist/index.js +197 -0
  234. package/dist/index.js.map +14 -0
  235. package/dist/link/index.d.ts +7 -0
  236. package/dist/link/index.d.ts.map +1 -0
  237. package/dist/link/index.js +16 -0
  238. package/dist/link/index.js.map +10 -0
  239. package/dist/link/router-link.d.ts +27 -0
  240. package/dist/link/router-link.d.ts.map +1 -0
  241. package/dist/lists/connection-page.d.ts +50 -0
  242. package/dist/lists/connection-page.d.ts.map +1 -0
  243. package/dist/lists/index.d.ts +13 -0
  244. package/dist/lists/index.d.ts.map +1 -0
  245. package/dist/lists/index.js +205 -0
  246. package/dist/lists/index.js.map +15 -0
  247. package/dist/lists/newest-first.d.ts +5 -0
  248. package/dist/lists/newest-first.d.ts.map +1 -0
  249. package/dist/lists/nodes-of.d.ts +21 -0
  250. package/dist/lists/nodes-of.d.ts.map +1 -0
  251. package/dist/lists/or-failed.d.ts +19 -0
  252. package/dist/lists/or-failed.d.ts.map +1 -0
  253. package/dist/lists/use-paged-rows.d.ts +40 -0
  254. package/dist/lists/use-paged-rows.d.ts.map +1 -0
  255. package/dist/lists/use-same-route-loading.d.ts +8 -0
  256. package/dist/lists/use-same-route-loading.d.ts.map +1 -0
  257. package/dist/lists/use-search-change.d.ts +20 -0
  258. package/dist/lists/use-search-change.d.ts.map +1 -0
  259. package/dist/mcp/index.d.ts +8 -0
  260. package/dist/mcp/index.d.ts.map +1 -0
  261. package/dist/mcp/index.js +105 -0
  262. package/dist/mcp/index.js.map +11 -0
  263. package/dist/mcp/mcp-relay.d.ts +58 -0
  264. package/dist/mcp/mcp-relay.d.ts.map +1 -0
  265. package/dist/mcp/relay.d.ts +38 -0
  266. package/dist/mcp/relay.d.ts.map +1 -0
  267. package/dist/media/client/error.d.ts +29 -0
  268. package/dist/media/client/error.d.ts.map +1 -0
  269. package/dist/media/client/index.d.ts +8 -0
  270. package/dist/media/client/index.d.ts.map +1 -0
  271. package/dist/media/client/index.js +133 -0
  272. package/dist/media/client/index.js.map +11 -0
  273. package/dist/media/client/upload.d.ts +32 -0
  274. package/dist/media/client/upload.d.ts.map +1 -0
  275. package/dist/media/forward.d.ts +14 -0
  276. package/dist/media/forward.d.ts.map +1 -0
  277. package/dist/media/headers.d.ts +11 -0
  278. package/dist/media/headers.d.ts.map +1 -0
  279. package/dist/media/index.d.ts +9 -0
  280. package/dist/media/index.d.ts.map +1 -0
  281. package/dist/media/index.js +396 -0
  282. package/dist/media/index.js.map +16 -0
  283. package/dist/media/options.d.ts +114 -0
  284. package/dist/media/options.d.ts.map +1 -0
  285. package/dist/media/path.d.ts +12 -0
  286. package/dist/media/path.d.ts.map +1 -0
  287. package/dist/media/read.d.ts +11 -0
  288. package/dist/media/read.d.ts.map +1 -0
  289. package/dist/media/refusal.d.ts +11 -0
  290. package/dist/media/refusal.d.ts.map +1 -0
  291. package/dist/media/respond.d.ts +8 -0
  292. package/dist/media/respond.d.ts.map +1 -0
  293. package/dist/media/write.d.ts +13 -0
  294. package/dist/media/write.d.ts.map +1 -0
  295. package/dist/navigation/index.d.ts +9 -0
  296. package/dist/navigation/index.d.ts.map +1 -0
  297. package/dist/navigation/index.js +48 -0
  298. package/dist/navigation/index.js.map +11 -0
  299. package/dist/navigation/use-focus-on-navigate.d.ts +16 -0
  300. package/dist/navigation/use-focus-on-navigate.d.ts.map +1 -0
  301. package/dist/navigation/use-route-transition.d.ts +19 -0
  302. package/dist/navigation/use-route-transition.d.ts.map +1 -0
  303. package/dist/nonce.d.ts +16 -0
  304. package/dist/nonce.d.ts.map +1 -0
  305. package/dist/oauth/answer.d.ts +33 -0
  306. package/dist/oauth/answer.d.ts.map +1 -0
  307. package/dist/oauth/binding.d.ts +43 -0
  308. package/dist/oauth/binding.d.ts.map +1 -0
  309. package/dist/oauth/consent.d.ts +134 -0
  310. package/dist/oauth/consent.d.ts.map +1 -0
  311. package/dist/oauth/grants.d.ts +88 -0
  312. package/dist/oauth/grants.d.ts.map +1 -0
  313. package/dist/oauth/index.d.ts +16 -0
  314. package/dist/oauth/index.d.ts.map +1 -0
  315. package/dist/oauth/index.js +207 -0
  316. package/dist/oauth/index.js.map +12 -0
  317. package/dist/oauth/model.d.ts +13 -0
  318. package/dist/oauth/model.d.ts.map +1 -0
  319. package/dist/oauth/react/index.d.ts +7 -0
  320. package/dist/oauth/react/index.d.ts.map +1 -0
  321. package/dist/oauth/react/index.js +99 -0
  322. package/dist/oauth/react/index.js.map +10 -0
  323. package/dist/oauth/react/use-consent.d.ts +52 -0
  324. package/dist/oauth/react/use-consent.d.ts.map +1 -0
  325. package/dist/oidc/dpop.d.ts +80 -0
  326. package/dist/oidc/dpop.d.ts.map +1 -0
  327. package/dist/oidc/errors.d.ts +16 -0
  328. package/dist/oidc/errors.d.ts.map +1 -0
  329. package/dist/oidc/flow.d.ts +59 -0
  330. package/dist/oidc/flow.d.ts.map +1 -0
  331. package/dist/oidc/index.d.ts +11 -0
  332. package/dist/oidc/index.d.ts.map +1 -0
  333. package/dist/oidc/index.js +742 -0
  334. package/dist/oidc/index.js.map +15 -0
  335. package/dist/oidc/oidc.d.ts +132 -0
  336. package/dist/oidc/oidc.d.ts.map +1 -0
  337. package/dist/oidc/revoke.d.ts +28 -0
  338. package/dist/oidc/revoke.d.ts.map +1 -0
  339. package/dist/oidc/seal.d.ts +20 -0
  340. package/dist/oidc/seal.d.ts.map +1 -0
  341. package/dist/pwa/build/build-worker.d.ts +41 -0
  342. package/dist/pwa/build/build-worker.d.ts.map +1 -0
  343. package/dist/pwa/build/index.d.ts +9 -0
  344. package/dist/pwa/build/index.d.ts.map +1 -0
  345. package/dist/pwa/build/index.js +9 -0
  346. package/dist/pwa/build/index.js.map +9 -0
  347. package/dist/pwa/build/precache.d.ts +17 -0
  348. package/dist/pwa/build/precache.d.ts.map +1 -0
  349. package/dist/pwa/index.d.ts +16 -0
  350. package/dist/pwa/index.d.ts.map +1 -0
  351. package/dist/pwa/index.js +110 -0
  352. package/dist/pwa/index.js.map +12 -0
  353. package/dist/pwa/model/caching.d.ts +46 -0
  354. package/dist/pwa/model/caching.d.ts.map +1 -0
  355. package/dist/pwa/model/clear-app-caches.d.ts +9 -0
  356. package/dist/pwa/model/clear-app-caches.d.ts.map +1 -0
  357. package/dist/pwa/model/font-precache.d.ts +15 -0
  358. package/dist/pwa/model/font-precache.d.ts.map +1 -0
  359. package/dist/pwa/model/manifest.d.ts +80 -0
  360. package/dist/pwa/model/manifest.d.ts.map +1 -0
  361. package/dist/pwa/model/precache-list.d.ts +40 -0
  362. package/dist/pwa/model/precache-list.d.ts.map +1 -0
  363. package/dist/pwa/model/registration.d.ts +39 -0
  364. package/dist/pwa/model/registration.d.ts.map +1 -0
  365. package/dist/pwa/model/start-service-worker.d.ts +24 -0
  366. package/dist/pwa/model/start-service-worker.d.ts.map +1 -0
  367. package/dist/pwa/model/storable.d.ts +8 -0
  368. package/dist/pwa/model/storable.d.ts.map +1 -0
  369. package/dist/pwa/model/theme-color.d.ts +20 -0
  370. package/dist/pwa/model/theme-color.d.ts.map +1 -0
  371. package/dist/pwa/model/update-notice.d.ts +38 -0
  372. package/dist/pwa/model/update-notice.d.ts.map +1 -0
  373. package/dist/pwa/model/worker-contract.d.ts +61 -0
  374. package/dist/pwa/model/worker-contract.d.ts.map +1 -0
  375. package/dist/pwa/react/index.d.ts +9 -0
  376. package/dist/pwa/react/index.d.ts.map +1 -0
  377. package/dist/pwa/react/index.js +75 -0
  378. package/dist/pwa/react/index.js.map +13 -0
  379. package/dist/pwa/react/use-online.d.ts +6 -0
  380. package/dist/pwa/react/use-online.d.ts.map +1 -0
  381. package/dist/pwa/react/use-service-worker.d.ts +33 -0
  382. package/dist/pwa/react/use-service-worker.d.ts.map +1 -0
  383. package/dist/pwa/react/use-update-notice.d.ts +14 -0
  384. package/dist/pwa/react/use-update-notice.d.ts.map +1 -0
  385. package/dist/pwa/server/index.d.ts +7 -0
  386. package/dist/pwa/server/index.d.ts.map +1 -0
  387. package/dist/pwa/server/index.js +18 -0
  388. package/dist/pwa/server/index.js.map +10 -0
  389. package/dist/pwa/server/no-cache.d.ts +22 -0
  390. package/dist/pwa/server/no-cache.d.ts.map +1 -0
  391. package/dist/pwa/worker/index.d.ts +9 -0
  392. package/dist/pwa/worker/index.d.ts.map +1 -0
  393. package/dist/pwa/worker/index.js +144 -0
  394. package/dist/pwa/worker/index.js.map +12 -0
  395. package/dist/pwa/worker/injected.d.ts +15 -0
  396. package/dist/pwa/worker/injected.d.ts.map +1 -0
  397. package/dist/pwa/worker/plan.d.ts +65 -0
  398. package/dist/pwa/worker/plan.d.ts.map +1 -0
  399. package/dist/pwa/worker/scope.d.ts +18 -0
  400. package/dist/pwa/worker/scope.d.ts.map +1 -0
  401. package/dist/pwa/worker/start-worker.d.ts +17 -0
  402. package/dist/pwa/worker/start-worker.d.ts.map +1 -0
  403. package/dist/react-router.d.ts +68 -0
  404. package/dist/react-router.d.ts.map +1 -0
  405. package/dist/server.d.ts +127 -0
  406. package/dist/server.d.ts.map +1 -0
  407. package/dist/session/codes.d.ts +9 -0
  408. package/dist/session/codes.d.ts.map +1 -0
  409. package/dist/session/cookies.d.ts +128 -0
  410. package/dist/session/cookies.d.ts.map +1 -0
  411. package/dist/session/flow-types.d.ts +235 -0
  412. package/dist/session/flow-types.d.ts.map +1 -0
  413. package/dist/session/guard.d.ts +10 -0
  414. package/dist/session/guard.d.ts.map +1 -0
  415. package/dist/session/index.d.ts +22 -0
  416. package/dist/session/index.d.ts.map +1 -0
  417. package/dist/session/index.js +1090 -0
  418. package/dist/session/index.js.map +27 -0
  419. package/dist/session/land.d.ts +28 -0
  420. package/dist/session/land.d.ts.map +1 -0
  421. package/dist/session/link-json.d.ts +22 -0
  422. package/dist/session/link-json.d.ts.map +1 -0
  423. package/dist/session/link-land.d.ts +20 -0
  424. package/dist/session/link-land.d.ts.map +1 -0
  425. package/dist/session/link-token.d.ts +24 -0
  426. package/dist/session/link-token.d.ts.map +1 -0
  427. package/dist/session/link-types.d.ts +142 -0
  428. package/dist/session/link-types.d.ts.map +1 -0
  429. package/dist/session/links.d.ts +14 -0
  430. package/dist/session/links.d.ts.map +1 -0
  431. package/dist/session/model/index.d.ts +8 -0
  432. package/dist/session/model/index.d.ts.map +1 -0
  433. package/dist/session/model/index.js +35 -0
  434. package/dist/session/model/index.js.map +9 -0
  435. package/dist/session/model/link-post.d.ts +35 -0
  436. package/dist/session/model/link-post.d.ts.map +1 -0
  437. package/dist/session/model/paths.d.ts +24 -0
  438. package/dist/session/model/paths.d.ts.map +1 -0
  439. package/dist/session/model/safe-next.d.ts +15 -0
  440. package/dist/session/model/safe-next.d.ts.map +1 -0
  441. package/dist/session/model/second-factor.d.ts +16 -0
  442. package/dist/session/model/second-factor.d.ts.map +1 -0
  443. package/dist/session/model/site-path.d.ts +10 -0
  444. package/dist/session/model/site-path.d.ts.map +1 -0
  445. package/dist/session/model/step-up-answers.d.ts +45 -0
  446. package/dist/session/model/step-up-answers.d.ts.map +1 -0
  447. package/dist/session/model/step-up-props.d.ts +22 -0
  448. package/dist/session/model/step-up-props.d.ts.map +1 -0
  449. package/dist/session/model/step-up.d.ts +48 -0
  450. package/dist/session/model/step-up.d.ts.map +1 -0
  451. package/dist/session/react/index.d.ts +13 -0
  452. package/dist/session/react/index.d.ts.map +1 -0
  453. package/dist/session/react/index.js +196 -0
  454. package/dist/session/react/index.js.map +14 -0
  455. package/dist/session/react/step-up/answers.d.ts +9 -0
  456. package/dist/session/react/step-up/answers.d.ts.map +1 -0
  457. package/dist/session/react/step-up/dialog-props.d.ts +27 -0
  458. package/dist/session/react/step-up/dialog-props.d.ts.map +1 -0
  459. package/dist/session/react/step-up/index.d.ts +7 -0
  460. package/dist/session/react/step-up/index.d.ts.map +1 -0
  461. package/dist/session/react/step-up/pending-runs.d.ts +21 -0
  462. package/dist/session/react/step-up/pending-runs.d.ts.map +1 -0
  463. package/dist/session/react/step-up/phase.d.ts +8 -0
  464. package/dist/session/react/step-up/phase.d.ts.map +1 -0
  465. package/dist/session/react/step-up/use-step-up-replay.d.ts +59 -0
  466. package/dist/session/react/step-up/use-step-up-replay.d.ts.map +1 -0
  467. package/dist/session/react/step-up/use-step-up-runner.d.ts +70 -0
  468. package/dist/session/react/step-up/use-step-up-runner.d.ts.map +1 -0
  469. package/dist/session/react/step-up/use-step-up.d.ts +51 -0
  470. package/dist/session/react/step-up/use-step-up.d.ts.map +1 -0
  471. package/dist/session/react/use-code-field.d.ts +37 -0
  472. package/dist/session/react/use-code-field.d.ts.map +1 -0
  473. package/dist/session/react/use-link-fragment.d.ts +22 -0
  474. package/dist/session/react/use-link-fragment.d.ts.map +1 -0
  475. package/dist/session/react/use-link-param.d.ts +26 -0
  476. package/dist/session/react/use-link-param.d.ts.map +1 -0
  477. package/dist/session/react/use-link-post.d.ts +39 -0
  478. package/dist/session/react/use-link-post.d.ts.map +1 -0
  479. package/dist/session/react/use-sign-out.d.ts +46 -0
  480. package/dist/session/react/use-sign-out.d.ts.map +1 -0
  481. package/dist/session/second-factor.d.ts +22 -0
  482. package/dist/session/second-factor.d.ts.map +1 -0
  483. package/dist/session/serialize.d.ts +42 -0
  484. package/dist/session/serialize.d.ts.map +1 -0
  485. package/dist/session/sign-in.d.ts +19 -0
  486. package/dist/session/sign-in.d.ts.map +1 -0
  487. package/dist/session/signed.d.ts +44 -0
  488. package/dist/session/signed.d.ts.map +1 -0
  489. package/dist/session/social-flow.d.ts +22 -0
  490. package/dist/session/social-flow.d.ts.map +1 -0
  491. package/dist/session/social-land.d.ts +31 -0
  492. package/dist/session/social-land.d.ts.map +1 -0
  493. package/dist/session/social-types.d.ts +136 -0
  494. package/dist/session/social-types.d.ts.map +1 -0
  495. package/dist/session/social.d.ts +32 -0
  496. package/dist/session/social.d.ts.map +1 -0
  497. package/dist/session/step-up-codes.d.ts +9 -0
  498. package/dist/session/step-up-codes.d.ts.map +1 -0
  499. package/dist/session/step-up-signed-out.d.ts +21 -0
  500. package/dist/session/step-up-signed-out.d.ts.map +1 -0
  501. package/dist/session/step-up-types.d.ts +127 -0
  502. package/dist/session/step-up-types.d.ts.map +1 -0
  503. package/dist/session/step-up.d.ts +17 -0
  504. package/dist/session/step-up.d.ts.map +1 -0
  505. package/dist/session/step.d.ts +22 -0
  506. package/dist/session/step.d.ts.map +1 -0
  507. package/dist/session/throttle.d.ts +73 -0
  508. package/dist/session/throttle.d.ts.map +1 -0
  509. package/dist/session/timed-wait.d.ts +4 -0
  510. package/dist/session/timed-wait.d.ts.map +1 -0
  511. package/dist/session/viewer.d.ts +34 -0
  512. package/dist/session/viewer.d.ts.map +1 -0
  513. package/dist/subscription/documents.d.ts +3 -0
  514. package/dist/subscription/documents.d.ts.map +1 -0
  515. package/dist/subscription/index.d.ts +7 -0
  516. package/dist/subscription/index.d.ts.map +1 -0
  517. package/dist/subscription/index.js +359 -0
  518. package/dist/subscription/index.js.map +14 -0
  519. package/dist/subscription/proxy.d.ts +54 -0
  520. package/dist/subscription/proxy.d.ts.map +1 -0
  521. package/dist/subscription/react/backoff.d.ts +8 -0
  522. package/dist/subscription/react/backoff.d.ts.map +1 -0
  523. package/dist/subscription/react/classify.d.ts +15 -0
  524. package/dist/subscription/react/classify.d.ts.map +1 -0
  525. package/dist/subscription/react/controller.d.ts +40 -0
  526. package/dist/subscription/react/controller.d.ts.map +1 -0
  527. package/dist/subscription/react/fake-timers.d.ts +8 -0
  528. package/dist/subscription/react/fake-timers.d.ts.map +1 -0
  529. package/dist/subscription/react/index.d.ts +15 -0
  530. package/dist/subscription/react/index.d.ts.map +1 -0
  531. package/dist/subscription/react/index.js +227 -0
  532. package/dist/subscription/react/index.js.map +17 -0
  533. package/dist/subscription/react/reconnect.d.ts +9 -0
  534. package/dist/subscription/react/reconnect.d.ts.map +1 -0
  535. package/dist/subscription/react/scheduler.d.ts +13 -0
  536. package/dist/subscription/react/scheduler.d.ts.map +1 -0
  537. package/dist/subscription/react/timers.d.ts +7 -0
  538. package/dist/subscription/react/timers.d.ts.map +1 -0
  539. package/dist/subscription/react/use-live-subscription.d.ts +36 -0
  540. package/dist/subscription/react/use-live-subscription.d.ts.map +1 -0
  541. package/dist/subscription/react/versions.d.ts +6 -0
  542. package/dist/subscription/react/versions.d.ts.map +1 -0
  543. package/dist/subscription/read.d.ts +17 -0
  544. package/dist/subscription/read.d.ts.map +1 -0
  545. package/dist/subscription/refusal.d.ts +11 -0
  546. package/dist/subscription/refusal.d.ts.map +1 -0
  547. package/dist/subscription/relay.d.ts +16 -0
  548. package/dist/subscription/relay.d.ts.map +1 -0
  549. package/dist/vite/bun.d.ts +21 -0
  550. package/dist/vite/bun.d.ts.map +1 -0
  551. package/dist/vite/bundle.d.ts +33 -0
  552. package/dist/vite/bundle.d.ts.map +1 -0
  553. package/dist/vite/compress.d.ts +18 -0
  554. package/dist/vite/compress.d.ts.map +1 -0
  555. package/dist/vite/config.d.ts +33 -0
  556. package/dist/vite/config.d.ts.map +1 -0
  557. package/dist/vite/dev.d.ts +28 -0
  558. package/dist/vite/dev.d.ts.map +1 -0
  559. package/dist/vite/entry.d.ts +20 -0
  560. package/dist/vite/entry.d.ts.map +1 -0
  561. package/dist/vite/hosts.d.ts +16 -0
  562. package/dist/vite/hosts.d.ts.map +1 -0
  563. package/dist/vite/index.d.ts +68 -0
  564. package/dist/vite/index.d.ts.map +1 -0
  565. package/dist/vite/index.js +635 -0
  566. package/dist/vite/index.js.map +22 -0
  567. package/dist/vite/inline.d.ts +18 -0
  568. package/dist/vite/inline.d.ts.map +1 -0
  569. package/dist/vite/node.d.ts +16 -0
  570. package/dist/vite/node.d.ts.map +1 -0
  571. package/dist/vite/preview.d.ts +8 -0
  572. package/dist/vite/preview.d.ts.map +1 -0
  573. package/dist/vite/runtime.d.ts +8 -0
  574. package/dist/vite/runtime.d.ts.map +1 -0
  575. package/dist/vite/socket.d.ts +75 -0
  576. package/dist/vite/socket.d.ts.map +1 -0
  577. package/dist/vite/worker.d.ts +16 -0
  578. package/dist/vite/worker.d.ts.map +1 -0
  579. package/dist/with-alxia.d.ts +36 -0
  580. package/dist/with-alxia.d.ts.map +1 -0
  581. package/docs/README.md +42 -0
  582. package/docs/guide/api-keys.md +216 -0
  583. package/docs/guide/beside-the-pages.md +201 -0
  584. package/docs/guide/csp-nonce.md +166 -0
  585. package/docs/guide/customising-the-server.md +324 -0
  586. package/docs/guide/deploying.md +102 -0
  587. package/docs/guide/document.md +334 -0
  588. package/docs/guide/errors.md +1147 -0
  589. package/docs/guide/fetcher.md +355 -0
  590. package/docs/guide/getting-started.md +112 -0
  591. package/docs/guide/help.md +325 -0
  592. package/docs/guide/how-it-works.md +274 -0
  593. package/docs/guide/link.md +32 -0
  594. package/docs/guide/lists.md +225 -0
  595. package/docs/guide/mcp.md +173 -0
  596. package/docs/guide/media.md +273 -0
  597. package/docs/guide/navigation.md +52 -0
  598. package/docs/guide/oauth.md +342 -0
  599. package/docs/guide/oidc.md +262 -0
  600. package/docs/guide/openapi.md +51 -0
  601. package/docs/guide/pwa.md +670 -0
  602. package/docs/guide/session.md +2105 -0
  603. package/docs/guide/subscriptions.md +211 -0
  604. package/docs/guide/testing.md +42 -0
  605. package/docs/guide/typing-the-loaders.md +311 -0
  606. package/docs/guide.md +82 -0
  607. package/docs/roadmap.md +474 -0
  608. package/docs/troubleshooting.md +3837 -0
  609. package/package.json +301 -5
@@ -0,0 +1,211 @@
1
+ # Subscriptions for a BFF
2
+
3
+ This page is for a React Router app that is the backend of its own pages (a
4
+ BFF) and wants to show a GraphQL subscription in the browser: a room's
5
+ events, a chat, a live counter. The browser must not hold the API's token and
6
+ must not be able to send the API a document of its own, so the app exposes
7
+ **one resource route** that checks the user's session, looks the operation up
8
+ in a list the server holds, and relays the API's server-sent events.
9
+
10
+ `@softistx/alxia-react-router/subscription` is that route. It imports nothing (web APIs only), so it adds no peer. Its browser side, `useLiveSubscription`, is [further down](#keep-it-alive-in-the-page).
11
+
12
+ ## Expose a subscription
13
+
14
+ `allow` maps each operation name to the **document the server sends for it**.
15
+ Build the map from your codegen's documents, so the text is the one your
16
+ client was generated from:
17
+
18
+ ```ts
19
+ // app/routes/events.ts: a resource route, served at /events
20
+ import { alxiaOf } from '@softistx/alxia-react-router';
21
+ import {
22
+ createSubscriptionProxy,
23
+ type SubscriptionArgs,
24
+ } from '@softistx/alxia-react-router/subscription';
25
+ import { print } from 'graphql';
26
+ import type { RouterContextProvider } from 'react-router';
27
+ import { ChatMessagesDocument, RoomEventsDocument } from '../generated/graphql';
28
+ import { cookies } from '../session.server';
29
+
30
+ const events = createSubscriptionProxy({
31
+ endpoint: 'https://api.example.com/graphql',
32
+ allow: {
33
+ RoomEvents: print(RoomEventsDocument), // a TypedDocumentNode
34
+ ChatMessages: print(ChatMessagesDocument),
35
+ // or the document string codegen exports, or a literal
36
+ },
37
+ getToken: (request) => cookies.token(request),
38
+ headers: (
39
+ request,
40
+ { context }: SubscriptionArgs<Readonly<RouterContextProvider>>,
41
+ ) => ({
42
+ 'x-client-name': 'my-bff',
43
+ 'x-proxy-secret': process.env.PROXY_SECRET,
44
+ // the trusted client address (behind `proxy: trustProxy(...)`), not the browser's own header; null leaves it out
45
+ 'x-forwarded-for': context ? alxiaOf(context).ip : null,
46
+ 'accept-language': request.headers.get('accept-language'),
47
+ }),});
48
+
49
+ export const loader = events.loader; // GET: operationName and variables in the query string
50
+ export const action = events.action; // POST: the same in a JSON body
51
+ ```
52
+
53
+ ```ts
54
+ // app/routes.ts
55
+ import { route, type RouteConfig } from '@react-router/dev/routes';
56
+
57
+ export default [route('events', 'routes/events.ts')] satisfies RouteConfig;
58
+ ```
59
+
60
+ The browser talks to `/events` with a client that speaks GraphQL over SSE in
61
+ its distinct connections mode, such as `graphql-sse`. It names the operation
62
+ and sends its variables; the `query` it sends, as `graphql-sse` always does,
63
+ is **ignored**:
64
+
65
+ ```ts
66
+ import { createClient } from 'graphql-sse';
67
+
68
+ const client = createClient({ url: '/events', singleConnection: false });
69
+
70
+ const dispose = client.subscribe(
71
+ {
72
+ query: 'subscription RoomEvents($id: ID!) { roomEvents(id: $id) { id kind } }',
73
+ operationName: 'RoomEvents',
74
+ variables: { id: roomId },
75
+ },
76
+ { next: show, error: report, complete: () => {} },
77
+ );
78
+ ```
79
+
80
+ `graphql-sse` sends a POST by default and a GET for `method: 'GET'`; both
81
+ work, each through the matching export.
82
+
83
+ ## What the proxy does
84
+
85
+ | Step | Rule |
86
+ | --- | --- |
87
+ | Same site | Both methods run the rule of `jsonActions`: an `Origin` that is not the app's own, or a `Sec-Fetch-Site` other than `same-origin` or `none`, is a **403** (`origin` sets the app's origin; the request's own by default). It reads headers only. A POST must be `application/json`, else **415**. |
88
+ | Session | `getToken(request)` gives the token, read on the server from the HttpOnly cookie. Empty, `null`, `undefined` or a token holding a line break is a **401**; nothing goes upstream. |
89
+ | Request | The client's `operationName` and `variables` are read. A body that cannot be read (the client left) is a **400**; a body past 64 KiB (`Content-Length` first, then the bytes read), a query string past 16 KiB or `variables` past 16 KiB is a **400**, as is malformed input. Its `query` and `extensions` are ignored. |
90
+ | Allow-list | Each document of `allow` must define `subscription <key>` and no other operation (fragments are fine), or `createSubscriptionProxy` throws a `TypeError` when it is created. `operationName` must be a key of `allow`, else **403**. The proxy sends **its own document** for it, with the client's variables: no document, fragment, extension or persisted id of the client's reaches the API. |
91
+ | Upstream request | A `POST` to `endpoint` with `Accept: text/event-stream`, `Authorization: Bearer <token>` and your `headers`. The browser's own headers and cookies are never forwarded. A header name or value no header can hold (a line break) is a worded **500**. |
92
+ | Relay | Whole events are relayed in order, as the client takes them: a slow client holds the upstream back instead of growing a buffer, and a heartbeat is skipped while one is waiting. A heartbeat comment (`:`) goes out every `heartbeatMs` (15000 by default, `0` turns it off), never inside an event. An event of more than 1 MiB with no end cuts the stream with an `UPSTREAM_ERROR`. |
93
+ | End | The upstream's `complete`, or the end of its stream, closes the client's stream. A stream that breaks sends a `next` with an `UPSTREAM_ERROR` and a `complete`. |
94
+ | Abort | When the browser closes the request, the upstream request is aborted: no subscription is left running. A request that is already aborted never starts one. |
95
+ | Rate limit | An upstream **429** is passed through with `Retry-After` and `retryAfter` in the body (`{ "retryAfter": 12, "errors": [{ "extensions": { "code": "RATE_LIMITED", "retryAfter": 12 } }] }`), read from the upstream's header or body. The proxy never retries. |
96
+ | Other failures | An upstream 5xx, an unreachable API or an answer that is not an event stream is a **502** (`UPSTREAM_ERROR`); an upstream 4xx such as a 401 passes through. |
97
+
98
+ The stream is answered with `Content-Type: text/event-stream`,
99
+ `Cache-Control: no-store, no-transform` and `X-Accel-Buffering: no`, so no
100
+ adapter or reverse proxy needs to buffer it.
101
+
102
+ ## Options
103
+
104
+ | Option | |
105
+ | --- | --- |
106
+ | `endpoint` | the API's GraphQL URL (required) |
107
+ | `allow` | operation name to the document sent upstream (required); each document must define `subscription <name>`, that operation alone, checked when the proxy is created |
108
+ | `getToken(request)` | the session's token, sync or async (required) |
109
+ | `headers` | a record, `Headers`, or `(request, args) => record`, sync or async; `args` is what React Router gave the route (`request`, `context`, `params`), so a header can come from the app's context; a `null` or `undefined` value is left out. A `(request) => record` function keeps working |
110
+ | `origin` | the app's origin for the same-site check, a string or a getter; the request's own by default |
111
+ | `heartbeatMs` | 15000 |
112
+ | `fetch` | the `fetch` used upstream (the global one); useful in specs |
113
+
114
+ ## Keep the stream alive
115
+
116
+ Bun closes a connection that has been idle for `idleTimeout` seconds, 10 by
117
+ default, which is shorter than the proxy's 15 second heartbeat (`heartbeatMs`)
118
+ and than the API's own 12 second ping. Left alone, an idle subscription is
119
+ reset at about 8 to 10 seconds, before the first heartbeat. Set `idleTimeout`
120
+ above both in the server's `listen` options:
121
+
122
+ ```ts
123
+ // app/server.ts
124
+ export default createServer({
125
+ listen: { idleTimeout: 30 }, // seconds
126
+ });
127
+ ```
128
+
129
+ The same goes for the API's server (`app.listen({ idleTimeout: 30 })` with
130
+ `@softistx/alxia-graphql`), and for a proxy's read timeout, which must be longer than
131
+ `heartbeatMs` too. Calling `server.timeout(request, 0)` from a resolver does
132
+ not lift it for the stream. Behind nginx, keep `proxy_buffering off` for the
133
+ route (the `X-Accel-Buffering: no` header does it per response).
134
+
135
+ ## Cross-site requests
136
+
137
+ Both methods refuse a request from another site (the rule above), and the
138
+ session cookie should stay `SameSite=Lax` (`sessionCookies` does it). The
139
+ allow-list is what the browser may start; because the documents are the
140
+ server's, it cannot start anything else, a mutation included. The route does
141
+ not stop a signed-in user from starting an allowed subscription as often as
142
+ they like: rate-limit it (`@softistx/alxia-rate-limit`) if the API does not.
143
+
144
+ ## Keep it alive in the page
145
+
146
+ `@softistx/alxia-react-router/subscription/react` is the browser side of the route
147
+ above. `useLiveSubscription(document, variables, options)` wraps
148
+ `useSubscription` of `@nxgt/graphql-client/react` (an optional peer, `>=0.7.0 <0.9.0`;
149
+ the page needs its `GraphQLProvider`) and handles what a stream that lives for
150
+ minutes needs. The bare client never retries, reconnects or deduplicates.
151
+
152
+ ```tsx
153
+ import { useLiveSubscription } from '@softistx/alxia-react-router/subscription/react';
154
+ import { useRevalidator } from 'react-router';
155
+ import { PublicationChangedDocument } from '../generated/graphql';
156
+
157
+ export function useLivePublication(id: string) {
158
+ const revalidator = useRevalidator();
159
+ return useLiveSubscription(
160
+ PublicationChangedDocument,
161
+ { id },
162
+ {
163
+ keyOf: ({ publicationChanged }) => publicationChanged.publication.id,
164
+ versionOf: ({ publicationChanged }) =>
165
+ publicationChanged.publication.version,
166
+ onChange: ({ publicationChanged }, { revalidate }) => {
167
+ if (!isOnPage(publicationChanged.publication.id)) revalidate();
168
+ },
169
+ revalidate: () => revalidator.revalidate(),
170
+ },
171
+ ); // { status, retry, revalidate }
172
+ }
173
+ ```
174
+
175
+ | Rule | What it does |
176
+ | --- | --- |
177
+ | Reconnect | After an end or a failure, the stream is opened again after 1 s, then 2 s, 4 s, up to 30 s, each spread over its upper half so tabs do not reconnect together. An accepted stream resets the wait. `status` is `reconnecting` meanwhile. |
178
+ | End classification | A **401** stops at once (the session is over; no reconnecting flicker). Any other **4xx** stops: repeating cannot change it. A **429** waits the `retryAfter` the proxy passes on (`errors[0].extensions.retryAfter`, or the body's), when it is longer than the backoff. A 5xx, a network error, a `realtime.session-ended` inside a 200 stream and a clean complete (the API closes a stream after its lifetime) reconnect. |
179
+ | Stopped | `status` is `stopped`; nothing reconnects. `retry()` opens the stream again from `connecting`. |
180
+ | Version dedupe | With `keyOf` and `versionOf`, an event whose version is **lower** than the highest seen for its key is dropped; `onChange` gets fresh events only. An event whose `keyOf` is `null` or `undefined` is never dropped. |
181
+ | Revalidate | Events are hints and nothing is replayed, so after every reopen but the first the page's data is read again through your `revalidate`: once after 300 ms of quiet, or 2 s after the first request of a burst. `onChange` can ask for one too, with `revalidate()` from its second argument. |
182
+ | Cleanup | Timers are cleared on unmount. |
183
+
184
+ **Reconnect only.** For a stream whose every event is the whole state (a
185
+ presence list), leave out `versionOf` and `revalidate`: every event reaches
186
+ `onChange`, and a reopen reads nothing since the stream lists everyone on open.
187
+
188
+ ```tsx
189
+ const [others, setOthers] = useState<Present[]>([]);
190
+ const { status } = useLiveSubscription(
191
+ PresenceDocument,
192
+ { roomId },
193
+ { onChange: ({ presence }) => setOthers(presence), skip: !roomId },
194
+ );
195
+ // on 'stopped' (a 401), drop what was shown
196
+ ```
197
+
198
+ `onChange` and `revalidate` are read when they are called, so a new closure
199
+ each render does not reopen the stream; only the document and the variables
200
+ (by value) do. The rules apart from React are exported too
201
+ (`createLiveController`, `classifyEnd`, `backoffDelay`) for a hook of your own.
202
+
203
+ ## Testing
204
+
205
+ For the hook, mock `@nxgt/graphql-client/react`'s `useSubscription` and call the
206
+ `onOpen`, `onData`, `onError` and `onComplete` it was given. For the rules, use
207
+ `createLiveController` with a `timers` of your own (a fake clock).
208
+
209
+ Give the proxy a fake API through `fetch`, or start a `Bun.serve` that
210
+ answers with an event stream, and call `events.action({ request })`; the
211
+ answer is a plain `Response`.
@@ -0,0 +1,42 @@
1
+ # Testing
2
+
3
+ This page covers testing the app in process, with no server.
4
+
5
+ `server.create(wiring)` makes the app in process, from a build: import
6
+ the server, and pass it React Router's build, which
7
+ `build/server/index.js` holds. The test needs Bun's types:
8
+ `bun add -d @types/bun`, and `"bun"` in the tsconfig's `types`.
9
+
10
+ ```ts
11
+ // app/server.test.ts
12
+ import { expect, test } from 'bun:test';
13
+ import type { ServerBuild } from 'react-router';
14
+ import server from './server';
15
+
16
+ const BROWSER = 'Mozilla/5.0 (Macintosh) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0 Safari/537.36';
17
+
18
+ test('the home page renders', async () => {
19
+ // After `bun run build`: React Router's build is inside the server build.
20
+ const build: ServerBuild = await import(new URL('../build/server/index.js', import.meta.url).href);
21
+ const app = server.create({ build, client: new URL('../build/client', import.meta.url) });
22
+ const response = await app.request('/', { headers: { 'user-agent': BROWSER } });
23
+ expect(response.status).toBe(200);
24
+ });
25
+ ```
26
+
27
+ Or drive the built app itself, the default export of
28
+ `build/server/index.js`: importing it starts no server. Or run it, as
29
+ [the example's spec](https://github.com/softistx/alxia/blob/develop/examples/react-router/app/server.spec.ts)
30
+ does: `bun build/server/index.js` with `PORT=0`, then read the URL from
31
+ its `alxia listening on <url>` line.
32
+
33
+ Send a browser's user agent. `isbot('Bun/1.4.2')` is true, and React
34
+ Router's entry waits for the whole page before it answers a bot, so a test
35
+ with Bun's own user agent never sees a page stream. An index route's action
36
+ is `POST /?index`, not `POST /`.
37
+
38
+ `app.request` runs without a server, so a loader's `alxiaOf(context).server`
39
+ is `undefined` there, and a `publish` it guards with `?.` sends nothing.
40
+ To test one, listen on a free port, `app.listen({ port: 0 })`, open the
41
+ socket, then post to the action (`/todos.data`, the single-fetch URL, for
42
+ its data rather than the page).
@@ -0,0 +1,311 @@
1
+ # Typing the loaders
2
+
3
+ This page covers reading alxia's context in a loader, an action or a
4
+ middleware, typed with `Register` or a type argument, and the keys an app
5
+ makes for itself.
6
+
7
+ Every request through the catch-all sets `alxiaContext`, this package's
8
+ key, on React Router's context provider, to what alxia's middlewares built for
9
+ that request. Three forms read it, each the same object:
10
+
11
+ - **`withAlxia(fn)`**, for a route typed by the generated `Route.*Args`:
12
+ `fn` gets `alxia` beside React Router's arguments;
13
+ - **`alxiaOf(context)`**, inside a plain function, and with a type argument;
14
+ - **`context.alxia`**, where the arguments are typed with `react-router`'s
15
+ own `LoaderFunctionArgs` and `ActionFunctionArgs`
16
+ ([below](#the-shorthand-contextalxia)).
17
+
18
+ ## `withAlxia(fn)`
19
+
20
+ ```ts
21
+ // app/routes/account.tsx
22
+ import { type AlxiaArgs, withAlxia } from '@softistx/alxia-react-router';
23
+ import { redirect } from 'react-router';
24
+ import type { Route } from './+types/account';
25
+
26
+ export const loader = withAlxia(({ alxia, params }: Route.LoaderArgs & AlxiaArgs) => {
27
+ if (alxia.user === null) throw redirect('/login');
28
+ return { name: alxia.user.name, tab: params.tab ?? 'profile' };
29
+ });
30
+ // The page's Route.ComponentProps['loaderData']: { name: string; tab: string }
31
+ ```
32
+
33
+ Annotate `fn`'s parameter as the generated arguments and `AlxiaArgs`:
34
+ `AlxiaArgs` is `{ alxia }`, typed by `Register`, and `AlxiaArgs<typeof server>`
35
+ names a server where nothing is registered. `withAlxia` returns a function of
36
+ React Router's arguments alone, with `fn`'s return type, so the generated
37
+ `loaderData` and `actionData`, and `useLoaderData<typeof loader>`, read what
38
+ `fn` returns. An action is written the same way; a middleware too, and its
39
+ `next` is passed on:
40
+
41
+ ```ts
42
+ import { type AlxiaArgs, withAlxia } from '@softistx/alxia-react-router';
43
+ import type { Route } from './+types/admin';
44
+
45
+ export const middleware: Route.MiddlewareFunction[] = [
46
+ withAlxia(async ({ alxia }: Parameters<Route.MiddlewareFunction>[0] & AlxiaArgs, next) => {
47
+ alxia.log.info('admin');
48
+ return next();
49
+ }),
50
+ ];
51
+ ```
52
+
53
+ Why a wrapper: `context.alxia` cannot be typed under the generated
54
+ arguments ([below](#the-shorthand-contextalxia)), and a wrapper that adds a
55
+ key is the one form TypeScript infers from the annotation alone. A type
56
+ argument, `withAlxia<Route.LoaderArgs>(fn)`, would fix the arguments but
57
+ stop TypeScript inferring `fn`'s return type, since it infers no type
58
+ argument once one is given: the page's `loaderData` would be lost. On a request that did not come
59
+ through alxia it throws what `alxiaOf` throws.
60
+
61
+ ## With `Register`: no type argument
62
+
63
+ The `declare module` block in `app/server.ts` names the server once:
64
+
65
+ ```ts
66
+ declare module '@softistx/alxia-react-router' {
67
+ interface Register {
68
+ server: typeof server;
69
+ }
70
+ }
71
+ ```
72
+
73
+ Every loader, action and middleware then reads it typed, with no import:
74
+
75
+ ```ts
76
+ // app/routes/account.tsx
77
+ import { alxiaOf } from '@softistx/alxia-react-router';
78
+ import { data, redirect } from 'react-router';
79
+ import type { Route } from './+types/account';
80
+
81
+ export function loader({ context }: Route.LoaderArgs) {
82
+ const { user, log, requestId } = alxiaOf(context);
83
+ if (user === null) throw redirect('/login');
84
+ log.info('account');
85
+ return { name: user.name, requestId };
86
+ }
87
+
88
+ export async function action({ request, context }: Route.ActionArgs) {
89
+ const { user } = alxiaOf(context);
90
+ const form = await request.formData();
91
+ if (user === null) return data({ error: 'signed out' }, { status: 401 });
92
+ return { saved: form.get('name'), by: user.name };
93
+ }
94
+ ```
95
+
96
+ Name `typeof server`, the default export's type, not the module's
97
+ (`typeof import('./server')`): a wrong registration makes every read a
98
+ compile error, as [the troubleshooting entry](../troubleshooting.md#property--does-not-exist-on-type-basecontext---readonly-registerserver-must-be-typeof-server-the-default-export-of-createserver-never-)
99
+ shows. The checks it gives:
100
+
101
+ ```ts
102
+ const ctx = alxiaOf(context);
103
+ ctx.tenant; // error: no middleware derives `tenant`
104
+ ctx.user.name; // error: `user` may be null
105
+ ```
106
+
107
+ ## Without `Register`: the type argument
108
+
109
+ Pass the server's type, imported with `import type`, so nothing is
110
+ bundled and the route never imports the server at runtime:
111
+
112
+ ```ts
113
+ // app/server.ts
114
+ const server = createServer({ configure: (app) => app.use(logger()) });
115
+ export default server;
116
+ export type Server = typeof server;
117
+ ```
118
+
119
+ ```ts
120
+ // app/routes/home.tsx
121
+ import { alxiaOf } from '@softistx/alxia-react-router';
122
+ import type { Server } from '../server';
123
+ import type { Route } from './+types/home';
124
+
125
+ export function loader({ context }: Route.LoaderArgs) {
126
+ const { log } = alxiaOf<Server>(context);
127
+ log.info('home');
128
+ return null;
129
+ }
130
+ ```
131
+
132
+ The type argument may also be an alxia app, the app *before* the
133
+ catch-all, for a server of your own. Anything else is a compile error.
134
+
135
+ ## With `@softistx/alxia`'s `Register`
136
+
137
+ `@softistx/alxia` has a `Register` of its own, which names the chain that
138
+ builds an app's context, for its route files
139
+ ([The app's type](https://github.com/softistx/alxia/blob/develop/packages/core/docs/guide/types.md#register-and-appcontext)).
140
+ `alxiaOf(context)` reads it when this package's `Register` names no
141
+ server:
142
+
143
+ ```ts
144
+ // app/context.ts
145
+ import { alxia } from '@softistx/alxia';
146
+
147
+ export const base = alxia().derive(({ request }) => ({ user: request.headers.get('x-user') }));
148
+
149
+ declare module '@softistx/alxia' {
150
+ interface Register {
151
+ context: typeof base;
152
+ }
153
+ }
154
+
155
+ // app/server.ts
156
+ const server = createServer({ configure: (app) => app.plugin(base) });
157
+ export default server;
158
+ ```
159
+
160
+ `alxiaOf(context).user` is then typed with no declaration in
161
+ `@softistx/alxia-react-router`. Which one is read, in order:
162
+
163
+ 1. a type argument, `alxiaOf<typeof server>(context)`;
164
+ 2. this package's `Register`, `server: typeof server`: the whole app the
165
+ pages run behind, `base` and everything `configure` adds after it;
166
+ 3. `@softistx/alxia`'s `Register`, `context: typeof base`: only what `base`
167
+ builds;
168
+ 4. neither: `BaseContext`, the request, its URL, `reply` and the rest of
169
+ what every middleware reads.
170
+
171
+ Declare this package's `Register` when `configure` adds to the context
172
+ after the base, and the loaders read it.
173
+
174
+ ## Why a global augmentation is right here
175
+
176
+ alxia's core refuses a global augmentation of a context key: a plugin
177
+ that added `user` to every route, declared before it or after, would
178
+ type `user` on routes that run before the plugin. That is the lie "order
179
+ is meaning" forbids. Core's own `Register` names the base that builds
180
+ the context instead, and what reads it requires it. `Register` here does
181
+ something else: it names the **one** server of the React Router build,
182
+ at the point of its catch-all, which is exactly what every loader runs
183
+ behind. One build has one server entry, so there is no second app for a
184
+ module to be confused with.
185
+
186
+ If two React Router apps share one TypeScript program (one tsconfig over
187
+ both folders of a monorepo), their two declarations conflict, and `tsc`
188
+ says so (`Subsequent property declarations must have the same type`).
189
+ Give each app its own tsconfig, or use the type argument in both.
190
+
191
+ ## The server: `server`
192
+
193
+ `alxiaOf(context).server` is core's `ctx.server`, the `Bun.Server` serving
194
+ the request, `undefined` with none
195
+ ([Serving](https://github.com/softistx/alxia/blob/develop/packages/core/docs/guide/serving.md#the-server-ctxserver)).
196
+ It is not `Register`'s `server`, which names what `createServer()` returned
197
+ for the types. From an action, its `publish` reaches the app's
198
+ [WebSocket](beside-the-pages.md#websockets) subscribers:
199
+
200
+ ```ts
201
+ // app/routes/todos.tsx
202
+ import { alxiaOf } from '@softistx/alxia-react-router';
203
+ import type { Route } from './+types/todos';
204
+
205
+ export async function action({ request, context }: Route.ActionArgs) {
206
+ const title = String((await request.formData()).get('title'));
207
+ // Bun's own publish: the bytes as given, not checked by a socket's `send` schema.
208
+ alxiaOf(context).server?.publish('todos', JSON.stringify({ added: title }));
209
+ return { added: title };
210
+ }
211
+ ```
212
+
213
+ What it is, by how the app runs:
214
+
215
+ | | `alxiaOf(context).server` |
216
+ | --- | --- |
217
+ | `bun build/server/index.js`, `server.start(app)`, `app.listen()` | the server `listen` started |
218
+ | `react-router dev`, `vite preview` | the `Bun.Server` on a loopback port that the plugin relays the app's sockets to (Vite's own server is `node:http`, not a `Bun.Server`): `publish` reaches every socket the app opened, its `url` is that port's, and `requestIP` and `timeout` know nothing of the request Vite took, so `ctx.ip` stays `undefined` there |
219
+ | Vite in middleware mode, a server of your own calling `app.fetch(request)` alone, `app.request(…)` in a test | `undefined` |
220
+
221
+ ## The shorthand: `context.alxia`
222
+
223
+ This package augments React Router's `RouterContextProvider` with a
224
+ read-only `alxia` property: the object `alxiaOf(context)` returns, with no
225
+ import and no call, typed by the same `Register` (core's, then
226
+ `BaseContext`, with none of this package's):
227
+
228
+ ```ts
229
+ import type { ActionFunctionArgs, LoaderFunctionArgs } from 'react-router';
230
+
231
+ export function loader({ context }: LoaderFunctionArgs) {
232
+ const { user, server } = context.alxia;
233
+ return { name: user?.name ?? 'anonymous', listening: server !== undefined };
234
+ }
235
+
236
+ export async function action({ context }: ActionFunctionArgs) {
237
+ context.alxia.server?.publish('todos', JSON.stringify({ changed: true }));
238
+ return { ok: true };
239
+ }
240
+ ```
241
+
242
+ **Typed with react-router's own argument types, not yet the generated
243
+ ones.** `LoaderFunctionArgs`, `ActionFunctionArgs`, `MiddlewareFunction` and
244
+ `RouterContextProvider`, imported from `react-router`, see `alxia`. The
245
+ generated `Route.LoaderArgs` does not: the `+types` files import from
246
+ `react-router/internal`, whose types (in react-router 8.4 and 8.5) point at its
247
+ `dist/development` build, while `react-router` itself points at
248
+ `dist/production`. That is a second declaration of `RouterContextProvider`,
249
+ which no exported path reaches, so no package can augment it. With
250
+ `Route.LoaderArgs`, `context.alxia` works at runtime and `tsc` reports
251
+ TS2339 ([Troubleshooting](../troubleshooting.md#property-alxia-does-not-exist-on-type-readonlyroutercontextprovider)):
252
+ use `withAlxia` (or `alxiaOf(context)`) there, until react-router ships one declaration.
253
+
254
+ It is a getter on the provider's prototype that reads `alxiaContext`: it
255
+ holds exactly when that key is set, in dev as in production, and on a
256
+ provider no catch-all filled it throws what `alxiaOf` throws. It is the
257
+ server's alone: a `clientLoader` or a `clientAction` has no alxia context.
258
+
259
+ ## Outside the catch-all
260
+
261
+ Without the plugin, under a plain `react-router dev`, or in a unit test
262
+ that calls a loader with a bare provider, there is no alxia context, and
263
+ `alxiaOf` and `context.alxia` throw, saying so. The getter is installed
264
+ when `@softistx/alxia-react-router` is first imported: a test whose program never
265
+ imports it reads `context.alxia` as `undefined`. See
266
+ [the troubleshooting entry](../troubleshooting.md#alxiaof-this-request-has-no-alxia-context-).
267
+
268
+ ## The app's own context keys
269
+
270
+ React Router 8 passes data to loaders through keys made by
271
+ `createContext<T>()`, and matches a key by object identity. Under the
272
+ plugin, the server is built and loaded with the routes, so a key in
273
+ `app/` is one object for both:
274
+
275
+ ```ts
276
+ // app/context.ts
277
+ import { createContext } from 'react-router';
278
+
279
+ export const greetingContext = createContext<string>('unset');
280
+ ```
281
+
282
+ ```ts
283
+ // app/server.ts
284
+ import { createServer } from '@softistx/alxia-react-router';
285
+ import { greetingContext } from './context';
286
+
287
+ export default createServer({
288
+ getLoadContext: (_ctx, context) => context.set(greetingContext, 'hello'),
289
+ });
290
+ ```
291
+
292
+ ```ts
293
+ // app/routes/home.tsx
294
+ import { greetingContext } from '../context';
295
+ import type { Route } from './+types/home';
296
+
297
+ export function loader({ context }: Route.LoaderArgs) {
298
+ return { greeting: context.get(greetingContext) };
299
+ }
300
+ ```
301
+
302
+ `getLoadContext` runs before React Router, on every request, with
303
+ `alxiaContext` already set. Its `ctx` is typed by `configure`'s app:
304
+ reading something no middleware derives is a compile error. Keep the keys in a
305
+ module of their own, such as `app/context.ts`, rather than in
306
+ `app/server.ts`: a route imports them, and the server file then stays out
307
+ of the client's module graph.
308
+
309
+ A server of your own, without the plugin, holds another copy of every
310
+ key under `app/`: see
311
+ [the troubleshooting entry](../troubleshooting.md#error-no-value-found-for-context).
package/docs/guide.md ADDED
@@ -0,0 +1,82 @@
1
+ # Guide
2
+
3
+ The guide moved to `docs/guide/`, one page per topic; the
4
+ [documentation index](README.md) lists them. This page only keeps the old
5
+ anchors, so a link to one of them still lands on the topic: each heading
6
+ below links to where it went.
7
+
8
+ ## Setup
9
+
10
+ Moved to [Getting started](guide/getting-started.md).
11
+
12
+ ## How it works
13
+
14
+ Moved to [How it works](guide/how-it-works.md).
15
+
16
+ ## Built for Bun
17
+
18
+ Moved to [Built for Bun](guide/how-it-works.md#built-for-bun).
19
+
20
+ ## Self-contained
21
+
22
+ Moved to [Self-contained](guide/how-it-works.md#self-contained).
23
+
24
+ ## Customising the server
25
+
26
+ Moved to [Customising the server](guide/customising-the-server.md).
27
+
28
+ ## Typing the loaders
29
+
30
+ Moved to [Typing the loaders](guide/typing-the-loaders.md).
31
+
32
+ ## The server: `server`
33
+
34
+ Moved to [The server: `server`](guide/typing-the-loaders.md#the-server-server).
35
+
36
+ ## The app's own context keys
37
+
38
+ Moved to [The app's own context keys](guide/typing-the-loaders.md#the-apps-own-context-keys).
39
+
40
+ ## A CSP nonce
41
+
42
+ Moved to [A CSP nonce](guide/csp-nonce.md).
43
+
44
+ ## Escape hatches
45
+
46
+ Moved to [Escape hatches](guide/customising-the-server.md#escape-hatches).
47
+
48
+ ## A server of your own, without the plugin
49
+
50
+ Moved to [A server of your own, without the plugin](guide/customising-the-server.md#a-server-of-your-own-without-the-plugin).
51
+
52
+ ## Middlewares around the pages
53
+
54
+ Moved to [Middlewares around the pages](guide/beside-the-pages.md#middlewares-around-the-pages).
55
+
56
+ ## Routes beside the pages
57
+
58
+ Moved to [Routes beside the pages](guide/beside-the-pages.md#routes-beside-the-pages).
59
+
60
+ ## WebSockets
61
+
62
+ Moved to [WebSockets](guide/beside-the-pages.md#websockets).
63
+
64
+ ## The client's files
65
+
66
+ Moved to [The client's files](guide/beside-the-pages.md#the-clients-files).
67
+
68
+ ## OpenAPI
69
+
70
+ Moved to [OpenAPI](guide/openapi.md).
71
+
72
+ ## Testing
73
+
74
+ Moved to [Testing](guide/testing.md).
75
+
76
+ ## Deploying
77
+
78
+ Moved to [Deploying](guide/deploying.md).
79
+
80
+ ## Docker
81
+
82
+ Moved to [Docker](guide/deploying.md#docker).