tempest-react-sdk 0.52.0 → 0.54.0

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 (507) hide show
  1. package/README.md +58 -7
  2. package/dist/access/Can.cjs +1 -1
  3. package/dist/access/Can.cjs.map +1 -1
  4. package/dist/access/Can.js +3 -3
  5. package/dist/access/Can.js.map +1 -1
  6. package/dist/audio/audio-bus.cjs +2 -0
  7. package/dist/audio/audio-bus.cjs.map +1 -0
  8. package/dist/audio/audio-bus.js +116 -0
  9. package/dist/audio/audio-bus.js.map +1 -0
  10. package/dist/audio/level-meter.cjs +1 -1
  11. package/dist/audio/level-meter.cjs.map +1 -1
  12. package/dist/audio/level-meter.js +15 -15
  13. package/dist/audio/level-meter.js.map +1 -1
  14. package/dist/audio/noise-floor.cjs +2 -0
  15. package/dist/audio/noise-floor.cjs.map +1 -0
  16. package/dist/audio/noise-floor.js +27 -0
  17. package/dist/audio/noise-floor.js.map +1 -0
  18. package/dist/audio/use-audio-bus.cjs +2 -0
  19. package/dist/audio/use-audio-bus.cjs.map +1 -0
  20. package/dist/audio/use-audio-bus.js +11 -0
  21. package/dist/audio/use-audio-bus.js.map +1 -0
  22. package/dist/audio/voice-activity.cjs +2 -0
  23. package/dist/audio/voice-activity.cjs.map +1 -0
  24. package/dist/audio/voice-activity.js +26 -0
  25. package/dist/audio/voice-activity.js.map +1 -0
  26. package/dist/audio/voice-chain-stages.cjs +2 -0
  27. package/dist/audio/voice-chain-stages.cjs.map +1 -0
  28. package/dist/audio/voice-chain-stages.js +82 -0
  29. package/dist/audio/voice-chain-stages.js.map +1 -0
  30. package/dist/audio/voice-chain.cjs +2 -0
  31. package/dist/audio/voice-chain.cjs.map +1 -0
  32. package/dist/audio/voice-chain.js +74 -0
  33. package/dist/audio/voice-chain.js.map +1 -0
  34. package/dist/auth/lazy-with-retry.cjs.map +1 -1
  35. package/dist/auth/lazy-with-retry.js.map +1 -1
  36. package/dist/auth/passkey.cjs.map +1 -1
  37. package/dist/auth/passkey.js.map +1 -1
  38. package/dist/br/BrazilStateCitySelect.cjs +1 -1
  39. package/dist/br/BrazilStateCitySelect.cjs.map +1 -1
  40. package/dist/br/BrazilStateCitySelect.js +36 -28
  41. package/dist/br/BrazilStateCitySelect.js.map +1 -1
  42. package/dist/br/data/br-centroids.cjs +1 -1
  43. package/dist/br/data/br-centroids.cjs.map +1 -1
  44. package/dist/br/data/br-centroids.js +11105 -11045
  45. package/dist/br/data/br-centroids.js.map +1 -1
  46. package/dist/br/data/br-locations.cjs +1 -1
  47. package/dist/br/data/br-locations.cjs.map +1 -1
  48. package/dist/br/data/br-locations.js +5803 -137
  49. package/dist/br/data/br-locations.js.map +1 -1
  50. package/dist/br/data/br-uf-geo.cjs +1 -1
  51. package/dist/br/data/br-uf-geo.cjs.map +1 -1
  52. package/dist/br/data/br-uf-geo.js +5721 -6777
  53. package/dist/br/data/br-uf-geo.js.map +1 -1
  54. package/dist/br/data/mun/AC.cjs +1 -1
  55. package/dist/br/data/mun/AC.cjs.map +1 -1
  56. package/dist/br/data/mun/AC.js +681 -689
  57. package/dist/br/data/mun/AC.js.map +1 -1
  58. package/dist/br/data/mun/AL.cjs +1 -1
  59. package/dist/br/data/mun/AL.cjs.map +1 -1
  60. package/dist/br/data/mun/AL.js +949 -844
  61. package/dist/br/data/mun/AL.js.map +1 -1
  62. package/dist/br/data/mun/AM.cjs +1 -1
  63. package/dist/br/data/mun/AM.cjs.map +1 -1
  64. package/dist/br/data/mun/AM.js +4337 -4218
  65. package/dist/br/data/mun/AM.js.map +1 -1
  66. package/dist/br/data/mun/AP.cjs +1 -1
  67. package/dist/br/data/mun/AP.cjs.map +1 -1
  68. package/dist/br/data/mun/AP.js +786 -780
  69. package/dist/br/data/mun/AP.js.map +1 -1
  70. package/dist/br/data/mun/BA.cjs +1 -1
  71. package/dist/br/data/mun/BA.cjs.map +1 -1
  72. package/dist/br/data/mun/BA.js +6329 -5633
  73. package/dist/br/data/mun/BA.js.map +1 -1
  74. package/dist/br/data/mun/CE.cjs +1 -1
  75. package/dist/br/data/mun/CE.cjs.map +1 -1
  76. package/dist/br/data/mun/CE.js +2544 -2487
  77. package/dist/br/data/mun/CE.js.map +1 -1
  78. package/dist/br/data/mun/DF.cjs +1 -1
  79. package/dist/br/data/mun/DF.cjs.map +1 -1
  80. package/dist/br/data/mun/DF.js +17 -16
  81. package/dist/br/data/mun/DF.js.map +1 -1
  82. package/dist/br/data/mun/ES.cjs +1 -1
  83. package/dist/br/data/mun/ES.cjs.map +1 -1
  84. package/dist/br/data/mun/ES.js +1101 -1070
  85. package/dist/br/data/mun/ES.js.map +1 -1
  86. package/dist/br/data/mun/GO.cjs +1 -1
  87. package/dist/br/data/mun/GO.cjs.map +1 -1
  88. package/dist/br/data/mun/GO.js +4632 -4636
  89. package/dist/br/data/mun/GO.js.map +1 -1
  90. package/dist/br/data/mun/MA.cjs +1 -1
  91. package/dist/br/data/mun/MA.cjs.map +1 -1
  92. package/dist/br/data/mun/MA.js +3603 -3457
  93. package/dist/br/data/mun/MA.js.map +1 -1
  94. package/dist/br/data/mun/MG.cjs +1 -1
  95. package/dist/br/data/mun/MG.cjs.map +1 -1
  96. package/dist/br/data/mun/MG.js +12716 -11739
  97. package/dist/br/data/mun/MG.js.map +1 -1
  98. package/dist/br/data/mun/MS.cjs +1 -1
  99. package/dist/br/data/mun/MS.cjs.map +1 -1
  100. package/dist/br/data/mun/MS.js +2182 -2335
  101. package/dist/br/data/mun/MS.js.map +1 -1
  102. package/dist/br/data/mun/MT.cjs +1 -1
  103. package/dist/br/data/mun/MT.cjs.map +1 -1
  104. package/dist/br/data/mun/MT.js +4808 -4896
  105. package/dist/br/data/mun/MT.js.map +1 -1
  106. package/dist/br/data/mun/PA.cjs +1 -1
  107. package/dist/br/data/mun/PA.cjs.map +1 -1
  108. package/dist/br/data/mun/PA.js +4981 -4901
  109. package/dist/br/data/mun/PA.js.map +1 -1
  110. package/dist/br/data/mun/PB.cjs +1 -1
  111. package/dist/br/data/mun/PB.cjs.map +1 -1
  112. package/dist/br/data/mun/PB.js +2418 -1956
  113. package/dist/br/data/mun/PB.js.map +1 -1
  114. package/dist/br/data/mun/PE.cjs +1 -1
  115. package/dist/br/data/mun/PE.cjs.map +1 -1
  116. package/dist/br/data/mun/PE.js +2164 -1987
  117. package/dist/br/data/mun/PE.js.map +1 -1
  118. package/dist/br/data/mun/PI.cjs +1 -1
  119. package/dist/br/data/mun/PI.cjs.map +1 -1
  120. package/dist/br/data/mun/PI.js +2982 -2844
  121. package/dist/br/data/mun/PI.js.map +1 -1
  122. package/dist/br/data/mun/PR.cjs +1 -1
  123. package/dist/br/data/mun/PR.cjs.map +1 -1
  124. package/dist/br/data/mun/PR.js +5425 -5240
  125. package/dist/br/data/mun/PR.js.map +1 -1
  126. package/dist/br/data/mun/RJ.cjs +1 -1
  127. package/dist/br/data/mun/RJ.cjs.map +1 -1
  128. package/dist/br/data/mun/RJ.js +1395 -1178
  129. package/dist/br/data/mun/RJ.js.map +1 -1
  130. package/dist/br/data/mun/RN.cjs +1 -1
  131. package/dist/br/data/mun/RN.cjs.map +1 -1
  132. package/dist/br/data/mun/RN.js +1608 -1382
  133. package/dist/br/data/mun/RN.js.map +1 -1
  134. package/dist/br/data/mun/RO.cjs +1 -1
  135. package/dist/br/data/mun/RO.cjs.map +1 -1
  136. package/dist/br/data/mun/RO.js +1392 -1470
  137. package/dist/br/data/mun/RO.js.map +1 -1
  138. package/dist/br/data/mun/RR.cjs +1 -1
  139. package/dist/br/data/mun/RR.cjs.map +1 -1
  140. package/dist/br/data/mun/RR.js +795 -778
  141. package/dist/br/data/mun/RR.js.map +1 -1
  142. package/dist/br/data/mun/RS.cjs +1 -1
  143. package/dist/br/data/mun/RS.cjs.map +1 -1
  144. package/dist/br/data/mun/RS.js +7579 -6424
  145. package/dist/br/data/mun/RS.js.map +1 -1
  146. package/dist/br/data/mun/SC.cjs +1 -1
  147. package/dist/br/data/mun/SC.cjs.map +1 -1
  148. package/dist/br/data/mun/SC.js +3979 -3357
  149. package/dist/br/data/mun/SC.js.map +1 -1
  150. package/dist/br/data/mun/SE.cjs +1 -1
  151. package/dist/br/data/mun/SE.cjs.map +1 -1
  152. package/dist/br/data/mun/SE.js +812 -625
  153. package/dist/br/data/mun/SE.js.map +1 -1
  154. package/dist/br/data/mun/SP.cjs +1 -1
  155. package/dist/br/data/mun/SP.cjs.map +1 -1
  156. package/dist/br/data/mun/SP.js +7866 -6803
  157. package/dist/br/data/mun/SP.js.map +1 -1
  158. package/dist/br/data/mun/TO.cjs +1 -1
  159. package/dist/br/data/mun/TO.cjs.map +1 -1
  160. package/dist/br/data/mun/TO.js +2763 -2817
  161. package/dist/br/data/mun/TO.js.map +1 -1
  162. package/dist/br/locations.cjs +1 -1
  163. package/dist/br/locations.cjs.map +1 -1
  164. package/dist/br/locations.js +97 -24
  165. package/dist/br/locations.js.map +1 -1
  166. package/dist/br/scales.cjs +1 -1
  167. package/dist/br/scales.cjs.map +1 -1
  168. package/dist/br/scales.js +8 -4
  169. package/dist/br/scales.js.map +1 -1
  170. package/dist/br/whatsapp.cjs +2 -0
  171. package/dist/br/whatsapp.cjs.map +1 -0
  172. package/dist/br/whatsapp.js +21 -0
  173. package/dist/br/whatsapp.js.map +1 -0
  174. package/dist/br.cjs +1 -1
  175. package/dist/br.cjs.map +1 -1
  176. package/dist/br.d.ts +188 -10
  177. package/dist/br.js +18 -17
  178. package/dist/br.js.map +1 -1
  179. package/dist/components/BottomSheet/BottomSheet.cjs +1 -1
  180. package/dist/components/BottomSheet/BottomSheet.cjs.map +1 -1
  181. package/dist/components/BottomSheet/BottomSheet.js +30 -27
  182. package/dist/components/BottomSheet/BottomSheet.js.map +1 -1
  183. package/dist/components/Command/Command.cjs +1 -1
  184. package/dist/components/Command/Command.cjs.map +1 -1
  185. package/dist/components/Command/Command.js +78 -75
  186. package/dist/components/Command/Command.js.map +1 -1
  187. package/dist/components/Drawer/Drawer.cjs +1 -1
  188. package/dist/components/Drawer/Drawer.cjs.map +1 -1
  189. package/dist/components/Drawer/Drawer.js +42 -39
  190. package/dist/components/Drawer/Drawer.js.map +1 -1
  191. package/dist/components/DropdownMenu/DropdownMenu.cjs +1 -1
  192. package/dist/components/DropdownMenu/DropdownMenu.cjs.map +1 -1
  193. package/dist/components/DropdownMenu/DropdownMenu.js +111 -67
  194. package/dist/components/DropdownMenu/DropdownMenu.js.map +1 -1
  195. package/dist/components/Modal/Modal.cjs +1 -1
  196. package/dist/components/Modal/Modal.cjs.map +1 -1
  197. package/dist/components/Modal/Modal.js +45 -42
  198. package/dist/components/Modal/Modal.js.map +1 -1
  199. package/dist/components/Money/Money.cjs +1 -1
  200. package/dist/components/Money/Money.cjs.map +1 -1
  201. package/dist/components/Money/Money.js +10 -9
  202. package/dist/components/Money/Money.js.map +1 -1
  203. package/dist/components/Pagination/Pagination.cjs +1 -1
  204. package/dist/components/Pagination/Pagination.cjs.map +1 -1
  205. package/dist/components/Pagination/Pagination.js +38 -31
  206. package/dist/components/Pagination/Pagination.js.map +1 -1
  207. package/dist/components/Pagination/Pagination.module.cjs +1 -1
  208. package/dist/components/Pagination/Pagination.module.cjs.map +1 -1
  209. package/dist/components/Pagination/Pagination.module.js +4 -4
  210. package/dist/components/Pagination/Pagination.module.js.map +1 -1
  211. package/dist/components/Portal/Portal.cjs +1 -1
  212. package/dist/components/Portal/Portal.cjs.map +1 -1
  213. package/dist/components/Portal/Portal.js +9 -6
  214. package/dist/components/Portal/Portal.js.map +1 -1
  215. package/dist/components/Portal/portal-host.cjs +2 -0
  216. package/dist/components/Portal/portal-host.cjs.map +1 -0
  217. package/dist/components/Portal/portal-host.js +11 -0
  218. package/dist/components/Portal/portal-host.js.map +1 -0
  219. package/dist/components/RangeSlider/RangeSlider.cjs +1 -1
  220. package/dist/components/RangeSlider/RangeSlider.cjs.map +1 -1
  221. package/dist/components/RangeSlider/RangeSlider.js +23 -23
  222. package/dist/components/RangeSlider/RangeSlider.js.map +1 -1
  223. package/dist/components/Scheduler/Scheduler.cjs +1 -1
  224. package/dist/components/Scheduler/Scheduler.cjs.map +1 -1
  225. package/dist/components/Scheduler/Scheduler.js +83 -82
  226. package/dist/components/Scheduler/Scheduler.js.map +1 -1
  227. package/dist/components/Slider/Slider.cjs +1 -1
  228. package/dist/components/Slider/Slider.cjs.map +1 -1
  229. package/dist/components/Slider/Slider.js +9 -9
  230. package/dist/components/Slider/Slider.js.map +1 -1
  231. package/dist/components/Toast/ToastProvider.cjs +1 -1
  232. package/dist/components/Toast/ToastProvider.cjs.map +1 -1
  233. package/dist/components/Toast/ToastProvider.js +55 -53
  234. package/dist/components/Toast/ToastProvider.js.map +1 -1
  235. package/dist/components/VirtualList/VirtualList.cjs +1 -1
  236. package/dist/components/VirtualList/VirtualList.cjs.map +1 -1
  237. package/dist/components/VirtualList/VirtualList.js +41 -31
  238. package/dist/components/VirtualList/VirtualList.js.map +1 -1
  239. package/dist/components/VirtualTable/VirtualTable.cjs +1 -1
  240. package/dist/components/VirtualTable/VirtualTable.cjs.map +1 -1
  241. package/dist/components/VirtualTable/VirtualTable.js +78 -68
  242. package/dist/components/VirtualTable/VirtualTable.js.map +1 -1
  243. package/dist/forms/FormField.cjs +1 -1
  244. package/dist/forms/FormField.cjs.map +1 -1
  245. package/dist/forms/FormField.js +23 -21
  246. package/dist/forms/FormField.js.map +1 -1
  247. package/dist/forms/masked-inputs.cjs +1 -1
  248. package/dist/forms/masked-inputs.cjs.map +1 -1
  249. package/dist/forms/masked-inputs.js +20 -19
  250. package/dist/forms/masked-inputs.js.map +1 -1
  251. package/dist/hooks/use-fullscreen-element.cjs +2 -0
  252. package/dist/hooks/use-fullscreen-element.cjs.map +1 -0
  253. package/dist/hooks/use-fullscreen-element.js +20 -0
  254. package/dist/hooks/use-fullscreen-element.js.map +1 -0
  255. package/dist/hooks/use-fullscreen.cjs +2 -0
  256. package/dist/hooks/use-fullscreen.cjs.map +1 -0
  257. package/dist/hooks/use-fullscreen.js +66 -0
  258. package/dist/hooks/use-fullscreen.js.map +1 -0
  259. package/dist/hooks/use-push-to-talk.cjs +2 -0
  260. package/dist/hooks/use-push-to-talk.cjs.map +1 -0
  261. package/dist/hooks/use-push-to-talk.js +61 -0
  262. package/dist/hooks/use-push-to-talk.js.map +1 -0
  263. package/dist/http/describe-api-error.cjs.map +1 -1
  264. package/dist/http/describe-api-error.js.map +1 -1
  265. package/dist/http/errors.cjs +1 -1
  266. package/dist/http/errors.cjs.map +1 -1
  267. package/dist/http/errors.js +34 -16
  268. package/dist/http/errors.js.map +1 -1
  269. package/dist/http/parse-response.cjs +2 -2
  270. package/dist/http/parse-response.cjs.map +1 -1
  271. package/dist/http/parse-response.js +9 -8
  272. package/dist/http/parse-response.js.map +1 -1
  273. package/dist/i18n/create-i18n.cjs +1 -1
  274. package/dist/i18n/create-i18n.cjs.map +1 -1
  275. package/dist/i18n/create-i18n.js +28 -27
  276. package/dist/i18n/create-i18n.js.map +1 -1
  277. package/dist/query/QueryProvider.cjs +1 -1
  278. package/dist/query/QueryProvider.cjs.map +1 -1
  279. package/dist/query/QueryProvider.js +13 -11
  280. package/dist/query/QueryProvider.js.map +1 -1
  281. package/dist/query/foreign-client-warning.cjs +2 -0
  282. package/dist/query/foreign-client-warning.cjs.map +1 -0
  283. package/dist/query/foreign-client-warning.js +12 -0
  284. package/dist/query/foreign-client-warning.js.map +1 -0
  285. package/dist/router/AppRouter.cjs +1 -1
  286. package/dist/router/AppRouter.cjs.map +1 -1
  287. package/dist/router/AppRouter.js +28 -21
  288. package/dist/router/AppRouter.js.map +1 -1
  289. package/dist/router/RouteGuard.cjs +1 -1
  290. package/dist/router/RouteGuard.cjs.map +1 -1
  291. package/dist/router/RouteGuard.js +4 -4
  292. package/dist/router/RouteGuard.js.map +1 -1
  293. package/dist/sse/create-event-stream.cjs +1 -1
  294. package/dist/sse/create-event-stream.cjs.map +1 -1
  295. package/dist/sse/create-event-stream.js +34 -38
  296. package/dist/sse/create-event-stream.js.map +1 -1
  297. package/dist/styles/AIChat.css +79 -0
  298. package/dist/styles/Accordion.css +12 -0
  299. package/dist/styles/Alert.css +32 -0
  300. package/dist/styles/AppBar.css +17 -0
  301. package/dist/styles/AppShell.css +8 -0
  302. package/dist/styles/AspectRatio.css +3 -0
  303. package/dist/styles/AudioPlayer.css +13 -0
  304. package/dist/styles/AudioRecorder.css +20 -0
  305. package/dist/styles/Avatar.css +13 -0
  306. package/dist/styles/AvatarGroup.css +18 -0
  307. package/dist/styles/Badge.css +25 -0
  308. package/dist/styles/Banner.css +13 -0
  309. package/dist/styles/BarList.css +10 -0
  310. package/dist/styles/BarcodeScanner.css +21 -0
  311. package/dist/styles/BottomNavigation.css +10 -0
  312. package/dist/styles/BottomSheet.css +11 -0
  313. package/dist/styles/BrazilMap.css +20 -0
  314. package/dist/styles/Breadcrumbs.css +8 -0
  315. package/dist/styles/Button.css +42 -0
  316. package/dist/styles/Calendar.css +16 -0
  317. package/dist/styles/Card.css +15 -0
  318. package/dist/styles/Carousel.css +17 -0
  319. package/dist/styles/Center.css +5 -0
  320. package/dist/styles/Chat.css +35 -0
  321. package/dist/styles/Checkbox.css +11 -0
  322. package/dist/styles/ChipInput.css +13 -0
  323. package/dist/styles/CodeBlock.css +25 -0
  324. package/dist/styles/Collapsible.css +6 -0
  325. package/dist/styles/Combobox.css +18 -0
  326. package/dist/styles/Command.css +20 -0
  327. package/dist/styles/ContextMenu.css +11 -0
  328. package/dist/styles/CopyButton.css +4 -0
  329. package/dist/styles/DataList.css +3 -0
  330. package/dist/styles/DataTable.css +19 -0
  331. package/dist/styles/DateRangePicker.css +22 -0
  332. package/dist/styles/DescriptionList.css +4 -0
  333. package/dist/styles/Divider.css +11 -0
  334. package/dist/styles/Drawer.css +22 -0
  335. package/dist/styles/DropdownMenu.css +16 -0
  336. package/dist/styles/Dropzone.css +7 -0
  337. package/dist/styles/EmptyState.css +6 -0
  338. package/dist/styles/ErrorState.css +6 -0
  339. package/dist/styles/ErrorText.css +2 -0
  340. package/dist/styles/FileUpload.css +17 -0
  341. package/dist/styles/FilterBar.css +19 -0
  342. package/dist/styles/FloatingActionButton.css +23 -0
  343. package/dist/styles/Form.css +21 -0
  344. package/dist/styles/HoverCard.css +11 -0
  345. package/dist/styles/IconPicker.css +6 -0
  346. package/dist/styles/Image.css +2 -0
  347. package/dist/styles/ImageCropper.css +16 -0
  348. package/dist/styles/Input.css +24 -0
  349. package/dist/styles/InstallBanner.css +8 -0
  350. package/dist/styles/Kanban.css +15 -0
  351. package/dist/styles/Kbd.css +5 -0
  352. package/dist/styles/Label.css +3 -0
  353. package/dist/styles/Layout.css +22 -0
  354. package/dist/styles/Lightbox.css +21 -0
  355. package/dist/styles/ListTile.css +14 -0
  356. package/dist/styles/MapLegend.css +9 -0
  357. package/dist/styles/Markdown.css +24 -0
  358. package/dist/styles/Masonry.css +4 -0
  359. package/dist/styles/Menubar.css +17 -0
  360. package/dist/styles/Modal.css +21 -0
  361. package/dist/styles/ModalsManager.css +2 -0
  362. package/dist/styles/MultiSelect.css +21 -0
  363. package/dist/styles/MunicipalitySearch.css +6 -0
  364. package/dist/styles/NProgress.css +2 -0
  365. package/dist/styles/Navbar.css +10 -0
  366. package/dist/styles/NavigationMenu.css +12 -0
  367. package/dist/styles/NavigationRail.css +14 -0
  368. package/dist/styles/NotificationCenter.css +21 -0
  369. package/dist/styles/OfflineIndicator.css +7 -0
  370. package/dist/styles/Page.css +13 -0
  371. package/dist/styles/Pagination.css +12 -0
  372. package/dist/styles/PasswordInput.css +21 -0
  373. package/dist/styles/PinInput.css +13 -0
  374. package/dist/styles/PixQRCode.css +9 -0
  375. package/dist/styles/Popover.css +10 -0
  376. package/dist/styles/Progress.css +11 -0
  377. package/dist/styles/QRCode.css +3 -0
  378. package/dist/styles/Radio.css +14 -0
  379. package/dist/styles/RangeSlider.css +15 -0
  380. package/dist/styles/RatingStars.css +11 -0
  381. package/dist/styles/RefreshIndicator.css +5 -0
  382. package/dist/styles/Resizable.css +13 -0
  383. package/dist/styles/RichTextEditor.css +19 -0
  384. package/dist/styles/SafeArea.css +7 -0
  385. package/dist/styles/Scheduler.css +24 -0
  386. package/dist/styles/ScrollArea.css +7 -0
  387. package/dist/styles/SearchBar.css +11 -0
  388. package/dist/styles/SegmentedControl.css +12 -0
  389. package/dist/styles/Select.css +14 -0
  390. package/dist/styles/Sidebar.css +19 -0
  391. package/dist/styles/SignaturePad.css +6 -0
  392. package/dist/styles/Skeleton.css +7 -0
  393. package/dist/styles/Slider.css +15 -0
  394. package/dist/styles/Spacer.css +4 -0
  395. package/dist/styles/Sparkline.css +4 -0
  396. package/dist/styles/Spinner.css +12 -0
  397. package/dist/styles/Stat.css +12 -0
  398. package/dist/styles/Stepper.css +17 -0
  399. package/dist/styles/StepperInput.css +15 -0
  400. package/dist/styles/Switch.css +11 -0
  401. package/dist/styles/SyncStatusBadge.css +13 -0
  402. package/dist/styles/Table.css +16 -0
  403. package/dist/styles/Tabs.css +14 -0
  404. package/dist/styles/Tag.css +14 -0
  405. package/dist/styles/Textarea.css +13 -0
  406. package/dist/styles/TimePicker.css +14 -0
  407. package/dist/styles/Timeline.css +17 -0
  408. package/dist/styles/Toast.css +21 -0
  409. package/dist/styles/Toggle.css +12 -0
  410. package/dist/styles/ToggleGroup.css +9 -0
  411. package/dist/styles/Tooltip.css +10 -0
  412. package/dist/styles/Tour.css +20 -0
  413. package/dist/styles/TrajectoryMap.css +16 -0
  414. package/dist/styles/Transfer.css +21 -0
  415. package/dist/styles/TreeView.css +17 -0
  416. package/dist/styles/TruncateText.css +2 -0
  417. package/dist/styles/UpdatePrompt.css +10 -0
  418. package/dist/styles/VirtualList.css +5 -0
  419. package/dist/styles/VirtualTable.css +17 -0
  420. package/dist/styles/VisuallyHidden.css +2 -0
  421. package/dist/styles/Wizard.css +4 -0
  422. package/dist/styles/actions.css +104 -0
  423. package/dist/styles/advanced.css +66 -0
  424. package/dist/styles/br.css +41 -0
  425. package/dist/styles/chat.css +113 -0
  426. package/dist/styles/core.css +40 -0
  427. package/dist/styles/data.css +222 -0
  428. package/dist/styles/editor.css +19 -0
  429. package/dist/styles/feedback.css +201 -0
  430. package/dist/styles/forms.css +321 -0
  431. package/dist/styles/geo.css +16 -0
  432. package/dist/styles/icons.css +6 -0
  433. package/dist/styles/identity.css +48 -0
  434. package/dist/styles/layout.css +122 -0
  435. package/dist/styles/media.css +52 -0
  436. package/dist/styles/navigation.css +167 -0
  437. package/dist/styles/overlay.css +73 -0
  438. package/dist/styles/utility.css +39 -0
  439. package/dist/styles.css +1 -1
  440. package/dist/sw/register-service-worker.cjs +1 -1
  441. package/dist/sw/register-service-worker.cjs.map +1 -1
  442. package/dist/sw/register-service-worker.js +21 -17
  443. package/dist/sw/register-service-worker.js.map +1 -1
  444. package/dist/sw.d.ts +17 -1
  445. package/dist/tempest-react-sdk.cjs +1 -1
  446. package/dist/tempest-react-sdk.d.ts +1382 -76
  447. package/dist/tempest-react-sdk.js +293 -281
  448. package/dist/utils/dev-mode.cjs.map +1 -1
  449. package/dist/utils/dev-mode.js.map +1 -1
  450. package/dist/utils/duplicate-instance.cjs +2 -0
  451. package/dist/utils/duplicate-instance.cjs.map +1 -0
  452. package/dist/utils/duplicate-instance.js +6 -0
  453. package/dist/utils/duplicate-instance.js.map +1 -0
  454. package/dist/utils/format.cjs +1 -1
  455. package/dist/utils/format.cjs.map +1 -1
  456. package/dist/utils/format.js +22 -14
  457. package/dist/utils/format.js.map +1 -1
  458. package/dist/utils/intl-cache.cjs +2 -0
  459. package/dist/utils/intl-cache.cjs.map +1 -0
  460. package/dist/utils/intl-cache.js +23 -0
  461. package/dist/utils/intl-cache.js.map +1 -0
  462. package/dist/utils/json-frame.cjs +2 -0
  463. package/dist/utils/json-frame.cjs.map +1 -0
  464. package/dist/utils/json-frame.js +30 -0
  465. package/dist/utils/json-frame.js.map +1 -0
  466. package/dist/utils/numbers.cjs +1 -1
  467. package/dist/utils/numbers.cjs.map +1 -1
  468. package/dist/utils/numbers.js +8 -7
  469. package/dist/utils/numbers.js.map +1 -1
  470. package/dist/vision/results.cjs +1 -1
  471. package/dist/vision/results.cjs.map +1 -1
  472. package/dist/vision/results.js +26 -17
  473. package/dist/vision/results.js.map +1 -1
  474. package/dist/vision.d.ts +29 -0
  475. package/dist/vite/tempest-icons.cjs +1 -1
  476. package/dist/vite/tempest-icons.cjs.map +1 -1
  477. package/dist/vite/tempest-icons.js +1 -1
  478. package/dist/vite/tempest-icons.js.map +1 -1
  479. package/dist/webrtc/link-stats.cjs +2 -0
  480. package/dist/webrtc/link-stats.cjs.map +1 -0
  481. package/dist/webrtc/link-stats.js +74 -0
  482. package/dist/webrtc/link-stats.js.map +1 -0
  483. package/dist/webrtc/opus-sdp.cjs +3 -0
  484. package/dist/webrtc/opus-sdp.cjs.map +1 -0
  485. package/dist/webrtc/opus-sdp.js +94 -0
  486. package/dist/webrtc/opus-sdp.js.map +1 -0
  487. package/dist/webrtc/sender-bitrate.cjs +2 -0
  488. package/dist/webrtc/sender-bitrate.cjs.map +1 -0
  489. package/dist/webrtc/sender-bitrate.js +15 -0
  490. package/dist/webrtc/sender-bitrate.js.map +1 -0
  491. package/dist/webrtc/use-link-stats.cjs +2 -0
  492. package/dist/webrtc/use-link-stats.cjs.map +1 -0
  493. package/dist/webrtc/use-link-stats.js +22 -0
  494. package/dist/webrtc/use-link-stats.js.map +1 -0
  495. package/dist/ws/create-web-socket.cjs +1 -1
  496. package/dist/ws/create-web-socket.cjs.map +1 -1
  497. package/dist/ws/create-web-socket.js +130 -58
  498. package/dist/ws/create-web-socket.js.map +1 -1
  499. package/dist/ws/resilience.cjs +2 -0
  500. package/dist/ws/resilience.cjs.map +1 -0
  501. package/dist/ws/resilience.js +21 -0
  502. package/dist/ws/resilience.js.map +1 -0
  503. package/dist/ws/use-web-socket.cjs +1 -1
  504. package/dist/ws/use-web-socket.cjs.map +1 -1
  505. package/dist/ws/use-web-socket.js +47 -39
  506. package/dist/ws/use-web-socket.js.map +1 -1
  507. package/package.json +5 -2
