angular-intlayer 8.1.2 → 8.1.3
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 +2 -116
- package/dist/cjs/UI/ContentSelector.component.cjs.map +1 -1
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.cjs +1 -11
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.cjs +1 -8
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
- package/dist/cjs/client/index.cjs +1 -28
- package/dist/cjs/client/installIntlayer.cjs +1 -77
- package/dist/cjs/client/installIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useDictionary.cjs +1 -15
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs +1 -24
- package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +1 -25
- package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
- package/dist/cjs/client/useIntl.cjs +1 -40
- package/dist/cjs/client/useIntl.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs +1 -44
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useLoadDynamic.cjs +1 -28
- package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs +1 -60
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocaleStorage.cjs +1 -60
- package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
- package/dist/cjs/editor/ContentSelectorWrapper.component.cjs +2 -51
- package/dist/cjs/editor/ContentSelectorWrapper.component.cjs.map +1 -1
- package/dist/cjs/editor/EditedContentRenderer.component.cjs +1 -54
- package/dist/cjs/editor/EditedContentRenderer.component.cjs.map +1 -1
- package/dist/cjs/editor/EditorSelectorRenderer.component.cjs +2 -35
- package/dist/cjs/editor/EditorSelectorRenderer.component.cjs.map +1 -1
- package/dist/cjs/editor/communicator.cjs +1 -63
- package/dist/cjs/editor/communicator.cjs.map +1 -1
- package/dist/cjs/editor/configuration.cjs +1 -22
- package/dist/cjs/editor/configuration.cjs.map +1 -1
- package/dist/cjs/editor/createSharedComposable.cjs +1 -50
- package/dist/cjs/editor/createSharedComposable.cjs.map +1 -1
- package/dist/cjs/editor/dictionariesRecord.cjs +1 -49
- package/dist/cjs/editor/dictionariesRecord.cjs.map +1 -1
- package/dist/cjs/editor/editedContent.cjs +1 -61
- package/dist/cjs/editor/editedContent.cjs.map +1 -1
- package/dist/cjs/editor/editorEnabled.cjs +1 -49
- package/dist/cjs/editor/editorEnabled.cjs.map +1 -1
- package/dist/cjs/editor/editorLocale.cjs +1 -21
- package/dist/cjs/editor/editorLocale.cjs.map +1 -1
- package/dist/cjs/editor/focusDictionary.cjs +1 -62
- package/dist/cjs/editor/focusDictionary.cjs.map +1 -1
- package/dist/cjs/editor/index.cjs +1 -25
- package/dist/cjs/editor/installIntlayerEditor.cjs +1 -52
- package/dist/cjs/editor/installIntlayerEditor.cjs.map +1 -1
- package/dist/cjs/editor/useCrossFrameMessageListener.cjs +1 -73
- package/dist/cjs/editor/useCrossFrameMessageListener.cjs.map +1 -1
- package/dist/cjs/editor/useCrossFrameState.cjs +1 -114
- package/dist/cjs/editor/useCrossFrameState.cjs.map +1 -1
- package/dist/cjs/editor/useCrossURLPathState.cjs +1 -65
- package/dist/cjs/editor/useCrossURLPathState.cjs.map +1 -1
- package/dist/cjs/editor/useEditedContentRenderer.cjs +1 -35
- package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -1
- package/dist/cjs/editor/useEditor.cjs +1 -24
- package/dist/cjs/editor/useEditor.cjs.map +1 -1
- package/dist/cjs/editor/useIframeClickInterceptor.cjs +1 -39
- package/dist/cjs/editor/useIframeClickInterceptor.cjs.map +1 -1
- package/dist/cjs/getDictionary.cjs +1 -17
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs +1 -18
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -49
- package/dist/cjs/markdown/index.cjs +1 -13
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs +1 -79
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -1
- package/dist/cjs/plugins.cjs +1 -188
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/renderIntlayerNode.cjs +1 -28
- package/dist/cjs/renderIntlayerNode.cjs.map +1 -1
- package/dist/cjs/webpack/index.cjs +1 -4
- package/dist/cjs/webpack/mergeConfig.cjs +1 -44
- package/dist/cjs/webpack/mergeConfig.cjs.map +1 -1
- package/dist/esm/UI/ContentSelector.component.mjs +2 -109
- package/dist/esm/UI/ContentSelector.component.mjs.map +1 -1
- package/dist/esm/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs +1 -10
- package/dist/esm/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs +1 -7
- package/dist/esm/client/index.mjs +1 -10
- package/dist/esm/client/installIntlayer.mjs +1 -65
- package/dist/esm/client/installIntlayer.mjs.map +1 -1
- package/dist/esm/client/useDictionary.mjs +1 -13
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/esm/client/useDictionaryAsync.mjs +1 -21
- package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
- package/dist/esm/client/useDictionaryDynamic.mjs +1 -22
- package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
- package/dist/esm/client/useIntl.mjs +1 -38
- package/dist/esm/client/useIntl.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs +1 -41
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useLoadDynamic.mjs +1 -26
- package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
- package/dist/esm/client/useLocale.mjs +1 -57
- package/dist/esm/client/useLocale.mjs.map +1 -1
- package/dist/esm/client/useLocaleStorage.mjs +1 -53
- package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
- package/dist/esm/editor/ContentSelectorWrapper.component.mjs +2 -44
- package/dist/esm/editor/ContentSelectorWrapper.component.mjs.map +1 -1
- package/dist/esm/editor/EditedContentRenderer.component.mjs +1 -47
- package/dist/esm/editor/EditedContentRenderer.component.mjs.map +1 -1
- package/dist/esm/editor/EditorSelectorRenderer.component.mjs +2 -28
- package/dist/esm/editor/EditorSelectorRenderer.component.mjs.map +1 -1
- package/dist/esm/editor/communicator.mjs +1 -58
- package/dist/esm/editor/communicator.mjs.map +1 -1
- package/dist/esm/editor/configuration.mjs +1 -19
- package/dist/esm/editor/configuration.mjs.map +1 -1
- package/dist/esm/editor/createSharedComposable.mjs +1 -47
- package/dist/esm/editor/createSharedComposable.mjs.map +1 -1
- package/dist/esm/editor/dictionariesRecord.mjs +1 -45
- package/dist/esm/editor/dictionariesRecord.mjs.map +1 -1
- package/dist/esm/editor/editedContent.mjs +1 -57
- package/dist/esm/editor/editedContent.mjs.map +1 -1
- package/dist/esm/editor/editorEnabled.mjs +1 -45
- package/dist/esm/editor/editorEnabled.mjs.map +1 -1
- package/dist/esm/editor/editorLocale.mjs +1 -19
- package/dist/esm/editor/editorLocale.mjs.map +1 -1
- package/dist/esm/editor/focusDictionary.mjs +1 -58
- package/dist/esm/editor/focusDictionary.mjs.map +1 -1
- package/dist/esm/editor/index.mjs +1 -6
- package/dist/esm/editor/installIntlayerEditor.mjs +1 -49
- package/dist/esm/editor/installIntlayerEditor.mjs.map +1 -1
- package/dist/esm/editor/useCrossFrameMessageListener.mjs +1 -71
- package/dist/esm/editor/useCrossFrameMessageListener.mjs.map +1 -1
- package/dist/esm/editor/useCrossFrameState.mjs +1 -112
- package/dist/esm/editor/useCrossFrameState.mjs.map +1 -1
- package/dist/esm/editor/useCrossURLPathState.mjs +1 -62
- package/dist/esm/editor/useCrossURLPathState.mjs.map +1 -1
- package/dist/esm/editor/useEditedContentRenderer.mjs +1 -26
- package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -1
- package/dist/esm/editor/useEditor.mjs +1 -23
- package/dist/esm/editor/useEditor.mjs.map +1 -1
- package/dist/esm/editor/useIframeClickInterceptor.mjs +1 -36
- package/dist/esm/editor/useIframeClickInterceptor.mjs.map +1 -1
- package/dist/esm/getDictionary.mjs +1 -15
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs +1 -16
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -14
- package/dist/esm/markdown/index.mjs +1 -3
- package/dist/esm/markdown/installIntlayerMarkdown.mjs +1 -68
- package/dist/esm/markdown/installIntlayerMarkdown.mjs.map +1 -1
- package/dist/esm/plugins.mjs +1 -182
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/esm/renderIntlayerNode.mjs +1 -26
- package/dist/esm/renderIntlayerNode.mjs.map +1 -1
- package/dist/esm/webpack/index.mjs +1 -3
- package/dist/esm/webpack/mergeConfig.mjs +1 -42
- package/dist/esm/webpack/mergeConfig.mjs.map +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts +2 -2
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/editor/ContentSelectorWrapper.component.d.ts +1 -1
- package/dist/types/editor/ContentSelectorWrapper.component.d.ts.map +1 -1
- package/dist/types/editor/EditorSelectorRenderer.component.d.ts +1 -1
- package/dist/types/getDictionary.d.ts +3 -3
- package/dist/types/getDictionary.d.ts.map +1 -1
- package/dist/types/getIntlayer.d.ts +1 -1
- package/dist/types/getIntlayer.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/markdown/installIntlayerMarkdown.d.ts +1 -1
- package/dist/types/markdown/installIntlayerMarkdown.d.ts.map +1 -1
- package/dist/types/plugins.d.ts +1 -1
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/webpack/mergeConfig.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -1,50 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
|
|
4
|
-
const require_editor_useCrossFrameState = require('./useCrossFrameState.cjs');
|
|
5
|
-
let _angular_core = require("@angular/core");
|
|
6
|
-
let _intlayer_editor = require("@intlayer/editor");
|
|
7
|
-
|
|
8
|
-
//#region src/editor/dictionariesRecord.ts
|
|
9
|
-
/**
|
|
10
|
-
* Singleton instance
|
|
11
|
-
*/
|
|
12
|
-
let instance = null;
|
|
13
|
-
const createDictionaryRecordClient = () => {
|
|
14
|
-
if (instance) return instance;
|
|
15
|
-
const localeDictionariesSignal = (0, _angular_core.signal)(void 0);
|
|
16
|
-
instance = {
|
|
17
|
-
localeDictionaries: localeDictionariesSignal.asReadonly(),
|
|
18
|
-
setLocaleDictionaries: (newValue) => {
|
|
19
|
-
localeDictionariesSignal.set(newValue ?? {});
|
|
20
|
-
},
|
|
21
|
-
setLocaleDictionary(dictionary) {
|
|
22
|
-
const current = localeDictionariesSignal();
|
|
23
|
-
localeDictionariesSignal.set({
|
|
24
|
-
...current,
|
|
25
|
-
[dictionary.localId]: dictionary
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
return instance;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Helper to install the provider into the injector
|
|
33
|
-
*/
|
|
34
|
-
const installDictionariesRecord = (_injector) => {
|
|
35
|
-
createDictionaryRecordClient();
|
|
36
|
-
};
|
|
37
|
-
const useDictionariesRecord = require_editor_createSharedComposable.createSharedComposable(() => {
|
|
38
|
-
const client = createDictionaryRecordClient();
|
|
39
|
-
if (!client) throw new Error("DictionariesRecord state not found");
|
|
40
|
-
const [_dictionariesRecord, setDictionariesRecord] = require_editor_useCrossFrameState.useCrossFrameState(_intlayer_editor.MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED, void 0);
|
|
41
|
-
(0, _angular_core.effect)(() => {
|
|
42
|
-
setDictionariesRecord(client.localeDictionaries());
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
//#endregion
|
|
47
|
-
exports.createDictionaryRecordClient = createDictionaryRecordClient;
|
|
48
|
-
exports.installDictionariesRecord = installDictionariesRecord;
|
|
49
|
-
exports.useDictionariesRecord = useDictionariesRecord;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./createSharedComposable.cjs`),t=require(`./useCrossFrameState.cjs`);let n=require(`@angular/core`),r=require(`@intlayer/editor`),i=null;const a=()=>{if(i)return i;let e=(0,n.signal)(void 0);return i={localeDictionaries:e.asReadonly(),setLocaleDictionaries:t=>{e.set(t??{})},setLocaleDictionary(t){let n=e();e.set({...n,[t.localId]:t})}},i},o=e=>{a()},s=e.createSharedComposable(()=>{let e=a();if(!e)throw Error(`DictionariesRecord state not found`);let[i,o]=t.useCrossFrameState(r.MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED,void 0);(0,n.effect)(()=>{o(e.localeDictionaries())})});exports.createDictionaryRecordClient=a,exports.installDictionariesRecord=o,exports.useDictionariesRecord=s;
|
|
50
2
|
//# sourceMappingURL=dictionariesRecord.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dictionariesRecord.cjs","names":["createSharedComposable","useCrossFrameState","MessageKey"],"sources":["../../../src/editor/dictionariesRecord.ts"],"sourcesContent":["import { effect, type Injector, type Signal, signal } from '@angular/core';\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: (dictionary: Dictionary) => void;\n};\n\nexport const createDictionaryRecordClient = () => {\n if (instance) return instance;\n\n const localeDictionariesSignal = signal<DictionaryContent | undefined>(\n undefined\n );\n\n instance = {\n localeDictionaries:\n localeDictionariesSignal.asReadonly() as Signal<DictionaryContent>,\n\n setLocaleDictionaries: (newValue) => {\n localeDictionariesSignal.set(newValue ?? {});\n },\n\n setLocaleDictionary(dictionary) {\n const current = localeDictionariesSignal();\n localeDictionariesSignal.set({\n ...current,\n [dictionary.localId!]: 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":"
|
|
1
|
+
{"version":3,"file":"dictionariesRecord.cjs","names":["createSharedComposable","useCrossFrameState","MessageKey"],"sources":["../../../src/editor/dictionariesRecord.ts"],"sourcesContent":["import { effect, type Injector, type Signal, signal } from '@angular/core';\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: (dictionary: Dictionary) => void;\n};\n\nexport const createDictionaryRecordClient = () => {\n if (instance) return instance;\n\n const localeDictionariesSignal = signal<DictionaryContent | undefined>(\n undefined\n );\n\n instance = {\n localeDictionaries:\n localeDictionariesSignal.asReadonly() as Signal<DictionaryContent>,\n\n setLocaleDictionaries: (newValue) => {\n localeDictionariesSignal.set(newValue ?? {});\n },\n\n setLocaleDictionary(dictionary) {\n const current = localeDictionariesSignal();\n localeDictionariesSignal.set({\n ...current,\n [dictionary.localId!]: 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":"mQASI,EAA4C,KAUhD,MAAa,MAAqC,CAChD,GAAI,EAAU,OAAO,EAErB,IAAM,GAAA,EAAA,EAAA,QACJ,IAAA,GACD,CAmBD,MAjBA,GAAW,CACT,mBACE,EAAyB,YAAY,CAEvC,sBAAwB,GAAa,CACnC,EAAyB,IAAI,GAAY,EAAE,CAAC,EAG9C,oBAAoB,EAAY,CAC9B,IAAM,EAAU,GAA0B,CAC1C,EAAyB,IAAI,CAC3B,GAAG,GACF,EAAW,SAAW,EACxB,CAAC,EAEL,CAEM,GAMI,EAA6B,GAAwB,CAChD,GAA8B,EAMnC,EAAwBA,EAAAA,2BAA6B,CAChE,IAAM,EAAS,GAA8B,CAE7C,GAAI,CAAC,EACH,MAAU,MAAM,qCAAqC,CAGvD,GAAM,CAAC,EAAqB,GAC1BC,EAAAA,mBACEC,EAAAA,WAAW,qCACX,IAAA,GACD,EAGH,EAAA,EAAA,YAAa,CAEX,EADiB,EAAO,oBAAoB,CACb,EAC/B,EACF"}
|
|
@@ -1,62 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
|
|
4
|
-
const require_editor_useCrossFrameState = require('./useCrossFrameState.cjs');
|
|
5
|
-
let _intlayer_core = require("@intlayer/core");
|
|
6
|
-
let _angular_core = require("@angular/core");
|
|
7
|
-
let _intlayer_editor = require("@intlayer/editor");
|
|
8
|
-
|
|
9
|
-
//#region src/editor/editedContent.ts
|
|
10
|
-
/**
|
|
11
|
-
* Singleton instance
|
|
12
|
-
*/
|
|
13
|
-
let instance = null;
|
|
14
|
-
/**
|
|
15
|
-
* Creates an edited content client
|
|
16
|
-
*/
|
|
17
|
-
const createEditedContentClient = () => {
|
|
18
|
-
if (instance) return instance;
|
|
19
|
-
const editedContentSignal = (0, _angular_core.signal)({});
|
|
20
|
-
instance = {
|
|
21
|
-
editedContent: editedContentSignal.asReadonly(),
|
|
22
|
-
getEditedContentValue: (localDictionaryIdOrKey, keyPath) => {
|
|
23
|
-
const editedContent = editedContentSignal();
|
|
24
|
-
if (!editedContent) return void 0;
|
|
25
|
-
if (localDictionaryIdOrKey.includes(":local:") || localDictionaryIdOrKey.includes(":remote:")) return (0, _intlayer_core.getContentNodeByKeyPath)(editedContent?.[localDictionaryIdOrKey]?.content ?? {}, keyPath);
|
|
26
|
-
const filteredDictionariesLocalId = Object.keys(editedContent).filter((key) => key.startsWith(`${localDictionaryIdOrKey}:`));
|
|
27
|
-
for (const localDictionaryId of filteredDictionariesLocalId) {
|
|
28
|
-
const contentNode = (0, _intlayer_core.getContentNodeByKeyPath)(editedContent?.[localDictionaryId]?.content ?? {}, keyPath);
|
|
29
|
-
if (contentNode) return contentNode;
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
setEditedContent: (editedContent) => {
|
|
33
|
-
editedContentSignal.set(editedContent);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
return instance;
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Helper to install the edited content into the injector
|
|
40
|
-
*/
|
|
41
|
-
const installEditedContent = (_injector) => {
|
|
42
|
-
createEditedContentClient();
|
|
43
|
-
};
|
|
44
|
-
const useEditedContent = require_editor_createSharedComposable.createSharedComposable(() => {
|
|
45
|
-
const client = createEditedContentClient();
|
|
46
|
-
if (!client) throw new Error("EditedContent state not found");
|
|
47
|
-
const [edited, setEdited] = require_editor_useCrossFrameState.useCrossFrameState(_intlayer_editor.MessageKey.INTLAYER_EDITED_CONTENT_CHANGED, {});
|
|
48
|
-
(0, _angular_core.effect)(() => {
|
|
49
|
-
const newValue = edited();
|
|
50
|
-
client.setEditedContent(newValue ?? {});
|
|
51
|
-
});
|
|
52
|
-
(0, _angular_core.effect)(() => {
|
|
53
|
-
setEdited(client.editedContent());
|
|
54
|
-
});
|
|
55
|
-
return client;
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
//#endregion
|
|
59
|
-
exports.createEditedContentClient = createEditedContentClient;
|
|
60
|
-
exports.installEditedContent = installEditedContent;
|
|
61
|
-
exports.useEditedContent = useEditedContent;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./createSharedComposable.cjs`),t=require(`./useCrossFrameState.cjs`);let n=require(`@angular/core`),r=require(`@intlayer/editor`),i=require(`@intlayer/core/dictionaryManipulator`),a=null;const o=()=>{if(a)return a;let e=(0,n.signal)({});return a={editedContent:e.asReadonly(),getEditedContentValue:(t,n)=>{let r=e();if(!r)return;if(t.includes(`:local:`)||t.includes(`:remote:`))return(0,i.getContentNodeByKeyPath)(r?.[t]?.content??{},n);let a=Object.keys(r).filter(e=>e.startsWith(`${t}:`));for(let e of a){let t=(0,i.getContentNodeByKeyPath)(r?.[e]?.content??{},n);if(t)return t}},setEditedContent:t=>{e.set(t)}},a},s=e=>{o()},c=e.createSharedComposable(()=>{let e=o();if(!e)throw Error(`EditedContent state not found`);let[i,a]=t.useCrossFrameState(r.MessageKey.INTLAYER_EDITED_CONTENT_CHANGED,{});return(0,n.effect)(()=>{let t=i();e.setEditedContent(t??{})}),(0,n.effect)(()=>{a(e.editedContent())}),e});exports.createEditedContentClient=o,exports.installEditedContent=s,exports.useEditedContent=c;
|
|
62
2
|
//# sourceMappingURL=editedContent.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editedContent.cjs","names":["createSharedComposable","useCrossFrameState","MessageKey"],"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":"
|
|
1
|
+
{"version":3,"file":"editedContent.cjs","names":["createSharedComposable","useCrossFrameState","MessageKey"],"sources":["../../../src/editor/editedContent.ts"],"sourcesContent":["import { effect, type Injector, type Signal, signal } from '@angular/core';\nimport { getContentNodeByKeyPath } from '@intlayer/core/dictionaryManipulator';\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":"qTA0BI,EAAuC,KAO3C,MAAa,MAAkC,CAC7C,GAAI,EAAU,OAAO,EAErB,IAAM,GAAA,EAAA,EAAA,QAA4C,EAAE,CAAC,CA8CrD,MA5CA,GAAW,CACT,cAAe,EAAoB,YAAY,CAC/C,uBACE,EACA,IAC4B,CAC5B,IAAM,EAAgB,GAAqB,CAE3C,GAAI,CAAC,EAAe,OAMpB,GAHE,EAAuB,SAAS,UAAU,EAC1C,EAAuB,SAAS,WAAW,CAS3C,OAAA,EAAA,EAAA,yBALE,IAAgB,IACZ,SAAW,EAAE,CAEyC,EAAQ,CAKtE,IAAM,EAA8B,OAAO,KAAK,EAAc,CAAC,OAC5D,GAAQ,EAAI,WAAW,GAAG,EAAuB,GAAG,CACtD,CAED,IAAK,IAAM,KAAqB,EAA6B,CAI3D,IAAM,GAAA,EAAA,EAAA,yBAFJ,IAAgB,IAAyC,SACzD,EAAE,CACwD,EAAQ,CAEpE,GAAI,EAAa,OAAO,IAK5B,iBAAmB,GAAiC,CAClD,EAAoB,IAAI,EAAc,EAEzC,CAEM,GAMI,EAAwB,GAAwB,CAC3C,GAA2B,EAMhC,EAAmBA,EAAAA,2BAA6B,CAC3D,IAAM,EAAS,GAA2B,CAE1C,GAAI,CAAC,EACH,MAAU,MAAM,gCAAgC,CAGlD,GAAM,CAAC,EAAQ,GAAaC,EAAAA,mBAC1BC,EAAAA,WAAW,gCACX,EAAE,CACH,CAaD,OAVA,EAAA,EAAA,YAAa,CACX,IAAM,EAAW,GAAQ,CACzB,EAAO,iBAAiB,GAAY,EAAE,CAAC,EACvC,EAEF,EAAA,EAAA,YAAa,CAEX,EADiB,EAAO,eAAe,CACpB,EACnB,CAEK,GACP"}
|
|
@@ -1,50 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
|
|
4
|
-
const require_editor_useCrossFrameMessageListener = require('./useCrossFrameMessageListener.cjs');
|
|
5
|
-
let _angular_core = require("@angular/core");
|
|
6
|
-
let _intlayer_editor = require("@intlayer/editor");
|
|
7
|
-
|
|
8
|
-
//#region src/editor/editorEnabled.ts
|
|
9
|
-
/**
|
|
10
|
-
* Singleton instance
|
|
11
|
-
*/
|
|
12
|
-
let instance = null;
|
|
13
|
-
/**
|
|
14
|
-
* Creates an editor wrapperEnabled client
|
|
15
|
-
*/
|
|
16
|
-
const createEditorEnabledClient = () => {
|
|
17
|
-
if (instance) return instance;
|
|
18
|
-
const wrapperEnabledSignal = (0, _angular_core.signal)(false);
|
|
19
|
-
const isInIframeSignal = (0, _angular_core.signal)(false);
|
|
20
|
-
const enabledSignal = (0, _angular_core.computed)(() => wrapperEnabledSignal() && isInIframeSignal());
|
|
21
|
-
instance = {
|
|
22
|
-
wrapperEnabled: wrapperEnabledSignal.asReadonly(),
|
|
23
|
-
isInIframe: isInIframeSignal.asReadonly(),
|
|
24
|
-
enabled: enabledSignal
|
|
25
|
-
};
|
|
26
|
-
return instance;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Helper to install the editor wrapperEnabled state into the injector
|
|
30
|
-
*/
|
|
31
|
-
const installEditorEnabled = (_injector) => {
|
|
32
|
-
createEditorEnabledClient();
|
|
33
|
-
};
|
|
34
|
-
const useEditorEnabled = require_editor_createSharedComposable.createSharedComposable(() => {
|
|
35
|
-
const client = createEditorEnabledClient();
|
|
36
|
-
if (!client) throw new Error("EditorEnabled state not found");
|
|
37
|
-
require_editor_useCrossFrameMessageListener.useCrossFrameMessageListener(`${_intlayer_editor.MessageKey.INTLAYER_EDITOR_ENABLED}/post`, (data) => {
|
|
38
|
-
client.wrapperEnabled.set(data);
|
|
39
|
-
});
|
|
40
|
-
(0, _angular_core.effect)(() => {
|
|
41
|
-
if (typeof window !== "undefined") client.isInIframe.set(window.self !== window.top);
|
|
42
|
-
}, { allowSignalWrites: true });
|
|
43
|
-
return client;
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
//#endregion
|
|
47
|
-
exports.createEditorEnabledClient = createEditorEnabledClient;
|
|
48
|
-
exports.installEditorEnabled = installEditorEnabled;
|
|
49
|
-
exports.useEditorEnabled = useEditorEnabled;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./createSharedComposable.cjs`),t=require(`./useCrossFrameMessageListener.cjs`);let n=require(`@angular/core`),r=require(`@intlayer/editor`),i=null;const a=()=>{if(i)return i;let e=(0,n.signal)(!1),t=(0,n.signal)(!1),r=(0,n.computed)(()=>e()&&t());return i={wrapperEnabled:e.asReadonly(),isInIframe:t.asReadonly(),enabled:r},i},o=e=>{a()},s=e.createSharedComposable(()=>{let e=a();if(!e)throw Error(`EditorEnabled state not found`);return t.useCrossFrameMessageListener(`${r.MessageKey.INTLAYER_EDITOR_ENABLED}/post`,t=>{e.wrapperEnabled.set(t)}),(0,n.effect)(()=>{typeof window<`u`&&e.isInIframe.set(window.self!==window.top)},{allowSignalWrites:!0}),e});exports.createEditorEnabledClient=a,exports.installEditorEnabled=o,exports.useEditorEnabled=s;
|
|
50
2
|
//# sourceMappingURL=editorEnabled.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editorEnabled.cjs","names":["createSharedComposable","MessageKey"],"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":"
|
|
1
|
+
{"version":3,"file":"editorEnabled.cjs","names":["createSharedComposable","MessageKey"],"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":"6QAuBI,EAA2C,KAO/C,MAAa,MAAkC,CAC7C,GAAI,EAAU,OAAO,EAErB,IAAM,GAAA,EAAA,EAAA,QAA8B,GAAM,CACpC,GAAA,EAAA,EAAA,QAA0B,GAAM,CAChC,GAAA,EAAA,EAAA,cACE,GAAsB,EAAI,GAAkB,CACnD,CAQD,MANA,GAAW,CACT,eAAgB,EAAqB,YAAY,CACjD,WAAY,EAAiB,YAAY,CACzC,QAAS,EACV,CAEM,GAMI,EAAwB,GAAwB,CAC3C,GAA2B,EAMhC,EAAmBA,EAAAA,2BAA6B,CAC3D,IAAM,EAAS,GAA2B,CAE1C,GAAI,CAAC,EACH,MAAU,MAAM,gCAAgC,CAqBlD,OAjBA,EAAA,6BACE,GAAGC,EAAAA,WAAW,wBAAwB,OACrC,GAAS,CACP,EAAO,eAAuB,IAAI,EAAK,EAE3C,EAGD,EAAA,EAAA,YACQ,CACA,OAAO,OAAW,KACnB,EAAO,WAAmB,IAAI,OAAO,OAAS,OAAO,IAAI,EAG9D,CAAE,kBAAmB,GAAM,CAC5B,CAEM,GACP"}
|
|
@@ -1,22 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
|
|
4
|
-
const require_editor_useCrossFrameState = require('./useCrossFrameState.cjs');
|
|
5
|
-
const require_client_installIntlayer = require('../client/installIntlayer.cjs');
|
|
6
|
-
let _angular_core = require("@angular/core");
|
|
7
|
-
let _intlayer_editor = require("@intlayer/editor");
|
|
8
|
-
|
|
9
|
-
//#region src/editor/editorLocale.ts
|
|
10
|
-
const useEditorLocale = require_editor_createSharedComposable.createSharedComposable(() => {
|
|
11
|
-
const client = (0, _angular_core.inject)(require_client_installIntlayer.INTLAYER_TOKEN);
|
|
12
|
-
if (!client) throw new Error("IntlayerEditor state not found");
|
|
13
|
-
const [_data, setData] = require_editor_useCrossFrameState.useCrossFrameState(_intlayer_editor.MessageKey.INTLAYER_CURRENT_LOCALE);
|
|
14
|
-
(0, _angular_core.effect)(() => {
|
|
15
|
-
setData(client.locale());
|
|
16
|
-
});
|
|
17
|
-
return client;
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
exports.useEditorLocale = useEditorLocale;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./createSharedComposable.cjs`),t=require(`./useCrossFrameState.cjs`),n=require(`../client/installIntlayer.cjs`);let r=require(`@angular/core`),i=require(`@intlayer/editor`);const a=e.createSharedComposable(()=>{let e=(0,r.inject)(n.INTLAYER_TOKEN);if(!e)throw Error(`IntlayerEditor state not found`);let[a,o]=t.useCrossFrameState(i.MessageKey.INTLAYER_CURRENT_LOCALE);return(0,r.effect)(()=>{o(e.locale())}),e});exports.useEditorLocale=a;
|
|
22
2
|
//# sourceMappingURL=editorLocale.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editorLocale.cjs","names":["createSharedComposable","INTLAYER_TOKEN","useCrossFrameState","MessageKey"],"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":"
|
|
1
|
+
{"version":3,"file":"editorLocale.cjs","names":["createSharedComposable","INTLAYER_TOKEN","useCrossFrameState","MessageKey"],"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":"8SAOA,MAAa,EAAkBA,EAAAA,2BAA6B,CAC1D,IAAM,GAAA,EAAA,EAAA,QAAkCC,EAAAA,eAAe,CAEvD,GAAI,CAAC,EACH,MAAU,MAAM,iCAAiC,CAGnD,GAAM,CAAC,EAAO,GAAWC,EAAAA,mBACvBC,EAAAA,WAAW,wBACZ,CAQD,OALA,EAAA,EAAA,YAAa,CAEX,EADiB,EAAO,QAAQ,CACL,EAC3B,CAEK,GACP"}
|
|
@@ -1,63 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
|
|
4
|
-
const require_editor_useCrossFrameState = require('./useCrossFrameState.cjs');
|
|
5
|
-
let _angular_core = require("@angular/core");
|
|
6
|
-
let _intlayer_editor = require("@intlayer/editor");
|
|
7
|
-
|
|
8
|
-
//#region src/editor/focusDictionary.ts
|
|
9
|
-
/**
|
|
10
|
-
* Singleton instance
|
|
11
|
-
*/
|
|
12
|
-
let instance = null;
|
|
13
|
-
/**
|
|
14
|
-
* Creates a focus dictionary client
|
|
15
|
-
*/
|
|
16
|
-
const createFocusDictionaryClient = () => {
|
|
17
|
-
if (instance) return instance;
|
|
18
|
-
const focusedContentSignal = (0, _angular_core.signal)(null);
|
|
19
|
-
const setFocusedContent = (focussedContent) => {
|
|
20
|
-
focusedContentSignal.set(focussedContent);
|
|
21
|
-
};
|
|
22
|
-
const setFocusedContentKeyPath = (keyPath) => {
|
|
23
|
-
const current = focusedContentSignal();
|
|
24
|
-
if (!current) return;
|
|
25
|
-
setFocusedContent({
|
|
26
|
-
...current,
|
|
27
|
-
keyPath
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
instance = {
|
|
31
|
-
focusedContent: focusedContentSignal.asReadonly(),
|
|
32
|
-
setFocusedContent,
|
|
33
|
-
setFocusedContentKeyPath
|
|
34
|
-
};
|
|
35
|
-
return instance;
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Helper to install the focus dictionary into the injector
|
|
39
|
-
*/
|
|
40
|
-
const installFocusDictionary = (_injector) => {
|
|
41
|
-
createFocusDictionaryClient();
|
|
42
|
-
};
|
|
43
|
-
/** consumer */
|
|
44
|
-
const useFocusDictionary = require_editor_createSharedComposable.createSharedComposable(() => {
|
|
45
|
-
const client = createFocusDictionaryClient();
|
|
46
|
-
const [focusedContent, setFocusedContent] = require_editor_useCrossFrameState.useCrossFrameState(_intlayer_editor.MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED);
|
|
47
|
-
if (!client) throw new Error("FocusDictionary state not found");
|
|
48
|
-
(0, _angular_core.effect)(() => {
|
|
49
|
-
const newValue = client.focusedContent();
|
|
50
|
-
if (JSON.stringify(newValue) !== JSON.stringify(focusedContent())) setFocusedContent(newValue);
|
|
51
|
-
});
|
|
52
|
-
(0, _angular_core.effect)(() => {
|
|
53
|
-
const newValue = focusedContent();
|
|
54
|
-
if (JSON.stringify(newValue) !== JSON.stringify(client.focusedContent())) client.setFocusedContent(newValue ?? null);
|
|
55
|
-
});
|
|
56
|
-
return client;
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
//#endregion
|
|
60
|
-
exports.createFocusDictionaryClient = createFocusDictionaryClient;
|
|
61
|
-
exports.installFocusDictionary = installFocusDictionary;
|
|
62
|
-
exports.useFocusDictionary = useFocusDictionary;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./createSharedComposable.cjs`),t=require(`./useCrossFrameState.cjs`);let n=require(`@angular/core`),r=require(`@intlayer/editor`),i=null;const a=()=>{if(i)return i;let e=(0,n.signal)(null),t=t=>{e.set(t)};return i={focusedContent:e.asReadonly(),setFocusedContent:t,setFocusedContentKeyPath:n=>{let r=e();r&&t({...r,keyPath:n})}},i},o=e=>{a()},s=e.createSharedComposable(()=>{let e=a(),[i,o]=t.useCrossFrameState(r.MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED);if(!e)throw Error(`FocusDictionary state not found`);return(0,n.effect)(()=>{let t=e.focusedContent();JSON.stringify(t)!==JSON.stringify(i())&&o(t)}),(0,n.effect)(()=>{let t=i();JSON.stringify(t)!==JSON.stringify(e.focusedContent())&&e.setFocusedContent(t??null)}),e});exports.createFocusDictionaryClient=a,exports.installFocusDictionary=o,exports.useFocusDictionary=s;
|
|
63
2
|
//# sourceMappingURL=focusDictionary.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focusDictionary.cjs","names":["createSharedComposable","useCrossFrameState","MessageKey"],"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":"
|
|
1
|
+
{"version":3,"file":"focusDictionary.cjs","names":["createSharedComposable","useCrossFrameState","MessageKey"],"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":"mQAqBI,EAAyC,KAK7C,MAAa,MAAoC,CAC/C,GAAI,EAAU,OAAO,EAErB,IAAM,GAAA,EAAA,EAAA,QAAkD,KAAK,CAEvD,EAAqB,GAAwC,CACjE,EAAqB,IAAI,EAAgB,EAe3C,MANA,GAAW,CACT,eAAgB,EAAqB,YAAY,CACjD,oBACA,yBATgC,GAAuB,CACvD,IAAM,EAAU,GAAsB,CACjC,GACL,EAAkB,CAAE,GAAG,EAAS,UAAS,CAAC,EAO3C,CAEM,GAMI,EAA0B,GAAwB,CAC7C,GAA6B,EAOlC,EAAqBA,EAAAA,2BAA6B,CAC7D,IAAM,EAAS,GAA6B,CACtC,CAAC,EAAgB,GACrBC,EAAAA,mBACEC,EAAAA,WAAW,iCACZ,CAEH,GAAI,CAAC,EACH,MAAU,MAAM,kCAAkC,CAoBpD,OAfA,EAAA,EAAA,YAAa,CACX,IAAM,EAAW,EAAO,gBAAgB,CACpC,KAAK,UAAU,EAAS,GAAK,KAAK,UAAU,GAAgB,CAAC,EAC/D,EAAkB,EAAS,EAE7B,EAGF,EAAA,EAAA,YAAa,CACX,IAAM,EAAW,GAAgB,CAC7B,KAAK,UAAU,EAAS,GAAK,KAAK,UAAU,EAAO,gBAAgB,CAAC,EACtE,EAAO,kBAAkB,GAAY,KAAK,EAE5C,CAEK,GACP"}
|
|
@@ -1,25 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_editor_ContentSelectorWrapper_component = require('./ContentSelectorWrapper.component.cjs');
|
|
3
|
-
const require_editor_EditedContentRenderer_component = require('./EditedContentRenderer.component.cjs');
|
|
4
|
-
const require_editor_EditorSelectorRenderer_component = require('./EditorSelectorRenderer.component.cjs');
|
|
5
|
-
const require_editor_installIntlayerEditor = require('./installIntlayerEditor.cjs');
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, 'ContentSelectorWrapperComponent', {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return require_editor_ContentSelectorWrapper_component.ContentSelectorWrapperComponent;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(exports, 'EditedContentRendererComponent', {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () {
|
|
16
|
-
return require_editor_EditedContentRenderer_component.EditedContentRendererComponent;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports, 'EditorSelectorRendererComponent', {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function () {
|
|
22
|
-
return require_editor_EditorSelectorRenderer_component.EditorSelectorRendererComponent;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
exports.installIntlayerEditor = require_editor_installIntlayerEditor.installIntlayerEditor;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./ContentSelectorWrapper.component.cjs`),t=require(`./EditedContentRenderer.component.cjs`),n=require(`./EditorSelectorRenderer.component.cjs`),r=require(`./installIntlayerEditor.cjs`);Object.defineProperty(exports,`ContentSelectorWrapperComponent`,{enumerable:!0,get:function(){return e.ContentSelectorWrapperComponent}}),Object.defineProperty(exports,`EditedContentRendererComponent`,{enumerable:!0,get:function(){return t.EditedContentRendererComponent}}),Object.defineProperty(exports,`EditorSelectorRendererComponent`,{enumerable:!0,get:function(){return n.EditorSelectorRendererComponent}}),exports.installIntlayerEditor=r.installIntlayerEditor;
|
|
@@ -1,53 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_editor_communicator = require('./communicator.cjs');
|
|
4
|
-
const require_editor_editorEnabled = require('./editorEnabled.cjs');
|
|
5
|
-
const require_editor_focusDictionary = require('./focusDictionary.cjs');
|
|
6
|
-
const require_editor_dictionariesRecord = require('./dictionariesRecord.cjs');
|
|
7
|
-
const require_editor_editedContent = require('./editedContent.cjs');
|
|
8
|
-
let _intlayer_config_built = require("@intlayer/config/built");
|
|
9
|
-
_intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
|
|
10
|
-
|
|
11
|
-
//#region src/editor/installIntlayerEditor.ts
|
|
12
|
-
const { editor } = _intlayer_config_built.default;
|
|
13
|
-
const { applicationURL, editorURL, cmsURL } = editor ?? {};
|
|
14
|
-
const postMessage = (data) => {
|
|
15
|
-
if (typeof window === "undefined") return;
|
|
16
|
-
if (!(window.self !== window.top)) return;
|
|
17
|
-
if (editor.applicationURL.length > 0) window.postMessage(data, editor.applicationURL);
|
|
18
|
-
if (editor.editorURL.length > 0) window.parent.postMessage(data, editor.editorURL);
|
|
19
|
-
if (editor.cmsURL.length > 0) window.parent.postMessage(data, editor.cmsURL);
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Angular-side replacement for the former <IntlayerEditorProvider> React component.
|
|
23
|
-
*
|
|
24
|
-
* Call **once** in your Angular application's bootstrap function or main module:
|
|
25
|
-
*
|
|
26
|
-
* ```typescript
|
|
27
|
-
* import { bootstrapApplication } from '@angular/platform-browser';
|
|
28
|
-
* import { AppComponent } from './app/app.component';
|
|
29
|
-
* import { installIntlayerEditor } from 'angular-intlayer';
|
|
30
|
-
*
|
|
31
|
-
* bootstrapApplication(AppComponent).then(appRef => {
|
|
32
|
-
* installIntlayerEditor(appRef.injector);
|
|
33
|
-
* });
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
const installIntlayerEditor = (injector) => {
|
|
37
|
-
require_editor_communicator.installCommunicator(injector, {
|
|
38
|
-
postMessage,
|
|
39
|
-
allowedOrigins: [
|
|
40
|
-
applicationURL,
|
|
41
|
-
editorURL,
|
|
42
|
-
cmsURL
|
|
43
|
-
]
|
|
44
|
-
});
|
|
45
|
-
require_editor_editorEnabled.installEditorEnabled(injector);
|
|
46
|
-
require_editor_dictionariesRecord.installDictionariesRecord(injector);
|
|
47
|
-
require_editor_editedContent.installEditedContent(injector);
|
|
48
|
-
require_editor_focusDictionary.installFocusDictionary(injector);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
//#endregion
|
|
52
|
-
exports.installIntlayerEditor = installIntlayerEditor;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`./communicator.cjs`),n=require(`./editorEnabled.cjs`),r=require(`./focusDictionary.cjs`),i=require(`./dictionariesRecord.cjs`),a=require(`./editedContent.cjs`);let o=require(`@intlayer/config/built`);o=e.__toESM(o);const{editor:s}=o.default,{applicationURL:c,editorURL:l,cmsURL:u}=s??{},d=e=>{typeof window>`u`||window.self!==window.top&&(s.applicationURL.length>0&&window.postMessage(e,s.applicationURL),s.editorURL.length>0&&window.parent.postMessage(e,s.editorURL),s.cmsURL.length>0&&window.parent.postMessage(e,s.cmsURL))},f=e=>{t.installCommunicator(e,{postMessage:d,allowedOrigins:[c,l,u]}),n.installEditorEnabled(e),i.installDictionariesRecord(e),a.installEditedContent(e),r.installFocusDictionary(e)};exports.installIntlayerEditor=f;
|
|
53
2
|
//# sourceMappingURL=installIntlayerEditor.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installIntlayerEditor.cjs","names":["configuration"],"sources":["../../../src/editor/installIntlayerEditor.ts"],"sourcesContent":["import type { Injector } from '@angular/core';\nimport configuration from '@intlayer/config/built';\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 installDictionariesRecord(injector);\n installEditedContent(injector);\n installFocusDictionary(injector);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"installIntlayerEditor.cjs","names":["configuration"],"sources":["../../../src/editor/installIntlayerEditor.ts"],"sourcesContent":["import type { Injector } from '@angular/core';\nimport configuration from '@intlayer/config/built';\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 installDictionariesRecord(injector);\n installEditedContent(injector);\n installFocusDictionary(injector);\n};\n"],"mappings":"0VAQA,KAAM,CAAE,UAAWA,EAAAA,QACb,CAAE,iBAAgB,YAAW,UAAW,GAAU,EAAE,CAEpD,EAAe,GAAc,CAC7B,OAAO,OAAW,KAEH,OAAO,OAAS,OAAO,MAItC,EAAO,eAAe,OAAS,GACjC,OAAO,YAAY,EAAM,EAAO,eAAe,CAG7C,EAAO,UAAU,OAAS,GAC5B,OAAO,OAAO,YAAY,EAAM,EAAO,UAAU,CAG/C,EAAO,OAAO,OAAS,GACzB,OAAO,OAAO,YAAY,EAAM,EAAO,OAAO,GAmBrC,EAAyB,GAA6B,CAKjE,EAAA,oBAAoB,EAAU,CAC5B,cACA,eAAgB,CAAC,EAAgB,EAAW,EAAO,CACpD,CAAC,CACF,EAAA,qBAAqB,EAAS,CAC9B,EAAA,0BAA0B,EAAS,CACnC,EAAA,qBAAqB,EAAS,CAC9B,EAAA,uBAAuB,EAAS"}
|
|
@@ -1,74 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
5
|
-
const require_editor_communicator = require('./communicator.cjs');
|
|
6
|
-
let _angular_core = require("@angular/core");
|
|
7
|
-
let _intlayer_editor = require("@intlayer/editor");
|
|
8
|
-
|
|
9
|
-
//#region src/editor/useCrossFrameMessageListener.ts
|
|
10
|
-
/** Map<key, Set<callback>> */
|
|
11
|
-
const subscribers = /* @__PURE__ */ new Map();
|
|
12
|
-
/** True once we've attached the single window listener */
|
|
13
|
-
let windowListenerAttached = false;
|
|
14
|
-
/** Helper to add/remove a callback for a key */
|
|
15
|
-
const addSubscriber = (key, cb) => {
|
|
16
|
-
let set = subscribers.get(key);
|
|
17
|
-
if (!set) {
|
|
18
|
-
set = /* @__PURE__ */ new Set();
|
|
19
|
-
subscribers.set(key, set);
|
|
20
|
-
}
|
|
21
|
-
set.add(cb);
|
|
22
|
-
};
|
|
23
|
-
const removeSubscriber = (key, cb) => {
|
|
24
|
-
const set = subscribers.get(key);
|
|
25
|
-
if (!set) return;
|
|
26
|
-
set.delete(cb);
|
|
27
|
-
if (set.size === 0) subscribers.delete(key);
|
|
28
|
-
};
|
|
29
|
-
/** The one global window listener */
|
|
30
|
-
const ensureGlobalListener = (allowedOrigins, selfId) => {
|
|
31
|
-
if (windowListenerAttached) return;
|
|
32
|
-
window.addEventListener("message", (event) => {
|
|
33
|
-
const { type, data, senderId } = event.data ?? {};
|
|
34
|
-
if (!type) return;
|
|
35
|
-
if (senderId === selfId) return;
|
|
36
|
-
if (!allowedOrigins || allowedOrigins.includes("*") || allowedOrigins.some((o) => (0, _intlayer_editor.compareUrls)(o, event.origin))) subscribers.get(type)?.forEach((cb) => {
|
|
37
|
-
cb(data);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
windowListenerAttached = true;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* useCrossFrameMessageListener
|
|
44
|
-
*
|
|
45
|
-
* @template S - type of the message payload
|
|
46
|
-
* @param key message type we care about
|
|
47
|
-
* @param onEventTriggered optional callback when a matching message arrives
|
|
48
|
-
* @returns postMessage(data?) helper scoped to this key
|
|
49
|
-
*/
|
|
50
|
-
const useCrossFrameMessageListener = (key, onEventTriggered) => {
|
|
51
|
-
const { allowedOrigins, postMessage, senderId } = require_editor_communicator.useCommunicator();
|
|
52
|
-
ensureGlobalListener(allowedOrigins, senderId);
|
|
53
|
-
if (onEventTriggered) {
|
|
54
|
-
addSubscriber(key, onEventTriggered);
|
|
55
|
-
try {
|
|
56
|
-
const destroyRef = (0, _angular_core.inject)(_angular_core.DestroyRef, { optional: true });
|
|
57
|
-
if (destroyRef) destroyRef.onDestroy(() => removeSubscriber(key, onEventTriggered));
|
|
58
|
-
} catch {
|
|
59
|
-
console.warn("useCrossFrameMessageListener called outside injection context; cleanup may not be available.");
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
const postMessageWrapper = (data) => {
|
|
63
|
-
postMessage({
|
|
64
|
-
type: key,
|
|
65
|
-
data,
|
|
66
|
-
senderId
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
return postMessageWrapper;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
//#endregion
|
|
73
|
-
exports.useCrossFrameMessageListener = useCrossFrameMessageListener;
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./communicator.cjs`);let t=require(`@angular/core`),n=require(`@intlayer/editor`);const r=new Map;let i=!1;const a=(e,t)=>{let n=r.get(e);n||(n=new Set,r.set(e,n)),n.add(t)},o=(e,t)=>{let n=r.get(e);n&&(n.delete(t),n.size===0&&r.delete(e))},s=(e,t)=>{i||=(window.addEventListener(`message`,i=>{let{type:a,data:o,senderId:s}=i.data??{};a&&s!==t&&(!e||e.includes(`*`)||e.some(e=>(0,n.compareUrls)(e,i.origin)))&&r.get(a)?.forEach(e=>{e(o)})}),!0)},c=(n,r)=>{let{allowedOrigins:i,postMessage:c,senderId:l}=e.useCommunicator();if(s(i,l),r){a(n,r);try{let e=(0,t.inject)(t.DestroyRef,{optional:!0});e&&e.onDestroy(()=>o(n,r))}catch{console.warn(`useCrossFrameMessageListener called outside injection context; cleanup may not be available.`)}}return e=>{c({type:n,data:e,senderId:l})}};exports.useCrossFrameMessageListener=c;
|
|
74
2
|
//# sourceMappingURL=useCrossFrameMessageListener.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCrossFrameMessageListener.cjs","names":["useCommunicator","DestroyRef"],"sources":["../../../src/editor/useCrossFrameMessageListener.ts"],"sourcesContent":["'use client';\n\nimport { DestroyRef, inject } from '@angular/core';\nimport { compareUrls, type MessageKey } from '@intlayer/editor';\nimport { useCommunicator } from './communicator';\n\n// ---------- module-level singletons ----------\ntype AnyFn = (data: unknown) => void;\n\n/** Map<key, Set<callback>> */\nconst subscribers = new Map<string, Set<AnyFn>>();\n\n/** True once we've attached the single window listener */\nlet windowListenerAttached = false;\n\n/** Helper to add/remove a callback for a key */\nconst addSubscriber = (key: string, cb: AnyFn) => {\n let set = subscribers.get(key);\n if (!set) {\n set = new Set();\n subscribers.set(key, set);\n }\n set.add(cb);\n};\n\nconst removeSubscriber = (key: string, cb: AnyFn) => {\n const set = subscribers.get(key);\n if (!set) return;\n set.delete(cb);\n if (set.size === 0) subscribers.delete(key);\n};\n\n/** The one global window listener */\nconst ensureGlobalListener = (\n allowedOrigins: string[] | undefined,\n selfId: string\n) => {\n if (windowListenerAttached) return;\n window.addEventListener('message', (event) => {\n const { type, data, senderId } = event.data ?? {};\n if (!type) return; // guard malformed messages\n if (senderId === selfId) return; // ignore my own\n\n // origin check\n if (\n !allowedOrigins ||\n allowedOrigins.includes('*') ||\n allowedOrigins.some((o) => compareUrls(o, event.origin))\n ) {\n // broadcast to everyone interested in this key\n subscribers.get(type)?.forEach((cb) => {\n cb(data);\n });\n }\n });\n windowListenerAttached = true;\n};\n// ---------- end module-level code ----------\n\n/**\n * useCrossFrameMessageListener\n *\n * @template S - type of the message payload\n * @param key message type we care about\n * @param onEventTriggered optional callback when a matching message arrives\n * @returns postMessage(data?) helper scoped to this key\n */\nexport const useCrossFrameMessageListener = <S>(\n key: `${MessageKey}` | `${MessageKey}/post` | `${MessageKey}/get`,\n onEventTriggered?: (data: S) => void\n) => {\n // Communicator is the same for everyone, so it's fine to call every time.\n const { allowedOrigins, postMessage, senderId } = useCommunicator();\n\n // --- 1. make sure the global listener exists ----\n ensureGlobalListener(allowedOrigins, senderId);\n\n // --- 2. register this caller's callback (if any) ---\n if (onEventTriggered) {\n addSubscriber(key, onEventTriggered as AnyFn);\n\n // Use Angular's DestroyRef for cleanup instead of Vue's onScopeDispose\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n if (destroyRef) {\n destroyRef.onDestroy(() =>\n removeSubscriber(key, onEventTriggered as AnyFn)\n );\n }\n } catch {\n // If called outside injection context, no cleanup available\n console.warn(\n 'useCrossFrameMessageListener called outside injection context; ' +\n 'cleanup may not be available.'\n );\n }\n }\n\n // --- 3. return a wrapper that tags outgoing messages with our key ---\n const postMessageWrapper = (data?: S) => {\n postMessage({ type: key, data, senderId });\n };\n\n return postMessageWrapper;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCrossFrameMessageListener.cjs","names":["useCommunicator","DestroyRef"],"sources":["../../../src/editor/useCrossFrameMessageListener.ts"],"sourcesContent":["'use client';\n\nimport { DestroyRef, inject } from '@angular/core';\nimport { compareUrls, type MessageKey } from '@intlayer/editor';\nimport { useCommunicator } from './communicator';\n\n// ---------- module-level singletons ----------\ntype AnyFn = (data: unknown) => void;\n\n/** Map<key, Set<callback>> */\nconst subscribers = new Map<string, Set<AnyFn>>();\n\n/** True once we've attached the single window listener */\nlet windowListenerAttached = false;\n\n/** Helper to add/remove a callback for a key */\nconst addSubscriber = (key: string, cb: AnyFn) => {\n let set = subscribers.get(key);\n if (!set) {\n set = new Set();\n subscribers.set(key, set);\n }\n set.add(cb);\n};\n\nconst removeSubscriber = (key: string, cb: AnyFn) => {\n const set = subscribers.get(key);\n if (!set) return;\n set.delete(cb);\n if (set.size === 0) subscribers.delete(key);\n};\n\n/** The one global window listener */\nconst ensureGlobalListener = (\n allowedOrigins: string[] | undefined,\n selfId: string\n) => {\n if (windowListenerAttached) return;\n window.addEventListener('message', (event) => {\n const { type, data, senderId } = event.data ?? {};\n if (!type) return; // guard malformed messages\n if (senderId === selfId) return; // ignore my own\n\n // origin check\n if (\n !allowedOrigins ||\n allowedOrigins.includes('*') ||\n allowedOrigins.some((o) => compareUrls(o, event.origin))\n ) {\n // broadcast to everyone interested in this key\n subscribers.get(type)?.forEach((cb) => {\n cb(data);\n });\n }\n });\n windowListenerAttached = true;\n};\n// ---------- end module-level code ----------\n\n/**\n * useCrossFrameMessageListener\n *\n * @template S - type of the message payload\n * @param key message type we care about\n * @param onEventTriggered optional callback when a matching message arrives\n * @returns postMessage(data?) helper scoped to this key\n */\nexport const useCrossFrameMessageListener = <S>(\n key: `${MessageKey}` | `${MessageKey}/post` | `${MessageKey}/get`,\n onEventTriggered?: (data: S) => void\n) => {\n // Communicator is the same for everyone, so it's fine to call every time.\n const { allowedOrigins, postMessage, senderId } = useCommunicator();\n\n // --- 1. make sure the global listener exists ----\n ensureGlobalListener(allowedOrigins, senderId);\n\n // --- 2. register this caller's callback (if any) ---\n if (onEventTriggered) {\n addSubscriber(key, onEventTriggered as AnyFn);\n\n // Use Angular's DestroyRef for cleanup instead of Vue's onScopeDispose\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n if (destroyRef) {\n destroyRef.onDestroy(() =>\n removeSubscriber(key, onEventTriggered as AnyFn)\n );\n }\n } catch {\n // If called outside injection context, no cleanup available\n console.warn(\n 'useCrossFrameMessageListener called outside injection context; ' +\n 'cleanup may not be available.'\n );\n }\n }\n\n // --- 3. return a wrapper that tags outgoing messages with our key ---\n const postMessageWrapper = (data?: S) => {\n postMessage({ type: key, data, senderId });\n };\n\n return postMessageWrapper;\n};\n"],"mappings":"gOAUA,MAAM,EAAc,IAAI,IAGxB,IAAI,EAAyB,GAG7B,MAAM,GAAiB,EAAa,IAAc,CAChD,IAAI,EAAM,EAAY,IAAI,EAAI,CACzB,IACH,EAAM,IAAI,IACV,EAAY,IAAI,EAAK,EAAI,EAE3B,EAAI,IAAI,EAAG,EAGP,GAAoB,EAAa,IAAc,CACnD,IAAM,EAAM,EAAY,IAAI,EAAI,CAC3B,IACL,EAAI,OAAO,EAAG,CACV,EAAI,OAAS,GAAG,EAAY,OAAO,EAAI,GAIvC,GACJ,EACA,IACG,CACC,AAkBJ,KAjBA,OAAO,iBAAiB,UAAY,GAAU,CAC5C,GAAM,CAAE,OAAM,OAAM,YAAa,EAAM,MAAQ,EAAE,CAC5C,GACD,IAAa,IAIf,CAAC,GACD,EAAe,SAAS,IAAI,EAC5B,EAAe,KAAM,IAAA,EAAA,EAAA,aAAkB,EAAG,EAAM,OAAO,CAAC,GAGxD,EAAY,IAAI,EAAK,EAAE,QAAS,GAAO,CACrC,EAAG,EAAK,EACR,EAEJ,CACuB,KAYd,GACX,EACA,IACG,CAEH,GAAM,CAAE,iBAAgB,cAAa,YAAaA,EAAAA,iBAAiB,CAMnE,GAHA,EAAqB,EAAgB,EAAS,CAG1C,EAAkB,CACpB,EAAc,EAAK,EAA0B,CAG7C,GAAI,CACF,IAAM,GAAA,EAAA,EAAA,QAAoBC,EAAAA,WAAY,CAAE,SAAU,GAAM,CAAC,CACrD,GACF,EAAW,cACT,EAAiB,EAAK,EAA0B,CACjD,MAEG,CAEN,QAAQ,KACN,+FAED,EASL,MAJ4B,IAAa,CACvC,EAAY,CAAE,KAAM,EAAK,OAAM,WAAU,CAAC"}
|