@intlayer/editor-react 9.6.0 → 9.7.1

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 (68) hide show
  1. package/dist/cjs/ConfigurationContext.cjs +2 -3
  2. package/dist/cjs/DictionariesRecordContext.cjs +2 -3
  3. package/dist/cjs/EditedContentContext.cjs +8 -5
  4. package/dist/cjs/EditedContentContext.cjs.map +1 -1
  5. package/dist/cjs/EditorEnabledContext.cjs +3 -4
  6. package/dist/cjs/EditorEnabledContext.cjs.map +1 -1
  7. package/dist/cjs/EditorProvider.cjs +2 -3
  8. package/dist/cjs/EditorStateContext.cjs +1 -2
  9. package/dist/cjs/FocusDictionaryContext.cjs +2 -3
  10. package/dist/cjs/index.cjs +21 -14
  11. package/dist/cjs/useCrossFrameState.cjs +2 -3
  12. package/dist/cjs/useCrossURLPathState.cjs +2 -3
  13. package/dist/cjs/useEditedContentPersistence.cjs +2 -3
  14. package/dist/cjs/useEditorLocale.cjs +2 -3
  15. package/dist/cjs/useFocusUnmergedDictionary.cjs +4 -5
  16. package/dist/cjs/useFrameConnectionStatus.cjs +43 -0
  17. package/dist/cjs/useFrameConnectionStatus.cjs.map +1 -0
  18. package/dist/cjs/useFrameReconnection.cjs +62 -0
  19. package/dist/cjs/useFrameReconnection.cjs.map +1 -0
  20. package/dist/esm/ConfigurationContext.mjs +1 -2
  21. package/dist/esm/DictionariesRecordContext.mjs +1 -2
  22. package/dist/esm/EditedContentContext.mjs +8 -5
  23. package/dist/esm/EditedContentContext.mjs.map +1 -1
  24. package/dist/esm/EditorEnabledContext.mjs +3 -4
  25. package/dist/esm/EditorEnabledContext.mjs.map +1 -1
  26. package/dist/esm/EditorProvider.mjs +1 -2
  27. package/dist/esm/EditorStateContext.mjs +1 -2
  28. package/dist/esm/FocusDictionaryContext.mjs +1 -2
  29. package/dist/esm/index.mjs +9 -7
  30. package/dist/esm/useCrossFrameState.mjs +1 -2
  31. package/dist/esm/useCrossURLPathState.mjs +1 -2
  32. package/dist/esm/useEditedContentPersistence.mjs +1 -2
  33. package/dist/esm/useEditorLocale.mjs +1 -2
  34. package/dist/esm/useFocusUnmergedDictionary.mjs +2 -3
  35. package/dist/esm/useFrameConnectionStatus.mjs +41 -0
  36. package/dist/esm/useFrameConnectionStatus.mjs.map +1 -0
  37. package/dist/esm/useFrameReconnection.mjs +59 -0
  38. package/dist/esm/useFrameReconnection.mjs.map +1 -0
  39. package/dist/types/ConfigurationContext.d.ts +0 -2
  40. package/dist/types/ConfigurationContext.d.ts.map +1 -1
  41. package/dist/types/DictionariesRecordContext.d.ts +0 -2
  42. package/dist/types/DictionariesRecordContext.d.ts.map +1 -1
  43. package/dist/types/EditedContentContext.d.ts +4 -2
  44. package/dist/types/EditedContentContext.d.ts.map +1 -1
  45. package/dist/types/EditorEnabledContext.d.ts +0 -2
  46. package/dist/types/EditorEnabledContext.d.ts.map +1 -1
  47. package/dist/types/EditorProvider.d.ts +0 -2
  48. package/dist/types/EditorProvider.d.ts.map +1 -1
  49. package/dist/types/EditorStateContext.d.ts +0 -2
  50. package/dist/types/EditorStateContext.d.ts.map +1 -1
  51. package/dist/types/FocusDictionaryContext.d.ts +0 -2
  52. package/dist/types/FocusDictionaryContext.d.ts.map +1 -1
  53. package/dist/types/index.d.ts +4 -2
  54. package/dist/types/useCrossFrameState.d.ts +0 -2
  55. package/dist/types/useCrossFrameState.d.ts.map +1 -1
  56. package/dist/types/useCrossURLPathState.d.ts +0 -2
  57. package/dist/types/useCrossURLPathState.d.ts.map +1 -1
  58. package/dist/types/useEditedContentPersistence.d.ts +0 -2
  59. package/dist/types/useEditedContentPersistence.d.ts.map +1 -1
  60. package/dist/types/useEditorLocale.d.ts +0 -2
  61. package/dist/types/useEditorLocale.d.ts.map +1 -1
  62. package/dist/types/useFocusUnmergedDictionary.d.ts +0 -2
  63. package/dist/types/useFocusUnmergedDictionary.d.ts.map +1 -1
  64. package/dist/types/useFrameConnectionStatus.d.ts +22 -0
  65. package/dist/types/useFrameConnectionStatus.d.ts.map +1 -0
  66. package/dist/types/useFrameReconnection.d.ts +23 -0
  67. package/dist/types/useFrameReconnection.d.ts.map +1 -0
  68. package/package.json +8 -8
@@ -1,10 +1,10 @@
1
1
  'use client';
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_EditorStateContext = require('./EditorStateContext.cjs');
4
+ const require_EditorStateContext = require("./EditorStateContext.cjs");
5
5
  let react = require("react");
6
6
 
7
- //#region src/ConfigurationContext.tsx
7
+ // src/ConfigurationContext.tsx
8
8
  /**
9
9
  * Returns the Intlayer configuration held by the editor state manager.
10
10
  */
@@ -20,6 +20,5 @@ const useConfiguration = () => {
20
20
  return configuration;
21
21
  };
22
22
 
23
- //#endregion
24
23
  exports.useConfiguration = useConfiguration;
25
24
  //# sourceMappingURL=ConfigurationContext.cjs.map
@@ -1,10 +1,10 @@
1
1
  'use client';
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_EditorStateContext = require('./EditorStateContext.cjs');
4
+ const require_EditorStateContext = require("./EditorStateContext.cjs");
5
5
  let react = require("react");
6
6
 
7
- //#region src/DictionariesRecordContext.tsx
7
+ // src/DictionariesRecordContext.tsx
8
8
  const useDictionariesRecord = () => {
9
9
  const manager = require_EditorStateContext.useEditorStateManager();
10
10
  const [localeDictionaries, setLocaleDictionariesState] = (0, react.useState)(manager?.localeDictionaries.value ?? {});
@@ -28,7 +28,6 @@ const useDictionariesRecordActions = () => {
28
28
  };
29
29
  };
30
30
 
31
- //#endregion
32
31
  exports.useDictionariesRecord = useDictionariesRecord;
33
32
  exports.useDictionariesRecordActions = useDictionariesRecordActions;
34
33
  //# sourceMappingURL=DictionariesRecordContext.cjs.map
@@ -1,13 +1,17 @@
1
1
  'use client';
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_EditorStateContext = require('./EditorStateContext.cjs');
4
+ const require_EditorStateContext = require("./EditorStateContext.cjs");
5
5
  let react = require("react");
6
6
 
