angular-intlayer 8.0.2 → 8.0.5
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 +4 -3
- package/dist/cjs/UI/ContentSelector.component.cjs.map +1 -1
- package/dist/cjs/_virtual/{_@oxc-project_runtime@0.110.0 → _@oxc-project_runtime@0.112.0}/helpers/decorate.cjs +1 -1
- package/dist/cjs/_virtual/{_@oxc-project_runtime@0.110.0 → _@oxc-project_runtime@0.112.0}/helpers/decorateMetadata.cjs +1 -1
- package/dist/cjs/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +1 -1
- package/dist/cjs/client/index.cjs +1 -0
- package/dist/cjs/client/installIntlayer.cjs +4 -3
- package/dist/cjs/client/installIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useDictionary.cjs +2 -1
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs +3 -2
- package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +3 -2
- package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
- package/dist/cjs/client/useIntl.cjs +2 -1
- package/dist/cjs/client/useIntl.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs +2 -1
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useLoadDynamic.cjs +2 -1
- package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs +3 -2
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocaleStorage.cjs +2 -1
- package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
- package/dist/cjs/editor/ContentSelectorWrapper.component.cjs +4 -3
- package/dist/cjs/editor/ContentSelectorWrapper.component.cjs.map +1 -1
- package/dist/cjs/editor/EditedContentRenderer.component.cjs +4 -3
- package/dist/cjs/editor/EditedContentRenderer.component.cjs.map +1 -1
- package/dist/cjs/editor/EditorSelectorRenderer.component.cjs +4 -3
- package/dist/cjs/editor/EditorSelectorRenderer.component.cjs.map +1 -1
- package/dist/cjs/editor/communicator.cjs +3 -2
- package/dist/cjs/editor/communicator.cjs.map +1 -1
- package/dist/cjs/editor/configuration.cjs +3 -2
- package/dist/cjs/editor/configuration.cjs.map +1 -1
- package/dist/cjs/editor/createSharedComposable.cjs +2 -1
- package/dist/cjs/editor/createSharedComposable.cjs.map +1 -1
- package/dist/cjs/editor/dictionariesRecord.cjs +2 -1
- package/dist/cjs/editor/dictionariesRecord.cjs.map +1 -1
- package/dist/cjs/editor/editedContent.cjs +2 -1
- package/dist/cjs/editor/editedContent.cjs.map +1 -1
- package/dist/cjs/editor/editorEnabled.cjs +2 -1
- package/dist/cjs/editor/editorEnabled.cjs.map +1 -1
- package/dist/cjs/editor/editorLocale.cjs +2 -1
- package/dist/cjs/editor/editorLocale.cjs.map +1 -1
- package/dist/cjs/editor/focusDictionary.cjs +2 -1
- package/dist/cjs/editor/focusDictionary.cjs.map +1 -1
- package/dist/cjs/editor/index.cjs +1 -0
- package/dist/cjs/editor/installIntlayerEditor.cjs +3 -2
- package/dist/cjs/editor/installIntlayerEditor.cjs.map +1 -1
- package/dist/cjs/editor/useCrossFrameMessageListener.cjs +2 -1
- package/dist/cjs/editor/useCrossFrameMessageListener.cjs.map +1 -1
- package/dist/cjs/editor/useCrossFrameState.cjs +2 -1
- package/dist/cjs/editor/useCrossFrameState.cjs.map +1 -1
- package/dist/cjs/editor/useCrossURLPathState.cjs +2 -1
- package/dist/cjs/editor/useCrossURLPathState.cjs.map +1 -1
- package/dist/cjs/editor/useEditedContentRenderer.cjs +3 -2
- package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -1
- package/dist/cjs/editor/useEditor.cjs +1 -0
- package/dist/cjs/editor/useEditor.cjs.map +1 -1
- package/dist/cjs/editor/useIframeClickInterceptor.cjs +2 -1
- package/dist/cjs/editor/useIframeClickInterceptor.cjs.map +1 -1
- package/dist/cjs/getDictionary.cjs +2 -1
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs +2 -1
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/markdown/index.cjs +1 -0
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs +3 -2
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -1
- package/dist/cjs/plugins.cjs +3 -2
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/renderIntlayerNode.cjs +1 -0
- package/dist/cjs/renderIntlayerNode.cjs.map +1 -1
- package/dist/cjs/webpack/index.cjs +1 -0
- package/dist/cjs/webpack/mergeConfig.cjs +2 -1
- package/dist/cjs/webpack/mergeConfig.cjs.map +1 -1
- package/dist/esm/UI/ContentSelector.component.mjs +2 -2
- package/dist/esm/_virtual/{_@oxc-project_runtime@0.110.0 → _@oxc-project_runtime@0.112.0}/helpers/decorate.mjs +1 -1
- package/dist/esm/_virtual/{_@oxc-project_runtime@0.110.0 → _@oxc-project_runtime@0.112.0}/helpers/decorateMetadata.mjs +1 -1
- package/dist/esm/client/installIntlayer.mjs +1 -1
- package/dist/esm/editor/ContentSelectorWrapper.component.mjs +2 -2
- package/dist/esm/editor/EditedContentRenderer.component.mjs +2 -2
- package/dist/esm/editor/EditorSelectorRenderer.component.mjs +2 -2
- package/dist/esm/editor/useEditedContentRenderer.mjs +1 -1
- package/dist/esm/markdown/installIntlayerMarkdown.mjs +1 -1
- package/dist/esm/plugins.mjs +1 -1
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/types/client/installIntlayer.d.ts +2 -2
- package/dist/types/client/useDictionaryAsync.d.ts +2 -2
- package/dist/types/client/useDictionaryDynamic.d.ts +3 -3
- package/dist/types/client/useIntl.d.ts +2 -2
- package/dist/types/client/useLocale.d.ts +2 -2
- package/dist/types/client/useLocaleStorage.d.ts +5 -5
- package/dist/types/editor/EditedContentRenderer.component.d.ts +2 -2
- package/dist/types/editor/useCrossURLPathState.d.ts +3 -3
- package/package.json +12 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editorLocale.cjs","names":["createSharedComposable","INTLAYER_TOKEN","useCrossFrameState","MessageKey"],"sources":["../../../src/editor/editorLocale.ts"],"sourcesContent":["import { effect, inject } from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport type { Locale, LocalesValues } from '@intlayer/types';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from '../client';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport const useEditorLocale = createSharedComposable(() => {\n const client = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n if (!client) {\n throw new Error('IntlayerEditor state not found');\n }\n\n const [_data, setData] = useCrossFrameState<LocalesValues>(\n MessageKey.INTLAYER_CURRENT_LOCALE\n );\n\n // Use Angular effects instead of Vue watchers\n effect(() => {\n const newValue = client.locale();\n setData(newValue as Locale);\n });\n\n return client;\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"editorLocale.cjs","names":["createSharedComposable","INTLAYER_TOKEN","useCrossFrameState","MessageKey"],"sources":["../../../src/editor/editorLocale.ts"],"sourcesContent":["import { effect, inject } from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport type { Locale, LocalesValues } from '@intlayer/types';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from '../client';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport const useEditorLocale = createSharedComposable(() => {\n const client = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n if (!client) {\n throw new Error('IntlayerEditor state not found');\n }\n\n const [_data, setData] = useCrossFrameState<LocalesValues>(\n MessageKey.INTLAYER_CURRENT_LOCALE\n );\n\n // Use Angular effects instead of Vue watchers\n effect(() => {\n const newValue = client.locale();\n setData(newValue as Locale);\n });\n\n return client;\n});\n"],"mappings":";;;;;;;;;AAOA,MAAa,kBAAkBA,mEAA6B;CAC1D,MAAM,mCAAkCC,8CAAe;AAEvD,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,iCAAiC;CAGnD,MAAM,CAAC,OAAO,WAAWC,qDACvBC,4BAAW,wBACZ;AAGD,iCAAa;AAEX,UADiB,OAAO,QAAQ,CACL;GAC3B;AAEF,QAAO;EACP"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
3
|
const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
|
|
3
4
|
const require_editor_useCrossFrameState = require('./useCrossFrameState.cjs');
|
|
4
5
|
let _angular_core = require("@angular/core");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focusDictionary.cjs","names":["createSharedComposable","useCrossFrameState","MessageKey"],"sources":["../../../src/editor/focusDictionary.ts"],"sourcesContent":["import { effect, type Injector, type Signal, signal } from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport type { KeyPath } from '@intlayer/types';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport type FileContent = {\n dictionaryKey: string;\n keyPath?: KeyPath[];\n dictionaryPath?: string;\n};\n\ntype FocusDictionaryClient = {\n focusedContent: Signal<FileContent | null>;\n setFocusedContent: (focussedContent: FileContent | null) => void;\n setFocusedContentKeyPath: (keyPath: KeyPath[]) => void;\n};\n\n/**\n * Singleton instance\n */\nlet instance: FocusDictionaryClient | null = null;\n\n/**\n * Creates a focus dictionary client\n */\nexport const createFocusDictionaryClient = () => {\n if (instance) return instance;\n\n const focusedContentSignal = signal<FileContent | null>(null);\n\n const setFocusedContent = (focussedContent: FileContent | null) => {\n focusedContentSignal.set(focussedContent);\n };\n\n const setFocusedContentKeyPath = (keyPath: KeyPath[]) => {\n const current = focusedContentSignal();\n if (!current) return;\n setFocusedContent({ ...current, keyPath });\n };\n\n instance = {\n focusedContent: focusedContentSignal.asReadonly(),\n setFocusedContent,\n setFocusedContentKeyPath,\n } as FocusDictionaryClient;\n\n return instance;\n};\n\n/**\n * Helper to install the focus dictionary into the injector\n */\nexport const installFocusDictionary = (_injector: Injector) => {\n const _client = createFocusDictionaryClient();\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createFocusDictionaryClient\n};\n\n/** consumer */\nexport const useFocusDictionary = createSharedComposable(() => {\n const client = createFocusDictionaryClient();\n const [focusedContent, setFocusedContent] =\n useCrossFrameState<FileContent | null>(\n MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED\n );\n\n if (!client) {\n throw new Error('FocusDictionary state not found');\n }\n\n // Use Angular effects instead of Vue watchers\n // Watch local (client) and update cross-frame\n effect(() => {\n const newValue = client.focusedContent();\n if (JSON.stringify(newValue) !== JSON.stringify(focusedContent())) {\n setFocusedContent(newValue);\n }\n });\n\n // Watch cross-frame and update local\n effect(() => {\n const newValue = focusedContent();\n if (JSON.stringify(newValue) !== JSON.stringify(client.focusedContent())) {\n client.setFocusedContent(newValue ?? null);\n }\n });\n\n return client;\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"focusDictionary.cjs","names":["createSharedComposable","useCrossFrameState","MessageKey"],"sources":["../../../src/editor/focusDictionary.ts"],"sourcesContent":["import { effect, type Injector, type Signal, signal } from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport type { KeyPath } from '@intlayer/types';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport type FileContent = {\n dictionaryKey: string;\n keyPath?: KeyPath[];\n dictionaryPath?: string;\n};\n\ntype FocusDictionaryClient = {\n focusedContent: Signal<FileContent | null>;\n setFocusedContent: (focussedContent: FileContent | null) => void;\n setFocusedContentKeyPath: (keyPath: KeyPath[]) => void;\n};\n\n/**\n * Singleton instance\n */\nlet instance: FocusDictionaryClient | null = null;\n\n/**\n * Creates a focus dictionary client\n */\nexport const createFocusDictionaryClient = () => {\n if (instance) return instance;\n\n const focusedContentSignal = signal<FileContent | null>(null);\n\n const setFocusedContent = (focussedContent: FileContent | null) => {\n focusedContentSignal.set(focussedContent);\n };\n\n const setFocusedContentKeyPath = (keyPath: KeyPath[]) => {\n const current = focusedContentSignal();\n if (!current) return;\n setFocusedContent({ ...current, keyPath });\n };\n\n instance = {\n focusedContent: focusedContentSignal.asReadonly(),\n setFocusedContent,\n setFocusedContentKeyPath,\n } as FocusDictionaryClient;\n\n return instance;\n};\n\n/**\n * Helper to install the focus dictionary into the injector\n */\nexport const installFocusDictionary = (_injector: Injector) => {\n const _client = createFocusDictionaryClient();\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createFocusDictionaryClient\n};\n\n/** consumer */\nexport const useFocusDictionary = createSharedComposable(() => {\n const client = createFocusDictionaryClient();\n const [focusedContent, setFocusedContent] =\n useCrossFrameState<FileContent | null>(\n MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED\n );\n\n if (!client) {\n throw new Error('FocusDictionary state not found');\n }\n\n // Use Angular effects instead of Vue watchers\n // Watch local (client) and update cross-frame\n effect(() => {\n const newValue = client.focusedContent();\n if (JSON.stringify(newValue) !== JSON.stringify(focusedContent())) {\n setFocusedContent(newValue);\n }\n });\n\n // Watch cross-frame and update local\n effect(() => {\n const newValue = focusedContent();\n if (JSON.stringify(newValue) !== JSON.stringify(client.focusedContent())) {\n client.setFocusedContent(newValue ?? null);\n }\n });\n\n return client;\n});\n"],"mappings":";;;;;;;;;;;AAqBA,IAAI,WAAyC;;;;AAK7C,MAAa,oCAAoC;AAC/C,KAAI,SAAU,QAAO;CAErB,MAAM,iDAAkD,KAAK;CAE7D,MAAM,qBAAqB,oBAAwC;AACjE,uBAAqB,IAAI,gBAAgB;;CAG3C,MAAM,4BAA4B,YAAuB;EACvD,MAAM,UAAU,sBAAsB;AACtC,MAAI,CAAC,QAAS;AACd,oBAAkB;GAAE,GAAG;GAAS;GAAS,CAAC;;AAG5C,YAAW;EACT,gBAAgB,qBAAqB,YAAY;EACjD;EACA;EACD;AAED,QAAO;;;;;AAMT,MAAa,0BAA0B,cAAwB;AAC7C,8BAA6B;;;AAO/C,MAAa,qBAAqBA,mEAA6B;CAC7D,MAAM,SAAS,6BAA6B;CAC5C,MAAM,CAAC,gBAAgB,qBACrBC,qDACEC,4BAAW,iCACZ;AAEH,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,kCAAkC;AAKpD,iCAAa;EACX,MAAM,WAAW,OAAO,gBAAgB;AACxC,MAAI,KAAK,UAAU,SAAS,KAAK,KAAK,UAAU,gBAAgB,CAAC,CAC/D,mBAAkB,SAAS;GAE7B;AAGF,iCAAa;EACX,MAAM,WAAW,gBAAgB;AACjC,MAAI,KAAK,UAAU,SAAS,KAAK,KAAK,UAAU,OAAO,gBAAgB,CAAC,CACtE,QAAO,kBAAkB,YAAY,KAAK;GAE5C;AAEF,QAAO;EACP"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
1
2
|
const require_editor_ContentSelectorWrapper_component = require('./ContentSelectorWrapper.component.cjs');
|
|
2
3
|
const require_editor_EditedContentRenderer_component = require('./EditedContentRenderer.component.cjs');
|
|
3
4
|
const require_editor_EditorSelectorRenderer_component = require('./EditorSelectorRenderer.component.cjs');
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
3
|
const require_editor_communicator = require('./communicator.cjs');
|
|
3
4
|
const require_editor_editorEnabled = require('./editorEnabled.cjs');
|
|
4
5
|
const require_editor_focusDictionary = require('./focusDictionary.cjs');
|
|
5
6
|
const require_editor_dictionariesRecord = require('./dictionariesRecord.cjs');
|
|
6
7
|
const require_editor_editedContent = require('./editedContent.cjs');
|
|
7
8
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
8
|
-
_intlayer_config_built =
|
|
9
|
+
_intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
|
|
9
10
|
|
|
10
11
|
//#region src/editor/installIntlayerEditor.ts
|
|
11
12
|
const { editor } = _intlayer_config_built.default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installIntlayerEditor.cjs","names":["configuration"],"sources":["../../../src/editor/installIntlayerEditor.ts"],"sourcesContent":["import type { Injector } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport { installCommunicator } from './communicator';\nimport { installDictionariesRecord } from './dictionariesRecord';\nimport { installEditedContent } from './editedContent';\nimport { installEditorEnabled } from './editorEnabled';\nimport { installFocusDictionary } from './focusDictionary';\n\nconst { editor } = configuration;\nconst { applicationURL, editorURL, cmsURL } = editor ?? {};\n\nconst postMessage = (data: any) => {\n if (typeof window === 'undefined') return;\n\n const isInIframe = window.self !== window.top;\n\n if (!isInIframe) return;\n\n if (editor.applicationURL.length > 0) {\n window.postMessage(data, editor.applicationURL);\n }\n\n if (editor.editorURL.length > 0) {\n window.parent.postMessage(data, editor.editorURL);\n }\n\n if (editor.cmsURL.length > 0) {\n window.parent.postMessage(data, editor.cmsURL);\n }\n};\n\n/**\n * Angular-side replacement for the former <IntlayerEditorProvider> React component.\n *\n * Call **once** in your Angular application's bootstrap function or main module:\n *\n * ```typescript\n * import { bootstrapApplication } from '@angular/platform-browser';\n * import { AppComponent } from './app/app.component';\n * import { installIntlayerEditor } from 'angular-intlayer';\n *\n * bootstrapApplication(AppComponent).then(appRef => {\n * installIntlayerEditor(appRef.injector);\n * });\n * ```\n */\nexport const installIntlayerEditor = (injector: Injector): void => {\n /* ---------------------------------------------------------------------\n * 1. Base providers – always on\n * -------------------------------------------------------------------*/\n\n installCommunicator(injector, {\n postMessage,\n allowedOrigins: [applicationURL, editorURL, cmsURL] as string[],\n });\n installEditorEnabled(injector);\n installDictionariesRecord(injector);\n installEditedContent(injector);\n installFocusDictionary(injector);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"installIntlayerEditor.cjs","names":["configuration"],"sources":["../../../src/editor/installIntlayerEditor.ts"],"sourcesContent":["import type { Injector } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport { installCommunicator } from './communicator';\nimport { installDictionariesRecord } from './dictionariesRecord';\nimport { installEditedContent } from './editedContent';\nimport { installEditorEnabled } from './editorEnabled';\nimport { installFocusDictionary } from './focusDictionary';\n\nconst { editor } = configuration;\nconst { applicationURL, editorURL, cmsURL } = editor ?? {};\n\nconst postMessage = (data: any) => {\n if (typeof window === 'undefined') return;\n\n const isInIframe = window.self !== window.top;\n\n if (!isInIframe) return;\n\n if (editor.applicationURL.length > 0) {\n window.postMessage(data, editor.applicationURL);\n }\n\n if (editor.editorURL.length > 0) {\n window.parent.postMessage(data, editor.editorURL);\n }\n\n if (editor.cmsURL.length > 0) {\n window.parent.postMessage(data, editor.cmsURL);\n }\n};\n\n/**\n * Angular-side replacement for the former <IntlayerEditorProvider> React component.\n *\n * Call **once** in your Angular application's bootstrap function or main module:\n *\n * ```typescript\n * import { bootstrapApplication } from '@angular/platform-browser';\n * import { AppComponent } from './app/app.component';\n * import { installIntlayerEditor } from 'angular-intlayer';\n *\n * bootstrapApplication(AppComponent).then(appRef => {\n * installIntlayerEditor(appRef.injector);\n * });\n * ```\n */\nexport const installIntlayerEditor = (injector: Injector): void => {\n /* ---------------------------------------------------------------------\n * 1. Base providers – always on\n * -------------------------------------------------------------------*/\n\n installCommunicator(injector, {\n postMessage,\n allowedOrigins: [applicationURL, editorURL, cmsURL] as string[],\n });\n installEditorEnabled(injector);\n installDictionariesRecord(injector);\n installEditedContent(injector);\n installFocusDictionary(injector);\n};\n"],"mappings":";;;;;;;;;;;AAQA,MAAM,EAAE,WAAWA;AACnB,MAAM,EAAE,gBAAgB,WAAW,WAAW,UAAU,EAAE;AAE1D,MAAM,eAAe,SAAc;AACjC,KAAI,OAAO,WAAW,YAAa;AAInC,KAAI,EAFe,OAAO,SAAS,OAAO,KAEzB;AAEjB,KAAI,OAAO,eAAe,SAAS,EACjC,QAAO,YAAY,MAAM,OAAO,eAAe;AAGjD,KAAI,OAAO,UAAU,SAAS,EAC5B,QAAO,OAAO,YAAY,MAAM,OAAO,UAAU;AAGnD,KAAI,OAAO,OAAO,SAAS,EACzB,QAAO,OAAO,YAAY,MAAM,OAAO,OAAO;;;;;;;;;;;;;;;;;AAmBlD,MAAa,yBAAyB,aAA6B;AAKjE,iDAAoB,UAAU;EAC5B;EACA,gBAAgB;GAAC;GAAgB;GAAW;GAAO;EACpD,CAAC;AACF,mDAAqB,SAAS;AAC9B,6DAA0B,SAAS;AACnC,mDAAqB,SAAS;AAC9B,uDAAuB,SAAS"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
4
5
|
const require_editor_communicator = require('./communicator.cjs');
|
|
5
6
|
let _angular_core = require("@angular/core");
|
|
6
7
|
let _intlayer_editor = require("@intlayer/editor");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCrossFrameMessageListener.cjs","names":["useCommunicator","DestroyRef"],"sources":["../../../src/editor/useCrossFrameMessageListener.ts"],"sourcesContent":["'use client';\n\nimport { DestroyRef, inject } from '@angular/core';\nimport { compareUrls, type MessageKey } from '@intlayer/editor';\nimport { useCommunicator } from './communicator';\n\n// ---------- module-level singletons ----------\ntype AnyFn = (data: unknown) => void;\n\n/** Map<key, Set<callback>> */\nconst subscribers = new Map<string, Set<AnyFn>>();\n\n/** True once we've attached the single window listener */\nlet windowListenerAttached = false;\n\n/** Helper to add/remove a callback for a key */\nconst addSubscriber = (key: string, cb: AnyFn) => {\n let set = subscribers.get(key);\n if (!set) {\n set = new Set();\n subscribers.set(key, set);\n }\n set.add(cb);\n};\n\nconst removeSubscriber = (key: string, cb: AnyFn) => {\n const set = subscribers.get(key);\n if (!set) return;\n set.delete(cb);\n if (set.size === 0) subscribers.delete(key);\n};\n\n/** The one global window listener */\nconst ensureGlobalListener = (\n allowedOrigins: string[] | undefined,\n selfId: string\n) => {\n if (windowListenerAttached) return;\n window.addEventListener('message', (event) => {\n const { type, data, senderId } = event.data ?? {};\n if (!type) return; // guard malformed messages\n if (senderId === selfId) return; // ignore my own\n\n // origin check\n if (\n !allowedOrigins ||\n allowedOrigins.includes('*') ||\n allowedOrigins.some((o) => compareUrls(o, event.origin))\n ) {\n // broadcast to everyone interested in this key\n subscribers.get(type)?.forEach((cb) => {\n cb(data);\n });\n }\n });\n windowListenerAttached = true;\n};\n// ---------- end module-level code ----------\n\n/**\n * useCrossFrameMessageListener\n *\n * @template S - type of the message payload\n * @param key message type we care about\n * @param onEventTriggered optional callback when a matching message arrives\n * @returns postMessage(data?) helper scoped to this key\n */\nexport const useCrossFrameMessageListener = <S>(\n key: `${MessageKey}` | `${MessageKey}/post` | `${MessageKey}/get`,\n onEventTriggered?: (data: S) => void\n) => {\n // Communicator is the same for everyone, so it's fine to call every time.\n const { allowedOrigins, postMessage, senderId } = useCommunicator();\n\n // --- 1. make sure the global listener exists ----\n ensureGlobalListener(allowedOrigins, senderId);\n\n // --- 2. register this caller's callback (if any) ---\n if (onEventTriggered) {\n addSubscriber(key, onEventTriggered as AnyFn);\n\n // Use Angular's DestroyRef for cleanup instead of Vue's onScopeDispose\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n if (destroyRef) {\n destroyRef.onDestroy(() =>\n removeSubscriber(key, onEventTriggered as AnyFn)\n );\n }\n } catch {\n // If called outside injection context, no cleanup available\n console.warn(\n 'useCrossFrameMessageListener called outside injection context; ' +\n 'cleanup may not be available.'\n );\n }\n }\n\n // --- 3. return a wrapper that tags outgoing messages with our key ---\n const postMessageWrapper = (data?: S) => {\n postMessage({ type: key, data, senderId });\n };\n\n return postMessageWrapper;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCrossFrameMessageListener.cjs","names":["useCommunicator","DestroyRef"],"sources":["../../../src/editor/useCrossFrameMessageListener.ts"],"sourcesContent":["'use client';\n\nimport { DestroyRef, inject } from '@angular/core';\nimport { compareUrls, type MessageKey } from '@intlayer/editor';\nimport { useCommunicator } from './communicator';\n\n// ---------- module-level singletons ----------\ntype AnyFn = (data: unknown) => void;\n\n/** Map<key, Set<callback>> */\nconst subscribers = new Map<string, Set<AnyFn>>();\n\n/** True once we've attached the single window listener */\nlet windowListenerAttached = false;\n\n/** Helper to add/remove a callback for a key */\nconst addSubscriber = (key: string, cb: AnyFn) => {\n let set = subscribers.get(key);\n if (!set) {\n set = new Set();\n subscribers.set(key, set);\n }\n set.add(cb);\n};\n\nconst removeSubscriber = (key: string, cb: AnyFn) => {\n const set = subscribers.get(key);\n if (!set) return;\n set.delete(cb);\n if (set.size === 0) subscribers.delete(key);\n};\n\n/** The one global window listener */\nconst ensureGlobalListener = (\n allowedOrigins: string[] | undefined,\n selfId: string\n) => {\n if (windowListenerAttached) return;\n window.addEventListener('message', (event) => {\n const { type, data, senderId } = event.data ?? {};\n if (!type) return; // guard malformed messages\n if (senderId === selfId) return; // ignore my own\n\n // origin check\n if (\n !allowedOrigins ||\n allowedOrigins.includes('*') ||\n allowedOrigins.some((o) => compareUrls(o, event.origin))\n ) {\n // broadcast to everyone interested in this key\n subscribers.get(type)?.forEach((cb) => {\n cb(data);\n });\n }\n });\n windowListenerAttached = true;\n};\n// ---------- end module-level code ----------\n\n/**\n * useCrossFrameMessageListener\n *\n * @template S - type of the message payload\n * @param key message type we care about\n * @param onEventTriggered optional callback when a matching message arrives\n * @returns postMessage(data?) helper scoped to this key\n */\nexport const useCrossFrameMessageListener = <S>(\n key: `${MessageKey}` | `${MessageKey}/post` | `${MessageKey}/get`,\n onEventTriggered?: (data: S) => void\n) => {\n // Communicator is the same for everyone, so it's fine to call every time.\n const { allowedOrigins, postMessage, senderId } = useCommunicator();\n\n // --- 1. make sure the global listener exists ----\n ensureGlobalListener(allowedOrigins, senderId);\n\n // --- 2. register this caller's callback (if any) ---\n if (onEventTriggered) {\n addSubscriber(key, onEventTriggered as AnyFn);\n\n // Use Angular's DestroyRef for cleanup instead of Vue's onScopeDispose\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n if (destroyRef) {\n destroyRef.onDestroy(() =>\n removeSubscriber(key, onEventTriggered as AnyFn)\n );\n }\n } catch {\n // If called outside injection context, no cleanup available\n console.warn(\n 'useCrossFrameMessageListener called outside injection context; ' +\n 'cleanup may not be available.'\n );\n }\n }\n\n // --- 3. return a wrapper that tags outgoing messages with our key ---\n const postMessageWrapper = (data?: S) => {\n postMessage({ type: key, data, senderId });\n };\n\n return postMessageWrapper;\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAM,8BAAc,IAAI,KAAyB;;AAGjD,IAAI,yBAAyB;;AAG7B,MAAM,iBAAiB,KAAa,OAAc;CAChD,IAAI,MAAM,YAAY,IAAI,IAAI;AAC9B,KAAI,CAAC,KAAK;AACR,wBAAM,IAAI,KAAK;AACf,cAAY,IAAI,KAAK,IAAI;;AAE3B,KAAI,IAAI,GAAG;;AAGb,MAAM,oBAAoB,KAAa,OAAc;CACnD,MAAM,MAAM,YAAY,IAAI,IAAI;AAChC,KAAI,CAAC,IAAK;AACV,KAAI,OAAO,GAAG;AACd,KAAI,IAAI,SAAS,EAAG,aAAY,OAAO,IAAI;;;AAI7C,MAAM,wBACJ,gBACA,WACG;AACH,KAAI,uBAAwB;AAC5B,QAAO,iBAAiB,YAAY,UAAU;EAC5C,MAAM,EAAE,MAAM,MAAM,aAAa,MAAM,QAAQ,EAAE;AACjD,MAAI,CAAC,KAAM;AACX,MAAI,aAAa,OAAQ;AAGzB,MACE,CAAC,kBACD,eAAe,SAAS,IAAI,IAC5B,eAAe,MAAM,wCAAkB,GAAG,MAAM,OAAO,CAAC,CAGxD,aAAY,IAAI,KAAK,EAAE,SAAS,OAAO;AACrC,MAAG,KAAK;IACR;GAEJ;AACF,0BAAyB;;;;;;;;;;AAY3B,MAAa,gCACX,KACA,qBACG;CAEH,MAAM,EAAE,gBAAgB,aAAa,aAAaA,6CAAiB;AAGnE,sBAAqB,gBAAgB,SAAS;AAG9C,KAAI,kBAAkB;AACpB,gBAAc,KAAK,iBAA0B;AAG7C,MAAI;GACF,MAAM,uCAAoBC,0BAAY,EAAE,UAAU,MAAM,CAAC;AACzD,OAAI,WACF,YAAW,gBACT,iBAAiB,KAAK,iBAA0B,CACjD;UAEG;AAEN,WAAQ,KACN,+FAED;;;CAKL,MAAM,sBAAsB,SAAa;AACvC,cAAY;GAAE,MAAM;GAAK;GAAM;GAAU,CAAC;;AAG5C,QAAO"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
3
|
const require_editor_communicator = require('./communicator.cjs');
|
|
3
4
|
const require_editor_useCrossFrameMessageListener = require('./useCrossFrameMessageListener.cjs');
|
|
4
5
|
let _angular_core = require("@angular/core");
|
|
@@ -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":";;;;;;;AAYA,MAAM,uCAAuB,IAAI,KAO9B;;;;AAKH,MAAM,gBACJ,OACA,cACkB;AAClB,KAAI,OAAO,UAAU,WACnB,QAAQ,MAA0B,UAAU;AAE9C,QAAO;;;;;;AAOT,MAAM,kBAAqB,QAAc;AACvC,KAAI,QAAQ,QAAQ,QAAQ,OAAW,QAAO;AAE9C,QAAO,KAAK,MAAM,KAAK,UAAU,IAAI,CAAC;;;;;;;;;;;;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AAU"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
3
|
const require_editor_useCrossFrameState = require('./useCrossFrameState.cjs');
|
|
3
4
|
let _angular_core = require("@angular/core");
|
|
4
5
|
let _intlayer_editor = require("@intlayer/editor");
|
|
@@ -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":";;;;;;;;;;;;;AAUA,MAAa,wBACX,SACA,SACGA,qDAA2BC,4BAAW,qBAAqB,SAAS,KAAK;;;;;;;AAQ9E,MAAa,yBAAyB,YAAqB;CACzD,MAAM,CAAC,OAAO,YAAY,qBAAqB,SAAS;EACtD,MAAM;EACN,SAAS;EACV,CAAC;CAGF,IAAI;CACJ,IAAI;CAGJ,MAAM,eAAe,SAAS,OAAO,SAAS,SAAS;AAGvD,KAAI;EACF,MAAM,uCAAoBC,0BAAY,EAAE,UAAU,MAAM,CAAC;AAEzD,MAAI,cAAc,OAAO,WAAW,aAAa;AAE/C,uBAAoB,QAAQ;AAC5B,0BAAuB,QAAQ;;;;;;GAO/B,MAAM,QACH,QACA,GAAG,SAA+C;AACjD,OAAG,MAAM,SAAS,KAAK;AACvB,WAAO,cAAc,IAAI,MAAM,iBAAiB,CAAC;;AAIrD,WAAQ,YAAY,KAAK,kBAAkB;AAC3C,WAAQ,eAAe,KAAK,qBAAqB;AAGjD,UAAO,iBAAiB,kBAAkB,OAAO;AACjD,UAAO,iBAAiB,YAAY,OAAO;AAC3C,UAAO,iBAAiB,cAAc,OAAO;AAG7C,WAAQ;AAGR,cAAW,gBAAgB;AACzB,WAAO,oBAAoB,kBAAkB,OAAO;AACpD,WAAO,oBAAoB,YAAY,OAAO;AAC9C,WAAO,oBAAoB,cAAc,OAAO;AAGhD,QAAI,kBAAmB,SAAQ,YAAY;AAC3C,QAAI,qBAAsB,SAAQ,eAAe;KACjD;;SAEE;AACN,UAAQ,KACN,yGAED;;AAGH,QAAO,CAAC,OAAO,SAAS"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_decorate = require('../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.cjs');
|
|
3
4
|
let _angular_core = require("@angular/core");
|
|
4
5
|
|
|
5
6
|
//#region src/editor/useEditedContentRenderer.ts
|
|
@@ -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":";;;;;;AAaA,MAAa,+BACX,IAAIA,6BAA4C,uBAAuB;AAKlE,yCAAM,6BAA6B;;;;CAIxC,yBACE,eACA,SACA,UACiB;EACjB,MAAM,iDAA8B,8BAA8B,EAChE,UAAU,MACX,CAAC;AAEF,2CAAsB;AAMpB,UALe,sBAAsB,sBACnC,eACA,QACD,IAEgB;IACjB;;;0FAvBM,EACV,YAAY,QACb,CAAC;;;;AA4BF,MAAa,4BACX,eACA,SACA,aACoB;AAEpB,kCADuB,6BAA6B,CACrC,yBAAyB,eAAe,SAAS,SAAS"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
1
2
|
const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
|
|
2
3
|
const require_editor_editorEnabled = require('./editorEnabled.cjs');
|
|
3
4
|
const require_editor_focusDictionary = require('./focusDictionary.cjs');
|
|
@@ -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":";;;;;;;;;;;AASA,MAAa,YAAYA,mEAA6B;AACpD,gDAAkB;AAClB,gDAAkB;AAClB,oDAAoB;AACpB,gEAAsB;AACtB,4DAAuB;AACvB,8CAAiB;AACjB,0DAAuB;AACvB,8CAAiB;EACjB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
3
|
const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
|
|
3
4
|
const require_editor_useCrossFrameMessageListener = require('./useCrossFrameMessageListener.cjs');
|
|
4
5
|
let _angular_core = require("@angular/core");
|
|
@@ -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":";;;;;;;;;;;;AAaA,MAAa,4BAA4BA,mEAA6B;CACpE,MAAM,cAAcC,yEAClBC,4BAAW,wBACZ;CAED,MAAM,gBAAgB;AACpB,eAAa;;AAIf,KAAI;EACF,MAAM,uCAAoBC,0BAAY,EAAE,UAAU,MAAM,CAAC;AAEzD,MAAI,cAAc,OAAO,WAAW,aAAa;AAE/C,UAAO,iBAAiB,aAAa,QAAQ;AAG7C,cAAW,gBACT,OAAO,oBAAoB,aAAa,QAAQ,CACjD;;SAEG;AACN,UAAQ,KACN,yGAED;;EAEH;;;;;AAMF,MAAa,uBAAuBH,mEAA6B;AAC/D,4BAA2B;AAE3B,0EACEE,4BAAW,yBACXE,kCACD;EACD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
3
|
const require_plugins = require('./plugins.cjs');
|
|
3
4
|
let _intlayer_core = require("@intlayer/core");
|
|
4
5
|
|
|
@@ -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';\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":";;;;;;AAWA,MAAa,iBAIX,YACA,QACA,sBACG;AAQH,0CAA+B,YAAY,QAPhB;EACzBA;EACAC;EACAC;EACA,GAAI,qBAAqB,EAAE;EAC5B,CAE0D"}
|
package/dist/cjs/getIntlayer.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
3
|
const require_plugins = require('./plugins.cjs');
|
|
3
4
|
let _intlayer_core = require("@intlayer/core");
|
|
4
5
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIntlayer.cjs","names":["intlayerNodePlugins","markdownPlugin","htmlPlugin","insertionPlugin"],"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import { getIntlayer as getIntlayerCore, type Plugins } from '@intlayer/core';\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":"
|
|
1
|
+
{"version":3,"file":"getIntlayer.cjs","names":["intlayerNodePlugins","markdownPlugin","htmlPlugin","insertionPlugin"],"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import { getIntlayer as getIntlayerCore, type Plugins } from '@intlayer/core';\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":";;;;;;AAeA,MAAa,eAIX,KACA,QACA,sBACG;AAUH,wCAA6B,KAAK,QATP;EACzBA;EACAC;EACAC;EACAC;EACA,GAAI,qBAAqB,EAAE;EAC5B,CAGiD"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
1
2
|
const require_client_installIntlayer = require('./client/installIntlayer.cjs');
|
|
2
3
|
const require_client_useDictionary = require('./client/useDictionary.cjs');
|
|
3
4
|
const require_client_useDictionaryAsync = require('./client/useDictionaryAsync.cjs');
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_decorate = require('../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.cjs');
|
|
3
4
|
let _intlayer_core = require("@intlayer/core");
|
|
4
5
|
let _angular_core = require("@angular/core");
|
|
5
6
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installIntlayerMarkdown.cjs","names":["InjectionToken"],"sources":["../../../src/markdown/installIntlayerMarkdown.ts"],"sourcesContent":["import {\n Injectable,\n InjectionToken,\n inject,\n type TemplateRef,\n} from '@angular/core';\nimport { compile, type MarkdownRuntime } from '@intlayer/core';\n\nexport const INTLAYER_MARKDOWN_TOKEN =\n new InjectionToken<IntlayerMarkdownProvider>('intlayerMarkdown');\n\ntype RenderMarkdownOptions = {\n components?: any;\n wrapper?: any;\n options?: any;\n};\n\ntype RenderMarkdownFunction = (\n markdown: string,\n overrides?: any | RenderMarkdownOptions\n) => string | TemplateRef<any>;\n\nexport type IntlayerMarkdownProvider = {\n renderMarkdown: RenderMarkdownFunction;\n};\n\n// Minimal runtime to generate HTML strings\nexport const htmlRuntime: MarkdownRuntime = {\n createElement: (tag: string | any, props: any, ...children: any[]) => {\n if (typeof tag !== 'string') {\n // Handle non-string tags if necessary (e.g. components), or fallback to div\n if (tag === htmlRuntime.Fragment) {\n return children.join('');\n }\n return '';\n }\n\n const attrs = props\n ? Object.entries(props)\n .map(([k, v]) => {\n if (k === 'key' || v === undefined || v === null) return '';\n const key = k === 'className' ? 'class' : k;\n return `${key}=\"${String(v).replace(/\"/g, '"')}\"`;\n })\n .filter(Boolean)\n .join(' ')\n : '';\n\n const childrenStr = children.join('');\n const voidTags = [\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n ];\n\n if (voidTags.includes(tag)) {\n return `<${tag} ${attrs} />`;\n }\n\n return `<${tag}${attrs ? ` ${attrs}` : ''}>${childrenStr}</${tag}>`;\n },\n cloneElement: (element: any, _props: any) => element, // Not really supported for strings\n Fragment: Symbol('Fragment'),\n};\n\n/**\n * Default markdown renderer that converts markdown to HTML string\n */\nconst defaultMarkdownRenderer: RenderMarkdownFunction = (markdown: string) =>\n compile(markdown, { runtime: htmlRuntime }) as string;\n\n/**\n * Create IntlayerMarkdown provider configuration\n */\nexport const createIntlayerMarkdownProvider = (\n renderMarkdown: RenderMarkdownFunction = defaultMarkdownRenderer\n) => ({\n provide: INTLAYER_MARKDOWN_TOKEN,\n useValue: {\n renderMarkdown,\n } as IntlayerMarkdownProvider,\n});\n\n/**\n * Injectable service for markdown rendering\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerMarkdownService {\n private markdownProvider = inject(INTLAYER_MARKDOWN_TOKEN, {\n optional: true,\n });\n\n renderMarkdown(markdown: string, overrides?: any): string | TemplateRef<any> {\n if (!this.markdownProvider) {\n return markdown; // Fallback to returning markdown as is\n }\n return this.markdownProvider.renderMarkdown(markdown, overrides);\n }\n}\n\n/**\n * Function to inject markdown provider\n */\nexport const useMarkdown = (): IntlayerMarkdownProvider => {\n const markdownProvider = inject(INTLAYER_MARKDOWN_TOKEN, { optional: true });\n\n if (!markdownProvider) {\n return {\n renderMarkdown: defaultMarkdownRenderer,\n };\n }\n\n return markdownProvider;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"installIntlayerMarkdown.cjs","names":["InjectionToken"],"sources":["../../../src/markdown/installIntlayerMarkdown.ts"],"sourcesContent":["import {\n Injectable,\n InjectionToken,\n inject,\n type TemplateRef,\n} from '@angular/core';\nimport { compile, type MarkdownRuntime } from '@intlayer/core';\n\nexport const INTLAYER_MARKDOWN_TOKEN =\n new InjectionToken<IntlayerMarkdownProvider>('intlayerMarkdown');\n\ntype RenderMarkdownOptions = {\n components?: any;\n wrapper?: any;\n options?: any;\n};\n\ntype RenderMarkdownFunction = (\n markdown: string,\n overrides?: any | RenderMarkdownOptions\n) => string | TemplateRef<any>;\n\nexport type IntlayerMarkdownProvider = {\n renderMarkdown: RenderMarkdownFunction;\n};\n\n// Minimal runtime to generate HTML strings\nexport const htmlRuntime: MarkdownRuntime = {\n createElement: (tag: string | any, props: any, ...children: any[]) => {\n if (typeof tag !== 'string') {\n // Handle non-string tags if necessary (e.g. components), or fallback to div\n if (tag === htmlRuntime.Fragment) {\n return children.join('');\n }\n return '';\n }\n\n const attrs = props\n ? Object.entries(props)\n .map(([k, v]) => {\n if (k === 'key' || v === undefined || v === null) return '';\n const key = k === 'className' ? 'class' : k;\n return `${key}=\"${String(v).replace(/\"/g, '"')}\"`;\n })\n .filter(Boolean)\n .join(' ')\n : '';\n\n const childrenStr = children.join('');\n const voidTags = [\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n ];\n\n if (voidTags.includes(tag)) {\n return `<${tag} ${attrs} />`;\n }\n\n return `<${tag}${attrs ? ` ${attrs}` : ''}>${childrenStr}</${tag}>`;\n },\n cloneElement: (element: any, _props: any) => element, // Not really supported for strings\n Fragment: Symbol('Fragment'),\n};\n\n/**\n * Default markdown renderer that converts markdown to HTML string\n */\nconst defaultMarkdownRenderer: RenderMarkdownFunction = (markdown: string) =>\n compile(markdown, { runtime: htmlRuntime }) as string;\n\n/**\n * Create IntlayerMarkdown provider configuration\n */\nexport const createIntlayerMarkdownProvider = (\n renderMarkdown: RenderMarkdownFunction = defaultMarkdownRenderer\n) => ({\n provide: INTLAYER_MARKDOWN_TOKEN,\n useValue: {\n renderMarkdown,\n } as IntlayerMarkdownProvider,\n});\n\n/**\n * Injectable service for markdown rendering\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerMarkdownService {\n private markdownProvider = inject(INTLAYER_MARKDOWN_TOKEN, {\n optional: true,\n });\n\n renderMarkdown(markdown: string, overrides?: any): string | TemplateRef<any> {\n if (!this.markdownProvider) {\n return markdown; // Fallback to returning markdown as is\n }\n return this.markdownProvider.renderMarkdown(markdown, overrides);\n }\n}\n\n/**\n * Function to inject markdown provider\n */\nexport const useMarkdown = (): IntlayerMarkdownProvider => {\n const markdownProvider = inject(INTLAYER_MARKDOWN_TOKEN, { optional: true });\n\n if (!markdownProvider) {\n return {\n renderMarkdown: defaultMarkdownRenderer,\n };\n }\n\n return markdownProvider;\n};\n"],"mappings":";;;;;;;AAQA,MAAa,0BACX,IAAIA,6BAAyC,mBAAmB;AAkBlE,MAAa,cAA+B;CAC1C,gBAAgB,KAAmB,OAAY,GAAG,aAAoB;AACpE,MAAI,OAAO,QAAQ,UAAU;AAE3B,OAAI,QAAQ,YAAY,SACtB,QAAO,SAAS,KAAK,GAAG;AAE1B,UAAO;;EAGT,MAAM,QAAQ,QACV,OAAO,QAAQ,MAAM,CAClB,KAAK,CAAC,GAAG,OAAO;AACf,OAAI,MAAM,SAAS,MAAM,UAAa,MAAM,KAAM,QAAO;AAEzD,UAAO,GADK,MAAM,cAAc,UAAU,EAC5B,IAAI,OAAO,EAAE,CAAC,QAAQ,MAAM,SAAS,CAAC;IACpD,CACD,OAAO,QAAQ,CACf,KAAK,IAAI,GACZ;EAEJ,MAAM,cAAc,SAAS,KAAK,GAAG;AAkBrC,MAjBiB;GACf;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAEY,SAAS,IAAI,CACxB,QAAO,IAAI,IAAI,GAAG,MAAM;AAG1B,SAAO,IAAI,MAAM,QAAQ,IAAI,UAAU,GAAG,GAAG,YAAY,IAAI,IAAI;;CAEnE,eAAe,SAAc,WAAgB;CAC7C,UAAU,OAAO,WAAW;CAC7B;;;;AAKD,MAAM,2BAAmD,yCAC/C,UAAU,EAAE,SAAS,aAAa,CAAC;;;;AAK7C,MAAa,kCACX,iBAAyC,6BACrC;CACJ,SAAS;CACT,UAAU,EACR,gBACD;CACF;AAQM,oCAAM,wBAAwB;CACnC,AAAQ,6CAA0B,yBAAyB,EACzD,UAAU,MACX,CAAC;CAEF,eAAe,UAAkB,WAA4C;AAC3E,MAAI,CAAC,KAAK,iBACR,QAAO;AAET,SAAO,KAAK,iBAAiB,eAAe,UAAU,UAAU;;;qFAZxD,EACV,YAAY,QACb,CAAC;;;;AAiBF,MAAa,oBAA8C;CACzD,MAAM,6CAA0B,yBAAyB,EAAE,UAAU,MAAM,CAAC;AAE5E,KAAI,CAAC,iBACH,QAAO,EACL,gBAAgB,yBACjB;AAGH,QAAO"}
|
package/dist/cjs/plugins.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
3
|
const require_editor_ContentSelectorWrapper_component = require('./editor/ContentSelectorWrapper.component.cjs');
|
|
3
4
|
const require_markdown_installIntlayerMarkdown = require('./markdown/installIntlayerMarkdown.cjs');
|
|
4
5
|
const require_renderIntlayerNode = require('./renderIntlayerNode.cjs');
|
|
@@ -66,7 +67,7 @@ const markdownStringPlugin = {
|
|
|
66
67
|
keyPath: []
|
|
67
68
|
});
|
|
68
69
|
const render = (components) => require_renderIntlayerNode.renderIntlayerNode({
|
|
69
|
-
...
|
|
70
|
+
...rest,
|
|
70
71
|
value: node,
|
|
71
72
|
children: () => ({
|
|
72
73
|
component: require_editor_ContentSelectorWrapper_component.ContentSelectorWrapperComponent,
|
package/dist/cjs/plugins.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","ContentSelectorWrapperComponent","useMarkdown","htmlRuntime","NodeType"],"sources":["../../src/plugins.ts"],"sourcesContent":["import {\n compile,\n type DeepTransformContent as DeepTransformContentCore,\n getMarkdownMetadata,\n type HTMLContent,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type InsertionContent,\n type MarkdownContent,\n type Plugins,\n} from '@intlayer/core';\nimport {\n type DeclaredLocales,\n type KeyPath,\n type LocalesValues,\n NodeType,\n} from '@intlayer/types';\nimport { ContentSelectorWrapperComponent } from './editor';\nimport { htmlRuntime, useMarkdown } from './markdown/installIntlayerMarkdown';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\n/** ---------------------------------------------\n * UTILS\n * --------------------------------------------- */\n\nconst createRuntimeWithOverides = (baseRuntime: any, overrides: any) => ({\n ...baseRuntime,\n createElement: (tag: string, props: any, ...children: any[]) => {\n const override = overrides?.[tag];\n\n if (override) {\n const newProps = { ...props, ...override };\n\n // Merge class attributes intelligently\n const originalClass = props?.class || props?.className;\n const overrideClass = override.class || override.className;\n\n if (originalClass && overrideClass) {\n newProps.class = `${originalClass} ${overrideClass}`;\n newProps.className = undefined;\n }\n\n return baseRuntime.createElement(tag, newProps, ...children);\n }\n\n return baseRuntime.createElement(tag, props, ...children);\n },\n});\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport interface IntlayerNode<T, P = {}> {\n value: T;\n children?: any;\n additionalProps?: P;\n}\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (_node, { children, ...rest }) =>\n renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: node,\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...components,\n },\n children: () => {\n const { renderMarkdown } = useMarkdown();\n return renderMarkdown(node, components);\n },\n }),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'toString') {\n return () => {\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === 'use') {\n return (newComponents?: any) => {\n const mergedComponents = { ...components, ...newComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\nexport type MarkdownCond<T, _S, _L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: Record<keyof U, any>) => any;\n metadata: DeepTransformContent<V>;\n }\n >\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const children = node[NodeType.Markdown];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\n/**\n * HTML conditional type.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T, _S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: Record<keyof U, any>) => any;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => IntlayerNode. */\nexport const htmlPlugin: Plugins = {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.HTML,\n\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeType.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: any) =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...userComponents,\n },\n children: html,\n }),\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'toString') {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: any) => {\n const mergedComponents = { ...components, ...userComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\n/**\n * Insertion conditional type.\n */\nexport type InsertionPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: infer _I;\n}\n ? (args: Record<string, string | number>) => string\n : never;\n\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props) => {\n const { plugins, ...rest } = props;\n\n // Return a function that performs the interpolation\n const render = (args: Record<string, string | number> = {}) => {\n let text = node.insertion as string;\n if (args) {\n Object.entries(args).forEach(([key, value]) => {\n text = text.replace(\n new RegExp(`{{\\\\s*${key}\\\\s*}}`, 'g'),\n String(value)\n );\n });\n }\n return text;\n };\n\n return renderIntlayerNode({\n ...rest,\n value: render as any,\n children: render,\n });\n },\n};\n\nexport interface IInterpreterPluginAngular<T, S, L extends LocalesValues> {\n angularIntlayerNode: IntlayerNodeCond<T>;\n angularMarkdown: MarkdownCond<T, S, L>;\n angularHtml: HTMLPluginCond<T, S, L>;\n angularInsertion: InsertionPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `angular-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n angularIntlayerNode: true;\n angularMarkdown: true;\n angularHtml: true;\n angularInsertion: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n"],"mappings":";;;;;;;;;;;AAwBA,MAAM,6BAA6B,aAAkB,eAAoB;CACvE,GAAG;CACH,gBAAgB,KAAa,OAAY,GAAG,aAAoB;EAC9D,MAAM,WAAW,YAAY;AAE7B,MAAI,UAAU;GACZ,MAAM,WAAW;IAAE,GAAG;IAAO,GAAG;IAAU;GAG1C,MAAM,gBAAgB,OAAO,SAAS,OAAO;GAC7C,MAAM,gBAAgB,SAAS,SAAS,SAAS;AAEjD,OAAI,iBAAiB,eAAe;AAClC,aAAS,QAAQ,GAAG,cAAc,GA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","useMarkdown","htmlRuntime","NodeType"],"sources":["../../src/plugins.ts"],"sourcesContent":["import {\n compile,\n type DeepTransformContent as DeepTransformContentCore,\n getMarkdownMetadata,\n type HTMLContent,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type InsertionContent,\n type MarkdownContent,\n type Plugins,\n} from '@intlayer/core';\nimport {\n type DeclaredLocales,\n type KeyPath,\n type LocalesValues,\n NodeType,\n} from '@intlayer/types';\nimport { ContentSelectorWrapperComponent } from './editor';\nimport { htmlRuntime, useMarkdown } from './markdown/installIntlayerMarkdown';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\n/** ---------------------------------------------\n * UTILS\n * --------------------------------------------- */\n\nconst createRuntimeWithOverides = (baseRuntime: any, overrides: any) => ({\n ...baseRuntime,\n createElement: (tag: string, props: any, ...children: any[]) => {\n const override = overrides?.[tag];\n\n if (override) {\n const newProps = { ...props, ...override };\n\n // Merge class attributes intelligently\n const originalClass = props?.class || props?.className;\n const overrideClass = override.class || override.className;\n\n if (originalClass && overrideClass) {\n newProps.class = `${originalClass} ${overrideClass}`;\n newProps.className = undefined;\n }\n\n return baseRuntime.createElement(tag, newProps, ...children);\n }\n\n return baseRuntime.createElement(tag, props, ...children);\n },\n});\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport interface IntlayerNode<T, P = {}> {\n value: T;\n children?: any;\n additionalProps?: P;\n}\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (_node, { children, ...rest }) =>\n renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: node,\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...rest,\n value: node,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...components,\n },\n children: () => {\n const { renderMarkdown } = useMarkdown();\n return renderMarkdown(node, components);\n },\n }),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'toString') {\n return () => {\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === 'use') {\n return (newComponents?: any) => {\n const mergedComponents = { ...components, ...newComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\nexport type MarkdownCond<T, _S, _L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: Record<keyof U, any>) => any;\n metadata: DeepTransformContent<V>;\n }\n >\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const children = node[NodeType.Markdown];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\n/**\n * HTML conditional type.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T, _S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: Record<keyof U, any>) => any;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => IntlayerNode. */\nexport const htmlPlugin: Plugins = {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.HTML,\n\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeType.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: any) =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...userComponents,\n },\n children: html,\n }),\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'toString') {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: any) => {\n const mergedComponents = { ...components, ...userComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\n/**\n * Insertion conditional type.\n */\nexport type InsertionPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: infer _I;\n}\n ? (args: Record<string, string | number>) => string\n : never;\n\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props) => {\n const { plugins, ...rest } = props;\n\n // Return a function that performs the interpolation\n const render = (args: Record<string, string | number> = {}) => {\n let text = node.insertion as string;\n if (args) {\n Object.entries(args).forEach(([key, value]) => {\n text = text.replace(\n new RegExp(`{{\\\\s*${key}\\\\s*}}`, 'g'),\n String(value)\n );\n });\n }\n return text;\n };\n\n return renderIntlayerNode({\n ...rest,\n value: render as any,\n children: render,\n });\n },\n};\n\nexport interface IInterpreterPluginAngular<T, S, L extends LocalesValues> {\n angularIntlayerNode: IntlayerNodeCond<T>;\n angularMarkdown: MarkdownCond<T, S, L>;\n angularHtml: HTMLPluginCond<T, S, L>;\n angularInsertion: InsertionPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `angular-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n angularIntlayerNode: true;\n angularMarkdown: true;\n angularHtml: true;\n angularInsertion: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n"],"mappings":";;;;;;;;;;;;AAwBA,MAAM,6BAA6B,aAAkB,eAAoB;CACvE,GAAG;CACH,gBAAgB,KAAa,OAAY,GAAG,aAAoB;EAC9D,MAAM,WAAW,YAAY;AAE7B,MAAI,UAAU;GACZ,MAAM,WAAW;IAAE,GAAG;IAAO,GAAG;IAAU;GAG1C,MAAM,gBAAgB,OAAO,SAAS,OAAO;GAC7C,MAAM,gBAAgB,SAAS,SAAS,SAAS;AAEjD,OAAI,iBAAiB,eAAe;AAClC,aAAS,QAAQ,GAAG,cAAc,GAAG;AACrC,aAAS,YAAY;;AAGvB,UAAO,YAAY,cAAc,KAAK,UAAU,GAAG,SAAS;;AAG9D,SAAO,YAAY,cAAc,KAAK,OAAO,GAAG,SAAS;;CAE5D;;AAiBD,MAAa,sBAA+B;CAC1C,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YAAY,OAAO,EAAE,UAAU,GAAG,WAChCA,8CAAmB;EACjB,GAAG;EACH,OAAO;EACP,iBAAiB;GACf,WAAWC;GACX,OAAO;IACL,eAAe,KAAK;IACpB,SAAS,KAAK;IACf;GAC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,OAAO,KAAK;AAMrB,uCAAe,MAAM,EACnB,SALc,0BACdA,sDACA,WACD,EAGA,CAAC;;AAIN,OAAI,SAAS,MAEX,SAAQ,mBAAyB;IAC/B,MAAM,mBAAmB;KAAE,GAAG;KAAY,GAAG;KAAgB;AAC7D,WAAO,YAAY,OAAO,iBAAiB,EAAE,iBAAiB;;AAIlE,UAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;KAE7C,CAAC;AAEJ,SAAO,YAAY,QAAQ,CAAQ;;CAEtC;AAgBD,MAAa,kBAA2B;CACtC,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAaC,yBAAS;CAC1D,YAAY,MAAwB,UAAU;EAC5C,MAAM,EAAE,SAAS,GAAG,SAAS;EAG7B,MAAM,UAAU,OAAwC,EAAE,KAAK;GAC7D,IAAI,OAAO,KAAK;AAChB,OAAI,KACF,QAAO,QAAQ,KAAK,CAAC,SAAS,CAAC,KAAK,WAAW;AAC7C,WAAO,KAAK,QACV,IAAI,OAAO,SAAS,IAAI,SAAS,IAAI,EACrC,OAAO,MAAM,CACd;KACD;AAEJ,UAAO;;AAGT,SAAOJ,8CAAmB;GACxB,GAAG;GACH,OAAO;GACP,UAAU;GACX,CAAC;;CAEL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderIntlayerNode.cjs","names":[],"sources":["../../src/renderIntlayerNode.ts"],"sourcesContent":["export type IntlayerNode<T = string, AdditionalProps = {}> = any & {\n value: T;\n} & AdditionalProps;\n\ntype RenderIntlayerNodeProps<T> = {\n value: T;\n children: any;\n additionalProps?: { [key: string]: any };\n};\n\nexport const renderIntlayerNode = <\n T extends number | string | boolean | undefined | null,\n>({\n children,\n value,\n additionalProps = {},\n}: RenderIntlayerNodeProps<T>): IntlayerNode<T> => {\n // If children is null or undefined, return a simple object with the value\n if (children == null) {\n return new Proxy({} as any, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return value;\n }\n\n if (\n additionalProps &&\n Object.keys(additionalProps).includes(prop as string)\n ) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n }\n\n // Return a Proxy that pretends to be the original content\n // but also has a .value getter and additional props.\n return new Proxy(children, {\n apply(target, thisArg, argumentsList) {\n if (typeof value === 'function') {\n return Reflect.apply(value as Function, thisArg, argumentsList);\n }\n return Reflect.apply(target as Function, thisArg, argumentsList);\n },\n get(target, prop, receiver) {\n if (prop === 'value') {\n return value;\n }\n\n if (prop === 'toString') {\n return () => {\n // console.log('renderIntlayerNode toString called for:', value);\n return String(value);\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => value;\n }\n\n if (\n additionalProps &&\n Object.keys(additionalProps).includes(prop as string)\n ) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"renderIntlayerNode.cjs","names":[],"sources":["../../src/renderIntlayerNode.ts"],"sourcesContent":["export type IntlayerNode<T = string, AdditionalProps = {}> = any & {\n value: T;\n} & AdditionalProps;\n\ntype RenderIntlayerNodeProps<T> = {\n value: T;\n children: any;\n additionalProps?: { [key: string]: any };\n};\n\nexport const renderIntlayerNode = <\n T extends number | string | boolean | undefined | null,\n>({\n children,\n value,\n additionalProps = {},\n}: RenderIntlayerNodeProps<T>): IntlayerNode<T> => {\n // If children is null or undefined, return a simple object with the value\n if (children == null) {\n return new Proxy({} as any, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return value;\n }\n\n if (\n additionalProps &&\n Object.keys(additionalProps).includes(prop as string)\n ) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n }\n\n // Return a Proxy that pretends to be the original content\n // but also has a .value getter and additional props.\n return new Proxy(children, {\n apply(target, thisArg, argumentsList) {\n if (typeof value === 'function') {\n return Reflect.apply(value as Function, thisArg, argumentsList);\n }\n return Reflect.apply(target as Function, thisArg, argumentsList);\n },\n get(target, prop, receiver) {\n if (prop === 'value') {\n return value;\n }\n\n if (prop === 'toString') {\n return () => {\n // console.log('renderIntlayerNode toString called for:', value);\n return String(value);\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => value;\n }\n\n if (\n additionalProps &&\n Object.keys(additionalProps).includes(prop as string)\n ) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n};\n"],"mappings":";;;AAUA,MAAa,sBAEX,EACA,UACA,OACA,kBAAkB,EAAE,OAC6B;AAEjD,KAAI,YAAY,KACd,QAAO,IAAI,MAAM,EAAE,EAAS,EAC1B,IAAI,QAAQ,MAAM,UAAU;AAC1B,MAAI,SAAS,QACX,QAAO;AAGT,MACE,mBACA,OAAO,KAAK,gBAAgB,CAAC,SAAS,KAAe,CAErD,QAAO,gBAAgB;AAGzB,SAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;IAE7C,CAAC;AAKJ,QAAO,IAAI,MAAM,UAAU;EACzB,MAAM,QAAQ,SAAS,eAAe;AACpC,OAAI,OAAO,UAAU,WACnB,QAAO,QAAQ,MAAM,OAAmB,SAAS,cAAc;AAEjE,UAAO,QAAQ,MAAM,QAAoB,SAAS,cAAc;;EAElE,IAAI,QAAQ,MAAM,UAAU;AAC1B,OAAI,SAAS,QACX,QAAO;AAGT,OAAI,SAAS,WACX,cAAa;AAEX,WAAO,OAAO,MAAM;;AAIxB,OAAI,SAAS,OAAO,YAClB,cAAa;AAGf,OACE,mBACA,OAAO,KAAK,gBAAgB,CAAC,SAAS,KAAe,CAErD,QAAO,gBAAgB;AAGzB,UAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;;EAE7C,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
3
|
let node_path = require("node:path");
|
|
3
4
|
let _intlayer_config = require("@intlayer/config");
|
|
4
5
|
let _intlayer_webpack = require("@intlayer/webpack");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeConfig.cjs","names":["IntlayerPlugin"],"sources":["../../../src/webpack/mergeConfig.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport { getAlias, getConfiguration } from '@intlayer/config';\nimport { IntlayerPlugin } from '@intlayer/webpack'; // adjust path if needed\nimport { defu } from 'defu';\n/** @ts-ignore Configuration type exist but raise error */\nimport type { Configuration as WebpackConfig } from 'webpack';\n\nexport const mergeConfig = (baseConfig: WebpackConfig): WebpackConfig => {\n const intlayerConfig = getConfiguration();\n\n const config = {\n resolve: {\n alias: getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value), // get absolute path\n }),\n },\n externals: {\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n chokidar: 'chokidar',\n fsevents: 'fsevents',\n },\n module: {\n rules: [\n {\n test: /\\.node$/,\n loader: 'node-loader',\n },\n ],\n },\n plugins: [new IntlayerPlugin(intlayerConfig)],\n };\n\n return defu(config, baseConfig) as WebpackConfig;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"mergeConfig.cjs","names":["IntlayerPlugin"],"sources":["../../../src/webpack/mergeConfig.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport { getAlias, getConfiguration } from '@intlayer/config';\nimport { IntlayerPlugin } from '@intlayer/webpack'; // adjust path if needed\nimport { defu } from 'defu';\n/** @ts-ignore Configuration type exist but raise error */\nimport type { Configuration as WebpackConfig } from 'webpack';\n\nexport const mergeConfig = (baseConfig: WebpackConfig): WebpackConfig => {\n const intlayerConfig = getConfiguration();\n\n const config = {\n resolve: {\n alias: getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value), // get absolute path\n }),\n },\n externals: {\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n chokidar: 'chokidar',\n fsevents: 'fsevents',\n },\n module: {\n rules: [\n {\n test: /\\.node$/,\n loader: 'node-loader',\n },\n ],\n },\n plugins: [new IntlayerPlugin(intlayerConfig)],\n };\n\n return defu(config, baseConfig) as WebpackConfig;\n};\n"],"mappings":";;;;;;;;AAOA,MAAa,eAAe,eAA6C;CACvE,MAAM,yDAAmC;AA2BzC,uBAzBe;EACb,SAAS,EACP,sCAAgB;GACd,eAAe;GACf,YAAY,iCAA0B,MAAM;GAC7C,CAAC,EACH;EACD,WAAW;GACT,SAAS;GACT,QAAQ;GACR,IAAI;GACJ,UAAU;GACV,UAAU;GACX;EACD,QAAQ,EACN,OAAO,CACL;GACE,MAAM;GACN,QAAQ;GACT,CACF,EACF;EACD,SAAS,CAAC,IAAIA,iCAAe,eAAe,CAAC;EAC9C,EAEmB,WAAW"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.
|
|
2
|
-
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs";
|
|
2
|
+
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
|
|
3
3
|
import { CommonModule } from "@angular/common";
|
|
4
4
|
import { Component, EventEmitter, HostListener, Input, Output, ViewChild, computed, signal } from "@angular/core";
|
|
5
5
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region \0@oxc-project+runtime@0.
|
|
1
|
+
//#region \0@oxc-project+runtime@0.112.0/helpers/decorate.js
|
|
2
2
|
function __decorate(decorators, target, key, desc) {
|
|
3
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region \0@oxc-project+runtime@0.
|
|
1
|
+
//#region \0@oxc-project+runtime@0.112.0/helpers/decorateMetadata.js
|
|
2
2
|
function __decorateMetadata(k, v) {
|
|
3
3
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
|
|
2
2
|
import { Injectable, InjectionToken, signal } from "@angular/core";
|
|
3
3
|
import configuration from "@intlayer/config/built";
|
|
4
4
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.
|
|
2
|
-
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs";
|
|
2
|
+
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
|
|
3
3
|
import { ContentSelectorComponent } from "../UI/ContentSelector.component.mjs";
|
|
4
4
|
import { useEditorEnabled } from "./editorEnabled.mjs";
|
|
5
5
|
import { useFocusDictionary } from "./focusDictionary.mjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.
|
|
2
|
-
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs";
|
|
2
|
+
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
|
|
3
3
|
import { useEditedContentRenderer } from "./useEditedContentRenderer.mjs";
|
|
4
4
|
import { getContent } from "@intlayer/core";
|
|
5
5
|
import { CommonModule } from "@angular/common";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.
|
|
2
|
-
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs";
|
|
2
|
+
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
|
|
3
3
|
import { ContentSelectorWrapperComponent } from "./ContentSelectorWrapper.component.mjs";
|
|
4
4
|
import { EditedContentRendererComponent } from "./EditedContentRenderer.component.mjs";
|
|
5
5
|
import { CommonModule } from "@angular/common";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
|
|
2
2
|
import { Injectable, InjectionToken, computed, inject } from "@angular/core";
|
|
3
3
|
|
|
4
4
|
//#region src/editor/useEditedContentRenderer.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
|
|
2
2
|
import { compile } from "@intlayer/core";
|
|
3
3
|
import { Injectable, InjectionToken, inject } from "@angular/core";
|
|
4
4
|
|