@dxtmisha/wiki 0.39.7 → 0.56.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 (227) hide show
  1. package/dist/{defineProperty-DblGXmzD.js → defineProperty-149Ahniv.js} +4 -4
  2. package/dist/library.js +1 -1
  3. package/dist/media/descriptions/wikiDescriptionsArea.d.ts +7 -0
  4. package/dist/media/descriptions/wikiDescriptionsClientOnly.d.ts +7 -0
  5. package/dist/media/descriptions/wikiDescriptionsContainer.d.ts +7 -0
  6. package/dist/media/descriptions/wikiDescriptionsHeader.d.ts +7 -0
  7. package/dist/media/descriptions/wikiDescriptionsPageArea.d.ts +7 -0
  8. package/dist/media/mdx/Area/wikiMdxArea.d.ts +7 -0
  9. package/dist/media/mdx/ClientOnly/wikiMdxClientOnly.d.ts +7 -0
  10. package/dist/media/mdx/Container/wikiMdxContainer.d.ts +7 -0
  11. package/dist/media/mdx/Header/wikiMdxHeader.d.ts +7 -0
  12. package/dist/media/mdx/PageArea/wikiMdxPageArea.d.ts +7 -0
  13. package/dist/media.d.ts +1 -1
  14. package/dist/media.js +127 -68
  15. package/dist/storybook.js +2707 -1841
  16. package/dist/{wikiDescriptions-Cv4WzSNL.js → wikiDescriptions-7XaHU3Yk.js} +182 -0
  17. package/package.json +1 -1
  18. package/src/media/functional/functional/composables/useApiAsyncRef/useApiAsyncRef.en.mdx +43 -0
  19. package/src/media/functional/functional/composables/useApiAsyncRef/useApiAsyncRef.ru.mdx +43 -0
  20. package/src/media/functional/functional/composables/useApiAsyncRef/useApiAsyncRef.vi.mdx +41 -0
  21. package/src/media/functional/functional/composables/useApiRef/useApiRef.en.mdx +20 -4
  22. package/src/media/functional/functional/composables/useApiRef/useApiRef.ru.mdx +21 -3
  23. package/src/media/functional/functional/composables/useApiRef/useApiRef.vi.mdx +20 -2
  24. package/src/media/functional/functional/functions/computedAsync/computedAsync.en.mdx +8 -0
  25. package/src/media/functional/functional/functions/computedAsync/computedAsync.ru.mdx +8 -0
  26. package/src/media/functional/functional/functions/computedAsync/computedAsync.vi.mdx +8 -0
  27. package/src/media/functional/functional/functions/computedEternity/computedEternity.en.mdx +8 -0
  28. package/src/media/functional/functional/functions/computedEternity/computedEternity.ru.mdx +8 -0
  29. package/src/media/functional/functional/functions/computedEternity/computedEternity.vi.mdx +8 -0
  30. package/src/media/functional/functional-basic/api/api.en.mdx +45 -0
  31. package/src/media/functional/functional-basic/api/api.ru.mdx +45 -0
  32. package/src/media/functional/functional-basic/api/api.vi.mdx +45 -0
  33. package/src/media/functional/functional-basic/classes/Api/Api.en.mdx +57 -54
  34. package/src/media/functional/functional-basic/classes/Api/Api.ru.mdx +57 -54
  35. package/src/media/functional/functional-basic/classes/Api/Api.vi.mdx +57 -54
  36. package/src/media/functional/functional-basic/classes/ApiCache/ApiCache.en.mdx +111 -0
  37. package/src/media/functional/functional-basic/classes/ApiCache/ApiCache.ru.mdx +111 -0
  38. package/src/media/functional/functional-basic/classes/ApiCache/ApiCache.vi.mdx +111 -0
  39. package/src/media/functional/functional-basic/classes/ApiDataReturn/ApiDataReturn.en.mdx +32 -0
  40. package/src/media/functional/functional-basic/classes/ApiDataReturn/ApiDataReturn.ru.mdx +32 -0
  41. package/src/media/functional/functional-basic/classes/ApiDataReturn/ApiDataReturn.vi.mdx +32 -0
  42. package/src/media/functional/functional-basic/classes/ApiDefault/ApiDefault.en.mdx +24 -28
  43. package/src/media/functional/functional-basic/classes/ApiDefault/ApiDefault.ru.mdx +24 -28
  44. package/src/media/functional/functional-basic/classes/ApiDefault/ApiDefault.vi.mdx +24 -28
  45. package/src/media/functional/functional-basic/classes/ApiHeaders/ApiHeaders.en.mdx +28 -14
  46. package/src/media/functional/functional-basic/classes/ApiHeaders/ApiHeaders.ru.mdx +33 -19
  47. package/src/media/functional/functional-basic/classes/ApiHeaders/ApiHeaders.vi.mdx +33 -19
  48. package/src/media/functional/functional-basic/classes/ApiHydration/ApiHydration.en.mdx +56 -0
  49. package/src/media/functional/functional-basic/classes/ApiHydration/ApiHydration.ru.mdx +56 -0
  50. package/src/media/functional/functional-basic/classes/ApiHydration/ApiHydration.vi.mdx +55 -0
  51. package/src/media/functional/functional-basic/classes/ApiInstance/ApiInstance.en.mdx +106 -51
  52. package/src/media/functional/functional-basic/classes/ApiInstance/ApiInstance.ru.mdx +107 -52
  53. package/src/media/functional/functional-basic/classes/ApiInstance/ApiInstance.vi.mdx +103 -49
  54. package/src/media/functional/functional-basic/classes/ApiPreparation/ApiPreparation.en.mdx +44 -26
  55. package/src/media/functional/functional-basic/classes/ApiPreparation/ApiPreparation.ru.mdx +45 -27
  56. package/src/media/functional/functional-basic/classes/ApiPreparation/ApiPreparation.vi.mdx +44 -26
  57. package/src/media/functional/functional-basic/classes/ApiResponse/ApiResponse.en.mdx +59 -21
  58. package/src/media/functional/functional-basic/classes/ApiResponse/ApiResponse.ru.mdx +63 -25
  59. package/src/media/functional/functional-basic/classes/ApiResponse/ApiResponse.vi.mdx +64 -26
  60. package/src/media/functional/functional-basic/classes/ApiStatus/ApiStatus.en.mdx +29 -32
  61. package/src/media/functional/functional-basic/classes/ApiStatus/ApiStatus.ru.mdx +33 -36
  62. package/src/media/functional/functional-basic/classes/ApiStatus/ApiStatus.vi.mdx +33 -36
  63. package/src/media/functional/functional-basic/classes/BroadcastMessage/BroadcastMessage.en.mdx +34 -53
  64. package/src/media/functional/functional-basic/classes/BroadcastMessage/BroadcastMessage.ru.mdx +33 -52
  65. package/src/media/functional/functional-basic/classes/BroadcastMessage/BroadcastMessage.vi.mdx +39 -58
  66. package/src/media/functional/functional-basic/classes/Cache/Cache.en.mdx +7 -4
  67. package/src/media/functional/functional-basic/classes/Cache/Cache.ru.mdx +7 -4
  68. package/src/media/functional/functional-basic/classes/Cache/Cache.vi.mdx +28 -25
  69. package/src/media/functional/functional-basic/classes/CacheItem/CacheItem.en.mdx +45 -53
  70. package/src/media/functional/functional-basic/classes/CacheItem/CacheItem.ru.mdx +46 -54
  71. package/src/media/functional/functional-basic/classes/CacheItem/CacheItem.vi.mdx +47 -55
  72. package/src/media/functional/functional-basic/classes/CacheStatic/CacheStatic.en.mdx +13 -1
  73. package/src/media/functional/functional-basic/classes/CacheStatic/CacheStatic.ru.mdx +13 -1
  74. package/src/media/functional/functional-basic/classes/CacheStatic/CacheStatic.vi.mdx +13 -0
  75. package/src/media/functional/functional-basic/classes/Cookie/Cookie.en.mdx +88 -44
  76. package/src/media/functional/functional-basic/classes/Cookie/Cookie.ru.mdx +88 -44
  77. package/src/media/functional/functional-basic/classes/Cookie/Cookie.vi.mdx +85 -41
  78. package/src/media/functional/functional-basic/classes/CookieBlock/CookieBlock.en.mdx +43 -22
  79. package/src/media/functional/functional-basic/classes/CookieBlock/CookieBlock.ru.mdx +46 -25
  80. package/src/media/functional/functional-basic/classes/CookieBlock/CookieBlock.vi.mdx +43 -22
  81. package/src/media/functional/functional-basic/classes/CookieBlockInstance/CookieBlockInstance.en.mdx +84 -0
  82. package/src/media/functional/functional-basic/classes/CookieBlockInstance/CookieBlockInstance.ru.mdx +84 -0
  83. package/src/media/functional/functional-basic/classes/CookieBlockInstance/CookieBlockInstance.vi.mdx +100 -0
  84. package/src/media/functional/functional-basic/classes/CookieStorage/CookieStorage.en.mdx +178 -0
  85. package/src/media/functional/functional-basic/classes/CookieStorage/CookieStorage.ru.mdx +178 -0
  86. package/src/media/functional/functional-basic/classes/CookieStorage/CookieStorage.vi.mdx +178 -0
  87. package/src/media/functional/functional-basic/classes/DataStorage/DataStorage.en.mdx +32 -25
  88. package/src/media/functional/functional-basic/classes/DataStorage/DataStorage.ru.mdx +32 -25
  89. package/src/media/functional/functional-basic/classes/DataStorage/DataStorage.vi.mdx +32 -27
  90. package/src/media/functional/functional-basic/classes/Datetime/Datetime.en.mdx +36 -4
  91. package/src/media/functional/functional-basic/classes/Datetime/Datetime.ru.mdx +36 -4
  92. package/src/media/functional/functional-basic/classes/Datetime/Datetime.vi.mdx +36 -4
  93. package/src/media/functional/functional-basic/classes/ErrorCenter/ErrorCenter.en.mdx +101 -70
  94. package/src/media/functional/functional-basic/classes/ErrorCenter/ErrorCenter.ru.mdx +100 -69
  95. package/src/media/functional/functional-basic/classes/ErrorCenter/ErrorCenter.vi.mdx +101 -70
  96. package/src/media/functional/functional-basic/classes/ErrorCenterHandler/ErrorCenterHandler.en.mdx +46 -42
  97. package/src/media/functional/functional-basic/classes/ErrorCenterHandler/ErrorCenterHandler.ru.mdx +46 -42
  98. package/src/media/functional/functional-basic/classes/ErrorCenterHandler/ErrorCenterHandler.vi.mdx +46 -42
  99. package/src/media/functional/functional-basic/classes/ErrorCenterInstance/ErrorCenterInstance.en.mdx +44 -96
  100. package/src/media/functional/functional-basic/classes/ErrorCenterInstance/ErrorCenterInstance.ru.mdx +44 -96
  101. package/src/media/functional/functional-basic/classes/ErrorCenterInstance/ErrorCenterInstance.vi.mdx +44 -96
  102. package/src/media/functional/functional-basic/classes/EventItem/EventItem.en.mdx +49 -28
  103. package/src/media/functional/functional-basic/classes/EventItem/EventItem.ru.mdx +21 -0
  104. package/src/media/functional/functional-basic/classes/EventItem/EventItem.vi.mdx +63 -42
  105. package/src/media/functional/functional-basic/classes/Formatters/Formatters.en.mdx +97 -109
  106. package/src/media/functional/functional-basic/classes/Formatters/Formatters.ru.mdx +86 -98
  107. package/src/media/functional/functional-basic/classes/Formatters/Formatters.vi.mdx +99 -111
  108. package/src/media/functional/functional-basic/classes/Geo/Geo.en.mdx +3 -3
  109. package/src/media/functional/functional-basic/classes/Geo/Geo.ru.mdx +5 -5
  110. package/src/media/functional/functional-basic/classes/Geo/Geo.vi.mdx +5 -5
  111. package/src/media/functional/functional-basic/classes/GeoFlag/GeoFlag.en.mdx +83 -40
  112. package/src/media/functional/functional-basic/classes/GeoFlag/GeoFlag.ru.mdx +83 -40
  113. package/src/media/functional/functional-basic/classes/GeoFlag/GeoFlag.vi.mdx +87 -44
  114. package/src/media/functional/functional-basic/classes/GeoInstance/GeoInstance.en.mdx +81 -0
  115. package/src/media/functional/functional-basic/classes/GeoInstance/GeoInstance.ru.mdx +81 -0
  116. package/src/media/functional/functional-basic/classes/GeoInstance/GeoInstance.vi.mdx +81 -0
  117. package/src/media/functional/functional-basic/classes/GeoPhone/GeoPhone.en.mdx +56 -105
  118. package/src/media/functional/functional-basic/classes/GeoPhone/GeoPhone.ru.mdx +53 -102
  119. package/src/media/functional/functional-basic/classes/GeoPhone/GeoPhone.vi.mdx +55 -105
  120. package/src/media/functional/functional-basic/classes/Hash/Hash.en.mdx +18 -7
  121. package/src/media/functional/functional-basic/classes/Hash/Hash.ru.mdx +18 -7
  122. package/src/media/functional/functional-basic/classes/Hash/Hash.vi.mdx +18 -7
  123. package/src/media/functional/functional-basic/classes/HashInstance/HashInstance.en.mdx +54 -0
  124. package/src/media/functional/functional-basic/classes/HashInstance/HashInstance.ru.mdx +54 -0
  125. package/src/media/functional/functional-basic/classes/HashInstance/HashInstance.vi.mdx +54 -0
  126. package/src/media/functional/functional-basic/classes/Meta/Meta.en.mdx +16 -0
  127. package/src/media/functional/functional-basic/classes/Meta/Meta.ru.mdx +16 -0
  128. package/src/media/functional/functional-basic/classes/Meta/Meta.vi.mdx +17 -1
  129. package/src/media/functional/functional-basic/classes/MetaManager/MetaManager.en.mdx +9 -0
  130. package/src/media/functional/functional-basic/classes/MetaManager/MetaManager.ru.mdx +9 -0
  131. package/src/media/functional/functional-basic/classes/MetaManager/MetaManager.vi.mdx +9 -0
  132. package/src/media/functional/functional-basic/classes/MetaStatic/MetaStatic.en.mdx +79 -0
  133. package/src/media/functional/functional-basic/classes/MetaStatic/MetaStatic.ru.mdx +79 -0
  134. package/src/media/functional/functional-basic/classes/MetaStatic/MetaStatic.vi.mdx +79 -0
  135. package/src/media/functional/functional-basic/classes/ResumableTimer/ResumableTimer.en.mdx +50 -0
  136. package/src/media/functional/functional-basic/classes/ResumableTimer/ResumableTimer.ru.mdx +50 -0
  137. package/src/media/functional/functional-basic/classes/ResumableTimer/ResumableTimer.vi.mdx +50 -0
  138. package/src/media/functional/functional-basic/classes/ServerStorage/ServerStorage.en.mdx +131 -0
  139. package/src/media/functional/functional-basic/classes/ServerStorage/ServerStorage.ru.mdx +131 -0
  140. package/src/media/functional/functional-basic/classes/ServerStorage/ServerStorage.vi.mdx +131 -0
  141. package/src/media/functional/functional-basic/classes/StorageCallback/StorageCallback.en.mdx +97 -0
  142. package/src/media/functional/functional-basic/classes/StorageCallback/StorageCallback.ru.mdx +97 -0
  143. package/src/media/functional/functional-basic/classes/StorageCallback/StorageCallback.vi.mdx +97 -0
  144. package/src/media/functional/functional-basic/functions/addTagHighlightMatch/addTagHighlightMatch.en.mdx +13 -5
  145. package/src/media/functional/functional-basic/functions/addTagHighlightMatch/addTagHighlightMatch.ru.mdx +13 -5
  146. package/src/media/functional/functional-basic/functions/addTagHighlightMatch/addTagHighlightMatch.vi.mdx +13 -5
  147. package/src/media/functional/functional-basic/functions/anyToString/anyToString.en.mdx +37 -19
  148. package/src/media/functional/functional-basic/functions/anyToString/anyToString.ru.mdx +37 -19
  149. package/src/media/functional/functional-basic/functions/anyToString/anyToString.vi.mdx +35 -17
  150. package/src/media/functional/functional-basic/functions/applyTemplate/applyTemplate.en.mdx +31 -19
  151. package/src/media/functional/functional-basic/functions/applyTemplate/applyTemplate.ru.mdx +31 -19
  152. package/src/media/functional/functional-basic/functions/applyTemplate/applyTemplate.vi.mdx +32 -20
  153. package/src/media/functional/functional-basic/functions/blobToBase64/blobToBase64.en.mdx +29 -15
  154. package/src/media/functional/functional-basic/functions/blobToBase64/blobToBase64.ru.mdx +28 -14
  155. package/src/media/functional/functional-basic/functions/blobToBase64/blobToBase64.vi.mdx +28 -14
  156. package/src/media/functional/functional-basic/functions/capitalize/capitalize.en.mdx +7 -3
  157. package/src/media/functional/functional-basic/functions/capitalize/capitalize.ru.mdx +7 -3
  158. package/src/media/functional/functional-basic/functions/capitalize/capitalize.vi.mdx +7 -3
  159. package/src/media/functional/functional-basic/functions/copyObject/copyObject.en.mdx +17 -13
  160. package/src/media/functional/functional-basic/functions/copyObject/copyObject.ru.mdx +17 -13
  161. package/src/media/functional/functional-basic/functions/copyObject/copyObject.vi.mdx +17 -13
  162. package/src/media/functional/functional-basic/functions/createElement/createElement.en.mdx +2 -0
  163. package/src/media/functional/functional-basic/functions/createElement/createElement.ru.mdx +2 -0
  164. package/src/media/functional/functional-basic/functions/createElement/createElement.vi.mdx +2 -0
  165. package/src/media/functional/functional-basic/functions/encodeAttribute/encodeAttribute.en.mdx +1 -3
  166. package/src/media/functional/functional-basic/functions/encodeAttribute/encodeAttribute.ru.mdx +1 -3
  167. package/src/media/functional/functional-basic/functions/encodeAttribute/encodeAttribute.vi.mdx +1 -3
  168. package/src/media/functional/functional-basic/functions/executeFunction/executeFunction.en.mdx +13 -10
  169. package/src/media/functional/functional-basic/functions/executeFunction/executeFunction.ru.mdx +14 -11
  170. package/src/media/functional/functional-basic/functions/executeFunction/executeFunction.vi.mdx +12 -9
  171. package/src/media/functional/functional-basic/functions/executePromise/executePromise.en.mdx +14 -13
  172. package/src/media/functional/functional-basic/functions/executePromise/executePromise.ru.mdx +15 -14
  173. package/src/media/functional/functional-basic/functions/executePromise/executePromise.vi.mdx +14 -13
  174. package/src/media/functional/functional-basic/functions/forEach/forEach.en.mdx +1 -1
  175. package/src/media/functional/functional-basic/functions/forEach/forEach.ru.mdx +1 -1
  176. package/src/media/functional/functional-basic/functions/forEach/forEach.vi.mdx +1 -1
  177. package/src/media/functional/functional-basic/functions/frame/frame.en.mdx +7 -4
  178. package/src/media/functional/functional-basic/functions/frame/frame.ru.mdx +6 -3
  179. package/src/media/functional/functional-basic/functions/frame/frame.vi.mdx +7 -4
  180. package/src/media/functional/functional-basic/functions/getArrayHighlightMatch/getArrayHighlightMatch.en.mdx +34 -0
  181. package/src/media/functional/functional-basic/functions/getArrayHighlightMatch/getArrayHighlightMatch.ru.mdx +34 -0
  182. package/src/media/functional/functional-basic/functions/getArrayHighlightMatch/getArrayHighlightMatch.vi.mdx +35 -0
  183. package/src/media/functional/functional-basic/functions/getCurrentDate/getCurrentDate.en.mdx +2 -0
  184. package/src/media/functional/functional-basic/functions/getCurrentDate/getCurrentDate.ru.mdx +2 -0
  185. package/src/media/functional/functional-basic/functions/getCurrentDate/getCurrentDate.vi.mdx +2 -0
  186. package/src/media/functional/functional-basic/functions/getCurrentTime/getCurrentTime.en.mdx +21 -0
  187. package/src/media/functional/functional-basic/functions/getCurrentTime/getCurrentTime.ru.mdx +21 -0
  188. package/src/media/functional/functional-basic/functions/getCurrentTime/getCurrentTime.vi.mdx +21 -0
  189. package/src/media/functional/functional-basic/functions/getElementId/getElementId.en.mdx +17 -3
  190. package/src/media/functional/functional-basic/functions/getElementId/getElementId.ru.mdx +17 -3
  191. package/src/media/functional/functional-basic/functions/getElementId/getElementId.vi.mdx +18 -4
  192. package/src/media/functional/functional-basic/functions/getElementSafeScript/getElementSafeScript.en.mdx +31 -0
  193. package/src/media/functional/functional-basic/functions/getElementSafeScript/getElementSafeScript.ru.mdx +31 -0
  194. package/src/media/functional/functional-basic/functions/getElementSafeScript/getElementSafeScript.vi.mdx +31 -0
  195. package/src/media/functional/functional-basic/functions/getOnlyText/getOnlyText.en.mdx +25 -0
  196. package/src/media/functional/functional-basic/functions/getOnlyText/getOnlyText.ru.mdx +25 -0
  197. package/src/media/functional/functional-basic/functions/getOnlyText/getOnlyText.vi.mdx +25 -0
  198. package/src/media/functional/functional-basic/functions/getSearchExp/getSearchExp.en.mdx +11 -4
  199. package/src/media/functional/functional-basic/functions/getSearchExp/getSearchExp.ru.mdx +14 -7
  200. package/src/media/functional/functional-basic/functions/getSearchExp/getSearchExp.vi.mdx +13 -6
  201. package/src/media/functional/functional-basic/functions/getSeparatingSearchExp/getSeparatingSearchExp.en.mdx +3 -2
  202. package/src/media/functional/functional-basic/functions/getSeparatingSearchExp/getSeparatingSearchExp.ru.mdx +3 -2
  203. package/src/media/functional/functional-basic/functions/getSeparatingSearchExp/getSeparatingSearchExp.vi.mdx +3 -2
  204. package/src/media/functional/functional-basic/functions/toNumber/toNumber.en.mdx +25 -9
  205. package/src/media/functional/functional-basic/functions/toNumber/toNumber.ru.mdx +25 -9
  206. package/src/media/functional/functional-basic/functions/toNumber/toNumber.vi.mdx +25 -9
  207. package/src/media/functional/functional-basic/functions/toString/toString.en.mdx +28 -0
  208. package/src/media/functional/functional-basic/functions/toString/toString.ru.mdx +28 -0
  209. package/src/media/functional/functional-basic/functions/toString/toString.vi.mdx +28 -0
  210. package/src/media/functional/functional-basic/icons/icons.en.mdx +3 -0
  211. package/src/media/functional/functional-basic/icons/icons.ru.mdx +3 -0
  212. package/src/media/functional/functional-basic/icons/icons.vi.mdx +3 -0
  213. package/src/media/functional/nitro-basic/functions/getInject.en.mdx +27 -0
  214. package/src/media/functional/nitro-basic/functions/getInject.ru.mdx +27 -0
  215. package/src/media/functional/nitro-basic/functions/getInject.vi.mdx +20 -0
  216. package/src/media/functional/ui/about/about.en.mdx +45 -0
  217. package/src/media/functional/ui/about/about.ru.mdx +45 -0
  218. package/src/media/functional/ui/about/about.vi.mdx +45 -0
  219. package/src/media/functional/ui/component/component.en.mdx +104 -0
  220. package/src/media/functional/ui/component/component.ru.mdx +106 -0
  221. package/src/media/functional/ui/component/component.vi.mdx +104 -0
  222. package/src/media/functional/ui/setup/setup.en.mdx +72 -0
  223. package/src/media/functional/ui/setup/setup.ru.mdx +72 -0
  224. package/src/media/functional/ui/setup/setup.vi.mdx +72 -0
  225. package/src/media/functional/ui/wiki-data.en.mdx +114 -0
  226. package/src/media/functional/ui/wiki-data.ru.mdx +114 -0
  227. package/src/media/functional/ui/wiki-data.vi.mdx +114 -0
