angular-intlayer 5.5.4 → 5.5.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/client/dictionary.service.cjs +70 -0
- package/dist/cjs/client/dictionary.service.cjs.map +1 -0
- package/dist/cjs/client/getBrowserLocale.cjs +34 -0
- package/dist/cjs/client/getBrowserLocale.cjs.map +1 -0
- package/dist/cjs/client/getDictionary.cjs +43 -0
- package/dist/cjs/client/getDictionary.cjs.map +1 -0
- package/dist/cjs/client/getLocale.cjs +31 -0
- package/dist/cjs/client/getLocale.cjs.map +1 -0
- package/dist/cjs/client/index.cjs +47 -0
- package/dist/cjs/client/index.cjs.map +1 -0
- package/dist/cjs/client/intlayer.service.cjs +43 -0
- package/dist/cjs/client/intlayer.service.cjs.map +1 -0
- package/dist/cjs/client/locale.service.cjs +66 -0
- package/dist/cjs/client/locale.service.cjs.map +1 -0
- package/dist/cjs/client/t.cjs +32 -0
- package/dist/cjs/client/t.cjs.map +1 -0
- package/dist/cjs/getDictionary.cjs +29 -0
- package/dist/cjs/getDictionary.cjs.map +1 -0
- package/dist/cjs/getIntlayer.cjs +31 -0
- package/dist/cjs/getIntlayer.cjs.map +1 -0
- package/dist/cjs/index.cjs +10 -4
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/markdown/index.cjs +36 -0
- package/dist/cjs/markdown/index.cjs.map +1 -0
- package/dist/cjs/plugins.cjs +106 -0
- package/dist/cjs/plugins.cjs.map +1 -0
- package/dist/esm/client/dictionary.service.mjs +46 -0
- package/dist/esm/client/dictionary.service.mjs.map +1 -0
- package/dist/esm/client/getBrowserLocale.mjs +10 -0
- package/dist/esm/client/getBrowserLocale.mjs.map +1 -0
- package/dist/esm/client/getDictionary.mjs +25 -0
- package/dist/esm/client/getDictionary.mjs.map +1 -0
- package/dist/esm/client/getLocale.mjs +7 -0
- package/dist/esm/client/getLocale.mjs.map +1 -0
- package/dist/esm/client/index.mjs +17 -0
- package/dist/esm/client/index.mjs.map +1 -0
- package/dist/esm/client/intlayer.service.mjs +19 -0
- package/dist/esm/client/intlayer.service.mjs.map +1 -0
- package/dist/esm/client/locale.service.mjs +42 -0
- package/dist/esm/client/locale.service.mjs.map +1 -0
- package/dist/esm/client/t.mjs +8 -0
- package/dist/esm/client/t.mjs.map +1 -0
- package/dist/esm/getDictionary.mjs +5 -0
- package/dist/esm/getDictionary.mjs.map +1 -0
- package/dist/esm/getIntlayer.mjs +7 -0
- package/dist/esm/getIntlayer.mjs.map +1 -0
- package/dist/esm/index.mjs +5 -2
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/markdown/index.mjs +11 -0
- package/dist/esm/markdown/index.mjs.map +1 -0
- package/dist/esm/plugins.mjs +82 -0
- package/dist/esm/plugins.mjs.map +1 -0
- package/dist/types/client/dictionary.service.d.ts +21 -0
- package/dist/types/client/dictionary.service.d.ts.map +1 -0
- package/dist/types/client/getBrowserLocale.d.ts +6 -0
- package/dist/types/client/getBrowserLocale.d.ts.map +1 -0
- package/dist/types/client/getDictionary.d.ts +8 -0
- package/dist/types/client/getDictionary.d.ts.map +1 -0
- package/dist/types/client/getLocale.d.ts +7 -0
- package/dist/types/client/getLocale.d.ts.map +1 -0
- package/dist/types/client/index.d.ts +8 -0
- package/dist/types/client/index.d.ts.map +1 -0
- package/dist/types/client/intlayer.service.d.ts +8 -0
- package/dist/types/client/intlayer.service.d.ts.map +1 -0
- package/dist/types/client/locale.service.d.ts +12 -0
- package/dist/types/client/locale.service.d.ts.map +1 -0
- package/dist/types/client/t.d.ts +8 -0
- package/dist/types/client/t.d.ts.map +1 -0
- package/dist/types/getDictionary.d.ts +2 -0
- package/dist/types/getDictionary.d.ts.map +1 -0
- package/dist/types/getIntlayer.d.ts +7 -0
- package/dist/types/getIntlayer.d.ts.map +1 -0
- package/dist/types/index.d.ts +10 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/markdown/index.d.ts +5 -0
- package/dist/types/markdown/index.d.ts.map +1 -0
- package/dist/types/plugins.d.ts +55 -0
- package/dist/types/plugins.d.ts.map +1 -0
- package/package.json +10 -8
- package/dist/cjs/intlayerMiddlewarePlugin.cjs +0 -224
- package/dist/cjs/intlayerMiddlewarePlugin.cjs.map +0 -1
- package/dist/cjs/intlayerPlugin.cjs +0 -76
- package/dist/cjs/intlayerPlugin.cjs.map +0 -1
- package/dist/esm/intlayerMiddlewarePlugin.mjs +0 -200
- package/dist/esm/intlayerMiddlewarePlugin.mjs.map +0 -1
- package/dist/esm/intlayerPlugin.mjs +0 -52
- package/dist/esm/intlayerPlugin.mjs.map +0 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var plugins_exports = {};
|
|
20
|
+
__export(plugins_exports, {
|
|
21
|
+
angularTemplatePlugin: () => angularTemplatePlugin,
|
|
22
|
+
intlayerNodePlugins: () => intlayerNodePlugins,
|
|
23
|
+
markdownPlugin: () => markdownPlugin,
|
|
24
|
+
markdownStringPlugin: () => markdownStringPlugin
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(plugins_exports);
|
|
27
|
+
var import_core = require("@intlayer/core");
|
|
28
|
+
const intlayerNodePlugins = {
|
|
29
|
+
id: "intlayer-node-plugin",
|
|
30
|
+
canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
|
|
31
|
+
transform: (_node, { children, ...rest }) => ({
|
|
32
|
+
...rest,
|
|
33
|
+
value: children,
|
|
34
|
+
children
|
|
35
|
+
})
|
|
36
|
+
};
|
|
37
|
+
const angularTemplatePlugin = {
|
|
38
|
+
id: "angular-template-plugin",
|
|
39
|
+
canHandle: (node) => typeof node === "object" && node && typeof node.createEmbeddedView === "function",
|
|
40
|
+
transform: (node, { plugins, ...rest }) => ({
|
|
41
|
+
...rest,
|
|
42
|
+
value: "[[angular-template]]",
|
|
43
|
+
children: node
|
|
44
|
+
})
|
|
45
|
+
};
|
|
46
|
+
const markdownStringPlugin = {
|
|
47
|
+
id: "markdown-string-plugin",
|
|
48
|
+
canHandle: (node) => typeof node === "string",
|
|
49
|
+
transform: (node, props, deepTransformNode) => {
|
|
50
|
+
const {
|
|
51
|
+
plugins,
|
|
52
|
+
// Removed to avoid circular dependencies
|
|
53
|
+
...rest
|
|
54
|
+
} = props;
|
|
55
|
+
const metadata = (0, import_core.getMarkdownMetadata)(node);
|
|
56
|
+
const metadataPlugins = {
|
|
57
|
+
id: "markdown-metadata-plugin",
|
|
58
|
+
canHandle: (metadataNode) => typeof metadataNode === "string" || typeof metadataNode === "number" || typeof metadataNode === "boolean" || !metadataNode,
|
|
59
|
+
transform: (metadataNode, props2) => ({
|
|
60
|
+
...props2,
|
|
61
|
+
value: metadataNode,
|
|
62
|
+
children: node
|
|
63
|
+
})
|
|
64
|
+
};
|
|
65
|
+
const metadataNodes = deepTransformNode(metadata, {
|
|
66
|
+
plugins: [metadataPlugins],
|
|
67
|
+
dictionaryKey: rest.dictionaryKey,
|
|
68
|
+
keyPath: []
|
|
69
|
+
});
|
|
70
|
+
return {
|
|
71
|
+
...props,
|
|
72
|
+
value: node,
|
|
73
|
+
children: node,
|
|
74
|
+
additionalProps: {
|
|
75
|
+
metadata: metadataNodes
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const markdownPlugin = {
|
|
81
|
+
id: "markdown-plugin",
|
|
82
|
+
canHandle: (node) => typeof node === "object" && node?.nodeType === import_core.NodeType.Markdown,
|
|
83
|
+
transform: (node, props, deepTransformNode) => {
|
|
84
|
+
const newKeyPath = [
|
|
85
|
+
...props.keyPath,
|
|
86
|
+
{
|
|
87
|
+
type: import_core.NodeType.Markdown
|
|
88
|
+
}
|
|
89
|
+
];
|
|
90
|
+
const children = node[import_core.NodeType.Markdown];
|
|
91
|
+
return deepTransformNode(children, {
|
|
92
|
+
...props,
|
|
93
|
+
children,
|
|
94
|
+
keyPath: newKeyPath,
|
|
95
|
+
plugins: [markdownStringPlugin, ...props.plugins ?? []]
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
100
|
+
0 && (module.exports = {
|
|
101
|
+
angularTemplatePlugin,
|
|
102
|
+
intlayerNodePlugins,
|
|
103
|
+
markdownPlugin,
|
|
104
|
+
markdownStringPlugin
|
|
105
|
+
});
|
|
106
|
+
//# sourceMappingURL=plugins.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/plugins.ts"],"sourcesContent":["import type { TemplateRef } from '@angular/core';\nimport {\n getMarkdownMetadata,\n KeyPath,\n MarkdownContent,\n NodeType,\n type DeepTransformContent as DeepTransformContentCore,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type Plugins,\n} from '@intlayer/core';\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 ...rest,\n value: children,\n children,\n }),\n};\n\n/** ---------------------------------------------\n * ANGULAR TEMPLATE PLUGIN\n * --------------------------------------------- */\n\nexport type AngularTemplateCond<T> =\n T extends TemplateRef<any> ? TemplateRef<any> : never;\n\n/** Angular template plugin. Handles Angular TemplateRef objects. */\nexport const angularTemplatePlugin: Plugins = {\n id: 'angular-template-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n node &&\n typeof node.createEmbeddedView === 'function',\n transform: (node, { plugins, ...rest }) => ({\n ...rest,\n value: '[[angular-template]]',\n children: node,\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 circular dependencies\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 ...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 return {\n ...props,\n value: node,\n children: node,\n additionalProps: {\n metadata: metadataNodes,\n },\n };\n },\n};\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer M;\n metadata?: infer U;\n}\n ? IntlayerNode<DeepTransformContent<M>, { metadata: DeepTransformContent<U> }>\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 * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginAngular<T> {\n angularTemplate: AngularTemplateCond<T>;\n intlayerNode: IntlayerNodeCond<T>;\n markdown: MarkdownCond<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 = IInterpreterPluginStateCore & {\n angularTemplate: true;\n intlayerNode: true;\n markdown: true;\n};\n\nexport type DeepTransformContent<T> = DeepTransformContentCore<\n T,\n IInterpreterPluginState\n>;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAQO;AAiBA,MAAM,sBAA+B;AAAA,EAC1C,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;AAAA,EAClB,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,KAAK,OAAO;AAAA,IAC5C,GAAG;AAAA,IACH,OAAO;AAAA,IACP;AAAA,EACF;AACF;AAUO,MAAM,wBAAiC;AAAA,EAC5C,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,QACA,OAAO,KAAK,uBAAuB;AAAA,EACrC,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,KAAK,OAAO;AAAA,IAC1C,GAAG;AAAA,IACH,OAAO;AAAA,IACP,UAAU;AAAA,EACZ;AACF;AAWO,MAAM,uBAAgC;AAAA,EAC3C,IAAI;AAAA,EACJ,WAAW,CAAC,SAAS,OAAO,SAAS;AAAA,EACrC,WAAW,CAAC,MAAc,OAAO,sBAAsB;AACrD,UAAM;AAAA,MACJ;AAAA;AAAA,MACA,GAAG;AAAA,IACL,IAAI;AAEJ,UAAM,eAAW,iCAAoB,IAAI;AAEzC,UAAM,kBAA2B;AAAA,MAC/B,IAAI;AAAA,MACJ,WAAW,CAAC,iBACV,OAAO,iBAAiB,YACxB,OAAO,iBAAiB,YACxB,OAAO,iBAAiB,aACxB,CAAC;AAAA,MACH,WAAW,CAAC,cAAcA,YAAW;AAAA,QACnC,GAAGA;AAAA,QACH,OAAO;AAAA,QACP,UAAU;AAAA,MACZ;AAAA,IACF;AAGA,UAAM,gBAAgB,kBAAkB,UAAU;AAAA,MAChD,SAAS,CAAC,eAAe;AAAA,MACzB,eAAe,KAAK;AAAA,MACpB,SAAS,CAAC;AAAA,IACZ,CAAC;AAED,WAAO;AAAA,MACL,GAAG;AAAA,MACH,OAAO;AAAA,MACP,UAAU;AAAA,MACV,iBAAiB;AAAA,QACf,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AACF;AAUO,MAAM,iBAA0B;AAAA,EACrC,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,qBAAS;AAAA,EAC1D,WAAW,CAAC,MAAuB,OAAO,sBAAsB;AAC9D,UAAM,aAAwB;AAAA,MAC5B,GAAG,MAAM;AAAA,MACT;AAAA,QACE,MAAM,qBAAS;AAAA,MACjB;AAAA,IACF;AAEA,UAAM,WAAW,KAAK,qBAAS,QAAQ;AAEvC,WAAO,kBAAkB,UAAU;AAAA,MACjC,GAAG;AAAA,MACH;AAAA,MACA,SAAS;AAAA,MACT,SAAS,CAAC,sBAAsB,GAAI,MAAM,WAAW,CAAC,CAAE;AAAA,IAC1D,CAAC;AAAA,EACH;AACF;","names":["props"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Injectable } from "@angular/core";
|
|
2
|
+
import { map } from "rxjs";
|
|
3
|
+
@Injectable({
|
|
4
|
+
providedIn: "root"
|
|
5
|
+
})
|
|
6
|
+
class DictionaryService {
|
|
7
|
+
constructor(localeService) {
|
|
8
|
+
this.localeService = localeService;
|
|
9
|
+
}
|
|
10
|
+
dictionaryCache = /* @__PURE__ */ new Map();
|
|
11
|
+
getDictionary(dictionary, locale) {
|
|
12
|
+
const targetLocale = locale || this.localeService.currentLocale;
|
|
13
|
+
const cacheKey = `${dictionary.id}-${targetLocale}`;
|
|
14
|
+
if (this.dictionaryCache.has(cacheKey)) {
|
|
15
|
+
return this.dictionaryCache.get(cacheKey);
|
|
16
|
+
}
|
|
17
|
+
const result = dictionary.content || dictionary;
|
|
18
|
+
this.dictionaryCache.set(cacheKey, result);
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
getDictionary$(dictionary) {
|
|
22
|
+
return this.localeService.locale$.pipe(
|
|
23
|
+
map((locale) => this.getDictionary(dictionary, locale))
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
getDictionaries$(dictionaries) {
|
|
27
|
+
return this.localeService.locale$.pipe(
|
|
28
|
+
map(
|
|
29
|
+
(locale) => dictionaries.map((dict) => this.getDictionary(dict, locale))
|
|
30
|
+
)
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
clearCache() {
|
|
34
|
+
this.dictionaryCache.clear();
|
|
35
|
+
}
|
|
36
|
+
clearCacheForDictionary(dictionaryId) {
|
|
37
|
+
const keysToDelete = Array.from(this.dictionaryCache.keys()).filter(
|
|
38
|
+
(key) => key.startsWith(`${dictionaryId}-`)
|
|
39
|
+
);
|
|
40
|
+
keysToDelete.forEach((key) => this.dictionaryCache.delete(key));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
DictionaryService
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=dictionary.service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/dictionary.service.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport type { Locales } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { Observable, map } from 'rxjs';\nimport { LocaleService } from './locale.service';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class DictionaryService {\n private dictionaryCache = new Map<string, any>();\n\n constructor(private localeService: LocaleService) {}\n\n getDictionary<T extends Dictionary & { id: string }>(\n dictionary: T,\n locale?: Locales\n ): any {\n const targetLocale = locale || this.localeService.currentLocale;\n const cacheKey = `${dictionary.id}-${targetLocale}`;\n\n if (this.dictionaryCache.has(cacheKey)) {\n return this.dictionaryCache.get(cacheKey);\n }\n\n // Use a simpler approach to avoid type complexity\n const result = dictionary.content || dictionary;\n this.dictionaryCache.set(cacheKey, result);\n\n return result;\n }\n\n getDictionary$<T extends Dictionary & { id: string }>(\n dictionary: T\n ): Observable<any> {\n return this.localeService.locale$.pipe(\n map((locale) => this.getDictionary(dictionary, locale))\n );\n }\n\n getDictionaries$(\n dictionaries: (Dictionary & { id: string })[]\n ): Observable<any[]> {\n return this.localeService.locale$.pipe(\n map((locale) =>\n dictionaries.map((dict) => this.getDictionary(dict, locale))\n )\n );\n }\n\n clearCache(): void {\n this.dictionaryCache.clear();\n }\n\n clearCacheForDictionary(dictionaryId: string): void {\n const keysToDelete = Array.from(this.dictionaryCache.keys()).filter((key) =>\n key.startsWith(`${dictionaryId}-`)\n );\n\n keysToDelete.forEach((key) => this.dictionaryCache.delete(key));\n }\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAG3B,SAAqB,WAAW;AAGhC,CAAC,WAAW;AAAA,EACV,YAAY;AACd,CAAC;AACM,MAAM,kBAAkB;AAAA,EAG7B,YAAoB,eAA8B;AAA9B;AAAA,EAA+B;AAAA,EAF3C,kBAAkB,oBAAI,IAAiB;AAAA,EAI/C,cACE,YACA,QACK;AACL,UAAM,eAAe,UAAU,KAAK,cAAc;AAClD,UAAM,WAAW,GAAG,WAAW,EAAE,IAAI,YAAY;AAEjD,QAAI,KAAK,gBAAgB,IAAI,QAAQ,GAAG;AACtC,aAAO,KAAK,gBAAgB,IAAI,QAAQ;AAAA,IAC1C;AAGA,UAAM,SAAS,WAAW,WAAW;AACrC,SAAK,gBAAgB,IAAI,UAAU,MAAM;AAEzC,WAAO;AAAA,EACT;AAAA,EAEA,eACE,YACiB;AACjB,WAAO,KAAK,cAAc,QAAQ;AAAA,MAChC,IAAI,CAAC,WAAW,KAAK,cAAc,YAAY,MAAM,CAAC;AAAA,IACxD;AAAA,EACF;AAAA,EAEA,iBACE,cACmB;AACnB,WAAO,KAAK,cAAc,QAAQ;AAAA,MAChC;AAAA,QAAI,CAAC,WACH,aAAa,IAAI,CAAC,SAAS,KAAK,cAAc,MAAM,MAAM,CAAC;AAAA,MAC7D;AAAA,IACF;AAAA,EACF;AAAA,EAEA,aAAmB;AACjB,SAAK,gBAAgB,MAAM;AAAA,EAC7B;AAAA,EAEA,wBAAwB,cAA4B;AAClD,UAAM,eAAe,MAAM,KAAK,KAAK,gBAAgB,KAAK,CAAC,EAAE;AAAA,MAAO,CAAC,QACnE,IAAI,WAAW,GAAG,YAAY,GAAG;AAAA,IACnC;AAEA,iBAAa,QAAQ,CAAC,QAAQ,KAAK,gBAAgB,OAAO,GAAG,CAAC;AAAA,EAChE;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/getBrowserLocale.ts"],"sourcesContent":["import { Locales } from '@intlayer/config';\n\n/**\n * Get the locale from the browser\n */\nexport const getBrowserLocale = (): Locales | undefined => {\n if (typeof window !== 'undefined' && window.navigator) {\n return window.navigator.language.split('-')[0] as Locales;\n }\n return undefined;\n};\n"],"mappings":"AAKO,MAAM,mBAAmB,MAA2B;AACzD,MAAI,OAAO,WAAW,eAAe,OAAO,WAAW;AACrD,WAAO,OAAO,UAAU,SAAS,MAAM,GAAG,EAAE,CAAC;AAAA,EAC/C;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getDictionary as getDictionaryCore
|
|
3
|
+
} from "@intlayer/core";
|
|
4
|
+
import {
|
|
5
|
+
angularTemplatePlugin,
|
|
6
|
+
intlayerNodePlugins,
|
|
7
|
+
markdownPlugin
|
|
8
|
+
} from "../plugins.mjs";
|
|
9
|
+
const getDictionary = (dictionary, locale, additionalPlugins) => {
|
|
10
|
+
const plugins = [
|
|
11
|
+
intlayerNodePlugins,
|
|
12
|
+
angularTemplatePlugin,
|
|
13
|
+
markdownPlugin,
|
|
14
|
+
...additionalPlugins ?? []
|
|
15
|
+
];
|
|
16
|
+
return getDictionaryCore(
|
|
17
|
+
dictionary,
|
|
18
|
+
locale,
|
|
19
|
+
plugins
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
getDictionary
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=getDictionary.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/getDictionary.ts"],"sourcesContent":["import type { Locales, LocalesValues } from '@intlayer/config';\nimport {\n type Dictionary,\n type Plugins,\n getDictionary as getDictionaryCore,\n} from '@intlayer/core';\nimport {\n type DeepTransformContent,\n angularTemplatePlugin,\n intlayerNodePlugins,\n markdownPlugin,\n} from '../plugins';\n\n/**\n * Get dictionary content for a specific locale\n */\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = Locales,\n>(\n dictionary: T,\n locale?: L,\n additionalPlugins?: Plugins[]\n) => {\n const plugins: Plugins[] = [\n intlayerNodePlugins,\n angularTemplatePlugin,\n markdownPlugin,\n ...(additionalPlugins ?? []),\n ];\n\n return getDictionaryCore(\n dictionary,\n locale,\n plugins\n ) as any as DeepTransformContent<T['content']>;\n};\n"],"mappings":"AACA;AAAA,EAGE,iBAAiB;AAAA,OACZ;AACP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAKA,MAAM,gBAAgB,CAI3B,YACA,QACA,sBACG;AACH,QAAM,UAAqB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAI,qBAAqB,CAAC;AAAA,EAC5B;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/getLocale.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config';\n\n/**\n * Get the current locale\n * This is a basic implementation that can be extended with Angular services\n */\nexport const getLocale = (): Locales => {\n // This is a placeholder implementation\n // In a real Angular app, this would likely use a service or injection\n return 'en' as Locales;\n};\n"],"mappings":"AAMO,MAAM,YAAY,MAAe;AAGtC,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DictionaryService } from "./dictionary.service.mjs";
|
|
2
|
+
import { getBrowserLocale } from "./getBrowserLocale.mjs";
|
|
3
|
+
import { getDictionary } from "./getDictionary.mjs";
|
|
4
|
+
import { getLocale } from "./getLocale.mjs";
|
|
5
|
+
import { IntlayerService } from "./intlayer.service.mjs";
|
|
6
|
+
import { LocaleService } from "./locale.service.mjs";
|
|
7
|
+
import { t } from "./t.mjs";
|
|
8
|
+
export {
|
|
9
|
+
DictionaryService,
|
|
10
|
+
IntlayerService,
|
|
11
|
+
LocaleService,
|
|
12
|
+
getBrowserLocale,
|
|
13
|
+
getDictionary,
|
|
14
|
+
getLocale,
|
|
15
|
+
t
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export { DictionaryService } from './dictionary.service';\nexport { getBrowserLocale } from './getBrowserLocale';\nexport { getDictionary } from './getDictionary';\nexport { getLocale } from './getLocale';\nexport { IntlayerService } from './intlayer.service';\nexport { LocaleService } from './locale.service';\nexport { t } from './t';\n"],"mappings":"AAAA,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;AAC9B,SAAS,SAAS;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Injectable } from "@angular/core";
|
|
2
|
+
import { BehaviorSubject } from "rxjs";
|
|
3
|
+
@Injectable({
|
|
4
|
+
providedIn: "root"
|
|
5
|
+
})
|
|
6
|
+
class IntlayerService {
|
|
7
|
+
localeSubject = new BehaviorSubject("en");
|
|
8
|
+
locale$ = this.localeSubject.asObservable();
|
|
9
|
+
get currentLocale() {
|
|
10
|
+
return this.localeSubject.value;
|
|
11
|
+
}
|
|
12
|
+
setLocale(locale) {
|
|
13
|
+
this.localeSubject.next(locale);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
IntlayerService
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=intlayer.service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/intlayer.service.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport type { Locales } from '@intlayer/config';\nimport { BehaviorSubject } from 'rxjs';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerService {\n private localeSubject = new BehaviorSubject<Locales>('en' as Locales);\n public locale$ = this.localeSubject.asObservable();\n\n get currentLocale(): Locales {\n return this.localeSubject.value;\n }\n\n setLocale(locale: Locales): void {\n this.localeSubject.next(locale);\n }\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAE3B,SAAS,uBAAuB;AAEhC,CAAC,WAAW;AAAA,EACV,YAAY;AACd,CAAC;AACM,MAAM,gBAAgB;AAAA,EACnB,gBAAgB,IAAI,gBAAyB,IAAe;AAAA,EAC7D,UAAU,KAAK,cAAc,aAAa;AAAA,EAEjD,IAAI,gBAAyB;AAC3B,WAAO,KAAK,cAAc;AAAA,EAC5B;AAAA,EAEA,UAAU,QAAuB;AAC/B,SAAK,cAAc,KAAK,MAAM;AAAA,EAChC;AACF;","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Injectable } from "@angular/core";
|
|
2
|
+
import { BehaviorSubject } from "rxjs";
|
|
3
|
+
import { getBrowserLocale } from "./getBrowserLocale.mjs";
|
|
4
|
+
@Injectable({
|
|
5
|
+
providedIn: "root"
|
|
6
|
+
})
|
|
7
|
+
class LocaleService {
|
|
8
|
+
localeSubject = new BehaviorSubject(
|
|
9
|
+
getBrowserLocale() || "en"
|
|
10
|
+
);
|
|
11
|
+
locale$ = this.localeSubject.asObservable();
|
|
12
|
+
constructor() {
|
|
13
|
+
const browserLocale = getBrowserLocale();
|
|
14
|
+
if (browserLocale) {
|
|
15
|
+
this.setLocale(browserLocale);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
get currentLocale() {
|
|
19
|
+
return this.localeSubject.value;
|
|
20
|
+
}
|
|
21
|
+
setLocale(locale) {
|
|
22
|
+
this.localeSubject.next(locale);
|
|
23
|
+
if (typeof localStorage !== "undefined") {
|
|
24
|
+
localStorage.setItem("intlayer-locale", locale);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
getStoredLocale() {
|
|
28
|
+
if (typeof localStorage !== "undefined") {
|
|
29
|
+
return localStorage.getItem("intlayer-locale");
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
clearStoredLocale() {
|
|
34
|
+
if (typeof localStorage !== "undefined") {
|
|
35
|
+
localStorage.removeItem("intlayer-locale");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
LocaleService
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=locale.service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/locale.service.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport type { Locales } from '@intlayer/config';\nimport { BehaviorSubject, Observable } from 'rxjs';\nimport { getBrowserLocale } from './getBrowserLocale';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class LocaleService {\n private localeSubject = new BehaviorSubject<Locales>(\n getBrowserLocale() || ('en' as Locales)\n );\n\n public locale$: Observable<Locales> = this.localeSubject.asObservable();\n\n constructor() {\n // Initialize with browser locale if available\n const browserLocale = getBrowserLocale();\n if (browserLocale) {\n this.setLocale(browserLocale);\n }\n }\n\n get currentLocale(): Locales {\n return this.localeSubject.value;\n }\n\n setLocale(locale: Locales): void {\n this.localeSubject.next(locale);\n\n // Optionally store in localStorage for persistence\n if (typeof localStorage !== 'undefined') {\n localStorage.setItem('intlayer-locale', locale);\n }\n }\n\n getStoredLocale(): Locales | null {\n if (typeof localStorage !== 'undefined') {\n return localStorage.getItem('intlayer-locale') as Locales;\n }\n return null;\n }\n\n clearStoredLocale(): void {\n if (typeof localStorage !== 'undefined') {\n localStorage.removeItem('intlayer-locale');\n }\n }\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAE3B,SAAS,uBAAmC;AAC5C,SAAS,wBAAwB;AAEjC,CAAC,WAAW;AAAA,EACV,YAAY;AACd,CAAC;AACM,MAAM,cAAc;AAAA,EACjB,gBAAgB,IAAI;AAAA,IAC1B,iBAAiB,KAAM;AAAA,EACzB;AAAA,EAEO,UAA+B,KAAK,cAAc,aAAa;AAAA,EAEtE,cAAc;AAEZ,UAAM,gBAAgB,iBAAiB;AACvC,QAAI,eAAe;AACjB,WAAK,UAAU,aAAa;AAAA,IAC9B;AAAA,EACF;AAAA,EAEA,IAAI,gBAAyB;AAC3B,WAAO,KAAK,cAAc;AAAA,EAC5B;AAAA,EAEA,UAAU,QAAuB;AAC/B,SAAK,cAAc,KAAK,MAAM;AAG9B,QAAI,OAAO,iBAAiB,aAAa;AACvC,mBAAa,QAAQ,mBAAmB,MAAM;AAAA,IAChD;AAAA,EACF;AAAA,EAEA,kBAAkC;AAChC,QAAI,OAAO,iBAAiB,aAAa;AACvC,aAAO,aAAa,QAAQ,iBAAiB;AAAA,IAC/C;AACA,WAAO;AAAA,EACT;AAAA,EAEA,oBAA0B;AACxB,QAAI,OAAO,iBAAiB,aAAa;AACvC,mBAAa,WAAW,iBAAiB;AAAA,IAC3C;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/t.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config';\nimport { type LanguageContent, getTranslation } from '@intlayer/core';\n\n/**\n * Translation function for Angular applications\n * Returns the translation of the provided multilang content\n */\nexport const t = <Content = string>(\n multilangContent: LanguageContent<Content>,\n locale: Locales\n) => {\n return getTranslation<Content>(multilangContent, locale);\n};\n"],"mappings":"AACA,SAA+B,sBAAsB;AAM9C,MAAM,IAAI,CACf,kBACA,WACG;AACH,SAAO,eAAwB,kBAAkB,MAAM;AACzD;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/getDictionary.ts"],"sourcesContent":["export { getDictionary } from './client/getDictionary';\n"],"mappings":"AAAA,SAAS,qBAAqB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import type { Locales, LocalesValues } from '@intlayer/config';\nimport type { Dictionary, Plugins } from '@intlayer/core';\n\n/**\n * Function to get the content of a dictionary for Angular applications\n */\nexport const getIntlayer = <\n T extends Dictionary,\n L extends LocalesValues = Locales,\n>(\n dictionary: T,\n locale: L,\n additionalPlugins?: Plugins[]\n): any => {\n // Simplified implementation to avoid type complexity\n return dictionary.content || dictionary;\n};\n"],"mappings":"AAMO,MAAM,cAAc,CAIzB,YACA,QACA,sBACQ;AAER,SAAO,WAAW,WAAW;AAC/B;","names":[]}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
1
|
+
export * from "./client/index.mjs";
|
|
2
|
+
export * from "./getDictionary.mjs";
|
|
3
|
+
export * from "./getIntlayer.mjs";
|
|
4
|
+
export * from "./markdown/index.mjs";
|
|
5
|
+
export * from "./plugins.mjs";
|
|
3
6
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { IInterpreterPluginAngular } from './plugins';\n\ndeclare module '@intlayer/core' {\n interface IInterpreterPlugin<T, S> extends IInterpreterPluginAngular<T> {}\n}\n\nexport * from './client';\nexport * from './getDictionary';\nexport * from './getIntlayer';\nexport * from './markdown';\nexport * from './plugins';\n"],"mappings":"AAMA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/markdown/index.ts"],"sourcesContent":["// Basic markdown support for Angular\n// This could be extended with Angular-specific markdown components\n\nexport const renderMarkdown = (content: string): string => {\n // Basic implementation - in a real app this might use a markdown library\n return content;\n};\n\nexport const MarkdownModule = {\n renderMarkdown,\n};\n"],"mappings":"AAGO,MAAM,iBAAiB,CAAC,YAA4B;AAEzD,SAAO;AACT;AAEO,MAAM,iBAAiB;AAAA,EAC5B;AACF;","names":[]}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getMarkdownMetadata,
|
|
3
|
+
NodeType
|
|
4
|
+
} from "@intlayer/core";
|
|
5
|
+
const intlayerNodePlugins = {
|
|
6
|
+
id: "intlayer-node-plugin",
|
|
7
|
+
canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
|
|
8
|
+
transform: (_node, { children, ...rest }) => ({
|
|
9
|
+
...rest,
|
|
10
|
+
value: children,
|
|
11
|
+
children
|
|
12
|
+
})
|
|
13
|
+
};
|
|
14
|
+
const angularTemplatePlugin = {
|
|
15
|
+
id: "angular-template-plugin",
|
|
16
|
+
canHandle: (node) => typeof node === "object" && node && typeof node.createEmbeddedView === "function",
|
|
17
|
+
transform: (node, { plugins, ...rest }) => ({
|
|
18
|
+
...rest,
|
|
19
|
+
value: "[[angular-template]]",
|
|
20
|
+
children: node
|
|
21
|
+
})
|
|
22
|
+
};
|
|
23
|
+
const markdownStringPlugin = {
|
|
24
|
+
id: "markdown-string-plugin",
|
|
25
|
+
canHandle: (node) => typeof node === "string",
|
|
26
|
+
transform: (node, props, deepTransformNode) => {
|
|
27
|
+
const {
|
|
28
|
+
plugins,
|
|
29
|
+
// Removed to avoid circular dependencies
|
|
30
|
+
...rest
|
|
31
|
+
} = props;
|
|
32
|
+
const metadata = getMarkdownMetadata(node);
|
|
33
|
+
const metadataPlugins = {
|
|
34
|
+
id: "markdown-metadata-plugin",
|
|
35
|
+
canHandle: (metadataNode) => typeof metadataNode === "string" || typeof metadataNode === "number" || typeof metadataNode === "boolean" || !metadataNode,
|
|
36
|
+
transform: (metadataNode, props2) => ({
|
|
37
|
+
...props2,
|
|
38
|
+
value: metadataNode,
|
|
39
|
+
children: node
|
|
40
|
+
})
|
|
41
|
+
};
|
|
42
|
+
const metadataNodes = deepTransformNode(metadata, {
|
|
43
|
+
plugins: [metadataPlugins],
|
|
44
|
+
dictionaryKey: rest.dictionaryKey,
|
|
45
|
+
keyPath: []
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
...props,
|
|
49
|
+
value: node,
|
|
50
|
+
children: node,
|
|
51
|
+
additionalProps: {
|
|
52
|
+
metadata: metadataNodes
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const markdownPlugin = {
|
|
58
|
+
id: "markdown-plugin",
|
|
59
|
+
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeType.Markdown,
|
|
60
|
+
transform: (node, props, deepTransformNode) => {
|
|
61
|
+
const newKeyPath = [
|
|
62
|
+
...props.keyPath,
|
|
63
|
+
{
|
|
64
|
+
type: NodeType.Markdown
|
|
65
|
+
}
|
|
66
|
+
];
|
|
67
|
+
const children = node[NodeType.Markdown];
|
|
68
|
+
return deepTransformNode(children, {
|
|
69
|
+
...props,
|
|
70
|
+
children,
|
|
71
|
+
keyPath: newKeyPath,
|
|
72
|
+
plugins: [markdownStringPlugin, ...props.plugins ?? []]
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
export {
|
|
77
|
+
angularTemplatePlugin,
|
|
78
|
+
intlayerNodePlugins,
|
|
79
|
+
markdownPlugin,
|
|
80
|
+
markdownStringPlugin
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=plugins.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/plugins.ts"],"sourcesContent":["import type { TemplateRef } from '@angular/core';\nimport {\n getMarkdownMetadata,\n KeyPath,\n MarkdownContent,\n NodeType,\n type DeepTransformContent as DeepTransformContentCore,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type Plugins,\n} from '@intlayer/core';\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 ...rest,\n value: children,\n children,\n }),\n};\n\n/** ---------------------------------------------\n * ANGULAR TEMPLATE PLUGIN\n * --------------------------------------------- */\n\nexport type AngularTemplateCond<T> =\n T extends TemplateRef<any> ? TemplateRef<any> : never;\n\n/** Angular template plugin. Handles Angular TemplateRef objects. */\nexport const angularTemplatePlugin: Plugins = {\n id: 'angular-template-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n node &&\n typeof node.createEmbeddedView === 'function',\n transform: (node, { plugins, ...rest }) => ({\n ...rest,\n value: '[[angular-template]]',\n children: node,\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 circular dependencies\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 ...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 return {\n ...props,\n value: node,\n children: node,\n additionalProps: {\n metadata: metadataNodes,\n },\n };\n },\n};\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer M;\n metadata?: infer U;\n}\n ? IntlayerNode<DeepTransformContent<M>, { metadata: DeepTransformContent<U> }>\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 * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginAngular<T> {\n angularTemplate: AngularTemplateCond<T>;\n intlayerNode: IntlayerNodeCond<T>;\n markdown: MarkdownCond<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 = IInterpreterPluginStateCore & {\n angularTemplate: true;\n intlayerNode: true;\n markdown: true;\n};\n\nexport type DeepTransformContent<T> = DeepTransformContentCore<\n T,\n IInterpreterPluginState\n>;\n"],"mappings":"AACA;AAAA,EACE;AAAA,EAGA;AAAA,OAIK;AAiBA,MAAM,sBAA+B;AAAA,EAC1C,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;AAAA,EAClB,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,KAAK,OAAO;AAAA,IAC5C,GAAG;AAAA,IACH,OAAO;AAAA,IACP;AAAA,EACF;AACF;AAUO,MAAM,wBAAiC;AAAA,EAC5C,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,QACA,OAAO,KAAK,uBAAuB;AAAA,EACrC,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,KAAK,OAAO;AAAA,IAC1C,GAAG;AAAA,IACH,OAAO;AAAA,IACP,UAAU;AAAA,EACZ;AACF;AAWO,MAAM,uBAAgC;AAAA,EAC3C,IAAI;AAAA,EACJ,WAAW,CAAC,SAAS,OAAO,SAAS;AAAA,EACrC,WAAW,CAAC,MAAc,OAAO,sBAAsB;AACrD,UAAM;AAAA,MACJ;AAAA;AAAA,MACA,GAAG;AAAA,IACL,IAAI;AAEJ,UAAM,WAAW,oBAAoB,IAAI;AAEzC,UAAM,kBAA2B;AAAA,MAC/B,IAAI;AAAA,MACJ,WAAW,CAAC,iBACV,OAAO,iBAAiB,YACxB,OAAO,iBAAiB,YACxB,OAAO,iBAAiB,aACxB,CAAC;AAAA,MACH,WAAW,CAAC,cAAcA,YAAW;AAAA,QACnC,GAAGA;AAAA,QACH,OAAO;AAAA,QACP,UAAU;AAAA,MACZ;AAAA,IACF;AAGA,UAAM,gBAAgB,kBAAkB,UAAU;AAAA,MAChD,SAAS,CAAC,eAAe;AAAA,MACzB,eAAe,KAAK;AAAA,MACpB,SAAS,CAAC;AAAA,IACZ,CAAC;AAED,WAAO;AAAA,MACL,GAAG;AAAA,MACH,OAAO;AAAA,MACP,UAAU;AAAA,MACV,iBAAiB;AAAA,QACf,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AACF;AAUO,MAAM,iBAA0B;AAAA,EACrC,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,SAAS;AAAA,EAC1D,WAAW,CAAC,MAAuB,OAAO,sBAAsB;AAC9D,UAAM,aAAwB;AAAA,MAC5B,GAAG,MAAM;AAAA,MACT;AAAA,QACE,MAAM,SAAS;AAAA,MACjB;AAAA,IACF;AAEA,UAAM,WAAW,KAAK,SAAS,QAAQ;AAEvC,WAAO,kBAAkB,UAAU;AAAA,MACjC,GAAG;AAAA,MACH;AAAA,MACA,SAAS;AAAA,MACT,SAAS,CAAC,sBAAsB,GAAI,MAAM,WAAW,CAAC,CAAE;AAAA,IAC1D,CAAC;AAAA,EACH;AACF;","names":["props"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Locales } from '@intlayer/config';
|
|
2
|
+
import type { Dictionary } from '@intlayer/core';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
import { LocaleService } from './locale.service';
|
|
5
|
+
export declare class DictionaryService {
|
|
6
|
+
private localeService;
|
|
7
|
+
private dictionaryCache;
|
|
8
|
+
constructor(localeService: LocaleService);
|
|
9
|
+
getDictionary<T extends Dictionary & {
|
|
10
|
+
id: string;
|
|
11
|
+
}>(dictionary: T, locale?: Locales): any;
|
|
12
|
+
getDictionary$<T extends Dictionary & {
|
|
13
|
+
id: string;
|
|
14
|
+
}>(dictionary: T): Observable<any>;
|
|
15
|
+
getDictionaries$(dictionaries: (Dictionary & {
|
|
16
|
+
id: string;
|
|
17
|
+
})[]): Observable<any[]>;
|
|
18
|
+
clearCache(): void;
|
|
19
|
+
clearCacheForDictionary(dictionaryId: string): void;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=dictionary.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dictionary.service.d.ts","sourceRoot":"","sources":["../../../src/client/dictionary.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAO,MAAM,MAAM,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,qBAGa,iBAAiB;IAGhB,OAAO,CAAC,aAAa;IAFjC,OAAO,CAAC,eAAe,CAA0B;gBAE7B,aAAa,EAAE,aAAa;IAEhD,aAAa,CAAC,CAAC,SAAS,UAAU,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,EACjD,UAAU,EAAE,CAAC,EACb,MAAM,CAAC,EAAE,OAAO,GACf,GAAG;IAeN,cAAc,CAAC,CAAC,SAAS,UAAU,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,EAClD,UAAU,EAAE,CAAC,GACZ,UAAU,CAAC,GAAG,CAAC;IAMlB,gBAAgB,CACd,YAAY,EAAE,CAAC,UAAU,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,GAC5C,UAAU,CAAC,GAAG,EAAE,CAAC;IAQpB,UAAU,IAAI,IAAI;IAIlB,uBAAuB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CAOpD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getBrowserLocale.d.ts","sourceRoot":"","sources":["../../../src/client/getBrowserLocale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAAO,OAAO,GAAG,SAK7C,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Locales, LocalesValues } from '@intlayer/config';
|
|
2
|
+
import { type Dictionary, type Plugins } from '@intlayer/core';
|
|
3
|
+
import { type DeepTransformContent } from '../plugins';
|
|
4
|
+
/**
|
|
5
|
+
* Get dictionary content for a specific locale
|
|
6
|
+
*/
|
|
7
|
+
export declare const getDictionary: <T extends Dictionary, L extends LocalesValues = Locales>(dictionary: T, locale?: L, additionalPlugins?: Plugins[]) => DeepTransformContent<T["content"]>;
|
|
8
|
+
//# sourceMappingURL=getDictionary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDictionary.d.ts","sourceRoot":"","sources":["../../../src/client/getDictionary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EACL,KAAK,UAAU,EACf,KAAK,OAAO,EAEb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,KAAK,oBAAoB,EAI1B,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,eAAO,MAAM,aAAa,GACxB,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,aAAa,GAAG,OAAO,EAEjC,YAAY,CAAC,EACb,SAAS,CAAC,EACV,oBAAoB,OAAO,EAAE,KAajB,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,CAC9C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLocale.d.ts","sourceRoot":"","sources":["../../../src/client/getLocale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,SAAS,QAAO,OAI5B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { DictionaryService } from './dictionary.service';
|
|
2
|
+
export { getBrowserLocale } from './getBrowserLocale';
|
|
3
|
+
export { getDictionary } from './getDictionary';
|
|
4
|
+
export { getLocale } from './getLocale';
|
|
5
|
+
export { IntlayerService } from './intlayer.service';
|
|
6
|
+
export { LocaleService } from './locale.service';
|
|
7
|
+
export { t } from './t';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Locales } from '@intlayer/config';
|
|
2
|
+
export declare class IntlayerService {
|
|
3
|
+
private localeSubject;
|
|
4
|
+
locale$: import("rxjs").Observable<Locales>;
|
|
5
|
+
get currentLocale(): Locales;
|
|
6
|
+
setLocale(locale: Locales): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=intlayer.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intlayer.service.d.ts","sourceRoot":"","sources":["../../../src/client/intlayer.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAGhD,qBAGa,eAAe;IAC1B,OAAO,CAAC,aAAa,CAAiD;IAC/D,OAAO,qCAAqC;IAEnD,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;CAGjC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Locales } from '@intlayer/config';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
export declare class LocaleService {
|
|
4
|
+
private localeSubject;
|
|
5
|
+
locale$: Observable<Locales>;
|
|
6
|
+
constructor();
|
|
7
|
+
get currentLocale(): Locales;
|
|
8
|
+
setLocale(locale: Locales): void;
|
|
9
|
+
getStoredLocale(): Locales | null;
|
|
10
|
+
clearStoredLocale(): void;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=locale.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale.service.d.ts","sourceRoot":"","sources":["../../../src/client/locale.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAmB,UAAU,EAAE,MAAM,MAAM,CAAC;AAGnD,qBAGa,aAAa;IACxB,OAAO,CAAC,aAAa,CAEnB;IAEK,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,CAAqC;;IAUxE,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAShC,eAAe,IAAI,OAAO,GAAG,IAAI;IAOjC,iBAAiB,IAAI,IAAI;CAK1B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Locales } from '@intlayer/config';
|
|
2
|
+
import { type LanguageContent } from '@intlayer/core';
|
|
3
|
+
/**
|
|
4
|
+
* Translation function for Angular applications
|
|
5
|
+
* Returns the translation of the provided multilang content
|
|
6
|
+
*/
|
|
7
|
+
export declare const t: <Content = string>(multilangContent: LanguageContent<Content>, locale: Locales) => Content;
|
|
8
|
+
//# sourceMappingURL=t.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"t.d.ts","sourceRoot":"","sources":["../../../src/client/t.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,KAAK,eAAe,EAAkB,MAAM,gBAAgB,CAAC;AAEtE;;;GAGG;AACH,eAAO,MAAM,CAAC,GAAI,OAAO,GAAG,MAAM,EAChC,kBAAkB,eAAe,CAAC,OAAO,CAAC,EAC1C,QAAQ,OAAO,YAGhB,CAAC"}
|