react-intlayer 1.0.1 → 1.2.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/{LocaleContextProvider.cjs → IntlayerProvider.cjs} +11 -11
- package/dist/cjs/IntlayerProvider.cjs.map +1 -0
- package/dist/cjs/IntlayerProvider.d.ts +9 -0
- package/dist/cjs/cli/react-intlayer.cjs +68 -0
- package/dist/cjs/cli/react-intlayer.cjs.map +1 -0
- package/dist/cjs/cli/react-intlayer.d.ts +1 -0
- package/dist/cjs/client/IntlayerClientProvider.cjs +69 -0
- package/dist/cjs/client/IntlayerClientProvider.cjs.map +1 -0
- package/dist/cjs/client/IntlayerClientProvider.d.ts +25 -0
- package/dist/cjs/client/getBrowserLocale.cjs +170 -0
- package/dist/cjs/client/getBrowserLocale.cjs.map +1 -0
- package/dist/cjs/client/getBrowserLocale.d.ts +26 -0
- package/dist/cjs/client/index.cjs +13 -7
- package/dist/cjs/client/index.cjs.map +1 -1
- package/dist/cjs/client/index.d.ts +3 -1
- package/dist/cjs/client/useContent.cjs +2 -2
- package/dist/cjs/client/useContent.cjs.map +1 -1
- package/dist/cjs/client/useContent.d.ts +4 -1
- package/dist/cjs/client/useIntlayer.cjs +2 -2
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.d.ts +5 -0
- package/dist/cjs/client/useLocale.cjs +6 -4
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocale.d.ts +4 -0
- package/dist/cjs/client/{LocaleClientContextProvider.cjs → useLocaleBase.cjs} +24 -17
- package/dist/cjs/client/useLocaleBase.cjs.map +1 -0
- package/dist/cjs/client/useLocaleBase.d.ts +14 -0
- package/dist/cjs/client/useLocaleCookie.cjs +1 -1
- package/dist/cjs/client/useLocaleCookie.cjs.map +1 -1
- package/dist/cjs/client/useLocaleCookie.d.ts +9 -0
- package/dist/cjs/client/useTraduction.cjs +2 -2
- package/dist/cjs/client/useTraduction.cjs.map +1 -1
- package/dist/cjs/client/useTraduction.d.ts +22 -1
- package/dist/cjs/craco/craco.config.cjs +32 -0
- package/dist/cjs/craco/craco.config.cjs.map +1 -0
- package/dist/cjs/craco/craco.config.d.ts +2 -0
- package/dist/cjs/craco/intlayerCracoPlugin.cjs +89 -0
- package/dist/cjs/craco/intlayerCracoPlugin.cjs.map +1 -0
- package/dist/cjs/craco/intlayerCracoPlugin.d.ts +26 -0
- package/dist/cjs/getEnumeration.cjs.map +1 -1
- package/dist/cjs/getEnumeration.d.ts +28 -0
- package/dist/cjs/getTranslation.cjs +1 -1
- package/dist/cjs/getTranslation.cjs.map +1 -1
- package/dist/cjs/getTranslation.d.ts +22 -1
- package/dist/cjs/index.cjs +8 -6
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +3 -1
- package/dist/cjs/processDictionary/index.cjs +33 -1
- package/dist/cjs/processDictionary/index.cjs.map +1 -1
- package/dist/cjs/processDictionary/index.d.ts +1 -1
- package/dist/cjs/server/{LocaleServerContextProvider.cjs → IntlayerServerProvider.cjs} +20 -14
- package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -0
- package/dist/{esm/server/LocaleServerContextProvider.d.mts → cjs/server/IntlayerServerProvider.d.ts} +17 -4
- package/dist/cjs/server/getLocaleTranslation.cjs +3 -3
- package/dist/cjs/server/getLocaleTranslation.cjs.map +1 -1
- package/dist/cjs/server/getLocaleTranslation.d.ts +3 -0
- package/dist/cjs/server/index.cjs +6 -6
- package/dist/cjs/server/index.cjs.map +1 -1
- package/dist/cjs/server/index.d.ts +1 -1
- package/dist/cjs/server/serverContext.cjs.map +1 -1
- package/dist/cjs/server/serverContext.d.ts +4 -4
- package/dist/cjs/server/useIntlayer.cjs +2 -2
- package/dist/cjs/server/useIntlayer.cjs.map +1 -1
- package/dist/cjs/server/useIntlayer.d.ts +5 -0
- package/dist/cjs/server/useTraduction.cjs +2 -2
- package/dist/cjs/server/useTraduction.cjs.map +1 -1
- package/dist/cjs/server/useTraduction.d.ts +22 -1
- package/dist/cjs/useIntlayerBase.cjs.map +1 -1
- package/dist/cjs/useIntlayerBase.d.ts +3 -6
- package/dist/cjs/vite/intlayerPlugin.cjs +60 -0
- package/dist/cjs/vite/intlayerPlugin.cjs.map +1 -0
- package/dist/cjs/vite/intlayerPlugin.d.ts +17 -0
- package/dist/esm/ContentEditor/ContentEditor.mjs +1 -0
- package/dist/esm/ContentEditor/ContentEditor.mjs.map +1 -1
- package/dist/esm/ContentEditor/contentRender.mjs +1 -0
- package/dist/esm/ContentEditor/contentRender.mjs.map +1 -1
- package/dist/esm/IntlayerProvider.d.mts +9 -0
- package/dist/esm/IntlayerProvider.mjs +18 -0
- package/dist/esm/IntlayerProvider.mjs.map +1 -0
- package/dist/esm/chunk-ZNCO4QRF.mjs +9 -0
- package/dist/esm/chunk-ZNCO4QRF.mjs.map +1 -0
- package/dist/esm/cli/react-intlayer.d.mts +1 -0
- package/dist/esm/cli/react-intlayer.mjs +45 -0
- package/dist/esm/cli/react-intlayer.mjs.map +1 -0
- package/dist/esm/client/IntlayerClientProvider.d.mts +25 -0
- package/dist/esm/client/IntlayerClientProvider.mjs +50 -0
- package/dist/esm/client/IntlayerClientProvider.mjs.map +1 -0
- package/dist/esm/client/getBrowserLocale.d.mts +26 -0
- package/dist/esm/client/getBrowserLocale.mjs +146 -0
- package/dist/esm/client/getBrowserLocale.mjs.map +1 -0
- package/dist/esm/client/index.d.mts +3 -1
- package/dist/esm/client/index.mjs +12 -7
- package/dist/esm/client/index.mjs.map +1 -1
- package/dist/esm/client/useContent.d.mts +4 -1
- package/dist/esm/client/useContent.mjs +3 -2
- package/dist/esm/client/useContent.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.d.mts +5 -0
- package/dist/esm/client/useIntlayer.mjs +3 -2
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useLocale.d.mts +4 -0
- package/dist/esm/client/useLocale.mjs +8 -5
- package/dist/esm/client/useLocale.mjs.map +1 -1
- package/dist/esm/client/useLocaleBase.d.mts +14 -0
- package/dist/esm/client/useLocaleBase.mjs +26 -0
- package/dist/esm/client/useLocaleBase.mjs.map +1 -0
- package/dist/esm/client/useLocaleCookie.d.mts +9 -0
- package/dist/esm/client/useLocaleCookie.mjs +3 -4
- package/dist/esm/client/useLocaleCookie.mjs.map +1 -1
- package/dist/esm/client/useTraduction.d.mts +22 -1
- package/dist/esm/client/useTraduction.mjs +3 -2
- package/dist/esm/client/useTraduction.mjs.map +1 -1
- package/dist/esm/craco/craco.config.d.mts +2 -0
- package/dist/esm/craco/craco.config.mjs +17 -0
- package/dist/esm/craco/craco.config.mjs.map +1 -0
- package/dist/esm/craco/intlayerCracoPlugin.d.mts +26 -0
- package/dist/esm/craco/intlayerCracoPlugin.mjs +54 -0
- package/dist/esm/craco/intlayerCracoPlugin.mjs.map +1 -0
- package/dist/esm/getEnumeration.d.mts +28 -0
- package/dist/esm/getEnumeration.mjs +1 -0
- package/dist/esm/getEnumeration.mjs.map +1 -1
- package/dist/esm/getTranslation.d.mts +22 -1
- package/dist/esm/getTranslation.mjs +3 -4
- package/dist/esm/getTranslation.mjs.map +1 -1
- package/dist/esm/index.d.mts +3 -1
- package/dist/esm/index.mjs +10 -7
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/processDictionary/index.d.mts +1 -1
- package/dist/esm/processDictionary/index.mjs +35 -4
- package/dist/esm/processDictionary/index.mjs.map +1 -1
- package/dist/{cjs/server/LocaleServerContextProvider.d.ts → esm/server/IntlayerServerProvider.d.mts} +17 -4
- package/dist/esm/server/IntlayerServerProvider.mjs +20 -0
- package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -0
- package/dist/esm/server/getLocaleTranslation.d.mts +3 -0
- package/dist/esm/server/getLocaleTranslation.mjs +5 -4
- package/dist/esm/server/getLocaleTranslation.mjs.map +1 -1
- package/dist/esm/server/index.d.mts +1 -1
- package/dist/esm/server/index.mjs +6 -5
- package/dist/esm/server/index.mjs.map +1 -1
- package/dist/esm/server/serverContext.d.mts +4 -4
- package/dist/esm/server/serverContext.mjs +1 -0
- package/dist/esm/server/serverContext.mjs.map +1 -1
- package/dist/esm/server/useIntlayer.d.mts +5 -0
- package/dist/esm/server/useIntlayer.mjs +3 -2
- package/dist/esm/server/useIntlayer.mjs.map +1 -1
- package/dist/esm/server/useTraduction.d.mts +22 -1
- package/dist/esm/server/useTraduction.mjs +3 -2
- package/dist/esm/server/useTraduction.mjs.map +1 -1
- package/dist/esm/useIntlayerBase.d.mts +3 -6
- package/dist/esm/useIntlayerBase.mjs +1 -0
- package/dist/esm/useIntlayerBase.mjs.map +1 -1
- package/dist/esm/vite/intlayerPlugin.d.mts +17 -0
- package/dist/esm/vite/intlayerPlugin.mjs +36 -0
- package/dist/esm/vite/intlayerPlugin.mjs.map +1 -0
- package/package.json +32 -7
- package/src/IntlayerProvider.tsx +24 -0
- package/src/cli/react-intlayer.ts +60 -0
- package/src/client/IntlayerClientProvider.tsx +76 -0
- package/src/client/getBrowserLocale.tsx +192 -0
- package/src/client/index.ts +7 -5
- package/src/client/useContent.ts +5 -2
- package/src/client/useIntlayer.ts +7 -2
- package/src/client/useLocale.ts +9 -5
- package/src/client/useLocaleBase.ts +24 -0
- package/src/client/useLocaleCookie.ts +11 -6
- package/src/client/useTraduction.ts +24 -3
- package/src/craco/craco.config.ts +11 -0
- package/src/craco/intlayerCracoPlugin.ts +89 -0
- package/src/getEnumeration.ts +28 -0
- package/src/getTranslation.ts +24 -6
- package/src/index.ts +5 -5
- package/src/processDictionary/index.ts +53 -6
- package/src/server/IntlayerServerProvider.tsx +36 -0
- package/src/server/getLocaleTranslation.ts +7 -4
- package/src/server/index.ts +3 -3
- package/src/server/serverContext.ts +4 -4
- package/src/server/useIntlayer.ts +8 -2
- package/src/server/useTraduction.ts +24 -3
- package/src/useIntlayerBase.ts +4 -1
- package/src/vite/intlayerPlugin.ts +59 -0
- package/dist/cjs/LocaleContextProvider.cjs.map +0 -1
- package/dist/cjs/LocaleContextProvider.d.ts +0 -9
- package/dist/cjs/client/LocaleClientContextProvider.cjs.map +0 -1
- package/dist/cjs/client/LocaleClientContextProvider.d.ts +0 -15
- package/dist/cjs/server/LocaleServerContextProvider.cjs.map +0 -1
- package/dist/esm/LocaleContextProvider.d.mts +0 -9
- package/dist/esm/LocaleContextProvider.mjs +0 -17
- package/dist/esm/LocaleContextProvider.mjs.map +0 -1
- package/dist/esm/client/LocaleClientContextProvider.d.mts +0 -15
- package/dist/esm/client/LocaleClientContextProvider.mjs +0 -21
- package/dist/esm/client/LocaleClientContextProvider.mjs.map +0 -1
- package/dist/esm/server/LocaleServerContextProvider.mjs +0 -16
- package/dist/esm/server/LocaleServerContextProvider.mjs.map +0 -1
- package/src/LocaleContextProvider.tsx +0 -26
- package/src/client/LocaleClientContextProvider.tsx +0 -35
- package/src/server/LocaleServerContextProvider.tsx +0 -24
|
@@ -16,25 +16,31 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
locale: () => locale
|
|
19
|
+
var IntlayerServerProvider_exports = {};
|
|
20
|
+
__export(IntlayerServerProvider_exports, {
|
|
21
|
+
IntlayerServerContext: () => IntlayerServerContext,
|
|
22
|
+
IntlayerServerProvider: () => IntlayerServerProvider,
|
|
23
|
+
locale: () => locale,
|
|
24
|
+
useIntlayer: () => useIntlayer
|
|
24
25
|
});
|
|
25
|
-
module.exports = __toCommonJS(
|
|
26
|
+
module.exports = __toCommonJS(IntlayerServerProvider_exports);
|
|
26
27
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
27
28
|
var import_client = require("@intlayer/config/client");
|
|
28
29
|
var import_serverContext = require('./serverContext.cjs');
|
|
29
|
-
const
|
|
30
|
-
import_client.
|
|
30
|
+
const IntlayerServerContext = (0, import_serverContext.createServerContext)(
|
|
31
|
+
(0, import_client.getConfiguration)().internationalization.defaultLocale
|
|
31
32
|
);
|
|
32
|
-
const
|
|
33
|
-
const
|
|
33
|
+
const useIntlayer = () => (0, import_serverContext.getServerContext)(IntlayerServerContext);
|
|
34
|
+
const locale = (0, import_serverContext.getServerContext)(IntlayerServerContext);
|
|
35
|
+
const IntlayerServerProvider = ({
|
|
36
|
+
children,
|
|
37
|
+
locale: locale2
|
|
38
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IntlayerServerContext.Provider, { value: locale2, children });
|
|
34
39
|
// Annotate the CommonJS export names for ESM import in node:
|
|
35
40
|
0 && (module.exports = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
locale
|
|
41
|
+
IntlayerServerContext,
|
|
42
|
+
IntlayerServerProvider,
|
|
43
|
+
locale,
|
|
44
|
+
useIntlayer
|
|
39
45
|
});
|
|
40
|
-
//# sourceMappingURL=
|
|
46
|
+
//# sourceMappingURL=IntlayerServerProvider.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import { type Locales, getConfiguration } from '@intlayer/config/client';\nimport type { FC, PropsWithChildren } from 'react';\nimport { createServerContext, getServerContext } from './serverContext';\n\n/**\n * Context that store the current locale on the server side\n */\nexport const IntlayerServerContext = createServerContext<Locales>(\n getConfiguration().internationalization.defaultLocale\n);\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: Locales;\n};\n\n/**\n * Provider that store the current locale on the server side\n */\nexport const IntlayerServerProvider: FC<IntlayerServerProviderProps> = ({\n children,\n locale,\n}) => (\n <IntlayerServerContext.Provider value={locale}>\n {children}\n </IntlayerServerContext.Provider>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgCE;AAhCF,oBAA+C;AAE/C,2BAAsD;AAK/C,MAAM,4BAAwB;AAAA,MACnC,gCAAiB,EAAE,qBAAqB;AAC1C;AAKO,MAAM,cAAc,UAAM,uCAAiB,qBAAqB;AAKhE,MAAM,aAAS,uCAAiB,qBAAqB;AASrD,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA,QAAAA;AACF,MACE,4CAAC,sBAAsB,UAAtB,EAA+B,OAAOA,SACpC,UACH;","names":["locale"]}
|
package/dist/{esm/server/LocaleServerContextProvider.d.mts → cjs/server/IntlayerServerProvider.d.ts}
RENAMED
|
@@ -2,7 +2,10 @@ import * as react from 'react';
|
|
|
2
2
|
import { PropsWithChildren, FC } from 'react';
|
|
3
3
|
import { Locales } from '@intlayer/config/client';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Context that store the current locale on the server side
|
|
7
|
+
*/
|
|
8
|
+
declare const IntlayerServerContext: {
|
|
6
9
|
Provider: ({ children, value, }: {
|
|
7
10
|
children: react.ReactNode;
|
|
8
11
|
value: Locales;
|
|
@@ -15,10 +18,20 @@ declare const LocaleServerContext: {
|
|
|
15
18
|
};
|
|
16
19
|
_defaultValue: Locales | undefined;
|
|
17
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Hook that provides the current locale
|
|
23
|
+
*/
|
|
24
|
+
declare const useIntlayer: () => Locales | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Get the current locale
|
|
27
|
+
*/
|
|
18
28
|
declare const locale: Locales | undefined;
|
|
19
|
-
type
|
|
29
|
+
type IntlayerServerProviderProps = PropsWithChildren & {
|
|
20
30
|
locale: Locales;
|
|
21
31
|
};
|
|
22
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Provider that store the current locale on the server side
|
|
34
|
+
*/
|
|
35
|
+
declare const IntlayerServerProvider: FC<IntlayerServerProviderProps>;
|
|
23
36
|
|
|
24
|
-
export {
|
|
37
|
+
export { IntlayerServerContext, IntlayerServerProvider, type IntlayerServerProviderProps, locale, useIntlayer };
|
|
@@ -23,13 +23,13 @@ __export(getLocaleTranslation_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(getLocaleTranslation_exports);
|
|
24
24
|
var import_client = require("@intlayer/config/client");
|
|
25
25
|
var import_core = require("@intlayer/core");
|
|
26
|
-
var
|
|
26
|
+
var import_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
|
|
27
27
|
var import_serverContext = require('./serverContext.cjs');
|
|
28
28
|
const getLocaleTranslation = (languageContent) => {
|
|
29
|
-
const locale = (0, import_serverContext.getServerContext)(
|
|
29
|
+
const locale = (0, import_serverContext.getServerContext)(import_IntlayerServerProvider.IntlayerServerContext);
|
|
30
30
|
const content = (0, import_core.getTranslationContent)(
|
|
31
31
|
languageContent,
|
|
32
|
-
locale ?? import_client.
|
|
32
|
+
locale ?? (0, import_client.getConfiguration)().internationalization.defaultLocale
|
|
33
33
|
);
|
|
34
34
|
return {
|
|
35
35
|
locale,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/getLocaleTranslation.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/server/getLocaleTranslation.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport { type LanguageContent, getTranslationContent } from '@intlayer/core';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, get the translation content based on the locale\n */\nexport const getLocaleTranslation = <Content>(\n languageContent: LanguageContent<Content>\n) => {\n const locale = getServerContext(IntlayerServerContext);\n const content = getTranslationContent<Content>(\n languageContent,\n locale ?? getConfiguration().internationalization.defaultLocale\n );\n\n return {\n locale,\n content,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,kBAA4D;AAC5D,oCAAsC;AACtC,2BAAiC;AAK1B,MAAM,uBAAuB,CAClC,oBACG;AACH,QAAM,aAAS,uCAAiB,mDAAqB;AACrD,QAAM,cAAU;AAAA,IACd;AAAA,IACA,cAAU,gCAAiB,EAAE,qBAAqB;AAAA,EACpD;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as _intlayer_config_client from '@intlayer/config/client';
|
|
2
2
|
import { LanguageContent } from '@intlayer/core';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* On the server side, get the translation content based on the locale
|
|
6
|
+
*/
|
|
4
7
|
declare const getLocaleTranslation: <Content>(languageContent: LanguageContent<Content>) => {
|
|
5
8
|
locale: _intlayer_config_client.Locales | undefined;
|
|
6
9
|
content: Content;
|
|
@@ -18,22 +18,22 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var server_exports = {};
|
|
20
20
|
__export(server_exports, {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
IntlayerServer: () => import_IntlayerServerProvider.IntlayerServerContext,
|
|
22
|
+
IntlayerServerProvider: () => import_IntlayerServerProvider.IntlayerServerProvider,
|
|
23
23
|
getLocaleContent: () => import_getLocaleTranslation.getLocaleTranslation,
|
|
24
|
-
locale: () =>
|
|
24
|
+
locale: () => import_IntlayerServerProvider.locale,
|
|
25
25
|
useIntlayer: () => import_useIntlayer.useIntlayer,
|
|
26
26
|
useTraduction: () => import_useTraduction.useTraduction
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(server_exports);
|
|
29
29
|
var import_getLocaleTranslation = require('./getLocaleTranslation.cjs');
|
|
30
30
|
var import_useTraduction = require('./useTraduction.cjs');
|
|
31
|
-
var
|
|
31
|
+
var import_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
|
|
32
32
|
var import_useIntlayer = require('./useIntlayer.cjs');
|
|
33
33
|
// Annotate the CommonJS export names for ESM import in node:
|
|
34
34
|
0 && (module.exports = {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
IntlayerServer,
|
|
36
|
+
IntlayerServerProvider,
|
|
37
37
|
getLocaleContent,
|
|
38
38
|
locale,
|
|
39
39
|
useIntlayer,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export { getLocaleTranslation as getLocaleContent } from './getLocaleTranslation';\nexport { useTraduction } from './useTraduction';\nexport {\n
|
|
1
|
+
{"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export { getLocaleTranslation as getLocaleContent } from './getLocaleTranslation';\nexport { useTraduction } from './useTraduction';\nexport {\n IntlayerServerContext as IntlayerServer,\n locale,\n IntlayerServerProvider,\n} from './IntlayerServerProvider';\nexport { useIntlayer } from './useIntlayer';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kCAAyD;AACzD,2BAA8B;AAC9B,oCAIO;AACP,yBAA4B;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getLocaleTranslation as getLocaleContent } from './getLocaleTranslation.js';
|
|
2
2
|
export { useTraduction } from './useTraduction.js';
|
|
3
|
-
export {
|
|
3
|
+
export { IntlayerServerContext as IntlayerServer, IntlayerServerProvider, locale } from './IntlayerServerProvider.js';
|
|
4
4
|
export { useIntlayer } from './useIntlayer.js';
|
|
5
5
|
import '@intlayer/config/client';
|
|
6
6
|
import '@intlayer/core';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/serverContext.ts"],"sourcesContent":["/**\n * Creates a new datastore for a given server context.\n * Attempts to closely mimic the `createContext` API.\n *\n * @example\n * const
|
|
1
|
+
{"version":3,"sources":["../../../src/server/serverContext.ts"],"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.Provider value={locale}>\n * {children}\n * </IntlayerServer.Provider>\n */\n\nimport react 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 const cache = react.cache<CacheType<T>> ?? cacheFallback;\n\n const getCache = cache(() => ({\n value: undefined,\n }));\n\n return {\n Provider: ({ children, value }) => {\n getCache().value = value;\n return children;\n },\n Consumer: ({ children }) => {\n const store = getCache();\n return children(store ? store.value : defaultValue);\n },\n _storage: getCache,\n _defaultValue: defaultValue,\n };\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> = {\n Provider: ({\n children,\n value,\n }: {\n children: React.ReactNode;\n value: T;\n }) => React.ReactNode;\n Consumer: ({\n children,\n }: {\n children: (context: T | undefined) => React.ReactNode;\n }) => React.ReactNode;\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,mBAAkB;AAIlB,MAAM,gBAAgB,MAAM,OAAO,EAAE,OAAO,OAAU;AAE/C,MAAM,sBAAsB,CAAI,iBAAuC;AAC5E,gBAAc;AAEd,QAAM,QAAQ,aAAAA,QAAM,SAAuB;AAE3C,QAAM,WAAW,MAAM,OAAO;AAAA,IAC5B,OAAO;AAAA,EACT,EAAE;AAEF,SAAO;AAAA,IACL,UAAU,CAAC,EAAE,UAAU,MAAM,MAAM;AACjC,eAAS,EAAE,QAAQ;AACnB,aAAO;AAAA,IACT;AAAA,IACA,UAAU,CAAC,EAAE,SAAS,MAAM;AAC1B,YAAM,QAAQ,SAAS;AACvB,aAAO,SAAS,QAAQ,MAAM,QAAQ,YAAY;AAAA,IACpD;AAAA,IACA,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AACF;AASO,MAAM,mBAAmB,CAAI;AAAA,EAClC;AAAA,EACA;AACF,MAAwB;AAEtB,QAAM,QAAQ,SAAS;AACvB,MAAI,CAAC;AAAO,WAAO;AACnB,SAAO,MAAM;AACf;AAuBA,MAAM,gBAAgB,MAAoB;AAExC,MAAI,OAAO,WAAW,aAAa;AACjC,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACF;","names":["react"]}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* Attempts to closely mimic the `createContext` API.
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
|
-
* const
|
|
6
|
+
* const IntlayerServer = createServerContext<string | null>(null);
|
|
7
7
|
*
|
|
8
|
-
* <
|
|
8
|
+
* <IntlayerServer.Provider value={locale}>
|
|
9
9
|
* {children}
|
|
10
|
-
* </
|
|
10
|
+
* </IntlayerServer.Provider>
|
|
11
11
|
*/
|
|
12
12
|
declare const createServerContext: <T>(defaultValue?: T) => ServerContext<T>;
|
|
13
13
|
/**
|
|
@@ -15,7 +15,7 @@ declare const createServerContext: <T>(defaultValue?: T) => ServerContext<T>;
|
|
|
15
15
|
* Attempts to closely mimic the `useContext` API.
|
|
16
16
|
*
|
|
17
17
|
* @example
|
|
18
|
-
* getServerContext(
|
|
18
|
+
* getServerContext(IntlayerServer);
|
|
19
19
|
*/
|
|
20
20
|
declare const getServerContext: <T>({ _storage, _defaultValue, }: ServerContext<T>) => T | undefined;
|
|
21
21
|
type ServerContext<T> = {
|
|
@@ -22,10 +22,10 @@ __export(useIntlayer_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(useIntlayer_exports);
|
|
24
24
|
var import_useIntlayerBase = require('../useIntlayerBase.cjs');
|
|
25
|
-
var
|
|
25
|
+
var import_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
|
|
26
26
|
var import_serverContext = require('./serverContext.cjs');
|
|
27
27
|
const useIntlayer = (id, locale) => {
|
|
28
|
-
const localeTarget = locale ?? (0, import_serverContext.getServerContext)(
|
|
28
|
+
const localeTarget = locale ?? (0, import_serverContext.getServerContext)(import_IntlayerServerProvider.IntlayerServerContext);
|
|
29
29
|
return (0, import_useIntlayerBase.useIntlayerBase)(id, localeTarget);
|
|
30
30
|
};
|
|
31
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport {\n type DictionaryKeys,\n useIntlayerBase,\n type UseIntlayer,\n} from '../useIntlayerBase';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport {\n type DictionaryKeys,\n useIntlayerBase,\n type UseIntlayer,\n} from '../useIntlayerBase';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, Hook that picking one dictionary by its id 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: UseIntlayer = <T extends DictionaryKeys>(\n id: T,\n locale?: Locales\n) => {\n const localeTarget =\n locale ?? getServerContext<Locales>(IntlayerServerContext);\n\n return useIntlayerBase(id, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,6BAIO;AACP,oCAAsC;AACtC,2BAAiC;AAO1B,MAAM,cAA2B,CACtC,IACA,WACG;AACH,QAAM,eACJ,cAAU,uCAA0B,mDAAqB;AAE3D,aAAO,wCAAgB,IAAI,YAAY;AACzC;","names":[]}
|
|
@@ -2,6 +2,11 @@ import { UseIntlayer } from '../useIntlayerBase.js';
|
|
|
2
2
|
import '@intlayer/config/client';
|
|
3
3
|
import 'intlayer';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* On the server side, Hook that picking one dictionary by its id and return the content
|
|
7
|
+
*
|
|
8
|
+
* If the locale is not provided, it will use the locale from the server context
|
|
9
|
+
*/
|
|
5
10
|
declare const useIntlayer: UseIntlayer;
|
|
6
11
|
|
|
7
12
|
export { useIntlayer };
|
|
@@ -22,10 +22,10 @@ __export(useTraduction_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(useTraduction_exports);
|
|
24
24
|
var import_getTranslation = require('../getTranslation.cjs');
|
|
25
|
-
var
|
|
25
|
+
var import_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
|
|
26
26
|
var import_serverContext = require('./serverContext.cjs');
|
|
27
27
|
const useTraduction = (languageContent) => {
|
|
28
|
-
const locale = (0, import_serverContext.getServerContext)(
|
|
28
|
+
const locale = (0, import_serverContext.getServerContext)(import_IntlayerServerProvider.IntlayerServerContext);
|
|
29
29
|
return (0, import_getTranslation.getTranslation)(languageContent, locale);
|
|
30
30
|
};
|
|
31
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/useTraduction.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport type { LanguageContent } from '@intlayer/core';\nimport { getTranslation } from '../getTranslation';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/server/useTraduction.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport type { LanguageContent } from '@intlayer/core';\nimport { getTranslation } from '../getTranslation';\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 = useTraduction<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 useTraduction = <Content = string>(\n languageContent: LanguageContent<Content>\n) => {\n const locale = getServerContext<Locales>(IntlayerServerContext);\n\n return getTranslation(languageContent, locale);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,4BAA+B;AAC/B,oCAAsC;AACtC,2BAAiC;AAuB1B,MAAM,gBAAgB,CAC3B,oBACG;AACH,QAAM,aAAS,uCAA0B,mDAAqB;AAE9D,aAAO,sCAAe,iBAAiB,MAAM;AAC/C;","names":[]}
|
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
import { LanguageContent } from '@intlayer/core';
|
|
2
2
|
|
|
3
|
-
|
|
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 = useTraduction<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
|
+
declare const useTraduction: <Content = string>(languageContent: LanguageContent<Content>) => Content;
|
|
4
25
|
|
|
5
26
|
export { useTraduction };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/useIntlayerBase.ts"],"sourcesContent":["/**\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
|
|
1
|
+
{"version":3,"sources":["../../src/useIntlayerBase.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\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 type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type { Content } from './processDictionary/contentDictionary';\nimport { processDictionary } from './processDictionary/index';\n\nexport type StringFallback<T> = T extends never ? string : T; // If no keys are found, return string to disable error, and accept any string as dictionary key\nexport type DictionaryKeys = StringFallback<\n keyof IntlayerDictionaryTypesConnector\n>;\n\nexport type UseIntlayer = <T extends DictionaryKeys>(\n id: T,\n locale?: Locales\n) => IntlayerDictionaryTypesConnector[T];\n\n/**\n * Hook that picking one dictionary by its id and return the content.\n */\nexport const useIntlayerBase: UseIntlayer = <T extends DictionaryKeys>(\n id: T,\n locale?: Locales\n) => {\n const dictionary: Content = dictionaries[id];\n\n return processDictionary(\n dictionary,\n locale\n ) as IntlayerDictionaryTypesConnector[T];\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,gCAAyB;AAGzB,+BAAkC;AAe3B,MAAM,kBAA+B,CAC1C,IACA,WACG;AACH,QAAM,aAAsB,0BAAAA,QAAa,EAAE;AAE3C,aAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":["dictionaries"]}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { Locales } from '@intlayer/config/client';
|
|
2
2
|
import { IntlayerDictionaryTypesConnector } from 'intlayer';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.
|
|
6
|
-
* Using an external package allow to alias it in the bundle configuration (such as webpack).
|
|
7
|
-
* The alias allow hot reload the app (such as nextjs) on any dictionary change.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
4
|
type StringFallback<T> = T extends never ? string : T;
|
|
11
5
|
type DictionaryKeys = StringFallback<keyof IntlayerDictionaryTypesConnector>;
|
|
12
6
|
type UseIntlayer = <T extends DictionaryKeys>(id: T, locale?: Locales) => IntlayerDictionaryTypesConnector[T];
|
|
7
|
+
/**
|
|
8
|
+
* Hook that picking one dictionary by its id and return the content.
|
|
9
|
+
*/
|
|
13
10
|
declare const useIntlayerBase: UseIntlayer;
|
|
14
11
|
|
|
15
12
|
export { type DictionaryKeys, type StringFallback, type UseIntlayer, useIntlayerBase };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var intlayerPlugin_exports = {};
|
|
20
|
+
__export(intlayerPlugin_exports, {
|
|
21
|
+
intLayerPlugin: () => intLayerPlugin
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(intlayerPlugin_exports);
|
|
24
|
+
var import_path = require("path");
|
|
25
|
+
var import_chokidar = require("@intlayer/chokidar");
|
|
26
|
+
var import_config = require("@intlayer/config");
|
|
27
|
+
var import_vite = require("vite");
|
|
28
|
+
const import_meta = {};
|
|
29
|
+
const intLayerPlugin = (_pluginOptions = {}) => ({
|
|
30
|
+
name: "vite-intlayer-plugin",
|
|
31
|
+
config: (config, { mode }) => {
|
|
32
|
+
const intlayerConfig = (0, import_config.getConfiguration)();
|
|
33
|
+
const env = (0, import_config.formatEnvVariable)("vite");
|
|
34
|
+
process.env = { ...process.env, ...(0, import_vite.loadEnv)(mode, process.cwd()), ...env };
|
|
35
|
+
const { mainDir, baseDir } = intlayerConfig.content;
|
|
36
|
+
const dictionariesPath = (0, import_path.join)(mainDir, "dictionaries.mjs");
|
|
37
|
+
const relativeDictionariesPath = (0, import_path.relative)(baseDir, dictionariesPath);
|
|
38
|
+
config.resolve = {
|
|
39
|
+
...config.resolve,
|
|
40
|
+
alias: {
|
|
41
|
+
...config.resolve?.alias,
|
|
42
|
+
"@intlayer/dictionaries-entry": (0, import_path.resolve)(relativeDictionariesPath)
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
return config;
|
|
46
|
+
},
|
|
47
|
+
buildStart: () => {
|
|
48
|
+
(0, import_chokidar.watch)({
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
+
persistent: import_meta.env === "development"
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
configureServer: (server) => {
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
intLayerPlugin
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=intlayerPlugin.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/vite/intlayerPlugin.ts"],"sourcesContent":["import { join, relative, resolve } from 'path';\nimport { watch } from '@intlayer/chokidar';\nimport { getConfiguration, formatEnvVariable } from '@intlayer/config';\nimport { loadEnv, type Plugin } from 'vite';\n\n// Plugin options type definition\ntype PluginOptions = {\n // Custom options for your plugin, if any\n};\n\n/**\n *\n * A Vite plugin that integrates IntLayer configuration into the build process\n *\n * ```ts\n * // Example usage of the plugin in a Vite configuration\n * export default defineConfig({\n * plugins: [ intLayerPlugin() ],\n * });\n * ```\n * */\nexport const intLayerPlugin = (_pluginOptions: PluginOptions = {}): Plugin => ({\n name: 'vite-intlayer-plugin',\n\n config: (config, { mode }) => {\n const intlayerConfig = getConfiguration();\n\n // Set all configuration values as environment variables\n const env = formatEnvVariable('vite');\n\n process.env = { ...process.env, ...loadEnv(mode, process.cwd()), ...env };\n\n const { mainDir, baseDir } = intlayerConfig.content;\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n // Update Vite's resolve alias\n config.resolve = {\n ...config.resolve,\n alias: {\n ...config.resolve?.alias,\n '@intlayer/dictionaries-entry': resolve(relativeDictionariesPath),\n },\n };\n\n return config;\n },\n\n buildStart: () => {\n // Code to run when Vite build starts\n watch({\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n persistent: (import.meta as any).env === 'development',\n });\n },\n configureServer: (server) => {\n // Custom server configuration, if needed\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwC;AACxC,sBAAsB;AACtB,oBAAoD;AACpD,kBAAqC;AAHrC;AAqBO,MAAM,iBAAiB,CAAC,iBAAgC,CAAC,OAAe;AAAA,EAC7E,MAAM;AAAA,EAEN,QAAQ,CAAC,QAAQ,EAAE,KAAK,MAAM;AAC5B,UAAM,qBAAiB,gCAAiB;AAGxC,UAAM,UAAM,iCAAkB,MAAM;AAEpC,YAAQ,MAAM,EAAE,GAAG,QAAQ,KAAK,OAAG,qBAAQ,MAAM,QAAQ,IAAI,CAAC,GAAG,GAAG,IAAI;AAExE,UAAM,EAAE,SAAS,QAAQ,IAAI,eAAe;AAC5C,UAAM,uBAAmB,kBAAK,SAAS,kBAAkB;AACzD,UAAM,+BAA2B,sBAAS,SAAS,gBAAgB;AAGnE,WAAO,UAAU;AAAA,MACf,GAAG,OAAO;AAAA,MACV,OAAO;AAAA,QACL,GAAG,OAAO,SAAS;AAAA,QACnB,oCAAgC,qBAAQ,wBAAwB;AAAA,MAClE;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,MAAM;AAEhB,+BAAM;AAAA;AAAA,MAEJ,YAAa,YAAoB,QAAQ;AAAA,IAC3C,CAAC;AAAA,EACH;AAAA,EACA,iBAAiB,CAAC,WAAW;AAAA,EAE7B;AACF;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
type PluginOptions = {};
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* A Vite plugin that integrates IntLayer configuration into the build process
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* // Example usage of the plugin in a Vite configuration
|
|
10
|
+
* export default defineConfig({
|
|
11
|
+
* plugins: [ intLayerPlugin() ],
|
|
12
|
+
* });
|
|
13
|
+
* ```
|
|
14
|
+
* */
|
|
15
|
+
declare const intLayerPlugin: (_pluginOptions?: PluginOptions) => Plugin;
|
|
16
|
+
|
|
17
|
+
export { intLayerPlugin };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ContentEditor/ContentEditor.tsx"],"sourcesContent":["'use client';\n\nimport {\n useEffect,\n useState,\n useRef,\n useCallback,\n type FC,\n type MouseEventHandler,\n} from 'react';\n\ntype ContentEditorProps = {\n children?: string;\n};\n\nconst PRESS_DETECT_DURATION = 500;\n\nexport const ContentEditor: FC<ContentEditorProps> = ({ children }) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isEditing, setIsEditing] = useState(false);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const handleOnLongPress = () => {\n setIsEditing(true);\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, PRESS_DETECT_DURATION);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseUp = () => {\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsEditing(false);\n }\n },\n [divRef]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: MouseEventHandler<HTMLDivElement> = (e) => {\n if (isEditing) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsEditing(false);\n };\n\n const onContentChange = (_e: React.FormEvent<HTMLDivElement>) => {\n // console.log(e.currentTarget.textContent);\n };\n\n return (\n <div\n role=\"textbox\"\n tabIndex={0}\n onKeyUp={() => null}\n contentEditable={isEditing}\n onInput={onContentChange}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n suppressContentEditableWarning={true} // To suppress the warning for controlled components\n style={\n isEditing\n ? {\n backgroundColor: 'transparent',\n cursor: 'text',\n display: 'inline',\n }\n : { cursor: 'pointer', display: 'inline' }\n }\n ref={divRef}\n >\n {children}\n </div>\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/ContentEditor/ContentEditor.tsx"],"sourcesContent":["'use client';\n\nimport {\n useEffect,\n useState,\n useRef,\n useCallback,\n type FC,\n type MouseEventHandler,\n} from 'react';\n\ntype ContentEditorProps = {\n children?: string;\n};\n\nconst PRESS_DETECT_DURATION = 500;\n\nexport const ContentEditor: FC<ContentEditorProps> = ({ children }) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isEditing, setIsEditing] = useState(false);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const handleOnLongPress = () => {\n setIsEditing(true);\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, PRESS_DETECT_DURATION);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseUp = () => {\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsEditing(false);\n }\n },\n [divRef]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: MouseEventHandler<HTMLDivElement> = (e) => {\n if (isEditing) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsEditing(false);\n };\n\n const onContentChange = (_e: React.FormEvent<HTMLDivElement>) => {\n // console.log(e.currentTarget.textContent);\n };\n\n return (\n <div\n role=\"textbox\"\n tabIndex={0}\n onKeyUp={() => null}\n contentEditable={isEditing}\n onInput={onContentChange}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n suppressContentEditableWarning={true} // To suppress the warning for controlled components\n style={\n isEditing\n ? {\n backgroundColor: 'transparent',\n cursor: 'text',\n display: 'inline',\n }\n : { cursor: 'pointer', display: 'inline' }\n }\n ref={divRef}\n >\n {children}\n </div>\n );\n};\n"],"mappings":";;AAsFI;AApFJ;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAMP,MAAM,wBAAwB;AAEvB,MAAM,gBAAwC,CAAC,EAAE,SAAS,MAAM;AACrE,QAAM,SAAS,OAAuB,IAAI;AAC1C,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,gBAAgB,OAA6C,IAAI;AAEvE,QAAM,oBAAoB,MAAM;AAC9B,iBAAa,IAAI;AAAA,EACnB;AAEA,QAAM,kBAAkB,MAAM;AAC5B,kBAAc,UAAU,WAAW,MAAM;AACvC,wBAAkB;AAAA,IACpB,GAAG,qBAAqB;AAAA,EAC1B;AAEA,QAAM,kBAAkB,MAAM;AAC5B,QAAI,cAAc,SAAS;AACzB,mBAAa,cAAc,OAAO;AAClC,oBAAc,UAAU;AAAA,IAC1B;AAAA,EACF;AAEA,QAAM,kBAAkB,MAAM;AAC5B,oBAAgB;AAChB,oBAAgB;AAAA,EAClB;AAEA,QAAM,gBAAgB,MAAM;AAC1B,oBAAgB;AAAA,EAClB;AAGA,QAAM,qBAAqB;AAAA,IACzB,CAAC,UAAsB;AACrB,UAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,SAAS,MAAM,MAAc,GAAG;AACpE,qBAAa,KAAK;AAAA,MACpB;AAAA,IACF;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AAEA,YAAU,MAAM;AAEd,aAAS,iBAAiB,aAAa,kBAAkB;AAEzD,WAAO,MAAM;AAEX,eAAS,oBAAoB,aAAa,kBAAkB;AAC5D,sBAAgB;AAAA,IAClB;AAAA,EACF,GAAG,CAAC,kBAAkB,CAAC;AAEvB,QAAM,gBAAmD,CAAC,MAAM;AAC9D,QAAI,WAAW;AACb,QAAE,eAAe;AACjB,QAAE,gBAAgB;AAAA,IACpB;AAAA,EACF;AAEA,QAAM,eAAe,MAAM;AAEzB,iBAAa,KAAK;AAAA,EACpB;AAEA,QAAM,kBAAkB,CAAC,OAAwC;AAAA,EAEjE;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,UAAU;AAAA,MACV,SAAS,MAAM;AAAA,MACf,iBAAiB;AAAA,MACjB,SAAS;AAAA,MACT,SAAS;AAAA,MACT,aAAa;AAAA,MACb,WAAW;AAAA,MACX,cAAc;AAAA,MACd,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,QAAQ;AAAA,MACR,gCAAgC;AAAA,MAChC,OACE,YACI;AAAA,QACE,iBAAiB;AAAA,QACjB,QAAQ;AAAA,QACR,SAAS;AAAA,MACX,IACA,EAAE,QAAQ,WAAW,SAAS,SAAS;AAAA,MAE7C,KAAK;AAAA,MAEJ;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ContentEditor/contentRender.tsx"],"sourcesContent":["import { ContentEditor } from './ContentEditor';\n\nexport const contentRender = (content: string) => {\n const isEditable = process.env.NODE_ENV === 'development';\n\n if (isEditable && ContentEditor) {\n return (<ContentEditor>{content}</ContentEditor>) as unknown as string;\n }\n\n return content;\n};\n"],"mappings":"AAMY;AANZ,SAAS,qBAAqB;AAEvB,MAAM,gBAAgB,CAAC,YAAoB;AAChD,QAAM,aAAa,QAAQ,IAAI,aAAa;AAE5C,MAAI,cAAc,eAAe;AAC/B,WAAQ,oBAAC,iBAAe,mBAAQ;AAAA,EAClC;AAEA,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/ContentEditor/contentRender.tsx"],"sourcesContent":["import { ContentEditor } from './ContentEditor';\n\nexport const contentRender = (content: string) => {\n const isEditable = process.env.NODE_ENV === 'development';\n\n if (isEditable && ContentEditor) {\n return (<ContentEditor>{content}</ContentEditor>) as unknown as string;\n }\n\n return content;\n};\n"],"mappings":";AAMY;AANZ,SAAS,qBAAqB;AAEvB,MAAM,gBAAgB,CAAC,YAAoB;AAChD,QAAM,aAAa,QAAQ,IAAI,aAAa;AAE5C,MAAI,cAAc,eAAe;AAC/B,WAAQ,oBAAC,iBAAe,mBAAQ;AAAA,EAClC;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { IntlayerClientProviderProps } from './client/IntlayerClientProvider.mjs';
|
|
3
|
+
import { IntlayerServerProviderProps } from './server/IntlayerServerProvider.mjs';
|
|
4
|
+
import '@intlayer/config/client';
|
|
5
|
+
|
|
6
|
+
type IntlayerProviderProps = IntlayerClientProviderProps & IntlayerServerProviderProps;
|
|
7
|
+
declare const IntlayerProvider: FC<IntlayerProviderProps>;
|
|
8
|
+
|
|
9
|
+
export { IntlayerProvider };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import "./chunk-ZNCO4QRF.mjs";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { getConfiguration } from "@intlayer/config/client";
|
|
4
|
+
import {
|
|
5
|
+
IntlayerClientProvider
|
|
6
|
+
} from './client/IntlayerClientProvider.mjs';
|
|
7
|
+
import {
|
|
8
|
+
IntlayerServerProvider
|
|
9
|
+
} from './server/IntlayerServerProvider.mjs';
|
|
10
|
+
const { defaultLocale } = getConfiguration().internationalization;
|
|
11
|
+
const IntlayerProvider = ({
|
|
12
|
+
children,
|
|
13
|
+
locale = defaultLocale
|
|
14
|
+
}) => /* @__PURE__ */ jsx(IntlayerServerProvider, { locale, children: /* @__PURE__ */ jsx(IntlayerClientProvider, { locale, children }) });
|
|
15
|
+
export {
|
|
16
|
+
IntlayerProvider
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=IntlayerProvider.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/IntlayerProvider.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport type { FC } from 'react';\nimport {\n IntlayerClientProvider,\n type IntlayerClientProviderProps,\n} from './client/IntlayerClientProvider';\nimport {\n IntlayerServerProvider,\n type IntlayerServerProviderProps,\n} from './server/IntlayerServerProvider';\n\nconst { defaultLocale } = getConfiguration().internationalization;\n\ntype IntlayerProviderProps = IntlayerClientProviderProps &\n IntlayerServerProviderProps;\n\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n children,\n locale = defaultLocale,\n}) => (\n <IntlayerServerProvider locale={locale}>\n <IntlayerClientProvider locale={locale}>{children}</IntlayerClientProvider>\n </IntlayerServerProvider>\n);\n"],"mappings":";AAqBI;AArBJ,SAAS,wBAAwB;AAEjC;AAAA,EACE;AAAA,OAEK;AACP;AAAA,EACE;AAAA,OAEK;AAEP,MAAM,EAAE,cAAc,IAAI,iBAAiB,EAAE;AAKtC,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA,SAAS;AACX,MACE,oBAAC,0BAAuB,QACtB,8BAAC,0BAAuB,QAAiB,UAAS,GACpD;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
__commonJS
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=chunk-ZNCO4QRF.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import spawn from "cross-spawn";
|
|
3
|
+
const args = process.argv.slice(2);
|
|
4
|
+
const scriptIndex = args.findIndex(
|
|
5
|
+
(x) => x === "build" || x === "start" || x === "test"
|
|
6
|
+
);
|
|
7
|
+
const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
|
|
8
|
+
switch (script) {
|
|
9
|
+
case "build":
|
|
10
|
+
case "start":
|
|
11
|
+
case "test": {
|
|
12
|
+
const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
|
|
13
|
+
const scriptPath = require.resolve(`@craco/craco/dist/scripts/${script}`);
|
|
14
|
+
const scriptArgs = args.slice(scriptIndex + 1);
|
|
15
|
+
const processArgs = nodeArgs.concat(scriptPath).concat([
|
|
16
|
+
...scriptArgs,
|
|
17
|
+
"--config",
|
|
18
|
+
"./node_modules/react-intlayer/dist/cjs/craco/craco.config.cjs"
|
|
19
|
+
]);
|
|
20
|
+
const child = spawn.sync("node", processArgs, { stdio: "inherit" });
|
|
21
|
+
if (child.signal) {
|
|
22
|
+
if (child.signal === "SIGKILL") {
|
|
23
|
+
console.info(`
|
|
24
|
+
The build failed because the process exited too early.
|
|
25
|
+
This probably means the system ran out of memory or someone called
|
|
26
|
+
\`kill -9\` on the process.
|
|
27
|
+
`);
|
|
28
|
+
} else if (child.signal === "SIGTERM") {
|
|
29
|
+
console.info(`
|
|
30
|
+
The build failed because the process exited too early.
|
|
31
|
+
Someone might have called \`kill\` or \`killall\`, or the system could
|
|
32
|
+
be shutting down.
|
|
33
|
+
`);
|
|
34
|
+
}
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
process.exit(child.status ?? void 0);
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
default:
|
|
41
|
+
console.info(`Unknown script "${script}".`);
|
|
42
|
+
console.info("Perhaps you need to update craco?");
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=react-intlayer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/react-intlayer.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * To make the setup easier, we are using craco to override the webpack configuration.\n * This script is used to run the craco scripts with the custom configuration.\n *\n * The script is based on the original craco script from create-react-app.\n */\n\nimport spawn from 'cross-spawn';\n\nconst args = process.argv.slice(2);\nconst scriptIndex = args.findIndex(\n (x) => x === 'build' || x === 'start' || x === 'test'\n);\nconst script = scriptIndex === -1 ? args[0] : args[scriptIndex];\n\nswitch (script) {\n case 'build':\n case 'start':\n case 'test': {\n const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];\n const scriptPath = require.resolve(`@craco/craco/dist/scripts/${script}`);\n const scriptArgs = args.slice(scriptIndex + 1);\n const processArgs = nodeArgs\n .concat(scriptPath)\n .concat([\n ...scriptArgs,\n '--config',\n './node_modules/react-intlayer/dist/cjs/craco/craco.config.cjs',\n ]);\n\n const child = spawn.sync('node', processArgs, { stdio: 'inherit' });\n\n if (child.signal) {\n if (child.signal === 'SIGKILL') {\n console.info(`\n The build failed because the process exited too early.\n This probably means the system ran out of memory or someone called\n \\`kill -9\\` on the process.\n `);\n } else if (child.signal === 'SIGTERM') {\n console.info(`\n The build failed because the process exited too early.\n Someone might have called \\`kill\\` or \\`killall\\`, or the system could\n be shutting down.\n `);\n }\n\n process.exit(1);\n }\n\n process.exit(child.status ?? undefined);\n break;\n }\n default:\n console.info(`Unknown script \"${script}\".`);\n console.info('Perhaps you need to update craco?');\n break;\n}\n"],"mappings":";AASA,OAAO,WAAW;AAElB,MAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,MAAM,cAAc,KAAK;AAAA,EACvB,CAAC,MAAM,MAAM,WAAW,MAAM,WAAW,MAAM;AACjD;AACA,MAAM,SAAS,gBAAgB,KAAK,KAAK,CAAC,IAAI,KAAK,WAAW;AAE9D,QAAQ,QAAQ;AAAA,EACd,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK,QAAQ;AACX,UAAM,WAAW,cAAc,IAAI,KAAK,MAAM,GAAG,WAAW,IAAI,CAAC;AACjE,UAAM,aAAa,QAAQ,QAAQ,6BAA6B,MAAM,EAAE;AACxE,UAAM,aAAa,KAAK,MAAM,cAAc,CAAC;AAC7C,UAAM,cAAc,SACjB,OAAO,UAAU,EACjB,OAAO;AAAA,MACN,GAAG;AAAA,MACH;AAAA,MACA;AAAA,IACF,CAAC;AAEH,UAAM,QAAQ,MAAM,KAAK,QAAQ,aAAa,EAAE,OAAO,UAAU,CAAC;AAElE,QAAI,MAAM,QAAQ;AAChB,UAAI,MAAM,WAAW,WAAW;AAC9B,gBAAQ,KAAK;AAAA;AAAA;AAAA;AAAA,aAIR;AAAA,MACP,WAAW,MAAM,WAAW,WAAW;AACrC,gBAAQ,KAAK;AAAA;AAAA;AAAA;AAAA,aAIR;AAAA,MACP;AAEA,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,YAAQ,KAAK,MAAM,UAAU,MAAS;AACtC;AAAA,EACF;AAAA,EACA;AACE,YAAQ,KAAK,mBAAmB,MAAM,IAAI;AAC1C,YAAQ,KAAK,mCAAmC;AAChD;AACJ;","names":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { PropsWithChildren, FC } from 'react';
|
|
3
|
+
import { Locales } from '@intlayer/config/client';
|
|
4
|
+
|
|
5
|
+
type IntlayerValue = {
|
|
6
|
+
locale: Locales;
|
|
7
|
+
setLocale: (newLocale: Locales) => void;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Context that store the current locale on the client side
|
|
11
|
+
*/
|
|
12
|
+
declare const IntlayerClientContext: react.Context<IntlayerValue>;
|
|
13
|
+
/**
|
|
14
|
+
* Hook that provides the current locale
|
|
15
|
+
*/
|
|
16
|
+
declare const useIntlayerContext: () => IntlayerValue;
|
|
17
|
+
type IntlayerClientProviderProps = PropsWithChildren & {
|
|
18
|
+
locale?: Locales;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Provider that store the current locale on the client side
|
|
22
|
+
*/
|
|
23
|
+
declare const IntlayerClientProvider: FC<IntlayerClientProviderProps>;
|
|
24
|
+
|
|
25
|
+
export { IntlayerClientContext, IntlayerClientProvider, type IntlayerClientProviderProps, useIntlayerContext };
|