@@ -6,23 +6,31 @@ import {Meta} from '@storybook/addon-docs/blocks'
6
6
 
7
7
  Một lớp linh hoạt để tương tác với `localStorage` và `sessionStorage` của trình duyệt. Nó bao gồm các tiền tố được tích hợp sẵn, thời gian hết hạn bộ đệm (cache), lưu vào bộ nhớ đệm (memory caching) cho các bản sao hoạt động và chuyển đổi JSON tự động.
8
8
 
9
+ > `DataStorage` là một **lớp phụ trợ**, được thiết kế để tương tác cấp thấp với bộ nhớ trình duyệt. Trong hầu hết các trường hợp, bạn nên sử dụng các lớp cấp cao hơn như `Cookie` hoặc `Api` cho các nhu cầu dữ liệu cụ thể.
10
+
9
11
  ## Tính năng chính
10
12
 
11
13
  - **Chuyển đổi Tự động** — tự động xử lý phân tích và chuyển đổi chuỗi JSON cho các cấu hình và đối tượng được lưu trữ.
12
14
  - **Bộ nhớ đệm Dựa trên Thời gian** — cho phép lưu các đối tượng cùng với mốc thời gian và tôn trọng các ràng buộc về tuổi đời (age) của dữ liệu trong quá trình truy xuất.