7
- //#region src/EditedContentContext.tsx
7
+ // src/EditedContentContext.tsx
8
+ /**
9
+ * Returns the edited content actions. Memoized on the manager so they can be
10
+ * used as effect dependencies without a compiler.
11
+ */
8
12
  const useEditedContentActions = () => {
9
13
  const manager = require_EditorStateContext.useEditorStateManager();
10
- return {
14
+ return (0, react.useMemo)(() => ({
11
15
  setEditedContentState: (value) => manager?.editedContent.set(value),
12
16
  setEditedDictionary: (dict) => manager?.setEditedDictionary(dict),
13
17
  setEditedContent: (localId, value) => manager?.setEditedContent(localId, value),
@@ -16,7 +20,7 @@ const useEditedContentActions = () => {
16
20
  removeEditedContent: (localId, keyPath) => manager?.removeContent(localId, keyPath),
17
21
  restoreEditedContent: (localId) => manager?.restoreContent(localId),
18
22
  getEditedContentValue: (localIdOrKey, keyPath) => manager?.getContentValue(localIdOrKey, keyPath)
19
- };
23
+ }), [manager]);
20
24
  };
21
25
  const useEditedContent = () => {
22
26
  const manager = require_EditorStateContext.useEditorStateManager();
@@ -33,7 +37,6 @@ const useEditedContent = () => {
33
37
  };
34
38
  };
35
39
 
36
- //#endregion
37
40
  exports.useEditedContent = useEditedContent;
38
41
  exports.useEditedContentActions = useEditedContentActions;
39
42
  //# sourceMappingURL=EditedContentContext.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"EditedContentContext.cjs","names":["useEditorStateManager","useState"],"sources":["../../src/EditedContentContext.tsx"],"sourcesContent":["'use client';\n\nimport type { DictionaryContent } from '@intlayer/editor';\nimport type {\n ContentNode,\n Dictionary,\n LocalDictionaryId,\n} from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { useEffect, useState } from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type { DictionaryContent } from '@intlayer/editor';\n\ntype EditedContentActionsContextType = {\n setEditedContentState: (editedContent: DictionaryContent) => void;\n setEditedDictionary: (dict: Dictionary) => void;\n setEditedContent: (\n localDictionaryId: LocalDictionaryId,\n newValue: Dictionary['content']\n ) => void;\n addEditedContent: (\n localDictionaryId: LocalDictionaryId,\n newValue: ContentNode<any>,\n keyPath?: KeyPath[],\n overwrite?: boolean\n ) => void;\n renameEditedContent: (\n localDictionaryId: LocalDictionaryId,\n newKey: KeyPath['key'],\n keyPath?: KeyPath[]\n ) => void;\n removeEditedContent: (\n localDictionaryId: LocalDictionaryId,\n keyPath: KeyPath[]\n ) => void;\n restoreEditedContent: (localDictionaryId: LocalDictionaryId) => void;\n getEditedContentValue: (\n localDictionaryIdOrKey: LocalDictionaryId | Dictionary['key'] | string,\n keyPath: KeyPath[]\n ) => ContentNode | undefined;\n};\n\nexport const useEditedContentActions = (): EditedContentActionsContextType => {\n const manager = useEditorStateManager();\n\n return {\n setEditedContentState: (value: DictionaryContent) =>\n manager?.editedContent.set(value),\n setEditedDictionary: (dict: Dictionary) =>\n manager?.setEditedDictionary(dict),\n setEditedContent: (\n localId: LocalDictionaryId,\n value: Dictionary['content']\n ) => manager?.setEditedContent(localId, value),\n addEditedContent: (localId, value, keyPath, overwrite) =>\n manager?.addContent(localId, value, keyPath, overwrite),\n renameEditedContent: (localId, newKey, keyPath) =>\n manager?.renameContent(localId, newKey, keyPath),\n removeEditedContent: (localId, keyPath) =>\n manager?.removeContent(localId, keyPath),\n restoreEditedContent: (localId) => manager?.restoreContent(localId),\n getEditedContentValue: (localIdOrKey, keyPath) =>\n manager?.getContentValue(localIdOrKey, keyPath),\n };\n};\n\nexport const useEditedContent = () => {\n const manager = useEditorStateManager();\n const [editedContent, setEditedContentState] = useState<\n DictionaryContent | undefined\n >(manager?.editedContent.value);\n\n useEffect(() => {\n if (!manager) return;\n const handler = (e: Event) =>\n setEditedContentState((e as CustomEvent<DictionaryContent>).detail);\n manager.editedContent.addEventListener('change', handler);\n return () => manager.editedContent.removeEventListener('change', handler);\n }, [manager]);\n\n const actions = useEditedContentActions();\n return { editedContent, ...actions };\n};\n"],"mappings":";;;;;;;AA2CA,MAAa,gCAAiE;CAC5E,MAAM,UAAUA,iDAAsB;CAEtC,OAAO;EACL,wBAAwB,UACtB,SAAS,cAAc,IAAI,KAAK;EAClC,sBAAsB,SACpB,SAAS,oBAAoB,IAAI;EACnC,mBACE,SACA,UACG,SAAS,iBAAiB,SAAS,KAAK;EAC7C,mBAAmB,SAAS,OAAO,SAAS,cAC1C,SAAS,WAAW,SAAS,OAAO,SAAS,SAAS;EACxD,sBAAsB,SAAS,QAAQ,YACrC,SAAS,cAAc,SAAS,QAAQ,OAAO;EACjD,sBAAsB,SAAS,YAC7B,SAAS,cAAc,SAAS,OAAO;EACzC,uBAAuB,YAAY,SAAS,eAAe,OAAO;EAClE,wBAAwB,cAAc,YACpC,SAAS,gBAAgB,cAAc,OAAO;CAClD;AACF;AAEA,MAAa,yBAAyB;CACpC,MAAM,UAAUA,iDAAsB;CACtC,MAAM,CAAC,eAAe,6BAAyBC,gBAE7C,SAAS,cAAc,KAAK;CAE9B,2BAAgB;EACd,IAAI,CAAC,SAAS;EACd,MAAM,WAAW,MACf,sBAAuB,EAAqC,MAAM;EACpE,QAAQ,cAAc,iBAAiB,UAAU,OAAO;EACxD,aAAa,QAAQ,cAAc,oBAAoB,UAAU,OAAO;CAC1E,GAAG,CAAC,OAAO,CAAC;CAGZ,OAAO;EAAE;EAAe,GADR,wBACiB;CAAE;AACrC"}
1
+ {"version":3,"file":"EditedContentContext.cjs","names":["useEditorStateManager","useMemo","useState"],"sources":["../../src/EditedContentContext.tsx"],"sourcesContent":["'use client';\n\nimport type { DictionaryContent } from '@intlayer/editor';\nimport type {\n ContentNode,\n Dictionary,\n LocalDictionaryId,\n} from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { useEffect, useMemo, useState } from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type { DictionaryContent } from '@intlayer/editor';\n\ntype EditedContentActionsContextType = {\n setEditedContentState: (editedContent: DictionaryContent) => void;\n setEditedDictionary: (dict: Dictionary) => void;\n setEditedContent: (\n localDictionaryId: LocalDictionaryId,\n newValue: Dictionary['content']\n ) => void;\n addEditedContent: (\n localDictionaryId: LocalDictionaryId,\n newValue: ContentNode<any>,\n keyPath?: KeyPath[],\n overwrite?: boolean\n ) => void;\n renameEditedContent: (\n localDictionaryId: LocalDictionaryId,\n newKey: KeyPath['key'],\n keyPath?: KeyPath[]\n ) => void;\n removeEditedContent: (\n localDictionaryId: LocalDictionaryId,\n keyPath: KeyPath[]\n ) => void;\n restoreEditedContent: (localDictionaryId: LocalDictionaryId) => void;\n getEditedContentValue: (\n localDictionaryIdOrKey: LocalDictionaryId | Dictionary['key'] | string,\n keyPath: KeyPath[]\n ) => ContentNode | undefined;\n};\n\n/**\n * Returns the edited content actions. Memoized on the manager so they can be\n * used as effect dependencies without a compiler.\n */\nexport const useEditedContentActions = (): EditedContentActionsContextType => {\n const manager = useEditorStateManager();\n\n return useMemo<EditedContentActionsContextType>(\n () => ({\n setEditedContentState: (value: DictionaryContent) =>\n manager?.editedContent.set(value),\n setEditedDictionary: (dict: Dictionary) =>\n manager?.setEditedDictionary(dict),\n setEditedContent: (\n localId: LocalDictionaryId,\n value: Dictionary['content']\n ) => manager?.setEditedContent(localId, value),\n addEditedContent: (localId, value, keyPath, overwrite) =>\n manager?.addContent(localId, value, keyPath, overwrite),\n renameEditedContent: (localId, newKey, keyPath) =>\n manager?.renameContent(localId, newKey, keyPath),\n removeEditedContent: (localId, keyPath) =>\n manager?.removeContent(localId, keyPath),\n restoreEditedContent: (localId) => manager?.restoreContent(localId),\n getEditedContentValue: (localIdOrKey, keyPath) =>\n manager?.getContentValue(localIdOrKey, keyPath),\n }),\n [manager]\n );\n};\n\nexport const useEditedContent = () => {\n const manager = useEditorStateManager();\n const [editedContent, setEditedContentState] = useState<\n DictionaryContent | undefined\n >(manager?.editedContent.value);\n\n useEffect(() => {\n if (!manager) return;\n const handler = (e: Event) =>\n setEditedContentState((e as CustomEvent<DictionaryContent>).detail);\n manager.editedContent.addEventListener('change', handler);\n return () => manager.editedContent.removeEventListener('change', handler);\n }, [manager]);\n\n const actions = useEditedContentActions();\n return { editedContent, ...actions };\n};\n"],"mappings":";;;;;;;;;;;AA+CA,MAAa,gCAAiE;CAC5E,MAAM,UAAUA,iDAAsB;CAEtC,WAAOC,sBACE;EACL,wBAAwB,UACtB,SAAS,cAAc,IAAI,KAAK;EAClC,sBAAsB,SACpB,SAAS,oBAAoB,IAAI;EACnC,mBACE,SACA,UACG,SAAS,iBAAiB,SAAS,KAAK;EAC7C,mBAAmB,SAAS,OAAO,SAAS,cAC1C,SAAS,WAAW,SAAS,OAAO,SAAS,SAAS;EACxD,sBAAsB,SAAS,QAAQ,YACrC,SAAS,cAAc,SAAS,QAAQ,OAAO;EACjD,sBAAsB,SAAS,YAC7B,SAAS,cAAc,SAAS,OAAO;EACzC,uBAAuB,YAAY,SAAS,eAAe,OAAO;EAClE,wBAAwB,cAAc,YACpC,SAAS,gBAAgB,cAAc,OAAO;CAClD,IACA,CAAC,OAAO,CACV;AACF;AAEA,MAAa,yBAAyB;CACpC,MAAM,UAAUD,iDAAsB;CACtC,MAAM,CAAC,eAAe,6BAAyBE,gBAE7C,SAAS,cAAc,KAAK;CAE9B,2BAAgB;EACd,IAAI,CAAC,SAAS;EACd,MAAM,WAAW,MACf,sBAAuB,EAAqC,MAAM;EACpE,QAAQ,cAAc,iBAAiB,UAAU,OAAO;EACxD,aAAa,QAAQ,cAAc,oBAAoB,UAAU,OAAO;CAC1E,GAAG,CAAC,OAAO,CAAC;CAGZ,OAAO;EAAE;EAAe,GADR,wBACiB;CAAE;AACrC"}
@@ -1,10 +1,10 @@
1
1
  'use client';
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_EditorStateContext = require('./EditorStateContext.cjs');
4
+ const require_EditorStateContext = require("./EditorStateContext.cjs");
5
5
  let react = require("react");
6
6
 
7
- //#region src/EditorEnabledContext.tsx
7
+ // src/EditorEnabledContext.tsx
8
8
  /**
9
9
  * Returns the current editor-enabled state, kept in sync with the shared
10
10
  * EditorStateManager. Replaces the old EditorEnabledContext + EditorEnabledProvider.
@@ -26,10 +26,9 @@ const useEditorEnabled = () => {
26
26
  */
27
27
  const useEditorPingClient = () => {
28
28
  const manager = require_EditorStateContext.useEditorStateManager();
29
- return () => manager?.pingClient();
29
+ return (0, react.useCallback)(() => manager?.pingClient(), [manager]);
30
30
  };
31
31
 
32
- //#endregion
33
32
  exports.useEditorEnabled = useEditorEnabled;
34
33
  exports.useEditorPingClient = useEditorPingClient;
35
34
  //# sourceMappingURL=EditorEnabledContext.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"EditorEnabledContext.cjs","names":["useEditorStateManager","useState"],"sources":["../../src/EditorEnabledContext.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect, useState } from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type EditorEnabledStateProps = {\n enabled: boolean;\n};\n\n/**\n * Returns the current editor-enabled state, kept in sync with the shared\n * EditorStateManager. Replaces the old EditorEnabledContext + EditorEnabledProvider.\n */\nexport const useEditorEnabled = (): EditorEnabledStateProps => {\n const manager = useEditorStateManager();\n const [enabled, setEnabled] = useState<boolean>(\n manager?.editorEnabled.value ?? false\n );\n\n useEffect(() => {\n if (!manager) return;\n\n const handler = (e: Event) =>\n setEnabled((e as CustomEvent<boolean>).detail);\n manager.editorEnabled.addEventListener('change', handler);\n return () => manager.editorEnabled.removeEventListener('change', handler);\n }, [manager]);\n\n return { enabled };\n};\n\n/**\n * Returns a function that re-pings the client via ARE_YOU_THERE.\n * Use this as the onClick for an \"Enable Editor\" / reconnect button.\n */\nexport const useEditorPingClient = (): (() => void) => {\n const manager = useEditorStateManager();\n\n return () => manager?.pingClient();\n};\n"],"mappings":";;;;;;;;;;;AAaA,MAAa,yBAAkD;CAC7D,MAAM,UAAUA,iDAAsB;CACtC,MAAM,CAAC,SAAS,kBAAcC,gBAC5B,SAAS,cAAc,SAAS,KAClC;CAEA,2BAAgB;EACd,IAAI,CAAC,SAAS;EAEd,MAAM,WAAW,MACf,WAAY,EAA2B,MAAM;EAC/C,QAAQ,cAAc,iBAAiB,UAAU,OAAO;EACxD,aAAa,QAAQ,cAAc,oBAAoB,UAAU,OAAO;CAC1E,GAAG,CAAC,OAAO,CAAC;CAEZ,OAAO,EAAE,QAAQ;AACnB;;;;;AAMA,MAAa,4BAA0C;CACrD,MAAM,UAAUD,iDAAsB;CAEtC,aAAa,SAAS,WAAW;AACnC"}
1
+ {"version":3,"file":"EditorEnabledContext.cjs","names":["useEditorStateManager","useState","useCallback"],"sources":["../../src/EditorEnabledContext.tsx"],"sourcesContent":["'use client';\n\nimport { useCallback, useEffect, useState } from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type EditorEnabledStateProps = {\n enabled: boolean;\n};\n\n/**\n * Returns the current editor-enabled state, kept in sync with the shared\n * EditorStateManager. Replaces the old EditorEnabledContext + EditorEnabledProvider.\n */\nexport const useEditorEnabled = (): EditorEnabledStateProps => {\n const manager = useEditorStateManager();\n const [enabled, setEnabled] = useState<boolean>(\n manager?.editorEnabled.value ?? false\n );\n\n useEffect(() => {\n if (!manager) return;\n\n const handler = (e: Event) =>\n setEnabled((e as CustomEvent<boolean>).detail);\n manager.editorEnabled.addEventListener('change', handler);\n return () => manager.editorEnabled.removeEventListener('change', handler);\n }, [manager]);\n\n return { enabled };\n};\n\n/**\n * Returns a function that re-pings the client via ARE_YOU_THERE.\n * Use this as the onClick for an \"Enable Editor\" / reconnect button.\n */\nexport const useEditorPingClient = (): (() => void) => {\n const manager = useEditorStateManager();\n\n return useCallback(() => manager?.pingClient(), [manager]);\n};\n"],"mappings":";;;;;;;;;;;AAaA,MAAa,yBAAkD;CAC7D,MAAM,UAAUA,iDAAsB;CACtC,MAAM,CAAC,SAAS,kBAAcC,gBAC5B,SAAS,cAAc,SAAS,KAClC;CAEA,2BAAgB;EACd,IAAI,CAAC,SAAS;EAEd,MAAM,WAAW,MACf,WAAY,EAA2B,MAAM;EAC/C,QAAQ,cAAc,iBAAiB,UAAU,OAAO;EACxD,aAAa,QAAQ,cAAc,oBAAoB,UAAU,OAAO;CAC1E,GAAG,CAAC,OAAO,CAAC;CAEZ,OAAO,EAAE,QAAQ;AACnB;;;;;AAMA,MAAa,4BAA0C;CACrD,MAAM,UAAUD,iDAAsB;CAEtC,WAAOE,yBAAkB,SAAS,WAAW,GAAG,CAAC,OAAO,CAAC;AAC3D"}
@@ -1,12 +1,12 @@
1
1
  'use client';
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_EditorStateContext = require('./EditorStateContext.cjs');
4
+ const require_EditorStateContext = require("./EditorStateContext.cjs");
5
5
  let react = require("react");
6
6
  let react_jsx_runtime = require("react/jsx-runtime");
7
7
  let _intlayer_editor = require("@intlayer/editor");
8
8
 
9
- //#region src/EditorProvider.tsx
9
+ // src/EditorProvider.tsx
10
10
  /**
11
11
  * EditorProvider creates and manages the lifecycle of an EditorStateManager,
12
12
  * provides it to all descendants, and registers the Lit web components.
@@ -41,6 +41,5 @@ const EditorProvider = ({ children, configuration, postMessage, allowedOrigins }
41
41
  });
42
42
  };
43
43
 
44
- //#endregion
45
44
  exports.EditorProvider = EditorProvider;
46
45
  //# sourceMappingURL=EditorProvider.cjs.map
@@ -4,7 +4,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
  let react = require("react");
5
5
  let react_jsx_runtime = require("react/jsx-runtime");
6
6
 
7
- //#region src/EditorStateContext.tsx
7
+ // src/EditorStateContext.tsx
8
8
  const EditorStateContext = (0, react.createContext)(null);
9
9
  const EditorStateProvider = ({ children, manager }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EditorStateContext.Provider, {
10
10
  value: manager,
@@ -12,7 +12,6 @@ const EditorStateProvider = ({ children, manager }) => /* @__PURE__ */ (0, react
12
12
  });
