angular-intlayer 5.5.9 → 5.5.11
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 +44 -11
- package/dist/cjs/UI/ContentSelector.component.cjs +141 -0
- package/dist/cjs/UI/ContentSelector.component.cjs.map +1 -0
- package/dist/cjs/client/index.cjs +13 -27
- package/dist/cjs/client/index.cjs.map +1 -1
- package/dist/cjs/client/installIntlayer.cjs +72 -0
- package/dist/cjs/client/installIntlayer.cjs.map +1 -0
- package/dist/cjs/client/{getDictionary.cjs → useDictionary.cjs} +15 -19
- package/dist/cjs/client/useDictionary.cjs.map +1 -0
- package/dist/cjs/client/useDictionaryDynamic.cjs +42 -0
- package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -0
- package/dist/cjs/client/{getBrowserLocale.cjs → useIntlayer.cjs} +17 -11
- package/dist/cjs/client/useIntlayer.cjs.map +1 -0
- package/dist/cjs/client/{intlayer.service.cjs → useLoadDynamic.cjs} +21 -19
- package/dist/cjs/client/useLoadDynamic.cjs.map +1 -0
- package/dist/cjs/client/useLocale.cjs +69 -0
- package/dist/cjs/client/useLocale.cjs.map +1 -0
- package/dist/cjs/client/useLocaleCookie.cjs +60 -0
- package/dist/cjs/client/useLocaleCookie.cjs.map +1 -0
- package/dist/cjs/editor/ContentSelectorWrapper.component.cjs +73 -0
- package/dist/cjs/editor/ContentSelectorWrapper.component.cjs.map +1 -0
- package/dist/cjs/editor/EditedContentRenderer.component.cjs +77 -0
- package/dist/cjs/editor/EditedContentRenderer.component.cjs.map +1 -0
- package/dist/cjs/editor/EditorSelectorRenderer.component.cjs +58 -0
- package/dist/cjs/editor/EditorSelectorRenderer.component.cjs.map +1 -0
- package/dist/cjs/editor/changedContent.cjs +62 -0
- package/dist/cjs/editor/changedContent.cjs.map +1 -0
- package/dist/cjs/editor/communicator.cjs +82 -0
- package/dist/cjs/editor/communicator.cjs.map +1 -0
- package/dist/cjs/editor/configuration.cjs +57 -0
- package/dist/cjs/editor/configuration.cjs.map +1 -0
- package/dist/cjs/editor/createSharedComposable.cjs +68 -0
- package/dist/cjs/editor/createSharedComposable.cjs.map +1 -0
- package/dist/cjs/editor/dictionariesRecord.cjs +83 -0
- package/dist/cjs/editor/dictionariesRecord.cjs.map +1 -0
- package/dist/cjs/editor/editedContent.cjs +77 -0
- package/dist/cjs/editor/editedContent.cjs.map +1 -0
- package/dist/cjs/editor/editorEnabled.cjs +76 -0
- package/dist/cjs/editor/editorEnabled.cjs.map +1 -0
- package/dist/cjs/editor/editorLocale.cjs +47 -0
- package/dist/cjs/editor/editorLocale.cjs.map +1 -0
- package/dist/cjs/editor/focusDictionary.cjs +80 -0
- package/dist/cjs/editor/focusDictionary.cjs.map +1 -0
- package/dist/cjs/editor/index.cjs +38 -0
- package/dist/cjs/editor/index.cjs.map +1 -0
- package/dist/cjs/editor/installIntlayerEditor.cjs +72 -0
- package/dist/cjs/editor/installIntlayerEditor.cjs.map +1 -0
- package/dist/cjs/editor/useCrossFrameMessageListener.cjs +83 -0
- package/dist/cjs/editor/useCrossFrameMessageListener.cjs.map +1 -0
- package/dist/cjs/editor/useCrossFrameState.cjs +95 -0
- package/dist/cjs/editor/useCrossFrameState.cjs.map +1 -0
- package/dist/cjs/editor/useCrossURLPathState.cjs +72 -0
- package/dist/cjs/editor/useCrossURLPathState.cjs.map +1 -0
- package/dist/cjs/editor/useEditedContentRenderer.cjs +58 -0
- package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -0
- package/dist/cjs/editor/useEditor.cjs +46 -0
- package/dist/cjs/editor/useEditor.cjs.map +1 -0
- package/dist/cjs/editor/useIframeClickInterceptor.cjs +62 -0
- package/dist/cjs/editor/useIframeClickInterceptor.cjs.map +1 -0
- package/dist/cjs/getDictionary.cjs +15 -2
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs +9 -2
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/markdown/index.cjs +3 -16
- package/dist/cjs/markdown/index.cjs.map +1 -1
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs +66 -0
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -0
- package/dist/cjs/plugins.cjs +27 -18
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/renderIntlayerNode.cjs +58 -0
- package/dist/cjs/renderIntlayerNode.cjs.map +1 -0
- package/dist/cjs/{client/getLocale.cjs → webpack/index.cjs} +6 -14
- package/dist/cjs/webpack/index.cjs.map +1 -0
- package/dist/cjs/webpack/mergeConfig.cjs +83 -0
- package/dist/cjs/webpack/mergeConfig.cjs.map +1 -0
- package/dist/esm/UI/ContentSelector.component.mjs +126 -0
- package/dist/esm/UI/ContentSelector.component.mjs.map +1 -0
- package/dist/esm/client/index.mjs +6 -16
- package/dist/esm/client/index.mjs.map +1 -1
- package/dist/esm/client/installIntlayer.mjs +35 -0
- package/dist/esm/client/installIntlayer.mjs.map +1 -0
- package/dist/esm/client/useDictionary.mjs +15 -0
- package/dist/esm/client/useDictionary.mjs.map +1 -0
- package/dist/esm/client/useDictionaryDynamic.mjs +18 -0
- package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -0
- package/dist/esm/client/useIntlayer.mjs +15 -0
- package/dist/esm/client/useIntlayer.mjs.map +1 -0
- package/dist/esm/client/useLoadDynamic.mjs +21 -0
- package/dist/esm/client/useLoadDynamic.mjs.map +1 -0
- package/dist/esm/client/useLocale.mjs +35 -0
- package/dist/esm/client/useLocale.mjs.map +1 -0
- package/dist/esm/client/useLocaleCookie.mjs +24 -0
- package/dist/esm/client/useLocaleCookie.mjs.map +1 -0
- package/dist/esm/editor/ContentSelectorWrapper.component.mjs +49 -0
- package/dist/esm/editor/ContentSelectorWrapper.component.mjs.map +1 -0
- package/dist/esm/editor/EditedContentRenderer.component.mjs +53 -0
- package/dist/esm/editor/EditedContentRenderer.component.mjs.map +1 -0
- package/dist/esm/editor/EditorSelectorRenderer.component.mjs +34 -0
- package/dist/esm/editor/EditorSelectorRenderer.component.mjs.map +1 -0
- package/dist/esm/editor/changedContent.mjs +36 -0
- package/dist/esm/editor/changedContent.mjs.map +1 -0
- package/dist/esm/editor/communicator.mjs +46 -0
- package/dist/esm/editor/communicator.mjs.map +1 -0
- package/dist/esm/editor/configuration.mjs +23 -0
- package/dist/esm/editor/configuration.mjs.map +1 -0
- package/dist/esm/editor/createSharedComposable.mjs +43 -0
- package/dist/esm/editor/createSharedComposable.mjs.map +1 -0
- package/dist/esm/editor/dictionariesRecord.mjs +47 -0
- package/dist/esm/editor/dictionariesRecord.mjs.map +1 -0
- package/dist/esm/editor/editedContent.mjs +51 -0
- package/dist/esm/editor/editedContent.mjs.map +1 -0
- package/dist/esm/editor/editorEnabled.mjs +50 -0
- package/dist/esm/editor/editorEnabled.mjs.map +1 -0
- package/dist/esm/editor/editorLocale.mjs +23 -0
- package/dist/esm/editor/editorLocale.mjs.map +1 -0
- package/dist/esm/editor/focusDictionary.mjs +54 -0
- package/dist/esm/editor/focusDictionary.mjs.map +1 -0
- package/dist/esm/editor/index.mjs +10 -0
- package/dist/esm/editor/index.mjs.map +1 -0
- package/dist/esm/editor/installIntlayerEditor.mjs +38 -0
- package/dist/esm/editor/installIntlayerEditor.mjs.map +1 -0
- package/dist/esm/editor/useCrossFrameMessageListener.mjs +59 -0
- package/dist/esm/editor/useCrossFrameMessageListener.mjs.map +1 -0
- package/dist/esm/editor/useCrossFrameState.mjs +71 -0
- package/dist/esm/editor/useCrossFrameState.mjs.map +1 -0
- package/dist/esm/editor/useCrossURLPathState.mjs +47 -0
- package/dist/esm/editor/useCrossURLPathState.mjs.map +1 -0
- package/dist/esm/editor/useEditedContentRenderer.mjs +37 -0
- package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -0
- package/dist/esm/editor/useEditor.mjs +22 -0
- package/dist/esm/editor/useEditor.mjs.map +1 -0
- package/dist/esm/editor/useIframeClickInterceptor.mjs +37 -0
- package/dist/esm/editor/useIframeClickInterceptor.mjs.map +1 -0
- package/dist/esm/getDictionary.mjs +19 -1
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs +14 -2
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/esm/markdown/index.mjs +1 -10
- package/dist/esm/markdown/index.mjs.map +1 -1
- package/dist/esm/markdown/installIntlayerMarkdown.mjs +39 -0
- package/dist/esm/markdown/installIntlayerMarkdown.mjs.map +1 -0
- package/dist/esm/plugins.mjs +27 -17
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/esm/renderIntlayerNode.mjs +34 -0
- package/dist/esm/renderIntlayerNode.mjs.map +1 -0
- package/dist/esm/webpack/index.mjs +2 -0
- package/dist/esm/webpack/index.mjs.map +1 -0
- package/dist/esm/webpack/mergeConfig.mjs +49 -0
- package/dist/esm/webpack/mergeConfig.mjs.map +1 -0
- package/dist/types/UI/ContentSelector.component.d.ts +32 -0
- package/dist/types/UI/ContentSelector.component.d.ts.map +1 -0
- package/dist/types/client/index.d.ts +6 -7
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/client/installIntlayer.d.ts +17 -0
- package/dist/types/client/installIntlayer.d.ts.map +1 -0
- package/dist/types/client/useDictionary.d.ts +5 -0
- package/dist/types/client/useDictionary.d.ts.map +1 -0
- package/dist/types/client/useDictionaryDynamic.d.ts +9 -0
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -0
- package/dist/types/client/useIntlayer.d.ts +10 -0
- package/dist/types/client/useIntlayer.d.ts.map +1 -0
- package/dist/types/client/useLoadDynamic.d.ts +8 -0
- package/dist/types/client/useLoadDynamic.d.ts.map +1 -0
- package/dist/types/client/useLocale.d.ts +15 -0
- package/dist/types/client/useLocale.d.ts.map +1 -0
- package/dist/types/client/useLocaleCookie.d.ts +17 -0
- package/dist/types/client/useLocaleCookie.d.ts.map +1 -0
- package/dist/types/editor/ContentSelectorWrapper.component.d.ts +19 -0
- package/dist/types/editor/ContentSelectorWrapper.component.d.ts.map +1 -0
- package/dist/types/editor/EditedContentRenderer.component.d.ts +19 -0
- package/dist/types/editor/EditedContentRenderer.component.d.ts.map +1 -0
- package/dist/types/editor/EditorSelectorRenderer.component.d.ts +13 -0
- package/dist/types/editor/EditorSelectorRenderer.component.d.ts.map +1 -0
- package/dist/types/editor/changedContent.d.ts +14 -0
- package/dist/types/editor/changedContent.d.ts.map +1 -0
- package/dist/types/editor/communicator.d.ts +28 -0
- package/dist/types/editor/communicator.d.ts.map +1 -0
- package/dist/types/editor/configuration.d.ts +2 -0
- package/dist/types/editor/configuration.d.ts.map +1 -0
- package/dist/types/editor/createSharedComposable.d.ts +14 -0
- package/dist/types/editor/createSharedComposable.d.ts.map +1 -0
- package/dist/types/editor/dictionariesRecord.d.ts +16 -0
- package/dist/types/editor/dictionariesRecord.d.ts.map +1 -0
- package/dist/types/editor/editedContent.d.ts +19 -0
- package/dist/types/editor/editedContent.d.ts.map +1 -0
- package/dist/types/editor/editorEnabled.d.ts +16 -0
- package/dist/types/editor/editorEnabled.d.ts.map +1 -0
- package/dist/types/editor/editorLocale.d.ts +3 -0
- package/dist/types/editor/editorLocale.d.ts.map +1 -0
- package/dist/types/editor/focusDictionary.d.ts +24 -0
- package/dist/types/editor/focusDictionary.d.ts.map +1 -0
- package/dist/types/editor/index.d.ts +5 -0
- package/dist/types/editor/index.d.ts.map +1 -0
- package/dist/types/editor/installIntlayerEditor.d.ts +18 -0
- package/dist/types/editor/installIntlayerEditor.d.ts.map +1 -0
- package/dist/types/editor/useCrossFrameMessageListener.d.ts +11 -0
- package/dist/types/editor/useCrossFrameMessageListener.d.ts.map +1 -0
- package/dist/types/editor/useCrossFrameState.d.ts +24 -0
- package/dist/types/editor/useCrossFrameState.d.ts.map +1 -0
- package/dist/types/editor/useCrossURLPathState.d.ts +16 -0
- package/dist/types/editor/useCrossURLPathState.d.ts.map +1 -0
- package/dist/types/editor/useEditedContentRenderer.d.ts +17 -0
- package/dist/types/editor/useEditedContentRenderer.d.ts.map +1 -0
- package/dist/types/editor/useEditor.d.ts +2 -0
- package/dist/types/editor/useEditor.d.ts.map +1 -0
- package/dist/types/editor/useIframeClickInterceptor.d.ts +11 -0
- package/dist/types/editor/useIframeClickInterceptor.d.ts.map +1 -0
- package/dist/types/getDictionary.d.ts +4 -1
- package/dist/types/getDictionary.d.ts.map +1 -1
- package/dist/types/getIntlayer.d.ts +4 -6
- package/dist/types/getIntlayer.d.ts.map +1 -1
- package/dist/types/markdown/index.d.ts +1 -4
- package/dist/types/markdown/index.d.ts.map +1 -1
- package/dist/types/markdown/installIntlayerMarkdown.d.ts +26 -0
- package/dist/types/markdown/installIntlayerMarkdown.d.ts.map +1 -0
- package/dist/types/plugins.d.ts +0 -9
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/renderIntlayerNode.d.ts +13 -0
- package/dist/types/renderIntlayerNode.d.ts.map +1 -0
- package/dist/types/webpack/index.d.ts +2 -0
- package/dist/types/webpack/index.d.ts.map +1 -0
- package/dist/types/webpack/mergeConfig.d.ts +3 -0
- package/dist/types/webpack/mergeConfig.d.ts.map +1 -0
- package/package.json +27 -11
- package/dist/cjs/client/dictionary.service.cjs +0 -70
- package/dist/cjs/client/dictionary.service.cjs.map +0 -1
- package/dist/cjs/client/getBrowserLocale.cjs.map +0 -1
- package/dist/cjs/client/getDictionary.cjs.map +0 -1
- package/dist/cjs/client/getLocale.cjs.map +0 -1
- package/dist/cjs/client/intlayer.service.cjs.map +0 -1
- package/dist/cjs/client/locale.service.cjs +0 -66
- package/dist/cjs/client/locale.service.cjs.map +0 -1
- package/dist/cjs/client/t.cjs +0 -32
- package/dist/cjs/client/t.cjs.map +0 -1
- package/dist/esm/client/dictionary.service.mjs +0 -46
- package/dist/esm/client/dictionary.service.mjs.map +0 -1
- package/dist/esm/client/getBrowserLocale.mjs +0 -10
- package/dist/esm/client/getBrowserLocale.mjs.map +0 -1
- package/dist/esm/client/getDictionary.mjs +0 -25
- package/dist/esm/client/getDictionary.mjs.map +0 -1
- package/dist/esm/client/getLocale.mjs +0 -7
- package/dist/esm/client/getLocale.mjs.map +0 -1
- package/dist/esm/client/intlayer.service.mjs +0 -19
- package/dist/esm/client/intlayer.service.mjs.map +0 -1
- package/dist/esm/client/locale.service.mjs +0 -42
- package/dist/esm/client/locale.service.mjs.map +0 -1
- package/dist/esm/client/t.mjs +0 -8
- package/dist/esm/client/t.mjs.map +0 -1
- package/dist/types/client/dictionary.service.d.ts +0 -21
- package/dist/types/client/dictionary.service.d.ts.map +0 -1
- package/dist/types/client/getBrowserLocale.d.ts +0 -6
- package/dist/types/client/getBrowserLocale.d.ts.map +0 -1
- package/dist/types/client/getDictionary.d.ts +0 -8
- package/dist/types/client/getDictionary.d.ts.map +0 -1
- package/dist/types/client/getLocale.d.ts +0 -7
- package/dist/types/client/getLocale.d.ts.map +0 -1
- package/dist/types/client/intlayer.service.d.ts +0 -8
- package/dist/types/client/intlayer.service.d.ts.map +0 -1
- package/dist/types/client/locale.service.d.ts +0 -12
- package/dist/types/client/locale.service.d.ts.map +0 -1
- package/dist/types/client/t.d.ts +0 -8
- package/dist/types/client/t.d.ts.map +0 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var createSharedComposable_exports = {};
|
|
20
|
+
__export(createSharedComposable_exports, {
|
|
21
|
+
createSharedComposable: () => createSharedComposable,
|
|
22
|
+
tryOnScopeDispose: () => tryOnScopeDispose
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(createSharedComposable_exports);
|
|
25
|
+
var import_core = require("@angular/core");
|
|
26
|
+
function tryOnScopeDispose(fn) {
|
|
27
|
+
try {
|
|
28
|
+
const destroyRef = (0, import_core.inject)(import_core.DestroyRef, { optional: true });
|
|
29
|
+
if (destroyRef) {
|
|
30
|
+
destroyRef.onDestroy(fn);
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
} catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const createSharedComposable = (composable) => {
|
|
39
|
+
let subscribers = 0;
|
|
40
|
+
let state;
|
|
41
|
+
let cleanupFn;
|
|
42
|
+
const dispose = () => {
|
|
43
|
+
subscribers -= 1;
|
|
44
|
+
if (cleanupFn && subscribers <= 0) {
|
|
45
|
+
cleanupFn();
|
|
46
|
+
state = void 0;
|
|
47
|
+
cleanupFn = void 0;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
return (...args) => {
|
|
51
|
+
subscribers += 1;
|
|
52
|
+
if (!state) {
|
|
53
|
+
state = composable(...args);
|
|
54
|
+
if (tryOnScopeDispose(dispose)) {
|
|
55
|
+
cleanupFn = dispose;
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
tryOnScopeDispose(dispose);
|
|
59
|
+
}
|
|
60
|
+
return state;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
createSharedComposable,
|
|
66
|
+
tryOnScopeDispose
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=createSharedComposable.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/createSharedComposable.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core';\n\ntype AnyFn = (...args: any[]) => any;\n\nexport type SharedComposableReturn<T extends AnyFn = AnyFn> = T;\n\n/**\n * Angular replacement for Vue's tryOnScopeDispose\n * Uses Angular's DestroyRef to handle cleanup when the injection context is destroyed\n */\nexport function tryOnScopeDispose(fn: () => void) {\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n if (destroyRef) {\n destroyRef.onDestroy(fn);\n return true;\n }\n return false;\n } catch {\n // If called outside injection context, return false\n return false;\n }\n}\n\n/**\n * Angular equivalent of Vue's createSharedComposable\n * Creates a singleton pattern for services/composables\n */\nexport const createSharedComposable = <Fn extends AnyFn>(\n composable: Fn\n): SharedComposableReturn<Fn> => {\n let subscribers = 0;\n let state: ReturnType<Fn> | undefined;\n let cleanupFn: (() => void) | undefined;\n\n const dispose = () => {\n subscribers -= 1;\n if (cleanupFn && subscribers <= 0) {\n cleanupFn();\n state = undefined;\n cleanupFn = undefined;\n }\n };\n\n return <Fn>((...args) => {\n subscribers += 1;\n if (!state) {\n state = composable(...args);\n // Set up cleanup when the first subscriber is destroyed\n if (tryOnScopeDispose(dispose)) {\n cleanupFn = dispose;\n }\n } else {\n // For additional subscribers, just set up their individual cleanup\n tryOnScopeDispose(dispose);\n }\n return state;\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmC;AAU5B,SAAS,kBAAkB,IAAgB;AAChD,MAAI;AACF,UAAM,iBAAa,oBAAO,wBAAY,EAAE,UAAU,KAAK,CAAC;AACxD,QAAI,YAAY;AACd,iBAAW,UAAU,EAAE;AACvB,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT,QAAQ;AAEN,WAAO;AAAA,EACT;AACF;AAMO,MAAM,yBAAyB,CACpC,eAC+B;AAC/B,MAAI,cAAc;AAClB,MAAI;AACJ,MAAI;AAEJ,QAAM,UAAU,MAAM;AACpB,mBAAe;AACf,QAAI,aAAa,eAAe,GAAG;AACjC,gBAAU;AACV,cAAQ;AACR,kBAAY;AAAA,IACd;AAAA,EACF;AAEA,SAAY,IAAI,SAAS;AACvB,mBAAe;AACf,QAAI,CAAC,OAAO;AACV,cAAQ,WAAW,GAAG,IAAI;AAE1B,UAAI,kBAAkB,OAAO,GAAG;AAC9B,oBAAY;AAAA,MACd;AAAA,IACF,OAAO;AAEL,wBAAkB,OAAO;AAAA,IAC3B;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var dictionariesRecord_exports = {};
|
|
30
|
+
__export(dictionariesRecord_exports, {
|
|
31
|
+
createDictionaryRecordClient: () => createDictionaryRecordClient,
|
|
32
|
+
installDictionariesRecord: () => installDictionariesRecord,
|
|
33
|
+
useDictionariesRecord: () => useDictionariesRecord
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(dictionariesRecord_exports);
|
|
36
|
+
var import_core = require("@angular/core");
|
|
37
|
+
var import_dictionaries_entry = __toESM(require("@intlayer/dictionaries-entry"));
|
|
38
|
+
var import_editor = require("@intlayer/editor");
|
|
39
|
+
var import_createSharedComposable = require('./createSharedComposable.cjs');
|
|
40
|
+
var import_useCrossFrameState = require('./useCrossFrameState.cjs');
|
|
41
|
+
let instance = null;
|
|
42
|
+
const createDictionaryRecordClient = () => {
|
|
43
|
+
if (instance) return instance;
|
|
44
|
+
const localeDictionariesSignal = (0, import_core.signal)(import_dictionaries_entry.default);
|
|
45
|
+
instance = {
|
|
46
|
+
localeDictionaries: localeDictionariesSignal.asReadonly(),
|
|
47
|
+
setLocaleDictionaries: (newValue) => {
|
|
48
|
+
localeDictionariesSignal.set(newValue ?? {});
|
|
49
|
+
},
|
|
50
|
+
setLocaleDictionary(dictionary) {
|
|
51
|
+
const current = localeDictionariesSignal();
|
|
52
|
+
localeDictionariesSignal.set({
|
|
53
|
+
...current,
|
|
54
|
+
[dictionary.key]: dictionary
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
return instance;
|
|
59
|
+
};
|
|
60
|
+
const installDictionariesRecord = (injector) => {
|
|
61
|
+
const client = createDictionaryRecordClient();
|
|
62
|
+
};
|
|
63
|
+
const useDictionariesRecord = (0, import_createSharedComposable.createSharedComposable)(() => {
|
|
64
|
+
const client = createDictionaryRecordClient();
|
|
65
|
+
if (!client) {
|
|
66
|
+
throw new Error("DictionariesRecord state not found");
|
|
67
|
+
}
|
|
68
|
+
const [_dictionariesRecord, setDictionariesRecord] = (0, import_useCrossFrameState.useCrossFrameState)(
|
|
69
|
+
import_editor.MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED,
|
|
70
|
+
void 0
|
|
71
|
+
);
|
|
72
|
+
(0, import_core.effect)(() => {
|
|
73
|
+
const newValue = client.localeDictionaries();
|
|
74
|
+
setDictionariesRecord(newValue);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
createDictionaryRecordClient,
|
|
80
|
+
installDictionariesRecord,
|
|
81
|
+
useDictionariesRecord
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=dictionariesRecord.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/dictionariesRecord.ts"],"sourcesContent":["import { effect, Injector, signal, Signal } from '@angular/core';\nimport type { Dictionary } from '@intlayer/core';\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport { MessageKey } from '@intlayer/editor';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\n/**\n * Singleton instance\n */\nlet instance: DictionariesRecordClient | null = null;\n\nexport type DictionaryContent = Record<Dictionary['key'], Dictionary>;\n\ntype DictionariesRecordClient = {\n localeDictionaries: Signal<DictionaryContent>;\n setLocaleDictionaries: (newValue: DictionaryContent) => void;\n setLocaleDictionary: (d: Dictionary) => void;\n};\n\nexport const createDictionaryRecordClient = () => {\n if (instance) return instance;\n\n const localeDictionariesSignal = signal<DictionaryContent>(dictionaries);\n\n instance = {\n localeDictionaries: localeDictionariesSignal.asReadonly(),\n\n setLocaleDictionaries: (newValue) => {\n localeDictionariesSignal.set(newValue ?? {});\n },\n\n setLocaleDictionary(dictionary) {\n const current = localeDictionariesSignal();\n localeDictionariesSignal.set({\n ...current,\n [dictionary.key]: dictionary,\n });\n },\n };\n\n return instance;\n};\n\n/**\n * Helper to install the provider into the injector\n */\nexport const installDictionariesRecord = (injector: Injector) => {\n const client = createDictionaryRecordClient();\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createDictionaryRecordClient\n};\n\nexport const useDictionariesRecord = createSharedComposable(() => {\n const client = createDictionaryRecordClient();\n\n if (!client) {\n throw new Error('DictionariesRecord state not found');\n }\n\n const [_dictionariesRecord, setDictionariesRecord] =\n useCrossFrameState<DictionaryContent>(\n MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED,\n undefined\n );\n\n // Use Angular effects instead of Vue watchers\n effect(() => {\n const newValue = client.localeDictionaries();\n setDictionariesRecord(newValue); // its undefined but shouldnt\n });\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiD;AAEjD,gCAAyB;AACzB,oBAA2B;AAC3B,oCAAuC;AACvC,gCAAmC;AAKnC,IAAI,WAA4C;AAUzC,MAAM,+BAA+B,MAAM;AAChD,MAAI,SAAU,QAAO;AAErB,QAAM,+BAA2B,oBAA0B,0BAAAA,OAAY;AAEvE,aAAW;AAAA,IACT,oBAAoB,yBAAyB,WAAW;AAAA,IAExD,uBAAuB,CAAC,aAAa;AACnC,+BAAyB,IAAI,YAAY,CAAC,CAAC;AAAA,IAC7C;AAAA,IAEA,oBAAoB,YAAY;AAC9B,YAAM,UAAU,yBAAyB;AACzC,+BAAyB,IAAI;AAAA,QAC3B,GAAG;AAAA,QACH,CAAC,WAAW,GAAG,GAAG;AAAA,MACpB,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;AAKO,MAAM,4BAA4B,CAAC,aAAuB;AAC/D,QAAM,SAAS,6BAA6B;AAI9C;AAEO,MAAM,4BAAwB,sDAAuB,MAAM;AAChE,QAAM,SAAS,6BAA6B;AAE5C,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,oCAAoC;AAAA,EACtD;AAEA,QAAM,CAAC,qBAAqB,qBAAqB,QAC/C;AAAA,IACE,yBAAW;AAAA,IACX;AAAA,EACF;AAGF,0BAAO,MAAM;AACX,UAAM,WAAW,OAAO,mBAAmB;AAC3C,0BAAsB,QAAQ;AAAA,EAChC,CAAC;AACH,CAAC;","names":["dictionaries"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var editedContent_exports = {};
|
|
20
|
+
__export(editedContent_exports, {
|
|
21
|
+
createEditedContentClient: () => createEditedContentClient,
|
|
22
|
+
installEditedContent: () => installEditedContent,
|
|
23
|
+
useEditedContent: () => useEditedContent
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(editedContent_exports);
|
|
26
|
+
var import_core = require("@angular/core");
|
|
27
|
+
var import_core2 = require("@intlayer/core");
|
|
28
|
+
var import_editor = require("@intlayer/editor");
|
|
29
|
+
var import_createSharedComposable = require('./createSharedComposable.cjs');
|
|
30
|
+
var import_useCrossFrameState = require('./useCrossFrameState.cjs');
|
|
31
|
+
let instance = null;
|
|
32
|
+
const INTLAYER_EDITED_CONTENT_SYMBOL = Symbol("EditedContent");
|
|
33
|
+
const createEditedContentClient = () => {
|
|
34
|
+
if (instance) return instance;
|
|
35
|
+
const editedContentSignal = (0, import_core.signal)({});
|
|
36
|
+
instance = {
|
|
37
|
+
editedContent: editedContentSignal.asReadonly(),
|
|
38
|
+
getEditedContentValue: (dictionaryKey, keyPath) => {
|
|
39
|
+
const content = editedContentSignal()?.[dictionaryKey]?.content;
|
|
40
|
+
if (!content) return void 0;
|
|
41
|
+
return (0, import_core2.getContentNodeByKeyPath)(content, keyPath);
|
|
42
|
+
},
|
|
43
|
+
setEditedContent: (editedContent) => {
|
|
44
|
+
editedContentSignal.set(editedContent);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
return instance;
|
|
48
|
+
};
|
|
49
|
+
const installEditedContent = (injector) => {
|
|
50
|
+
const client = createEditedContentClient();
|
|
51
|
+
};
|
|
52
|
+
const useEditedContent = (0, import_createSharedComposable.createSharedComposable)(() => {
|
|
53
|
+
const client = createEditedContentClient();
|
|
54
|
+
if (!client) {
|
|
55
|
+
throw new Error("EditedContent state not found");
|
|
56
|
+
}
|
|
57
|
+
const [edited, setEdited] = (0, import_useCrossFrameState.useCrossFrameState)(
|
|
58
|
+
import_editor.MessageKey.INTLAYER_EDITED_CONTENT_CHANGED,
|
|
59
|
+
{}
|
|
60
|
+
);
|
|
61
|
+
(0, import_core.effect)(() => {
|
|
62
|
+
const newValue = edited();
|
|
63
|
+
client.setEditedContent(newValue ?? {});
|
|
64
|
+
});
|
|
65
|
+
(0, import_core.effect)(() => {
|
|
66
|
+
const newValue = client.editedContent();
|
|
67
|
+
setEdited(newValue);
|
|
68
|
+
});
|
|
69
|
+
return client;
|
|
70
|
+
});
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
createEditedContentClient,
|
|
74
|
+
installEditedContent,
|
|
75
|
+
useEditedContent
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=editedContent.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/editedContent.ts"],"sourcesContent":["import { effect, Injector, signal, Signal } from '@angular/core';\nimport type { ContentNode, Dictionary, KeyPath } from '@intlayer/core';\nimport { getContentNodeByKeyPath } from '@intlayer/core';\nimport { MessageKey } from '@intlayer/editor';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport type EditedContent = Record<Dictionary['key'], Dictionary>;\n\ntype EditedContentClient = {\n editedContent: Signal<EditedContent>;\n setEditedContent: (editedContent: EditedContent) => void;\n getEditedContentValue: (\n dictionaryKey: Dictionary['key'],\n keyPath: KeyPath[]\n ) => ContentNode | undefined;\n};\n\n/**\n * Singleton instance\n */\nlet instance: EditedContentClient | null = null;\n\nconst INTLAYER_EDITED_CONTENT_SYMBOL = Symbol('EditedContent');\n\n/**\n * Creates an edited content client\n */\nexport const createEditedContentClient = () => {\n if (instance) return instance;\n\n const editedContentSignal = signal<EditedContent>({});\n\n instance = {\n editedContent: editedContentSignal.asReadonly(),\n getEditedContentValue: (\n dictionaryKey: Dictionary['key'],\n keyPath: KeyPath[]\n ): ContentNode | undefined => {\n const content = editedContentSignal()?.[dictionaryKey]?.content;\n if (!content) return undefined;\n\n return getContentNodeByKeyPath(content, keyPath);\n },\n setEditedContent: (editedContent: EditedContent) => {\n editedContentSignal.set(editedContent);\n },\n };\n\n return instance;\n};\n\n/**\n * Helper to install the edited content into the injector\n */\nexport const installEditedContent = (injector: Injector) => {\n const client = createEditedContentClient();\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createEditedContentClient\n};\n\nexport const useEditedContent = createSharedComposable(() => {\n const client = createEditedContentClient();\n\n if (!client) {\n throw new Error('EditedContent state not found');\n }\n\n const [edited, setEdited] = useCrossFrameState<EditedContent>(\n MessageKey.INTLAYER_EDITED_CONTENT_CHANGED,\n {}\n );\n\n // Use Angular effects instead of Vue watchers\n effect(() => {\n const newValue = edited();\n client.setEditedContent(newValue ?? {});\n });\n\n effect(() => {\n const newValue = client.editedContent();\n setEdited(newValue);\n });\n\n return client;\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiD;AAEjD,IAAAA,eAAwC;AACxC,oBAA2B;AAC3B,oCAAuC;AACvC,gCAAmC;AAgBnC,IAAI,WAAuC;AAE3C,MAAM,iCAAiC,OAAO,eAAe;AAKtD,MAAM,4BAA4B,MAAM;AAC7C,MAAI,SAAU,QAAO;AAErB,QAAM,0BAAsB,oBAAsB,CAAC,CAAC;AAEpD,aAAW;AAAA,IACT,eAAe,oBAAoB,WAAW;AAAA,IAC9C,uBAAuB,CACrB,eACA,YAC4B;AAC5B,YAAM,UAAU,oBAAoB,IAAI,aAAa,GAAG;AACxD,UAAI,CAAC,QAAS,QAAO;AAErB,iBAAO,sCAAwB,SAAS,OAAO;AAAA,IACjD;AAAA,IACA,kBAAkB,CAAC,kBAAiC;AAClD,0BAAoB,IAAI,aAAa;AAAA,IACvC;AAAA,EACF;AAEA,SAAO;AACT;AAKO,MAAM,uBAAuB,CAAC,aAAuB;AAC1D,QAAM,SAAS,0BAA0B;AAI3C;AAEO,MAAM,uBAAmB,sDAAuB,MAAM;AAC3D,QAAM,SAAS,0BAA0B;AAEzC,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AAEA,QAAM,CAAC,QAAQ,SAAS,QAAI;AAAA,IAC1B,yBAAW;AAAA,IACX,CAAC;AAAA,EACH;AAGA,0BAAO,MAAM;AACX,UAAM,WAAW,OAAO;AACxB,WAAO,iBAAiB,YAAY,CAAC,CAAC;AAAA,EACxC,CAAC;AAED,0BAAO,MAAM;AACX,UAAM,WAAW,OAAO,cAAc;AACtC,cAAU,QAAQ;AAAA,EACpB,CAAC;AAED,SAAO;AACT,CAAC;","names":["import_core"]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var editorEnabled_exports = {};
|
|
20
|
+
__export(editorEnabled_exports, {
|
|
21
|
+
createEditorEnabledClient: () => createEditorEnabledClient,
|
|
22
|
+
installEditorEnabled: () => installEditorEnabled,
|
|
23
|
+
useEditorEnabled: () => useEditorEnabled
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(editorEnabled_exports);
|
|
26
|
+
var import_core = require("@angular/core");
|
|
27
|
+
var import_editor = require("@intlayer/editor");
|
|
28
|
+
var import_createSharedComposable = require('./createSharedComposable.cjs');
|
|
29
|
+
var import_useCrossFrameMessageListener = require('./useCrossFrameMessageListener.cjs');
|
|
30
|
+
let instance = null;
|
|
31
|
+
const INTLAYER_EDITOR_ENABLED_SYMBOL = Symbol("EditorEnabled");
|
|
32
|
+
const createEditorEnabledClient = () => {
|
|
33
|
+
if (instance) return instance;
|
|
34
|
+
const wrapperEnabledSignal = (0, import_core.signal)(false);
|
|
35
|
+
const isInIframeSignal = (0, import_core.signal)(false);
|
|
36
|
+
const enabledSignal = (0, import_core.computed)(
|
|
37
|
+
() => wrapperEnabledSignal() && isInIframeSignal()
|
|
38
|
+
);
|
|
39
|
+
instance = {
|
|
40
|
+
wrapperEnabled: wrapperEnabledSignal.asReadonly(),
|
|
41
|
+
isInIframe: isInIframeSignal.asReadonly(),
|
|
42
|
+
enabled: enabledSignal
|
|
43
|
+
};
|
|
44
|
+
return instance;
|
|
45
|
+
};
|
|
46
|
+
const installEditorEnabled = (injector) => {
|
|
47
|
+
const client = createEditorEnabledClient();
|
|
48
|
+
};
|
|
49
|
+
const useEditorEnabled = (0, import_createSharedComposable.createSharedComposable)(() => {
|
|
50
|
+
const client = createEditorEnabledClient();
|
|
51
|
+
if (!client) {
|
|
52
|
+
throw new Error("EditorEnabled state not found");
|
|
53
|
+
}
|
|
54
|
+
(0, import_useCrossFrameMessageListener.useCrossFrameMessageListener)(
|
|
55
|
+
`${import_editor.MessageKey.INTLAYER_EDITOR_ENABLED}/post`,
|
|
56
|
+
(data) => {
|
|
57
|
+
client.wrapperEnabled.set(data);
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
(0, import_core.effect)(
|
|
61
|
+
() => {
|
|
62
|
+
if (typeof window !== "undefined") {
|
|
63
|
+
client.isInIframe.set(window.self !== window.top);
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
{ allowSignalWrites: true }
|
|
67
|
+
);
|
|
68
|
+
return client;
|
|
69
|
+
});
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
createEditorEnabledClient,
|
|
73
|
+
installEditorEnabled,
|
|
74
|
+
useEditorEnabled
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=editorEnabled.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/editorEnabled.ts"],"sourcesContent":["import { computed, effect, Injector, signal, Signal } from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameMessageListener } from './useCrossFrameMessageListener';\n\n/* ------------------------------------------------------------------ */\n/* public type – identical to the React version */\n/* ------------------------------------------------------------------ */\nexport type EditorEnabledStateProps = {\n wrapperEnabled: Signal<boolean>;\n isInIframe: Signal<boolean>;\n enabled: Signal<boolean>;\n};\n\n/**\n * Singleton instance\n */\nlet instance: EditorEnabledStateProps | null = null;\n\nconst INTLAYER_EDITOR_ENABLED_SYMBOL = Symbol('EditorEnabled');\n\n/**\n * Creates an editor wrapperEnabled client\n */\nexport const createEditorEnabledClient = () => {\n if (instance) return instance;\n\n const wrapperEnabledSignal = signal(false);\n const isInIframeSignal = signal(false);\n const enabledSignal = computed(\n () => wrapperEnabledSignal() && isInIframeSignal()\n );\n\n instance = {\n wrapperEnabled: wrapperEnabledSignal.asReadonly(),\n isInIframe: isInIframeSignal.asReadonly(),\n enabled: enabledSignal,\n };\n\n return instance;\n};\n\n/**\n * Helper to install the editor wrapperEnabled state into the injector\n */\nexport const installEditorEnabled = (injector: Injector) => {\n const client = createEditorEnabledClient();\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createEditorEnabledClient\n};\n\nexport const useEditorEnabled = createSharedComposable(() => {\n const client = createEditorEnabledClient();\n\n if (!client) {\n throw new Error('EditorEnabled state not found');\n }\n\n // Listen for the iframe parent if the editor send a message `INTLAYER_EDITOR_ENABLED`\n useCrossFrameMessageListener<boolean>(\n `${MessageKey.INTLAYER_EDITOR_ENABLED}/post`,\n (data) => {\n (client.wrapperEnabled as any).set(data);\n }\n );\n\n // Use effect to set up the iframe check immediately\n effect(\n () => {\n if (typeof window !== 'undefined') {\n (client.isInIframe as any).set(window.self !== window.top);\n }\n },\n { allowSignalWrites: true }\n );\n\n return client;\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2D;AAC3D,oBAA2B;AAC3B,oCAAuC;AACvC,0CAA6C;AAc7C,IAAI,WAA2C;AAE/C,MAAM,iCAAiC,OAAO,eAAe;AAKtD,MAAM,4BAA4B,MAAM;AAC7C,MAAI,SAAU,QAAO;AAErB,QAAM,2BAAuB,oBAAO,KAAK;AACzC,QAAM,uBAAmB,oBAAO,KAAK;AACrC,QAAM,oBAAgB;AAAA,IACpB,MAAM,qBAAqB,KAAK,iBAAiB;AAAA,EACnD;AAEA,aAAW;AAAA,IACT,gBAAgB,qBAAqB,WAAW;AAAA,IAChD,YAAY,iBAAiB,WAAW;AAAA,IACxC,SAAS;AAAA,EACX;AAEA,SAAO;AACT;AAKO,MAAM,uBAAuB,CAAC,aAAuB;AAC1D,QAAM,SAAS,0BAA0B;AAI3C;AAEO,MAAM,uBAAmB,sDAAuB,MAAM;AAC3D,QAAM,SAAS,0BAA0B;AAEzC,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AAGA;AAAA,IACE,GAAG,yBAAW,uBAAuB;AAAA,IACrC,CAAC,SAAS;AACR,MAAC,OAAO,eAAuB,IAAI,IAAI;AAAA,IACzC;AAAA,EACF;AAGA;AAAA,IACE,MAAM;AACJ,UAAI,OAAO,WAAW,aAAa;AACjC,QAAC,OAAO,WAAmB,IAAI,OAAO,SAAS,OAAO,GAAG;AAAA,MAC3D;AAAA,IACF;AAAA,IACA,EAAE,mBAAmB,KAAK;AAAA,EAC5B;AAEA,SAAO;AACT,CAAC;","names":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var editorLocale_exports = {};
|
|
20
|
+
__export(editorLocale_exports, {
|
|
21
|
+
useEditorLocale: () => useEditorLocale
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(editorLocale_exports);
|
|
24
|
+
var import_core = require("@angular/core");
|
|
25
|
+
var import_editor = require("@intlayer/editor");
|
|
26
|
+
var import_client = require('../client/index.cjs');
|
|
27
|
+
var import_createSharedComposable = require('./createSharedComposable.cjs');
|
|
28
|
+
var import_useCrossFrameState = require('./useCrossFrameState.cjs');
|
|
29
|
+
const useEditorLocale = (0, import_createSharedComposable.createSharedComposable)(() => {
|
|
30
|
+
const client = (0, import_core.inject)(import_client.INTLAYER_TOKEN);
|
|
31
|
+
if (!client) {
|
|
32
|
+
throw new Error("IntlayerEditor state not found");
|
|
33
|
+
}
|
|
34
|
+
const [_data, setData] = (0, import_useCrossFrameState.useCrossFrameState)(
|
|
35
|
+
import_editor.MessageKey.INTLAYER_CURRENT_LOCALE
|
|
36
|
+
);
|
|
37
|
+
(0, import_core.effect)(() => {
|
|
38
|
+
const newValue = client.locale();
|
|
39
|
+
setData(newValue);
|
|
40
|
+
});
|
|
41
|
+
return client;
|
|
42
|
+
});
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
useEditorLocale
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=editorLocale.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/editorLocale.ts"],"sourcesContent":["import { effect, inject } from '@angular/core';\nimport type { Locales } from '@intlayer/config/client';\nimport { MessageKey } from '@intlayer/editor';\nimport { INTLAYER_TOKEN, IntlayerProvider } from '../client';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport const useEditorLocale = createSharedComposable(() => {\n const client = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n if (!client) {\n throw new Error('IntlayerEditor state not found');\n }\n\n const [_data, setData] = useCrossFrameState<Locales>(\n MessageKey.INTLAYER_CURRENT_LOCALE\n );\n\n // Use Angular effects instead of Vue watchers\n effect(() => {\n const newValue = client.locale();\n setData(newValue);\n });\n\n return client;\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA+B;AAE/B,oBAA2B;AAC3B,oBAAiD;AACjD,oCAAuC;AACvC,gCAAmC;AAE5B,MAAM,sBAAkB,sDAAuB,MAAM;AAC1D,QAAM,aAAS,oBAAyB,4BAAc;AAEtD,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,gCAAgC;AAAA,EAClD;AAEA,QAAM,CAAC,OAAO,OAAO,QAAI;AAAA,IACvB,yBAAW;AAAA,EACb;AAGA,0BAAO,MAAM;AACX,UAAM,WAAW,OAAO,OAAO;AAC/B,YAAQ,QAAQ;AAAA,EAClB,CAAC;AAED,SAAO;AACT,CAAC;","names":[]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var focusDictionary_exports = {};
|
|
20
|
+
__export(focusDictionary_exports, {
|
|
21
|
+
createFocusDictionaryClient: () => createFocusDictionaryClient,
|
|
22
|
+
installFocusDictionary: () => installFocusDictionary,
|
|
23
|
+
useFocusDictionary: () => useFocusDictionary
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(focusDictionary_exports);
|
|
26
|
+
var import_core = require("@angular/core");
|
|
27
|
+
var import_editor = require("@intlayer/editor");
|
|
28
|
+
var import_createSharedComposable = require('./createSharedComposable.cjs');
|
|
29
|
+
var import_useCrossFrameState = require('./useCrossFrameState.cjs');
|
|
30
|
+
let instance = null;
|
|
31
|
+
const createFocusDictionaryClient = () => {
|
|
32
|
+
if (instance) return instance;
|
|
33
|
+
const focusedContentSignal = (0, import_core.signal)(null);
|
|
34
|
+
const setFocusedContent = (focussedContent) => {
|
|
35
|
+
focusedContentSignal.set(focussedContent);
|
|
36
|
+
};
|
|
37
|
+
const setFocusedContentKeyPath = (keyPath) => {
|
|
38
|
+
const current = focusedContentSignal();
|
|
39
|
+
if (!current) return;
|
|
40
|
+
setFocusedContent({ ...current, keyPath });
|
|
41
|
+
};
|
|
42
|
+
instance = {
|
|
43
|
+
focusedContent: focusedContentSignal.asReadonly(),
|
|
44
|
+
setFocusedContent,
|
|
45
|
+
setFocusedContentKeyPath
|
|
46
|
+
};
|
|
47
|
+
return instance;
|
|
48
|
+
};
|
|
49
|
+
const installFocusDictionary = (injector) => {
|
|
50
|
+
const client = createFocusDictionaryClient();
|
|
51
|
+
};
|
|
52
|
+
const useFocusDictionary = (0, import_createSharedComposable.createSharedComposable)(() => {
|
|
53
|
+
const client = createFocusDictionaryClient();
|
|
54
|
+
const [focusedContent, setFocusedContent] = (0, import_useCrossFrameState.useCrossFrameState)(
|
|
55
|
+
import_editor.MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED
|
|
56
|
+
);
|
|
57
|
+
if (!client) {
|
|
58
|
+
throw new Error("FocusDictionary state not found");
|
|
59
|
+
}
|
|
60
|
+
(0, import_core.effect)(() => {
|
|
61
|
+
const newValue = client.focusedContent();
|
|
62
|
+
if (JSON.stringify(newValue) !== JSON.stringify(focusedContent())) {
|
|
63
|
+
setFocusedContent(newValue);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
(0, import_core.effect)(() => {
|
|
67
|
+
const newValue = focusedContent();
|
|
68
|
+
if (JSON.stringify(newValue) !== JSON.stringify(client.focusedContent())) {
|
|
69
|
+
client.setFocusedContent(newValue ?? null);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return client;
|
|
73
|
+
});
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
createFocusDictionaryClient,
|
|
77
|
+
installFocusDictionary,
|
|
78
|
+
useFocusDictionary
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=focusDictionary.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/focusDictionary.ts"],"sourcesContent":["import { effect, Injector, signal, Signal } from '@angular/core';\nimport type { KeyPath } from '@intlayer/core';\nimport { MessageKey } from '@intlayer/editor';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport type FileContent = {\n dictionaryKey: string;\n keyPath?: KeyPath[];\n dictionaryPath?: string;\n};\n\ntype FocusDictionaryClient = {\n focusedContent: Signal<FileContent | null>;\n setFocusedContent: (focussedContent: FileContent | null) => void;\n setFocusedContentKeyPath: (keyPath: KeyPath[]) => void;\n};\n\n/**\n * Singleton instance\n */\nlet instance: FocusDictionaryClient | null = null;\n\n/**\n * Creates a focus dictionary client\n */\nexport const createFocusDictionaryClient = () => {\n if (instance) return instance;\n\n const focusedContentSignal = signal<FileContent | null>(null);\n\n const setFocusedContent = (focussedContent: FileContent | null) => {\n focusedContentSignal.set(focussedContent);\n };\n\n const setFocusedContentKeyPath = (keyPath: KeyPath[]) => {\n const current = focusedContentSignal();\n if (!current) return;\n setFocusedContent({ ...current, keyPath });\n };\n\n instance = {\n focusedContent: focusedContentSignal.asReadonly(),\n setFocusedContent,\n setFocusedContentKeyPath,\n } as FocusDictionaryClient;\n\n return instance;\n};\n\n/**\n * Helper to install the focus dictionary into the injector\n */\nexport const installFocusDictionary = (injector: Injector) => {\n const client = createFocusDictionaryClient();\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createFocusDictionaryClient\n};\n\n/** consumer */\nexport const useFocusDictionary = createSharedComposable(() => {\n const client = createFocusDictionaryClient();\n const [focusedContent, setFocusedContent] =\n useCrossFrameState<FileContent | null>(\n MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED\n );\n\n if (!client) {\n throw new Error('FocusDictionary state not found');\n }\n\n // Use Angular effects instead of Vue watchers\n // Watch local (client) and update cross-frame\n effect(() => {\n const newValue = client.focusedContent();\n if (JSON.stringify(newValue) !== JSON.stringify(focusedContent())) {\n setFocusedContent(newValue);\n }\n });\n\n // Watch cross-frame and update local\n effect(() => {\n const newValue = focusedContent();\n if (JSON.stringify(newValue) !== JSON.stringify(client.focusedContent())) {\n client.setFocusedContent(newValue ?? null);\n }\n });\n\n return client;\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiD;AAEjD,oBAA2B;AAC3B,oCAAuC;AACvC,gCAAmC;AAiBnC,IAAI,WAAyC;AAKtC,MAAM,8BAA8B,MAAM;AAC/C,MAAI,SAAU,QAAO;AAErB,QAAM,2BAAuB,oBAA2B,IAAI;AAE5D,QAAM,oBAAoB,CAAC,oBAAwC;AACjE,yBAAqB,IAAI,eAAe;AAAA,EAC1C;AAEA,QAAM,2BAA2B,CAAC,YAAuB;AACvD,UAAM,UAAU,qBAAqB;AACrC,QAAI,CAAC,QAAS;AACd,sBAAkB,EAAE,GAAG,SAAS,QAAQ,CAAC;AAAA,EAC3C;AAEA,aAAW;AAAA,IACT,gBAAgB,qBAAqB,WAAW;AAAA,IAChD;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AACT;AAKO,MAAM,yBAAyB,CAAC,aAAuB;AAC5D,QAAM,SAAS,4BAA4B;AAI7C;AAGO,MAAM,yBAAqB,sDAAuB,MAAM;AAC7D,QAAM,SAAS,4BAA4B;AAC3C,QAAM,CAAC,gBAAgB,iBAAiB,QACtC;AAAA,IACE,yBAAW;AAAA,EACb;AAEF,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AAIA,0BAAO,MAAM;AACX,UAAM,WAAW,OAAO,eAAe;AACvC,QAAI,KAAK,UAAU,QAAQ,MAAM,KAAK,UAAU,eAAe,CAAC,GAAG;AACjE,wBAAkB,QAAQ;AAAA,IAC5B;AAAA,EACF,CAAC;AAGD,0BAAO,MAAM;AACX,UAAM,WAAW,eAAe;AAChC,QAAI,KAAK,UAAU,QAAQ,MAAM,KAAK,UAAU,OAAO,eAAe,CAAC,GAAG;AACxE,aAAO,kBAAkB,YAAY,IAAI;AAAA,IAC3C;AAAA,EACF,CAAC;AAED,SAAO;AACT,CAAC;","names":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var editor_exports = {};
|
|
21
|
+
__export(editor_exports, {
|
|
22
|
+
ContentSelectorWrapperComponent: () => import_ContentSelectorWrapper.ContentSelectorWrapperComponent,
|
|
23
|
+
EditedContentRendererComponent: () => import_EditedContentRenderer.EditedContentRendererComponent,
|
|
24
|
+
EditorSelectorRendererComponent: () => import_EditorSelectorRenderer.EditorSelectorRendererComponent
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(editor_exports);
|
|
27
|
+
var import_ContentSelectorWrapper = require('./ContentSelectorWrapper.component.cjs');
|
|
28
|
+
var import_EditedContentRenderer = require('./EditedContentRenderer.component.cjs');
|
|
29
|
+
var import_EditorSelectorRenderer = require('./EditorSelectorRenderer.component.cjs');
|
|
30
|
+
__reExport(editor_exports, require('./installIntlayerEditor.cjs'), module.exports);
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
ContentSelectorWrapperComponent,
|
|
34
|
+
EditedContentRendererComponent,
|
|
35
|
+
EditorSelectorRendererComponent,
|
|
36
|
+
...require('./installIntlayerEditor.cjs')
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/index.ts"],"sourcesContent":["export { ContentSelectorWrapperComponent } from './ContentSelectorWrapper.component';\nexport { EditedContentRendererComponent } from './EditedContentRenderer.component';\nexport { EditorSelectorRendererComponent } from './EditorSelectorRenderer.component';\nexport * from './installIntlayerEditor';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAAgD;AAChD,mCAA+C;AAC/C,oCAAgD;AAChD,2BAAc,oCAHd;","names":[]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var installIntlayerEditor_exports = {};
|
|
30
|
+
__export(installIntlayerEditor_exports, {
|
|
31
|
+
installIntlayerEditor: () => installIntlayerEditor
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(installIntlayerEditor_exports);
|
|
34
|
+
var import_built = __toESM(require("@intlayer/config/built"));
|
|
35
|
+
var import_changedContent = require('./changedContent.cjs');
|
|
36
|
+
var import_communicator = require('./communicator.cjs');
|
|
37
|
+
var import_dictionariesRecord = require('./dictionariesRecord.cjs');
|
|
38
|
+
var import_editedContent = require('./editedContent.cjs');
|
|
39
|
+
var import_editorEnabled = require('./editorEnabled.cjs');
|
|
40
|
+
var import_focusDictionary = require('./focusDictionary.cjs');
|
|
41
|
+
const { editor } = import_built.default;
|
|
42
|
+
const { applicationURL, editorURL, cmsURL } = editor ?? {};
|
|
43
|
+
const postMessage = (data) => {
|
|
44
|
+
if (typeof window === "undefined") return;
|
|
45
|
+
const isInIframe = window.self !== window.top;
|
|
46
|
+
if (!isInIframe) return;
|
|
47
|
+
if (editor.applicationURL.length > 0) {
|
|
48
|
+
window.postMessage(data, editor.applicationURL);
|
|
49
|
+
}
|
|
50
|
+
if (editor.editorURL.length > 0) {
|
|
51
|
+
window.parent.postMessage(data, editor.editorURL);
|
|
52
|
+
}
|
|
53
|
+
if (editor.cmsURL.length > 0) {
|
|
54
|
+
window.parent.postMessage(data, editor.cmsURL);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const installIntlayerEditor = (injector) => {
|
|
58
|
+
(0, import_communicator.installCommunicator)(injector, {
|
|
59
|
+
postMessage,
|
|
60
|
+
allowedOrigins: [applicationURL, editorURL, cmsURL]
|
|
61
|
+
});
|
|
62
|
+
(0, import_editorEnabled.installEditorEnabled)(injector);
|
|
63
|
+
(0, import_changedContent.installChangedContent)(injector);
|
|
64
|
+
(0, import_dictionariesRecord.installDictionariesRecord)(injector);
|
|
65
|
+
(0, import_editedContent.installEditedContent)(injector);
|
|
66
|
+
(0, import_focusDictionary.installFocusDictionary)(injector);
|
|
67
|
+
};
|
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
+
0 && (module.exports = {
|
|
70
|
+
installIntlayerEditor
|
|
71
|
+
});
|
|
72
|
+
//# sourceMappingURL=installIntlayerEditor.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/installIntlayerEditor.ts"],"sourcesContent":["import { Injector } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport { installChangedContent } from './changedContent';\nimport { installCommunicator } from './communicator';\nimport { installDictionariesRecord } from './dictionariesRecord';\nimport { installEditedContent } from './editedContent';\nimport { installEditorEnabled } from './editorEnabled';\nimport { installFocusDictionary } from './focusDictionary';\n\nconst { editor } = configuration;\nconst { applicationURL, editorURL, cmsURL } = editor ?? {};\n\nconst postMessage = (data: any) => {\n if (typeof window === 'undefined') return;\n\n const isInIframe = window.self !== window.top;\n\n if (!isInIframe) return;\n\n if (editor.applicationURL.length > 0) {\n window.postMessage(data, editor.applicationURL);\n }\n\n if (editor.editorURL.length > 0) {\n window.parent.postMessage(data, editor.editorURL);\n }\n\n if (editor.cmsURL.length > 0) {\n window.parent.postMessage(data, editor.cmsURL);\n }\n};\n\n/**\n * Angular-side replacement for the former <IntlayerEditorProvider> React component.\n *\n * Call **once** in your Angular application's bootstrap function or main module:\n *\n * ```typescript\n * import { bootstrapApplication } from '@angular/platform-browser';\n * import { AppComponent } from './app/app.component';\n * import { installIntlayerEditor } from 'angular-intlayer';\n *\n * bootstrapApplication(AppComponent).then(appRef => {\n * installIntlayerEditor(appRef.injector);\n * });\n * ```\n */\nexport const installIntlayerEditor = (injector: Injector): void => {\n /* ---------------------------------------------------------------------\n * 1. Base providers – always on\n * -------------------------------------------------------------------*/\n\n installCommunicator(injector, {\n postMessage,\n allowedOrigins: [applicationURL, editorURL, cmsURL] as string[],\n });\n installEditorEnabled(injector);\n installChangedContent(injector);\n installDictionariesRecord(injector);\n installEditedContent(injector);\n installFocusDictionary(injector);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA0B;AAC1B,4BAAsC;AACtC,0BAAoC;AACpC,gCAA0C;AAC1C,2BAAqC;AACrC,2BAAqC;AACrC,6BAAuC;AAEvC,MAAM,EAAE,OAAO,IAAI,aAAAA;AACnB,MAAM,EAAE,gBAAgB,WAAW,OAAO,IAAI,UAAU,CAAC;AAEzD,MAAM,cAAc,CAAC,SAAc;AACjC,MAAI,OAAO,WAAW,YAAa;AAEnC,QAAM,aAAa,OAAO,SAAS,OAAO;AAE1C,MAAI,CAAC,WAAY;AAEjB,MAAI,OAAO,eAAe,SAAS,GAAG;AACpC,WAAO,YAAY,MAAM,OAAO,cAAc;AAAA,EAChD;AAEA,MAAI,OAAO,UAAU,SAAS,GAAG;AAC/B,WAAO,OAAO,YAAY,MAAM,OAAO,SAAS;AAAA,EAClD;AAEA,MAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,WAAO,OAAO,YAAY,MAAM,OAAO,MAAM;AAAA,EAC/C;AACF;AAiBO,MAAM,wBAAwB,CAAC,aAA6B;AAKjE,+CAAoB,UAAU;AAAA,IAC5B;AAAA,IACA,gBAAgB,CAAC,gBAAgB,WAAW,MAAM;AAAA,EACpD,CAAC;AACD,iDAAqB,QAAQ;AAC7B,mDAAsB,QAAQ;AAC9B,2DAA0B,QAAQ;AAClC,iDAAqB,QAAQ;AAC7B,qDAAuB,QAAQ;AACjC;","names":["configuration"]}
|