preact-intlayer 6.1.6 → 7.0.0-canary.3

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 (297) hide show
  1. package/dist/cjs/IntlayerNode.cjs +15 -45
  2. package/dist/cjs/IntlayerNode.cjs.map +1 -1
  3. package/dist/cjs/UI/ContentSelector.cjs +98 -130
  4. package/dist/cjs/UI/ContentSelector.cjs.map +1 -1
  5. package/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
  6. package/dist/cjs/client/IntlayerProvider.cjs +67 -95
  7. package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
  8. package/dist/cjs/client/format/index.cjs +17 -50
  9. package/dist/cjs/client/format/useCompact.cjs +29 -39
  10. package/dist/cjs/client/format/useCompact.cjs.map +1 -1
  11. package/dist/cjs/client/format/useCurrency.cjs +43 -39
  12. package/dist/cjs/client/format/useCurrency.cjs.map +1 -1
  13. package/dist/cjs/client/format/useDate.cjs +45 -36
  14. package/dist/cjs/client/format/useDate.cjs.map +1 -1
  15. package/dist/cjs/client/format/useList.cjs +40 -39
  16. package/dist/cjs/client/format/useList.cjs.map +1 -1
  17. package/dist/cjs/client/format/useNumber.cjs +41 -39
  18. package/dist/cjs/client/format/useNumber.cjs.map +1 -1
  19. package/dist/cjs/client/format/usePercentage.cjs +37 -39
  20. package/dist/cjs/client/format/usePercentage.cjs.map +1 -1
  21. package/dist/cjs/client/format/useRelativeTime.cjs +37 -39
  22. package/dist/cjs/client/format/useRelativeTime.cjs.map +1 -1
  23. package/dist/cjs/client/format/useUnit.cjs +36 -39
  24. package/dist/cjs/client/format/useUnit.cjs.map +1 -1
  25. package/dist/cjs/client/index.cjs +29 -69
  26. package/dist/cjs/client/t.cjs +21 -34
  27. package/dist/cjs/client/t.cjs.map +1 -1
  28. package/dist/cjs/client/useContent.cjs +16 -36
  29. package/dist/cjs/client/useContent.cjs.map +1 -1
  30. package/dist/cjs/client/useDictionary.cjs +26 -36
  31. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  32. package/dist/cjs/client/useDictionaryAsync.cjs +23 -52
  33. package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
  34. package/dist/cjs/client/useDictionaryDynamic.cjs +22 -42
  35. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  36. package/dist/cjs/client/useIntlayer.cjs +26 -36
  37. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  38. package/dist/cjs/client/useLoadDynamic.cjs +21 -50
  39. package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
  40. package/dist/cjs/client/useLocale.cjs +36 -67
  41. package/dist/cjs/client/useLocale.cjs.map +1 -1
  42. package/dist/cjs/client/useLocaleBase.cjs +25 -53
  43. package/dist/cjs/client/useLocaleBase.cjs.map +1 -1
  44. package/dist/cjs/client/useLocaleStorage.cjs +60 -0
  45. package/dist/cjs/client/useLocaleStorage.cjs.map +1 -0
  46. package/dist/cjs/client/useTraduction.cjs +34 -35
  47. package/dist/cjs/client/useTraduction.cjs.map +1 -1
  48. package/dist/cjs/editor/CommunicatorContext.cjs +40 -62
  49. package/dist/cjs/editor/CommunicatorContext.cjs.map +1 -1
  50. package/dist/cjs/editor/ConfigurationContext.cjs +26 -47
  51. package/dist/cjs/editor/ConfigurationContext.cjs.map +1 -1
  52. package/dist/cjs/editor/ContentSelectorWrapper.cjs +58 -94
  53. package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -1
  54. package/dist/cjs/editor/DictionariesRecordContext.cjs +47 -73
  55. package/dist/cjs/editor/DictionariesRecordContext.cjs.map +1 -1
  56. package/dist/cjs/editor/EditedContentContext.cjs +160 -211
  57. package/dist/cjs/editor/EditedContentContext.cjs.map +1 -1
  58. package/dist/cjs/editor/EditorEnabledContext.cjs +34 -59
  59. package/dist/cjs/editor/EditorEnabledContext.cjs.map +1 -1
  60. package/dist/cjs/editor/EditorProvider.cjs +62 -66
  61. package/dist/cjs/editor/EditorProvider.cjs.map +1 -1
  62. package/dist/cjs/editor/FocusDictionaryContext.cjs +51 -75
  63. package/dist/cjs/editor/FocusDictionaryContext.cjs.map +1 -1
  64. package/dist/cjs/editor/IntlayerEditorProvider.cjs +45 -94
  65. package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +1 -1
  66. package/dist/cjs/editor/index.cjs +3 -23
  67. package/dist/cjs/editor/useCrossFrameMessageListener.cjs +73 -50
  68. package/dist/cjs/editor/useCrossFrameMessageListener.cjs.map +1 -1
  69. package/dist/cjs/editor/useCrossFrameState.cjs +106 -73
  70. package/dist/cjs/editor/useCrossFrameState.cjs.map +1 -1
  71. package/dist/cjs/editor/useCrossURLPathState.cjs +67 -66
  72. package/dist/cjs/editor/useCrossURLPathState.cjs.map +1 -1
  73. package/dist/cjs/editor/useEditedContentRenderer.cjs +27 -59
  74. package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -1
  75. package/dist/cjs/editor/useIframeClickInterceptor.cjs +24 -47
  76. package/dist/cjs/editor/useIframeClickInterceptor.cjs.map +1 -1
  77. package/dist/cjs/getDictionary.cjs +15 -40
  78. package/dist/cjs/getDictionary.cjs.map +1 -1
  79. package/dist/cjs/getIntlayer.cjs +15 -36
  80. package/dist/cjs/getIntlayer.cjs.map +1 -1
  81. package/dist/cjs/index.cjs +30 -62
  82. package/dist/cjs/markdown/MarkdownProvider.cjs +19 -39
  83. package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -1
  84. package/dist/cjs/markdown/MarkdownRenderer.cjs +39 -80
  85. package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -1
  86. package/dist/cjs/markdown/index.cjs +7 -25
  87. package/dist/cjs/plugins.cjs +97 -119
  88. package/dist/cjs/plugins.cjs.map +1 -1
  89. package/dist/cjs/preactElement/renderPreactElement.cjs +34 -59
  90. package/dist/cjs/preactElement/renderPreactElement.cjs.map +1 -1
  91. package/dist/esm/IntlayerNode.mjs +13 -25
  92. package/dist/esm/IntlayerNode.mjs.map +1 -1
  93. package/dist/esm/UI/ContentSelector.mjs +94 -105
  94. package/dist/esm/UI/ContentSelector.mjs.map +1 -1
  95. package/dist/esm/client/IntlayerProvider.mjs +51 -54
  96. package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
  97. package/dist/esm/client/format/index.mjs +2 -11
  98. package/dist/esm/client/format/useCompact.mjs +24 -13
  99. package/dist/esm/client/format/useCompact.mjs.map +1 -1
  100. package/dist/esm/client/format/useCurrency.mjs +38 -13
  101. package/dist/esm/client/format/useCurrency.mjs.map +1 -1
  102. package/dist/esm/client/format/useDate.mjs +40 -10
  103. package/dist/esm/client/format/useDate.mjs.map +1 -1
  104. package/dist/esm/client/format/useList.mjs +35 -13
  105. package/dist/esm/client/format/useList.mjs.map +1 -1
  106. package/dist/esm/client/format/useNumber.mjs +36 -13
  107. package/dist/esm/client/format/useNumber.mjs.map +1 -1
  108. package/dist/esm/client/format/usePercentage.mjs +32 -13
  109. package/dist/esm/client/format/usePercentage.mjs.map +1 -1
  110. package/dist/esm/client/format/useRelativeTime.mjs +32 -13
  111. package/dist/esm/client/format/useRelativeTime.mjs.map +1 -1
  112. package/dist/esm/client/format/useUnit.mjs +31 -13
  113. package/dist/esm/client/format/useUnit.mjs.map +1 -1
  114. package/dist/esm/client/index.mjs +5 -32
  115. package/dist/esm/client/t.mjs +16 -8
  116. package/dist/esm/client/t.mjs.map +1 -1
  117. package/dist/esm/client/useContent.mjs +14 -10
  118. package/dist/esm/client/useContent.mjs.map +1 -1
  119. package/dist/esm/client/useDictionary.mjs +23 -11
  120. package/dist/esm/client/useDictionary.mjs.map +1 -1
  121. package/dist/esm/client/useDictionaryAsync.mjs +18 -16
  122. package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
  123. package/dist/esm/client/useDictionaryDynamic.mjs +17 -15
  124. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  125. package/dist/esm/client/useIntlayer.mjs +23 -11
  126. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  127. package/dist/esm/client/useLoadDynamic.mjs +20 -26
  128. package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
  129. package/dist/esm/client/useLocale.mjs +31 -31
  130. package/dist/esm/client/useLocale.mjs.map +1 -1
  131. package/dist/esm/client/useLocaleBase.mjs +19 -16
  132. package/dist/esm/client/useLocaleBase.mjs.map +1 -1
  133. package/dist/esm/client/useLocaleStorage.mjs +52 -0
  134. package/dist/esm/client/useLocaleStorage.mjs.map +1 -0
  135. package/dist/esm/client/useTraduction.mjs +29 -9
  136. package/dist/esm/client/useTraduction.mjs.map +1 -1
  137. package/dist/esm/editor/CommunicatorContext.mjs +28 -24
  138. package/dist/esm/editor/CommunicatorContext.mjs.map +1 -1
  139. package/dist/esm/editor/ConfigurationContext.mjs +20 -24
  140. package/dist/esm/editor/ConfigurationContext.mjs.map +1 -1
  141. package/dist/esm/editor/ContentSelectorWrapper.mjs +50 -70
  142. package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -1
  143. package/dist/esm/editor/DictionariesRecordContext.mjs +37 -47
  144. package/dist/esm/editor/DictionariesRecordContext.mjs.map +1 -1
  145. package/dist/esm/editor/EditedContentContext.mjs +146 -187
  146. package/dist/esm/editor/EditedContentContext.mjs.map +1 -1
  147. package/dist/esm/editor/EditorEnabledContext.mjs +23 -33
  148. package/dist/esm/editor/EditorEnabledContext.mjs.map +1 -1
  149. package/dist/esm/editor/EditorProvider.mjs +57 -54
  150. package/dist/esm/editor/EditorProvider.mjs.map +1 -1
  151. package/dist/esm/editor/FocusDictionaryContext.mjs +42 -49
  152. package/dist/esm/editor/FocusDictionaryContext.mjs.map +1 -1
  153. package/dist/esm/editor/IntlayerEditorProvider.mjs +37 -55
  154. package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -1
  155. package/dist/esm/editor/index.mjs +3 -2
  156. package/dist/esm/editor/useCrossFrameMessageListener.mjs +68 -24
  157. package/dist/esm/editor/useCrossFrameMessageListener.mjs.map +1 -1
  158. package/dist/esm/editor/useCrossFrameState.mjs +102 -47
  159. package/dist/esm/editor/useCrossFrameState.mjs.map +1 -1
  160. package/dist/esm/editor/useCrossURLPathState.mjs +60 -40
  161. package/dist/esm/editor/useCrossURLPathState.mjs.map +1 -1
  162. package/dist/esm/editor/useEditedContentRenderer.mjs +23 -33
  163. package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -1
  164. package/dist/esm/editor/useIframeClickInterceptor.mjs +18 -20
  165. package/dist/esm/editor/useIframeClickInterceptor.mjs.map +1 -1
  166. package/dist/esm/getDictionary.mjs +13 -22
  167. package/dist/esm/getDictionary.mjs.map +1 -1
  168. package/dist/esm/getIntlayer.mjs +13 -18
  169. package/dist/esm/getIntlayer.mjs.map +1 -1
  170. package/dist/esm/index.mjs +13 -39
  171. package/dist/esm/markdown/MarkdownProvider.mjs +14 -16
  172. package/dist/esm/markdown/MarkdownProvider.mjs.map +1 -1
  173. package/dist/esm/markdown/MarkdownRenderer.mjs +34 -57
  174. package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -1
  175. package/dist/esm/markdown/index.mjs +4 -3
  176. package/dist/esm/plugins.mjs +86 -92
  177. package/dist/esm/plugins.mjs.map +1 -1
  178. package/dist/esm/preactElement/renderPreactElement.mjs +31 -34
  179. package/dist/esm/preactElement/renderPreactElement.mjs.map +1 -1
  180. package/dist/types/IntlayerNode.d.ts +19 -12
  181. package/dist/types/IntlayerNode.d.ts.map +1 -1
  182. package/dist/types/UI/ContentSelector.d.ts +12 -9
  183. package/dist/types/UI/ContentSelector.d.ts.map +1 -1
  184. package/dist/types/client/IntlayerProvider.d.ts +22 -16
  185. package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
  186. package/dist/types/client/format/index.d.ts +9 -9
  187. package/dist/types/client/format/useCompact.d.ts +8 -2
  188. package/dist/types/client/format/useCompact.d.ts.map +1 -1
  189. package/dist/types/client/format/useCurrency.d.ts +8 -2
  190. package/dist/types/client/format/useCurrency.d.ts.map +1 -1
  191. package/dist/types/client/format/useDate.d.ts +7 -2
  192. package/dist/types/client/format/useDate.d.ts.map +1 -1
  193. package/dist/types/client/format/useList.d.ts +8 -2
  194. package/dist/types/client/format/useList.d.ts.map +1 -1
  195. package/dist/types/client/format/useNumber.d.ts +8 -2
  196. package/dist/types/client/format/useNumber.d.ts.map +1 -1
  197. package/dist/types/client/format/usePercentage.d.ts +8 -2
  198. package/dist/types/client/format/usePercentage.d.ts.map +1 -1
  199. package/dist/types/client/format/useRelativeTime.d.ts +9 -3
  200. package/dist/types/client/format/useRelativeTime.d.ts.map +1 -1
  201. package/dist/types/client/format/useUnit.d.ts +8 -2
  202. package/dist/types/client/format/useUnit.d.ts.map +1 -1
  203. package/dist/types/client/index.d.ts +11 -12
  204. package/dist/types/client/t.d.ts +7 -3
  205. package/dist/types/client/t.d.ts.map +1 -1
  206. package/dist/types/client/useContent.d.ts +10 -5
  207. package/dist/types/client/useContent.d.ts.map +1 -1
  208. package/dist/types/client/useDictionary.d.ts +9 -3
  209. package/dist/types/client/useDictionary.d.ts.map +1 -1
  210. package/dist/types/client/useDictionaryAsync.d.ts +7 -3
  211. package/dist/types/client/useDictionaryAsync.d.ts.map +1 -1
  212. package/dist/types/client/useDictionaryDynamic.d.ts +9 -3
  213. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
  214. package/dist/types/client/useIntlayer.d.ts +8 -5
  215. package/dist/types/client/useIntlayer.d.ts.map +1 -1
  216. package/dist/types/client/useLoadDynamic.d.ts +4 -1
  217. package/dist/types/client/useLoadDynamic.d.ts.map +1 -1
  218. package/dist/types/client/useLocale.d.ts +16 -8
  219. package/dist/types/client/useLocale.d.ts.map +1 -1
  220. package/dist/types/client/useLocaleBase.d.ts +10 -5
  221. package/dist/types/client/useLocaleBase.d.ts.map +1 -1
  222. package/dist/types/client/useLocaleStorage.d.ts +45 -0
  223. package/dist/types/client/useLocaleStorage.d.ts.map +1 -0
  224. package/dist/types/client/useTraduction.d.ts +7 -2
  225. package/dist/types/client/useTraduction.d.ts.map +1 -1
  226. package/dist/types/editor/CommunicatorContext.d.ts +15 -11
  227. package/dist/types/editor/CommunicatorContext.d.ts.map +1 -1
  228. package/dist/types/editor/ConfigurationContext.d.ts +12 -7
  229. package/dist/types/editor/ConfigurationContext.d.ts.map +1 -1
  230. package/dist/types/editor/ContentSelectorWrapper.d.ts +8 -4
  231. package/dist/types/editor/ContentSelectorWrapper.d.ts.map +1 -1
  232. package/dist/types/editor/DictionariesRecordContext.d.ts +15 -12
  233. package/dist/types/editor/DictionariesRecordContext.d.ts.map +1 -1
  234. package/dist/types/editor/EditedContentContext.d.ts +32 -29
  235. package/dist/types/editor/EditedContentContext.d.ts.map +1 -1
  236. package/dist/types/editor/EditorEnabledContext.d.ts +14 -9
  237. package/dist/types/editor/EditorEnabledContext.d.ts.map +1 -1
  238. package/dist/types/editor/EditorProvider.d.ts +9 -5
  239. package/dist/types/editor/EditorProvider.d.ts.map +1 -1
  240. package/dist/types/editor/FocusDictionaryContext.d.ts +18 -15
  241. package/dist/types/editor/FocusDictionaryContext.d.ts.map +1 -1
  242. package/dist/types/editor/IntlayerEditorProvider.d.ts +7 -3
  243. package/dist/types/editor/IntlayerEditorProvider.d.ts.map +1 -1
  244. package/dist/types/editor/index.d.ts +2 -2
  245. package/dist/types/editor/useCrossFrameMessageListener.d.ts +7 -2
  246. package/dist/types/editor/useCrossFrameMessageListener.d.ts.map +1 -1
  247. package/dist/types/editor/useCrossFrameState.d.ts +11 -7
  248. package/dist/types/editor/useCrossFrameState.d.ts.map +1 -1
  249. package/dist/types/editor/useCrossURLPathState.d.ts +8 -3
  250. package/dist/types/editor/useCrossURLPathState.d.ts.map +1 -1
  251. package/dist/types/editor/useEditedContentRenderer.d.ts +16 -10
  252. package/dist/types/editor/useEditedContentRenderer.d.ts.map +1 -1
  253. package/dist/types/editor/useIframeClickInterceptor.d.ts +5 -2
  254. package/dist/types/editor/useIframeClickInterceptor.d.ts.map +1 -1
  255. package/dist/types/getDictionary.d.ts +8 -4
  256. package/dist/types/getDictionary.d.ts.map +1 -1
  257. package/dist/types/getIntlayer.d.ts +8 -4
  258. package/dist/types/getIntlayer.d.ts.map +1 -1
  259. package/dist/types/index.d.ts +18 -6
  260. package/dist/types/index.d.ts.map +1 -1
  261. package/dist/types/markdown/MarkdownProvider.d.ts +8 -5
  262. package/dist/types/markdown/MarkdownProvider.d.ts.map +1 -1
  263. package/dist/types/markdown/MarkdownRenderer.d.ts +13 -11
  264. package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -1
  265. package/dist/types/markdown/index.d.ts +3 -3
  266. package/dist/types/plugins.d.ts +33 -27
  267. package/dist/types/plugins.d.ts.map +1 -1
  268. package/dist/types/preactElement/renderPreactElement.d.ts +7 -3
  269. package/dist/types/preactElement/renderPreactElement.d.ts.map +1 -1
  270. package/package.json +40 -46
  271. package/LICENSE +0 -202
  272. package/dist/cjs/client/format/index.cjs.map +0 -1
  273. package/dist/cjs/client/getBrowserLocale.cjs +0 -173
  274. package/dist/cjs/client/getBrowserLocale.cjs.map +0 -1
  275. package/dist/cjs/client/index.cjs.map +0 -1
  276. package/dist/cjs/client/useLocaleCookie.cjs +0 -60
  277. package/dist/cjs/client/useLocaleCookie.cjs.map +0 -1
  278. package/dist/cjs/editor/index.cjs.map +0 -1
  279. package/dist/cjs/index.cjs.map +0 -1
  280. package/dist/cjs/markdown/index.cjs.map +0 -1
  281. package/dist/esm/client/format/index.mjs.map +0 -1
  282. package/dist/esm/client/getBrowserLocale.mjs +0 -138
  283. package/dist/esm/client/getBrowserLocale.mjs.map +0 -1
  284. package/dist/esm/client/index.mjs.map +0 -1
  285. package/dist/esm/client/useLocaleCookie.mjs +0 -24
  286. package/dist/esm/client/useLocaleCookie.mjs.map +0 -1
  287. package/dist/esm/editor/index.mjs.map +0 -1
  288. package/dist/esm/index.mjs.map +0 -1
  289. package/dist/esm/markdown/index.mjs.map +0 -1
  290. package/dist/types/client/format/index.d.ts.map +0 -1
  291. package/dist/types/client/getBrowserLocale.d.ts +0 -25
  292. package/dist/types/client/getBrowserLocale.d.ts.map +0 -1
  293. package/dist/types/client/index.d.ts.map +0 -1
  294. package/dist/types/client/useLocaleCookie.d.ts +0 -17
  295. package/dist/types/client/useLocaleCookie.d.ts.map +0 -1
  296. package/dist/types/editor/index.d.ts.map +0 -1
  297. package/dist/types/markdown/index.d.ts.map +0 -1
