react-intlayer 3.5.4 → 3.5.6

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 (78) hide show
  1. package/README.md +5 -5
  2. package/dist/cjs/cli/react-intlayer.cjs +4 -4
  3. package/dist/cjs/cli/react-intlayer.cjs.map +1 -1
  4. package/dist/cjs/client/index.cjs +3 -0
  5. package/dist/cjs/client/index.cjs.map +1 -1
  6. package/dist/cjs/client/useIntlayerAsync.cjs +55 -0
  7. package/dist/cjs/client/useIntlayerAsync.cjs.map +1 -0
  8. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs +59 -0
  9. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs.map +1 -0
  10. package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -1
  11. package/dist/cjs/editor/IntlayerEditorProvider.cjs +5 -1
  12. package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +1 -1
  13. package/dist/cjs/editor/renderContentEditor.cjs.map +1 -1
  14. package/dist/cjs/getDictionary.cjs +1 -1
  15. package/dist/cjs/getDictionary.cjs.map +1 -1
  16. package/dist/cjs/getIntlayer.cjs.map +1 -1
  17. package/dist/cjs/getIntlayerAsync.cjs +42 -0
  18. package/dist/cjs/getIntlayerAsync.cjs.map +1 -0
  19. package/dist/cjs/index.cjs +2 -0
  20. package/dist/cjs/index.cjs.map +1 -1
  21. package/dist/cjs/processDictionary/contentDictionary.cjs.map +1 -1
  22. package/dist/cjs/processDictionary/index.cjs +13 -13
  23. package/dist/cjs/processDictionary/index.cjs.map +1 -1
  24. package/dist/cjs/utils/PoweredByMeta/index.cjs +40 -0
  25. package/dist/cjs/utils/PoweredByMeta/index.cjs.map +1 -0
  26. package/dist/cjs/vite/intlayerMiddlewarePlugin.cjs +185 -59
  27. package/dist/cjs/vite/intlayerMiddlewarePlugin.cjs.map +1 -1
  28. package/dist/esm/cli/react-intlayer.mjs +5 -5
  29. package/dist/esm/cli/react-intlayer.mjs.map +1 -1
  30. package/dist/esm/client/index.mjs +2 -0
  31. package/dist/esm/client/index.mjs.map +1 -1
  32. package/dist/esm/client/useIntlayerAsync.mjs +34 -0
  33. package/dist/esm/client/useIntlayerAsync.mjs.map +1 -0
  34. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs +36 -0
  35. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs.map +1 -0
  36. package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -1
  37. package/dist/esm/editor/IntlayerEditorProvider.mjs +6 -2
  38. package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -1
  39. package/dist/esm/editor/renderContentEditor.mjs.map +1 -1
  40. package/dist/esm/getDictionary.mjs +1 -1
  41. package/dist/esm/getDictionary.mjs.map +1 -1
  42. package/dist/esm/getIntlayer.mjs.map +1 -1
  43. package/dist/esm/getIntlayerAsync.mjs +19 -0
  44. package/dist/esm/getIntlayerAsync.mjs.map +1 -0
  45. package/dist/esm/index.mjs +2 -0
  46. package/dist/esm/index.mjs.map +1 -1
  47. package/dist/esm/processDictionary/index.mjs +13 -13
  48. package/dist/esm/processDictionary/index.mjs.map +1 -1
  49. package/dist/esm/utils/PoweredByMeta/index.mjs +17 -0
  50. package/dist/esm/utils/PoweredByMeta/index.mjs.map +1 -0
  51. package/dist/esm/vite/intlayerMiddlewarePlugin.mjs +186 -63
  52. package/dist/esm/vite/intlayerMiddlewarePlugin.mjs.map +1 -1
  53. package/dist/types/client/index.d.ts +1 -0
  54. package/dist/types/client/index.d.ts.map +1 -1
  55. package/dist/types/client/useIntlayerAsync.d.ts +15 -0
  56. package/dist/types/client/useIntlayerAsync.d.ts.map +1 -0
  57. package/dist/types/distantDictionary/fetchDistantDictionary.d.ts +6 -0
  58. package/dist/types/distantDictionary/fetchDistantDictionary.d.ts.map +1 -0
  59. package/dist/types/editor/ContentSelectorWrapper.d.ts +1 -1
  60. package/dist/types/editor/ContentSelectorWrapper.d.ts.map +1 -1
  61. package/dist/types/editor/IntlayerEditorProvider.d.ts.map +1 -1
  62. package/dist/types/editor/renderContentEditor.d.ts +1 -1
  63. package/dist/types/editor/renderContentEditor.d.ts.map +1 -1
  64. package/dist/types/getIntlayer.d.ts +1 -2
  65. package/dist/types/getIntlayer.d.ts.map +1 -1
  66. package/dist/types/getIntlayerAsync.d.ts +13 -0
  67. package/dist/types/getIntlayerAsync.d.ts.map +1 -0
  68. package/dist/types/index.d.ts +1 -1
  69. package/dist/types/index.d.ts.map +1 -1
  70. package/dist/types/processDictionary/contentDictionary.d.ts +1 -1
  71. package/dist/types/processDictionary/contentDictionary.d.ts.map +1 -1
  72. package/dist/types/processDictionary/index.d.ts +2 -2
  73. package/dist/types/processDictionary/index.d.ts.map +1 -1
  74. package/dist/types/utils/PoweredByMeta/index.d.ts +3 -0
  75. package/dist/types/utils/PoweredByMeta/index.d.ts.map +1 -0
  76. package/dist/types/vite/intlayerMiddlewarePlugin.d.ts +3 -10
  77. package/dist/types/vite/intlayerMiddlewarePlugin.d.ts.map +1 -1
  78. package/package.json +16 -15
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/getIntlayerAsync.ts"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport { DeclarationContent } from 'intlayer';\nimport { fetchDistantDictionary } from './distantDictionary/fetchDistantDictionary';\nimport { getDictionary } from './getDictionary';\nimport { DictionaryKeys, DataFromDictionaryKey } from './getIntlayer';\n\nexport type GetIntlayerAsync = <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = true,\n>(\n key: T,\n locale?: L,\n isRenderEditor?: R\n) => Promise<DataFromDictionaryKey<T, L, R> | null>;\n\n/**\n * On the client side, Hook that picking one dictionary by its key and return the content\n *\n * This hook will prerender the locale dictionary and fetch simultaneously the distant dictionaries to hydrate it.\n *\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const getIntlayerAsync: GetIntlayerAsync = async <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = true,\n>(\n key: T,\n locale?: L,\n isRenderEditor = true as R\n) => {\n const jsonDistantDictionary = await fetchDistantDictionary(key);\n\n if (jsonDistantDictionary) {\n return getDictionary(\n jsonDistantDictionary as unknown as DeclarationContent,\n locale,\n isRenderEditor\n ) as DataFromDictionaryKey<T, L, R>;\n }\n\n return null;\n};\n"],"mappings":";;AAIA,SAAS,8BAA8B;AACvC,SAAS,qBAAqB;AAqBvB,MAAM,mBAAqC,OAKhD,KACA,QACA,iBAAiB,SACd;AACH,QAAM,wBAAwB,MAAM,uBAAuB,GAAG;AAE9D,MAAI,uBAAuB;AACzB,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -4,6 +4,7 @@ import {
4
4
  IntlayerProvider,
5
5
  IntlayerClientContext,
6
6
  useIntlayer,
7
+ useIntlayerAsync,
7
8
  useDictionary,
8
9
  useLocale,
9
10
  useTraduction,