13
15
  - **Quản lý Tiền tố** — hỗ trợ cả tiền tố toàn cục và riêng biệt để cách ly cũng như gom nhóm các khóa trong `localStorage`.
14
- - **Tối ưu nhớ** — tạo ra các singleton cho những khóa giống nhau nhằm tránh các thao tác đọc đĩa bị lặp lại.
16
+ - **Tối ưu Bộ nhớ** — tạo ra các singleton cho những khóa giống nhau nhằm tránh các thao tác đọc đĩa bị lặp lại.
17
+ - **Hỗ trợ SSR** — sử dụng cơ chế cách ly theo từng request trong quá trình render phía server để ngăn chặn rò rỉ dữ liệu giữa các phiên làm việc song song.
15
18
 
16
19
  ## Khởi tạo
17
20
 
18
21
  Để khởi tạo đối tượng, hãy gọi hàm khởi tạo `DataStorage(name, isSession)`.
19
22
 
23
+ ### Ràng buộc Generic (Generic Constraints)
24
+
25
+ Lớp hỗ trợ generic sau để đảm bảo kiểm soát kiểu dữ liệu nghiêm ngặt cho giá trị được lưu trữ:
26
+ - `T` — Kiểu dữ liệu của giá trị được lưu trữ.
27
+
20
28
  **Tham số:**