@@ -1,3 +1,3 @@
1
- function e(e,t,n){let r=e.safeParse(t);if(r.success)return r.data;if(typeof process<`u`&&(process.env.NODE_ENV===`development`||process.env.NODE_ENV===`test`)){let e=r.error.issues.map(e=>` - ${e.path.join(`.`)||`<root>`}: ${e.message}`).join(`
2
- `);throw Error(`[parseResponse] Contract drift on ${n}:\n${e}\n\nRaw payload: ${JSON.stringify(t,null,2)}`)}throw Error(`Resposta inválida do servidor (${n}).`)}exports.parseResponse=e;
1
+ const e=require("../utils/dev-mode.cjs");function t(t,n,r){let i=t.safeParse(n);if(i.success)return i.data;if(e.isDevBuild()){let e=i.error.issues.map(e=>` - ${e.path.join(`.`)||`<root>`}: ${e.message}`).join(`
2
+ `);throw Error(`[parseResponse] Contract drift on ${r}:\n${e}\n\nRaw payload: ${JSON.stringify(n,null,2)}`)}throw Error(`Resposta inválida do servidor (${r}).`)}exports.parseResponse=t;
3
3
  //# sourceMappingURL=parse-response.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-response.cjs","names":[],"sources":["../../src/http/parse-response.ts"],"sourcesContent":["import type { z } from \"zod\";\n\n/**\n * Validate an unknown response payload against a zod schema.\n *\n * In development, throws a detailed error pointing at the divergent field.\n * In production, throws a generic error so internals do not leak to users.\n *\n * @param schema - The zod schema to parse against.\n * @param raw - The raw response payload.\n * @param context - A label used in error messages, e.g. \"POST /auth/login\".\n * @returns The parsed, typed payload.\n */\nexport function parseResponse<TSchema extends z.ZodTypeAny>(\n schema: TSchema,\n raw: unknown,\n context: string,\n): z.infer<TSchema> {\n const result = schema.safeParse(raw);\n if (result.success) {\n return result.data;\n }\n\n const isDev =\n typeof process !== \"undefined\" &&\n (process.env?.NODE_ENV === \"development\" || process.env?.NODE_ENV === \"test\");\n\n if (isDev) {\n const issues = result.error.issues\n .map((i) => ` - ${i.path.join(\".\") || \"<root>\"}: ${i.message}`)\n .join(\"\\n\");\n throw new Error(\n `[parseResponse] Contract drift on ${context}:\\n${issues}\\n\\nRaw payload: ${JSON.stringify(raw, null, 2)}`,\n );\n }\n throw new Error(`Resposta inválida do servidor (${context}).`);\n}\n"],"mappings":"AAaA,SAAgB,EACZ,EACA,EACA,EACgB,CAChB,IAAM,EAAS,EAAO,UAAU,CAAG,EACnC,GAAI,EAAO,QACP,OAAO,EAAO,KAOlB,GAHI,OAAO,QAAY,MAAA,QAAA,IAAA,WACQ,eAAA,QAAA,IAAA,WAA2C,QAE/D,CACP,IAAM,EAAS,EAAO,MAAM,OACvB,IAAK,GAAM,OAAO,EAAE,KAAK,KAAK,GAAG,GAAK,SAAS,IAAI,EAAE,SAAS,CAAC,CAC/D,KAAK;CAAI,EACd,MAAU,MACN,qCAAqC,EAAQ,KAAK,EAAO,mBAAmB,KAAK,UAAU,EAAK,KAAM,CAAC,GAC3G,CACJ,CACA,MAAU,MAAM,kCAAkC,EAAQ,GAAG,CACjE"}
1
+ {"version":3,"file":"parse-response.cjs","names":[],"sources":["../../src/http/parse-response.ts"],"sourcesContent":["import type { z } from \"zod\";\n\nimport { isDevBuild } from \"../utils/dev-mode\";\n\n/**\n * Validate an unknown response payload against a zod schema.\n *\n * A development build throws a detailed error naming every divergent field path\n * and embedding the raw payload; every other build throws a generic sentence, so\n * server internals never reach a user's screen or an error tracker.\n *\n * Which one you get comes from `isDevBuild()`, the SDK's single answer to that\n * question, rather than from a check written here. This function used to ask\n * `typeof process !== \"undefined\" && process.env?.NODE_ENV === \"development\"`,\n * and a browser has no `process` identifier at all — so the guard short-circuited\n * and the detailed branch was dead in exactly the build it was written for, no\n * matter what the bundler substituted behind it.\n *\n * The rule `isDevBuild()` applies is `NODE_ENV !== \"production\"`, which is wider\n * than the old `\"development\" || \"test\"`: a staging build that never sets\n * `NODE_ENV=production` gets the drift report, raw payload included.\n *\n * @param schema - The zod schema to parse against.\n * @param raw - The raw response payload.\n * @param context - A label used in error messages, e.g. \"POST /auth/login\".\n * @returns The parsed, typed payload.\n * @throws Error When the payload does not match the schema: `[parseResponse]\n * Contract drift on <context>` with the field paths and the raw payload in a\n * development build, `Resposta inválida do servidor (<context>).` otherwise.\n */\nexport function parseResponse<TSchema extends z.ZodTypeAny>(\n schema: TSchema,\n raw: unknown,\n context: string,\n): z.infer<TSchema> {\n const result = schema.safeParse(raw);\n if (result.success) {\n return result.data;\n }\n\n if (isDevBuild()) {\n const issues = result.error.issues\n .map((i) => ` - ${i.path.join(\".\") || \"<root>\"}: ${i.message}`)\n .join(\"\\n\");\n throw new Error(\n `[parseResponse] Contract drift on ${context}:\\n${issues}\\n\\nRaw payload: ${JSON.stringify(raw, null, 2)}`,\n );\n }\n throw new Error(`Resposta inválida do servidor (${context}).`);\n}\n"],"mappings":"yCA8BA,SAAgB,EACZ,EACA,EACA,EACgB,CAChB,IAAM,EAAS,EAAO,UAAU,CAAG,EACnC,GAAI,EAAO,QACP,OAAO,EAAO,KAGlB,GAAI,EAAA,WAAW,EAAG,CACd,IAAM,EAAS,EAAO,MAAM,OACvB,IAAK,GAAM,OAAO,EAAE,KAAK,KAAK,GAAG,GAAK,SAAS,IAAI,EAAE,SAAS,CAAC,CAC/D,KAAK;CAAI,EACd,MAAU,MACN,qCAAqC,EAAQ,KAAK,EAAO,mBAAmB,KAAK,UAAU,EAAK,KAAM,CAAC,GAC3G,CACJ,CACA,MAAU,MAAM,kCAAkC,EAAQ,GAAG,CACjE"}
@@ -1,14 +1,15 @@
1
+ import { isDevBuild as e } from "../utils/dev-mode.js";
1
2
  //#region src/http/parse-response.ts
