angular-intlayer 8.1.2 → 8.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/UI/ContentSelector.component.cjs +2 -116
- package/dist/cjs/UI/ContentSelector.component.cjs.map +1 -1
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.cjs +1 -11
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.cjs +1 -8
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
- package/dist/cjs/client/index.cjs +1 -28
- package/dist/cjs/client/installIntlayer.cjs +1 -77
- package/dist/cjs/client/installIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useDictionary.cjs +1 -15
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs +1 -24
- package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +1 -25
- package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
- package/dist/cjs/client/useIntl.cjs +1 -40
- package/dist/cjs/client/useIntl.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs +1 -44
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useLoadDynamic.cjs +1 -28
- package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs +1 -60
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocaleStorage.cjs +1 -60
- package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
- package/dist/cjs/editor/ContentSelectorWrapper.component.cjs +2 -51
- package/dist/cjs/editor/ContentSelectorWrapper.component.cjs.map +1 -1
- package/dist/cjs/editor/EditedContentRenderer.component.cjs +1 -54
- package/dist/cjs/editor/EditedContentRenderer.component.cjs.map +1 -1
- package/dist/cjs/editor/EditorSelectorRenderer.component.cjs +2 -35
- package/dist/cjs/editor/EditorSelectorRenderer.component.cjs.map +1 -1
- package/dist/cjs/editor/communicator.cjs +1 -63
- package/dist/cjs/editor/communicator.cjs.map +1 -1
- package/dist/cjs/editor/configuration.cjs +1 -22
- package/dist/cjs/editor/configuration.cjs.map +1 -1
- package/dist/cjs/editor/createSharedComposable.cjs +1 -50
- package/dist/cjs/editor/createSharedComposable.cjs.map +1 -1
- package/dist/cjs/editor/dictionariesRecord.cjs +1 -49
- package/dist/cjs/editor/dictionariesRecord.cjs.map +1 -1
- package/dist/cjs/editor/editedContent.cjs +1 -61
- package/dist/cjs/editor/editedContent.cjs.map +1 -1
- package/dist/cjs/editor/editorEnabled.cjs +1 -49
- package/dist/cjs/editor/editorEnabled.cjs.map +1 -1
- package/dist/cjs/editor/editorLocale.cjs +1 -21
- package/dist/cjs/editor/editorLocale.cjs.map +1 -1
- package/dist/cjs/editor/focusDictionary.cjs +1 -62
- package/dist/cjs/editor/focusDictionary.cjs.map +1 -1
- package/dist/cjs/editor/index.cjs +1 -25
- package/dist/cjs/editor/installIntlayerEditor.cjs +1 -52
- package/dist/cjs/editor/installIntlayerEditor.cjs.map +1 -1
- package/dist/cjs/editor/useCrossFrameMessageListener.cjs +1 -73
- package/dist/cjs/editor/useCrossFrameMessageListener.cjs.map +1 -1
- package/dist/cjs/editor/useCrossFrameState.cjs +1 -114
- package/dist/cjs/editor/useCrossFrameState.cjs.map +1 -1
- package/dist/cjs/editor/useCrossURLPathState.cjs +1 -65
- package/dist/cjs/editor/useCrossURLPathState.cjs.map +1 -1
- package/dist/cjs/editor/useEditedContentRenderer.cjs +1 -35
- package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -1
- package/dist/cjs/editor/useEditor.cjs +1 -24
- package/dist/cjs/editor/useEditor.cjs.map +1 -1
- package/dist/cjs/editor/useIframeClickInterceptor.cjs +1 -39
- package/dist/cjs/editor/useIframeClickInterceptor.cjs.map +1 -1
- package/dist/cjs/getDictionary.cjs +1 -17
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs +1 -18
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -49
- package/dist/cjs/markdown/index.cjs +1 -13
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs +1 -79
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -1
- package/dist/cjs/plugins.cjs +1 -188
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/renderIntlayerNode.cjs +1 -28
- package/dist/cjs/renderIntlayerNode.cjs.map +1 -1
- package/dist/cjs/webpack/index.cjs +1 -4
- package/dist/cjs/webpack/mergeConfig.cjs +1 -44
- package/dist/cjs/webpack/mergeConfig.cjs.map +1 -1
- package/dist/esm/UI/ContentSelector.component.mjs +2 -109
- package/dist/esm/UI/ContentSelector.component.mjs.map +1 -1
- package/dist/esm/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs +1 -10
- package/dist/esm/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs +1 -7
- package/dist/esm/client/index.mjs +1 -10
- package/dist/esm/client/installIntlayer.mjs +1 -65
- package/dist/esm/client/installIntlayer.mjs.map +1 -1
- package/dist/esm/client/useDictionary.mjs +1 -13
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/esm/client/useDictionaryAsync.mjs +1 -21
- package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
- package/dist/esm/client/useDictionaryDynamic.mjs +1 -22
- package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
- package/dist/esm/client/useIntl.mjs +1 -38
- package/dist/esm/client/useIntl.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs +1 -41
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useLoadDynamic.mjs +1 -26
- package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
- package/dist/esm/client/useLocale.mjs +1 -57
- package/dist/esm/client/useLocale.mjs.map +1 -1
- package/dist/esm/client/useLocaleStorage.mjs +1 -53
- package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
- package/dist/esm/editor/ContentSelectorWrapper.component.mjs +2 -44
- package/dist/esm/editor/ContentSelectorWrapper.component.mjs.map +1 -1
- package/dist/esm/editor/EditedContentRenderer.component.mjs +1 -47
- package/dist/esm/editor/EditedContentRenderer.component.mjs.map +1 -1
- package/dist/esm/editor/EditorSelectorRenderer.component.mjs +2 -28
- package/dist/esm/editor/EditorSelectorRenderer.component.mjs.map +1 -1
- package/dist/esm/editor/communicator.mjs +1 -58
- package/dist/esm/editor/communicator.mjs.map +1 -1
- package/dist/esm/editor/configuration.mjs +1 -19
- package/dist/esm/editor/configuration.mjs.map +1 -1
- package/dist/esm/editor/createSharedComposable.mjs +1 -47
- package/dist/esm/editor/createSharedComposable.mjs.map +1 -1
- package/dist/esm/editor/dictionariesRecord.mjs +1 -45
- package/dist/esm/editor/dictionariesRecord.mjs.map +1 -1
- package/dist/esm/editor/editedContent.mjs +1 -57
- package/dist/esm/editor/editedContent.mjs.map +1 -1
- package/dist/esm/editor/editorEnabled.mjs +1 -45
- package/dist/esm/editor/editorEnabled.mjs.map +1 -1
- package/dist/esm/editor/editorLocale.mjs +1 -19
- package/dist/esm/editor/editorLocale.mjs.map +1 -1
- package/dist/esm/editor/focusDictionary.mjs +1 -58
- package/dist/esm/editor/focusDictionary.mjs.map +1 -1
- package/dist/esm/editor/index.mjs +1 -6
- package/dist/esm/editor/installIntlayerEditor.mjs +1 -49
- package/dist/esm/editor/installIntlayerEditor.mjs.map +1 -1
- package/dist/esm/editor/useCrossFrameMessageListener.mjs +1 -71
- package/dist/esm/editor/useCrossFrameMessageListener.mjs.map +1 -1
- package/dist/esm/editor/useCrossFrameState.mjs +1 -112
- package/dist/esm/editor/useCrossFrameState.mjs.map +1 -1
- package/dist/esm/editor/useCrossURLPathState.mjs +1 -62
- package/dist/esm/editor/useCrossURLPathState.mjs.map +1 -1
- package/dist/esm/editor/useEditedContentRenderer.mjs +1 -26
- package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -1
- package/dist/esm/editor/useEditor.mjs +1 -23
- package/dist/esm/editor/useEditor.mjs.map +1 -1
- package/dist/esm/editor/useIframeClickInterceptor.mjs +1 -36
- package/dist/esm/editor/useIframeClickInterceptor.mjs.map +1 -1
- package/dist/esm/getDictionary.mjs +1 -15
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs +1 -16
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -14
- package/dist/esm/markdown/index.mjs +1 -3
- package/dist/esm/markdown/installIntlayerMarkdown.mjs +1 -68
- package/dist/esm/markdown/installIntlayerMarkdown.mjs.map +1 -1
- package/dist/esm/plugins.mjs +1 -182
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/esm/renderIntlayerNode.mjs +1 -26
- package/dist/esm/renderIntlayerNode.mjs.map +1 -1
- package/dist/esm/webpack/index.mjs +1 -3
- package/dist/esm/webpack/mergeConfig.mjs +1 -42
- package/dist/esm/webpack/mergeConfig.mjs.map +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts +2 -2
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/editor/ContentSelectorWrapper.component.d.ts +1 -1
- package/dist/types/editor/ContentSelectorWrapper.component.d.ts.map +1 -1
- package/dist/types/editor/EditorSelectorRenderer.component.d.ts +1 -1
- package/dist/types/getDictionary.d.ts +3 -3
- package/dist/types/getDictionary.d.ts.map +1 -1
- package/dist/types/getIntlayer.d.ts +1 -1
- package/dist/types/getIntlayer.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/markdown/installIntlayerMarkdown.d.ts +1 -1
- package/dist/types/markdown/installIntlayerMarkdown.d.ts.map +1 -1
- package/dist/types/plugins.d.ts +1 -1
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/webpack/mergeConfig.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -1,115 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_editor_communicator = require('./communicator.cjs');
|
|
4
|
-
const require_editor_useCrossFrameMessageListener = require('./useCrossFrameMessageListener.cjs');
|
|
5
|
-
let _angular_core = require("@angular/core");
|
|
6
|
-
|
|
7
|
-
//#region src/editor/useCrossFrameState.ts
|
|
8
|
-
const crossFrameStateCache = /* @__PURE__ */ new Map();
|
|
9
|
-
/**
|
|
10
|
-
* Utility to resolve either a value or an updater function (mirrors React's `setState`).
|
|
11
|
-
*/
|
|
12
|
-
const resolveState = (state, prevState) => {
|
|
13
|
-
if (typeof state === "function") return state(prevState);
|
|
14
|
-
return state;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Creates a plain object copy that can be safely serialized
|
|
18
|
-
* for postMessage communication
|
|
19
|
-
*/
|
|
20
|
-
const toSerializable = (obj) => {
|
|
21
|
-
if (obj === null || obj === void 0) return obj;
|
|
22
|
-
return JSON.parse(JSON.stringify(obj));
|
|
23
|
-
};
|
|
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, postState } = crossFrameStateCache.get(key);
|
|
44
|
-
return [
|
|
45
|
-
state,
|
|
46
|
-
setState,
|
|
47
|
-
postState
|
|
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
|
-
];
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
//#endregion
|
|
114
|
-
exports.useCrossFrameState = useCrossFrameState;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./communicator.cjs`),t=require(`./useCrossFrameMessageListener.cjs`);let n=require(`@angular/core`);const r=new Map,i=(e,t)=>typeof e==`function`?e(t):e,a=e=>e==null?e:JSON.parse(JSON.stringify(e)),o=(o,s,c={emit:!0,receive:!0})=>{if(r.has(o)){let{state:e,setState:t,postState:n}=r.get(o);return[e,t,n]}let{emit:l=!0,receive:u=!0}=c,d=(0,n.signal)(i(s)),{postMessage:f,senderId:p}=e.useCommunicator(),m=e=>{!l||typeof f!=`function`||e===void 0||f({type:`${o}/post`,data:e,senderId:p})},h=e=>{let t=a(i(e,d()));d.set(t),m(t)},g=()=>{typeof f==`function`&&f({type:`${o}/post`,data:d(),senderId:p})};return m(d()),u&&typeof f==`function`&&d()===void 0&&f({type:`${o}/get`,senderId:p}),t.useCrossFrameMessageListener(`${o}/post`,u?e=>{d.set(e)}:void 0),t.useCrossFrameMessageListener(`${o}/get`,l?(e,t)=>{l&&t!==p&&m(d())}:void 0),r.set(o,{state:d,setState:h,postState:g}),[d,h,g]};exports.useCrossFrameState=o;
|
|
115
2
|
//# sourceMappingURL=useCrossFrameState.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCrossFrameState.cjs","names":["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":"
|
|
1
|
+
{"version":3,"file":"useCrossFrameState.cjs","names":["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":"qOAYA,MAAM,EAAuB,IAAI,IAY3B,GACJ,EACA,IAEI,OAAO,GAAU,WACX,EAA0B,EAAU,CAEvC,EAOH,EAAqB,GACrB,GAAQ,KAAkC,EAEvC,KAAK,MAAM,KAAK,UAAU,EAAI,CAAC,CAiB3B,GACX,EACA,EACA,EAAkC,CAAE,KAAM,GAAM,QAAS,GAAM,GAK5D,CACH,GAAI,EAAqB,IAAI,EAAI,CAAE,CAEjC,GAAM,CAAE,QAAO,WAAU,aAAc,EAAqB,IAAI,EAAI,CACpE,MAAO,CAAC,EAAO,EAAU,EAAU,CAGrC,GAAM,CAAE,OAAO,GAAM,UAAU,IAAS,EAMlC,GAAA,EAAA,EAAA,QAAoC,EAAgB,EAAa,CAAC,CAGlE,CAAE,cAAa,YAAaA,EAAAA,iBAAiB,CAK7C,EAAkB,GAAyB,CAE7C,CAAC,GACD,OAAO,GAAgB,YAChB,IAAU,QAGnB,EAAY,CACV,KAAM,GAAG,EAAI,OACb,KAAM,EACN,WACD,CAAC,EAME,EAAY,GAAqD,CAErE,IAAM,EAAa,EADN,EAAgB,EAAuB,GAAa,CAAC,CAC3B,CACvC,EAAY,IAAI,EAAW,CAC3B,EAAe,EAAW,EAMtB,MAAkB,CAClB,OAAO,GAAgB,YAC3B,EAAY,CACV,KAAM,GAAG,EAAI,OACb,KAAM,GAAa,CACnB,WACD,CAAC,EA0CJ,OAtCA,EAAe,GAAa,CAAC,CAI3B,GACA,OAAO,GAAgB,YAChB,GAAa,GAAK,QAEzB,EAAY,CAAE,KAAM,GAAG,EAAI,MAAO,WAAU,CAAC,CAM/C,EAAA,6BACE,GAAG,EAAI,OACP,EACK,GAAS,CACR,EAAY,IAAI,EAAK,EAEvB,IAAA,GACL,CASD,EAAA,6BACE,GAAG,EAAI,MACP,GARwB,EAAY,IAA4B,CAC3D,GACD,IAAmB,GACvB,EAAe,GAAa,CAAC,EAKH,IAAA,GAC3B,CAGD,EAAqB,IAAI,EAAK,CAAE,MAAO,EAAa,WAAU,YAAW,CAAC,CAEnE,CAAC,EAAsC,EAAU,EAAU"}
|
|
@@ -1,66 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_editor_useCrossFrameState = require('./useCrossFrameState.cjs');
|
|
4
|
-
let _angular_core = require("@angular/core");
|
|
5
|
-
let _intlayer_editor = require("@intlayer/editor");
|
|
6
|
-
|
|
7
|
-
//#region src/editor/useCrossURLPathState.ts
|
|
8
|
-
/**
|
|
9
|
-
* Hook to create and manage a cross-frame synchronized URL path state
|
|
10
|
-
* @param initial - The initial URL path
|
|
11
|
-
* @param opts - Options for controlling emit and receive behavior
|
|
12
|
-
* @returns A tuple containing [state signal, setState function, forceSync function]
|
|
13
|
-
*/
|
|
14
|
-
const useCrossURLPathState = (initial, opts) => require_editor_useCrossFrameState.useCrossFrameState(_intlayer_editor.MessageKey.INTLAYER_URL_CHANGE, initial, opts);
|
|
15
|
-
/**
|
|
16
|
-
* Hook for host applications to push URL path changes into the shared state
|
|
17
|
-
* This also monkey patches history methods to capture navigation events
|
|
18
|
-
* @param initial - The initial URL path
|
|
19
|
-
* @returns A tuple containing [state signal, setState function]
|
|
20
|
-
*/
|
|
21
|
-
const useCrossURLPathSetter = (initial) => {
|
|
22
|
-
const [state, setState] = useCrossURLPathState(initial, {
|
|
23
|
-
emit: true,
|
|
24
|
-
receive: false
|
|
25
|
-
});
|
|
26
|
-
let originalPushState;
|
|
27
|
-
let originalReplaceState;
|
|
28
|
-
const update = () => setState(window.location.pathname);
|
|
29
|
-
try {
|
|
30
|
-
const destroyRef = (0, _angular_core.inject)(_angular_core.DestroyRef, { optional: true });
|
|
31
|
-
if (destroyRef && typeof window !== "undefined") {
|
|
32
|
-
originalPushState = history.pushState;
|
|
33
|
-
originalReplaceState = history.replaceState;
|
|
34
|
-
/**
|
|
35
|
-
* Wraps a history function to dispatch a custom event when called
|
|
36
|
-
* @param fn - The history function to wrap
|
|
37
|
-
* @returns The wrapped function
|
|
38
|
-
*/
|
|
39
|
-
const wrap = (fn) => (...args) => {
|
|
40
|
-
fn.apply(history, args);
|
|
41
|
-
window.dispatchEvent(new Event("locationchange"));
|
|
42
|
-
};
|
|
43
|
-
history.pushState = wrap(originalPushState);
|
|
44
|
-
history.replaceState = wrap(originalReplaceState);
|
|
45
|
-
window.addEventListener("locationchange", update);
|
|
46
|
-
window.addEventListener("popstate", update);
|
|
47
|
-
window.addEventListener("hashchange", update);
|
|
48
|
-
update();
|
|
49
|
-
destroyRef.onDestroy(() => {
|
|
50
|
-
window.removeEventListener("locationchange", update);
|
|
51
|
-
window.removeEventListener("popstate", update);
|
|
52
|
-
window.removeEventListener("hashchange", update);
|
|
53
|
-
if (originalPushState) history.pushState = originalPushState;
|
|
54
|
-
if (originalReplaceState) history.replaceState = originalReplaceState;
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
} catch {
|
|
58
|
-
console.warn("useCrossURLPathSetter called outside injection context; URL path synchronization may not be available.");
|
|
59
|
-
}
|
|
60
|
-
return [state, setState];
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
//#endregion
|
|
64
|
-
exports.useCrossURLPathSetter = useCrossURLPathSetter;
|
|
65
|
-
exports.useCrossURLPathState = useCrossURLPathState;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./useCrossFrameState.cjs`);let t=require(`@angular/core`),n=require(`@intlayer/editor`);const r=(t,r)=>e.useCrossFrameState(n.MessageKey.INTLAYER_URL_CHANGE,t,r),i=e=>{let[n,i]=r(e,{emit:!0,receive:!1}),a,o,s=()=>i(window.location.pathname);try{let e=(0,t.inject)(t.DestroyRef,{optional:!0});if(e&&typeof window<`u`){a=history.pushState,o=history.replaceState;let t=e=>(...t)=>{e.apply(history,t),window.dispatchEvent(new Event(`locationchange`))};history.pushState=t(a),history.replaceState=t(o),window.addEventListener(`locationchange`,s),window.addEventListener(`popstate`,s),window.addEventListener(`hashchange`,s),s(),e.onDestroy(()=>{window.removeEventListener(`locationchange`,s),window.removeEventListener(`popstate`,s),window.removeEventListener(`hashchange`,s),a&&(history.pushState=a),o&&(history.replaceState=o)})}}catch{console.warn(`useCrossURLPathSetter called outside injection context; URL path synchronization may not be available.`)}return[n,i]};exports.useCrossURLPathSetter=i,exports.useCrossURLPathState=r;
|
|
66
2
|
//# sourceMappingURL=useCrossURLPathState.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCrossURLPathState.cjs","names":["useCrossFrameState","MessageKey","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":"
|
|
1
|
+
{"version":3,"file":"useCrossURLPathState.cjs","names":["useCrossFrameState","MessageKey","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":"yNAUA,MAAa,GACX,EACA,IACGA,EAAAA,mBAA2BC,EAAAA,WAAW,oBAAqB,EAAS,EAAK,CAQjE,EAAyB,GAAqB,CACzD,GAAM,CAAC,EAAO,GAAY,EAAqB,EAAS,CACtD,KAAM,GACN,QAAS,GACV,CAAC,CAGE,EACA,EAGE,MAAe,EAAS,OAAO,SAAS,SAAS,CAGvD,GAAI,CACF,IAAM,GAAA,EAAA,EAAA,QAAoBC,EAAAA,WAAY,CAAE,SAAU,GAAM,CAAC,CAEzD,GAAI,GAAc,OAAO,OAAW,IAAa,CAE/C,EAAoB,QAAQ,UAC5B,EAAuB,QAAQ,aAO/B,IAAM,EACH,IACA,GAAG,IAA+C,CACjD,EAAG,MAAM,QAAS,EAAK,CACvB,OAAO,cAAc,IAAI,MAAM,iBAAiB,CAAC,EAIrD,QAAQ,UAAY,EAAK,EAAkB,CAC3C,QAAQ,aAAe,EAAK,EAAqB,CAGjD,OAAO,iBAAiB,iBAAkB,EAAO,CACjD,OAAO,iBAAiB,WAAY,EAAO,CAC3C,OAAO,iBAAiB,aAAc,EAAO,CAG7C,GAAQ,CAGR,EAAW,cAAgB,CACzB,OAAO,oBAAoB,iBAAkB,EAAO,CACpD,OAAO,oBAAoB,WAAY,EAAO,CAC9C,OAAO,oBAAoB,aAAc,EAAO,CAG5C,IAAmB,QAAQ,UAAY,GACvC,IAAsB,QAAQ,aAAe,IACjD,OAEE,CACN,QAAQ,KACN,yGAED,CAGH,MAAO,CAAC,EAAO,EAAS"}
|
|
@@ -1,36 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_decorate = require('../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.cjs');
|
|
4
|
-
let _angular_core = require("@angular/core");
|
|
5
|
-
|
|
6
|
-
//#region src/editor/useEditedContentRenderer.ts
|
|
7
|
-
const EDITED_CONTENT_ACTIONS_TOKEN = new _angular_core.InjectionToken("editedContentActions");
|
|
8
|
-
let EditedContentRendererService = class EditedContentRendererService {
|
|
9
|
-
/**
|
|
10
|
-
* Mirrors the React hook one-for-one.
|
|
11
|
-
*/
|
|
12
|
-
useEditedContentRenderer(dictionaryKey, keyPath, fallback) {
|
|
13
|
-
const editedContentContext = (0, _angular_core.inject)(EDITED_CONTENT_ACTIONS_TOKEN, { optional: true });
|
|
14
|
-
return (0, _angular_core.computed)(() => {
|
|
15
|
-
return editedContentContext?.getEditedContentValue(dictionaryKey, keyPath) ?? fallback;
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
EditedContentRendererService = require_decorate.__decorate([(0, _angular_core.Injectable)({ providedIn: "root" })], EditedContentRendererService);
|
|
20
|
-
/**
|
|
21
|
-
* Standalone function that can be used like the Vue composable
|
|
22
|
-
*/
|
|
23
|
-
const useEditedContentRenderer = (dictionaryKey, keyPath, fallback) => {
|
|
24
|
-
return (0, _angular_core.inject)(EditedContentRendererService).useEditedContentRenderer(dictionaryKey, keyPath, fallback);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
exports.EDITED_CONTENT_ACTIONS_TOKEN = EDITED_CONTENT_ACTIONS_TOKEN;
|
|
29
|
-
Object.defineProperty(exports, 'EditedContentRendererService', {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
get: function () {
|
|
32
|
-
return EditedContentRendererService;
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
exports.useEditedContentRenderer = useEditedContentRenderer;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.cjs`);let t=require(`@angular/core`);const n=new t.InjectionToken(`editedContentActions`);let r=class{useEditedContentRenderer(e,r,i){let a=(0,t.inject)(n,{optional:!0});return(0,t.computed)(()=>a?.getEditedContentValue(e,r)??i)}};r=e.__decorate([(0,t.Injectable)({providedIn:`root`})],r);const i=(e,n,i)=>(0,t.inject)(r).useEditedContentRenderer(e,n,i);exports.EDITED_CONTENT_ACTIONS_TOKEN=n,Object.defineProperty(exports,`EditedContentRendererService`,{enumerable:!0,get:function(){return r}}),exports.useEditedContentRenderer=i;
|
|
36
2
|
//# sourceMappingURL=useEditedContentRenderer.cjs.map
|
|
@@ -1 +1 @@
|
|
|
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":"
|
|
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":"iOAaA,MAAa,EACX,IAAIA,EAAAA,eAA4C,uBAAuB,CAKlE,IAAA,EAAA,KAAmC,CAIxC,yBACE,EACA,EACA,EACiB,CACjB,IAAM,GAAA,EAAA,EAAA,QAA8B,EAA8B,CAChE,SAAU,GACX,CAAC,CAEF,OAAA,EAAA,EAAA,cACiB,GAAsB,sBACnC,EACA,EACD,EAEgB,EACjB,oCAvBM,CACV,WAAY,OACb,CAAC,CAAA,CAAA,EAAA,CA4BF,MAAa,GACX,EACA,EACA,KAGA,EAAA,EAAA,QADuB,EAA6B,CACrC,yBAAyB,EAAe,EAAS,EAAS"}
|
|
@@ -1,25 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
|
|
3
|
-
const require_editor_editorEnabled = require('./editorEnabled.cjs');
|
|
4
|
-
const require_editor_focusDictionary = require('./focusDictionary.cjs');
|
|
5
|
-
const require_editor_configuration = require('./configuration.cjs');
|
|
6
|
-
const require_editor_dictionariesRecord = require('./dictionariesRecord.cjs');
|
|
7
|
-
const require_editor_editorLocale = require('./editorLocale.cjs');
|
|
8
|
-
const require_editor_useCrossURLPathState = require('./useCrossURLPathState.cjs');
|
|
9
|
-
const require_editor_useIframeClickInterceptor = require('./useIframeClickInterceptor.cjs');
|
|
10
|
-
|
|
11
|
-
//#region src/editor/useEditor.ts
|
|
12
|
-
const useEditor = require_editor_createSharedComposable.createSharedComposable(() => {
|
|
13
|
-
require_editor_configuration.useConfiguration();
|
|
14
|
-
require_editor_editorEnabled.useEditorEnabled();
|
|
15
|
-
require_editor_focusDictionary.useFocusDictionary();
|
|
16
|
-
require_editor_useIframeClickInterceptor.useIframeClickMerger();
|
|
17
|
-
require_editor_useCrossURLPathState.useCrossURLPathSetter();
|
|
18
|
-
require_editor_editorLocale.useEditorLocale();
|
|
19
|
-
require_editor_dictionariesRecord.useDictionariesRecord();
|
|
20
|
-
require_editor_editorLocale.useEditorLocale();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
exports.useEditor = useEditor;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./createSharedComposable.cjs`),t=require(`./editorEnabled.cjs`),n=require(`./focusDictionary.cjs`),r=require(`./configuration.cjs`),i=require(`./dictionariesRecord.cjs`),a=require(`./editorLocale.cjs`),o=require(`./useCrossURLPathState.cjs`),s=require(`./useIframeClickInterceptor.cjs`),c=e.createSharedComposable(()=>{r.useConfiguration(),t.useEditorEnabled(),n.useFocusDictionary(),s.useIframeClickMerger(),o.useCrossURLPathSetter(),a.useEditorLocale(),i.useDictionariesRecord(),a.useEditorLocale()});exports.useEditor=c;
|
|
25
2
|
//# sourceMappingURL=useEditor.cjs.map
|
|
@@ -1 +1 @@
|
|
|
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":"
|
|
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":"mXASa,EAAYA,EAAAA,2BAA6B,CACpD,EAAA,kBAAkB,CAClB,EAAA,kBAAkB,CAClB,EAAA,oBAAoB,CACpB,EAAA,sBAAsB,CACtB,EAAA,uBAAuB,CACvB,EAAA,iBAAiB,CACjB,EAAA,uBAAuB,CACvB,EAAA,iBAAiB,EACjB"}
|
|
@@ -1,40 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
|
|
4
|
-
const require_editor_useCrossFrameMessageListener = require('./useCrossFrameMessageListener.cjs');
|
|
5
|
-
let _angular_core = require("@angular/core");
|
|
6
|
-
let _intlayer_editor = require("@intlayer/editor");
|
|
7
|
-
|
|
8
|
-
//#region src/editor/useIframeClickInterceptor.ts
|
|
9
|
-
/**
|
|
10
|
-
* Hook that intercepts clicks in the iframe and sends them to the parent window
|
|
11
|
-
* This allows the parent window to know when the iframe is clicked
|
|
12
|
-
*/
|
|
13
|
-
const useIframeClickInterceptor = require_editor_createSharedComposable.createSharedComposable(() => {
|
|
14
|
-
const postMessage = require_editor_useCrossFrameMessageListener.useCrossFrameMessageListener(_intlayer_editor.MessageKey.INTLAYER_IFRAME_CLICKED);
|
|
15
|
-
const handler = () => {
|
|
16
|
-
postMessage();
|
|
17
|
-
};
|
|
18
|
-
try {
|
|
19
|
-
const destroyRef = (0, _angular_core.inject)(_angular_core.DestroyRef, { optional: true });
|
|
20
|
-
if (destroyRef && typeof window !== "undefined") {
|
|
21
|
-
window.addEventListener("mousedown", handler);
|
|
22
|
-
destroyRef.onDestroy(() => window.removeEventListener("mousedown", handler));
|
|
23
|
-
}
|
|
24
|
-
} catch {
|
|
25
|
-
console.warn("useIframeClickInterceptor called outside injection context; event listener setup may not be available.");
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
/**
|
|
29
|
-
* Hook for the parent window to listen for iframe clicks and merge them
|
|
30
|
-
* This makes iframe clicks behave as if they happened in the parent window
|
|
31
|
-
*/
|
|
32
|
-
const useIframeClickMerger = require_editor_createSharedComposable.createSharedComposable(() => {
|
|
33
|
-
useIframeClickInterceptor();
|
|
34
|
-
require_editor_useCrossFrameMessageListener.useCrossFrameMessageListener(_intlayer_editor.MessageKey.INTLAYER_IFRAME_CLICKED, _intlayer_editor.mergeIframeClick);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
//#endregion
|
|
38
|
-
exports.useIframeClickInterceptor = useIframeClickInterceptor;
|
|
39
|
-
exports.useIframeClickMerger = useIframeClickMerger;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./createSharedComposable.cjs`),t=require(`./useCrossFrameMessageListener.cjs`);let n=require(`@angular/core`),r=require(`@intlayer/editor`);const i=e.createSharedComposable(()=>{let e=t.useCrossFrameMessageListener(r.MessageKey.INTLAYER_IFRAME_CLICKED),i=()=>{e()};try{let e=(0,n.inject)(n.DestroyRef,{optional:!0});e&&typeof window<`u`&&(window.addEventListener(`mousedown`,i),e.onDestroy(()=>window.removeEventListener(`mousedown`,i)))}catch{console.warn(`useIframeClickInterceptor called outside injection context; event listener setup may not be available.`)}}),a=e.createSharedComposable(()=>{i(),t.useCrossFrameMessageListener(r.MessageKey.INTLAYER_IFRAME_CLICKED,r.mergeIframeClick)});exports.useIframeClickInterceptor=i,exports.useIframeClickMerger=a;
|
|
40
2
|
//# sourceMappingURL=useIframeClickInterceptor.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIframeClickInterceptor.cjs","names":["createSharedComposable","useCrossFrameMessageListener","MessageKey","DestroyRef","mergeIframeClick"],"sources":["../../../src/editor/useIframeClickInterceptor.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core';\nimport { MessageKey, mergeIframeClick } from '@intlayer/editor';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameMessageListener } from './useCrossFrameMessageListener';\n\n/* ─────────────────────────────────────────────\n 1. \"Interceptor\" – send a postMessage when\n the editor iframe itself is clicked.\n────────────────────────────────────────────── */\n/**\n * Hook that intercepts clicks in the iframe and sends them to the parent window\n * This allows the parent window to know when the iframe is clicked\n */\nexport const useIframeClickInterceptor = createSharedComposable(() => {\n const postMessage = useCrossFrameMessageListener<undefined>(\n MessageKey.INTLAYER_IFRAME_CLICKED\n );\n\n const handler = () => {\n postMessage();\n };\n\n // Use Angular's DestroyRef for cleanup instead of Vue's lifecycle hooks\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n\n if (destroyRef && typeof window !== 'undefined') {\n // Set up event listener immediately\n window.addEventListener('mousedown', handler);\n\n // Clean up on destroy\n destroyRef.onDestroy(() =>\n window.removeEventListener('mousedown', handler)\n );\n }\n } catch {\n console.warn(\n 'useIframeClickInterceptor called outside injection context; ' +\n 'event listener setup may not be available.'\n );\n }\n});\n\n/**\n * Hook for the parent window to listen for iframe clicks and merge them\n * This makes iframe clicks behave as if they happened in the parent window\n */\nexport const useIframeClickMerger = createSharedComposable(() => {\n useIframeClickInterceptor();\n\n useCrossFrameMessageListener<MessageEvent>(\n MessageKey.INTLAYER_IFRAME_CLICKED,\n mergeIframeClick\n );\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIframeClickInterceptor.cjs","names":["createSharedComposable","useCrossFrameMessageListener","MessageKey","DestroyRef","mergeIframeClick"],"sources":["../../../src/editor/useIframeClickInterceptor.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core';\nimport { MessageKey, mergeIframeClick } from '@intlayer/editor';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameMessageListener } from './useCrossFrameMessageListener';\n\n/* ─────────────────────────────────────────────\n 1. \"Interceptor\" – send a postMessage when\n the editor iframe itself is clicked.\n────────────────────────────────────────────── */\n/**\n * Hook that intercepts clicks in the iframe and sends them to the parent window\n * This allows the parent window to know when the iframe is clicked\n */\nexport const useIframeClickInterceptor = createSharedComposable(() => {\n const postMessage = useCrossFrameMessageListener<undefined>(\n MessageKey.INTLAYER_IFRAME_CLICKED\n );\n\n const handler = () => {\n postMessage();\n };\n\n // Use Angular's DestroyRef for cleanup instead of Vue's lifecycle hooks\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n\n if (destroyRef && typeof window !== 'undefined') {\n // Set up event listener immediately\n window.addEventListener('mousedown', handler);\n\n // Clean up on destroy\n destroyRef.onDestroy(() =>\n window.removeEventListener('mousedown', handler)\n );\n }\n } catch {\n console.warn(\n 'useIframeClickInterceptor called outside injection context; ' +\n 'event listener setup may not be available.'\n );\n }\n});\n\n/**\n * Hook for the parent window to listen for iframe clicks and merge them\n * This makes iframe clicks behave as if they happened in the parent window\n */\nexport const useIframeClickMerger = createSharedComposable(() => {\n useIframeClickInterceptor();\n\n useCrossFrameMessageListener<MessageEvent>(\n MessageKey.INTLAYER_IFRAME_CLICKED,\n mergeIframeClick\n );\n});\n"],"mappings":"6QAaA,MAAa,EAA4BA,EAAAA,2BAA6B,CACpE,IAAM,EAAcC,EAAAA,6BAClBC,EAAAA,WAAW,wBACZ,CAEK,MAAgB,CACpB,GAAa,EAIf,GAAI,CACF,IAAM,GAAA,EAAA,EAAA,QAAoBC,EAAAA,WAAY,CAAE,SAAU,GAAM,CAAC,CAErD,GAAc,OAAO,OAAW,MAElC,OAAO,iBAAiB,YAAa,EAAQ,CAG7C,EAAW,cACT,OAAO,oBAAoB,YAAa,EAAQ,CACjD,OAEG,CACN,QAAQ,KACN,yGAED,GAEH,CAMW,EAAuBH,EAAAA,2BAA6B,CAC/D,GAA2B,CAE3B,EAAA,6BACEE,EAAAA,WAAW,wBACXE,EAAAA,iBACD,EACD"}
|
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_plugins = require('./plugins.cjs');
|
|
4
|
-
let _intlayer_core = require("@intlayer/core");
|
|
5
|
-
|
|
6
|
-
//#region src/getDictionary.ts
|
|
7
|
-
const getDictionary = (dictionary, locale, additionalPlugins) => {
|
|
8
|
-
return (0, _intlayer_core.getDictionary)(dictionary, locale, [
|
|
9
|
-
require_plugins.intlayerNodePlugins,
|
|
10
|
-
require_plugins.markdownPlugin,
|
|
11
|
-
require_plugins.htmlPlugin,
|
|
12
|
-
...additionalPlugins ?? []
|
|
13
|
-
]);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
//#endregion
|
|
17
|
-
exports.getDictionary = getDictionary;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./_virtual/_rolldown/runtime.cjs`);const e=require(`./plugins.cjs`);let t=require(`@intlayer/core/interpreter`);const n=(n,r,i)=>(0,t.getDictionary)(n,r,[e.intlayerNodePlugins,e.markdownPlugin,e.htmlPlugin,...i??[]]);exports.getDictionary=n;
|
|
18
2
|
//# sourceMappingURL=getDictionary.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDictionary.cjs","names":["intlayerNodePlugins","markdownPlugin","htmlPlugin"],"sources":["../../src/getDictionary.ts"],"sourcesContent":["import {\n getDictionary as getDictionaryCore,\n type Plugins,\n} from '@intlayer/core';\nimport type {\n DeclaredLocales,\n Dictionary,\n LocalesValues,\n} from '@intlayer/types';\nimport { htmlPlugin, intlayerNodePlugins, markdownPlugin } from './plugins';\n\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L,\n additionalPlugins?: Plugins[]\n) => {\n const plugins: Plugins[] = [\n intlayerNodePlugins,\n markdownPlugin,\n htmlPlugin,\n ...(additionalPlugins ?? []),\n ];\n\n return getDictionaryCore<T, L>(dictionary, locale, plugins);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getDictionary.cjs","names":["intlayerNodePlugins","markdownPlugin","htmlPlugin"],"sources":["../../src/getDictionary.ts"],"sourcesContent":["import {\n getDictionary as getDictionaryCore,\n type Plugins,\n} from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n Dictionary,\n LocalesValues,\n} from '@intlayer/types';\nimport { htmlPlugin, intlayerNodePlugins, markdownPlugin } from './plugins';\n\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L,\n additionalPlugins?: Plugins[]\n) => {\n const plugins: Plugins[] = [\n intlayerNodePlugins,\n markdownPlugin,\n htmlPlugin,\n ...(additionalPlugins ?? []),\n ];\n\n return getDictionaryCore<T, L>(dictionary, locale, plugins);\n};\n"],"mappings":"4LAWA,MAAa,GAIX,EACA,EACA,KASA,EAAA,EAAA,eAA+B,EAAY,EAPhB,CACzBA,EAAAA,oBACAC,EAAAA,eACAC,EAAAA,WACA,GAAI,GAAqB,EAAE,CAC5B,CAE0D"}
|
package/dist/cjs/getIntlayer.cjs
CHANGED
|
@@ -1,19 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_plugins = require('./plugins.cjs');
|
|
4
|
-
let _intlayer_core = require("@intlayer/core");
|
|
5
|
-
|
|
6
|
-
//#region src/getIntlayer.ts
|
|
7
|
-
const getIntlayer = (key, locale, additionalPlugins) => {
|
|
8
|
-
return (0, _intlayer_core.getIntlayer)(key, locale, [
|
|
9
|
-
require_plugins.intlayerNodePlugins,
|
|
10
|
-
require_plugins.markdownPlugin,
|
|
11
|
-
require_plugins.htmlPlugin,
|
|
12
|
-
require_plugins.insertionPlugin,
|
|
13
|
-
...additionalPlugins ?? []
|
|
14
|
-
]);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
//#endregion
|
|
18
|
-
exports.getIntlayer = getIntlayer;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./_virtual/_rolldown/runtime.cjs`);const e=require(`./plugins.cjs`);let t=require(`@intlayer/core/interpreter`);const n=(n,r,i)=>(0,t.getIntlayer)(n,r,[e.intlayerNodePlugins,e.markdownPlugin,e.htmlPlugin,e.insertionPlugin,...i??[]]);exports.getIntlayer=n;
|
|
19
2
|
//# sourceMappingURL=getIntlayer.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIntlayer.cjs","names":["intlayerNodePlugins","markdownPlugin","htmlPlugin","insertionPlugin"],"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"getIntlayer.cjs","names":["intlayerNodePlugins","markdownPlugin","htmlPlugin","insertionPlugin"],"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import {\n getIntlayer as getIntlayerCore,\n type Plugins,\n} from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types';\nimport {\n type DeepTransformContent,\n htmlPlugin,\n insertionPlugin,\n intlayerNodePlugins,\n markdownPlugin,\n} from './plugins';\n\nexport const getIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L,\n additionalPlugins?: Plugins[]\n) => {\n const plugins: Plugins[] = [\n intlayerNodePlugins,\n markdownPlugin,\n htmlPlugin,\n insertionPlugin,\n ...(additionalPlugins ?? []),\n ];\n\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n return getIntlayerCore<T, L>(key, locale, plugins) as DeepTransformContent<\n DictionaryRegistryContent<T>\n >;\n};\n"],"mappings":"4LAkBA,MAAa,GAIX,EACA,EACA,KAWA,EAAA,EAAA,aAA6B,EAAK,EATP,CACzBA,EAAAA,oBACAC,EAAAA,eACAC,EAAAA,WACAC,EAAAA,gBACA,GAAI,GAAqB,EAAE,CAC5B,CAGiD"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,49 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_client_installIntlayer = require('./client/installIntlayer.cjs');
|
|
3
|
-
const require_client_useDictionary = require('./client/useDictionary.cjs');
|
|
4
|
-
const require_client_useDictionaryAsync = require('./client/useDictionaryAsync.cjs');
|
|
5
|
-
const require_client_useLoadDynamic = require('./client/useLoadDynamic.cjs');
|
|
6
|
-
const require_client_useDictionaryDynamic = require('./client/useDictionaryDynamic.cjs');
|
|
7
|
-
const require_client_useIntl = require('./client/useIntl.cjs');
|
|
8
|
-
const require_getIntlayer = require('./getIntlayer.cjs');
|
|
9
|
-
const require_client_useIntlayer = require('./client/useIntlayer.cjs');
|
|
10
|
-
const require_client_useLocale = require('./client/useLocale.cjs');
|
|
11
|
-
const require_markdown_installIntlayerMarkdown = require('./markdown/installIntlayerMarkdown.cjs');
|
|
12
|
-
const require_plugins = require('./plugins.cjs');
|
|
13
|
-
const require_getDictionary = require('./getDictionary.cjs');
|
|
14
|
-
|
|
15
|
-
exports.INTLAYER_MARKDOWN_TOKEN = require_markdown_installIntlayerMarkdown.INTLAYER_MARKDOWN_TOKEN;
|
|
16
|
-
exports.INTLAYER_TOKEN = require_client_installIntlayer.INTLAYER_TOKEN;
|
|
17
|
-
Object.defineProperty(exports, 'IntlayerMarkdownService', {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () {
|
|
20
|
-
return require_markdown_installIntlayerMarkdown.IntlayerMarkdownService;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
Object.defineProperty(exports, 'IntlayerProvider', {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
get: function () {
|
|
26
|
-
return require_client_installIntlayer.IntlayerProvider;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
exports.createIntlayerClient = require_client_installIntlayer.createIntlayerClient;
|
|
30
|
-
exports.createIntlayerMarkdownProvider = require_markdown_installIntlayerMarkdown.createIntlayerMarkdownProvider;
|
|
31
|
-
exports.getDictionary = require_getDictionary.getDictionary;
|
|
32
|
-
exports.getIntlayer = require_getIntlayer.getIntlayer;
|
|
33
|
-
exports.htmlPlugin = require_plugins.htmlPlugin;
|
|
34
|
-
exports.htmlRuntime = require_markdown_installIntlayerMarkdown.htmlRuntime;
|
|
35
|
-
exports.insertionPlugin = require_plugins.insertionPlugin;
|
|
36
|
-
exports.installIntlayer = require_client_installIntlayer.installIntlayer;
|
|
37
|
-
exports.intlayerNodePlugins = require_plugins.intlayerNodePlugins;
|
|
38
|
-
exports.isUpdatableNode = require_client_useIntlayer.isUpdatableNode;
|
|
39
|
-
exports.markdownPlugin = require_plugins.markdownPlugin;
|
|
40
|
-
exports.markdownStringPlugin = require_plugins.markdownStringPlugin;
|
|
41
|
-
exports.provideIntlayer = require_client_installIntlayer.provideIntlayer;
|
|
42
|
-
exports.useDictionary = require_client_useDictionary.useDictionary;
|
|
43
|
-
exports.useDictionaryAsync = require_client_useDictionaryAsync.useDictionaryAsync;
|
|
44
|
-
exports.useDictionaryDynamic = require_client_useDictionaryDynamic.useDictionaryDynamic;
|
|
45
|
-
exports.useIntl = require_client_useIntl.useIntl;
|
|
46
|
-
exports.useIntlayer = require_client_useIntlayer.useIntlayer;
|
|
47
|
-
exports.useLoadDynamic = require_client_useLoadDynamic.useLoadDynamic;
|
|
48
|
-
exports.useLocale = require_client_useLocale.useLocale;
|
|
49
|
-
exports.useMarkdown = require_markdown_installIntlayerMarkdown.useMarkdown;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./client/installIntlayer.cjs`),t=require(`./client/useDictionary.cjs`),n=require(`./client/useDictionaryAsync.cjs`),r=require(`./client/useLoadDynamic.cjs`),i=require(`./client/useDictionaryDynamic.cjs`),a=require(`./client/useIntl.cjs`),o=require(`./getIntlayer.cjs`),s=require(`./client/useIntlayer.cjs`),c=require(`./client/useLocale.cjs`),l=require(`./markdown/installIntlayerMarkdown.cjs`),u=require(`./plugins.cjs`),d=require(`./getDictionary.cjs`);exports.INTLAYER_MARKDOWN_TOKEN=l.INTLAYER_MARKDOWN_TOKEN,exports.INTLAYER_TOKEN=e.INTLAYER_TOKEN,Object.defineProperty(exports,`IntlayerMarkdownService`,{enumerable:!0,get:function(){return l.IntlayerMarkdownService}}),Object.defineProperty(exports,`IntlayerProvider`,{enumerable:!0,get:function(){return e.IntlayerProvider}}),exports.createIntlayerClient=e.createIntlayerClient,exports.createIntlayerMarkdownProvider=l.createIntlayerMarkdownProvider,exports.getDictionary=d.getDictionary,exports.getIntlayer=o.getIntlayer,exports.htmlPlugin=u.htmlPlugin,exports.htmlRuntime=l.htmlRuntime,exports.insertionPlugin=u.insertionPlugin,exports.installIntlayer=e.installIntlayer,exports.intlayerNodePlugins=u.intlayerNodePlugins,exports.isUpdatableNode=s.isUpdatableNode,exports.markdownPlugin=u.markdownPlugin,exports.markdownStringPlugin=u.markdownStringPlugin,exports.provideIntlayer=e.provideIntlayer,exports.useDictionary=t.useDictionary,exports.useDictionaryAsync=n.useDictionaryAsync,exports.useDictionaryDynamic=i.useDictionaryDynamic,exports.useIntl=a.useIntl,exports.useIntlayer=s.useIntlayer,exports.useLoadDynamic=r.useLoadDynamic,exports.useLocale=c.useLocale,exports.useMarkdown=l.useMarkdown;
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_markdown_installIntlayerMarkdown = require('./installIntlayerMarkdown.cjs');
|
|
3
|
-
|
|
4
|
-
exports.INTLAYER_MARKDOWN_TOKEN = require_markdown_installIntlayerMarkdown.INTLAYER_MARKDOWN_TOKEN;
|
|
5
|
-
Object.defineProperty(exports, 'IntlayerMarkdownService', {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function () {
|
|
8
|
-
return require_markdown_installIntlayerMarkdown.IntlayerMarkdownService;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
exports.createIntlayerMarkdownProvider = require_markdown_installIntlayerMarkdown.createIntlayerMarkdownProvider;
|
|
12
|
-
exports.htmlRuntime = require_markdown_installIntlayerMarkdown.htmlRuntime;
|
|
13
|
-
exports.useMarkdown = require_markdown_installIntlayerMarkdown.useMarkdown;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./installIntlayerMarkdown.cjs`);exports.INTLAYER_MARKDOWN_TOKEN=e.INTLAYER_MARKDOWN_TOKEN,Object.defineProperty(exports,`IntlayerMarkdownService`,{enumerable:!0,get:function(){return e.IntlayerMarkdownService}}),exports.createIntlayerMarkdownProvider=e.createIntlayerMarkdownProvider,exports.htmlRuntime=e.htmlRuntime,exports.useMarkdown=e.useMarkdown;
|
|
@@ -1,80 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_decorate = require('../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.cjs');
|
|
4
|
-
let _intlayer_core = require("@intlayer/core");
|
|
5
|
-
let _angular_core = require("@angular/core");
|
|
6
|
-
|
|
7
|
-
//#region src/markdown/installIntlayerMarkdown.ts
|
|
8
|
-
const INTLAYER_MARKDOWN_TOKEN = new _angular_core.InjectionToken("intlayerMarkdown");
|
|
9
|
-
const htmlRuntime = {
|
|
10
|
-
createElement: (tag, props, ...children) => {
|
|
11
|
-
if (typeof tag !== "string") {
|
|
12
|
-
if (tag === htmlRuntime.Fragment) return children.join("");
|
|
13
|
-
return "";
|
|
14
|
-
}
|
|
15
|
-
const attrs = props ? Object.entries(props).map(([k, v]) => {
|
|
16
|
-
if (k === "key" || v === void 0 || v === null) return "";
|
|
17
|
-
return `${k === "className" ? "class" : k}="${String(v).replace(/"/g, """)}"`;
|
|
18
|
-
}).filter(Boolean).join(" ") : "";
|
|
19
|
-
const childrenStr = children.join("");
|
|
20
|
-
if ([
|
|
21
|
-
"area",
|
|
22
|
-
"base",
|
|
23
|
-
"br",
|
|
24
|
-
"col",
|
|
25
|
-
"embed",
|
|
26
|
-
"hr",
|
|
27
|
-
"img",
|
|
28
|
-
"input",
|
|
29
|
-
"link",
|
|
30
|
-
"meta",
|
|
31
|
-
"param",
|
|
32
|
-
"source",
|
|
33
|
-
"track",
|
|
34
|
-
"wbr"
|
|
35
|
-
].includes(tag)) return `<${tag} ${attrs} />`;
|
|
36
|
-
return `<${tag}${attrs ? ` ${attrs}` : ""}>${childrenStr}</${tag}>`;
|
|
37
|
-
},
|
|
38
|
-
cloneElement: (element, _props) => element,
|
|
39
|
-
Fragment: Symbol("Fragment")
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Default markdown renderer that converts markdown to HTML string
|
|
43
|
-
*/
|
|
44
|
-
const defaultMarkdownRenderer = (markdown) => (0, _intlayer_core.compile)(markdown, { runtime: htmlRuntime });
|
|
45
|
-
/**
|
|
46
|
-
* Create IntlayerMarkdown provider configuration
|
|
47
|
-
*/
|
|
48
|
-
const createIntlayerMarkdownProvider = (renderMarkdown = defaultMarkdownRenderer) => ({
|
|
49
|
-
provide: INTLAYER_MARKDOWN_TOKEN,
|
|
50
|
-
useValue: { renderMarkdown }
|
|
51
|
-
});
|
|
52
|
-
let IntlayerMarkdownService = class IntlayerMarkdownService {
|
|
53
|
-
markdownProvider = (0, _angular_core.inject)(INTLAYER_MARKDOWN_TOKEN, { optional: true });
|
|
54
|
-
renderMarkdown(markdown, overrides) {
|
|
55
|
-
if (!this.markdownProvider) return markdown;
|
|
56
|
-
return this.markdownProvider.renderMarkdown(markdown, overrides);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
IntlayerMarkdownService = require_decorate.__decorate([(0, _angular_core.Injectable)({ providedIn: "root" })], IntlayerMarkdownService);
|
|
60
|
-
/**
|
|
61
|
-
* Function to inject markdown provider
|
|
62
|
-
*/
|
|
63
|
-
const useMarkdown = () => {
|
|
64
|
-
const markdownProvider = (0, _angular_core.inject)(INTLAYER_MARKDOWN_TOKEN, { optional: true });
|
|
65
|
-
if (!markdownProvider) return { renderMarkdown: defaultMarkdownRenderer };
|
|
66
|
-
return markdownProvider;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
//#endregion
|
|
70
|
-
exports.INTLAYER_MARKDOWN_TOKEN = INTLAYER_MARKDOWN_TOKEN;
|
|
71
|
-
Object.defineProperty(exports, 'IntlayerMarkdownService', {
|
|
72
|
-
enumerable: true,
|
|
73
|
-
get: function () {
|
|
74
|
-
return IntlayerMarkdownService;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
exports.createIntlayerMarkdownProvider = createIntlayerMarkdownProvider;
|
|
78
|
-
exports.htmlRuntime = htmlRuntime;
|
|
79
|
-
exports.useMarkdown = useMarkdown;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.cjs`);let t=require(`@intlayer/core/markdown`),n=require(`@angular/core`);const r=new n.InjectionToken(`intlayerMarkdown`),i={createElement:(e,t,...n)=>{if(typeof e!=`string`)return e===i.Fragment?n.join(``):``;let r=t?Object.entries(t).map(([e,t])=>e===`key`||t==null?``:`${e===`className`?`class`:e}="${String(t).replace(/"/g,`"`)}"`).filter(Boolean).join(` `):``,a=n.join(``);return[`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`].includes(e)?`<${e} ${r} />`:`<${e}${r?` ${r}`:``}>${a}</${e}>`},cloneElement:(e,t)=>e,Fragment:Symbol(`Fragment`)},a=e=>(0,t.compile)(e,{runtime:i}),o=(e=a)=>({provide:r,useValue:{renderMarkdown:e}});let s=class{markdownProvider=(0,n.inject)(r,{optional:!0});renderMarkdown(e,t){return this.markdownProvider?this.markdownProvider.renderMarkdown(e,t):e}};s=e.__decorate([(0,n.Injectable)({providedIn:`root`})],s);const c=()=>(0,n.inject)(r,{optional:!0})||{renderMarkdown:a};exports.INTLAYER_MARKDOWN_TOKEN=r,Object.defineProperty(exports,`IntlayerMarkdownService`,{enumerable:!0,get:function(){return s}}),exports.createIntlayerMarkdownProvider=o,exports.htmlRuntime=i,exports.useMarkdown=c;
|
|
80
2
|
//# sourceMappingURL=installIntlayerMarkdown.cjs.map
|