@@ -29,6 +30,7 @@ export {
29
30
  t,
30
31
  useDictionary,
31
32
  useIntlayer,
33
+ useIntlayerAsync,
32
34
  useIntlayerContext,
33
35
  useLocale,
34
36
  useLocaleBase,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { getTranslation } from './getTranslation';\nexport {\n IntlayerProvider,\n type IntlayerProviderProps,\n IntlayerClientContext,\n useIntlayer,\n useDictionary,\n useLocale,\n useTraduction,\n useLocaleCookie,\n useIntlayerContext,\n localeCookie,\n setLocaleCookie,\n getBrowserLocale,\n useLocaleBase,\n t,\n} from './client/index';\nexport { getDictionary } from './getDictionary';\nexport { getIntlayer } from './getIntlayer';\nexport { type IntlayerNode } from './editor/renderContentEditor';\n"],"mappings":";AAAA,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { getTranslation } from './getTranslation';\nexport {\n IntlayerProvider,\n type IntlayerProviderProps,\n IntlayerClientContext,\n useIntlayer,\n useIntlayerAsync,\n useDictionary,\n useLocale,\n useTraduction,\n useLocaleCookie,\n useIntlayerContext,\n localeCookie,\n setLocaleCookie,\n getBrowserLocale,\n useLocaleBase,\n t,\n} from './client/index';\nexport { getDictionary } from './getDictionary';\nexport { getIntlayer } from './getIntlayer';\nexport { type IntlayerNode } from './editor/renderContentEditor';\n"],"mappings":";AAAA,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;","names":[]}
@@ -10,7 +10,7 @@ import { getTranslation } from '../getTranslation.mjs';
10
10
  const {
11
11
  internationalization: { defaultLocale }
12
12
  } = getConfiguration();
13
- const processTranslation = (languageContent, locale, dictionaryId, dictionaryPath, keyPath = []) => {
13
+ const processTranslation = (languageContent, locale, dictionaryKey, dictionaryPath, keyPath = []) => {
14
14
  const translationResult = getTranslation(
15
15
  languageContent,
16
16
  locale
@@ -21,13 +21,13 @@ const processTranslation = (languageContent, locale, dictionaryId, dictionaryPat
21
21
  ];
22
22
  return processDictionary(
23
23
  translationResult,
24
- dictionaryId,
24
+ dictionaryKey,
25
25
  dictionaryPath,
26
26
  resultKeyPath,
27
27
  locale
28
28
  );
29
29
  };
30
- const processEnumeration = (enumerationContent, locale, dictionaryId, dictionaryPath, keyPath = []) => (quantity) => {
30
+ const processEnumeration = (enumerationContent, locale, dictionaryKey, dictionaryPath, keyPath = []) => (quantity) => {
31
31
  const enumerationResult = getEnumeration(
32
32
  enumerationContent,
33
33
  quantity
@@ -42,20 +42,20 @@ const processEnumeration = (enumerationContent, locale, dictionaryId, dictionary
42
42
  ];
43
43
  return processDictionary(
44
44
  enumerationResult,
45
- dictionaryId,
45
+ dictionaryKey,
46
46
  dictionaryPath,
47
47
  resultKeyPath,
48
48
  locale
49
49
  );
50
50
  };
51
51
  const isReactNode = (node) => typeof node?.key !== "undefined" && typeof node?.props !== "undefined";
52
- const processNode = (field, locale, dictionaryId, dictionaryPath, keyPath = []) => {
52
+ const processNode = (field, locale, dictionaryKey, dictionaryPath, keyPath = []) => {
53
53
  if (typeof field === "object") {
54
54
  if (field.nodeType === NodeType.Translation) {
55
55
  return processTranslation(
56
56
  field[NodeType.Translation],
57
57
  locale,
58
- dictionaryId,
58
+ dictionaryKey,
59
59
  dictionaryPath,
60
60
  keyPath
61
61
  );
@@ -64,7 +64,7 @@ const processNode = (field, locale, dictionaryId, dictionaryPath, keyPath = [])
64
64
  return processEnumeration(
65
65
  field[NodeType.Enumeration],
66
66
  locale,
67
- dictionaryId,
67
+ dictionaryKey,
68
68
  dictionaryPath,
69
69
  keyPath
70
70
  );
@@ -73,7 +73,7 @@ const processNode = (field, locale, dictionaryId, dictionaryPath, keyPath = [])
73
73
  return processDictionary(
74
74
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
75
75
  field,
76
- dictionaryId,
76
+ dictionaryKey,
77
77
  dictionaryPath,
78
78
  keyPath,
79
79
  locale
@@ -105,7 +105,7 @@ const createReactElement = (element) => {
105
105
  return createElement(type ?? "div", props, ...props.children);
106
106
  };
107
107
  const traceKeys = ["filePath", "nodeType"];
108
- const processDictionary = (content, dictionaryId, dictionaryPath, keyPath = [], locale = defaultLocale) => {
108
+ const processDictionary = (content, dictionaryKey, dictionaryPath, keyPath = [], locale = defaultLocale) => {
109
109
  if (isReactNode(content)) {
110
110
  return createReactElement(
111
111
  content
@@ -118,7 +118,7 @@ const processDictionary = (content, dictionaryId, dictionaryPath, keyPath = [],
118
118
  return processNode(
119
119
  content,
120
120
  locale,
121
- dictionaryId,
121
+ dictionaryKey,
122
122
  dictionaryPath,
123
123
  keyPath
124
124
  );
@@ -131,7 +131,7 @@ const processDictionary = (content, dictionaryId, dictionaryPath, keyPath = [],
131
131
  return processNode(
132
132
  field,
133
133
  locale,
134
- dictionaryId,
134
+ dictionaryKey,
135
135
  dictionaryPath,
136
136
  resultKeyPath
137
137
  );
@@ -150,7 +150,7 @@ const processDictionary = (content, dictionaryId, dictionaryPath, keyPath = [],
150
150
  const nodeResult = processNode(
151
151
  field,
152
152
  locale,
153
- dictionaryId,
153
+ dictionaryKey,
154
154
  dictionaryPath,
155
155
  resultKeyPath
156
156
  );
@@ -162,7 +162,7 @@ const processDictionary = (content, dictionaryId, dictionaryPath, keyPath = [],
162
162
  return {
163
163
  content,
164
164
  keyPath,
165
- dictionaryId,
165
+ dictionaryKey,
166
166
  dictionaryPath
167
167
  };
168
168
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/processDictionary/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { type Locales, getConfiguration } from '@intlayer/config/client';\nimport {\n NodeType,\n type QuantityContent,\n type LanguageContent,\n findMatchingCondition,\n type KeyPath,\n type DictionaryValue,\n type TranslationContent,\n type EnumerationContent,\n type TypedNode,\n} from '@intlayer/core';\nimport { type ReactElement, createElement, type ReactNode } from 'react';\nimport { getEnumeration } from '../getEnumeration';\nimport { getTranslation } from '../getTranslation';\nimport type {\n TransformedContent,\n TransformedContentValue,\n} from './contentDictionary';\n\nconst {\n internationalization: { defaultLocale },\n} = getConfiguration();\n\nconst processTranslation = (\n languageContent: LanguageContent<DictionaryValue>,\n locale: Locales,\n dictionaryId: string,\n dictionaryPath?: string,\n keyPath: KeyPath[] = []\n): TransformedContent => {\n const translationResult: DictionaryValue = getTranslation<DictionaryValue>(\n languageContent,\n locale\n );\n\n const resultKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: locale },\n ];\n\n return processDictionary(\n translationResult,\n dictionaryId,\n dictionaryPath,\n resultKeyPath,\n locale\n );\n};\n\nconst processEnumeration =\n (\n enumerationContent: QuantityContent<DictionaryValue>,\n locale: Locales,\n dictionaryId: string,\n dictionaryPath?: string,\n keyPath: KeyPath[] = []\n ): TransformedContentValue =>\n (quantity: number): TransformedContentValue => {\n const enumerationResult: DictionaryValue = getEnumeration<DictionaryValue>(\n enumerationContent,\n quantity\n );\n\n const matchingCondition = findMatchingCondition(\n enumerationContent,\n quantity\n );\n\n const resultKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Enumeration, key: matchingCondition.toString() },\n ];\n\n return processDictionary(\n enumerationResult,\n dictionaryId,\n dictionaryPath,\n resultKeyPath,\n locale\n ) as TransformedContentValue;\n };\n\nconst isReactNode = (node: Record<string, unknown>): boolean =>\n typeof node?.key !== 'undefined' && typeof node?.props !== 'undefined';\n\nexport const processNode = (\n field: DictionaryValue | undefined,\n locale: Locales,\n dictionaryId: string,\n dictionaryPath?: string,\n keyPath: KeyPath[] = []\n): TransformedContentValue => {\n if (typeof field === 'object') {\n if (\n (field as TranslationContent<DictionaryValue>).nodeType ===\n NodeType.Translation\n ) {\n return processTranslation(\n field[\n NodeType.Translation as keyof typeof field\n ] as LanguageContent<DictionaryValue>,\n locale,\n dictionaryId,\n dictionaryPath,\n keyPath\n ) as TransformedContentValue;\n }\n\n if (\n (field as EnumerationContent<DictionaryValue>).nodeType ===\n NodeType.Enumeration\n ) {\n return processEnumeration(\n field[\n NodeType.Enumeration as keyof typeof field\n ] as QuantityContent<DictionaryValue>,\n locale,\n dictionaryId,\n dictionaryPath,\n keyPath\n );\n }\n }\n\n return processDictionary(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n field!,\n dictionaryId,\n dictionaryPath,\n keyPath,\n locale\n ) as TransformedContentValue;\n};\n\n// This function recursively creates React elements from a given JSON-like structure\nconst createReactElement = (element: ReactElement) => {\n if (typeof element === 'string') {\n // If it's a string, simply return it (used for text content)\n return element;\n }\n\n const convertChildrenAsArray = (element: ReactElement): ReactElement => {\n if (element?.props && typeof element.props.children === 'object') {\n const childrenResult: ReactNode[] = [];\n const { children } = element.props;\n\n // Create the children elements recursively, if any\n Object.keys(children).forEach((key) => {\n childrenResult.push(createReactElement(children[key]));\n });\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: element.props.children },\n };\n };\n\n const fixedElement = convertChildrenAsArray(element);\n\n const { type, props } = fixedElement;\n\n // Create and return the React element\n return createElement(type ?? 'div', props, ...props.children);\n};\n\nconst traceKeys: string[] = ['filePath', 'nodeType'];\n\n/**\n * Function that process a dictionary and return the result to be used in the application.\n */\nexport const processDictionary = (\n content: DictionaryValue,\n dictionaryId: string,\n dictionaryPath?: string,\n keyPath: KeyPath[] = [],\n locale: Locales = defaultLocale\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): TransformedContent => {\n // If it's a React element, render it\n if (isReactNode(content as Record<string, unknown>)) {\n return createReactElement(\n content as unknown as ReactElement\n ) as unknown as TransformedContent;\n }\n\n if (content && typeof content === 'object') {\n const isArray = Array.isArray(content);\n\n let result: TransformedContent = {};\n\n if (typeof (content as TypedNode).nodeType !== 'undefined') {\n return processNode(\n content as DictionaryValue,\n locale,\n dictionaryId,\n dictionaryPath,\n keyPath\n ) as TransformedContent;\n } else if (isArray) {\n // Eslint fix because promises are awaited during build stage\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n result = (content as DictionaryValue[]).map((field, key) => {\n const resultKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key },\n ];\n\n return processNode(\n field,\n locale,\n dictionaryId,\n dictionaryPath,\n resultKeyPath\n );\n }) as TransformedContent;\n } else {\n // List each key in the content and process it\n for (const key of Object.keys(content)) {\n const field = content[key as keyof typeof content];\n\n if (traceKeys.includes(key)) {\n result[key] = field as TransformedContentValue;\n continue;\n }\n\n const resultKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n\n const nodeResult = processNode(\n field,\n locale,\n dictionaryId,\n dictionaryPath,\n resultKeyPath\n );\n\n result[key] = nodeResult;\n }\n }\n\n return result;\n }\n\n return {\n content: content as TransformedContentValue,\n keyPath,\n dictionaryId,\n dictionaryPath,\n };\n};\n"],"mappings":";AACA,SAAuB,wBAAwB;AAC/C;AAAA,EACE;AAAA,EAGA;AAAA,OAMK;AACP,SAA4B,qBAAqC;AACjE,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAM/B,MAAM;AAAA,EACJ,sBAAsB,EAAE,cAAc;AACxC,IAAI,iBAAiB;AAErB,MAAM,qBAAqB,CACzB,iBACA,QACA,cACA,gBACA,UAAqB,CAAC,MACC;AACvB,QAAM,oBAAqC;AAAA,IACzC;AAAA,IACA;AAAA,EACF;AAEA,QAAM,gBAA2B;AAAA,IAC/B,GAAG;AAAA,IACH,EAAE,MAAM,SAAS,aAAa,KAAK,OAAO;AAAA,EAC5C;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEA,MAAM,qBACJ,CACE,oBACA,QACA,cACA,gBACA,UAAqB,CAAC,MAExB,CAAC,aAA8C;AAC7C,QAAM,oBAAqC;AAAA,IACzC;AAAA,IACA;AAAA,EACF;AAEA,QAAM,oBAAoB;AAAA,IACxB;AAAA,IACA;AAAA,EACF;AAEA,QAAM,gBAA2B;AAAA,IAC/B,GAAG;AAAA,IACH,EAAE,MAAM,SAAS,aAAa,KAAK,kBAAkB,SAAS,EAAE;AAAA,EAClE;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEF,MAAM,cAAc,CAAC,SACnB,OAAO,MAAM,QAAQ,eAAe,OAAO,MAAM,UAAU;AAEtD,MAAM,cAAc,CACzB,OACA,QACA,cACA,gBACA,UAA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gBACA,UAAqB,CAAC,GACtB,SAAkB,kBAEK;AAEvB,MAAI,YAAY,OAAkC,GAAG;AACnD,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAEA,MAAI,WAAW,OAAO,YAAY,UAAU;AAC1C,UAAM,UAAU,MAAM,QAAQ,OAAO;AAErC,QAAI,SAA6B,CAAC;AAElC,QAAI,OAAQ,QAAsB,aAAa,aAAa;AAC1D,aAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF,WAAW,SAAS;AAGlB,eAAU,QAA8B,IAAI,CAAC,OAAO,QAAQ;AAC1D,cAAM,gBAA2B;AAAA,UAC/B,GAAG;AAAA,UACH,EAAE,MAAM,SAAS,OAAO,IAAI;AAAA,QAC9B;AAEA,eAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH,OAAO;AAEL,iBAAW,OAAO,OAAO,KAAK,OAAO,GAAG;AACtC,cAAM,QAAQ,QAAQ,GAA2B;AAEjD,YAAI,UAAU,SAAS,GAAG,GAAG;AAC3B,iBAAO,GAAG,IAAI;AACd;AAAA,QACF;AAEA,cAAM,gBAA2B;AAAA,UAC/B,GAAG;AAAA,UACH,EAAE,MAAM,SAAS,QAAQ,IAAI;AAAA,QAC/B;AAEA,cAAM,aAAa;AAAA,UACjB;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAEA,eAAO,GAAG,IAAI;AAAA,MAChB;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["element"]}
1
+ {"version":3,"sources":["../../../src/processDictionary/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { type Locales, getConfiguration } from '@intlayer/config/client';\nimport {\n NodeType,\n type QuantityContent,\n type LanguageContent,\n findMatchingCondition,\n type KeyPath,\n type DictionaryValue,\n type TranslationContent,\n type EnumerationContent,\n type TypedNode,\n} from '@intlayer/core';\nimport { type ReactElement, createElement, type ReactNode } from 'react';\nimport { getEnumeration } from '../getEnumeration';\nimport { getTranslation } from '../getTranslation';\nimport type {\n TransformedContent,\n TransformedContentValue,\n} from './contentDictionary';\n\nconst {\n internationalization: { defaultLocale },\n} = getConfiguration();\n\nconst processTranslation = (\n languageContent: LanguageContent<DictionaryValue>,\n locale: Locales,\n dictionaryKey: string,\n dictionaryPath?: string,\n keyPath: KeyPath[] = []\n): TransformedContent => {\n const translationResult: DictionaryValue = getTranslation<DictionaryValue>(\n languageContent,\n locale\n );\n\n const resultKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: locale },\n ];\n\n return processDictionary(\n translationResult,\n dictionaryKey,\n dictionaryPath,\n resultKeyPath,\n locale\n );\n};\n\nconst processEnumeration =\n (\n enumerationContent: QuantityContent<DictionaryValue>,\n locale: Locales,\n dictionaryKey: string,\n dictionaryPath?: string,\n keyPath: KeyPath[] = []\n ): TransformedContentValue =>\n (quantity: number): TransformedContentValue => {\n const enumerationResult: DictionaryValue = getEnumeration<DictionaryValue>(\n enumerationContent,\n quantity\n );\n\n const matchingCondition = findMatchingCondition(\n enumerationContent,\n quantity\n );\n\n const resultKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Enumeration, key: matchingCondition.toString() },\n ];\n\n return processDictionary(\n enumerationResult,\n dictionaryKey,\n dictionaryPath,\n resultKeyPath,\n locale\n ) as TransformedContentValue;\n };\n\nconst isReactNode = (node: Record<string, unknown>): boolean =>\n typeof node?.key !== 'undefined' && typeof node?.props !== 'undefined';\n\nexport const processNode = (\n field: DictionaryValue | undefined,\n locale: Locales,\n dictionaryKey: string,\n dictionaryPath?: string,\n keyPath: KeyPath[] = []\n): TransformedContentValue => {\n if (typeof field === 'object') {\n if (\n (field as TranslationContent<DictionaryValue>).nodeType ===\n NodeType.Translation\n ) {\n return processTranslation(\n field[\n NodeType.Translation as keyof typeof field\n ] as LanguageContent<DictionaryValue>,\n locale,\n dictionaryKey,\n dictionaryPath,\n keyPath\n ) as TransformedContentValue;\n }\n\n if (\n (field as EnumerationContent<DictionaryValue>).nodeType ===\n NodeType.Enumeration\n ) {\n return processEnumeration(\n field[\n NodeType.Enumeration as keyof typeof field\n ] as QuantityContent<DictionaryValue>,\n locale,\n dictionaryKey,\n dictionaryPath,\n keyPath\n );\n }\n }\n\n return processDictionary(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n field!,\n dictionaryKey,\n dictionaryPath,\n keyPath,\n locale\n ) as TransformedContentValue;\n};\n\n// This function recursively creates React elements from a given JSON-like structure\nconst createReactElement = (element: ReactElement) => {\n if (typeof element === 'string') {\n // If it's a string, simply return it (used for text content)\n return element;\n }\n\n const convertChildrenAsArray = (element: ReactElement): ReactElement => {\n if (element?.props && typeof element.props.children === 'object') {\n const childrenResult: ReactNode[] = [];\n const { children } = element.props;\n\n // Create the children elements recursively, if any\n Object.keys(children).forEach((key) => {\n childrenResult.push(createReactElement(children[key]));\n });\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: element.props.children },\n };\n };\n\n const fixedElement = convertChildrenAsArray(element);\n\n const { type, props } = fixedElement;\n\n // Create and return the React element\n return createElement(type ?? 'div', props, ...props.children);\n};\n\nconst traceKeys: string[] = ['filePath', 'nodeType'];\n\n/**\n * Function that process a dictionary and return the result to be used in the application.\n */\nexport const processDictionary = (\n content: DictionaryValue,\n dictionaryKey: string,\n dictionaryPath?: string,\n keyPath: KeyPath[] = [],\n locale: Locales = defaultLocale\n): TransformedContent => {\n // If it's a React element, render it\n if (isReactNode(content as Record<string, unknown>)) {\n return createReactElement(\n content as unknown as ReactElement\n ) as unknown as TransformedContent;\n }\n\n if (content && typeof content === 'object') {\n const isArray = Array.isArray(content);\n\n let result: TransformedContent = {};\n\n if (typeof (content as TypedNode).nodeType !== 'undefined') {\n return processNode(\n content as DictionaryValue,\n locale,\n dictionaryKey,\n dictionaryPath,\n keyPath\n ) as TransformedContent;\n } else if (isArray) {\n // Eslint fix because promises are awaited during build stage\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n result = (content as DictionaryValue[]).map((field, key) => {\n const resultKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key },\n ];\n\n return processNode(\n field,\n locale,\n dictionaryKey,\n dictionaryPath,\n resultKeyPath\n );\n }) as TransformedContent;\n } else {\n // List each key in the content and process it\n for (const key of Object.keys(content)) {\n const field = content[key as keyof typeof content];\n\n if (traceKeys.includes(key)) {\n result[key] = field as TransformedContentValue;\n continue;\n }\n\n const resultKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n\n const nodeResult = processNode(\n field,\n locale,\n dictionaryKey,\n dictionaryPath,\n resultKeyPath\n );\n\n result[key] = nodeResult;\n }\n }\n\n return result;\n }\n\n return {\n content: content as TransformedContentValue,\n keyPath,\n dictionaryKey,\n dictionaryPath,\n };\n};\n"],"mappings":";AACA,SAAuB,wBAAwB;AAC/C;AAAA,EACE;AAAA,EAGA;AAAA,OAMK;AACP,SAA4B,qBAAqC;AACjE,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAM/B,MAAM;AAAA,EACJ,sBAAsB,EAAE,cAAc;AACxC,IAAI,iBAAiB;AAErB,MAAM,qBAAqB,CACzB,iBACA,QACA,eACA,gBACA,UAAqB,CAAC,MACC;AACvB,QAAM,oBAAqC;AAAA,IACzC;AAAA,IACA;AAAA,EACF;AAEA,QAAM,gBAA2B;AAAA,IAC/B,GAAG;AAAA,IACH,EAAE,MAAM,SAAS,aAAa,KAAK,OAAO;AAAA,EAC5C;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEA,MAAM,qBACJ,CACE,oBAC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AA,QACF;AAEA,cAAM,gBAA2B;AAAA,UAC/B,GAAG;AAAA,UACH,EAAE,MAAM,SAAS,QAAQ,IAAI;AAAA,QAC/B;AAEA,cAAM,aAAa;AAAA,UACjB;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAEA,eAAO,GAAG,IAAI;AAAA,MAChB;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["element"]}
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import "../../chunk-ZD7AOCMD.mjs";
3
+ import { useEffect } from "react";
4
+ const PoweredByMeta = () => {
5
+ if (process.env.NODE_ENV !== "production") return null;
6
+ useEffect(() => {
7
+ const metaTag = document.createElement("meta");
8
+ metaTag.name = "content-powered-by";
9
+ metaTag.content = "Intlayer - https://intlayer.org";
10
+ document.head.appendChild(metaTag);
11
+ }, []);
12
+ return null;
13
+ };
14
+ export {
15
+ PoweredByMeta
16
+ };
17
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/utils/PoweredByMeta/index.ts"],"sourcesContent":["'use client';\n\nimport { type FC, useEffect } from 'react';\n\nexport const PoweredByMeta: FC = () => {\n if (process.env.NODE_ENV !== 'production') return null;\n\n useEffect(() => {\n const metaTag = document.createElement('meta');\n metaTag.name = 'content-powered-by';\n metaTag.content = 'Intlayer - https://intlayer.org';\n document.head.appendChild(metaTag);\n }, []);\n\n return null; // This component does not render anything visible\n};\n"],"mappings":";;AAEA,SAAkB,iBAAiB;AAE5B,MAAM,gBAAoB,MAAM;AACrC,MAAI,QAAQ,IAAI,aAAa,aAAc,QAAO;AAElD,YAAU,MAAM;AACd,UAAM,UAAU,SAAS,cAAc,MAAM;AAC7C,YAAQ,OAAO;AACf,YAAQ,UAAU;AAClB,aAAS,KAAK,YAAY,OAAO;AAAA,EACnC,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;","names":[]}
@@ -1,76 +1,199 @@
1
1
  import "../chunk-ZD7AOCMD.mjs";
2
+ import { parse } from "url";
2
3
  import { getConfiguration } from "@intlayer/config";
3
- import {
4
- getPathWithoutLocale,
5
- localeDetector
6
- } from "@intlayer/core";
4
+ import { localeDetector } from "@intlayer/core";
7
5
  const intlayerConfig = getConfiguration();
8
6
  const { internationalization, middleware } = intlayerConfig;
9
7
  const { locales: supportedLocales, defaultLocale } = internationalization;
10
- const { cookieName, headerName, prefixDefault } = middleware;
11
- const intLayerMiddlewarePlugin = (_pluginOptions = {}) => ({
12
- name: "vite-intlayer-middleware-plugin",
13
- configureServer: (server) => {
14
- server.middlewares.use((req, res, next) => {
15
- if (req.url?.startsWith("/node_modules") || req.url?.startsWith("/@") || req.url?.split("?")[0].match(/\.[a-z]+$/i)) {
16
- return next();
17
- }
18
- const originalUrl = req.url ?? "/";
19
- const cookies = parseCookies(req.headers.cookie ?? "");
20
- const cookieLocale = cookies[cookieName];
21
- const headers = req.headers;
22
- const headerLocale = headers[headerName];
23
- const pathParts = originalUrl.split("?")[0].split("/").filter(Boolean);
24
- const firstPart = pathParts[0];
25
- const pathLocale = pathParts[0] && supportedLocales.includes(firstPart) ? pathParts[0] : void 0;
26
- if (!pathLocale) {
27
- let locale;
28
- if (!locale && cookieLocale && supportedLocales.includes(cookieLocale)) {
29
- locale = cookieLocale;
30
- }
31
- if (!locale && headerLocale && supportedLocales.includes(headerLocale)) {
32
- locale = headerLocale;
33
- }
34
- if (!locale) {
35
- const detectedLocale = localeDetector(
36
- headers,
37
- supportedLocales,
38
- defaultLocale
39
- );
40
- locale = detectedLocale;
41
- }
42
- req.url = formatUrlWithLocale(originalUrl, locale);
43
- if (req.url === originalUrl) {
8
+ const {
9
+ cookieName,
10
+ headerName,
11
+ prefixDefault,
12
+ noPrefix,
13
+ serverSetCookie,
14
+ basePath = ""
15
+ } = middleware;
16
+ const intLayerMiddlewarePlugin = () => {
17
+ return {
18
+ name: "vite-intlayer-middleware-plugin",
19
+ configureServer: (server) => {
20
+ server.middlewares.use((req, res, next) => {
21
+ if (req.url?.startsWith("/node_modules") || req.url?.startsWith("/@") || req.url?.split("?")[0].match(/\.[a-z]+$/i)) {
44
22
  return next();
45
23
  }
46
- res.writeHead(301, { Location: req.url });
47
- return res.end();
48
- }
49
- if (pathLocale.toString() === defaultLocale.toString() && !prefixDefault) {
50
- req.url = getPathWithoutLocale(originalUrl, supportedLocales);
51
- res.writeHead(301, { Location: req.url });
52
- return res.end();
53
- }
54
- return next();
24
+ const parsedUrl = parse(req.url ?? "/", true);
25
+ const originalPath = parsedUrl.pathname ?? "/";
26
+ const cookies = parseCookies(req.headers.cookie ?? "");
27
+ const cookieLocale = getValidLocaleFromCookie(cookies[cookieName]);
28
+ const pathLocale = getPathLocale(originalPath);
29
+ if (noPrefix) {
30
+ handleNoPrefix({
31
+ req,
32
+ res,
33
+ next,
34
+ originalPath,
35
+ cookieLocale
36
+ });
37
+ return;
38
+ }
39
+ handlePrefix({
40
+ req,
41
+ res,
42
+ next,
43
+ originalPath,
44
+ pathLocale,
45
+ cookieLocale
46
+ });
47
+ });
48
+ }
49
+ };
50
+ };
51
+ const parseCookies = (cookieHeader) => {
52
+ return cookieHeader.split(";").reduce(
53
+ (acc, cookie) => {
54
+ const [key, val] = cookie.trim().split("=");
55
+ acc[key] = val;
56
+ return acc;
57
+ },
58
+ {}
59
+ );
60
+ };
61
+ const getValidLocaleFromCookie = (locale) => {
62
+ if (locale && supportedLocales.includes(locale)) {
63
+ return locale;
64
+ }
65
+ return void 0;
66
+ };
67
+ const getPathLocale = (pathname) => {
68
+ const segments = pathname.split("/").filter(Boolean);
69
+ const firstSegment = segments[0];
70
+ if (firstSegment && supportedLocales.includes(firstSegment)) {
71
+ return firstSegment;
72
+ }
73
+ return void 0;
74
+ };
75
+ const redirectUrl = (res, newUrl) => {
76
+ res.writeHead(301, { Location: newUrl });
77
+ return res.end();
78
+ };
79
+ const rewriteUrl = (req, res, newUrl, locale) => {
80
+ req.url = newUrl;
81
+ if (locale && headerName) {
82
+ res.setHeader(headerName, locale);
83
+ }
84
+ };
85
+ const constructPath = (locale, currentPath) => {
86
+ const cleanBasePath = basePath.startsWith("/") ? basePath : `/${basePath}`;
87
+ const normalizedBasePath = cleanBasePath === "/" ? "" : cleanBasePath;
88
+ let newPath = `${normalizedBasePath}/${locale}${currentPath}`;
89
+ if (!prefixDefault && locale === defaultLocale) {
90
+ newPath = `${normalizedBasePath}${currentPath}`;
91
+ }
92
+ return newPath;
93
+ };
94
+ const handleNoPrefix = ({
95
+ req,
96
+ res,
97
+ next,
98
+ originalPath,
99
+ cookieLocale
100
+ }) => {
101
+ let locale = cookieLocale ?? defaultLocale;
102
+ if (!cookieLocale) {
103
+ const detectedLocale = localeDetector(
104
+ req.headers,
105
+ supportedLocales,
106
+ defaultLocale
107
+ );
108
+ locale = detectedLocale;
109
+ }
110
+ rewriteUrl(req, res, originalPath, locale);
111
+ return next();
112
+ };
113
+ const handlePrefix = ({
114
+ req,
115
+ res,
116
+ next,
117
+ originalPath,
118
+ pathLocale,
119
+ cookieLocale
120
+ }) => {
121
+ if (!pathLocale) {
122
+ handleMissingPathLocale({
123
+ req,
124
+ res,
125
+ next,
126
+ originalPath,
127
+ cookieLocale
55
128
  });
129
+ return;
56
130
  }
57
- });
58
- const parseCookies = (cookieHeader) => cookieHeader.split(";").reduce(
59
- (acc, cookie) => {
60
- const [key, val] = cookie.trim().split("=");
61
- acc[key] = val;
62
- return acc;
63
- },
64
- {}
65
- );
66
- const formatUrlWithLocale = (url, locale) => {
67
- if (locale.toString() === defaultLocale.toString()) {
68
- if (prefixDefault) {
69
- return `/${locale}${url}`;
70
- }
71
- return url;
131
+ handleExistingPathLocale({
132
+ req,
133
+ res,
134
+ next,
135
+ originalPath,
136
+ pathLocale,
137
+ cookieLocale
138
+ });
139
+ };
140
+ const handleMissingPathLocale = ({
141
+ req,
142
+ res,
143
+ next,
144
+ originalPath,
145
+ cookieLocale
146
+ }) => {
147
+ let locale = cookieLocale ?? localeDetector(
148
+ req.headers,
149
+ supportedLocales,
150
+ defaultLocale
151
+ );
152
+ if (!supportedLocales.includes(locale)) {
153
+ locale = defaultLocale;
154
+ }
155
+ const newPath = constructPath(locale, originalPath);
156
+ if (prefixDefault || locale !== defaultLocale) {
157
+ return redirectUrl(res, newPath);
158
+ }
159
+ rewriteUrl(req, res, newPath, locale);
160
+ return next();
161
+ };
162
+ const handleExistingPathLocale = ({
163
+ req,
164
+ res,
165
+ next,
166
+ originalPath,
167
+ pathLocale,
168
+ cookieLocale
169
+ }) => {
170
+ if (cookieLocale && cookieLocale !== pathLocale && serverSetCookie !== "always") {
171
+ const newPath = originalPath.replace(`/${pathLocale}`, `/${cookieLocale}`);
172
+ const finalPath = constructPath(cookieLocale, newPath.replace(/^\/+/, "/"));
173
+ return redirectUrl(res, finalPath);
174
+ }
175
+ handleDefaultLocaleRedirect({
176
+ req,
177
+ res,
178
+ next,
179
+ originalPath,
180
+ pathLocale
181
+ });
182
+ };
183
+ const handleDefaultLocaleRedirect = ({
184
+ req,
185
+ res,
186
+ next,
187
+ originalPath,
188
+ pathLocale
189
+ }) => {
190
+ if (!prefixDefault && pathLocale === defaultLocale) {
191
+ const newPath = originalPath.replace(`/${defaultLocale}`, "") ?? "/";
192
+ rewriteUrl(req, res, newPath, pathLocale);
193
+ return next();
72
194
  }
73
- return `/${locale}${url}`;
195
+ rewriteUrl(req, res, originalPath, pathLocale);
196
+ return next();
74
197
  };
75
198
  export {
76
199
  intLayerMiddlewarePlugin
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/vite/intlayerMiddlewarePlugin.ts"],"sourcesContent":["import { getConfiguration, Locales } from '@intlayer/config';\nimport {\n getPathWithoutLocale,\n localeDetector as localeDetector,\n} from '@intlayer/core';\n// @ts-ignore - Fix error Module '\"vite\"' has no exported member\nimport { type Plugin } from 'vite';\n\nconst intlayerConfig = getConfiguration();\nconst { internationalization, middleware } = intlayerConfig;\n\nconst { locales: supportedLocales, defaultLocale } = internationalization;\nconst { cookieName, headerName, prefixDefault } = middleware;\n\n/**\n * A Vite plugin that integrates IntLayer middleware into the build process\n *\n * ```ts\n * // Example usage of the plugin in a Vite configuration\n * export default defineConfig({\n * plugins: [ intLayerMiddlewarePlugin() ],\n * });\n * ```\n */\nexport const intLayerMiddlewarePlugin = (_pluginOptions = {}): Plugin => ({\n name: 'vite-intlayer-middleware-plugin',\n\n configureServer: (server) => {\n // server.middlewares is a Connect instance; you can add middleware here\n server.middlewares.use((req, res, next) => {\n // Skip if request looks like a static asset or internal Vite request\n if (\n req.url?.startsWith('/node_modules') ||\n req.url?.startsWith('/@') ||\n req.url?.split('?')[0].match(/\\.[a-z]+$/i) // checks if URL has a file extension\n ) {\n return next();\n }\n\n const originalUrl = req.url ?? '/';\n\n const cookies = parseCookies(req.headers.cookie ?? '');\n const cookieLocale = cookies[cookieName];\n\n const headers = req.headers;\n const headerLocale = headers[headerName];\n\n const pathParts = originalUrl.split('?')[0].split('/').filter(Boolean);\n\n const firstPart = pathParts[0] as unknown as Locales;\n\n const pathLocale =\n pathParts[0] && supportedLocales.includes(firstPart)\n ? pathParts[0]\n : undefined;\n\n if (!pathLocale) {\n let locale;\n\n // Try to get the locale from the request cookies\n if (\n !locale &&\n cookieLocale &&\n supportedLocales.includes(cookieLocale as Locales)\n ) {\n locale = cookieLocale as Locales;\n }\n\n // Try to get the locale from the request headers\n if (\n !locale &&\n headerLocale &&\n supportedLocales.includes(headerLocale as Locales)\n ) {\n locale = headerLocale as Locales;\n }\n\n // Get the locale from the negotiator\n if (!locale) {\n const detectedLocale = localeDetector(\n headers as Record<string, string>,\n supportedLocales,\n defaultLocale\n );\n locale = detectedLocale;\n }\n\n // Instead of redirecting, try rewriting internally:\n req.url = formatUrlWithLocale(originalUrl, locale);\n\n if (req.url === originalUrl) {\n return next();\n }\n\n res.writeHead(301, { Location: req.url });\n return res.end();\n }\n\n if (\n pathLocale.toString() === defaultLocale.toString() &&\n !prefixDefault\n ) {\n req.url = getPathWithoutLocale(originalUrl, supportedLocales);\n\n res.writeHead(301, { Location: req.url });\n return res.end();\n }\n\n return next();\n });\n },\n});\n\n// Simple cookie parser:\nconst parseCookies = (cookieHeader: string) =>\n cookieHeader.split(';').reduce(\n (acc, cookie) => {\n const [key, val] = cookie.trim().split('=');\n acc[key as keyof typeof acc] = val;\n return acc;\n },\n {} as Record<string, string>\n );\n\nconst formatUrlWithLocale = (url: string, locale: Locales) => {\n if (locale.toString() === defaultLocale.toString()) {\n if (prefixDefault) {\n return `/${locale}${url}`;\n }\n\n return url;\n }\n\n return `/${locale}${url}`;\n};\n"],"mappings":";AAAA,SAAS,wBAAiC;AAC1C;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAIP,MAAM,iBAAiB,iBAAiB;AACxC,MAAM,EAAE,sBAAsB,WAAW,IAAI;AAE7C,MAAM,EAAE,SAAS,kBAAkB,cAAc,IAAI;AACrD,MAAM,EAAE,YAAY,YAAY,cAAc,IAAI;AAY3C,MAAM,2BAA2B,CAAC,iBAAiB,CAAC,OAAe;AAAA,EACxE,MAAM;AAAA,EAEN,iBAAiB,CAAC,WAAW;AAE3B,WAAO,YAAY,IAAI,CAAC,KAAK,KAAK,SAAS;AAEzC,UACE,IAAI,KAAK,WAAW,eAAe,KACnC,IAAI,KAAK,WAAW,IAAI,KACxB,IAAI,KAAK,MAAM,GAAG,EAAE,CAAC,EAAE,MAAM,YAAY,GACzC;AACA,eAAO,KAAK;AAAA,MACd;AAEA,YAAM,cAAc,IAAI,OAAO;AAE/B,YAAM,UAAU,aAAa,IAAI,QAAQ,UAAU,EAAE;AACrD,YAAM,eAAe,QAAQ,UAAU;AAEvC,YAAM,UAAU,IAAI;AACpB,YAAM,eAAe,QAAQ,UAAU;AAEvC,YAAM,YAAY,YAAY,MAAM,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG,EAAE,OAAO,OAAO;AAErE,YAAM,YAAY,UAAU,CAAC;AAE7B,Y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AM,GAAG,GAAG;AACzB;","names":[]}
1
+ {"version":3,"sources":["../../../src/vite/intlayerMiddlewarePlugin.ts"],"sourcesContent":["import { IncomingMessage, ServerResponse } from 'http';\nimport { parse } from 'url';\nimport { getConfiguration, type Locales } from '@intlayer/config';\nimport { localeDetector } from '@intlayer/core';\n/* @ts-ignore - Vite types error */\nimport type { Connect, Plugin } from 'vite';\n\n// Grab all the config you need.\n// Make sure your config includes the following fields if you want to replicate Next.js logic:\n// - internationalization.locales\n// - internationalization.defaultLocale\n// - middleware.cookieName\n// - middleware.headerName\n// - middleware.prefixDefault\n// - middleware.noPrefix\n// - middleware.serverSetCookie\n// - middleware.basePath\n// - etc.\nconst intlayerConfig = getConfiguration();\nconst { internationalization, middleware } = intlayerConfig;\nconst { locales: supportedLocales, defaultLocale } = internationalization;\n\nconst {\n cookieName,\n headerName,\n prefixDefault,\n noPrefix,\n serverSetCookie,\n basePath = '',\n} = middleware;\n\n/**\n * A Vite plugin that integrates a logic similar to the Next.js intlayer middleware.\n */\nexport const intLayerMiddlewarePlugin = (): Plugin => {\n return {\n name: 'vite-intlayer-middleware-plugin',\n configureServer: (server) => {\n server.middlewares.use((req, res, next) => {\n // 1. Bypass assets and special Vite endpoints\n if (\n req.url?.startsWith('/node_modules') ||\n req.url?.startsWith('/@') ||\n req.url?.split('?')[0].match(/\\.[a-z]+$/i) // checks for file extensions\n ) {\n return next();\n }\n\n // 2. Parse original URL for path and query\n const parsedUrl = parse(req.url ?? '/', true);\n const originalPath = parsedUrl.pathname ?? '/';\n\n // 3. Attempt to read the cookie locale\n const cookies = parseCookies(req.headers.cookie ?? '');\n const cookieLocale = getValidLocaleFromCookie(cookies[cookieName]);\n\n // 4. Check if there's a locale prefix in the path\n const pathLocale = getPathLocale(originalPath);\n\n // 5. If noPrefix is true, we skip prefix logic altogether\n if (noPrefix) {\n handleNoPrefix({\n req,\n res,\n next,\n originalPath,\n cookieLocale,\n });\n return;\n }\n\n // 6. Otherwise, handle prefix logic\n handlePrefix({\n req,\n res,\n next,\n originalPath,\n pathLocale,\n cookieLocale,\n });\n });\n },\n };\n};\n\n/* --------------------------------------------------------------------\n * Helper & Utility Functions\n * --------------------------------------------------------------------\n */\n\n/**\n * Parses cookies from the Cookie header string into an object.\n */\nconst parseCookies = (cookieHeader: string) => {\n return cookieHeader.split(';').reduce(\n (acc, cookie) => {\n const [key, val] = cookie.trim().split('=');\n acc[key] = val;\n return acc;\n },\n {} as Record<string, string>\n );\n};\n\n/**\n * Checks if the cookie locale is valid and is included in the supported locales.\n */\nconst getValidLocaleFromCookie = (\n locale: string | undefined\n): Locales | undefined => {\n if (locale && supportedLocales.includes(locale as Locales)) {\n return locale as Locales;\n }\n return undefined;\n};\n\n/**\n * Extracts the locale from the URL pathname if present as the first segment.\n */\nconst getPathLocale = (pathname: string): Locales | undefined => {\n // e.g. if pathname is /en/some/page or /en\n // we check if \"en\" is in your supportedLocales\n const segments = pathname.split('/').filter(Boolean);\n const firstSegment = segments[0];\n if (firstSegment && supportedLocales.includes(firstSegment as Locales)) {\n return firstSegment as Locales;\n }\n return undefined;\n};\n\n/**\n * Writes a 301 redirect response with the given new URL.\n */\nconst redirectUrl = (res: ServerResponse<IncomingMessage>, newUrl: string) => {\n res.writeHead(301, { Location: newUrl });\n return res.end();\n};\n\n/**\n * \"Rewrite\" the request internally by adjusting req.url;\n * we also set the locale in the response header if needed.\n */\nconst rewriteUrl = (\n req: Connect.IncomingMessage,\n res: ServerResponse<IncomingMessage>,\n newUrl: string,\n locale?: Locales\n) => {\n req.url = newUrl;\n // If you want to mimic Next.js's behavior of setting a header for the locale:\n if (locale && headerName) {\n res.setHeader(headerName, locale);\n }\n};\n\n/**\n * Constructs a new path string, optionally including a locale prefix and basePath.\n * - basePath: (e.g., '/myapp')\n * - locale: (e.g., 'en')\n * - currentPath:(e.g., '/products/shoes')\n */\nconst constructPath = (locale: Locales, currentPath: string) => {\n // Ensure basePath always starts with '/', and remove trailing slash if needed\n const cleanBasePath = basePath.startsWith('/') ? basePath : `/${basePath}`;\n // If basePath is '/', no trailing slash is needed\n const normalizedBasePath = cleanBasePath === '/' ? '' : cleanBasePath;\n\n // Combine basePath + locale + the rest of the path\n // Example: basePath = '/myapp', locale = 'en', currentPath = '/products' => '/myapp/en/products'\n let newPath = `${normalizedBasePath}/${locale}${currentPath}`;\n\n // Special case: if prefixDefault is false and locale is defaultLocale, remove the locale prefix\n if (!prefixDefault && locale === defaultLocale) {\n newPath = `${normalizedBasePath}${currentPath}`;\n }\n\n return newPath;\n};\n\n/* --------------------------------------------------------------------\n * Handlers that mirror Next.js style logic\n * --------------------------------------------------------------------\n */\n\n/**\n * If `noPrefix` is true, we never prefix the locale in the URL.\n * We simply rewrite the request to the same path, but with the best-chosen locale\n * in a header or cookie if desired.\n */\nconst handleNoPrefix = ({\n req,\n res,\n next,\n originalPath,\n cookieLocale,\n}: {\n req: Connect.IncomingMessage;\n res: ServerResponse<IncomingMessage>;\n next: Connect.NextFunction;\n originalPath: string;\n cookieLocale?: Locales;\n}) => {\n // Determine the best locale\n let locale = cookieLocale ?? defaultLocale;\n\n // Use fallback to localeDetector if no cookie\n if (!cookieLocale) {\n const detectedLocale = localeDetector(\n req.headers as Record<string, string>,\n supportedLocales,\n defaultLocale\n );\n locale = detectedLocale;\n }\n\n // Just rewrite the URL in-place (no prefix). We do NOT redirect because we do not want to alter the URL.\n rewriteUrl(req, res, originalPath, locale);\n return next();\n};\n\n/**\n * The main prefix logic:\n * - If there's no pathLocale in the URL, we might want to detect & redirect or rewrite\n * - If there is a pathLocale, handle cookie mismatch or default locale special cases\n */\nconst handlePrefix = ({\n req,\n res,\n next,\n originalPath,\n pathLocale,\n cookieLocale,\n}: {\n req: Connect.IncomingMessage;\n res: ServerResponse<IncomingMessage>;\n next: Connect.NextFunction;\n originalPath: string;\n pathLocale?: Locales;\n cookieLocale?: Locales;\n}) => {\n // 1. If pathLocale is missing, handle\n if (!pathLocale) {\n handleMissingPathLocale({\n req,\n res,\n next,\n originalPath,\n cookieLocale,\n });\n return;\n }\n\n // 2. If pathLocale exists, handle possible mismatch with cookie\n handleExistingPathLocale({\n req,\n res,\n next,\n originalPath,\n pathLocale,\n cookieLocale,\n });\n};\n\n/**\n * Handles requests where the locale is missing from the URL pathname.\n * We detect a locale from cookie / headers / default, then either redirect or rewrite.\n */\nconst handleMissingPathLocale = ({\n req,\n res,\n next,\n originalPath,\n cookieLocale,\n}: {\n req: Connect.IncomingMessage;\n res: ServerResponse<IncomingMessage>;\n next: Connect.NextFunction;\n originalPath: string;\n cookieLocale?: Locales;\n}) => {\n // 1. Choose the best locale\n let locale =\n cookieLocale ??\n localeDetector(\n req.headers as Record<string, string>,\n supportedLocales,\n defaultLocale\n );\n\n // 2. If still invalid, fallback\n if (!supportedLocales.includes(locale)) {\n locale = defaultLocale;\n }\n\n // 3. Construct new path\n const newPath = constructPath(locale, originalPath);\n\n // If we always prefix default or if this is not the default locale, do a 301 redirect\n // so that the user sees the locale in the URL.\n if (prefixDefault || locale !== defaultLocale) {\n return redirectUrl(res, newPath);\n }\n\n // If we do NOT prefix the default locale, just rewrite in place\n rewriteUrl(req, res, newPath, locale);\n return next();\n};\n\n/**\n * Handles requests where the locale prefix is present in the pathname.\n * We verify if the cookie locale differs from the path locale; if so, handle.\n */\nconst handleExistingPathLocale = ({\n req,\n res,\n next,\n originalPath,\n pathLocale,\n cookieLocale,\n}: {\n req: Connect.IncomingMessage;\n res: ServerResponse<IncomingMessage>;\n next: Connect.NextFunction;\n originalPath: string;\n pathLocale: Locales;\n cookieLocale?: Locales;\n}) => {\n // 1. If the cookie locale is set and differs from the path locale,\n // and we're not forcing the cookie to always override\n if (\n cookieLocale &&\n cookieLocale !== pathLocale &&\n serverSetCookie !== 'always'\n ) {\n // We want to swap out the pathLocale with the cookieLocale\n const newPath = originalPath.replace(`/${pathLocale}`, `/${cookieLocale}`);\n const finalPath = constructPath(cookieLocale, newPath.replace(/^\\/+/, '/'));\n return redirectUrl(res, finalPath);\n }\n\n // 2. Otherwise, handle default-locale prefix if needed\n handleDefaultLocaleRedirect({\n req,\n res,\n next,\n originalPath,\n pathLocale,\n });\n};\n\n/**\n * If the path locale is the default locale but we don't want to prefix the default, remove it.\n */\nconst handleDefaultLocaleRedirect = ({\n req,\n res,\n next,\n originalPath,\n pathLocale,\n}: {\n req: Connect.IncomingMessage;\n res: ServerResponse<IncomingMessage>;\n next: Connect.NextFunction;\n originalPath: string;\n pathLocale: Locales;\n}) => {\n // If we don't prefix default AND the path locale is the default locale -> remove it\n if (!prefixDefault && pathLocale === defaultLocale) {\n // Remove the default locale part from the path\n const newPath = originalPath.replace(`/${defaultLocale}`, '') ?? '/';\n rewriteUrl(req, res, newPath, pathLocale);\n return next();\n }\n\n // If we do prefix default or pathLocale != default, keep as is, but rewrite headers\n rewriteUrl(req, res, originalPath, pathLocale);\n return next();\n};\n"],"mappings":";AACA,SAAS,aAAa;AACtB,SAAS,wBAAsC;AAC/C,SAAS,sBAAsB;AAe/B,MAAM,iBAAiB,iBAAiB;AACxC,MAAM,EAAE,sBAAsB,WAAW,IAAI;AAC7C,MAAM,EAAE,SAAS,kBAAkB,cAAc,IAAI;AAErD,MAAM;AAAA,EACJ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AACb,IAAI;AAKG,MAAM,2BAA2B,MAAc;AACpD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,iBAAiB,CAAC,WAAW;AAC3B,aAAO,YAAY,IAAI,CAAC,KAAK,KAAK,SAAS;AAEzC,YACE,IAAI,KAAK,WAAW,eAAe,KACnC,IAAI,KAAK,WAAW,IAAI,KACxB,IAAI,KAAK,MAAM,GAAG,EAAE,CAAC,EAAE,MAAM,YAAY,GACzC;AACA,iBAAO,KAAK;AAAA,QACd;AAGA,cAAM,YAAY,MAAM,IAAI,OAAO,KAAK,IAAI;AAC5C,cAAM,eAAe,UAAU,YAAY;AAG3C,cAAM,UAAU,aAAa,IAAI,QAAQ,UAAU,EAAE;A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,KAAK,SAAS,MAAM;AACpC,SAAO,KAAK;AACd;AAMA,MAAM,2BAA2B,CAAC;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAOM;AAGJ,MACE,gBACA,iBAAiB,cACjB,oBAAoB,UACpB;AAEA,UAAM,UAAU,aAAa,QAAQ,IAAI,UAAU,IAAI,IAAI,YAAY,EAAE;AACzE,UAAM,YAAY,cAAc,cAAc,QAAQ,QAAQ,QAAQ,GAAG,CAAC;AAC1E,WAAO,YAAY,KAAK,SAAS;AAAA,EACnC;AAGA,8BAA4B;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAKA,MAAM,8BAA8B,CAAC;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAMM;AAEJ,MAAI,CAAC,iBAAiB,eAAe,eAAe;AAElD,UAAM,UAAU,aAAa,QAAQ,IAAI,aAAa,IAAI,EAAE,KAAK;AACjE,eAAW,KAAK,KAAK,SAAS,UAAU;AACxC,WAAO,KAAK;AAAA,EACd;AAGA,aAAW,KAAK,KAAK,cAAc,UAAU;AAC7C,SAAO,KAAK;AACd;","names":[]}
@@ -1,5 +1,6 @@
1
1
  export { type IntlayerProviderProps, IntlayerClientContext, useIntlayerContext, IntlayerProvider, } from './IntlayerProvider';
2
2
  export { useIntlayer } from './useIntlayer';
3
+ export { useIntlayerAsync } from './useIntlayerAsync';
3
4
  export { useDictionary } from './useDictionary';
4
5
  export { useLocaleBase } from './useLocaleBase';
5
6
  export { useLocale } from './useLocale';
@@ -1 +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"}
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,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,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,15 @@
1
+ import type { Locales } from '@intlayer/config/client';
2
+ import { DataFromDictionaryKey, type DictionaryKeys } from '../getIntlayer';
3
+ export type UseIntlayerAsync = <T extends DictionaryKeys, L extends Locales, R extends boolean = true>(key: T, locale?: L, isRenderEditor?: R) => DataFromDictionaryKey<T, L, R> & {
4
+ isLoading: boolean;
5
+ };
6
+ /**
7
+ * On the client side, Hook that picking one dictionary by its key and return the content
8
+ *
9
+ * This hook will prerender the locale dictionary and fetch simultaneously the distant dictionaries to hydrate it.
10
+ *
11
+ *
12
+ * If the locale is not provided, it will use the locale from the client context
13
+ */
14
+ export declare const useIntlayerAsync: UseIntlayerAsync;
15
+ //# sourceMappingURL=useIntlayerAsync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIntlayerAsync.d.ts","sourceRoot":"","sources":["../../../src/client/useIntlayerAsync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EACL,qBAAqB,EACrB,KAAK,cAAc,EAEpB,MAAM,gBAAgB,CAAC;AAIxB,MAAM,MAAM,gBAAgB,GAAG,CAC7B,CAAC,SAAS,cAAc,EACxB,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,GAAG,IAAI,EAExB,GAAG,EAAE,CAAC,EACN,MAAM,CAAC,EAAE,CAAC,EACV,cAAc,CAAC,EAAE,CAAC,KACf,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAE7D;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,EAAE,gBAiC9B,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { type DictionaryAPI } from '@intlayer/backend';
2
+ /**
3
+ * Fetch distant dictionary
4
+ */
5
+ export declare const fetchDistantDictionary: (dictionaryKey: string) => Promise<DictionaryAPI>;
6
+ //# sourceMappingURL=fetchDistantDictionary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchDistantDictionary.d.ts","sourceRoot":"","sources":["../../../src/distantDictionary/fetchDistantDictionary.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAKvD;;GAEG;AACH,eAAO,MAAM,sBAAsB,kBAClB,MAAM,KACpB,OAAO,CAAC,aAAa,CAoCvB,CAAC"}
@@ -2,7 +2,7 @@ import { type KeyPath } from '@intlayer/core';
2
2
  import { type FC, type ReactNode } from 'react';
3
3
  export type ContentSelectorWrapperProps = {
4
4
  children: ReactNode;
5
- dictionaryId: string;
5
+ dictionaryKey: string;
6
6
  dictionaryPath: string;
7
7
  keyPath: KeyPath[];
8
8
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ContentSelectorWrapper.d.ts","sourceRoot":"","sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEhD,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,EAAE,SAAS,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CAE9C,CAAC"}
1
+ {"version":3,"file":"ContentSelectorWrapper.d.ts","sourceRoot":"","sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEhD,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,EAAE,SAAS,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CAE9C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerEditorProvider.d.ts","sourceRoot":"","sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG9C,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,iBAAiB,CAExD,CAAC"}
1
+ {"version":3,"file":"IntlayerEditorProvider.d.ts","sourceRoot":"","sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAI9C,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,iBAAiB,CAKxD,CAAC"}
@@ -2,7 +2,7 @@ import type { KeyPath } from '@intlayer/core';
2
2
  import type { ReactNode } from 'react';
3
3
  export type IntlayerEditorElementProps = {
4
4
  content: string;
5
- dictionaryId: string;
5
+ dictionaryKey: string;
6
6
  dictionaryPath: string;
7
7
  keyPath: KeyPath[];
8
8
  isContentSelectable: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"renderContentEditor.d.ts","sourceRoot":"","sources":["../../../src/editor/renderContentEditor.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAM,SAAS,EAAE,MAAM,OAAO,CAAC;AAO3C,MAAM,MAAM,0BAA0B,GAAG;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAAC;AAeF,MAAM,MAAM,YAAY,CAAC,CAAC,GAAG,MAAM,IAAI,SAAS,GAAG;IACjD,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF,eAAO,MAAM,oBAAoB,SACzB,0BAA0B,oCAE/B,YASF,CAAC"}
1
+ {"version":3,"file":"renderContentEditor.d.ts","sourceRoot":"","sources":["../../../src/editor/renderContentEditor.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAM,SAAS,EAAE,MAAM,OAAO,CAAC;AAO3C,MAAM,MAAM,0BAA0B,GAAG;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAAC;AAeF,MAAM,MAAM,YAAY,CAAC,CAAC,GAAG,MAAM,IAAI,SAAS,GAAG;IACjD,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF,eAAO,MAAM,oBAAoB,SACzB,0BAA0B,oCAE/B,YASF,CAAC"}
@@ -23,7 +23,7 @@ export type DictionaryKeys = StringFallback<keyof IntlayerDictionaryTypesConnect
23
23
  * Represents the data type returned by the useIntlayer hook,
24
24
  * excluding the 'id' and 'filePath' keys from the dictionary content.
25
25
  */
26
- type DataFromDictionaryKey<T extends DictionaryKeys, K extends Locales, R extends boolean = false> = DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content'], K, R>;
26
+ export type DataFromDictionaryKey<T extends DictionaryKeys, K extends Locales, R extends boolean = false> = DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content'], K, R>;
27
27
  /**
28
28
  * Type definition for the useIntlayer hook, which takes a dictionary ID and an optional locale,
29
29
  * and returns the deeply transformed dictionary content.
@@ -32,5 +32,4 @@ type DataFromDictionaryKey<T extends DictionaryKeys, K extends Locales, R extend
32
32
  export type UseIntlayer = <T extends DictionaryKeys, L extends Locales, R extends boolean = false>(key: T, locale?: L, isRenderEditor?: R) => DataFromDictionaryKey<T, L, R>;
33
33
  export type UseIntlayerEditable = <T extends DictionaryKeys, L extends Locales, R extends boolean = true>(key: T, locale?: L, isRenderEditor?: R) => DataFromDictionaryKey<T, L, R>;
34
34
  export declare const getIntlayer: UseIntlayer;
35
- export {};
36
35
  //# sourceMappingURL=getIntlayer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getIntlayer.d.ts","sourceRoot":"","sources":["../../src/getIntlayer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAQhD,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,EACL,KAAK,oBAAoB,EAE1B,MAAM,iBAAiB,CAAC;AAGzB;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS,KAAK,GAAG,MAAM,GAAG,CAAC,CAAC;AAE7D;;;;;;;;;;GAUG;AACH,MAAM,MAAM,cAAc,GAAG,cAAc,CACzC,MAAM,gCAAgC,CACvC,CAAC;AAEF;;;GAGG;AACH,KAAK,qBAAqB,CACxB,CAAC,SAAS,cAAc,EACxB,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,GAAG,KAAK,IACvB,oBAAoB,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAE/E;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,CACxB,CAAC,SAAS,cAAc,EACxB,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,GAAG,KAAK,EAEzB,GAAG,EAAE,CAAC,EACN,MAAM,CAAC,EAAE,CAAC,EACV,cAAc,CAAC,EAAE,CAAC,KACf,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAEpC,MAAM,MAAM,mBAAmB,GAAG,CAChC,CAAC,SAAS,cAAc,EACxB,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,GAAG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