@intlayer/editor-react 9.7.0 → 9.7.2
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.
- package/dist/cjs/ConfigurationContext.cjs +2 -3
- package/dist/cjs/DictionariesRecordContext.cjs +2 -3
- package/dist/cjs/EditedContentContext.cjs +2 -3
- package/dist/cjs/EditorEnabledContext.cjs +2 -3
- package/dist/cjs/EditorProvider.cjs +3 -4
- package/dist/cjs/EditorStateContext.cjs +1 -2
- package/dist/cjs/FocusDictionaryContext.cjs +2 -3
- package/dist/cjs/index.cjs +19 -15
- package/dist/cjs/useCrossFrameState.cjs +2 -3
- package/dist/cjs/useCrossURLPathState.cjs +2 -3
- package/dist/cjs/useEditedContentPersistence.cjs +2 -3
- package/dist/cjs/useEditorLocale.cjs +2 -3
- package/dist/cjs/useFocusUnmergedDictionary.cjs +4 -5
- package/dist/cjs/useFrameConnectionStatus.cjs +2 -3
- package/dist/cjs/useFrameReconnection.cjs +62 -0
- package/dist/cjs/useFrameReconnection.cjs.map +1 -0
- package/dist/esm/ConfigurationContext.mjs +1 -2
- package/dist/esm/DictionariesRecordContext.mjs +1 -2
- package/dist/esm/EditedContentContext.mjs +1 -2
- package/dist/esm/EditorEnabledContext.mjs +1 -2
- package/dist/esm/EditorProvider.mjs +2 -3
- package/dist/esm/EditorStateContext.mjs +1 -2
- package/dist/esm/FocusDictionaryContext.mjs +1 -2
- package/dist/esm/index.mjs +8 -7
- package/dist/esm/useCrossFrameState.mjs +1 -2
- package/dist/esm/useCrossURLPathState.mjs +1 -2
- package/dist/esm/useEditedContentPersistence.mjs +1 -2
- package/dist/esm/useEditorLocale.mjs +1 -2
- package/dist/esm/useFocusUnmergedDictionary.mjs +2 -3
- package/dist/esm/useFrameConnectionStatus.mjs +1 -2
- package/dist/esm/useFrameReconnection.mjs +59 -0
- package/dist/esm/useFrameReconnection.mjs.map +1 -0
- package/dist/types/ConfigurationContext.d.ts +0 -2
- package/dist/types/ConfigurationContext.d.ts.map +1 -1
- package/dist/types/DictionariesRecordContext.d.ts +0 -2
- package/dist/types/DictionariesRecordContext.d.ts.map +1 -1
- package/dist/types/EditedContentContext.d.ts +0 -2
- package/dist/types/EditedContentContext.d.ts.map +1 -1
- package/dist/types/EditorEnabledContext.d.ts +0 -2
- package/dist/types/EditorEnabledContext.d.ts.map +1 -1
- package/dist/types/EditorProvider.d.ts +0 -2
- package/dist/types/EditorProvider.d.ts.map +1 -1
- package/dist/types/EditorStateContext.d.ts +1 -3
- package/dist/types/EditorStateContext.d.ts.map +1 -1
- package/dist/types/FocusDictionaryContext.d.ts +0 -2
- package/dist/types/FocusDictionaryContext.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -2
- package/dist/types/useCrossFrameState.d.ts +0 -2
- package/dist/types/useCrossFrameState.d.ts.map +1 -1
- package/dist/types/useCrossURLPathState.d.ts +0 -2
- package/dist/types/useCrossURLPathState.d.ts.map +1 -1
- package/dist/types/useEditedContentPersistence.d.ts +0 -2
- package/dist/types/useEditedContentPersistence.d.ts.map +1 -1
- package/dist/types/useEditorLocale.d.ts +0 -2
- package/dist/types/useEditorLocale.d.ts.map +1 -1
- package/dist/types/useFocusUnmergedDictionary.d.ts +0 -2
- package/dist/types/useFocusUnmergedDictionary.d.ts.map +1 -1
- package/dist/types/useFrameConnectionStatus.d.ts +0 -2
- package/dist/types/useFrameConnectionStatus.d.ts.map +1 -1
- package/dist/types/useFrameReconnection.d.ts +23 -0
- package/dist/types/useFrameReconnection.d.ts.map +1 -0
- package/package.json +30 -30
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_EditorStateContext = require(
|
|
4
|
+
const require_EditorStateContext = require("./EditorStateContext.cjs");
|
|
5
5
|
let react = require("react");
|
|
6
6
|
|
|
7
|
-
|
|
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(
|
|
4
|
+
const require_EditorStateContext = require("./EditorStateContext.cjs");
|
|
5
5
|
let react = require("react");
|
|
6
6
|
|
|
7
|
-
|
|
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,10 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_EditorStateContext = require(
|
|
4
|
+
const require_EditorStateContext = require("./EditorStateContext.cjs");
|
|
5
5
|
let react = require("react");
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/EditedContentContext.tsx
|
|
8
8
|
/**
|
|
9
9
|
* Returns the edited content actions. Memoized on the manager so they can be
|
|
10
10
|
* used as effect dependencies without a compiler.
|
|
@@ -37,7 +37,6 @@ const useEditedContent = () => {
|
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
//#endregion
|
|
41
40
|
exports.useEditedContent = useEditedContent;
|
|
42
41
|
exports.useEditedContentActions = useEditedContentActions;
|
|
43
42
|
//# sourceMappingURL=EditedContentContext.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(
|
|
4
|
+
const require_EditorStateContext = require("./EditorStateContext.cjs");
|
|
5
5
|
let react = require("react");
|
|
6
6
|
|
|
7
|
-
|
|
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.
|
|
@@ -29,7 +29,6 @@ const useEditorPingClient = () => {
|
|
|
29
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,12 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_EditorStateContext = require(
|
|
4
|
+
const require_EditorStateContext = require("./EditorStateContext.cjs");
|
|
5
|
+
let _intlayer_editor = require("@intlayer/editor");
|
|
5
6
|
let react = require("react");
|
|
6
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
-
let _intlayer_editor = require("@intlayer/editor");
|
|
8
8
|
|
|
9
|
-
|
|
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
|
-
|
|
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(
|
|
4
|
+
const require_EditorStateContext = require("./EditorStateContext.cjs");
|
|
5
5
|
let react = require("react");
|
|
6
6
|
|
|
7
|
-
|
|
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
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
3
|
-
const require_DictionariesRecordContext = require(
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const require_useFocusUnmergedDictionary = require(
|
|
14
|
-
const require_useFrameConnectionStatus = require(
|
|
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");
|
|
15
16
|
let _intlayer_editor = require("@intlayer/editor");
|
|
16
17
|
|
|
17
18
|
exports.EditorProvider = require_EditorProvider.EditorProvider;
|
|
18
19
|
exports.EditorStateProvider = require_EditorStateContext.EditorStateProvider;
|
|
19
20
|
exports.FRAME_CONNECTION_TIMEOUT_MS = require_useFrameConnectionStatus.FRAME_CONNECTION_TIMEOUT_MS;
|
|
20
|
-
|
|
21
|
+
exports.FRAME_RECONNECTION_INTERVAL_MS = require_useFrameReconnection.FRAME_RECONNECTION_INTERVAL_MS;
|
|
22
|
+
Object.defineProperty(exports, "MessageKey", {
|
|
21
23
|
enumerable: true,
|
|
22
24
|
get: function () {
|
|
23
25
|
return _intlayer_editor.MessageKey;
|
|
24
26
|
}
|
|
25
27
|
});
|
|
28
|
+
exports.isApplicationReachable = require_useFrameReconnection.isApplicationReachable;
|
|
26
29
|
exports.useConfiguration = require_ConfigurationContext.useConfiguration;
|
|
27
30
|
exports.useCrossFrameState = require_useCrossFrameState.useCrossFrameState;
|
|
28
31
|
exports.useCrossURLPathState = require_useCrossURLPathState.useCrossURLPathState;
|
|
@@ -37,4 +40,5 @@ exports.useEditorPingClient = require_EditorEnabledContext.useEditorPingClient;
|
|
|
37
40
|
exports.useEditorStateManager = require_EditorStateContext.useEditorStateManager;
|
|
38
41
|
exports.useFocusDictionary = require_FocusDictionaryContext.useFocusDictionary;
|
|
39
42
|
exports.useFocusUnmergedDictionary = require_useFocusUnmergedDictionary.useFocusUnmergedDictionary;
|
|
40
|
-
exports.useFrameConnectionStatus = require_useFrameConnectionStatus.useFrameConnectionStatus;
|
|
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(
|
|
4
|
+
const require_EditorStateContext = require("./EditorStateContext.cjs");
|
|
5
5
|
let react = require("react");
|
|
6
6
|
|
|
7
|
-
|
|
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(
|
|
4
|
+
const require_useCrossFrameState = require("./useCrossFrameState.cjs");
|
|
5
5
|
let _intlayer_editor = require("@intlayer/editor");
|
|
6
6
|
|
|
7
|
-
|
|
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(
|
|
4
|
+
const require_EditedContentContext = require("./EditedContentContext.cjs");
|
|
5
5
|
let react = require("react");
|
|
6
6
|
|
|
7
|
-
|
|
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(
|
|
4
|
+
const require_EditorStateContext = require("./EditorStateContext.cjs");
|
|
5
5
|
let react = require("react");
|
|
6
6
|
|
|
7
|
-
|
|
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(
|
|
5
|
-
const
|
|
6
|
-
const
|
|
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
|
-
|
|
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
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_EditorEnabledContext = require(
|
|
4
|
+
const require_EditorEnabledContext = require("./EditorEnabledContext.cjs");
|
|
5
5
|
let react = require("react");
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/useFrameConnectionStatus.ts
|
|
8
8
|
/** Delay after a frame load before an unanswered handshake counts as failed. */
|
|
9
9
|
const FRAME_CONNECTION_TIMEOUT_MS = 5e3;
|
|
10
10
|
/**
|
|
@@ -38,7 +38,6 @@ const useFrameConnectionStatus = (timeoutMs = FRAME_CONNECTION_TIMEOUT_MS) => {
|
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
//#endregion
|
|
42
41
|
exports.FRAME_CONNECTION_TIMEOUT_MS = FRAME_CONNECTION_TIMEOUT_MS;
|
|
43
42
|
exports.useFrameConnectionStatus = useFrameConnectionStatus;
|
|
44
43
|
//# sourceMappingURL=useFrameConnectionStatus.cjs.map
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { useEditorStateManager } from "./EditorStateContext.mjs";
|
|
4
4
|
import { useEffect, useMemo, useState } from "react";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/EditedContentContext.tsx
|
|
7
7
|
/**
|
|
8
8
|
* Returns the edited content actions. Memoized on the manager so they can be
|
|
9
9
|
* used as effect dependencies without a compiler.
|
|
@@ -36,6 +36,5 @@ const useEditedContent = () => {
|
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
//#endregion
|
|
40
39
|
export { useEditedContent, useEditedContentActions };
|
|
41
40
|
//# sourceMappingURL=EditedContentContext.mjs.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { useEditorStateManager } from "./EditorStateContext.mjs";
|
|
4
4
|
import { useCallback, useEffect, useState } from "react";
|
|
5
5
|
|
|
6
|
-
|
|
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.
|
|
@@ -28,6 +28,5 @@ const useEditorPingClient = () => {
|
|
|
28
28
|
return useCallback(() => manager?.pingClient(), [manager]);
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
//#endregion
|
|
32
31
|
export { useEditorEnabled, useEditorPingClient };
|
|
33
32
|
//# sourceMappingURL=EditorEnabledContext.mjs.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { EditorStateProvider } from "./EditorStateContext.mjs";
|
|
4
|
+
import { EditorStateManager, defineIntlayerElements, setGlobalEditorManager } from "@intlayer/editor";
|
|
4
5
|
import { useEffect, useRef } from "react";
|
|
5
6
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
import { EditorStateManager, defineIntlayerElements, setGlobalEditorManager } from "@intlayer/editor";
|
|
7
7
|
|
|
8
|
-
|
|
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
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { createContext, useContext } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/EditorStateContext.tsx
|
|
7
7
|
const EditorStateContext = createContext(null);
|
|
8
8
|
const EditorStateProvider = ({ children, manager }) => /* @__PURE__ */ jsx(EditorStateContext.Provider, {
|
|
9
9
|
value: manager,
|
|
@@ -11,6 +11,5 @@ const EditorStateProvider = ({ children, manager }) => /* @__PURE__ */ jsx(Edito
|
|
|
11
11
|
});
|
|
12
12
|
const useEditorStateManager = () => useContext(EditorStateContext);
|
|
13
13
|
|
|
14
|
-
//#endregion
|
|
15
14
|
export { EditorStateProvider, useEditorStateManager };
|
|
16
15
|
//# sourceMappingURL=EditorStateContext.mjs.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { useEditorStateManager } from "./EditorStateContext.mjs";
|
|
4
4
|
import { useCallback, useEffect, useState } from "react";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/FocusDictionaryContext.tsx
|
|
7
7
|
/**
|
|
8
8
|
* Returns the content focused in the editor, shared with the client frame.
|
|
9
9
|
*/
|
|
@@ -23,6 +23,5 @@ const useFocusDictionary = () => {
|
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
//#endregion
|
|
27
26
|
export { useFocusDictionary };
|
|
28
27
|
//# sourceMappingURL=FocusDictionaryContext.mjs.map
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useConfiguration } from "./ConfigurationContext.mjs";
|
|
2
2
|
import { useDictionariesRecord, useDictionariesRecordActions } from "./DictionariesRecordContext.mjs";
|
|
3
|
-
import { useCrossFrameState } from "./useCrossFrameState.mjs";
|
|
4
|
-
import { useCrossURLPathState } from "./useCrossURLPathState.mjs";
|
|
5
3
|
import { useEditedContent, useEditedContentActions } from "./EditedContentContext.mjs";
|
|
6
|
-
import { useEditedContentPersistence } from "./useEditedContentPersistence.mjs";
|
|
7
|
-
import { useEditorLocale } from "./useEditorLocale.mjs";
|
|
8
|
-
import { useConfiguration } from "./ConfigurationContext.mjs";
|
|
9
4
|
import { useEditorEnabled, useEditorPingClient } from "./EditorEnabledContext.mjs";
|
|
10
5
|
import { EditorProvider } from "./EditorProvider.mjs";
|
|
6
|
+
import { EditorStateProvider, useEditorStateManager } from "./EditorStateContext.mjs";
|
|
11
7
|
import { useFocusDictionary } from "./FocusDictionaryContext.mjs";
|
|
8
|
+
import { useCrossFrameState } from "./useCrossFrameState.mjs";
|
|
9
|
+
import { useCrossURLPathState } from "./useCrossURLPathState.mjs";
|
|
10
|
+
import { useEditedContentPersistence } from "./useEditedContentPersistence.mjs";
|
|
11
|
+
import { useEditorLocale } from "./useEditorLocale.mjs";
|
|
12
12
|
import { useFocusUnmergedDictionary } from "./useFocusUnmergedDictionary.mjs";
|
|
13
13
|
import { FRAME_CONNECTION_TIMEOUT_MS, useFrameConnectionStatus } from "./useFrameConnectionStatus.mjs";
|
|
14
|
+
import { FRAME_RECONNECTION_INTERVAL_MS, isApplicationReachable, useFrameReconnection } from "./useFrameReconnection.mjs";
|
|
14
15
|
import { MessageKey } from "@intlayer/editor";
|
|
15
16
|
|
|
16
|
-
export { EditorProvider, EditorStateProvider, FRAME_CONNECTION_TIMEOUT_MS, MessageKey, useConfiguration, useCrossFrameState, useCrossURLPathState, useDictionariesRecord, useDictionariesRecordActions, useEditedContent, useEditedContentActions, useEditedContentPersistence, useEditorEnabled, useEditorLocale, useEditorPingClient, useEditorStateManager, useFocusDictionary, useFocusUnmergedDictionary, useFrameConnectionStatus };
|
|
17
|
+
export { EditorProvider, EditorStateProvider, FRAME_CONNECTION_TIMEOUT_MS, FRAME_RECONNECTION_INTERVAL_MS, MessageKey, isApplicationReachable, useConfiguration, useCrossFrameState, useCrossURLPathState, useDictionariesRecord, useDictionariesRecordActions, useEditedContent, useEditedContentActions, useEditedContentPersistence, useEditorEnabled, useEditorLocale, useEditorPingClient, useEditorStateManager, useFocusDictionary, useFocusUnmergedDictionary, useFrameConnectionStatus, useFrameReconnection };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { useEditorStateManager } from "./EditorStateContext.mjs";
|
|
4
4
|
import { useEffect, useState } from "react";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/useCrossFrameState.tsx
|
|
7
7
|
/**
|
|
8
8
|
* Returns the latest value another frame posted under `key`.
|
|
9
9
|
*/
|
|
@@ -14,6 +14,5 @@ const useCrossFrameState = (key, initialValue) => {
|
|
|
14
14
|
return value;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
//#endregion
|
|
18
17
|
export { useCrossFrameState };
|
|
19
18
|
//# sourceMappingURL=useCrossFrameState.mjs.map
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
import { useCrossFrameState } from "./useCrossFrameState.mjs";
|
|
4
4
|
import { MessageKey } from "@intlayer/editor";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/useCrossURLPathState.tsx
|
|
7
7
|
/**
|
|
8
8
|
* Returns the path currently displayed by the client application.
|
|
9
9
|
*/
|
|
10
10
|
const useCrossURLPathState = () => useCrossFrameState(MessageKey.INTLAYER_URL_CHANGE, void 0);
|
|
11
11
|
|
|
12
|
-
//#endregion
|
|
13
12
|
export { useCrossURLPathState };
|
|
14
13
|
//# sourceMappingURL=useCrossURLPathState.mjs.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { useEditedContent } from "./EditedContentContext.mjs";
|
|
4
4
|
import { useEffect } from "react";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/useEditedContentPersistence.tsx
|
|
7
7
|
const EDITED_CONTENT_STORAGE_KEY = "INTLAYER_EDITED_CONTENT_CHANGED";
|
|
8
8
|
/**
|
|
9
9
|
* Persists the edited content in localStorage, and restores it on mount so
|
|
@@ -27,6 +27,5 @@ const useEditedContentPersistence = () => {
|
|
|
27
27
|
}, [editedContent]);
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
//#endregion
|
|
31
30
|
export { useEditedContentPersistence };
|
|
32
31
|
//# sourceMappingURL=useEditedContentPersistence.mjs.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { useEditorStateManager } from "./EditorStateContext.mjs";
|
|
4
4
|
import { useEffect, useState } from "react";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/useEditorLocale.tsx
|
|
7
7
|
const useEditorLocale = () => {
|
|
8
8
|
const manager = useEditorStateManager();
|
|
9
9
|
const [locale, setLocale] = useState(manager?.currentLocale.value);
|
|
@@ -16,6 +16,5 @@ const useEditorLocale = () => {
|
|
|
16
16
|
return locale;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
//#endregion
|
|
20
19
|
export { useEditorLocale };
|
|
21
20
|
//# sourceMappingURL=useEditorLocale.mjs.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useDictionariesRecord } from "./DictionariesRecordContext.mjs";
|
|
4
|
-
import { useEditorLocale } from "./useEditorLocale.mjs";
|
|
5
4
|
import { useFocusDictionary } from "./FocusDictionaryContext.mjs";
|
|
5
|
+
import { useEditorLocale } from "./useEditorLocale.mjs";
|
|
6
6
|
import { useMemo } from "react";
|
|
7
7
|
import { getContentNodeByKeyPath } from "@intlayer/core/dictionaryManipulator";
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// src/useFocusUnmergedDictionary.tsx
|
|
10
10
|
/**
|
|
11
11
|
* Converts merged keypath format to unmerged format.
|
|
12
12
|
* Merged: [{type: "translation", key: "fr"}, {type: "object", key: "title"}]
|
|
@@ -45,6 +45,5 @@ const useFocusUnmergedDictionary = () => {
|
|
|
45
45
|
};
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
//#endregion
|
|
49
48
|
export { useFocusUnmergedDictionary };
|
|
50
49
|
//# sourceMappingURL=useFocusUnmergedDictionary.mjs.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { useEditorEnabled } from "./EditorEnabledContext.mjs";
|
|
4
4
|
import { useCallback, useEffect, useState } from "react";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/useFrameConnectionStatus.ts
|
|
7
7
|
/** Delay after a frame load before an unanswered handshake counts as failed. */
|
|
8
8
|
const FRAME_CONNECTION_TIMEOUT_MS = 5e3;
|
|
9
9
|
/**
|
|
@@ -37,6 +37,5 @@ const useFrameConnectionStatus = (timeoutMs = FRAME_CONNECTION_TIMEOUT_MS) => {
|
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
//#endregion
|
|
41
40
|
export { FRAME_CONNECTION_TIMEOUT_MS, useFrameConnectionStatus };
|
|
42
41
|
//# sourceMappingURL=useFrameConnectionStatus.mjs.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
|
|
5
|
+
// src/useFrameReconnection.ts
|
|
6
|
+
/** Delay between two probes of a disconnected application. */
|
|
7
|
+
const FRAME_RECONNECTION_INTERVAL_MS = 3e3;
|
|
8
|
+
/**
|
|
9
|
+
* Whether the application answers. `no-cors` resolves on any HTTP answer and
|
|
10
|
+
* only rejects on a network failure: the editor origin is rarely in the
|
|
11
|
+
* application's CORS allowlist.
|
|
12
|
+
*/
|
|
13
|
+
const isApplicationReachable = (applicationURL) => fetch(applicationURL, {
|
|
14
|
+
method: "HEAD",
|
|
15
|
+
mode: "no-cors",
|
|
16
|
+
cache: "no-store"
|
|
17
|
+
}).then(() => true).catch(() => false);
|
|
18
|
+
/**
|
|
19
|
+
* Reconnects a disconnected application frame: the frame is reloaded once
|
|
20
|
+
* when the application still answers (e.g. it reloaded while its dev server
|
|
21
|
+
* restarted), then each time it answers again after being unreachable.
|
|
22
|
+
*/
|
|
23
|
+
const useFrameReconnection = ({ applicationURL, isDisconnected, reloadFrame, intervalMs = FRAME_RECONNECTION_INTERVAL_MS }) => {
|
|
24
|
+
const hasReloadedRef = useRef(false);
|
|
25
|
+
const reloadFrameRef = useRef(reloadFrame);
|
|
26
|
+
reloadFrameRef.current = reloadFrame;
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (!isDisconnected) {
|
|
29
|
+
hasReloadedRef.current = false;
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (!applicationURL) return;
|
|
33
|
+
let isCancelled = false;
|
|
34
|
+
const probe = async () => {
|
|
35
|
+
const isReachable = await isApplicationReachable(applicationURL);
|
|
36
|
+
if (isCancelled) return;
|
|
37
|
+
if (!isReachable) {
|
|
38
|
+
hasReloadedRef.current = false;
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (hasReloadedRef.current) return;
|
|
42
|
+
hasReloadedRef.current = true;
|
|
43
|
+
reloadFrameRef.current();
|
|
44
|
+
};
|
|
45
|
+
probe();
|
|
46
|
+
const interval = setInterval(() => void probe(), intervalMs);
|
|
47
|
+
return () => {
|
|
48
|
+
isCancelled = true;
|
|
49
|
+
clearInterval(interval);
|
|
50
|
+
};
|
|
51
|
+
}, [
|
|
52
|
+
applicationURL,
|
|
53
|
+
isDisconnected,
|
|
54
|
+
intervalMs
|
|
55
|
+
]);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export { FRAME_RECONNECTION_INTERVAL_MS, isApplicationReachable, useFrameReconnection };
|
|
59
|
+
//# sourceMappingURL=useFrameReconnection.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFrameReconnection.mjs","names":[],"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,iBAAiB,OAAO,KAAK;CACnC,MAAM,iBAAiB,OAAO,WAAW;CACzC,eAAe,UAAU;CAEzB,gBAAgB;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"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
|
-
//#region src/ConfigurationContext.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Returns the Intlayer configuration held by the editor state manager.
|
|
5
4
|
*/
|
|
6
5
|
export declare const useConfiguration: () => IntlayerConfig | undefined;
|
|
7
|
-
//#endregion
|
|
8
6
|
//# sourceMappingURL=ConfigurationContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigurationContext.d.ts","names":[],"sources":["../../src/ConfigurationContext.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ConfigurationContext.d.ts","names":[],"sources":["../../src/ConfigurationContext.tsx"],"mappings":";;;;qBASa,wBAAuB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DictionaryContent, DictionaryContent as DictionaryContent$1 } from "@intlayer/editor";
|
|
2
2
|
import { Dictionary } from "@intlayer/types/dictionary";
|
|
3
|
-
//#region src/DictionariesRecordContext.d.ts
|
|
4
3
|
type DictionariesRecordStatesContextType = {
|
|
5
4
|
localeDictionaries: DictionaryContent$1;
|
|
6
5
|
};
|
|
@@ -10,6 +9,5 @@ type DictionariesRecordActionsContextType = {
|
|
|
10
9
|
};
|
|
11
10
|
export declare const useDictionariesRecord: () => DictionariesRecordStatesContextType & DictionariesRecordActionsContextType;
|
|
12
11
|
export declare const useDictionariesRecordActions: () => DictionariesRecordActionsContextType;
|
|
13
|
-
//#endregion
|
|
14
12
|
export type { DictionaryContent };
|
|
15
13
|
//# sourceMappingURL=DictionariesRecordContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionariesRecordContext.d.ts","names":[],"sources":["../../src/DictionariesRecordContext.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"DictionariesRecordContext.d.ts","names":["DictionaryContent"],"sources":["../../src/DictionariesRecordContext.tsx"],"mappings":";;KASK;EACH,oBAAoBA;;KAEjB;EACH,wBAAwB,OAAOA;EAC/B,sBAAsB,YAAY;;qBAGvB,6BAA4B,sCACvC;qBAgCW,oCACP"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DictionaryContent, DictionaryContent as DictionaryContent$1 } from "@intlayer/editor";
|
|
2
2
|
import { ContentNode, Dictionary, LocalDictionaryId } from "@intlayer/types/dictionary";
|
|
3
3
|
import { KeyPath } from "@intlayer/types/keyPath";
|
|
4
|
-
//#region src/EditedContentContext.d.ts
|
|
5
4
|
type EditedContentActionsContextType = {
|
|
6
5
|
setEditedContentState: (editedContent: DictionaryContent$1) => void;
|
|
7
6
|
setEditedDictionary: (dict: Dictionary) => void;
|
|
@@ -28,6 +27,5 @@ export declare const useEditedContent: () => {
|
|
|
28
27
|
getEditedContentValue: (localDictionaryIdOrKey: LocalDictionaryId | Dictionary['key'] | string, keyPath: KeyPath[]) => ContentNode | undefined;
|
|
29
28
|
editedContent: DictionaryContent$1;
|
|
30
29
|
};
|
|
31
|
-
//#endregion
|
|
32
30
|
export type { DictionaryContent };
|
|
33
31
|
//# sourceMappingURL=EditedContentContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditedContentContext.d.ts","names":[],"sources":["../../src/EditedContentContext.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EditedContentContext.d.ts","names":["DictionaryContent"],"sources":["../../src/EditedContentContext.tsx"],"mappings":";;;KAcK;EACH,wBAAwB,eAAeA;EACvC,sBAAsB,MAAM;EAC5B,mBACE,mBAAmB,mBACnB,UAAU;EAEZ,mBACE,mBAAmB,mBACnB,UAAU,kBACV,UAAU,WACV;EAEF,sBACE,mBAAmB,mBACnB,QAAQ,gBACR,UAAU;EAEZ,sBACE,mBAAmB,mBACnB,SAAS;EAEX,uBAAuB,mBAAmB;EAC1C,wBACE,wBAAwB,oBAAoB,4BAC5C,SAAS,cACN;;;;;;qBAOM,+BAA8B;qBA2B9B;EA3DY,wBAAC,eAAeA;EAClB,sBAAC,MAAM;EACV,mBAChB,mBAAmB,mBACnB,UAAU;EAEM,mBAChB,mBAAmB,mBACnB,UAAU,kBACV,UAAU,WACV;EAEmB,sBACnB,mBAAmB,mBACnB,QAAQ,gBACR,UAAU;EAES,sBACnB,mBAAmB,mBACnB,SAAS;EAEW,uBAAC,mBAAmB;EACnB,wBACrB,wBAAwB,oBAAoB,4BAC5C,SAAS,cACN"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/EditorEnabledContext.d.ts
|
|
2
1
|
export type EditorEnabledStateProps = {
|
|
3
2
|
enabled: boolean;
|
|
4
3
|
};
|
|
@@ -12,5 +11,4 @@ export declare const useEditorEnabled: () => EditorEnabledStateProps;
|
|
|
12
11
|
* Use this as the onClick for an "Enable Editor" / reconnect button.
|
|
13
12
|
*/
|
|
14
13
|
export declare const useEditorPingClient: () => (() => void);
|
|
15
|
-
//#endregion
|
|
16
14
|
//# sourceMappingURL=EditorEnabledContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorEnabledContext.d.ts","names":[],"sources":["../../src/EditorEnabledContext.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EditorEnabledContext.d.ts","names":[],"sources":["../../src/EditorEnabledContext.tsx"],"mappings":"A,YAKY;EACV;;;;;;qBAOW,wBAAuB;;;;;qBAsBvB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
2
|
import { FC, PropsWithChildren } from "react";
|
|
3
|
-
//#region src/EditorProvider.d.ts
|
|
4
3
|
export type EditorProviderProps = {
|
|
5
4
|
configuration: Pick<IntlayerConfig, 'editor' | 'internationalization'>;
|
|
6
5
|
postMessage: (data: any) => void;
|
|
@@ -11,5 +10,4 @@ export type EditorProviderProps = {
|
|
|
11
10
|
* provides it to all descendants, and registers the Lit web components.
|
|
12
11
|
*/
|
|
13
12
|
export declare const EditorProvider: FC<PropsWithChildren<EditorProviderProps>>;
|
|
14
|
-
//#endregion
|
|
15
13
|
//# sourceMappingURL=EditorProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorProvider.d.ts","names":[],"sources":["../../src/EditorProvider.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EditorProvider.d.ts","names":[],"sources":["../../src/EditorProvider.tsx"],"mappings":";;YAYY;EACV,eAAe,KAAK;EACpB,cAAc;EACd;;;;;;qBAOW,gBAAgB,GAAG,kBAAkB"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { EditorStateManager } from "@intlayer/editor";
|
|
2
1
|
import { FC, PropsWithChildren } from "react";
|
|
3
|
-
|
|
2
|
+
import { EditorStateManager } from "@intlayer/editor";
|
|
4
3
|
export declare const EditorStateProvider: FC<PropsWithChildren<{
|
|
5
4
|
manager: EditorStateManager;
|
|
6
5
|
}>>;
|
|
7
6
|
export declare const useEditorStateManager: () => EditorStateManager | null;
|
|
8
|
-
//#endregion
|
|
9
7
|
//# sourceMappingURL=EditorStateContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorStateContext.d.ts","names":[],"sources":["../../src/EditorStateContext.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EditorStateContext.d.ts","names":[],"sources":["../../src/EditorStateContext.tsx"],"mappings":";;qBAYa,qBAAqB,GAChC;EAAoB,SAAS;;qBAOlB,6BAA4B"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CrossFrameStateAction, FileContent, FileContent as FileContent$1 } from "@intlayer/editor";
|
|
2
2
|
import { KeyPath } from "@intlayer/types/keyPath";
|
|
3
|
-
//#region src/FocusDictionaryContext.d.ts
|
|
4
3
|
export type FocusDictionaryActions = {
|
|
5
4
|
/** Accepts a value or an updater — `setFocusedContent(prev => …)`. */
|
|
6
5
|
setFocusedContent: (value: CrossFrameStateAction<FileContent$1 | null>) => void;
|
|
@@ -12,6 +11,5 @@ export type FocusDictionaryActions = {
|
|
|
12
11
|
export declare const useFocusDictionary: () => FocusDictionaryActions & {
|
|
13
12
|
focusedContent: FileContent$1 | null;
|
|
14
13
|
};
|
|
15
|
-
//#endregion
|
|
16
14
|
export type { FileContent };
|
|
17
15
|
//# sourceMappingURL=FocusDictionaryContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FocusDictionaryContext.d.ts","names":[],"sources":["../../src/FocusDictionaryContext.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"FocusDictionaryContext.d.ts","names":["FileContent"],"sources":["../../src/FocusDictionaryContext.tsx"],"mappings":";;YASY;;EAEV,oBAAoB,OAAO,sBAAsBA;EACjD,2BAA2B,SAAS;;;;;qBAMzB,0BAAyB;EACpC,gBAAgBA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useConfiguration } from "./ConfigurationContext.js";
|
|
2
|
-
import { DictionaryContent
|
|
2
|
+
import { DictionaryContent, useDictionariesRecord, useDictionariesRecordActions } from "./DictionariesRecordContext.js";
|
|
3
3
|
import { useEditedContent, useEditedContentActions } from "./EditedContentContext.js";
|
|
4
4
|
import { EditorEnabledStateProps, useEditorEnabled, useEditorPingClient } from "./EditorEnabledContext.js";
|
|
5
5
|
import { EditorProvider, EditorProviderProps } from "./EditorProvider.js";
|
|
@@ -11,5 +11,6 @@ import { useEditedContentPersistence } from "./useEditedContentPersistence.js";
|
|
|
11
11
|
import { useEditorLocale } from "./useEditorLocale.js";
|
|
12
12
|
import { useFocusUnmergedDictionary } from "./useFocusUnmergedDictionary.js";
|
|
13
13
|
import { FRAME_CONNECTION_TIMEOUT_MS, FrameConnectionStatus, useFrameConnectionStatus } from "./useFrameConnectionStatus.js";
|
|
14
|
+
import { FRAME_RECONNECTION_INTERVAL_MS, FrameReconnectionOptions, isApplicationReachable, useFrameReconnection } from "./useFrameReconnection.js";
|
|
14
15
|
import { MessageKey } from "@intlayer/editor";
|
|
15
|
-
export { EditorEnabledStateProps, EditorProvider, EditorProviderProps, EditorStateProvider, FRAME_CONNECTION_TIMEOUT_MS, type FileContent, FocusDictionaryActions, FrameConnectionStatus, MessageKey, useConfiguration, useCrossFrameState, useCrossURLPathState, useDictionariesRecord, useDictionariesRecordActions, useEditedContent, useEditedContentActions, useEditedContentPersistence, useEditorEnabled, useEditorLocale, useEditorPingClient, useEditorStateManager, useFocusDictionary, useFocusUnmergedDictionary, useFrameConnectionStatus };
|
|
16
|
+
export { type DictionaryContent, EditorEnabledStateProps, EditorProvider, EditorProviderProps, EditorStateProvider, FRAME_CONNECTION_TIMEOUT_MS, FRAME_RECONNECTION_INTERVAL_MS, type FileContent, FocusDictionaryActions, FrameConnectionStatus, FrameReconnectionOptions, MessageKey, isApplicationReachable, useConfiguration, useCrossFrameState, useCrossURLPathState, useDictionariesRecord, useDictionariesRecordActions, useEditedContent, useEditedContentActions, useEditedContentPersistence, useEditorEnabled, useEditorLocale, useEditorPingClient, useEditorStateManager, useFocusDictionary, useFocusUnmergedDictionary, useFrameConnectionStatus, useFrameReconnection };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { MessageKey } from "@intlayer/editor";
|
|
2
|
-
//#region src/useCrossFrameState.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Returns the latest value another frame posted under `key`.
|
|
5
4
|
*/
|
|
6
5
|
export declare const useCrossFrameState: <Value>(key: `${MessageKey}`, initialValue: Value) => Value;
|
|
7
|
-
//#endregion
|
|
8
6
|
//# sourceMappingURL=useCrossFrameState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCrossFrameState.d.ts","names":[],"sources":["../../src/useCrossFrameState.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCrossFrameState.d.ts","names":[],"sources":["../../src/useCrossFrameState.tsx"],"mappings":";;;;qBASa,qBAAsB,OAAK,QAC9B,cAAY,cACN,UACb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCrossURLPathState.d.ts","names":[],"sources":["../../src/useCrossURLPathState.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCrossURLPathState.d.ts","names":[],"sources":["../../src/useCrossURLPathState.tsx"],"mappings":";;;qBAQa"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
//#region src/useEditedContentPersistence.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Persists the edited content in localStorage, and restores it on mount so
|
|
4
3
|
* unsaved edits survive a page reload.
|
|
5
4
|
*/
|
|
6
5
|
export declare const useEditedContentPersistence: () => void;
|
|
7
|
-
//#endregion
|
|
8
6
|
//# sourceMappingURL=useEditedContentPersistence.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditedContentPersistence.d.ts","names":[],"sources":["../../src/useEditedContentPersistence.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useEditedContentPersistence.d.ts","names":[],"sources":["../../src/useEditedContentPersistence.tsx"],"mappings":";;;;qBAWa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditorLocale.d.ts","names":[],"sources":["../../src/useEditorLocale.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useEditorLocale.d.ts","names":[],"sources":["../../src/useEditorLocale.tsx"],"mappings":";qBAMa,uBAAsB"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { FileContent } from "./FocusDictionaryContext.js";
|
|
2
2
|
import { KeyPath } from "@intlayer/types/keyPath";
|
|
3
|
-
//#region src/useFocusUnmergedDictionary.d.ts
|
|
4
3
|
export declare const useFocusUnmergedDictionary: () => {
|
|
5
4
|
focusedContent: FileContent;
|
|
6
5
|
setFocusedContent: (value: import("@intlayer/editor").CrossFrameStateAction<FileContent | null>) => void;
|
|
7
6
|
setFocusedContentKeyPath: (keyPath: KeyPath[]) => void;
|
|
8
7
|
};
|
|
9
|
-
//#endregion
|
|
10
8
|
//# sourceMappingURL=useFocusUnmergedDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFocusUnmergedDictionary.d.ts","names":[],"sources":["../../src/useFocusUnmergedDictionary.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFocusUnmergedDictionary.d.ts","names":[],"sources":["../../src/useFocusUnmergedDictionary.tsx"],"mappings":";;qBA8Ca"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/useFrameConnectionStatus.d.ts
|
|
2
1
|
/** Delay after a frame load before an unanswered handshake counts as failed. */
|
|
3
2
|
export declare const FRAME_CONNECTION_TIMEOUT_MS = 5000;
|
|
4
3
|
export type FrameConnectionStatus = {
|
|
@@ -20,5 +19,4 @@ export type FrameConnectionStatus = {
|
|
|
20
19
|
* handshake is the only signal available.
|
|
21
20
|
*/
|
|
22
21
|
export declare const useFrameConnectionStatus: (timeoutMs?: number) => FrameConnectionStatus;
|
|
23
|
-
//#endregion
|
|
24
22
|
//# sourceMappingURL=useFrameConnectionStatus.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFrameConnectionStatus.d.ts","names":[],"sources":["../../src/useFrameConnectionStatus.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFrameConnectionStatus.d.ts","names":[],"sources":["../../src/useFrameConnectionStatus.ts"],"mappings":";qBAMa;YAED;;;;;;EAMV;;EAEA;;EAEA;;;;;;;;qBASW,2BAAwB,uBAElC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Delay between two probes of a disconnected application. */
|
|
2
|
+
export declare const FRAME_RECONNECTION_INTERVAL_MS = 3000;
|
|
3
|
+
/**
|
|
4
|
+
* Whether the application answers. `no-cors` resolves on any HTTP answer and
|
|
5
|
+
* only rejects on a network failure: the editor origin is rarely in the
|
|
6
|
+
* application's CORS allowlist.
|
|
7
|
+
*/
|
|
8
|
+
export declare const isApplicationReachable: (applicationURL: string) => Promise<boolean>;
|
|
9
|
+
export type FrameReconnectionOptions = {
|
|
10
|
+
applicationURL: string | undefined;
|
|
11
|
+
/** The frame lost (or never got) its connection to the editor. */
|
|
12
|
+
isDisconnected: boolean;
|
|
13
|
+
/** Reloads the application frame. */
|
|
14
|
+
reloadFrame: () => void;
|
|
15
|
+
intervalMs?: number;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Reconnects a disconnected application frame: the frame is reloaded once
|
|
19
|
+
* when the application still answers (e.g. it reloaded while its dev server
|
|
20
|
+
* restarted), then each time it answers again after being unreachable.
|
|
21
|
+
*/
|
|
22
|
+
export declare const useFrameReconnection: ({ applicationURL, isDisconnected, reloadFrame, intervalMs }: FrameReconnectionOptions) => void;
|
|
23
|
+
//# sourceMappingURL=useFrameReconnection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFrameReconnection.d.ts","names":[],"sources":["../../src/useFrameReconnection.ts"],"mappings":";qBAKa;;;;;;qBAOA,yBAAsB,2BAEhC;YAKS;EACV;;EAEA;;EAEA;EACA;;;;;;;qBAQW,yBAAoB,gBAAA,gBAAA,aAAA,cAK9B"}
|
package/package.json
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/editor-react",
|
|
3
|
-
"version": "9.7.
|
|
3
|
+
"version": "9.7.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Provides the states, contexts, hooks and components to interact with the Intlayer editor for a React application",
|
|
6
6
|
"keywords": [
|
|
7
|
-
"
|
|
7
|
+
"api",
|
|
8
8
|
"editor",
|
|
9
|
-
"
|
|
9
|
+
"intlayer"
|
|
10
10
|
],
|
|
11
11
|
"homepage": "https://intlayer.org",
|
|
12
12
|
"bugs": {
|
|
13
13
|
"url": "https://github.com/aymericzip/intlayer/issues"
|
|
14
14
|
},
|
|
15
|
-
"repository": {
|
|
16
|
-
"type": "git",
|
|
17
|
-
"url": "git+https://github.com/aymericzip/intlayer.git"
|
|
18
|
-
},
|
|
19
15
|
"license": "Apache-2.0",
|
|
20
16
|
"author": {
|
|
21
17
|
"name": "Aymeric PINEAU",
|
|
@@ -28,15 +24,15 @@
|
|
|
28
24
|
"url": "https://github.com/aymericzip"
|
|
29
25
|
}
|
|
30
26
|
],
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
"types": "./dist/types/index.d.ts",
|
|
35
|
-
"require": "./dist/cjs/index.cjs",
|
|
36
|
-
"import": "./dist/esm/index.mjs"
|
|
37
|
-
},
|
|
38
|
-
"./package.json": "./package.json"
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/aymericzip/intlayer.git"
|
|
39
30
|
},
|
|
31
|
+
"files": [
|
|
32
|
+
"./dist",
|
|
33
|
+
"./package.json"
|
|
34
|
+
],
|
|
35
|
+
"sideEffects": false,
|
|
40
36
|
"main": "dist/cjs/index.cjs",
|
|
41
37
|
"module": "dist/esm/index.mjs",
|
|
42
38
|
"types": "dist/types/index.d.ts",
|
|
@@ -47,19 +43,23 @@
|
|
|
47
43
|
]
|
|
48
44
|
}
|
|
49
45
|
},
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
"exports": {
|
|
47
|
+
".": {
|
|
48
|
+
"types": "./dist/types/index.d.ts",
|
|
49
|
+
"require": "./dist/cjs/index.cjs",
|
|
50
|
+
"import": "./dist/esm/index.mjs"
|
|
51
|
+
},
|
|
52
|
+
"./package.json": "./package.json"
|
|
53
|
+
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build": "bun --bun tsdown --config tsdown.config.ts",
|
|
56
56
|
"build:ci": "bun --bun tsdown --config tsdown.config.ts",
|
|
57
57
|
"clean": "bun --bun rimraf ./dist .turbo",
|
|
58
58
|
"dev": "bun --bun tsdown --config tsdown.config.ts --watch",
|
|
59
|
-
"format": "
|
|
60
|
-
"format:fix": "
|
|
61
|
-
"lint": "
|
|
62
|
-
"lint:fix": "
|
|
59
|
+
"format": "oxfmt --check .",
|
|
60
|
+
"format:fix": "oxfmt .",
|
|
61
|
+
"lint": "oxlint .",
|
|
62
|
+
"lint:fix": "oxlint --fix .",
|
|
63
63
|
"process-files": "ts-node src/transpiler/processFilesCLI.ts --dir $npm_config_dir --extension $npm_config_extension --no-node-snapshot",
|
|
64
64
|
"prepublish": "cp -f ../../../README.md ./README.md",
|
|
65
65
|
"publish": "bun publish || true",
|
|
@@ -71,10 +71,10 @@
|
|
|
71
71
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@intlayer/config": "9.7.
|
|
75
|
-
"@intlayer/core": "9.7.
|
|
76
|
-
"@intlayer/editor": "9.7.
|
|
77
|
-
"@intlayer/types": "9.7.
|
|
74
|
+
"@intlayer/config": "9.7.2",
|
|
75
|
+
"@intlayer/core": "9.7.2",
|
|
76
|
+
"@intlayer/editor": "9.7.2",
|
|
77
|
+
"@intlayer/types": "9.7.2"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@types/node": "^26",
|
|
@@ -85,10 +85,10 @@
|
|
|
85
85
|
"@utils/tsdown-config": "1.0.4",
|
|
86
86
|
"react": ">=16.0.0",
|
|
87
87
|
"react-dom": ">=16.0.0",
|
|
88
|
-
"rimraf": "6.1.
|
|
89
|
-
"tsdown": "0.23.
|
|
88
|
+
"rimraf": "6.1.4",
|
|
89
|
+
"tsdown": "0.23.7",
|
|
90
90
|
"typescript": "7.0.2",
|
|
91
|
-
"vitest": "5.0
|
|
91
|
+
"vitest": "5.1.0"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"react": ">=16.0.0",
|