angular-intlayer 6.1.6 → 7.0.0-canary.2
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,95 +1,115 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var useCrossFrameState_exports = {};
|
|
20
|
-
__export(useCrossFrameState_exports, {
|
|
21
|
-
useCrossFrameState: () => useCrossFrameState
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(useCrossFrameState_exports);
|
|
24
|
-
var import_core = require("@angular/core");
|
|
25
|
-
var import_communicator = require('./communicator.cjs');
|
|
26
|
-
var import_useCrossFrameMessageListener = require('./useCrossFrameMessageListener.cjs');
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_editor_communicator = require('./communicator.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
|
+
|
|
7
|
+
//#region src/editor/useCrossFrameState.ts
|
|
27
8
|
const crossFrameStateCache = /* @__PURE__ */ new Map();
|
|
9
|
+
/**
|
|
10
|
+
* Utility to resolve either a value or an updater function (mirrors React's `setState`).
|
|
11
|
+
*/
|
|
28
12
|
const resolveState = (state, prevState) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
return state;
|
|
13
|
+
if (typeof state === "function") return state(prevState);
|
|
14
|
+
return state;
|
|
33
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Creates a plain object copy that can be safely serialized
|
|
18
|
+
* for postMessage communication
|
|
19
|
+
*/
|
|
34
20
|
const toSerializable = (obj) => {
|
|
35
|
-
|
|
36
|
-
|
|
21
|
+
if (obj === null || obj === void 0) return obj;
|
|
22
|
+
return JSON.parse(JSON.stringify(obj));
|
|
37
23
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Angular replacement for Vue's cross-frame state composable.
|
|
26
|
+
* It synchronises a reactive value across frames/windows via the `postMessage` API.
|
|
27
|
+
*
|
|
28
|
+
* @template S The type of the state being synchronised.
|
|
29
|
+
* @param key Unique key identifying this state channel.
|
|
30
|
+
* @param initialState Initial value (or lazy factory) for the state.
|
|
31
|
+
* @param options Control flags for emitting/receiving updates.
|
|
32
|
+
*
|
|
33
|
+
* @returns `[stateSignal, setState, postState]`
|
|
34
|
+
* - `stateSignal` – Angular `Signal<S | undefined>` holding the current state.
|
|
35
|
+
* - `setState` – Setter with the same API as React's `setState`.
|
|
36
|
+
* - `postState` – Manually broadcast the current state (useful after mutations outside `setState`).
|
|
37
|
+
*/
|
|
38
|
+
const useCrossFrameState = (key, initialState, options = {
|
|
39
|
+
emit: true,
|
|
40
|
+
receive: true
|
|
41
|
+
}) => {
|
|
42
|
+
if (crossFrameStateCache.has(key)) {
|
|
43
|
+
const { state, setState: setState$1, postState: postState$1 } = crossFrameStateCache.get(key);
|
|
44
|
+
return [
|
|
45
|
+
state,
|
|
46
|
+
setState$1,
|
|
47
|
+
postState$1
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
const { emit = true, receive = true } = options;
|
|
51
|
+
/**
|
|
52
|
+
* Internal reactive state using Angular signals.
|
|
53
|
+
* We resolve the initial value here to avoid one extra render (same idea as in the React version).
|
|
54
|
+
*/
|
|
55
|
+
const stateSignal = (0, __angular_core.signal)(resolveState(initialState));
|
|
56
|
+
const { postMessage, senderId } = require_editor_communicator.useCommunicator();
|
|
57
|
+
/**
|
|
58
|
+
* Broadcast the given value if emitting is allowed and the communicator is ready.
|
|
59
|
+
*/
|
|
60
|
+
const broadcastState = (value) => {
|
|
61
|
+
if (!emit || typeof postMessage !== "function" || typeof value === "undefined") return;
|
|
62
|
+
postMessage({
|
|
63
|
+
type: `${key}/post`,
|
|
64
|
+
data: value,
|
|
65
|
+
senderId
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Setter that mirrors React's `setState` signature (supports value or updater fn).
|
|
70
|
+
*/
|
|
71
|
+
const setState = (valueOrUpdater) => {
|
|
72
|
+
const serialised = toSerializable(resolveState(valueOrUpdater, stateSignal()));
|
|
73
|
+
stateSignal.set(serialised);
|
|
74
|
+
broadcastState(serialised);
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Manually broadcast the current state to peers.
|
|
78
|
+
*/
|
|
79
|
+
const postState = () => {
|
|
80
|
+
if (typeof postMessage !== "function") return;
|
|
81
|
+
postMessage({
|
|
82
|
+
type: `${key}/post`,
|
|
83
|
+
data: stateSignal(),
|
|
84
|
+
senderId
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
broadcastState(stateSignal());
|
|
88
|
+
if (receive && typeof postMessage === "function" && typeof stateSignal() === "undefined") postMessage({
|
|
89
|
+
type: `${key}/get`,
|
|
90
|
+
senderId
|
|
91
|
+
});
|
|
92
|
+
require_editor_useCrossFrameMessageListener.useCrossFrameMessageListener(`${key}/post`, receive ? (data) => {
|
|
93
|
+
stateSignal.set(data);
|
|
94
|
+
} : void 0);
|
|
95
|
+
const handleGetMessage = (_, originSenderId) => {
|
|
96
|
+
if (!emit) return;
|
|
97
|
+
if (originSenderId === senderId) return;
|
|
98
|
+
broadcastState(stateSignal());
|
|
99
|
+
};
|
|
100
|
+
require_editor_useCrossFrameMessageListener.useCrossFrameMessageListener(`${key}/get`, emit ? handleGetMessage : void 0);
|
|
101
|
+
crossFrameStateCache.set(key, {
|
|
102
|
+
state: stateSignal,
|
|
103
|
+
setState,
|
|
104
|
+
postState
|
|
105
|
+
});
|
|
106
|
+
return [
|
|
107
|
+
stateSignal,
|
|
108
|
+
setState,
|
|
109
|
+
postState
|
|
110
|
+
];
|
|
90
111
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
});
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
exports.useCrossFrameState = useCrossFrameState;
|
|
95
115
|
//# sourceMappingURL=useCrossFrameState.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/useCrossFrameState.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useCrossFrameState.cjs","names":["setState","postState","useCommunicator"],"sources":["../../../src/editor/useCrossFrameState.ts"],"sourcesContent":["import { type Signal, signal } from '@angular/core';\nimport type { MessageKey } from '@intlayer/editor';\nimport { useCommunicator } from './communicator';\nimport { useCrossFrameMessageListener } from './useCrossFrameMessageListener';\n\nexport type CrossFrameStateOptions = {\n /** Whether to broadcast state changes to other instances (default: true) */\n emit?: boolean;\n /** Whether to listen for state updates from other instances (default: true) */\n receive?: boolean;\n};\n\nconst crossFrameStateCache = new Map<\n string,\n {\n state: Signal<any>;\n setState: (v: any | ((prev: any) => any)) => void;\n postState: () => void;\n }\n>();\n\n/**\n * Utility to resolve either a value or an updater function (mirrors React's `setState`).\n */\nconst resolveState = <S>(\n state: S | ((prev?: S) => S) | undefined,\n prevState?: S\n): S | undefined => {\n if (typeof state === 'function') {\n return (state as (prev?: S) => S)(prevState);\n }\n return state as S;\n};\n\n/**\n * Creates a plain object copy that can be safely serialized\n * for postMessage communication\n */\nconst toSerializable = <T>(obj: T): T => {\n if (obj === null || obj === undefined) return obj;\n // Using parse/stringify for a quick deep clone to remove reactivity\n return JSON.parse(JSON.stringify(obj));\n};\n\n/**\n * Angular replacement for Vue's cross-frame state composable.\n * It synchronises a reactive value across frames/windows via the `postMessage` API.\n *\n * @template S The type of the state being synchronised.\n * @param key Unique key identifying this state channel.\n * @param initialState Initial value (or lazy factory) for the state.\n * @param options Control flags for emitting/receiving updates.\n *\n * @returns `[stateSignal, setState, postState]`\n * - `stateSignal` – Angular `Signal<S | undefined>` holding the current state.\n * - `setState` – Setter with the same API as React's `setState`.\n * - `postState` – Manually broadcast the current state (useful after mutations outside `setState`).\n */\nexport const useCrossFrameState = <S>(\n key: `${MessageKey}`,\n initialState?: S | (() => S),\n options: CrossFrameStateOptions = { emit: true, receive: true }\n): [\n Signal<S | undefined>,\n (v: S | ((prev: S | undefined) => S)) => void,\n () => void,\n] => {\n if (crossFrameStateCache.has(key)) {\n // Return the existing instance\n const { state, setState, postState } = crossFrameStateCache.get(key)!;\n return [state, setState, postState];\n }\n\n const { emit = true, receive = true } = options;\n\n /**\n * Internal reactive state using Angular signals.\n * We resolve the initial value here to avoid one extra render (same idea as in the React version).\n */\n const stateSignal = signal<S | undefined>(resolveState<S>(initialState));\n\n // Get communicator within injection context\n const { postMessage, senderId } = useCommunicator();\n\n /**\n * Broadcast the given value if emitting is allowed and the communicator is ready.\n */\n const broadcastState = (value: S | undefined) => {\n if (\n !emit ||\n typeof postMessage !== 'function' ||\n typeof value === 'undefined'\n )\n return;\n postMessage({\n type: `${key}/post`,\n data: value,\n senderId,\n });\n };\n\n /**\n * Setter that mirrors React's `setState` signature (supports value or updater fn).\n */\n const setState = (valueOrUpdater: S | ((prev: S | undefined) => S)) => {\n const next = resolveState<S>(valueOrUpdater as any, stateSignal());\n const serialised = toSerializable(next);\n stateSignal.set(serialised);\n broadcastState(serialised);\n };\n\n /**\n * Manually broadcast the current state to peers.\n */\n const postState = () => {\n if (typeof postMessage !== 'function') return;\n postMessage({\n type: `${key}/post`,\n data: stateSignal(),\n senderId,\n });\n };\n\n // Emit the initial state (if any) right away so that peers can pick it up.\n broadcastState(stateSignal());\n\n // If we are in receive mode but have no state yet, ask peers for theirs.\n if (\n receive &&\n typeof postMessage === 'function' &&\n typeof stateSignal() === 'undefined'\n ) {\n postMessage({ type: `${key}/get`, senderId });\n }\n\n /* ───────────────────── Incoming messages ───────────────────── */\n\n // 1. Updates posted by other frames\n useCrossFrameMessageListener<S>(\n `${key}/post`,\n receive\n ? (data) => {\n stateSignal.set(data);\n }\n : undefined\n );\n\n // 2. Requests from peers asking for our current value\n const handleGetMessage = (_: unknown, originSenderId?: string) => {\n if (!emit) return;\n if (originSenderId === senderId) return; // Don't respond to our own request\n broadcastState(stateSignal());\n };\n\n useCrossFrameMessageListener(\n `${key}/get`,\n emit ? handleGetMessage : undefined\n );\n\n // Cache this instance\n crossFrameStateCache.set(key, { state: stateSignal, setState, postState });\n\n return [stateSignal as Signal<S | undefined>, setState, postState];\n};\n"],"mappings":";;;;;;;AAYA,MAAM,uCAAuB,IAAI,KAO9B;;;;AAKH,MAAM,gBACJ,OACA,cACkB;AAClB,KAAI,OAAO,UAAU,WACnB,QAAQ,MAA0B,UAAU;AAE9C,QAAO;;;;;;AAOT,MAAM,kBAAqB,QAAc;AACvC,KAAI,QAAQ,QAAQ,QAAQ,OAAW,QAAO;AAE9C,QAAO,KAAK,MAAM,KAAK,UAAU,IAAI,CAAC;;;;;;;;;;;;;;;;AAiBxC,MAAa,sBACX,KACA,cACA,UAAkC;CAAE,MAAM;CAAM,SAAS;CAAM,KAK5D;AACH,KAAI,qBAAqB,IAAI,IAAI,EAAE;EAEjC,MAAM,EAAE,OAAO,sBAAU,2BAAc,qBAAqB,IAAI,IAAI;AACpE,SAAO;GAAC;GAAOA;GAAUC;GAAU;;CAGrC,MAAM,EAAE,OAAO,MAAM,UAAU,SAAS;;;;;CAMxC,MAAM,yCAAoC,aAAgB,aAAa,CAAC;CAGxE,MAAM,EAAE,aAAa,aAAaC,6CAAiB;;;;CAKnD,MAAM,kBAAkB,UAAyB;AAC/C,MACE,CAAC,QACD,OAAO,gBAAgB,cACvB,OAAO,UAAU,YAEjB;AACF,cAAY;GACV,MAAM,GAAG,IAAI;GACb,MAAM;GACN;GACD,CAAC;;;;;CAMJ,MAAM,YAAY,mBAAqD;EAErE,MAAM,aAAa,eADN,aAAgB,gBAAuB,aAAa,CAAC,CAC3B;AACvC,cAAY,IAAI,WAAW;AAC3B,iBAAe,WAAW;;;;;CAM5B,MAAM,kBAAkB;AACtB,MAAI,OAAO,gBAAgB,WAAY;AACvC,cAAY;GACV,MAAM,GAAG,IAAI;GACb,MAAM,aAAa;GACnB;GACD,CAAC;;AAIJ,gBAAe,aAAa,CAAC;AAG7B,KACE,WACA,OAAO,gBAAgB,cACvB,OAAO,aAAa,KAAK,YAEzB,aAAY;EAAE,MAAM,GAAG,IAAI;EAAO;EAAU,CAAC;AAM/C,0EACE,GAAG,IAAI,QACP,WACK,SAAS;AACR,cAAY,IAAI,KAAK;KAEvB,OACL;CAGD,MAAM,oBAAoB,GAAY,mBAA4B;AAChE,MAAI,CAAC,KAAM;AACX,MAAI,mBAAmB,SAAU;AACjC,iBAAe,aAAa,CAAC;;AAG/B,0EACE,GAAG,IAAI,OACP,OAAO,mBAAmB,OAC3B;AAGD,sBAAqB,IAAI,KAAK;EAAE,OAAO;EAAa;EAAU;EAAW,CAAC;AAE1E,QAAO;EAAC;EAAsC;EAAU;EAAU"}
|
|
@@ -1,72 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
useCrossURLPathState: () => useCrossURLPathState
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(useCrossURLPathState_exports);
|
|
25
|
-
var import_core = require("@angular/core");
|
|
26
|
-
var import_editor = require("@intlayer/editor");
|
|
27
|
-
var import_useCrossFrameState = require('./useCrossFrameState.cjs');
|
|
28
|
-
const useCrossURLPathState = (initial, opts) => (0, import_useCrossFrameState.useCrossFrameState)(import_editor.MessageKey.INTLAYER_URL_CHANGE, initial, opts);
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_editor_useCrossFrameState = require('./useCrossFrameState.cjs');
|
|
3
|
+
let __angular_core = require("@angular/core");
|
|
4
|
+
__angular_core = require_rolldown_runtime.__toESM(__angular_core);
|
|
5
|
+
let __intlayer_editor = require("@intlayer/editor");
|
|
6
|
+
__intlayer_editor = require_rolldown_runtime.__toESM(__intlayer_editor);
|
|
7
|
+
|
|
8
|
+
//#region src/editor/useCrossURLPathState.ts
|
|
9
|
+
/**
|
|
10
|
+
* Hook to create and manage a cross-frame synchronized URL path state
|
|
11
|
+
* @param initial - The initial URL path
|
|
12
|
+
* @param opts - Options for controlling emit and receive behavior
|
|
13
|
+
* @returns A tuple containing [state signal, setState function, forceSync function]
|
|
14
|
+
*/
|
|
15
|
+
const useCrossURLPathState = (initial, opts) => require_editor_useCrossFrameState.useCrossFrameState(__intlayer_editor.MessageKey.INTLAYER_URL_CHANGE, initial, opts);
|
|
16
|
+
/**
|
|
17
|
+
* Hook for host applications to push URL path changes into the shared state
|
|
18
|
+
* This also monkey patches history methods to capture navigation events
|
|
19
|
+
* @param initial - The initial URL path
|
|
20
|
+
* @returns A tuple containing [state signal, setState function]
|
|
21
|
+
*/
|
|
29
22
|
const useCrossURLPathSetter = (initial) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
23
|
+
const [state, setState] = useCrossURLPathState(initial, {
|
|
24
|
+
emit: true,
|
|
25
|
+
receive: false
|
|
26
|
+
});
|
|
27
|
+
let originalPushState;
|
|
28
|
+
let originalReplaceState;
|
|
29
|
+
const update = () => setState(window.location.pathname);
|
|
30
|
+
try {
|
|
31
|
+
const destroyRef = (0, __angular_core.inject)(__angular_core.DestroyRef, { optional: true });
|
|
32
|
+
if (destroyRef && typeof window !== "undefined") {
|
|
33
|
+
originalPushState = history.pushState;
|
|
34
|
+
originalReplaceState = history.replaceState;
|
|
35
|
+
/**
|
|
36
|
+
* Wraps a history function to dispatch a custom event when called
|
|
37
|
+
* @param fn - The history function to wrap
|
|
38
|
+
* @returns The wrapped function
|
|
39
|
+
*/
|
|
40
|
+
const wrap = (fn) => (...args) => {
|
|
41
|
+
fn.apply(history, args);
|
|
42
|
+
window.dispatchEvent(new Event("locationchange"));
|
|
43
|
+
};
|
|
44
|
+
history.pushState = wrap(originalPushState);
|
|
45
|
+
history.replaceState = wrap(originalReplaceState);
|
|
46
|
+
window.addEventListener("locationchange", update);
|
|
47
|
+
window.addEventListener("popstate", update);
|
|
48
|
+
window.addEventListener("hashchange", update);
|
|
49
|
+
update();
|
|
50
|
+
destroyRef.onDestroy(() => {
|
|
51
|
+
window.removeEventListener("locationchange", update);
|
|
52
|
+
window.removeEventListener("popstate", update);
|
|
53
|
+
window.removeEventListener("hashchange", update);
|
|
54
|
+
if (originalPushState) history.pushState = originalPushState;
|
|
55
|
+
if (originalReplaceState) history.replaceState = originalReplaceState;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
} catch {
|
|
59
|
+
console.warn("useCrossURLPathSetter called outside injection context; URL path synchronization may not be available.");
|
|
60
|
+
}
|
|
61
|
+
return [state, setState];
|
|
66
62
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
});
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
exports.useCrossURLPathSetter = useCrossURLPathSetter;
|
|
66
|
+
exports.useCrossURLPathState = useCrossURLPathState;
|
|
72
67
|
//# sourceMappingURL=useCrossURLPathState.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/useCrossURLPathState.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport { useCrossFrameState } from './useCrossFrameState';\n\n/**\n * Hook to create and manage a cross-frame synchronized URL path state\n * @param initial - The initial URL path\n * @param opts - Options for controlling emit and receive behavior\n * @returns A tuple containing [state signal, setState function, forceSync function]\n */\nexport const useCrossURLPathState = (\n initial?: string,\n opts?: Parameters<typeof useCrossFrameState>[2]\n) => useCrossFrameState<string>(MessageKey.INTLAYER_URL_CHANGE, initial, opts);\n\n/**\n * Hook for host applications to push URL path changes into the shared state\n * This also monkey patches history methods to capture navigation events\n * @param initial - The initial URL path\n * @returns A tuple containing [state signal, setState function]\n */\nexport const useCrossURLPathSetter = (initial?: string) => {\n const [state, setState] = useCrossURLPathState(initial, {\n emit: true,\n receive: false,\n });\n\n // Original history methods\n let originalPushState: typeof history.pushState;\n let originalReplaceState: typeof history.replaceState;\n\n // Function to update state with current pathname\n const update = () => setState(window.location.pathname);\n\n // Use Angular's DestroyRef for cleanup instead of Vue lifecycle hooks\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n\n if (destroyRef && typeof window !== 'undefined') {\n // Save original methods\n originalPushState = history.pushState;\n originalReplaceState = history.replaceState;\n\n /**\n * Wraps a history function to dispatch a custom event when called\n * @param fn - The history function to wrap\n * @returns The wrapped function\n */\n const wrap =\n (fn: typeof history.pushState) =>\n (...args: Parameters<typeof history.pushState>) => {\n fn.apply(history, args);\n window.dispatchEvent(new Event('locationchange'));\n };\n\n // Patch history methods\n history.pushState = wrap(originalPushState);\n history.replaceState = wrap(originalReplaceState);\n\n // Add event listeners\n window.addEventListener('locationchange', update);\n window.addEventListener('popstate', update);\n window.addEventListener('hashchange', update);\n\n // Initialize immediately\n update();\n\n // Clean up on destroy\n destroyRef.onDestroy(() => {\n window.removeEventListener('locationchange', update);\n window.removeEventListener('popstate', update);\n window.removeEventListener('hashchange', update);\n\n // Restore original history methods\n if (originalPushState) history.pushState = originalPushState;\n if (originalReplaceState) history.replaceState = originalReplaceState;\n });\n }\n } catch {\n console.warn(\n 'useCrossURLPathSetter called outside injection context; ' +\n 'URL path synchronization may not be available.'\n );\n }\n\n return [state, setState] as const;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCrossURLPathState.cjs","names":["useCrossFrameState","MessageKey","originalPushState: typeof history.pushState","originalReplaceState: typeof history.replaceState","DestroyRef"],"sources":["../../../src/editor/useCrossURLPathState.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport { useCrossFrameState } from './useCrossFrameState';\n\n/**\n * Hook to create and manage a cross-frame synchronized URL path state\n * @param initial - The initial URL path\n * @param opts - Options for controlling emit and receive behavior\n * @returns A tuple containing [state signal, setState function, forceSync function]\n */\nexport const useCrossURLPathState = (\n initial?: string,\n opts?: Parameters<typeof useCrossFrameState>[2]\n) => useCrossFrameState<string>(MessageKey.INTLAYER_URL_CHANGE, initial, opts);\n\n/**\n * Hook for host applications to push URL path changes into the shared state\n * This also monkey patches history methods to capture navigation events\n * @param initial - The initial URL path\n * @returns A tuple containing [state signal, setState function]\n */\nexport const useCrossURLPathSetter = (initial?: string) => {\n const [state, setState] = useCrossURLPathState(initial, {\n emit: true,\n receive: false,\n });\n\n // Original history methods\n let originalPushState: typeof history.pushState;\n let originalReplaceState: typeof history.replaceState;\n\n // Function to update state with current pathname\n const update = () => setState(window.location.pathname);\n\n // Use Angular's DestroyRef for cleanup instead of Vue lifecycle hooks\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n\n if (destroyRef && typeof window !== 'undefined') {\n // Save original methods\n originalPushState = history.pushState;\n originalReplaceState = history.replaceState;\n\n /**\n * Wraps a history function to dispatch a custom event when called\n * @param fn - The history function to wrap\n * @returns The wrapped function\n */\n const wrap =\n (fn: typeof history.pushState) =>\n (...args: Parameters<typeof history.pushState>) => {\n fn.apply(history, args);\n window.dispatchEvent(new Event('locationchange'));\n };\n\n // Patch history methods\n history.pushState = wrap(originalPushState);\n history.replaceState = wrap(originalReplaceState);\n\n // Add event listeners\n window.addEventListener('locationchange', update);\n window.addEventListener('popstate', update);\n window.addEventListener('hashchange', update);\n\n // Initialize immediately\n update();\n\n // Clean up on destroy\n destroyRef.onDestroy(() => {\n window.removeEventListener('locationchange', update);\n window.removeEventListener('popstate', update);\n window.removeEventListener('hashchange', update);\n\n // Restore original history methods\n if (originalPushState) history.pushState = originalPushState;\n if (originalReplaceState) history.replaceState = originalReplaceState;\n });\n }\n } catch {\n console.warn(\n 'useCrossURLPathSetter called outside injection context; ' +\n 'URL path synchronization may not be available.'\n );\n }\n\n return [state, setState] as const;\n};\n"],"mappings":";;;;;;;;;;;;;;AAUA,MAAa,wBACX,SACA,SACGA,qDAA2BC,6BAAW,qBAAqB,SAAS,KAAK;;;;;;;AAQ9E,MAAa,yBAAyB,YAAqB;CACzD,MAAM,CAAC,OAAO,YAAY,qBAAqB,SAAS;EACtD,MAAM;EACN,SAAS;EACV,CAAC;CAGF,IAAIC;CACJ,IAAIC;CAGJ,MAAM,eAAe,SAAS,OAAO,SAAS,SAAS;AAGvD,KAAI;EACF,MAAM,wCAAoBC,2BAAY,EAAE,UAAU,MAAM,CAAC;AAEzD,MAAI,cAAc,OAAO,WAAW,aAAa;AAE/C,uBAAoB,QAAQ;AAC5B,0BAAuB,QAAQ;;;;;;GAO/B,MAAM,QACH,QACA,GAAG,SAA+C;AACjD,OAAG,MAAM,SAAS,KAAK;AACvB,WAAO,cAAc,IAAI,MAAM,iBAAiB,CAAC;;AAIrD,WAAQ,YAAY,KAAK,kBAAkB;AAC3C,WAAQ,eAAe,KAAK,qBAAqB;AAGjD,UAAO,iBAAiB,kBAAkB,OAAO;AACjD,UAAO,iBAAiB,YAAY,OAAO;AAC3C,UAAO,iBAAiB,cAAc,OAAO;AAG7C,WAAQ;AAGR,cAAW,gBAAgB;AACzB,WAAO,oBAAoB,kBAAkB,OAAO;AACpD,WAAO,oBAAoB,YAAY,OAAO;AAC9C,WAAO,oBAAoB,cAAc,OAAO;AAGhD,QAAI,kBAAmB,SAAQ,YAAY;AAC3C,QAAI,qBAAsB,SAAQ,eAAe;KACjD;;SAEE;AACN,UAAQ,KACN,yGAED;;AAGH,QAAO,CAAC,OAAO,SAAS"}
|
|
@@ -1,58 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __angular_core = require("@angular/core");
|
|
3
|
+
__angular_core = require_rolldown_runtime.__toESM(__angular_core);
|
|
4
|
+
|
|
5
|
+
//#region src/editor/useEditedContentRenderer.ts
|
|
6
|
+
const EDITED_CONTENT_ACTIONS_TOKEN = new __angular_core.InjectionToken("editedContentActions");
|
|
7
|
+
var EditedContentRendererService = @((0, __angular_core.Injectable)({ providedIn: "root" })) class {
|
|
8
|
+
/**
|
|
9
|
+
* Mirrors the React hook one-for-one.
|
|
10
|
+
*/
|
|
11
|
+
useEditedContentRenderer(dictionaryKey, keyPath, fallback) {
|
|
12
|
+
const editedContentContext = (0, __angular_core.inject)(EDITED_CONTENT_ACTIONS_TOKEN, { optional: true });
|
|
13
|
+
return (0, __angular_core.computed)(() => {
|
|
14
|
+
return editedContentContext?.getEditedContentValue(dictionaryKey, keyPath) ?? fallback;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
9
17
|
};
|
|
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 useEditedContentRenderer_exports = {};
|
|
20
|
-
__export(useEditedContentRenderer_exports, {
|
|
21
|
-
EDITED_CONTENT_ACTIONS_TOKEN: () => EDITED_CONTENT_ACTIONS_TOKEN,
|
|
22
|
-
EditedContentRendererService: () => EditedContentRendererService,
|
|
23
|
-
useEditedContentRenderer: () => useEditedContentRenderer
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(useEditedContentRenderer_exports);
|
|
26
|
-
var import_core = require("@angular/core");
|
|
27
|
-
const EDITED_CONTENT_ACTIONS_TOKEN = new import_core.InjectionToken("editedContentActions");
|
|
28
|
-
@((0, import_core.Injectable)({
|
|
29
|
-
providedIn: "root"
|
|
30
|
-
}))
|
|
31
|
-
class EditedContentRendererService {
|
|
32
|
-
/**
|
|
33
|
-
* Mirrors the React hook one-for-one.
|
|
34
|
-
*/
|
|
35
|
-
useEditedContentRenderer(dictionaryKey, keyPath, fallback) {
|
|
36
|
-
const editedContentContext = (0, import_core.inject)(EDITED_CONTENT_ACTIONS_TOKEN, {
|
|
37
|
-
optional: true
|
|
38
|
-
});
|
|
39
|
-
return (0, import_core.computed)(() => {
|
|
40
|
-
const edited = editedContentContext?.getEditedContentValue(
|
|
41
|
-
dictionaryKey,
|
|
42
|
-
keyPath
|
|
43
|
-
);
|
|
44
|
-
return edited ?? fallback;
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
18
|
+
/**
|
|
19
|
+
* Standalone function that can be used like the Vue composable
|
|
20
|
+
*/
|
|
48
21
|
const useEditedContentRenderer = (dictionaryKey, keyPath, fallback) => {
|
|
49
|
-
|
|
50
|
-
return service.useEditedContentRenderer(dictionaryKey, keyPath, fallback);
|
|
22
|
+
return (0, __angular_core.inject)(EditedContentRendererService).useEditedContentRenderer(dictionaryKey, keyPath, fallback);
|
|
51
23
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
});
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
exports.EDITED_CONTENT_ACTIONS_TOKEN = EDITED_CONTENT_ACTIONS_TOKEN;
|
|
27
|
+
exports.EditedContentRendererService = EditedContentRendererService;
|
|
28
|
+
exports.useEditedContentRenderer = useEditedContentRenderer;
|
|
58
29
|
//# sourceMappingURL=useEditedContentRenderer.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/useEditedContentRenderer.ts"],"sourcesContent":["import {\n computed,\n
|
|
1
|
+
{"version":3,"file":"useEditedContentRenderer.cjs","names":["InjectionToken"],"sources":["../../../src/editor/useEditedContentRenderer.ts"],"sourcesContent":["import {\n computed,\n Injectable,\n InjectionToken,\n inject,\n type Signal,\n} from '@angular/core';\nimport type { KeyPath } from '@intlayer/types';\n\nexport interface EditedContentActions {\n getEditedContentValue(dictionaryKey: string, keyPath: KeyPath[]): unknown;\n}\n\nexport const EDITED_CONTENT_ACTIONS_TOKEN =\n new InjectionToken<EditedContentActions | null>('editedContentActions');\n\n@Injectable({\n providedIn: 'root',\n})\nexport class EditedContentRendererService {\n /**\n * Mirrors the React hook one-for-one.\n */\n useEditedContentRenderer(\n dictionaryKey: string,\n keyPath: KeyPath[],\n fallback: unknown\n ): Signal<unknown> {\n const editedContentContext = inject(EDITED_CONTENT_ACTIONS_TOKEN, {\n optional: true,\n });\n\n return computed(() => {\n const edited = editedContentContext?.getEditedContentValue(\n dictionaryKey,\n keyPath\n ) as string | undefined;\n\n return edited ?? fallback;\n });\n }\n}\n\n/**\n * Standalone function that can be used like the Vue composable\n */\nexport const useEditedContentRenderer = (\n dictionaryKey: string,\n keyPath: KeyPath[],\n fallback: unknown\n): Signal<unknown> => {\n const service = inject(EditedContentRendererService);\n return service.useEditedContentRenderer(dictionaryKey, keyPath, fallback);\n};\n"],"mappings":";;;;;AAaA,MAAa,+BACX,IAAIA,8BAA4C,uBAAuB;AAKzE,IAAa,+BAHb,iCAAY,EACV,YAAY,QACb,CAAC,EACF,MAA0C;;;;CAIxC,yBACE,eACA,SACA,UACiB;EACjB,MAAM,kDAA8B,8BAA8B,EAChE,UAAU,MACX,CAAC;AAEF,4CAAsB;AAMpB,UALe,sBAAsB,sBACnC,eACA,QACD,IAEgB;IACjB;;;;;;AAON,MAAa,4BACX,eACA,SACA,aACoB;AAEpB,mCADuB,6BAA6B,CACrC,yBAAyB,eAAe,SAAS,SAAS"}
|
|
@@ -1,46 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
__export(useEditor_exports, {
|
|
21
|
-
useEditor: () => useEditor
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(useEditor_exports);
|
|
24
|
-
var import_configuration = require('./configuration.cjs');
|
|
25
|
-
var import_createSharedComposable = require('./createSharedComposable.cjs');
|
|
26
|
-
var import_dictionariesRecord = require('./dictionariesRecord.cjs');
|
|
27
|
-
var import_editorEnabled = require('./editorEnabled.cjs');
|
|
28
|
-
var import_editorLocale = require('./editorLocale.cjs');
|
|
29
|
-
var import_focusDictionary = require('./focusDictionary.cjs');
|
|
30
|
-
var import_useCrossURLPathState = require('./useCrossURLPathState.cjs');
|
|
31
|
-
var import_useIframeClickInterceptor = require('./useIframeClickInterceptor.cjs');
|
|
32
|
-
const useEditor = (0, import_createSharedComposable.createSharedComposable)(() => {
|
|
33
|
-
(0, import_configuration.useConfiguration)();
|
|
34
|
-
(0, import_editorEnabled.useEditorEnabled)();
|
|
35
|
-
(0, import_focusDictionary.useFocusDictionary)();
|
|
36
|
-
(0, import_useIframeClickInterceptor.useIframeClickMerger)();
|
|
37
|
-
(0, import_useCrossURLPathState.useCrossURLPathSetter)();
|
|
38
|
-
(0, import_editorLocale.useEditorLocale)();
|
|
39
|
-
(0, import_dictionariesRecord.useDictionariesRecord)();
|
|
40
|
-
(0, import_editorLocale.useEditorLocale)();
|
|
41
|
-
});
|
|
42
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
-
0 && (module.exports = {
|
|
44
|
-
useEditor
|
|
1
|
+
const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
|
|
2
|
+
const require_editor_editorEnabled = require('./editorEnabled.cjs');
|
|
3
|
+
const require_editor_focusDictionary = require('./focusDictionary.cjs');
|
|
4
|
+
const require_editor_configuration = require('./configuration.cjs');
|
|
5
|
+
const require_editor_dictionariesRecord = require('./dictionariesRecord.cjs');
|
|
6
|
+
const require_editor_editorLocale = require('./editorLocale.cjs');
|
|
7
|
+
const require_editor_useCrossURLPathState = require('./useCrossURLPathState.cjs');
|
|
8
|
+
const require_editor_useIframeClickInterceptor = require('./useIframeClickInterceptor.cjs');
|
|
9
|
+
|
|
10
|
+
//#region src/editor/useEditor.ts
|
|
11
|
+
const useEditor = require_editor_createSharedComposable.createSharedComposable(() => {
|
|
12
|
+
require_editor_configuration.useConfiguration();
|
|
13
|
+
require_editor_editorEnabled.useEditorEnabled();
|
|
14
|
+
require_editor_focusDictionary.useFocusDictionary();
|
|
15
|
+
require_editor_useIframeClickInterceptor.useIframeClickMerger();
|
|
16
|
+
require_editor_useCrossURLPathState.useCrossURLPathSetter();
|
|
17
|
+
require_editor_editorLocale.useEditorLocale();
|
|
18
|
+
require_editor_dictionariesRecord.useDictionariesRecord();
|
|
19
|
+
require_editor_editorLocale.useEditorLocale();
|
|
45
20
|
});
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.useEditor = useEditor;
|
|
46
24
|
//# sourceMappingURL=useEditor.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/useEditor.ts"],"sourcesContent":["import { useConfiguration } from './configuration';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useDictionariesRecord } from './dictionariesRecord';\nimport { useEditorEnabled } from './editorEnabled';\nimport { useEditorLocale } from './editorLocale';\nimport { useFocusDictionary } from './focusDictionary';\nimport { useCrossURLPathSetter } from './useCrossURLPathState';\nimport { useIframeClickMerger } from './useIframeClickInterceptor';\n\nexport const useEditor = createSharedComposable(() => {\n useConfiguration();\n useEditorEnabled();\n useFocusDictionary();\n useIframeClickMerger();\n useCrossURLPathSetter();\n useEditorLocale();\n useDictionariesRecord();\n useEditorLocale();\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useEditor.cjs","names":["createSharedComposable"],"sources":["../../../src/editor/useEditor.ts"],"sourcesContent":["import { useConfiguration } from './configuration';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useDictionariesRecord } from './dictionariesRecord';\nimport { useEditorEnabled } from './editorEnabled';\nimport { useEditorLocale } from './editorLocale';\nimport { useFocusDictionary } from './focusDictionary';\nimport { useCrossURLPathSetter } from './useCrossURLPathState';\nimport { useIframeClickMerger } from './useIframeClickInterceptor';\n\nexport const useEditor = createSharedComposable(() => {\n useConfiguration();\n useEditorEnabled();\n useFocusDictionary();\n useIframeClickMerger();\n useCrossURLPathSetter();\n useEditorLocale();\n useDictionariesRecord();\n useEditorLocale();\n});\n"],"mappings":";;;;;;;;;;AASA,MAAa,YAAYA,mEAA6B;AACpD,gDAAkB;AAClB,gDAAkB;AAClB,oDAAoB;AACpB,gEAAsB;AACtB,4DAAuB;AACvB,8CAAiB;AACjB,0DAAuB;AACvB,8CAAiB;EACjB"}
|