react-intlayer 5.3.7 → 5.3.8
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/getIntlayer.cjs +10 -5
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/markdown/MarkdownRenderer.cjs +18 -1
- package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -1
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/esm/getIntlayer.mjs +8 -4
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/esm/markdown/MarkdownRenderer.mjs +20 -2
- package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -1
- package/dist/esm/plugins.mjs.map +1 -1
- package/package.json +15 -15
- package/dist/types/IntlayerNode.d.ts +0 -15
- package/dist/types/IntlayerNode.d.ts.map +0 -1
- package/dist/types/UI/ContentSelector.d.ts +0 -10
- package/dist/types/UI/ContentSelector.d.ts.map +0 -1
- package/dist/types/client/IntlayerProvider.d.ts +0 -28
- package/dist/types/client/IntlayerProvider.d.ts.map +0 -1
- package/dist/types/client/PoweredByMeta.d.ts +0 -3
- package/dist/types/client/PoweredByMeta.d.ts.map +0 -1
- package/dist/types/client/getBrowserLocale.d.ts +0 -25
- package/dist/types/client/getBrowserLocale.d.ts.map +0 -1
- package/dist/types/client/index.d.ts +0 -10
- package/dist/types/client/index.d.ts.map +0 -1
- package/dist/types/client/t.d.ts +0 -9
- package/dist/types/client/t.d.ts.map +0 -1
- package/dist/types/client/useContent.d.ts +0 -10
- package/dist/types/client/useContent.d.ts.map +0 -1
- package/dist/types/client/useDictionary.d.ts +0 -9
- package/dist/types/client/useDictionary.d.ts.map +0 -1
- package/dist/types/client/useIntlayer.d.ts +0 -11
- package/dist/types/client/useIntlayer.d.ts.map +0 -1
- package/dist/types/client/useIntlayerAsync.d.ts +0 -14
- package/dist/types/client/useIntlayerAsync.d.ts.map +0 -1
- package/dist/types/client/useLocale.d.ts +0 -16
- package/dist/types/client/useLocale.d.ts.map +0 -1
- package/dist/types/client/useLocaleBase.d.ts +0 -11
- package/dist/types/client/useLocaleBase.d.ts.map +0 -1
- package/dist/types/client/useLocaleCookie.d.ts +0 -17
- package/dist/types/client/useLocaleCookie.d.ts.map +0 -1
- package/dist/types/client/useTraduction.d.ts +0 -24
- package/dist/types/client/useTraduction.d.ts.map +0 -1
- package/dist/types/editor/ContentSelectorWrapper.d.ts +0 -5
- package/dist/types/editor/ContentSelectorWrapper.d.ts.map +0 -1
- package/dist/types/editor/IntlayerEditorProvider.d.ts +0 -3
- package/dist/types/editor/IntlayerEditorProvider.d.ts.map +0 -1
- package/dist/types/editor/index.d.ts +0 -2
- package/dist/types/editor/index.d.ts.map +0 -1
- package/dist/types/editor/useEditedContentRenderer.d.ts +0 -12
- package/dist/types/editor/useEditedContentRenderer.d.ts.map +0 -1
- package/dist/types/getDictionary.d.ts +0 -5
- package/dist/types/getDictionary.d.ts.map +0 -1
- package/dist/types/getIntlayer.d.ts +0 -5
- package/dist/types/getIntlayer.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -9
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/markdown/MarkdownProvider.d.ts +0 -9
- package/dist/types/markdown/MarkdownProvider.d.ts.map +0 -1
- package/dist/types/markdown/MarkdownRenderer.d.ts +0 -14
- package/dist/types/markdown/MarkdownRenderer.d.ts.map +0 -1
- package/dist/types/markdown/index.d.ts +0 -3
- package/dist/types/markdown/index.d.ts.map +0 -1
- package/dist/types/plugins.d.ts +0 -54
- package/dist/types/plugins.d.ts.map +0 -1
- package/dist/types/reactElement/renderReactElement.d.ts +0 -3
- package/dist/types/reactElement/renderReactElement.d.ts.map +0 -1
- package/dist/types/server/IntlayerServerProvider.d.ts +0 -35
- package/dist/types/server/IntlayerServerProvider.d.ts.map +0 -1
- package/dist/types/server/index.d.ts +0 -5
- package/dist/types/server/index.d.ts.map +0 -1
- package/dist/types/server/serverContext.d.ts +0 -37
- package/dist/types/server/serverContext.d.ts.map +0 -1
- package/dist/types/server/t.d.ts +0 -25
- package/dist/types/server/t.d.ts.map +0 -1
- package/dist/types/server/useDictionary.d.ts +0 -9
- package/dist/types/server/useDictionary.d.ts.map +0 -1
- package/dist/types/server/useIntlayer.d.ts +0 -9
- package/dist/types/server/useIntlayer.d.ts.map +0 -1
package/dist/cjs/getIntlayer.cjs
CHANGED
|
@@ -18,22 +18,27 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var getIntlayer_exports = {};
|
|
20
20
|
__export(getIntlayer_exports, {
|
|
21
|
-
getIntlayer: () => getIntlayer
|
|
21
|
+
getIntlayer: () => getIntlayer,
|
|
22
|
+
reactIntlayerPlugins: () => reactIntlayerPlugins
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(getIntlayer_exports);
|
|
24
25
|
var import_core = require("@intlayer/core");
|
|
25
26
|
var import_plugins = require('./plugins.cjs');
|
|
27
|
+
const reactIntlayerPlugins = [
|
|
28
|
+
import_plugins.intlayerNodePlugins,
|
|
29
|
+
import_plugins.reactNodePlugins,
|
|
30
|
+
import_plugins.markdownPlugin
|
|
31
|
+
];
|
|
26
32
|
const getIntlayer = (key, locale, additionalPlugins) => {
|
|
27
33
|
const plugins = [
|
|
28
|
-
|
|
29
|
-
import_plugins.reactNodePlugins,
|
|
30
|
-
import_plugins.markdownPlugin,
|
|
34
|
+
...reactIntlayerPlugins,
|
|
31
35
|
...additionalPlugins ?? []
|
|
32
36
|
];
|
|
33
37
|
return (0, import_core.getIntlayer)(key, locale, plugins);
|
|
34
38
|
};
|
|
35
39
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
40
|
0 && (module.exports = {
|
|
37
|
-
getIntlayer
|
|
41
|
+
getIntlayer,
|
|
42
|
+
reactIntlayerPlugins
|
|
38
43
|
});
|
|
39
44
|
//# sourceMappingURL=getIntlayer.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import {\n type DictionaryKeys,\n type Plugins,\n getIntlayer as getIntlayerCore,\n} from '@intlayer/core';\nimport type { IntlayerDictionaryTypesConnector, LocalesValues } from 'intlayer';\nimport {\n type DeepTransformContent,\n intlayerNodePlugins,\n markdownPlugin,\n reactNodePlugins,\n} from './plugins';\n\nexport const getIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: L,\n additionalPlugins?: Plugins[]\n) => {\n const plugins: Plugins[] = [\n
|
|
1
|
+
{"version":3,"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import {\n type DictionaryKeys,\n type Plugins,\n getIntlayer as getIntlayerCore,\n} from '@intlayer/core';\nimport type { IntlayerDictionaryTypesConnector, LocalesValues } from 'intlayer';\nimport {\n type DeepTransformContent,\n intlayerNodePlugins,\n markdownPlugin,\n reactNodePlugins,\n} from './plugins';\n\nexport const reactIntlayerPlugins: Plugins[] = [\n intlayerNodePlugins,\n reactNodePlugins,\n markdownPlugin,\n];\n\nexport const getIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: L,\n additionalPlugins?: Plugins[]\n) => {\n const plugins: Plugins[] = [\n ...reactIntlayerPlugins,\n ...(additionalPlugins ?? []),\n ];\n\n return getIntlayerCore(key, locale, plugins) as any as DeepTransformContent<\n IntlayerDictionaryTypesConnector[T]['content']\n >;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAIO;AAEP,qBAKO;AAEA,MAAM,uBAAkC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AACF;AAEO,MAAM,cAAc,CACzB,KACA,QACA,sBACG;AACH,QAAM,UAAqB;AAAA,IACzB,GAAG;AAAA,IACH,GAAI,qBAAqB,CAAC;AAAA,EAC5B;AAEA,aAAO,YAAAA,aAAgB,KAAK,QAAQ,OAAO;AAG7C;","names":["getIntlayerCore"]}
|
|
@@ -29,7 +29,8 @@ var import_core = require("@intlayer/core");
|
|
|
29
29
|
const MarkdownRenderer = ({
|
|
30
30
|
dictionaryKey,
|
|
31
31
|
keyPath,
|
|
32
|
-
children
|
|
32
|
+
children,
|
|
33
|
+
locale
|
|
33
34
|
}) => {
|
|
34
35
|
const { renderMarkdown } = (0, import_MarkdownProvider.useMarkdownContext)();
|
|
35
36
|
const editedContentContext = (0, import_useEditedContentRenderer.useEditedContentRenderer)({
|
|
@@ -37,6 +38,22 @@ const MarkdownRenderer = ({
|
|
|
37
38
|
keyPath,
|
|
38
39
|
children
|
|
39
40
|
});
|
|
41
|
+
if (typeof children !== typeof editedContentContext) {
|
|
42
|
+
console.error("warning ", {
|
|
43
|
+
children,
|
|
44
|
+
editedContentContext,
|
|
45
|
+
keyPath
|
|
46
|
+
});
|
|
47
|
+
const transformedEditedContent = (0, import_core.getContent)(
|
|
48
|
+
editedContentContext,
|
|
49
|
+
{
|
|
50
|
+
dictionaryKey,
|
|
51
|
+
keyPath
|
|
52
|
+
},
|
|
53
|
+
locale
|
|
54
|
+
);
|
|
55
|
+
return renderMarkdown(transformedEditedContent);
|
|
56
|
+
}
|
|
40
57
|
return renderMarkdown(editedContentContext);
|
|
41
58
|
};
|
|
42
59
|
const MarkdownMetadataRenderer = ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["'use client';\n\nimport type { FC, ReactNode } from 'react';\nimport { useMarkdownContext } from './MarkdownProvider';\nimport { useEditedContentRenderer } from '../editor/useEditedContentRenderer';\nimport {\n ContentNode,\n getContentNodeByKeyPath,\n getMarkdownMetadata,\n KeyPath,\n} from '@intlayer/core';\n\ntype MarkdownRendererProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n children: string;\n};\n\nexport const MarkdownRenderer: FC<MarkdownRendererProps> = ({\n dictionaryKey,\n keyPath,\n children,\n}): ReactNode => {\n const { renderMarkdown } = useMarkdownContext();\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey,\n keyPath,\n children,\n });\n\n return renderMarkdown(editedContentContext);\n};\n\ntype MarkdownMetadataRendererProps = MarkdownRendererProps & {\n metadataKeyPath: KeyPath[];\n};\n\nexport const MarkdownMetadataRenderer: FC<MarkdownMetadataRendererProps> = ({\n dictionaryKey,\n keyPath,\n children,\n metadataKeyPath,\n}): ReactNode => {\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey,\n keyPath,\n children,\n });\n const metadata = getMarkdownMetadata(editedContentContext);\n\n const metadataEl = getContentNodeByKeyPath(\n metadata as ContentNode,\n metadataKeyPath\n );\n\n return metadataEl as ReactNode;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,8BAAmC;AACnC,sCAAyC;AACzC,
|
|
1
|
+
{"version":3,"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["'use client';\n\nimport type { FC, ReactNode } from 'react';\nimport { useMarkdownContext } from './MarkdownProvider';\nimport { useEditedContentRenderer } from '../editor/useEditedContentRenderer';\nimport {\n ContentNode,\n getContentNodeByKeyPath,\n getMarkdownMetadata,\n KeyPath,\n getContent,\n} from '@intlayer/core';\nimport { LocalesValues } from 'intlayer';\n\ntype MarkdownRendererProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: LocalesValues;\n children: string;\n};\n\nexport const MarkdownRenderer: FC<MarkdownRendererProps> = ({\n dictionaryKey,\n keyPath,\n children,\n locale,\n}): ReactNode => {\n const { renderMarkdown } = useMarkdownContext();\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey,\n keyPath,\n children,\n });\n\n if (typeof children !== typeof editedContentContext) {\n console.error('warning ', {\n children,\n editedContentContext,\n keyPath,\n });\n const transformedEditedContent = getContent(\n editedContentContext,\n {\n dictionaryKey,\n keyPath,\n },\n locale\n );\n\n return renderMarkdown(transformedEditedContent);\n }\n\n return renderMarkdown(editedContentContext);\n};\n\ntype MarkdownMetadataRendererProps = MarkdownRendererProps & {\n metadataKeyPath: KeyPath[];\n};\n\nexport const MarkdownMetadataRenderer: FC<MarkdownMetadataRendererProps> = ({\n dictionaryKey,\n keyPath,\n children,\n metadataKeyPath,\n}): ReactNode => {\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey,\n keyPath,\n children,\n });\n const metadata = getMarkdownMetadata(editedContentContext);\n\n const metadataEl = getContentNodeByKeyPath(\n metadata as ContentNode,\n metadataKeyPath\n );\n\n return metadataEl as ReactNode;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,8BAAmC;AACnC,sCAAyC;AACzC,kBAMO;AAUA,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAiB;AACf,QAAM,EAAE,eAAe,QAAI,4CAAmB;AAC9C,QAAM,2BAAuB,0DAAyB;AAAA,IACpD;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,MAAI,OAAO,aAAa,OAAO,sBAAsB;AACnD,YAAQ,MAAM,YAAY;AAAA,MACxB;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AACD,UAAM,+BAA2B;AAAA,MAC/B;AAAA,MACA;AAAA,QACE;AAAA,QACA;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAEA,WAAO,eAAe,wBAAwB;AAAA,EAChD;AAEA,SAAO,eAAe,oBAAoB;AAC5C;AAMO,MAAM,2BAA8D,CAAC;AAAA,EAC1E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAiB;AACf,QAAM,2BAAuB,0DAAyB;AAAA,IACpD;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,QAAM,eAAW,iCAAoB,oBAAoB;AAEzD,QAAM,iBAAa;AAAA,IACjB;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
package/dist/cjs/plugins.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugins.tsx"],"sourcesContent":["import {\n type Plugins,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type DeepTransformContent as DeepTransformContentCore,\n type MarkdownContent,\n NodeType,\n KeyPath,\n getMarkdownMetadata,\n} from '@intlayer/core';\nimport type { ReactNode } from 'react';\nimport { renderIntlayerNode, type IntlayerNode } from './IntlayerNode';\nimport { EditedContentRenderer } from './editor/useEditedContentRenderer';\nimport { ContentSelectorRenderer } from './editor';\nimport { MarkdownMetadataRenderer, MarkdownRenderer } from './markdown';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\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: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children: (\n <ContentSelectorRenderer {...rest}>\n <EditedContentRenderer {...rest}>\n {rest.children}\n </EditedContentRenderer>\n </ContentSelectorRenderer>\n ),\n }),\n};\n\n/** ---------------------------------------------\n * REACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type ReactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? ReactNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const reactNodePlugins: Plugins = {\n id: 'react-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[react-element]]',\n children: (\n <ContentSelectorRenderer {...rest}>\n renderReactElement(node)\n </ContentSelectorRenderer>\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: (\n <ContentSelectorRenderer {...rest}>\n <MarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataRenderer>\n </ContentSelectorRenderer>\n ),\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 renderIntlayerNode({\n ...props,\n value: node,\n children: (\n <ContentSelectorRenderer {...rest}>\n <MarkdownRenderer {...rest}>{node}</MarkdownRenderer>\n </ContentSelectorRenderer>\n ),\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 * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginReact<T> {\n reactNode: ReactNodeCond<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 `react-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = IInterpreterPluginStateCore & {\n reactNode: 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;
|
|
1
|
+
{"version":3,"sources":["../../src/plugins.tsx"],"sourcesContent":["import {\n type Plugins,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type DeepTransformContent as DeepTransformContentCore,\n type MarkdownContent,\n NodeType,\n KeyPath,\n getMarkdownMetadata,\n TypedNode,\n} from '@intlayer/core';\nimport type { ReactNode } from 'react';\nimport { renderIntlayerNode, type IntlayerNode } from './IntlayerNode';\nimport { EditedContentRenderer } from './editor/useEditedContentRenderer';\nimport { ContentSelectorRenderer } from './editor';\nimport { MarkdownMetadataRenderer, MarkdownRenderer } from './markdown';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\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: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children: (\n <ContentSelectorRenderer {...rest}>\n <EditedContentRenderer {...rest}>\n {rest.children}\n </EditedContentRenderer>\n </ContentSelectorRenderer>\n ),\n }),\n};\n\n/** ---------------------------------------------\n * REACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type ReactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? ReactNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const reactNodePlugins: Plugins = {\n id: 'react-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[react-element]]',\n children: (\n <ContentSelectorRenderer {...rest}>\n renderReactElement(node)\n </ContentSelectorRenderer>\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: (\n <ContentSelectorRenderer {...rest}>\n <MarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataRenderer>\n </ContentSelectorRenderer>\n ),\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 renderIntlayerNode({\n ...props,\n value: node,\n children: (\n <ContentSelectorRenderer {...rest}>\n <MarkdownRenderer {...rest}>{node}</MarkdownRenderer>\n </ContentSelectorRenderer>\n ),\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 * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginReact<T> {\n reactNode: ReactNodeCond<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 `react-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = IInterpreterPluginStateCore & {\n reactNode: 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;AA2CU;AA3CV,kBASO;AAEP,0BAAsD;AACtD,sCAAsC;AACtC,oBAAwC;AACxC,sBAA2D;AAWpD,MAAM,sBAA+B;AAAA,EAC1C,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;AAAA,EAClB,WAAW,CACT,OACA;AAAA,IACE;AAAA;AAAA,IACA,GAAG;AAAA,EACL,UAEA,wCAAmB;AAAA,IACjB,GAAG;AAAA,IACH,OAAO,KAAK;AAAA,IACZ,UACE,4CAAC,yCAAyB,GAAG,MAC3B,sDAAC,yDAAuB,GAAG,MACxB,eAAK,UACR,GACF;AAAA,EAEJ,CAAC;AACL;AAcO,MAAM,mBAA4B;AAAA,EACvC,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,KAAK,UAAU,eACtB,OAAO,KAAK,QAAQ;AAAA,EAEtB,WAAW,CACT,OACA;AAAA,IACE;AAAA;AAAA,IACA,GAAG;AAAA,EACL,UAEA,wCAAmB;AAAA,IACjB,GAAG;AAAA,IACH,OAAO;AAAA,IACP,UACE,4CAAC,yCAAyB,GAAG,MAAM,sCAEnC;AAAA,EAEJ,CAAC;AACL;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,eACxB,wCAAmB;AAAA,QACjB,GAAGA;AAAA,QACH,OAAO;AAAA,QACP,UACE,4CAAC,yCAAyB,GAAG,MAC3B;AAAA,UAAC;AAAA;AAAA,YACE,GAAG;AAAA,YACJ,iBAAiBA,OAAM;AAAA,YAEtB;AAAA;AAAA,QACH,GACF;AAAA,MAEJ,CAAC;AAAA,IACL;AAGA,UAAM,gBAAgB,kBAAkB,UAAU;AAAA,MAChD,SAAS,CAAC,eAAe;AAAA,MACzB,eAAe,KAAK;AAAA,MACpB,SAAS,CAAC;AAAA,IACZ,CAAC;AAED,eAAO,wCAAmB;AAAA,MACxB,GAAG;AAAA,MACH,OAAO;AAAA,MACP,UACE,4CAAC,yCAAyB,GAAG,MAC3B,sDAAC,oCAAkB,GAAG,MAAO,gBAAK,GACpC;AAAA,MAEF,iBAAiB;AAAA,QACf,UAAU;AAAA,MACZ;AAAA,IACF,CAAC;AAAA,EACH;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"]}
|
package/dist/esm/getIntlayer.mjs
CHANGED
|
@@ -6,16 +6,20 @@ import {
|
|
|
6
6
|
markdownPlugin,
|
|
7
7
|
reactNodePlugins
|
|
8
8
|
} from "./plugins.mjs";
|
|
9
|
+
const reactIntlayerPlugins = [
|
|
10
|
+
intlayerNodePlugins,
|
|
11
|
+
reactNodePlugins,
|
|
12
|
+
markdownPlugin
|
|
13
|
+
];
|
|
9
14
|
const getIntlayer = (key, locale, additionalPlugins) => {
|
|
10
15
|
const plugins = [
|
|
11
|
-
|
|
12
|
-
reactNodePlugins,
|
|
13
|
-
markdownPlugin,
|
|
16
|
+
...reactIntlayerPlugins,
|
|
14
17
|
...additionalPlugins ?? []
|
|
15
18
|
];
|
|
16
19
|
return getIntlayerCore(key, locale, plugins);
|
|
17
20
|
};
|
|
18
21
|
export {
|
|
19
|
-
getIntlayer
|
|
22
|
+
getIntlayer,
|
|
23
|
+
reactIntlayerPlugins
|
|
20
24
|
};
|
|
21
25
|
//# sourceMappingURL=getIntlayer.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import {\n type DictionaryKeys,\n type Plugins,\n getIntlayer as getIntlayerCore,\n} from '@intlayer/core';\nimport type { IntlayerDictionaryTypesConnector, LocalesValues } from 'intlayer';\nimport {\n type DeepTransformContent,\n intlayerNodePlugins,\n markdownPlugin,\n reactNodePlugins,\n} from './plugins';\n\nexport const getIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: L,\n additionalPlugins?: Plugins[]\n) => {\n const plugins: Plugins[] = [\n
|
|
1
|
+
{"version":3,"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import {\n type DictionaryKeys,\n type Plugins,\n getIntlayer as getIntlayerCore,\n} from '@intlayer/core';\nimport type { IntlayerDictionaryTypesConnector, LocalesValues } from 'intlayer';\nimport {\n type DeepTransformContent,\n intlayerNodePlugins,\n markdownPlugin,\n reactNodePlugins,\n} from './plugins';\n\nexport const reactIntlayerPlugins: Plugins[] = [\n intlayerNodePlugins,\n reactNodePlugins,\n markdownPlugin,\n];\n\nexport const getIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: L,\n additionalPlugins?: Plugins[]\n) => {\n const plugins: Plugins[] = [\n ...reactIntlayerPlugins,\n ...(additionalPlugins ?? []),\n ];\n\n return getIntlayerCore(key, locale, plugins) as any as DeepTransformContent<\n IntlayerDictionaryTypesConnector[T]['content']\n >;\n};\n"],"mappings":"AAAA;AAAA,EAGE,eAAe;AAAA,OACV;AAEP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,uBAAkC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AACF;AAEO,MAAM,cAAc,CACzB,KACA,QACA,sBACG;AACH,QAAM,UAAqB;AAAA,IACzB,GAAG;AAAA,IACH,GAAI,qBAAqB,CAAC;AAAA,EAC5B;AAEA,SAAO,gBAAgB,KAAK,QAAQ,OAAO;AAG7C;","names":[]}
|
|
@@ -3,12 +3,14 @@ import { useMarkdownContext } from "./MarkdownProvider.mjs";
|
|
|
3
3
|
import { useEditedContentRenderer } from "../editor/useEditedContentRenderer.mjs";
|
|
4
4
|
import {
|
|
5
5
|
getContentNodeByKeyPath,
|
|
6
|
-
getMarkdownMetadata
|
|
6
|
+
getMarkdownMetadata,
|
|
7
|
+
getContent
|
|
7
8
|
} from "@intlayer/core";
|
|
8
9
|
const MarkdownRenderer = ({
|
|
9
10
|
dictionaryKey,
|
|
10
11
|
keyPath,
|
|
11
|
-
children
|
|
12
|
+
children,
|
|
13
|
+
locale
|
|
12
14
|
}) => {
|
|
13
15
|
const { renderMarkdown } = useMarkdownContext();
|
|
14
16
|
const editedContentContext = useEditedContentRenderer({
|
|
@@ -16,6 +18,22 @@ const MarkdownRenderer = ({
|
|
|
16
18
|
keyPath,
|
|
17
19
|
children
|
|
18
20
|
});
|
|
21
|
+
if (typeof children !== typeof editedContentContext) {
|
|
22
|
+
console.error("warning ", {
|
|
23
|
+
children,
|
|
24
|
+
editedContentContext,
|
|
25
|
+
keyPath
|
|
26
|
+
});
|
|
27
|
+
const transformedEditedContent = getContent(
|
|
28
|
+
editedContentContext,
|
|
29
|
+
{
|
|
30
|
+
dictionaryKey,
|
|
31
|
+
keyPath
|
|
32
|
+
},
|
|
33
|
+
locale
|
|
34
|
+
);
|
|
35
|
+
return renderMarkdown(transformedEditedContent);
|
|
36
|
+
}
|
|
19
37
|
return renderMarkdown(editedContentContext);
|
|
20
38
|
};
|
|
21
39
|
const MarkdownMetadataRenderer = ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["'use client';\n\nimport type { FC, ReactNode } from 'react';\nimport { useMarkdownContext } from './MarkdownProvider';\nimport { useEditedContentRenderer } from '../editor/useEditedContentRenderer';\nimport {\n ContentNode,\n getContentNodeByKeyPath,\n getMarkdownMetadata,\n KeyPath,\n} from '@intlayer/core';\n\ntype MarkdownRendererProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n children: string;\n};\n\nexport const MarkdownRenderer: FC<MarkdownRendererProps> = ({\n dictionaryKey,\n keyPath,\n children,\n}): ReactNode => {\n const { renderMarkdown } = useMarkdownContext();\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey,\n keyPath,\n children,\n });\n\n return renderMarkdown(editedContentContext);\n};\n\ntype MarkdownMetadataRendererProps = MarkdownRendererProps & {\n metadataKeyPath: KeyPath[];\n};\n\nexport const MarkdownMetadataRenderer: FC<MarkdownMetadataRendererProps> = ({\n dictionaryKey,\n keyPath,\n children,\n metadataKeyPath,\n}): ReactNode => {\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey,\n keyPath,\n children,\n });\n const metadata = getMarkdownMetadata(editedContentContext);\n\n const metadataEl = getContentNodeByKeyPath(\n metadata as ContentNode,\n metadataKeyPath\n );\n\n return metadataEl as ReactNode;\n};\n"],"mappings":";AAGA,SAAS,0BAA0B;AACnC,SAAS,gCAAgC;AACzC;AAAA,EAEE;AAAA,EACA;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["'use client';\n\nimport type { FC, ReactNode } from 'react';\nimport { useMarkdownContext } from './MarkdownProvider';\nimport { useEditedContentRenderer } from '../editor/useEditedContentRenderer';\nimport {\n ContentNode,\n getContentNodeByKeyPath,\n getMarkdownMetadata,\n KeyPath,\n getContent,\n} from '@intlayer/core';\nimport { LocalesValues } from 'intlayer';\n\ntype MarkdownRendererProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: LocalesValues;\n children: string;\n};\n\nexport const MarkdownRenderer: FC<MarkdownRendererProps> = ({\n dictionaryKey,\n keyPath,\n children,\n locale,\n}): ReactNode => {\n const { renderMarkdown } = useMarkdownContext();\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey,\n keyPath,\n children,\n });\n\n if (typeof children !== typeof editedContentContext) {\n console.error('warning ', {\n children,\n editedContentContext,\n keyPath,\n });\n const transformedEditedContent = getContent(\n editedContentContext,\n {\n dictionaryKey,\n keyPath,\n },\n locale\n );\n\n return renderMarkdown(transformedEditedContent);\n }\n\n return renderMarkdown(editedContentContext);\n};\n\ntype MarkdownMetadataRendererProps = MarkdownRendererProps & {\n metadataKeyPath: KeyPath[];\n};\n\nexport const MarkdownMetadataRenderer: FC<MarkdownMetadataRendererProps> = ({\n dictionaryKey,\n keyPath,\n children,\n metadataKeyPath,\n}): ReactNode => {\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey,\n keyPath,\n children,\n });\n const metadata = getMarkdownMetadata(editedContentContext);\n\n const metadataEl = getContentNodeByKeyPath(\n metadata as ContentNode,\n metadataKeyPath\n );\n\n return metadataEl as ReactNode;\n};\n"],"mappings":";AAGA,SAAS,0BAA0B;AACnC,SAAS,gCAAgC;AACzC;AAAA,EAEE;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AAUA,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAiB;AACf,QAAM,EAAE,eAAe,IAAI,mBAAmB;AAC9C,QAAM,uBAAuB,yBAAyB;AAAA,IACpD;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,MAAI,OAAO,aAAa,OAAO,sBAAsB;AACnD,YAAQ,MAAM,YAAY;AAAA,MACxB;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AACD,UAAM,2BAA2B;AAAA,MAC/B;AAAA,MACA;AAAA,QACE;AAAA,QACA;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAEA,WAAO,eAAe,wBAAwB;AAAA,EAChD;AAEA,SAAO,eAAe,oBAAoB;AAC5C;AAMO,MAAM,2BAA8D,CAAC;AAAA,EAC1E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAiB;AACf,QAAM,uBAAuB,yBAAyB;AAAA,IACpD;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,QAAM,WAAW,oBAAoB,oBAAoB;AAEzD,QAAM,aAAa;AAAA,IACjB;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
package/dist/esm/plugins.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugins.tsx"],"sourcesContent":["import {\n type Plugins,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type DeepTransformContent as DeepTransformContentCore,\n type MarkdownContent,\n NodeType,\n KeyPath,\n getMarkdownMetadata,\n} from '@intlayer/core';\nimport type { ReactNode } from 'react';\nimport { renderIntlayerNode, type IntlayerNode } from './IntlayerNode';\nimport { EditedContentRenderer } from './editor/useEditedContentRenderer';\nimport { ContentSelectorRenderer } from './editor';\nimport { MarkdownMetadataRenderer, MarkdownRenderer } from './markdown';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\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: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children: (\n <ContentSelectorRenderer {...rest}>\n <EditedContentRenderer {...rest}>\n {rest.children}\n </EditedContentRenderer>\n </ContentSelectorRenderer>\n ),\n }),\n};\n\n/** ---------------------------------------------\n * REACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type ReactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? ReactNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const reactNodePlugins: Plugins = {\n id: 'react-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[react-element]]',\n children: (\n <ContentSelectorRenderer {...rest}>\n renderReactElement(node)\n </ContentSelectorRenderer>\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: (\n <ContentSelectorRenderer {...rest}>\n <MarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataRenderer>\n </ContentSelectorRenderer>\n ),\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 renderIntlayerNode({\n ...props,\n value: node,\n children: (\n <ContentSelectorRenderer {...rest}>\n <MarkdownRenderer {...rest}>{node}</MarkdownRenderer>\n </ContentSelectorRenderer>\n ),\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 * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginReact<T> {\n reactNode: ReactNodeCond<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 `react-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = IInterpreterPluginStateCore & {\n reactNode: true;\n intlayerNode: true;\n markdown: true;\n};\n\nexport type DeepTransformContent<T> = DeepTransformContentCore<\n T,\n IInterpreterPluginState\n>;\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/plugins.tsx"],"sourcesContent":["import {\n type Plugins,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type DeepTransformContent as DeepTransformContentCore,\n type MarkdownContent,\n NodeType,\n KeyPath,\n getMarkdownMetadata,\n TypedNode,\n} from '@intlayer/core';\nimport type { ReactNode } from 'react';\nimport { renderIntlayerNode, type IntlayerNode } from './IntlayerNode';\nimport { EditedContentRenderer } from './editor/useEditedContentRenderer';\nimport { ContentSelectorRenderer } from './editor';\nimport { MarkdownMetadataRenderer, MarkdownRenderer } from './markdown';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\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: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children: (\n <ContentSelectorRenderer {...rest}>\n <EditedContentRenderer {...rest}>\n {rest.children}\n </EditedContentRenderer>\n </ContentSelectorRenderer>\n ),\n }),\n};\n\n/** ---------------------------------------------\n * REACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type ReactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? ReactNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const reactNodePlugins: Plugins = {\n id: 'react-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[react-element]]',\n children: (\n <ContentSelectorRenderer {...rest}>\n renderReactElement(node)\n </ContentSelectorRenderer>\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: (\n <ContentSelectorRenderer {...rest}>\n <MarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataRenderer>\n </ContentSelectorRenderer>\n ),\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 renderIntlayerNode({\n ...props,\n value: node,\n children: (\n <ContentSelectorRenderer {...rest}>\n <MarkdownRenderer {...rest}>{node}</MarkdownRenderer>\n </ContentSelectorRenderer>\n ),\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 * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginReact<T> {\n reactNode: ReactNodeCond<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 `react-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = IInterpreterPluginStateCore & {\n reactNode: true;\n intlayerNode: true;\n markdown: true;\n};\n\nexport type DeepTransformContent<T> = DeepTransformContentCore<\n T,\n IInterpreterPluginState\n>;\n"],"mappings":"AA2CU;AA3CV;AAAA,EAKE;AAAA,EAEA;AAAA,OAEK;AAEP,SAAS,0BAA6C;AACtD,SAAS,6BAA6B;AACtC,SAAS,+BAA+B;AACxC,SAAS,0BAA0B,wBAAwB;AAWpD,MAAM,sBAA+B;AAAA,EAC1C,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;AAAA,EAClB,WAAW,CACT,OACA;AAAA,IACE;AAAA;AAAA,IACA,GAAG;AAAA,EACL,MAEA,mBAAmB;AAAA,IACjB,GAAG;AAAA,IACH,OAAO,KAAK;AAAA,IACZ,UACE,oBAAC,2BAAyB,GAAG,MAC3B,8BAAC,yBAAuB,GAAG,MACxB,eAAK,UACR,GACF;AAAA,EAEJ,CAAC;AACL;AAcO,MAAM,mBAA4B;AAAA,EACvC,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,KAAK,UAAU,eACtB,OAAO,KAAK,QAAQ;AAAA,EAEtB,WAAW,CACT,OACA;AAAA,IACE;AAAA;AAAA,IACA,GAAG;AAAA,EACL,MAEA,mBAAmB;AAAA,IACjB,GAAG;AAAA,IACH,OAAO;AAAA,IACP,UACE,oBAAC,2BAAyB,GAAG,MAAM,sCAEnC;AAAA,EAEJ,CAAC;AACL;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,WACxB,mBAAmB;AAAA,QACjB,GAAGA;AAAA,QACH,OAAO;AAAA,QACP,UACE,oBAAC,2BAAyB,GAAG,MAC3B;AAAA,UAAC;AAAA;AAAA,YACE,GAAG;AAAA,YACJ,iBAAiBA,OAAM;AAAA,YAEtB;AAAA;AAAA,QACH,GACF;AAAA,MAEJ,CAAC;AAAA,IACL;AAGA,UAAM,gBAAgB,kBAAkB,UAAU;AAAA,MAChD,SAAS,CAAC,eAAe;AAAA,MACzB,eAAe,KAAK;AAAA,MACpB,SAAS,CAAC;AAAA,IACZ,CAAC;AAED,WAAO,mBAAmB;AAAA,MACxB,GAAG;AAAA,MACH,OAAO;AAAA,MACP,UACE,oBAAC,2BAAyB,GAAG,MAC3B,8BAAC,oBAAkB,GAAG,MAAO,gBAAK,GACpC;AAAA,MAEF,iBAAiB;AAAA,QACf,UAAU;AAAA,MACZ;AAAA,IACF,CAAC;AAAA,EACH;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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-intlayer",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your React applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -69,11 +69,11 @@
|
|
|
69
69
|
],
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"js-cookie": "^3.0.5",
|
|
72
|
-
"@intlayer/
|
|
73
|
-
"@intlayer/
|
|
74
|
-
"@intlayer/
|
|
75
|
-
"@intlayer/
|
|
76
|
-
"@intlayer/editor-react": "5.3.
|
|
72
|
+
"@intlayer/api": "5.3.8",
|
|
73
|
+
"@intlayer/core": "5.3.8",
|
|
74
|
+
"@intlayer/dictionaries-entry": "5.3.8",
|
|
75
|
+
"@intlayer/config": "5.3.8",
|
|
76
|
+
"@intlayer/editor-react": "5.3.8"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@craco/types": "^7.1.0",
|
|
@@ -89,21 +89,21 @@
|
|
|
89
89
|
"tsc-alias": "^1.8.10",
|
|
90
90
|
"tsup": "^8.3.5",
|
|
91
91
|
"typescript": "^5.7.3",
|
|
92
|
-
"@intlayer/backend": "5.3.7",
|
|
93
92
|
"@utils/eslint-config": "1.0.4",
|
|
94
|
-
"@utils/ts-config": "1.0.4",
|
|
95
93
|
"@utils/ts-config-types": "1.0.4",
|
|
96
|
-
"@
|
|
94
|
+
"@intlayer/backend": "5.3.8",
|
|
95
|
+
"@utils/tsup-config": "1.0.4",
|
|
96
|
+
"@utils/ts-config": "1.0.4"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
99
99
|
"react": ">=16.0.0",
|
|
100
100
|
"react-dom": ">=16.0.0",
|
|
101
|
-
"@intlayer/api": "5.3.
|
|
102
|
-
"@intlayer/config": "5.3.
|
|
103
|
-
"@intlayer/
|
|
104
|
-
"intlayer": "5.3.
|
|
105
|
-
"
|
|
106
|
-
"@intlayer/editor-react": "5.3.
|
|
101
|
+
"@intlayer/api": "5.3.8",
|
|
102
|
+
"@intlayer/config": "5.3.8",
|
|
103
|
+
"@intlayer/core": "5.3.8",
|
|
104
|
+
"@intlayer/dictionaries-entry": "5.3.8",
|
|
105
|
+
"intlayer": "5.3.8",
|
|
106
|
+
"@intlayer/editor-react": "5.3.8"
|
|
107
107
|
},
|
|
108
108
|
"engines": {
|
|
109
109
|
"node": ">=14.18"
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { NodeProps } from '@intlayer/core';
|
|
2
|
-
import { type PropsWithChildren, type ReactNode } from 'react';
|
|
3
|
-
export type IntlayerNode<T = NodeProps['children'], AdditionalProps = {}> = ReactNode & {
|
|
4
|
-
value: T;
|
|
5
|
-
} & AdditionalProps;
|
|
6
|
-
type RenderIntlayerNodeProps<T> = PropsWithChildren<{
|
|
7
|
-
value: T;
|
|
8
|
-
children: ReactNode;
|
|
9
|
-
additionalProps?: {
|
|
10
|
-
[key: string]: any;
|
|
11
|
-
};
|
|
12
|
-
}>;
|
|
13
|
-
export declare const renderIntlayerNode: <T extends number | string | boolean | undefined | null>({ children, value, additionalProps, }: RenderIntlayerNodeProps<T>) => IntlayerNode<T>;
|
|
14
|
-
export {};
|
|
15
|
-
//# sourceMappingURL=IntlayerNode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerNode.d.ts","sourceRoot":"","sources":["../../src/IntlayerNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,SAAS,EAGf,MAAM,OAAO,CAAC;AAEf,MAAM,MAAM,YAAY,CACtB,CAAC,GAAG,SAAS,CAAC,UAAU,CAAC,EACzB,eAAe,GAAG,EAAE,IAClB,SAAS,GAAG;IACd,KAAK,EAAE,CAAC,CAAC;CACV,GAAG,eAAe,CAAC;AAEpB,KAAK,uBAAuB,CAAC,CAAC,IAAI,iBAAiB,CAAC;IAClD,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,EAAE,SAAS,CAAC;IACpB,eAAe,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CAC1C,CAAC,CAAC;AAEH,eAAO,MAAM,kBAAkB,GAC7B,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,EACtD,uCAIC,uBAAuB,CAAC,CAAC,CAAC,KAAG,YAAY,CAAC,CAAC,CA0B7C,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type FC, type HTMLAttributes } from 'react';
|
|
2
|
-
type ContentSelectorProps = {
|
|
3
|
-
onPress: () => void;
|
|
4
|
-
onClickOutside?: () => void;
|
|
5
|
-
pressDuration?: number;
|
|
6
|
-
isSelecting?: boolean;
|
|
7
|
-
} & Omit<HTMLAttributes<HTMLDivElement>, 'content'>;
|
|
8
|
-
export declare const ContentSelector: FC<ContentSelectorProps>;
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=ContentSelector.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelector.d.ts","sourceRoot":"","sources":["../../../src/UI/ContentSelector.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,EAAE,EAEP,KAAK,cAAc,EACpB,MAAM,OAAO,CAAC;AAIf,KAAK,oBAAoB,GAAG;IAC1B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,SAAS,CAAC,CAAC;AAEpD,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAkHpD,CAAC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { LocalesValues } from '@intlayer/config/client';
|
|
2
|
-
import { type FC, type PropsWithChildren } from 'react';
|
|
3
|
-
type IntlayerValue = {
|
|
4
|
-
locale: LocalesValues;
|
|
5
|
-
setLocale: (newLocale: LocalesValues) => void;
|
|
6
|
-
disableEditor?: boolean;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Context that store the current locale on the client side
|
|
10
|
-
*/
|
|
11
|
-
export declare const IntlayerClientContext: import("react").Context<IntlayerValue>;
|
|
12
|
-
/**
|
|
13
|
-
* Hook that provides the current locale
|
|
14
|
-
*/
|
|
15
|
-
export declare const useIntlayerContext: () => IntlayerValue;
|
|
16
|
-
export type IntlayerProviderProps = PropsWithChildren<{
|
|
17
|
-
locale?: LocalesValues;
|
|
18
|
-
defaultLocale?: LocalesValues;
|
|
19
|
-
setLocale?: (locale: LocalesValues) => void;
|
|
20
|
-
disableEditor?: boolean;
|
|
21
|
-
}>;
|
|
22
|
-
/**
|
|
23
|
-
* Provider that store the current locale on the client side
|
|
24
|
-
*/
|
|
25
|
-
export declare const IntlayerProviderContent: FC<IntlayerProviderProps>;
|
|
26
|
-
export declare const IntlayerProvider: FC<IntlayerProviderProps>;
|
|
27
|
-
export {};
|
|
28
|
-
//# sourceMappingURL=IntlayerProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerProvider.d.ts","sourceRoot":"","sources":["../../../src/client/IntlayerProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAI7D,OAAO,EACL,KAAK,EAAE,EACP,KAAK,iBAAiB,EAGvB,MAAM,OAAO,CAAC;AAMf,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,EAAE,CAAC,SAAS,EAAE,aAAa,KAAK,IAAI,CAAC;IAC9C,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,wCAIhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,qBAA0C,CAAC;AAE1E,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;IACpD,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAC5C,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,qBAAqB,CA8C7D,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAKtD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PoweredByMeta.d.ts","sourceRoot":"","sources":["../../../src/client/PoweredByMeta.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,EAAa,MAAM,OAAO,CAAC;AAE3C,eAAO,MAAM,aAAa,EAAE,EAkB3B,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Locales } from '@intlayer/config/client';
|
|
2
|
-
export declare enum LanguageDetector {
|
|
3
|
-
Querystring = "querystring",
|
|
4
|
-
Cookie = "cookie",
|
|
5
|
-
LocalStorage = "localStorage",
|
|
6
|
-
SessionStorage = "sessionStorage",
|
|
7
|
-
Navigator = "navigator",
|
|
8
|
-
HtmlTag = "htmlTag"
|
|
9
|
-
}
|
|
10
|
-
type LanguageDetectorOptions = {
|
|
11
|
-
order?: LanguageDetector[];
|
|
12
|
-
lookupQuerystring?: string;
|
|
13
|
-
lookupCookie?: string;
|
|
14
|
-
lookupLocalStorage?: string;
|
|
15
|
-
lookupSessionStorage?: string;
|
|
16
|
-
excludeCacheFor?: string[];
|
|
17
|
-
htmlTag?: HTMLElement | null;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Core language detector function
|
|
21
|
-
* const detectedLanguages = detectLanguage(['LanguageDetector.Cookie', 'LanguageDetector.LocalStorage'], { lookupCookie: 'myCookie' });
|
|
22
|
-
*/
|
|
23
|
-
export declare const getBrowserLocale: (userOptions?: LanguageDetectorOptions | undefined) => Locales;
|
|
24
|
-
export {};
|
|
25
|
-
//# sourceMappingURL=getBrowserLocale.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getBrowserLocale.d.ts","sourceRoot":"","sources":["../../../src/client/getBrowserLocale.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAKlD,oBAAY,gBAAgB;IAC1B,WAAW,gBAAgB;IAC3B,MAAM,WAAW;IACjB,YAAY,iBAAiB;IAC7B,cAAc,mBAAmB;IACjC,SAAS,cAAc;IACvB,OAAO,YAAY;CACpB;AAGD,KAAK,uBAAuB,GAAG;IAC7B,KAAK,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAC9B,CAAC;AA8JF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAC3B,cAAa,uBAAuB,GAAG,SAAc,KACpD,OAMF,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { type IntlayerProviderProps, IntlayerClientContext, IntlayerProviderContent, useIntlayerContext, IntlayerProvider, } from './IntlayerProvider';
|
|
2
|
-
export { useIntlayer } from './useIntlayer';
|
|
3
|
-
export { useIntlayerAsync } from './useIntlayerAsync';
|
|
4
|
-
export { useDictionary } from './useDictionary';
|
|
5
|
-
export { useLocaleBase } from './useLocaleBase';
|
|
6
|
-
export { useLocale } from './useLocale';
|
|
7
|
-
export { useLocaleCookie, localeCookie, setLocaleCookie, } from './useLocaleCookie';
|
|
8
|
-
export { getBrowserLocale } from './getBrowserLocale';
|
|
9
|
-
export { t } from './t';
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAC1B,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACL,eAAe,EACf,YAAY,EACZ,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC"}
|
package/dist/types/client/t.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Locales } from '@intlayer/config/client';
|
|
2
|
-
import { type LanguageContent } from '@intlayer/core';
|
|
3
|
-
/**
|
|
4
|
-
* On the client side, this function returns the translation of the provided multilang content.
|
|
5
|
-
*
|
|
6
|
-
* If the locale is not provided, it will use the locale from the client context
|
|
7
|
-
*/
|
|
8
|
-
export declare const t: <Content = string>(multilangContent: LanguageContent<Content>, locale?: Locales) => Content;
|
|
9
|
-
//# sourceMappingURL=t.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"t.d.ts","sourceRoot":"","sources":["../../../src/client/t.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,KAAK,eAAe,EAAkB,MAAM,gBAAgB,CAAC;AAItE;;;;GAIG;AACH,eAAO,MAAM,CAAC,GAAI,OAAO,GAAG,MAAM,EAChC,kBAAkB,eAAe,CAAC,OAAO,CAAC,EAC1C,SAAS,OAAO,YAMjB,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { LanguageContent } from '@intlayer/core';
|
|
2
|
-
/**
|
|
3
|
-
* On the client side, hook to get the translation content based on the locale
|
|
4
|
-
*/
|
|
5
|
-
export declare const useContent: <Content>(languageContent: LanguageContent<Content>) => {
|
|
6
|
-
locale: import("intlayer").LocalesValues;
|
|
7
|
-
content: Content;
|
|
8
|
-
t: <Content_1 = string>(languageContent: LanguageContent<Content_1>) => Content_1;
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=useContent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useContent.d.ts","sourceRoot":"","sources":["../../../src/client/useContent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAItD;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,EAChC,iBAAiB,eAAe,CAAC,OAAO,CAAC;;;;CAW1C,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { LocalesValues } from '@intlayer/config/client';
|
|
2
|
-
import type { Dictionary } from '@intlayer/core';
|
|
3
|
-
/**
|
|
4
|
-
* On the server side, Hook that transform a dictionary and return the content
|
|
5
|
-
*
|
|
6
|
-
* If the locale is not provided, it will use the locale from the client context
|
|
7
|
-
*/
|
|
8
|
-
export declare const useDictionary: <T extends Dictionary>(dictionary: T, locale?: LocalesValues) => import("@intlayer/core").DeepTransformContent<T["content"], import("../plugins").IInterpreterPluginState>;
|
|
9
|
-
//# sourceMappingURL=useDictionary.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.d.ts","sourceRoot":"","sources":["../../../src/client/useDictionary.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAKjD;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,UAAU,EAChD,YAAY,CAAC,EACb,SAAS,aAAa,8GAMvB,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Locales } from '@intlayer/config/client';
|
|
2
|
-
import type { DictionaryKeys } from '@intlayer/core';
|
|
3
|
-
import type { IntlayerDictionaryTypesConnector } from 'intlayer';
|
|
4
|
-
import type { DeepTransformContent } from '../plugins';
|
|
5
|
-
/**
|
|
6
|
-
* On the client side, Hook that picking one dictionary by its key and return the content
|
|
7
|
-
*
|
|
8
|
-
* If the locale is not provided, it will use the locale from the client context
|
|
9
|
-
*/
|
|
10
|
-
export declare const useIntlayer: <T extends DictionaryKeys>(key: T, locale?: Locales) => DeepTransformContent<IntlayerDictionaryTypesConnector[T]["content"]>;
|
|
11
|
-
//# sourceMappingURL=useIntlayer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.d.ts","sourceRoot":"","sources":["../../../src/client/useIntlayer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGrD,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAIjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGvD;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,cAAc,EAClD,KAAK,CAAC,EACN,SAAS,OAAO,KACf,oBAAoB,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAWrE,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { LocalesValues } from '@intlayer/config/client';
|
|
2
|
-
import { type DictionaryKeys } from '@intlayer/core';
|
|
3
|
-
/**
|
|
4
|
-
* On the client side, Hook that picking one dictionary by its key and return the content
|
|
5
|
-
*
|
|
6
|
-
* This hook will prerender the locale dictionary and fetch simultaneously the distant dictionaries to hydrate it.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* If the locale is not provided, it will use the locale from the client context
|
|
10
|
-
*/
|
|
11
|
-
export declare const useIntlayerAsync: <T extends DictionaryKeys>(key: T, locale?: LocalesValues) => import("@intlayer/core").DeepTransformContent<import("intlayer").IntlayerDictionaryTypesConnector[T]["content"], import("@intlayer/core").IInterpreterPluginState> & {
|
|
12
|
-
isLoading: boolean;
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=useIntlayerAsync.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayerAsync.d.ts","sourceRoot":"","sources":["../../../src/client/useIntlayerAsync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EACL,KAAK,cAAc,EAGpB,MAAM,gBAAgB,CAAC;AAIxB;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,cAAc,EACvD,KAAK,CAAC,EACN,SAAS,aAAa,KA6B6B,qKAA0B;IAC3E,SAAS,EAAE,OAAO,CAAC;CAEtB,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { LocalesValues } from '@intlayer/config/client';
|
|
2
|
-
type useLocaleProps = {
|
|
3
|
-
onLocaleChange?: (locale: LocalesValues) => void;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* On the client side, hook to get the current locale and all related fields
|
|
7
|
-
*/
|
|
8
|
-
export declare const useLocale: ({ onLocaleChange }?: useLocaleProps) => {
|
|
9
|
-
locale: LocalesValues;
|
|
10
|
-
defaultLocale: import("intlayer").Locales;
|
|
11
|
-
availableLocales: import("intlayer").Locales[];
|
|
12
|
-
localeList: import("intlayer").Locales[];
|
|
13
|
-
setLocale: (locale: LocalesValues) => void;
|
|
14
|
-
};
|
|
15
|
-
export {};
|
|
16
|
-
//# sourceMappingURL=useLocale.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.d.ts","sourceRoot":"","sources":["../../../src/client/useLocale.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAQ7D,KAAK,cAAc,GAAG;IACpB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;CAClD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,GAAI,qBAAoB,cAAmB;;;;;wBAsBpC,aAAa;CAkBzC,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* On the client side, hook to get the current locale and all related fields
|
|
3
|
-
*/
|
|
4
|
-
export declare const useLocaleBase: () => {
|
|
5
|
-
locale: import("intlayer").LocalesValues;
|
|
6
|
-
defaultLocale: import("intlayer").Locales;
|
|
7
|
-
availableLocales: import("intlayer").Locales[];
|
|
8
|
-
localeList: import("intlayer").Locales[];
|
|
9
|
-
setLocale: (newLocale: import("intlayer").LocalesValues) => void;
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=useLocaleBase.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLocaleBase.d.ts","sourceRoot":"","sources":["../../../src/client/useLocaleBase.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;CAUzB,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { LocalesValues } from '@intlayer/config/client';
|
|
2
|
-
/**
|
|
3
|
-
* Get the locale cookie
|
|
4
|
-
*/
|
|
5
|
-
export declare const localeCookie: LocalesValues | undefined;
|
|
6
|
-
/**
|
|
7
|
-
* Set the locale cookie
|
|
8
|
-
*/
|
|
9
|
-
export declare const setLocaleCookie: (locale: LocalesValues) => void;
|
|
10
|
-
/**
|
|
11
|
-
* Hook that provides the locale cookie and a function to set it
|
|
12
|
-
*/
|
|
13
|
-
export declare const useLocaleCookie: () => {
|
|
14
|
-
localeCookie: LocalesValues;
|
|
15
|
-
setLocaleCookie: (locale: LocalesValues) => void;
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=useLocaleCookie.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLocaleCookie.d.ts","sourceRoot":"","sources":["../../../src/client/useLocaleCookie.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAe7D;;GAEG;AACH,eAAO,MAAM,YAAY,EACrB,aAAa,GACb,SAAS,CAAC;AAEd;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,aAAa,SAEpD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe;;8BAPY,aAAa;CAUnD,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { type LanguageContent } from '@intlayer/core';
|
|
2
|
-
/**
|
|
3
|
-
* On the client side, Hook that picking one dictionary by its id and return the content.
|
|
4
|
-
*
|
|
5
|
-
* If not locale found, it will return the content related to the default locale.
|
|
6
|
-
*
|
|
7
|
-
* Return either the content editor, or the content itself depending on the configuration.
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
*
|
|
11
|
-
* ```tsx
|
|
12
|
-
* const content = useTranslation<string>({
|
|
13
|
-
* en: 'Hello',
|
|
14
|
-
* fr: 'Bonjour',
|
|
15
|
-
* }, 'fr');
|
|
16
|
-
* // 'Bonjour'
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* Using TypeScript:
|
|
20
|
-
* - this function will require each locale to be defined if defined in the project configuration.
|
|
21
|
-
* - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.
|
|
22
|
-
*/
|
|
23
|
-
export declare const useTranslation: <Content = string>(languageContent: LanguageContent<Content>) => Content;
|
|
24
|
-
//# sourceMappingURL=useTraduction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useTraduction.d.ts","sourceRoot":"","sources":["../../../src/client/useTraduction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAItE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,GAAG,MAAM,EAC7C,iBAAiB,eAAe,CAAC,OAAO,CAAC,KACxC,OAIF,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type NodeProps } from '@intlayer/core';
|
|
2
|
-
import { type HTMLAttributes, type FC } from 'react';
|
|
3
|
-
export type ContentSelectorWrapperProps = NodeProps & Omit<HTMLAttributes<HTMLDivElement>, 'children'>;
|
|
4
|
-
export declare const ContentSelectorRenderer: FC<ContentSelectorWrapperProps>;
|
|
5
|
-
//# sourceMappingURL=ContentSelectorWrapper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelectorWrapper.d.ts","sourceRoot":"","sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAiB,MAAM,gBAAgB,CAAC;AAE/D,OAAO,EAAE,KAAK,cAAc,EAAwB,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAI3E,MAAM,MAAM,2BAA2B,GAAG,SAAS,GACjD,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC,CAAC;AAkCnD,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,2BAA2B,CAgBnE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerEditorProvider.d.ts","sourceRoot":"","sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAAa,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AA0DnE,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,iBAAiB,CA6CxD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/editor/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { FC } from 'react';
|
|
2
|
-
import type { KeyPath } from '@intlayer/core';
|
|
3
|
-
type EditedContentRendererProps = {
|
|
4
|
-
dictionaryKey: string;
|
|
5
|
-
keyPath: KeyPath[];
|
|
6
|
-
children: string;
|
|
7
|
-
renderChildren?: (children: any) => any;
|
|
8
|
-
};
|
|
9
|
-
export declare const useEditedContentRenderer: ({ dictionaryKey, keyPath, children, }: EditedContentRendererProps) => string;
|
|
10
|
-
export declare const EditedContentRenderer: FC<EditedContentRendererProps>;
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=useEditedContentRenderer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useEditedContentRenderer.d.ts","sourceRoot":"","sources":["../../../src/editor/useEditedContentRenderer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,KAAK,0BAA0B,GAAG;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,GAAG,CAAC;CACzC,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,uCAItC,0BAA0B,WAe5B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,EAAE,CAAC,0BAA0B,CAMhE,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Locales, LocalesValues } from '@intlayer/config/client';
|
|
2
|
-
import { type Dictionary, type Plugins } from '@intlayer/core';
|
|
3
|
-
import { type DeepTransformContent } from './plugins';
|
|
4
|
-
export declare const getDictionary: <T extends Dictionary, L extends LocalesValues = Locales>(dictionary: T, locale?: L, additionalPlugins?: Plugins[]) => DeepTransformContent<T["content"]>;
|
|
5
|
-
//# sourceMappingURL=getDictionary.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getDictionary.d.ts","sourceRoot":"","sources":["../../src/getDictionary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EACL,KAAK,UAAU,EACf,KAAK,OAAO,EAEb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,KAAK,oBAAoB,EAI1B,MAAM,WAAW,CAAC;AAEnB,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"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type DictionaryKeys, type Plugins } from '@intlayer/core';
|
|
2
|
-
import type { IntlayerDictionaryTypesConnector, LocalesValues } from 'intlayer';
|
|
3
|
-
import { type DeepTransformContent } from './plugins';
|
|
4
|
-
export declare const getIntlayer: <T extends DictionaryKeys, L extends LocalesValues>(key: T, locale?: L, additionalPlugins?: Plugins[]) => DeepTransformContent<IntlayerDictionaryTypesConnector[T]["content"]>;
|
|
5
|
-
//# sourceMappingURL=getIntlayer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getIntlayer.d.ts","sourceRoot":"","sources":["../../src/getIntlayer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,OAAO,EAEb,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,gCAAgC,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAChF,OAAO,EACL,KAAK,oBAAoB,EAI1B,MAAM,WAAW,CAAC;AAEnB,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,cAAc,EAAE,CAAC,SAAS,aAAa,EAC3E,KAAK,CAAC,EACN,SAAS,CAAC,EACV,oBAAoB,OAAO,EAAE,KAS0B,oBAAoB,CACzE,gCAAgC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAEjD,CAAC"}
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { IInterpreterPluginReact } from './plugins';
|
|
2
|
-
declare module '@intlayer/core' {
|
|
3
|
-
interface IInterpreterPlugin<T, S> extends IInterpreterPluginReact<T> {
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
export { IntlayerProvider, IntlayerProviderContent, type IntlayerProviderProps, IntlayerClientContext, useIntlayer, useIntlayerAsync, useDictionary, useLocale, useLocaleCookie, useIntlayerContext, localeCookie, setLocaleCookie, getBrowserLocale, useLocaleBase, t, } from './client/index';
|
|
7
|
-
export { type IntlayerNode } from './IntlayerNode';
|
|
8
|
-
export { MarkdownProvider } from './markdown/index';
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,QAAQ,gBAAgB,CAAC;IAC9B,UAAU,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,uBAAuB,CAAC,CAAC,CAAC;KAAG;CACzE;AAED,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,KAAK,qBAAqB,EAC1B,qBAAqB,EACrB,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,CAAC,GACF,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type FC, type PropsWithChildren, type ReactNode } from 'react';
|
|
2
|
-
type MarkdownContextValue = {
|
|
3
|
-
renderMarkdown: (markdown: string) => ReactNode;
|
|
4
|
-
};
|
|
5
|
-
type MarkdownProviderProps = PropsWithChildren<MarkdownContextValue>;
|
|
6
|
-
export declare const useMarkdownContext: () => MarkdownContextValue;
|
|
7
|
-
export declare const MarkdownProvider: FC<MarkdownProviderProps>;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=MarkdownProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownProvider.d.ts","sourceRoot":"","sources":["../../../src/markdown/MarkdownProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,EAAE,EACP,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,KAAK,oBAAoB,GAAG;IAC1B,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,SAAS,CAAC;CACjD,CAAC;AAEF,KAAK,qBAAqB,GAAG,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;AAMrE,eAAO,MAAM,kBAAkB,4BAAoC,CAAC;AAEpE,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAOtD,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { FC } from 'react';
|
|
2
|
-
import { KeyPath } from '@intlayer/core';
|
|
3
|
-
type MarkdownRendererProps = {
|
|
4
|
-
dictionaryKey: string;
|
|
5
|
-
keyPath: KeyPath[];
|
|
6
|
-
children: string;
|
|
7
|
-
};
|
|
8
|
-
export declare const MarkdownRenderer: FC<MarkdownRendererProps>;
|
|
9
|
-
type MarkdownMetadataRendererProps = MarkdownRendererProps & {
|
|
10
|
-
metadataKeyPath: KeyPath[];
|
|
11
|
-
};
|
|
12
|
-
export declare const MarkdownMetadataRenderer: FC<MarkdownMetadataRendererProps>;
|
|
13
|
-
export {};
|
|
14
|
-
//# sourceMappingURL=MarkdownRenderer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownRenderer.d.ts","sourceRoot":"","sources":["../../../src/markdown/MarkdownRenderer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAa,MAAM,OAAO,CAAC;AAG3C,OAAO,EAIL,OAAO,EACR,MAAM,gBAAgB,CAAC;AAExB,KAAK,qBAAqB,GAAG;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAatD,CAAC;AAEF,KAAK,6BAA6B,GAAG,qBAAqB,GAAG;IAC3D,eAAe,EAAE,OAAO,EAAE,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,EAAE,CAAC,6BAA6B,CAmBtE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/markdown/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
|
package/dist/types/plugins.d.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { type Plugins, type IInterpreterPluginState as IInterpreterPluginStateCore, type DeepTransformContent as DeepTransformContentCore, NodeType } from '@intlayer/core';
|
|
2
|
-
import type { ReactNode } from 'react';
|
|
3
|
-
import { type IntlayerNode } from './IntlayerNode';
|
|
4
|
-
/** ---------------------------------------------
|
|
5
|
-
* INTLAYER NODE PLUGIN
|
|
6
|
-
* --------------------------------------------- */
|
|
7
|
-
export type IntlayerNodeCond<T> = T extends number | string ? IntlayerNode<T> : never;
|
|
8
|
-
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
9
|
-
export declare const intlayerNodePlugins: Plugins;
|
|
10
|
-
/** ---------------------------------------------
|
|
11
|
-
* REACT NODE PLUGIN
|
|
12
|
-
* --------------------------------------------- */
|
|
13
|
-
export type ReactNodeCond<T> = T extends {
|
|
14
|
-
props: any;
|
|
15
|
-
key: any;
|
|
16
|
-
} ? ReactNode : never;
|
|
17
|
-
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
18
|
-
export declare const reactNodePlugins: Plugins;
|
|
19
|
-
/**
|
|
20
|
-
* MARKDOWN PLUGIN
|
|
21
|
-
*/
|
|
22
|
-
export type MarkdownStringCond<T> = T extends string ? IntlayerNode<string, {
|
|
23
|
-
metadata: DeepTransformContent<string>;
|
|
24
|
-
}> : never;
|
|
25
|
-
/** Markdown string plugin. Replaces string node with a component that render the markdown. */
|
|
26
|
-
export declare const markdownStringPlugin: Plugins;
|
|
27
|
-
export type MarkdownCond<T> = T extends {
|
|
28
|
-
nodeType: NodeType | string;
|
|
29
|
-
[NodeType.Markdown]: infer M;
|
|
30
|
-
metadata?: infer U;
|
|
31
|
-
} ? IntlayerNode<DeepTransformContent<M>, {
|
|
32
|
-
metadata: DeepTransformContent<U>;
|
|
33
|
-
}> : never;
|
|
34
|
-
export declare const markdownPlugin: Plugins;
|
|
35
|
-
/** ---------------------------------------------
|
|
36
|
-
* PLUGINS RESULT
|
|
37
|
-
* --------------------------------------------- */
|
|
38
|
-
export interface IInterpreterPluginReact<T> {
|
|
39
|
-
reactNode: ReactNodeCond<T>;
|
|
40
|
-
intlayerNode: IntlayerNodeCond<T>;
|
|
41
|
-
markdown: MarkdownCond<T>;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.
|
|
45
|
-
*
|
|
46
|
-
* Otherwise the the `react-intlayer` plugins will override the types of `intlayer` functions.
|
|
47
|
-
*/
|
|
48
|
-
export type IInterpreterPluginState = IInterpreterPluginStateCore & {
|
|
49
|
-
reactNode: true;
|
|
50
|
-
intlayerNode: true;
|
|
51
|
-
markdown: true;
|
|
52
|
-
};
|
|
53
|
-
export type DeepTransformContent<T> = DeepTransformContentCore<T, IInterpreterPluginState>;
|
|
54
|
-
//# sourceMappingURL=plugins.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../src/plugins.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,uBAAuB,IAAI,2BAA2B,EAC3D,KAAK,oBAAoB,IAAI,wBAAwB,EAErD,QAAQ,EAGT,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAKvE;;oDAEoD;AAEpD,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG,MAAM,GACvD,YAAY,CAAC,CAAC,CAAC,GACf,KAAK,CAAC;AAEV,wFAAwF;AACxF,eAAO,MAAM,mBAAmB,EAAE,OAwBjC,CAAC;AAEF;;oDAEoD;AAEpD,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS;IACvC,KAAK,EAAE,GAAG,CAAC;IACX,GAAG,EAAE,GAAG,CAAC;CACV,GACG,SAAS,GACT,KAAK,CAAC;AAEV,wFAAwF;AACxF,eAAO,MAAM,gBAAgB,EAAE,OAuB9B,CAAC;AAEF;;GAEG;AAEH,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAChD,YAAY,CAAC,MAAM,EAAE;IAAE,QAAQ,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC,GAChE,KAAK,CAAC;AAEV,8FAA8F;AAC9F,eAAO,MAAM,oBAAoB,EAAE,OAuDlC,CAAC;AAEF,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS;IACtC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC5B,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;CACpB,GACG,YAAY,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE;IAAE,QAAQ,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAA;CAAE,CAAC,GAC5E,KAAK,CAAC;AAEV,eAAO,MAAM,cAAc,EAAE,OAqB5B,CAAC;AACF;;oDAEoD;AAEpD,MAAM,WAAW,uBAAuB,CAAC,CAAC;IACxC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAC5B,YAAY,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAClC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;CAC3B;AAED;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAAG,2BAA2B,GAAG;IAClE,SAAS,EAAE,IAAI,CAAC;IAChB,YAAY,EAAE,IAAI,CAAC;IACnB,QAAQ,EAAE,IAAI,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,wBAAwB,CAC5D,CAAC,EACD,uBAAuB,CACxB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderReactElement.d.ts","sourceRoot":"","sources":["../../../src/reactElement/renderReactElement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAiC,MAAM,OAAO,CAAC;AAGzE,eAAO,MAAM,kBAAkB,GAAI,SAAS,YAAY,CAAC,GAAG,CAAC,2EA4C5D,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { LocalesValues } from '@intlayer/config/client';
|
|
2
|
-
import type { FC, PropsWithChildren } from 'react';
|
|
3
|
-
/**
|
|
4
|
-
* Context that store the current locale on the server side
|
|
5
|
-
*/
|
|
6
|
-
export declare const IntlayerServerContext: FC<PropsWithChildren<{
|
|
7
|
-
value?: LocalesValues;
|
|
8
|
-
}>> & {
|
|
9
|
-
Provider: FC<PropsWithChildren<{
|
|
10
|
-
value?: LocalesValues;
|
|
11
|
-
}>>;
|
|
12
|
-
Consumer: FC<PropsWithChildren<{
|
|
13
|
-
children: (context: LocalesValues) => import("react").ReactNode;
|
|
14
|
-
}>>;
|
|
15
|
-
_storage: () => {
|
|
16
|
-
value: LocalesValues;
|
|
17
|
-
};
|
|
18
|
-
_defaultValue: LocalesValues;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Hook that provides the current locale
|
|
22
|
-
*/
|
|
23
|
-
export declare const useIntlayer: () => LocalesValues;
|
|
24
|
-
/**
|
|
25
|
-
* Get the current locale
|
|
26
|
-
*/
|
|
27
|
-
export declare const locale: LocalesValues;
|
|
28
|
-
export type IntlayerServerProviderProps = PropsWithChildren & {
|
|
29
|
-
locale?: LocalesValues;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Provider that store the current locale on the server side
|
|
33
|
-
*/
|
|
34
|
-
export declare const IntlayerServerProvider: FC<IntlayerServerProviderProps>;
|
|
35
|
-
//# sourceMappingURL=IntlayerServerProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerServerProvider.d.ts","sourceRoot":"","sources":["../../../src/server/IntlayerServerProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAKnD;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;CACiB,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,WAAW,qBAAgD,CAAC;AAEzE;;GAEG;AACH,eAAO,MAAM,MAAM,eAA0C,CAAC;AAE9D,MAAM,MAAM,2BAA2B,GAAG,iBAAiB,GAAG;IAC5D,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CAOlE,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { IntlayerServerContext as IntlayerServer, locale, IntlayerServerProvider, } from './IntlayerServerProvider';
|
|
2
|
-
export { useIntlayer } from './useIntlayer';
|
|
3
|
-
export { useDictionary } from './useDictionary';
|
|
4
|
-
export { t } from './t';
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,IAAI,cAAc,EACvC,MAAM,EACN,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a new datastore for a given server context.
|
|
3
|
-
* Attempts to closely mimic the `createContext` API.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* const IntlayerServer = createServerContext<string | null>(null);
|
|
7
|
-
*
|
|
8
|
-
* <IntlayerServer value={locale}>
|
|
9
|
-
* {children}
|
|
10
|
-
* </IntlayerServer>
|
|
11
|
-
*/
|
|
12
|
-
import { type FC, type PropsWithChildren, type ReactNode } from 'react';
|
|
13
|
-
export declare const createServerContext: <T>(defaultValue?: T) => ServerContext<T>;
|
|
14
|
-
/**
|
|
15
|
-
* Fetches a value present in a given server context.
|
|
16
|
-
* Attempts to closely mimic the `useContext` API.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* getServerContext(IntlayerServer);
|
|
20
|
-
*/
|
|
21
|
-
export declare const getServerContext: <T>({ _storage, _defaultValue, }: ServerContext<T>) => T;
|
|
22
|
-
type ServerContext<T> = FC<PropsWithChildren<{
|
|
23
|
-
value?: T;
|
|
24
|
-
}>> & {
|
|
25
|
-
Provider: FC<PropsWithChildren<{
|
|
26
|
-
value?: T;
|
|
27
|
-
}>>;
|
|
28
|
-
Consumer: FC<PropsWithChildren<{
|
|
29
|
-
children: (context: T | undefined) => ReactNode;
|
|
30
|
-
}>>;
|
|
31
|
-
_storage: () => {
|
|
32
|
-
value: T | undefined;
|
|
33
|
-
};
|
|
34
|
-
_defaultValue: T | undefined;
|
|
35
|
-
};
|
|
36
|
-
export {};
|
|
37
|
-
//# sourceMappingURL=serverContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serverContext.d.ts","sourceRoot":"","sources":["../../../src/server/serverContext.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAc,EAAE,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAM/E,eAAO,MAAM,mBAAmB,GAAI,CAAC,EAAG,eAAe,CAAC,KAAG,aAAa,CAAC,CAAC,CA4BzE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,EAAG,8BAGlC,aAAa,CAAC,CAAC,CAAC,MAKlB,CAAC;AAEF,KAAK,aAAa,CAAC,CAAC,IAAI,EAAE,CAAC,iBAAiB,CAAC;IAAE,KAAK,CAAC,EAAE,CAAC,CAAA;CAAE,CAAC,CAAC,GAAG;IAC7D,QAAQ,EAAE,EAAE,CAAC,iBAAiB,CAAC;QAAE,KAAK,CAAC,EAAE,CAAC,CAAA;KAAE,CAAC,CAAC,CAAC;IAC/C,QAAQ,EAAE,EAAE,CACV,iBAAiB,CAAC;QAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,SAAS,KAAK,SAAS,CAAA;KAAE,CAAC,CACvE,CAAC;IACF,QAAQ,EAAE,MAAM;QAAE,KAAK,EAAE,CAAC,GAAG,SAAS,CAAA;KAAE,CAAC;IACzC,aAAa,EAAE,CAAC,GAAG,SAAS,CAAC;CAC9B,CAAC"}
|
package/dist/types/server/t.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { LocalesValues } from '@intlayer/config/client';
|
|
2
|
-
import { type LanguageContent } from '@intlayer/core';
|
|
3
|
-
/**
|
|
4
|
-
* On the server side, hook to get the translation content based on the locale
|
|
5
|
-
*
|
|
6
|
-
* If not locale found, it will return the content related to the default locale.
|
|
7
|
-
*
|
|
8
|
-
* Return either the content editor, or the content itself depending on the configuration.
|
|
9
|
-
*
|
|
10
|
-
* Usage:
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* const content = t<string>({
|
|
14
|
-
* en: 'Hello',
|
|
15
|
-
* fr: 'Bonjour',
|
|
16
|
-
* }, 'fr');
|
|
17
|
-
* // 'Bonjour'
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* Using TypeScript:
|
|
21
|
-
* - this function will require each locale to be defined if defined in the project configuration.
|
|
22
|
-
* - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.
|
|
23
|
-
*/
|
|
24
|
-
export declare const t: <Content = string>(multilangContent: LanguageContent<Content>, locale?: LocalesValues) => Content;
|
|
25
|
-
//# sourceMappingURL=t.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"t.d.ts","sourceRoot":"","sources":["../../../src/server/t.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,KAAK,eAAe,EAAkB,MAAM,gBAAgB,CAAC;AAItE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,CAAC,GAAI,OAAO,GAAG,MAAM,EAChC,kBAAkB,eAAe,CAAC,OAAO,CAAC,EAC1C,SAAS,aAAa,YAMvB,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { LocalesValues } from '@intlayer/config/client';
|
|
2
|
-
import { type Dictionary } from '@intlayer/core';
|
|
3
|
-
/**
|
|
4
|
-
* On the server side, Hook that transform a dictionary and return the content
|
|
5
|
-
*
|
|
6
|
-
* If the locale is not provided, it will use the locale from the server context
|
|
7
|
-
*/
|
|
8
|
-
export declare const useDictionary: <T extends Dictionary>(dictionary: T, locale?: LocalesValues) => import("@intlayer/core").DeepTransformContent<T["content"], import("../plugins").IInterpreterPluginState>;
|
|
9
|
-
//# sourceMappingURL=useDictionary.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.d.ts","sourceRoot":"","sources":["../../../src/server/useDictionary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAKjD;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,UAAU,EAChD,YAAY,CAAC,EACb,SAAS,aAAa,8GAMvB,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { LocalesValues } from '@intlayer/config/client';
|
|
2
|
-
import { type DictionaryKeys } from '@intlayer/core';
|
|
3
|
-
/**
|
|
4
|
-
* On the server side, Hook that picking one dictionary by its key and return the content
|
|
5
|
-
*
|
|
6
|
-
* If the locale is not provided, it will use the locale from the server context
|
|
7
|
-
*/
|
|
8
|
-
export declare const useIntlayer: <T extends DictionaryKeys, K extends LocalesValues>(key: T, locale?: K) => import("@intlayer/core").DeepTransformContent<import("intlayer").IntlayerDictionaryTypesConnector[T]["content"], import("../plugins").IInterpreterPluginState>;
|
|
9
|
-
//# sourceMappingURL=useIntlayer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.d.ts","sourceRoot":"","sources":["../../../src/server/useIntlayer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAKrD;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,cAAc,EAAE,CAAC,SAAS,aAAa,EAC3E,KAAK,CAAC,EACN,SAAS,CAAC,mKAMX,CAAC"}
|