21
29
  - `name: string` — tên của khóa lưu trữ.
22
30
  - `isSession: boolean = false` — có sử dụng `sessionStorage` hay không (mặc định là `localStorage`).
23
31
 
24
32
  ```typescript
25
- import { DataStorage } from '@dxtmisha/functional'
33
+ import { DataStorage } from '@dxtmisha/functional-basic'
26
34
 
27
35
  // 1. Tạo một thực thể cho localStorage
28
36
  const settings = new DataStorage('settings')
@@ -31,25 +39,31 @@ const settings = new DataStorage('settings')
31
39
  const session = new DataStorage('user_session', true)
32
40
  ```
33
41
 
34
- ## Cách sử dụng Cơ bản
42
+ ## Các phương thức
35
43
 
36
- ## Cấu hình toàn cục
44
+ ### Truy cập Bộ lưu trữ
37
45
 
38
- - `setPrefix(newPrefix: string): void` (static) Thay đổi tên tiền tố toàn cục áp dụng cho những instance mới đang định dùng môi trường `localStorage`. Giá trị tiền tố mặc định `ui-storage`.
46
+ - `get(defaultValue?: T | (() => T), cache?: number): T | undefined` Truy xuất giá trị hiện được lưu trữ. Nếu thời gian cache được cung cấp, sẽ trả về `undefined` nếu dữ liệu đã quá hạn.
47
+ - `set(value?: T | (() => T)): T | undefined` — Thiết lập hoặc cập nhật giá trị trong cơ chế lưu trữ. Truyền `undefined` sẽ xóa mục đó.
48
+ - `remove(): this` — Xóa khóa tương ứng khỏi môi trường lưu trữ và thực thể trong bộ nhớ.
49
+ - `update(): this` — Buộc thực thể bộ nhớ phải đồng bộ hóa với dữ liệu thô hiện tại bên trong các Storage API vật lý.
39
50
 
