react-intlayer 5.0.6 → 5.1.1
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/IntlayerNode.cjs.map +1 -1
- package/dist/cjs/client/IntlayerProvider.cjs +2 -2
- package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
- package/dist/cjs/client/useDictionary.cjs +2 -5
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs +1 -1
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useIntlayerAsync.cjs +2 -2
- package/dist/cjs/client/useIntlayerAsync.cjs.map +1 -1
- package/dist/cjs/editor/ContentSelectorWrapper.cjs +2 -1
- package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -1
- package/dist/cjs/editor/IntlayerEditorProvider.cjs +1 -1
- package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +1 -1
- package/dist/cjs/editor/renderContentEditor.cjs +1 -1
- package/dist/cjs/editor/renderContentEditor.cjs.map +1 -1
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/markdown/MarkdownProvider.cjs +1 -1
- package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -1
- package/dist/cjs/markdown/MarkdownRenderer.cjs +1 -1
- package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -1
- package/dist/cjs/plugins.cjs +1 -1
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/reactElement/renderReactElement.cjs +2 -2
- package/dist/cjs/reactElement/renderReactElement.cjs.map +1 -1
- package/dist/cjs/server/IntlayerServerProvider.cjs +1 -1
- package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -1
- package/dist/cjs/server/serverContext.cjs +15 -11
- package/dist/cjs/server/serverContext.cjs.map +1 -1
- package/dist/cjs/server/t.cjs +1 -1
- package/dist/cjs/server/t.cjs.map +1 -1
- package/dist/cjs/server/useDictionary.cjs +1 -1
- package/dist/cjs/server/useDictionary.cjs.map +1 -1
- package/dist/cjs/server/useIntlayer.cjs +1 -1
- package/dist/cjs/server/useIntlayer.cjs.map +1 -1
- package/dist/esm/IntlayerNode.mjs.map +1 -1
- package/dist/esm/client/IntlayerProvider.mjs +3 -6
- package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
- package/dist/esm/client/useDictionary.mjs +2 -5
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs +1 -1
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useIntlayerAsync.mjs +3 -3
- package/dist/esm/client/useIntlayerAsync.mjs.map +1 -1
- package/dist/esm/editor/ContentSelectorWrapper.mjs +2 -1
- package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -1
- package/dist/esm/editor/IntlayerEditorProvider.mjs +1 -1
- package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -1
- package/dist/esm/editor/renderContentEditor.mjs +1 -1
- package/dist/esm/editor/renderContentEditor.mjs.map +1 -1
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/markdown/MarkdownProvider.mjs +1 -1
- package/dist/esm/markdown/MarkdownProvider.mjs.map +1 -1
- package/dist/esm/markdown/MarkdownRenderer.mjs +1 -1
- package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -1
- package/dist/esm/plugins.mjs +1 -1
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/esm/reactElement/renderReactElement.mjs +2 -2
- package/dist/esm/reactElement/renderReactElement.mjs.map +1 -1
- package/dist/esm/server/IntlayerServerProvider.mjs +1 -1
- package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
- package/dist/esm/server/serverContext.mjs +15 -11
- package/dist/esm/server/serverContext.mjs.map +1 -1
- package/dist/esm/server/t.mjs +1 -1
- package/dist/esm/server/t.mjs.map +1 -1
- package/dist/esm/server/useDictionary.mjs +1 -1
- package/dist/esm/server/useDictionary.mjs.map +1 -1
- package/dist/esm/server/useIntlayer.mjs +1 -1
- package/dist/esm/server/useIntlayer.mjs.map +1 -1
- package/dist/types/client/IntlayerProvider.d.ts +2 -2
- package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
- package/dist/types/client/useDictionary.d.ts +2 -2
- package/dist/types/client/useDictionary.d.ts.map +1 -1
- package/dist/types/client/useIntlayer.d.ts +1 -1
- package/dist/types/client/useIntlayer.d.ts.map +1 -1
- package/dist/types/client/useIntlayerAsync.d.ts +1 -1
- package/dist/types/client/useIntlayerAsync.d.ts.map +1 -1
- package/dist/types/editor/ContentSelectorWrapper.d.ts +1 -1
- package/dist/types/editor/ContentSelectorWrapper.d.ts.map +1 -1
- package/dist/types/editor/IntlayerEditorProvider.d.ts.map +1 -1
- package/dist/types/editor/renderContentEditor.d.ts +2 -2
- package/dist/types/editor/renderContentEditor.d.ts.map +1 -1
- package/dist/types/getDictionary.d.ts +1 -1
- package/dist/types/getDictionary.d.ts.map +1 -1
- package/dist/types/getIntlayer.d.ts +1 -1
- package/dist/types/getIntlayer.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownProvider.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownRenderer.d.ts +1 -1
- package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -1
- package/dist/types/plugins.d.ts +0 -1
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/reactElement/renderReactElement.d.ts +1 -1
- package/dist/types/reactElement/renderReactElement.d.ts.map +1 -1
- package/dist/types/server/IntlayerServerProvider.d.ts +9 -8
- package/dist/types/server/IntlayerServerProvider.d.ts.map +1 -1
- package/dist/types/server/serverContext.d.ts +21 -8
- package/dist/types/server/serverContext.d.ts.map +1 -1
- package/dist/types/server/t.d.ts.map +1 -1
- package/dist/types/server/useIntlayer.d.ts.map +1 -1
- package/package.json +19 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport { type Dictionary } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary<T, LocalesValues>(dictionary, localeTarget);\n};\n"],"mappings":";AAIA,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,6BAA6B;AAO/B,MAAM,gBAAgB,CAC3B,YACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,eAAe,UAAU;AAE/B,SAAO,cAAgC,YAAY,YAAY;AACjE;","names":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useChangedContent } from "@intlayer/editor-react";
|
|
3
3
|
import { useContext } from "react";
|
|
4
|
-
import { IntlayerClientContext } from "./IntlayerProvider.mjs";
|
|
5
4
|
import { getDictionary } from "../getDictionary.mjs";
|
|
6
5
|
import { getIntlayer } from "../getIntlayer.mjs";
|
|
6
|
+
import { IntlayerClientContext } from "./IntlayerProvider.mjs";
|
|
7
7
|
const useIntlayer = (key, locale) => {
|
|
8
8
|
const { locale: currentLocale } = useContext(IntlayerClientContext);
|
|
9
9
|
const { changedContent } = useChangedContent();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport type { DictionaryKeys } from '@intlayer/core';\nimport { useChangedContent } from '@intlayer/editor-react';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { useContext } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useIntlayer = <T extends DictionaryKeys>(\n key: T,\n locale?: Locales\n): DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content']> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const { changedContent } = useChangedContent();\n const localeTarget = locale ?? currentLocale;\n\n if (changedContent?.[key]) {\n // @ts-ignore fix instantiation is excessively deep and possibly infinite\n return getDictionary(changedContent?.[key], localeTarget);\n }\n\n return getIntlayer(key, localeTarget);\n};\n"],"mappings":";AAIA,SAAS,yBAAyB;AAGlC,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AAE5B,SAAS,6BAA6B;AAO/B,MAAM,cAAc,CACzB,KACA,WACyE;AACzE,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,EAAE,eAAe,IAAI,kBAAkB;AAC7C,QAAM,eAAe,UAAU;AAE/B,MAAI,iBAAiB,GAAG,GAAG;AAEzB,WAAO,cAAc,iBAAiB,GAAG,GAAG,YAAY;AAAA,EAC1D;AAEA,SAAO,YAAY,KAAK,YAAY;AACtC;","names":[]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useContext, useEffect, useMemo, useState } from "react";
|
|
3
|
-
import { IntlayerClientContext } from "./IntlayerProvider.mjs";
|
|
4
2
|
import {
|
|
5
3
|
getIntlayer,
|
|
6
4
|
getIntlayerAsync
|
|
7
5
|
} from "@intlayer/core";
|
|
8
|
-
|
|
6
|
+
import { useContext, useEffect, useMemo, useState } from "react";
|
|
7
|
+
import { IntlayerClientContext } from "./IntlayerProvider.mjs";
|
|
8
|
+
const useIntlayerAsync = (key, locale) => {
|
|
9
9
|
const { locale: currentLocale } = useContext(IntlayerClientContext);
|
|
10
10
|
const localeTarget = locale ?? currentLocale;
|
|
11
11
|
const localeDictionary = getIntlayer(key, localeTarget);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/useIntlayerAsync.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport { useContext, useEffect, useMemo, useState } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useIntlayerAsync.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport {\n type DictionaryKeys,\n getIntlayer,\n getIntlayerAsync,\n} from '@intlayer/core';\nimport { useContext, useEffect, useMemo, useState } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its key and return the content\n *\n * This hook will prerender the locale dictionary and fetch simultaneously the distant dictionaries to hydrate it.\n *\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useIntlayerAsync = <T extends DictionaryKeys>(\n key: T,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n const localeDictionary = getIntlayer(key, localeTarget);\n const [distantDictionary, setDistantDictionary] = useState<\n typeof localeDictionary | null | undefined\n >(undefined);\n const [isLoading, setIsLoading] = useState(false);\n\n useEffect(() => {\n setIsLoading(true);\n\n getIntlayerAsync(key)\n .then((distantDictionary) => {\n if (distantDictionary) {\n setDistantDictionary(distantDictionary);\n }\n })\n .finally(() => {\n setIsLoading(false);\n });\n }, []);\n\n const dictionary = useMemo(\n () => distantDictionary ?? localeDictionary,\n [distantDictionary, localeDictionary]\n );\n\n return { ...(dictionary as object), isLoading } as typeof localeDictionary & {\n isLoading: boolean;\n };\n};\n"],"mappings":";AAGA;AAAA,EAEE;AAAA,EACA;AAAA,OACK;AACP,SAAS,YAAY,WAAW,SAAS,gBAAgB;AACzD,SAAS,6BAA6B;AAU/B,MAAM,mBAAmB,CAC9B,KACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,eAAe,UAAU;AAC/B,QAAM,mBAAmB,YAAY,KAAK,YAAY;AACtD,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAEhD,MAAS;AACX,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAEhD,YAAU,MAAM;AACd,iBAAa,IAAI;AAEjB,qBAAiB,GAAG,EACjB,KAAK,CAACA,uBAAsB;AAC3B,UAAIA,oBAAmB;AACrB,6BAAqBA,kBAAiB;AAAA,MACxC;AAAA,IACF,CAAC,EACA,QAAQ,MAAM;AACb,mBAAa,KAAK;AAAA,IACpB,CAAC;AAAA,EACL,GAAG,CAAC,CAAC;AAEL,QAAM,aAAa;AAAA,IACjB,MAAM,qBAAqB;AAAA,IAC3B,CAAC,mBAAmB,gBAAgB;AAAA,EACtC;AAEA,SAAO,EAAE,GAAI,YAAuB,UAAU;AAGhD;","names":["distantDictionary"]}
|
|
@@ -12,12 +12,13 @@ import {
|
|
|
12
12
|
useState,
|
|
13
13
|
useMemo
|
|
14
14
|
} from "react";
|
|
15
|
-
import { ContentSelector } from "../UI/ContentSelector.mjs";
|
|
16
15
|
import { useIntlayerContext } from "../client/index.mjs";
|
|
16
|
+
import { ContentSelector } from "../UI/ContentSelector.mjs";
|
|
17
17
|
const ContentSelectorWrapperContent = ({
|
|
18
18
|
children,
|
|
19
19
|
dictionaryKey,
|
|
20
20
|
keyPath,
|
|
21
|
+
dictionaryPath,
|
|
21
22
|
...props
|
|
22
23
|
}) => {
|
|
23
24
|
const { focusedContent, setFocusedContent } = useFocusDictionary();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { type NodeProps, isSameKeyPath } from '@intlayer/core';\nimport {\n useFocusDictionary,\n useEditedContentActions,\n useEditorEnabled,\n} from '@intlayer/editor-react';\nimport {\n useCallback,\n useEffect,\n useState,\n useMemo,\n type FC,\n type ReactNode,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { type NodeProps, isSameKeyPath } from '@intlayer/core';\nimport {\n useFocusDictionary,\n useEditedContentActions,\n useEditorEnabled,\n} from '@intlayer/editor-react';\nimport {\n type HTMLAttributes,\n useCallback,\n useEffect,\n useState,\n useMemo,\n type FC,\n type ReactNode,\n} from 'react';\nimport { useIntlayerContext } from '../client';\nimport { ContentSelector } from '../UI/ContentSelector';\n\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'content'>;\n\nconst ContentSelectorWrapperContent: FC<ContentSelectorWrapperProps> = ({\n children,\n dictionaryKey,\n keyPath,\n dictionaryPath,\n ...props\n}) => {\n const { focusedContent, setFocusedContent } = useFocusDictionary();\n const { getEditedContentValue } = useEditedContentActions();\n\n const editedValue = useMemo(\n () => getEditedContentValue(dictionaryKey, keyPath),\n [dictionaryKey, keyPath, getEditedContentValue]\n );\n\n const [displayedChildren, setDisplayedChildren] =\n useState<ReactNode>(children);\n\n const handleSelect = useCallback(\n () =>\n setFocusedContent({\n dictionaryKey,\n keyPath,\n }),\n [dictionaryKey, keyPath, setFocusedContent]\n );\n\n const isSelected = useMemo(\n () =>\n (focusedContent?.dictionaryKey === dictionaryKey &&\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent?.keyPath ?? [], keyPath)) ??\n false,\n [focusedContent, keyPath, dictionaryKey]\n );\n\n useEffect(() => {\n // Use useEffect to avoid 'Text content does not match server-rendered HTML' error\n if (editedValue && typeof editedValue === 'string') {\n setDisplayedChildren(editedValue);\n } else {\n setDisplayedChildren(children);\n }\n }, [editedValue, focusedContent, children]);\n\n return (\n <ContentSelector onPress={handleSelect} isSelecting={isSelected} {...props}>\n {displayedChildren}\n </ContentSelector>\n );\n};\n\nexport const ContentSelectorWrapper: FC<ContentSelectorWrapperProps> = ({\n children,\n ...props\n}) => {\n const { enabled } = useEditorEnabled();\n const { disableEditor } = useIntlayerContext();\n\n if (enabled && !disableEditor) {\n return (\n <ContentSelectorWrapperContent {...props}>\n {children}\n </ContentSelectorWrapperContent>\n );\n }\n\n return <>{children}</>;\n};\n"],"mappings":";AAqEI,SAqBK,UArBL;AAnEJ,SAAyB,qBAAqB;AAC9C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAKhC,MAAM,gCAAiE,CAAC;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,gBAAgB,kBAAkB,IAAI,mBAAmB;AACjE,QAAM,EAAE,sBAAsB,IAAI,wBAAwB;AAE1D,QAAM,cAAc;AAAA,IAClB,MAAM,sBAAsB,eAAe,OAAO;AAAA,IAClD,CAAC,eAAe,SAAS,qBAAqB;AAAA,EAChD;AAEA,QAAM,CAAC,mBAAmB,oBAAoB,IAC5C,SAAoB,QAAQ;AAE9B,QAAM,eAAe;AAAA,IACnB,MACE,kBAAkB;AAAA,MAChB;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,eAAe,SAAS,iBAAiB;AAAA,EAC5C;AAEA,QAAM,aAAa;AAAA,IACjB,OACG,gBAAgB,kBAAkB,kBAChC,gBAAgB,SAAS,UAAU,KAAK,KACzC,cAAc,gBAAgB,WAAW,CAAC,GAAG,OAAO,MACtD;AAAA,IACF,CAAC,gBAAgB,SAAS,aAAa;AAAA,EACzC;AAEA,YAAU,MAAM;AAEd,QAAI,eAAe,OAAO,gBAAgB,UAAU;AAClD,2BAAqB,WAAW;AAAA,IAClC,OAAO;AACL,2BAAqB,QAAQ;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,aAAa,gBAAgB,QAAQ,CAAC;AAE1C,SACE,oBAAC,mBAAgB,SAAS,cAAc,aAAa,YAAa,GAAG,OAClE,6BACH;AAEJ;AAEO,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,QAAQ,IAAI,iBAAiB;AACrC,QAAM,EAAE,cAAc,IAAI,mBAAmB;AAE7C,MAAI,WAAW,CAAC,eAAe;AAC7B,WACE,oBAAC,iCAA+B,GAAG,OAChC,UACH;AAAA,EAEJ;AAEA,SAAO,gCAAG,UAAS;AACrB;","names":[]}
|
|
@@ -22,7 +22,7 @@ const IntlayerEditorHooksEnabled = () => {
|
|
|
22
22
|
setLocaleDictionaries(
|
|
23
23
|
dictionaries
|
|
24
24
|
);
|
|
25
|
-
}, [
|
|
25
|
+
}, []);
|
|
26
26
|
useIframeClickInterceptor();
|
|
27
27
|
const { setChangedContent } = useChangedContentActions();
|
|
28
28
|
const { editor } = getConfiguration();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["'use client';\n\nimport { IntlayerEventListener } from '@intlayer/api';\nimport { getConfiguration } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport {\n EditorProvider,\n useCrossURLPathState,\n useDictionariesRecordActions,\n useIframeClickInterceptor,\n useEditorEnabled,\n useChangedContentActions,\n} from '@intlayer/editor-react';\nimport { useEffect, type FC, type PropsWithChildren } from 'react';\n\nconst IntlayerEditorHooksEnabled: FC = () => {\n /**\n * URL Messages\n */\n useCrossURLPathState(undefined, {\n receive: false,\n emit: true,\n });\n\n /**\n * Locale Dictionaries Messages\n */\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n\n useEffect(() => {\n setLocaleDictionaries(\n dictionaries as unknown as Record<string, Dictionary>\n );\n }, []);\n\n /**\n * Click Messages\n */\n useIframeClickInterceptor();\n\n /**\n * Hot reloading\n */\n const { setChangedContent } = useChangedContentActions();\n const { editor } = getConfiguration();\n const eventSource = new IntlayerEventListener();\n\n useEffect(() => {\n if (!editor.hotReload) return;\n if (!editor.clientId) return;\n if (!editor.clientSecret) return;\n\n eventSource.initialize();\n\n eventSource.onDictionaryChange = (dictionary) =>\n setChangedContent(dictionary.key, dictionary.content);\n\n return () => eventSource.cleanup();\n }, []);\n\n return <></>;\n};\n\nconst IntlayerEditorHook: FC = () => {\n const { enabled } = useEditorEnabled();\n\n return enabled ? <IntlayerEditorHooksEnabled /> : <></>;\n};\n\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => {\n const configuration = getConfiguration();\n\n const { editor } = configuration;\n\n return (\n <EditorProvider\n postMessage={(data: any) => {\n if (typeof window === 'undefined') return;\n\n if (editor.applicationURL.length > 0) {\n window?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the current application URL to synchronize the locales states.\n editor.applicationURL\n );\n }\n\n if (editor.editorURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the editor for security reasons.\n // Correspond to the editor URL to synchronize the locales states.\n editor.editorURL\n );\n }\n\n if (editor.cmsURL.length > 0) {\n window.parent?.postMessage(\n data,\n // Use to restrict the origin of the CMS for security reasons.\n // Correspond to the CMS URL.\n editor.cmsURL\n );\n }\n }}\n allowedOrigins={[editor.editorURL, editor.cmsURL, editor.applicationURL]}\n mode=\"client\"\n configuration={configuration}\n >\n <IntlayerEditorHook />\n {children}\n </EditorProvider>\n );\n};\n"],"mappings":";AAkES,wBAeL,YAfK;AAhET,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAOjC,OAAO,kBAAkB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAkD;AAE3D,MAAM,6BAAiC,MAAM;AAI3C,uBAAqB,QAAW;AAAA,IAC9B,SAAS;AAAA,IACT,MAAM;AAAA,EACR,CAAC;AAKD,QAAM,EAAE,sBAAsB,IAAI,6BAA6B;AAE/D,YAAU,MAAM;AACd;AAAA,MACE;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AAKL,4BAA0B;AAK1B,QAAM,EAAE,kBAAkB,IAAI,yBAAyB;AACvD,QAAM,EAAE,OAAO,IAAI,iBAAiB;AACpC,QAAM,cAAc,IAAI,sBAAsB;AAE9C,YAAU,MAAM;AACd,QAAI,CAAC,OAAO,UAAW;AACvB,QAAI,CAAC,OAAO,SAAU;AACtB,QAAI,CAAC,OAAO,aAAc;AAE1B,gBAAY,WAAW;AAEvB,gBAAY,qBAAqB,CAAC,eAChC,kBAAkB,WAAW,KAAK,WAAW,OAAO;AAEtD,WAAO,MAAM,YAAY,QAAQ;AAAA,EACnC,GAAG,CAAC,CAAC;AAEL,SAAO,gCAAE;AACX;AAEA,MAAM,qBAAyB,MAAM;AACnC,QAAM,EAAE,QAAQ,IAAI,iBAAiB;AAErC,SAAO,UAAU,oBAAC,8BAA2B,IAAK,gCAAE;AACtD;AAEO,MAAM,yBAAgD,CAAC,EAAE,SAAS,MAAM;AAC7E,QAAM,gBAAgB,iBAAiB;AAEvC,QAAM,EAAE,OAAO,IAAI;AAEnB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAa,CAAC,SAAc;AAC1B,YAAI,OAAO,WAAW,YAAa;AAEnC,YAAI,OAAO,eAAe,SAAS,GAAG;AACpC,kBAAQ;AAAA,YACN;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAEA,YAAI,OAAO,UAAU,SAAS,GAAG;AAC/B,iBAAO,QAAQ;AAAA,YACb;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAEA,YAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,iBAAO,QAAQ;AAAA,YACb;AAAA;AAAA;AAAA,YAGA,OAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAAA,MACA,gBAAgB,CAAC,OAAO,WAAW,OAAO,QAAQ,OAAO,cAAc;AAAA,MACvE,MAAK;AAAA,MACL;AAAA,MAEA;AAAA,4BAAC,sBAAmB;AAAA,QACnB;AAAA;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { rendererIntlayerNode } from "../IntlayerNode.mjs";
|
|
2
3
|
import {
|
|
3
4
|
ContentSelectorWrapper
|
|
4
5
|
} from "./ContentSelectorWrapper.mjs";
|
|
5
|
-
import { rendererIntlayerNode } from "../IntlayerNode.mjs";
|
|
6
6
|
const renderIntlayerEditor = (props) => rendererIntlayerNode({
|
|
7
7
|
value: props.content,
|
|
8
8
|
children: /* @__PURE__ */ jsx(ContentSelectorWrapper, { ...props, children: props.content })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/renderContentEditor.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/renderContentEditor.tsx"],"sourcesContent":["import { type NodeProps } from '@intlayer/core';\nimport { type IntlayerNode, rendererIntlayerNode } from '../IntlayerNode';\nimport {\n ContentSelectorWrapper,\n type ContentSelectorWrapperProps,\n} from './ContentSelectorWrapper';\n\nexport type RenderIntlayerEditorProps = Omit<\n ContentSelectorWrapperProps,\n 'children' | 'content'\n> &\n NodeProps;\n\nexport const renderIntlayerEditor = (\n props: RenderIntlayerEditorProps\n): IntlayerNode =>\n rendererIntlayerNode({\n value: props.content,\n children: (\n <ContentSelectorWrapper {...props}>\n {props.content}\n </ContentSelectorWrapper>\n ),\n });\n"],"mappings":"AAmBM;AAlBN,SAA4B,4BAA4B;AACxD;AAAA,EACE;AAAA,OAEK;AAQA,MAAM,uBAAuB,CAClC,UAEA,qBAAqB;AAAA,EACnB,OAAO,MAAM;AAAA,EACb,UACE,oBAAC,0BAAwB,GAAG,OACzB,gBAAM,SACT;AAEJ,CAAC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getDictionary.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/getDictionary.ts"],"sourcesContent":["import type { Locales, LocalesValues } from '@intlayer/config/client';\nimport {\n type Dictionary,\n type Plugins,\n getDictionary as getDictionaryCore,\n} from '@intlayer/core';\nimport {\n type DeepTransformContent,\n intlayerNodePlugins,\n markdownPlugin,\n reactNodePlugins,\n} from './plugins';\n\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = Locales,\n>(\n dictionary: T,\n locale?: L,\n additionalPlugins?: Plugins[]\n) => {\n const plugins: Plugins[] = [\n intlayerNodePlugins,\n reactNodePlugins,\n markdownPlugin,\n ...(additionalPlugins ?? []),\n ];\n\n return getDictionaryCore(\n dictionary,\n locale,\n plugins\n ) as any as DeepTransformContent<T['content']>;\n};\n"],"mappings":"AACA;AAAA,EAGE,iBAAiB;AAAA,OACZ;AACP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,gBAAgB,CAI3B,YACA,QACA,sBACG;AACH,QAAM,UAAqB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAI,qBAAqB,CAAC;AAAA,EAC5B;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getIntlayer.ts"],"sourcesContent":["
|
|
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 intlayerNodePlugins,\n reactNodePlugins,\n markdownPlugin,\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,cAAc,CACzB,KACA,QACA,sBACG;AACH,QAAM,UAAqB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAI,qBAAqB,CAAC;AAAA,EAC5B;AAEA,SAAO,gBAAgB,KAAK,QAAQ,OAAO;AAG7C;","names":[]}
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { IInterpreterPluginReact } from './plugins';\n\ndeclare module '@intlayer/core' {\n interface IInterpreterPlugin<T, S> extends IInterpreterPluginReact<T> {}\n}\n\nexport {\n IntlayerProvider,\n IntlayerProviderContent,\n type IntlayerProviderProps,\n IntlayerClientContext,\n useIntlayer,\n useIntlayerAsync,\n useDictionary,\n useLocale,\n useLocaleCookie,\n useIntlayerContext,\n localeCookie,\n setLocaleCookie,\n getBrowserLocale,\n useLocaleBase,\n t,\n} from './client/index';\nexport { type IntlayerNode } from './IntlayerNode';\nexport { MarkdownProvider } from './markdown/index';\n"],"mappings":"AAMA;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,wBAAwB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import type { IInterpreterPluginReact } from './plugins';\n\ndeclare module '@intlayer/core' {\n interface IInterpreterPlugin<T, S> extends IInterpreterPluginReact<T> {}\n}\n\nexport {\n IntlayerProvider,\n IntlayerProviderContent,\n type IntlayerProviderProps,\n IntlayerClientContext,\n useIntlayer,\n useIntlayerAsync,\n useDictionary,\n useLocale,\n useLocaleCookie,\n useIntlayerContext,\n localeCookie,\n setLocaleCookie,\n getBrowserLocale,\n useLocaleBase,\n t,\n} from './client/index';\nexport { type IntlayerNode } from './IntlayerNode';\nexport { MarkdownProvider } from './markdown/index';\n"],"mappings":"AAMA;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,wBAAwB;","names":[]}
|
|
@@ -11,7 +11,7 @@ const useMarkdownContext = () => useContext(MarkdownContext);
|
|
|
11
11
|
const MarkdownProvider = ({
|
|
12
12
|
children,
|
|
13
13
|
renderMarkdown
|
|
14
|
-
}) => /* @__PURE__ */ jsx(MarkdownContext
|
|
14
|
+
}) => /* @__PURE__ */ jsx(MarkdownContext, { value: { renderMarkdown }, children });
|
|
15
15
|
export {
|
|
16
16
|
MarkdownProvider,
|
|
17
17
|
useMarkdownContext
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/markdown/MarkdownProvider.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n useContext,\n type FC,\n type PropsWithChildren,\n type ReactNode,\n} from 'react';\n\ntype MarkdownContextValue = {\n renderMarkdown: (markdown: string) => ReactNode;\n};\n\ntype MarkdownProviderProps = PropsWithChildren<MarkdownContextValue>;\n\nconst MarkdownContext = createContext<MarkdownContextValue>({\n renderMarkdown: (markdown: string) => markdown,\n});\n\nexport const useMarkdownContext = () => useContext(MarkdownContext);\n\nexport const MarkdownProvider: FC<MarkdownProviderProps> = ({\n children,\n renderMarkdown,\n}) =>
|
|
1
|
+
{"version":3,"sources":["../../../src/markdown/MarkdownProvider.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n useContext,\n type FC,\n type PropsWithChildren,\n type ReactNode,\n} from 'react';\n\ntype MarkdownContextValue = {\n renderMarkdown: (markdown: string) => ReactNode;\n};\n\ntype MarkdownProviderProps = PropsWithChildren<MarkdownContextValue>;\n\nconst MarkdownContext = createContext<MarkdownContextValue>({\n renderMarkdown: (markdown: string) => markdown,\n});\n\nexport const useMarkdownContext = () => useContext(MarkdownContext);\n\nexport const MarkdownProvider: FC<MarkdownProviderProps> = ({\n children,\n renderMarkdown,\n}) => <MarkdownContext value={{ renderMarkdown }}>{children}</MarkdownContext>;\n"],"mappings":";AAyBM;AAvBN;AAAA,EACE;AAAA,EACA;AAAA,OAIK;AAQP,MAAM,kBAAkB,cAAoC;AAAA,EAC1D,gBAAgB,CAAC,aAAqB;AACxC,CAAC;AAEM,MAAM,qBAAqB,MAAM,WAAW,eAAe;AAE3D,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AACF,MAAM,oBAAC,mBAAgB,OAAO,EAAE,eAAe,GAAI,UAAS;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["'use client';\n\nimport { FC } from 'react';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["'use client';\n\nimport type { FC } from 'react';\nimport { type IntlayerNode, rendererIntlayerNode } from '../IntlayerNode';\nimport { useMarkdownContext } from './MarkdownProvider';\n\nexport const MarkdownRenderer: FC<{ markdown: string }> = ({\n markdown,\n}): IntlayerNode => {\n const { renderMarkdown } = useMarkdownContext();\n\n return rendererIntlayerNode({\n value: markdown,\n children: renderMarkdown(markdown),\n });\n};\n"],"mappings":";AAGA,SAA4B,4BAA4B;AACxD,SAAS,0BAA0B;AAE5B,MAAM,mBAA6C,CAAC;AAAA,EACzD;AACF,MAAoB;AAClB,QAAM,EAAE,eAAe,IAAI,mBAAmB;AAE9C,SAAO,qBAAqB;AAAA,IAC1B,OAAO;AAAA,IACP,UAAU,eAAe,QAAQ;AAAA,EACnC,CAAC;AACH;","names":[]}
|
package/dist/esm/plugins.mjs
CHANGED
|
@@ -13,7 +13,7 @@ const intlayerNodePlugins = {
|
|
|
13
13
|
}) => renderIntlayerEditor(rest)
|
|
14
14
|
};
|
|
15
15
|
const reactNodePlugins = {
|
|
16
|
-
canHandle: (node) => typeof node === "object" && typeof node.
|
|
16
|
+
canHandle: (node) => typeof node === "object" && typeof node.props !== "undefined" && typeof node.key !== "undefined",
|
|
17
17
|
transform: renderReactElement
|
|
18
18
|
};
|
|
19
19
|
const markdownPlugin = {
|
package/dist/esm/plugins.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugins.tsx"],"sourcesContent":["
|
|
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} from '@intlayer/core';\nimport type { ReactNode } from 'react';\nimport { renderIntlayerEditor } from './editor';\nimport type { IntlayerNode } from './IntlayerNode';\nimport { renderMarkdown } from './markdown/renderMarkdown';\nimport { renderReactElement } from './reactElement/renderReactElement';\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 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 ) => renderIntlayerEditor(rest),\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 canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: renderReactElement,\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: string;\n}\n ? IntlayerNode<string>\n : never;\n\n/** Markdown plugin. Replaces node with a function that takes quantity => string. */\nexport const markdownPlugin: Plugins = {\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent) => renderMarkdown(node[NodeType.Markdown]),\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,EAKE;AAAA,OACK;AAEP,SAAS,4BAA4B;AAErC,SAAS,sBAAsB;AAC/B,SAAS,0BAA0B;AAW5B,MAAM,sBAA+B;AAAA,EAC1C,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;AAAA,EAClB,WAAW,CACT,OACA;AAAA,IACE;AAAA;AAAA,IACA,GAAG;AAAA,EACL,MACG,qBAAqB,IAAI;AAChC;AAcO,MAAM,mBAA4B;AAAA,EACvC,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,KAAK,UAAU,eACtB,OAAO,KAAK,QAAQ;AAAA,EAEtB,WAAW;AACb;AAcO,MAAM,iBAA0B;AAAA,EACrC,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,SAAS;AAAA,EAC1D,WAAW,CAAC,SAA0B,eAAe,KAAK,SAAS,QAAQ,CAAC;AAC9E;","names":[]}
|
|
@@ -19,7 +19,7 @@ const renderReactElement = (element) => {
|
|
|
19
19
|
}
|
|
20
20
|
return {
|
|
21
21
|
...element2,
|
|
22
|
-
props: { ...element2.props, children: element2.props
|
|
22
|
+
props: { ...element2.props, children: element2.props?.children ?? [] }
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
25
|
const fixedElement = convertChildrenAsArray(
|
|
@@ -27,7 +27,7 @@ const renderReactElement = (element) => {
|
|
|
27
27
|
);
|
|
28
28
|
const { type, props } = fixedElement;
|
|
29
29
|
return createElement(
|
|
30
|
-
type ?? "
|
|
30
|
+
type ?? "span",
|
|
31
31
|
props,
|
|
32
32
|
...props.children
|
|
33
33
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/reactElement/renderReactElement.ts"],"sourcesContent":["import { type ReactElement, type ReactNode, createElement } from 'react';\n\n// This function recursively creates React elements from a given JSON-like structure\nexport const renderReactElement = (element: ReactElement) => {\n if (typeof element === 'string') {\n // If it's a string, simply return it (used for text content)\n return element;\n }\n\n const convertChildrenAsArray = (\n element: ReactElement<{ children?: ReactNode }>\n ): ReactElement<{ children?: ReactNode }> => {\n if (element?.props && typeof element.props.children === 'object') {\n const childrenResult: ReactNode[] = [];\n const { children } = element.props;\n\n // Create the children elements recursively, if any\n Object.keys(children ?? {}).forEach((key) => {\n childrenResult.push(\n renderReactElement((children ?? {})[key as keyof typeof children])\n );\n });\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: element.props
|
|
1
|
+
{"version":3,"sources":["../../../src/reactElement/renderReactElement.ts"],"sourcesContent":["import { type ReactElement, type ReactNode, createElement } from 'react';\n\n// This function recursively creates React elements from a given JSON-like structure\nexport const renderReactElement = (element: ReactElement<any>) => {\n if (typeof element === 'string') {\n // If it's a string, simply return it (used for text content)\n return element;\n }\n\n const convertChildrenAsArray = (\n element: ReactElement<{ children?: ReactNode }>\n ): ReactElement<{ children?: ReactNode }> => {\n if (element?.props && typeof element.props.children === 'object') {\n const childrenResult: ReactNode[] = [];\n const { children } = element.props;\n\n // Create the children elements recursively, if any\n Object.keys(children ?? {}).forEach((key) => {\n childrenResult.push(\n renderReactElement((children ?? {})[key as keyof typeof children])\n );\n });\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: element.props?.children ?? [] },\n };\n };\n\n const fixedElement = convertChildrenAsArray(\n element as ReactElement<{ children?: ReactNode }>\n );\n\n const { type, props } = fixedElement;\n\n // Create and return the React element\n return createElement(\n type ?? 'span',\n props,\n ...(props.children as ReactNode[])\n );\n};\n"],"mappings":"AAAA,SAA4C,qBAAqB;AAG1D,MAAM,qBAAqB,CAAC,YAA+B;AAChE,MAAI,OAAO,YAAY,UAAU;AAE/B,WAAO;AAAA,EACT;AAEA,QAAM,yBAAyB,CAC7BA,aAC2C;AAC3C,QAAIA,UAAS,SAAS,OAAOA,SAAQ,MAAM,aAAa,UAAU;AAChE,YAAM,iBAA8B,CAAC;AACrC,YAAM,EAAE,SAAS,IAAIA,SAAQ;AAG7B,aAAO,KAAK,YAAY,CAAC,CAAC,EAAE,QAAQ,CAAC,QAAQ;AAC3C,uBAAe;AAAA,UACb,oBAAoB,YAAY,CAAC,GAAG,GAA4B,CAAC;AAAA,QACnE;AAAA,MACF,CAAC;AAED,aAAO;AAAA,QACL,GAAGA;AAAA,QACH,OAAO,EAAE,GAAGA,SAAQ,OAAO,UAAU,eAAe;AAAA,MACtD;AAAA,IACF;AAEA,WAAO;AAAA,MACL,GAAGA;AAAA,MACH,OAAO,EAAE,GAAGA,SAAQ,OAAO,UAAUA,SAAQ,OAAO,YAAY,CAAC,EAAE;AAAA,IACrE;AAAA,EACF;AAEA,QAAM,eAAe;AAAA,IACnB;AAAA,EACF;AAEA,QAAM,EAAE,MAAM,MAAM,IAAI;AAGxB,SAAO;AAAA,IACL,QAAQ;AAAA,IACR;AAAA,IACA,GAAI,MAAM;AAAA,EACZ;AACF;","names":["element"]}
|
|
@@ -8,7 +8,7 @@ const locale = getServerContext(IntlayerServerContext);
|
|
|
8
8
|
const IntlayerServerProvider = ({
|
|
9
9
|
children,
|
|
10
10
|
locale: locale2 = defaultLocale
|
|
11
|
-
}) => /* @__PURE__ */ jsx(IntlayerServerContext
|
|
11
|
+
}) => /* @__PURE__ */ jsx(IntlayerServerContext, { value: locale2, children });
|
|
12
12
|
export {
|
|
13
13
|
IntlayerServerContext,
|
|
14
14
|
IntlayerServerProvider,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import { type LocalesValues, getConfiguration } from '@intlayer/config/client';\nimport type { FC, PropsWithChildren } from 'react';\nimport { createServerContext, getServerContext } from './serverContext';\n\nconst { defaultLocale } = getConfiguration().internationalization;\n\n/**\n * Context that store the current locale on the server side\n */\nexport const IntlayerServerContext =\n createServerContext<LocalesValues>(defaultLocale);\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayer = () => getServerContext(IntlayerServerContext);\n\n/**\n * Get the current locale\n */\nexport const locale = getServerContext(IntlayerServerContext);\n\nexport type IntlayerServerProviderProps = PropsWithChildren & {\n locale?: LocalesValues;\n};\n\n/**\n * Provider that store the current locale on the server side\n */\nexport const IntlayerServerProvider: FC<IntlayerServerProviderProps> = ({\n children,\n locale = defaultLocale,\n}) =>
|
|
1
|
+
{"version":3,"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import { type LocalesValues, getConfiguration } from '@intlayer/config/client';\nimport type { FC, PropsWithChildren } from 'react';\nimport { createServerContext, getServerContext } from './serverContext';\n\nconst { defaultLocale } = getConfiguration().internationalization;\n\n/**\n * Context that store the current locale on the server side\n */\nexport const IntlayerServerContext =\n createServerContext<LocalesValues>(defaultLocale);\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayer = () => getServerContext(IntlayerServerContext);\n\n/**\n * Get the current locale\n */\nexport const locale = getServerContext(IntlayerServerContext);\n\nexport type IntlayerServerProviderProps = PropsWithChildren & {\n locale?: LocalesValues;\n};\n\n/**\n * Provider that store the current locale on the server side\n */\nexport const IntlayerServerProvider: FC<IntlayerServerProviderProps> = ({\n children,\n locale = defaultLocale,\n}) => <IntlayerServerContext value={locale}>{children}</IntlayerServerContext>;\n"],"mappings":"AAgCM;AAhCN,SAA6B,wBAAwB;AAErD,SAAS,qBAAqB,wBAAwB;AAEtD,MAAM,EAAE,cAAc,IAAI,iBAAiB,EAAE;AAKtC,MAAM,wBACX,oBAAmC,aAAa;AAK3C,MAAM,cAAc,MAAM,iBAAiB,qBAAqB;AAKhE,MAAM,SAAS,iBAAiB,qBAAqB;AASrD,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA,QAAAA,UAAS;AACX,MAAM,oBAAC,yBAAsB,OAAOA,SAAS,UAAS;","names":["locale"]}
|
|
@@ -6,18 +6,22 @@ const createServerContext = (defaultValue) => {
|
|
|
6
6
|
const getCache = cache(() => ({
|
|
7
7
|
value: void 0
|
|
8
8
|
}));
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const store = getCache();
|
|
16
|
-
return children(store ? store.value : defaultValue);
|
|
17
|
-
},
|
|
18
|
-
_storage: getCache,
|
|
19
|
-
_defaultValue: defaultValue
|
|
9
|
+
const Provider = ({
|
|
10
|
+
children,
|
|
11
|
+
value
|
|
12
|
+
}) => {
|
|
13
|
+
getCache().value = value;
|
|
14
|
+
return children;
|
|
20
15
|
};
|
|
16
|
+
const ServerContext = Provider;
|
|
17
|
+
ServerContext.Provider = Provider;
|
|
18
|
+
ServerContext.Consumer = (props) => {
|
|
19
|
+
const store = getCache();
|
|
20
|
+
return props.children(store ? store.value : defaultValue);
|
|
21
|
+
};
|
|
22
|
+
ServerContext._storage = getCache;
|
|
23
|
+
ServerContext._defaultValue = defaultValue;
|
|
24
|
+
return ServerContext;
|
|
21
25
|
};
|
|
22
26
|
const getServerContext = ({
|
|
23
27
|
_storage,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/serverContext.
|
|
1
|
+
{"version":3,"sources":["../../../src/server/serverContext.tsx"],"sourcesContent":["/**\n * Creates a new datastore for a given server context.\n * Attempts to closely mimic the `createContext` API.\n *\n * @example\n * const IntlayerServer = createServerContext<string | null>(null);\n *\n * <IntlayerServer value={locale}>\n * {children}\n * </IntlayerServer>\n */\nimport react, { type FC, type PropsWithChildren, type ReactNode } from 'react';\n\ntype CacheType<T> = () => { value: T | undefined };\n\nconst cacheFallback = () => () => ({ value: undefined });\n\nexport const createServerContext = <T,>(defaultValue?: T): ServerContext<T> => {\n throwInClient();\n\n /** @ts-ignore remove error Property 'cache' does not exist on type 'typeof React'. */\n const cache = react.cache<CacheType<T>> ?? cacheFallback;\n\n const getCache = cache(() => ({\n value: undefined,\n }));\n\n const Provider: FC<PropsWithChildren<{ value?: T }>> = ({\n children,\n value,\n }) => {\n getCache().value = value;\n return children;\n };\n\n const ServerContext = Provider as ServerContext<T>;\n ServerContext.Provider = Provider;\n ServerContext.Consumer = (props) => {\n const store = getCache();\n return props.children(store ? store.value : defaultValue);\n };\n ServerContext._storage = getCache;\n ServerContext._defaultValue = defaultValue;\n\n return ServerContext;\n};\n\n/**\n * Fetches a value present in a given server context.\n * Attempts to closely mimic the `useContext` API.\n *\n * @example\n * getServerContext(IntlayerServer);\n */\nexport const getServerContext = <T,>({\n _storage,\n _defaultValue,\n}: ServerContext<T>) => {\n // throwInClient();\n const store = _storage();\n if (!store) return _defaultValue;\n return store.value;\n};\n\ntype ServerContext<T> = FC<PropsWithChildren<{ value?: T }>> & {\n Provider: FC<PropsWithChildren<{ value?: T }>>;\n Consumer: FC<\n PropsWithChildren<{ children: (context: T | undefined) => ReactNode }>\n >;\n _storage: () => { value: T | undefined };\n _defaultValue: T | undefined;\n};\n\n/**\n * Throws if called within a client component environment.\n * Useful to help prevent mistakes.\n */\nconst throwInClient = (): void | never => {\n // If window.document is defined we're in a client component\n if (typeof window !== 'undefined') {\n throw new Error(`createServerContext only works in Server Components`);\n }\n};\n"],"mappings":"AAWA,OAAO,WAAgE;AAIvE,MAAM,gBAAgB,MAAM,OAAO,EAAE,OAAO,OAAU;AAE/C,MAAM,sBAAsB,CAAK,iBAAuC;AAC7E,gBAAc;AAGd,QAAM,QAAQ,MAAM,SAAuB;AAE3C,QAAM,WAAW,MAAM,OAAO;AAAA,IAC5B,OAAO;AAAA,EACT,EAAE;AAEF,QAAM,WAAiD,CAAC;AAAA,IACtD;AAAA,IACA;AAAA,EACF,MAAM;AACJ,aAAS,EAAE,QAAQ;AACnB,WAAO;AAAA,EACT;AAEA,QAAM,gBAAgB;AACtB,gBAAc,WAAW;AACzB,gBAAc,WAAW,CAAC,UAAU;AAClC,UAAM,QAAQ,SAAS;AACvB,WAAO,MAAM,SAAS,QAAQ,MAAM,QAAQ,YAAY;AAAA,EAC1D;AACA,gBAAc,WAAW;AACzB,gBAAc,gBAAgB;AAE9B,SAAO;AACT;AASO,MAAM,mBAAmB,CAAK;AAAA,EACnC;AAAA,EACA;AACF,MAAwB;AAEtB,QAAM,QAAQ,SAAS;AACvB,MAAI,CAAC,MAAO,QAAO;AACnB,SAAO,MAAM;AACf;AAeA,MAAM,gBAAgB,MAAoB;AAExC,MAAI,OAAO,WAAW,aAAa;AACjC,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACF;","names":[]}
|
package/dist/esm/server/t.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { getTranslation } from "@intlayer/core";
|
|
1
2
|
import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
|
|
2
3
|
import { getServerContext } from "./serverContext.mjs";
|
|
3
|
-
import { getTranslation } from "@intlayer/core";
|
|
4
4
|
const t = (multilangContent, locale) => {
|
|
5
5
|
const currentLocale = getServerContext(IntlayerServerContext);
|
|
6
6
|
const localeTarget = locale ?? currentLocale;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/t.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/server/t.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport { type LanguageContent, getTranslation } from '@intlayer/core';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, hook to get the translation content based on the locale\n *\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```ts\n * const content = t<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const t = <Content = string>(\n multilangContent: LanguageContent<Content>,\n locale?: LocalesValues\n) => {\n const currentLocale = getServerContext<LocalesValues>(IntlayerServerContext);\n const localeTarget = locale ?? currentLocale;\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":"AACA,SAA+B,sBAAsB;AACrD,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAuB1B,MAAM,IAAI,CACf,kBACA,WACG;AACH,QAAM,gBAAgB,iBAAgC,qBAAqB;AAC3E,QAAM,eAAe,UAAU;AAE/B,SAAO,eAAwB,kBAAkB,YAAY;AAC/D;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { getDictionary } from "../getDictionary.mjs";
|
|
1
2
|
import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
|
|
2
3
|
import { getServerContext } from "./serverContext.mjs";
|
|
3
|
-
import { getDictionary } from "../getDictionary.mjs";
|
|
4
4
|
const useDictionary = (dictionary, locale) => {
|
|
5
5
|
const localeTarget = locale ?? getServerContext(IntlayerServerContext);
|
|
6
6
|
return getDictionary(dictionary, localeTarget);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport { type Dictionary } from '@intlayer/core';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport { type Dictionary } from '@intlayer/core';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n) => {\n const localeTarget =\n locale ?? getServerContext<LocalesValues>(IntlayerServerContext);\n\n return getDictionary<T, LocalesValues>(dictionary, localeTarget);\n};\n"],"mappings":"AAEA,SAAS,qBAAqB;AAC9B,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAO1B,MAAM,gBAAgB,CAC3B,YACA,WACG;AACH,QAAM,eACJ,UAAU,iBAAgC,qBAAqB;AAEjE,SAAO,cAAgC,YAAY,YAAY;AACjE;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { getIntlayer } from "../getIntlayer.mjs";
|
|
1
2
|
import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
|
|
2
3
|
import { getServerContext } from "./serverContext.mjs";
|
|
3
|
-
import { getIntlayer } from "../getIntlayer.mjs";
|
|
4
4
|
const useIntlayer = (key, locale) => {
|
|
5
5
|
const localeTarget = locale ?? getServerContext(IntlayerServerContext);
|
|
6
6
|
return getIntlayer(key, localeTarget);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport { type DictionaryKeys } from '@intlayer/core';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useIntlayer = <T extends DictionaryKeys, K extends LocalesValues>(\n key: T,\n locale?: K\n) => {\n const localeTarget =\n locale ?? getServerContext<LocalesValues>(IntlayerServerContext);\n\n return getIntlayer(key, localeTarget);\n};\n"],"mappings":"AAEA,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAO1B,MAAM,cAAc,CACzB,KACA,WACG;AACH,QAAM,eACJ,UAAU,iBAAgC,qBAAqB;AAEjE,SAAO,YAAY,KAAK,YAAY;AACtC;","names":[]}
|
|
@@ -13,11 +13,11 @@ export declare const IntlayerClientContext: import("react").Context<IntlayerValu
|
|
|
13
13
|
* Hook that provides the current locale
|
|
14
14
|
*/
|
|
15
15
|
export declare const useIntlayerContext: () => IntlayerValue;
|
|
16
|
-
export type IntlayerProviderProps = PropsWithChildren
|
|
16
|
+
export type IntlayerProviderProps = PropsWithChildren<{
|
|
17
17
|
locale?: LocalesValues;
|
|
18
18
|
setLocale?: (locale: LocalesValues) => void;
|
|
19
19
|
disableEditor?: boolean;
|
|
20
|
-
}
|
|
20
|
+
}>;
|
|
21
21
|
/**
|
|
22
22
|
* Provider that store the current locale on the client side
|
|
23
23
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerProvider.d.ts","sourceRoot":"","sources":["../../../src/client/IntlayerProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"IntlayerProvider.d.ts","sourceRoot":"","sources":["../../../src/client/IntlayerProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE/E,OAAO,EACL,KAAK,EAAE,EACP,KAAK,iBAAiB,EAKvB,MAAM,OAAO,CAAC;AAKf,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,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,CA6C7D,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAItD,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { LocalesValues } from '@intlayer/config/client';
|
|
2
|
-
import {
|
|
2
|
+
import { type Dictionary } from '@intlayer/core';
|
|
3
3
|
/**
|
|
4
4
|
* On the server side, Hook that transform a dictionary and return the content
|
|
5
5
|
*
|
|
6
6
|
* If the locale is not provided, it will use the locale from the client context
|
|
7
7
|
*/
|
|
8
|
-
export declare const useDictionary: <T extends Dictionary>(dictionary: T, locale?: LocalesValues) => DeepTransformContent<T["content"]>;
|
|
8
|
+
export declare const useDictionary: <T extends Dictionary>(dictionary: T, locale?: LocalesValues) => import("@intlayer/core").DeepTransformContent<T["content"], import("../plugins").IInterpreterPluginState>;
|
|
9
9
|
//# sourceMappingURL=useDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.d.ts","sourceRoot":"","sources":["../../../src/client/useDictionary.ts"],"names":[],"mappings":"
|
|
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,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAKjD;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,UAAU,cACpC,CAAC,WACJ,aAAa,8GAMvB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Locales } from '@intlayer/config/client';
|
|
2
2
|
import type { DictionaryKeys } from '@intlayer/core';
|
|
3
|
-
import { IntlayerDictionaryTypesConnector } from 'intlayer';
|
|
3
|
+
import type { IntlayerDictionaryTypesConnector } from 'intlayer';
|
|
4
4
|
import type { DeepTransformContent } from '../plugins';
|
|
5
5
|
/**
|
|
6
6
|
* On the client side, Hook that picking one dictionary by its key and return the content
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.d.ts","sourceRoot":"","sources":["../../../src/client/useIntlayer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;
|
|
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,OAC7C,CAAC,WACG,OAAO,KACf,oBAAoB,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAWrE,CAAC"}
|
|
@@ -8,7 +8,7 @@ import { type DictionaryKeys } from '@intlayer/core';
|
|
|
8
8
|
*
|
|
9
9
|
* If the locale is not provided, it will use the locale from the client context
|
|
10
10
|
*/
|
|
11
|
-
export declare const useIntlayerAsync: <T extends DictionaryKeys>(key: T, locale?: LocalesValues
|
|
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
12
|
isLoading: boolean;
|
|
13
13
|
};
|
|
14
14
|
//# sourceMappingURL=useIntlayerAsync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayerAsync.d.ts","sourceRoot":"","sources":["../../../src/client/useIntlayerAsync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;
|
|
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,OAClD,CAAC,WACG,aAAa,KA6B6B,qKAA0B;IAC3E,SAAS,EAAE,OAAO,CAAC;CAEtB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type NodeProps } from '@intlayer/core';
|
|
2
|
-
import { type
|
|
2
|
+
import { type HTMLAttributes, type FC } from 'react';
|
|
3
3
|
export type ContentSelectorWrapperProps = NodeProps & Omit<HTMLAttributes<HTMLDivElement>, 'content'>;
|
|
4
4
|
export declare const ContentSelectorWrapper: FC<ContentSelectorWrapperProps>;
|
|
5
5
|
//# sourceMappingURL=ContentSelectorWrapper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelectorWrapper.d.ts","sourceRoot":"","sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAiB,MAAM,gBAAgB,CAAC;AAM/D,OAAO,
|
|
1
|
+
{"version":3,"file":"ContentSelectorWrapper.d.ts","sourceRoot":"","sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAiB,MAAM,gBAAgB,CAAC;AAM/D,OAAO,EACL,KAAK,cAAc,EAKnB,KAAK,EAAE,EAER,MAAM,OAAO,CAAC;AAIf,MAAM,MAAM,2BAA2B,GAAG,SAAS,GACjD,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,SAAS,CAAC,CAAC;AAsDlD,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CAgBlE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerEditorProvider.d.ts","sourceRoot":"","sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IntlayerEditorProvider.d.ts","sourceRoot":"","sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAa,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAwDnE,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,iBAAiB,CA6CxD,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type ContentSelectorWrapperProps } from './ContentSelectorWrapper';
|
|
2
1
|
import { type NodeProps } from '@intlayer/core';
|
|
3
|
-
import { IntlayerNode } from '../IntlayerNode';
|
|
2
|
+
import { type IntlayerNode } from '../IntlayerNode';
|
|
3
|
+
import { type ContentSelectorWrapperProps } from './ContentSelectorWrapper';
|
|
4
4
|
export type RenderIntlayerEditorProps = Omit<ContentSelectorWrapperProps, 'children' | 'content'> & NodeProps;
|
|
5
5
|
export declare const renderIntlayerEditor: (props: RenderIntlayerEditorProps) => IntlayerNode;
|
|
6
6
|
//# sourceMappingURL=renderContentEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderContentEditor.d.ts","sourceRoot":"","sources":["../../../src/editor/renderContentEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"renderContentEditor.d.ts","sourceRoot":"","sources":["../../../src/editor/renderContentEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,KAAK,YAAY,EAAwB,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAEL,KAAK,2BAA2B,EACjC,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAC1C,2BAA2B,EAC3B,UAAU,GAAG,SAAS,CACvB,GACC,SAAS,CAAC;AAEZ,eAAO,MAAM,oBAAoB,UACxB,yBAAyB,KAC/B,YAQC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { Locales, LocalesValues } from '@intlayer/config/client';
|
|
1
2
|
import { type Dictionary, type Plugins } from '@intlayer/core';
|
|
2
3
|
import { type DeepTransformContent } from './plugins';
|
|
3
|
-
import type { Locales, LocalesValues } from '@intlayer/config/client';
|
|
4
4
|
export declare const getDictionary: <T extends Dictionary, L extends LocalesValues = Locales>(dictionary: T, locale?: L, additionalPlugins?: Plugins[]) => DeepTransformContent<T["content"]>;
|
|
5
5
|
//# sourceMappingURL=getDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDictionary.d.ts","sourceRoot":"","sources":["../../src/getDictionary.ts"],"names":[],"mappings":"
|
|
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,wBAEX,CAAC,WACJ,CAAC,sBACU,OAAO,EAAE,KAajB,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,CAC9C,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type DictionaryKeys, type Plugins } from '@intlayer/core';
|
|
2
|
-
import { type DeepTransformContent } from './plugins';
|
|
3
2
|
import type { IntlayerDictionaryTypesConnector, LocalesValues } from 'intlayer';
|
|
3
|
+
import { type DeepTransformContent } from './plugins';
|
|
4
4
|
export declare const getIntlayer: <T extends DictionaryKeys, L extends LocalesValues>(key: T, locale?: L, additionalPlugins?: Plugins[]) => DeepTransformContent<IntlayerDictionaryTypesConnector[T]["content"]>;
|
|
5
5
|
//# sourceMappingURL=getIntlayer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIntlayer.d.ts","sourceRoot":"","sources":["../../src/getIntlayer.ts"],"names":[],"mappings":"
|
|
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,OACtE,CAAC,WACG,CAAC,sBACU,OAAO,EAAE,KAS0B,oBAAoB,CACzE,gCAAgC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAEjD,CAAC"}
|
package/dist/types/index.d.ts
CHANGED