react-intlayer 3.0.3 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/client/IntlayerProvider.cjs +9 -5
- package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
- package/dist/cjs/craco/intlayerCracoPlugin.cjs +1 -2
- package/dist/cjs/craco/intlayerCracoPlugin.cjs.map +1 -1
- package/dist/cjs/{craco → utils}/removeUndefinedValueObject.cjs.map +1 -1
- package/dist/esm/client/IntlayerProvider.mjs +9 -5
- package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
- package/dist/esm/craco/intlayerCracoPlugin.mjs +1 -2
- package/dist/esm/craco/intlayerCracoPlugin.mjs.map +1 -1
- package/dist/esm/{craco → utils}/removeUndefinedValueObject.mjs.map +1 -1
- package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
- package/dist/types/craco/intlayerCracoPlugin.d.ts.map +1 -1
- package/dist/types/{craco → utils}/removeUndefinedValueObject.d.ts.map +1 -1
- package/package.json +24 -24
- /package/dist/cjs/{craco → utils}/removeUndefinedValueObject.cjs +0 -0
- /package/dist/esm/{craco → utils}/removeUndefinedValueObject.mjs +0 -0
- /package/dist/types/{craco → utils}/removeUndefinedValueObject.d.ts +0 -0
|
@@ -38,9 +38,10 @@ const IntlayerProvider = ({
|
|
|
38
38
|
locale,
|
|
39
39
|
children,
|
|
40
40
|
setLocale: setLocaleProp,
|
|
41
|
-
editorEnabled
|
|
41
|
+
editorEnabled = true
|
|
42
42
|
}) => {
|
|
43
|
-
const {
|
|
43
|
+
const { internationalization, editor } = (0, import_client.getConfiguration)();
|
|
44
|
+
const { defaultLocale, locales: availableLocales } = internationalization;
|
|
44
45
|
const [currentLocale, setCurrentLocale] = (0, import_react.useState)(
|
|
45
46
|
locale ?? import_useLocaleCookie.localeCookie ?? defaultLocale
|
|
46
47
|
);
|
|
@@ -61,16 +62,19 @@ const IntlayerProvider = ({
|
|
|
61
62
|
() => ({ locale: currentLocale, setLocale }),
|
|
62
63
|
[currentLocale, setLocale]
|
|
63
64
|
);
|
|
64
|
-
|
|
65
|
+
const isEditorEnabled = Boolean(
|
|
66
|
+
editor?.enabled && editor.clientId && editor.clientSecret && editorEnabled
|
|
67
|
+
);
|
|
68
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IntlayerClientContext.Provider, { value, children: isEditorEnabled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
65
69
|
import_intlayer_editor.ContentEditionLayout,
|
|
66
70
|
{
|
|
67
71
|
locale: currentLocale,
|
|
68
72
|
setLocale,
|
|
69
73
|
localeList: availableLocales,
|
|
70
|
-
editorEnabled,
|
|
74
|
+
editorEnabled: isEditorEnabled,
|
|
71
75
|
children
|
|
72
76
|
}
|
|
73
|
-
) });
|
|
77
|
+
) : children });
|
|
74
78
|
};
|
|
75
79
|
// Annotate the CommonJS export names for ESM import in node:
|
|
76
80
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type Locales } from '@intlayer/config/client';\nimport { ContentEditionLayout } from 'intlayer-editor';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n type FC,\n useState,\n useCallback,\n} from 'react';\nimport { localeCookie, setLocaleCookie } from './useLocaleCookie';\n\ntype IntlayerValue = {\n locale: Locales;\n setLocale: (newLocale: Locales) => void;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerProviderProps = PropsWithChildren & {\n locale?: Locales;\n setLocale?: (locale: Locales) => void;\n editorEnabled?: boolean;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n locale,\n children,\n setLocale: setLocaleProp,\n editorEnabled,\n}) => {\n const { defaultLocale, locales: availableLocales }
|
|
1
|
+
{"version":3,"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type Locales } from '@intlayer/config/client';\nimport { ContentEditionLayout } from 'intlayer-editor';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n type FC,\n useState,\n useCallback,\n} from 'react';\nimport { localeCookie, setLocaleCookie } from './useLocaleCookie';\n\ntype IntlayerValue = {\n locale: Locales;\n setLocale: (newLocale: Locales) => void;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerProviderProps = PropsWithChildren & {\n locale?: Locales;\n setLocale?: (locale: Locales) => void;\n editorEnabled?: boolean;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n locale,\n children,\n setLocale: setLocaleProp,\n editorEnabled = true,\n}) => {\n const { internationalization, editor } = getConfiguration();\n const { defaultLocale, locales: availableLocales } = internationalization;\n\n const [currentLocale, setCurrentLocale] = useState(\n locale ?? localeCookie ?? defaultLocale\n );\n\n const setLocaleBase = useCallback(\n (newLocale: Locales) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales.includes(newLocale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleCookie(newLocale); // Optionally set cookie for persistence\n },\n [availableLocales, currentLocale, locale]\n );\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n const value: IntlayerValue = useMemo<IntlayerValue>(\n () => ({ locale: currentLocale, setLocale: setLocale }),\n [currentLocale, setLocale]\n );\n\n const isEditorEnabled = Boolean(\n editor?.enabled && editor.clientId && editor.clientSecret && editorEnabled\n );\n\n return (\n <IntlayerClientContext.Provider value={value}>\n {isEditorEnabled ? (\n <ContentEditionLayout\n locale={currentLocale}\n setLocale={setLocale}\n localeList={availableLocales}\n editorEnabled={isEditorEnabled}\n >\n {children}\n </ContentEditionLayout>\n ) : (\n children\n )}\n </IntlayerClientContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoFQ;AAlFR,oBAA+C;AAC/C,6BAAqC;AACrC,mBAQO;AACP,6BAA8C;AAUvC,MAAM,4BAAwB,4BAA6B;AAAA,EAChE,QAAQ,2CAAgB,gCAAiB,EAAE,qBAAqB;AAAA,EAChE,WAAW,MAAM;AACnB,CAAC;AAKM,MAAM,qBAAqB,UAAM,yBAAW,qBAAqB;AAWjE,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,gBAAgB;AAClB,MAAM;AACJ,QAAM,EAAE,sBAAsB,OAAO,QAAI,gCAAiB;AAC1D,QAAM,EAAE,eAAe,SAAS,iBAAiB,IAAI;AAErD,QAAM,CAAC,eAAe,gBAAgB,QAAI;AAAA,IACxC,UAAU,uCAAgB;AAAA,EAC5B;AAEA,QAAM,oBAAgB;AAAA,IACpB,CAAC,cAAuB;AACtB,UAAI,cAAc,SAAS,MAAM,UAAU,SAAS,EAAG;AAEvD,UAAI,CAAC,iBAAiB,SAAS,SAAS,GAAG;AACzC,gBAAQ,MAAM,UAAU,MAAM,mBAAmB;AACjD;AAAA,MACF;AAEA,uBAAiB,SAAS;AAC1B,kDAAgB,SAAS;AAAA,IAC3B;AAAA,IACA,CAAC,kBAAkB,eAAe,MAAM;AAAA,EAC1C;AAEA,QAAM,YAAY,iBAAiB;AAEnC,QAAM,YAAuB;AAAA,IAC3B,OAAO,EAAE,QAAQ,eAAe,UAAqB;AAAA,IACrD,CAAC,eAAe,SAAS;AAAA,EAC3B;AAEA,QAAM,kBAAkB;AAAA,IACtB,QAAQ,WAAW,OAAO,YAAY,OAAO,gBAAgB;AAAA,EAC/D;AAEA,SACE,4CAAC,sBAAsB,UAAtB,EAA+B,OAC7B,4BACC;AAAA,IAAC;AAAA;AAAA,MACC,QAAQ;AAAA,MACR;AAAA,MACA,YAAY;AAAA,MACZ,eAAe;AAAA,MAEd;AAAA;AAAA,EACH,IAEA,UAEJ;AAEJ;","names":[]}
|
|
@@ -37,7 +37,7 @@ var import_path = require("path");
|
|
|
37
37
|
var import_config = require("@intlayer/config");
|
|
38
38
|
var import_webpack = require("@intlayer/webpack");
|
|
39
39
|
var import_webpack2 = __toESM(require("webpack"));
|
|
40
|
-
var import_removeUndefinedValueObject = require('
|
|
40
|
+
var import_removeUndefinedValueObject = require('../utils/removeUndefinedValueObject.cjs');
|
|
41
41
|
const intlayerConfig = (0, import_config.getConfiguration)();
|
|
42
42
|
const env = (0, import_config.formatEnvVariable)("react_app");
|
|
43
43
|
const overrideWebpackConfig = ({
|
|
@@ -62,7 +62,6 @@ const overrideCracoConfig = ({
|
|
|
62
62
|
const { mainDir, baseDir } = intlayerConfig.content;
|
|
63
63
|
const dictionariesPath = (0, import_path.join)(mainDir, "dictionaries.mjs");
|
|
64
64
|
const relativeDictionariesPath = (0, import_path.relative)(baseDir, dictionariesPath);
|
|
65
|
-
console.log("env", (0, import_removeUndefinedValueObject.removeUndefinedValueObject)(env));
|
|
66
65
|
return {
|
|
67
66
|
...cracoConfig,
|
|
68
67
|
webpack: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/craco/intlayerCracoPlugin.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n// @ts-nocheck\n\nimport { resolve, relative, join } from 'path';\nimport type {\n CracoConfig,\n CracoConfigOverride,\n CracoPlugin,\n WebpackConfigOverride,\n} from '@craco/types';\nimport { getConfiguration, formatEnvVariable } from '@intlayer/config';\nimport { IntLayerPlugin as IntLayerWebpackPlugin } from '@intlayer/webpack';\nimport webpack, { type Configuration as WebpackConfig } from 'webpack';\nimport { removeUndefinedValueObject } from '
|
|
1
|
+
{"version":3,"sources":["../../../src/craco/intlayerCracoPlugin.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n// @ts-nocheck\n\nimport { resolve, relative, join } from 'path';\nimport type {\n CracoConfig,\n CracoConfigOverride,\n CracoPlugin,\n WebpackConfigOverride,\n} from '@craco/types';\nimport { getConfiguration, formatEnvVariable } from '@intlayer/config';\nimport { IntLayerPlugin as IntLayerWebpackPlugin } from '@intlayer/webpack';\nimport webpack, { type Configuration as WebpackConfig } from 'webpack';\nimport { removeUndefinedValueObject } from '../utils/removeUndefinedValueObject';\n\n// Get IntLayer configuration\nconst intlayerConfig = getConfiguration();\n\n// Format environment variables\nconst env: Record<string, string> = formatEnvVariable('react_app');\n\n// Custom CRACO plugin function to override webpack configuration\nexport const overrideWebpackConfig = ({\n webpackConfig,\n}: WebpackConfigOverride): WebpackConfig => {\n webpackConfig.externals = {\n ...(typeof webpackConfig.externals === 'object'\n ? webpackConfig.externals\n : {}),\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n vm: 'vm',\n };\n\n (webpackConfig.module?.rules ?? []).push({\n test: /\\.node$/,\n use: 'node-loader',\n });\n\n // You can add any custom CRACO plugins here if needed\n // config.plugins.push(new CustomCracoPlugin());\n\n return webpackConfig;\n};\n\n// Return a CRACO configuration object\nexport const overrideCracoConfig = ({\n cracoConfig,\n}: CracoConfigOverride): CracoConfig => {\n const { mainDir, baseDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n return {\n ...cracoConfig,\n webpack: {\n ...cracoConfig.webpack,\n plugins: {\n ...cracoConfig.webpack?.plugins,\n add: [\n new webpack.EnvironmentPlugin(removeUndefinedValueObject(env)),\n new IntLayerWebpackPlugin(),\n ],\n },\n alias: {\n ...cracoConfig.webpack?.alias,\n '@intlayer/dictionaries-entry': resolve('./', relativeDictionariesPath),\n },\n },\n };\n};\n\n/**\n * A CRACO plugin that adds the IntLayer configuration to the webpack configuration and sets the environment variables.\n *\n * Usage:\n *\n * ```ts\n * const cracoConfig: CracoConfig = {\n * plugins: [\n * {\n * plugin: intlayerCracoPlugin(),\n * },\n * ],\n * };\n *\n * export default cracoConfig;\n * ```\n *\n */\nexport const plugin: CracoPlugin = {\n overrideCracoConfig,\n overrideWebpackConfig,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAwC;AAOxC,oBAAoD;AACpD,qBAAwD;AACxD,IAAAA,kBAA6D;AAC7D,wCAA2C;AAG3C,MAAM,qBAAiB,gCAAiB;AAGxC,MAAM,UAA8B,iCAAkB,WAAW;AAG1D,MAAM,wBAAwB,CAAC;AAAA,EACpC;AACF,MAA4C;AAC1C,gBAAc,YAAY;AAAA,IACxB,GAAI,OAAO,cAAc,cAAc,WACnC,cAAc,YACd,CAAC;AAAA,IACL,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,IAAI;AAAA,IACJ,IAAI;AAAA,EACN;AAEA,GAAC,cAAc,QAAQ,SAAS,CAAC,GAAG,KAAK;AAAA,IACvC,MAAM;AAAA,IACN,KAAK;AAAA,EACP,CAAC;AAKD,SAAO;AACT;AAGO,MAAM,sBAAsB,CAAC;AAAA,EAClC;AACF,MAAwC;AACtC,QAAM,EAAE,SAAS,QAAQ,IAAI,eAAe;AAE5C,QAAM,uBAAmB,kBAAK,SAAS,kBAAkB;AACzD,QAAM,+BAA2B,sBAAS,SAAS,gBAAgB;AAEnE,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,YAAY;AAAA,MACf,SAAS;AAAA,QACP,GAAG,YAAY,SAAS;AAAA,QACxB,KAAK;AAAA,UACH,IAAI,gBAAAC,QAAQ,sBAAkB,8DAA2B,GAAG,CAAC;AAAA,UAC7D,IAAI,eAAAC,eAAsB;AAAA,QAC5B;AAAA,MACF;AAAA,MACA,OAAO;AAAA,QACL,GAAG,YAAY,SAAS;AAAA,QACxB,oCAAgC,qBAAQ,MAAM,wBAAwB;AAAA,MACxE;AAAA,IACF;AAAA,EACF;AACF;AAoBO,MAAM,SAAsB;AAAA,EACjC;AAAA,EACA;AACF;","names":["import_webpack","webpack","IntLayerWebpackPlugin"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/removeUndefinedValueObject.ts"],"sourcesContent":["export const removeUndefinedValueObject = <T extends Record<string, unknown>>(\n obj: T\n): T => {\n const newObj: T = {} as T;\n\n for (const key in obj) {\n if (obj[key] !== undefined) {\n newObj[key] = obj[key];\n }\n }\n\n Object.freeze(newObj);\n\n return newObj;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,6BAA6B,CACxC,QACM;AACN,QAAM,SAAY,CAAC;AAEnB,aAAW,OAAO,KAAK;AACrB,QAAI,IAAI,GAAG,MAAM,QAAW;AAC1B,aAAO,GAAG,IAAI,IAAI,GAAG;AAAA,IACvB;AAAA,EACF;AAEA,SAAO,OAAO,MAAM;AAEpB,SAAO;AACT;","names":[]}
|
|
@@ -20,9 +20,10 @@ const IntlayerProvider = ({
|
|
|
20
20
|
locale,
|
|
21
21
|
children,
|
|
22
22
|
setLocale: setLocaleProp,
|
|
23
|
-
editorEnabled
|
|
23
|
+
editorEnabled = true
|
|
24
24
|
}) => {
|
|
25
|
-
const {
|
|
25
|
+
const { internationalization, editor } = getConfiguration();
|
|
26
|
+
const { defaultLocale, locales: availableLocales } = internationalization;
|
|
26
27
|
const [currentLocale, setCurrentLocale] = useState(
|
|
27
28
|
locale ?? localeCookie ?? defaultLocale
|
|
28
29
|
);
|
|
@@ -43,16 +44,19 @@ const IntlayerProvider = ({
|
|
|
43
44
|
() => ({ locale: currentLocale, setLocale }),
|
|
44
45
|
[currentLocale, setLocale]
|
|
45
46
|
);
|
|
46
|
-
|
|
47
|
+
const isEditorEnabled = Boolean(
|
|
48
|
+
editor?.enabled && editor.clientId && editor.clientSecret && editorEnabled
|
|
49
|
+
);
|
|
50
|
+
return /* @__PURE__ */ jsx(IntlayerClientContext.Provider, { value, children: isEditorEnabled ? /* @__PURE__ */ jsx(
|
|
47
51
|
ContentEditionLayout,
|
|
48
52
|
{
|
|
49
53
|
locale: currentLocale,
|
|
50
54
|
setLocale,
|
|
51
55
|
localeList: availableLocales,
|
|
52
|
-
editorEnabled,
|
|
56
|
+
editorEnabled: isEditorEnabled,
|
|
53
57
|
children
|
|
54
58
|
}
|
|
55
|
-
) });
|
|
59
|
+
) : children });
|
|
56
60
|
};
|
|
57
61
|
export {
|
|
58
62
|
IntlayerClientContext,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type Locales } from '@intlayer/config/client';\nimport { ContentEditionLayout } from 'intlayer-editor';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n type FC,\n useState,\n useCallback,\n} from 'react';\nimport { localeCookie, setLocaleCookie } from './useLocaleCookie';\n\ntype IntlayerValue = {\n locale: Locales;\n setLocale: (newLocale: Locales) => void;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerProviderProps = PropsWithChildren & {\n locale?: Locales;\n setLocale?: (locale: Locales) => void;\n editorEnabled?: boolean;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n locale,\n children,\n setLocale: setLocaleProp,\n editorEnabled,\n}) => {\n const { defaultLocale, locales: availableLocales }
|
|
1
|
+
{"version":3,"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type Locales } from '@intlayer/config/client';\nimport { ContentEditionLayout } from 'intlayer-editor';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n type FC,\n useState,\n useCallback,\n} from 'react';\nimport { localeCookie, setLocaleCookie } from './useLocaleCookie';\n\ntype IntlayerValue = {\n locale: Locales;\n setLocale: (newLocale: Locales) => void;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerProviderProps = PropsWithChildren & {\n locale?: Locales;\n setLocale?: (locale: Locales) => void;\n editorEnabled?: boolean;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n locale,\n children,\n setLocale: setLocaleProp,\n editorEnabled = true,\n}) => {\n const { internationalization, editor } = getConfiguration();\n const { defaultLocale, locales: availableLocales } = internationalization;\n\n const [currentLocale, setCurrentLocale] = useState(\n locale ?? localeCookie ?? defaultLocale\n );\n\n const setLocaleBase = useCallback(\n (newLocale: Locales) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales.includes(newLocale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleCookie(newLocale); // Optionally set cookie for persistence\n },\n [availableLocales, currentLocale, locale]\n );\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n const value: IntlayerValue = useMemo<IntlayerValue>(\n () => ({ locale: currentLocale, setLocale: setLocale }),\n [currentLocale, setLocale]\n );\n\n const isEditorEnabled = Boolean(\n editor?.enabled && editor.clientId && editor.clientSecret && editorEnabled\n );\n\n return (\n <IntlayerClientContext.Provider value={value}>\n {isEditorEnabled ? (\n <ContentEditionLayout\n locale={currentLocale}\n setLocale={setLocale}\n localeList={availableLocales}\n editorEnabled={isEditorEnabled}\n >\n {children}\n </ContentEditionLayout>\n ) : (\n children\n )}\n </IntlayerClientContext.Provider>\n );\n};\n"],"mappings":";;AAoFQ;AAlFR,SAAS,wBAAsC;AAC/C,SAAS,4BAA4B;AACrC;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc,uBAAuB;AAUvC,MAAM,wBAAwB,cAA6B;AAAA,EAChE,QAAQ,gBAAgB,iBAAiB,EAAE,qBAAqB;AAAA,EAChE,WAAW,MAAM;AACnB,CAAC;AAKM,MAAM,qBAAqB,MAAM,WAAW,qBAAqB;AAWjE,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,gBAAgB;AAClB,MAAM;AACJ,QAAM,EAAE,sBAAsB,OAAO,IAAI,iBAAiB;AAC1D,QAAM,EAAE,eAAe,SAAS,iBAAiB,IAAI;AAErD,QAAM,CAAC,eAAe,gBAAgB,IAAI;AAAA,IACxC,UAAU,gBAAgB;AAAA,EAC5B;AAEA,QAAM,gBAAgB;AAAA,IACpB,CAAC,cAAuB;AACtB,UAAI,cAAc,SAAS,MAAM,UAAU,SAAS,EAAG;AAEvD,UAAI,CAAC,iBAAiB,SAAS,SAAS,GAAG;AACzC,gBAAQ,MAAM,UAAU,MAAM,mBAAmB;AACjD;AAAA,MACF;AAEA,uBAAiB,SAAS;AAC1B,sBAAgB,SAAS;AAAA,IAC3B;AAAA,IACA,CAAC,kBAAkB,eAAe,MAAM;AAAA,EAC1C;AAEA,QAAM,YAAY,iBAAiB;AAEnC,QAAM,QAAuB;AAAA,IAC3B,OAAO,EAAE,QAAQ,eAAe,UAAqB;AAAA,IACrD,CAAC,eAAe,SAAS;AAAA,EAC3B;AAEA,QAAM,kBAAkB;AAAA,IACtB,QAAQ,WAAW,OAAO,YAAY,OAAO,gBAAgB;AAAA,EAC/D;AAEA,SACE,oBAAC,sBAAsB,UAAtB,EAA+B,OAC7B,4BACC;AAAA,IAAC;AAAA;AAAA,MACC,QAAQ;AAAA,MACR;AAAA,MACA,YAAY;AAAA,MACZ,eAAe;AAAA,MAEd;AAAA;AAAA,EACH,IAEA,UAEJ;AAEJ;","names":[]}
|
|
@@ -3,7 +3,7 @@ import { resolve, relative, join } from "path";
|
|
|
3
3
|
import { getConfiguration, formatEnvVariable } from "@intlayer/config";
|
|
4
4
|
import { IntLayerPlugin as IntLayerWebpackPlugin } from "@intlayer/webpack";
|
|
5
5
|
import webpack from "webpack";
|
|
6
|
-
import { removeUndefinedValueObject } from '
|
|
6
|
+
import { removeUndefinedValueObject } from '../utils/removeUndefinedValueObject.mjs';
|
|
7
7
|
const intlayerConfig = getConfiguration();
|
|
8
8
|
const env = formatEnvVariable("react_app");
|
|
9
9
|
const overrideWebpackConfig = ({
|
|
@@ -28,7 +28,6 @@ const overrideCracoConfig = ({
|
|
|
28
28
|
const { mainDir, baseDir } = intlayerConfig.content;
|
|
29
29
|
const dictionariesPath = join(mainDir, "dictionaries.mjs");
|
|
30
30
|
const relativeDictionariesPath = relative(baseDir, dictionariesPath);
|
|
31
|
-
console.log("env", removeUndefinedValueObject(env));
|
|
32
31
|
return {
|
|
33
32
|
...cracoConfig,
|
|
34
33
|
webpack: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/craco/intlayerCracoPlugin.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n// @ts-nocheck\n\nimport { resolve, relative, join } from 'path';\nimport type {\n CracoConfig,\n CracoConfigOverride,\n CracoPlugin,\n WebpackConfigOverride,\n} from '@craco/types';\nimport { getConfiguration, formatEnvVariable } from '@intlayer/config';\nimport { IntLayerPlugin as IntLayerWebpackPlugin } from '@intlayer/webpack';\nimport webpack, { type Configuration as WebpackConfig } from 'webpack';\nimport { removeUndefinedValueObject } from '
|
|
1
|
+
{"version":3,"sources":["../../../src/craco/intlayerCracoPlugin.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n// @ts-nocheck\n\nimport { resolve, relative, join } from 'path';\nimport type {\n CracoConfig,\n CracoConfigOverride,\n CracoPlugin,\n WebpackConfigOverride,\n} from '@craco/types';\nimport { getConfiguration, formatEnvVariable } from '@intlayer/config';\nimport { IntLayerPlugin as IntLayerWebpackPlugin } from '@intlayer/webpack';\nimport webpack, { type Configuration as WebpackConfig } from 'webpack';\nimport { removeUndefinedValueObject } from '../utils/removeUndefinedValueObject';\n\n// Get IntLayer configuration\nconst intlayerConfig = getConfiguration();\n\n// Format environment variables\nconst env: Record<string, string> = formatEnvVariable('react_app');\n\n// Custom CRACO plugin function to override webpack configuration\nexport const overrideWebpackConfig = ({\n webpackConfig,\n}: WebpackConfigOverride): WebpackConfig => {\n webpackConfig.externals = {\n ...(typeof webpackConfig.externals === 'object'\n ? webpackConfig.externals\n : {}),\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n vm: 'vm',\n };\n\n (webpackConfig.module?.rules ?? []).push({\n test: /\\.node$/,\n use: 'node-loader',\n });\n\n // You can add any custom CRACO plugins here if needed\n // config.plugins.push(new CustomCracoPlugin());\n\n return webpackConfig;\n};\n\n// Return a CRACO configuration object\nexport const overrideCracoConfig = ({\n cracoConfig,\n}: CracoConfigOverride): CracoConfig => {\n const { mainDir, baseDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n return {\n ...cracoConfig,\n webpack: {\n ...cracoConfig.webpack,\n plugins: {\n ...cracoConfig.webpack?.plugins,\n add: [\n new webpack.EnvironmentPlugin(removeUndefinedValueObject(env)),\n new IntLayerWebpackPlugin(),\n ],\n },\n alias: {\n ...cracoConfig.webpack?.alias,\n '@intlayer/dictionaries-entry': resolve('./', relativeDictionariesPath),\n },\n },\n };\n};\n\n/**\n * A CRACO plugin that adds the IntLayer configuration to the webpack configuration and sets the environment variables.\n *\n * Usage:\n *\n * ```ts\n * const cracoConfig: CracoConfig = {\n * plugins: [\n * {\n * plugin: intlayerCracoPlugin(),\n * },\n * ],\n * };\n *\n * export default cracoConfig;\n * ```\n *\n */\nexport const plugin: CracoPlugin = {\n overrideCracoConfig,\n overrideWebpackConfig,\n};\n"],"mappings":";AAGA,SAAS,SAAS,UAAU,YAAY;AAOxC,SAAS,kBAAkB,yBAAyB;AACpD,SAAS,kBAAkB,6BAA6B;AACxD,OAAO,aAAsD;AAC7D,SAAS,kCAAkC;AAG3C,MAAM,iBAAiB,iBAAiB;AAGxC,MAAM,MAA8B,kBAAkB,WAAW;AAG1D,MAAM,wBAAwB,CAAC;AAAA,EACpC;AACF,MAA4C;AAC1C,gBAAc,YAAY;AAAA,IACxB,GAAI,OAAO,cAAc,cAAc,WACnC,cAAc,YACd,CAAC;AAAA,IACL,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,IAAI;AAAA,IACJ,IAAI;AAAA,EACN;AAEA,GAAC,cAAc,QAAQ,SAAS,CAAC,GAAG,KAAK;AAAA,IACvC,MAAM;AAAA,IACN,KAAK;AAAA,EACP,CAAC;AAKD,SAAO;AACT;AAGO,MAAM,sBAAsB,CAAC;AAAA,EAClC;AACF,MAAwC;AACtC,QAAM,EAAE,SAAS,QAAQ,IAAI,eAAe;AAE5C,QAAM,mBAAmB,KAAK,SAAS,kBAAkB;AACzD,QAAM,2BAA2B,SAAS,SAAS,gBAAgB;AAEnE,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,YAAY;AAAA,MACf,SAAS;AAAA,QACP,GAAG,YAAY,SAAS;AAAA,QACxB,KAAK;AAAA,UACH,IAAI,QAAQ,kBAAkB,2BAA2B,GAAG,CAAC;AAAA,UAC7D,IAAI,sBAAsB;AAAA,QAC5B;AAAA,MACF;AAAA,MACA,OAAO;AAAA,QACL,GAAG,YAAY,SAAS;AAAA,QACxB,gCAAgC,QAAQ,MAAM,wBAAwB;AAAA,MACxE;AAAA,IACF;AAAA,EACF;AACF;AAoBO,MAAM,SAAsB;AAAA,EACjC;AAAA,EACA;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/removeUndefinedValueObject.ts"],"sourcesContent":["export const removeUndefinedValueObject = <T extends Record<string, unknown>>(\n obj: T\n): T => {\n const newObj: T = {} as T;\n\n for (const key in obj) {\n if (obj[key] !== undefined) {\n newObj[key] = obj[key];\n }\n }\n\n Object.freeze(newObj);\n\n return newObj;\n};\n"],"mappings":";AAAO,MAAM,6BAA6B,CACxC,QACM;AACN,QAAM,SAAY,CAAC;AAEnB,aAAW,OAAO,KAAK;AACrB,QAAI,IAAI,GAAG,MAAM,QAAW;AAC1B,aAAO,GAAG,IAAI,IAAI,GAAG;AAAA,IACvB;AAAA,EACF;AAEA,SAAO,OAAO,MAAM;AAEpB,SAAO;AACT;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerProvider.d.ts","sourceRoot":"","sources":["../../../src/client/IntlayerProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,EACL,KAAK,iBAAiB,EAItB,KAAK,EAAE,EAGR,MAAM,OAAO,CAAC;AAGf,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,wCAGhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,qBAA0C,CAAC;AAE1E,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,GAAG;IACtD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"IntlayerProvider.d.ts","sourceRoot":"","sources":["../../../src/client/IntlayerProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,EACL,KAAK,iBAAiB,EAItB,KAAK,EAAE,EAGR,MAAM,OAAO,CAAC;AAGf,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,wCAGhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,qBAA0C,CAAC;AAE1E,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,GAAG;IACtD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAuDtD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerCracoPlugin.d.ts","sourceRoot":"","sources":["../../../src/craco/intlayerCracoPlugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAGtB,OAAgB,EAAE,KAAK,aAAa,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAUvE,eAAO,MAAM,qBAAqB,uBAE/B,qBAAqB,KAAG,aAoB1B,CAAC;AAGF,eAAO,MAAM,mBAAmB,qBAE7B,mBAAmB,KAAG,
|
|
1
|
+
{"version":3,"file":"intlayerCracoPlugin.d.ts","sourceRoot":"","sources":["../../../src/craco/intlayerCracoPlugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAGtB,OAAgB,EAAE,KAAK,aAAa,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAUvE,eAAO,MAAM,qBAAqB,uBAE/B,qBAAqB,KAAG,aAoB1B,CAAC;AAGF,eAAO,MAAM,mBAAmB,qBAE7B,mBAAmB,KAAG,WAuBxB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,MAAM,EAAE,WAGpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeUndefinedValueObject.d.ts","sourceRoot":"","sources":["../../../src/
|
|
1
|
+
{"version":3,"file":"removeUndefinedValueObject.d.ts","sourceRoot":"","sources":["../../../src/utils/removeUndefinedValueObject.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,OACrE,CAAC,KACL,CAYF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-intlayer",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Internationalization layer for React applications. Declare your multilingual contant in the same lever than your component. Powered by TypeScript, declaration files.",
|
|
6
6
|
"keywords": [
|
|
@@ -81,42 +81,42 @@
|
|
|
81
81
|
],
|
|
82
82
|
"dependencies": {
|
|
83
83
|
"@craco/craco": "^7.1.0",
|
|
84
|
-
"cross-spawn": "^7.0.
|
|
84
|
+
"cross-spawn": "^7.0.5",
|
|
85
85
|
"js-cookie": "^3.0.5",
|
|
86
|
-
"react-cookie": "^7.
|
|
87
|
-
"vite": "^5.4.
|
|
88
|
-
"webpack": "^5.
|
|
89
|
-
"@intlayer/
|
|
90
|
-
"@intlayer/
|
|
91
|
-
"@intlayer/webpack": "^3.0
|
|
92
|
-
"
|
|
93
|
-
"intlayer": "^3.0
|
|
94
|
-
"intlayer
|
|
86
|
+
"react-cookie": "^7.2.2",
|
|
87
|
+
"vite": "^5.4.11",
|
|
88
|
+
"webpack": "^5.96.1",
|
|
89
|
+
"@intlayer/config": "^3.1.0",
|
|
90
|
+
"@intlayer/chokidar": "^3.1.0",
|
|
91
|
+
"@intlayer/webpack": "^3.1.0",
|
|
92
|
+
"intlayer-editor": "^3.1.0",
|
|
93
|
+
"intlayer": "^3.1.0",
|
|
94
|
+
"@intlayer/core": "^3.1.0"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
|
97
97
|
"@craco/types": "^7.1.0",
|
|
98
98
|
"@types/cross-spawn": "^6.0.6",
|
|
99
99
|
"@types/js-cookie": "^3.0.6",
|
|
100
|
-
"@types/node": "^
|
|
101
|
-
"@types/react": "^18.3.
|
|
102
|
-
"concurrently": "^
|
|
103
|
-
"eslint": "^9.
|
|
104
|
-
"prettier": "3.3.3",
|
|
100
|
+
"@types/node": "^22.9.0",
|
|
101
|
+
"@types/react": "^18.3.12",
|
|
102
|
+
"concurrently": "^9.1.0",
|
|
103
|
+
"eslint": "^9.14.0",
|
|
104
|
+
"prettier": "^3.3.3",
|
|
105
105
|
"react": "^18.3.1",
|
|
106
106
|
"react-dom": "^18.3.1",
|
|
107
|
-
"rimraf": "
|
|
107
|
+
"rimraf": "^6.0.1",
|
|
108
108
|
"tsc-alias": "^1.8.10",
|
|
109
|
-
"tsup": "^8.3.
|
|
110
|
-
"typescript": "^5.
|
|
109
|
+
"tsup": "^8.3.5",
|
|
110
|
+
"typescript": "^5.6.3",
|
|
111
111
|
"@utils/eslint-config": "^1.0.4",
|
|
112
|
-
"@utils/ts-config-types": "^1.0.4",
|
|
113
112
|
"@utils/tsup-config": "^1.0.4",
|
|
114
|
-
"@utils/ts-config": "^1.0.4"
|
|
113
|
+
"@utils/ts-config": "^1.0.4",
|
|
114
|
+
"@utils/ts-config-types": "^1.0.4"
|
|
115
115
|
},
|
|
116
116
|
"peerDependencies": {
|
|
117
|
-
"react": "
|
|
118
|
-
"react-dom": "
|
|
119
|
-
"@intlayer/dictionaries-entry": "^3.0
|
|
117
|
+
"react": ">=16.0.0 <19.0.0",
|
|
118
|
+
"react-dom": ">=16.0.0 <19.0.0",
|
|
119
|
+
"@intlayer/dictionaries-entry": "^3.1.0"
|
|
120
120
|
},
|
|
121
121
|
"engines": {
|
|
122
122
|
"node": ">=14.18"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|