react-intlayer 2.0.12 → 3.0.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 (167) hide show
  1. package/README.md +51 -51
  2. package/dist/cjs/client/IntlayerProvider.cjs +2 -2
  3. package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
  4. package/dist/cjs/client/getBrowserLocale.cjs.map +1 -1
  5. package/dist/cjs/client/index.cjs +6 -0
  6. package/dist/cjs/client/index.cjs.map +1 -1
  7. package/dist/cjs/client/t.cjs +37 -0
  8. package/dist/cjs/client/t.cjs.map +1 -0
  9. package/dist/cjs/client/useDictionary.cjs +37 -0
  10. package/dist/cjs/client/useDictionary.cjs.map +1 -0
  11. package/dist/cjs/client/useIntlayer.cjs +2 -2
  12. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  13. package/dist/cjs/craco/craco.config.cjs.map +1 -1
  14. package/dist/cjs/craco/intlayerCracoPlugin.cjs.map +1 -1
  15. package/dist/cjs/index.cjs +4 -0
  16. package/dist/cjs/index.cjs.map +1 -1
  17. package/dist/cjs/processDictionary/index.cjs +3 -2
  18. package/dist/cjs/processDictionary/index.cjs.map +1 -1
  19. package/dist/cjs/server/index.cjs +6 -0
  20. package/dist/cjs/server/index.cjs.map +1 -1
  21. package/dist/cjs/server/serverContext.cjs.map +1 -1
  22. package/dist/cjs/server/t.cjs +36 -0
  23. package/dist/cjs/server/t.cjs.map +1 -0
  24. package/dist/cjs/server/useDictionary.cjs +35 -0
  25. package/dist/cjs/server/useDictionary.cjs.map +1 -0
  26. package/dist/cjs/server/useIntlayer.cjs +2 -2
  27. package/dist/cjs/server/useIntlayer.cjs.map +1 -1
  28. package/dist/cjs/useDictionaryBase.cjs +69 -0
  29. package/dist/cjs/useDictionaryBase.cjs.map +1 -0
  30. package/dist/cjs/useIntlayerBase.cjs +10 -29
  31. package/dist/cjs/useIntlayerBase.cjs.map +1 -1
  32. package/dist/cjs/vite/intlayerPlugin.cjs.map +1 -1
  33. package/dist/esm/client/IntlayerProvider.mjs +1 -1
  34. package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
  35. package/dist/esm/client/getBrowserLocale.mjs.map +1 -1
  36. package/dist/esm/client/index.mjs +4 -0
  37. package/dist/esm/client/index.mjs.map +1 -1
  38. package/dist/esm/client/t.mjs +14 -0
  39. package/dist/esm/client/t.mjs.map +1 -0
  40. package/dist/esm/client/useDictionary.mjs +14 -0
  41. package/dist/esm/client/useDictionary.mjs.map +1 -0
  42. package/dist/esm/client/useIntlayer.mjs +2 -2
  43. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  44. package/dist/esm/craco/craco.config.mjs.map +1 -1
  45. package/dist/esm/craco/intlayerCracoPlugin.mjs.map +1 -1
  46. package/dist/esm/index.mjs +5 -1
  47. package/dist/esm/index.mjs.map +1 -1
  48. package/dist/esm/processDictionary/index.mjs +3 -2
  49. package/dist/esm/processDictionary/index.mjs.map +1 -1
  50. package/dist/esm/server/index.mjs +4 -0
  51. package/dist/esm/server/index.mjs.map +1 -1
  52. package/dist/esm/server/serverContext.mjs.map +1 -1
  53. package/dist/esm/server/t.mjs +13 -0
  54. package/dist/esm/server/t.mjs.map +1 -0
  55. package/dist/esm/server/useDictionary.mjs +12 -0
  56. package/dist/esm/server/useDictionary.mjs.map +1 -0
  57. package/dist/esm/server/useIntlayer.mjs +2 -2
  58. package/dist/esm/server/useIntlayer.mjs.map +1 -1
  59. package/dist/esm/useDictionaryBase.mjs +45 -0
  60. package/dist/esm/useDictionaryBase.mjs.map +1 -0
  61. package/dist/esm/useIntlayerBase.mjs +12 -28
  62. package/dist/esm/useIntlayerBase.mjs.map +1 -1
  63. package/dist/esm/vite/intlayerPlugin.mjs.map +1 -1
  64. package/dist/types/cli/react-intlayer.d.ts +9 -0
  65. package/dist/types/cli/react-intlayer.d.ts.map +1 -0
  66. package/dist/types/client/IntlayerProvider.d.ts +25 -0
  67. package/dist/types/client/IntlayerProvider.d.ts.map +1 -0
  68. package/dist/{cjs → types}/client/getBrowserLocale.d.ts +5 -6
  69. package/dist/types/client/getBrowserLocale.d.ts.map +1 -0
  70. package/dist/types/client/index.d.ts +10 -0
  71. package/dist/types/client/index.d.ts.map +1 -0
  72. package/dist/types/client/t.d.ts +9 -0
  73. package/dist/types/client/t.d.ts.map +1 -0
  74. package/dist/types/client/useContent.d.ts +10 -0
  75. package/dist/types/client/useContent.d.ts.map +1 -0
  76. package/dist/types/client/useDictionary.d.ts +8 -0
  77. package/dist/types/client/useDictionary.d.ts.map +1 -0
  78. package/dist/types/client/useIntlayer.d.ts +8 -0
  79. package/dist/types/client/useIntlayer.d.ts.map +1 -0
  80. package/dist/types/client/useLocale.d.ts +11 -0
  81. package/dist/types/client/useLocale.d.ts.map +1 -0
  82. package/dist/types/client/useLocaleBase.d.ts +11 -0
  83. package/dist/types/client/useLocaleBase.d.ts.map +1 -0
  84. package/dist/types/client/useLocaleCookie.d.ts +17 -0
  85. package/dist/types/client/useLocaleCookie.d.ts.map +1 -0
  86. package/dist/{cjs → types}/client/useTraduction.d.ts +3 -5
  87. package/dist/types/client/useTraduction.d.ts.map +1 -0
  88. package/dist/types/craco/craco.config.d.ts +2 -0
  89. package/dist/types/craco/craco.config.d.ts.map +1 -0
  90. package/dist/types/craco/intlayerCracoPlugin.d.ts +24 -0
  91. package/dist/types/craco/intlayerCracoPlugin.d.ts.map +1 -0
  92. package/dist/{cjs → types}/getEnumeration.d.ts +3 -5
  93. package/dist/types/getEnumeration.d.ts.map +1 -0
  94. package/dist/{cjs → types}/getTranslation.d.ts +4 -6
  95. package/dist/types/getTranslation.d.ts.map +1 -0
  96. package/dist/types/index.d.ts +4 -0
  97. package/dist/types/index.d.ts.map +1 -0
  98. package/dist/types/processDictionary/contentDictionary.d.ts +14 -0
  99. package/dist/types/processDictionary/contentDictionary.d.ts.map +1 -0
  100. package/dist/types/processDictionary/index.d.ts +9 -0
  101. package/dist/types/processDictionary/index.d.ts.map +1 -0
  102. package/dist/types/server/IntlayerServerProvider.d.ts +34 -0
  103. package/dist/types/server/IntlayerServerProvider.d.ts.map +1 -0
  104. package/dist/types/server/getLocaleTranslation.d.ts +9 -0
  105. package/dist/types/server/getLocaleTranslation.d.ts.map +1 -0
  106. package/dist/types/server/index.d.ts +7 -0
  107. package/dist/types/server/index.d.ts.map +1 -0
  108. package/dist/{cjs → types}/server/serverContext.d.ts +4 -15
  109. package/dist/types/server/serverContext.d.ts.map +1 -0
  110. package/dist/types/server/t.d.ts +9 -0
  111. package/dist/types/server/t.d.ts.map +1 -0
  112. package/dist/types/server/useDictionary.d.ts +8 -0
  113. package/dist/types/server/useDictionary.d.ts.map +1 -0
  114. package/dist/types/server/useIntlayer.d.ts +8 -0
  115. package/dist/types/server/useIntlayer.d.ts.map +1 -0
  116. package/dist/{cjs → types}/server/useTraduction.d.ts +3 -5
  117. package/dist/types/server/useTraduction.d.ts.map +1 -0
  118. package/dist/types/useDictionaryBase.d.ts +37 -0
  119. package/dist/types/useDictionaryBase.d.ts.map +1 -0
  120. package/dist/types/useIntlayerBase.d.ts +39 -0
  121. package/dist/types/useIntlayerBase.d.ts.map +1 -0
  122. package/dist/{cjs → types}/vite/intlayerPlugin.d.ts +4 -5
  123. package/dist/types/vite/intlayerPlugin.d.ts.map +1 -0
  124. package/package.json +38 -28
  125. package/dist/cjs/cli/react-intlayer.d.ts +0 -1
  126. package/dist/cjs/client/IntlayerProvider.d.ts +0 -27
  127. package/dist/cjs/client/index.d.ts +0 -13
  128. package/dist/cjs/client/useContent.d.ts +0 -13
  129. package/dist/cjs/client/useIntlayer.d.ts +0 -14
  130. package/dist/cjs/client/useLocale.d.ts +0 -14
  131. package/dist/cjs/client/useLocaleBase.d.ts +0 -14
  132. package/dist/cjs/client/useLocaleCookie.d.ts +0 -19
  133. package/dist/cjs/craco/craco.config.d.ts +0 -2
  134. package/dist/cjs/craco/intlayerCracoPlugin.d.ts +0 -26
  135. package/dist/cjs/index.d.ts +0 -14
  136. package/dist/cjs/processDictionary/contentDictionary.d.ts +0 -16
  137. package/dist/cjs/processDictionary/index.d.ts +0 -12
  138. package/dist/cjs/server/IntlayerServerProvider.d.ts +0 -36
  139. package/dist/cjs/server/getLocaleTranslation.d.ts +0 -12
  140. package/dist/cjs/server/index.d.ts +0 -10
  141. package/dist/cjs/server/useIntlayer.d.ts +0 -14
  142. package/dist/cjs/useIntlayerBase.d.ts +0 -70
  143. package/dist/esm/cli/react-intlayer.d.mts +0 -1
  144. package/dist/esm/client/IntlayerProvider.d.mts +0 -27
  145. package/dist/esm/client/getBrowserLocale.d.mts +0 -26
  146. package/dist/esm/client/index.d.mts +0 -13
  147. package/dist/esm/client/useContent.d.mts +0 -13
  148. package/dist/esm/client/useIntlayer.d.mts +0 -14
  149. package/dist/esm/client/useLocale.d.mts +0 -14
  150. package/dist/esm/client/useLocaleBase.d.mts +0 -14
  151. package/dist/esm/client/useLocaleCookie.d.mts +0 -19
  152. package/dist/esm/client/useTraduction.d.mts +0 -26
  153. package/dist/esm/craco/craco.config.d.mts +0 -2
  154. package/dist/esm/craco/intlayerCracoPlugin.d.mts +0 -26
  155. package/dist/esm/getEnumeration.d.mts +0 -33
  156. package/dist/esm/getTranslation.d.mts +0 -27
  157. package/dist/esm/index.d.mts +0 -14
  158. package/dist/esm/processDictionary/contentDictionary.d.mts +0 -16
  159. package/dist/esm/processDictionary/index.d.mts +0 -12
  160. package/dist/esm/server/IntlayerServerProvider.d.mts +0 -36
  161. package/dist/esm/server/getLocaleTranslation.d.mts +0 -12
  162. package/dist/esm/server/index.d.mts +0 -10
  163. package/dist/esm/server/serverContext.d.mts +0 -35
  164. package/dist/esm/server/useIntlayer.d.mts +0 -14
  165. package/dist/esm/server/useTraduction.d.mts +0 -26
  166. package/dist/esm/useIntlayerBase.d.mts +0 -70
  167. package/dist/esm/vite/intlayerPlugin.d.mts +0 -17
