angular-intlayer 6.1.6 → 7.0.0-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/dist/cjs/UI/ContentSelector.component.cjs +94 -121
- package/dist/cjs/UI/ContentSelector.component.cjs.map +1 -1
- package/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/cjs/client/index.cjs +19 -35
- package/dist/cjs/client/installIntlayer.cjs +39 -68
- package/dist/cjs/client/installIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useDictionary.cjs +13 -36
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs +23 -48
- package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +24 -52
- package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs +16 -36
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useLoadDynamic.cjs +26 -42
- package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs +35 -67
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocaleStorage.cjs +61 -0
- package/dist/cjs/client/useLocaleStorage.cjs.map +1 -0
- package/dist/cjs/editor/ContentSelectorWrapper.component.cjs +41 -63
- package/dist/cjs/editor/ContentSelectorWrapper.component.cjs.map +1 -1
- package/dist/cjs/editor/EditedContentRenderer.component.cjs +44 -75
- package/dist/cjs/editor/EditedContentRenderer.component.cjs.map +1 -1
- package/dist/cjs/editor/EditorSelectorRenderer.component.cjs +25 -45
- package/dist/cjs/editor/EditorSelectorRenderer.component.cjs.map +1 -1
- package/dist/cjs/editor/communicator.cjs +55 -73
- package/dist/cjs/editor/communicator.cjs.map +1 -1
- package/dist/cjs/editor/configuration.cjs +21 -54
- package/dist/cjs/editor/configuration.cjs.map +1 -1
- package/dist/cjs/editor/createSharedComposable.cjs +46 -63
- package/dist/cjs/editor/createSharedComposable.cjs.map +1 -1
- package/dist/cjs/editor/dictionariesRecord.cjs +47 -77
- package/dist/cjs/editor/dictionariesRecord.cjs.map +1 -1
- package/dist/cjs/editor/editedContent.cjs +58 -71
- package/dist/cjs/editor/editedContent.cjs.map +1 -1
- package/dist/cjs/editor/editorEnabled.cjs +45 -70
- package/dist/cjs/editor/editorEnabled.cjs.map +1 -1
- package/dist/cjs/editor/editorLocale.cjs +21 -45
- package/dist/cjs/editor/editorLocale.cjs.map +1 -1
- package/dist/cjs/editor/focusDictionary.cjs +58 -74
- package/dist/cjs/editor/focusDictionary.cjs.map +1 -1
- package/dist/cjs/editor/index.cjs +9 -38
- package/dist/cjs/editor/installIntlayerEditor.cjs +46 -64
- package/dist/cjs/editor/installIntlayerEditor.cjs.map +1 -1
- package/dist/cjs/editor/useCrossFrameMessageListener.cjs +63 -72
- package/dist/cjs/editor/useCrossFrameMessageListener.cjs.map +1 -1
- package/dist/cjs/editor/useCrossFrameState.cjs +108 -88
- package/dist/cjs/editor/useCrossFrameState.cjs.map +1 -1
- package/dist/cjs/editor/useCrossURLPathState.cjs +64 -69
- package/dist/cjs/editor/useCrossURLPathState.cjs.map +1 -1
- package/dist/cjs/editor/useEditedContentRenderer.cjs +25 -54
- package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -1
- package/dist/cjs/editor/useEditor.cjs +22 -44
- package/dist/cjs/editor/useEditor.cjs.map +1 -1
- package/dist/cjs/editor/useIframeClickInterceptor.cjs +38 -59
- package/dist/cjs/editor/useIframeClickInterceptor.cjs.map +1 -1
- package/dist/cjs/getDictionary.cjs +14 -39
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs +14 -35
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/index.cjs +32 -31
- package/dist/cjs/markdown/index.cjs +6 -23
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs +33 -60
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -1
- package/dist/cjs/plugins.cjs +77 -108
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/renderIntlayerNode.cjs +16 -56
- package/dist/cjs/renderIntlayerNode.cjs.map +1 -1
- package/dist/cjs/webpack/index.cjs +3 -23
- package/dist/cjs/webpack/mergeConfig.cjs +33 -68
- package/dist/cjs/webpack/mergeConfig.cjs.map +1 -1
- package/dist/esm/UI/ContentSelector.component.mjs +89 -104
- package/dist/esm/UI/ContentSelector.component.mjs.map +1 -1
- package/dist/esm/client/index.mjs +9 -8
- package/dist/esm/client/installIntlayer.mjs +29 -27
- package/dist/esm/client/installIntlayer.mjs.map +1 -1
- package/dist/esm/client/useDictionary.mjs +10 -11
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/esm/client/useDictionaryAsync.mjs +18 -12
- package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
- package/dist/esm/client/useDictionaryDynamic.mjs +18 -15
- package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs +12 -10
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useLoadDynamic.mjs +23 -17
- package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
- package/dist/esm/client/useLocale.mjs +30 -31
- package/dist/esm/client/useLocale.mjs.map +1 -1
- package/dist/esm/client/useLocaleStorage.mjs +54 -0
- package/dist/esm/client/useLocaleStorage.mjs.map +1 -0
- package/dist/esm/editor/ContentSelectorWrapper.component.mjs +32 -34
- package/dist/esm/editor/ContentSelectorWrapper.component.mjs.map +1 -1
- package/dist/esm/editor/EditedContentRenderer.component.mjs +38 -49
- package/dist/esm/editor/EditedContentRenderer.component.mjs.map +1 -1
- package/dist/esm/editor/EditorSelectorRenderer.component.mjs +19 -18
- package/dist/esm/editor/EditorSelectorRenderer.component.mjs.map +1 -1
- package/dist/esm/editor/communicator.mjs +48 -35
- package/dist/esm/editor/communicator.mjs.map +1 -1
- package/dist/esm/editor/configuration.mjs +15 -18
- package/dist/esm/editor/configuration.mjs.map +1 -1
- package/dist/esm/editor/createSharedComposable.mjs +42 -37
- package/dist/esm/editor/createSharedComposable.mjs.map +1 -1
- package/dist/esm/editor/dictionariesRecord.mjs +38 -38
- package/dist/esm/editor/dictionariesRecord.mjs.map +1 -1
- package/dist/esm/editor/editedContent.mjs +49 -42
- package/dist/esm/editor/editedContent.mjs.map +1 -1
- package/dist/esm/editor/editorEnabled.mjs +37 -41
- package/dist/esm/editor/editorEnabled.mjs.map +1 -1
- package/dist/esm/editor/editorLocale.mjs +15 -18
- package/dist/esm/editor/editorLocale.mjs.map +1 -1
- package/dist/esm/editor/focusDictionary.mjs +50 -45
- package/dist/esm/editor/focusDictionary.mjs.map +1 -1
- package/dist/esm/editor/index.mjs +3 -7
- package/dist/esm/editor/installIntlayerEditor.mjs +40 -26
- package/dist/esm/editor/installIntlayerEditor.mjs.map +1 -1
- package/dist/esm/editor/useCrossFrameMessageListener.mjs +58 -46
- package/dist/esm/editor/useCrossFrameMessageListener.mjs.map +1 -1
- package/dist/esm/editor/useCrossFrameState.mjs +104 -62
- package/dist/esm/editor/useCrossFrameState.mjs.map +1 -1
- package/dist/esm/editor/useCrossURLPathState.mjs +57 -41
- package/dist/esm/editor/useCrossURLPathState.mjs.map +1 -1
- package/dist/esm/editor/useEditedContentRenderer.mjs +21 -33
- package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -1
- package/dist/esm/editor/useEditor.mjs +16 -14
- package/dist/esm/editor/useEditor.mjs.map +1 -1
- package/dist/esm/editor/useIframeClickInterceptor.mjs +30 -30
- package/dist/esm/editor/useIframeClickInterceptor.mjs.map +1 -1
- package/dist/esm/getDictionary.mjs +12 -20
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs +12 -16
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/esm/index.mjs +13 -6
- package/dist/esm/markdown/index.mjs +3 -2
- package/dist/esm/markdown/installIntlayerMarkdown.mjs +27 -32
- package/dist/esm/markdown/installIntlayerMarkdown.mjs.map +1 -1
- package/dist/esm/plugins.mjs +70 -83
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/esm/renderIntlayerNode.mjs +15 -32
- package/dist/esm/renderIntlayerNode.mjs.map +1 -1
- package/dist/esm/webpack/index.mjs +3 -2
- package/dist/esm/webpack/mergeConfig.mjs +25 -31
- package/dist/esm/webpack/mergeConfig.mjs.map +1 -1
- package/dist/types/UI/ContentSelector.component.d.ts +32 -30
- package/dist/types/UI/ContentSelector.component.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +8 -8
- package/dist/types/client/installIntlayer.d.ts +15 -9
- package/dist/types/client/installIntlayer.d.ts.map +1 -1
- package/dist/types/client/useDictionary.d.ts +7 -4
- package/dist/types/client/useDictionary.d.ts.map +1 -1
- package/dist/types/client/useDictionaryAsync.d.ts +7 -3
- package/dist/types/client/useDictionaryAsync.d.ts.map +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts +9 -3
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/client/useIntlayer.d.ts +9 -7
- package/dist/types/client/useIntlayer.d.ts.map +1 -1
- package/dist/types/client/useLoadDynamic.d.ts +4 -1
- package/dist/types/client/useLoadDynamic.d.ts.map +1 -1
- package/dist/types/client/useLocale.d.ts +17 -8
- package/dist/types/client/useLocale.d.ts.map +1 -1
- package/dist/types/client/useLocaleStorage.d.ts +49 -0
- package/dist/types/client/useLocaleStorage.d.ts.map +1 -0
- package/dist/types/editor/ContentSelectorWrapper.component.d.ts +18 -12
- package/dist/types/editor/ContentSelectorWrapper.component.d.ts.map +1 -1
- package/dist/types/editor/EditedContentRenderer.component.d.ts +20 -16
- package/dist/types/editor/EditedContentRenderer.component.d.ts.map +1 -1
- package/dist/types/editor/EditorSelectorRenderer.component.d.ts +11 -6
- package/dist/types/editor/EditorSelectorRenderer.component.d.ts.map +1 -1
- package/dist/types/editor/communicator.d.ts +14 -9
- package/dist/types/editor/communicator.d.ts.map +1 -1
- package/dist/types/editor/configuration.d.ts +4 -1
- package/dist/types/editor/configuration.d.ts.map +1 -1
- package/dist/types/editor/createSharedComposable.d.ts +6 -4
- package/dist/types/editor/createSharedComposable.d.ts.map +1 -1
- package/dist/types/editor/dictionariesRecord.d.ts +13 -10
- package/dist/types/editor/dictionariesRecord.d.ts.map +1 -1
- package/dist/types/editor/editedContent.d.ts +13 -10
- package/dist/types/editor/editedContent.d.ts.map +1 -1
- package/dist/types/editor/editorEnabled.d.ts +12 -8
- package/dist/types/editor/editorEnabled.d.ts.map +1 -1
- package/dist/types/editor/editorLocale.d.ts +6 -2
- package/dist/types/editor/editorLocale.d.ts.map +1 -1
- package/dist/types/editor/focusDictionary.d.ts +16 -13
- package/dist/types/editor/focusDictionary.d.ts.map +1 -1
- package/dist/types/editor/index.d.ts +5 -5
- package/dist/types/editor/installIntlayerEditor.d.ts +7 -2
- package/dist/types/editor/installIntlayerEditor.d.ts.map +1 -1
- package/dist/types/editor/useCrossFrameMessageListener.d.ts +7 -2
- package/dist/types/editor/useCrossFrameMessageListener.d.ts.map +1 -1
- package/dist/types/editor/useCrossFrameState.d.ts +12 -8
- package/dist/types/editor/useCrossFrameState.d.ts.map +1 -1
- package/dist/types/editor/useCrossURLPathState.d.ts +9 -3
- package/dist/types/editor/useCrossURLPathState.d.ts.map +1 -1
- package/dist/types/editor/useEditedContentRenderer.d.ts +15 -11
- package/dist/types/editor/useEditedContentRenderer.d.ts.map +1 -1
- package/dist/types/editor/useEditor.d.ts +4 -1
- package/dist/types/editor/useEditor.d.ts.map +1 -1
- package/dist/types/editor/useIframeClickInterceptor.d.ts +5 -2
- package/dist/types/editor/useIframeClickInterceptor.d.ts.map +1 -1
- package/dist/types/getDictionary.d.ts +8 -4
- package/dist/types/getDictionary.d.ts.map +1 -1
- package/dist/types/getIntlayer.d.ts +8 -4
- package/dist/types/getIntlayer.d.ts.map +1 -1
- package/dist/types/index.d.ts +16 -8
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/markdown/index.d.ts +2 -2
- package/dist/types/markdown/installIntlayerMarkdown.d.ts +15 -12
- package/dist/types/markdown/installIntlayerMarkdown.d.ts.map +1 -1
- package/dist/types/plugins.d.ts +29 -23
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/renderIntlayerNode.d.ts +16 -10
- package/dist/types/renderIntlayerNode.d.ts.map +1 -1
- package/dist/types/webpack/index.d.ts +2 -2
- package/dist/types/webpack/mergeConfig.d.ts +5 -2
- package/dist/types/webpack/mergeConfig.d.ts.map +1 -1
- package/package.json +43 -49
- package/LICENSE +0 -202
- package/dist/cjs/client/index.cjs.map +0 -1
- package/dist/cjs/client/useLocaleCookie.cjs +0 -60
- package/dist/cjs/client/useLocaleCookie.cjs.map +0 -1
- package/dist/cjs/editor/index.cjs.map +0 -1
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/markdown/index.cjs.map +0 -1
- package/dist/cjs/webpack/index.cjs.map +0 -1
- package/dist/esm/client/index.mjs.map +0 -1
- package/dist/esm/client/useLocaleCookie.mjs +0 -24
- package/dist/esm/client/useLocaleCookie.mjs.map +0 -1
- package/dist/esm/editor/index.mjs.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/markdown/index.mjs.map +0 -1
- package/dist/esm/webpack/index.mjs.map +0 -1
- package/dist/types/client/index.d.ts.map +0 -1
- package/dist/types/client/useLocaleCookie.d.ts +0 -17
- package/dist/types/client/useLocaleCookie.d.ts.map +0 -1
- package/dist/types/editor/index.d.ts.map +0 -1
- package/dist/types/markdown/index.d.ts.map +0 -1
- package/dist/types/webpack/index.d.ts.map +0 -1
|
@@ -1,43 +1,48 @@
|
|
|
1
1
|
import { DestroyRef, inject } from "@angular/core";
|
|
2
|
+
|
|
3
|
+
//#region src/editor/createSharedComposable.ts
|
|
4
|
+
/**
|
|
5
|
+
* Angular replacement for Vue's tryOnScopeDispose
|
|
6
|
+
* Uses Angular's DestroyRef to handle cleanup when the injection context is destroyed
|
|
7
|
+
*/
|
|
2
8
|
function tryOnScopeDispose(fn) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
try {
|
|
10
|
+
const destroyRef = inject(DestroyRef, { optional: true });
|
|
11
|
+
if (destroyRef) {
|
|
12
|
+
destroyRef.onDestroy(fn);
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
} catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
13
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Angular equivalent of Vue's createSharedComposable
|
|
22
|
+
* Creates a singleton pattern for services/composables
|
|
23
|
+
*/
|
|
14
24
|
const createSharedComposable = (composable) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
tryOnScopeDispose(dispose);
|
|
35
|
-
}
|
|
36
|
-
return state;
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
export {
|
|
40
|
-
createSharedComposable,
|
|
41
|
-
tryOnScopeDispose
|
|
25
|
+
let subscribers = 0;
|
|
26
|
+
let state;
|
|
27
|
+
let cleanupFn;
|
|
28
|
+
const dispose = () => {
|
|
29
|
+
subscribers -= 1;
|
|
30
|
+
if (cleanupFn && subscribers <= 0) {
|
|
31
|
+
cleanupFn();
|
|
32
|
+
state = void 0;
|
|
33
|
+
cleanupFn = void 0;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return ((...args) => {
|
|
37
|
+
subscribers += 1;
|
|
38
|
+
if (!state) {
|
|
39
|
+
state = composable(...args);
|
|
40
|
+
if (tryOnScopeDispose(dispose)) cleanupFn = dispose;
|
|
41
|
+
} else tryOnScopeDispose(dispose);
|
|
42
|
+
return state;
|
|
43
|
+
});
|
|
42
44
|
};
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
export { createSharedComposable, tryOnScopeDispose };
|
|
43
48
|
//# sourceMappingURL=createSharedComposable.mjs.map
|
|
@@ -1 +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":"
|
|
1
|
+
{"version":3,"file":"createSharedComposable.mjs","names":["state: ReturnType<Fn> | undefined","cleanupFn: (() => void) | undefined"],"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":";;;;;;;AAUA,SAAgB,kBAAkB,IAAgB;AAChD,KAAI;EACF,MAAM,aAAa,OAAO,YAAY,EAAE,UAAU,MAAM,CAAC;AACzD,MAAI,YAAY;AACd,cAAW,UAAU,GAAG;AACxB,UAAO;;AAET,SAAO;SACD;AAEN,SAAO;;;;;;;AAQX,MAAa,0BACX,eAC+B;CAC/B,IAAI,cAAc;CAClB,IAAIA;CACJ,IAAIC;CAEJ,MAAM,gBAAgB;AACpB,iBAAe;AACf,MAAI,aAAa,eAAe,GAAG;AACjC,cAAW;AACX,WAAQ;AACR,eAAY;;;AAIhB,UAAa,GAAG,SAAS;AACvB,iBAAe;AACf,MAAI,CAAC,OAAO;AACV,WAAQ,WAAW,GAAG,KAAK;AAE3B,OAAI,kBAAkB,QAAQ,CAC5B,aAAY;QAId,mBAAkB,QAAQ;AAE5B,SAAO"}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { effect, signal } from "@angular/core";
|
|
2
|
-
import dictionaries from "@intlayer/dictionaries-entry";
|
|
3
|
-
import { MessageKey } from "@intlayer/editor";
|
|
4
1
|
import { createSharedComposable } from "./createSharedComposable.mjs";
|
|
5
2
|
import { useCrossFrameState } from "./useCrossFrameState.mjs";
|
|
3
|
+
import { effect, signal } from "@angular/core";
|
|
4
|
+
import { MessageKey } from "@intlayer/editor";
|
|
5
|
+
import { getDictionaries } from "@intlayer/dictionaries-entry";
|
|
6
|
+
|
|
7
|
+
//#region src/editor/dictionariesRecord.ts
|
|
8
|
+
/**
|
|
9
|
+
* Singleton instance
|
|
10
|
+
*/
|
|
6
11
|
let instance = null;
|
|
7
12
|
const createDictionaryRecordClient = () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
if (instance) return instance;
|
|
14
|
+
const localeDictionariesSignal = signal(getDictionaries());
|
|
15
|
+
instance = {
|
|
16
|
+
localeDictionaries: localeDictionariesSignal.asReadonly(),
|
|
17
|
+
setLocaleDictionaries: (newValue) => {
|
|
18
|
+
localeDictionariesSignal.set(newValue ?? {});
|
|
19
|
+
},
|
|
20
|
+
setLocaleDictionary(dictionary) {
|
|
21
|
+
const current = localeDictionariesSignal();
|
|
22
|
+
localeDictionariesSignal.set({
|
|
23
|
+
...current,
|
|
24
|
+
[dictionary.key]: dictionary
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return instance;
|
|
24
29
|
};
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Helper to install the provider into the injector
|
|
32
|
+
*/
|
|
33
|
+
const installDictionariesRecord = (_injector) => {
|
|
34
|
+
createDictionaryRecordClient();
|
|
27
35
|
};
|
|
28
36
|
const useDictionariesRecord = createSharedComposable(() => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
void 0
|
|
36
|
-
);
|
|
37
|
-
effect(() => {
|
|
38
|
-
const newValue = client.localeDictionaries();
|
|
39
|
-
setDictionariesRecord(newValue);
|
|
40
|
-
});
|
|
37
|
+
const client = createDictionaryRecordClient();
|
|
38
|
+
if (!client) throw new Error("DictionariesRecord state not found");
|
|
39
|
+
const [_dictionariesRecord, setDictionariesRecord] = useCrossFrameState(MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED, void 0);
|
|
40
|
+
effect(() => {
|
|
41
|
+
setDictionariesRecord(client.localeDictionaries());
|
|
42
|
+
});
|
|
41
43
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
useDictionariesRecord
|
|
46
|
-
};
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
export { createDictionaryRecordClient, installDictionariesRecord, useDictionariesRecord };
|
|
47
47
|
//# sourceMappingURL=dictionariesRecord.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/dictionariesRecord.ts"],"sourcesContent":["import { effect, Injector,
|
|
1
|
+
{"version":3,"file":"dictionariesRecord.mjs","names":["instance: DictionariesRecordClient | null"],"sources":["../../../src/editor/dictionariesRecord.ts"],"sourcesContent":["import { effect, type Injector, type Signal, signal } from '@angular/core';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport { MessageKey } from '@intlayer/editor';\nimport type { Dictionary } from '@intlayer/types';\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 dictionaries = getDictionaries();\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":";;;;;;;;;;AAUA,IAAIA,WAA4C;AAUhD,MAAa,qCAAqC;AAChD,KAAI,SAAU,QAAO;CAGrB,MAAM,2BAA2B,OADZ,iBAAiB,CACkC;AAExE,YAAW;EACT,oBAAoB,yBAAyB,YAAY;EAEzD,wBAAwB,aAAa;AACnC,4BAAyB,IAAI,YAAY,EAAE,CAAC;;EAG9C,oBAAoB,YAAY;GAC9B,MAAM,UAAU,0BAA0B;AAC1C,4BAAyB,IAAI;IAC3B,GAAG;KACF,WAAW,MAAM;IACnB,CAAC;;EAEL;AAED,QAAO;;;;;AAMT,MAAa,6BAA6B,cAAwB;AAChD,+BAA8B;;AAMhD,MAAa,wBAAwB,6BAA6B;CAChE,MAAM,SAAS,8BAA8B;AAE7C,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,qCAAqC;CAGvD,MAAM,CAAC,qBAAqB,yBAC1B,mBACE,WAAW,sCACX,OACD;AAGH,cAAa;AAEX,wBADiB,OAAO,oBAAoB,CACb;GAC/B;EACF"}
|
|
@@ -1,51 +1,58 @@
|
|
|
1
|
-
import { effect, signal } from "@angular/core";
|
|
2
|
-
import { getContentNodeByKeyPath } from "@intlayer/core";
|
|
3
|
-
import { MessageKey } from "@intlayer/editor";
|
|
4
1
|
import { createSharedComposable } from "./createSharedComposable.mjs";
|
|
5
2
|
import { useCrossFrameState } from "./useCrossFrameState.mjs";
|
|
3
|
+
import { getContentNodeByKeyPath } from "@intlayer/core";
|
|
4
|
+
import { effect, signal } from "@angular/core";
|
|
5
|
+
import { MessageKey } from "@intlayer/editor";
|
|
6
|
+
|
|
7
|
+
//#region src/editor/editedContent.ts
|
|
8
|
+
/**
|
|
9
|
+
* Singleton instance
|
|
10
|
+
*/
|
|
6
11
|
let instance = null;
|
|
7
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Creates an edited content client
|
|
14
|
+
*/
|
|
8
15
|
const createEditedContentClient = () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
if (instance) return instance;
|
|
17
|
+
const editedContentSignal = signal({});
|
|
18
|
+
instance = {
|
|
19
|
+
editedContent: editedContentSignal.asReadonly(),
|
|
20
|
+
getEditedContentValue: (localDictionaryIdOrKey, keyPath) => {
|
|
21
|
+
const editedContent = editedContentSignal();
|
|
22
|
+
if (!editedContent) return void 0;
|
|
23
|
+
if (localDictionaryIdOrKey.includes(":local:") || localDictionaryIdOrKey.includes(":remote:")) return getContentNodeByKeyPath(editedContent?.[localDictionaryIdOrKey]?.content ?? {}, keyPath);
|
|
24
|
+
const filteredDictionariesLocalId = Object.keys(editedContent).filter((key) => key.startsWith(`${localDictionaryIdOrKey}:`));
|
|
25
|
+
for (const localDictionaryId of filteredDictionariesLocalId) {
|
|
26
|
+
const contentNode = getContentNodeByKeyPath(editedContent?.[localDictionaryId]?.content ?? {}, keyPath);
|
|
27
|
+
if (contentNode) return contentNode;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
setEditedContent: (editedContent) => {
|
|
31
|
+
editedContentSignal.set(editedContent);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
return instance;
|
|
23
35
|
};
|
|
24
|
-
|
|
25
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Helper to install the edited content into the injector
|
|
38
|
+
*/
|
|
39
|
+
const installEditedContent = (_injector) => {
|
|
40
|
+
createEditedContentClient();
|
|
26
41
|
};
|
|
27
42
|
const useEditedContent = createSharedComposable(() => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
effect(() => {
|
|
41
|
-
const newValue = client.editedContent();
|
|
42
|
-
setEdited(newValue);
|
|
43
|
-
});
|
|
44
|
-
return client;
|
|
43
|
+
const client = createEditedContentClient();
|
|
44
|
+
if (!client) throw new Error("EditedContent state not found");
|
|
45
|
+
const [edited, setEdited] = useCrossFrameState(MessageKey.INTLAYER_EDITED_CONTENT_CHANGED, {});
|
|
46
|
+
effect(() => {
|
|
47
|
+
const newValue = edited();
|
|
48
|
+
client.setEditedContent(newValue ?? {});
|
|
49
|
+
});
|
|
50
|
+
effect(() => {
|
|
51
|
+
setEdited(client.editedContent());
|
|
52
|
+
});
|
|
53
|
+
return client;
|
|
45
54
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
useEditedContent
|
|
50
|
-
};
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { createEditedContentClient, installEditedContent, useEditedContent };
|
|
51
58
|
//# sourceMappingURL=editedContent.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/editedContent.ts"],"sourcesContent":["import { effect, Injector,
|
|
1
|
+
{"version":3,"file":"editedContent.mjs","names":["instance: EditedContentClient | null"],"sources":["../../../src/editor/editedContent.ts"],"sourcesContent":["import { effect, type Injector, type Signal, signal } from '@angular/core';\nimport { getContentNodeByKeyPath } from '@intlayer/core';\nimport { MessageKey } from '@intlayer/editor';\nimport type {\n ContentNode,\n Dictionary,\n KeyPath,\n LocalDictionaryId,\n} from '@intlayer/types';\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 localDictionaryIdOrKey: LocalDictionaryId | Dictionary['key'] | string,\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 localDictionaryIdOrKey: LocalDictionaryId | Dictionary['key'] | string,\n keyPath: KeyPath[]\n ): ContentNode | undefined => {\n const editedContent = editedContentSignal();\n\n if (!editedContent) return undefined;\n\n const isDictionaryId =\n localDictionaryIdOrKey.includes(':local:') ||\n localDictionaryIdOrKey.includes(':remote:');\n\n if (isDictionaryId) {\n const currentContent =\n editedContent?.[localDictionaryIdOrKey as LocalDictionaryId]\n ?.content ?? {};\n\n const contentNode = getContentNodeByKeyPath(currentContent, keyPath);\n\n return contentNode;\n }\n\n const filteredDictionariesLocalId = Object.keys(editedContent).filter(\n (key) => key.startsWith(`${localDictionaryIdOrKey}:`)\n );\n\n for (const localDictionaryId of filteredDictionariesLocalId) {\n const currentContent =\n editedContent?.[localDictionaryId as LocalDictionaryId]?.content ??\n {};\n const contentNode = getContentNodeByKeyPath(currentContent, keyPath);\n\n if (contentNode) return contentNode;\n }\n\n return undefined;\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":";;;;;;;;;;AA0BA,IAAIA,WAAuC;;;;AAO3C,MAAa,kCAAkC;AAC7C,KAAI,SAAU,QAAO;CAErB,MAAM,sBAAsB,OAAsB,EAAE,CAAC;AAErD,YAAW;EACT,eAAe,oBAAoB,YAAY;EAC/C,wBACE,wBACA,YAC4B;GAC5B,MAAM,gBAAgB,qBAAqB;AAE3C,OAAI,CAAC,cAAe,QAAO;AAM3B,OAHE,uBAAuB,SAAS,UAAU,IAC1C,uBAAuB,SAAS,WAAW,CAS3C,QAFoB,wBAHlB,gBAAgB,yBACZ,WAAW,EAAE,EAEyC,QAAQ;GAKtE,MAAM,8BAA8B,OAAO,KAAK,cAAc,CAAC,QAC5D,QAAQ,IAAI,WAAW,GAAG,uBAAuB,GAAG,CACtD;AAED,QAAK,MAAM,qBAAqB,6BAA6B;IAI3D,MAAM,cAAc,wBAFlB,gBAAgB,oBAAyC,WACzD,EAAE,EACwD,QAAQ;AAEpE,QAAI,YAAa,QAAO;;;EAK5B,mBAAmB,kBAAiC;AAClD,uBAAoB,IAAI,cAAc;;EAEzC;AAED,QAAO;;;;;AAMT,MAAa,wBAAwB,cAAwB;AAC3C,4BAA2B;;AAM7C,MAAa,mBAAmB,6BAA6B;CAC3D,MAAM,SAAS,2BAA2B;AAE1C,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,gCAAgC;CAGlD,MAAM,CAAC,QAAQ,aAAa,mBAC1B,WAAW,iCACX,EAAE,CACH;AAGD,cAAa;EACX,MAAM,WAAW,QAAQ;AACzB,SAAO,iBAAiB,YAAY,EAAE,CAAC;GACvC;AAEF,cAAa;AAEX,YADiB,OAAO,eAAe,CACpB;GACnB;AAEF,QAAO;EACP"}
|
|
@@ -1,50 +1,46 @@
|
|
|
1
|
-
import { computed, effect, signal } from "@angular/core";
|
|
2
|
-
import { MessageKey } from "@intlayer/editor";
|
|
3
1
|
import { createSharedComposable } from "./createSharedComposable.mjs";
|
|
4
2
|
import { useCrossFrameMessageListener } from "./useCrossFrameMessageListener.mjs";
|
|
3
|
+
import { computed, effect, signal } from "@angular/core";
|
|
4
|
+
import { MessageKey } from "@intlayer/editor";
|
|
5
|
+
|
|
6
|
+
//#region src/editor/editorEnabled.ts
|
|
7
|
+
/**
|
|
8
|
+
* Singleton instance
|
|
9
|
+
*/
|
|
5
10
|
let instance = null;
|
|
6
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Creates an editor wrapperEnabled client
|
|
13
|
+
*/
|
|
7
14
|
const createEditorEnabledClient = () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
return instance;
|
|
15
|
+
if (instance) return instance;
|
|
16
|
+
const wrapperEnabledSignal = signal(false);
|
|
17
|
+
const isInIframeSignal = signal(false);
|
|
18
|
+
const enabledSignal = computed(() => wrapperEnabledSignal() && isInIframeSignal());
|
|
19
|
+
instance = {
|
|
20
|
+
wrapperEnabled: wrapperEnabledSignal.asReadonly(),
|
|
21
|
+
isInIframe: isInIframeSignal.asReadonly(),
|
|
22
|
+
enabled: enabledSignal
|
|
23
|
+
};
|
|
24
|
+
return instance;
|
|
20
25
|
};
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Helper to install the editor wrapperEnabled state into the injector
|
|
28
|
+
*/
|
|
29
|
+
const installEditorEnabled = (_injector) => {
|
|
30
|
+
createEditorEnabledClient();
|
|
23
31
|
};
|
|
24
32
|
const useEditorEnabled = createSharedComposable(() => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
);
|
|
35
|
-
effect(
|
|
36
|
-
() => {
|
|
37
|
-
if (typeof window !== "undefined") {
|
|
38
|
-
client.isInIframe.set(window.self !== window.top);
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
{ allowSignalWrites: true }
|
|
42
|
-
);
|
|
43
|
-
return client;
|
|
33
|
+
const client = createEditorEnabledClient();
|
|
34
|
+
if (!client) throw new Error("EditorEnabled state not found");
|
|
35
|
+
useCrossFrameMessageListener(`${MessageKey.INTLAYER_EDITOR_ENABLED}/post`, (data) => {
|
|
36
|
+
client.wrapperEnabled.set(data);
|
|
37
|
+
});
|
|
38
|
+
effect(() => {
|
|
39
|
+
if (typeof window !== "undefined") client.isInIframe.set(window.self !== window.top);
|
|
40
|
+
}, { allowSignalWrites: true });
|
|
41
|
+
return client;
|
|
44
42
|
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
useEditorEnabled
|
|
49
|
-
};
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { createEditorEnabledClient, installEditorEnabled, useEditorEnabled };
|
|
50
46
|
//# sourceMappingURL=editorEnabled.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/editorEnabled.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"editorEnabled.mjs","names":["instance: EditorEnabledStateProps | null"],"sources":["../../../src/editor/editorEnabled.ts"],"sourcesContent":["import {\n computed,\n effect,\n type Injector,\n type Signal,\n signal,\n} 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":";;;;;;;;;AAuBA,IAAIA,WAA2C;;;;AAO/C,MAAa,kCAAkC;AAC7C,KAAI,SAAU,QAAO;CAErB,MAAM,uBAAuB,OAAO,MAAM;CAC1C,MAAM,mBAAmB,OAAO,MAAM;CACtC,MAAM,gBAAgB,eACd,sBAAsB,IAAI,kBAAkB,CACnD;AAED,YAAW;EACT,gBAAgB,qBAAqB,YAAY;EACjD,YAAY,iBAAiB,YAAY;EACzC,SAAS;EACV;AAED,QAAO;;;;;AAMT,MAAa,wBAAwB,cAAwB;AAC3C,4BAA2B;;AAM7C,MAAa,mBAAmB,6BAA6B;CAC3D,MAAM,SAAS,2BAA2B;AAE1C,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,gCAAgC;AAIlD,8BACE,GAAG,WAAW,wBAAwB,SACrC,SAAS;AACR,EAAC,OAAO,eAAuB,IAAI,KAAK;GAE3C;AAGD,cACQ;AACJ,MAAI,OAAO,WAAW,YACpB,CAAC,OAAO,WAAmB,IAAI,OAAO,SAAS,OAAO,IAAI;IAG9D,EAAE,mBAAmB,MAAM,CAC5B;AAED,QAAO;EACP"}
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
import { effect, inject } from "@angular/core";
|
|
2
|
-
import { MessageKey } from "@intlayer/editor";
|
|
3
|
-
import { INTLAYER_TOKEN } from "../client/index.mjs";
|
|
4
1
|
import { createSharedComposable } from "./createSharedComposable.mjs";
|
|
5
2
|
import { useCrossFrameState } from "./useCrossFrameState.mjs";
|
|
3
|
+
import { INTLAYER_TOKEN } from "../client/installIntlayer.mjs";
|
|
4
|
+
import { effect, inject } from "@angular/core";
|
|
5
|
+
import { MessageKey } from "@intlayer/editor";
|
|
6
|
+
|
|
7
|
+
//#region src/editor/editorLocale.ts
|
|
6
8
|
const useEditorLocale = createSharedComposable(() => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
effect(() => {
|
|
15
|
-
const newValue = client.locale();
|
|
16
|
-
setData(newValue);
|
|
17
|
-
});
|
|
18
|
-
return client;
|
|
9
|
+
const client = inject(INTLAYER_TOKEN);
|
|
10
|
+
if (!client) throw new Error("IntlayerEditor state not found");
|
|
11
|
+
const [_data, setData] = useCrossFrameState(MessageKey.INTLAYER_CURRENT_LOCALE);
|
|
12
|
+
effect(() => {
|
|
13
|
+
setData(client.locale());
|
|
14
|
+
});
|
|
15
|
+
return client;
|
|
19
16
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { useEditorLocale };
|
|
23
20
|
//# sourceMappingURL=editorLocale.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/editorLocale.ts"],"sourcesContent":["import { effect, inject } from '@angular/core';\nimport
|
|
1
|
+
{"version":3,"file":"editorLocale.mjs","names":[],"sources":["../../../src/editor/editorLocale.ts"],"sourcesContent":["import { effect, inject } from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport type { Locale, LocalesValues } from '@intlayer/types';\nimport { INTLAYER_TOKEN, type 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<LocalesValues>(\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 as Locale);\n });\n\n return client;\n});\n"],"mappings":";;;;;;;AAOA,MAAa,kBAAkB,6BAA6B;CAC1D,MAAM,SAAS,OAAyB,eAAe;AAEvD,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,iCAAiC;CAGnD,MAAM,CAAC,OAAO,WAAW,mBACvB,WAAW,wBACZ;AAGD,cAAa;AAEX,UADiB,OAAO,QAAQ,CACL;GAC3B;AAEF,QAAO;EACP"}
|
|
@@ -1,54 +1,59 @@
|
|
|
1
|
-
import { effect, signal } from "@angular/core";
|
|
2
|
-
import { MessageKey } from "@intlayer/editor";
|
|
3
1
|
import { createSharedComposable } from "./createSharedComposable.mjs";
|
|
4
2
|
import { useCrossFrameState } from "./useCrossFrameState.mjs";
|
|
3
|
+
import { effect, signal } from "@angular/core";
|
|
4
|
+
import { MessageKey } from "@intlayer/editor";
|
|
5
|
+
|
|
6
|
+
//#region src/editor/focusDictionary.ts
|
|
7
|
+
/**
|
|
8
|
+
* Singleton instance
|
|
9
|
+
*/
|
|
5
10
|
let instance = null;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a focus dictionary client
|
|
13
|
+
*/
|
|
6
14
|
const createFocusDictionaryClient = () => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
if (instance) return instance;
|
|
16
|
+
const focusedContentSignal = signal(null);
|
|
17
|
+
const setFocusedContent = (focussedContent) => {
|
|
18
|
+
focusedContentSignal.set(focussedContent);
|
|
19
|
+
};
|
|
20
|
+
const setFocusedContentKeyPath = (keyPath) => {
|
|
21
|
+
const current = focusedContentSignal();
|
|
22
|
+
if (!current) return;
|
|
23
|
+
setFocusedContent({
|
|
24
|
+
...current,
|
|
25
|
+
keyPath
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
instance = {
|
|
29
|
+
focusedContent: focusedContentSignal.asReadonly(),
|
|
30
|
+
setFocusedContent,
|
|
31
|
+
setFocusedContentKeyPath
|
|
32
|
+
};
|
|
33
|
+
return instance;
|
|
23
34
|
};
|
|
24
|
-
|
|
25
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Helper to install the focus dictionary into the injector
|
|
37
|
+
*/
|
|
38
|
+
const installFocusDictionary = (_injector) => {
|
|
39
|
+
createFocusDictionaryClient();
|
|
26
40
|
};
|
|
41
|
+
/** consumer */
|
|
27
42
|
const useFocusDictionary = createSharedComposable(() => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
-
effect(() => {
|
|
42
|
-
const newValue = focusedContent();
|
|
43
|
-
if (JSON.stringify(newValue) !== JSON.stringify(client.focusedContent())) {
|
|
44
|
-
client.setFocusedContent(newValue ?? null);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
return client;
|
|
43
|
+
const client = createFocusDictionaryClient();
|
|
44
|
+
const [focusedContent, setFocusedContent] = useCrossFrameState(MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED);
|
|
45
|
+
if (!client) throw new Error("FocusDictionary state not found");
|
|
46
|
+
effect(() => {
|
|
47
|
+
const newValue = client.focusedContent();
|
|
48
|
+
if (JSON.stringify(newValue) !== JSON.stringify(focusedContent())) setFocusedContent(newValue);
|
|
49
|
+
});
|
|
50
|
+
effect(() => {
|
|
51
|
+
const newValue = focusedContent();
|
|
52
|
+
if (JSON.stringify(newValue) !== JSON.stringify(client.focusedContent())) client.setFocusedContent(newValue ?? null);
|
|
53
|
+
});
|
|
54
|
+
return client;
|
|
48
55
|
});
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
useFocusDictionary
|
|
53
|
-
};
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
export { createFocusDictionaryClient, installFocusDictionary, useFocusDictionary };
|
|
54
59
|
//# sourceMappingURL=focusDictionary.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/focusDictionary.ts"],"sourcesContent":["import { effect, Injector,
|
|
1
|
+
{"version":3,"file":"focusDictionary.mjs","names":["instance: FocusDictionaryClient | null"],"sources":["../../../src/editor/focusDictionary.ts"],"sourcesContent":["import { effect, type Injector, type Signal, signal } from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport type { KeyPath } from '@intlayer/types';\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":";;;;;;;;;AAqBA,IAAIA,WAAyC;;;;AAK7C,MAAa,oCAAoC;AAC/C,KAAI,SAAU,QAAO;CAErB,MAAM,uBAAuB,OAA2B,KAAK;CAE7D,MAAM,qBAAqB,oBAAwC;AACjE,uBAAqB,IAAI,gBAAgB;;CAG3C,MAAM,4BAA4B,YAAuB;EACvD,MAAM,UAAU,sBAAsB;AACtC,MAAI,CAAC,QAAS;AACd,oBAAkB;GAAE,GAAG;GAAS;GAAS,CAAC;;AAG5C,YAAW;EACT,gBAAgB,qBAAqB,YAAY;EACjD;EACA;EACD;AAED,QAAO;;;;;AAMT,MAAa,0BAA0B,cAAwB;AAC7C,8BAA6B;;;AAO/C,MAAa,qBAAqB,6BAA6B;CAC7D,MAAM,SAAS,6BAA6B;CAC5C,MAAM,CAAC,gBAAgB,qBACrB,mBACE,WAAW,iCACZ;AAEH,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,kCAAkC;AAKpD,cAAa;EACX,MAAM,WAAW,OAAO,gBAAgB;AACxC,MAAI,KAAK,UAAU,SAAS,KAAK,KAAK,UAAU,gBAAgB,CAAC,CAC/D,mBAAkB,SAAS;GAE7B;AAGF,cAAa;EACX,MAAM,WAAW,gBAAgB;AACjC,MAAI,KAAK,UAAU,SAAS,KAAK,KAAK,UAAU,OAAO,gBAAgB,CAAC,CACtE,QAAO,kBAAkB,YAAY,KAAK;GAE5C;AAEF,QAAO;EACP"}
|