40
- ## Quản lý dữ liệu
51
+ ### Cấu hình
41
52
 
42
- ### `get`
53
+ - `static setPrefix(newPrefix: string): void` — Thay đổi tiền tố toàn cục áp dụng cho các thực thể mới. Tiền tố mặc định là `ui-storage`.
43
54
 
44
- Truy xuất cấu hình đã phân tích hiện tại được lưu lại từ trước.
55
+ ## SSR Hydration
45
56
 
46
- **Tham số:**
47
- - `defaultValue?: T | (() => T)` — giá trị dự phòng được trả về nếu bên trong bộ lưu trữ trống rỗng.
48
- - `cache?: number` — độ tuổi tối đa cho phép (tính bằng giây). Nếu dữ liệu đã cũ hơn mức này, nó sẽ cư xử như thể không có gì được lưu trữ.
57
+ Lớp `DataStorage` hoàn toàn tương thích với Server-Side Rendering (SSR). Nó sử dụng một registry đặc biệt để cách ly các instance giữa các HTTP request khác nhau trên server.
49
58
 
50
- **Trả về:** `T | undefined` giá trị được lưu trữ hoặc `undefined`.
59
+ > Để tránh lỗi hydration (khi HTML render từ server khác với client), bạn nên gọi phương thức `get()` bên trong `useEffect` hoặc các hook chỉ chạy client. Trên server, `get()` sẽ luôn trả về `undefined` (hoặc `defaultValue`) vì `localStorage` không khả dụng.
51
60
 
61
+ ## Ví dụ
62
+
63
+ ### Sử dụng Giá trị Mặc định và Cache
52
64
  ```javascript
65
+ const settings = new DataStorage('user_settings')
66
+
53
67
  // Lấy dữ liệu, trả về object rỗng nếu không tìm thấy
54
68
  const currentSettings = settings.get({})
55
69
 
@@ -57,20 +71,11 @@ const currentSettings = settings.get({})
57
71
  const cachedItem = settings.get(undefined, 60)
58
72
  ```
59
73
 
60
- ### `set`
61
-
62
- Thiết lập hoặc cập nhật một giá trị trong cơ chế lưu trữ.
63
-
64
- **Tham số:**
65
- - `value?: T | (() => T)` — giá trị muốn lưu. Việc truyền `undefined` sẽ loại bỏ mục đó khỏi kho lưu trữ.
66
-
67
- **Trả về:** `T | undefined` — giá trị được lưu trữ.
68
-
74
+ ### Đồng bộ hóa Thủ công
69
75
  ```javascript
70
- settings.set({ theme: 'dark', notifications: true })
71
- ```
72
-
73
- ## Các phương thức bổ sung
76
+ const storage = new DataStorage('shared_data')
74
77
 
75
- - `remove(): this` Xóa bỏ chính xác khóa lưu trữ tương ứng từ phần môi trường phần mềm `localStorage` hoặc `sessionStorage`, đồng thời lập tức dọn sạch dữ liệu khối nhớ hiện tại.
76
- - `update(): this` Buộc bộ đệm đối tượng trong bộ nhớ tự đồng bộ lại thật khít so với dữ liệu rỗng hiện hành bên trong các hàm Storage API vật lý.
78
+ // ... dữ liệu thể đã thay đổi trong một tab khác hoặc phần khác của ứng dụng
79
+ storage.update() // Đồng bộ hóa bộ nhớ với đĩa
80
+ console.log(storage.get())
81
+ ```
@@ -46,7 +46,7 @@ const fromTs = new Datetime(1710460800000)
46
46
  - `getHoursType(): GeoHours` — Determines the hour format (12 or 24) for the current locale.
47
47
  - `getHour24(): boolean` — Returns the current setting for displaying the 24-hour format.
48
48
  - `getTimeZoneOffset(): number` — Returns the time zone offset in minutes.
49
- - `getTimeZone(style?: GeoTimeZoneStyle): string` — Returns the time zone (supports `minute`, `hour`, `RFC` styles).
49
+ - `getTimeZone(style?: GeoTimeZoneStyle): string` — Returns the time zone (supports `minute`, `hour`, `RFC` styles; default format with colon).
50
50
  - `getFirstDayCode(): GeoFirstDay` — Returns the code for the first day of the week (0 for Sunday, 1 for Monday, 6 for Saturday).
51
51
 
52
52
  ### Value Retrieval
@@ -57,7 +57,7 @@ const fromTs = new Datetime(1710460800000)
57
57
  - `getHour(): number` — Returns the hours.
58
58
  - `getMinute(): number` — Returns the minutes.
59
59
  - `getSecond(): number` — Returns the seconds.
60
- - `getMaxDay(): number` — Returns the number of days in the current month.
60
+ - `getMaxDay(): number` — Returns the number of the last day of the current month (28-31).
61
61
 
62
62
  ### Value Setting
63
63
 
@@ -92,7 +92,7 @@ Modify the current `Datetime` object.
92
92
  - `moveWeekdayFirst(): this` — Move to the first day of the current week.
93
93
  - `moveWeekdayLast(): this` — Move to the last day of the current week.
94
94
  - `moveWeekdayFirstByMonth(): this` — Move to the first day of the first week of the month.
95
- - `moveWeekdayLastByMonth(): this` — Move to the first day of the first full week of the next month.
95
+ - `moveWeekdayLastByMonth(): this` — Move to the last day of the last week of the current month.
96
96
  - `moveWeekdayNext(): this` — Shift one week forward.
97
97
  - `moveWeekdayPrevious(): this` — Shift one week backward.
98
98
  - `moveDayFirst(): this` — Move to the first day of the current month.
@@ -113,7 +113,7 @@ Create copies of the data.
113
113
  - `cloneWeekdayFirst(): Datetime` — Copy set to the beginning of the current week.
114
114
  - `cloneWeekdayLast(): Datetime` — Copy set to the end of the current week.
115
115
  - `cloneWeekdayFirstByMonth(): Datetime` — Copy to the beginning of the first week of the month.
116
- - `cloneWeekdayLastByMonth(): Datetime` — Copy to the beginning of the last week of the month.
116
+ - `cloneWeekdayLastByMonth(): Datetime` — Copy to the end of the last week of the month.
117
117
  - `cloneWeekdayNext(): Datetime` — Copy with a shift of one week forward.
118
118
  - `cloneWeekdayPrevious(): Datetime` — Copy with a shift of one week backward.
119
119
  - `cloneDayFirst(): Datetime` — Copy to the first day of the current month.
@@ -159,6 +159,38 @@ dt.standard() // "2024-03-15T00:00:00+03:00"
159
159
  dt.standard(false) // "2024-03-15T00:00:00"
160
160
  ```
161
161
 