@@ -0,0 +1,13 @@
1
+ import "../chunk-ZD7AOCMD.mjs";
2
+ import { getTranslation } from '../getTranslation.mjs';
3
+ import { IntlayerServerContext } from './IntlayerServerProvider.mjs';
4
+ import { getServerContext } from './serverContext.mjs';
5
+ const t = (multilangContent, locale) => {
6
+ const currentLocale = getServerContext(IntlayerServerContext);
7
+ const localeTarget = locale ?? currentLocale;
8
+ return getTranslation(multilangContent, localeTarget);
9
+ };
10
+ export {
11
+ t
12
+ };
13
+ //# sourceMappingURL=t.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/server/t.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport type { LanguageContent } from '@intlayer/core';\nimport { getTranslation } from '../getTranslation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the service side, this function returns the translation of the provided multilang content.\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const t = <Content = string>(\n multilangContent: LanguageContent<Content>,\n locale?: Locales\n) => {\n const currentLocale = getServerContext<Locales>(IntlayerServerContext);\n const localeTarget = locale ?? currentLocale;\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":";AAEA,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAO1B,MAAM,IAAI,CACf,kBACA,WACG;AACH,QAAM,gBAAgB,iBAA0B,qBAAqB;AACrE,QAAM,eAAe,UAAU;AAE/B,SAAO,eAAwB,kBAAkB,YAAY;AAC/D;","names":[]}
@@ -0,0 +1,12 @@
1
+ import "../chunk-ZD7AOCMD.mjs";
2
+ import { useDictionaryBase } from '../useDictionaryBase.mjs';
3
+ import { IntlayerServerContext } from './IntlayerServerProvider.mjs';
4
+ import { getServerContext } from './serverContext.mjs';
5
+ const useDictionary = (dictionary, locale) => {
6
+ const localeTarget = locale ?? getServerContext(IntlayerServerContext);
7
+ return useDictionaryBase(dictionary, localeTarget);
8
+ };
9
+ export {
10
+ useDictionary
11
+ };
12
+ //# sourceMappingURL=useDictionary.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport type { DeclarationContent } from '@intlayer/core';\nimport { useDictionaryBase, type UseDictionary } from '../useDictionaryBase';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\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 server context\n */\nexport const useDictionary: UseDictionary = <T extends DeclarationContent>(\n dictionary: T,\n locale?: Locales\n) => {\n const localeTarget =\n locale ?? getServerContext<Locales>(IntlayerServerContext);\n\n return useDictionaryBase(dictionary, localeTarget);\n};\n"],"mappings":";AAEA,SAAS,yBAA6C;AACtD,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAO1B,MAAM,gBAA+B,CAC1C,YACA,WACG;AACH,QAAM,eACJ,UAAU,iBAA0B,qBAAqB;AAE3D,SAAO,kBAAkB,YAAY,YAAY;AACnD;","names":[]}
@@ -4,9 +4,9 @@ import {
4
4
  } from '../useIntlayerBase.mjs';
5
5
  import { IntlayerServerContext } from './IntlayerServerProvider.mjs';
6
6
  import { getServerContext } from './serverContext.mjs';