@@ -1,45 +1,25 @@
1
- "use strict";
2
- "use client";
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var useDictionaryDynamic_exports = {};
21
- __export(useDictionaryDynamic_exports, {
22
- useDictionaryDynamic: () => useDictionaryDynamic
23
- });
24
- module.exports = __toCommonJS(useDictionaryDynamic_exports);
25
- var import_hooks = require("preact/hooks");
26
- var import_IntlayerProvider = require('./IntlayerProvider.cjs');
27
- var import_useDictionary = require('./useDictionary.cjs');
28
- var import_useLoadDynamic = require('./useLoadDynamic.cjs');
1
+ 'use client';
2
+
3
+
4
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
5
+ const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
6
+ const require_client_useDictionary = require('./useDictionary.cjs');
7
+ const require_client_useLoadDynamic = require('./useLoadDynamic.cjs');
8
+ let preact_hooks = require("preact/hooks");
9
+ preact_hooks = require_rolldown_runtime.__toESM(preact_hooks);
10
+
11
+ //#region src/client/useDictionaryDynamic.ts
12
+ /**
13
+ * On the server side, Hook that transform a dictionary and return the content
14
+ *
15
+ * If the locale is not provided, it will use the locale from the client context
16
+ */
29
17
  const useDictionaryDynamic = (dictionaryPromise, key, locale) => {
30
- const { locale: currentLocale } = (0, import_hooks.useContext)(import_IntlayerProvider.IntlayerClientContext);
31
- const localeTarget = (0, import_hooks.useMemo)(
32
- () => locale ?? currentLocale,
33
- [currentLocale, locale]
34
- );
35
- const dictionary = (0, import_useLoadDynamic.useLoadDynamic)(
36
- `${String(key)}.${localeTarget}`,
37
- dictionaryPromise[localeTarget]()
38
- );
39
- return (0, import_useDictionary.useDictionary)(dictionary, localeTarget);
18
+ const { locale: currentLocale } = (0, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
19
+ const localeTarget = (0, preact_hooks.useMemo)(() => locale ?? currentLocale, [currentLocale, locale]);
20
+ return require_client_useDictionary.useDictionary(require_client_useLoadDynamic.useLoadDynamic(`${String(key)}.${localeTarget}`, dictionaryPromise[localeTarget]?.()), localeTarget);
40
21
  };
41
- // Annotate the CommonJS export names for ESM import in node:
42
- 0 && (module.exports = {
43
- useDictionaryDynamic
44
- });
22
+
23
+ //#endregion
24
+ exports.useDictionaryDynamic = useDictionaryDynamic;
45
25
  //# sourceMappingURL=useDictionaryDynamic.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type {\n Dictionary,\n DictionaryKeys,\n LanguageContent,\n} from '@intlayer/core';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: LanguageContent<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = useMemo(\n () => locale ?? currentLocale,\n [currentLocale, locale]\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n dictionaryPromise[localeTarget]!()\n ) as T;\n\n return useDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,mBAAoC;AACpC,8BAAsC;AACtC,2BAA8B;AAC9B,4BAA+B;AAOxB,MAAM,uBAAuB,CAIlC,mBACA,KACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,QAAI,yBAAW,6CAAqB;AAClE,QAAM,mBAAe;AAAA,IACnB,MAAM,UAAU;AAAA,IAChB,CAAC,eAAe,MAAM;AAAA,EACxB;AAEA,QAAM,iBAAa;AAAA,IACjB,GAAG,OAAO,GAAG,CAAC,IAAI,YAAY;AAAA,IAC9B,kBAAkB,YAAY,EAAG;AAAA,EACnC;AAEA,aAAO,oCAAc,YAAY,YAAY;AAC/C;","names":[]}
1
+ {"version":3,"file":"useDictionaryDynamic.cjs","names":["IntlayerClientContext","useDictionary","useLoadDynamic"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport type {\n Dictionary,\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = useMemo(\n () => locale ?? currentLocale,\n [currentLocale, locale]\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,MAAa,wBAIX,mBACA,KACA,WACG;CACH,MAAM,EAAE,QAAQ,+CAA6BA,sDAAsB;CACnE,MAAM,+CACE,UAAU,eAChB,CAAC,eAAe,OAAO,CACxB;AAOD,QAAOC,2CALYC,6CACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBACjB,kBAA0B,iBAAiB,CAC7C,EAEgC,aAAa"}
@@ -1,39 +1,29 @@
1
- "use strict";
2
- "use client";
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var useIntlayer_exports = {};
21
- __export(useIntlayer_exports, {
22
- useIntlayer: () => useIntlayer
23
- });
24
- module.exports = __toCommonJS(useIntlayer_exports);
25
- var import_hooks = require("preact/hooks");
26
- var import_getIntlayer = require('../getIntlayer.cjs');
27
- var import_IntlayerProvider = require('./IntlayerProvider.cjs');
1
+ 'use client';
2
+
3
+
4
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
5
+ const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
6
+ const require_getIntlayer = require('../getIntlayer.cjs');
7
+ let preact_hooks = require("preact/hooks");
8
+ preact_hooks = require_rolldown_runtime.__toESM(preact_hooks);
9
+
10
+ //#region src/client/useIntlayer.ts
11
+ /**
12
+ * On the client side, Hook that picking one dictionary by its key and return the content
13
+ *
14
+ * If the locale is not provided, it will use the locale from the client context
15
+ */
28
16
  const useIntlayer = (key, locale) => {
29
- const { locale: currentLocale } = (0, import_hooks.useContext)(import_IntlayerProvider.IntlayerClientContext);
30
- return (0, import_hooks.useMemo)(() => {
31
- const localeTarget = locale ?? currentLocale;
32
- return (0, import_getIntlayer.getIntlayer)(key, localeTarget);
33
- }, [key, currentLocale, locale]);
17
+ const { locale: currentLocale } = (0, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
18
+ return (0, preact_hooks.useMemo)(() => {
19
+ return require_getIntlayer.getIntlayer(key, locale ?? currentLocale);
20
+ }, [
21
+ key,
22
+ currentLocale,
23
+ locale
24
+ ]);
34
25
  };
35
- // Annotate the CommonJS export names for ESM import in node:
36
- 0 && (module.exports = {
37
- useIntlayer
38
- });
26
+
27
+ //#endregion
28
+ exports.useIntlayer = useIntlayer;
39
29
  //# sourceMappingURL=useIntlayer.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { DictionaryKeys } from '@intlayer/core';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useIntlayer = <T extends DictionaryKeys>(\n key: T,\n locale?: LocalesValues\n): DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content']> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n return useMemo(() => {\n const localeTarget = locale ?? currentLocale;\n\n return getIntlayer(key, localeTarget) as any;\n }, [key, currentLocale, locale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,mBAAoC;AACpC,yBAA4B;AAE5B,8BAAsC;AAO/B,MAAM,cAAc,CACzB,KACA,WACyE;AACzE,QAAM,EAAE,QAAQ,cAAc,QAAI,yBAAW,6CAAqB;AAElE,aAAO,sBAAQ,MAAM;AACnB,UAAM,eAAe,UAAU;AAE/B,eAAO,gCAAY,KAAK,YAAY;AAAA,EACtC,GAAG,CAAC,KAAK,eAAe,MAAM,CAAC;AACjC;","names":[]}
1
+ {"version":3,"file":"useIntlayer.cjs","names":["IntlayerClientContext","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type {\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n return useMemo(() => {\n const localeTarget = locale ?? currentLocale;\n\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n return getIntlayer<T, L>(key, localeTarget as L) as DeepTransformContent<\n DictionaryRegistryContent<T>\n >;\n }, [key, currentLocale, locale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,MAAa,eACX,KACA,WACG;CACH,MAAM,EAAE,QAAQ,+CAA6BA,sDAAsB;AAEnE,wCAAqB;AAInB,SAAOC,gCAAkB,KAHJ,UAAU,cAGiB;IAG/C;EAAC;EAAK;EAAe;EAAO,CAAC"}
@@ -1,56 +1,27 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var useLoadDynamic_exports = {};
20
- __export(useLoadDynamic_exports, {
21
- useLoadDynamic: () => useLoadDynamic
22
- });
23
- module.exports = __toCommonJS(useLoadDynamic_exports);
1
+
2
+ //#region src/client/useLoadDynamic.ts
24
3
  const createSuspender = (promise) => {
25
- let status = "pending";
26
- let result;
27
- const suspender = promise.then(
28
- (r) => {
29
- status = "success";
30
- result = r;
31
- },
32
- (e) => {
33
- status = "error";
34
- result = e;
35
- }
36
- );
37
- return {
38
- read() {
39
- if (status === "pending") throw suspender;
40
- if (status === "error") throw result;
41
- return result;
42
- }
43
- };
4
+ let status = "pending";
5
+ let result;
6
+ const suspender = promise.then((r) => {
7
+ status = "success";
8
+ result = r;
9
+ }, (e) => {
10
+ status = "error";
11
+ result = e;
12
+ });
13
+ return { read() {
14
+ if (status === "pending") throw suspender;
15
+ if (status === "error") throw result;
16
+ return result;
17
+ } };
44
18
  };
45
19
  const cache = /* @__PURE__ */ new Map();
46
20
  const useLoadDynamic = (key, promise) => {
47
- if (!cache.has(key)) {
48
- cache.set(key, createSuspender(promise));
49
- }
50
- return cache.get(key).read();
21
+ if (!cache.has(key)) cache.set(key, createSuspender(promise));
22
+ return cache.get(key).read();
51
23
  };
52
- // Annotate the CommonJS export names for ESM import in node:
53
- 0 && (module.exports = {
54
- useLoadDynamic
55
- });
24
+
25
+ //#endregion
26
+ exports.useLoadDynamic = useLoadDynamic;
56
27
  //# sourceMappingURL=useLoadDynamic.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useLoadDynamic.ts"],"sourcesContent":["type Status = 'pending' | 'success' | 'error';\n\nconst createSuspender = <T>(promise: Promise<T>) => {\n let status: Status = 'pending';\n let result: T;\n const suspender = promise.then(\n (r) => {\n status = 'success';\n result = r;\n },\n (e) => {\n status = 'error';\n result = e as any;\n }\n );\n\n return {\n read() {\n if (status === 'pending') throw suspender;\n if (status === 'error') throw result;\n return result!;\n },\n };\n};\n\nconst cache = new Map<string, ReturnType<typeof createSuspender>>();\n\nexport const useLoadDynamic = <T>(key: string, promise: Promise<T>): T => {\n if (!cache.has(key)) {\n cache.set(key, createSuspender(promise));\n }\n\n return (cache.get(key)! as ReturnType<typeof createSuspender>).read() as T;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,MAAM,kBAAkB,CAAI,YAAwB;AAClD,MAAI,SAAiB;AACrB,MAAI;AACJ,QAAM,YAAY,QAAQ;AAAA,IACxB,CAAC,MAAM;AACL,eAAS;AACT,eAAS;AAAA,IACX;AAAA,IACA,CAAC,MAAM;AACL,eAAS;AACT,eAAS;AAAA,IACX;AAAA,EACF;AAEA,SAAO;AAAA,IACL,OAAO;AACL,UAAI,WAAW,UAAW,OAAM;AAChC,UAAI,WAAW,QAAS,OAAM;AAC9B,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEA,MAAM,QAAQ,oBAAI,IAAgD;AAE3D,MAAM,iBAAiB,CAAI,KAAa,YAA2B;AACxE,MAAI,CAAC,MAAM,IAAI,GAAG,GAAG;AACnB,UAAM,IAAI,KAAK,gBAAgB,OAAO,CAAC;AAAA,EACzC;AAEA,SAAQ,MAAM,IAAI,GAAG,EAA0C,KAAK;AACtE;","names":[]}
1
+ {"version":3,"file":"useLoadDynamic.cjs","names":["status: Status","result: T"],"sources":["../../../src/client/useLoadDynamic.ts"],"sourcesContent":["type Status = 'pending' | 'success' | 'error';\n\nconst createSuspender = <T>(promise: Promise<T>) => {\n let status: Status = 'pending';\n let result: T;\n const suspender = promise.then(\n (r) => {\n status = 'success';\n result = r;\n },\n (e) => {\n status = 'error';\n result = e as any;\n }\n );\n\n return {\n read() {\n if (status === 'pending') throw suspender;\n if (status === 'error') throw result;\n return result!;\n },\n };\n};\n\nconst cache = new Map<string, ReturnType<typeof createSuspender>>();\n\nexport const useLoadDynamic = <T>(key: string, promise: Promise<T>): T => {\n if (!cache.has(key)) {\n cache.set(key, createSuspender(promise));\n }\n\n return (cache.get(key)! as ReturnType<typeof createSuspender>).read() as T;\n};\n"],"mappings":";;AAEA,MAAM,mBAAsB,YAAwB;CAClD,IAAIA,SAAiB;CACrB,IAAIC;CACJ,MAAM,YAAY,QAAQ,MACvB,MAAM;AACL,WAAS;AACT,WAAS;KAEV,MAAM;AACL,WAAS;AACT,WAAS;GAEZ;AAED,QAAO,EACL,OAAO;AACL,MAAI,WAAW,UAAW,OAAM;AAChC,MAAI,WAAW,QAAS,OAAM;AAC9B,SAAO;IAEV;;AAGH,MAAM,wBAAQ,IAAI,KAAiD;AAEnE,MAAa,kBAAqB,KAAa,YAA2B;AACxE,KAAI,CAAC,MAAM,IAAI,IAAI,CACjB,OAAM,IAAI,KAAK,gBAAgB,QAAQ,CAAC;AAG1C,QAAQ,MAAM,IAAI,IAAI,CAAyC,MAAM"}
@@ -1,69 +1,38 @@
1
- "use strict";
2
- "use client";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
1
+ 'use client';
2
+
3
+
4
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
5
+ const require_client_useLocaleStorage = require('./useLocaleStorage.cjs');
6
+ const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
7
+ let __intlayer_config_built = require("@intlayer/config/built");
8
+ __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
9
+ let preact_hooks = require("preact/hooks");
10
+ preact_hooks = require_rolldown_runtime.__toESM(preact_hooks);
11
+
12
+ //#region src/client/useLocale.ts
13
+ /**
14
+ * On the client side, hook to get the current locale and all related fields
15
+ */
16
+ const useLocale = ({ isCookieEnabled, onLocaleChange } = {}) => {
17
+ const { defaultLocale, locales: availableLocales } = __intlayer_config_built.default?.internationalization ?? {};
18
+ const { locale, setLocale: setLocaleState, isCookieEnabled: isCookieEnabledContext } = (0, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
19
+ const setLocale = (locale$1) => {
20
+ if (!availableLocales?.map(String).includes(locale$1)) {
21
+ console.error(`Locale ${locale$1} is not available`);
22
+ return;
23
+ }
24
+ setLocaleState(locale$1);
25
+ require_client_useLocaleStorage.setLocaleInStorage(locale$1, isCookieEnabled ?? isCookieEnabledContext ?? true);
26
+ onLocaleChange?.(locale$1);
27
+ };
28
+ return {
29
+ locale,
30
+ defaultLocale,
31
+ availableLocales,
32
+ setLocale
33
+ };
12
34
  };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var useLocale_exports = {};
31
- __export(useLocale_exports, {
32
- useLocale: () => useLocale
33
- });
34
- module.exports = __toCommonJS(useLocale_exports);
35
- var import_built = __toESM(require("@intlayer/config/built"));
36
- var import_hooks = require("preact/hooks");
37
- var import_IntlayerProvider = require('./IntlayerProvider.cjs');
38
- var import_useLocaleCookie = require('./useLocaleCookie.cjs');
39
- const useLocale = ({ onLocaleChange } = {}) => {
40
- const { defaultLocale, locales: availableLocales } = import_built.default?.internationalization ?? {};
41
- const { locale, setLocale: setLocaleState } = (0, import_hooks.useContext)(
42
- import_IntlayerProvider.IntlayerClientContext
43
- );
44
- const { setLocaleCookie } = (0, import_useLocaleCookie.useLocaleCookie)();
45
- const setLocale = (locale2) => {
46
- if (!availableLocales?.map(String).includes(locale2)) {
47
- console.error(`Locale ${locale2} is not available`);
48
- return;
49
- }
50
- setLocaleState(locale2);
51
- setLocaleCookie(locale2);
52
- onLocaleChange?.(locale2);
53
- };
54
- return {
55
- locale,
56
- // Current locale
57
- defaultLocale,
58
- // Principal locale defined in config
59
- availableLocales,
60
- // List of the available locales defined in config
61
- setLocale
62
- // Function to set the locale
63
- };
64
- };
65
- // Annotate the CommonJS export names for ESM import in node:
66
- 0 && (module.exports = {
67
- useLocale
68
- });
35
+
36
+ //#endregion
37
+ exports.useLocale = useLocale;
69
38
  //# sourceMappingURL=useLocale.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/config/client';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useLocaleCookie } from './useLocaleCookie';\n\ntype useLocaleProps = {\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocale = ({ onLocaleChange }: useLocaleProps = {}) => {\n const { defaultLocale, locales: availableLocales } =\n configuration?.internationalization ?? {};\n\n const { locale, setLocale: setLocaleState } = useContext(\n IntlayerClientContext\n );\n const { setLocaleCookie } = useLocaleCookie();\n\n const setLocale = (locale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleState(locale);\n setLocaleCookie(locale);\n onLocaleChange?.(locale);\n };\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA0B;AAE1B,mBAA2B;AAC3B,8BAAsC;AACtC,6BAAgC;AASzB,MAAM,YAAY,CAAC,EAAE,eAAe,IAAoB,CAAC,MAAM;AACpE,QAAM,EAAE,eAAe,SAAS,iBAAiB,IAC/C,aAAAA,SAAe,wBAAwB,CAAC;AAE1C,QAAM,EAAE,QAAQ,WAAW,eAAe,QAAI;AAAA,IAC5C;AAAA,EACF;AACA,QAAM,EAAE,gBAAgB,QAAI,wCAAgB;AAE5C,QAAM,YAAY,CAACC,YAA0B;AAC3C,QAAI,CAAC,kBAAkB,IAAI,MAAM,EAAE,SAASA,OAAM,GAAG;AACnD,cAAQ,MAAM,UAAUA,OAAM,mBAAmB;AACjD;AAAA,IACF;AAEA,mBAAeA,OAAM;AACrB,oBAAgBA,OAAM;AACtB,qBAAiBA,OAAM;AAAA,EACzB;AAEA,SAAO;AAAA,IACL;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,EACF;AACF;","names":["configuration","locale"]}
1
+ {"version":3,"file":"useLocale.cjs","names":["configuration","IntlayerClientContext","locale"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype useLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: useLocaleProps = {}) => {\n const { defaultLocale, locales: availableLocales } =\n configuration?.internationalization ?? {};\n\n const {\n locale,\n setLocale: setLocaleState,\n isCookieEnabled: isCookieEnabledContext,\n } = useContext(IntlayerClientContext);\n\n const setLocale = (locale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleState(locale);\n\n setLocaleInStorage(\n locale,\n isCookieEnabled ?? isCookieEnabledContext ?? true\n );\n\n onLocaleChange?.(locale);\n };\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,MAAa,aAAa,EACxB,iBACA,mBACkB,EAAE,KAAK;CACzB,MAAM,EAAE,eAAe,SAAS,qBAC9BA,iCAAe,wBAAwB,EAAE;CAE3C,MAAM,EACJ,QACA,WAAW,gBACX,iBAAiB,wDACJC,sDAAsB;CAErC,MAAM,aAAa,aAA0B;AAC3C,MAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAASC,SAAO,EAAE;AACnD,WAAQ,MAAM,UAAUA,SAAO,mBAAmB;AAClD;;AAGF,iBAAeA,SAAO;AAEtB,qDACEA,UACA,mBAAmB,0BAA0B,KAC9C;AAED,mBAAiBA,SAAO;;AAG1B,QAAO;EACL;EACA;EACA;EACA;EACD"}
@@ -1,56 +1,28 @@
1
- "use strict";
2
- "use client";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var useLocaleBase_exports = {};
31
- __export(useLocaleBase_exports, {
32
- useLocaleBase: () => useLocaleBase
33
- });
34
- module.exports = __toCommonJS(useLocaleBase_exports);
35
- var import_built = __toESM(require("@intlayer/config/built"));
36
- var import_hooks = require("preact/hooks");
37
- var import_IntlayerProvider = require('./IntlayerProvider.cjs');
38
- const { defaultLocale, locales: availableLocales } = import_built.default.internationalization;
1
+ 'use client';
2
+
3
+
4
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
5
+ const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
6
+ let __intlayer_config_built = require("@intlayer/config/built");
7
+ __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
8
+ let preact_hooks = require("preact/hooks");
9
+ preact_hooks = require_rolldown_runtime.__toESM(preact_hooks);
10
+
11
+ //#region src/client/useLocaleBase.ts
12
+ const { defaultLocale, locales: availableLocales } = __intlayer_config_built.default.internationalization;
13
+ /**
14
+ * On the client side, hook to get the current locale and all related fields
15
+ */
39
16
  const useLocaleBase = () => {
40
- const { locale, setLocale } = (0, import_hooks.useContext)(import_IntlayerProvider.IntlayerClientContext);
41
- return {
42
- locale,
43
- // Current locale
44
- defaultLocale,
45
- // Principal locale defined in config
46
- availableLocales,
47
- // List of the available locales defined in config
48
- setLocale
49
- // Function to set the locale
50
- };
17
+ const { locale, setLocale } = (0, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
18
+ return {
19
+ locale,
20
+ defaultLocale,
21
+ availableLocales,
22
+ setLocale
23
+ };
51
24
  };
52
- // Annotate the CommonJS export names for ESM import in node:
53
- 0 && (module.exports = {
54
- useLocaleBase
55
- });
25
+
26
+ //#endregion
27
+ exports.useLocaleBase = useLocaleBase;
56
28
  //# sourceMappingURL=useLocaleBase.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useLocaleBase.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\nconst { defaultLocale, locales: availableLocales } =\n configuration.internationalization;\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocaleBase = () => {\n const { locale, setLocale } = useContext(IntlayerClientContext);\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA0B;AAC1B,mBAA2B;AAC3B,8BAAsC;AAEtC,MAAM,EAAE,eAAe,SAAS,iBAAiB,IAC/C,aAAAA,QAAc;AAKT,MAAM,gBAAgB,MAAM;AACjC,QAAM,EAAE,QAAQ,UAAU,QAAI,yBAAW,6CAAqB;AAE9D,SAAO;AAAA,IACL;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,EACF;AACF;","names":["configuration"]}
1
+ {"version":3,"file":"useLocaleBase.cjs","names":["configuration","IntlayerClientContext"],"sources":["../../../src/client/useLocaleBase.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\nconst { defaultLocale, locales: availableLocales } =\n configuration.internationalization;\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocaleBase = () => {\n const { locale, setLocale } = useContext(IntlayerClientContext);\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";;;;;;;;;;;AAMA,MAAM,EAAE,eAAe,SAAS,qBAC9BA,gCAAc;;;;AAKhB,MAAa,sBAAsB;CACjC,MAAM,EAAE,QAAQ,2CAAyBC,sDAAsB;AAE/D,QAAO;EACL;EACA;EACA;EACA;EACD"}
@@ -0,0 +1,60 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ let __intlayer_core = require("@intlayer/core");
3
+ __intlayer_core = require_rolldown_runtime.__toESM(__intlayer_core);
4
+ let preact_hooks = require("preact/hooks");
5
+ preact_hooks = require_rolldown_runtime.__toESM(preact_hooks);
6
+
7
+ //#region src/client/useLocaleStorage.ts
8
+ /**
9
+ * Get the locale cookie
10
+ */
11
+ const localeInStorage = (0, __intlayer_core.getLocaleFromStorage)(__intlayer_core.localeStorageOptions);
12
+ /**
13
+ * @deprecated Use localeInStorage instead
14
+ *
15
+ * Get the locale cookie
16
+ */
17
+ const localeCookie = localeInStorage;
18
+ /**
19
+ * Set the locale cookie
20
+ */
21
+ const setLocaleInStorage = (locale, isCookieEnabled) => (0, __intlayer_core.setLocaleInStorage)(locale, {
22
+ ...__intlayer_core.localeStorageOptions,
23
+ isCookieEnabled
24
+ });
25
+ /**
26
+ * @deprecated Use setLocaleInStorage instead
27
+ *
28
+ * Set the locale cookie
29
+ */
30
+ const setLocaleCookie = setLocaleInStorage;
31
+ /**
32
+ * Hook that provides the locale storage and a function to set it
33
+ */
34
+ const useLocaleStorage = (isCookieEnabled) => (0, preact_hooks.useMemo)(() => (0, __intlayer_core.LocaleStorage)({
35
+ ...__intlayer_core.localeStorageOptions,
36
+ isCookieEnabled
37
+ }), [isCookieEnabled]);
38
+ /**
39
+ * @deprecated Use useLocaleStorage instead
40
+ *
41
+ * For GDPR compliance, use useLocaleStorage instead
42
+ *
43
+ * Hook that provides the locale cookie and a function to set it
44
+ */
45
+ const useLocaleCookie = (isCookieEnabled) => {
46
+ const storage = useLocaleStorage(isCookieEnabled);
47
+ return {
48
+ localeCookie: storage.getLocale(),
49
+ setLocaleCookie: storage.setLocale
50
+ };
51
+ };
52
+
53
+ //#endregion
54
+ exports.localeCookie = localeCookie;
55
+ exports.localeInStorage = localeInStorage;
56
+ exports.setLocaleCookie = setLocaleCookie;
57
+ exports.setLocaleInStorage = setLocaleInStorage;
58
+ exports.useLocaleCookie = useLocaleCookie;
59
+ exports.useLocaleStorage = useLocaleStorage;
60
+ //# sourceMappingURL=useLocaleStorage.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocaleStorage.cjs","names":["localeStorageOptions"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import {\n getLocaleFromStorage,\n LocaleStorage,\n localeStorageOptions,\n setLocaleInStorage as setLocaleInStorageCore,\n} from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { useMemo } from 'preact/hooks';\n\n/**\n * Get the locale cookie\n */\nexport const localeInStorage = getLocaleFromStorage(localeStorageOptions);\n/**\n * @deprecated Use localeInStorage instead\n *\n * Get the locale cookie\n */\nexport const localeCookie = localeInStorage;\n\n/**\n * Set the locale cookie\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n isCookieEnabled: boolean\n) =>\n setLocaleInStorageCore(locale, {\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n/**\n * @deprecated Use setLocaleInStorage instead\n *\n * Set the locale cookie\n */\nexport const setLocaleCookie = setLocaleInStorage;\n\n/**\n * Hook that provides the locale storage and a function to set it\n */\nexport const useLocaleStorage = (isCookieEnabled?: boolean) =>\n useMemo(\n () =>\n LocaleStorage({\n ...localeStorageOptions,\n isCookieEnabled,\n }),\n [isCookieEnabled]\n );\n\n/**\n * @deprecated Use useLocaleStorage instead\n *\n * For GDPR compliance, use useLocaleStorage instead\n *\n * Hook that provides the locale cookie and a function to set it\n */\nexport const useLocaleCookie = (isCookieEnabled?: boolean) => {\n const storage = useLocaleStorage(isCookieEnabled);\n return {\n localeCookie: storage.getLocale(),\n setLocaleCookie: storage.setLocale,\n };\n};\n"],"mappings":";;;;;;;;;;AAYA,MAAa,4DAAuCA,qCAAqB;;;;;;AAMzE,MAAa,eAAe;;;;AAK5B,MAAa,sBACX,QACA,4DAEuB,QAAQ;CAC7B,GAAGA;CACH;CACD,CAAC;;;;;;AAOJ,MAAa,kBAAkB;;;;AAK/B,MAAa,oBAAoB,uFAGb;CACZ,GAAGA;CACH;CACD,CAAC,EACJ,CAAC,gBAAgB,CAClB;;;;;;;;AASH,MAAa,mBAAmB,oBAA8B;CAC5D,MAAM,UAAU,iBAAiB,gBAAgB;AACjD,QAAO;EACL,cAAc,QAAQ,WAAW;EACjC,iBAAiB,QAAQ;EAC1B"}
@@ -1,38 +1,37 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var useTraduction_exports = {};
20
- __export(useTraduction_exports, {
21
- useTranslation: () => useTranslation
22
- });
23
- module.exports = __toCommonJS(useTraduction_exports);
24
- var import_core = require("@intlayer/core");
25
- var import_hooks = require("preact/hooks");
26
- var import_IntlayerProvider = require('./IntlayerProvider.cjs');
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
3
+ let __intlayer_core = require("@intlayer/core");
4
+ __intlayer_core = require_rolldown_runtime.__toESM(__intlayer_core);
5
+ let preact_hooks = require("preact/hooks");
6
+ preact_hooks = require_rolldown_runtime.__toESM(preact_hooks);
7
+
8
+ //#region src/client/useTraduction.ts
9
+ /**
10
+ * On the client side, Hook that picking one dictionary by its id and return the content.
11
+ *
12
+ * If not locale found, it will return the content related to the default locale.
13
+ *
14
+ * Return either the content editor, or the content itself depending on the configuration.
15
+ *
16
+ * Usage:
17
+ *
18
+ * ```tsx
19
+ * const content = useTranslation<string>({
20
+ * en: 'Hello',
21
+ * fr: 'Bonjour',
22
+ * }, 'fr');
23
+ * // 'Bonjour'
24
+ * ```
25
+ *
26
+ * Using TypeScript:
27
+ * - this function will require each locale to be defined if defined in the project configuration.
28
+ * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.
29
+ */
27
30
  const useTranslation = (languageContent) => {
28
- const { locale } = (0, import_hooks.useContext)(import_IntlayerProvider.IntlayerClientContext);
29
- return (0, import_hooks.useMemo)(
30
- () => (0, import_core.getTranslation)(languageContent, locale),
31
- [languageContent, locale]
32
- );
31
+ const { locale } = (0, preact_hooks.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
32
+ return (0, preact_hooks.useMemo)(() => (0, __intlayer_core.getTranslation)(languageContent, locale), [languageContent, locale]);
33
33
  };
34
- // Annotate the CommonJS export names for ESM import in node:
35
- 0 && (module.exports = {
36
- useTranslation
37
- });
34
+
35
+ //#endregion
36
+ exports.useTranslation = useTranslation;
38
37
  //# sourceMappingURL=useTraduction.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useTraduction.ts"],"sourcesContent":["import { getTranslation, type LanguageContent } from '@intlayer/core';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its id and return the content.\n *\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```tsx\n * const content = useTranslation<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const useTranslation = <Content = string>(\n languageContent: LanguageContent<Content>\n): Content => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useMemo(\n () => getTranslation(languageContent, locale),\n [languageContent, locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqD;AACrD,mBAAoC;AACpC,8BAAsC;AAuB/B,MAAM,iBAAiB,CAC5B,oBACY;AACZ,QAAM,EAAE,OAAO,QAAI,yBAAW,6CAAqB;AAEnD,aAAO;AAAA,IACL,UAAM,4BAAe,iBAAiB,MAAM;AAAA,IAC5C,CAAC,iBAAiB,MAAM;AAAA,EAC1B;AACF;","names":[]}
1
+ {"version":3,"file":"useTraduction.cjs","names":["IntlayerClientContext"],"sources":["../../../src/client/useTraduction.ts"],"sourcesContent":["import { getTranslation } from '@intlayer/core';\nimport type { StrictModeLocaleMap } from '@intlayer/types';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its id and return the content.\n *\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```tsx\n * const content = useTranslation<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const useTranslation = <Content = string>(\n languageContent: StrictModeLocaleMap<Content>\n): Content => {\n const { locale } = useContext(IntlayerClientContext);\n\n return useMemo(\n () => getTranslation(languageContent, locale),\n [languageContent, locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,kBACX,oBACY;CACZ,MAAM,EAAE,wCAAsBA,sDAAsB;AAEpD,4EACuB,iBAAiB,OAAO,EAC7C,CAAC,iBAAiB,OAAO,CAC1B"}