162
+ ## SSR and Hydration
163
+
164
+ > **Warning (SSR):** Creating a `Datetime` instance without a specific date (using the current time) for rendering in SSR may lead to hydration mismatches because the time or time zone on the server may differ from the time on the client.
165
+
166
+ ### Recommended Practices
167
+
168
+ When using `Datetime` in SSR environments:
169
+
170
+ 1. **Always provide specific dates**: Pass explicit dates to the constructor instead of relying on the current time.
171
+
172
+ 2. **Use server-side date initialization**: Initialize dates on the server with specific values to ensure consistency.
173
+
174
+ 3. **Client-side only for dynamic dates**: For dates that need to show the current time, initialize them only on the client side (e.g., in `useEffect`).
175
+
176
+ 4. **Consider timezone differences**: Be aware that server and client timezones may differ, affecting date calculations and formatting.
177
+
178
+ ### Example of Safe SSR Usage
179
+
180
+ ```javascript
181
+ // ✅ Good: Specific date for SSR
182
+ const serverDate = new Datetime('2024-03-15')
183
+
184
+ // ✅ Good: Initialize on client for current time
185
+ useEffect(() => {
186
+ const now = new Datetime()
187
+ setCurrentTime(now.locale('datetime'))
188
+ }, [])
189
+
190
+ // ❌ Avoid: Current time in SSR
191
+ const now = new Datetime() // May cause hydration mismatch
192
+ ```
193
+
162
194
  ## Usage Examples
163
195
 
164
196
  ### Working with Intervals and Navigation
@@ -46,7 +46,7 @@ const fromTs = new Datetime(1710460800000)
46
46
  - `getHoursType(): GeoHours` — Определяет формат часов (12 или 24) для текущей локали.
47
47
  - `getHour24(): boolean` — Возвращает текущую настройку отображения 24-часового формата.
48
48
  - `getTimeZoneOffset(): number` — Возвращает смещение часового пояса в минутах.
49
- - `getTimeZone(style?: GeoTimeZoneStyle): string` — Возвращает часовой пояс (поддерживает стили `minute`, `hour`, `RFC`).
49
+ - `getTimeZone(style?: GeoTimeZoneStyle): string` — Возвращает часовой пояс (поддерживает стили `minute`, `hour`, `RFC`; по умолчанию формат с двоеточием).
50
50
  - `getFirstDayCode(): GeoFirstDay` — Возвращает код первого дня недели (0 для воскресенья, 1 для понедельника, 6 для субботы).
51
51
 
52
52
  ### Получение значений
@@ -57,7 +57,7 @@ const fromTs = new Datetime(1710460800000)
57
57
  - `getHour(): number` — Возвращает часы.
58
58
  - `getMinute(): number` — Возвращает минуты.
59
59
  - `getSecond(): number` — Возвращает секунды.
60
- - `getMaxDay(): number` — Возвращает количество дней в текущем месяце.
60
+ - `getMaxDay(): number` — Возвращает число последнего дня текущего месяца (28-31).
61
61
 
62
62
  ### Установка значений
63
63
 
@@ -92,7 +92,7 @@ const fromTs = new Datetime(1710460800000)
92
92
  - `moveWeekdayFirst(): this` — Переход к первому дню текущей недели.
93
93
  - `moveWeekdayLast(): this` — Переход к последнему дню текущей недели.
94
94
  - `moveWeekdayFirstByMonth(): this` — Переход к первому дню первой недели месяца.
95
- - `moveWeekdayLastByMonth(): this` — Переход к первому дню первой полной недели следующего месяца.
95
+ - `moveWeekdayLastByMonth(): this` — Переход к последнему дню последней недели текущего месяца.
96
96
  - `moveWeekdayNext(): this` — Смещение на одну неделю вперед.
97
97
  - `moveWeekdayPrevious(): this` — Смещение на одну неделю назад.
98
98
  - `moveDayFirst(): this` — Переход к первому числу текущего месяца.
@@ -113,7 +113,7 @@ const fromTs = new Datetime(1710460800000)
113
113
  - `cloneWeekdayFirst(): Datetime` — Копия, установленная на начало текущей недели.
114
114
  - `cloneWeekdayLast(): Datetime` — Копия, установленная на конец текущей недели.
115
115
  - `cloneWeekdayFirstByMonth(): Datetime` — Копия на начало первой недели месяца.
116
- - `cloneWeekdayLastByMonth(): Datetime` — Копия на начало последней недели месяца.
116
+ - `cloneWeekdayLastByMonth(): Datetime` — Копия на конец последней недели месяца.
117
117
  - `cloneWeekdayNext(): Datetime` — Копия со сдвигом на неделю вперед.
118
118
  - `cloneWeekdayPrevious(): Datetime` — Копия со сдвигом на неделю назад.
119
119
  - `cloneDayFirst(): Datetime` — Копия на первое число текущего месяца.
@@ -159,6 +159,38 @@ dt.standard() // "2024-03-15T00:00:00+03:00"
159
159
  dt.standard(false) // "2024-03-15T00:00:00"
