@intlayer/next-i18next 8.12.5-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +330 -0
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/cjs/appWithTranslation.cjs +31 -0
- package/dist/cjs/appWithTranslation.cjs.map +1 -0
- package/dist/cjs/index.cjs +69 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/compareUrls.cjs +39 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/compareUrls.cjs.map +1 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/ContentSelector.cjs +161 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/ContentSelector.cjs.map +1 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.cjs +269 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.cjs.map +1 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/EditedContent.cjs +161 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/EditedContent.cjs.map +1 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/IntlayerEditorElement.cjs +88 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/IntlayerEditorElement.cjs.map +1 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/defineIntlayerElements.cjs +27 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/components/defineIntlayerElements.cjs.map +1 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/CrossFrameMessenger.cjs +80 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/CrossFrameMessenger.cjs.map +1 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/CrossFrameStateManager.cjs +75 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/CrossFrameStateManager.cjs.map +1 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/EditorStateManager.cjs +383 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/EditorStateManager.cjs.map +1 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/IframeClickInterceptor.cjs +45 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/IframeClickInterceptor.cjs.map +1 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/UrlStateManager.cjs +59 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/UrlStateManager.cjs.map +1 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/editedContentBus.cjs +36 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/editedContentBus.cjs.map +1 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/focusedContentBus.cjs +42 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/focusedContentBus.cjs.map +1 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/globalManager.cjs +82 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/globalManager.cjs.map +1 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/initEditorClient.cjs +55 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/core/initEditorClient.cjs.map +1 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/index.cjs +19 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/isEnabled.cjs +9 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/isEnabled.cjs.map +1 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/mergeIframeClick.cjs +22 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/mergeIframeClick.cjs.map +1 -0
- package/dist/cjs/packages/@intlayer/unmerged-dictionaries-entry/dist/esm/index.cjs +32 -0
- package/dist/cjs/packages/@intlayer/unmerged-dictionaries-entry/dist/esm/index.cjs.map +1 -0
- package/dist/cjs/packages/react-intlayer/dist/esm/client/IntlayerContext.cjs +25 -0
- package/dist/cjs/packages/react-intlayer/dist/esm/client/IntlayerContext.cjs.map +1 -0
- package/dist/cjs/packages/react-intlayer/dist/esm/client/IntlayerProvider.cjs +78 -0
- package/dist/cjs/packages/react-intlayer/dist/esm/client/IntlayerProvider.cjs.map +1 -0
- package/dist/cjs/packages/react-intlayer/dist/esm/client/useLocaleStorage.cjs +24 -0
- package/dist/cjs/packages/react-intlayer/dist/esm/client/useLocaleStorage.cjs.map +1 -0
- package/dist/cjs/packages/react-intlayer/dist/esm/editor/EditorProvider.cjs +11 -0
- package/dist/cjs/packages/react-intlayer/dist/esm/editor/EditorProvider.cjs.map +1 -0
- package/dist/cjs/packages/react-intlayer/dist/esm/editor/useEditor.cjs +39 -0
- package/dist/cjs/packages/react-intlayer/dist/esm/editor/useEditor.cjs.map +1 -0
- package/dist/cjs/plugin/index.cjs +170 -0
- package/dist/cjs/plugin/index.cjs.map +1 -0
- package/dist/cjs/serverSideTranslations.cjs +46 -0
- package/dist/cjs/serverSideTranslations.cjs.map +1 -0
- package/dist/esm/_virtual/_rolldown/runtime.mjs +8 -0
- package/dist/esm/appWithTranslation.mjs +29 -0
- package/dist/esm/appWithTranslation.mjs.map +1 -0
- package/dist/esm/index.mjs +11 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/compareUrls.mjs +38 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/compareUrls.mjs.map +1 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/ContentSelector.mjs +160 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/ContentSelector.mjs.map +1 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.mjs +266 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/ContentSelectorWrapper.mjs.map +1 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/EditedContent.mjs +159 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/EditedContent.mjs.map +1 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/IntlayerEditorElement.mjs +88 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/IntlayerEditorElement.mjs.map +1 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/defineIntlayerElements.mjs +26 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/components/defineIntlayerElements.mjs.map +1 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/CrossFrameMessenger.mjs +80 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/CrossFrameMessenger.mjs.map +1 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/CrossFrameStateManager.mjs +74 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/CrossFrameStateManager.mjs.map +1 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/EditorStateManager.mjs +381 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/EditorStateManager.mjs.map +1 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/IframeClickInterceptor.mjs +45 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/IframeClickInterceptor.mjs.map +1 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/UrlStateManager.mjs +58 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/UrlStateManager.mjs.map +1 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/editedContentBus.mjs +33 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/editedContentBus.mjs.map +1 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/focusedContentBus.mjs +39 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/focusedContentBus.mjs.map +1 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/globalManager.mjs +79 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/globalManager.mjs.map +1 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/initEditorClient.mjs +52 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/core/initEditorClient.mjs.map +1 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/index.mjs +18 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/isEnabled.mjs +8 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/isEnabled.mjs.map +1 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/mergeIframeClick.mjs +21 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/mergeIframeClick.mjs.map +1 -0
- package/dist/esm/packages/@intlayer/unmerged-dictionaries-entry/dist/esm/index.browser.mjs +6 -0
- package/dist/esm/packages/@intlayer/unmerged-dictionaries-entry/dist/esm/index.browser.mjs.map +1 -0
- package/dist/esm/packages/react-intlayer/dist/esm/client/IntlayerContext.mjs +23 -0
- package/dist/esm/packages/react-intlayer/dist/esm/client/IntlayerContext.mjs.map +1 -0
- package/dist/esm/packages/react-intlayer/dist/esm/client/IntlayerProvider.mjs +77 -0
- package/dist/esm/packages/react-intlayer/dist/esm/client/IntlayerProvider.mjs.map +1 -0
- package/dist/esm/packages/react-intlayer/dist/esm/client/useLocaleStorage.mjs +22 -0
- package/dist/esm/packages/react-intlayer/dist/esm/client/useLocaleStorage.mjs.map +1 -0
- package/dist/esm/packages/react-intlayer/dist/esm/editor/EditorProvider.mjs +11 -0
- package/dist/esm/packages/react-intlayer/dist/esm/editor/EditorProvider.mjs.map +1 -0
- package/dist/esm/packages/react-intlayer/dist/esm/editor/useEditor.mjs +38 -0
- package/dist/esm/packages/react-intlayer/dist/esm/editor/useEditor.mjs.map +1 -0
- package/dist/esm/plugin/index.mjs +165 -0
- package/dist/esm/plugin/index.mjs.map +1 -0
- package/dist/esm/serverSideTranslations.mjs +44 -0
- package/dist/esm/serverSideTranslations.mjs.map +1 -0
- package/dist/types/appWithTranslation.d.ts +18 -0
- package/dist/types/appWithTranslation.d.ts.map +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/plugin/index.d.ts +23 -0
- package/dist/types/plugin/index.d.ts.map +1 -0
- package/dist/types/serverSideTranslations.d.ts +33 -0
- package/dist/types/serverSideTranslations.d.ts.map +1 -0
- package/package.json +116 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//#region ../../packages/@intlayer/editor/dist/esm/core/UrlStateManager.mjs
|
|
2
|
+
/**
|
|
3
|
+
* UrlStateManager patches window.history and broadcasts URL path changes
|
|
4
|
+
* across frames via postMessage.
|
|
5
|
+
*
|
|
6
|
+
* Replaces useCrossURLPathSetter / useCrossURLPathState across all frameworks.
|
|
7
|
+
*/
|
|
8
|
+
var UrlStateManager = class {
|
|
9
|
+
_messenger;
|
|
10
|
+
_originalPushState = null;
|
|
11
|
+
_originalReplaceState = null;
|
|
12
|
+
_listeners = [];
|
|
13
|
+
constructor(messenger) {
|
|
14
|
+
this._messenger = messenger;
|
|
15
|
+
}
|
|
16
|
+
start() {
|
|
17
|
+
if (typeof window === "undefined") return;
|
|
18
|
+
const updateURLState = () => {
|
|
19
|
+
this._messenger.send(`INTLAYER_URL_CHANGE/post`, window.location.pathname);
|
|
20
|
+
};
|
|
21
|
+
this._originalPushState = history.pushState;
|
|
22
|
+
this._originalReplaceState = history.replaceState;
|
|
23
|
+
const injectLocationChange = (method) => function(...args) {
|
|
24
|
+
method.apply(this, args);
|
|
25
|
+
window.dispatchEvent(new Event("locationchange"));
|
|
26
|
+
};
|
|
27
|
+
history.pushState = injectLocationChange(this._originalPushState);
|
|
28
|
+
history.replaceState = injectLocationChange(this._originalReplaceState);
|
|
29
|
+
for (const eventName of [
|
|
30
|
+
"locationchange",
|
|
31
|
+
"popstate",
|
|
32
|
+
"hashchange",
|
|
33
|
+
"load"
|
|
34
|
+
]) {
|
|
35
|
+
const listener = updateURLState;
|
|
36
|
+
window.addEventListener(eventName, listener);
|
|
37
|
+
this._listeners.push([eventName, listener]);
|
|
38
|
+
}
|
|
39
|
+
updateURLState();
|
|
40
|
+
}
|
|
41
|
+
stop() {
|
|
42
|
+
if (typeof window === "undefined") return;
|
|
43
|
+
for (const [eventName, listener] of this._listeners) window.removeEventListener(eventName, listener);
|
|
44
|
+
this._listeners = [];
|
|
45
|
+
if (this._originalPushState) {
|
|
46
|
+
history.pushState = this._originalPushState;
|
|
47
|
+
this._originalPushState = null;
|
|
48
|
+
}
|
|
49
|
+
if (this._originalReplaceState) {
|
|
50
|
+
history.replaceState = this._originalReplaceState;
|
|
51
|
+
this._originalReplaceState = null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { UrlStateManager };
|
|
58
|
+
//# sourceMappingURL=UrlStateManager.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UrlStateManager.mjs","names":[],"sources":["../../../../../../../../../../packages/@intlayer/editor/dist/esm/core/UrlStateManager.mjs"],"sourcesContent":["import { MessageKey } from \"../messageKey.mjs\";\n\n//#region src/core/UrlStateManager.ts\n/**\n* UrlStateManager patches window.history and broadcasts URL path changes\n* across frames via postMessage.\n*\n* Replaces useCrossURLPathSetter / useCrossURLPathState across all frameworks.\n*/\nvar UrlStateManager = class {\n\t_messenger;\n\t_originalPushState = null;\n\t_originalReplaceState = null;\n\t_listeners = [];\n\tconstructor(messenger) {\n\t\tthis._messenger = messenger;\n\t}\n\tstart() {\n\t\tif (typeof window === \"undefined\") return;\n\t\tconst updateURLState = () => {\n\t\t\tthis._messenger.send(`${\"INTLAYER_URL_CHANGE\"}/post`, window.location.pathname);\n\t\t};\n\t\tthis._originalPushState = history.pushState;\n\t\tthis._originalReplaceState = history.replaceState;\n\t\tconst injectLocationChange = (method) => function(...args) {\n\t\t\tmethod.apply(this, args);\n\t\t\twindow.dispatchEvent(new Event(\"locationchange\"));\n\t\t};\n\t\thistory.pushState = injectLocationChange(this._originalPushState);\n\t\thistory.replaceState = injectLocationChange(this._originalReplaceState);\n\t\tfor (const eventName of [\n\t\t\t\"locationchange\",\n\t\t\t\"popstate\",\n\t\t\t\"hashchange\",\n\t\t\t\"load\"\n\t\t]) {\n\t\t\tconst listener = updateURLState;\n\t\t\twindow.addEventListener(eventName, listener);\n\t\t\tthis._listeners.push([eventName, listener]);\n\t\t}\n\t\tupdateURLState();\n\t}\n\tstop() {\n\t\tif (typeof window === \"undefined\") return;\n\t\tfor (const [eventName, listener] of this._listeners) window.removeEventListener(eventName, listener);\n\t\tthis._listeners = [];\n\t\tif (this._originalPushState) {\n\t\t\thistory.pushState = this._originalPushState;\n\t\t\tthis._originalPushState = null;\n\t\t}\n\t\tif (this._originalReplaceState) {\n\t\t\thistory.replaceState = this._originalReplaceState;\n\t\t\tthis._originalReplaceState = null;\n\t\t}\n\t}\n};\n\n//#endregion\nexport { UrlStateManager };\n//# sourceMappingURL=UrlStateManager.mjs.map"],"mappings":";;;;;;;AASA,IAAI,kBAAkB,MAAM;CAC3B;CACA,qBAAqB;CACrB,wBAAwB;CACxB,aAAa,EAAE;CACf,YAAY,WAAW;AACtB,OAAK,aAAa;;CAEnB,QAAQ;AACP,MAAI,OAAO,WAAW,YAAa;EACnC,MAAM,uBAAuB;AAC5B,QAAK,WAAW,KAAK,4BAAiC,OAAO,SAAS,SAAS;;AAEhF,OAAK,qBAAqB,QAAQ;AAClC,OAAK,wBAAwB,QAAQ;EACrC,MAAM,wBAAwB,WAAW,SAAS,GAAG,MAAM;AAC1D,UAAO,MAAM,MAAM,KAAK;AACxB,UAAO,cAAc,IAAI,MAAM,iBAAiB,CAAC;;AAElD,UAAQ,YAAY,qBAAqB,KAAK,mBAAmB;AACjE,UAAQ,eAAe,qBAAqB,KAAK,sBAAsB;AACvE,OAAK,MAAM,aAAa;GACvB;GACA;GACA;GACA;GACA,EAAE;GACF,MAAM,WAAW;AACjB,UAAO,iBAAiB,WAAW,SAAS;AAC5C,QAAK,WAAW,KAAK,CAAC,WAAW,SAAS,CAAC;;AAE5C,kBAAgB;;CAEjB,OAAO;AACN,MAAI,OAAO,WAAW,YAAa;AACnC,OAAK,MAAM,CAAC,WAAW,aAAa,KAAK,WAAY,QAAO,oBAAoB,WAAW,SAAS;AACpG,OAAK,aAAa,EAAE;AACpB,MAAI,KAAK,oBAAoB;AAC5B,WAAQ,YAAY,KAAK;AACzB,QAAK,qBAAqB;;AAE3B,MAAI,KAAK,uBAAuB;AAC/B,WAAQ,eAAe,KAAK;AAC5B,QAAK,wBAAwB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region ../../packages/@intlayer/editor/dist/esm/core/editedContentBus.mjs
|
|
2
|
+
const BUS_KEY = "__intlayer_edited_content_bus__";
|
|
3
|
+
const BUS_EVENTS_KEY = "__intlayer_edited_content_bus_events__";
|
|
4
|
+
const getBusTarget = () => {
|
|
5
|
+
if (typeof window === "undefined") return new EventTarget();
|
|
6
|
+
const w = window;
|
|
7
|
+
if (!w[BUS_EVENTS_KEY]) w[BUS_EVENTS_KEY] = new EventTarget();
|
|
8
|
+
return w[BUS_EVENTS_KEY];
|
|
9
|
+
};
|
|
10
|
+
const getGlobalEditedContent = () => {
|
|
11
|
+
if (typeof window === "undefined") return {};
|
|
12
|
+
return window[BUS_KEY] ?? {};
|
|
13
|
+
};
|
|
14
|
+
const setGlobalEditedContent = (content, sourceId) => {
|
|
15
|
+
if (typeof window !== "undefined") window[BUS_KEY] = content;
|
|
16
|
+
getBusTarget().dispatchEvent(new CustomEvent("change", { detail: {
|
|
17
|
+
content,
|
|
18
|
+
sourceId
|
|
19
|
+
} }));
|
|
20
|
+
};
|
|
21
|
+
const subscribeToGlobalEditedContent = (cb) => {
|
|
22
|
+
const handler = (e) => {
|
|
23
|
+
const { content, sourceId } = e.detail;
|
|
24
|
+
cb(content, sourceId);
|
|
25
|
+
};
|
|
26
|
+
const target = getBusTarget();
|
|
27
|
+
target.addEventListener("change", handler);
|
|
28
|
+
return () => target.removeEventListener("change", handler);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { getGlobalEditedContent, setGlobalEditedContent, subscribeToGlobalEditedContent };
|
|
33
|
+
//# sourceMappingURL=editedContentBus.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editedContentBus.mjs","names":[],"sources":["../../../../../../../../../../packages/@intlayer/editor/dist/esm/core/editedContentBus.mjs"],"sourcesContent":["//#region src/core/editedContentBus.ts\nconst BUS_KEY = \"__intlayer_edited_content_bus__\";\nconst BUS_EVENTS_KEY = \"__intlayer_edited_content_bus_events__\";\nconst getBusTarget = () => {\n\tif (typeof window === \"undefined\") return new EventTarget();\n\tconst w = window;\n\tif (!w[BUS_EVENTS_KEY]) w[BUS_EVENTS_KEY] = new EventTarget();\n\treturn w[BUS_EVENTS_KEY];\n};\nconst getGlobalEditedContent = () => {\n\tif (typeof window === \"undefined\") return {};\n\treturn window[BUS_KEY] ?? {};\n};\nconst setGlobalEditedContent = (content, sourceId) => {\n\tif (typeof window !== \"undefined\") window[BUS_KEY] = content;\n\tgetBusTarget().dispatchEvent(new CustomEvent(\"change\", { detail: {\n\t\tcontent,\n\t\tsourceId\n\t} }));\n};\nconst subscribeToGlobalEditedContent = (cb) => {\n\tconst handler = (e) => {\n\t\tconst { content, sourceId } = e.detail;\n\t\tcb(content, sourceId);\n\t};\n\tconst target = getBusTarget();\n\ttarget.addEventListener(\"change\", handler);\n\treturn () => target.removeEventListener(\"change\", handler);\n};\n\n//#endregion\nexport { getGlobalEditedContent, setGlobalEditedContent, subscribeToGlobalEditedContent };\n//# sourceMappingURL=editedContentBus.mjs.map"],"mappings":";AACA,MAAM,UAAU;AAChB,MAAM,iBAAiB;AACvB,MAAM,qBAAqB;AAC1B,KAAI,OAAO,WAAW,YAAa,QAAO,IAAI,aAAa;CAC3D,MAAM,IAAI;AACV,KAAI,CAAC,EAAE,gBAAiB,GAAE,kBAAkB,IAAI,aAAa;AAC7D,QAAO,EAAE;;AAEV,MAAM,+BAA+B;AACpC,KAAI,OAAO,WAAW,YAAa,QAAO,EAAE;AAC5C,QAAO,OAAO,YAAY,EAAE;;AAE7B,MAAM,0BAA0B,SAAS,aAAa;AACrD,KAAI,OAAO,WAAW,YAAa,QAAO,WAAW;AACrD,eAAc,CAAC,cAAc,IAAI,YAAY,UAAU,EAAE,QAAQ;EAChE;EACA;EACA,EAAE,CAAC,CAAC;;AAEN,MAAM,kCAAkC,OAAO;CAC9C,MAAM,WAAW,MAAM;EACtB,MAAM,EAAE,SAAS,aAAa,EAAE;AAChC,KAAG,SAAS,SAAS;;CAEtB,MAAM,SAAS,cAAc;AAC7B,QAAO,iBAAiB,UAAU,QAAQ;AAC1C,cAAa,OAAO,oBAAoB,UAAU,QAAQ"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//#region ../../packages/@intlayer/editor/dist/esm/core/focusedContentBus.mjs
|
|
2
|
+
const BUS_KEY = "__intlayer_focused_content_bus__";
|
|
3
|
+
const BUS_EVENTS_KEY = "__intlayer_focused_content_bus_events__";
|
|
4
|
+
const getBusTarget = () => {
|
|
5
|
+
if (typeof window === "undefined") return new EventTarget();
|
|
6
|
+
const w = window;
|
|
7
|
+
if (!w[BUS_EVENTS_KEY]) w[BUS_EVENTS_KEY] = new EventTarget();
|
|
8
|
+
return w[BUS_EVENTS_KEY];
|
|
9
|
+
};
|
|
10
|
+
const getGlobalFocusedContent = () => {
|
|
11
|
+
if (typeof window === "undefined") return void 0;
|
|
12
|
+
const w = window;
|
|
13
|
+
if (!w.__intlayer_focused_content_bus_set__) return void 0;
|
|
14
|
+
return w[BUS_KEY] ?? null;
|
|
15
|
+
};
|
|
16
|
+
const setGlobalFocusedContent = (content, sourceId) => {
|
|
17
|
+
if (typeof window !== "undefined") {
|
|
18
|
+
const w = window;
|
|
19
|
+
w[BUS_KEY] = content;
|
|
20
|
+
w.__intlayer_focused_content_bus_set__ = true;
|
|
21
|
+
}
|
|
22
|
+
getBusTarget().dispatchEvent(new CustomEvent("change", { detail: {
|
|
23
|
+
content,
|
|
24
|
+
sourceId
|
|
25
|
+
} }));
|
|
26
|
+
};
|
|
27
|
+
const subscribeToGlobalFocusedContent = (cb) => {
|
|
28
|
+
const handler = (e) => {
|
|
29
|
+
const { content, sourceId } = e.detail;
|
|
30
|
+
cb(content, sourceId);
|
|
31
|
+
};
|
|
32
|
+
const target = getBusTarget();
|
|
33
|
+
target.addEventListener("change", handler);
|
|
34
|
+
return () => target.removeEventListener("change", handler);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { getGlobalFocusedContent, setGlobalFocusedContent, subscribeToGlobalFocusedContent };
|
|
39
|
+
//# sourceMappingURL=focusedContentBus.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focusedContentBus.mjs","names":[],"sources":["../../../../../../../../../../packages/@intlayer/editor/dist/esm/core/focusedContentBus.mjs"],"sourcesContent":["//#region src/core/focusedContentBus.ts\nconst BUS_KEY = \"__intlayer_focused_content_bus__\";\nconst BUS_EVENTS_KEY = \"__intlayer_focused_content_bus_events__\";\nconst getBusTarget = () => {\n\tif (typeof window === \"undefined\") return new EventTarget();\n\tconst w = window;\n\tif (!w[BUS_EVENTS_KEY]) w[BUS_EVENTS_KEY] = new EventTarget();\n\treturn w[BUS_EVENTS_KEY];\n};\nconst getGlobalFocusedContent = () => {\n\tif (typeof window === \"undefined\") return void 0;\n\tconst w = window;\n\tif (!w.__intlayer_focused_content_bus_set__) return void 0;\n\treturn w[BUS_KEY] ?? null;\n};\nconst setGlobalFocusedContent = (content, sourceId) => {\n\tif (typeof window !== \"undefined\") {\n\t\tconst w = window;\n\t\tw[BUS_KEY] = content;\n\t\tw.__intlayer_focused_content_bus_set__ = true;\n\t}\n\tgetBusTarget().dispatchEvent(new CustomEvent(\"change\", { detail: {\n\t\tcontent,\n\t\tsourceId\n\t} }));\n};\nconst subscribeToGlobalFocusedContent = (cb) => {\n\tconst handler = (e) => {\n\t\tconst { content, sourceId } = e.detail;\n\t\tcb(content, sourceId);\n\t};\n\tconst target = getBusTarget();\n\ttarget.addEventListener(\"change\", handler);\n\treturn () => target.removeEventListener(\"change\", handler);\n};\n\n//#endregion\nexport { getGlobalFocusedContent, setGlobalFocusedContent, subscribeToGlobalFocusedContent };\n//# sourceMappingURL=focusedContentBus.mjs.map"],"mappings":";AACA,MAAM,UAAU;AAChB,MAAM,iBAAiB;AACvB,MAAM,qBAAqB;AAC1B,KAAI,OAAO,WAAW,YAAa,QAAO,IAAI,aAAa;CAC3D,MAAM,IAAI;AACV,KAAI,CAAC,EAAE,gBAAiB,GAAE,kBAAkB,IAAI,aAAa;AAC7D,QAAO,EAAE;;AAEV,MAAM,gCAAgC;AACrC,KAAI,OAAO,WAAW,YAAa,QAAO,KAAK;CAC/C,MAAM,IAAI;AACV,KAAI,CAAC,EAAE,qCAAsC,QAAO,KAAK;AACzD,QAAO,EAAE,YAAY;;AAEtB,MAAM,2BAA2B,SAAS,aAAa;AACtD,KAAI,OAAO,WAAW,aAAa;EAClC,MAAM,IAAI;AACV,IAAE,WAAW;AACb,IAAE,uCAAuC;;AAE1C,eAAc,CAAC,cAAc,IAAI,YAAY,UAAU,EAAE,QAAQ;EAChE;EACA;EACA,EAAE,CAAC,CAAC;;AAEN,MAAM,mCAAmC,OAAO;CAC/C,MAAM,WAAW,MAAM;EACtB,MAAM,EAAE,SAAS,aAAa,EAAE;AAChC,KAAG,SAAS,SAAS;;CAEtB,MAAM,SAAS,cAAc;AAC7B,QAAO,iBAAiB,UAAU,QAAQ;AAC1C,cAAa,OAAO,oBAAoB,UAAU,QAAQ"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
//#region ../../packages/@intlayer/editor/dist/esm/core/globalManager.mjs
|
|
2
|
+
/**
|
|
3
|
+
* Keys on window used to share the singleton across multiple module instances.
|
|
4
|
+
* When bundlers include @intlayer/editor more than once (e.g. framework package +
|
|
5
|
+
* app), each copy has its own module-level variables. Using window ensures they
|
|
6
|
+
* all read/write the same manager and event-target.
|
|
7
|
+
*/
|
|
8
|
+
const MANAGER_KEY = "__intlayer_editor_manager__";
|
|
9
|
+
const EVENTS_KEY = "__intlayer_editor_manager_events__";
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves or creates a shared EventTarget for global editor manager events.
|
|
12
|
+
* In browser environments, stores the EventTarget on window to ensure sharing
|
|
13
|
+
* across multiple module instances. In SSR environments, creates a fresh
|
|
14
|
+
* EventTarget (no sharing needed on server-side).
|
|
15
|
+
*
|
|
16
|
+
* @returns The shared EventTarget instance for dispatching manager change events
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
const getEventTarget = () => {
|
|
20
|
+
if (typeof window === "undefined") return new EventTarget();
|
|
21
|
+
const windowGlobals = window;
|
|
22
|
+
if (!windowGlobals[EVENTS_KEY]) windowGlobals[EVENTS_KEY] = new EventTarget();
|
|
23
|
+
return windowGlobals[EVENTS_KEY];
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Retrieves the global editor state manager instance.
|
|
27
|
+
* Returns null if no manager has been set or in SSR environments where
|
|
28
|
+
* window is undefined.
|
|
29
|
+
*
|
|
30
|
+
* @returns The global EditorStateManager instance or null if not set
|
|
31
|
+
*/
|
|
32
|
+
const getGlobalEditorManager = () => {
|
|
33
|
+
if (typeof window === "undefined") return null;
|
|
34
|
+
return window[MANAGER_KEY] ?? null;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Sets the global editor state manager instance and notifies all listeners
|
|
38
|
+
* of the change through a CustomEvent.
|
|
39
|
+
*
|
|
40
|
+
* @param manager - The EditorStateManager instance to set globally, or null to clear it
|
|
41
|
+
*/
|
|
42
|
+
const setGlobalEditorManager = (manager) => {
|
|
43
|
+
if (typeof window !== "undefined") {
|
|
44
|
+
const windowGlobals = window;
|
|
45
|
+
windowGlobals[MANAGER_KEY] = manager;
|
|
46
|
+
}
|
|
47
|
+
getEventTarget().dispatchEvent(new CustomEvent("change", { detail: manager }));
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Registers a callback function to be invoked whenever the global editor
|
|
51
|
+
* manager changes. Useful for reactive updates across the application.
|
|
52
|
+
*
|
|
53
|
+
* @param changeCallback - Function to invoke with the new manager state whenever it changes
|
|
54
|
+
* @returns An unsubscribe function that removes the listener when called
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* const unsubscribe = onGlobalEditorManagerChange((manager) => {
|
|
59
|
+
* console.log('Manager updated:', manager);
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
62
|
+
* // Later, clean up the listener
|
|
63
|
+
* unsubscribe();
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
const onGlobalEditorManagerChange = (changeCallback) => {
|
|
67
|
+
const eventTarget = getEventTarget();
|
|
68
|
+
const eventHandler = (event) => {
|
|
69
|
+
changeCallback(event.detail);
|
|
70
|
+
};
|
|
71
|
+
eventTarget.addEventListener("change", eventHandler);
|
|
72
|
+
return () => {
|
|
73
|
+
eventTarget.removeEventListener("change", eventHandler);
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
//#endregion
|
|
78
|
+
export { getGlobalEditorManager, onGlobalEditorManagerChange, setGlobalEditorManager };
|
|
79
|
+
//# sourceMappingURL=globalManager.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"globalManager.mjs","names":[],"sources":["../../../../../../../../../../packages/@intlayer/editor/dist/esm/core/globalManager.mjs"],"sourcesContent":["//#region src/core/globalManager.ts\n/**\n* Keys on window used to share the singleton across multiple module instances.\n* When bundlers include @intlayer/editor more than once (e.g. framework package +\n* app), each copy has its own module-level variables. Using window ensures they\n* all read/write the same manager and event-target.\n*/\nconst MANAGER_KEY = \"__intlayer_editor_manager__\";\nconst EVENTS_KEY = \"__intlayer_editor_manager_events__\";\n/**\n* Retrieves or creates a shared EventTarget for global editor manager events.\n* In browser environments, stores the EventTarget on window to ensure sharing\n* across multiple module instances. In SSR environments, creates a fresh\n* EventTarget (no sharing needed on server-side).\n*\n* @returns The shared EventTarget instance for dispatching manager change events\n* @private\n*/\nconst getEventTarget = () => {\n\tif (typeof window === \"undefined\") return new EventTarget();\n\tconst windowGlobals = window;\n\tif (!windowGlobals[EVENTS_KEY]) windowGlobals[EVENTS_KEY] = new EventTarget();\n\treturn windowGlobals[EVENTS_KEY];\n};\n/**\n* Retrieves the global editor state manager instance.\n* Returns null if no manager has been set or in SSR environments where\n* window is undefined.\n*\n* @returns The global EditorStateManager instance or null if not set\n*/\nconst getGlobalEditorManager = () => {\n\tif (typeof window === \"undefined\") return null;\n\treturn window[MANAGER_KEY] ?? null;\n};\n/**\n* Sets the global editor state manager instance and notifies all listeners\n* of the change through a CustomEvent.\n*\n* @param manager - The EditorStateManager instance to set globally, or null to clear it\n*/\nconst setGlobalEditorManager = (manager) => {\n\tif (typeof window !== \"undefined\") {\n\t\tconst windowGlobals = window;\n\t\twindowGlobals[MANAGER_KEY] = manager;\n\t}\n\tgetEventTarget().dispatchEvent(new CustomEvent(\"change\", { detail: manager }));\n};\n/**\n* Registers a callback function to be invoked whenever the global editor\n* manager changes. Useful for reactive updates across the application.\n*\n* @param changeCallback - Function to invoke with the new manager state whenever it changes\n* @returns An unsubscribe function that removes the listener when called\n*\n* @example\n* ```typescript\n* const unsubscribe = onGlobalEditorManagerChange((manager) => {\n* console.log('Manager updated:', manager);\n* });\n*\n* // Later, clean up the listener\n* unsubscribe();\n* ```\n*/\nconst onGlobalEditorManagerChange = (changeCallback) => {\n\tconst eventTarget = getEventTarget();\n\tconst eventHandler = (event) => {\n\t\tchangeCallback(event.detail);\n\t};\n\teventTarget.addEventListener(\"change\", eventHandler);\n\treturn () => {\n\t\teventTarget.removeEventListener(\"change\", eventHandler);\n\t};\n};\n\n//#endregion\nexport { getGlobalEditorManager, onGlobalEditorManagerChange, setGlobalEditorManager };\n//# sourceMappingURL=globalManager.mjs.map"],"mappings":";;;;;;;AAOA,MAAM,cAAc;AACpB,MAAM,aAAa;;;;;;;;;;AAUnB,MAAM,uBAAuB;AAC5B,KAAI,OAAO,WAAW,YAAa,QAAO,IAAI,aAAa;CAC3D,MAAM,gBAAgB;AACtB,KAAI,CAAC,cAAc,YAAa,eAAc,cAAc,IAAI,aAAa;AAC7E,QAAO,cAAc;;;;;;;;;AAStB,MAAM,+BAA+B;AACpC,KAAI,OAAO,WAAW,YAAa,QAAO;AAC1C,QAAO,OAAO,gBAAgB;;;;;;;;AAQ/B,MAAM,0BAA0B,YAAY;AAC3C,KAAI,OAAO,WAAW,aAAa;EAClC,MAAM,gBAAgB;AACtB,gBAAc,eAAe;;AAE9B,iBAAgB,CAAC,cAAc,IAAI,YAAY,UAAU,EAAE,QAAQ,SAAS,CAAC,CAAC;;;;;;;;;;;;;;;;;;;AAmB/E,MAAM,+BAA+B,mBAAmB;CACvD,MAAM,cAAc,gBAAgB;CACpC,MAAM,gBAAgB,UAAU;AAC/B,iBAAe,MAAM,OAAO;;AAE7B,aAAY,iBAAiB,UAAU,aAAa;AACpD,cAAa;AACZ,cAAY,oBAAoB,UAAU,aAAa"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { getGlobalEditorManager, setGlobalEditorManager } from "./globalManager.mjs";
|
|
2
|
+
import { EditorStateManager } from "./EditorStateManager.mjs";
|
|
3
|
+
import { defineIntlayerElements } from "../components/defineIntlayerElements.mjs";
|
|
4
|
+
import { editor } from "@intlayer/config/built";
|
|
5
|
+
|
|
6
|
+
//#region ../../packages/@intlayer/editor/dist/esm/core/initEditorClient.mjs
|
|
7
|
+
const buildClientMessengerConfig = () => {
|
|
8
|
+
return {
|
|
9
|
+
allowedOrigins: [editor?.editorURL, editor?.cmsURL].filter(Boolean),
|
|
10
|
+
postMessageFn: (payload, origin) => {
|
|
11
|
+
if (typeof window === "undefined") return;
|
|
12
|
+
if (!(window.self !== window.top)) return;
|
|
13
|
+
window.parent?.postMessage(payload, origin);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
/** Reference count — tracks how many providers have called initEditorClient. */
|
|
18
|
+
let _clientRefCount = 0;
|
|
19
|
+
/**
|
|
20
|
+
* Initialize the Intlayer editor client singleton.
|
|
21
|
+
* Safe to call multiple times — returns the existing manager if already initialized.
|
|
22
|
+
* Increments a reference counter so nested providers don't destroy the manager
|
|
23
|
+
* prematurely when the inner provider unmounts.
|
|
24
|
+
*/
|
|
25
|
+
const initEditorClient = () => {
|
|
26
|
+
_clientRefCount++;
|
|
27
|
+
const existing = getGlobalEditorManager();
|
|
28
|
+
if (existing) return existing;
|
|
29
|
+
const manager = new EditorStateManager({
|
|
30
|
+
mode: "client",
|
|
31
|
+
messenger: buildClientMessengerConfig(),
|
|
32
|
+
configuration: { editor }
|
|
33
|
+
});
|
|
34
|
+
setGlobalEditorManager(manager);
|
|
35
|
+
defineIntlayerElements();
|
|
36
|
+
manager.start();
|
|
37
|
+
return manager;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Decrement the reference count and stop the global editor client singleton
|
|
41
|
+
* only when the last provider unmounts.
|
|
42
|
+
*/
|
|
43
|
+
const stopEditorClient = () => {
|
|
44
|
+
_clientRefCount = Math.max(0, _clientRefCount - 1);
|
|
45
|
+
if (_clientRefCount > 0) return;
|
|
46
|
+
getGlobalEditorManager()?.stop();
|
|
47
|
+
setGlobalEditorManager(null);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
export { buildClientMessengerConfig, initEditorClient, stopEditorClient };
|
|
52
|
+
//# sourceMappingURL=initEditorClient.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initEditorClient.mjs","names":[],"sources":["../../../../../../../../../../packages/@intlayer/editor/dist/esm/core/initEditorClient.mjs"],"sourcesContent":["import { getGlobalEditorManager, setGlobalEditorManager } from \"./globalManager.mjs\";\nimport { EditorStateManager } from \"./EditorStateManager.mjs\";\nimport { defineIntlayerElements } from \"../components/defineIntlayerElements.mjs\";\nimport { editor } from \"@intlayer/config/built\";\n\n//#region src/core/initEditorClient.ts\nconst buildClientMessengerConfig = () => {\n\treturn {\n\t\tallowedOrigins: [editor?.editorURL, editor?.cmsURL].filter(Boolean),\n\t\tpostMessageFn: (payload, origin) => {\n\t\t\tif (typeof window === \"undefined\") return;\n\t\t\tif (!(window.self !== window.top)) return;\n\t\t\twindow.parent?.postMessage(payload, origin);\n\t\t}\n\t};\n};\n/** Reference count — tracks how many providers have called initEditorClient. */\nlet _clientRefCount = 0;\n/**\n* Initialize the Intlayer editor client singleton.\n* Safe to call multiple times — returns the existing manager if already initialized.\n* Increments a reference counter so nested providers don't destroy the manager\n* prematurely when the inner provider unmounts.\n*/\nconst initEditorClient = () => {\n\t_clientRefCount++;\n\tconst existing = getGlobalEditorManager();\n\tif (existing) return existing;\n\tconst manager = new EditorStateManager({\n\t\tmode: \"client\",\n\t\tmessenger: buildClientMessengerConfig(),\n\t\tconfiguration: { editor }\n\t});\n\tsetGlobalEditorManager(manager);\n\tdefineIntlayerElements();\n\tmanager.start();\n\treturn manager;\n};\n/**\n* Decrement the reference count and stop the global editor client singleton\n* only when the last provider unmounts.\n*/\nconst stopEditorClient = () => {\n\t_clientRefCount = Math.max(0, _clientRefCount - 1);\n\tif (_clientRefCount > 0) return;\n\tgetGlobalEditorManager()?.stop();\n\tsetGlobalEditorManager(null);\n};\n\n//#endregion\nexport { buildClientMessengerConfig, initEditorClient, stopEditorClient };\n//# sourceMappingURL=initEditorClient.mjs.map"],"mappings":";;;;;;AAMA,MAAM,mCAAmC;AACxC,QAAO;EACN,gBAAgB,CAAC,QAAQ,WAAW,QAAQ,OAAO,CAAC,OAAO,QAAQ;EACnE,gBAAgB,SAAS,WAAW;AACnC,OAAI,OAAO,WAAW,YAAa;AACnC,OAAI,EAAE,OAAO,SAAS,OAAO,KAAM;AACnC,UAAO,QAAQ,YAAY,SAAS,OAAO;;EAE5C;;;AAGF,IAAI,kBAAkB;;;;;;;AAOtB,MAAM,yBAAyB;AAC9B;CACA,MAAM,WAAW,wBAAwB;AACzC,KAAI,SAAU,QAAO;CACrB,MAAM,UAAU,IAAI,mBAAmB;EACtC,MAAM;EACN,WAAW,4BAA4B;EACvC,eAAe,EAAE,QAAQ;EACzB,CAAC;AACF,wBAAuB,QAAQ;AAC/B,yBAAwB;AACxB,SAAQ,OAAO;AACf,QAAO;;;;;;AAMR,MAAM,yBAAyB;AAC9B,mBAAkB,KAAK,IAAI,GAAG,kBAAkB,EAAE;AAClD,KAAI,kBAAkB,EAAG;AACzB,yBAAwB,EAAE,MAAM;AAChC,wBAAuB,KAAK"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { compareUrls } from "./compareUrls.mjs";
|
|
2
|
+
import { mergeIframeClick } from "./mergeIframeClick.mjs";
|
|
3
|
+
import { IntlayerContentSelectorElement } from "./components/ContentSelector.mjs";
|
|
4
|
+
import { getGlobalEditorManager, onGlobalEditorManagerChange, setGlobalEditorManager } from "./core/globalManager.mjs";
|
|
5
|
+
import { IntlayerContentSelectorWrapperElement, defineIntlayerContentSelectorWrapper } from "./components/ContentSelectorWrapper.mjs";
|
|
6
|
+
import { IntlayerEditedContentElement, defineIntlayerEditedContent } from "./components/EditedContent.mjs";
|
|
7
|
+
import { CrossFrameMessenger } from "./core/CrossFrameMessenger.mjs";
|
|
8
|
+
import { CrossFrameStateManager } from "./core/CrossFrameStateManager.mjs";
|
|
9
|
+
import { getGlobalEditedContent, setGlobalEditedContent, subscribeToGlobalEditedContent } from "./core/editedContentBus.mjs";
|
|
10
|
+
import { getGlobalFocusedContent, setGlobalFocusedContent, subscribeToGlobalFocusedContent } from "./core/focusedContentBus.mjs";
|
|
11
|
+
import { IframeClickInterceptor } from "./core/IframeClickInterceptor.mjs";
|
|
12
|
+
import { UrlStateManager } from "./core/UrlStateManager.mjs";
|
|
13
|
+
import { EditorStateManager } from "./core/EditorStateManager.mjs";
|
|
14
|
+
import { IntlayerEditorElement } from "./components/IntlayerEditorElement.mjs";
|
|
15
|
+
import { defineIntlayerEditorElement, defineIntlayerElements } from "./components/defineIntlayerElements.mjs";
|
|
16
|
+
import { buildClientMessengerConfig, initEditorClient, stopEditorClient } from "./core/initEditorClient.mjs";
|
|
17
|
+
|
|
18
|
+
export { initEditorClient, stopEditorClient };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { editor } from "@intlayer/config/built";
|
|
2
|
+
|
|
3
|
+
//#region ../../packages/@intlayer/editor/dist/esm/isEnabled.mjs
|
|
4
|
+
const isEnabled = !(process.env["INTLAYER_EDITOR_ENABLED"] === "false") && editor?.enabled && typeof window !== "undefined" && window.self !== window.top;
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
export { isEnabled };
|
|
8
|
+
//# sourceMappingURL=isEnabled.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isEnabled.mjs","names":[],"sources":["../../../../../../../../../packages/@intlayer/editor/dist/esm/isEnabled.mjs"],"sourcesContent":["import { editor } from \"@intlayer/config/built\";\n\n//#region src/isEnabled.ts\nconst TREE_SHAKE_EDITOR = process.env[\"INTLAYER_EDITOR_ENABLED\"] === \"false\";\nconst isEnabled = !TREE_SHAKE_EDITOR && editor?.enabled && typeof window !== \"undefined\" && window.self !== window.top;\n\n//#endregion\nexport { isEnabled };\n//# sourceMappingURL=isEnabled.mjs.map"],"mappings":";;;AAIA,MAAM,YAAY,EADQ,QAAQ,IAAI,+BAA+B,YAC7B,QAAQ,WAAW,OAAO,WAAW,eAAe,OAAO,SAAS,OAAO"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region ../../packages/@intlayer/editor/dist/esm/mergeIframeClick.mjs
|
|
2
|
+
const mergeIframeClick = (event) => {
|
|
3
|
+
const simulatedMouseDownEvent = new MouseEvent("mousedown", {
|
|
4
|
+
bubbles: true,
|
|
5
|
+
cancelable: true,
|
|
6
|
+
view: window
|
|
7
|
+
});
|
|
8
|
+
const simulatedClickEvent = new MouseEvent("click", {
|
|
9
|
+
bubbles: true,
|
|
10
|
+
cancelable: true,
|
|
11
|
+
view: window
|
|
12
|
+
});
|
|
13
|
+
Object.assign(simulatedClickEvent, { iframeData: event });
|
|
14
|
+
Object.assign(simulatedMouseDownEvent, { iframeData: event });
|
|
15
|
+
window.dispatchEvent(simulatedClickEvent);
|
|
16
|
+
window.dispatchEvent(simulatedMouseDownEvent);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { mergeIframeClick };
|
|
21
|
+
//# sourceMappingURL=mergeIframeClick.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeIframeClick.mjs","names":[],"sources":["../../../../../../../../../packages/@intlayer/editor/dist/esm/mergeIframeClick.mjs"],"sourcesContent":["//#region src/mergeIframeClick.ts\nconst mergeIframeClick = (event) => {\n\tconst simulatedMouseDownEvent = new MouseEvent(\"mousedown\", {\n\t\tbubbles: true,\n\t\tcancelable: true,\n\t\tview: window\n\t});\n\tconst simulatedClickEvent = new MouseEvent(\"click\", {\n\t\tbubbles: true,\n\t\tcancelable: true,\n\t\tview: window\n\t});\n\tObject.assign(simulatedClickEvent, { iframeData: event });\n\tObject.assign(simulatedMouseDownEvent, { iframeData: event });\n\twindow.dispatchEvent(simulatedClickEvent);\n\twindow.dispatchEvent(simulatedMouseDownEvent);\n};\n\n//#endregion\nexport { mergeIframeClick };\n//# sourceMappingURL=mergeIframeClick.mjs.map"],"mappings":";AACA,MAAM,oBAAoB,UAAU;CACnC,MAAM,0BAA0B,IAAI,WAAW,aAAa;EAC3D,SAAS;EACT,YAAY;EACZ,MAAM;EACN,CAAC;CACF,MAAM,sBAAsB,IAAI,WAAW,SAAS;EACnD,SAAS;EACT,YAAY;EACZ,MAAM;EACN,CAAC;AACF,QAAO,OAAO,qBAAqB,EAAE,YAAY,OAAO,CAAC;AACzD,QAAO,OAAO,yBAAyB,EAAE,YAAY,OAAO,CAAC;AAC7D,QAAO,cAAc,oBAAoB;AACzC,QAAO,cAAc,wBAAwB"}
|
package/dist/esm/packages/@intlayer/unmerged-dictionaries-entry/dist/esm/index.browser.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.browser.mjs","names":[],"sources":["../../../../../../../../../packages/@intlayer/unmerged-dictionaries-entry/dist/esm/index.browser.mjs"],"sourcesContent":["//#region src/index.browser.ts\nconst getUnmergedDictionaries = () => ({});\n\n//#endregion\nexport { getUnmergedDictionaries };\n//# sourceMappingURL=index.browser.mjs.map"],"mappings":";AACA,MAAM,iCAAiC,EAAE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { localeInStorage } from "./useLocaleStorage.mjs";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
import { internationalization } from "@intlayer/config/built";
|
|
4
|
+
|
|
5
|
+
//#region ../../packages/react-intlayer/dist/esm/client/IntlayerContext.mjs
|
|
6
|
+
/**
|
|
7
|
+
* Context that stores the current locale on the client side.
|
|
8
|
+
*/
|
|
9
|
+
const IntlayerClientContext = createContext({
|
|
10
|
+
locale: localeInStorage ?? internationalization?.defaultLocale,
|
|
11
|
+
setLocale: () => null,
|
|
12
|
+
isCookieEnabled: true
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Hook that provides the current Intlayer client context.
|
|
16
|
+
*
|
|
17
|
+
* @returns The current Intlayer context values.
|
|
18
|
+
*/
|
|
19
|
+
const useIntlayerContext = () => useContext(IntlayerClientContext) ?? {};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { IntlayerClientContext, useIntlayerContext };
|
|
23
|
+
//# sourceMappingURL=IntlayerContext.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntlayerContext.mjs","names":[],"sources":["../../../../../../../../../packages/react-intlayer/dist/esm/client/IntlayerContext.mjs"],"sourcesContent":["import { localeInStorage } from \"./useLocaleStorage.mjs\";\nimport { internationalization } from \"@intlayer/config/built\";\nimport { createContext, useContext } from \"react\";\n\n//#region src/client/IntlayerContext.tsx\n/**\n* Context that stores the current locale on the client side.\n*/\nconst IntlayerClientContext = createContext({\n\tlocale: localeInStorage ?? internationalization?.defaultLocale,\n\tsetLocale: () => null,\n\tisCookieEnabled: true\n});\n/**\n* Hook that provides the current Intlayer client context.\n*\n* @returns The current Intlayer context values.\n*/\nconst useIntlayerContext = () => useContext(IntlayerClientContext) ?? {};\n\n//#endregion\nexport { IntlayerClientContext, useIntlayerContext };\n//# sourceMappingURL=IntlayerContext.mjs.map"],"mappings":";;;;;;;;AAQA,MAAM,wBAAwB,cAAc;CAC3C,QAAQ,mBAAmB,sBAAsB;CACjD,iBAAiB;CACjB,iBAAiB;CACjB,CAAC;;;;;;AAMF,MAAM,2BAA2B,WAAW,sBAAsB,IAAI,EAAE"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { localeInStorage, setLocaleInStorage } from "./useLocaleStorage.mjs";
|
|
4
|
+
import { IntlayerClientContext } from "./IntlayerContext.mjs";
|
|
5
|
+
import { EditorProvider } from "../editor/EditorProvider.mjs";
|
|
6
|
+
import { useEffect, useState } from "react";
|
|
7
|
+
import { internationalization } from "@intlayer/config/built";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { setIntlayerIdentifier } from "@intlayer/config/client";
|
|
10
|
+
import { localeResolver } from "@intlayer/core/localization";
|
|
11
|
+
|
|
12
|
+
//#region ../../packages/react-intlayer/dist/esm/client/IntlayerProvider.mjs
|
|
13
|
+
/**
|
|
14
|
+
* Provider that stores the current locale on the client side.
|
|
15
|
+
*
|
|
16
|
+
* This component is focused on content delivery without the editor features.
|
|
17
|
+
*
|
|
18
|
+
* @param props - The provider props.
|
|
19
|
+
* @returns The provider component.
|
|
20
|
+
*/
|
|
21
|
+
const IntlayerProviderContent = ({ locale: localeProp, defaultLocale: defaultLocaleProp, children, setLocale: setLocaleProp, disableEditor, isCookieEnabled }) => {
|
|
22
|
+
const { locales: availableLocales, defaultLocale: defaultLocaleConfig } = internationalization ?? {};
|
|
23
|
+
const [currentLocale, setCurrentLocale] = useState(localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (localeProp && localeProp !== currentLocale) setCurrentLocale(localeProp);
|
|
26
|
+
}, [localeProp]);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
setIntlayerIdentifier();
|
|
29
|
+
}, []);
|
|
30
|
+
const setLocaleBase = (newLocale) => {
|
|
31
|
+
if (currentLocale.toString() === newLocale.toString()) return;
|
|
32
|
+
if (!availableLocales?.map(String).includes(newLocale)) {
|
|
33
|
+
console.error(`Locale ${newLocale} is not available`);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
setCurrentLocale(newLocale);
|
|
37
|
+
setLocaleInStorage(newLocale, isCookieEnabled);
|
|
38
|
+
};
|
|
39
|
+
const setLocale = setLocaleProp ?? setLocaleBase;
|
|
40
|
+
const resolvedLocale = localeResolver(currentLocale);
|
|
41
|
+
return /* @__PURE__ */ jsx(IntlayerClientContext.Provider, {
|
|
42
|
+
value: {
|
|
43
|
+
locale: resolvedLocale,
|
|
44
|
+
setLocale,
|
|
45
|
+
disableEditor
|
|
46
|
+
},
|
|
47
|
+
children
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Main provider for Intlayer in React applications.
|
|
52
|
+
*
|
|
53
|
+
* It includes the editor provider by default, allowing for live content editing
|
|
54
|
+
* if configured.
|
|
55
|
+
*
|
|
56
|
+
* @param props - The provider props.
|
|
57
|
+
* @returns The provider component with editor support.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx
|
|
61
|
+
* import { IntlayerProvider } from 'react-intlayer';
|
|
62
|
+
*
|
|
63
|
+
* const App = () => (
|
|
64
|
+
* <IntlayerProvider>
|
|
65
|
+
* <MyComponent />
|
|
66
|
+
* </IntlayerProvider>
|
|
67
|
+
* );
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
const IntlayerProvider = ({ children, ...props }) => /* @__PURE__ */ jsxs(IntlayerProviderContent, {
|
|
71
|
+
...props,
|
|
72
|
+
children: [/* @__PURE__ */ jsx(EditorProvider, {}), children]
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
export { IntlayerProvider };
|
|
77
|
+
//# sourceMappingURL=IntlayerProvider.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntlayerProvider.mjs","names":[],"sources":["../../../../../../../../../packages/react-intlayer/dist/esm/client/IntlayerProvider.mjs"],"sourcesContent":["'use client';\n\nimport { localeInStorage, setLocaleInStorage } from \"./useLocaleStorage.mjs\";\nimport { IntlayerClientContext } from \"./IntlayerContext.mjs\";\nimport { EditorProvider } from \"../editor/EditorProvider.mjs\";\nimport { internationalization } from \"@intlayer/config/built\";\nimport { useEffect, useState } from \"react\";\nimport { jsx, jsxs } from \"react/jsx-runtime\";\nimport { setIntlayerIdentifier } from \"@intlayer/config/client\";\nimport { localeResolver } from \"@intlayer/core/localization\";\n\n//#region src/client/IntlayerProvider.tsx\n/**\n* Provider that stores the current locale on the client side.\n*\n* This component is focused on content delivery without the editor features.\n*\n* @param props - The provider props.\n* @returns The provider component.\n*/\nconst IntlayerProviderContent = ({ locale: localeProp, defaultLocale: defaultLocaleProp, children, setLocale: setLocaleProp, disableEditor, isCookieEnabled }) => {\n\tconst { locales: availableLocales, defaultLocale: defaultLocaleConfig } = internationalization ?? {};\n\tconst [currentLocale, setCurrentLocale] = useState(localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig);\n\tuseEffect(() => {\n\t\tif (localeProp && localeProp !== currentLocale) setCurrentLocale(localeProp);\n\t}, [localeProp]);\n\tuseEffect(() => {\n\t\tsetIntlayerIdentifier();\n\t}, []);\n\tconst setLocaleBase = (newLocale) => {\n\t\tif (currentLocale.toString() === newLocale.toString()) return;\n\t\tif (!availableLocales?.map(String).includes(newLocale)) {\n\t\t\tconsole.error(`Locale ${newLocale} is not available`);\n\t\t\treturn;\n\t\t}\n\t\tsetCurrentLocale(newLocale);\n\t\tsetLocaleInStorage(newLocale, isCookieEnabled);\n\t};\n\tconst setLocale = setLocaleProp ?? setLocaleBase;\n\tconst resolvedLocale = localeResolver(currentLocale);\n\treturn /* @__PURE__ */ jsx(IntlayerClientContext.Provider, {\n\t\tvalue: {\n\t\t\tlocale: resolvedLocale,\n\t\t\tsetLocale,\n\t\t\tdisableEditor\n\t\t},\n\t\tchildren\n\t});\n};\n/**\n* Main provider for Intlayer in React applications.\n*\n* It includes the editor provider by default, allowing for live content editing\n* if configured.\n*\n* @param props - The provider props.\n* @returns The provider component with editor support.\n*\n* @example\n* ```tsx\n* import { IntlayerProvider } from 'react-intlayer';\n*\n* const App = () => (\n* <IntlayerProvider>\n* <MyComponent />\n* </IntlayerProvider>\n* );\n* ```\n*/\nconst IntlayerProvider = ({ children, ...props }) => /* @__PURE__ */ jsxs(IntlayerProviderContent, {\n\t...props,\n\tchildren: [/* @__PURE__ */ jsx(EditorProvider, {}), children]\n});\n\n//#endregion\nexport { IntlayerProvider, IntlayerProviderContent };\n//# sourceMappingURL=IntlayerProvider.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,2BAA2B,EAAE,QAAQ,YAAY,eAAe,mBAAmB,UAAU,WAAW,eAAe,eAAe,sBAAsB;CACjK,MAAM,EAAE,SAAS,kBAAkB,eAAe,wBAAwB,wBAAwB,EAAE;CACpG,MAAM,CAAC,eAAe,oBAAoB,SAAS,cAAc,mBAAmB,qBAAqB,oBAAoB;AAC7H,iBAAgB;AACf,MAAI,cAAc,eAAe,cAAe,kBAAiB,WAAW;IAC1E,CAAC,WAAW,CAAC;AAChB,iBAAgB;AACf,yBAAuB;IACrB,EAAE,CAAC;CACN,MAAM,iBAAiB,cAAc;AACpC,MAAI,cAAc,UAAU,KAAK,UAAU,UAAU,CAAE;AACvD,MAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,UAAU,EAAE;AACvD,WAAQ,MAAM,UAAU,UAAU,mBAAmB;AACrD;;AAED,mBAAiB,UAAU;AAC3B,qBAAmB,WAAW,gBAAgB;;CAE/C,MAAM,YAAY,iBAAiB;CACnC,MAAM,iBAAiB,eAAe,cAAc;AACpD,QAAuB,oBAAI,sBAAsB,UAAU;EAC1D,OAAO;GACN,QAAQ;GACR;GACA;GACA;EACD;EACA,CAAC;;;;;;;;;;;;;;;;;;;;;;AAsBH,MAAM,oBAAoB,EAAE,UAAU,GAAG,YAA4B,qBAAK,yBAAyB;CAClG,GAAG;CACH,UAAU,CAAiB,oBAAI,gBAAgB,EAAE,CAAC,EAAE,SAAS;CAC7D,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import "react";
|
|
2
|
+
import { getLocaleFromStorageClient, localeStorageOptions, setLocaleInStorageClient } from "@intlayer/core/utils";
|
|
3
|
+
|
|
4
|
+
//#region ../../packages/react-intlayer/dist/esm/client/useLocaleStorage.mjs
|
|
5
|
+
/**
|
|
6
|
+
* Get the locale cookie
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Get the locale cookie
|
|
10
|
+
*/
|
|
11
|
+
const localeInStorage = getLocaleFromStorageClient(localeStorageOptions);
|
|
12
|
+
/**
|
|
13
|
+
* Set the locale cookie
|
|
14
|
+
*/
|
|
15
|
+
const setLocaleInStorage = (locale, isCookieEnabled) => setLocaleInStorageClient(locale, {
|
|
16
|
+
...localeStorageOptions,
|
|
17
|
+
isCookieEnabled
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { localeInStorage, setLocaleInStorage };
|
|
22
|
+
//# sourceMappingURL=useLocaleStorage.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLocaleStorage.mjs","names":[],"sources":["../../../../../../../../../packages/react-intlayer/dist/esm/client/useLocaleStorage.mjs"],"sourcesContent":["import { useMemo } from \"react\";\nimport { LocaleStorageClient, getLocaleFromStorageClient, localeStorageOptions, setLocaleInStorageClient } from \"@intlayer/core/utils\";\n\n//#region src/client/useLocaleStorage.ts\n/**\n* Get the locale cookie\n*/\n/**\n* Get the locale cookie\n*/\nconst localeInStorage = getLocaleFromStorageClient(localeStorageOptions);\n/**\n* @deprecated Use localeInStorage instead\n*\n* Get the locale cookie\n*/\nconst localeCookie = localeInStorage;\n/**\n* Set the locale cookie\n*/\nconst setLocaleInStorage = (locale, isCookieEnabled) => setLocaleInStorageClient(locale, {\n\t...localeStorageOptions,\n\tisCookieEnabled\n});\n/**\n* @deprecated Use setLocaleInStorage instead\n*\n* Set the locale cookie\n*/\nconst setLocaleCookie = setLocaleInStorage;\n/**\n* Hook that provides the locale cookie and a function to set it\n*/\nconst useLocaleStorage = (isCookieEnabled) => useMemo(() => LocaleStorageClient({\n\t...localeStorageOptions,\n\tisCookieEnabled\n}), [isCookieEnabled]);\n/**\n* @deprecated Use useLocaleStorage instead\n*\n* For GDPR compliance, use useLocaleStorage instead\n*\n* Hook that provides the locale cookie and a function to set it\n*/\nconst useLocaleCookie = useLocaleStorage;\n\n//#endregion\nexport { localeCookie, localeInStorage, setLocaleCookie, setLocaleInStorage, useLocaleCookie, useLocaleStorage };\n//# sourceMappingURL=useLocaleStorage.mjs.map"],"mappings":";;;;;;;;;;AAUA,MAAM,kBAAkB,2BAA2B,qBAAqB;;;;AAUxE,MAAM,sBAAsB,QAAQ,oBAAoB,yBAAyB,QAAQ;CACxF,GAAG;CACH;CACA,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useEditor } from "./useEditor.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../packages/react-intlayer/dist/esm/editor/EditorProvider.mjs
|
|
4
|
+
const EditorProvider = ({ children }) => {
|
|
5
|
+
useEditor();
|
|
6
|
+
return children;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { EditorProvider };
|
|
11
|
+
//# sourceMappingURL=EditorProvider.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorProvider.mjs","names":[],"sources":["../../../../../../../../../packages/react-intlayer/dist/esm/editor/EditorProvider.mjs"],"sourcesContent":["import { useEditor } from \"./useEditor.mjs\";\n\n//#region src/editor/EditorProvider.tsx\nconst EditorProvider = ({ children }) => {\n\tuseEditor();\n\treturn children;\n};\n\n//#endregion\nexport { EditorProvider };\n//# sourceMappingURL=EditorProvider.mjs.map"],"mappings":";;;AAGA,MAAM,kBAAkB,EAAE,eAAe;AACxC,YAAW;AACX,QAAO"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { isEnabled } from "../../../../@intlayer/editor/dist/esm/isEnabled.mjs";
|
|
4
|
+
import { useIntlayerContext } from "../client/IntlayerContext.mjs";
|
|
5
|
+
import { useEffect, useRef } from "react";
|
|
6
|
+
|
|
7
|
+
//#region ../../packages/react-intlayer/dist/esm/editor/useEditor.mjs
|
|
8
|
+
/**
|
|
9
|
+
* Initializes the Intlayer editor client singleton when the editor is enabled.
|
|
10
|
+
* Syncs the current locale from the Intlayer context into the editor manager so
|
|
11
|
+
* the editor always knows which locale the app is displaying.
|
|
12
|
+
*/
|
|
13
|
+
const useEditor = () => {
|
|
14
|
+
const { locale } = useIntlayerContext() ?? {};
|
|
15
|
+
const managerRef = useRef(null);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (process.env["INTLAYER_EDITOR_ENABLED"] === "false" || !isEnabled) return;
|
|
18
|
+
import("../../../../@intlayer/editor/dist/esm/index.mjs").then(({ initEditorClient }) => {
|
|
19
|
+
const manager = initEditorClient();
|
|
20
|
+
managerRef.current = manager;
|
|
21
|
+
if (locale) manager.currentLocale.set(locale);
|
|
22
|
+
});
|
|
23
|
+
return () => {
|
|
24
|
+
managerRef.current = null;
|
|
25
|
+
import("../../../../@intlayer/editor/dist/esm/index.mjs").then(({ stopEditorClient }) => {
|
|
26
|
+
stopEditorClient();
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}, []);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (!locale || !managerRef.current) return;
|
|
32
|
+
managerRef.current.currentLocale.set(locale);
|
|
33
|
+
}, [locale]);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { useEditor };
|
|
38
|
+
//# sourceMappingURL=useEditor.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEditor.mjs","names":[],"sources":["../../../../../../../../../packages/react-intlayer/dist/esm/editor/useEditor.mjs"],"sourcesContent":["'use client';\n\nimport { useIntlayerContext } from \"../client/IntlayerContext.mjs\";\nimport { useEffect, useRef } from \"react\";\nimport { isEnabled } from \"@intlayer/editor/isEnabled\";\n\n//#region src/editor/useEditor.tsx\n/**\n* Initializes the Intlayer editor client singleton when the editor is enabled.\n* Syncs the current locale from the Intlayer context into the editor manager so\n* the editor always knows which locale the app is displaying.\n*/\nconst useEditor = () => {\n\tconst { locale } = useIntlayerContext() ?? {};\n\tconst managerRef = useRef(null);\n\tuseEffect(() => {\n\t\tif (process.env[\"INTLAYER_EDITOR_ENABLED\"] === \"false\" || !isEnabled) return;\n\t\timport(\"@intlayer/editor\").then(({ initEditorClient }) => {\n\t\t\tconst manager = initEditorClient();\n\t\t\tmanagerRef.current = manager;\n\t\t\tif (locale) manager.currentLocale.set(locale);\n\t\t});\n\t\treturn () => {\n\t\t\tmanagerRef.current = null;\n\t\t\timport(\"@intlayer/editor\").then(({ stopEditorClient }) => {\n\t\t\t\tstopEditorClient();\n\t\t\t});\n\t\t};\n\t}, []);\n\tuseEffect(() => {\n\t\tif (!locale || !managerRef.current) return;\n\t\tmanagerRef.current.currentLocale.set(locale);\n\t}, [locale]);\n};\n\n//#endregion\nexport { useEditor };\n//# sourceMappingURL=useEditor.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,MAAM,kBAAkB;CACvB,MAAM,EAAE,WAAW,oBAAoB,IAAI,EAAE;CAC7C,MAAM,aAAa,OAAO,KAAK;AAC/B,iBAAgB;AACf,MAAI,QAAQ,IAAI,+BAA+B,WAAW,CAAC,UAAW;AACtE,SAAO,mDAAoB,MAAM,EAAE,uBAAuB;GACzD,MAAM,UAAU,kBAAkB;AAClC,cAAW,UAAU;AACrB,OAAI,OAAQ,SAAQ,cAAc,IAAI,OAAO;IAC5C;AACF,eAAa;AACZ,cAAW,UAAU;AACrB,UAAO,mDAAoB,MAAM,EAAE,uBAAuB;AACzD,sBAAkB;KACjB;;IAED,EAAE,CAAC;AACN,iBAAgB;AACf,MAAI,CAAC,UAAU,CAAC,WAAW,QAAS;AACpC,aAAW,QAAQ,cAAc,IAAI,OAAO;IAC1C,CAAC,OAAO,CAAC"}
|