13
13
  const useEditorStateManager = () => (0, react.useContext)(EditorStateContext);
14
14
 
15
- //#endregion
16
15
  exports.EditorStateProvider = EditorStateProvider;
17
16
  exports.useEditorStateManager = useEditorStateManager;
18
17
  //# sourceMappingURL=EditorStateContext.cjs.map
@@ -1,10 +1,10 @@
1
1
  'use client';
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_EditorStateContext = require('./EditorStateContext.cjs');
4
+ const require_EditorStateContext = require("./EditorStateContext.cjs");
5
5
  let react = require("react");
6
6
 
7
- //#region src/FocusDictionaryContext.tsx
7
+ // src/FocusDictionaryContext.tsx
8
8
  /**
9
9
  * Returns the content focused in the editor, shared with the client frame.
10
10
  */
@@ -24,6 +24,5 @@ const useFocusDictionary = () => {
24
24
  };
25
25
  };
26
26
 
27
- //#endregion
28
27
  exports.useFocusDictionary = useFocusDictionary;
29
28
  //# sourceMappingURL=FocusDictionaryContext.cjs.map
@@ -1,26 +1,31 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_EditorStateContext = require('./EditorStateContext.cjs');
3
- const require_DictionariesRecordContext = require('./DictionariesRecordContext.cjs');
4
- const require_useCrossFrameState = require('./useCrossFrameState.cjs');
5
- const require_useCrossURLPathState = require('./useCrossURLPathState.cjs');
6
- const require_EditedContentContext = require('./EditedContentContext.cjs');
7
- const require_useEditedContentPersistence = require('./useEditedContentPersistence.cjs');
8
- const require_useEditorLocale = require('./useEditorLocale.cjs');
9
- const require_ConfigurationContext = require('./ConfigurationContext.cjs');
10
- const require_EditorEnabledContext = require('./EditorEnabledContext.cjs');
11
- const require_EditorProvider = require('./EditorProvider.cjs');
12
- const require_FocusDictionaryContext = require('./FocusDictionaryContext.cjs');
13
- const require_useFocusUnmergedDictionary = require('./useFocusUnmergedDictionary.cjs');
2
+ const require_ConfigurationContext = require("./ConfigurationContext.cjs");
3
+ const require_DictionariesRecordContext = require("./DictionariesRecordContext.cjs");
4
+ const require_EditedContentContext = require("./EditedContentContext.cjs");
5
+ const require_EditorEnabledContext = require("./EditorEnabledContext.cjs");
6
+ const require_EditorProvider = require("./EditorProvider.cjs");
7
+ const require_EditorStateContext = require("./EditorStateContext.cjs");
8
+ const require_FocusDictionaryContext = require("./FocusDictionaryContext.cjs");
9
+ const require_useCrossFrameState = require("./useCrossFrameState.cjs");
10
+ const require_useCrossURLPathState = require("./useCrossURLPathState.cjs");
11
+ const require_useEditedContentPersistence = require("./useEditedContentPersistence.cjs");
12
+ const require_useEditorLocale = require("./useEditorLocale.cjs");
13
+ const require_useFocusUnmergedDictionary = require("./useFocusUnmergedDictionary.cjs");
14
+ const require_useFrameConnectionStatus = require("./useFrameConnectionStatus.cjs");
15
+ const require_useFrameReconnection = require("./useFrameReconnection.cjs");
14
16
  let _intlayer_editor = require("@intlayer/editor");