160
160
  ```
161
161
 
162
+ ## SSR и Гидратация
163
+
164
+ > **Внимание (SSR):** Создание экземпляра `Datetime` без указания конкретной даты (использование текущего времени) для отрисовки в SSR может привести к ошибкам гидратации, так как время или часовой пояс сервера могут отличаться от времени на стороне клиента.
165
+
166
+ ### Рекомендуемые практики
167
+
168
+ При использовании `Datetime` в SSR-окружениях:
169
+
170
+ 1. **Всегда указывайте конкретные даты**: Передавайте явные даты в конструктор вместо использования текущего времени.
171
+
172
+ 2. **Используйте инициализацию даты на сервере**: Инициализируйте даты на сервере с конкретными значениями для обеспечения согласованности.
173
+
174
+ 3. **Только клиентская инициализация для динамических дат**: Для дат, которые должны показывать текущее время, инициализируйте их только на стороне клиента (например, в `useEffect`).
175
+
176
+ 4. **Учитывайте различия часовых поясов**: Помните, что часовые пояса сервера и клиента могут отличаться, что влияет на вычисления и форматирование дат.
177
+
178
+ ### Пример безопасного использования в SSR
179
+
180
+ ```javascript
181
+ // ✅ Хорошо: Конкретная дата для SSR
182
+ const serverDate = new Datetime('2024-03-15')
183
+
184
+ // ✅ Хорошо: Инициализация на клиенте для текущего времени
185
+ useEffect(() => {
186
+ const now = new Datetime()
187
+ setCurrentTime(now.locale('datetime'))
188
+ }, [])
189
+
190
+ // ❌ Избегайте: Текущее время в SSR
191
+ const now = new Datetime() // Может вызвать ошибку гидратации
192
+ ```
193
+
162
194
  ## Примеры использования
163
195
 
164
196
  ### Работа с интервалами и навигацией
@@ -46,7 +46,7 @@ const fromTs = new Datetime(1710460800000)
46
46
  - `getHoursType(): GeoHours` — Xác định định dạng giờ (12 hoặc 24) cho địa phương hiện tại.
47
47
  - `getHour24(): boolean` — Trả về thiết lập hiện tại cho việc hiển thị định dạng 24 giờ.
48
48
  - `getTimeZoneOffset(): number` — Trả về độ lệch múi giờ tính bằng phút.
49
- - `getTimeZone(style?: GeoTimeZoneStyle): string` — Trả về múi giờ (hỗ trợ các kiểu `minute`, `hour`, `RFC`).
49
+ - `getTimeZone(style?: GeoTimeZoneStyle): string` — Trả về múi giờ (hỗ trợ các kiểu `minute`, `hour`, `RFC`; định dạng mặc định với dấu hai chấm).
50
50
  - `getFirstDayCode(): GeoFirstDay` — Trả về mã cho ngày đầu tiên của tuần (0 cho Chủ Nhật, 1 cho Thứ Hai, 6 cho Thứ Bảy).
51
51
 
52
52
  ### Lấy giá trị
@@ -57,7 +57,7 @@ const fromTs = new Datetime(1710460800000)
57
57
  - `getHour(): number` — Trả về giờ.
58
58
  - `getMinute(): number` — Trả về phút.
59
59
  - `getSecond(): number` — Trả về giây.
60
- - `getMaxDay(): number` — Trả về số ngày trong tháng hiện tại.
60
+ - `getMaxDay(): number` — Trả về số của ngày cuối cùng trong tháng hiện tại (28-31).
61
61
 
62
62
  ### Thiết lập giá trị
63
63
 
@@ -92,7 +92,7 @@ Thay đổi đối tượng `Datetime` hiện tại.
92
92
  - `moveWeekdayFirst(): this` — Chuyển đến ngày đầu tiên của tuần hiện tại.
93
93
  - `moveWeekdayLast(): this` — Chuyển đến ngày cuối cùng của tuần hiện tại.
94
94
  - `moveWeekdayFirstByMonth(): this` — Chuyển đến ngày đầu tiên của tuần đầu tiên trong tháng.
95
- - `moveWeekdayLastByMonth(): this` — Chuyển đến ngày đầu tiên của tuần đầy đủ đầu tiên của tháng tiếp theo.
95
+ - `moveWeekdayLastByMonth(): this` — Chuyển đến ngày cuối cùng của tuần cuối cùng trong tháng hiện tại.
96
96
  - `moveWeekdayNext(): this` — Dịch chuyển một tuần về phía trước.
97
97
  - `moveWeekdayPrevious(): this` — Dịch chuyển một tuần về phía sau.
98
98
  - `moveDayFirst(): this` — Chuyển đến ngày đầu tiên của tháng hiện tại.
@@ -113,7 +113,7 @@ Tạo bản sao của dữ liệu.
113
113
  - `cloneWeekdayFirst(): Datetime` — Sao chép được thiết lập vào đầu tuần hiện tại.
114
114
  - `cloneWeekdayLast(): Datetime` — Sao chép được thiết lập vào cuối tuần hiện tại.
115
115
  - `cloneWeekdayFirstByMonth(): Datetime` — Sao chép đến đầu tuần đầu tiên của tháng.
116
- - `cloneWeekdayLastByMonth(): Datetime` — Sao chép đến đầu tuần cuối cùng của tháng.
116
+ - `cloneWeekdayLastByMonth(): Datetime` — Sao chép đến cuối tuần cuối cùng của tháng.
117
117
  - `cloneWeekdayNext(): Datetime` — Sao chép với việc dịch chuyển một tuần về phía trước.
118
118
  - `cloneWeekdayPrevious(): Datetime` — Sao chép với việc dịch chuyển một tuần về phía sau.
119
119
  - `cloneDayFirst(): Datetime` — Sao chép đến ngày đầu tiên của tháng hiện tại.
@@ -159,6 +159,38 @@ dt.standard() // "2024-03-15T00:00:00+03:00"
159
159
  dt.standard(false) // "2024-03-15T00:00:00"
160
160
  ```
161
161
 
162
+ ## SSR và Hydration
163
+
164
+ > **Cảnh báo (SSR):** Việc tạo một thực thể `Datetime` mà không có ngày cụ thể (sử dụng thời gian hiện tại) để render trong SSR có thể dẫn đến lỗi hydration mismatch vì thời gian hoặc múi giờ trên máy chủ có thể khác với thời gian trên máy khách.
165
+
166
+ ### Thực tiễn khuyến nghị
167
+
168
+ Khi sử dụng `Datetime` trong môi trường SSR:
169
+
170
+ 1. **Luôn cung cấp ngày cụ thể**: Truyền ngày cụ thể vào hàm khởi tạo thay vì sử dụng thời gian hiện tại.
171
+
172
+ 2. **Sử dụng khởi tạo ngày ở phía máy chủ**: Khởi tạo ngày ở máy chủ với các giá trị cụ thể để đảm bảo tính nhất quán.
173
+
174
+ 3. **Chỉ khởi tạo ở phía máy khách cho ngày động**: Đối với ngày cần hiển thị thời gian hiện tại, chỉ khởi tạo ở phía máy khách (ví dụ: trong `useEffect`).
175
+
176
+ 4. **Cân nhắc sự khác biệt múi giờ**: Lưu ý rằng múi giờ máy chủ và máy khách có thể khác nhau, ảnh hưởng đến tính toán và định dạng ngày.
177
+
178
+ ### Ví dụ về sử dụng an toàn trong SSR
179
+
180
+ ```javascript
181
+ // ✅ Tốt: Ngày cụ thể cho SSR
182
+ const serverDate = new Datetime('2024-03-15')
183
+
184
+ // ✅ Tốt: Khởi tạo ở máy khách cho thời gian hiện tại
185
+ useEffect(() => {
186
+ const now = new Datetime()
187
+ setCurrentTime(now.locale('datetime'))
188
+ }, [])
189
+
190
+ // ❌ Tránh: Thời gian hiện tại trong SSR
191
+ const now = new Datetime() // Có thể gây lỗi hydration
192
+ ```
193
+
162
194
  ## Ví dụ sử dụng
163
195
 
164
196
  ### Làm việc với Khoảng thời gian và Điều hướng
@@ -2,94 +2,125 @@ import {Meta} from '@storybook/addon-docs/blocks'
2
2
 
3
3
  <Meta title='@dxtmisha/en/functional-basic/Classes/ErrorCenter - Error Management'/>
4
4
 
5
- # ErrorCenter
5
+ # ErrorCenter Class
6
6
 
7
- A static wrapper for `ErrorCenterInstance` providing centralized management for error storage, retrieval, and event-based handling. It acts as a global registry for error causes and provides a mechanism to register and trigger custom handlers for different error groups.
7
+ `ErrorCenter` is the central tool for managing all errors in the application. It allows you to register possible error causes in one place, configure the reaction to them (e.g., showing notifications), and trigger them from any part of the code.
8
8
 
9
- The class follows the "Static Bridge" pattern, delegating all operations to a singleton instance while maintaining a clean, globally accessible API.
9
+ The class acts as a static bridge (Static Bridge), directing all requests to a single `ErrorCenterInstance`.
10
10
 
11
- ## Key Features
11
+ ## Methods
12
12
 
13
- - **Static Access** — Global access to error management without the need for manual instantiation.
14
- - **Centralized Registry**Stores standardized error causes (labels and messages) for consistent UI feedback.
15
- - **Group-Based Handling** — Allows registering multiple callbacks for specific error categories.
16
- - **Chainable API** — Methods for adding causes and handlers support fluent interface design.
17
- - **Predefined Defaults** — Comes pre-configured with standard network error causes (`timeout`, `offline`, `notFound`, etc.).
13
+ ### Action
14
+ - `on(cause: ErrorCenterCauseItem): void` Starts the processing. Searches the registry, merges data, and calls the appropriate callbacks.
18
15
 
19
- ## Check Methods
16
+ ### Verification
17
+ - `has(code: string, group?: string): boolean` — Checks if an error is registered.
18
+ - `get(code: string, group?: string): ErrorCenterCauseItem | undefined` — Returns error data from the registry.
20
19
 
