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,83 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var dictionariesRecord_exports = {};
|
|
30
|
-
__export(dictionariesRecord_exports, {
|
|
31
|
-
createDictionaryRecordClient: () => createDictionaryRecordClient,
|
|
32
|
-
installDictionariesRecord: () => installDictionariesRecord,
|
|
33
|
-
useDictionariesRecord: () => useDictionariesRecord
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(dictionariesRecord_exports);
|
|
36
|
-
var import_core = require("@angular/core");
|
|
37
|
-
var import_dictionaries_entry = __toESM(require("@intlayer/dictionaries-entry"));
|
|
38
|
-
var import_editor = require("@intlayer/editor");
|
|
39
|
-
var import_createSharedComposable = require('./createSharedComposable.cjs');
|
|
40
|
-
var import_useCrossFrameState = require('./useCrossFrameState.cjs');
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
|
|
3
|
+
const require_editor_useCrossFrameState = require('./useCrossFrameState.cjs');
|
|
4
|
+
let __angular_core = require("@angular/core");
|
|
5
|
+
__angular_core = require_rolldown_runtime.__toESM(__angular_core);
|
|
6
|
+
let __intlayer_editor = require("@intlayer/editor");
|
|
7
|
+
__intlayer_editor = require_rolldown_runtime.__toESM(__intlayer_editor);
|
|
8
|
+
let __intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
|
|
9
|
+
__intlayer_dictionaries_entry = require_rolldown_runtime.__toESM(__intlayer_dictionaries_entry);
|
|
10
|
+
|
|
11
|
+
//#region src/editor/dictionariesRecord.ts
|
|
12
|
+
/**
|
|
13
|
+
* Singleton instance
|
|
14
|
+
*/
|
|
41
15
|
let instance = null;
|
|
42
16
|
const createDictionaryRecordClient = () => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
17
|
+
if (instance) return instance;
|
|
18
|
+
const localeDictionariesSignal = (0, __angular_core.signal)((0, __intlayer_dictionaries_entry.getDictionaries)());
|
|
19
|
+
instance = {
|
|
20
|
+
localeDictionaries: localeDictionariesSignal.asReadonly(),
|
|
21
|
+
setLocaleDictionaries: (newValue) => {
|
|
22
|
+
localeDictionariesSignal.set(newValue ?? {});
|
|
23
|
+
},
|
|
24
|
+
setLocaleDictionary(dictionary) {
|
|
25
|
+
const current = localeDictionariesSignal();
|
|
26
|
+
localeDictionariesSignal.set({
|
|
27
|
+
...current,
|
|
28
|
+
[dictionary.key]: dictionary
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return instance;
|
|
59
33
|
};
|
|
60
|
-
|
|
61
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Helper to install the provider into the injector
|
|
36
|
+
*/
|
|
37
|
+
const installDictionariesRecord = (_injector) => {
|
|
38
|
+
createDictionaryRecordClient();
|
|
62
39
|
};
|
|
63
|
-
const useDictionariesRecord =
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
void 0
|
|
71
|
-
);
|
|
72
|
-
(0, import_core.effect)(() => {
|
|
73
|
-
const newValue = client.localeDictionaries();
|
|
74
|
-
setDictionariesRecord(newValue);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
-
0 && (module.exports = {
|
|
79
|
-
createDictionaryRecordClient,
|
|
80
|
-
installDictionariesRecord,
|
|
81
|
-
useDictionariesRecord
|
|
40
|
+
const useDictionariesRecord = require_editor_createSharedComposable.createSharedComposable(() => {
|
|
41
|
+
const client = createDictionaryRecordClient();
|
|
42
|
+
if (!client) throw new Error("DictionariesRecord state not found");
|
|
43
|
+
const [_dictionariesRecord, setDictionariesRecord] = require_editor_useCrossFrameState.useCrossFrameState(__intlayer_editor.MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED, void 0);
|
|
44
|
+
(0, __angular_core.effect)(() => {
|
|
45
|
+
setDictionariesRecord(client.localeDictionaries());
|
|
46
|
+
});
|
|
82
47
|
});
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
exports.createDictionaryRecordClient = createDictionaryRecordClient;
|
|
51
|
+
exports.installDictionariesRecord = installDictionariesRecord;
|
|
52
|
+
exports.useDictionariesRecord = useDictionariesRecord;
|
|
83
53
|
//# sourceMappingURL=dictionariesRecord.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/dictionariesRecord.ts"],"sourcesContent":["import { effect, Injector,
|
|
1
|
+
{"version":3,"file":"dictionariesRecord.cjs","names":["instance: DictionariesRecordClient | null","createSharedComposable","useCrossFrameState","MessageKey"],"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,0GADgC,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,wBAAwBC,mEAA6B;CAChE,MAAM,SAAS,8BAA8B;AAE7C,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,qCAAqC;CAGvD,MAAM,CAAC,qBAAqB,yBAC1BC,qDACEC,6BAAW,sCACX,OACD;AAGH,kCAAa;AAEX,wBADiB,OAAO,oBAAoB,CACb;GAC/B;EACF"}
|
|
@@ -1,77 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var editedContent_exports = {};
|
|
20
|
-
__export(editedContent_exports, {
|
|
21
|
-
createEditedContentClient: () => createEditedContentClient,
|
|
22
|
-
installEditedContent: () => installEditedContent,
|
|
23
|
-
useEditedContent: () => useEditedContent
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(editedContent_exports);
|
|
26
|
-
var import_core = require("@angular/core");
|
|
27
|
-
var import_core2 = require("@intlayer/core");
|
|
28
|
-
var import_editor = require("@intlayer/editor");
|
|
29
|
-
var import_createSharedComposable = require('./createSharedComposable.cjs');
|
|
30
|
-
var import_useCrossFrameState = require('./useCrossFrameState.cjs');
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
|
|
3
|
+
const require_editor_useCrossFrameState = require('./useCrossFrameState.cjs');
|
|
4
|
+
let __intlayer_core = require("@intlayer/core");
|
|
5
|
+
__intlayer_core = require_rolldown_runtime.__toESM(__intlayer_core);
|
|
6
|
+
let __angular_core = require("@angular/core");
|
|
7
|
+
__angular_core = require_rolldown_runtime.__toESM(__angular_core);
|
|
8
|
+
let __intlayer_editor = require("@intlayer/editor");
|
|
9
|
+
__intlayer_editor = require_rolldown_runtime.__toESM(__intlayer_editor);
|
|
10
|
+
|
|
11
|
+
//#region src/editor/editedContent.ts
|
|
12
|
+
/**
|
|
13
|
+
* Singleton instance
|
|
14
|
+
*/
|
|
31
15
|
let instance = null;
|
|
32
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Creates an edited content client
|
|
18
|
+
*/
|
|
33
19
|
const createEditedContentClient = () => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
20
|
+
if (instance) return instance;
|
|
21
|
+
const editedContentSignal = (0, __angular_core.signal)({});
|
|
22
|
+
instance = {
|
|
23
|
+
editedContent: editedContentSignal.asReadonly(),
|
|
24
|
+
getEditedContentValue: (localDictionaryIdOrKey, keyPath) => {
|
|
25
|
+
const editedContent = editedContentSignal();
|
|
26
|
+
if (!editedContent) return void 0;
|
|
27
|
+
if (localDictionaryIdOrKey.includes(":local:") || localDictionaryIdOrKey.includes(":remote:")) return (0, __intlayer_core.getContentNodeByKeyPath)(editedContent?.[localDictionaryIdOrKey]?.content ?? {}, keyPath);
|
|
28
|
+
const filteredDictionariesLocalId = Object.keys(editedContent).filter((key) => key.startsWith(`${localDictionaryIdOrKey}:`));
|
|
29
|
+
for (const localDictionaryId of filteredDictionariesLocalId) {
|
|
30
|
+
const contentNode = (0, __intlayer_core.getContentNodeByKeyPath)(editedContent?.[localDictionaryId]?.content ?? {}, keyPath);
|
|
31
|
+
if (contentNode) return contentNode;
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
setEditedContent: (editedContent) => {
|
|
35
|
+
editedContentSignal.set(editedContent);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
return instance;
|
|
48
39
|
};
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Helper to install the edited content into the injector
|
|
42
|
+
*/
|
|
43
|
+
const installEditedContent = (_injector) => {
|
|
44
|
+
createEditedContentClient();
|
|
51
45
|
};
|
|
52
|
-
const useEditedContent =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
});
|
|
65
|
-
(0, import_core.effect)(() => {
|
|
66
|
-
const newValue = client.editedContent();
|
|
67
|
-
setEdited(newValue);
|
|
68
|
-
});
|
|
69
|
-
return client;
|
|
70
|
-
});
|
|
71
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
-
0 && (module.exports = {
|
|
73
|
-
createEditedContentClient,
|
|
74
|
-
installEditedContent,
|
|
75
|
-
useEditedContent
|
|
46
|
+
const useEditedContent = require_editor_createSharedComposable.createSharedComposable(() => {
|
|
47
|
+
const client = createEditedContentClient();
|
|
48
|
+
if (!client) throw new Error("EditedContent state not found");
|
|
49
|
+
const [edited, setEdited] = require_editor_useCrossFrameState.useCrossFrameState(__intlayer_editor.MessageKey.INTLAYER_EDITED_CONTENT_CHANGED, {});
|
|
50
|
+
(0, __angular_core.effect)(() => {
|
|
51
|
+
const newValue = edited();
|
|
52
|
+
client.setEditedContent(newValue ?? {});
|
|
53
|
+
});
|
|
54
|
+
(0, __angular_core.effect)(() => {
|
|
55
|
+
setEdited(client.editedContent());
|
|
56
|
+
});
|
|
57
|
+
return client;
|
|
76
58
|
});
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
exports.createEditedContentClient = createEditedContentClient;
|
|
62
|
+
exports.installEditedContent = installEditedContent;
|
|
63
|
+
exports.useEditedContent = useEditedContent;
|
|
77
64
|
//# sourceMappingURL=editedContent.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/editedContent.ts"],"sourcesContent":["import { effect, Injector,
|
|
1
|
+
{"version":3,"file":"editedContent.cjs","names":["instance: EditedContentClient | null","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":";;;;;;;;;;;;;;AA0BA,IAAIA,WAAuC;;;;AAO3C,MAAa,kCAAkC;AAC7C,KAAI,SAAU,QAAO;CAErB,MAAM,iDAA4C,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,qDALE,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,2DAFJ,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,mBAAmBC,mEAA6B;CAC3D,MAAM,SAAS,2BAA2B;AAE1C,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,gCAAgC;CAGlD,MAAM,CAAC,QAAQ,aAAaC,qDAC1BC,6BAAW,iCACX,EAAE,CACH;AAGD,kCAAa;EACX,MAAM,WAAW,QAAQ;AACzB,SAAO,iBAAiB,YAAY,EAAE,CAAC;GACvC;AAEF,kCAAa;AAEX,YADiB,OAAO,eAAe,CACpB;GACnB;AAEF,QAAO;EACP"}
|
|
@@ -1,76 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var editorEnabled_exports = {};
|
|
20
|
-
__export(editorEnabled_exports, {
|
|
21
|
-
createEditorEnabledClient: () => createEditorEnabledClient,
|
|
22
|
-
installEditorEnabled: () => installEditorEnabled,
|
|
23
|
-
useEditorEnabled: () => useEditorEnabled
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(editorEnabled_exports);
|
|
26
|
-
var import_core = require("@angular/core");
|
|
27
|
-
var import_editor = require("@intlayer/editor");
|
|
28
|
-
var import_createSharedComposable = require('./createSharedComposable.cjs');
|
|
29
|
-
var import_useCrossFrameMessageListener = require('./useCrossFrameMessageListener.cjs');
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
|
|
3
|
+
const require_editor_useCrossFrameMessageListener = require('./useCrossFrameMessageListener.cjs');
|
|
4
|
+
let __angular_core = require("@angular/core");
|
|
5
|
+
__angular_core = require_rolldown_runtime.__toESM(__angular_core);
|
|
6
|
+
let __intlayer_editor = require("@intlayer/editor");
|
|
7
|
+
__intlayer_editor = require_rolldown_runtime.__toESM(__intlayer_editor);
|
|
8
|
+
|
|
9
|
+
//#region src/editor/editorEnabled.ts
|
|
10
|
+
/**
|
|
11
|
+
* Singleton instance
|
|
12
|
+
*/
|
|
30
13
|
let instance = null;
|
|
31
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Creates an editor wrapperEnabled client
|
|
16
|
+
*/
|
|
32
17
|
const createEditorEnabledClient = () => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
return instance;
|
|
18
|
+
if (instance) return instance;
|
|
19
|
+
const wrapperEnabledSignal = (0, __angular_core.signal)(false);
|
|
20
|
+
const isInIframeSignal = (0, __angular_core.signal)(false);
|
|
21
|
+
const enabledSignal = (0, __angular_core.computed)(() => wrapperEnabledSignal() && isInIframeSignal());
|
|
22
|
+
instance = {
|
|
23
|
+
wrapperEnabled: wrapperEnabledSignal.asReadonly(),
|
|
24
|
+
isInIframe: isInIframeSignal.asReadonly(),
|
|
25
|
+
enabled: enabledSignal
|
|
26
|
+
};
|
|
27
|
+
return instance;
|
|
45
28
|
};
|
|
46
|
-
|
|
47
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Helper to install the editor wrapperEnabled state into the injector
|
|
31
|
+
*/
|
|
32
|
+
const installEditorEnabled = (_injector) => {
|
|
33
|
+
createEditorEnabledClient();
|
|
48
34
|
};
|
|
49
|
-
const useEditorEnabled =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
);
|
|
60
|
-
(0, import_core.effect)(
|
|
61
|
-
() => {
|
|
62
|
-
if (typeof window !== "undefined") {
|
|
63
|
-
client.isInIframe.set(window.self !== window.top);
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
{ allowSignalWrites: true }
|
|
67
|
-
);
|
|
68
|
-
return client;
|
|
69
|
-
});
|
|
70
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
-
0 && (module.exports = {
|
|
72
|
-
createEditorEnabledClient,
|
|
73
|
-
installEditorEnabled,
|
|
74
|
-
useEditorEnabled
|
|
35
|
+
const useEditorEnabled = require_editor_createSharedComposable.createSharedComposable(() => {
|
|
36
|
+
const client = createEditorEnabledClient();
|
|
37
|
+
if (!client) throw new Error("EditorEnabled state not found");
|
|
38
|
+
require_editor_useCrossFrameMessageListener.useCrossFrameMessageListener(`${__intlayer_editor.MessageKey.INTLAYER_EDITOR_ENABLED}/post`, (data) => {
|
|
39
|
+
client.wrapperEnabled.set(data);
|
|
40
|
+
});
|
|
41
|
+
(0, __angular_core.effect)(() => {
|
|
42
|
+
if (typeof window !== "undefined") client.isInIframe.set(window.self !== window.top);
|
|
43
|
+
}, { allowSignalWrites: true });
|
|
44
|
+
return client;
|
|
75
45
|
});
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
exports.createEditorEnabledClient = createEditorEnabledClient;
|
|
49
|
+
exports.installEditorEnabled = installEditorEnabled;
|
|
50
|
+
exports.useEditorEnabled = useEditorEnabled;
|
|
76
51
|
//# sourceMappingURL=editorEnabled.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/editorEnabled.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"editorEnabled.cjs","names":["instance: EditorEnabledStateProps | null","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":";;;;;;;;;;;;AAuBA,IAAIA,WAA2C;;;;AAO/C,MAAa,kCAAkC;AAC7C,KAAI,SAAU,QAAO;CAErB,MAAM,kDAA8B,MAAM;CAC1C,MAAM,8CAA0B,MAAM;CACtC,MAAM,mDACE,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,mBAAmBC,mEAA6B;CAC3D,MAAM,SAAS,2BAA2B;AAE1C,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,gCAAgC;AAIlD,0EACE,GAAGC,6BAAW,wBAAwB,SACrC,SAAS;AACR,EAAC,OAAO,eAAuB,IAAI,KAAK;GAE3C;AAGD,kCACQ;AACJ,MAAI,OAAO,WAAW,YACpB,CAAC,OAAO,WAAmB,IAAI,OAAO,SAAS,OAAO,IAAI;IAG9D,EAAE,mBAAmB,MAAM,CAC5B;AAED,QAAO;EACP"}
|
|
@@ -1,47 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
var editorLocale_exports = {};
|
|
20
|
-
__export(editorLocale_exports, {
|
|
21
|
-
useEditorLocale: () => useEditorLocale
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(editorLocale_exports);
|
|
24
|
-
var import_core = require("@angular/core");
|
|
25
|
-
var import_editor = require("@intlayer/editor");
|
|
26
|
-
var import_client = require('../client/index.cjs');
|
|
27
|
-
var import_createSharedComposable = require('./createSharedComposable.cjs');
|
|
28
|
-
var import_useCrossFrameState = require('./useCrossFrameState.cjs');
|
|
29
|
-
const useEditorLocale = (0, import_createSharedComposable.createSharedComposable)(() => {
|
|
30
|
-
const client = (0, import_core.inject)(import_client.INTLAYER_TOKEN);
|
|
31
|
-
if (!client) {
|
|
32
|
-
throw new Error("IntlayerEditor state not found");
|
|
33
|
-
}
|
|
34
|
-
const [_data, setData] = (0, import_useCrossFrameState.useCrossFrameState)(
|
|
35
|
-
import_editor.MessageKey.INTLAYER_CURRENT_LOCALE
|
|
36
|
-
);
|
|
37
|
-
(0, import_core.effect)(() => {
|
|
38
|
-
const newValue = client.locale();
|
|
39
|
-
setData(newValue);
|
|
40
|
-
});
|
|
41
|
-
return client;
|
|
42
|
-
});
|
|
43
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
-
0 && (module.exports = {
|
|
45
|
-
useEditorLocale
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
|
|
3
|
+
const require_editor_useCrossFrameState = require('./useCrossFrameState.cjs');
|
|
4
|
+
const require_client_installIntlayer = require('../client/installIntlayer.cjs');
|
|
5
|
+
let __angular_core = require("@angular/core");
|
|
6
|
+
__angular_core = require_rolldown_runtime.__toESM(__angular_core);
|
|
7
|
+
let __intlayer_editor = require("@intlayer/editor");
|
|
8
|
+
__intlayer_editor = require_rolldown_runtime.__toESM(__intlayer_editor);
|
|
9
|
+
|
|
10
|
+
//#region src/editor/editorLocale.ts
|
|
11
|
+
const useEditorLocale = require_editor_createSharedComposable.createSharedComposable(() => {
|
|
12
|
+
const client = (0, __angular_core.inject)(require_client_installIntlayer.INTLAYER_TOKEN);
|
|
13
|
+
if (!client) throw new Error("IntlayerEditor state not found");
|
|
14
|
+
const [_data, setData] = require_editor_useCrossFrameState.useCrossFrameState(__intlayer_editor.MessageKey.INTLAYER_CURRENT_LOCALE);
|
|
15
|
+
(0, __angular_core.effect)(() => {
|
|
16
|
+
setData(client.locale());
|
|
17
|
+
});
|
|
18
|
+
return client;
|
|
46
19
|
});
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.useEditorLocale = useEditorLocale;
|
|
47
23
|
//# sourceMappingURL=editorLocale.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/editorLocale.ts"],"sourcesContent":["import { effect, inject } from '@angular/core';\nimport
|
|
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":";;;;;;;;;;AAOA,MAAa,kBAAkBA,mEAA6B;CAC1D,MAAM,oCAAkCC,8CAAe;AAEvD,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,iCAAiC;CAGnD,MAAM,CAAC,OAAO,WAAWC,qDACvBC,6BAAW,wBACZ;AAGD,kCAAa;AAEX,UADiB,OAAO,QAAQ,CACL;GAC3B;AAEF,QAAO;EACP"}
|