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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLoadDynamic.cjs","names":[],"sources":["../../../src/client/useLoadDynamic.ts"],"sourcesContent":["import { signal } from '@angular/core';\n\n/**\n * A \"synchronous\" loader for a dynamically‐imported JSON (or anything).\n *\n * - Immediately returns a reactive signal so that Angular can properly track changes.\n * - When the Promise resolves, it replaces the signal's value with the real data.\n */\nexport const useLoadDynamic = <T extends Record<string, any>>(\n key: string,\n promise: Promise<T>\n): T => {\n // A module‐level cache of Promises, so we only import once per key.\n const cache: Map<string, Promise<T>> = (useLoadDynamic as any)._cache ||\n ((useLoadDynamic as any)._cache = new Map());\n\n // Hold the \"current\" value as a reactive signal\n // This starts as an empty object but Angular can track changes to it\n const container = signal({} as T);\n\n if (!cache.has(key)) {\n // Kick off the dynamic import & cache it\n const p = promise.then((real) => {\n // As soon as the import resolves, update the signal with the real data\n container.set(real);\n return real;\n });\n cache.set(key, p);\n } else {\n // If it's already in flight (or done), hook into it so that the container still updates\n cache.get(key)?.then((real) => {\n container.set(real);\n });\n }\n\n // Return the current signal value directly - Angular can track all changes to it\n return container();\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLoadDynamic.cjs","names":[],"sources":["../../../src/client/useLoadDynamic.ts"],"sourcesContent":["import { signal } from '@angular/core';\n\n/**\n * A \"synchronous\" loader for a dynamically‐imported JSON (or anything).\n *\n * - Immediately returns a reactive signal so that Angular can properly track changes.\n * - When the Promise resolves, it replaces the signal's value with the real data.\n */\nexport const useLoadDynamic = <T extends Record<string, any>>(\n key: string,\n promise: Promise<T>\n): T => {\n // A module‐level cache of Promises, so we only import once per key.\n const cache: Map<string, Promise<T>> = (useLoadDynamic as any)._cache ||\n ((useLoadDynamic as any)._cache = new Map());\n\n // Hold the \"current\" value as a reactive signal\n // This starts as an empty object but Angular can track changes to it\n const container = signal({} as T);\n\n if (!cache.has(key)) {\n // Kick off the dynamic import & cache it\n const p = promise.then((real) => {\n // As soon as the import resolves, update the signal with the real data\n container.set(real);\n return real;\n });\n cache.set(key, p);\n } else {\n // If it's already in flight (or done), hook into it so that the container still updates\n cache.get(key)?.then((real) => {\n container.set(real);\n });\n }\n\n // Return the current signal value directly - Angular can track all changes to it\n return container();\n};\n"],"mappings":"+IAQA,MAAa,GACX,EACA,IACM,CAEN,IAAM,EAAkC,AACvC,EAAwB,SAAS,IAAI,IAIhC,GAAA,EAAA,EAAA,QAAmB,EAAE,CAAM,CAEjC,GAAK,EAAM,IAAI,EAAI,CAUjB,EAAM,IAAI,EAAI,EAAE,KAAM,GAAS,CAC7B,EAAU,IAAI,EAAK,EACnB,KAZiB,CAEnB,IAAM,EAAI,EAAQ,KAAM,IAEtB,EAAU,IAAI,EAAK,CACZ,GACP,CACF,EAAM,IAAI,EAAK,EAAE,CASnB,OAAO,GAAW"}
|
|
@@ -1,61 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_client_installIntlayer = require('./installIntlayer.cjs');
|
|
4
|
-
const require_client_useLocaleStorage = require('./useLocaleStorage.cjs');
|
|
5
|
-
let _angular_core = require("@angular/core");
|
|
6
|
-
let _intlayer_config_built = require("@intlayer/config/built");
|
|
7
|
-
_intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
|
|
8
|
-
|
|
9
|
-
//#region src/client/useLocale.ts
|
|
10
|
-
/**
|
|
11
|
-
* Angular hook to manage the current locale and related functions.
|
|
12
|
-
*
|
|
13
|
-
* @param props - Optional configuration for locale management.
|
|
14
|
-
* @returns An object containing the current locale (signal), default locale, available locales, and a function to update the locale.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```ts
|
|
18
|
-
* import { Component } from '@angular/core';
|
|
19
|
-
* import { useLocale } from 'angular-intlayer';
|
|
20
|
-
*
|
|
21
|
-
* @Component({
|
|
22
|
-
* standalone: true,
|
|
23
|
-
* selector: 'app-locale-switcher',
|
|
24
|
-
* template: `
|
|
25
|
-
* <select [value]="locale()" (change)="setLocale($any($event.target).value)">
|
|
26
|
-
* @for (loc of availableLocales; track loc) {
|
|
27
|
-
* <option [value]="loc">{{ loc }}</option>
|
|
28
|
-
* }
|
|
29
|
-
* </select>
|
|
30
|
-
* `,
|
|
31
|
-
* })
|
|
32
|
-
* export class LocaleSwitcher {
|
|
33
|
-
* const { locale, setLocale, availableLocales } = useLocale();
|
|
34
|
-
* }
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
const useLocale = ({ isCookieEnabled, onLocaleChange } = {}) => {
|
|
38
|
-
const { defaultLocale, locales: availableLocales } = _intlayer_config_built.default?.internationalization ?? {};
|
|
39
|
-
const intlayer = (0, _angular_core.inject)(require_client_installIntlayer.INTLAYER_TOKEN);
|
|
40
|
-
const locale = (0, _angular_core.computed)(() => intlayer?.locale() ?? defaultLocale);
|
|
41
|
-
const isCookieEnabledContext = (0, _angular_core.computed)(() => intlayer?.isCookieEnabled() ?? true);
|
|
42
|
-
const setLocale = (newLocale) => {
|
|
43
|
-
if (!availableLocales?.map(String).includes(newLocale)) {
|
|
44
|
-
console.error(`Locale ${newLocale} is not available`);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
if (intlayer) intlayer.setLocale(newLocale);
|
|
48
|
-
require_client_useLocaleStorage.setLocaleInStorage(newLocale, isCookieEnabled ?? isCookieEnabledContext() ?? true);
|
|
49
|
-
onLocaleChange?.(newLocale);
|
|
50
|
-
};
|
|
51
|
-
return {
|
|
52
|
-
locale,
|
|
53
|
-
defaultLocale,
|
|
54
|
-
availableLocales,
|
|
55
|
-
setLocale
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
//#endregion
|
|
60
|
-
exports.useLocale = useLocale;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`./installIntlayer.cjs`),n=require(`./useLocaleStorage.cjs`);let r=require(`@angular/core`),i=require(`@intlayer/config/built`);i=e.__toESM(i);const a=({isCookieEnabled:e,onLocaleChange:a}={})=>{let{defaultLocale:o,locales:s}=i.default?.internationalization??{},c=(0,r.inject)(t.INTLAYER_TOKEN),l=(0,r.computed)(()=>c?.locale()??o),u=(0,r.computed)(()=>c?.isCookieEnabled()??!0);return{locale:l,defaultLocale:o,availableLocales:s,setLocale:t=>{if(!s?.map(String).includes(t)){console.error(`Locale ${t} is not available`);return}c&&c.setLocale(t),n.setLocaleInStorage(t,e??u()??!0),a?.(t)}}};exports.useLocale=a;
|
|
61
2
|
//# sourceMappingURL=useLocale.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.cjs","names":["configuration","INTLAYER_TOKEN"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype useLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\n/**\n * Angular hook to manage the current locale and related functions.\n *\n * @param props - Optional configuration for locale management.\n * @returns An object containing the current locale (signal), default locale, available locales, and a function to update the locale.\n *\n * @example\n * ```ts\n * import { Component } from '@angular/core';\n * import { useLocale } from 'angular-intlayer';\n *\n * @Component({\n * standalone: true,\n * selector: 'app-locale-switcher',\n * template: `\n * <select [value]=\"locale()\" (change)=\"setLocale($any($event.target).value)\">\n * @for (loc of availableLocales; track loc) {\n * <option [value]=\"loc\">{{ loc }}</option>\n * }\n * </select>\n * `,\n * })\n * export class LocaleSwitcher {\n * const { locale, setLocale, availableLocales } = useLocale();\n * }\n * ```\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: useLocaleProps = {}) => {\n const { defaultLocale, locales: availableLocales } =\n configuration?.internationalization ?? {};\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n // Create a reactive reference for the locale\n const locale = computed(() => intlayer?.locale() ?? defaultLocale);\n const isCookieEnabledContext = computed(\n () => intlayer?.isCookieEnabled() ?? true\n );\n\n const setLocale = (newLocale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n if (intlayer) {\n intlayer.setLocale(newLocale);\n }\n setLocaleInStorage(\n newLocale,\n isCookieEnabled ?? isCookieEnabledContext() ?? true\n );\n onLocaleChange?.(newLocale);\n };\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocale.cjs","names":["configuration","INTLAYER_TOKEN"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype useLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\n/**\n * Angular hook to manage the current locale and related functions.\n *\n * @param props - Optional configuration for locale management.\n * @returns An object containing the current locale (signal), default locale, available locales, and a function to update the locale.\n *\n * @example\n * ```ts\n * import { Component } from '@angular/core';\n * import { useLocale } from 'angular-intlayer';\n *\n * @Component({\n * standalone: true,\n * selector: 'app-locale-switcher',\n * template: `\n * <select [value]=\"locale()\" (change)=\"setLocale($any($event.target).value)\">\n * @for (loc of availableLocales; track loc) {\n * <option [value]=\"loc\">{{ loc }}</option>\n * }\n * </select>\n * `,\n * })\n * export class LocaleSwitcher {\n * const { locale, setLocale, availableLocales } = useLocale();\n * }\n * ```\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: useLocaleProps = {}) => {\n const { defaultLocale, locales: availableLocales } =\n configuration?.internationalization ?? {};\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n // Create a reactive reference for the locale\n const locale = computed(() => intlayer?.locale() ?? defaultLocale);\n const isCookieEnabledContext = computed(\n () => intlayer?.isCookieEnabled() ?? true\n );\n\n const setLocale = (newLocale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n if (intlayer) {\n intlayer.setLocale(newLocale);\n }\n setLocaleInStorage(\n newLocale,\n isCookieEnabled ?? isCookieEnabledContext() ?? true\n );\n onLocaleChange?.(newLocale);\n };\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":"iRAsCA,MAAa,GAAa,CACxB,kBACA,kBACkB,EAAE,GAAK,CACzB,GAAM,CAAE,gBAAe,QAAS,GAC9BA,EAAAA,SAAe,sBAAwB,EAAE,CACrC,GAAA,EAAA,EAAA,QAAoCC,EAAAA,eAAe,CAGnD,GAAA,EAAA,EAAA,cAAwB,GAAU,QAAQ,EAAI,EAAc,CAC5D,GAAA,EAAA,EAAA,cACE,GAAU,iBAAiB,EAAI,GACtC,CAkBD,MAAO,CACL,SACA,gBACA,mBACA,UApBiB,GAA6B,CAC9C,GAAI,CAAC,GAAkB,IAAI,OAAO,CAAC,SAAS,EAAU,CAAE,CACtD,QAAQ,MAAM,UAAU,EAAU,mBAAmB,CACrD,OAGE,GACF,EAAS,UAAU,EAAU,CAE/B,EAAA,mBACE,EACA,GAAmB,GAAwB,EAAI,GAChD,CACD,IAAiB,EAAU,EAQ5B"}
|
|
@@ -1,61 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let _intlayer_core = require("@intlayer/core");
|
|
4
|
-
|
|
5
|
-
//#region src/client/useLocaleStorage.ts
|
|
6
|
-
/**
|
|
7
|
-
* Get the locale cookie
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Get the locale cookie
|
|
11
|
-
*/
|
|
12
|
-
const localeInStorage = (0, _intlayer_core.getLocaleFromStorage)(_intlayer_core.localeStorageOptions);
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated Use localeInStorage instead
|
|
15
|
-
*
|
|
16
|
-
* Get the locale cookie
|
|
17
|
-
*/
|
|
18
|
-
const localeCookie = localeInStorage;
|
|
19
|
-
/**
|
|
20
|
-
* Set the locale cookie
|
|
21
|
-
*/
|
|
22
|
-
const setLocaleInStorage = (locale, isCookieEnabled) => (0, _intlayer_core.setLocaleInStorage)(locale, {
|
|
23
|
-
..._intlayer_core.localeStorageOptions,
|
|
24
|
-
isCookieEnabled
|
|
25
|
-
});
|
|
26
|
-
/**
|
|
27
|
-
* @deprecated Use setLocaleInStorage instead
|
|
28
|
-
*
|
|
29
|
-
* Set the locale cookie
|
|
30
|
-
*/
|
|
31
|
-
const setLocaleCookie = setLocaleInStorage;
|
|
32
|
-
/**
|
|
33
|
-
* Hook that provides the locale storage and a function to set it
|
|
34
|
-
*/
|
|
35
|
-
const useLocaleStorage = (isCookieEnabled) => (0, _intlayer_core.LocaleStorage)({
|
|
36
|
-
..._intlayer_core.localeStorageOptions,
|
|
37
|
-
isCookieEnabled
|
|
38
|
-
});
|
|
39
|
-
/**
|
|
40
|
-
* @deprecated Use useLocaleStorage instead
|
|
41
|
-
*
|
|
42
|
-
* For GDPR compliance, use useLocaleStorage instead
|
|
43
|
-
*
|
|
44
|
-
* Hook that provides the locale cookie and a function to set it
|
|
45
|
-
*/
|
|
46
|
-
const useLocaleCookie = (isCookieEnabled) => {
|
|
47
|
-
const storage = useLocaleStorage(isCookieEnabled);
|
|
48
|
-
return {
|
|
49
|
-
localeCookie: storage.getLocale(),
|
|
50
|
-
setLocaleCookie: storage.setLocale
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
//#endregion
|
|
55
|
-
exports.localeCookie = localeCookie;
|
|
56
|
-
exports.localeInStorage = localeInStorage;
|
|
57
|
-
exports.setLocaleCookie = setLocaleCookie;
|
|
58
|
-
exports.setLocaleInStorage = setLocaleInStorage;
|
|
59
|
-
exports.useLocaleCookie = useLocaleCookie;
|
|
60
|
-
exports.useLocaleStorage = useLocaleStorage;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/core/utils`),t=require(`@intlayer/core/localization`);const n=(0,e.getLocaleFromStorage)(t.localeStorageOptions),r=n,i=(n,r)=>(0,e.setLocaleInStorage)(n,{...t.localeStorageOptions,isCookieEnabled:r}),a=i,o=n=>(0,e.LocaleStorage)({...t.localeStorageOptions,isCookieEnabled:n}),s=e=>{let t=o(e);return{localeCookie:t.getLocale(),setLocaleCookie:t.setLocale}};exports.localeCookie=r,exports.localeInStorage=n,exports.setLocaleCookie=a,exports.setLocaleInStorage=i,exports.useLocaleCookie=s,exports.useLocaleStorage=o;
|
|
61
2
|
//# sourceMappingURL=useLocaleStorage.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocaleStorage.cjs","names":["localeStorageOptions"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import {\n getLocaleFromStorage,\n LocaleStorage,\n
|
|
1
|
+
{"version":3,"file":"useLocaleStorage.cjs","names":["localeStorageOptions"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import { localeStorageOptions } from '@intlayer/core/localization';\nimport {\n getLocaleFromStorage,\n LocaleStorage,\n setLocaleInStorage as setLocaleInStorageCore,\n} from '@intlayer/core/utils';\nimport type { LocalesValues } from '@intlayer/types';\n\n/**\n * Get the locale cookie\n */\n/**\n * Get the locale cookie\n */\nexport const localeInStorage = getLocaleFromStorage(localeStorageOptions);\n/**\n * @deprecated Use localeInStorage instead\n *\n * Get the locale cookie\n */\nexport const localeCookie = localeInStorage;\n\n/**\n * Set the locale cookie\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n isCookieEnabled: boolean\n) =>\n setLocaleInStorageCore(locale, {\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n/**\n * @deprecated Use setLocaleInStorage instead\n *\n * Set the locale cookie\n */\nexport const setLocaleCookie = setLocaleInStorage;\n\n/**\n * Hook that provides the locale storage and a function to set it\n */\nexport const useLocaleStorage = (isCookieEnabled?: boolean) =>\n LocaleStorage({\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n/**\n * @deprecated Use useLocaleStorage instead\n *\n * For GDPR compliance, use useLocaleStorage instead\n *\n * Hook that provides the locale cookie and a function to set it\n */\nexport const useLocaleCookie = (isCookieEnabled?: boolean) => {\n const storage = useLocaleStorage(isCookieEnabled);\n\n return {\n localeCookie: storage.getLocale(),\n setLocaleCookie: storage.setLocale,\n };\n};\n"],"mappings":"+LAcA,MAAa,GAAA,EAAA,EAAA,sBAAuCA,EAAAA,qBAAqB,CAM5D,EAAe,EAKf,GACX,EACA,KAAA,EAAA,EAAA,oBAEuB,EAAQ,CAC7B,GAAGA,EAAAA,qBACH,kBACD,CAAC,CAOS,EAAkB,EAKlB,EAAoB,IAAA,EAAA,EAAA,eACjB,CACZ,GAAGA,EAAAA,qBACH,kBACD,CAAC,CASS,EAAmB,GAA8B,CAC5D,IAAM,EAAU,EAAiB,EAAgB,CAEjD,MAAO,CACL,aAAc,EAAQ,WAAW,CACjC,gBAAiB,EAAQ,UAC1B"}
|
|
@@ -1,44 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_decorateMetadata = require('../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.cjs');
|
|
4
|
-
const require_decorate = require('../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.cjs');
|
|
5
|
-
const require_UI_ContentSelector_component = require('../UI/ContentSelector.component.cjs');
|
|
6
|
-
const require_editor_editorEnabled = require('./editorEnabled.cjs');
|
|
7
|
-
const require_editor_focusDictionary = require('./focusDictionary.cjs');
|
|
8
|
-
const require_editor_useEditor = require('./useEditor.cjs');
|
|
9
|
-
let _intlayer_core = require("@intlayer/core");
|
|
10
|
-
let _intlayer_types = require("@intlayer/types");
|
|
11
|
-
let _angular_common = require("@angular/common");
|
|
12
|
-
let _angular_core = require("@angular/core");
|
|
13
|
-
|
|
14
|
-
//#region src/editor/ContentSelectorWrapper.component.ts
|
|
15
|
-
let ContentSelectorWrapperComponent = class ContentSelectorWrapperComponent {
|
|
16
|
-
dictionaryKey;
|
|
17
|
-
keyPath;
|
|
18
|
-
focusDictionary = require_editor_focusDictionary.useFocusDictionary();
|
|
19
|
-
editorEnabled = require_editor_editorEnabled.useEditorEnabled();
|
|
20
|
-
constructor() {
|
|
21
|
-
require_editor_useEditor.useEditor();
|
|
22
|
-
}
|
|
23
|
-
isSelected = (0, _angular_core.computed)(() => {
|
|
24
|
-
const focusedContent = this.focusDictionary.focusedContent();
|
|
25
|
-
return focusedContent?.dictionaryKey === this.dictionaryKey && (focusedContent.keyPath?.length ?? 0) > 0 && (0, _intlayer_core.isSameKeyPath)(focusedContent.keyPath ?? [], this.keyPath);
|
|
26
|
-
});
|
|
27
|
-
enabled = (0, _angular_core.computed)(() => this.editorEnabled.enabled());
|
|
28
|
-
handleSelect() {
|
|
29
|
-
this.focusDictionary.setFocusedContent({
|
|
30
|
-
dictionaryKey: this.dictionaryKey,
|
|
31
|
-
keyPath: this.keyPath.filter((key) => key.type !== _intlayer_types.NodeType.Translation)
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
require_decorate.__decorate([(0, _angular_core.Input)(), require_decorateMetadata.__decorateMetadata("design:type", String)], ContentSelectorWrapperComponent.prototype, "dictionaryKey", void 0);
|
|
36
|
-
require_decorate.__decorate([(0, _angular_core.Input)(), require_decorateMetadata.__decorateMetadata("design:type", Array)], ContentSelectorWrapperComponent.prototype, "keyPath", void 0);
|
|
37
|
-
ContentSelectorWrapperComponent = require_decorate.__decorate([(0, _angular_core.Component)({
|
|
38
|
-
selector: "app-content-selector-wrapper",
|
|
39
|
-
standalone: true,
|
|
40
|
-
imports: [_angular_common.CommonModule, require_UI_ContentSelector_component.ContentSelectorComponent],
|
|
41
|
-
template: `
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.cjs`),t=require(`../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.cjs`),n=require(`../UI/ContentSelector.component.cjs`),r=require(`./editorEnabled.cjs`),i=require(`./focusDictionary.cjs`),a=require(`./useEditor.cjs`);let o=require(`@intlayer/types`),s=require(`@angular/common`),c=require(`@angular/core`),l=require(`@intlayer/core/utils`),u=class{dictionaryKey;keyPath;focusDictionary=i.useFocusDictionary();editorEnabled=r.useEditorEnabled();constructor(){a.useEditor()}isSelected=(0,c.computed)(()=>{let e=this.focusDictionary.focusedContent();return e?.dictionaryKey===this.dictionaryKey&&(e.keyPath?.length??0)>0&&(0,l.isSameKeyPath)(e.keyPath??[],this.keyPath)});enabled=(0,c.computed)(()=>this.editorEnabled.enabled());handleSelect(){this.focusDictionary.setFocusedContent({dictionaryKey:this.dictionaryKey,keyPath:this.keyPath.filter(e=>e.type!==o.NodeType.Translation)})}};t.__decorate([(0,c.Input)(),e.__decorateMetadata(`design:type`,String)],u.prototype,`dictionaryKey`,void 0),t.__decorate([(0,c.Input)(),e.__decorateMetadata(`design:type`,Array)],u.prototype,`keyPath`,void 0),u=t.__decorate([(0,c.Component)({selector:`app-content-selector-wrapper`,standalone:!0,imports:[s.CommonModule,n.ContentSelectorComponent],template:`
|
|
42
2
|
<app-content-selector
|
|
43
3
|
*ngIf="enabled()"
|
|
44
4
|
(press)="handleSelect()"
|
|
@@ -47,14 +7,5 @@ ContentSelectorWrapperComponent = require_decorate.__decorate([(0, _angular_core
|
|
|
47
7
|
<ng-content></ng-content>
|
|
48
8
|
</app-content-selector>
|
|
49
9
|
<ng-content *ngIf="!enabled()"></ng-content>
|
|
50
|
-
`
|
|
51
|
-
}), require_decorateMetadata.__decorateMetadata("design:paramtypes", [])], ContentSelectorWrapperComponent);
|
|
52
|
-
|
|
53
|
-
//#endregion
|
|
54
|
-
Object.defineProperty(exports, 'ContentSelectorWrapperComponent', {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function () {
|
|
57
|
-
return ContentSelectorWrapperComponent;
|
|
58
|
-
}
|
|
59
|
-
});
|
|
10
|
+
`}),e.__decorateMetadata(`design:paramtypes`,[])],u),Object.defineProperty(exports,`ContentSelectorWrapperComponent`,{enumerable:!0,get:function(){return u}});
|
|
60
11
|
//# sourceMappingURL=ContentSelectorWrapper.component.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelectorWrapper.component.cjs","names":["useFocusDictionary","useEditorEnabled","NodeType","CommonModule","ContentSelectorComponent"],"sources":["../../../src/editor/ContentSelectorWrapper.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, computed, Input } from '@angular/core';\nimport {
|
|
1
|
+
{"version":3,"file":"ContentSelectorWrapper.component.cjs","names":["useFocusDictionary","useEditorEnabled","NodeType","CommonModule","ContentSelectorComponent"],"sources":["../../../src/editor/ContentSelectorWrapper.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, computed, Input } from '@angular/core';\nimport type { NodeProps } from '@intlayer/core/interpreter';\nimport { isSameKeyPath } from '@intlayer/core/utils';\nimport { NodeType } from '@intlayer/types';\nimport { ContentSelectorComponent } from '../UI/ContentSelector.component';\nimport { useEditorEnabled } from './editorEnabled';\nimport { useFocusDictionary } from './focusDictionary';\nimport { useEditor } from './useEditor';\n\n/**\n * Combine your NodeProps (which include dictionaryKey & keyPath)\n * with any other div-like attributes.\n */\nexport interface ContentSelectorWrapperProps extends NodeProps {\n [key: string]: any;\n}\n\n@Component({\n selector: 'app-content-selector-wrapper',\n standalone: true,\n imports: [CommonModule, ContentSelectorComponent],\n template: `\n <app-content-selector\n *ngIf=\"enabled()\"\n (press)=\"handleSelect()\"\n [isSelecting]=\"isSelected()\"\n >\n <ng-content></ng-content>\n </app-content-selector>\n <ng-content *ngIf=\"!enabled()\"></ng-content>\n `,\n})\nexport class ContentSelectorWrapperComponent {\n @Input() dictionaryKey!: string;\n @Input() keyPath!: any[];\n\n // pull in the editor state & focus API\n private focusDictionary = useFocusDictionary();\n private editorEnabled = useEditorEnabled();\n\n constructor() {\n useEditor();\n }\n\n // compute whether this node is the current focus\n isSelected = computed(() => {\n const focusedContent = this.focusDictionary.focusedContent();\n return (\n focusedContent?.dictionaryKey === this.dictionaryKey &&\n (focusedContent.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent.keyPath ?? [], this.keyPath)\n );\n });\n\n enabled = computed(() => this.editorEnabled.enabled());\n\n // when the selector is clicked, update focus\n handleSelect() {\n this.focusDictionary.setFocusedContent({\n dictionaryKey: this.dictionaryKey,\n keyPath: this.keyPath.filter((key) => key.type !== NodeType.Translation),\n });\n }\n}\n"],"mappings":"miBAiCO,EAAA,KAAsC,CAC3C,cACA,QAGA,gBAA0BA,EAAAA,oBAAoB,CAC9C,cAAwBC,EAAAA,kBAAkB,CAE1C,aAAc,CACZ,EAAA,WAAW,CAIb,YAAA,EAAA,EAAA,cAA4B,CAC1B,IAAM,EAAiB,KAAK,gBAAgB,gBAAgB,CAC5D,OACE,GAAgB,gBAAkB,KAAK,gBACtC,EAAe,SAAS,QAAU,GAAK,IAAA,EAAA,EAAA,eAC1B,EAAe,SAAW,EAAE,CAAE,KAAK,QAAQ,EAE3D,CAEF,SAAA,EAAA,EAAA,cAAyB,KAAK,cAAc,SAAS,CAAC,CAGtD,cAAe,CACb,KAAK,gBAAgB,kBAAkB,CACrC,cAAe,KAAK,cACpB,QAAS,KAAK,QAAQ,OAAQ,GAAQ,EAAI,OAASC,EAAAA,SAAS,YAAY,CACzE,CAAC,8BA5BI,CAAA,EAAA,mBAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,gBAAA,IAAA,GAAA,4BACA,CAAA,EAAA,mBAAA,cAAA,MAAA,CAAA,CAAA,EAAA,UAAA,UAAA,IAAA,GAAA,iCAjBC,CACT,SAAU,+BACV,WAAY,GACZ,QAAS,CAACC,EAAAA,aAAcC,EAAAA,yBAAyB,CACjD,SAAU;;;;;;;;;IAUX,CAAC,CAAA,EAAA,mBAAA,oBAAA,EAAA,CAAA,CAAA,CAAA,EAAA"}
|
|
@@ -1,55 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_decorateMetadata = require('../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.cjs');
|
|
4
|
-
const require_decorate = require('../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.cjs');
|
|
5
|
-
const require_editor_useEditedContentRenderer = require('./useEditedContentRenderer.cjs');
|
|
6
|
-
let _intlayer_core = require("@intlayer/core");
|
|
7
|
-
let _angular_common = require("@angular/common");
|
|
8
|
-
let _angular_core = require("@angular/core");
|
|
9
|
-
|
|
10
|
-
//#region src/editor/EditedContentRenderer.component.ts
|
|
11
|
-
let EditedContentRendererComponent = class EditedContentRendererComponent {
|
|
12
|
-
dictionaryKey;
|
|
13
|
-
keyPath;
|
|
14
|
-
locale;
|
|
15
|
-
fallback = (0, _angular_core.signal)("");
|
|
16
|
-
rawContent = (0, _angular_core.computed)(() => {
|
|
17
|
-
return require_editor_useEditedContentRenderer.useEditedContentRenderer(this.dictionaryKey, this.keyPath, this.fallback);
|
|
18
|
-
});
|
|
19
|
-
/**
|
|
20
|
-
* Object → getContent → string, same as the React version.
|
|
21
|
-
*/
|
|
22
|
-
renderedContent = (0, _angular_core.computed)(() => {
|
|
23
|
-
const rawContentValue = this.rawContent();
|
|
24
|
-
if (typeof rawContentValue === "object" && rawContentValue !== null) {
|
|
25
|
-
const transformed = (0, _intlayer_core.getContent)(rawContentValue, {
|
|
26
|
-
dictionaryKey: this.dictionaryKey,
|
|
27
|
-
keyPath: this.keyPath
|
|
28
|
-
}, this.locale);
|
|
29
|
-
if (typeof transformed !== "string") {
|
|
30
|
-
console.error(`Incorrect edited content format. Content type: ${typeof transformed}. Expected string. Value ${JSON.stringify(transformed)}`);
|
|
31
|
-
return this.fallback();
|
|
32
|
-
}
|
|
33
|
-
return transformed;
|
|
34
|
-
}
|
|
35
|
-
return rawContentValue();
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
require_decorate.__decorate([(0, _angular_core.Input)(), require_decorateMetadata.__decorateMetadata("design:type", String)], EditedContentRendererComponent.prototype, "dictionaryKey", void 0);
|
|
39
|
-
require_decorate.__decorate([(0, _angular_core.Input)(), require_decorateMetadata.__decorateMetadata("design:type", Array)], EditedContentRendererComponent.prototype, "keyPath", void 0);
|
|
40
|
-
require_decorate.__decorate([(0, _angular_core.Input)(), require_decorateMetadata.__decorateMetadata("design:type", Object)], EditedContentRendererComponent.prototype, "locale", void 0);
|
|
41
|
-
EditedContentRendererComponent = require_decorate.__decorate([(0, _angular_core.Component)({
|
|
42
|
-
selector: "app-edited-content-renderer",
|
|
43
|
-
standalone: true,
|
|
44
|
-
imports: [_angular_common.CommonModule],
|
|
45
|
-
template: ` <span [innerHTML]="renderedContent()"></span> `
|
|
46
|
-
})], EditedContentRendererComponent);
|
|
47
|
-
|
|
48
|
-
//#endregion
|
|
49
|
-
Object.defineProperty(exports, 'EditedContentRendererComponent', {
|
|
50
|
-
enumerable: true,
|
|
51
|
-
get: function () {
|
|
52
|
-
return EditedContentRendererComponent;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.cjs`),t=require(`../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.cjs`),n=require(`./useEditedContentRenderer.cjs`);let r=require(`@intlayer/core/interpreter`),i=require(`@angular/common`),a=require(`@angular/core`),o=class{dictionaryKey;keyPath;locale;fallback=(0,a.signal)(``);rawContent=(0,a.computed)(()=>n.useEditedContentRenderer(this.dictionaryKey,this.keyPath,this.fallback));renderedContent=(0,a.computed)(()=>{let e=this.rawContent();if(typeof e==`object`&&e){let t=(0,r.getContent)(e,{dictionaryKey:this.dictionaryKey,keyPath:this.keyPath},this.locale);return typeof t==`string`?t:(console.error(`Incorrect edited content format. Content type: ${typeof t}. Expected string. Value ${JSON.stringify(t)}`),this.fallback())}return e()})};t.__decorate([(0,a.Input)(),e.__decorateMetadata(`design:type`,String)],o.prototype,`dictionaryKey`,void 0),t.__decorate([(0,a.Input)(),e.__decorateMetadata(`design:type`,Array)],o.prototype,`keyPath`,void 0),t.__decorate([(0,a.Input)(),e.__decorateMetadata(`design:type`,Object)],o.prototype,`locale`,void 0),o=t.__decorate([(0,a.Component)({selector:`app-edited-content-renderer`,standalone:!0,imports:[i.CommonModule],template:` <span [innerHTML]="renderedContent()"></span> `})],o),Object.defineProperty(exports,`EditedContentRendererComponent`,{enumerable:!0,get:function(){return o}});
|
|
55
2
|
//# sourceMappingURL=EditedContentRenderer.component.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditedContentRenderer.component.cjs","names":["useEditedContentRenderer","CommonModule"],"sources":["../../../src/editor/EditedContentRenderer.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, computed, Input, signal } from '@angular/core';\nimport { getContent } from '@intlayer/core';\nimport type { ContentNode, KeyPath, Locale } from '@intlayer/types';\nimport { useEditedContentRenderer } from './useEditedContentRenderer';\n\nexport interface EditedContentRendererProps {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: Locale;\n}\n\n@Component({\n selector: 'app-edited-content-renderer',\n standalone: true,\n imports: [CommonModule],\n template: ` <span [innerHTML]=\"renderedContent()\"></span> `,\n})\nexport class EditedContentRendererComponent {\n @Input() dictionaryKey!: string;\n @Input() keyPath!: KeyPath[];\n @Input() locale?: Locale;\n\n private fallback = signal('');\n\n private rawContent = computed(() => {\n return useEditedContentRenderer(\n this.dictionaryKey,\n this.keyPath,\n this.fallback\n );\n });\n\n /**\n * Object → getContent → string, same as the React version.\n */\n renderedContent = computed(() => {\n const rawContentValue = this.rawContent();\n\n if (typeof rawContentValue === 'object' && rawContentValue !== null) {\n const transformed = getContent(\n rawContentValue as ContentNode,\n {\n dictionaryKey: this.dictionaryKey,\n keyPath: this.keyPath,\n },\n this.locale\n );\n\n if (typeof transformed !== 'string') {\n console.error(\n `Incorrect edited content format. Content type: ${typeof transformed}. Expected string. Value ${JSON.stringify(\n transformed\n )}`\n );\n return this.fallback();\n }\n return transformed;\n }\n\n return rawContentValue() as string;\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EditedContentRenderer.component.cjs","names":["useEditedContentRenderer","CommonModule"],"sources":["../../../src/editor/EditedContentRenderer.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, computed, Input, signal } from '@angular/core';\nimport { getContent } from '@intlayer/core/interpreter';\nimport type { ContentNode, KeyPath, Locale } from '@intlayer/types';\nimport { useEditedContentRenderer } from './useEditedContentRenderer';\n\nexport interface EditedContentRendererProps {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: Locale;\n}\n\n@Component({\n selector: 'app-edited-content-renderer',\n standalone: true,\n imports: [CommonModule],\n template: ` <span [innerHTML]=\"renderedContent()\"></span> `,\n})\nexport class EditedContentRendererComponent {\n @Input() dictionaryKey!: string;\n @Input() keyPath!: KeyPath[];\n @Input() locale?: Locale;\n\n private fallback = signal('');\n\n private rawContent = computed(() => {\n return useEditedContentRenderer(\n this.dictionaryKey,\n this.keyPath,\n this.fallback\n );\n });\n\n /**\n * Object → getContent → string, same as the React version.\n */\n renderedContent = computed(() => {\n const rawContentValue = this.rawContent();\n\n if (typeof rawContentValue === 'object' && rawContentValue !== null) {\n const transformed = getContent(\n rawContentValue as ContentNode,\n {\n dictionaryKey: this.dictionaryKey,\n keyPath: this.keyPath,\n },\n this.locale\n );\n\n if (typeof transformed !== 'string') {\n console.error(\n `Incorrect edited content format. Content type: ${typeof transformed}. Expected string. Value ${JSON.stringify(\n transformed\n )}`\n );\n return this.fallback();\n }\n return transformed;\n }\n\n return rawContentValue() as string;\n });\n}\n"],"mappings":"saAkBO,EAAA,KAAqC,CAC1C,cACA,QACA,OAEA,UAAQ,EAAA,EAAA,QAAkB,GAAG,CAE7B,YAAQ,EAAA,EAAA,cACCA,EAAAA,yBACL,KAAK,cACL,KAAK,QACL,KAAK,SACN,CACD,CAKF,iBAAA,EAAA,EAAA,cAAiC,CAC/B,IAAM,EAAkB,KAAK,YAAY,CAEzC,GAAI,OAAO,GAAoB,UAAY,EAA0B,CACnE,IAAM,GAAA,EAAA,EAAA,YACJ,EACA,CACE,cAAe,KAAK,cACpB,QAAS,KAAK,QACf,CACD,KAAK,OACN,CAUD,OARI,OAAO,GAAgB,SAQpB,GAPL,QAAQ,MACN,kDAAkD,OAAO,EAAY,2BAA2B,KAAK,UACnG,EACD,GACF,CACM,KAAK,UAAU,EAK1B,OAAO,GAAiB,EACxB,6BA1CM,CAAA,EAAA,mBAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,gBAAA,IAAA,GAAA,4BACA,CAAA,EAAA,mBAAA,cAAA,MAAA,CAAA,CAAA,EAAA,UAAA,UAAA,IAAA,GAAA,4BACA,CAAA,EAAA,mBAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,SAAA,IAAA,GAAA,iCATC,CACT,SAAU,8BACV,WAAY,GACZ,QAAS,CAACC,EAAAA,aAAa,CACvB,SAAU,kDACX,CAAC,CAAA,CAAA,EAAA"}
|
|
@@ -1,28 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_decorateMetadata = require('../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.cjs');
|
|
4
|
-
const require_decorate = require('../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.cjs');
|
|
5
|
-
const require_editor_ContentSelectorWrapper_component = require('./ContentSelectorWrapper.component.cjs');
|
|
6
|
-
const require_editor_EditedContentRenderer_component = require('./EditedContentRenderer.component.cjs');
|
|
7
|
-
let _angular_common = require("@angular/common");
|
|
8
|
-
let _angular_core = require("@angular/core");
|
|
9
|
-
|
|
10
|
-
//#region src/editor/EditorSelectorRenderer.component.ts
|
|
11
|
-
let EditorSelectorRendererComponent = class EditorSelectorRendererComponent {
|
|
12
|
-
dictionaryKey;
|
|
13
|
-
keyPath;
|
|
14
|
-
};
|
|
15
|
-
require_decorate.__decorate([(0, _angular_core.Input)(), require_decorateMetadata.__decorateMetadata("design:type", String)], EditorSelectorRendererComponent.prototype, "dictionaryKey", void 0);
|
|
16
|
-
require_decorate.__decorate([(0, _angular_core.Input)(), require_decorateMetadata.__decorateMetadata("design:type", Array)], EditorSelectorRendererComponent.prototype, "keyPath", void 0);
|
|
17
|
-
EditorSelectorRendererComponent = require_decorate.__decorate([(0, _angular_core.Component)({
|
|
18
|
-
selector: "app-editor-selector-renderer",
|
|
19
|
-
standalone: true,
|
|
20
|
-
imports: [
|
|
21
|
-
_angular_common.CommonModule,
|
|
22
|
-
require_editor_ContentSelectorWrapper_component.ContentSelectorWrapperComponent,
|
|
23
|
-
require_editor_EditedContentRenderer_component.EditedContentRendererComponent
|
|
24
|
-
],
|
|
25
|
-
template: `
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.cjs`),t=require(`../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.cjs`),n=require(`./ContentSelectorWrapper.component.cjs`),r=require(`./EditedContentRenderer.component.cjs`);let i=require(`@angular/common`),a=require(`@angular/core`),o=class{dictionaryKey;keyPath};t.__decorate([(0,a.Input)(),e.__decorateMetadata(`design:type`,String)],o.prototype,`dictionaryKey`,void 0),t.__decorate([(0,a.Input)(),e.__decorateMetadata(`design:type`,Array)],o.prototype,`keyPath`,void 0),o=t.__decorate([(0,a.Component)({selector:`app-editor-selector-renderer`,standalone:!0,imports:[i.CommonModule,n.ContentSelectorWrapperComponent,r.EditedContentRendererComponent],template:`
|
|
26
2
|
<app-content-selector-wrapper
|
|
27
3
|
[dictionaryKey]="dictionaryKey"
|
|
28
4
|
[keyPath]="keyPath"
|
|
@@ -34,14 +10,5 @@ EditorSelectorRendererComponent = require_decorate.__decorate([(0, _angular_core
|
|
|
34
10
|
<ng-content></ng-content>
|
|
35
11
|
</app-edited-content-renderer>
|
|
36
12
|
</app-content-selector-wrapper>
|
|
37
|
-
`
|
|
38
|
-
})], EditorSelectorRendererComponent);
|
|
39
|
-
|
|
40
|
-
//#endregion
|
|
41
|
-
Object.defineProperty(exports, 'EditorSelectorRendererComponent', {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
get: function () {
|
|
44
|
-
return EditorSelectorRendererComponent;
|
|
45
|
-
}
|
|
46
|
-
});
|
|
13
|
+
`})],o),Object.defineProperty(exports,`EditorSelectorRendererComponent`,{enumerable:!0,get:function(){return o}});
|
|
47
14
|
//# sourceMappingURL=EditorSelectorRenderer.component.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorSelectorRenderer.component.cjs","names":["CommonModule","ContentSelectorWrapperComponent","EditedContentRendererComponent"],"sources":["../../../src/editor/EditorSelectorRenderer.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, Input } from '@angular/core';\nimport type { NodeProps } from '@intlayer/core';\nimport { ContentSelectorWrapperComponent } from './ContentSelectorWrapper.component';\nimport { EditedContentRendererComponent } from './EditedContentRenderer.component';\n\n/**\n * Combine your NodeProps (which include dictionaryKey & keyPath)\n * with any other div-like attributes.\n */\nexport interface EditorSelectorRendererProps extends NodeProps {\n [key: string]: any;\n}\n\n@Component({\n selector: 'app-editor-selector-renderer',\n standalone: true,\n imports: [\n CommonModule,\n ContentSelectorWrapperComponent,\n EditedContentRendererComponent,\n ],\n template: `\n <app-content-selector-wrapper\n [dictionaryKey]=\"dictionaryKey\"\n [keyPath]=\"keyPath\"\n >\n <app-edited-content-renderer\n [dictionaryKey]=\"dictionaryKey\"\n [keyPath]=\"keyPath\"\n >\n <ng-content></ng-content>\n </app-edited-content-renderer>\n </app-content-selector-wrapper>\n `,\n})\nexport class EditorSelectorRendererComponent {\n @Input() dictionaryKey!: string;\n @Input() keyPath!: any[];\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EditorSelectorRenderer.component.cjs","names":["CommonModule","ContentSelectorWrapperComponent","EditedContentRendererComponent"],"sources":["../../../src/editor/EditorSelectorRenderer.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, Input } from '@angular/core';\nimport type { NodeProps } from '@intlayer/core/interpreter';\nimport { ContentSelectorWrapperComponent } from './ContentSelectorWrapper.component';\nimport { EditedContentRendererComponent } from './EditedContentRenderer.component';\n\n/**\n * Combine your NodeProps (which include dictionaryKey & keyPath)\n * with any other div-like attributes.\n */\nexport interface EditorSelectorRendererProps extends NodeProps {\n [key: string]: any;\n}\n\n@Component({\n selector: 'app-editor-selector-renderer',\n standalone: true,\n imports: [\n CommonModule,\n ContentSelectorWrapperComponent,\n EditedContentRendererComponent,\n ],\n template: `\n <app-content-selector-wrapper\n [dictionaryKey]=\"dictionaryKey\"\n [keyPath]=\"keyPath\"\n >\n <app-edited-content-renderer\n [dictionaryKey]=\"dictionaryKey\"\n [keyPath]=\"keyPath\"\n >\n <ng-content></ng-content>\n </app-edited-content-renderer>\n </app-content-selector-wrapper>\n `,\n})\nexport class EditorSelectorRendererComponent {\n @Input() dictionaryKey!: string;\n @Input() keyPath!: any[];\n}\n"],"mappings":"ybAoCO,EAAA,KAAsC,CAC3C,cACA,oCADQ,CAAA,EAAA,mBAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,gBAAA,IAAA,GAAA,4BACA,CAAA,EAAA,mBAAA,cAAA,MAAA,CAAA,CAAA,EAAA,UAAA,UAAA,IAAA,GAAA,iCAxBC,CACT,SAAU,+BACV,WAAY,GACZ,QAAS,CACPA,EAAAA,aACAC,EAAAA,gCACAC,EAAAA,+BACD,CACD,SAAU;;;;;;;;;;;;IAaX,CAAC,CAAA,CAAA,EAAA"}
|
|
@@ -1,64 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let _intlayer_config_built = require("@intlayer/config/built");
|
|
4
|
-
_intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
|
|
5
|
-
|
|
6
|
-
//#region src/editor/communicator.ts
|
|
7
|
-
const randomUUID = () => Math.random().toString(36).slice(2);
|
|
8
|
-
const { editor } = _intlayer_config_built.default;
|
|
9
|
-
/**
|
|
10
|
-
* Default values for the communicator
|
|
11
|
-
*/
|
|
12
|
-
const defaultValue = {
|
|
13
|
-
postMessage: () => null,
|
|
14
|
-
allowedOrigins: [
|
|
15
|
-
editor?.applicationURL,
|
|
16
|
-
editor?.editorURL,
|
|
17
|
-
editor?.cmsURL
|
|
18
|
-
],
|
|
19
|
-
senderId: ""
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Singleton instance
|
|
23
|
-
*/
|
|
24
|
-
let instance = null;
|
|
25
|
-
/**
|
|
26
|
-
* Creates a communicator client
|
|
27
|
-
* @param options - Options for configuring the communicator
|
|
28
|
-
*/
|
|
29
|
-
const createCommunicator = (options = { postMessage: () => null }) => {
|
|
30
|
-
if (instance) return instance;
|
|
31
|
-
instance = {
|
|
32
|
-
...defaultValue,
|
|
33
|
-
...options,
|
|
34
|
-
senderId: randomUUID()
|
|
35
|
-
};
|
|
36
|
-
return instance;
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Helper to install the Intlayer communicator into the injector
|
|
40
|
-
*/
|
|
41
|
-
const installCommunicator = (_injector, options = { postMessage: () => null }) => {
|
|
42
|
-
createCommunicator(options);
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Hook to access the communicator
|
|
46
|
-
* @returns The communicator instance
|
|
47
|
-
*/
|
|
48
|
-
const useCommunicator = () => {
|
|
49
|
-
try {
|
|
50
|
-
return createCommunicator() || defaultValue;
|
|
51
|
-
} catch (_error) {
|
|
52
|
-
console.warn("useCommunicator: Error accessing communicator. Returning default communicator.");
|
|
53
|
-
return {
|
|
54
|
-
postMessage: () => null,
|
|
55
|
-
senderId: ""
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
//#endregion
|
|
61
|
-
exports.createCommunicator = createCommunicator;
|
|
62
|
-
exports.installCommunicator = installCommunicator;
|
|
63
|
-
exports.useCommunicator = useCommunicator;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`);let t=require(`@intlayer/config/built`);t=e.__toESM(t);const n=()=>Math.random().toString(36).slice(2),{editor:r}=t.default,i={postMessage:()=>null,allowedOrigins:[r?.applicationURL,r?.editorURL,r?.cmsURL],senderId:``};let a=null;const o=(e={postMessage:()=>null})=>a||(a={...i,...e,senderId:n()},a),s=(e,t={postMessage:()=>null})=>{o(t)},c=()=>{try{return o()||i}catch{return console.warn(`useCommunicator: Error accessing communicator. Returning default communicator.`),{postMessage:()=>null,senderId:``}}};exports.createCommunicator=o,exports.installCommunicator=s,exports.useCommunicator=c;
|
|
64
2
|
//# sourceMappingURL=communicator.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"communicator.cjs","names":["configuration"],"sources":["../../../src/editor/communicator.ts"],"sourcesContent":["import type { Injector } from '@angular/core';\nimport configuration from '@intlayer/config/built';\n\nconst randomUUID = () => Math.random().toString(36).slice(2);\n\n/**\n * Interface defining a cross-frame communicator\n */\nexport type Communicator = {\n postMessage: typeof window.postMessage;\n allowedOrigins?: string[];\n senderId: string;\n};\n\n/**\n * Configuration options for the communicator\n */\nexport type CommunicatorOptions = Omit<Communicator, 'senderId'>;\n\nconst { editor } = configuration;\n\n/**\n * Default values for the communicator\n */\nconst defaultValue: Communicator = {\n postMessage: () => null,\n allowedOrigins: [\n editor?.applicationURL,\n editor?.editorURL,\n editor?.cmsURL,\n ] as string[],\n senderId: '',\n};\n\n/**\n * Singleton instance\n */\nlet instance: Communicator | null = null;\n\nconst _INTLAYER_COMMUNICATOR_SYMBOL = Symbol('Communicator');\n\n/**\n * Creates a communicator client\n * @param options - Options for configuring the communicator\n */\nexport const createCommunicator = (\n options: CommunicatorOptions = { postMessage: () => null }\n) => {\n if (instance) return instance;\n\n instance = {\n ...defaultValue,\n ...options,\n senderId: randomUUID(),\n };\n\n return instance;\n};\n\n/**\n * Helper to install the Intlayer communicator into the injector\n */\nexport const installCommunicator = (\n _injector: Injector,\n options: CommunicatorOptions = { postMessage: () => null }\n) => {\n const _client = createCommunicator(options);\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createCommunicator\n};\n\n/**\n * Hook to access the communicator\n * @returns The communicator instance\n */\nexport const useCommunicator = (): Communicator => {\n try {\n const communicator = createCommunicator();\n return communicator || defaultValue;\n } catch (_error) {\n console.warn(\n 'useCommunicator: Error accessing communicator. Returning default communicator.'\n );\n return {\n postMessage: () => null,\n senderId: '',\n };\n }\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"communicator.cjs","names":["configuration"],"sources":["../../../src/editor/communicator.ts"],"sourcesContent":["import type { Injector } from '@angular/core';\nimport configuration from '@intlayer/config/built';\n\nconst randomUUID = () => Math.random().toString(36).slice(2);\n\n/**\n * Interface defining a cross-frame communicator\n */\nexport type Communicator = {\n postMessage: typeof window.postMessage;\n allowedOrigins?: string[];\n senderId: string;\n};\n\n/**\n * Configuration options for the communicator\n */\nexport type CommunicatorOptions = Omit<Communicator, 'senderId'>;\n\nconst { editor } = configuration;\n\n/**\n * Default values for the communicator\n */\nconst defaultValue: Communicator = {\n postMessage: () => null,\n allowedOrigins: [\n editor?.applicationURL,\n editor?.editorURL,\n editor?.cmsURL,\n ] as string[],\n senderId: '',\n};\n\n/**\n * Singleton instance\n */\nlet instance: Communicator | null = null;\n\nconst _INTLAYER_COMMUNICATOR_SYMBOL = Symbol('Communicator');\n\n/**\n * Creates a communicator client\n * @param options - Options for configuring the communicator\n */\nexport const createCommunicator = (\n options: CommunicatorOptions = { postMessage: () => null }\n) => {\n if (instance) return instance;\n\n instance = {\n ...defaultValue,\n ...options,\n senderId: randomUUID(),\n };\n\n return instance;\n};\n\n/**\n * Helper to install the Intlayer communicator into the injector\n */\nexport const installCommunicator = (\n _injector: Injector,\n options: CommunicatorOptions = { postMessage: () => null }\n) => {\n const _client = createCommunicator(options);\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createCommunicator\n};\n\n/**\n * Hook to access the communicator\n * @returns The communicator instance\n */\nexport const useCommunicator = (): Communicator => {\n try {\n const communicator = createCommunicator();\n return communicator || defaultValue;\n } catch (_error) {\n console.warn(\n 'useCommunicator: Error accessing communicator. Returning default communicator.'\n );\n return {\n postMessage: () => null,\n senderId: '',\n };\n }\n};\n"],"mappings":"+KAGA,MAAM,MAAmB,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,CAgBtD,CAAE,UAAWA,EAAAA,QAKb,EAA6B,CACjC,gBAAmB,KACnB,eAAgB,CACd,GAAQ,eACR,GAAQ,UACR,GAAQ,OACT,CACD,SAAU,GACX,CAKD,IAAI,EAAgC,KAQpC,MAAa,GACX,EAA+B,CAAE,gBAAmB,KAAM,GAEtD,IAEJ,EAAW,CACT,GAAG,EACH,GAAG,EACH,SAAU,GAAY,CACvB,CAEM,GAMI,GACX,EACA,EAA+B,CAAE,gBAAmB,KAAM,GACvD,CACa,EAAmB,EAAQ,EAUhC,MAAsC,CACjD,GAAI,CAEF,OADqB,GAAoB,EAClB,OACR,CAIf,OAHA,QAAQ,KACN,iFACD,CACM,CACL,gBAAmB,KACnB,SAAU,GACX"}
|
|
@@ -1,23 +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
|
-
let _intlayer_config_built = require("@intlayer/config/built");
|
|
7
|
-
_intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
|
|
8
|
-
|
|
9
|
-
//#region src/editor/configuration.ts
|
|
10
|
-
const useConfiguration = () => {
|
|
11
|
-
const [pushedConfiguration, setConfiguration] = require_editor_useCrossFrameState.useCrossFrameState(_intlayer_editor.MessageKey.INTLAYER_CONFIGURATION);
|
|
12
|
-
try {
|
|
13
|
-
if ((0, _angular_core.inject)(_angular_core.DestroyRef, { optional: true })) {
|
|
14
|
-
if (!pushedConfiguration()) setConfiguration(_intlayer_config_built.default);
|
|
15
|
-
}
|
|
16
|
-
} catch {
|
|
17
|
-
console.warn("useConfiguration called outside injection context; configuration may not be synchronized.");
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
//#endregion
|
|
22
|
-
exports.useConfiguration = useConfiguration;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`./useCrossFrameState.cjs`);let n=require(`@angular/core`),r=require(`@intlayer/editor`),i=require(`@intlayer/config/built`);i=e.__toESM(i);const a=()=>{let[e,a]=t.useCrossFrameState(r.MessageKey.INTLAYER_CONFIGURATION);try{(0,n.inject)(n.DestroyRef,{optional:!0})&&(e()||a(i.default))}catch{console.warn(`useConfiguration called outside injection context; configuration may not be synchronized.`)}};exports.useConfiguration=a;
|
|
23
2
|
//# sourceMappingURL=configuration.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.cjs","names":["useCrossFrameState","MessageKey","DestroyRef","configuration"],"sources":["../../../src/editor/configuration.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport { MessageKey } from '@intlayer/editor';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport const useConfiguration = () => {\n const [pushedConfiguration, setConfiguration] =\n useCrossFrameState<IntlayerConfig>(MessageKey.INTLAYER_CONFIGURATION);\n\n // Use Angular's injection context instead of Vue's onMounted\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n\n if (destroyRef) {\n // Execute immediately since Angular doesn't have the same lifecycle hooks\n if (!pushedConfiguration()) {\n setConfiguration(configuration);\n }\n }\n } catch {\n console.warn(\n 'useConfiguration called outside injection context; ' +\n 'configuration may not be synchronized.'\n );\n }\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"configuration.cjs","names":["useCrossFrameState","MessageKey","DestroyRef","configuration"],"sources":["../../../src/editor/configuration.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport { MessageKey } from '@intlayer/editor';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport const useConfiguration = () => {\n const [pushedConfiguration, setConfiguration] =\n useCrossFrameState<IntlayerConfig>(MessageKey.INTLAYER_CONFIGURATION);\n\n // Use Angular's injection context instead of Vue's onMounted\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n\n if (destroyRef) {\n // Execute immediately since Angular doesn't have the same lifecycle hooks\n if (!pushedConfiguration()) {\n setConfiguration(configuration);\n }\n }\n } catch {\n console.warn(\n 'useConfiguration called outside injection context; ' +\n 'configuration may not be synchronized.'\n );\n }\n};\n"],"mappings":"8QAMA,MAAa,MAAyB,CACpC,GAAM,CAAC,EAAqB,GAC1BA,EAAAA,mBAAmCC,EAAAA,WAAW,uBAAuB,CAGvE,GAAI,EAGF,EAAA,EAAA,QAF0BC,EAAAA,WAAY,CAAE,SAAU,GAAM,CAAC,GAIlD,GAAqB,EACxB,EAAiBC,EAAAA,QAAc,OAG7B,CACN,QAAQ,KACN,4FAED"}
|
|
@@ -1,51 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let _angular_core = require("@angular/core");
|
|
4
|
-
|
|
5
|
-
//#region src/editor/createSharedComposable.ts
|
|
6
|
-
/**
|
|
7
|
-
* Angular replacement for Vue's tryOnScopeDispose
|
|
8
|
-
* Uses Angular's DestroyRef to handle cleanup when the injection context is destroyed
|
|
9
|
-
*/
|
|
10
|
-
function tryOnScopeDispose(fn) {
|
|
11
|
-
try {
|
|
12
|
-
const destroyRef = (0, _angular_core.inject)(_angular_core.DestroyRef, { optional: true });
|
|
13
|
-
if (destroyRef) {
|
|
14
|
-
destroyRef.onDestroy(fn);
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
return false;
|
|
18
|
-
} catch {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Angular equivalent of Vue's createSharedComposable
|
|
24
|
-
* Creates a singleton pattern for services/composables
|
|
25
|
-
*/
|
|
26
|
-
const createSharedComposable = (composable) => {
|
|
27
|
-
let subscribers = 0;
|
|
28
|
-
let state;
|
|
29
|
-
let cleanupFn;
|
|
30
|
-
const dispose = () => {
|
|
31
|
-
subscribers -= 1;
|
|
32
|
-
if (cleanupFn && subscribers <= 0) {
|
|
33
|
-
cleanupFn();
|
|
34
|
-
state = void 0;
|
|
35
|
-
cleanupFn = void 0;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
return ((...args) => {
|
|
39
|
-
subscribers += 1;
|
|
40
|
-
if (!state) {
|
|
41
|
-
state = composable(...args);
|
|
42
|
-
if (tryOnScopeDispose(dispose)) cleanupFn = dispose;
|
|
43
|
-
} else tryOnScopeDispose(dispose);
|
|
44
|
-
return state;
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
//#endregion
|
|
49
|
-
exports.createSharedComposable = createSharedComposable;
|
|
50
|
-
exports.tryOnScopeDispose = tryOnScopeDispose;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@angular/core`);function t(t){try{let n=(0,e.inject)(e.DestroyRef,{optional:!0});return n?(n.onDestroy(t),!0):!1}catch{return!1}}const n=e=>{let n=0,r,i,a=()=>{--n,i&&n<=0&&(i(),r=void 0,i=void 0)};return((...o)=>(n+=1,r?t(a):(r=e(...o),t(a)&&(i=a)),r))};exports.createSharedComposable=n,exports.tryOnScopeDispose=t;
|
|
51
2
|
//# sourceMappingURL=createSharedComposable.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSharedComposable.cjs","names":["DestroyRef"],"sources":["../../../src/editor/createSharedComposable.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core';\n\ntype AnyFn = (...args: any[]) => any;\n\nexport type SharedComposableReturn<T extends AnyFn = AnyFn> = T;\n\n/**\n * Angular replacement for Vue's tryOnScopeDispose\n * Uses Angular's DestroyRef to handle cleanup when the injection context is destroyed\n */\nexport function tryOnScopeDispose(fn: () => void) {\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n if (destroyRef) {\n destroyRef.onDestroy(fn);\n return true;\n }\n return false;\n } catch {\n // If called outside injection context, return false\n return false;\n }\n}\n\n/**\n * Angular equivalent of Vue's createSharedComposable\n * Creates a singleton pattern for services/composables\n */\nexport const createSharedComposable = <Fn extends AnyFn>(\n composable: Fn\n): SharedComposableReturn<Fn> => {\n let subscribers = 0;\n let state: ReturnType<Fn> | undefined;\n let cleanupFn: (() => void) | undefined;\n\n const dispose = () => {\n subscribers -= 1;\n if (cleanupFn && subscribers <= 0) {\n cleanupFn();\n state = undefined;\n cleanupFn = undefined;\n }\n };\n\n return <Fn>((...args) => {\n subscribers += 1;\n if (!state) {\n state = composable(...args);\n // Set up cleanup when the first subscriber is destroyed\n if (tryOnScopeDispose(dispose)) {\n cleanupFn = dispose;\n }\n } else {\n // For additional subscribers, just set up their individual cleanup\n tryOnScopeDispose(dispose);\n }\n return state;\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"createSharedComposable.cjs","names":["DestroyRef"],"sources":["../../../src/editor/createSharedComposable.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core';\n\ntype AnyFn = (...args: any[]) => any;\n\nexport type SharedComposableReturn<T extends AnyFn = AnyFn> = T;\n\n/**\n * Angular replacement for Vue's tryOnScopeDispose\n * Uses Angular's DestroyRef to handle cleanup when the injection context is destroyed\n */\nexport function tryOnScopeDispose(fn: () => void) {\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n if (destroyRef) {\n destroyRef.onDestroy(fn);\n return true;\n }\n return false;\n } catch {\n // If called outside injection context, return false\n return false;\n }\n}\n\n/**\n * Angular equivalent of Vue's createSharedComposable\n * Creates a singleton pattern for services/composables\n */\nexport const createSharedComposable = <Fn extends AnyFn>(\n composable: Fn\n): SharedComposableReturn<Fn> => {\n let subscribers = 0;\n let state: ReturnType<Fn> | undefined;\n let cleanupFn: (() => void) | undefined;\n\n const dispose = () => {\n subscribers -= 1;\n if (cleanupFn && subscribers <= 0) {\n cleanupFn();\n state = undefined;\n cleanupFn = undefined;\n }\n };\n\n return <Fn>((...args) => {\n subscribers += 1;\n if (!state) {\n state = composable(...args);\n // Set up cleanup when the first subscriber is destroyed\n if (tryOnScopeDispose(dispose)) {\n cleanupFn = dispose;\n }\n } else {\n // For additional subscribers, just set up their individual cleanup\n tryOnScopeDispose(dispose);\n }\n return state;\n });\n};\n"],"mappings":"+IAUA,SAAgB,EAAkB,EAAgB,CAChD,GAAI,CACF,IAAM,GAAA,EAAA,EAAA,QAAoBA,EAAAA,WAAY,CAAE,SAAU,GAAM,CAAC,CAKzD,OAJI,GACF,EAAW,UAAU,EAAG,CACjB,IAEF,QACD,CAEN,MAAO,IAQX,MAAa,EACX,GAC+B,CAC/B,IAAI,EAAc,EACd,EACA,EAEE,MAAgB,CACpB,IACI,GAAa,GAAe,IAC9B,GAAW,CACX,EAAQ,IAAA,GACR,EAAY,IAAA,KAIhB,QAAa,GAAG,KACd,GAAe,EACV,EAQH,EAAkB,EAAQ,EAP1B,EAAQ,EAAW,GAAG,EAAK,CAEvB,EAAkB,EAAQ,GAC5B,EAAY,IAMT"}
|