21
- - `has(code: string, group?: string): boolean` — Checks if an error cause exists in the registry.
22
- - `get(code: string, group?: string): ErrorCenterCauseItem | undefined` — Retrieves the full error cause object.
20
+ ### Configuration
21
+ - `add(cause: ErrorCenterCauseItem): void` — Adds a single error cause.
22
+ - `addList(causes: ErrorCenterCauseList): void` — Adds a list of errors (batch registration).
23
+ - `addHandler(group: ErrorCenterGroup, handler: ErrorCenterHandlerCallback): void` — Registers a reaction to a group of errors.
24
+ - `addHandlerList(handlers: ErrorCenterHandlerList): void` — Batch registration of several handlers.
23
25
 
24
- ## Instance Retrieval
25
-
26
- - `getItem(): ErrorCenterInstance` — Returns the underlying instance used by the static wrapper.
27
-
28
- ## Configuration
29
-
30
- - `add(cause: ErrorCenterCauseItem): this` — Adds a single error cause to the global storage.
31
- - `addList(causes: ErrorCenterCauseList): this` — Adds multiple error causes to the registry at once.
32
- - `addHandler(group: ErrorCenterGroup, handler: ErrorCenterHandlerCallback): this` — Registers a callback function for a specific group.
33
- - `addHandlerList(handlers: ErrorCenterHandlerList): this` — Registers a batch of handlers.
34
-
35
- ## Action Methods
36
-
37
- ### `on`
38
-
39
- Triggers error handling for the specified cause. It merges the provided cause with stored data (if any), executes all registered handlers for the group, and logs the error to the console.
40
-
41
- **Parameters:**
42
- - `cause: ErrorCenterCauseItem` — The cause to trigger. Only `code` and `group` are required if the cause was previously registered via `add()`.
43
-
44
- **Returns:** `this`
26
+ ### Auxiliary
27
+ - `getItem(): ErrorCenterInstance` — Returns the internal instance of the class.
45
28
 
46
29
  ## Types
47
30
 
48
- ### `ErrorCenterCauseItem`
49
-
50
- The main object used to define an error cause.
31
+ #### `ErrorCenterGroup`
32
+ Group name (e.g., 'api', 'auth') or `undefined` for a general handler.
51
33
 
52
- - `group?: ErrorCenterGroup` — The category/group the error belongs to.
53
- - `code: string` Unique identifier for the error.
54
- - `label?: string` — Human-readable name of the error.
55
- - `message?: string` — Detailed description of the error.
56
- - `details?: any` — Optional object for additional context or technical data.
34
+ #### `ErrorCenterCauseItem`
35
+ Object describing an error: `group`, `code` (required), `priority`, `label`, `message`, `details`.
57
36
 
58
- ### `ErrorCenterGroup`
37
+ ## Usage Guide
59
38
 
60
- A simple type definition for categorizing errors: `string | undefined`.
61
-
62
- ## Default Error Causes
63
-
64
- The `ErrorCenter` is automatically populated with these standard network-related causes:
39
+ ### Step 1: Registration (Registry)
40
+ Create an error dictionary to store texts separately from the code.
41
+ ```typescript
42
+ ErrorCenter.add({
43
+ group: 'auth',
44
+ code: 'LOGIN_FAILED',
45
+ label: 'Login Failed',
46
+ message: 'Invalid password.'
47
+ })
48
+ ```
65
49
 
66
- - `unknown` **Unknown Error**: An unexpected error occurred. Please try again.
67
- - `timeout` **Request Timeout**: The request took too long. Please check your connection.
68
- - `offline` — **No Connection**: You are offline. Please check your internet connection.
69
- - `notFound` **Not Found**: The requested resource could not be found.
70
- - `server` — **Server Error**: Internal server error occurred.
50
+ ### Step 2: Subscription (Handlers)
51
+ Specify how the application should react to an error group.
52
+ ```typescript
53
+ ErrorCenter.addHandler('auth', (cause) => {
54
+ alert(cause.message);
55
+ });
56
+ ```
71
57
 
72
- ## Usage Example
58
+ ### Step 3: Execution (Execution)
59
+ Trigger the error by its code and group.
60
+ ```typescript
61
+ ErrorCenter.on({ group: 'auth', code: 'LOGIN_FAILED' });
62
+ ```
73
63
 
74
- ```javascript
64
+ ## Standard Error Causes
65
+
66
+ The class already contains pre-defined descriptions for common situations.
67
+
68
+ #### API Group (`api`)
69
+ Used for network request errors.
70
+ - **forbidden** — Forbidden (403).
71
+ - **notFound** — Resource not found (404).
72
+ - **offline** — No internet connection.
73
+ - **server** — Internal server error (500).
74
+ - **timeout** — Request timeout.
75
+ - **unauthorized** — Authorization error (401).
76
+ - **unknown** — Unknown error.
77
+ - **cacheClear**, **cacheGet**, **cacheRemove**, **cacheSet** — Cache errors.
78
+
79
+ #### Intl Group (`intl`)
80
+ Errors during data formatting (dates, numbers, etc.).
81
+ - **datetime**, **display**, **number**, **plural**, **relative**.
82
+ - **invalid** — Invalid date or incorrect format.
83
+
84
+ #### Storage Group (`storage`)
85
+ Errors during interaction with local or server storage.
86
+ - **context** — Missing context.
87
+ - **error** — General read/write failure.
88
+
89
+ #### Other Groups
90
+ These groups use a universal error code `error`. Triggering is done via `ErrorCenter.on({ group: 'group_name', code: 'error' })`.
91
+ - **broadcast** — Errors in data exchange between browser tabs.
92
+ - **hydration** — Error during data synchronization between server and client.
93
+ - **share** — Error when trying to share content (Sharing API).
94
+ - **transformation** — Error during data transformation or parsing.
95
+
96
+ ## Examples
97
+
98
+ ### Integration with Notification System
99
+ ```typescript
75
100
  import { ErrorCenter } from '@dxtmisha/functional-basic'
76
101
 
77
- // 1. Configure global handlers
102
+ // Set up once at app startup
78
103
  ErrorCenter.addHandler('api', (cause) => {
79
- notification.error({
80
- title: cause.label,
81
- message: cause.message
82
- })
83
- })
84
-
85
- // 2. Register specific error causes
86
- ErrorCenter.add({
87
- group: 'auth',
88
- code: 'token_expired',
89
- label: 'Session Expired',
90
- message: 'Your session has timed out. Please log in again.'
91
- })
104
+ Toast.show(cause.label || 'Error', cause.message);
105
+ });
106
+
107
+ // Use in any service
108
+ async function loadData() {
109
+ try {
110
+ const data = await fetch('/api');
111
+ } catch (e) {
112
+ ErrorCenter.on({ group: 'api', code: 'server', details: e });
113
+ }
114
+ }
115
+ ```
92
116
 
93
- // 3. Trigger errors via code and group
94
- ErrorCenter.on({ group: 'auth', code: 'token_expired' })
117
+ ### Working with Custom Groups
118
+ ```typescript
119
+ // On-the-fly registration
120
+ ErrorCenter.on({
121
+ group: 'upload',
122
+ code: 'SIZE_LIMIT',
123
+ label: 'File Too Large',
124
+ message: 'Max 5MB'
125
+ });
95
126
  ```