2
- function e(e, t, n) {
3
- let r = e.safeParse(t);
4
- if (r.success) return r.data;
5
- if (typeof process < "u" && (process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test")) {
6
- let e = r.error.issues.map((e) => ` - ${e.path.join(".") || "<root>"}: ${e.message}`).join("\n");
7
- throw Error(`[parseResponse] Contract drift on ${n}:\n${e}\n\nRaw payload: ${JSON.stringify(t, null, 2)}`);
3
+ function t(t, n, r) {
4
+ let i = t.safeParse(n);
5
+ if (i.success) return i.data;
6
+ if (e()) {
7
+ let e = i.error.issues.map((e) => ` - ${e.path.join(".") || "<root>"}: ${e.message}`).join("\n");
8
+ throw Error(`[parseResponse] Contract drift on ${r}:\n${e}\n\nRaw payload: ${JSON.stringify(n, null, 2)}`);
8
9
  }
9
- throw Error(`Resposta inválida do servidor (${n}).`);
10
+ throw Error(`Resposta inválida do servidor (${r}).`);
10
11
  }
11
12
  //#endregion
12
- export { e as parseResponse };
13
+ export { t as parseResponse };
13
14
 
14
15
  //# sourceMappingURL=parse-response.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-response.js","names":[],"sources":["../../src/http/parse-response.ts"],"sourcesContent":["import type { z } from \"zod\";\n\n/**\n * Validate an unknown response payload against a zod schema.\n *\n * In development, throws a detailed error pointing at the divergent field.\n * In production, throws a generic error so internals do not leak to users.\n *\n * @param schema - The zod schema to parse against.\n * @param raw - The raw response payload.\n * @param context - A label used in error messages, e.g. \"POST /auth/login\".\n * @returns The parsed, typed payload.\n */\nexport function parseResponse<TSchema extends z.ZodTypeAny>(\n schema: TSchema,\n raw: unknown,\n context: string,\n): z.infer<TSchema> {\n const result = schema.safeParse(raw);\n if (result.success) {\n return result.data;\n }\n\n const isDev =\n typeof process !== \"undefined\" &&\n (process.env?.NODE_ENV === \"development\" || process.env?.NODE_ENV === \"test\");\n\n if (isDev) {\n const issues = result.error.issues\n .map((i) => ` - ${i.path.join(\".\") || \"<root>\"}: ${i.message}`)\n .join(\"\\n\");\n throw new Error(\n `[parseResponse] Contract drift on ${context}:\\n${issues}\\n\\nRaw payload: ${JSON.stringify(raw, null, 2)}`,\n );\n }\n throw new Error(`Resposta inválida do servidor (${context}).`);\n}\n"],"mappings":";AAaA,SAAgB,EACZ,GACA,GACA,GACgB;CAChB,IAAM,IAAS,EAAO,UAAU,CAAG;CACnC,IAAI,EAAO,SACP,OAAO,EAAO;CAOlB,IAHI,OAAO,UAAY,QAAA,QAAA,IAAA,aACQ,iBAAA,QAAA,IAAA,aAA2C,SAE/D;EACP,IAAM,IAAS,EAAO,MAAM,OACvB,KAAK,MAAM,OAAO,EAAE,KAAK,KAAK,GAAG,KAAK,SAAS,IAAI,EAAE,SAAS,CAAC,CAC/D,KAAK,IAAI;EACd,MAAU,MACN,qCAAqC,EAAQ,KAAK,EAAO,mBAAmB,KAAK,UAAU,GAAK,MAAM,CAAC,GAC3G;CACJ;CACA,MAAU,MAAM,kCAAkC,EAAQ,GAAG;AACjE"}
1
+ {"version":3,"file":"parse-response.js","names":[],"sources":["../../src/http/parse-response.ts"],"sourcesContent":["import type { z } from \"zod\";\n\nimport { isDevBuild } from \"../utils/dev-mode\";\n\n/**\n * Validate an unknown response payload against a zod schema.\n *\n * A development build throws a detailed error naming every divergent field path\n * and embedding the raw payload; every other build throws a generic sentence, so\n * server internals never reach a user's screen or an error tracker.\n *\n * Which one you get comes from `isDevBuild()`, the SDK's single answer to that\n * question, rather than from a check written here. This function used to ask\n * `typeof process !== \"undefined\" && process.env?.NODE_ENV === \"development\"`,\n * and a browser has no `process` identifier at all — so the guard short-circuited\n * and the detailed branch was dead in exactly the build it was written for, no\n * matter what the bundler substituted behind it.\n *\n * The rule `isDevBuild()` applies is `NODE_ENV !== \"production\"`, which is wider\n * than the old `\"development\" || \"test\"`: a staging build that never sets\n * `NODE_ENV=production` gets the drift report, raw payload included.\n *\n * @param schema - The zod schema to parse against.\n * @param raw - The raw response payload.\n * @param context - A label used in error messages, e.g. \"POST /auth/login\".\n * @returns The parsed, typed payload.\n * @throws Error When the payload does not match the schema: `[parseResponse]\n * Contract drift on <context>` with the field paths and the raw payload in a\n * development build, `Resposta inválida do servidor (<context>).` otherwise.\n */\nexport function parseResponse<TSchema extends z.ZodTypeAny>(\n schema: TSchema,\n raw: unknown,\n context: string,\n): z.infer<TSchema> {\n const result = schema.safeParse(raw);\n if (result.success) {\n return result.data;\n }\n\n if (isDevBuild()) {\n const issues = result.error.issues\n .map((i) => ` - ${i.path.join(\".\") || \"<root>\"}: ${i.message}`)\n .join(\"\\n\");\n throw new Error(\n `[parseResponse] Contract drift on ${context}:\\n${issues}\\n\\nRaw payload: ${JSON.stringify(raw, null, 2)}`,\n );\n }\n throw new Error(`Resposta inválida do servidor (${context}).`);\n}\n"],"mappings":";;AA8BA,SAAgB,EACZ,GACA,GACA,GACgB;CAChB,IAAM,IAAS,EAAO,UAAU,CAAG;CACnC,IAAI,EAAO,SACP,OAAO,EAAO;CAGlB,IAAI,EAAW,GAAG;EACd,IAAM,IAAS,EAAO,MAAM,OACvB,KAAK,MAAM,OAAO,EAAE,KAAK,KAAK,GAAG,KAAK,SAAS,IAAI,EAAE,SAAS,CAAC,CAC/D,KAAK,IAAI;EACd,MAAU,MACN,qCAAqC,EAAQ,KAAK,EAAO,mBAAmB,KAAK,UAAU,GAAK,MAAM,CAAC,GAC3G;CACJ;CACA,MAAU,MAAM,kCAAkC,EAAQ,GAAG;AACjE"}
@@ -1,2 +1,2 @@
1
- function e(e,t){return t?e.replace(/\{(\w+)\}/g,(e,n)=>{let r=t[n];return r===void 0?`{${n}}`:String(r)}):e}function t(e,t,n,r){let i=e[t]?.[r];if(i!==void 0)return i;if(n){let t=e[n]?.[r];if(t!==void 0)return t}return null}function n(r){let{locale:i,fallbackLocale:a=null,messages:o}=r;function s(n,r,s){let c=t(o,i,a,n)??s?.default;return c===void 0?n:e(c,r)}function c(n,r,s,c){let l=t(o,i,a,`${n}${r===1?`_one`:`_other`}`)??t(o,i,a,n)??c?.default;return l===void 0?n:e(l,{count:r,...s??{}})}function l(e,t){return new Intl.NumberFormat(i,t).format(e)}function u(e,t){let n=typeof e==`string`?new Date(e):e;return Number.isNaN(n.getTime())?``:new Intl.DateTimeFormat(i,t).format(n)}return{locale:i,fallbackLocale:a,t:s,plural:c,formatNumber:l,formatDate:u,withLocale:e=>n({locale:e,fallbackLocale:a??void 0,messages:o})}}exports.createI18n=n;
1
+ const e=require("../utils/intl-cache.cjs");function t(e,t){return t?e.replace(/\{(\w+)\}/g,(e,n)=>{let r=t[n];return r===void 0?`{${n}}`:String(r)}):e}function n(e,t,n,r){let i=e[t]?.[r];if(i!==void 0)return i;if(n){let t=e[n]?.[r];if(t!==void 0)return t}return null}function r(i){let{locale:a,fallbackLocale:o=null,messages:s}=i;function c(e,r,i){let c=n(s,a,o,e)??i?.default;return c===void 0?e:t(c,r)}function l(e,r,i,c){let l=n(s,a,o,`${e}${r===1?`_one`:`_other`}`)??n(s,a,o,e)??c?.default;return l===void 0?e:t(l,{count:r,...i??{}})}function u(t,n){return e.numberFormat(a,n).format(t)}function d(t,n){let r=typeof t==`string`?new Date(t):t;return Number.isNaN(r.getTime())?``:e.dateTimeFormat(a,n).format(r)}return{locale:a,fallbackLocale:o,t:c,plural:l,formatNumber:u,formatDate:d,withLocale:e=>r({locale:e,fallbackLocale:o??void 0,messages:s})}}exports.createI18n=r;
2
2
  //# sourceMappingURL=create-i18n.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-i18n.cjs","names":[],"sources":["../../src/i18n/create-i18n.ts"],"sourcesContent":["export type Messages = Record<string, string>;\nexport type Catalog = Record<string, Messages>;\nexport type InterpolationValues = Record<string, string | number>;\n\nexport interface CreateI18nOptions {\n /** Initial locale. */\n locale: string;\n /** Fallback locale used when a key is missing in the active locale. */\n fallbackLocale?: string;\n /** Catalog `{ [locale]: { [key]: \"...\" } }`. */\n messages: Catalog;\n}\n\n/** Per-call options for {@link I18n.t} and {@link I18n.plural}. */\nexport interface TranslateOptions {\n /**\n * Text to use when the catalog defines neither the key nor its fallback.\n *\n * Without this, a miss returns the key, and a caller that wants its own text\n * instead has to *detect* the miss — which from the outside means comparing\n * the result against the key it just passed in. That heuristic is wrong for a\n * catalog that legitimately maps a key to itself, and it is what every\n * translatable string the SDK ships would otherwise have to copy.\n *\n * Interpolated like any other message, so a default carries `{placeholders}`\n * too and is not second-class.\n */\n default?: string;\n}\n\nexport interface I18n {\n /** Currently active locale. */\n locale: string;\n /** Fallback locale (or `null` when not configured). */\n fallbackLocale: string | null;\n /**\n * Translate `key`, interpolating `{name}` placeholders from `params`.\n * Falls back to the configured fallback locale, then to `options.default`,\n * then to the key itself.\n */\n t: (key: string, params?: InterpolationValues, options?: TranslateOptions) => string;\n /**\n * Plural-aware translation. Tries `${key}_one` for `count === 1` and\n * `${key}_other` otherwise, with `{count}` available for interpolation.\n * Falls back to `options.default`, then to the key itself.\n */\n plural: (\n key: string,\n count: number,\n params?: InterpolationValues,\n options?: TranslateOptions,\n ) => string;\n /** Format a number using `Intl.NumberFormat` on the active locale. */\n formatNumber: (value: number, options?: Intl.NumberFormatOptions) => string;\n /** Format a Date using `Intl.DateTimeFormat` on the active locale. */\n formatDate: (value: Date | string, options?: Intl.DateTimeFormatOptions) => string;\n /** Build a new `I18n` instance pointing at a different locale. */\n withLocale: (locale: string) => I18n;\n}\n\nfunction interpolate(template: string, params?: InterpolationValues): string {\n if (!params) return template;\n return template.replace(/\\{(\\w+)\\}/g, (_match, name: string) => {\n const value = params[name];\n return value === undefined ? `{${name}}` : String(value);\n });\n}\n\nfunction lookup(\n catalog: Catalog,\n locale: string,\n fallback: string | null,\n key: string,\n): string | null {\n const direct = catalog[locale]?.[key];\n if (direct !== undefined) return direct;\n if (fallback) {\n const fallbackValue = catalog[fallback]?.[key];\n if (fallbackValue !== undefined) return fallbackValue;\n }\n return null;\n}\n\n/**\n * Create an i18n object with translation, pluralization and Intl helpers.\n *\n * The catalog is a plain `{ [locale]: { [key]: \"...\" } }` map — bring your\n * own keys, namespaces, or nested-key conventions. The SDK does not enforce\n * a schema so you can plug it into any string-loading pipeline.\n *\n * @example\n * const i18n = createI18n({\n * locale: \"pt-BR\",\n * fallbackLocale: \"en\",\n * messages: {\n * \"pt-BR\": {\n * \"greet\": \"Olá, {name}\",\n * \"alos_one\": \"{count} Alô\",\n * \"alos_other\": \"{count} Alôs\",\n * },\n * \"en\": { greet: \"Hi, {name}\", alos_one: \"{count} Alo\", alos_other: \"{count} Alos\" },\n * },\n * });\n * i18n.t(\"greet\", { name: \"Mau\" }); // \"Olá, Mau\"\n * i18n.plural(\"alos\", 3); // \"3 Alôs\"\n *\n * @example\n * // A key the catalog does not define, with text to show instead of the key.\n * i18n.t(\"cart.empty\", undefined, { default: \"Seu carrinho está vazio\" });\n */\nexport function createI18n(options: CreateI18nOptions): I18n {\n const { locale, fallbackLocale = null, messages } = options;\n\n function t(key: string, params?: InterpolationValues, options?: TranslateOptions): string {\n const template = lookup(messages, locale, fallbackLocale, key) ?? options?.default;\n if (template === undefined) return key;\n return interpolate(template, params);\n }\n\n function plural(\n key: string,\n count: number,\n params?: InterpolationValues,\n options?: TranslateOptions,\n ): string {\n const suffix = count === 1 ? \"_one\" : \"_other\";\n const template =\n lookup(messages, locale, fallbackLocale, `${key}${suffix}`) ??\n lookup(messages, locale, fallbackLocale, key) ??\n options?.default;\n if (template === undefined) return key;\n return interpolate(template, { count, ...(params ?? {}) });\n }\n\n function formatNumber(value: number, opts?: Intl.NumberFormatOptions): string {\n return new Intl.NumberFormat(locale, opts).format(value);\n }\n\n function formatDate(value: Date | string, opts?: Intl.DateTimeFormatOptions): string {\n const date = typeof value === \"string\" ? new Date(value) : value;\n if (Number.isNaN(date.getTime())) return \"\";\n return new Intl.DateTimeFormat(locale, opts).format(date);\n }\n\n return {\n locale,\n fallbackLocale,\n t,\n plural,\n formatNumber,\n formatDate,\n withLocale: (nextLocale) =>\n createI18n({\n locale: nextLocale,\n fallbackLocale: fallbackLocale ?? undefined,\n messages,\n }),\n };\n}\n"],"mappings":"AA4DA,SAAS,EAAY,EAAkB,EAAsC,CAEzE,OADK,EACE,EAAS,QAAQ,cAAe,EAAQ,IAAiB,CAC5D,IAAM,EAAQ,EAAO,GACrB,OAAO,IAAU,IAAA,GAAY,IAAI,EAAK,GAAK,OAAO,CAAK,CAC3D,CAAC,EAJmB,CAKxB,CAEA,SAAS,EACL,EACA,EACA,EACA,EACa,CACb,IAAM,EAAS,EAAQ,EAAO,GAAG,GACjC,GAAI,IAAW,IAAA,GAAW,OAAO,EACjC,GAAI,EAAU,CACV,IAAM,EAAgB,EAAQ,EAAS,GAAG,GAC1C,GAAI,IAAkB,IAAA,GAAW,OAAO,CAC5C,CACA,OAAO,IACX,CA6BA,SAAgB,EAAW,EAAkC,CACzD,GAAM,CAAE,SAAQ,iBAAiB,KAAM,YAAa,EAEpD,SAAS,EAAE,EAAa,EAA8B,EAAoC,CACtF,IAAM,EAAW,EAAO,EAAU,EAAQ,EAAgB,CAAG,GAAK,GAAS,QAE3E,OADI,IAAa,IAAA,GAAkB,EAC5B,EAAY,EAAU,CAAM,CACvC,CAEA,SAAS,EACL,EACA,EACA,EACA,EACM,CAEN,IAAM,EACF,EAAO,EAAU,EAAQ,EAAgB,GAAG,IAFjC,IAAU,EAAI,OAAS,UAEwB,GAC1D,EAAO,EAAU,EAAQ,EAAgB,CAAG,GAC5C,GAAS,QAEb,OADI,IAAa,IAAA,GAAkB,EAC5B,EAAY,EAAU,CAAE,QAAO,GAAI,GAAU,CAAC,CAAG,CAAC,CAC7D,CAEA,SAAS,EAAa,EAAe,EAAyC,CAC1E,OAAO,IAAI,KAAK,aAAa,EAAQ,CAAI,CAAC,CAAC,OAAO,CAAK,CAC3D,CAEA,SAAS,EAAW,EAAsB,EAA2C,CACjF,IAAM,EAAO,OAAO,GAAU,SAAW,IAAI,KAAK,CAAK,EAAI,EAE3D,OADI,OAAO,MAAM,EAAK,QAAQ,CAAC,EAAU,GAClC,IAAI,KAAK,eAAe,EAAQ,CAAI,CAAC,CAAC,OAAO,CAAI,CAC5D,CAEA,MAAO,CACH,SACA,iBACA,IACA,SACA,eACA,aACA,WAAa,GACT,EAAW,CACP,OAAQ,EACR,eAAgB,GAAkB,IAAA,GAClC,UACJ,CAAC,CACT,CACJ"}
1
+ {"version":3,"file":"create-i18n.cjs","names":[],"sources":["../../src/i18n/create-i18n.ts"],"sourcesContent":["import { dateTimeFormat, numberFormat } from \"@/utils/intl-cache\";\nexport type Messages = Record<string, string>;\nexport type Catalog = Record<string, Messages>;\nexport type InterpolationValues = Record<string, string | number>;\n\nexport interface CreateI18nOptions {\n /** Initial locale. */\n locale: string;\n /** Fallback locale used when a key is missing in the active locale. */\n fallbackLocale?: string;\n /** Catalog `{ [locale]: { [key]: \"...\" } }`. */\n messages: Catalog;\n}\n\n/** Per-call options for {@link I18n.t} and {@link I18n.plural}. */\nexport interface TranslateOptions {\n /**\n * Text to use when the catalog defines neither the key nor its fallback.\n *\n * Without this, a miss returns the key, and a caller that wants its own text\n * instead has to *detect* the miss — which from the outside means comparing\n * the result against the key it just passed in. That heuristic is wrong for a\n * catalog that legitimately maps a key to itself, and it is what every\n * translatable string the SDK ships would otherwise have to copy.\n *\n * Interpolated like any other message, so a default carries `{placeholders}`\n * too and is not second-class.\n */\n default?: string;\n}\n\nexport interface I18n {\n /** Currently active locale. */\n locale: string;\n /** Fallback locale (or `null` when not configured). */\n fallbackLocale: string | null;\n /**\n * Translate `key`, interpolating `{name}` placeholders from `params`.\n * Falls back to the configured fallback locale, then to `options.default`,\n * then to the key itself.\n */\n t: (key: string, params?: InterpolationValues, options?: TranslateOptions) => string;\n /**\n * Plural-aware translation. Tries `${key}_one` for `count === 1` and\n * `${key}_other` otherwise, with `{count}` available for interpolation.\n * Falls back to `options.default`, then to the key itself.\n */\n plural: (\n key: string,\n count: number,\n params?: InterpolationValues,\n options?: TranslateOptions,\n ) => string;\n /** Format a number using `Intl.NumberFormat` on the active locale. */\n formatNumber: (value: number, options?: Intl.NumberFormatOptions) => string;\n /** Format a Date using `Intl.DateTimeFormat` on the active locale. */\n formatDate: (value: Date | string, options?: Intl.DateTimeFormatOptions) => string;\n /** Build a new `I18n` instance pointing at a different locale. */\n withLocale: (locale: string) => I18n;\n}\n\nfunction interpolate(template: string, params?: InterpolationValues): string {\n if (!params) return template;\n return template.replace(/\\{(\\w+)\\}/g, (_match, name: string) => {\n const value = params[name];\n return value === undefined ? `{${name}}` : String(value);\n });\n}\n\nfunction lookup(\n catalog: Catalog,\n locale: string,\n fallback: string | null,\n key: string,\n): string | null {\n const direct = catalog[locale]?.[key];\n if (direct !== undefined) return direct;\n if (fallback) {\n const fallbackValue = catalog[fallback]?.[key];\n if (fallbackValue !== undefined) return fallbackValue;\n }\n return null;\n}\n\n/**\n * Create an i18n object with translation, pluralization and Intl helpers.\n *\n * The catalog is a plain `{ [locale]: { [key]: \"...\" } }` map — bring your\n * own keys, namespaces, or nested-key conventions. The SDK does not enforce\n * a schema so you can plug it into any string-loading pipeline.\n *\n * @example\n * const i18n = createI18n({\n * locale: \"pt-BR\",\n * fallbackLocale: \"en\",\n * messages: {\n * \"pt-BR\": {\n * \"greet\": \"Olá, {name}\",\n * \"alos_one\": \"{count} Alô\",\n * \"alos_other\": \"{count} Alôs\",\n * },\n * \"en\": { greet: \"Hi, {name}\", alos_one: \"{count} Alo\", alos_other: \"{count} Alos\" },\n * },\n * });\n * i18n.t(\"greet\", { name: \"Mau\" }); // \"Olá, Mau\"\n * i18n.plural(\"alos\", 3); // \"3 Alôs\"\n *\n * @example\n * // A key the catalog does not define, with text to show instead of the key.\n * i18n.t(\"cart.empty\", undefined, { default: \"Seu carrinho está vazio\" });\n */\nexport function createI18n(options: CreateI18nOptions): I18n {\n const { locale, fallbackLocale = null, messages } = options;\n\n function t(key: string, params?: InterpolationValues, options?: TranslateOptions): string {\n const template = lookup(messages, locale, fallbackLocale, key) ?? options?.default;\n if (template === undefined) return key;\n return interpolate(template, params);\n }\n\n function plural(\n key: string,\n count: number,\n params?: InterpolationValues,\n options?: TranslateOptions,\n ): string {\n const suffix = count === 1 ? \"_one\" : \"_other\";\n const template =\n lookup(messages, locale, fallbackLocale, `${key}${suffix}`) ??\n lookup(messages, locale, fallbackLocale, key) ??\n options?.default;\n if (template === undefined) return key;\n return interpolate(template, { count, ...(params ?? {}) });\n }\n\n function formatNumber(value: number, opts?: Intl.NumberFormatOptions): string {\n return numberFormat(locale, opts).format(value);\n }\n\n function formatDate(value: Date | string, opts?: Intl.DateTimeFormatOptions): string {\n const date = typeof value === \"string\" ? new Date(value) : value;\n if (Number.isNaN(date.getTime())) return \"\";\n return dateTimeFormat(locale, opts).format(date);\n }\n\n return {\n locale,\n fallbackLocale,\n t,\n plural,\n formatNumber,\n formatDate,\n withLocale: (nextLocale) =>\n createI18n({\n locale: nextLocale,\n fallbackLocale: fallbackLocale ?? undefined,\n messages,\n }),\n };\n}\n"],"mappings":"2CA6DA,SAAS,EAAY,EAAkB,EAAsC,CAEzE,OADK,EACE,EAAS,QAAQ,cAAe,EAAQ,IAAiB,CAC5D,IAAM,EAAQ,EAAO,GACrB,OAAO,IAAU,IAAA,GAAY,IAAI,EAAK,GAAK,OAAO,CAAK,CAC3D,CAAC,EAJmB,CAKxB,CAEA,SAAS,EACL,EACA,EACA,EACA,EACa,CACb,IAAM,EAAS,EAAQ,EAAO,GAAG,GACjC,GAAI,IAAW,IAAA,GAAW,OAAO,EACjC,GAAI,EAAU,CACV,IAAM,EAAgB,EAAQ,EAAS,GAAG,GAC1C,GAAI,IAAkB,IAAA,GAAW,OAAO,CAC5C,CACA,OAAO,IACX,CA6BA,SAAgB,EAAW,EAAkC,CACzD,GAAM,CAAE,SAAQ,iBAAiB,KAAM,YAAa,EAEpD,SAAS,EAAE,EAAa,EAA8B,EAAoC,CACtF,IAAM,EAAW,EAAO,EAAU,EAAQ,EAAgB,CAAG,GAAK,GAAS,QAE3E,OADI,IAAa,IAAA,GAAkB,EAC5B,EAAY,EAAU,CAAM,CACvC,CAEA,SAAS,EACL,EACA,EACA,EACA,EACM,CAEN,IAAM,EACF,EAAO,EAAU,EAAQ,EAAgB,GAAG,IAFjC,IAAU,EAAI,OAAS,UAEwB,GAC1D,EAAO,EAAU,EAAQ,EAAgB,CAAG,GAC5C,GAAS,QAEb,OADI,IAAa,IAAA,GAAkB,EAC5B,EAAY,EAAU,CAAE,QAAO,GAAI,GAAU,CAAC,CAAG,CAAC,CAC7D,CAEA,SAAS,EAAa,EAAe,EAAyC,CAC1E,OAAO,EAAA,aAAa,EAAQ,CAAI,CAAC,CAAC,OAAO,CAAK,CAClD,CAEA,SAAS,EAAW,EAAsB,EAA2C,CACjF,IAAM,EAAO,OAAO,GAAU,SAAW,IAAI,KAAK,CAAK,EAAI,EAE3D,OADI,OAAO,MAAM,EAAK,QAAQ,CAAC,EAAU,GAClC,EAAA,eAAe,EAAQ,CAAI,CAAC,CAAC,OAAO,CAAI,CACnD,CAEA,MAAO,CACH,SACA,iBACA,IACA,SACA,eACA,aACA,WAAa,GACT,EAAW,CACP,OAAQ,EACR,eAAgB,GAAkB,IAAA,GAClC,UACJ,CAAC,CACT,CACJ"}
@@ -1,11 +1,12 @@
1
+ import { dateTimeFormat as e, numberFormat as t } from "../utils/intl-cache.js";
1
2
  //#region src/i18n/create-i18n.ts
2
- function e(e, t) {
3
+ function n(e, t) {
3
4
  return t ? e.replace(/\{(\w+)\}/g, (e, n) => {
4
5
  let r = t[n];
5
6
  return r === void 0 ? `{${n}}` : String(r);
6
7
  }) : e;
7
8
  }
8
- function t(e, t, n, r) {
9
+ function r(e, t, n, r) {
9
10
  let i = e[t]?.[r];
10
11
  if (i !== void 0) return i;
11
12
  if (n) {
@@ -14,41 +15,41 @@ function t(e, t, n, r) {
14
15
  }
15
16
  return null;
16
17
  }
17
- function n(r) {
18
- let { locale: i, fallbackLocale: a = null, messages: o } = r;
19
- function s(n, r, s) {
20
- let c = t(o, i, a, n) ?? s?.default;
21
- return c === void 0 ? n : e(c, r);
18
+ function i(a) {
19
+ let { locale: o, fallbackLocale: s = null, messages: c } = a;
20
+ function l(e, t, i) {
21
+ let a = r(c, o, s, e) ?? i?.default;
22
+ return a === void 0 ? e : n(a, t);
22
23
  }
23
- function c(n, r, s, c) {
24
- let l = t(o, i, a, `${n}${r === 1 ? "_one" : "_other"}`) ?? t(o, i, a, n) ?? c?.default;
25
- return l === void 0 ? n : e(l, {
26
- count: r,
27
- ...s ?? {}
24
+ function u(e, t, i, a) {
25
+ let l = r(c, o, s, `${e}${t === 1 ? "_one" : "_other"}`) ?? r(c, o, s, e) ?? a?.default;
26
+ return l === void 0 ? e : n(l, {
27
+ count: t,
28
+ ...i ?? {}
28
29
  });
29
30
  }
30
- function l(e, t) {
31
- return new Intl.NumberFormat(i, t).format(e);
31
+ function d(e, n) {
32
+ return t(o, n).format(e);
32
33
  }
33
- function u(e, t) {
34
- let n = typeof e == "string" ? new Date(e) : e;
35
- return Number.isNaN(n.getTime()) ? "" : new Intl.DateTimeFormat(i, t).format(n);
34
+ function f(t, n) {
35
+ let r = typeof t == "string" ? new Date(t) : t;
36
+ return Number.isNaN(r.getTime()) ? "" : e(o, n).format(r);
36
37
  }
37
38
  return {
38
- locale: i,
39
- fallbackLocale: a,
40
- t: s,
41
- plural: c,
42
- formatNumber: l,
43
- formatDate: u,
44
- withLocale: (e) => n({
39
+ locale: o,
40
+ fallbackLocale: s,
41
+ t: l,
42
+ plural: u,
43
+ formatNumber: d,
44
+ formatDate: f,
45
+ withLocale: (e) => i({
45
46
  locale: e,
46
- fallbackLocale: a ?? void 0,
47
- messages: o
47
+ fallbackLocale: s ?? void 0,
48
+ messages: c
48
49
  })
49
50
  };
50
51
  }
51
52
  //#endregion
52
- export { n as createI18n };
53
+ export { i as createI18n };
53
54
 
54
55
  //# sourceMappingURL=create-i18n.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-i18n.js","names":[],"sources":["../../src/i18n/create-i18n.ts"],"sourcesContent":["export type Messages = Record<string, string>;\nexport type Catalog = Record<string, Messages>;\nexport type InterpolationValues = Record<string, string | number>;\n\nexport interface CreateI18nOptions {\n /** Initial locale. */\n locale: string;\n /** Fallback locale used when a key is missing in the active locale. */\n fallbackLocale?: string;\n /** Catalog `{ [locale]: { [key]: \"...\" } }`. */\n messages: Catalog;\n}\n\n/** Per-call options for {@link I18n.t} and {@link I18n.plural}. */\nexport interface TranslateOptions {\n /**\n * Text to use when the catalog defines neither the key nor its fallback.\n *\n * Without this, a miss returns the key, and a caller that wants its own text\n * instead has to *detect* the miss — which from the outside means comparing\n * the result against the key it just passed in. That heuristic is wrong for a\n * catalog that legitimately maps a key to itself, and it is what every\n * translatable string the SDK ships would otherwise have to copy.\n *\n * Interpolated like any other message, so a default carries `{placeholders}`\n * too and is not second-class.\n */\n default?: string;\n}\n\nexport interface I18n {\n /** Currently active locale. */\n locale: string;\n /** Fallback locale (or `null` when not configured). */\n fallbackLocale: string | null;\n /**\n * Translate `key`, interpolating `{name}` placeholders from `params`.\n * Falls back to the configured fallback locale, then to `options.default`,\n * then to the key itself.\n */\n t: (key: string, params?: InterpolationValues, options?: TranslateOptions) => string;\n /**\n * Plural-aware translation. Tries `${key}_one` for `count === 1` and\n * `${key}_other` otherwise, with `{count}` available for interpolation.\n * Falls back to `options.default`, then to the key itself.\n */\n plural: (\n key: string,\n count: number,\n params?: InterpolationValues,\n options?: TranslateOptions,\n ) => string;\n /** Format a number using `Intl.NumberFormat` on the active locale. */\n formatNumber: (value: number, options?: Intl.NumberFormatOptions) => string;\n /** Format a Date using `Intl.DateTimeFormat` on the active locale. */\n formatDate: (value: Date | string, options?: Intl.DateTimeFormatOptions) => string;\n /** Build a new `I18n` instance pointing at a different locale. */\n withLocale: (locale: string) => I18n;\n}\n\nfunction interpolate(template: string, params?: InterpolationValues): string {\n if (!params) return template;\n return template.replace(/\\{(\\w+)\\}/g, (_match, name: string) => {\n const value = params[name];\n return value === undefined ? `{${name}}` : String(value);\n });\n}\n\nfunction lookup(\n catalog: Catalog,\n locale: string,\n fallback: string | null,\n key: string,\n): string | null {\n const direct = catalog[locale]?.[key];\n if (direct !== undefined) return direct;\n if (fallback) {\n const fallbackValue = catalog[fallback]?.[key];\n if (fallbackValue !== undefined) return fallbackValue;\n }\n return null;\n}\n\n/**\n * Create an i18n object with translation, pluralization and Intl helpers.\n *\n * The catalog is a plain `{ [locale]: { [key]: \"...\" } }` map — bring your\n * own keys, namespaces, or nested-key conventions. The SDK does not enforce\n * a schema so you can plug it into any string-loading pipeline.\n *\n * @example\n * const i18n = createI18n({\n * locale: \"pt-BR\",\n * fallbackLocale: \"en\",\n * messages: {\n * \"pt-BR\": {\n * \"greet\": \"Olá, {name}\",\n * \"alos_one\": \"{count} Alô\",\n * \"alos_other\": \"{count} Alôs\",\n * },\n * \"en\": { greet: \"Hi, {name}\", alos_one: \"{count} Alo\", alos_other: \"{count} Alos\" },\n * },\n * });\n * i18n.t(\"greet\", { name: \"Mau\" }); // \"Olá, Mau\"\n * i18n.plural(\"alos\", 3); // \"3 Alôs\"\n *\n * @example\n * // A key the catalog does not define, with text to show instead of the key.\n * i18n.t(\"cart.empty\", undefined, { default: \"Seu carrinho está vazio\" });\n */\nexport function createI18n(options: CreateI18nOptions): I18n {\n const { locale, fallbackLocale = null, messages } = options;\n\n function t(key: string, params?: InterpolationValues, options?: TranslateOptions): string {\n const template = lookup(messages, locale, fallbackLocale, key) ?? options?.default;\n if (template === undefined) return key;\n return interpolate(template, params);\n }\n\n function plural(\n key: string,\n count: number,\n params?: InterpolationValues,\n options?: TranslateOptions,\n ): string {\n const suffix = count === 1 ? \"_one\" : \"_other\";\n const template =\n lookup(messages, locale, fallbackLocale, `${key}${suffix}`) ??\n lookup(messages, locale, fallbackLocale, key) ??\n options?.default;\n if (template === undefined) return key;\n return interpolate(template, { count, ...(params ?? {}) });\n }\n\n function formatNumber(value: number, opts?: Intl.NumberFormatOptions): string {\n return new Intl.NumberFormat(locale, opts).format(value);\n }\n\n function formatDate(value: Date | string, opts?: Intl.DateTimeFormatOptions): string {\n const date = typeof value === \"string\" ? new Date(value) : value;\n if (Number.isNaN(date.getTime())) return \"\";\n return new Intl.DateTimeFormat(locale, opts).format(date);\n }\n\n return {\n locale,\n fallbackLocale,\n t,\n plural,\n formatNumber,\n formatDate,\n withLocale: (nextLocale) =>\n createI18n({\n locale: nextLocale,\n fallbackLocale: fallbackLocale ?? undefined,\n messages,\n }),\n };\n}\n"],"mappings":";AA4DA,SAAS,EAAY,GAAkB,GAAsC;CAEzE,OADK,IACE,EAAS,QAAQ,eAAe,GAAQ,MAAiB;EAC5D,IAAM,IAAQ,EAAO;EACrB,OAAO,MAAU,KAAA,IAAY,IAAI,EAAK,KAAK,OAAO,CAAK;CAC3D,CAAC,IAJmB;AAKxB;AAEA,SAAS,EACL,GACA,GACA,GACA,GACa;CACb,IAAM,IAAS,EAAQ,EAAO,GAAG;CACjC,IAAI,MAAW,KAAA,GAAW,OAAO;CACjC,IAAI,GAAU;EACV,IAAM,IAAgB,EAAQ,EAAS,GAAG;EAC1C,IAAI,MAAkB,KAAA,GAAW,OAAO;CAC5C;CACA,OAAO;AACX;AA6BA,SAAgB,EAAW,GAAkC;CACzD,IAAM,EAAE,WAAQ,oBAAiB,MAAM,gBAAa;CAEpD,SAAS,EAAE,GAAa,GAA8B,GAAoC;EACtF,IAAM,IAAW,EAAO,GAAU,GAAQ,GAAgB,CAAG,KAAK,GAAS;EAE3E,OADI,MAAa,KAAA,IAAkB,IAC5B,EAAY,GAAU,CAAM;CACvC;CAEA,SAAS,EACL,GACA,GACA,GACA,GACM;EAEN,IAAM,IACF,EAAO,GAAU,GAAQ,GAAgB,GAAG,IAFjC,MAAU,IAAI,SAAS,UAEwB,KAC1D,EAAO,GAAU,GAAQ,GAAgB,CAAG,KAC5C,GAAS;EAEb,OADI,MAAa,KAAA,IAAkB,IAC5B,EAAY,GAAU;GAAE;GAAO,GAAI,KAAU,CAAC;EAAG,CAAC;CAC7D;CAEA,SAAS,EAAa,GAAe,GAAyC;EAC1E,OAAO,IAAI,KAAK,aAAa,GAAQ,CAAI,CAAC,CAAC,OAAO,CAAK;CAC3D;CAEA,SAAS,EAAW,GAAsB,GAA2C;EACjF,IAAM,IAAO,OAAO,KAAU,WAAW,IAAI,KAAK,CAAK,IAAI;EAE3D,OADI,OAAO,MAAM,EAAK,QAAQ,CAAC,IAAU,KAClC,IAAI,KAAK,eAAe,GAAQ,CAAI,CAAC,CAAC,OAAO,CAAI;CAC5D;CAEA,OAAO;EACH;EACA;EACA;EACA;EACA;EACA;EACA,aAAa,MACT,EAAW;GACP,QAAQ;GACR,gBAAgB,KAAkB,KAAA;GAClC;EACJ,CAAC;CACT;AACJ"}
1
+ {"version":3,"file":"create-i18n.js","names":[],"sources":["../../src/i18n/create-i18n.ts"],"sourcesContent":["import { dateTimeFormat, numberFormat } from \"@/utils/intl-cache\";\nexport type Messages = Record<string, string>;\nexport type Catalog = Record<string, Messages>;\nexport type InterpolationValues = Record<string, string | number>;\n\nexport interface CreateI18nOptions {\n /** Initial locale. */\n locale: string;\n /** Fallback locale used when a key is missing in the active locale. */\n fallbackLocale?: string;\n /** Catalog `{ [locale]: { [key]: \"...\" } }`. */\n messages: Catalog;\n}\n\n/** Per-call options for {@link I18n.t} and {@link I18n.plural}. */\nexport interface TranslateOptions {\n /**\n * Text to use when the catalog defines neither the key nor its fallback.\n *\n * Without this, a miss returns the key, and a caller that wants its own text\n * instead has to *detect* the miss — which from the outside means comparing\n * the result against the key it just passed in. That heuristic is wrong for a\n * catalog that legitimately maps a key to itself, and it is what every\n * translatable string the SDK ships would otherwise have to copy.\n *\n * Interpolated like any other message, so a default carries `{placeholders}`\n * too and is not second-class.\n */\n default?: string;\n}\n\nexport interface I18n {\n /** Currently active locale. */\n locale: string;\n /** Fallback locale (or `null` when not configured). */\n fallbackLocale: string | null;\n /**\n * Translate `key`, interpolating `{name}` placeholders from `params`.\n * Falls back to the configured fallback locale, then to `options.default`,\n * then to the key itself.\n */\n t: (key: string, params?: InterpolationValues, options?: TranslateOptions) => string;\n /**\n * Plural-aware translation. Tries `${key}_one` for `count === 1` and\n * `${key}_other` otherwise, with `{count}` available for interpolation.\n * Falls back to `options.default`, then to the key itself.\n */\n plural: (\n key: string,\n count: number,\n params?: InterpolationValues,\n options?: TranslateOptions,\n ) => string;\n /** Format a number using `Intl.NumberFormat` on the active locale. */\n formatNumber: (value: number, options?: Intl.NumberFormatOptions) => string;\n /** Format a Date using `Intl.DateTimeFormat` on the active locale. */\n formatDate: (value: Date | string, options?: Intl.DateTimeFormatOptions) => string;\n /** Build a new `I18n` instance pointing at a different locale. */\n withLocale: (locale: string) => I18n;\n}\n\nfunction interpolate(template: string, params?: InterpolationValues): string {\n if (!params) return template;\n return template.replace(/\\{(\\w+)\\}/g, (_match, name: string) => {\n const value = params[name];\n return value === undefined ? `{${name}}` : String(value);\n });\n}\n\nfunction lookup(\n catalog: Catalog,\n locale: string,\n fallback: string | null,\n key: string,\n): string | null {\n const direct = catalog[locale]?.[key];\n if (direct !== undefined) return direct;\n if (fallback) {\n const fallbackValue = catalog[fallback]?.[key];\n if (fallbackValue !== undefined) return fallbackValue;\n }\n return null;\n}\n\n/**\n * Create an i18n object with translation, pluralization and Intl helpers.\n *\n * The catalog is a plain `{ [locale]: { [key]: \"...\" } }` map — bring your\n * own keys, namespaces, or nested-key conventions. The SDK does not enforce\n * a schema so you can plug it into any string-loading pipeline.\n *\n * @example\n * const i18n = createI18n({\n * locale: \"pt-BR\",\n * fallbackLocale: \"en\",\n * messages: {\n * \"pt-BR\": {\n * \"greet\": \"Olá, {name}\",\n * \"alos_one\": \"{count} Alô\",\n * \"alos_other\": \"{count} Alôs\",\n * },\n * \"en\": { greet: \"Hi, {name}\", alos_one: \"{count} Alo\", alos_other: \"{count} Alos\" },\n * },\n * });\n * i18n.t(\"greet\", { name: \"Mau\" }); // \"Olá, Mau\"\n * i18n.plural(\"alos\", 3); // \"3 Alôs\"\n *\n * @example\n * // A key the catalog does not define, with text to show instead of the key.\n * i18n.t(\"cart.empty\", undefined, { default: \"Seu carrinho está vazio\" });\n */\nexport function createI18n(options: CreateI18nOptions): I18n {\n const { locale, fallbackLocale = null, messages } = options;\n\n function t(key: string, params?: InterpolationValues, options?: TranslateOptions): string {\n const template = lookup(messages, locale, fallbackLocale, key) ?? options?.default;\n if (template === undefined) return key;\n return interpolate(template, params);\n }\n\n function plural(\n key: string,\n count: number,\n params?: InterpolationValues,\n options?: TranslateOptions,\n ): string {\n const suffix = count === 1 ? \"_one\" : \"_other\";\n const template =\n lookup(messages, locale, fallbackLocale, `${key}${suffix}`) ??\n lookup(messages, locale, fallbackLocale, key) ??\n options?.default;\n if (template === undefined) return key;\n return interpolate(template, { count, ...(params ?? {}) });\n }\n\n function formatNumber(value: number, opts?: Intl.NumberFormatOptions): string {\n return numberFormat(locale, opts).format(value);\n }\n\n function formatDate(value: Date | string, opts?: Intl.DateTimeFormatOptions): string {\n const date = typeof value === \"string\" ? new Date(value) : value;\n if (Number.isNaN(date.getTime())) return \"\";\n return dateTimeFormat(locale, opts).format(date);\n }\n\n return {\n locale,\n fallbackLocale,\n t,\n plural,\n formatNumber,\n formatDate,\n withLocale: (nextLocale) =>\n createI18n({\n locale: nextLocale,\n fallbackLocale: fallbackLocale ?? undefined,\n messages,\n }),\n };\n}\n"],"mappings":";;AA6DA,SAAS,EAAY,GAAkB,GAAsC;CAEzE,OADK,IACE,EAAS,QAAQ,eAAe,GAAQ,MAAiB;EAC5D,IAAM,IAAQ,EAAO;EACrB,OAAO,MAAU,KAAA,IAAY,IAAI,EAAK,KAAK,OAAO,CAAK;CAC3D,CAAC,IAJmB;AAKxB;AAEA,SAAS,EACL,GACA,GACA,GACA,GACa;CACb,IAAM,IAAS,EAAQ,EAAO,GAAG;CACjC,IAAI,MAAW,KAAA,GAAW,OAAO;CACjC,IAAI,GAAU;EACV,IAAM,IAAgB,EAAQ,EAAS,GAAG;EAC1C,IAAI,MAAkB,KAAA,GAAW,OAAO;CAC5C;CACA,OAAO;AACX;AA6BA,SAAgB,EAAW,GAAkC;CACzD,IAAM,EAAE,WAAQ,oBAAiB,MAAM,gBAAa;CAEpD,SAAS,EAAE,GAAa,GAA8B,GAAoC;EACtF,IAAM,IAAW,EAAO,GAAU,GAAQ,GAAgB,CAAG,KAAK,GAAS;EAE3E,OADI,MAAa,KAAA,IAAkB,IAC5B,EAAY,GAAU,CAAM;CACvC;CAEA,SAAS,EACL,GACA,GACA,GACA,GACM;EAEN,IAAM,IACF,EAAO,GAAU,GAAQ,GAAgB,GAAG,IAFjC,MAAU,IAAI,SAAS,UAEwB,KAC1D,EAAO,GAAU,GAAQ,GAAgB,CAAG,KAC5C,GAAS;EAEb,OADI,MAAa,KAAA,IAAkB,IAC5B,EAAY,GAAU;GAAE;GAAO,GAAI,KAAU,CAAC;EAAG,CAAC;CAC7D;CAEA,SAAS,EAAa,GAAe,GAAyC;EAC1E,OAAO,EAAa,GAAQ,CAAI,CAAC,CAAC,OAAO,CAAK;CAClD;CAEA,SAAS,EAAW,GAAsB,GAA2C;EACjF,IAAM,IAAO,OAAO,KAAU,WAAW,IAAI,KAAK,CAAK,IAAI;EAE3D,OADI,OAAO,MAAM,EAAK,QAAQ,CAAC,IAAU,KAClC,EAAe,GAAQ,CAAI,CAAC,CAAC,OAAO,CAAI;CACnD;CAEA,OAAO;EACH;EACA;EACA;EACA;EACA;EACA;EACA,aAAa,MACT,EAAW;GACP,QAAQ;GACR,gBAAgB,KAAkB,KAAA;GAClC;EACJ,CAAC;CACT;AACJ"}
@@ -1,2 +1,2 @@
1
- const e=require("./constants.cjs"),t=require("./retry-policy.cjs");let n=require("react"),r=require("react/jsx-runtime"),i=require("@tanstack/react-query");function a({children:a,client:o,defaultOptions:s}){let[c]=(0,n.useState)(()=>o??new i.QueryClient({defaultOptions:{queries:{staleTime:e.STALE_TIME.DEFAULT,gcTime:e.CACHE_TIME.DEFAULT,retry:t.shouldRetryQuery,refetchOnWindowFocus:!1,...s?.queries??{}},mutations:{retry:0,...s?.mutations??{}}}}));return(0,r.jsx)(i.QueryClientProvider,{client:c,children:a})}exports.QueryProvider=a;
1
+ const e=require("./constants.cjs"),t=require("./retry-policy.cjs"),n=require("./foreign-client-warning.cjs");let r=require("react"),i=require("react/jsx-runtime"),a=require("@tanstack/react-query");function o({children:o,client:s,defaultOptions:c}){n.warnOnForeignClient(s);let[l]=(0,r.useState)(()=>s??new a.QueryClient({defaultOptions:{queries:{staleTime:e.STALE_TIME.DEFAULT,gcTime:e.CACHE_TIME.DEFAULT,retry:t.shouldRetryQuery,refetchOnWindowFocus:!1,...c?.queries??{}},mutations:{retry:0,...c?.mutations??{}}}}));return(0,i.jsx)(a.QueryClientProvider,{client:l,children:o})}exports.QueryProvider=o;
2
2
  //# sourceMappingURL=QueryProvider.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"QueryProvider.cjs","names":[],"sources":["../../src/query/QueryProvider.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport type { DefaultOptions } from \"@tanstack/react-query\";\nimport { STALE_TIME, CACHE_TIME } from \"./constants\";\nimport { shouldRetryQuery } from \"./retry-policy\";\n\nexport interface QueryProviderProps {\n children: ReactNode;\n /** Pass an existing client to share it across roots. */\n client?: QueryClient;\n /** Overrides for the default options applied when no `client` is provided. */\n defaultOptions?: DefaultOptions;\n}\n\n/**\n * Wrapper around `QueryClientProvider` that bootstraps a `QueryClient` with\n * sane SDK defaults (5-minute stale time, 30-minute gc time, one retry for\n * failures worth replaying).\n *\n * Retries follow {@link shouldRetryQuery} rather than a flat count: a 4xx other\n * than 408/429 is the server refusing on purpose, and replaying it only doubles\n * the network log while the spinner keeps turning.\n */\nexport function QueryProvider({ children, client, defaultOptions }: QueryProviderProps) {\n const [internalClient] = useState<QueryClient>(\n () =>\n client ??\n new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: STALE_TIME.DEFAULT,\n gcTime: CACHE_TIME.DEFAULT,\n retry: shouldRetryQuery,\n refetchOnWindowFocus: false,\n ...(defaultOptions?.queries ?? {}),\n },\n mutations: {\n retry: 0,\n ...(defaultOptions?.mutations ?? {}),\n },\n },\n }),\n );\n\n return <QueryClientProvider client={internalClient}>{children}</QueryClientProvider>;\n}\n"],"mappings":"4JAwBA,SAAgB,EAAc,CAAE,WAAU,SAAQ,kBAAsC,CACpF,GAAM,CAAC,IAAA,EAAkB,EAAA,SAAA,KAEjB,GACA,IAAI,EAAA,YAAY,CACZ,eAAgB,CACZ,QAAS,CACL,UAAW,EAAA,WAAW,QACtB,OAAQ,EAAA,WAAW,QACnB,MAAO,EAAA,iBACP,qBAAsB,GACtB,GAAI,GAAgB,SAAW,CAAC,CACpC,EACA,UAAW,CACP,MAAO,EACP,GAAI,GAAgB,WAAa,CAAC,CACtC,CACJ,CACJ,CAAC,CACT,EAEA,OAAO,EAAA,EAAA,IAAA,CAAC,EAAA,oBAAD,CAAqB,OAAQ,EAAiB,UAA8B,CAAA,CACvF"}
1
+ {"version":3,"file":"QueryProvider.cjs","names":[],"sources":["../../src/query/QueryProvider.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport type { DefaultOptions } from \"@tanstack/react-query\";\nimport { STALE_TIME, CACHE_TIME } from \"./constants\";\nimport { shouldRetryQuery } from \"./retry-policy\";\nimport { warnOnForeignClient } from \"./foreign-client-warning\";\n\nexport interface QueryProviderProps {\n children: ReactNode;\n /** Pass an existing client to share it across roots. */\n client?: QueryClient;\n /** Overrides for the default options applied when no `client` is provided. */\n defaultOptions?: DefaultOptions;\n}\n\n/**\n * Wrapper around `QueryClientProvider` that bootstraps a `QueryClient` with\n * sane SDK defaults (5-minute stale time, 30-minute gc time, one retry for\n * failures worth replaying).\n *\n * Retries follow {@link shouldRetryQuery} rather than a flat count: a 4xx other\n * than 408/429 is the server refusing on purpose, and replaying it only doubles\n * the network log while the spinner keeps turning.\n */\nexport function QueryProvider({ children, client, defaultOptions }: QueryProviderProps) {\n warnOnForeignClient(client);\n\n const [internalClient] = useState<QueryClient>(\n () =>\n client ??\n new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: STALE_TIME.DEFAULT,\n gcTime: CACHE_TIME.DEFAULT,\n retry: shouldRetryQuery,\n refetchOnWindowFocus: false,\n ...(defaultOptions?.queries ?? {}),\n },\n mutations: {\n retry: 0,\n ...(defaultOptions?.mutations ?? {}),\n },\n },\n }),\n );\n\n return <QueryClientProvider client={internalClient}>{children}</QueryClientProvider>;\n}\n"],"mappings":"sMAyBA,SAAgB,EAAc,CAAE,WAAU,SAAQ,kBAAsC,CACpF,EAAA,oBAAoB,CAAM,EAE1B,GAAM,CAAC,IAAA,EAAkB,EAAA,SAAA,KAEjB,GACA,IAAI,EAAA,YAAY,CACZ,eAAgB,CACZ,QAAS,CACL,UAAW,EAAA,WAAW,QACtB,OAAQ,EAAA,WAAW,QACnB,MAAO,EAAA,iBACP,qBAAsB,GACtB,GAAI,GAAgB,SAAW,CAAC,CACpC,EACA,UAAW,CACP,MAAO,EACP,GAAI,GAAgB,WAAa,CAAC,CACtC,CACJ,CACJ,CAAC,CACT,EAEA,OAAO,EAAA,EAAA,IAAA,CAAC,EAAA,oBAAD,CAAqB,OAAQ,EAAiB,UAA8B,CAAA,CACvF"}
@@ -1,29 +1,31 @@
1
1
  import { CACHE_TIME as e, STALE_TIME as t } from "./constants.js";
2
2
  import { shouldRetryQuery as n } from "./retry-policy.js";
3
- import { useState as r } from "react";
4
- import { jsx as i } from "react/jsx-runtime";
5
- import { QueryClient as a, QueryClientProvider as o } from "@tanstack/react-query";
3
+ import { warnOnForeignClient as r } from "./foreign-client-warning.js";
4
+ import { useState as i } from "react";
5
+ import { jsx as a } from "react/jsx-runtime";
6
+ import { QueryClient as o, QueryClientProvider as s } from "@tanstack/react-query";
6
7
  //#region src/query/QueryProvider.tsx
7
- function s({ children: s, client: c, defaultOptions: l }) {
8
- let [u] = r(() => c ?? new a({ defaultOptions: {
8
+ function c({ children: c, client: l, defaultOptions: u }) {
9
+ r(l);
10
+ let [d] = i(() => l ?? new o({ defaultOptions: {
9
11
  queries: {
10
12
  staleTime: t.DEFAULT,
11
13
  gcTime: e.DEFAULT,
12
14
  retry: n,
13
15
  refetchOnWindowFocus: !1,
14
- ...l?.queries ?? {}
16
+ ...u?.queries ?? {}
15
17
  },
16
18
  mutations: {
17
19
  retry: 0,
18
- ...l?.mutations ?? {}
20
+ ...u?.mutations ?? {}
19
21
  }
20
22
  } }));
21
- return /* @__PURE__ */ i(o, {
22
- client: u,
23
- children: s
23
+ return /* @__PURE__ */ a(s, {
24
+ client: d,
25
+ children: c
24
26
  });
25
27
  }
26
28
  //#endregion
27
- export { s as QueryProvider };
29
+ export { c as QueryProvider };
28
30
 
29
31
  //# sourceMappingURL=QueryProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"QueryProvider.js","names":[],"sources":["../../src/query/QueryProvider.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport type { DefaultOptions } from \"@tanstack/react-query\";\nimport { STALE_TIME, CACHE_TIME } from \"./constants\";\nimport { shouldRetryQuery } from \"./retry-policy\";\n\nexport interface QueryProviderProps {\n children: ReactNode;\n /** Pass an existing client to share it across roots. */\n client?: QueryClient;\n /** Overrides for the default options applied when no `client` is provided. */\n defaultOptions?: DefaultOptions;\n}\n\n/**\n * Wrapper around `QueryClientProvider` that bootstraps a `QueryClient` with\n * sane SDK defaults (5-minute stale time, 30-minute gc time, one retry for\n * failures worth replaying).\n *\n * Retries follow {@link shouldRetryQuery} rather than a flat count: a 4xx other\n * than 408/429 is the server refusing on purpose, and replaying it only doubles\n * the network log while the spinner keeps turning.\n */\nexport function QueryProvider({ children, client, defaultOptions }: QueryProviderProps) {\n const [internalClient] = useState<QueryClient>(\n () =>\n client ??\n new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: STALE_TIME.DEFAULT,\n gcTime: CACHE_TIME.DEFAULT,\n retry: shouldRetryQuery,\n refetchOnWindowFocus: false,\n ...(defaultOptions?.queries ?? {}),\n },\n mutations: {\n retry: 0,\n ...(defaultOptions?.mutations ?? {}),\n },\n },\n }),\n );\n\n return <QueryClientProvider client={internalClient}>{children}</QueryClientProvider>;\n}\n"],"mappings":";;;;;;AAwBA,SAAgB,EAAc,EAAE,aAAU,WAAQ,qBAAsC;CACpF,IAAM,CAAC,KAAkB,QAEjB,KACA,IAAI,EAAY,EACZ,gBAAgB;EACZ,SAAS;GACL,WAAW,EAAW;GACtB,QAAQ,EAAW;GACnB,OAAO;GACP,sBAAsB;GACtB,GAAI,GAAgB,WAAW,CAAC;EACpC;EACA,WAAW;GACP,OAAO;GACP,GAAI,GAAgB,aAAa,CAAC;EACtC;CACJ,EACJ,CAAC,CACT;CAEA,OAAO,kBAAC,GAAD;EAAqB,QAAQ;EAAiB;CAA8B,CAAA;AACvF"}
1
+ {"version":3,"file":"QueryProvider.js","names":[],"sources":["../../src/query/QueryProvider.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport type { DefaultOptions } from \"@tanstack/react-query\";\nimport { STALE_TIME, CACHE_TIME } from \"./constants\";\nimport { shouldRetryQuery } from \"./retry-policy\";\nimport { warnOnForeignClient } from \"./foreign-client-warning\";\n\nexport interface QueryProviderProps {\n children: ReactNode;\n /** Pass an existing client to share it across roots. */\n client?: QueryClient;\n /** Overrides for the default options applied when no `client` is provided. */\n defaultOptions?: DefaultOptions;\n}\n\n/**\n * Wrapper around `QueryClientProvider` that bootstraps a `QueryClient` with\n * sane SDK defaults (5-minute stale time, 30-minute gc time, one retry for\n * failures worth replaying).\n *\n * Retries follow {@link shouldRetryQuery} rather than a flat count: a 4xx other\n * than 408/429 is the server refusing on purpose, and replaying it only doubles\n * the network log while the spinner keeps turning.\n */\nexport function QueryProvider({ children, client, defaultOptions }: QueryProviderProps) {\n warnOnForeignClient(client);\n\n const [internalClient] = useState<QueryClient>(\n () =>\n client ??\n new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: STALE_TIME.DEFAULT,\n gcTime: CACHE_TIME.DEFAULT,\n retry: shouldRetryQuery,\n refetchOnWindowFocus: false,\n ...(defaultOptions?.queries ?? {}),\n },\n mutations: {\n retry: 0,\n ...(defaultOptions?.mutations ?? {}),\n },\n },\n }),\n );\n\n return <QueryClientProvider client={internalClient}>{children}</QueryClientProvider>;\n}\n"],"mappings":";;;;;;;AAyBA,SAAgB,EAAc,EAAE,aAAU,WAAQ,qBAAsC;CACpF,EAAoB,CAAM;CAE1B,IAAM,CAAC,KAAkB,QAEjB,KACA,IAAI,EAAY,EACZ,gBAAgB;EACZ,SAAS;GACL,WAAW,EAAW;GACtB,QAAQ,EAAW;GACnB,OAAO;GACP,sBAAsB;GACtB,GAAI,GAAgB,WAAW,CAAC;EACpC;EACA,WAAW;GACP,OAAO;GACP,GAAI,GAAgB,aAAa,CAAC;EACtC;CACJ,EACJ,CAAC,CACT;CAEA,OAAO,kBAAC,GAAD;EAAqB,QAAQ;EAAiB;CAA8B,CAAA;AACvF"}
@@ -0,0 +1,2 @@
1
+ const e=require("../utils/dev-mode.cjs"),t=require("../utils/duplicate-instance.cjs");let n=require("@tanstack/react-query");var r=!1;function i(i){r||i===void 0||!e.isDevBuild()||i instanceof n.QueryClient||typeof i.getQueryCache==`function`&&typeof i.mount==`function`&&(r=!0,console.warn(`[tempest-react-sdk] <QueryProvider client={...} /> received a QueryClient built by a different copy of @tanstack/react-query. The SDK publishes it on its own copy's context, so the app's \`useQuery\` calls will throw "No QueryClient set" even though this provider is mounted. `+t.DUPLICATE_COPY_REMEDY))}exports.warnOnForeignClient=i;
2
+ //# sourceMappingURL=foreign-client-warning.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foreign-client-warning.cjs","names":[],"sources":["../../src/query/foreign-client-warning.ts"],"sourcesContent":["/**\n * Internal, in its own file for the reason the AppBar warning is: a module that\n * exports a component may export nothing else without breaking Fast Refresh\n * (`react-refresh/only-export-components`), and the warn-once latch needs a\n * reset for tests to assert the warning more than once.\n */\nimport { QueryClient } from \"@tanstack/react-query\";\n\nimport { isDevBuild } from \"../utils/dev-mode\";\nimport { DUPLICATE_COPY_REMEDY } from \"../utils/duplicate-instance\";\n\n/** Set once the warning has printed, so a re-render does not bury the console. */\nlet warnedForeignClient = false;\n\n/**\n * Reset the warn-once latch. Test-only: the latch is module state, so a suite\n * asserting the warning more than once would otherwise see it only the first time.\n */\nexport function resetForeignClientWarning(): void {\n warnedForeignClient = false;\n}\n\n/**\n * Warn when the `client` handed in was built by a different copy of\n * `@tanstack/react-query`.\n *\n * This prop is the one place the app's copy and the SDK's copy touch: the app\n * constructs a `QueryClient` and passes it in, and `QueryClientProvider` —\n * resolved from the SDK's copy — publishes it on *that* copy's context. Every\n * `useQuery` in the app then reads the app copy's context, finds nothing, and\n * throws `No QueryClient set, use QueryClientProvider to set one` while a\n * provider is plainly mounted three lines up. Nothing in that message points at\n * the duplicate, which is why it costs an afternoon.\n *\n * `instanceof` is the discriminator, and it is exactly the right one: two copies\n * define two distinct `QueryClient` classes, so a client from the other copy\n * duck-types perfectly and fails the identity check. The duck-type guard runs\n * first so the warning fires only on the shape that is actually a client —\n * without it, every hand-rolled test double would trip it.\n *\n * @param client - The client the caller passed, if any.\n */\nexport function warnOnForeignClient(client: QueryClient | undefined): void {\n if (warnedForeignClient || client === undefined || !isDevBuild()) return;\n if (client instanceof QueryClient) return;\n const looksLikeClient =\n typeof (client as Partial<QueryClient>).getQueryCache === \"function\" &&\n typeof (client as Partial<QueryClient>).mount === \"function\";\n if (!looksLikeClient) return;\n warnedForeignClient = true;\n console.warn(\n \"[tempest-react-sdk] <QueryProvider client={...} /> received a QueryClient \" +\n \"built by a different copy of @tanstack/react-query. The SDK publishes it on \" +\n \"its own copy's context, so the app's `useQuery` calls will throw \" +\n '\"No QueryClient set\" even though this provider is mounted. ' +\n DUPLICATE_COPY_REMEDY,\n );\n}\n"],"mappings":"6HAYA,IAAI,EAAsB,GA8B1B,SAAgB,EAAoB,EAAuC,CACnE,GAAuB,IAAW,IAAA,IAAa,CAAC,EAAA,WAAW,GAC3D,aAAkB,EAAA,aAElB,OAAQ,EAAgC,eAAkB,YAC1D,OAAQ,EAAgC,OAAU,aAEtD,EAAsB,GACtB,QAAQ,KACJ,uRAII,EAAA,qBACR,EACJ"}
@@ -0,0 +1,12 @@
1
+ import { isDevBuild as e } from "../utils/dev-mode.js";
2
+ import { DUPLICATE_COPY_REMEDY as t } from "../utils/duplicate-instance.js";
3
+ import { QueryClient as n } from "@tanstack/react-query";
4
+ //#region src/query/foreign-client-warning.ts
5
+ var r = !1;
6
+ function i(i) {
7
+ r || i === void 0 || !e() || i instanceof n || typeof i.getQueryCache == "function" && typeof i.mount == "function" && (r = !0, console.warn("[tempest-react-sdk] <QueryProvider client={...} /> received a QueryClient built by a different copy of @tanstack/react-query. The SDK publishes it on its own copy's context, so the app's `useQuery` calls will throw \"No QueryClient set\" even though this provider is mounted. " + t));
8
+ }
9
+ //#endregion
10
+ export { i as warnOnForeignClient };
11
+
12
+ //# sourceMappingURL=foreign-client-warning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foreign-client-warning.js","names":[],"sources":["../../src/query/foreign-client-warning.ts"],"sourcesContent":["/**\n * Internal, in its own file for the reason the AppBar warning is: a module that\n * exports a component may export nothing else without breaking Fast Refresh\n * (`react-refresh/only-export-components`), and the warn-once latch needs a\n * reset for tests to assert the warning more than once.\n */\nimport { QueryClient } from \"@tanstack/react-query\";\n\nimport { isDevBuild } from \"../utils/dev-mode\";\nimport { DUPLICATE_COPY_REMEDY } from \"../utils/duplicate-instance\";\n\n/** Set once the warning has printed, so a re-render does not bury the console. */\nlet warnedForeignClient = false;\n\n/**\n * Reset the warn-once latch. Test-only: the latch is module state, so a suite\n * asserting the warning more than once would otherwise see it only the first time.\n */\nexport function resetForeignClientWarning(): void {\n warnedForeignClient = false;\n}\n\n/**\n * Warn when the `client` handed in was built by a different copy of\n * `@tanstack/react-query`.\n *\n * This prop is the one place the app's copy and the SDK's copy touch: the app\n * constructs a `QueryClient` and passes it in, and `QueryClientProvider` —\n * resolved from the SDK's copy — publishes it on *that* copy's context. Every\n * `useQuery` in the app then reads the app copy's context, finds nothing, and\n * throws `No QueryClient set, use QueryClientProvider to set one` while a\n * provider is plainly mounted three lines up. Nothing in that message points at\n * the duplicate, which is why it costs an afternoon.\n *\n * `instanceof` is the discriminator, and it is exactly the right one: two copies\n * define two distinct `QueryClient` classes, so a client from the other copy\n * duck-types perfectly and fails the identity check. The duck-type guard runs\n * first so the warning fires only on the shape that is actually a client —\n * without it, every hand-rolled test double would trip it.\n *\n * @param client - The client the caller passed, if any.\n */\nexport function warnOnForeignClient(client: QueryClient | undefined): void {\n if (warnedForeignClient || client === undefined || !isDevBuild()) return;\n if (client instanceof QueryClient) return;\n const looksLikeClient =\n typeof (client as Partial<QueryClient>).getQueryCache === \"function\" &&\n typeof (client as Partial<QueryClient>).mount === \"function\";\n if (!looksLikeClient) return;\n warnedForeignClient = true;\n console.warn(\n \"[tempest-react-sdk] <QueryProvider client={...} /> received a QueryClient \" +\n \"built by a different copy of @tanstack/react-query. The SDK publishes it on \" +\n \"its own copy's context, so the app's `useQuery` calls will throw \" +\n '\"No QueryClient set\" even though this provider is mounted. ' +\n DUPLICATE_COPY_REMEDY,\n );\n}\n"],"mappings":";;;;AAYA,IAAI,IAAsB;AA8B1B,SAAgB,EAAoB,GAAuC;CACnE,KAAuB,MAAW,KAAA,KAAa,CAAC,EAAW,KAC3D,aAAkB,KAElB,OAAQ,EAAgC,iBAAkB,cAC1D,OAAQ,EAAgC,SAAU,eAEtD,IAAsB,IACtB,QAAQ,KACJ,yRAII,CACR;AACJ"}
@@ -1,2 +1,2 @@
1
- const e=require("../auth/lazy-with-retry.cjs"),t=require("./RouteGuard.cjs");let n=require("react"),r=require("react/jsx-runtime"),i=require("react-router");function a(e){return e}var o=new WeakMap;function s(t){let n=o.get(t);return n||(n=e.lazyWithRetry(t.lazy),o.set(t,n)),n}function c({guard:e,redirectTo:n,children:i}){let a=typeof e==`function`?e():e;return(0,r.jsx)(t.RouteGuard,{when:a,redirectTo:n,children:i})}function l(e){return e.map((e,t)=>{let n=e.element;if(e.lazy){let t=s(e);n=(0,r.jsx)(t,{})}return e.guard!==void 0&&(n=(0,r.jsx)(c,{guard:e.guard,redirectTo:e.redirectTo,children:n})),e.index?(0,r.jsx)(i.Route,{index:!0,element:n},`index-${t}`):(0,r.jsx)(i.Route,{path:e.path,element:n,caseSensitive:e.caseSensitive,children:e.children?l(e.children):null},e.path??`route-${t}`)})}var u={browser:i.BrowserRouter,hash:i.HashRouter,memory:i.MemoryRouter};function d({routes:e,router:t=`browser`,basename:a,initialEntries:o,fallback:s=null}){let c=(0,n.useMemo)(()=>l(e),[e]),d=u[t];return(0,r.jsx)(d,{...t===`memory`?{basename:a,initialEntries:o}:{basename:a},children:(0,r.jsx)(n.Suspense,{fallback:s,children:(0,r.jsx)(i.Routes,{children:c})})})}exports.AppRouter=d,exports.defineRoutes=a;
1
+ const e=require("../auth/lazy-with-retry.cjs"),t=require("./RouteGuard.cjs");let n=require("react"),r=require("react/jsx-runtime"),i=require("react-router");function a(e){return e}var o=new WeakMap;function s(t){let n=o.get(t);return n||(n=e.lazyWithRetry(t.lazy),o.set(t,n)),n}function c({guard:e,guardFallback:n,redirectTo:i,children:a}){let o=typeof e==`function`?e():e;return(0,r.jsx)(t.RouteGuard,{when:o,fallback:n,redirectTo:i,children:a})}var l=new WeakMap,u=0;function d(e){let t=l.get(e);return t||(t=`guard-${++u}`,l.set(e,t)),t}function f(e,t){return e.map((e,n)=>{let a=e.element;if(e.lazy){let t=s(e);a=(0,r.jsx)(t,{})}return e.guard!==void 0&&(a=(0,r.jsx)(c,{guard:e.guard,guardFallback:e.guardFallback??t,redirectTo:e.redirectTo,children:a},d(e))),e.index?(0,r.jsx)(i.Route,{index:!0,element:a},`index-${n}`):(0,r.jsx)(i.Route,{path:e.path,element:a,caseSensitive:e.caseSensitive,children:e.children?f(e.children,t):null},e.path??`route-${n}`)})}var p={browser:i.BrowserRouter,hash:i.HashRouter,memory:i.MemoryRouter};function m({routes:e,router:t=`browser`,basename:a,initialEntries:o,fallback:s=null}){let c=(0,n.useMemo)(()=>f(e,s),[e,s]),l=p[t];return(0,r.jsx)(l,{...t===`memory`?{basename:a,initialEntries:o}:{basename:a},children:(0,r.jsx)(n.Suspense,{fallback:s,children:(0,r.jsx)(i.Routes,{children:c})})})}exports.AppRouter=m,exports.defineRoutes=a;
2
2
  //# sourceMappingURL=AppRouter.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"AppRouter.cjs","names":[],"sources":["../../src/router/AppRouter.tsx"],"sourcesContent":["import { Suspense, useMemo } from \"react\";\nimport type { ComponentType, ReactNode } from \"react\";\nimport { BrowserRouter, HashRouter, MemoryRouter, Routes, Route } from \"react-router\";\nimport { lazyWithRetry } from \"../auth/lazy-with-retry\";\nimport { RouteGuard } from \"./RouteGuard\";\nimport type { RouterKind, TempestRouteObject } from \"./types\";\n\n/**\n * Identity helper that types a declarative route tree. Use it so editors give\n * autocomplete and type-checking on every node; the array is returned as-is.\n *\n * @example\n * export const routes = defineRoutes([\n * { path: \"/\", element: <Layout />, children: [\n * { index: true, lazy: () => import(\"./pages/Home\") },\n * { path: \"settings\", lazy: () => import(\"./pages/Settings\"),\n * guard: () => useAuth.getState().isAuthenticated, redirectTo: \"/login\" },\n * ] },\n * ]);\n */\nexport function defineRoutes(routes: TempestRouteObject[]): TempestRouteObject[] {\n return routes;\n}\n\nconst lazyCache = new WeakMap<TempestRouteObject, ComponentType<unknown>>();\n\nfunction resolveLazy(route: TempestRouteObject): ComponentType<unknown> {\n let comp = lazyCache.get(route);\n if (!comp) {\n comp = lazyWithRetry(route.lazy!);\n lazyCache.set(route, comp);\n }\n return comp;\n}\n\nfunction GuardedElement({\n guard,\n redirectTo,\n children,\n}: {\n guard: boolean | (() => boolean);\n redirectTo?: string;\n children: ReactNode;\n}) {\n const allowed = typeof guard === \"function\" ? guard() : guard;\n return (\n <RouteGuard when={allowed} redirectTo={redirectTo}>\n {children}\n </RouteGuard>\n );\n}\n\nfunction toRouteElements(routes: TempestRouteObject[]): ReactNode {\n return routes.map((route, i) => {\n let element: ReactNode = route.element;\n if (route.lazy) {\n const LazyComponent = resolveLazy(route);\n element = <LazyComponent />;\n }\n if (route.guard !== undefined) {\n element = (\n <GuardedElement guard={route.guard} redirectTo={route.redirectTo}>\n {element}\n </GuardedElement>\n );\n }\n\n if (route.index) {\n return <Route key={`index-${i}`} index element={element} />;\n }\n\n return (\n <Route\n key={route.path ?? `route-${i}`}\n path={route.path}\n element={element}\n caseSensitive={route.caseSensitive}\n >\n {route.children ? toRouteElements(route.children) : null}\n </Route>\n );\n });\n}\n\nconst ROUTERS: Record<RouterKind, typeof BrowserRouter> = {\n browser: BrowserRouter,\n hash: HashRouter,\n memory: MemoryRouter,\n};\n\nexport interface AppRouterProps {\n /** Declarative route tree, ideally built with {@link defineRoutes}. */\n routes: TempestRouteObject[];\n /** History strategy (default: `\"browser\"`). */\n router?: RouterKind;\n /** App-wide base path forwarded to the underlying router. */\n basename?: string;\n /** Initial URLs for the `\"memory\"` router (tests / non-DOM hosts). */\n initialEntries?: string[];\n /** Suspense fallback shown while a `lazy` route chunk loads. */\n fallback?: ReactNode;\n}\n\n/**\n * Render a full React Router (v7 or v8, declarative mode) from a\n * {@link defineRoutes}\n * tree: picks the history strategy, wraps everything in a `<Suspense>` boundary\n * for `lazy` routes, and applies per-route `guard` redirects. This is the\n * single entry point apps mount at their root.\n *\n * @example\n * <AppRouter routes={routes} fallback={<Spinner />} />\n */\nexport function AppRouter({\n routes,\n router = \"browser\",\n basename,\n initialEntries,\n fallback = null,\n}: AppRouterProps) {\n const tree = useMemo(() => toRouteElements(routes), [routes]);\n const Router = ROUTERS[router];\n const routerProps = router === \"memory\" ? { basename, initialEntries } : { basename };\n\n return (\n <Router {...routerProps}>\n <Suspense fallback={fallback}>\n <Routes>{tree}</Routes>\n </Suspense>\n </Router>\n );\n}\n"],"mappings":"6JAoBA,SAAgB,EAAa,EAAoD,CAC7E,OAAO,CACX,CAEA,IAAM,EAAY,IAAI,QAEtB,SAAS,EAAY,EAAmD,CACpE,IAAI,EAAO,EAAU,IAAI,CAAK,EAK9B,OAJK,IACD,EAAO,EAAA,cAAc,EAAM,IAAK,EAChC,EAAU,IAAI,EAAO,CAAI,GAEtB,CACX,CAEA,SAAS,EAAe,CACpB,QACA,aACA,YAKD,CACC,IAAM,EAAU,OAAO,GAAU,WAAa,EAAM,EAAI,EACxD,OACI,EAAA,EAAA,IAAA,CAAC,EAAA,WAAD,CAAY,KAAM,EAAqB,aAClC,UACO,CAAA,CAEpB,CAEA,SAAS,EAAgB,EAAyC,CAC9D,OAAO,EAAO,KAAK,EAAO,IAAM,CAC5B,IAAI,EAAqB,EAAM,QAC/B,GAAI,EAAM,KAAM,CACZ,IAAM,EAAgB,EAAY,CAAK,EACvC,GAAU,EAAA,EAAA,IAAA,CAAC,EAAD,CAAgB,CAAA,CAC9B,CAaA,OAZI,EAAM,QAAU,IAAA,KAChB,GACI,EAAA,EAAA,IAAA,CAAC,EAAD,CAAgB,MAAO,EAAM,MAAO,WAAY,EAAM,WACjD,SAAA,CACW,CAAA,GAIpB,EAAM,OACC,EAAA,EAAA,IAAA,CAAC,EAAA,MAAD,CAA0B,MAAA,GAAe,SAAU,EAAvC,SAAS,GAA8B,GAI1D,EAAA,EAAA,IAAA,CAAC,EAAA,MAAD,CAEI,KAAM,EAAM,KACH,UACT,cAAe,EAAM,cAEpB,SAAA,EAAM,SAAW,EAAgB,EAAM,QAAQ,EAAI,IACjD,EANE,EAAM,MAAQ,SAAS,GAMzB,CAEf,CAAC,CACL,CAEA,IAAM,EAAoD,CACtD,QAAS,EAAA,cACT,KAAM,EAAA,WACN,OAAQ,EAAA,YACZ,EAyBA,SAAgB,EAAU,CACtB,SACA,SAAS,UACT,WACA,iBACA,WAAW,MACI,CACf,IAAM,GAAA,EAAO,EAAA,QAAA,KAAc,EAAgB,CAAM,EAAG,CAAC,CAAM,CAAC,EACtD,EAAS,EAAQ,GAGvB,OACI,EAAA,EAAA,IAAA,CAAC,EAAD,CAAQ,GAHQ,IAAW,SAAW,CAAE,WAAU,gBAAe,EAAI,CAAE,UAAS,EAI5E,UAAA,EAAA,EAAA,IAAA,CAAC,EAAA,SAAD,CAAoB,WAChB,UAAA,EAAA,EAAA,IAAA,CAAC,EAAA,OAAD,CAAA,SAAS,CAAa,CAAA,CAChB,CAAA,CACN,CAAA,CAEhB"}
1
+ {"version":3,"file":"AppRouter.cjs","names":[],"sources":["../../src/router/AppRouter.tsx"],"sourcesContent":["import { Suspense, useMemo } from \"react\";\nimport type { ComponentType, ReactNode } from \"react\";\nimport { BrowserRouter, HashRouter, MemoryRouter, Routes, Route } from \"react-router\";\nimport { lazyWithRetry } from \"../auth/lazy-with-retry\";\nimport { RouteGuard } from \"./RouteGuard\";\nimport type { RouteGuardResult, RouterKind, TempestRouteObject } from \"./types\";\n\n/**\n * Identity helper that types a declarative route tree. Use it so editors give\n * autocomplete and type-checking on every node; the array is returned as-is.\n *\n * @example\n * export const routes = defineRoutes([\n * { path: \"/\", element: <Layout />, children: [\n * { index: true, lazy: () => import(\"./pages/Home\") },\n * { path: \"settings\", lazy: () => import(\"./pages/Settings\"),\n * guard: () => useAuth.getState().isAuthenticated, redirectTo: \"/login\" },\n * ] },\n * ]);\n */\nexport function defineRoutes(routes: TempestRouteObject[]): TempestRouteObject[] {\n return routes;\n}\n\nconst lazyCache = new WeakMap<TempestRouteObject, ComponentType<unknown>>();\n\nfunction resolveLazy(route: TempestRouteObject): ComponentType<unknown> {\n let comp = lazyCache.get(route);\n if (!comp) {\n comp = lazyWithRetry(route.lazy!);\n lazyCache.set(route, comp);\n }\n return comp;\n}\n\n/**\n * Runs one route's `guard` and renders the outcome.\n *\n * The guard is called during this component's render, which is what lets it\n * call hooks — `useCan` returning `{ allowed, isLoading }` maps straight onto\n * the three outcomes. See {@link guardKey} for why each guarded route gets its\n * own instance.\n */\nfunction GuardedElement({\n guard,\n guardFallback,\n redirectTo,\n children,\n}: {\n guard: boolean | (() => RouteGuardResult);\n guardFallback?: ReactNode;\n redirectTo?: string;\n children: ReactNode;\n}) {\n const allowed = typeof guard === \"function\" ? guard() : guard;\n return (\n <RouteGuard when={allowed} fallback={guardFallback} redirectTo={redirectTo}>\n {children}\n </RouteGuard>\n );\n}\n\nconst guardKeys = new WeakMap<TempestRouteObject, string>();\nlet guardKeySeq = 0;\n\n/**\n * A key unique to each route object, so React remounts `GuardedElement` when\n * the matched route changes instead of reusing the instance.\n *\n * Load-bearing once guards may call hooks. React Router renders the matched\n * route's element at the same position in the tree, so without a differing key\n * React reconciles two different routes onto the same `GuardedElement`\n * instance and the previous route's guard state survives into the next one's —\n * a guard reading `useState(\"from-a\")` still reads `\"from-a\"` after navigating\n * to a route whose guard initialises it to `\"from-b\"`. Path is not enough on\n * its own: two routes in different branches can share one.\n */\nfunction guardKey(route: TempestRouteObject): string {\n let key = guardKeys.get(route);\n if (!key) {\n key = `guard-${++guardKeySeq}`;\n guardKeys.set(route, key);\n }\n return key;\n}\n\nfunction toRouteElements(routes: TempestRouteObject[], fallback: ReactNode): ReactNode {\n return routes.map((route, i) => {\n let element: ReactNode = route.element;\n if (route.lazy) {\n const LazyComponent = resolveLazy(route);\n element = <LazyComponent />;\n }\n if (route.guard !== undefined) {\n element = (\n <GuardedElement\n key={guardKey(route)}\n guard={route.guard}\n guardFallback={route.guardFallback ?? fallback}\n redirectTo={route.redirectTo}\n >\n {element}\n </GuardedElement>\n );\n }\n\n if (route.index) {\n return <Route key={`index-${i}`} index element={element} />;\n }\n\n return (\n <Route\n key={route.path ?? `route-${i}`}\n path={route.path}\n element={element}\n caseSensitive={route.caseSensitive}\n >\n {route.children ? toRouteElements(route.children, fallback) : null}\n </Route>\n );\n });\n}\n\nconst ROUTERS: Record<RouterKind, typeof BrowserRouter> = {\n browser: BrowserRouter,\n hash: HashRouter,\n memory: MemoryRouter,\n};\n\nexport interface AppRouterProps {\n /** Declarative route tree, ideally built with {@link defineRoutes}. */\n routes: TempestRouteObject[];\n /** History strategy (default: `\"browser\"`). */\n router?: RouterKind;\n /** App-wide base path forwarded to the underlying router. */\n basename?: string;\n /** Initial URLs for the `\"memory\"` router (tests / non-DOM hosts). */\n initialEntries?: string[];\n /**\n * Suspense fallback shown while a `lazy` route chunk loads, and the default\n * for a route whose `guard` answers `\"pending\"` — one spinner covers both\n * kinds of \"not ready yet\". A route overrides it with its own\n * `guardFallback`.\n */\n fallback?: ReactNode;\n}\n\n/**\n * Render a full React Router (v7 or v8, declarative mode) from a\n * {@link defineRoutes}\n * tree: picks the history strategy, wraps everything in a `<Suspense>` boundary\n * for `lazy` routes, and applies per-route `guard` redirects. This is the\n * single entry point apps mount at their root.\n *\n * @example\n * <AppRouter routes={routes} fallback={<Spinner />} />\n */\nexport function AppRouter({\n routes,\n router = \"browser\",\n basename,\n initialEntries,\n fallback = null,\n}: AppRouterProps) {\n const tree = useMemo(() => toRouteElements(routes, fallback), [routes, fallback]);\n const Router = ROUTERS[router];\n const routerProps = router === \"memory\" ? { basename, initialEntries } : { basename };\n\n return (\n <Router {...routerProps}>\n <Suspense fallback={fallback}>\n <Routes>{tree}</Routes>\n </Suspense>\n </Router>\n );\n}\n"],"mappings":"6JAoBA,SAAgB,EAAa,EAAoD,CAC7E,OAAO,CACX,CAEA,IAAM,EAAY,IAAI,QAEtB,SAAS,EAAY,EAAmD,CACpE,IAAI,EAAO,EAAU,IAAI,CAAK,EAK9B,OAJK,IACD,EAAO,EAAA,cAAc,EAAM,IAAK,EAChC,EAAU,IAAI,EAAO,CAAI,GAEtB,CACX,CAUA,SAAS,EAAe,CACpB,QACA,gBACA,aACA,YAMD,CACC,IAAM,EAAU,OAAO,GAAU,WAAa,EAAM,EAAI,EACxD,OACI,EAAA,EAAA,IAAA,CAAC,EAAA,WAAD,CAAY,KAAM,EAAS,SAAU,EAA2B,aAC3D,UACO,CAAA,CAEpB,CAEA,IAAM,EAAY,IAAI,QAClB,EAAc,EAclB,SAAS,EAAS,EAAmC,CACjD,IAAI,EAAM,EAAU,IAAI,CAAK,EAK7B,OAJK,IACD,EAAM,SAAS,EAAE,IACjB,EAAU,IAAI,EAAO,CAAG,GAErB,CACX,CAEA,SAAS,EAAgB,EAA8B,EAAgC,CACnF,OAAO,EAAO,KAAK,EAAO,IAAM,CAC5B,IAAI,EAAqB,EAAM,QAC/B,GAAI,EAAM,KAAM,CACZ,IAAM,EAAgB,EAAY,CAAK,EACvC,GAAU,EAAA,EAAA,IAAA,CAAC,EAAD,CAAgB,CAAA,CAC9B,CAkBA,OAjBI,EAAM,QAAU,IAAA,KAChB,GACI,EAAA,EAAA,IAAA,CAAC,EAAD,CAEI,MAAO,EAAM,MACb,cAAe,EAAM,eAAiB,EACtC,WAAY,EAAM,WAEjB,SAAA,CACW,EANP,EAAS,CAAK,CAMP,GAIpB,EAAM,OACC,EAAA,EAAA,IAAA,CAAC,EAAA,MAAD,CAA0B,MAAA,GAAe,SAAU,EAAvC,SAAS,GAA8B,GAI1D,EAAA,EAAA,IAAA,CAAC,EAAA,MAAD,CAEI,KAAM,EAAM,KACH,UACT,cAAe,EAAM,cAEpB,SAAA,EAAM,SAAW,EAAgB,EAAM,SAAU,CAAQ,EAAI,IAC3D,EANE,EAAM,MAAQ,SAAS,GAMzB,CAEf,CAAC,CACL,CAEA,IAAM,EAAoD,CACtD,QAAS,EAAA,cACT,KAAM,EAAA,WACN,OAAQ,EAAA,YACZ,EA8BA,SAAgB,EAAU,CACtB,SACA,SAAS,UACT,WACA,iBACA,WAAW,MACI,CACf,IAAM,GAAA,EAAO,EAAA,QAAA,KAAc,EAAgB,EAAQ,CAAQ,EAAG,CAAC,EAAQ,CAAQ,CAAC,EAC1E,EAAS,EAAQ,GAGvB,OACI,EAAA,EAAA,IAAA,CAAC,EAAD,CAAQ,GAHQ,IAAW,SAAW,CAAE,WAAU,gBAAe,EAAI,CAAE,UAAS,EAI5E,UAAA,EAAA,EAAA,IAAA,CAAC,EAAA,SAAD,CAAoB,WAChB,UAAA,EAAA,EAAA,IAAA,CAAC,EAAA,OAAD,CAAA,SAAS,CAAa,CAAA,CAChB,CAAA,CACN,CAAA,CAEhB"}
@@ -12,43 +12,50 @@ function f(t) {
12
12
  let n = d.get(t);
13
13
  return n || (n = e(t.lazy), d.set(t, n)), n;
14
14
  }
15
- function p({ guard: e, redirectTo: n, children: r }) {
16
- let a = typeof e == "function" ? e() : e;
15
+ function p({ guard: e, guardFallback: n, redirectTo: r, children: a }) {
16
+ let o = typeof e == "function" ? e() : e;
17
17
  return /* @__PURE__ */ i(t, {
18
- when: a,
19
- redirectTo: n,
20
- children: r
18
+ when: o,
19
+ fallback: n,
20
+ redirectTo: r,
21
+ children: a
21
22
  });
22
23
  }
23
- function m(e) {
24
- return e.map((e, t) => {
25
- let n = e.element;
24
+ var m = /* @__PURE__ */ new WeakMap(), h = 0;
25
+ function g(e) {
26
+ let t = m.get(e);
27
+ return t || (t = `guard-${++h}`, m.set(e, t)), t;
28
+ }
29
+ function _(e, t) {
30
+ return e.map((e, n) => {
31
+ let r = e.element;
26
32
  if (e.lazy) {
27
33
  let t = f(e);
28
- n = /* @__PURE__ */ i(t, {});
34
+ r = /* @__PURE__ */ i(t, {});
29
35
  }
30
- return e.guard !== void 0 && (n = /* @__PURE__ */ i(p, {
36
+ return e.guard !== void 0 && (r = /* @__PURE__ */ i(p, {
31
37
  guard: e.guard,
38
+ guardFallback: e.guardFallback ?? t,
32
39
  redirectTo: e.redirectTo,
33
- children: n
34
- })), e.index ? /* @__PURE__ */ i(c, {
40
+ children: r
41
+ }, g(e))), e.index ? /* @__PURE__ */ i(c, {
35
42
  index: !0,
36
- element: n
37
- }, `index-${t}`) : /* @__PURE__ */ i(c, {
43
+ element: r
44
+ }, `index-${n}`) : /* @__PURE__ */ i(c, {
38
45
  path: e.path,
39
- element: n,
46
+ element: r,
40
47
  caseSensitive: e.caseSensitive,
41
- children: e.children ? m(e.children) : null
42
- }, e.path ?? `route-${t}`);
48
+ children: e.children ? _(e.children, t) : null
49
+ }, e.path ?? `route-${n}`);
43
50
  });
44
51
  }
45
- var h = {
52
+ var v = {
46
53
  browser: a,
47
54
  hash: o,
48
55
  memory: s
49
56
  };
50
- function g({ routes: e, router: t = "browser", basename: a, initialEntries: o, fallback: s = null }) {
51
- let c = r(() => m(e), [e]), u = h[t];
57
+ function y({ routes: e, router: t = "browser", basename: a, initialEntries: o, fallback: s = null }) {
58
+ let c = r(() => _(e, s), [e, s]), u = v[t];
52
59
  return /* @__PURE__ */ i(u, {
53
60
  ...t === "memory" ? {
54
61
  basename: a,
@@ -61,6 +68,6 @@ function g({ routes: e, router: t = "browser", basename: a, initialEntries: o, f
61
68
  });
62
69
  }
63
70
  //#endregion
64
- export { g as AppRouter, u as defineRoutes };
71
+ export { y as AppRouter, u as defineRoutes };
65
72
 
66
73
  //# sourceMappingURL=AppRouter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AppRouter.js","names":[],"sources":["../../src/router/AppRouter.tsx"],"sourcesContent":["import { Suspense, useMemo } from \"react\";\nimport type { ComponentType, ReactNode } from \"react\";\nimport { BrowserRouter, HashRouter, MemoryRouter, Routes, Route } from \"react-router\";\nimport { lazyWithRetry } from \"../auth/lazy-with-retry\";\nimport { RouteGuard } from \"./RouteGuard\";\nimport type { RouterKind, TempestRouteObject } from \"./types\";\n\n/**\n * Identity helper that types a declarative route tree. Use it so editors give\n * autocomplete and type-checking on every node; the array is returned as-is.\n *\n * @example\n * export const routes = defineRoutes([\n * { path: \"/\", element: <Layout />, children: [\n * { index: true, lazy: () => import(\"./pages/Home\") },\n * { path: \"settings\", lazy: () => import(\"./pages/Settings\"),\n * guard: () => useAuth.getState().isAuthenticated, redirectTo: \"/login\" },\n * ] },\n * ]);\n */\nexport function defineRoutes(routes: TempestRouteObject[]): TempestRouteObject[] {\n return routes;\n}\n\nconst lazyCache = new WeakMap<TempestRouteObject, ComponentType<unknown>>();\n\nfunction resolveLazy(route: TempestRouteObject): ComponentType<unknown> {\n let comp = lazyCache.get(route);\n if (!comp) {\n comp = lazyWithRetry(route.lazy!);\n lazyCache.set(route, comp);\n }\n return comp;\n}\n\nfunction GuardedElement({\n guard,\n redirectTo,\n children,\n}: {\n guard: boolean | (() => boolean);\n redirectTo?: string;\n children: ReactNode;\n}) {\n const allowed = typeof guard === \"function\" ? guard() : guard;\n return (\n <RouteGuard when={allowed} redirectTo={redirectTo}>\n {children}\n </RouteGuard>\n );\n}\n\nfunction toRouteElements(routes: TempestRouteObject[]): ReactNode {\n return routes.map((route, i) => {\n let element: ReactNode = route.element;\n if (route.lazy) {\n const LazyComponent = resolveLazy(route);\n element = <LazyComponent />;\n }\n if (route.guard !== undefined) {\n element = (\n <GuardedElement guard={route.guard} redirectTo={route.redirectTo}>\n {element}\n </GuardedElement>\n );\n }\n\n if (route.index) {\n return <Route key={`index-${i}`} index element={element} />;\n }\n\n return (\n <Route\n key={route.path ?? `route-${i}`}\n path={route.path}\n element={element}\n caseSensitive={route.caseSensitive}\n >\n {route.children ? toRouteElements(route.children) : null}\n </Route>\n );\n });\n}\n\nconst ROUTERS: Record<RouterKind, typeof BrowserRouter> = {\n browser: BrowserRouter,\n hash: HashRouter,\n memory: MemoryRouter,\n};\n\nexport interface AppRouterProps {\n /** Declarative route tree, ideally built with {@link defineRoutes}. */\n routes: TempestRouteObject[];\n /** History strategy (default: `\"browser\"`). */\n router?: RouterKind;\n /** App-wide base path forwarded to the underlying router. */\n basename?: string;\n /** Initial URLs for the `\"memory\"` router (tests / non-DOM hosts). */\n initialEntries?: string[];\n /** Suspense fallback shown while a `lazy` route chunk loads. */\n fallback?: ReactNode;\n}\n\n/**\n * Render a full React Router (v7 or v8, declarative mode) from a\n * {@link defineRoutes}\n * tree: picks the history strategy, wraps everything in a `<Suspense>` boundary\n * for `lazy` routes, and applies per-route `guard` redirects. This is the\n * single entry point apps mount at their root.\n *\n * @example\n * <AppRouter routes={routes} fallback={<Spinner />} />\n */\nexport function AppRouter({\n routes,\n router = \"browser\",\n basename,\n initialEntries,\n fallback = null,\n}: AppRouterProps) {\n const tree = useMemo(() => toRouteElements(routes), [routes]);\n const Router = ROUTERS[router];\n const routerProps = router === \"memory\" ? { basename, initialEntries } : { basename };\n\n return (\n <Router {...routerProps}>\n <Suspense fallback={fallback}>\n <Routes>{tree}</Routes>\n </Suspense>\n </Router>\n );\n}\n"],"mappings":";;;;;;AAoBA,SAAgB,EAAa,GAAoD;CAC7E,OAAO;AACX;AAEA,IAAM,oBAAY,IAAI,QAAoD;AAE1E,SAAS,EAAY,GAAmD;CACpE,IAAI,IAAO,EAAU,IAAI,CAAK;CAK9B,OAJK,MACD,IAAO,EAAc,EAAM,IAAK,GAChC,EAAU,IAAI,GAAO,CAAI,IAEtB;AACX;AAEA,SAAS,EAAe,EACpB,UACA,eACA,eAKD;CACC,IAAM,IAAU,OAAO,KAAU,aAAa,EAAM,IAAI;CACxD,OACI,kBAAC,GAAD;EAAY,MAAM;EAAqB;EAClC;CACO,CAAA;AAEpB;AAEA,SAAS,EAAgB,GAAyC;CAC9D,OAAO,EAAO,KAAK,GAAO,MAAM;EAC5B,IAAI,IAAqB,EAAM;EAC/B,IAAI,EAAM,MAAM;GACZ,IAAM,IAAgB,EAAY,CAAK;GACvC,IAAU,kBAAC,GAAD,CAAgB,CAAA;EAC9B;EAaA,OAZI,EAAM,UAAU,KAAA,MAChB,IACI,kBAAC,GAAD;GAAgB,OAAO,EAAM;GAAO,YAAY,EAAM;GACjD,UAAA;EACW,CAAA,IAIpB,EAAM,QACC,kBAAC,GAAD;GAA0B,OAAA;GAAe;EAAU,GAAvC,SAAS,GAA8B,IAI1D,kBAAC,GAAD;GAEI,MAAM,EAAM;GACH;GACT,eAAe,EAAM;GAEpB,UAAA,EAAM,WAAW,EAAgB,EAAM,QAAQ,IAAI;EACjD,GANE,EAAM,QAAQ,SAAS,GAMzB;CAEf,CAAC;AACL;AAEA,IAAM,IAAoD;CACtD,SAAS;CACT,MAAM;CACN,QAAQ;AACZ;AAyBA,SAAgB,EAAU,EACtB,WACA,YAAS,WACT,aACA,mBACA,cAAW,QACI;CACf,IAAM,IAAO,QAAc,EAAgB,CAAM,GAAG,CAAC,CAAM,CAAC,GACtD,IAAS,EAAQ;CAGvB,OACI,kBAAC,GAAD;EAAQ,GAHQ,MAAW,WAAW;GAAE;GAAU;EAAe,IAAI,EAAE,YAAS;EAI5E,UAAA,kBAAC,GAAD;GAAoB;GAChB,UAAA,kBAAC,GAAD,EAAA,UAAS,EAAa,CAAA;EAChB,CAAA;CACN,CAAA;AAEhB"}
1
+ {"version":3,"file":"AppRouter.js","names":[],"sources":["../../src/router/AppRouter.tsx"],"sourcesContent":["import { Suspense, useMemo } from \"react\";\nimport type { ComponentType, ReactNode } from \"react\";\nimport { BrowserRouter, HashRouter, MemoryRouter, Routes, Route } from \"react-router\";\nimport { lazyWithRetry } from \"../auth/lazy-with-retry\";\nimport { RouteGuard } from \"./RouteGuard\";\nimport type { RouteGuardResult, RouterKind, TempestRouteObject } from \"./types\";\n\n/**\n * Identity helper that types a declarative route tree. Use it so editors give\n * autocomplete and type-checking on every node; the array is returned as-is.\n *\n * @example\n * export const routes = defineRoutes([\n * { path: \"/\", element: <Layout />, children: [\n * { index: true, lazy: () => import(\"./pages/Home\") },\n * { path: \"settings\", lazy: () => import(\"./pages/Settings\"),\n * guard: () => useAuth.getState().isAuthenticated, redirectTo: \"/login\" },\n * ] },\n * ]);\n */\nexport function defineRoutes(routes: TempestRouteObject[]): TempestRouteObject[] {\n return routes;\n}\n\nconst lazyCache = new WeakMap<TempestRouteObject, ComponentType<unknown>>();\n\nfunction resolveLazy(route: TempestRouteObject): ComponentType<unknown> {\n let comp = lazyCache.get(route);\n if (!comp) {\n comp = lazyWithRetry(route.lazy!);\n lazyCache.set(route, comp);\n }\n return comp;\n}\n\n/**\n * Runs one route's `guard` and renders the outcome.\n *\n * The guard is called during this component's render, which is what lets it\n * call hooks — `useCan` returning `{ allowed, isLoading }` maps straight onto\n * the three outcomes. See {@link guardKey} for why each guarded route gets its\n * own instance.\n */\nfunction GuardedElement({\n guard,\n guardFallback,\n redirectTo,\n children,\n}: {\n guard: boolean | (() => RouteGuardResult);\n guardFallback?: ReactNode;\n redirectTo?: string;\n children: ReactNode;\n}) {\n const allowed = typeof guard === \"function\" ? guard() : guard;\n return (\n <RouteGuard when={allowed} fallback={guardFallback} redirectTo={redirectTo}>\n {children}\n </RouteGuard>\n );\n}\n\nconst guardKeys = new WeakMap<TempestRouteObject, string>();\nlet guardKeySeq = 0;\n\n/**\n * A key unique to each route object, so React remounts `GuardedElement` when\n * the matched route changes instead of reusing the instance.\n *\n * Load-bearing once guards may call hooks. React Router renders the matched\n * route's element at the same position in the tree, so without a differing key\n * React reconciles two different routes onto the same `GuardedElement`\n * instance and the previous route's guard state survives into the next one's —\n * a guard reading `useState(\"from-a\")` still reads `\"from-a\"` after navigating\n * to a route whose guard initialises it to `\"from-b\"`. Path is not enough on\n * its own: two routes in different branches can share one.\n */\nfunction guardKey(route: TempestRouteObject): string {\n let key = guardKeys.get(route);\n if (!key) {\n key = `guard-${++guardKeySeq}`;\n guardKeys.set(route, key);\n }\n return key;\n}\n\nfunction toRouteElements(routes: TempestRouteObject[], fallback: ReactNode): ReactNode {\n return routes.map((route, i) => {\n let element: ReactNode = route.element;\n if (route.lazy) {\n const LazyComponent = resolveLazy(route);\n element = <LazyComponent />;\n }\n if (route.guard !== undefined) {\n element = (\n <GuardedElement\n key={guardKey(route)}\n guard={route.guard}\n guardFallback={route.guardFallback ?? fallback}\n redirectTo={route.redirectTo}\n >\n {element}\n </GuardedElement>\n );\n }\n\n if (route.index) {\n return <Route key={`index-${i}`} index element={element} />;\n }\n\n return (\n <Route\n key={route.path ?? `route-${i}`}\n path={route.path}\n element={element}\n caseSensitive={route.caseSensitive}\n >\n {route.children ? toRouteElements(route.children, fallback) : null}\n </Route>\n );\n });\n}\n\nconst ROUTERS: Record<RouterKind, typeof BrowserRouter> = {\n browser: BrowserRouter,\n hash: HashRouter,\n memory: MemoryRouter,\n};\n\nexport interface AppRouterProps {\n /** Declarative route tree, ideally built with {@link defineRoutes}. */\n routes: TempestRouteObject[];\n /** History strategy (default: `\"browser\"`). */\n router?: RouterKind;\n /** App-wide base path forwarded to the underlying router. */\n basename?: string;\n /** Initial URLs for the `\"memory\"` router (tests / non-DOM hosts). */\n initialEntries?: string[];\n /**\n * Suspense fallback shown while a `lazy` route chunk loads, and the default\n * for a route whose `guard` answers `\"pending\"` — one spinner covers both\n * kinds of \"not ready yet\". A route overrides it with its own\n * `guardFallback`.\n */\n fallback?: ReactNode;\n}\n\n/**\n * Render a full React Router (v7 or v8, declarative mode) from a\n * {@link defineRoutes}\n * tree: picks the history strategy, wraps everything in a `<Suspense>` boundary\n * for `lazy` routes, and applies per-route `guard` redirects. This is the\n * single entry point apps mount at their root.\n *\n * @example\n * <AppRouter routes={routes} fallback={<Spinner />} />\n */\nexport function AppRouter({\n routes,\n router = \"browser\",\n basename,\n initialEntries,\n fallback = null,\n}: AppRouterProps) {\n const tree = useMemo(() => toRouteElements(routes, fallback), [routes, fallback]);\n const Router = ROUTERS[router];\n const routerProps = router === \"memory\" ? { basename, initialEntries } : { basename };\n\n return (\n <Router {...routerProps}>\n <Suspense fallback={fallback}>\n <Routes>{tree}</Routes>\n </Suspense>\n </Router>\n );\n}\n"],"mappings":";;;;;;AAoBA,SAAgB,EAAa,GAAoD;CAC7E,OAAO;AACX;AAEA,IAAM,oBAAY,IAAI,QAAoD;AAE1E,SAAS,EAAY,GAAmD;CACpE,IAAI,IAAO,EAAU,IAAI,CAAK;CAK9B,OAJK,MACD,IAAO,EAAc,EAAM,IAAK,GAChC,EAAU,IAAI,GAAO,CAAI,IAEtB;AACX;AAUA,SAAS,EAAe,EACpB,UACA,kBACA,eACA,eAMD;CACC,IAAM,IAAU,OAAO,KAAU,aAAa,EAAM,IAAI;CACxD,OACI,kBAAC,GAAD;EAAY,MAAM;EAAS,UAAU;EAA2B;EAC3D;CACO,CAAA;AAEpB;AAEA,IAAM,oBAAY,IAAI,QAAoC,GACtD,IAAc;AAclB,SAAS,EAAS,GAAmC;CACjD,IAAI,IAAM,EAAU,IAAI,CAAK;CAK7B,OAJK,MACD,IAAM,SAAS,EAAE,KACjB,EAAU,IAAI,GAAO,CAAG,IAErB;AACX;AAEA,SAAS,EAAgB,GAA8B,GAAgC;CACnF,OAAO,EAAO,KAAK,GAAO,MAAM;EAC5B,IAAI,IAAqB,EAAM;EAC/B,IAAI,EAAM,MAAM;GACZ,IAAM,IAAgB,EAAY,CAAK;GACvC,IAAU,kBAAC,GAAD,CAAgB,CAAA;EAC9B;EAkBA,OAjBI,EAAM,UAAU,KAAA,MAChB,IACI,kBAAC,GAAD;GAEI,OAAO,EAAM;GACb,eAAe,EAAM,iBAAiB;GACtC,YAAY,EAAM;GAEjB,UAAA;EACW,GANP,EAAS,CAAK,CAMP,IAIpB,EAAM,QACC,kBAAC,GAAD;GAA0B,OAAA;GAAe;EAAU,GAAvC,SAAS,GAA8B,IAI1D,kBAAC,GAAD;GAEI,MAAM,EAAM;GACH;GACT,eAAe,EAAM;GAEpB,UAAA,EAAM,WAAW,EAAgB,EAAM,UAAU,CAAQ,IAAI;EAC3D,GANE,EAAM,QAAQ,SAAS,GAMzB;CAEf,CAAC;AACL;AAEA,IAAM,IAAoD;CACtD,SAAS;CACT,MAAM;CACN,QAAQ;AACZ;AA8BA,SAAgB,EAAU,EACtB,WACA,YAAS,WACT,aACA,mBACA,cAAW,QACI;CACf,IAAM,IAAO,QAAc,EAAgB,GAAQ,CAAQ,GAAG,CAAC,GAAQ,CAAQ,CAAC,GAC1E,IAAS,EAAQ;CAGvB,OACI,kBAAC,GAAD;EAAQ,GAHQ,MAAW,WAAW;GAAE;GAAU;EAAe,IAAI,EAAE,YAAS;EAI5E,UAAA,kBAAC,GAAD;GAAoB;GAChB,UAAA,kBAAC,GAAD,EAAA,UAAS,EAAa,CAAA;EAChB,CAAA;CACN,CAAA;AAEhB"}
@@ -1,2 +1,2 @@
1
- let e=require("react/jsx-runtime"),t=require("react-router");function n({when:n,redirectTo:r=`/`,replace:i=!0,children:a}){return(0,e.jsx)(e.Fragment,{children:n?a:(0,e.jsx)(t.Navigate,{to:r,replace:i})})}exports.RouteGuard=n;
1
+ let e=require("react/jsx-runtime"),t=require("react-router");function n({when:n,fallback:r=null,redirectTo:i=`/`,replace:a=!0,children:o}){return n===`pending`?(0,e.jsx)(e.Fragment,{children:r}):(0,e.jsx)(e.Fragment,{children:n?o:(0,e.jsx)(t.Navigate,{to:i,replace:a})})}exports.RouteGuard=n;
2
2
  //# sourceMappingURL=RouteGuard.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"RouteGuard.cjs","names":[],"sources":["../../src/router/RouteGuard.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { Navigate } from \"react-router\";\n\nexport interface RouteGuardProps {\n /**\n * Whether access is allowed. Pass a boolean or anything truthy/falsy —\n * typically `useAuthStore((s) => s.isAuthenticated)`.\n */\n when: boolean;\n /** Where to redirect when `when` is falsy (default: `\"/\"`). */\n redirectTo?: string;\n /** Replace history entry on redirect instead of pushing (default: true). */\n replace?: boolean;\n /** Protected content, usually `<Outlet />` for a guarded layout route. */\n children: ReactNode;\n}\n\n/**\n * Declarative route guard built on React Router's `<Navigate>`. Renders its\n * children when `when` is truthy, otherwise redirects. Pairs naturally with\n * `createAuthStore` for protected areas.\n *\n * @example\n * <RouteGuard when={useAuthStore((s) => s.isAuthenticated)} redirectTo=\"/login\">\n * <Outlet />\n * </RouteGuard>\n */\nexport function RouteGuard({ when, redirectTo = \"/\", replace = true, children }: RouteGuardProps) {\n return <>{when ? children : <Navigate to={redirectTo} replace={replace} />}</>;\n}\n"],"mappings":"6DA2BA,SAAgB,EAAW,CAAE,OAAM,aAAa,IAAK,UAAU,GAAM,YAA6B,CAC9F,OAAO,EAAA,EAAA,IAAA,CAAA,EAAA,SAAA,CAAA,SAAG,EAAO,GAAW,EAAA,EAAA,IAAA,CAAC,EAAA,SAAD,CAAU,GAAI,EAAqB,SAAU,CAAA,CAAI,CAAA,CACjF"}
1
+ {"version":3,"file":"RouteGuard.cjs","names":[],"sources":["../../src/router/RouteGuard.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { Navigate } from \"react-router\";\nimport type { RouteGuardResult } from \"./types\";\n\nexport interface RouteGuardProps {\n /**\n * Whether access is allowed typically\n * `useAuthStore((s) => s.isAuthenticated)`.\n *\n * `\"pending\"` is the third answer, for a permission that has not resolved\n * yet: it holds the decision and renders {@link fallback} instead of\n * choosing between two wrong moves — redirecting someone who does have\n * access, or showing the screen to someone who does not.\n */\n when: RouteGuardResult;\n /**\n * Rendered while `when` is `\"pending\"`. Defaults to nothing, which is a\n * blank screen — pass the same spinner the rest of the app uses.\n */\n fallback?: ReactNode;\n /** Where to redirect when `when` is falsy (default: `\"/\"`). */\n redirectTo?: string;\n /** Replace history entry on redirect instead of pushing (default: true). */\n replace?: boolean;\n /** Protected content, usually `<Outlet />` for a guarded layout route. */\n children: ReactNode;\n}\n\n/**\n * Declarative route guard built on React Router's `<Navigate>`. Renders its\n * children when `when` is `true`, redirects when it is `false`, and holds on\n * `\"pending\"`. Pairs naturally with `createAuthStore` for protected areas, and\n * with `useCan` for permissions that resolve over the network.\n *\n * @example\n * <RouteGuard when={useAuthStore((s) => s.isAuthenticated)} redirectTo=\"/login\">\n * <Outlet />\n * </RouteGuard>\n *\n * @example\n * const { allowed, isLoading } = useCan({ action: \"read\", resource: \"finance\" });\n *\n * <RouteGuard when={isLoading ? \"pending\" : allowed} fallback={<Spinner />}>\n * <Outlet />\n * </RouteGuard>\n */\nexport function RouteGuard({\n when,\n fallback = null,\n redirectTo = \"/\",\n replace = true,\n children,\n}: RouteGuardProps) {\n if (when === \"pending\") return <>{fallback}</>;\n return <>{when ? children : <Navigate to={redirectTo} replace={replace} />}</>;\n}\n"],"mappings":"6DA8CA,SAAgB,EAAW,CACvB,OACA,WAAW,KACX,aAAa,IACb,UAAU,GACV,YACgB,CAEhB,OADI,IAAS,WAAkB,EAAA,EAAA,IAAA,CAAA,EAAA,SAAA,CAAA,SAAG,CAAW,CAAA,GACtC,EAAA,EAAA,IAAA,CAAA,EAAA,SAAA,CAAA,SAAG,EAAO,GAAW,EAAA,EAAA,IAAA,CAAC,EAAA,SAAD,CAAU,GAAI,EAAqB,SAAU,CAAA,CAAI,CAAA,CACjF"}
@@ -1,10 +1,10 @@
1
1
  import { Fragment as e, jsx as t } from "react/jsx-runtime";
2
2
  import { Navigate as n } from "react-router";
3
3
  //#region src/router/RouteGuard.tsx
4
- function r({ when: r, redirectTo: i = "/", replace: a = !0, children: o }) {
5
- return /* @__PURE__ */ t(e, { children: r ? o : /* @__PURE__ */ t(n, {
6
- to: i,
7
- replace: a
4
+ function r({ when: r, fallback: i = null, redirectTo: a = "/", replace: o = !0, children: s }) {
5
+ return r === "pending" ? /* @__PURE__ */ t(e, { children: i }) : /* @__PURE__ */ t(e, { children: r ? s : /* @__PURE__ */ t(n, {
6
+ to: a,
7
+ replace: o
8
8
  }) });
9
9
  }
10
10
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"RouteGuard.js","names":[],"sources":["../../src/router/RouteGuard.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { Navigate } from \"react-router\";\n\nexport interface RouteGuardProps {\n /**\n * Whether access is allowed. Pass a boolean or anything truthy/falsy —\n * typically `useAuthStore((s) => s.isAuthenticated)`.\n */\n when: boolean;\n /** Where to redirect when `when` is falsy (default: `\"/\"`). */\n redirectTo?: string;\n /** Replace history entry on redirect instead of pushing (default: true). */\n replace?: boolean;\n /** Protected content, usually `<Outlet />` for a guarded layout route. */\n children: ReactNode;\n}\n\n/**\n * Declarative route guard built on React Router's `<Navigate>`. Renders its\n * children when `when` is truthy, otherwise redirects. Pairs naturally with\n * `createAuthStore` for protected areas.\n *\n * @example\n * <RouteGuard when={useAuthStore((s) => s.isAuthenticated)} redirectTo=\"/login\">\n * <Outlet />\n * </RouteGuard>\n */\nexport function RouteGuard({ when, redirectTo = \"/\", replace = true, children }: RouteGuardProps) {\n return <>{when ? children : <Navigate to={redirectTo} replace={replace} />}</>;\n}\n"],"mappings":";;;AA2BA,SAAgB,EAAW,EAAE,SAAM,gBAAa,KAAK,aAAU,IAAM,eAA6B;CAC9F,OAAO,kBAAA,GAAA,EAAA,UAAG,IAAO,IAAW,kBAAC,GAAD;EAAU,IAAI;EAAqB;CAAU,CAAA,EAAI,CAAA;AACjF"}
1
+ {"version":3,"file":"RouteGuard.js","names":[],"sources":["../../src/router/RouteGuard.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { Navigate } from \"react-router\";\nimport type { RouteGuardResult } from \"./types\";\n\nexport interface RouteGuardProps {\n /**\n * Whether access is allowed typically\n * `useAuthStore((s) => s.isAuthenticated)`.\n *\n * `\"pending\"` is the third answer, for a permission that has not resolved\n * yet: it holds the decision and renders {@link fallback} instead of\n * choosing between two wrong moves — redirecting someone who does have\n * access, or showing the screen to someone who does not.\n */\n when: RouteGuardResult;\n /**\n * Rendered while `when` is `\"pending\"`. Defaults to nothing, which is a\n * blank screen — pass the same spinner the rest of the app uses.\n */\n fallback?: ReactNode;\n /** Where to redirect when `when` is falsy (default: `\"/\"`). */\n redirectTo?: string;\n /** Replace history entry on redirect instead of pushing (default: true). */\n replace?: boolean;\n /** Protected content, usually `<Outlet />` for a guarded layout route. */\n children: ReactNode;\n}\n\n/**\n * Declarative route guard built on React Router's `<Navigate>`. Renders its\n * children when `when` is `true`, redirects when it is `false`, and holds on\n * `\"pending\"`. Pairs naturally with `createAuthStore` for protected areas, and\n * with `useCan` for permissions that resolve over the network.\n *\n * @example\n * <RouteGuard when={useAuthStore((s) => s.isAuthenticated)} redirectTo=\"/login\">\n * <Outlet />\n * </RouteGuard>\n *\n * @example\n * const { allowed, isLoading } = useCan({ action: \"read\", resource: \"finance\" });\n *\n * <RouteGuard when={isLoading ? \"pending\" : allowed} fallback={<Spinner />}>\n * <Outlet />\n * </RouteGuard>\n */\nexport function RouteGuard({\n when,\n fallback = null,\n redirectTo = \"/\",\n replace = true,\n children,\n}: RouteGuardProps) {\n if (when === \"pending\") return <>{fallback}</>;\n return <>{when ? children : <Navigate to={redirectTo} replace={replace} />}</>;\n}\n"],"mappings":";;;AA8CA,SAAgB,EAAW,EACvB,SACA,cAAW,MACX,gBAAa,KACb,aAAU,IACV,eACgB;CAEhB,OADI,MAAS,YAAkB,kBAAA,GAAA,EAAA,UAAG,EAAW,CAAA,IACtC,kBAAA,GAAA,EAAA,UAAG,IAAO,IAAW,kBAAC,GAAD;EAAU,IAAI;EAAqB;CAAU,CAAA,EAAI,CAAA;AACjF"}
@@ -1,2 +1,2 @@
1
- function e(e){try{return JSON.parse(e)}catch{return e}}function t(t,n={}){let{withCredentials:r=!1,namedEvents:i=[],heartbeatEvents:a=[`ping`],maxRetries:o=10,initialBackoff:s=1e3,maxBackoff:c=3e4,parser:l=e,onOpen:u,onMessage:d,onError:f,onStatusChange:p}=n,m=null,h=null,g=0,_=`idle`,v=!1;function y(e){_!==e&&(_=e,p?.(e))}function b(e,t){a.includes(e)||d?.({event:e,data:l(t.data),id:t.lastEventId||void 0,raw:t})}function x(){if(v)return;if(g>=o){y(`error`);return}let e=Math.min(s*2**g,c);g+=1,h=setTimeout(S,e)}function S(){if(v)return;m&&m.close(),y(`connecting`);let e=new EventSource(t,{withCredentials:r});m=e,e.onopen=()=>{g=0,y(`open`),u?.()},e.onmessage=e=>b(`message`,e);for(let t of i)e.addEventListener(t,e=>b(t,e));for(let t of a)e.addEventListener(t,()=>{});e.onerror=t=>{f?.(t),e.close(),m=null,y(`closed`),x()}}function C(){v=!0,h&&=(clearTimeout(h),null),g=0,m&&=(m.close(),null),y(`closed`)}function w(){h&&=(clearTimeout(h),null),g=0,v=!1,S()}return S(),{close:C,reconnect:w,get status(){return _}}}exports.createEventStream=t;
1
+ const e=require("../utils/json-frame.cjs");function t(t,n={}){let{withCredentials:r=!1,namedEvents:i=[],heartbeatEvents:a=[`ping`],maxRetries:o=10,initialBackoff:s=1e3,maxBackoff:c=3e4,parser:l,onOpen:u,onMessage:d,onError:f,onParseError:p,onStatusChange:m}=n,h=null,g=null,_=0,v=`idle`,y=!1;function b(e){v!==e&&(v=e,m?.(e))}function x(t,n){if(a.includes(t))return;let r=e.decodeFrame(typeof n.data==`string`?n.data:``,l,p,`createEventStream`);r.delivered&&d?.({event:t,data:r.data,id:n.lastEventId||void 0,raw:n})}function S(){if(y)return;if(_>=o){b(`error`);return}let e=Math.min(s*2**_,c);_+=1,g=setTimeout(C,e)}function C(){if(y)return;h&&h.close(),b(`connecting`);let e=new EventSource(t,{withCredentials:r});h=e,e.onopen=()=>{_=0,b(`open`),u?.()},e.onmessage=e=>x(`message`,e);for(let t of i)e.addEventListener(t,e=>x(t,e));for(let t of a)e.addEventListener(t,()=>{});e.onerror=t=>{f?.(t),e.close(),h=null,b(`closed`),S()}}function w(){y=!0,g&&=(clearTimeout(g),null),_=0,h&&=(h.close(),null),b(`closed`)}function T(){g&&=(clearTimeout(g),null),_=0,y=!1,C()}return C(),{close:w,reconnect:T,get status(){return v}}}exports.createEventStream=t;
2
2
  //# sourceMappingURL=create-event-stream.cjs.map