7
- const useIntlayer = (id, locale) => {
7
+ const useIntlayer = (key, locale) => {
8
8
  const localeTarget = locale ?? getServerContext(IntlayerServerContext);
9
- return useIntlayerBase(id, localeTarget);
9
+ return useIntlayerBase(key, localeTarget);
10
10
  };
11
11
  export {
12
12
  useIntlayer
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport {\n type DictionaryKeys,\n useIntlayerBase,\n type UseIntlayer,\n} from '../useIntlayerBase';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that picking one dictionary by its id and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useIntlayer: UseIntlayer = <T extends DictionaryKeys>(\n id: T,\n locale?: Locales\n) => {\n const localeTarget =\n locale ?? getServerContext<Locales>(IntlayerServerContext);\n\n return useIntlayerBase(id, localeTarget);\n};\n"],"mappings":";AACA;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAO1B,MAAM,cAA2B,CACtC,IACA,WACG;AACH,QAAM,eACJ,UAAU,iBAA0B,qBAAqB;AAE3D,SAAO,gBAAgB,IAAI,YAAY;AACzC;","names":[]}
1
+ {"version":3,"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport {\n type DictionaryKeys,\n useIntlayerBase,\n type UseIntlayer,\n} from '../useIntlayerBase';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server 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 server context\n */\nexport const useIntlayer: UseIntlayer = <T extends DictionaryKeys>(\n key: T,\n locale?: Locales\n) => {\n const localeTarget =\n locale ?? getServerContext<Locales>(IntlayerServerContext);\n\n return useIntlayerBase(key, localeTarget);\n};\n"],"mappings":";AACA;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAO1B,MAAM,cAA2B,CACtC,KACA,WACG;AACH,QAAM,eACJ,UAAU,iBAA0B,qBAAqB;AAE3D,SAAO,gBAAgB,KAAK,YAAY;AAC1C;","names":[]}
@@ -0,0 +1,45 @@
1
+ import "./chunk-ZD7AOCMD.mjs";
2
+ import { renderIntlayerEditor } from "intlayer-editor";
3
+ import { isValidElement } from "react";
4
+ import { processDictionary } from './processDictionary/index.mjs';
5
+ const recursiveTransformContent = (value, isContentSelectable = false) => {
6
+ if (typeof value === "function") {
7
+ return (props) => recursiveTransformContent(value(props), isContentSelectable);
8
+ } else if (typeof value === "object") {
9
+ if (typeof value.dictionaryId !== "undefined") {
10
+ return renderIntlayerEditor(value, isContentSelectable);
11
+ } else if (Array.isArray(value)) {
12
+ return value.map(
13
+ (el) => recursiveTransformContent(el, isContentSelectable)
14
+ );
15
+ } else if (isValidElement(value)) {
16
+ return value;
17
+ }
18
+ return Object.entries(value).reduce(
19
+ (acc, [key, value2]) => ({
20
+ ...acc,
21
+ [key]: recursiveTransformContent(value2, isContentSelectable)
22
+ }),
23
+ {}
24
+ );
25
+ }
26
+ return value;
27
+ };
28
+ const useDictionaryBase = (dictionary, locale, isContentSelectable = false) => {
29
+ const result = processDictionary(
30
+ dictionary.content,
31
+ dictionary.key,
32
+ dictionary.filePath,
33
+ [],
34
+ locale
35
+ );
36
+ return recursiveTransformContent(
37
+ result,
38
+ isContentSelectable
39
+ );
40
+ };
41
+ export {
42
+ recursiveTransformContent,
43
+ useDictionaryBase
44
+ };
45
+ //# sourceMappingURL=useDictionaryBase.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/useDictionaryBase.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Locales } from '@intlayer/config';\nimport type {\n DeclarationContent,\n DictionaryValue,\n NodeType,\n} from '@intlayer/core';\nimport { renderIntlayerEditor } from 'intlayer-editor';\nimport { isValidElement, type ReactNode } from 'react';\nimport { processDictionary } from './processDictionary/index';\n\nexport type IntlayerNode<T = string> = ReactNode & {\n value: T;\n};\n\ntype TransformNodeType<T, L extends Locales> = T extends {\n [NodeType.Enumeration]: { '1': any };\n}\n ? (quantity: number) => DeepTransformContent<T[NodeType.Enumeration]['1'], L>\n : T extends {\n [NodeType.Translation]: object;\n }\n ? L extends keyof T[NodeType.Translation]\n ? DeepTransformContent<T[NodeType.Translation][L], L>\n : never\n : T;\n\nexport type DeepTransformContent<T, L extends Locales> = T extends object // Check if the property is an object\n ? T extends (infer U)[] // If it's an array, infer the type of array elements\n ? DeepTransformContent<U, L>[] // Apply DeepTransformContent recursively to each element of the array\n : T extends {\n nodeType: NodeType | string;\n }\n ? TransformNodeType<T, L>\n : T extends { _owner: any; key: any; props: any; ref: any }\n ? ReactNode\n : {\n [K in keyof T]: DeepTransformContent<T[K], L>;\n }\n : T extends undefined\n ? never\n : IntlayerNode<T>;\n\n/**\n * Go through the object. If a object has a keyPath, render the intlayer editor if editor enabled.\n */\nexport const recursiveTransformContent = (\n value: any,\n isContentSelectable = false\n): object => {\n if (typeof value === 'function') {\n return (props: any) =>\n recursiveTransformContent(value(props), isContentSelectable);\n } else if (typeof value === 'object') {\n if (typeof value.dictionaryId !== 'undefined') {\n return renderIntlayerEditor(value, isContentSelectable);\n } else if (Array.isArray(value)) {\n return value.map((el) =>\n recursiveTransformContent(el, isContentSelectable)\n );\n } else if (isValidElement(value)) {\n return value;\n }\n\n return Object.entries(value).reduce(\n (acc, [key, value]) => ({\n ...acc,\n [key]: recursiveTransformContent(value, isContentSelectable),\n }),\n {} as object\n );\n }\n\n return value;\n};\n\ntype DataFromDictionary<\n T extends DeclarationContent,\n K extends Locales,\n> = DeepTransformContent<T['content'], K>;\n\nexport type UseDictionary = <T extends DeclarationContent, L extends Locales>(\n dictionary: T,\n locale?: L\n) => DataFromDictionary<T, L>;\n\n// Add description is JSDoc\n/**\n * Hook that picks one dictionary by its id and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryBase: UseDictionary = <\n T extends DeclarationContent,\n L extends Locales,\n>(\n dictionary: T,\n locale?: L,\n isContentSelectable = false\n) => {\n const result = processDictionary(\n dictionary.content as DictionaryValue,\n dictionary.key,\n dictionary.filePath,\n [],\n locale\n );\n\n return recursiveTransformContent(\n result,\n isContentSelectable\n ) as DataFromDictionary<T, L>;\n};\n"],"mappings":";AAOA,SAAS,4BAA4B;AACrC,SAAS,sBAAsC;AAC/C,SAAS,yBAAyB;AAqC3B,MAAM,4BAA4B,CACvC,OACA,sBAAsB,UACX;AACX,MAAI,OAAO,UAAU,YAAY;AAC/B,WAAO,CAAC,UACN,0BAA0B,MAAM,KAAK,GAAG,mBAAmB;AAAA,EAC/D,WAAW,OAAO,UAAU,UAAU;AACpC,QAAI,OAAO,MAAM,iBAAiB,aAAa;AAC7C,aAAO,qBAAqB,OAAO,mBAAmB;AAAA,IACxD,WAAW,MAAM,QAAQ,KAAK,GAAG;AAC/B,aAAO,MAAM;AAAA,QAAI,CAAC,OAChB,0BAA0B,IAAI,mBAAmB;AAAA,MACnD;AAAA,IACF,WAAW,eAAe,KAAK,GAAG;AAChC,aAAO;AAAA,IACT;AAEA,WAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,MAC3B,CAAC,KAAK,CAAC,KAAKA,MAAK,OAAO;AAAA,QACtB,GAAG;AAAA,QACH,CAAC,GAAG,GAAG,0BAA0BA,QAAO,mBAAmB;AAAA,MAC7D;AAAA,MACA,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;AAkBO,MAAM,oBAAmC,CAI9C,YACA,QACA,sBAAsB,UACnB;AACH,QAAM,SAAS;AAAA,IACb,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX,CAAC;AAAA,IACD;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":["value"]}
@@ -1,41 +1,25 @@
1
1
  import "./chunk-ZD7AOCMD.mjs";
2
2
  import dictionaries from "@intlayer/dictionaries-entry";
3
- import { renderIntlayerEditor } from "intlayer-editor/client";
4
- import { isValidElement } from "react";
5
3
  import { processDictionary } from './processDictionary/index.mjs';
6
- const recursiveTransformContent = (value) => {
7
- if (typeof value === "function") {
8
- return (props) => recursiveTransformContent(value(props));
9
- } else if (typeof value === "object" && typeof value.keyPath !== "undefined" && typeof value.dictionaryId !== "undefined" && typeof value.dictionaryPath !== "undefined") {
10
- return renderIntlayerEditor(value);
11
- } else if (typeof value === "object" && Array.isArray(value)) {
12
- return value.map(recursiveTransformContent);
13
- } else if (typeof value === "object" && isValidElement(value)) {
14
- return value;
15
- } else if (typeof value === "object") {
16
- return Object.entries(value).reduce(
17
- (acc, [key, value2]) => ({
18
- ...acc,
19
- [key]: recursiveTransformContent(value2)
20
- }),
21
- {}
22
- );
23
- }
24
- return value.value;
25
- };
26
- const useIntlayerBase = (id, locale) => {
27
- const dictionary = dictionaries[id];
4
+ import {
5
+ recursiveTransformContent
6
+ } from './useDictionaryBase.mjs';
7
+ const useIntlayerBase = (key, locale) => {
8
+ const dictionary = dictionaries[key];
28
9
  const result = processDictionary(
29
- dictionary,
30
- id,
10
+ dictionary.content,
11
+ dictionary.key,
31
12
  dictionary.filePath,
32
13
  [],
33
14
  locale
34
15
  );
35
- return recursiveTransformContent(result);
16
+ const isContentSelectable = true;
17
+ return recursiveTransformContent(
18
+ result,
19
+ isContentSelectable
20
+ );
36
21
  };
37
22
  export {
38
- recursiveTransformContent,
39
23
  useIntlayerBase
40
24
  };
41
25
  //# sourceMappingURL=useIntlayerBase.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/useIntlayerBase.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Locales } from '@intlayer/config';\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport type { Dictionary, NodeType } from '@intlayer/core';\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { renderIntlayerEditor } from 'intlayer-editor/client';\nimport { isValidElement, type ReactNode } from 'react';\nimport { processDictionary } from './processDictionary/index';\n\n/**\n * Provides a fallback to string type if the generic type T is never,\n * otherwise returns T. This is useful for handling cases where no keys are found.\n * Example: StringFallback<never> -> string; StringFallback<'key'> -> 'key'\n */\nexport type StringFallback<T> = T extends never ? string : T; // If no keys are found, return string to disable error, and accept any string as dictionary key\n\n/**\n * Represents the keys of the IntlayerDictionaryTypesConnector,\n * ensuring they are valid dictionary keys or fallback to string if none exist.\n *\n * Example:\n * ```ts\n * DictionaryKeys -> 'key1' | 'key2'\n * // or if IntlayerDictionaryTypesConnector is not defined,\n * DictionaryKeys -> string\n * ```\n */\nexport type DictionaryKeys = StringFallback<\n keyof IntlayerDictionaryTypesConnector\n>;\n\nexport type IntlayerNode<T = string> = ReactNode & {\n value: T;\n};\n\ntype TransformNodeType<T, L extends Locales> = T extends {\n [NodeType.Enumeration]: { '1': any };\n}\n ? (quantity: number) => DeepTransformContent<T[NodeType.Enumeration]['1'], L>\n : T extends {\n [NodeType.Translation]: object;\n }\n ? L extends keyof T[NodeType.Translation]\n ? DeepTransformContent<T[NodeType.Translation][L], L> // DeepTransformContent<T[L], L>\n : never\n : T;\n\ntype DeepTransformContent<T, L extends Locales> = T extends object // Check if the property is an object\n ? T extends (infer U)[] // If it's an array, infer the type of array elements\n ? DeepTransformContent<U, L>[] // Apply DeepTransformContent recursively to each element of the array\n : T extends {\n nodeType: NodeType | string;\n }\n ? TransformNodeType<T, L>\n : T extends { _owner: any; key: any; props: any; ref: any }\n ? ReactNode\n : {\n [K in keyof T]: DeepTransformContent<T[K], L>;\n }\n : T extends undefined\n ? never\n : IntlayerNode<T>;\n\n/**\n * Excludes the 'id' and 'filePath' keys from the dictionary content,\n * as they are not part of the IntlayerDictionaryTypesConnector type.\n */\ntype ExcludeIntlayerUtilsKeys<T> = Omit<T, 'id' | 'filePath'>;\n\n/**\n * Represents the data type returned by the useIntlayer hook,\n * excluding the 'id' and 'filePath' keys from the dictionary content.\n */\ntype Data<\n T extends DictionaryKeys,\n K extends Locales,\n> = ExcludeIntlayerUtilsKeys<\n DeepTransformContent<IntlayerDictionaryTypesConnector[T], K>\n>;\n\n/**\n * Parcourt the object. If a object has a keyPath, render the intlayer editor if editor enabled.\n */\nexport const recursiveTransformContent = (value: any): object => {\n if (typeof value === 'function') {\n return (props: any) => recursiveTransformContent(value(props));\n } else if (\n typeof value === 'object' &&\n typeof value.keyPath !== 'undefined' &&\n typeof value.dictionaryId !== 'undefined' &&\n typeof value.dictionaryPath !== 'undefined'\n ) {\n return renderIntlayerEditor(value);\n } else if (typeof value === 'object' && Array.isArray(value)) {\n return value.map(recursiveTransformContent);\n } else if (typeof value === 'object' && isValidElement(value)) {\n return value;\n } else if (typeof value === 'object') {\n return Object.entries(value).reduce(\n (acc, [key, value]) => ({\n ...acc,\n [key]: recursiveTransformContent(value),\n }),\n {} as object\n );\n }\n\n return value.value;\n};\n\n/**\n * Type definition for the useIntlayer hook, which takes a dictionary ID and an optional locale,\n * and returns the deeply transformed dictionary content.\n *\n */\nexport type UseIntlayer = <T extends DictionaryKeys, L extends Locales>(\n id: T,\n locale?: L\n) => Data<T, L>;\n\n/**\n * Hook that picks one dictionary by its ID and returns the content,\n * deeply transformed according to the dictionary structure and metadata.\n */\nexport const useIntlayerBase: UseIntlayer = <\n T extends DictionaryKeys,\n L extends Locales,\n>(\n id: T,\n locale?: L\n) => {\n const dictionary: Dictionary = dictionaries[id as keyof typeof dictionaries];\n\n const result = processDictionary(\n dictionary,\n id,\n dictionary.filePath,\n [],\n locale\n ) as object;\n\n return recursiveTransformContent(result) as Data<T, L>;\n};\n"],"mappings":";AAQA,OAAO,kBAAkB;AAEzB,SAAS,4BAA4B;AACrC,SAAS,sBAAsC;AAC/C,SAAS,yBAAyB;AA4E3B,MAAM,4BAA4B,CAAC,UAAuB;AAC/D,MAAI,OAAO,UAAU,YAAY;AAC/B,WAAO,CAAC,UAAe,0BAA0B,MAAM,KAAK,CAAC;AAAA,EAC/D,WACE,OAAO,UAAU,YACjB,OAAO,MAAM,YAAY,eACzB,OAAO,MAAM,iBAAiB,eAC9B,OAAO,MAAM,mBAAmB,aAChC;AACA,WAAO,qBAAqB,KAAK;AAAA,EACnC,WAAW,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAAG;AAC5D,WAAO,MAAM,IAAI,yBAAyB;AAAA,EAC5C,WAAW,OAAO,UAAU,YAAY,eAAe,KAAK,GAAG;AAC7D,WAAO;AAAA,EACT,WAAW,OAAO,UAAU,UAAU;AACpC,WAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,MAC3B,CAAC,KAAK,CAAC,KAAKA,MAAK,OAAO;AAAA,QACtB,GAAG;AAAA,QACH,CAAC,GAAG,GAAG,0BAA0BA,MAAK;AAAA,MACxC;AAAA,MACA,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO,MAAM;AACf;AAgBO,MAAM,kBAA+B,CAI1C,IACA,WACG;AACH,QAAM,aAAyB,aAAa,EAA+B;AAE3E,QAAM,SAAS;AAAA,IACb;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,CAAC;AAAA,IACD;AAAA,EACF;AAEA,SAAO,0BAA0B,MAAM;AACzC;","names":["value"]}
1
+ {"version":3,"sources":["../../src/useIntlayerBase.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { processDictionary } from './processDictionary/index';\nimport {\n type DeepTransformContent,\n recursiveTransformContent,\n} from './useDictionaryBase';\n\n/**\n * Provides a fallback to string type if the generic type T is never,\n * otherwise returns T. This is useful for handling cases where no keys are found.\n * Example: StringFallback<never> -> string; StringFallback<'key'> -> 'key'\n */\nexport type StringFallback<T> = T extends never ? string : T; // If no keys are found, return string to disable error, and accept any string as dictionary key\n\n/**\n * Represents the keys of the IntlayerDictionaryTypesConnector,\n * ensuring they are valid dictionary keys or fallback to string if none exist.\n *\n * Example:\n * ```ts\n * DictionaryKeys -> 'key1' | 'key2'\n * // or if IntlayerDictionaryTypesConnector is not defined,\n * DictionaryKeys -> string\n * ```\n */\nexport type DictionaryKeys = StringFallback<\n keyof IntlayerDictionaryTypesConnector\n>;\n\n/**\n * Represents the data type returned by the useIntlayer hook,\n * excluding the 'id' and 'filePath' keys from the dictionary content.\n */\ntype DataFromDictionaryKey<\n T extends DictionaryKeys,\n K extends Locales,\n> = DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content'], K>;\n\n/**\n * Type definition for the useIntlayer hook, which takes a dictionary ID and an optional locale,\n * and returns the deeply transformed dictionary content.\n *\n */\nexport type UseIntlayer = <T extends DictionaryKeys, L extends Locales>(\n key: T,\n locale?: L\n) => DataFromDictionaryKey<T, L>;\n\n/**\n * Hook that picks one dictionary by its ID and returns the content,\n * deeply transformed according to the dictionary structure and metadata.\n */\nexport const useIntlayerBase: UseIntlayer = <\n T extends DictionaryKeys,\n L extends Locales,\n>(\n key: T,\n locale?: L\n) => {\n const dictionary: Dictionary = dictionaries[key as keyof typeof dictionaries];\n\n const result = processDictionary(\n dictionary.content,\n dictionary.key,\n dictionary.filePath,\n [],\n locale\n );\n\n const isContentSelectable = true;\n\n return recursiveTransformContent(\n result,\n isContentSelectable\n ) as DataFromDictionaryKey<T, L>;\n};\n"],"mappings":";AAOA,OAAO,kBAAkB;AAEzB,SAAS,yBAAyB;AAClC;AAAA,EAEE;AAAA,OACK;AA+CA,MAAM,kBAA+B,CAI1C,KACA,WACG;AACH,QAAM,aAAyB,aAAa,GAAgC;AAE5E,QAAM,SAAS;AAAA,IACb,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX,CAAC;AAAA,IACD;AAAA,EACF;AAEA,QAAM,sBAAsB;AAE5B,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/vite/intlayerPlugin.ts"],"sourcesContent":["import { join, relative, resolve } from 'path';\nimport { watch } from '@intlayer/chokidar';\nimport { getConfiguration, formatEnvVariable } from '@intlayer/config';\nimport { loadEnv, type Plugin } from 'vite';\n\n// Plugin options type definition\ntype PluginOptions = {\n // Custom options for your plugin, if any\n};\n\n/**\n *\n * A Vite plugin that integrates IntLayer configuration into the build process\n *\n * ```ts\n * // Example usage of the plugin in a Vite configuration\n * export default defineConfig({\n * plugins: [ intLayerPlugin() ],\n * });\n * ```\n * */\nexport const intLayerPlugin = (_pluginOptions: PluginOptions = {}): Plugin => ({\n name: 'vite-intlayer-plugin',\n\n config: (config, { mode }) => {\n const intlayerConfig = getConfiguration();\n\n // Set all configuration values as environment variables\n const env = formatEnvVariable('vite');\n\n process.env = { ...process.env, ...loadEnv(mode, process.cwd()), ...env };\n\n const { mainDir, baseDir } = intlayerConfig.content;\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n // Update Vite's resolve alias\n config.resolve = {\n ...config.resolve,\n alias: {\n ...config.resolve?.alias,\n '@intlayer/dictionaries-entry': resolve(relativeDictionariesPath),\n },\n };\n\n const externals: string[] = (config.build?.rollupOptions?.external ??\n []) as string[];\n\n config.build = {\n ...config.build,\n rollupOptions: {\n ...config.build?.rollupOptions,\n external: [...externals, 'module'],\n },\n };\n\n return config;\n },\n\n buildStart: () => {\n // Code to run when Vite build starts\n watch({\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n persistent: (import.meta as any).env === 'development',\n });\n },\n configureServer: () => {\n // Custom server configuration, if needed\n },\n});\n"],"mappings":";AAAA,SAAS,MAAM,UAAU,eAAe;AACxC,SAAS,aAAa;AACtB,SAAS,kBAAkB,yBAAyB;AACpD,SAAS,eAA4B;AAkB9B,MAAM,iBAAiB,CAAC,iBAAgC,CAAC,OAAe;AAAA,EAC7E,MAAM;AAAA,EAEN,QAAQ,CAAC,QAAQ,EAAE,KAAK,MAAM;AAC5B,UAAM,iBAAiB,iBAAiB;AAGxC,UAAM,MAAM,kBAAkB,MAAM;AAEpC,YAAQ,MAAM,EAAE,GAAG,QAAQ,KAAK,GAAG,QAAQ,MAAM,QAAQ,IAAI,CAAC,GAAG,GAAG,IAAI;AAExE,UAAM,EAAE,SAAS,QAAQ,IAAI,eAAe;AAC5C,UAAM,mBAAmB,KAAK,SAAS,kBAAkB;AACzD,UAAM,2BAA2B,SAAS,SAAS,gBAAgB;AAGnE,WAAO,UAAU;AAAA,MACf,GAAG,OAAO;AAAA,MACV,OAAO;AAAA,QACL,GAAG,OAAO,SAAS;AAAA,QACnB,gCAAgC,QAAQ,wBAAwB;AAAA,MAClE;AAAA,IACF;AAEA,UAAM,YAAuB,OAAO,OAAO,eAAe,YACxD,CAAC;AAEH,WAAO,QAAQ;AAAA,MACb,GAAG,OAAO;AAAA,MACV,eAAe;AAAA,QACb,GAAG,OAAO,OAAO;AAAA,QACjB,UAAU,CAAC,GAAG,WAAW,QAAQ;AAAA,MACnC;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,MAAM;AAEhB,UAAM;AAAA;AAAA,MAEJ,YAAa,YAAoB,QAAQ;AAAA,IAC3C,CAAC;AAAA,EACH;AAAA,EACA,iBAAiB,MAAM;AAAA,EAEvB;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/vite/intlayerPlugin.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-object-type */\n\nimport { join, relative, resolve } from 'path';\nimport { watch } from '@intlayer/chokidar';\nimport { getConfiguration, formatEnvVariable } from '@intlayer/config';\nimport { loadEnv, type Plugin } from 'vite';\n\n// Plugin options type definition\ntype PluginOptions = {\n // Custom options for your plugin, if any\n};\n\n/**\n *\n * A Vite plugin that integrates IntLayer configuration into the build process\n *\n * ```ts\n * // Example usage of the plugin in a Vite configuration\n * export default defineConfig({\n * plugins: [ intLayerPlugin() ],\n * });\n * ```\n * */\nexport const intLayerPlugin = (_pluginOptions: PluginOptions = {}): Plugin => ({\n name: 'vite-intlayer-plugin',\n\n config: (config, { mode }) => {\n const intlayerConfig = getConfiguration();\n\n // Set all configuration values as environment variables\n const env = formatEnvVariable('vite');\n\n process.env = { ...process.env, ...loadEnv(mode, process.cwd()), ...env };\n\n const { mainDir, baseDir } = intlayerConfig.content;\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n // Update Vite's resolve alias\n config.resolve = {\n ...config.resolve,\n alias: {\n ...config.resolve?.alias,\n '@intlayer/dictionaries-entry': resolve(relativeDictionariesPath),\n },\n };\n\n const externals: string[] = (config.build?.rollupOptions?.external ??\n []) as string[];\n\n config.build = {\n ...config.build,\n rollupOptions: {\n ...config.build?.rollupOptions,\n external: [...externals, 'module'],\n },\n };\n\n return config;\n },\n\n buildStart: () => {\n // Code to run when Vite build starts\n watch({\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n persistent: (import.meta as any).env === 'development',\n });\n },\n configureServer: () => {\n // Custom server configuration, if needed\n },\n});\n"],"mappings":";AAEA,SAAS,MAAM,UAAU,eAAe;AACxC,SAAS,aAAa;AACtB,SAAS,kBAAkB,yBAAyB;AACpD,SAAS,eAA4B;AAkB9B,MAAM,iBAAiB,CAAC,iBAAgC,CAAC,OAAe;AAAA,EAC7E,MAAM;AAAA,EAEN,QAAQ,CAAC,QAAQ,EAAE,KAAK,MAAM;AAC5B,UAAM,iBAAiB,iBAAiB;AAGxC,UAAM,MAAM,kBAAkB,MAAM;AAEpC,YAAQ,MAAM,EAAE,GAAG,QAAQ,KAAK,GAAG,QAAQ,MAAM,QAAQ,IAAI,CAAC,GAAG,GAAG,IAAI;AAExE,UAAM,EAAE,SAAS,QAAQ,IAAI,eAAe;AAC5C,UAAM,mBAAmB,KAAK,SAAS,kBAAkB;AACzD,UAAM,2BAA2B,SAAS,SAAS,gBAAgB;AAGnE,WAAO,UAAU;AAAA,MACf,GAAG,OAAO;AAAA,MACV,OAAO;AAAA,QACL,GAAG,OAAO,SAAS;AAAA,QACnB,gCAAgC,QAAQ,wBAAwB;AAAA,MAClE;AAAA,IACF;AAEA,UAAM,YAAuB,OAAO,OAAO,eAAe,YACxD,CAAC;AAEH,WAAO,QAAQ;AAAA,MACb,GAAG,OAAO;AAAA,MACV,eAAe;AAAA,QACb,GAAG,OAAO,OAAO;AAAA,QACjB,UAAU,CAAC,GAAG,WAAW,QAAQ;AAAA,MACnC;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,MAAM;AAEhB,UAAM;AAAA;AAAA,MAEJ,YAAa,YAAoB,QAAQ;AAAA,IAC3C,CAAC;AAAA,EACH;AAAA,EACA,iBAAiB,MAAM;AAAA,EAEvB;AACF;","names":[]}
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * To make the setup easier, we are using craco to override the webpack configuration.
4
+ * This script is used to run the craco scripts with the custom configuration.
5
+ *
6
+ * The script is based on the original craco script from create-react-app.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=react-intlayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-intlayer.d.ts","sourceRoot":"","sources":["../../../src/cli/react-intlayer.ts"],"names":[],"mappings":";AAEA;;;;;GAKG"}
@@ -0,0 +1,25 @@
1
+ import { type Locales } from '@intlayer/config/client';
2
+ import { type PropsWithChildren, type FC } from 'react';
3
+ type IntlayerValue = {
4
+ locale: Locales;
5
+ setLocale: (newLocale: Locales) => void;
6
+ };
7
+ /**
8
+ * Context that store the current locale on the client side
9
+ */
10
+ export declare const IntlayerClientContext: import("react").Context<IntlayerValue>;
11
+ /**
12
+ * Hook that provides the current locale
13
+ */
14
+ export declare const useIntlayerContext: () => IntlayerValue;
15
+ export type IntlayerProviderProps = PropsWithChildren & {
16
+ locale?: Locales;
17
+ setLocale?: (locale: Locales) => void;
18
+ editorEnabled?: boolean;
19
+ };
20
+ /**
21
+ * Provider that store the current locale on the client side
22
+ */
23
+ export declare const IntlayerProvider: FC<IntlayerProviderProps>;
24
+ export {};
25
+ //# sourceMappingURL=IntlayerProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IntlayerProvider.d.ts","sourceRoot":"","sources":["../../../src/client/IntlayerProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,EACL,KAAK,iBAAiB,EAItB,KAAK,EAAE,EAGR,MAAM,OAAO,CAAC;AAGf,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,wCAGhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,qBAA0C,CAAC;AAE1E,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,GAAG;IACtD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CA+CtD,CAAC"}
@@ -1,6 +1,5 @@
1
- import { Locales } from '@intlayer/config/client';
2
-
3
- declare enum LanguageDetector {
1
+ import { type Locales } from '@intlayer/config/client';
2
+ export declare enum LanguageDetector {
4
3
  Querystring = "querystring",
5
4
  Cookie = "cookie",
6
5
  LocalStorage = "localStorage",
@@ -21,6 +20,6 @@ type LanguageDetectorOptions = {
21
20
  * Core language detector function
22
21
  * const detectedLanguages = detectLanguage(['LanguageDetector.Cookie', 'LanguageDetector.LocalStorage'], { lookupCookie: 'myCookie' });
23
22
  */
24
- declare const getBrowserLocale: (userOptions?: LanguageDetectorOptions | undefined) => Locales;
25
-
26
- export { LanguageDetector, getBrowserLocale };
23
+ export declare const getBrowserLocale: (userOptions?: LanguageDetectorOptions | undefined) => Locales;
24
+ export {};
25
+ //# sourceMappingURL=getBrowserLocale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getBrowserLocale.d.ts","sourceRoot":"","sources":["../../../src/client/getBrowserLocale.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGzE,oBAAY,gBAAgB;IAC1B,WAAW,gBAAgB;IAC3B,MAAM,WAAW;IACjB,YAAY,iBAAiB;IAC7B,cAAc,mBAAmB;IACjC,SAAS,cAAc;IACvB,OAAO,YAAY;CACpB;AAGD,KAAK,uBAAuB,GAAG;IAC7B,KAAK,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAC9B,CAAC;AA8JF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,iBACd,uBAAuB,GAAG,SAAS,KAC/C,OAMF,CAAC"}
@@ -0,0 +1,10 @@
1
+ export { type IntlayerProviderProps, IntlayerClientContext, useIntlayerContext, IntlayerProvider, } from './IntlayerProvider';
2
+ export { useIntlayer } from './useIntlayer';
3
+ export { useDictionary } from './useDictionary';
4
+ export { useLocaleBase } from './useLocaleBase';
5
+ export { useLocale } from './useLocale';
6
+ export { useTraduction } from './useTraduction';
7
+ export { useLocaleCookie, localeCookie, setLocaleCookie, } from './useLocaleCookie';
8
+ export { getBrowserLocale } from './getBrowserLocale';
9
+ export { t } from './t';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAC1B,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,eAAe,EACf,YAAY,EACZ,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Locales } from '@intlayer/config/client';
2
+ import type { LanguageContent } from '@intlayer/core';
3
+ /**
4
+ * On the client side, this function returns the translation of the provided multilang content.
5
+ *
6
+ * If the locale is not provided, it will use the locale from the client context
7
+ */
8
+ export declare const t: <Content = string>(multilangContent: LanguageContent<Content>, locale?: Locales) => Content;
9
+ //# sourceMappingURL=t.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"t.d.ts","sourceRoot":"","sources":["../../../src/client/t.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAKtD;;;;GAIG;AACH,eAAO,MAAM,CAAC,GAAI,OAAO,6BACL,eAAe,CAAC,OAAO,CAAC,WACjC,OAAO,YAMjB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { LanguageContent } from '@intlayer/core';
2
+ /**
3
+ * On the client side, hook to get the translation content based on the locale
4
+ */
5
+ export declare const useContent: <Content>(languageContent: LanguageContent<Content>) => {
6
+ locale: import("intlayer").Locales;
7
+ content: Content;
8
+ t: <Content_1 = string>(languageContent: LanguageContent<Content_1>) => Content_1;
9
+ };
10
+ //# sourceMappingURL=useContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useContent.d.ts","sourceRoot":"","sources":["../../../src/client/useContent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAItD;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,mBACf,eAAe,CAAC,OAAO,CAAC;;;;CAW1C,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { type UseDictionary } from '../useDictionaryBase';
2
+ /**
3
+ * On the server side, Hook that transform a dictionary and return the content
4
+ *
5
+ * If the locale is not provided, it will use the locale from the client context
6
+ */
7
+ export declare const useDictionary: UseDictionary;
8
+ //# sourceMappingURL=useDictionary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDictionary.d.ts","sourceRoot":"","sources":["../../../src/client/useDictionary.ts"],"names":[],"mappings":"AAKA,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG7E;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,aAQ3B,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { type UseIntlayer } from '../useIntlayerBase';
2
+ /**
3
+ * On the client side, Hook that picking one dictionary by its key and return the content
4
+ *
5
+ * If the locale is not provided, it will use the locale from the client context
6
+ */
7
+ export declare const useIntlayer: UseIntlayer;
8
+ //# sourceMappingURL=useIntlayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIntlayer.d.ts","sourceRoot":"","sources":["../../../src/client/useIntlayer.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,oBAAoB,CAAC;AAG5B;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,WAQzB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * On the client side, hook to get the current locale and all related fields
3
+ */
4
+ export declare const useLocale: () => {
5
+ locale: import("intlayer").Locales;
6
+ defaultLocale: import("intlayer").Locales;
7
+ availableLocales: import("intlayer").Locales[];
8
+ localeList: import("intlayer").Locales[];
9
+ setLocale: (newLocale: import("intlayer").Locales) => void;
10
+ };
11
+ //# sourceMappingURL=useLocale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocale.d.ts","sourceRoot":"","sources":["../../../src/client/useLocale.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;CAYrB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * On the client side, hook to get the current locale and all related fields
3
+ */
4
+ export declare const useLocaleBase: () => {
5
+ locale: import("intlayer").Locales;
6
+ defaultLocale: import("intlayer").Locales;
7
+ availableLocales: import("intlayer").Locales[];
8
+ localeList: import("intlayer").Locales[];
9
+ setLocale: (newLocale: import("intlayer").Locales) => void;
10
+ };
11
+ //# sourceMappingURL=useLocaleBase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocaleBase.d.ts","sourceRoot":"","sources":["../../../src/client/useLocaleBase.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;CAUzB,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { type Locales } from '@intlayer/config/client';
2
+ /**
3
+ * Get the locale cookie
4
+ */
5
+ export declare const localeCookie: Locales | undefined;
6
+ /**
7
+ * Set the locale cookie
8
+ */
9
+ export declare const setLocaleCookie: (locale: Locales) => void;
10
+ /**
11
+ * Hook that provides the locale cookie and a function to set it
12
+ */
13
+ export declare const useLocaleCookie: () => {
14
+ localeCookie: Locales;
15
+ setLocaleCookie: (locale: Locales) => void;
16
+ };
17
+ //# sourceMappingURL=useLocaleCookie.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocaleCookie.d.ts","sourceRoot":"","sources":["../../../src/client/useLocaleCookie.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAoB,MAAM,yBAAyB,CAAC;AAazE;;GAEG;AACH,eAAO,MAAM,YAAY,EACrB,OAAO,GACP,SAAS,CAAC;AAEd;;GAEG;AACH,eAAO,MAAM,eAAe,WAAY,OAAO,SAE9C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe;;8BAPY,OAAO;CAU7C,CAAC"}
@@ -1,5 +1,4 @@
1
- import { LanguageContent } from '@intlayer/core';
2
-
1
+ import type { LanguageContent } from '@intlayer/core';
3
2
  /**
4
3
  * On the client side, Hook that picking one dictionary by its id and return the content.
5
4
  *
@@ -21,6 +20,5 @@ import { LanguageContent } from '@intlayer/core';
21
20
  * - this function will require each locale to be defined if defined in the project configuration.
22
21
  * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.
23
22
  */
24
- declare const useTraduction: <Content = string>(languageContent: LanguageContent<Content>) => Content;
25
-
26
- export { useTraduction };
23
+ export declare const useTraduction: <Content = string>(languageContent: LanguageContent<Content>) => Content;
24
+ //# sourceMappingURL=useTraduction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTraduction.d.ts","sourceRoot":"","sources":["../../../src/client/useTraduction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAKtD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,4BAClB,eAAe,CAAC,OAAO,CAAC,KACxC,OAIF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=craco.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"craco.config.d.ts","sourceRoot":"","sources":["../../../src/craco/craco.config.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ import type { CracoConfig, CracoConfigOverride, CracoPlugin, WebpackConfigOverride } from '@craco/types';
2
+ import { type Configuration as WebpackConfig } from 'webpack';
3
+ export declare const overrideWebpackConfig: ({ webpackConfig, }: WebpackConfigOverride) => WebpackConfig;
4
+ export declare const overrideCracoConfig: ({ cracoConfig, }: CracoConfigOverride) => CracoConfig;
5
+ /**
6
+ * A CRACO plugin that adds the IntLayer configuration to the webpack configuration and sets the environment variables.
7
+ *
8
+ * Usage:
9
+ *
10
+ * ```ts
11
+ * const cracoConfig: CracoConfig = {
12
+ * plugins: [
13
+ * {
14
+ * plugin: intlayerCracoPlugin(),
15
+ * },
16
+ * ],
17
+ * };
18
+ *
19
+ * export default cracoConfig;
20
+ * ```
21
+ *
22
+ */
23
+ export declare const plugin: CracoPlugin;
24
+ //# sourceMappingURL=intlayerCracoPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intlayerCracoPlugin.d.ts","sourceRoot":"","sources":["../../../src/craco/intlayerCracoPlugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAGtB,OAAgB,EAAE,KAAK,aAAa,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AASvE,eAAO,MAAM,qBAAqB,uBAE/B,qBAAqB,KAAG,aAoB1B,CAAC;AAGF,eAAO,MAAM,mBAAmB,qBAE7B,mBAAmB,KAAG,WAoBxB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,MAAM,EAAE,WAGpB,CAAC"}
@@ -1,5 +1,4 @@
1
- import { QuantityContent } from '@intlayer/core';
2
-
1
+ import { type QuantityContent } from '@intlayer/core';
3
2
  /**
4
3
  * Allow to pick a content based on a quantity.
5
4
  *
@@ -28,6 +27,5 @@ import { QuantityContent } from '@intlayer/core';
28
27
  * ```
29
28
  *
30
29
  */
31
- declare const getEnumeration: <Content>(enumerationContent: QuantityContent<Content>, quantity: number) => Content;
32
-
33
- export { getEnumeration };
30
+ export declare const getEnumeration: <Content>(enumerationContent: QuantityContent<Content>, quantity: number) => Content;
31
+ //# sourceMappingURL=getEnumeration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getEnumeration.d.ts","sourceRoot":"","sources":["../../src/getEnumeration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAyB,MAAM,gBAAgB,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,sBAChB,eAAe,CAAC,OAAO,CAAC,YAClC,MAAM,KACf,OAOF,CAAC"}
@@ -1,6 +1,5 @@
1
- import { Locales } from '@intlayer/config/client';
2
- import { LanguageContent } from '@intlayer/core';
3
-
1
+ import { type Locales } from '@intlayer/config/client';
2
+ import { type LanguageContent } from '@intlayer/core';
4
3
  /**
5
4
  *
6
5
  * Allow to pick a content based on a locale.
@@ -22,6 +21,5 @@ import { LanguageContent } from '@intlayer/core';
22
21
  * - this function will require each locale to be defined if defined in the project configuration.
23
22
  * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.
24
23
  */
25
- declare const getTranslation: <Content = string>(languageContent: LanguageContent<Content>, locale?: Locales) => Content;
26
-
27
- export { getTranslation };
24
+ export declare const getTranslation: <Content = string>(languageContent: LanguageContent<Content>, locale?: Locales) => Content;
25
+ //# sourceMappingURL=getTranslation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTranslation.d.ts","sourceRoot":"","sources":["../../src/getTranslation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAoB,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,KAAK,eAAe,EAAyB,MAAM,gBAAgB,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,4BACnB,eAAe,CAAC,OAAO,CAAC,WAChC,OAAO,KACf,OASF,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { getTranslation } from './getTranslation';
2
+ export { IntlayerProvider, type IntlayerProviderProps, IntlayerClientContext, useIntlayer, useDictionary, useLocale, useTraduction, useLocaleCookie, localeCookie, setLocaleCookie, getBrowserLocale, useLocaleBase, t, } from './client/index';
3
+ export { type IntlayerNode } from './useDictionaryBase';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,EAC1B,qBAAqB,EACrB,WAAW,EACX,aAAa,EACb,SAAS,EACT,aAAa,EACb,eAAe,EACf,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,CAAC,GACF,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { KeyPath, Locales } from '@intlayer/core';
2
+ import type { ReactNode } from 'react';
3
+ export type TransformedContentValue = string | ReactNode | {
4
+ [key: string]: TransformedContentValue;
5
+ } | undefined | ((quantity: number) => TransformedContentValue);
6
+ export type TransformedContentObject = {
7
+ dictionaryId: string;
8
+ dictionaryPath: string;
9
+ keyPath: KeyPath[];
10
+ locale: Locales;
11
+ content: TransformedContentValue | TransformedContentValue[] | undefined;
12
+ };
13
+ export type TransformedContent = Record<string, TransformedContentValue | TransformedContentValue[] | TransformedContentObject | undefined> | ReactNode;
14
+ //# sourceMappingURL=contentDictionary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contentDictionary.d.ts","sourceRoot":"","sources":["../../../src/processDictionary/contentDictionary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,uBAAuB,GAC/B,MAAM,GACN,SAAS,GACT;IACE,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB,CAAC;CACxC,GACD,SAAS,GACT,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,uBAAuB,CAAC,CAAC;AAEpD,MAAM,MAAM,wBAAwB,GAAG;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,uBAAuB,GAAG,uBAAuB,EAAE,GAAG,SAAS,CAAC;CAC1E,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAC1B,MAAM,CACJ,MAAM,EACJ,uBAAuB,GACvB,uBAAuB,EAAE,GACzB,wBAAwB,GACxB,SAAS,CACZ,GACD,SAAS,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { type Locales } from '@intlayer/config/client';
2
+ import { type KeyPath, type DictionaryValue } from '@intlayer/core';
3
+ import type { TransformedContent, TransformedContentValue } from './contentDictionary';
4
+ export declare const processNode: (field: DictionaryValue | undefined, locale: Locales, dictionaryId: string, dictionaryPath?: string, keyPath?: KeyPath[]) => TransformedContentValue;
5
+ /**
6
+ * Function that process a dictionary and return the result to be used in the application.
7
+ */
8
+ export declare const processDictionary: (content: DictionaryValue, dictionaryId: string, dictionaryPath?: string, keyPath?: KeyPath[], locale?: Locales) => TransformedContent;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/processDictionary/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,EAAoB,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAKL,KAAK,OAAO,EACZ,KAAK,eAAe,EAIrB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,qBAAqB,CAAC;AAoE7B,eAAO,MAAM,WAAW,UACf,eAAe,GAAG,SAAS,UAC1B,OAAO,gBACD,MAAM,mBACH,MAAM,YACd,OAAO,EAAE,KACjB,uBAyCF,CAAC;AAyCF;;GAEG;AACH,eAAO,MAAM,iBAAiB,YACnB,eAAe,gBACV,MAAM,mBACH,MAAM,YACd,OAAO,EAAE,WACV,OAAO,KAEd,kBA0EF,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { type Locales } from '@intlayer/config/client';
2
+ import type { FC, PropsWithChildren } from 'react';
3
+ /**
4
+ * Context that store the current locale on the server side
5
+ */
6
+ export declare const IntlayerServerContext: {
7
+ Provider: ({ children, value, }: {
8
+ children: React.ReactNode;
9
+ value: Locales;
10
+ }) => React.ReactNode;
11
+ Consumer: ({ children, }: {
12
+ children: (context: Locales) => React.ReactNode;
13
+ }) => React.ReactNode;
14
+ _storage: () => {
15
+ value: Locales;
16
+ };
17
+ _defaultValue: Locales;
18
+ };
19
+ /**
20
+ * Hook that provides the current locale
21
+ */
22
+ export declare const useIntlayer: () => Locales;
23
+ /**
24
+ * Get the current locale
25
+ */
26
+ export declare const locale: Locales;
27
+ export type IntlayerServerProviderProps = PropsWithChildren & {
28
+ locale?: Locales;
29
+ };
30
+ /**
31
+ * Provider that store the current locale on the server side
32
+ */
33
+ export declare const IntlayerServerProvider: FC<IntlayerServerProviderProps>;
34
+ //# sourceMappingURL=IntlayerServerProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IntlayerServerProvider.d.ts","sourceRoot":"","sources":["../../../src/server/IntlayerServerProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAoB,MAAM,yBAAyB,CAAC;AACzE,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAKnD;;GAEG;AACH,eAAO,MAAM,qBAAqB;;kBA4B4c,MAAO,SAAS;;UAAuB,MAAO,SAAS;;wCAA+E,MAAO,SAAS;UAAS,MAAO,SAAS;;;;;CA3BhnB,CAAC;AAE9C;;GAEG;AACH,eAAO,MAAM,WAAW,eAAgD,CAAC;AAEzE;;GAEG;AACH,eAAO,MAAM,MAAM,SAA0C,CAAC;AAE9D,MAAM,MAAM,2BAA2B,GAAG,iBAAiB,GAAG;IAC5D,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CAOlE,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { type LanguageContent } from '@intlayer/core';
2
+ /**
3
+ * On the server side, get the translation content based on the locale
4
+ */
5
+ export declare const getLocaleTranslation: <Content>(languageContent: LanguageContent<Content>) => {
6
+ locale: import("intlayer").Locales;
7
+ content: Content;
8
+ };
9
+ //# sourceMappingURL=getLocaleTranslation.d.ts.map