react-intlayer 5.5.1 → 5.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,12 +22,17 @@ __export(useDictionary_exports, {
22
22
  useDictionary: () => useDictionary
23
23
  });
24
24
  module.exports = __toCommonJS(useDictionary_exports);
25
+ var import_editor_react = require("@intlayer/editor-react");
25
26
  var import_react = require("react");
26
27
  var import_getDictionary = require('../getDictionary.cjs');
27
28
  var import_IntlayerProvider = require('./IntlayerProvider.cjs');
28
29
  const useDictionary = (dictionary, locale) => {
29
30
  const { locale: currentLocale } = (0, import_react.useContext)(import_IntlayerProvider.IntlayerClientContext);
30
31
  const localeTarget = locale ?? currentLocale;
32
+ const { changedContent } = (0, import_editor_react.useChangedContent)();
33
+ if (changedContent?.[dictionary.key]) {
34
+ return (0, import_getDictionary.getDictionary)(changedContent?.[dictionary.key], localeTarget);
35
+ }
31
36
  return (0, import_getDictionary.getDictionary)(dictionary, localeTarget);
32
37
  };
33
38
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary<T, LocalesValues>(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,mBAA2B;AAC3B,2BAA8B;AAC9B,8BAAsC;AAO/B,MAAM,gBAAgB,CAC3B,YACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,QAAI,yBAAW,6CAAqB;AAClE,QAAM,eAAe,UAAU;AAE/B,aAAO,oCAAgC,YAAY,YAAY;AACjE;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\nimport { useChangedContent } from '@intlayer/editor-react';\nimport { useContext } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n const { changedContent } = useChangedContent();\n\n if (changedContent?.[dictionary.key]) {\n // @ts-ignore fix instantiation is excessively deep and possibly infinite\n return getDictionary(changedContent?.[dictionary.key], localeTarget);\n }\n\n return getDictionary<T, LocalesValues>(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAAkC;AAClC,mBAA2B;AAC3B,2BAA8B;AAC9B,8BAAsC;AAO/B,MAAM,gBAAgB,CAC3B,YACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,QAAI,yBAAW,6CAAqB;AAClE,QAAM,eAAe,UAAU;AAC/B,QAAM,EAAE,eAAe,QAAI,uCAAkB;AAE7C,MAAI,iBAAiB,WAAW,GAAG,GAAG;AAEpC,eAAO,oCAAc,iBAAiB,WAAW,GAAG,GAAG,YAAY;AAAA,EACrE;AAEA,aAAO,oCAAgC,YAAY,YAAY;AACjE;","names":[]}
@@ -35,17 +35,10 @@ module.exports = __toCommonJS(IntlayerEditorProvider_exports);
35
35
  var import_jsx_runtime = require("react/jsx-runtime");
36
36
  var import_api = require("@intlayer/api");
37
37
  var import_built = __toESM(require("@intlayer/config/built"));
38
- var import_dictionaries_entry = __toESM(require("@intlayer/dictionaries-entry"));
39
38
  var import_editor_react = require("@intlayer/editor-react");
40
39
  var import_react = require("react");
41
40
  const IntlayerEditorHooksEnabled = () => {
42
41
  (0, import_editor_react.useCrossURLPathSetter)();
43
- const { setLocaleDictionaries } = (0, import_editor_react.useDictionariesRecordActions)();
44
- (0, import_react.useEffect)(() => {
45
- setLocaleDictionaries(
46
- import_dictionaries_entry.default
47
- );
48
- }, []);
49
42
  (0, import_editor_react.useIframeClickInterceptor)();
50
43
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
51
44
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["'use client';\n\nimport { IntlayerEventListener } from '@intlayer/api';\nimport configuration from '@intlayer/config/built';\n\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 {\n EditorProvider,\n useChangedContentActions,\n useCrossURLPathSetter,\n useDictionariesRecordActions,\n useEditorEnabled,\n useIframeClickInterceptor,\n} from '@intlayer/editor-react';\nimport { useEffect, type FC, type PropsWithChildren } from 'react';\n\nconst IntlayerEditorHooksEnabled: FC = () => {\n /**\n * URL Messages\n */\n useCrossURLPathSetter();\n\n /**\n * Locale Dictionaries Messages\n */\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n\n useEffect(() => {\n setLocaleDictionaries(\n dictionaries as unknown as Record<string, Dictionary>\n );\n }, []);\n\n /**\n * Click Messages\n */\n useIframeClickInterceptor();\n\n return <></>;\n};\n\nconst { editor } = configuration;\n\nconst IntlayerEditorHook: FC = () => {\n const { enabled } = useEditorEnabled();\n\n /**\n * Hot reloading\n */\n const { setChangedContent } = useChangedContentActions();\n\n useEffect(() => {\n if (!editor.hotReload) return;\n if (!editor.clientId) return;\n if (!editor.clientSecret) return;\n\n const eventSource = new IntlayerEventListener();\n try {\n eventSource.initialize().then(() => {\n eventSource.onDictionaryChange = (dictionary) =>\n setChangedContent(dictionary.key, dictionary.content);\n });\n } catch (error) {\n console.error('Error initializing IntlayerEventListener:', error);\n }\n\n return () => eventSource.cleanup();\n }, []);\n\n return enabled ? <IntlayerEditorHooksEnabled /> : <></>;\n};\n\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => {\n return (\n <EditorProvider\n postMessage={(data: any) => {\n if (typeof window === 'undefined') return;\n\n const isInIframe = window.self !== window.top;\n if (!isInIframe) return;\n\n if (editor.applicationURL.length > 0) {\n window?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the current application URL to synchronize the locales states.\n editor.applicationURL\n );\n }\n\n if (editor.editorURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the editor URL to synchronize the locales states.\n editor.editorURL\n );\n }\n\n if (editor.cmsURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the CMS for security reasons.\n // Correspond to the CMS URL.\n editor.cmsURL\n );\n }\n }}\n allowedOrigins={[\n editor?.editorURL,\n editor?.cmsURL,\n editor?.applicationURL,\n ]}\n mode=\"client\"\n configuration={configuration}\n >\n <IntlayerEditorHook />\n {children}\n </EditorProvider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4CS;AA1CT,iBAAsC;AACtC,mBAA0B;AAQ1B,gCAAyB;AACzB,0BAOO;AACP,mBAA2D;AAE3D,MAAM,6BAAiC,MAAM;AAI3C,iDAAsB;AAKtB,QAAM,EAAE,sBAAsB,QAAI,kDAA6B;AAE/D,8BAAU,MAAM;AACd;AAAA,MACE,0BAAAA;AAAA,IAC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A,MACF;AAAA,MACA,gBAAgB;AAAA,QACd,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,QAAQ;AAAA,MACV;AAAA,MACA,MAAK;AAAA,MACL,eAAe,aAAAA;AAAA,MAEf;AAAA,oDAAC,sBAAmB;AAAA,QACnB;AAAA;AAAA;AAAA,EACH;AAEJ;","names":["dictionaries","configuration"]}
1
+ {"version":3,"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["'use client';\n\nimport { IntlayerEventListener } from '@intlayer/api';\nimport configuration from '@intlayer/config/built';\nimport {\n EditorProvider,\n useChangedContentActions,\n useCrossURLPathSetter,\n useEditorEnabled,\n useIframeClickInterceptor,\n} from '@intlayer/editor-react';\nimport { useEffect, type FC, type PropsWithChildren } from 'react';\n\nconst IntlayerEditorHooksEnabled: FC = () => {\n /**\n * URL Messages\n */\n useCrossURLPathSetter();\n\n /**\n * Click Messages\n */\n useIframeClickInterceptor();\n\n return <></>;\n};\n\nconst { editor } = configuration;\n\nconst IntlayerEditorHook: FC = () => {\n const { enabled } = useEditorEnabled();\n\n /**\n * Hot reloading\n */\n const { setChangedContent } = useChangedContentActions();\n\n useEffect(() => {\n if (!editor.hotReload) return;\n if (!editor.clientId) return;\n if (!editor.clientSecret) return;\n\n const eventSource = new IntlayerEventListener();\n try {\n eventSource.initialize().then(() => {\n eventSource.onDictionaryChange = (dictionary) =>\n setChangedContent(dictionary.key, dictionary.content);\n });\n } catch (error) {\n console.error('Error initializing IntlayerEventListener:', error);\n }\n\n return () => eventSource.cleanup();\n }, []);\n\n return enabled ? <IntlayerEditorHooksEnabled /> : <></>;\n};\n\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => {\n return (\n <EditorProvider\n postMessage={(data: any) => {\n if (typeof window === 'undefined') return;\n\n const isInIframe = window.self !== window.top;\n if (!isInIframe) return;\n\n if (editor.applicationURL.length > 0) {\n window?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the current application URL to synchronize the locales states.\n editor.applicationURL\n );\n }\n\n if (editor.editorURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the editor URL to synchronize the locales states.\n editor.editorURL\n );\n }\n\n if (editor.cmsURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the CMS for security reasons.\n // Correspond to the CMS URL.\n editor.cmsURL\n );\n }\n }}\n allowedOrigins={[\n editor?.editorURL,\n editor?.cmsURL,\n editor?.applicationURL,\n ]}\n mode=\"client\"\n configuration={configuration}\n >\n <IntlayerEditorHook />\n {children}\n </EditorProvider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAwBS;AAtBT,iBAAsC;AACtC,mBAA0B;AAC1B,0BAMO;AACP,mBAA2D;AAE3D,MAAM,6BAAiC,MAAM;AAI3C,iDAAsB;AAKtB,qDAA0B;AAE1B,SAAO,2EAAE;AACX;AAEA,MAAM,EAAE,OAAO,IAAI,aAAAA;AAEnB,MAAM,qBAAyB,MAAM;AACnC,QAAM,EAAE,QAAQ,QAAI,sCAAiB;AAKrC,QAAM,EAAE,kBAAkB,QAAI,8CAAyB;AAEvD,8BAAU,MAAM;AACd,QAAI,CAAC,OAAO,UAAW;AACvB,QAAI,CAAC,OAAO,SAAU;AACtB,QAAI,CAAC,OAAO,aAAc;AAE1B,UAAM,cAAc,IAAI,iCAAsB;AAC9C,QAAI;AACF,kBAAY,WAAW,EAAE,KAAK,MAAM;AAClC,oBAAY,qBAAqB,CAAC,eAChC,kBAAkB,WAAW,KAAK,WAAW,OAAO;AAAA,MACxD,CAAC;AAAA,IACH,SAAS,OAAO;AACd,cAAQ,MAAM,6CAA6C,KAAK;AAAA,IAClE;AAEA,WAAO,MAAM,YAAY,QAAQ;AAAA,EACnC,GAAG,CAAC,CAAC;AAEL,SAAO,UAAU,4CAAC,8BAA2B,IAAK,2EAAE;AACtD;AAEO,MAAM,yBAAgD,CAAC,EAAE,SAAS,MAAM;AAC7E,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAa,CAAC,SAAc;AAC1B,YAAI,OAAO,WAAW,YAAa;AAEnC,cAAM,aAAa,OAAO,SAAS,OAAO;AAC1C,YAAI,CAAC,WAAY;AAEjB,YAAI,OAAO,eAAe,SAAS,GAAG;AACpC,kBAAQ;AAAA,YACN;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAEA,YAAI,OAAO,UAAU,SAAS,GAAG;AAC/B,iBAAO,QAAQ;AAAA,YACb;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAEA,YAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,iBAAO,QAAQ;AAAA,YACb;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAAA,MACA,gBAAgB;AAAA,QACd,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,QAAQ;AAAA,MACV;AAAA,MACA,MAAK;AAAA,MACL,eAAe,aAAAA;AAAA,MAEf;AAAA,oDAAC,sBAAmB;AAAA,QACnB;AAAA;AAAA;AAAA,EACH;AAEJ;","names":["configuration"]}
@@ -1,10 +1,15 @@
1
1
  "use client";
2
+ import { useChangedContent } from "@intlayer/editor-react";
2
3
  import { useContext } from "react";
3
4
  import { getDictionary } from "../getDictionary.mjs";
4
5
  import { IntlayerClientContext } from "./IntlayerProvider.mjs";
5
6
  const useDictionary = (dictionary, locale) => {
6
7
  const { locale: currentLocale } = useContext(IntlayerClientContext);
7
8
  const localeTarget = locale ?? currentLocale;
9
+ const { changedContent } = useChangedContent();
10
+ if (changedContent?.[dictionary.key]) {
11
+ return getDictionary(changedContent?.[dictionary.key], localeTarget);
12
+ }
8
13
  return getDictionary(dictionary, localeTarget);
9
14
  };
10
15
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary<T, LocalesValues>(dictionary, localeTarget);\n};\n"],"mappings":";AAIA,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,6BAA6B;AAO/B,MAAM,gBAAgB,CAC3B,YACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,eAAe,UAAU;AAE/B,SAAO,cAAgC,YAAY,YAAY;AACjE;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\nimport { useChangedContent } from '@intlayer/editor-react';\nimport { useContext } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n const { changedContent } = useChangedContent();\n\n if (changedContent?.[dictionary.key]) {\n // @ts-ignore fix instantiation is excessively deep and possibly infinite\n return getDictionary(changedContent?.[dictionary.key], localeTarget);\n }\n\n return getDictionary<T, LocalesValues>(dictionary, localeTarget);\n};\n"],"mappings":";AAIA,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,6BAA6B;AAO/B,MAAM,gBAAgB,CAC3B,YACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,eAAe,UAAU;AAC/B,QAAM,EAAE,eAAe,IAAI,kBAAkB;AAE7C,MAAI,iBAAiB,WAAW,GAAG,GAAG;AAEpC,WAAO,cAAc,iBAAiB,WAAW,GAAG,GAAG,YAAY;AAAA,EACrE;AAEA,SAAO,cAAgC,YAAY,YAAY;AACjE;","names":[]}
@@ -2,24 +2,16 @@
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { IntlayerEventListener } from "@intlayer/api";
4
4
  import configuration from "@intlayer/config/built";
5
- import dictionaries from "@intlayer/dictionaries-entry";
6
5
  import {
7
6
  EditorProvider,
8
7
  useChangedContentActions,
9
8
  useCrossURLPathSetter,
10
- useDictionariesRecordActions,
11
9
  useEditorEnabled,
12
10
  useIframeClickInterceptor
13
11
  } from "@intlayer/editor-react";
14
12
  import { useEffect } from "react";
15
13
  const IntlayerEditorHooksEnabled = () => {
16
14
  useCrossURLPathSetter();
17
- const { setLocaleDictionaries } = useDictionariesRecordActions();
18
- useEffect(() => {
19
- setLocaleDictionaries(
20
- dictionaries
21
- );
22
- }, []);
23
15
  useIframeClickInterceptor();
24
16
  return /* @__PURE__ */ jsx(Fragment, {});
25
17
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["'use client';\n\nimport { IntlayerEventListener } from '@intlayer/api';\nimport configuration from '@intlayer/config/built';\n\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 {\n EditorProvider,\n useChangedContentActions,\n useCrossURLPathSetter,\n useDictionariesRecordActions,\n useEditorEnabled,\n useIframeClickInterceptor,\n} from '@intlayer/editor-react';\nimport { useEffect, type FC, type PropsWithChildren } from 'react';\n\nconst IntlayerEditorHooksEnabled: FC = () => {\n /**\n * URL Messages\n */\n useCrossURLPathSetter();\n\n /**\n * Locale Dictionaries Messages\n */\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n\n useEffect(() => {\n setLocaleDictionaries(\n dictionaries as unknown as Record<string, Dictionary>\n );\n }, []);\n\n /**\n * Click Messages\n */\n useIframeClickInterceptor();\n\n return <></>;\n};\n\nconst { editor } = configuration;\n\nconst IntlayerEditorHook: FC = () => {\n const { enabled } = useEditorEnabled();\n\n /**\n * Hot reloading\n */\n const { setChangedContent } = useChangedContentActions();\n\n useEffect(() => {\n if (!editor.hotReload) return;\n if (!editor.clientId) return;\n if (!editor.clientSecret) return;\n\n const eventSource = new IntlayerEventListener();\n try {\n eventSource.initialize().then(() => {\n eventSource.onDictionaryChange = (dictionary) =>\n setChangedContent(dictionary.key, dictionary.content);\n });\n } catch (error) {\n console.error('Error initializing IntlayerEventListener:', error);\n }\n\n return () => eventSource.cleanup();\n }, []);\n\n return enabled ? <IntlayerEditorHooksEnabled /> : <></>;\n};\n\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => {\n return (\n <EditorProvider\n postMessage={(data: any) => {\n if (typeof window === 'undefined') return;\n\n const isInIframe = window.self !== window.top;\n if (!isInIframe) return;\n\n if (editor.applicationURL.length > 0) {\n window?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the current application URL to synchronize the locales states.\n editor.applicationURL\n );\n }\n\n if (editor.editorURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the editor URL to synchronize the locales states.\n editor.editorURL\n );\n }\n\n if (editor.cmsURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the CMS for security reasons.\n // Correspond to the CMS URL.\n editor.cmsURL\n );\n }\n }}\n allowedOrigins={[\n editor?.editorURL,\n editor?.cmsURL,\n editor?.applicationURL,\n ]}\n mode=\"client\"\n configuration={configuration}\n >\n <IntlayerEditorHook />\n {children}\n </EditorProvider>\n );\n};\n"],"mappings":";AA4CS,wBAoCL,YApCK;AA1CT,SAAS,6BAA6B;AACtC,OAAO,mBAAmB;AAQ1B,OAAO,kBAAkB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAkD;AAE3D,MAAM,6BAAiC,MAAM;AAI3C,wBAAsB;AAKtB,QAAM,EAAE,sBAAsB,IAAI,6BAA6B;AAE/D,YAAU,MAAM;AACd;AAAA,MACE;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AAKL,4BAA0B;AAE1B,SAAO,gCAAE;AACX;AAEA,MAAM,EAAE,OAAO,IAAI;AAEnB,MAAM,qBAAyB,MAAM;AACnC,QAAM,EAAE,QAAQ,IAAI,iBAAiB;AAKrC,QAAM,EAAE,kBAAkB,IAAI,yBAAyB;AAEvD,YAAU,MAAM;AACd,QAAI,CAAC,OAAO,UAAW;AACvB,QAAI,CAAC,OAAO,SAAU;AACtB,QAAI,CAAC,OAAO,aAAc;AAE1B,UAAM,cAAc,IAAI,sBAAsB;AAC9C,QAAI;AACF,kBAAY,WAAW,EAAE,KAAK,MAAM;AAClC,oBAAY,qBAAqB,CAAC,eAChC,kBAAkB,WAAW,KAAK,WAAW,OAAO;AAAA,MACxD,CAAC;AAAA,IACH,SAAS,OAAO;AACd,cAAQ,MAAM,6CAA6C,KAAK;AAAA,IAClE;AAEA,WAAO,MAAM,YAAY,QAAQ;AAAA,EACnC,GAAG,CAAC,CAAC;AAEL,SAAO,UAAU,oBAAC,8BAA2B,IAAK,gCAAE;AACtD;AAEO,MAAM,yBAAgD,CAAC,EAAE,SAAS,MAAM;AAC7E,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAa,CAAC,SAAc;AAC1B,YAAI,OAAO,WAAW,YAAa;AAEnC,cAAM,aAAa,OAAO,SAAS,OAAO;AAC1C,YAAI,CAAC,WAAY;AAEjB,YAAI,OAAO,eAAe,SAAS,GAAG;AACpC,kBAAQ;AAAA,YACN;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAEA,YAAI,OAAO,UAAU,SAAS,GAAG;AAC/B,iBAAO,QAAQ;AAAA,YACb;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAEA,YAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,iBAAO,QAAQ;AAAA,YACb;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAAA,MACA,gBAAgB;AAAA,QACd,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,QAAQ;AAAA,MACV;AAAA,MACA,MAAK;AAAA,MACL;AAAA,MAEA;AAAA,4BAAC,sBAAmB;AAAA,QACnB;AAAA;AAAA;AAAA,EACH;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["'use client';\n\nimport { IntlayerEventListener } from '@intlayer/api';\nimport configuration from '@intlayer/config/built';\nimport {\n EditorProvider,\n useChangedContentActions,\n useCrossURLPathSetter,\n useEditorEnabled,\n useIframeClickInterceptor,\n} from '@intlayer/editor-react';\nimport { useEffect, type FC, type PropsWithChildren } from 'react';\n\nconst IntlayerEditorHooksEnabled: FC = () => {\n /**\n * URL Messages\n */\n useCrossURLPathSetter();\n\n /**\n * Click Messages\n */\n useIframeClickInterceptor();\n\n return <></>;\n};\n\nconst { editor } = configuration;\n\nconst IntlayerEditorHook: FC = () => {\n const { enabled } = useEditorEnabled();\n\n /**\n * Hot reloading\n */\n const { setChangedContent } = useChangedContentActions();\n\n useEffect(() => {\n if (!editor.hotReload) return;\n if (!editor.clientId) return;\n if (!editor.clientSecret) return;\n\n const eventSource = new IntlayerEventListener();\n try {\n eventSource.initialize().then(() => {\n eventSource.onDictionaryChange = (dictionary) =>\n setChangedContent(dictionary.key, dictionary.content);\n });\n } catch (error) {\n console.error('Error initializing IntlayerEventListener:', error);\n }\n\n return () => eventSource.cleanup();\n }, []);\n\n return enabled ? <IntlayerEditorHooksEnabled /> : <></>;\n};\n\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => {\n return (\n <EditorProvider\n postMessage={(data: any) => {\n if (typeof window === 'undefined') return;\n\n const isInIframe = window.self !== window.top;\n if (!isInIframe) return;\n\n if (editor.applicationURL.length > 0) {\n window?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the current application URL to synchronize the locales states.\n editor.applicationURL\n );\n }\n\n if (editor.editorURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the editor URL to synchronize the locales states.\n editor.editorURL\n );\n }\n\n if (editor.cmsURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the CMS for security reasons.\n // Correspond to the CMS URL.\n editor.cmsURL\n );\n }\n }}\n allowedOrigins={[\n editor?.editorURL,\n editor?.cmsURL,\n editor?.applicationURL,\n ]}\n mode=\"client\"\n configuration={configuration}\n >\n <IntlayerEditorHook />\n {children}\n </EditorProvider>\n );\n};\n"],"mappings":";AAwBS,wBAoCL,YApCK;AAtBT,SAAS,6BAA6B;AACtC,OAAO,mBAAmB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAkD;AAE3D,MAAM,6BAAiC,MAAM;AAI3C,wBAAsB;AAKtB,4BAA0B;AAE1B,SAAO,gCAAE;AACX;AAEA,MAAM,EAAE,OAAO,IAAI;AAEnB,MAAM,qBAAyB,MAAM;AACnC,QAAM,EAAE,QAAQ,IAAI,iBAAiB;AAKrC,QAAM,EAAE,kBAAkB,IAAI,yBAAyB;AAEvD,YAAU,MAAM;AACd,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core';
5
5
  *
6
6
  * If the locale is not provided, it will use the locale from the client context
7
7
  */
8
- export declare const useDictionary: <T extends Dictionary>(dictionary: T, locale?: LocalesValues) => import("@intlayer/core").DeepTransformContent<T["content"], import("../plugins").IInterpreterPluginState>;
8
+ export declare const useDictionary: <T extends Dictionary>(dictionary: T, locale?: LocalesValues) => any;
9
9
  //# sourceMappingURL=useDictionary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.d.ts","sourceRoot":"","sources":["../../../src/client/useDictionary.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAKjD;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,UAAU,EAChD,YAAY,CAAC,EACb,SAAS,aAAa,8GAMvB,CAAC"}
1
+ {"version":3,"file":"useDictionary.d.ts","sourceRoot":"","sources":["../../../src/client/useDictionary.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAMjD;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,UAAU,EAChD,YAAY,CAAC,EACb,SAAS,aAAa,QAYvB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerEditorProvider.d.ts","sourceRoot":"","sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAAa,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AA0DnE,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,iBAAiB,CAgDxD,CAAC"}
1
+ {"version":3,"file":"IntlayerEditorProvider.d.ts","sourceRoot":"","sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAa,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AA+CnE,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,iBAAiB,CAgDxD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-intlayer",
3
- "version": "5.5.1",
3
+ "version": "5.5.3",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your React applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -69,11 +69,11 @@
69
69
  ],
70
70
  "dependencies": {
71
71
  "js-cookie": "^3.0.5",
72
- "@intlayer/config": "5.5.1",
73
- "@intlayer/core": "5.5.1",
74
- "@intlayer/api": "5.5.1",
75
- "@intlayer/dictionaries-entry": "5.5.1",
76
- "@intlayer/editor-react": "5.5.1"
72
+ "@intlayer/config": "5.5.3",
73
+ "@intlayer/core": "5.5.3",
74
+ "@intlayer/dictionaries-entry": "5.5.3",
75
+ "@intlayer/api": "5.5.3",
76
+ "@intlayer/editor-react": "5.5.3"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@craco/types": "^7.1.0",
@@ -89,21 +89,21 @@
89
89
  "tsc-alias": "^1.8.11",
90
90
  "tsup": "^8.4.0",
91
91
  "typescript": "^5.8.2",
92
- "@intlayer/backend": "5.5.1",
93
92
  "@utils/eslint-config": "1.0.4",
94
- "@utils/ts-config": "1.0.4",
95
93
  "@utils/ts-config-types": "1.0.4",
96
- "@utils/tsup-config": "1.0.4"
94
+ "@utils/ts-config": "1.0.4",
95
+ "@utils/tsup-config": "1.0.4",
96
+ "@intlayer/backend": "5.5.3"
97
97
  },
98
98
  "peerDependencies": {
99
99
  "react": ">=16.0.0",
100
100
  "react-dom": ">=16.0.0",
101
- "@intlayer/api": "5.5.1",
102
- "@intlayer/config": "5.5.1",
103
- "@intlayer/dictionaries-entry": "5.5.1",
104
- "@intlayer/core": "5.5.1",
105
- "@intlayer/editor-react": "5.5.1",
106
- "intlayer": "5.5.1"
101
+ "@intlayer/api": "5.5.3",
102
+ "@intlayer/config": "5.5.3",
103
+ "@intlayer/core": "5.5.3",
104
+ "@intlayer/editor-react": "5.5.3",
105
+ "intlayer": "5.5.3",
106
+ "@intlayer/dictionaries-entry": "5.5.3"
107
107
  },
108
108
  "engines": {
109
109
  "node": ">=14.18"