react-intlayer 1.2.0 → 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/IntlayerProvider.cjs +1 -1
- package/dist/cjs/IntlayerProvider.cjs.map +1 -1
- 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 +26 -2
- package/dist/cjs/client/IntlayerClientProvider.cjs.map +1 -1
- package/dist/cjs/client/IntlayerClientProvider.d.ts +2 -1
- 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 +6 -0
- package/dist/cjs/client/index.cjs.map +1 -1
- package/dist/cjs/client/index.d.ts +2 -0
- package/dist/cjs/client/useContent.cjs +2 -2
- package/dist/cjs/client/useContent.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs +5 -3
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocale.d.ts +1 -0
- package/dist/cjs/client/useLocaleBase.cjs +49 -0
- 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/useTraduction.cjs.map +1 -1
- package/dist/cjs/client/useTraduction.d.ts +6 -5
- 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 +8 -5
- package/dist/cjs/getTranslation.cjs +1 -1
- package/dist/cjs/getTranslation.cjs.map +1 -1
- package/dist/cjs/getTranslation.d.ts +3 -2
- package/dist/cjs/index.cjs +4 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/processDictionary/index.cjs +33 -1
- package/dist/cjs/processDictionary/index.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/getLocaleTranslation.cjs +1 -1
- package/dist/cjs/server/getLocaleTranslation.cjs.map +1 -1
- package/dist/cjs/server/useTraduction.cjs.map +1 -1
- package/dist/cjs/server/useTraduction.d.ts +4 -3
- 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.mjs +3 -2
- package/dist/esm/IntlayerProvider.mjs.map +1 -1
- 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 +2 -1
- package/dist/esm/client/IntlayerClientProvider.mjs +33 -7
- package/dist/esm/client/IntlayerClientProvider.mjs.map +1 -1
- 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 +2 -0
- package/dist/esm/client/index.mjs +5 -0
- package/dist/esm/client/index.mjs.map +1 -1
- package/dist/esm/client/useContent.mjs +3 -2
- package/dist/esm/client/useContent.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs +1 -0
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useLocale.d.mts +1 -0
- package/dist/esm/client/useLocale.mjs +7 -4
- 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.mjs +3 -4
- package/dist/esm/client/useLocaleCookie.mjs.map +1 -1
- package/dist/esm/client/useTraduction.d.mts +6 -5
- package/dist/esm/client/useTraduction.mjs +1 -0
- 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 +8 -5
- package/dist/esm/getEnumeration.mjs +1 -0
- package/dist/esm/getEnumeration.mjs.map +1 -1
- package/dist/esm/getTranslation.d.mts +3 -2
- package/dist/esm/getTranslation.mjs +3 -4
- package/dist/esm/getTranslation.mjs.map +1 -1
- package/dist/esm/index.d.mts +2 -0
- package/dist/esm/index.mjs +6 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/processDictionary/index.mjs +35 -4
- package/dist/esm/processDictionary/index.mjs.map +1 -1
- package/dist/esm/server/IntlayerServerProvider.mjs +3 -4
- package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
- package/dist/esm/server/getLocaleTranslation.mjs +3 -2
- package/dist/esm/server/getLocaleTranslation.mjs.map +1 -1
- package/dist/esm/server/index.mjs +1 -0
- package/dist/esm/server/index.mjs.map +1 -1
- package/dist/esm/server/serverContext.mjs +1 -0
- package/dist/esm/server/serverContext.mjs.map +1 -1
- package/dist/esm/server/useIntlayer.mjs +1 -0
- package/dist/esm/server/useIntlayer.mjs.map +1 -1
- package/dist/esm/server/useTraduction.d.mts +4 -3
- package/dist/esm/server/useTraduction.mjs +1 -0
- package/dist/esm/server/useTraduction.mjs.map +1 -1
- 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 +30 -5
- package/src/IntlayerProvider.tsx +2 -2
- package/src/cli/react-intlayer.ts +60 -0
- package/src/client/IntlayerClientProvider.tsx +43 -12
- package/src/client/getBrowserLocale.tsx +192 -0
- package/src/client/index.ts +2 -0
- package/src/client/useContent.ts +2 -2
- package/src/client/useLocale.ts +5 -4
- package/src/client/useLocaleBase.ts +24 -0
- package/src/client/useLocaleCookie.ts +2 -5
- package/src/client/useTraduction.ts +6 -5
- package/src/craco/craco.config.ts +11 -0
- package/src/craco/intlayerCracoPlugin.ts +89 -0
- package/src/getEnumeration.ts +8 -5
- package/src/getTranslation.ts +5 -7
- package/src/index.ts +2 -1
- package/src/processDictionary/index.ts +52 -5
- package/src/server/IntlayerServerProvider.tsx +2 -5
- package/src/server/getLocaleTranslation.ts +2 -2
- package/src/server/useTraduction.ts +4 -3
- package/src/vite/intlayerPlugin.ts +59 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var intlayerPlugin = __toESM(require('./intlayerCracoPlugin.cjs'));
|
|
25
|
+
module.exports = {
|
|
26
|
+
plugins: [
|
|
27
|
+
{
|
|
28
|
+
plugin: intlayerPlugin
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=craco.config.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/craco/craco.config.ts"],"sourcesContent":["import type { CracoConfig } from '@craco/types';\nimport * as intlayerPlugin from './intlayerCracoPlugin';\n\n// Usage Example\nmodule.exports = {\n plugins: [\n {\n plugin: intlayerPlugin,\n },\n ],\n} satisfies CracoConfig;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA,qBAAgC;AAGhC,OAAO,UAAU;AAAA,EACf,SAAS;AAAA,IACP;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var intlayerCracoPlugin_exports = {};
|
|
30
|
+
__export(intlayerCracoPlugin_exports, {
|
|
31
|
+
overrideCracoConfig: () => overrideCracoConfig,
|
|
32
|
+
overrideWebpackConfig: () => overrideWebpackConfig,
|
|
33
|
+
plugin: () => plugin
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(intlayerCracoPlugin_exports);
|
|
36
|
+
var import_path = require("path");
|
|
37
|
+
var import_config = require("@intlayer/config");
|
|
38
|
+
var import_webpack = require("@intlayer/webpack");
|
|
39
|
+
var import_webpack2 = __toESM(require("webpack"));
|
|
40
|
+
const intlayerConfig = (0, import_config.getConfiguration)();
|
|
41
|
+
const env = (0, import_config.formatEnvVariable)("react_app");
|
|
42
|
+
const overrideWebpackConfig = ({
|
|
43
|
+
webpackConfig
|
|
44
|
+
}) => {
|
|
45
|
+
webpackConfig.externals = {
|
|
46
|
+
...typeof webpackConfig.externals === "object" ? webpackConfig.externals : {},
|
|
47
|
+
esbuild: "esbuild",
|
|
48
|
+
module: "module",
|
|
49
|
+
fs: "fs",
|
|
50
|
+
vm: "vm"
|
|
51
|
+
};
|
|
52
|
+
(webpackConfig.module?.rules ?? []).push({
|
|
53
|
+
test: /\.node$/,
|
|
54
|
+
use: "node-loader"
|
|
55
|
+
});
|
|
56
|
+
return webpackConfig;
|
|
57
|
+
};
|
|
58
|
+
const overrideCracoConfig = ({
|
|
59
|
+
cracoConfig
|
|
60
|
+
}) => {
|
|
61
|
+
const { mainDir, baseDir } = intlayerConfig.content;
|
|
62
|
+
const dictionariesPath = (0, import_path.join)(mainDir, "dictionaries.mjs");
|
|
63
|
+
const relativeDictionariesPath = (0, import_path.relative)(baseDir, dictionariesPath);
|
|
64
|
+
return {
|
|
65
|
+
...cracoConfig,
|
|
66
|
+
webpack: {
|
|
67
|
+
...cracoConfig.webpack,
|
|
68
|
+
plugins: {
|
|
69
|
+
...cracoConfig.webpack?.plugins,
|
|
70
|
+
add: [new import_webpack2.default.EnvironmentPlugin(env), new import_webpack.IntLayerPlugin()]
|
|
71
|
+
},
|
|
72
|
+
alias: {
|
|
73
|
+
...cracoConfig.webpack?.alias,
|
|
74
|
+
"@intlayer/dictionaries-entry": (0, import_path.resolve)("./", relativeDictionariesPath)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
const plugin = {
|
|
80
|
+
overrideCracoConfig,
|
|
81
|
+
overrideWebpackConfig
|
|
82
|
+
};
|
|
83
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
+
0 && (module.exports = {
|
|
85
|
+
overrideCracoConfig,
|
|
86
|
+
overrideWebpackConfig,
|
|
87
|
+
plugin
|
|
88
|
+
});
|
|
89
|
+
//# sourceMappingURL=intlayerCracoPlugin.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/craco/intlayerCracoPlugin.ts"],"sourcesContent":["import { 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';\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: [new webpack.EnvironmentPlugin(env), new IntLayerWebpackPlugin()],\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;AAAA,kBAAwC;AAOxC,oBAAoD;AACpD,qBAAwD;AACxD,IAAAA,kBAA6D;AAG7D,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,CAAC,IAAI,gBAAAC,QAAQ,kBAAkB,GAAG,GAAG,IAAI,eAAAC,eAAsB,CAAC;AAAA,MACvE;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"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { WebpackConfigOverride, CracoConfigOverride, CracoConfig, CracoPlugin } from '@craco/types';
|
|
2
|
+
import { Configuration } from 'webpack';
|
|
3
|
+
|
|
4
|
+
declare const overrideWebpackConfig: ({ webpackConfig, }: WebpackConfigOverride) => Configuration;
|
|
5
|
+
declare const overrideCracoConfig: ({ cracoConfig, }: CracoConfigOverride) => CracoConfig;
|
|
6
|
+
/**
|
|
7
|
+
* A CRACO plugin that adds the IntLayer configuration to the webpack configuration and sets the environment variables.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const cracoConfig: CracoConfig = {
|
|
13
|
+
* plugins: [
|
|
14
|
+
* {
|
|
15
|
+
* plugin: intlayerCracoPlugin(),
|
|
16
|
+
* },
|
|
17
|
+
* ],
|
|
18
|
+
* };
|
|
19
|
+
*
|
|
20
|
+
* export default cracoConfig;
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
declare const plugin: CracoPlugin;
|
|
25
|
+
|
|
26
|
+
export { overrideCracoConfig, overrideWebpackConfig, plugin };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getEnumeration.ts"],"sourcesContent":["import { type QuantityContent, getEnumerationContent } from '@intlayer/core';\nimport { contentRender } from './ContentEditor/contentRender';\n\n/**\n * Allow to pick a content based on a quantity.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * const content = getEnumeration({\n * '<=-2.3': 'You have less than -2.3',\n * '<1': 'You have less than one',\n * '2': 'You have two',\n * '>=3': 'You have three or more',\n * }
|
|
1
|
+
{"version":3,"sources":["../../src/getEnumeration.ts"],"sourcesContent":["import { type QuantityContent, getEnumerationContent } from '@intlayer/core';\nimport { contentRender } from './ContentEditor/contentRender';\n\n/**\n * Allow to pick a content based on a quantity.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```ts\n * const content = getEnumeration({\n * '<=-2.3': 'You have less than -2.3',\n * '<1': 'You have less than one',\n * '2': 'You have two',\n * '>=3': 'You have three or more',\n * }, 2);\n * // 'You have two'\n * ```\n *\n * The order of the keys will define the priority of the content.\n *\n * ```ts\n * const content = getEnumeration({\n * '<4': 'You have less than four',\n * '2': 'You have two',\n * }, 2);\n * // 'You have less than four'\n * ```\n *\n */\nexport const getEnumeration = <Content>(\n enumerationContent: QuantityContent<Content>,\n quantity: number\n): Content => {\n const result: Content = getEnumerationContent<Content>(\n enumerationContent,\n quantity\n );\n\n if (typeof result === 'string') {\n return contentRender(result) as Content;\n }\n\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA4D;AAC5D,2BAA8B;AA8BvB,MAAM,iBAAiB,CAC5B,oBACA,aACY;AACZ,QAAM,aAAkB;AAAA,IACtB;AAAA,IACA;AAAA,EACF;AAEA,MAAI,OAAO,WAAW,UAAU;AAC9B,eAAO,oCAAc,MAAM;AAAA,EAC7B;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -7,22 +7,25 @@ import { QuantityContent } from '@intlayer/core';
|
|
|
7
7
|
*
|
|
8
8
|
* Usage:
|
|
9
9
|
*
|
|
10
|
+
* ```ts
|
|
10
11
|
* const content = getEnumeration({
|
|
11
12
|
* '<=-2.3': 'You have less than -2.3',
|
|
12
13
|
* '<1': 'You have less than one',
|
|
13
14
|
* '2': 'You have two',
|
|
14
15
|
* '>=3': 'You have three or more',
|
|
15
|
-
* },
|
|
16
|
-
* 2);
|
|
16
|
+
* }, 2);
|
|
17
17
|
* // 'You have two'
|
|
18
|
+
* ```
|
|
18
19
|
*
|
|
19
20
|
* The order of the keys will define the priority of the content.
|
|
20
21
|
*
|
|
22
|
+
* ```ts
|
|
21
23
|
* const content = getEnumeration({
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* });
|
|
24
|
+
* '<4': 'You have less than four',
|
|
25
|
+
* '2': 'You have two',
|
|
26
|
+
* }, 2);
|
|
25
27
|
* // 'You have less than four'
|
|
28
|
+
* ```
|
|
26
29
|
*
|
|
27
30
|
*/
|
|
28
31
|
declare const getEnumeration: <Content>(enumerationContent: QuantityContent<Content>, quantity: number) => Content;
|
|
@@ -25,7 +25,7 @@ var import_client = require("@intlayer/config/client");
|
|
|
25
25
|
var import_core = require("@intlayer/core");
|
|
26
26
|
var import_contentRender = require('./ContentEditor/contentRender.cjs');
|
|
27
27
|
const getTranslation = (languageContent, locale) => {
|
|
28
|
-
const { defaultLocale } = import_client.
|
|
28
|
+
const { defaultLocale } = (0, import_client.getConfiguration)().internationalization;
|
|
29
29
|
const result = (0, import_core.getTranslationContent)(
|
|
30
30
|
languageContent,
|
|
31
31
|
locale ?? defaultLocale
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getTranslation.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/getTranslation.ts"],"sourcesContent":["import { type Locales, getConfiguration } from '@intlayer/config/client';\nimport { type LanguageContent, getTranslationContent } from '@intlayer/core';\nimport { contentRender } from './ContentEditor/contentRender';\n\n/**\n *\n * Allow to pick a content based on a locale.\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 = getTranslation<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 getTranslation = <Content = string>(\n languageContent: LanguageContent<Content>,\n locale?: Locales\n): Content => {\n const { defaultLocale } = getConfiguration().internationalization;\n\n const result: Content = getTranslationContent<Content>(\n languageContent,\n locale ?? defaultLocale\n );\n\n if (typeof result === 'string') {\n return contentRender(result) as Content;\n }\n\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+C;AAC/C,kBAA4D;AAC5D,2BAA8B;AAuBvB,MAAM,iBAAiB,CAC5B,iBACA,WACY;AACZ,QAAM,EAAE,cAAc,QAAI,gCAAiB,EAAE;AAE7C,QAAM,aAAkB;AAAA,IACtB;AAAA,IACA,UAAU;AAAA,EACZ;AAEA,MAAI,OAAO,WAAW,UAAU;AAC9B,eAAO,oCAAc,MAAM;AAAA,EAC7B;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -10,12 +10,13 @@ import { LanguageContent } from '@intlayer/core';
|
|
|
10
10
|
*
|
|
11
11
|
* Usage:
|
|
12
12
|
*
|
|
13
|
+
* ```ts
|
|
13
14
|
* const content = getTranslation<string>({
|
|
14
15
|
* en: 'Hello',
|
|
15
16
|
* fr: 'Bonjour',
|
|
16
|
-
* },
|
|
17
|
-
* 'fr');
|
|
17
|
+
* }, 'fr');
|
|
18
18
|
* // 'Bonjour'
|
|
19
|
+
* ```
|
|
19
20
|
*
|
|
20
21
|
* Using TypeScript:
|
|
21
22
|
* - this function will require each locale to be defined if defined in the project configuration.
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -20,11 +20,13 @@ var src_exports = {};
|
|
|
20
20
|
__export(src_exports, {
|
|
21
21
|
IntlayerClient: () => import_client.IntlayerClient,
|
|
22
22
|
IntlayerClientProvider: () => import_client.IntlayerClientProvider,
|
|
23
|
+
getBrowserLocale: () => import_client.getBrowserLocale,
|
|
23
24
|
getTranslation: () => import_getTranslation.getTranslation,
|
|
24
25
|
localeCookie: () => import_client.localeCookie,
|
|
25
26
|
setLocaleCookie: () => import_client.setLocaleCookie,
|
|
26
27
|
useIntlayer: () => import_client.useIntlayer,
|
|
27
28
|
useLocale: () => import_client.useLocale,
|
|
29
|
+
useLocaleBase: () => import_client.useLocaleBase,
|
|
28
30
|
useLocaleCookie: () => import_client.useLocaleCookie,
|
|
29
31
|
useTraduction: () => import_client.useTraduction
|
|
30
32
|
});
|
|
@@ -35,11 +37,13 @@ var import_client = require('./client/index.cjs');
|
|
|
35
37
|
0 && (module.exports = {
|
|
36
38
|
IntlayerClient,
|
|
37
39
|
IntlayerClientProvider,
|
|
40
|
+
getBrowserLocale,
|
|
38
41
|
getTranslation,
|
|
39
42
|
localeCookie,
|
|
40
43
|
setLocaleCookie,
|
|
41
44
|
useIntlayer,
|
|
42
45
|
useLocale,
|
|
46
|
+
useLocaleBase,
|
|
43
47
|
useLocaleCookie,
|
|
44
48
|
useTraduction
|
|
45
49
|
});
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { getTranslation } from './getTranslation';\nexport {\n IntlayerClientProvider,\n type IntlayerClientProviderProps,\n IntlayerClient,\n useIntlayer,\n useLocale,\n useTraduction,\n useLocaleCookie,\n localeCookie,\n setLocaleCookie,\n} from './client/index';\
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { getTranslation } from './getTranslation';\nexport {\n IntlayerClientProvider,\n type IntlayerClientProviderProps,\n IntlayerClient,\n useIntlayer,\n useLocale,\n useTraduction,\n useLocaleCookie,\n localeCookie,\n setLocaleCookie,\n getBrowserLocale,\n useLocaleBase,\n} from './client/index';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA+B;AAC/B,oBAYO;","names":[]}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export { getTranslation } from './getTranslation.js';
|
|
2
2
|
export { IntlayerClientContext as IntlayerClient, IntlayerClientProvider, IntlayerClientProviderProps } from './client/IntlayerClientProvider.js';
|
|
3
3
|
export { useIntlayer } from './client/useIntlayer.js';
|
|
4
|
+
export { useLocaleBase } from './client/useLocaleBase.js';
|
|
4
5
|
export { useLocale } from './client/useLocale.js';
|
|
5
6
|
export { useTraduction } from './client/useTraduction.js';
|
|
6
7
|
export { localeCookie, setLocaleCookie, useLocaleCookie } from './client/useLocaleCookie.js';
|
|
8
|
+
export { getBrowserLocale } from './client/getBrowserLocale.js';
|
|
7
9
|
import '@intlayer/config/client';
|
|
8
10
|
import '@intlayer/core';
|
|
9
11
|
import 'react';
|
|
@@ -24,9 +24,10 @@ __export(processDictionary_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(processDictionary_exports);
|
|
25
25
|
var import_client = require("@intlayer/config/client");
|
|
26
26
|
var import_core = require("@intlayer/core");
|
|
27
|
+
var import_react = require("react");
|
|
27
28
|
var import_getEnumeration = require('../getEnumeration.cjs');
|
|
28
29
|
var import_getTranslation = require('../getTranslation.cjs');
|
|
29
|
-
const defaultLocale = import_client.
|
|
30
|
+
const { defaultLocale } = (0, import_client.getConfiguration)().internationalization;
|
|
30
31
|
const processTranslation = (languageContent, locale) => {
|
|
31
32
|
const translationResult = (0, import_getTranslation.getTranslation)(
|
|
32
33
|
languageContent,
|
|
@@ -43,6 +44,7 @@ const processEnumeration = (enumerationContent, locale) => {
|
|
|
43
44
|
return processDictionary(enumerationResult, locale);
|
|
44
45
|
};
|
|
45
46
|
};
|
|
47
|
+
const isReactNode = (node) => typeof node?.key !== "undefined" && typeof node?.props !== "undefined";
|
|
46
48
|
const processNode = (field, locale) => {
|
|
47
49
|
if (typeof field !== "object" || field === null) {
|
|
48
50
|
return field;
|
|
@@ -61,7 +63,37 @@ const processNode = (field, locale) => {
|
|
|
61
63
|
}
|
|
62
64
|
return field;
|
|
63
65
|
};
|
|
66
|
+
const createReactElement = (element) => {
|
|
67
|
+
if (typeof element === "string") {
|
|
68
|
+
return element;
|
|
69
|
+
}
|
|
70
|
+
const convertChildrenAsArray = (element2) => {
|
|
71
|
+
if (element2?.props && typeof element2.props.children === "object") {
|
|
72
|
+
const childrenResult = [];
|
|
73
|
+
const { children } = element2.props;
|
|
74
|
+
Object.keys(children).forEach((key) => {
|
|
75
|
+
childrenResult.push(createReactElement(children[key]));
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
...element2,
|
|
79
|
+
props: { ...element2.props, children: childrenResult }
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
...element2,
|
|
84
|
+
props: { ...element2.props, children: element2.props.children }
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
const fixedElement = convertChildrenAsArray(element);
|
|
88
|
+
const { type, props } = fixedElement;
|
|
89
|
+
return (0, import_react.createElement)(type ?? "div", props, ...props.children);
|
|
90
|
+
};
|
|
64
91
|
const processDictionary = (content, locale = defaultLocale) => {
|
|
92
|
+
if (isReactNode(content)) {
|
|
93
|
+
return createReactElement(
|
|
94
|
+
content
|
|
95
|
+
);
|
|
96
|
+
}
|
|
65
97
|
if (content && typeof content === "object") {
|
|
66
98
|
const result = {};
|
|
67
99
|
for (const key of Object.keys(content)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/processDictionary/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/processDictionary/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { type Locales, getConfiguration } from '@intlayer/config/client';\nimport {\n NodeType,\n type QuantityContent,\n type LanguageContent,\n} from '@intlayer/core';\nimport { type ReactElement, createElement, type ReactNode } from 'react';\nimport { getEnumeration } from '../getEnumeration';\nimport { getTranslation } from '../getTranslation';\nimport type {\n Content,\n ContentValue,\n TransformedContent,\n TransformedContentValue,\n} from './contentDictionary';\n\nconst { defaultLocale } = getConfiguration().internationalization;\n\nconst processTranslation = (\n languageContent: LanguageContent<ContentValue>,\n locale: Locales\n): TransformedContent => {\n const translationResult: ContentValue = getTranslation<ContentValue>(\n languageContent,\n locale\n );\n\n return processDictionary(translationResult as Content, locale);\n};\n\nconst processEnumeration = (\n enumerationContent: QuantityContent<ContentValue>,\n locale: Locales\n): TransformedContentValue => {\n return (quantity: number): TransformedContentValue => {\n const enumerationResult: ContentValue = getEnumeration<ContentValue>(\n enumerationContent,\n quantity\n );\n\n //\n return processDictionary(enumerationResult as Content, locale);\n };\n};\n\nconst isReactNode = (node: Record<string, unknown>): boolean =>\n typeof node?.key !== 'undefined' && typeof node?.props !== 'undefined';\n\nexport const processNode = (\n field: ContentValue | undefined,\n locale: Locales\n): TransformedContentValue => {\n if (typeof field !== 'object' || field === null) {\n return field;\n }\n\n if (field.nodeType === NodeType.Translation) {\n return processTranslation(field as LanguageContent<ContentValue>, locale);\n }\n\n if (field.nodeType === NodeType.Enumeration) {\n return processEnumeration(\n field satisfies QuantityContent<ContentValue>,\n locale\n );\n }\n\n if (typeof (field as any).type === 'undefined') {\n return processDictionary(field as Content, locale);\n }\n\n return field as TransformedContentValue;\n};\n\n// This function recursively creates React elements from a given JSON-like structure\nconst createReactElement = (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 // Destructure the component properties\n\n const convertChildrenAsArray = (element: ReactElement): ReactElement => {\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(createReactElement(children[key]));\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(element);\n\n const { type, props } = fixedElement;\n\n // Create and return the React element\n return createElement(type ?? 'div', props, ...props.children);\n};\n\n/**\n * Function that process a dictionary and return the result to be used in the application.\n */\nexport const processDictionary = (\n content: Content,\n locale: Locales = defaultLocale\n): TransformedContent => {\n // If it's a React element, render it\n if (isReactNode(content)) {\n return createReactElement(\n content as unknown as ReactElement\n ) as unknown as TransformedContent;\n }\n\n if (content && typeof content === 'object') {\n const result: TransformedContent = {};\n\n // List each key in the content and process it\n for (const key of Object.keys(content)) {\n const field = content[key];\n\n result[key] = processNode(field, locale);\n }\n\n return result;\n }\n\n // If it's a string, number, or function, return it\n return content;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA+C;AAC/C,kBAIO;AACP,mBAAiE;AACjE,4BAA+B;AAC/B,4BAA+B;AAQ/B,MAAM,EAAE,cAAc,QAAI,gCAAiB,EAAE;AAE7C,MAAM,qBAAqB,CACzB,iBACA,WACuB;AACvB,QAAM,wBAAkC;AAAA,IACtC;AAAA,IACA;AAAA,EACF;AAEA,SAAO,kBAAkB,mBAA8B,MAAM;AAC/D;AAEA,MAAM,qBAAqB,CACzB,oBACA,WAC4B;AAC5B,SAAO,CAAC,aAA8C;AACpD,UAAM,wBAAkC;AAAA,MACtC;AAAA,MACA;AAAA,IACF;AAGA,WAAO,kBAAkB,mBAA8B,MAAM;AAAA,EAC/D;AACF;AAEA,MAAM,cAAc,CAAC,SACnB,OAAO,MAAM,QAAQ,eAAe,OAAO,MAAM,UAAU;AAEtD,MAAM,cAAc,CACzB,OACA,WAC4B;AAC5B,MAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,WAAO;AAAA,EACT;AAEA,MAAI,MAAM,aAAa,qBAAS,aAAa;AAC3C,WAAO,mBAAmB,OAAwC,MAAM;AAAA,EAC1E;AAEA,MAAI,MAAM,aAAa,qBAAS,aAAa;AAC3C,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,MAAI,OAAQ,MAAc,SAAS,aAAa;AAC9C,WAAO,kBAAkB,OAAkB,MAAM;AAAA,EACnD;AAEA,SAAO;AACT;AAGA,MAAM,qBAAqB,CAAC,YAA0B;AACpD,MAAI,OAAO,YAAY,UAAU;AAE/B,WAAO;AAAA,EACT;AAIA,QAAM,yBAAyB,CAACA,aAAwC;AACtE,QAAIA,UAAS,SAAS,OAAOA,SAAQ,MAAM,aAAa,UAAU;AAChE,YAAM,iBAA8B,CAAC;AACrC,YAAM,EAAE,SAAS,IAAIA,SAAQ;AAG7B,aAAO,KAAK,QAAQ,EAAE,QAAQ,CAAC,QAAQ;AACrC,uBAAe,KAAK,mBAAmB,SAAS,GAAG,CAAC,CAAC;AAAA,MACvD,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,MAAM,SAAS;AAAA,IAC9D;AAAA,EACF;AAEA,QAAM,eAAe,uBAAuB,OAAO;AAEnD,QAAM,EAAE,MAAM,MAAM,IAAI;AAGxB,aAAO,4BAAc,QAAQ,OAAO,OAAO,GAAG,MAAM,QAAQ;AAC9D;AAKO,MAAM,oBAAoB,CAC/B,SACA,SAAkB,kBACK;AAEvB,MAAI,YAAY,OAAO,GAAG;AACxB,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAEA,MAAI,WAAW,OAAO,YAAY,UAAU;AAC1C,UAAM,SAA6B,CAAC;AAGpC,eAAW,OAAO,OAAO,KAAK,OAAO,GAAG;AACtC,YAAM,QAAQ,QAAQ,GAAG;AAEzB,aAAO,GAAG,IAAI,YAAY,OAAO,MAAM;AAAA,IACzC;AAEA,WAAO;AAAA,EACT;AAGA,SAAO;AACT;","names":["element"]}
|
|
@@ -28,7 +28,7 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
28
28
|
var import_client = require("@intlayer/config/client");
|
|
29
29
|
var import_serverContext = require('./serverContext.cjs');
|
|
30
30
|
const IntlayerServerContext = (0, import_serverContext.createServerContext)(
|
|
31
|
-
import_client.
|
|
31
|
+
(0, import_client.getConfiguration)().internationalization.defaultLocale
|
|
32
32
|
);
|
|
33
33
|
const useIntlayer = () => (0, import_serverContext.getServerContext)(IntlayerServerContext);
|
|
34
34
|
const locale = (0, import_serverContext.getServerContext)(IntlayerServerContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import {
|
|
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"]}
|
|
@@ -29,7 +29,7 @@ const getLocaleTranslation = (languageContent) => {
|
|
|
29
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 +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 { 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 * const content =
|
|
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":[]}
|
|
@@ -9,12 +9,13 @@ import { LanguageContent } from '@intlayer/core';
|
|
|
9
9
|
*
|
|
10
10
|
* Usage:
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* const content = useTraduction<string>({
|
|
13
14
|
* en: 'Hello',
|
|
14
15
|
* fr: 'Bonjour',
|
|
15
|
-
* },
|
|
16
|
-
* 'fr');
|
|
16
|
+
* }, 'fr');
|
|
17
17
|
* // 'Bonjour'
|
|
18
|
+
* ```
|
|
18
19
|
*
|
|
19
20
|
* Using TypeScript:
|
|
20
21
|
* - this function will require each locale to be defined if defined in the project configuration.
|
|
@@ -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":[]}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import "./chunk-ZNCO4QRF.mjs";
|
|
1
2
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
+
import { getConfiguration } from "@intlayer/config/client";
|
|
3
4
|
import {
|
|
4
5
|
IntlayerClientProvider
|
|
5
6
|
} from './client/IntlayerClientProvider.mjs';
|
|
6
7
|
import {
|
|
7
8
|
IntlayerServerProvider
|
|
8
9
|
} from './server/IntlayerServerProvider.mjs';
|
|
9
|
-
const defaultLocale =
|
|
10
|
+
const { defaultLocale } = getConfiguration().internationalization;
|
|
10
11
|
const IntlayerProvider = ({
|
|
11
12
|
children,
|
|
12
13
|
locale = defaultLocale
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/IntlayerProvider.tsx"],"sourcesContent":["import {
|
|
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":[]}
|