angular-intlayer 8.4.4 → 8.4.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/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.cjs +11 -0
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.cjs +8 -0
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/cjs/client/index.cjs +28 -1
- package/dist/cjs/client/installIntlayer.cjs +77 -1
- package/dist/cjs/client/installIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useDictionary.cjs +15 -1
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs +24 -1
- package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +25 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
- package/dist/cjs/client/useIntl.cjs +40 -1
- package/dist/cjs/client/useIntl.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs +44 -1
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useLoadDynamic.cjs +28 -1
- package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs +60 -1
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocaleStorage.cjs +61 -1
- package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
- package/dist/cjs/editor/ContentSelector.component.cjs +38 -1
- package/dist/cjs/editor/ContentSelector.component.cjs.map +1 -0
- package/dist/cjs/editor/useEditor.cjs +31 -1
- package/dist/cjs/editor/useEditor.cjs.map +1 -1
- package/dist/cjs/getDictionary.cjs +10 -1
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs +10 -1
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/index.cjs +50 -1
- package/dist/cjs/markdown/index.cjs +13 -1
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs +79 -1
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -1
- package/dist/cjs/plugins.cjs +212 -1
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/renderIntlayerNode.cjs +28 -1
- package/dist/cjs/renderIntlayerNode.cjs.map +1 -1
- package/dist/cjs/webpack/index.cjs +4 -1
- package/dist/cjs/webpack/mergeConfig.cjs +45 -1
- package/dist/cjs/webpack/mergeConfig.cjs.map +1 -1
- package/dist/esm/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.mjs +10 -0
- package/dist/esm/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.mjs +7 -0
- package/dist/esm/client/index.mjs +10 -1
- package/dist/esm/client/installIntlayer.mjs +65 -1
- package/dist/esm/client/installIntlayer.mjs.map +1 -1
- package/dist/esm/client/useDictionary.mjs +13 -1
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/esm/client/useDictionaryAsync.mjs +21 -1
- package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
- package/dist/esm/client/useDictionaryDynamic.mjs +22 -1
- package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
- package/dist/esm/client/useIntl.mjs +38 -1
- package/dist/esm/client/useIntl.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs +41 -1
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useLoadDynamic.mjs +26 -1
- package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
- package/dist/esm/client/useLocale.mjs +57 -1
- package/dist/esm/client/useLocale.mjs.map +1 -1
- package/dist/esm/client/useLocaleStorage.mjs +54 -1
- package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
- package/dist/esm/editor/ContentSelector.component.mjs +31 -1
- package/dist/esm/editor/ContentSelector.component.mjs.map +1 -0
- package/dist/esm/editor/useEditor.mjs +29 -1
- package/dist/esm/editor/useEditor.mjs.map +1 -1
- package/dist/esm/getDictionary.mjs +8 -1
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs +8 -1
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/esm/index.mjs +14 -1
- package/dist/esm/markdown/index.mjs +3 -1
- package/dist/esm/markdown/installIntlayerMarkdown.mjs +68 -1
- package/dist/esm/markdown/installIntlayerMarkdown.mjs.map +1 -1
- package/dist/esm/plugins.mjs +203 -1
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/esm/renderIntlayerNode.mjs +26 -1
- package/dist/esm/renderIntlayerNode.mjs.map +1 -1
- package/dist/esm/webpack/index.mjs +3 -1
- package/dist/esm/webpack/mergeConfig.mjs +43 -1
- package/dist/esm/webpack/mergeConfig.mjs.map +1 -1
- package/dist/types/client/index.d.ts +8 -8
- package/dist/types/client/installIntlayer.d.ts +50 -2
- package/dist/types/client/installIntlayer.d.ts.map +1 -0
- package/dist/types/client/useDictionary.d.ts +10 -2
- package/dist/types/client/useDictionary.d.ts.map +1 -0
- package/dist/types/client/useDictionaryAsync.d.ts +14 -2
- package/dist/types/client/useDictionaryAsync.d.ts.map +1 -0
- package/dist/types/client/useDictionaryDynamic.d.ts +17 -2
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -0
- package/dist/types/client/useIntl.d.ts +33 -2
- package/dist/types/client/useIntl.d.ts.map +1 -0
- package/dist/types/client/useIntlayer.d.ts +38 -2
- package/dist/types/client/useIntlayer.d.ts.map +1 -0
- package/dist/types/client/useLoadDynamic.d.ts +11 -2
- package/dist/types/client/useLoadDynamic.d.ts.map +1 -0
- package/dist/types/client/useLocale.d.ts +48 -2
- package/dist/types/client/useLocale.d.ts.map +1 -0
- package/dist/types/getDictionary.d.ts +9 -2
- package/dist/types/getDictionary.d.ts.map +1 -0
- package/dist/types/getIntlayer.d.ts +8 -2
- package/dist/types/getIntlayer.d.ts.map +1 -0
- package/dist/types/index.d.ts +21 -13
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/markdown/index.d.ts +1 -1
- package/dist/types/markdown/installIntlayerMarkdown.d.ts +36 -2
- package/dist/types/markdown/installIntlayerMarkdown.d.ts.map +1 -0
- package/dist/types/plugins.d.ts +90 -2
- package/dist/types/plugins.d.ts.map +1 -0
- package/dist/types/webpack/index.d.ts +2 -5
- package/dist/types/webpack/mergeConfig.d.ts +5 -2
- package/dist/types/webpack/mergeConfig.d.ts.map +1 -0
- package/package.json +8 -8
- package/dist/cjs/ContentSelector.component-Dfy-4WRH.cjs +0 -9
- package/dist/cjs/ContentSelector.component-Dfy-4WRH.cjs.map +0 -1
- package/dist/cjs/chunk-Bmb41Sf3.cjs +0 -1
- package/dist/cjs/decorate-B_4qGGx3.cjs +0 -1
- package/dist/esm/ContentSelector.component-B9Uvy9gY.mjs +0 -9
- package/dist/esm/ContentSelector.component-B9Uvy9gY.mjs.map +0 -1
- package/dist/esm/decorate-EVKP5RjP.mjs +0 -1
- package/dist/types/getDictionary-DDjZzxAC.d.ts +0 -9
- package/dist/types/getDictionary-DDjZzxAC.d.ts.map +0 -1
- package/dist/types/getIntlayer-CWM6qsJJ.d.ts +0 -8
- package/dist/types/getIntlayer-CWM6qsJJ.d.ts.map +0 -1
- package/dist/types/index-Cf8zm5QQ.d.ts +0 -1
- package/dist/types/index-D5QAgZ5v.d.ts +0 -22
- package/dist/types/index-D5QAgZ5v.d.ts.map +0 -1
- package/dist/types/installIntlayer-Ce7kST5N.d.ts +0 -50
- package/dist/types/installIntlayer-Ce7kST5N.d.ts.map +0 -1
- package/dist/types/installIntlayerMarkdown-BIU3FTDH.d.ts +0 -36
- package/dist/types/installIntlayerMarkdown-BIU3FTDH.d.ts.map +0 -1
- package/dist/types/plugins-C_v3w-vC.d.ts +0 -89
- package/dist/types/plugins-C_v3w-vC.d.ts.map +0 -1
- package/dist/types/useDictionary-Dq9yu0X_.d.ts +0 -10
- package/dist/types/useDictionary-Dq9yu0X_.d.ts.map +0 -1
- package/dist/types/useDictionaryAsync-BYUsr8w4.d.ts +0 -14
- package/dist/types/useDictionaryAsync-BYUsr8w4.d.ts.map +0 -1
- package/dist/types/useIntl-CHizZCR2.d.ts +0 -33
- package/dist/types/useIntl-CHizZCR2.d.ts.map +0 -1
- package/dist/types/useIntlayer-m3n_upwm.d.ts +0 -38
- package/dist/types/useIntlayer-m3n_upwm.d.ts.map +0 -1
- package/dist/types/useLoadDynamic-C4pltPcC.d.ts +0 -11
- package/dist/types/useLoadDynamic-C4pltPcC.d.ts.map +0 -1
- package/dist/types/useLocale-BzfAmXlx.d.ts +0 -48
- package/dist/types/useLocale-BzfAmXlx.d.ts.map +0 -1
- package/dist/types/webpack/index.d.ts.map +0 -1
|
@@ -1 +1,38 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_decorateMetadata = require('../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.cjs');
|
|
4
|
+
const require_decorate = require('../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.cjs');
|
|
5
|
+
let _angular_core = require("@angular/core");
|
|
6
|
+
|
|
7
|
+
//#region src/editor/ContentSelector.component.ts
|
|
8
|
+
let ContentSelectorWrapperComponent = class ContentSelectorWrapperComponent {
|
|
9
|
+
dictionaryKey;
|
|
10
|
+
keyPath;
|
|
11
|
+
get keyPathJson() {
|
|
12
|
+
return JSON.stringify(this.keyPath);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
require_decorate.__decorate([(0, _angular_core.Input)(), require_decorateMetadata.__decorateMetadata("design:type", String)], ContentSelectorWrapperComponent.prototype, "dictionaryKey", void 0);
|
|
16
|
+
require_decorate.__decorate([(0, _angular_core.Input)(), require_decorateMetadata.__decorateMetadata("design:type", Array)], ContentSelectorWrapperComponent.prototype, "keyPath", void 0);
|
|
17
|
+
ContentSelectorWrapperComponent = require_decorate.__decorate([(0, _angular_core.Component)({
|
|
18
|
+
selector: "app-content-selector-wrapper",
|
|
19
|
+
standalone: true,
|
|
20
|
+
schemas: [_angular_core.CUSTOM_ELEMENTS_SCHEMA],
|
|
21
|
+
template: `
|
|
22
|
+
<intlayer-content-selector-wrapper
|
|
23
|
+
[attr.key-path]="keyPathJson"
|
|
24
|
+
[attr.dictionary-key]="dictionaryKey"
|
|
25
|
+
>
|
|
26
|
+
<ng-content></ng-content>
|
|
27
|
+
</intlayer-content-selector-wrapper>
|
|
28
|
+
`
|
|
29
|
+
})], ContentSelectorWrapperComponent);
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
Object.defineProperty(exports, 'ContentSelectorWrapperComponent', {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return ContentSelectorWrapperComponent;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=ContentSelector.component.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentSelector.component.cjs","names":["CUSTOM_ELEMENTS_SCHEMA"],"sources":["../../../src/editor/ContentSelector.component.ts"],"sourcesContent":["import { Component, CUSTOM_ELEMENTS_SCHEMA, Input } from '@angular/core';\n\n@Component({\n selector: 'app-content-selector-wrapper',\n standalone: true,\n schemas: [CUSTOM_ELEMENTS_SCHEMA],\n template: `\n <intlayer-content-selector-wrapper\n [attr.key-path]=\"keyPathJson\"\n [attr.dictionary-key]=\"dictionaryKey\"\n >\n <ng-content></ng-content>\n </intlayer-content-selector-wrapper>\n `,\n})\nexport class ContentSelectorWrapperComponent {\n @Input() dictionaryKey!: string;\n @Input() keyPath!: any[];\n\n get keyPathJson() {\n return JSON.stringify(this.keyPath);\n }\n}\n"],"mappings":";;;;;;;AAeO,4CAAM,gCAAgC;CAC3C,AAAS;CACT,AAAS;CAET,IAAI,cAAc;AAChB,SAAO,KAAK,UAAU,KAAK,QAAQ;;;uDAJ7B;uDACA;4FAfC;CACT,UAAU;CACV,YAAY;CACZ,SAAS,CAACA,qCAAuB;CACjC,UAAU;;;;;;;;CAQX,CAAC"}
|
|
@@ -1,2 +1,32 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_client_installIntlayer = require('../client/installIntlayer.cjs');
|
|
4
|
+
let _angular_core = require("@angular/core");
|
|
5
|
+
let _intlayer_editor_isEnabled = require("@intlayer/editor/isEnabled");
|
|
6
|
+
|
|
7
|
+
//#region src/editor/useEditor.ts
|
|
8
|
+
const useEditor = () => {
|
|
9
|
+
if (process.env.INTLAYER_EDITOR_ENABLED === "false" || !_intlayer_editor_isEnabled.isEnabled) return;
|
|
10
|
+
const destroyRef = (0, _angular_core.inject)(_angular_core.DestroyRef, { optional: true });
|
|
11
|
+
const client = (0, _angular_core.inject)(require_client_installIntlayer.INTLAYER_TOKEN, { optional: true });
|
|
12
|
+
const injector = (0, _angular_core.inject)(_angular_core.Injector);
|
|
13
|
+
import("@intlayer/editor").then(({ initEditorClient }) => {
|
|
14
|
+
const manager = initEditorClient();
|
|
15
|
+
if (client) {
|
|
16
|
+
const effectRef = (0, _angular_core.runInInjectionContext)(injector, () => (0, _angular_core.effect)(() => {
|
|
17
|
+
const locale = client.locale();
|
|
18
|
+
if (locale) manager.currentLocale.set(locale);
|
|
19
|
+
}));
|
|
20
|
+
destroyRef?.onDestroy(() => effectRef.destroy());
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
destroyRef?.onDestroy(() => {
|
|
24
|
+
import("@intlayer/editor").then(({ stopEditorClient }) => {
|
|
25
|
+
stopEditorClient();
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
exports.useEditor = useEditor;
|
|
2
32
|
//# sourceMappingURL=useEditor.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditor.cjs","names":["isEnabled","DestroyRef","INTLAYER_TOKEN","Injector"],"sources":["../../../src/editor/useEditor.ts"],"sourcesContent":["import {\n DestroyRef,\n effect,\n Injector,\n inject,\n runInInjectionContext,\n} from '@angular/core';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from '../client';\n\nexport const useEditor = () => {\n if (process.env.INTLAYER_EDITOR_ENABLED === 'false' || !isEnabled) return;\n\n const destroyRef = inject(DestroyRef, { optional: true });\n const client = inject<IntlayerProvider>(INTLAYER_TOKEN, {\n optional: true,\n } as any);\n const injector = inject(Injector);\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n\n if (client) {\n const effectRef = runInInjectionContext(injector, () =>\n effect(() => {\n const locale = client.locale();\n if (locale) manager.currentLocale.set(locale as Locale);\n })\n );\n destroyRef?.onDestroy(() => effectRef.destroy());\n }\n });\n\n destroyRef?.onDestroy(() => {\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useEditor.cjs","names":["isEnabled","DestroyRef","INTLAYER_TOKEN","Injector"],"sources":["../../../src/editor/useEditor.ts"],"sourcesContent":["import {\n DestroyRef,\n effect,\n Injector,\n inject,\n runInInjectionContext,\n} from '@angular/core';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from '../client';\n\nexport const useEditor = () => {\n if (process.env.INTLAYER_EDITOR_ENABLED === 'false' || !isEnabled) return;\n\n const destroyRef = inject(DestroyRef, { optional: true });\n const client = inject<IntlayerProvider>(INTLAYER_TOKEN, {\n optional: true,\n } as any);\n const injector = inject(Injector);\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n\n if (client) {\n const effectRef = runInInjectionContext(injector, () =>\n effect(() => {\n const locale = client.locale();\n if (locale) manager.currentLocale.set(locale as Locale);\n })\n );\n destroyRef?.onDestroy(() => effectRef.destroy());\n }\n });\n\n destroyRef?.onDestroy(() => {\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n });\n};\n"],"mappings":";;;;;;;AAWA,MAAa,kBAAkB;AAC7B,KAAI,QAAQ,IAAI,4BAA4B,WAAW,CAACA,qCAAW;CAEnE,MAAM,uCAAoBC,0BAAY,EAAE,UAAU,MAAM,CAAC;CACzD,MAAM,mCAAkCC,+CAAgB,EACtD,UAAU,MACX,CAAQ;CACT,MAAM,qCAAkBC,uBAAS;AAEjC,QAAO,oBAAoB,MAAM,EAAE,uBAAuB;EACxD,MAAM,UAAU,kBAAkB;AAElC,MAAI,QAAQ;GACV,MAAM,qDAAkC,gDACzB;IACX,MAAM,SAAS,OAAO,QAAQ;AAC9B,QAAI,OAAQ,SAAQ,cAAc,IAAI,OAAiB;KACvD,CACH;AACD,eAAY,gBAAgB,UAAU,SAAS,CAAC;;GAElD;AAEF,aAAY,gBAAgB;AAC1B,SAAO,oBAAoB,MAAM,EAAE,uBAAuB;AACxD,qBAAkB;IAClB;GACF"}
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_plugins = require('./plugins.cjs');
|
|
4
|
+
let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
|
|
5
|
+
|
|
6
|
+
//#region src/getDictionary.ts
|
|
7
|
+
const getDictionary = (dictionary, locale) => (0, _intlayer_core_interpreter.getDictionary)(dictionary, locale, require_plugins.getPlugins(locale));
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
exports.getDictionary = getDictionary;
|
|
2
11
|
//# sourceMappingURL=getDictionary.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDictionary.cjs","names":["getPlugins"],"sources":["../../src/getDictionary.ts"],"sourcesContent":["import { getDictionary as getDictionaryCore } from '@intlayer/core/interpreter';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getPlugins } from './plugins';\n\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n) => getDictionaryCore<T, L>(dictionary,
|
|
1
|
+
{"version":3,"file":"getDictionary.cjs","names":["getPlugins"],"sources":["../../src/getDictionary.ts"],"sourcesContent":["import { getDictionary as getDictionaryCore } from '@intlayer/core/interpreter';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getPlugins } from './plugins';\n\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n) => getDictionaryCore<T, L>(dictionary, locale, getPlugins(locale));\n"],"mappings":";;;;;;AAQA,MAAa,iBAIX,YACA,yDAC2B,YAAY,QAAQA,2BAAW,OAAO,CAAC"}
|
package/dist/cjs/getIntlayer.cjs
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_plugins = require('./plugins.cjs');
|
|
4
|
+
let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
|
|
5
|
+
|
|
6
|
+
//#region src/getIntlayer.ts
|
|
7
|
+
const getIntlayer = (key, locale) => (0, _intlayer_core_interpreter.getIntlayer)(key, locale, require_plugins.getPlugins(locale));
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
exports.getIntlayer = getIntlayer;
|
|
2
11
|
//# sourceMappingURL=getIntlayer.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIntlayer.cjs","names":["getPlugins"],"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import { getIntlayer as getIntlayerCore } from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\nexport const getIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L\n) =>\n getIntlayerCore<T, L>(\n key,\n locale,\n getPlugins(locale)\n ) as DeepTransformContent<DictionaryRegistryContent<T>>;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getIntlayer.cjs","names":["getPlugins"],"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import { getIntlayer as getIntlayerCore } from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\nexport const getIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L\n) =>\n getIntlayerCore<T, L>(\n key,\n locale,\n getPlugins(locale)\n ) as DeepTransformContent<DictionaryRegistryContent<T>>;\n"],"mappings":";;;;;;AASA,MAAa,eAIX,KACA,uDAGE,KACA,QACAA,2BAAW,OAAO,CACnB"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1 +1,50 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_markdown_installIntlayerMarkdown = require('./markdown/installIntlayerMarkdown.cjs');
|
|
3
|
+
const require_plugins = require('./plugins.cjs');
|
|
4
|
+
const require_getIntlayer = require('./getIntlayer.cjs');
|
|
5
|
+
const require_getDictionary = require('./getDictionary.cjs');
|
|
6
|
+
const require_client_installIntlayer = require('./client/installIntlayer.cjs');
|
|
7
|
+
const require_client_useDictionary = require('./client/useDictionary.cjs');
|
|
8
|
+
const require_client_useDictionaryAsync = require('./client/useDictionaryAsync.cjs');
|
|
9
|
+
const require_client_useLoadDynamic = require('./client/useLoadDynamic.cjs');
|
|
10
|
+
const require_client_useDictionaryDynamic = require('./client/useDictionaryDynamic.cjs');
|
|
11
|
+
const require_client_useIntl = require('./client/useIntl.cjs');
|
|
12
|
+
const require_client_useIntlayer = require('./client/useIntlayer.cjs');
|
|
13
|
+
const require_client_useLocale = require('./client/useLocale.cjs');
|
|
14
|
+
|
|
15
|
+
exports.INTLAYER_MARKDOWN_TOKEN = require_markdown_installIntlayerMarkdown.INTLAYER_MARKDOWN_TOKEN;
|
|
16
|
+
exports.INTLAYER_TOKEN = require_client_installIntlayer.INTLAYER_TOKEN;
|
|
17
|
+
Object.defineProperty(exports, 'IntlayerMarkdownService', {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () {
|
|
20
|
+
return require_markdown_installIntlayerMarkdown.IntlayerMarkdownService;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, 'IntlayerProvider', {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () {
|
|
26
|
+
return require_client_installIntlayer.IntlayerProvider;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
exports.createIntlayerClient = require_client_installIntlayer.createIntlayerClient;
|
|
30
|
+
exports.createIntlayerMarkdownProvider = require_markdown_installIntlayerMarkdown.createIntlayerMarkdownProvider;
|
|
31
|
+
exports.getDictionary = require_getDictionary.getDictionary;
|
|
32
|
+
exports.getIntlayer = require_getIntlayer.getIntlayer;
|
|
33
|
+
exports.getPlugins = require_plugins.getPlugins;
|
|
34
|
+
exports.htmlPlugin = require_plugins.htmlPlugin;
|
|
35
|
+
exports.htmlRuntime = require_markdown_installIntlayerMarkdown.htmlRuntime;
|
|
36
|
+
exports.insertionPlugin = require_plugins.insertionPlugin;
|
|
37
|
+
exports.installIntlayer = require_client_installIntlayer.installIntlayer;
|
|
38
|
+
exports.intlayerNodePlugins = require_plugins.intlayerNodePlugins;
|
|
39
|
+
exports.isUpdatableNode = require_client_useIntlayer.isUpdatableNode;
|
|
40
|
+
exports.markdownPlugin = require_plugins.markdownPlugin;
|
|
41
|
+
exports.markdownStringPlugin = require_plugins.markdownStringPlugin;
|
|
42
|
+
exports.provideIntlayer = require_client_installIntlayer.provideIntlayer;
|
|
43
|
+
exports.useDictionary = require_client_useDictionary.useDictionary;
|
|
44
|
+
exports.useDictionaryAsync = require_client_useDictionaryAsync.useDictionaryAsync;
|
|
45
|
+
exports.useDictionaryDynamic = require_client_useDictionaryDynamic.useDictionaryDynamic;
|
|
46
|
+
exports.useIntl = require_client_useIntl.useIntl;
|
|
47
|
+
exports.useIntlayer = require_client_useIntlayer.useIntlayer;
|
|
48
|
+
exports.useLoadDynamic = require_client_useLoadDynamic.useLoadDynamic;
|
|
49
|
+
exports.useLocale = require_client_useLocale.useLocale;
|
|
50
|
+
exports.useMarkdown = require_markdown_installIntlayerMarkdown.useMarkdown;
|
|
@@ -1 +1,13 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_markdown_installIntlayerMarkdown = require('./installIntlayerMarkdown.cjs');
|
|
3
|
+
|
|
4
|
+
exports.INTLAYER_MARKDOWN_TOKEN = require_markdown_installIntlayerMarkdown.INTLAYER_MARKDOWN_TOKEN;
|
|
5
|
+
Object.defineProperty(exports, 'IntlayerMarkdownService', {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function () {
|
|
8
|
+
return require_markdown_installIntlayerMarkdown.IntlayerMarkdownService;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
exports.createIntlayerMarkdownProvider = require_markdown_installIntlayerMarkdown.createIntlayerMarkdownProvider;
|
|
12
|
+
exports.htmlRuntime = require_markdown_installIntlayerMarkdown.htmlRuntime;
|
|
13
|
+
exports.useMarkdown = require_markdown_installIntlayerMarkdown.useMarkdown;
|
|
@@ -1,2 +1,80 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
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.115.0/helpers/decorate.cjs');
|
|
4
|
+
let _intlayer_core_markdown = require("@intlayer/core/markdown");
|
|
5
|
+
let _angular_core = require("@angular/core");
|
|
6
|
+
|
|
7
|
+
//#region src/markdown/installIntlayerMarkdown.ts
|
|
8
|
+
const INTLAYER_MARKDOWN_TOKEN = new _angular_core.InjectionToken("intlayerMarkdown");
|
|
9
|
+
const htmlRuntime = {
|
|
10
|
+
createElement: (tag, props, ...children) => {
|
|
11
|
+
if (typeof tag !== "string") {
|
|
12
|
+
if (tag === htmlRuntime.Fragment) return children.join("");
|
|
13
|
+
return "";
|
|
14
|
+
}
|
|
15
|
+
const attrs = props ? Object.entries(props).map(([k, v]) => {
|
|
16
|
+
if (k === "key" || v === void 0 || v === null) return "";
|
|
17
|
+
return `${k === "className" ? "class" : k}="${String(v).replace(/"/g, """)}"`;
|
|
18
|
+
}).filter(Boolean).join(" ") : "";
|
|
19
|
+
const childrenStr = children.join("");
|
|
20
|
+
if ([
|
|
21
|
+
"area",
|
|
22
|
+
"base",
|
|
23
|
+
"br",
|
|
24
|
+
"col",
|
|
25
|
+
"embed",
|
|
26
|
+
"hr",
|
|
27
|
+
"img",
|
|
28
|
+
"input",
|
|
29
|
+
"link",
|
|
30
|
+
"meta",
|
|
31
|
+
"param",
|
|
32
|
+
"source",
|
|
33
|
+
"track",
|
|
34
|
+
"wbr"
|
|
35
|
+
].includes(tag)) return `<${tag} ${attrs} />`;
|
|
36
|
+
return `<${tag}${attrs ? ` ${attrs}` : ""}>${childrenStr}</${tag}>`;
|
|
37
|
+
},
|
|
38
|
+
cloneElement: (element, _props) => element,
|
|
39
|
+
Fragment: Symbol("Fragment")
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Default markdown renderer that converts markdown to HTML string
|
|
43
|
+
*/
|
|
44
|
+
const defaultMarkdownRenderer = (markdown) => (0, _intlayer_core_markdown.compile)(markdown, { runtime: htmlRuntime });
|
|
45
|
+
/**
|
|
46
|
+
* Create IntlayerMarkdown provider configuration
|
|
47
|
+
*/
|
|
48
|
+
const createIntlayerMarkdownProvider = (renderMarkdown = defaultMarkdownRenderer) => ({
|
|
49
|
+
provide: INTLAYER_MARKDOWN_TOKEN,
|
|
50
|
+
useValue: { renderMarkdown }
|
|
51
|
+
});
|
|
52
|
+
let IntlayerMarkdownService = class IntlayerMarkdownService {
|
|
53
|
+
markdownProvider = (0, _angular_core.inject)(INTLAYER_MARKDOWN_TOKEN, { optional: true });
|
|
54
|
+
renderMarkdown(markdown, overrides) {
|
|
55
|
+
if (!this.markdownProvider) return markdown;
|
|
56
|
+
return this.markdownProvider.renderMarkdown(markdown, overrides);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
IntlayerMarkdownService = require_decorate.__decorate([(0, _angular_core.Injectable)({ providedIn: "root" })], IntlayerMarkdownService);
|
|
60
|
+
/**
|
|
61
|
+
* Function to inject markdown provider
|
|
62
|
+
*/
|
|
63
|
+
const useMarkdown = () => {
|
|
64
|
+
const markdownProvider = (0, _angular_core.inject)(INTLAYER_MARKDOWN_TOKEN, { optional: true });
|
|
65
|
+
if (!markdownProvider) return { renderMarkdown: defaultMarkdownRenderer };
|
|
66
|
+
return markdownProvider;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
exports.INTLAYER_MARKDOWN_TOKEN = INTLAYER_MARKDOWN_TOKEN;
|
|
71
|
+
Object.defineProperty(exports, 'IntlayerMarkdownService', {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
get: function () {
|
|
74
|
+
return IntlayerMarkdownService;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
exports.createIntlayerMarkdownProvider = createIntlayerMarkdownProvider;
|
|
78
|
+
exports.htmlRuntime = htmlRuntime;
|
|
79
|
+
exports.useMarkdown = useMarkdown;
|
|
2
80
|
//# sourceMappingURL=installIntlayerMarkdown.cjs.map
|
|
@@ -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 type { MarkdownRuntime } from '@intlayer/core/markdown';\nimport { compile } from '@intlayer/core/markdown';\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 type { MarkdownRuntime } from '@intlayer/core/markdown';\nimport { compile } from '@intlayer/core/markdown';\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":";;;;;;;AASA,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,kDAC/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,2 +1,213 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_renderIntlayerNode = require('./renderIntlayerNode.cjs');
|
|
4
|
+
const require_editor_ContentSelector_component = require('./editor/ContentSelector.component.cjs');
|
|
5
|
+
const require_markdown_installIntlayerMarkdown = require('./markdown/installIntlayerMarkdown.cjs');
|
|
6
|
+
let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
|
|
7
|
+
let _intlayer_config_built = require("@intlayer/config/built");
|
|
8
|
+
_intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
|
|
9
|
+
let _intlayer_core_markdown = require("@intlayer/core/markdown");
|
|
10
|
+
let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
|
|
11
|
+
_intlayer_types_nodeType = require_runtime.__toESM(_intlayer_types_nodeType);
|
|
12
|
+
|
|
13
|
+
//#region src/plugins.ts
|
|
14
|
+
/** ---------------------------------------------
|
|
15
|
+
* UTILS
|
|
16
|
+
* --------------------------------------------- */
|
|
17
|
+
const createRuntimeWithOverides = (baseRuntime, overrides) => ({
|
|
18
|
+
...baseRuntime,
|
|
19
|
+
createElement: (tag, props, ...children) => {
|
|
20
|
+
const override = overrides?.[tag];
|
|
21
|
+
if (override) {
|
|
22
|
+
const newProps = {
|
|
23
|
+
...props,
|
|
24
|
+
...override
|
|
25
|
+
};
|
|
26
|
+
const originalClass = props?.class || props?.className;
|
|
27
|
+
const overrideClass = override.class || override.className;
|
|
28
|
+
if (originalClass && overrideClass) {
|
|
29
|
+
newProps.class = `${originalClass} ${overrideClass}`;
|
|
30
|
+
newProps.className = void 0;
|
|
31
|
+
}
|
|
32
|
+
return baseRuntime.createElement(tag, newProps, ...children);
|
|
33
|
+
}
|
|
34
|
+
return baseRuntime.createElement(tag, props, ...children);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
38
|
+
const intlayerNodePlugins = {
|
|
39
|
+
id: "intlayer-node-plugin",
|
|
40
|
+
canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
|
|
41
|
+
transform: (_node, { children, ...rest }) => require_renderIntlayerNode.renderIntlayerNode({
|
|
42
|
+
...rest,
|
|
43
|
+
value: children,
|
|
44
|
+
children: () => ({
|
|
45
|
+
component: _intlayer_config_built.default?.editor.enabled ? require_editor_ContentSelector_component.ContentSelectorWrapperComponent : children,
|
|
46
|
+
props: {
|
|
47
|
+
dictionaryKey: rest.dictionaryKey,
|
|
48
|
+
keyPath: rest.keyPath
|
|
49
|
+
},
|
|
50
|
+
children
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
};
|
|
54
|
+
/** Markdown string plugin. Replaces string node with a component that render the markdown. */
|
|
55
|
+
const markdownStringPlugin = {
|
|
56
|
+
id: "markdown-string-plugin",
|
|
57
|
+
canHandle: (node) => typeof node === "string",
|
|
58
|
+
transform: (node, props, deepTransformNode) => {
|
|
59
|
+
const { plugins, ...rest } = props;
|
|
60
|
+
const metadataNodes = deepTransformNode((0, _intlayer_core_markdown.getMarkdownMetadata)(node), {
|
|
61
|
+
plugins: [{
|
|
62
|
+
id: "markdown-metadata-plugin",
|
|
63
|
+
canHandle: (metadataNode) => typeof metadataNode === "string" || typeof metadataNode === "number" || typeof metadataNode === "boolean" || !metadataNode,
|
|
64
|
+
transform: (metadataNode, props) => require_renderIntlayerNode.renderIntlayerNode({
|
|
65
|
+
...props,
|
|
66
|
+
value: metadataNode,
|
|
67
|
+
children: node
|
|
68
|
+
})
|
|
69
|
+
}],
|
|
70
|
+
dictionaryKey: rest.dictionaryKey,
|
|
71
|
+
keyPath: []
|
|
72
|
+
});
|
|
73
|
+
const render = (components) => require_renderIntlayerNode.renderIntlayerNode({
|
|
74
|
+
...rest,
|
|
75
|
+
value: node,
|
|
76
|
+
children: _intlayer_config_built.default?.editor.enabled ? () => ({
|
|
77
|
+
component: require_editor_ContentSelector_component.ContentSelectorWrapperComponent,
|
|
78
|
+
props: {
|
|
79
|
+
dictionaryKey: rest.dictionaryKey,
|
|
80
|
+
keyPath: rest.keyPath,
|
|
81
|
+
...components
|
|
82
|
+
},
|
|
83
|
+
children: () => {
|
|
84
|
+
const { renderMarkdown } = require_markdown_installIntlayerMarkdown.useMarkdown();
|
|
85
|
+
return renderMarkdown(node, components);
|
|
86
|
+
}
|
|
87
|
+
}) : () => {
|
|
88
|
+
const { renderMarkdown } = require_markdown_installIntlayerMarkdown.useMarkdown();
|
|
89
|
+
return renderMarkdown(node, components);
|
|
90
|
+
},
|
|
91
|
+
additionalProps: { metadata: metadataNodes }
|
|
92
|
+
});
|
|
93
|
+
const createProxy = (element, components) => new Proxy(element, { get(target, prop, receiver) {
|
|
94
|
+
if (prop === "value") return node;
|
|
95
|
+
if (prop === "metadata") return metadataNodes;
|
|
96
|
+
if (prop === "toString") return () => {
|
|
97
|
+
return (0, _intlayer_core_markdown.compile)(node, { runtime: components ? createRuntimeWithOverides(require_markdown_installIntlayerMarkdown.htmlRuntime, components) : require_markdown_installIntlayerMarkdown.htmlRuntime });
|
|
98
|
+
};
|
|
99
|
+
if (prop === Symbol.toPrimitive) return () => {
|
|
100
|
+
return (0, _intlayer_core_markdown.compile)(node, { runtime: components ? createRuntimeWithOverides(require_markdown_installIntlayerMarkdown.htmlRuntime, components) : require_markdown_installIntlayerMarkdown.htmlRuntime });
|
|
101
|
+
};
|
|
102
|
+
if (prop === "use") return (newComponents) => {
|
|
103
|
+
const mergedComponents = {
|
|
104
|
+
...components,
|
|
105
|
+
...newComponents
|
|
106
|
+
};
|
|
107
|
+
return createProxy(render(mergedComponents), mergedComponents);
|
|
108
|
+
};
|
|
109
|
+
return Reflect.get(target, prop, receiver);
|
|
110
|
+
} });
|
|
111
|
+
return createProxy(render());
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const markdownPlugin = {
|
|
115
|
+
id: "markdown-plugin",
|
|
116
|
+
canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.MARKDOWN,
|
|
117
|
+
transform: (node, props, deepTransformNode) => {
|
|
118
|
+
const newKeyPath = [...props.keyPath, { type: _intlayer_types_nodeType.MARKDOWN }];
|
|
119
|
+
const children = node[_intlayer_types_nodeType.MARKDOWN];
|
|
120
|
+
return deepTransformNode(children, {
|
|
121
|
+
...props,
|
|
122
|
+
children,
|
|
123
|
+
keyPath: newKeyPath,
|
|
124
|
+
plugins: [markdownStringPlugin, ...props.plugins ?? []]
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
/** HTML plugin. Replaces node with a function that takes components => IntlayerNode. */
|
|
129
|
+
const htmlPlugin = {
|
|
130
|
+
id: "html-plugin",
|
|
131
|
+
canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.HTML,
|
|
132
|
+
transform: (node, props) => {
|
|
133
|
+
const html = node[_intlayer_types_nodeType.HTML];
|
|
134
|
+
const { plugins, ...rest } = props;
|
|
135
|
+
const render = (userComponents) => require_renderIntlayerNode.renderIntlayerNode({
|
|
136
|
+
...rest,
|
|
137
|
+
value: html,
|
|
138
|
+
children: _intlayer_config_built.default?.editor.enabled ? () => ({
|
|
139
|
+
component: require_editor_ContentSelector_component.ContentSelectorWrapperComponent,
|
|
140
|
+
props: {
|
|
141
|
+
dictionaryKey: rest.dictionaryKey,
|
|
142
|
+
keyPath: rest.keyPath,
|
|
143
|
+
...userComponents
|
|
144
|
+
},
|
|
145
|
+
children: html
|
|
146
|
+
}) : html
|
|
147
|
+
});
|
|
148
|
+
const createProxy = (element, components) => new Proxy(element, { get(target, prop, receiver) {
|
|
149
|
+
if (prop === "value") return html;
|
|
150
|
+
if (prop === "toString") return () => {
|
|
151
|
+
if (!components || typeof components === "object" && Object.keys(components).length === 0) return String(html);
|
|
152
|
+
return (0, _intlayer_core_markdown.compile)(html, { runtime: createRuntimeWithOverides(require_markdown_installIntlayerMarkdown.htmlRuntime, components) });
|
|
153
|
+
};
|
|
154
|
+
if (prop === Symbol.toPrimitive) return () => {
|
|
155
|
+
if (!components || typeof components === "object" && Object.keys(components).length === 0) return String(html);
|
|
156
|
+
return (0, _intlayer_core_markdown.compile)(html, { runtime: createRuntimeWithOverides(require_markdown_installIntlayerMarkdown.htmlRuntime, components) });
|
|
157
|
+
};
|
|
158
|
+
if (prop === "use") return (userComponents) => {
|
|
159
|
+
const mergedComponents = {
|
|
160
|
+
...components,
|
|
161
|
+
...userComponents
|
|
162
|
+
};
|
|
163
|
+
return createProxy(render(mergedComponents), mergedComponents);
|
|
164
|
+
};
|
|
165
|
+
return Reflect.get(target, prop, receiver);
|
|
166
|
+
} });
|
|
167
|
+
return createProxy(render());
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const insertionPlugin = {
|
|
171
|
+
id: "insertion-plugin",
|
|
172
|
+
canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.INSERTION,
|
|
173
|
+
transform: (node, props) => {
|
|
174
|
+
const { plugins, ...rest } = props;
|
|
175
|
+
const render = (args = {}) => {
|
|
176
|
+
let text = node[_intlayer_types_nodeType.INSERTION];
|
|
177
|
+
if (args) Object.entries(args).forEach(([key, value]) => {
|
|
178
|
+
text = text.replace(new RegExp(`{{\\s*${key}\\s*}}`, "g"), String(value));
|
|
179
|
+
});
|
|
180
|
+
return text;
|
|
181
|
+
};
|
|
182
|
+
return require_renderIntlayerNode.renderIntlayerNode({
|
|
183
|
+
...rest,
|
|
184
|
+
value: render,
|
|
185
|
+
children: render
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Get the plugins array for Angular content transformation.
|
|
191
|
+
* This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.
|
|
192
|
+
*/
|
|
193
|
+
const getPlugins = (locale, fallback = true) => [
|
|
194
|
+
(0, _intlayer_core_interpreter.translationPlugin)(locale ?? _intlayer_config_built.default.internationalization.defaultLocale, fallback ? _intlayer_config_built.default.internationalization.defaultLocale : void 0),
|
|
195
|
+
_intlayer_core_interpreter.enumerationPlugin,
|
|
196
|
+
_intlayer_core_interpreter.conditionPlugin,
|
|
197
|
+
(0, _intlayer_core_interpreter.nestedPlugin)(locale ?? _intlayer_config_built.default.internationalization.defaultLocale),
|
|
198
|
+
_intlayer_core_interpreter.filePlugin,
|
|
199
|
+
_intlayer_core_interpreter.genderPlugin,
|
|
200
|
+
intlayerNodePlugins,
|
|
201
|
+
markdownPlugin,
|
|
202
|
+
htmlPlugin,
|
|
203
|
+
insertionPlugin
|
|
204
|
+
];
|
|
205
|
+
|
|
206
|
+
//#endregion
|
|
207
|
+
exports.getPlugins = getPlugins;
|
|
208
|
+
exports.htmlPlugin = htmlPlugin;
|
|
209
|
+
exports.insertionPlugin = insertionPlugin;
|
|
210
|
+
exports.intlayerNodePlugins = intlayerNodePlugins;
|
|
211
|
+
exports.markdownPlugin = markdownPlugin;
|
|
212
|
+
exports.markdownStringPlugin = markdownStringPlugin;
|
|
2
213
|
//# sourceMappingURL=plugins.cjs.map
|