angular-intlayer 7.6.0-canary.0 → 8.0.0-canary.0
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/index.cjs +2 -0
- package/dist/cjs/client/useIntl.cjs +40 -0
- package/dist/cjs/client/useIntl.cjs.map +1 -0
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs +2 -2
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -1
- package/dist/cjs/plugins.cjs +11 -3
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/esm/client/index.mjs +2 -1
- package/dist/esm/client/useIntl.mjs +39 -0
- package/dist/esm/client/useIntl.mjs.map +1 -0
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/markdown/installIntlayerMarkdown.mjs +2 -2
- package/dist/esm/markdown/installIntlayerMarkdown.mjs.map +1 -1
- package/dist/esm/plugins.mjs +11 -3
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/types/client/index.d.ts +2 -1
- package/dist/types/client/useDictionaryDynamic.d.ts +2 -2
- package/dist/types/client/useIntl.d.ts +90 -0
- package/dist/types/client/useIntl.d.ts.map +1 -0
- package/dist/types/client/useLocale.d.ts +5 -5
- package/dist/types/client/useLocaleStorage.d.ts +5 -5
- package/dist/types/editor/ContentSelectorWrapper.component.d.ts +3 -3
- package/dist/types/editor/EditedContentRenderer.component.d.ts +2 -2
- package/dist/types/editor/useCrossURLPathState.d.ts +3 -3
- package/dist/types/index.d.ts +4 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/markdown/installIntlayerMarkdown.d.ts +7 -2
- package/dist/types/markdown/installIntlayerMarkdown.d.ts.map +1 -1
- package/dist/types/plugins.d.ts +7 -6
- package/dist/types/plugins.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -3,6 +3,7 @@ const require_client_useDictionary = require('./useDictionary.cjs');
|
|
|
3
3
|
const require_client_useDictionaryAsync = require('./useDictionaryAsync.cjs');
|
|
4
4
|
const require_client_useLoadDynamic = require('./useLoadDynamic.cjs');
|
|
5
5
|
const require_client_useDictionaryDynamic = require('./useDictionaryDynamic.cjs');
|
|
6
|
+
const require_client_useIntl = require('./useIntl.cjs');
|
|
6
7
|
const require_client_useIntlayer = require('./useIntlayer.cjs');
|
|
7
8
|
const require_client_useLocale = require('./useLocale.cjs');
|
|
8
9
|
|
|
@@ -14,6 +15,7 @@ exports.isUpdatableNode = require_client_useIntlayer.isUpdatableNode;
|
|
|
14
15
|
exports.useDictionary = require_client_useDictionary.useDictionary;
|
|
15
16
|
exports.useDictionaryAsync = require_client_useDictionaryAsync.useDictionaryAsync;
|
|
16
17
|
exports.useDictionaryDynamic = require_client_useDictionaryDynamic.useDictionaryDynamic;
|
|
18
|
+
exports.useIntl = require_client_useIntl.useIntl;
|
|
17
19
|
exports.useIntlayer = require_client_useIntlayer.useIntlayer;
|
|
18
20
|
exports.useLoadDynamic = require_client_useLoadDynamic.useLoadDynamic;
|
|
19
21
|
exports.useLocale = require_client_useLocale.useLocale;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_client_installIntlayer = require('./installIntlayer.cjs');
|
|
3
|
+
let _intlayer_core = require("@intlayer/core");
|
|
4
|
+
let _angular_core = require("@angular/core");
|
|
5
|
+
|
|
6
|
+
//#region src/client/useIntl.ts
|
|
7
|
+
/**
|
|
8
|
+
* Angular composable that provides a locale-bound `Intl` object.
|
|
9
|
+
*
|
|
10
|
+
* It acts exactly like the native `Intl` object, but acts as a proxy to:
|
|
11
|
+
* 1. Inject the current locale automatically if none is provided.
|
|
12
|
+
* 2. Use the performance-optimized `CachedIntl` under the hood.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { Component, computed } from '@angular/core';
|
|
17
|
+
* import { useIntl } from 'angular-intlayer';
|
|
18
|
+
*
|
|
19
|
+
* @Component({ ... })
|
|
20
|
+
* export class MyComponent {
|
|
21
|
+
* intl = useIntl();
|
|
22
|
+
* formattedPrice = computed(() =>
|
|
23
|
+
* new this.intl().NumberFormat({
|
|
24
|
+
* style: 'currency',
|
|
25
|
+
* currency: 'USD'
|
|
26
|
+
* }).format(123.45)
|
|
27
|
+
* );
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
const useIntl = (locale) => {
|
|
32
|
+
const intlayer = (0, _angular_core.inject)(require_client_installIntlayer.IntlayerProvider);
|
|
33
|
+
return (0, _angular_core.computed)(() => {
|
|
34
|
+
return (0, _intlayer_core.bindIntl)(locale ?? intlayer.locale());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
exports.useIntl = useIntl;
|
|
40
|
+
//# sourceMappingURL=useIntl.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIntl.cjs","names":["IntlayerProvider"],"sources":["../../../src/client/useIntl.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport { bindIntl } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerProvider } from './installIntlayer';\n\n/**\n * Angular composable that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```typescript\n * import { Component, computed } from '@angular/core';\n * import { useIntl } from 'angular-intlayer';\n *\n * @Component({ ... })\n * export class MyComponent {\n * intl = useIntl();\n * formattedPrice = computed(() =>\n * new this.intl().NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45)\n * );\n * }\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const intlayer = inject(IntlayerProvider);\n\n return computed(() => {\n const currentLocale = locale ?? intlayer.locale();\n\n return bindIntl(currentLocale);\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,WAAW,WAA2B;CACjD,MAAM,qCAAkBA,gDAAiB;AAEzC,0CAAsB;AAGpB,sCAFsB,UAAU,SAAS,QAAQ,CAEnB;GAC9B"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@ const require_client_useDictionary = require('./client/useDictionary.cjs');
|
|
|
3
3
|
const require_client_useDictionaryAsync = require('./client/useDictionaryAsync.cjs');
|
|
4
4
|
const require_client_useLoadDynamic = require('./client/useLoadDynamic.cjs');
|
|
5
5
|
const require_client_useDictionaryDynamic = require('./client/useDictionaryDynamic.cjs');
|
|
6
|
+
const require_client_useIntl = require('./client/useIntl.cjs');
|
|
6
7
|
const require_getIntlayer = require('./getIntlayer.cjs');
|
|
7
8
|
const require_client_useIntlayer = require('./client/useIntlayer.cjs');
|
|
8
9
|
const require_client_useLocale = require('./client/useLocale.cjs');
|
|
@@ -26,6 +27,7 @@ exports.markdownStringPlugin = require_plugins.markdownStringPlugin;
|
|
|
26
27
|
exports.useDictionary = require_client_useDictionary.useDictionary;
|
|
27
28
|
exports.useDictionaryAsync = require_client_useDictionaryAsync.useDictionaryAsync;
|
|
28
29
|
exports.useDictionaryDynamic = require_client_useDictionaryDynamic.useDictionaryDynamic;
|
|
30
|
+
exports.useIntl = require_client_useIntl.useIntl;
|
|
29
31
|
exports.useIntlayer = require_client_useIntlayer.useIntlayer;
|
|
30
32
|
exports.useLoadDynamic = require_client_useLoadDynamic.useLoadDynamic;
|
|
31
33
|
exports.useLocale = require_client_useLocale.useLocale;
|
|
@@ -16,9 +16,9 @@ const createIntlayerMarkdownProvider = (renderMarkdown = defaultMarkdownRenderer
|
|
|
16
16
|
});
|
|
17
17
|
var IntlayerMarkdownService = @((0, _angular_core.Injectable)({ providedIn: "root" })) class {
|
|
18
18
|
markdownProvider = (0, _angular_core.inject)(INTLAYER_MARKDOWN_TOKEN, { optional: true });
|
|
19
|
-
renderMarkdown(markdown) {
|
|
19
|
+
renderMarkdown(markdown, overrides) {
|
|
20
20
|
if (!this.markdownProvider) return markdown;
|
|
21
|
-
return this.markdownProvider.renderMarkdown(markdown);
|
|
21
|
+
return this.markdownProvider.renderMarkdown(markdown, overrides);
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
@@ -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';\n\nexport const INTLAYER_MARKDOWN_TOKEN =\n new InjectionToken<IntlayerMarkdownProvider>('intlayerMarkdown');\n\ntype RenderMarkdownFunction = (markdown: string) => string | TemplateRef<any>;\n\nexport type IntlayerMarkdownProvider = {\n renderMarkdown: RenderMarkdownFunction;\n};\n\n/**\n * Default markdown renderer that returns the markdown as is\n */\nconst defaultMarkdownRenderer: RenderMarkdownFunction = (markdown: string) =>\n markdown;\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): string | TemplateRef<any> {\n if (!this.markdownProvider) {\n return markdown; // Fallback to returning markdown as is\n }\n return this.markdownProvider.renderMarkdown(markdown);\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":";;;;AAOA,MAAa,0BACX,IAAIA,6BAAyC,mBAAmB;;;;
|
|
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';\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/**\n * Default markdown renderer that returns the markdown as is\n */\nconst defaultMarkdownRenderer: RenderMarkdownFunction = (markdown: string) =>\n markdown;\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":";;;;AAOA,MAAa,0BACX,IAAIA,6BAAyC,mBAAmB;;;;AAoBlE,MAAM,2BAAmD,aACvD;;;;AAKF,MAAa,kCACX,iBAAyC,6BACrC;CACJ,SAAS;CACT,UAAU,EACR,gBACD;CACF;AAQD,IAAa,0BAHb,gCAAY,EACV,YAAY,QACb,CAAC,EACF,MAAqC;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;;;;;;AAOpE,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
|
@@ -42,22 +42,30 @@ const markdownStringPlugin = {
|
|
|
42
42
|
dictionaryKey: rest.dictionaryKey,
|
|
43
43
|
keyPath: []
|
|
44
44
|
});
|
|
45
|
-
|
|
45
|
+
const render = (overrides) => require_renderIntlayerNode.renderIntlayerNode({
|
|
46
46
|
...props,
|
|
47
47
|
value: node,
|
|
48
48
|
children: () => ({
|
|
49
49
|
component: require_editor_ContentSelectorWrapper_component.ContentSelectorWrapperComponent,
|
|
50
50
|
props: {
|
|
51
51
|
dictionaryKey: rest.dictionaryKey,
|
|
52
|
-
keyPath: rest.keyPath
|
|
52
|
+
keyPath: rest.keyPath,
|
|
53
|
+
...overrides
|
|
53
54
|
},
|
|
54
55
|
children: () => {
|
|
55
56
|
const { renderMarkdown } = require_markdown_installIntlayerMarkdown.useMarkdown();
|
|
56
|
-
return renderMarkdown(node);
|
|
57
|
+
return renderMarkdown(node, overrides);
|
|
57
58
|
}
|
|
58
59
|
}),
|
|
59
60
|
additionalProps: { metadata: metadataNodes }
|
|
60
61
|
});
|
|
62
|
+
const element = render();
|
|
63
|
+
return new Proxy(element, { get(target, prop, receiver) {
|
|
64
|
+
if (prop === "value") return node;
|
|
65
|
+
if (prop === "metadata") return metadataNodes;
|
|
66
|
+
if (prop === "use") return (overrides) => render(overrides);
|
|
67
|
+
return Reflect.get(target, prop, receiver);
|
|
68
|
+
} });
|
|
61
69
|
}
|
|
62
70
|
};
|
|
63
71
|
const markdownPlugin = {
|
package/dist/cjs/plugins.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","ContentSelectorWrapperComponent","props","useMarkdown","NodeType"],"sources":["../../src/plugins.ts"],"sourcesContent":["import {\n type DeepTransformContent as DeepTransformContentCore,\n getMarkdownMetadata,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type MarkdownContent,\n type Plugins,\n} from '@intlayer/core';\nimport { type KeyPath, NodeType } from '@intlayer/types';\nimport { ContentSelectorWrapperComponent } from './editor';\nimport { useMarkdown } from './markdown/installIntlayerMarkdown';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport interface IntlayerNode<T, P = {}> {\n value: T;\n children?: any;\n additionalProps?: P;\n}\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (_node, { children, ...rest }) =>\n renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: node,\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n
|
|
1
|
+
{"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","ContentSelectorWrapperComponent","props","useMarkdown","NodeType"],"sources":["../../src/plugins.ts"],"sourcesContent":["import {\n type DeepTransformContent as DeepTransformContentCore,\n getMarkdownMetadata,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type MarkdownContent,\n type Plugins,\n} from '@intlayer/core';\nimport { type KeyPath, type LocalesValues, NodeType } from '@intlayer/types';\nimport { ContentSelectorWrapperComponent } from './editor';\nimport { useMarkdown } from './markdown/installIntlayerMarkdown';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport interface IntlayerNode<T, P = {}> {\n value: T;\n children?: any;\n additionalProps?: P;\n}\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (_node, { children, ...rest }) =>\n renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: node,\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (overrides?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...overrides,\n },\n children: () => {\n const { renderMarkdown } = useMarkdown();\n return renderMarkdown(node, overrides);\n },\n }),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as any;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (overrides?: any) => render(overrides);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n};\n\nexport type MarkdownCond<T, S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer M;\n metadata?: infer U;\n}\n ? {\n use: (overrides: any) => any;\n metadata: DeepTransformContent<U>;\n } & any\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, S, L extends LocalesValues> {\n intlayerNode: IntlayerNodeCond<T>;\n markdown: MarkdownCond<T, S, L>;\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 intlayerNode: true;\n markdown: true;\n};\n\nexport type DeepTransformContent<T> = DeepTransformContentCore<\n T,\n IInterpreterPluginState\n>;\n"],"mappings":";;;;;;;;;AA2BA,MAAa,sBAA+B;CAC1C,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YAAY,OAAO,EAAE,UAAU,GAAG,WAChCA,8CAAmB;EACjB,GAAG;EACH,OAAO;EACP,iBAAiB;GACf,WAAWC;GACX,OAAO;IACL,eAAe,KAAK;IACpB,SAAS,KAAK;IACf;GACS;GACX;EACF,CAAC;CACL;;AAWD,MAAa,uBAAgC;CAC3C,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS;CACrC,YAAY,MAAc,OAAO,sBAAsB;EACrD,MAAM,EACJ,SACA,GAAG,SACD;EAoBJ,MAAM,gBAAgB,0DAlBe,KAAK,EAkBQ;GAChD,SAAS,CAjBsB;IAC/B,IAAI;IACJ,YAAY,iBACV,OAAO,iBAAiB,YACxB,OAAO,iBAAiB,YACxB,OAAO,iBAAiB,aACxB,CAAC;IACH,YAAY,cAAc,YACxBD,8CAAmB;KACjB,GAAGE;KACH,OAAO;KACP,UAAU;KACX,CAAC;IACL,CAI2B;GAC1B,eAAe,KAAK;GACpB,SAAS,EAAE;GACZ,CAAC;EAEF,MAAM,UAAU,cACdF,8CAAmB;GACjB,GAAG;GACH,OAAO;GACP,iBAAiB;IACf,WAAWC;IACX,OAAO;KACL,eAAe,KAAK;KACpB,SAAS,KAAK;KACd,GAAG;KACJ;IACD,gBAAgB;KACd,MAAM,EAAE,mBAAmBE,sDAAa;AACxC,YAAO,eAAe,MAAM,UAAU;;IAEzC;GACD,iBAAiB,EACf,UAAU,eACX;GACF,CAAC;EAEJ,MAAM,UAAU,QAAQ;AAExB,SAAO,IAAI,MAAM,SAAS,EACxB,IAAI,QAAQ,MAAM,UAAU;AAC1B,OAAI,SAAS,QACX,QAAO;AAET,OAAI,SAAS,WACX,QAAO;AAGT,OAAI,SAAS,MACX,SAAQ,cAAoB,OAAO,UAAU;AAG/C,UAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;KAE7C,CAAC;;CAEL;AAaD,MAAa,iBAA0B;CACrC,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAaC,yBAAS;CAC1D,YAAY,MAAuB,OAAO,sBAAsB;EAC9D,MAAM,aAAwB,CAC5B,GAAG,MAAM,SACT,EACE,MAAMA,yBAAS,UAChB,CACF;EAED,MAAM,WAAW,KAAKA,yBAAS;AAE/B,SAAO,kBAAkB,UAAU;GACjC,GAAG;GACH;GACA,SAAS;GACT,SAAS,CAAC,sBAAsB,GAAI,MAAM,WAAW,EAAE,CAAE;GAC1D,CAAC;;CAEL"}
|
|
@@ -3,7 +3,8 @@ import { useDictionary } from "./useDictionary.mjs";
|
|
|
3
3
|
import { useDictionaryAsync } from "./useDictionaryAsync.mjs";
|
|
4
4
|
import { useLoadDynamic } from "./useLoadDynamic.mjs";
|
|
5
5
|
import { useDictionaryDynamic } from "./useDictionaryDynamic.mjs";
|
|
6
|
+
import { useIntl } from "./useIntl.mjs";
|
|
6
7
|
import { isUpdatableNode, useIntlayer } from "./useIntlayer.mjs";
|
|
7
8
|
import { useLocale } from "./useLocale.mjs";
|
|
8
9
|
|
|
9
|
-
export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, isUpdatableNode, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntlayer, useLoadDynamic, useLocale };
|
|
10
|
+
export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, isUpdatableNode, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntl, useIntlayer, useLoadDynamic, useLocale };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { IntlayerProvider } from "./installIntlayer.mjs";
|
|
2
|
+
import { bindIntl } from "@intlayer/core";
|
|
3
|
+
import { computed, inject } from "@angular/core";
|
|
4
|
+
|
|
5
|
+
//#region src/client/useIntl.ts
|
|
6
|
+
/**
|
|
7
|
+
* Angular composable that provides a locale-bound `Intl` object.
|
|
8
|
+
*
|
|
9
|
+
* It acts exactly like the native `Intl` object, but acts as a proxy to:
|
|
10
|
+
* 1. Inject the current locale automatically if none is provided.
|
|
11
|
+
* 2. Use the performance-optimized `CachedIntl` under the hood.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { Component, computed } from '@angular/core';
|
|
16
|
+
* import { useIntl } from 'angular-intlayer';
|
|
17
|
+
*
|
|
18
|
+
* @Component({ ... })
|
|
19
|
+
* export class MyComponent {
|
|
20
|
+
* intl = useIntl();
|
|
21
|
+
* formattedPrice = computed(() =>
|
|
22
|
+
* new this.intl().NumberFormat({
|
|
23
|
+
* style: 'currency',
|
|
24
|
+
* currency: 'USD'
|
|
25
|
+
* }).format(123.45)
|
|
26
|
+
* );
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
const useIntl = (locale) => {
|
|
31
|
+
const intlayer = inject(IntlayerProvider);
|
|
32
|
+
return computed(() => {
|
|
33
|
+
return bindIntl(locale ?? intlayer.locale());
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { useIntl };
|
|
39
|
+
//# sourceMappingURL=useIntl.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../src/client/useIntl.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport { bindIntl } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { IntlayerProvider } from './installIntlayer';\n\n/**\n * Angular composable that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```typescript\n * import { Component, computed } from '@angular/core';\n * import { useIntl } from 'angular-intlayer';\n *\n * @Component({ ... })\n * export class MyComponent {\n * intl = useIntl();\n * formattedPrice = computed(() =>\n * new this.intl().NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45)\n * );\n * }\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const intlayer = inject(IntlayerProvider);\n\n return computed(() => {\n const currentLocale = locale ?? intlayer.locale();\n\n return bindIntl(currentLocale);\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,WAAW,WAA2B;CACjD,MAAM,WAAW,OAAO,iBAAiB;AAEzC,QAAO,eAAe;AAGpB,SAAO,SAFe,UAAU,SAAS,QAAQ,CAEnB;GAC9B"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { useDictionary } from "./client/useDictionary.mjs";
|
|
|
3
3
|
import { useDictionaryAsync } from "./client/useDictionaryAsync.mjs";
|
|
4
4
|
import { useLoadDynamic } from "./client/useLoadDynamic.mjs";
|
|
5
5
|
import { useDictionaryDynamic } from "./client/useDictionaryDynamic.mjs";
|
|
6
|
+
import { useIntl } from "./client/useIntl.mjs";
|
|
6
7
|
import { getIntlayer } from "./getIntlayer.mjs";
|
|
7
8
|
import { isUpdatableNode, useIntlayer } from "./client/useIntlayer.mjs";
|
|
8
9
|
import { useLocale } from "./client/useLocale.mjs";
|
|
@@ -10,4 +11,4 @@ import { INTLAYER_MARKDOWN_TOKEN, IntlayerMarkdownService, createIntlayerMarkdow
|
|
|
10
11
|
import { intlayerNodePlugins, markdownPlugin, markdownStringPlugin } from "./plugins.mjs";
|
|
11
12
|
import { getDictionary } from "./getDictionary.mjs";
|
|
12
13
|
|
|
13
|
-
export { INTLAYER_MARKDOWN_TOKEN, INTLAYER_TOKEN, IntlayerMarkdownService, IntlayerProvider, createIntlayerClient, createIntlayerMarkdownProvider, getDictionary, getIntlayer, installIntlayer, intlayerNodePlugins, isUpdatableNode, markdownPlugin, markdownStringPlugin, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntlayer, useLoadDynamic, useLocale, useMarkdown };
|
|
14
|
+
export { INTLAYER_MARKDOWN_TOKEN, INTLAYER_TOKEN, IntlayerMarkdownService, IntlayerProvider, createIntlayerClient, createIntlayerMarkdownProvider, getDictionary, getIntlayer, installIntlayer, intlayerNodePlugins, isUpdatableNode, markdownPlugin, markdownStringPlugin, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntl, useIntlayer, useLoadDynamic, useLocale, useMarkdown };
|
|
@@ -15,9 +15,9 @@ const createIntlayerMarkdownProvider = (renderMarkdown = defaultMarkdownRenderer
|
|
|
15
15
|
});
|
|
16
16
|
var IntlayerMarkdownService = @Injectable({ providedIn: "root" }) class {
|
|
17
17
|
markdownProvider = inject(INTLAYER_MARKDOWN_TOKEN, { optional: true });
|
|
18
|
-
renderMarkdown(markdown) {
|
|
18
|
+
renderMarkdown(markdown, overrides) {
|
|
19
19
|
if (!this.markdownProvider) return markdown;
|
|
20
|
-
return this.markdownProvider.renderMarkdown(markdown);
|
|
20
|
+
return this.markdownProvider.renderMarkdown(markdown, overrides);
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installIntlayerMarkdown.mjs","names":[],"sources":["../../../src/markdown/installIntlayerMarkdown.ts"],"sourcesContent":["import {\n Injectable,\n InjectionToken,\n inject,\n type TemplateRef,\n} from '@angular/core';\n\nexport const INTLAYER_MARKDOWN_TOKEN =\n new InjectionToken<IntlayerMarkdownProvider>('intlayerMarkdown');\n\ntype RenderMarkdownFunction = (markdown: string) => string | TemplateRef<any>;\n\nexport type IntlayerMarkdownProvider = {\n renderMarkdown: RenderMarkdownFunction;\n};\n\n/**\n * Default markdown renderer that returns the markdown as is\n */\nconst defaultMarkdownRenderer: RenderMarkdownFunction = (markdown: string) =>\n markdown;\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): string | TemplateRef<any> {\n if (!this.markdownProvider) {\n return markdown; // Fallback to returning markdown as is\n }\n return this.markdownProvider.renderMarkdown(markdown);\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":";;;AAOA,MAAa,0BACX,IAAI,eAAyC,mBAAmB;;;;
|
|
1
|
+
{"version":3,"file":"installIntlayerMarkdown.mjs","names":[],"sources":["../../../src/markdown/installIntlayerMarkdown.ts"],"sourcesContent":["import {\n Injectable,\n InjectionToken,\n inject,\n type TemplateRef,\n} from '@angular/core';\n\nexport const INTLAYER_MARKDOWN_TOKEN =\n new InjectionToken<IntlayerMarkdownProvider>('intlayerMarkdown');\n\ntype RenderMarkdownOptions = {\n components?: any;\n wrapper?: any;\n options?: any;\n};\n\ntype RenderMarkdownFunction = (\n markdown: string,\n overrides?: any | RenderMarkdownOptions\n) => string | TemplateRef<any>;\n\nexport type IntlayerMarkdownProvider = {\n renderMarkdown: RenderMarkdownFunction;\n};\n\n/**\n * Default markdown renderer that returns the markdown as is\n */\nconst defaultMarkdownRenderer: RenderMarkdownFunction = (markdown: string) =>\n markdown;\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":";;;AAOA,MAAa,0BACX,IAAI,eAAyC,mBAAmB;;;;AAoBlE,MAAM,2BAAmD,aACvD;;;;AAKF,MAAa,kCACX,iBAAyC,6BACrC;CACJ,SAAS;CACT,UAAU,EACR,gBACD;CACF;AAQD,IAAa,0BAHb,CAAC,WAAW,EACV,YAAY,QACb,CAAC,CACF,MAAqC;CACnC,AAAQ,mBAAmB,OAAO,yBAAyB,EACzD,UAAU,MACX,CAAC;CAEF,eAAe,UAAkB,WAA4C;AAC3E,MAAI,CAAC,KAAK,iBACR,QAAO;AAET,SAAO,KAAK,iBAAiB,eAAe,UAAU,UAAU;;;;;;AAOpE,MAAa,oBAA8C;CACzD,MAAM,mBAAmB,OAAO,yBAAyB,EAAE,UAAU,MAAM,CAAC;AAE5E,KAAI,CAAC,iBACH,QAAO,EACL,gBAAgB,yBACjB;AAGH,QAAO"}
|
package/dist/esm/plugins.mjs
CHANGED
|
@@ -41,22 +41,30 @@ const markdownStringPlugin = {
|
|
|
41
41
|
dictionaryKey: rest.dictionaryKey,
|
|
42
42
|
keyPath: []
|
|
43
43
|
});
|
|
44
|
-
|
|
44
|
+
const render = (overrides) => renderIntlayerNode({
|
|
45
45
|
...props,
|
|
46
46
|
value: node,
|
|
47
47
|
children: () => ({
|
|
48
48
|
component: ContentSelectorWrapperComponent,
|
|
49
49
|
props: {
|
|
50
50
|
dictionaryKey: rest.dictionaryKey,
|
|
51
|
-
keyPath: rest.keyPath
|
|
51
|
+
keyPath: rest.keyPath,
|
|
52
|
+
...overrides
|
|
52
53
|
},
|
|
53
54
|
children: () => {
|
|
54
55
|
const { renderMarkdown } = useMarkdown();
|
|
55
|
-
return renderMarkdown(node);
|
|
56
|
+
return renderMarkdown(node, overrides);
|
|
56
57
|
}
|
|
57
58
|
}),
|
|
58
59
|
additionalProps: { metadata: metadataNodes }
|
|
59
60
|
});
|
|
61
|
+
const element = render();
|
|
62
|
+
return new Proxy(element, { get(target, prop, receiver) {
|
|
63
|
+
if (prop === "value") return node;
|
|
64
|
+
if (prop === "metadata") return metadataNodes;
|
|
65
|
+
if (prop === "use") return (overrides) => render(overrides);
|
|
66
|
+
return Reflect.get(target, prop, receiver);
|
|
67
|
+
} });
|
|
60
68
|
}
|
|
61
69
|
};
|
|
62
70
|
const markdownPlugin = {
|
package/dist/esm/plugins.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.mjs","names":["props"],"sources":["../../src/plugins.ts"],"sourcesContent":["import {\n type DeepTransformContent as DeepTransformContentCore,\n getMarkdownMetadata,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type MarkdownContent,\n type Plugins,\n} from '@intlayer/core';\nimport { type KeyPath, NodeType } from '@intlayer/types';\nimport { ContentSelectorWrapperComponent } from './editor';\nimport { useMarkdown } from './markdown/installIntlayerMarkdown';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport interface IntlayerNode<T, P = {}> {\n value: T;\n children?: any;\n additionalProps?: P;\n}\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (_node, { children, ...rest }) =>\n renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: node,\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n
|
|
1
|
+
{"version":3,"file":"plugins.mjs","names":["props"],"sources":["../../src/plugins.ts"],"sourcesContent":["import {\n type DeepTransformContent as DeepTransformContentCore,\n getMarkdownMetadata,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type MarkdownContent,\n type Plugins,\n} from '@intlayer/core';\nimport { type KeyPath, type LocalesValues, NodeType } from '@intlayer/types';\nimport { ContentSelectorWrapperComponent } from './editor';\nimport { useMarkdown } from './markdown/installIntlayerMarkdown';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport interface IntlayerNode<T, P = {}> {\n value: T;\n children?: any;\n additionalProps?: P;\n}\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (_node, { children, ...rest }) =>\n renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: node,\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (overrides?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...overrides,\n },\n children: () => {\n const { renderMarkdown } = useMarkdown();\n return renderMarkdown(node, overrides);\n },\n }),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as any;\n\n return new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (overrides?: any) => render(overrides);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n};\n\nexport type MarkdownCond<T, S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer M;\n metadata?: infer U;\n}\n ? {\n use: (overrides: any) => any;\n metadata: DeepTransformContent<U>;\n } & any\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, S, L extends LocalesValues> {\n intlayerNode: IntlayerNodeCond<T>;\n markdown: MarkdownCond<T, S, L>;\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 intlayerNode: true;\n markdown: true;\n};\n\nexport type DeepTransformContent<T> = DeepTransformContentCore<\n T,\n IInterpreterPluginState\n>;\n"],"mappings":";;;;;;;;AA2BA,MAAa,sBAA+B;CAC1C,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YAAY,OAAO,EAAE,UAAU,GAAG,WAChC,mBAAmB;EACjB,GAAG;EACH,OAAO;EACP,iBAAiB;GACf,WAAW;GACX,OAAO;IACL,eAAe,KAAK;IACpB,SAAS,KAAK;IACf;GACS;GACX;EACF,CAAC;CACL;;AAWD,MAAa,uBAAgC;CAC3C,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS;CACrC,YAAY,MAAc,OAAO,sBAAsB;EACrD,MAAM,EACJ,SACA,GAAG,SACD;EAoBJ,MAAM,gBAAgB,kBAlBL,oBAAoB,KAAK,EAkBQ;GAChD,SAAS,CAjBsB;IAC/B,IAAI;IACJ,YAAY,iBACV,OAAO,iBAAiB,YACxB,OAAO,iBAAiB,YACxB,OAAO,iBAAiB,aACxB,CAAC;IACH,YAAY,cAAc,YACxB,mBAAmB;KACjB,GAAGA;KACH,OAAO;KACP,UAAU;KACX,CAAC;IACL,CAI2B;GAC1B,eAAe,KAAK;GACpB,SAAS,EAAE;GACZ,CAAC;EAEF,MAAM,UAAU,cACd,mBAAmB;GACjB,GAAG;GACH,OAAO;GACP,iBAAiB;IACf,WAAW;IACX,OAAO;KACL,eAAe,KAAK;KACpB,SAAS,KAAK;KACd,GAAG;KACJ;IACD,gBAAgB;KACd,MAAM,EAAE,mBAAmB,aAAa;AACxC,YAAO,eAAe,MAAM,UAAU;;IAEzC;GACD,iBAAiB,EACf,UAAU,eACX;GACF,CAAC;EAEJ,MAAM,UAAU,QAAQ;AAExB,SAAO,IAAI,MAAM,SAAS,EACxB,IAAI,QAAQ,MAAM,UAAU;AAC1B,OAAI,SAAS,QACX,QAAO;AAET,OAAI,SAAS,WACX,QAAO;AAGT,OAAI,SAAS,MACX,SAAQ,cAAoB,OAAO,UAAU;AAG/C,UAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;KAE7C,CAAC;;CAEL;AAaD,MAAa,iBAA0B;CACrC,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,SAAS;CAC1D,YAAY,MAAuB,OAAO,sBAAsB;EAC9D,MAAM,aAAwB,CAC5B,GAAG,MAAM,SACT,EACE,MAAM,SAAS,UAChB,CACF;EAED,MAAM,WAAW,KAAK,SAAS;AAE/B,SAAO,kBAAkB,UAAU;GACjC,GAAG;GACH;GACA,SAAS;GACT,SAAS,CAAC,sBAAsB,GAAI,MAAM,WAAW,EAAE,CAAE;GAC1D,CAAC;;CAEL"}
|
|
@@ -2,7 +2,8 @@ import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer
|
|
|
2
2
|
import { useDictionary } from "./useDictionary.js";
|
|
3
3
|
import { useDictionaryAsync } from "./useDictionaryAsync.js";
|
|
4
4
|
import { useDictionaryDynamic } from "./useDictionaryDynamic.js";
|
|
5
|
+
import { useIntl } from "./useIntl.js";
|
|
5
6
|
import { isUpdatableNode, useIntlayer } from "./useIntlayer.js";
|
|
6
7
|
import { useLoadDynamic } from "./useLoadDynamic.js";
|
|
7
8
|
import { useLocale } from "./useLocale.js";
|
|
8
|
-
export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, isUpdatableNode, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntlayer, useLoadDynamic, useLocale };
|
|
9
|
+
export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, isUpdatableNode, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntl, useIntlayer, useLoadDynamic, useLocale };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IInterpreterPluginState as IInterpreterPluginState$1 } from "../plugins.js";
|
|
2
2
|
import "../index.js";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _intlayer_types1 from "@intlayer/types";
|
|
4
4
|
import { Dictionary, DictionaryKeys, LocalesValues, StrictModeLocaleMap } from "@intlayer/types";
|
|
5
5
|
import * as _intlayer_core1 from "@intlayer/core";
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ import * as _intlayer_core1 from "@intlayer/core";
|
|
|
10
10
|
*
|
|
11
11
|
* If the locale is not provided, it will use the locale from the client context
|
|
12
12
|
*/
|
|
13
|
-
declare const useDictionaryDynamic: <T extends Dictionary, K extends DictionaryKeys>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: K, locale?: LocalesValues) => _intlayer_core1.DeepTransformContent<T["content"], IInterpreterPluginState$1,
|
|
13
|
+
declare const useDictionaryDynamic: <T extends Dictionary, K extends DictionaryKeys>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: K, locale?: LocalesValues) => _intlayer_core1.DeepTransformContent<T["content"], IInterpreterPluginState$1, _intlayer_types1.Locale>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { useDictionaryDynamic };
|
|
16
16
|
//# sourceMappingURL=useDictionaryDynamic.d.ts.map
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import * as _angular_core1 from "@angular/core";
|
|
2
|
+
import { LocalesValues } from "@intlayer/types";
|
|
3
|
+
|
|
4
|
+
//#region src/client/useIntl.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Angular composable that provides a locale-bound `Intl` object.
|
|
8
|
+
*
|
|
9
|
+
* It acts exactly like the native `Intl` object, but acts as a proxy to:
|
|
10
|
+
* 1. Inject the current locale automatically if none is provided.
|
|
11
|
+
* 2. Use the performance-optimized `CachedIntl` under the hood.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { Component, computed } from '@angular/core';
|
|
16
|
+
* import { useIntl } from 'angular-intlayer';
|
|
17
|
+
*
|
|
18
|
+
* @Component({ ... })
|
|
19
|
+
* export class MyComponent {
|
|
20
|
+
* intl = useIntl();
|
|
21
|
+
* formattedPrice = computed(() =>
|
|
22
|
+
* new this.intl().NumberFormat({
|
|
23
|
+
* style: 'currency',
|
|
24
|
+
* currency: 'USD'
|
|
25
|
+
* }).format(123.45)
|
|
26
|
+
* );
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare const useIntl: (locale?: LocalesValues) => _angular_core1.Signal<{
|
|
31
|
+
Collator: {
|
|
32
|
+
new (locales?: LocalesValues, options?: Intl.CollatorOptions): Intl.Collator;
|
|
33
|
+
new (options?: Intl.CollatorOptions & {
|
|
34
|
+
locale?: LocalesValues;
|
|
35
|
+
}): Intl.Collator;
|
|
36
|
+
};
|
|
37
|
+
NumberFormat: {
|
|
38
|
+
new (locales?: LocalesValues, options?: Intl.NumberFormatOptions): Intl.NumberFormat;
|
|
39
|
+
new (options?: Intl.NumberFormatOptions & {
|
|
40
|
+
locale?: LocalesValues;
|
|
41
|
+
}): Intl.NumberFormat;
|
|
42
|
+
};
|
|
43
|
+
DateTimeFormat: {
|
|
44
|
+
new (locales?: LocalesValues, options?: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
|
|
45
|
+
new (options?: Intl.DateTimeFormatOptions & {
|
|
46
|
+
locale?: LocalesValues;
|
|
47
|
+
}): Intl.DateTimeFormat;
|
|
48
|
+
};
|
|
49
|
+
getCanonicalLocales: typeof Intl.getCanonicalLocales;
|
|
50
|
+
readonly PluralRules: {
|
|
51
|
+
new (locales?: LocalesValues, options?: Intl.PluralRulesOptions): Intl.PluralRules;
|
|
52
|
+
new (options?: Intl.PluralRulesOptions & {
|
|
53
|
+
locale?: LocalesValues;
|
|
54
|
+
}): Intl.PluralRules;
|
|
55
|
+
};
|
|
56
|
+
readonly RelativeTimeFormat: {
|
|
57
|
+
new (locales?: LocalesValues, options?: Intl.RelativeTimeFormatOptions): Intl.RelativeTimeFormat;
|
|
58
|
+
new (options?: Intl.RelativeTimeFormatOptions & {
|
|
59
|
+
locale?: LocalesValues;
|
|
60
|
+
}): Intl.RelativeTimeFormat;
|
|
61
|
+
};
|
|
62
|
+
readonly Locale: {
|
|
63
|
+
new (locales?: LocalesValues, options?: Intl.LocaleOptions): Intl.Locale;
|
|
64
|
+
new (options?: Intl.LocaleOptions & {
|
|
65
|
+
locale?: LocalesValues;
|
|
66
|
+
}): Intl.Locale;
|
|
67
|
+
};
|
|
68
|
+
readonly DisplayNames: {
|
|
69
|
+
new (locales?: LocalesValues, options?: Intl.DisplayNamesOptions): Intl.DisplayNames;
|
|
70
|
+
new (options?: Intl.DisplayNamesOptions & {
|
|
71
|
+
locale?: LocalesValues;
|
|
72
|
+
}): Intl.DisplayNames;
|
|
73
|
+
};
|
|
74
|
+
readonly ListFormat: {
|
|
75
|
+
new (locales?: LocalesValues, options?: Intl.ListFormatOptions): Intl.ListFormat;
|
|
76
|
+
new (options?: Intl.ListFormatOptions & {
|
|
77
|
+
locale?: LocalesValues;
|
|
78
|
+
}): Intl.ListFormat;
|
|
79
|
+
};
|
|
80
|
+
supportedValuesOf: typeof Intl.supportedValuesOf;
|
|
81
|
+
readonly Segmenter: {
|
|
82
|
+
new (locales?: LocalesValues, options?: Intl.SegmenterOptions): Intl.Segmenter;
|
|
83
|
+
new (options?: Intl.SegmenterOptions & {
|
|
84
|
+
locale?: LocalesValues;
|
|
85
|
+
}): Intl.Segmenter;
|
|
86
|
+
};
|
|
87
|
+
}>;
|
|
88
|
+
//#endregion
|
|
89
|
+
export { useIntl };
|
|
90
|
+
//# sourceMappingURL=useIntl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIntl.d.ts","names":[],"sources":["../../../src/client/useIntl.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA6BA;;;;;;;;;;;;;;;;;;;;;cAAa,mBAAoB,iCAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA,SAAA,YAAA,EAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
1
|
+
import * as _angular_core0 from "@angular/core";
|
|
2
|
+
import * as _intlayer_types0 from "@intlayer/types";
|
|
3
3
|
import { LocalesValues } from "@intlayer/types";
|
|
4
4
|
|
|
5
5
|
//#region src/client/useLocale.d.ts
|
|
@@ -14,9 +14,9 @@ declare const useLocale: ({
|
|
|
14
14
|
isCookieEnabled,
|
|
15
15
|
onLocaleChange
|
|
16
16
|
}?: useLocaleProps) => {
|
|
17
|
-
locale:
|
|
18
|
-
defaultLocale:
|
|
19
|
-
availableLocales:
|
|
17
|
+
locale: _angular_core0.Signal<"af" | "af-ZA" | "ar" | "ar-AE" | "ar-BH" | "ar-DZ" | "ar-EG" | "ar-IQ" | "ar-JO" | "ar-KW" | "ar-LB" | "ar-LY" | "ar-MA" | "ar-OM" | "ar-QA" | "ar-SA" | "ar-SY" | "ar-TN" | "ar-YE" | "az" | "az-AZ" | "be" | "be-BY" | "bg" | "bg-BG" | "bs" | "bs-BA" | "ca" | "ca-ES" | "cs" | "cs-CZ" | "cy" | "cy-GB" | "da" | "da-DK" | "de" | "de-AT" | "de-CH" | "de-DE" | "de-LI" | "de-LU" | "dv" | "dv-MV" | "el" | "el-GR" | "en" | "en-AU" | "en-BZ" | "en-CA" | "en-CB" | "en-GB" | "en-IE" | "en-JM" | "en-NZ" | "en-PH" | "en-TT" | "en-US" | "en-ZA" | "en-ZW" | "eo" | "es" | "es-AR" | "es-BO" | "es-CL" | "es-CO" | "es-CR" | "es-DO" | "es-EC" | "es-ES" | "es-GT" | "es-HN" | "es-MX" | "es-NI" | "es-PA" | "es-PE" | "es-PR" | "es-PY" | "es-SV" | "es-UY" | "es-VE" | "et" | "et-EE" | "eu" | "eu-ES" | "fa" | "fa-IR" | "fi" | "fi-FI" | "fo" | "fo-FO" | "fr" | "fr-BE" | "fr-CA" | "fr-CH" | "fr-FR" | "fr-LU" | "fr-MC" | "ga" | "ga-IE" | "gd" | "gd-GB" | "gl" | "gl-ES" | "gu" | "gu-IN" | "he" | "he-IL" | "hi" | "hi-IN" | "hr" | "hr-BA" | "hr-HR" | "hu" | "hu-HU" | "hy" | "hy-AM" | "id" | "id-ID" | "is" | "is-IS" | "it" | "it-CH" | "it-IT" | "ja" | "ja-JP" | "ka" | "ka-GE" | "kk" | "kk-KZ" | "kn" | "kn-IN" | "ko" | "ko-KR" | "kok" | "kok-IN" | "ku" | "ku-TR" | "ky" | "ky-KG" | "lt" | "lt-LT" | "lv" | "lv-LV" | "mi" | "mi-NZ" | "mk" | "mk-MK" | "mn" | "mn-MN" | "mr" | "mr-IN" | "ms" | "ms-BN" | "ms-MY" | "mt" | "mt-MT" | "ml" | "ml-IN" | "no" | "nb" | "nb-NO" | "nl" | "nl-BE" | "nl-NL" | "nn" | "nn-NO" | "ns" | "ns-ZA" | "pa" | "pa-IN" | "pl" | "pl-PL" | "ps" | "ps-AR" | "pt" | "pt-BR" | "pt-PT" | "qu" | "qu-BO" | "qu-EC" | "qu-PE" | "ro" | "ro-RO" | "ro-MD" | "rm" | "rm-CH" | "ru" | "ru-RU" | "ru-MD" | "sa" | "sa-IN" | "se" | "se-FI" | "se-NO" | "se-SE" | "hsb" | "hsb-DE" | "dsb" | "dsb-DE" | "sk" | "sk-SK" | "sl" | "sl-SI" | "sq" | "sq-AL" | "sr" | "sr-BA" | "sr-SP" | "sv" | "sv-FI" | "sv-SE" | "sw" | "sw-KE" | "syr" | "syr-SY" | "ta" | "ta-IN" | "te" | "te-IN" | "th" | "th-TH" | "tl" | "tl-PH" | "tn" | "tn-ZA" | "tr" | "tr-TR" | "tt" | "tt-RU" | "ts" | "uk" | "uk-UA" | "ur" | "ur-PK" | "uz" | "uz-UZ" | "vi" | "vi-VN" | "ve" | "ve-ZA" | "xh" | "xh-ZA" | "zh" | "zh-Hans" | "zh-CN" | "zh-HK" | "zh-MO" | "zh-SG" | "zh-Hant" | "zu" | "zu-ZA" | "bn" | "bn-BD" | "bn-IN" | "bn-MM" | "my" | "my-MM" | "km" | "km-KH" | "lo" | "lo-LA" | "yo" | "yo-NG" | "yi" | "yi-001" | "am" | "am-ET" | "ne" | "ne-NP" | "si" | "si-LK" | "sr-Cyrl" | "sr-RS" | "en-IN" | "en-SG" | "en-HK" | "en-NG" | "en-PK" | "en-MY" | "en-BW" | "en-KE" | "en-TZ" | "en-GH" | "en-UG" | "es-CU" | "es-US" | "pt-GW" | "pt-MZ" | "pt-ST" | "pt-CV" | "pt-TL" | "pt-MO" | "zh-TW" | "ar-MR" | "ar-PS" | "ar-SD" | "ar-DJ" | "ar-SO" | "ar-TD" | "ar-KM" | (string & {})>;
|
|
18
|
+
defaultLocale: _intlayer_types0.Locale;
|
|
19
|
+
availableLocales: _intlayer_types0.Locale[];
|
|
20
20
|
setLocale: (newLocale: LocalesValues) => void;
|
|
21
21
|
};
|
|
22
22
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _intlayer_types2 from "@intlayer/types";
|
|
2
2
|
import { LocalesValues } from "@intlayer/types";
|
|
3
3
|
|
|
4
4
|
//#region src/client/useLocaleStorage.d.ts
|
|
@@ -9,13 +9,13 @@ import { LocalesValues } from "@intlayer/types";
|
|
|
9
9
|
/**
|
|
10
10
|
* Get the locale cookie
|
|
11
11
|
*/
|
|
12
|
-
declare const localeInStorage:
|
|
12
|
+
declare const localeInStorage: _intlayer_types2.Locale;
|
|
13
13
|
/**
|
|
14
14
|
* @deprecated Use localeInStorage instead
|
|
15
15
|
*
|
|
16
16
|
* Get the locale cookie
|
|
17
17
|
*/
|
|
18
|
-
declare const localeCookie:
|
|
18
|
+
declare const localeCookie: _intlayer_types2.Locale;
|
|
19
19
|
/**
|
|
20
20
|
* Set the locale cookie
|
|
21
21
|
*/
|
|
@@ -30,7 +30,7 @@ declare const setLocaleCookie: (locale: LocalesValues, isCookieEnabled: boolean)
|
|
|
30
30
|
* Hook that provides the locale storage and a function to set it
|
|
31
31
|
*/
|
|
32
32
|
declare const useLocaleStorage: (isCookieEnabled?: boolean) => {
|
|
33
|
-
getLocale: () =>
|
|
33
|
+
getLocale: () => _intlayer_types2.Locale;
|
|
34
34
|
setLocale: (locale: LocalesValues) => void;
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
@@ -41,7 +41,7 @@ declare const useLocaleStorage: (isCookieEnabled?: boolean) => {
|
|
|
41
41
|
* Hook that provides the locale cookie and a function to set it
|
|
42
42
|
*/
|
|
43
43
|
declare const useLocaleCookie: (isCookieEnabled?: boolean) => {
|
|
44
|
-
localeCookie:
|
|
44
|
+
localeCookie: _intlayer_types2.Locale;
|
|
45
45
|
setLocaleCookie: (locale: LocalesValues) => void;
|
|
46
46
|
};
|
|
47
47
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _angular_core5 from "@angular/core";
|
|
2
2
|
import { NodeProps } from "@intlayer/core";
|
|
3
3
|
|
|
4
4
|
//#region src/editor/ContentSelectorWrapper.component.d.ts
|
|
@@ -16,8 +16,8 @@ declare class ContentSelectorWrapperComponent {
|
|
|
16
16
|
private focusDictionary;
|
|
17
17
|
private editorEnabled;
|
|
18
18
|
constructor();
|
|
19
|
-
isSelected:
|
|
20
|
-
enabled:
|
|
19
|
+
isSelected: _angular_core5.Signal<boolean>;
|
|
20
|
+
enabled: _angular_core5.Signal<boolean>;
|
|
21
21
|
handleSelect(): void;
|
|
22
22
|
}
|
|
23
23
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _angular_core2 from "@angular/core";
|
|
2
2
|
import { KeyPath, Locale } from "@intlayer/types";
|
|
3
3
|
|
|
4
4
|
//#region src/editor/EditedContentRenderer.component.d.ts
|
|
@@ -16,7 +16,7 @@ declare class EditedContentRendererComponent {
|
|
|
16
16
|
/**
|
|
17
17
|
* Object → getContent → string, same as the React version.
|
|
18
18
|
*/
|
|
19
|
-
renderedContent:
|
|
19
|
+
renderedContent: _angular_core2.Signal<string>;
|
|
20
20
|
}
|
|
21
21
|
//#endregion
|
|
22
22
|
export { EditedContentRendererComponent, EditedContentRendererProps };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCrossFrameState } from "./useCrossFrameState.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _angular_core3 from "@angular/core";
|
|
3
3
|
|
|
4
4
|
//#region src/editor/useCrossURLPathState.d.ts
|
|
5
5
|
|
|
@@ -9,14 +9,14 @@ import * as _angular_core4 from "@angular/core";
|
|
|
9
9
|
* @param opts - Options for controlling emit and receive behavior
|
|
10
10
|
* @returns A tuple containing [state signal, setState function, forceSync function]
|
|
11
11
|
*/
|
|
12
|
-
declare const useCrossURLPathState: (initial?: string, opts?: Parameters<typeof useCrossFrameState>[2]) => [
|
|
12
|
+
declare const useCrossURLPathState: (initial?: string, opts?: Parameters<typeof useCrossFrameState>[2]) => [_angular_core3.Signal<string>, (v: string | ((prev: string) => string)) => void, () => void];
|
|
13
13
|
/**
|
|
14
14
|
* Hook for host applications to push URL path changes into the shared state
|
|
15
15
|
* This also monkey patches history methods to capture navigation events
|
|
16
16
|
* @param initial - The initial URL path
|
|
17
17
|
* @returns A tuple containing [state signal, setState function]
|
|
18
18
|
*/
|
|
19
|
-
declare const useCrossURLPathSetter: (initial?: string) => readonly [
|
|
19
|
+
declare const useCrossURLPathSetter: (initial?: string) => readonly [_angular_core3.Signal<string>, (v: string | ((prev: string) => string)) => void];
|
|
20
20
|
//#endregion
|
|
21
21
|
export { useCrossURLPathSetter, useCrossURLPathState };
|
|
22
22
|
//# sourceMappingURL=useCrossURLPathState.d.ts.map
|
package/dist/types/index.d.ts
CHANGED
|
@@ -7,15 +7,17 @@ import { getIntlayer } from "./getIntlayer.js";
|
|
|
7
7
|
import { INTLAYER_MARKDOWN_TOKEN, IntlayerMarkdownProvider, IntlayerMarkdownService, createIntlayerMarkdownProvider, useMarkdown } from "./markdown/installIntlayerMarkdown.js";
|
|
8
8
|
import "./markdown/index.js";
|
|
9
9
|
import { useDictionaryDynamic } from "./client/useDictionaryDynamic.js";
|
|
10
|
+
import { useIntl } from "./client/useIntl.js";
|
|
10
11
|
import { isUpdatableNode, useIntlayer } from "./client/useIntlayer.js";
|
|
11
12
|
import { useLoadDynamic } from "./client/useLoadDynamic.js";
|
|
12
13
|
import { useLocale } from "./client/useLocale.js";
|
|
13
14
|
import "./client/index.js";
|
|
15
|
+
import { LocalesValues } from "@intlayer/types";
|
|
14
16
|
|
|
15
17
|
//#region src/index.d.ts
|
|
16
18
|
declare module '@intlayer/core' {
|
|
17
|
-
interface IInterpreterPlugin<T, S, L> extends IInterpreterPluginAngular<T> {}
|
|
19
|
+
interface IInterpreterPlugin<T, S, L extends LocalesValues> extends IInterpreterPluginAngular<T, S, L> {}
|
|
18
20
|
}
|
|
19
21
|
//#endregion
|
|
20
|
-
export { DeepTransformContent, IInterpreterPluginAngular, IInterpreterPluginState, INTLAYER_MARKDOWN_TOKEN, INTLAYER_TOKEN, IntlayerMarkdownProvider, IntlayerMarkdownService, IntlayerNode, IntlayerNodeCond, IntlayerProvider, MarkdownCond, MarkdownStringCond, createIntlayerClient, createIntlayerMarkdownProvider, getDictionary, getIntlayer, installIntlayer, intlayerNodePlugins, isUpdatableNode, markdownPlugin, markdownStringPlugin, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntlayer, useLoadDynamic, useLocale, useMarkdown };
|
|
22
|
+
export { DeepTransformContent, IInterpreterPluginAngular, IInterpreterPluginState, INTLAYER_MARKDOWN_TOKEN, INTLAYER_TOKEN, IntlayerMarkdownProvider, IntlayerMarkdownService, IntlayerNode, IntlayerNodeCond, IntlayerProvider, MarkdownCond, MarkdownStringCond, createIntlayerClient, createIntlayerMarkdownProvider, getDictionary, getIntlayer, installIntlayer, intlayerNodePlugins, isUpdatableNode, markdownPlugin, markdownStringPlugin, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntl, useIntlayer, useLoadDynamic, useLocale, useMarkdown };
|
|
21
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;+CAK+C,uBACnC,0BAA0B,GAAG,GAAG"}
|
|
@@ -2,7 +2,12 @@ import { InjectionToken, TemplateRef } from "@angular/core";
|
|
|
2
2
|
|
|
3
3
|
//#region src/markdown/installIntlayerMarkdown.d.ts
|
|
4
4
|
declare const INTLAYER_MARKDOWN_TOKEN: InjectionToken<IntlayerMarkdownProvider>;
|
|
5
|
-
type
|
|
5
|
+
type RenderMarkdownOptions = {
|
|
6
|
+
components?: any;
|
|
7
|
+
wrapper?: any;
|
|
8
|
+
options?: any;
|
|
9
|
+
};
|
|
10
|
+
type RenderMarkdownFunction = (markdown: string, overrides?: any | RenderMarkdownOptions) => string | TemplateRef<any>;
|
|
6
11
|
type IntlayerMarkdownProvider = {
|
|
7
12
|
renderMarkdown: RenderMarkdownFunction;
|
|
8
13
|
};
|
|
@@ -18,7 +23,7 @@ declare const createIntlayerMarkdownProvider: (renderMarkdown?: RenderMarkdownFu
|
|
|
18
23
|
*/
|
|
19
24
|
declare class IntlayerMarkdownService {
|
|
20
25
|
private markdownProvider;
|
|
21
|
-
renderMarkdown(markdown: string): string | TemplateRef<any>;
|
|
26
|
+
renderMarkdown(markdown: string, overrides?: any): string | TemplateRef<any>;
|
|
22
27
|
}
|
|
23
28
|
/**
|
|
24
29
|
* Function to inject markdown provider
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installIntlayerMarkdown.d.ts","names":[],"sources":["../../../src/markdown/installIntlayerMarkdown.ts"],"sourcesContent":[],"mappings":";;;cAOa,yBAAuB,eAAA;KAG/B,
|
|
1
|
+
{"version":3,"file":"installIntlayerMarkdown.d.ts","names":[],"sources":["../../../src/markdown/installIntlayerMarkdown.ts"],"sourcesContent":[],"mappings":";;;cAOa,yBAAuB,eAAA;KAG/B,qBAAA;EAHQ,UAAA,CAAA,EAAA,GAAA;EAGR,OAAA,CAAA,EAAA,GAAA;EAMA,OAAA,CAAA,EAAA,GAAA;AAKL,CAAA;AAaA,KAlBK,sBAAA,GAkBQ,CAAA,QAOX,EAAA,MAAA,EAAA,SAAA,CAAA,EAAA,GAAA,GAvBkB,qBAuBlB,EAAA,GAAA,MAAA,GAtBY,WAsBZ,CAAA,GAAA,CAAA;AANgB,KAdN,wBAAA,GAcM;kBAbA;;;;AAwBlB;AAmBa,cA/BA,8BA+BkB,EAAA,CAAA,cAU9B,CAAA,EAxCiB,sBAwCjB,EAAA,GAAA;;YAnCM;;;;;cASM,uBAAA;;8DAKiD;;;;;cAWjD,mBAAkB"}
|
package/dist/types/plugins.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NodeType } from "@intlayer/types";
|
|
1
|
+
import { LocalesValues, NodeType } from "@intlayer/types";
|
|
2
2
|
import { DeepTransformContent as DeepTransformContent$1, IInterpreterPluginState as IInterpreterPluginState$1, Plugins } from "@intlayer/core";
|
|
3
3
|
|
|
4
4
|
//#region src/plugins.d.ts
|
|
@@ -22,20 +22,21 @@ type MarkdownStringCond<T> = T extends string ? IntlayerNode<string, {
|
|
|
22
22
|
}> : never;
|
|
23
23
|
/** Markdown string plugin. Replaces string node with a component that render the markdown. */
|
|
24
24
|
declare const markdownStringPlugin: Plugins;
|
|
25
|
-
type MarkdownCond<T> = T extends {
|
|
25
|
+
type MarkdownCond<T, S, L extends LocalesValues> = T extends {
|
|
26
26
|
nodeType: NodeType | string;
|
|
27
27
|
[NodeType.Markdown]: infer M;
|
|
28
28
|
metadata?: infer U;
|
|
29
|
-
} ?
|
|
29
|
+
} ? {
|
|
30
|
+
use: (overrides: any) => any;
|
|
30
31
|
metadata: DeepTransformContent<U>;
|
|
31
|
-
}
|
|
32
|
+
} & any : never;
|
|
32
33
|
declare const markdownPlugin: Plugins;
|
|
33
34
|
/** ---------------------------------------------
|
|
34
35
|
* PLUGINS RESULT
|
|
35
36
|
* --------------------------------------------- */
|
|
36
|
-
interface IInterpreterPluginAngular<T> {
|
|
37
|
+
interface IInterpreterPluginAngular<T, S, L extends LocalesValues> {
|
|
37
38
|
intlayerNode: IntlayerNodeCond<T>;
|
|
38
|
-
markdown: MarkdownCond<T>;
|
|
39
|
+
markdown: MarkdownCond<T, S, L>;
|
|
39
40
|
}
|
|
40
41
|
/**
|
|
41
42
|
* Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.ts"],"sourcesContent":[],"mappings":";;;;;;;AAgBA;AAAkC,KAAtB,gBAAsB,CAAA,CAAA,CAAA,GAAA,CAAA,SAAA,MAAA,GAAA,MAAA,GAC9B,YAD8B,CACjB,CADiB,CAAA,GAAA,KAAA;AACjB,UAGA,YAHA,CAAA,CAAA,EAAA,IAAA,CAAA,CAAA,CAAA,CAAA;EAAb,KAAA,EAIK,CAJL;EAAY,QAAA,CAAA,EAAA,GAAA;EAGC,eAAY,CAAA,EAGT,CAHS;AAO7B;AAyBA;AAAoC,cAzBvB,mBAyBuB,EAzBF,OAyBE;;;;AAKvB,KALD,
|
|
1
|
+
{"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.ts"],"sourcesContent":[],"mappings":";;;;;;;AAgBA;AAAkC,KAAtB,gBAAsB,CAAA,CAAA,CAAA,GAAA,CAAA,SAAA,MAAA,GAAA,MAAA,GAC9B,YAD8B,CACjB,CADiB,CAAA,GAAA,KAAA;AACjB,UAGA,YAHA,CAAA,CAAA,EAAA,IAAA,CAAA,CAAA,CAAA,CAAA;EAAb,KAAA,EAIK,CAJL;EAAY,QAAA,CAAA,EAAA,GAAA;EAGC,eAAY,CAAA,EAGT,CAHS;AAO7B;AAyBA;AAAoC,cAzBvB,mBAyBuB,EAzBF,OAyBE;;;;AAKvB,KALD,kBA8EX,CAAA,CAAA,CAAA,GA9EmC,CA8EnC,SAAA,MAAA,GA7EG,YA6EH,CAAA,MAAA,EAAA;EAEW,QAAA,EA/EyB,oBA+Eb,CAAA,MAAA,CAAA;CAAiB,CAAA,GAAA,KAAA;;AAC7B,cA5EC,oBA4ED,EA5EuB,OA4EvB;AACT,KAFS,YAEA,CAAA,CAAA,EAAA,CAAA,EAAA,UAF6B,aAE7B,CAAA,GAF8C,CAE9C,SAAA;EAKyB,QAAA,EANzB,QAMyB,GAAA,MAAA;EAArB,CALb,QAAA,CAAS,QAAA,CAKI,EAAA,KAAA,EAAA;EAAoB,QAAA,CAAA,EAAA,KAAA,EAAA;AAIpC,CAAA,GAAa;EA2BI,GAAA,EAAA,CAAA,SAAA,EAAA,GAAA,EAAA,GAAA,GAAyB;EAAiB,QAAA,EA/B3C,oBA+B2C,CA/BtB,CA+BsB,CAAA;CAC1B,GAAA,GAAA,GAAA,KAAA;AAAjB,cA5BH,cA4BG,EA5Ba,OA4Bb;;;;AACJ,UAFK,yBAEL,CAAA,CAAA,EAAA,CAAA,EAAA,UAF+C,aAE/C,CAAA,CAAA;EAAY,YAAA,EADR,gBACQ,CADS,CACT,CAAA;EAQZ,QAAA,EARA,YAQA,CARa,CAQb,EARgB,CAQO,EARJ,CAQI,CAAA;AAKnC;;;;;;KALY,uBAAA,GAA0B;;;;KAK1B,0BAA0B,uBACpC,GACA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "angular-intlayer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0-canary.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Angular applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -85,17 +85,17 @@
|
|
|
85
85
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@intlayer/chokidar": "
|
|
89
|
-
"@intlayer/config": "
|
|
90
|
-
"@intlayer/core": "
|
|
91
|
-
"@intlayer/dictionaries-entry": "
|
|
92
|
-
"@intlayer/editor": "
|
|
93
|
-
"@intlayer/types": "
|
|
94
|
-
"@intlayer/webpack": "
|
|
88
|
+
"@intlayer/chokidar": "8.0.0-canary.0",
|
|
89
|
+
"@intlayer/config": "8.0.0-canary.0",
|
|
90
|
+
"@intlayer/core": "8.0.0-canary.0",
|
|
91
|
+
"@intlayer/dictionaries-entry": "8.0.0-canary.0",
|
|
92
|
+
"@intlayer/editor": "8.0.0-canary.0",
|
|
93
|
+
"@intlayer/types": "8.0.0-canary.0",
|
|
94
|
+
"@intlayer/webpack": "8.0.0-canary.0",
|
|
95
95
|
"defu": "6.1.4"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
|
-
"@types/node": "25.0.
|
|
98
|
+
"@types/node": "25.0.9",
|
|
99
99
|
"@types/webpack": "5.28.5",
|
|
100
100
|
"@utils/ts-config": "1.0.4",
|
|
101
101
|
"@utils/ts-config-types": "1.0.4",
|