15
17
 
16
18
  exports.EditorProvider = require_EditorProvider.EditorProvider;
17
19
  exports.EditorStateProvider = require_EditorStateContext.EditorStateProvider;
18
- Object.defineProperty(exports, 'MessageKey', {
20
+ exports.FRAME_CONNECTION_TIMEOUT_MS = require_useFrameConnectionStatus.FRAME_CONNECTION_TIMEOUT_MS;
21
+ exports.FRAME_RECONNECTION_INTERVAL_MS = require_useFrameReconnection.FRAME_RECONNECTION_INTERVAL_MS;
22
+ Object.defineProperty(exports, "MessageKey", {
19
23
  enumerable: true,
20
24
  get: function () {
21
25
  return _intlayer_editor.MessageKey;
22
26
  }
23
27
  });
28
+ exports.isApplicationReachable = require_useFrameReconnection.isApplicationReachable;
24
29
  exports.useConfiguration = require_ConfigurationContext.useConfiguration;
25
30
  exports.useCrossFrameState = require_useCrossFrameState.useCrossFrameState;
26
31
  exports.useCrossURLPathState = require_useCrossURLPathState.useCrossURLPathState;
@@ -34,4 +39,6 @@ exports.useEditorLocale = require_useEditorLocale.useEditorLocale;
34
39
  exports.useEditorPingClient = require_EditorEnabledContext.useEditorPingClient;
35
40
  exports.useEditorStateManager = require_EditorStateContext.useEditorStateManager;
36
41
  exports.useFocusDictionary = require_FocusDictionaryContext.useFocusDictionary;
37
- exports.useFocusUnmergedDictionary = require_useFocusUnmergedDictionary.useFocusUnmergedDictionary;
42
+ exports.useFocusUnmergedDictionary = require_useFocusUnmergedDictionary.useFocusUnmergedDictionary;
43
+ exports.useFrameConnectionStatus = require_useFrameConnectionStatus.useFrameConnectionStatus;
44
+ exports.useFrameReconnection = require_useFrameReconnection.useFrameReconnection;
@@ -1,10 +1,10 @@
1
1
  'use client';
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_EditorStateContext = require('./EditorStateContext.cjs');
4
+ const require_EditorStateContext = require("./EditorStateContext.cjs");
5
5
  let react = require("react");
6
6
 
7
- //#region src/useCrossFrameState.tsx
7
+ // src/useCrossFrameState.tsx
8
8
  /**
9
9
  * Returns the latest value another frame posted under `key`.
10
10
  */
@@ -15,6 +15,5 @@ const useCrossFrameState = (key, initialValue) => {
15
15
  return value;
16
16
  };
17
17
 
18
- //#endregion
19
18
  exports.useCrossFrameState = useCrossFrameState;
20
19
  //# sourceMappingURL=useCrossFrameState.cjs.map
@@ -1,15 +1,14 @@
1
1
  'use client';
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_useCrossFrameState = require('./useCrossFrameState.cjs');
4
+ const require_useCrossFrameState = require("./useCrossFrameState.cjs");
5
5
  let _intlayer_editor = require("@intlayer/editor");
6
6
 
7
- //#region src/useCrossURLPathState.tsx
7
+ // src/useCrossURLPathState.tsx
8
8
  /**
9
9
  * Returns the path currently displayed by the client application.
10
10
  */
11
11
  const useCrossURLPathState = () => require_useCrossFrameState.useCrossFrameState(_intlayer_editor.MessageKey.INTLAYER_URL_CHANGE, void 0);
12
12
 
13
- //#endregion
14
13
  exports.useCrossURLPathState = useCrossURLPathState;
15
14
  //# sourceMappingURL=useCrossURLPathState.cjs.map
@@ -1,10 +1,10 @@
1
1
  'use client';
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_EditedContentContext = require('./EditedContentContext.cjs');
4
+ const require_EditedContentContext = require("./EditedContentContext.cjs");
5
5
  let react = require("react");
6
6
 
7
- //#region src/useEditedContentPersistence.tsx
7
+ // src/useEditedContentPersistence.tsx
8
8
  const EDITED_CONTENT_STORAGE_KEY = "INTLAYER_EDITED_CONTENT_CHANGED";
9
9
  /**
10
10
  * Persists the edited content in localStorage, and restores it on mount so
@@ -28,6 +28,5 @@ const useEditedContentPersistence = () => {
28
28
  }, [editedContent]);
29
29
  };
30
30
 
31
- //#endregion
32
31
  exports.useEditedContentPersistence = useEditedContentPersistence;
33
32
  //# sourceMappingURL=useEditedContentPersistence.cjs.map
@@ -1,10 +1,10 @@
1
1
  'use client';
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_EditorStateContext = require('./EditorStateContext.cjs');
4
+ const require_EditorStateContext = require("./EditorStateContext.cjs");
5
5
  let react = require("react");
6
6
 
7
- //#region src/useEditorLocale.tsx
7
+ // src/useEditorLocale.tsx
8
8
  const useEditorLocale = () => {
9
9
  const manager = require_EditorStateContext.useEditorStateManager();
10
10
  const [locale, setLocale] = (0, react.useState)(manager?.currentLocale.value);
@@ -17,6 +17,5 @@ const useEditorLocale = () => {
17
17
  return locale;
18
18
  };
19
19
 
20
- //#endregion
21
20
  exports.useEditorLocale = useEditorLocale;
22
21
  //# sourceMappingURL=useEditorLocale.cjs.map
@@ -1,13 +1,13 @@
1
1
  'use client';
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_DictionariesRecordContext = require('./DictionariesRecordContext.cjs');
5
- const require_useEditorLocale = require('./useEditorLocale.cjs');
6
- const require_FocusDictionaryContext = require('./FocusDictionaryContext.cjs');
4
+ const require_DictionariesRecordContext = require("./DictionariesRecordContext.cjs");
5
+ const require_FocusDictionaryContext = require("./FocusDictionaryContext.cjs");
6
+ const require_useEditorLocale = require("./useEditorLocale.cjs");
7
7
  let react = require("react");
8
8
  let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
9
9
 
10
- //#region src/useFocusUnmergedDictionary.tsx
10
+ // src/useFocusUnmergedDictionary.tsx
11
11
  /**
12
12
  * Converts merged keypath format to unmerged format.
13
13
  * Merged: [{type: "translation", key: "fr"}, {type: "object", key: "title"}]
@@ -46,6 +46,5 @@ const useFocusUnmergedDictionary = () => {
46
46
  };
47
47
  };
48
48
 
49
- //#endregion
50
49
  exports.useFocusUnmergedDictionary = useFocusUnmergedDictionary;
51
50
  //# sourceMappingURL=useFocusUnmergedDictionary.cjs.map
@@ -0,0 +1,43 @@
1
+ 'use client';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_EditorEnabledContext = require("./EditorEnabledContext.cjs");
5
+ let react = require("react");
6
+
7
+ // src/useFrameConnectionStatus.ts
8
+ /** Delay after a frame load before an unanswered handshake counts as failed. */
9
+ const FRAME_CONNECTION_TIMEOUT_MS = 5e3;
10
+ /**
11
+ * Detects an application frame that never connects to the editor.
12
+ * A frame blocked by the application's framing policy still fires `load` on
13
+ * an empty error page that the parent cannot inspect, so the missing
14
+ * handshake is the only signal available.
15
+ */
16
+ const useFrameConnectionStatus = (timeoutMs = FRAME_CONNECTION_TIMEOUT_MS) => {
17
+ const { enabled } = require_EditorEnabledContext.useEditorEnabled();
18
+ const [loadCount, setLoadCount] = (0, react.useState)(0);
19
+ const [isTimedOut, setIsTimedOut] = (0, react.useState)(false);
20
+ (0, react.useEffect)(() => {
21
+ if (enabled || loadCount === 0) return;
22
+ const timeout = setTimeout(() => setIsTimedOut(true), timeoutMs);
23
+ return () => clearTimeout(timeout);
24
+ }, [
25
+ enabled,
26
+ loadCount,
27
+ timeoutMs
28
+ ]);
29
+ const handleFrameLoad = (0, react.useCallback)(() => {
30
+ setIsTimedOut(false);
31
+ setLoadCount((count) => count + 1);
32
+ }, []);
33
+ const dismiss = (0, react.useCallback)(() => setIsTimedOut(false), []);
34
+ return {
35
+ isConnectionFailed: isTimedOut && !enabled,
36
+ handleFrameLoad,
37
+ dismiss
38
+ };
39
+ };
40
+
41
+ exports.FRAME_CONNECTION_TIMEOUT_MS = FRAME_CONNECTION_TIMEOUT_MS;
42
+ exports.useFrameConnectionStatus = useFrameConnectionStatus;
43
+ //# sourceMappingURL=useFrameConnectionStatus.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFrameConnectionStatus.cjs","names":["useEditorEnabled","useState","useCallback"],"sources":["../../src/useFrameConnectionStatus.ts"],"sourcesContent":["'use client';\n\nimport { useCallback, useEffect, useState } from 'react';\nimport { useEditorEnabled } from './EditorEnabledContext';\n\n/** Delay after a frame load before an unanswered handshake counts as failed. */\nexport const FRAME_CONNECTION_TIMEOUT_MS = 5_000;\n\nexport type FrameConnectionStatus = {\n /**\n * The frame loaded but its client never answered the handshake: the page\n * refused to be framed (CSP `frame-ancestors`, `X-Frame-Options`), or it\n * does not run the editor client.\n */\n isConnectionFailed: boolean;\n /** To call on every `load` event of the application frame. */\n handleFrameLoad: () => void;\n /** Hides the failure until the next load. */\n dismiss: () => void;\n};\n\n/**\n * Detects an application frame that never connects to the editor.\n * A frame blocked by the application's framing policy still fires `load` on\n * an empty error page that the parent cannot inspect, so the missing\n * handshake is the only signal available.\n */\nexport const useFrameConnectionStatus = (\n timeoutMs: number = FRAME_CONNECTION_TIMEOUT_MS\n): FrameConnectionStatus => {\n const { enabled } = useEditorEnabled();\n const [loadCount, setLoadCount] = useState(0);\n const [isTimedOut, setIsTimedOut] = useState(false);\n\n useEffect(() => {\n if (enabled || loadCount === 0) return;\n\n const timeout = setTimeout(() => setIsTimedOut(true), timeoutMs);\n\n return () => clearTimeout(timeout);\n }, [enabled, loadCount, timeoutMs]);\n\n const handleFrameLoad = useCallback(() => {\n setIsTimedOut(false);\n setLoadCount((count) => count + 1);\n }, []);\n\n const dismiss = useCallback(() => setIsTimedOut(false), []);\n\n return {\n isConnectionFailed: isTimedOut && !enabled,\n handleFrameLoad,\n dismiss,\n };\n};\n"],"mappings":";;;;;;;;AAMA,MAAa,8BAA8B;;;;;;;AAqB3C,MAAa,4BACX,YAAoB,gCACM;CAC1B,MAAM,EAAE,YAAYA,8CAAiB;CACrC,MAAM,CAAC,WAAW,oBAAgBC,gBAAS,CAAC;CAC5C,MAAM,CAAC,YAAY,qBAAiBA,gBAAS,KAAK;CAElD,2BAAgB;EACd,IAAI,WAAW,cAAc,GAAG;EAEhC,MAAM,UAAU,iBAAiB,cAAc,IAAI,GAAG,SAAS;EAE/D,aAAa,aAAa,OAAO;CACnC,GAAG;EAAC;EAAS;EAAW;CAAS,CAAC;CAElC,MAAM,sBAAkBC,yBAAkB;EACxC,cAAc,KAAK;EACnB,cAAc,UAAU,QAAQ,CAAC;CACnC,GAAG,CAAC,CAAC;CAEL,MAAM,cAAUA,yBAAkB,cAAc,KAAK,GAAG,CAAC,CAAC;CAE1D,OAAO;EACL,oBAAoB,cAAc,CAAC;EACnC;EACA;CACF;AACF"}
@@ -0,0 +1,62 @@
1
+ 'use client';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ let react = require("react");
5
+
6
+ // src/useFrameReconnection.ts
7
+ /** Delay between two probes of a disconnected application. */
8
+ const FRAME_RECONNECTION_INTERVAL_MS = 3e3;
9
+ /**
10
+ * Whether the application answers. `no-cors` resolves on any HTTP answer and
11
+ * only rejects on a network failure: the editor origin is rarely in the
12
+ * application's CORS allowlist.
13
+ */
14
+ const isApplicationReachable = (applicationURL) => fetch(applicationURL, {
15
+ method: "HEAD",
16
+ mode: "no-cors",
17
+ cache: "no-store"
18
+ }).then(() => true).catch(() => false);
19
+ /**
20
+ * Reconnects a disconnected application frame: the frame is reloaded once
21
+ * when the application still answers (e.g. it reloaded while its dev server
22
+ * restarted), then each time it answers again after being unreachable.
23
+ */
24
+ const useFrameReconnection = ({ applicationURL, isDisconnected, reloadFrame, intervalMs = FRAME_RECONNECTION_INTERVAL_MS }) => {
25
+ const hasReloadedRef = (0, react.useRef)(false);
26
+ const reloadFrameRef = (0, react.useRef)(reloadFrame);
27
+ reloadFrameRef.current = reloadFrame;
28
+ (0, react.useEffect)(() => {
29
+ if (!isDisconnected) {
30
+ hasReloadedRef.current = false;
31
+ return;
32
+ }
33
+ if (!applicationURL) return;
34
+ let isCancelled = false;
35
+ const probe = async () => {
36
+ const isReachable = await isApplicationReachable(applicationURL);
37
+ if (isCancelled) return;
38
+ if (!isReachable) {
39
+ hasReloadedRef.current = false;
40
+ return;
41
+ }
42
+ if (hasReloadedRef.current) return;
43
+ hasReloadedRef.current = true;
44
+ reloadFrameRef.current();
45
+ };
46
+ probe();
47
+ const interval = setInterval(() => void probe(), intervalMs);
48
+ return () => {
49
+ isCancelled = true;
50
+ clearInterval(interval);
51
+ };
52
+ }, [
53
+ applicationURL,
54
+ isDisconnected,
55
+ intervalMs
56
+ ]);
57
+ };
58
+
59
+ exports.FRAME_RECONNECTION_INTERVAL_MS = FRAME_RECONNECTION_INTERVAL_MS;
60
+ exports.isApplicationReachable = isApplicationReachable;
61
+ exports.useFrameReconnection = useFrameReconnection;
62
+ //# sourceMappingURL=useFrameReconnection.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFrameReconnection.cjs","names":["useRef"],"sources":["../../src/useFrameReconnection.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useRef } from 'react';\n\n/** Delay between two probes of a disconnected application. */\nexport const FRAME_RECONNECTION_INTERVAL_MS = 3_000;\n\n/**\n * Whether the application answers. `no-cors` resolves on any HTTP answer and\n * only rejects on a network failure: the editor origin is rarely in the\n * application's CORS allowlist.\n */\nexport const isApplicationReachable = (\n applicationURL: string\n): Promise<boolean> =>\n fetch(applicationURL, { method: 'HEAD', mode: 'no-cors', cache: 'no-store' })\n .then(() => true)\n .catch(() => false);\n\nexport type FrameReconnectionOptions = {\n applicationURL: string | undefined;\n /** The frame lost (or never got) its connection to the editor. */\n isDisconnected: boolean;\n /** Reloads the application frame. */\n reloadFrame: () => void;\n intervalMs?: number;\n};\n\n/**\n * Reconnects a disconnected application frame: the frame is reloaded once\n * when the application still answers (e.g. it reloaded while its dev server\n * restarted), then each time it answers again after being unreachable.\n */\nexport const useFrameReconnection = ({\n applicationURL,\n isDisconnected,\n reloadFrame,\n intervalMs = FRAME_RECONNECTION_INTERVAL_MS,\n}: FrameReconnectionOptions): void => {\n // Kept across probes: one reload per reachable period, so a frame that\n // never connects (framing refused, editor disabled) is not reloaded forever\n const hasReloadedRef = useRef(false);\n const reloadFrameRef = useRef(reloadFrame);\n reloadFrameRef.current = reloadFrame;\n\n useEffect(() => {\n if (!isDisconnected) {\n hasReloadedRef.current = false;\n return;\n }\n\n if (!applicationURL) return;\n\n let isCancelled = false;\n\n const probe = async () => {\n const isReachable = await isApplicationReachable(applicationURL);\n\n if (isCancelled) return;\n\n if (!isReachable) {\n hasReloadedRef.current = false;\n return;\n }\n\n if (hasReloadedRef.current) return;\n\n hasReloadedRef.current = true;\n reloadFrameRef.current();\n };\n\n void probe();\n const interval = setInterval(() => void probe(), intervalMs);\n\n return () => {\n isCancelled = true;\n clearInterval(interval);\n };\n }, [applicationURL, isDisconnected, intervalMs]);\n};\n"],"mappings":";;;;;;;AAKA,MAAa,iCAAiC;;;;;;AAO9C,MAAa,0BACX,mBAEA,MAAM,gBAAgB;CAAE,QAAQ;CAAQ,MAAM;CAAW,OAAO;AAAW,CAAC,CAAC,CAC1E,WAAW,IAAI,CAAC,CAChB,YAAY,KAAK;;;;;;AAgBtB,MAAa,wBAAwB,EACnC,gBACA,gBACA,aACA,aAAa,qCACuB;CAGpC,MAAM,qBAAiBA,cAAO,KAAK;CACnC,MAAM,qBAAiBA,cAAO,WAAW;CACzC,eAAe,UAAU;CAEzB,2BAAgB;EACd,IAAI,CAAC,gBAAgB;GACnB,eAAe,UAAU;GACzB;EACF;EAEA,IAAI,CAAC,gBAAgB;EAErB,IAAI,cAAc;EAElB,MAAM,QAAQ,YAAY;GACxB,MAAM,cAAc,MAAM,uBAAuB,cAAc;GAE/D,IAAI,aAAa;GAEjB,IAAI,CAAC,aAAa;IAChB,eAAe,UAAU;IACzB;GACF;GAEA,IAAI,eAAe,SAAS;GAE5B,eAAe,UAAU;GACzB,eAAe,QAAQ;EACzB;EAEA,AAAK,MAAM;EACX,MAAM,WAAW,kBAAkB,KAAK,MAAM,GAAG,UAAU;EAE3D,aAAa;GACX,cAAc;GACd,cAAc,QAAQ;EACxB;CACF,GAAG;EAAC;EAAgB;EAAgB;CAAU,CAAC;AACjD"}
@@ -3,7 +3,7 @@
3
3
  import { useEditorStateManager } from "./EditorStateContext.mjs";
4
4
  import { useEffect, useState } from "react";
5
5
 
6
- //#region src/ConfigurationContext.tsx
6
+ // src/ConfigurationContext.tsx
7
7
  /**
8
8
  * Returns the Intlayer configuration held by the editor state manager.
9
9
  */
@@ -19,6 +19,5 @@ const useConfiguration = () => {
19
19
  return configuration;
20
20
  };
21
21
 
22
- //#endregion
23
22
  export { useConfiguration };
24
23
  //# sourceMappingURL=ConfigurationContext.mjs.map
@@ -3,7 +3,7 @@
3
3
  import { useEditorStateManager } from "./EditorStateContext.mjs";
4
4
  import { useCallback, useEffect, useState } from "react";
5
5
 
6
- //#region src/DictionariesRecordContext.tsx
6
+ // src/DictionariesRecordContext.tsx
7
7
  const useDictionariesRecord = () => {
8
8
  const manager = useEditorStateManager();
9
9
  const [localeDictionaries, setLocaleDictionariesState] = useState(manager?.localeDictionaries.value ?? {});
@@ -27,6 +27,5 @@ const useDictionariesRecordActions = () => {
27
27
  };
28
28
  };
29
29
 
30
- //#endregion
31
30
  export { useDictionariesRecord, useDictionariesRecordActions };
32
31
  //# sourceMappingURL=DictionariesRecordContext.mjs.map
@@ -1,12 +1,16 @@
1
1
  'use client';
2
2
 
3
3
  import { useEditorStateManager } from "./EditorStateContext.mjs";
4
- import { useEffect, useState } from "react";
4
+ import { useEffect, useMemo, useState } from "react";
5
5
 
6
- //#region src/EditedContentContext.tsx
6
+ // src/EditedContentContext.tsx
7
+ /**
8
+ * Returns the edited content actions. Memoized on the manager so they can be
9
+ * used as effect dependencies without a compiler.
10
+ */
7
11
  const useEditedContentActions = () => {
8
12
  const manager = useEditorStateManager();
9
- return {
13
+ return useMemo(() => ({
10
14
  setEditedContentState: (value) => manager?.editedContent.set(value),
11
15
  setEditedDictionary: (dict) => manager?.setEditedDictionary(dict),
12
16
  setEditedContent: (localId, value) => manager?.setEditedContent(localId, value),
@@ -15,7 +19,7 @@ const useEditedContentActions = () => {
15
19
  removeEditedContent: (localId, keyPath) => manager?.removeContent(localId, keyPath),
16
20
  restoreEditedContent: (localId) => manager?.restoreContent(localId),
17
21
  getEditedContentValue: (localIdOrKey, keyPath) => manager?.getContentValue(localIdOrKey, keyPath)
18
- };
22
+ }), [manager]);
19
23
  };
20
24
  const useEditedContent = () => {
21
25
  const manager = useEditorStateManager();
@@ -32,6 +36,5 @@ const useEditedContent = () => {
32
36
  };
33
37
  };
34
38
 
35
- //#endregion
36
39
  export { useEditedContent, useEditedContentActions };
37
40
  //# sourceMappingURL=EditedContentContext.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"EditedContentContext.mjs","names":[],"sources":["../../src/EditedContentContext.tsx"],"sourcesContent":["'use client';\n\nimport type { DictionaryContent } from '@intlayer/editor';\nimport type {\n ContentNode,\n Dictionary,\n LocalDictionaryId,\n} from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { useEffect, useState } from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type { DictionaryContent } from '@intlayer/editor';\n\ntype EditedContentActionsContextType = {\n setEditedContentState: (editedContent: DictionaryContent) => void;\n setEditedDictionary: (dict: Dictionary) => void;\n setEditedContent: (\n localDictionaryId: LocalDictionaryId,\n newValue: Dictionary['content']\n ) => void;\n addEditedContent: (\n localDictionaryId: LocalDictionaryId,\n newValue: ContentNode<any>,\n keyPath?: KeyPath[],\n overwrite?: boolean\n ) => void;\n renameEditedContent: (\n localDictionaryId: LocalDictionaryId,\n newKey: KeyPath['key'],\n keyPath?: KeyPath[]\n ) => void;\n removeEditedContent: (\n localDictionaryId: LocalDictionaryId,\n keyPath: KeyPath[]\n ) => void;\n restoreEditedContent: (localDictionaryId: LocalDictionaryId) => void;\n getEditedContentValue: (\n localDictionaryIdOrKey: LocalDictionaryId | Dictionary['key'] | string,\n keyPath: KeyPath[]\n ) => ContentNode | undefined;\n};\n\nexport const useEditedContentActions = (): EditedContentActionsContextType => {\n const manager = useEditorStateManager();\n\n return {\n setEditedContentState: (value: DictionaryContent) =>\n manager?.editedContent.set(value),\n setEditedDictionary: (dict: Dictionary) =>\n manager?.setEditedDictionary(dict),\n setEditedContent: (\n localId: LocalDictionaryId,\n value: Dictionary['content']\n ) => manager?.setEditedContent(localId, value),\n addEditedContent: (localId, value, keyPath, overwrite) =>\n manager?.addContent(localId, value, keyPath, overwrite),\n renameEditedContent: (localId, newKey, keyPath) =>\n manager?.renameContent(localId, newKey, keyPath),\n removeEditedContent: (localId, keyPath) =>\n manager?.removeContent(localId, keyPath),\n restoreEditedContent: (localId) => manager?.restoreContent(localId),\n getEditedContentValue: (localIdOrKey, keyPath) =>\n manager?.getContentValue(localIdOrKey, keyPath),\n };\n};\n\nexport const useEditedContent = () => {\n const manager = useEditorStateManager();\n const [editedContent, setEditedContentState] = useState<\n DictionaryContent | undefined\n >(manager?.editedContent.value);\n\n useEffect(() => {\n if (!manager) return;\n const handler = (e: Event) =>\n setEditedContentState((e as CustomEvent<DictionaryContent>).detail);\n manager.editedContent.addEventListener('change', handler);\n return () => manager.editedContent.removeEventListener('change', handler);\n }, [manager]);\n\n const actions = useEditedContentActions();\n return { editedContent, ...actions };\n};\n"],"mappings":";;;;;;AA2CA,MAAa,gCAAiE;CAC5E,MAAM,UAAU,sBAAsB;CAEtC,OAAO;EACL,wBAAwB,UACtB,SAAS,cAAc,IAAI,KAAK;EAClC,sBAAsB,SACpB,SAAS,oBAAoB,IAAI;EACnC,mBACE,SACA,UACG,SAAS,iBAAiB,SAAS,KAAK;EAC7C,mBAAmB,SAAS,OAAO,SAAS,cAC1C,SAAS,WAAW,SAAS,OAAO,SAAS,SAAS;EACxD,sBAAsB,SAAS,QAAQ,YACrC,SAAS,cAAc,SAAS,QAAQ,OAAO;EACjD,sBAAsB,SAAS,YAC7B,SAAS,cAAc,SAAS,OAAO;EACzC,uBAAuB,YAAY,SAAS,eAAe,OAAO;EAClE,wBAAwB,cAAc,YACpC,SAAS,gBAAgB,cAAc,OAAO;CAClD;AACF;AAEA,MAAa,yBAAyB;CACpC,MAAM,UAAU,sBAAsB;CACtC,MAAM,CAAC,eAAe,yBAAyB,SAE7C,SAAS,cAAc,KAAK;CAE9B,gBAAgB;EACd,IAAI,CAAC,SAAS;EACd,MAAM,WAAW,MACf,sBAAuB,EAAqC,MAAM;EACpE,QAAQ,cAAc,iBAAiB,UAAU,OAAO;EACxD,aAAa,QAAQ,cAAc,oBAAoB,UAAU,OAAO;CAC1E,GAAG,CAAC,OAAO,CAAC;CAGZ,OAAO;EAAE;EAAe,GADR,wBACiB;CAAE;AACrC"}
1
+ {"version":3,"file":"EditedContentContext.mjs","names":[],"sources":["../../src/EditedContentContext.tsx"],"sourcesContent":["'use client';\n\nimport type { DictionaryContent } from '@intlayer/editor';\nimport type {\n ContentNode,\n Dictionary,\n LocalDictionaryId,\n} from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { useEffect, useMemo, useState } from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type { DictionaryContent } from '@intlayer/editor';\n\ntype EditedContentActionsContextType = {\n setEditedContentState: (editedContent: DictionaryContent) => void;\n setEditedDictionary: (dict: Dictionary) => void;\n setEditedContent: (\n localDictionaryId: LocalDictionaryId,\n newValue: Dictionary['content']\n ) => void;\n addEditedContent: (\n localDictionaryId: LocalDictionaryId,\n newValue: ContentNode<any>,\n keyPath?: KeyPath[],\n overwrite?: boolean\n ) => void;\n renameEditedContent: (\n localDictionaryId: LocalDictionaryId,\n newKey: KeyPath['key'],\n keyPath?: KeyPath[]\n ) => void;\n removeEditedContent: (\n localDictionaryId: LocalDictionaryId,\n keyPath: KeyPath[]\n ) => void;\n restoreEditedContent: (localDictionaryId: LocalDictionaryId) => void;\n getEditedContentValue: (\n localDictionaryIdOrKey: LocalDictionaryId | Dictionary['key'] | string,\n keyPath: KeyPath[]\n ) => ContentNode | undefined;\n};\n\n/**\n * Returns the edited content actions. Memoized on the manager so they can be\n * used as effect dependencies without a compiler.\n */\nexport const useEditedContentActions = (): EditedContentActionsContextType => {\n const manager = useEditorStateManager();\n\n return useMemo<EditedContentActionsContextType>(\n () => ({\n setEditedContentState: (value: DictionaryContent) =>\n manager?.editedContent.set(value),\n setEditedDictionary: (dict: Dictionary) =>\n manager?.setEditedDictionary(dict),\n setEditedContent: (\n localId: LocalDictionaryId,\n value: Dictionary['content']\n ) => manager?.setEditedContent(localId, value),\n addEditedContent: (localId, value, keyPath, overwrite) =>\n manager?.addContent(localId, value, keyPath, overwrite),\n renameEditedContent: (localId, newKey, keyPath) =>\n manager?.renameContent(localId, newKey, keyPath),\n removeEditedContent: (localId, keyPath) =>\n manager?.removeContent(localId, keyPath),\n restoreEditedContent: (localId) => manager?.restoreContent(localId),\n getEditedContentValue: (localIdOrKey, keyPath) =>\n manager?.getContentValue(localIdOrKey, keyPath),\n }),\n [manager]\n );\n};\n\nexport const useEditedContent = () => {\n const manager = useEditorStateManager();\n const [editedContent, setEditedContentState] = useState<\n DictionaryContent | undefined\n >(manager?.editedContent.value);\n\n useEffect(() => {\n if (!manager) return;\n const handler = (e: Event) =>\n setEditedContentState((e as CustomEvent<DictionaryContent>).detail);\n manager.editedContent.addEventListener('change', handler);\n return () => manager.editedContent.removeEventListener('change', handler);\n }, [manager]);\n\n const actions = useEditedContentActions();\n return { editedContent, ...actions };\n};\n"],"mappings":";;;;;;;;;;AA+CA,MAAa,gCAAiE;CAC5E,MAAM,UAAU,sBAAsB;CAEtC,OAAO,eACE;EACL,wBAAwB,UACtB,SAAS,cAAc,IAAI,KAAK;EAClC,sBAAsB,SACpB,SAAS,oBAAoB,IAAI;EACnC,mBACE,SACA,UACG,SAAS,iBAAiB,SAAS,KAAK;EAC7C,mBAAmB,SAAS,OAAO,SAAS,cAC1C,SAAS,WAAW,SAAS,OAAO,SAAS,SAAS;EACxD,sBAAsB,SAAS,QAAQ,YACrC,SAAS,cAAc,SAAS,QAAQ,OAAO;EACjD,sBAAsB,SAAS,YAC7B,SAAS,cAAc,SAAS,OAAO;EACzC,uBAAuB,YAAY,SAAS,eAAe,OAAO;EAClE,wBAAwB,cAAc,YACpC,SAAS,gBAAgB,cAAc,OAAO;CAClD,IACA,CAAC,OAAO,CACV;AACF;AAEA,MAAa,yBAAyB;CACpC,MAAM,UAAU,sBAAsB;CACtC,MAAM,CAAC,eAAe,yBAAyB,SAE7C,SAAS,cAAc,KAAK;CAE9B,gBAAgB;EACd,IAAI,CAAC,SAAS;EACd,MAAM,WAAW,MACf,sBAAuB,EAAqC,MAAM;EACpE,QAAQ,cAAc,iBAAiB,UAAU,OAAO;EACxD,aAAa,QAAQ,cAAc,oBAAoB,UAAU,OAAO;CAC1E,GAAG,CAAC,OAAO,CAAC;CAGZ,OAAO;EAAE;EAAe,GADR,wBACiB;CAAE;AACrC"}
@@ -1,9 +1,9 @@
1
1
  'use client';
2
2
 
3
3
  import { useEditorStateManager } from "./EditorStateContext.mjs";
4
- import { useEffect, useState } from "react";
4
+ import { useCallback, useEffect, useState } from "react";
5
5
 
6
- //#region src/EditorEnabledContext.tsx
6
+ // src/EditorEnabledContext.tsx
7
7
  /**
8
8
  * Returns the current editor-enabled state, kept in sync with the shared
9
9
  * EditorStateManager. Replaces the old EditorEnabledContext + EditorEnabledProvider.
@@ -25,9 +25,8 @@ const useEditorEnabled = () => {
25
25
  */
26
26
  const useEditorPingClient = () => {
27
27
  const manager = useEditorStateManager();
28
- return () => manager?.pingClient();
28
+ return useCallback(() => manager?.pingClient(), [manager]);
29
29
  };
30
30
 
31
- //#endregion
32
31
  export { useEditorEnabled, useEditorPingClient };
33
32
  //# sourceMappingURL=EditorEnabledContext.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"EditorEnabledContext.mjs","names":[],"sources":["../../src/EditorEnabledContext.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect, useState } from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type EditorEnabledStateProps = {\n enabled: boolean;\n};\n\n/**\n * Returns the current editor-enabled state, kept in sync with the shared\n * EditorStateManager. Replaces the old EditorEnabledContext + EditorEnabledProvider.\n */\nexport const useEditorEnabled = (): EditorEnabledStateProps => {\n const manager = useEditorStateManager();\n const [enabled, setEnabled] = useState<boolean>(\n manager?.editorEnabled.value ?? false\n );\n\n useEffect(() => {\n if (!manager) return;\n\n const handler = (e: Event) =>\n setEnabled((e as CustomEvent<boolean>).detail);\n manager.editorEnabled.addEventListener('change', handler);\n return () => manager.editorEnabled.removeEventListener('change', handler);\n }, [manager]);\n\n return { enabled };\n};\n\n/**\n * Returns a function that re-pings the client via ARE_YOU_THERE.\n * Use this as the onClick for an \"Enable Editor\" / reconnect button.\n */\nexport const useEditorPingClient = (): (() => void) => {\n const manager = useEditorStateManager();\n\n return () => manager?.pingClient();\n};\n"],"mappings":";;;;;;;;;;AAaA,MAAa,yBAAkD;CAC7D,MAAM,UAAU,sBAAsB;CACtC,MAAM,CAAC,SAAS,cAAc,SAC5B,SAAS,cAAc,SAAS,KAClC;CAEA,gBAAgB;EACd,IAAI,CAAC,SAAS;EAEd,MAAM,WAAW,MACf,WAAY,EAA2B,MAAM;EAC/C,QAAQ,cAAc,iBAAiB,UAAU,OAAO;EACxD,aAAa,QAAQ,cAAc,oBAAoB,UAAU,OAAO;CAC1E,GAAG,CAAC,OAAO,CAAC;CAEZ,OAAO,EAAE,QAAQ;AACnB;;;;;AAMA,MAAa,4BAA0C;CACrD,MAAM,UAAU,sBAAsB;CAEtC,aAAa,SAAS,WAAW;AACnC"}
1
+ {"version":3,"file":"EditorEnabledContext.mjs","names":[],"sources":["../../src/EditorEnabledContext.tsx"],"sourcesContent":["'use client';\n\nimport { useCallback, useEffect, useState } from 'react';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type EditorEnabledStateProps = {\n enabled: boolean;\n};\n\n/**\n * Returns the current editor-enabled state, kept in sync with the shared\n * EditorStateManager. Replaces the old EditorEnabledContext + EditorEnabledProvider.\n */\nexport const useEditorEnabled = (): EditorEnabledStateProps => {\n const manager = useEditorStateManager();\n const [enabled, setEnabled] = useState<boolean>(\n manager?.editorEnabled.value ?? false\n );\n\n useEffect(() => {\n if (!manager) return;\n\n const handler = (e: Event) =>\n setEnabled((e as CustomEvent<boolean>).detail);\n manager.editorEnabled.addEventListener('change', handler);\n return () => manager.editorEnabled.removeEventListener('change', handler);\n }, [manager]);\n\n return { enabled };\n};\n\n/**\n * Returns a function that re-pings the client via ARE_YOU_THERE.\n * Use this as the onClick for an \"Enable Editor\" / reconnect button.\n */\nexport const useEditorPingClient = (): (() => void) => {\n const manager = useEditorStateManager();\n\n return useCallback(() => manager?.pingClient(), [manager]);\n};\n"],"mappings":";;;;;;;;;;AAaA,MAAa,yBAAkD;CAC7D,MAAM,UAAU,sBAAsB;CACtC,MAAM,CAAC,SAAS,cAAc,SAC5B,SAAS,cAAc,SAAS,KAClC;CAEA,gBAAgB;EACd,IAAI,CAAC,SAAS;EAEd,MAAM,WAAW,MACf,WAAY,EAA2B,MAAM;EAC/C,QAAQ,cAAc,iBAAiB,UAAU,OAAO;EACxD,aAAa,QAAQ,cAAc,oBAAoB,UAAU,OAAO;CAC1E,GAAG,CAAC,OAAO,CAAC;CAEZ,OAAO,EAAE,QAAQ;AACnB;;;;;AAMA,MAAa,4BAA0C;CACrD,MAAM,UAAU,sBAAsB;CAEtC,OAAO,kBAAkB,SAAS,WAAW,GAAG,CAAC,OAAO,CAAC;AAC3D"}
@@ -5,7 +5,7 @@ import { useEffect, useRef } from "react";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  import { EditorStateManager, defineIntlayerElements, setGlobalEditorManager } from "@intlayer/editor";
7
7
 
8
- //#region src/EditorProvider.tsx
8
+ // src/EditorProvider.tsx
9
9
  /**
10
10
  * EditorProvider creates and manages the lifecycle of an EditorStateManager,
11
11
  * provides it to all descendants, and registers the Lit web components.
@@ -40,6 +40,5 @@ const EditorProvider = ({ children, configuration, postMessage, allowedOrigins }
40
40
  });
41
41
  };
42
42
 
43
- //#endregion
44
43
  export { EditorProvider };
45
44
  //# sourceMappingURL=EditorProvider.mjs.map