react-intlayer 3.5.4 → 3.5.5
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/README.md +4 -4
- package/dist/cjs/cli/react-intlayer.cjs +4 -4
- package/dist/cjs/cli/react-intlayer.cjs.map +1 -1
- package/dist/cjs/client/index.cjs +3 -0
- package/dist/cjs/client/index.cjs.map +1 -1
- package/dist/cjs/client/useIntlayerAsync.cjs +55 -0
- package/dist/cjs/client/useIntlayerAsync.cjs.map +1 -0
- package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs +59 -0
- package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs.map +1 -0
- package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -1
- package/dist/cjs/editor/IntlayerEditorProvider.cjs +5 -1
- package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +1 -1
- package/dist/cjs/editor/renderContentEditor.cjs.map +1 -1
- package/dist/cjs/getDictionary.cjs +1 -1
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/getIntlayerAsync.cjs +42 -0
- package/dist/cjs/getIntlayerAsync.cjs.map +1 -0
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/processDictionary/contentDictionary.cjs.map +1 -1
- package/dist/cjs/processDictionary/index.cjs +13 -13
- package/dist/cjs/processDictionary/index.cjs.map +1 -1
- package/dist/cjs/utils/PoweredByMeta/index.cjs +40 -0
- package/dist/cjs/utils/PoweredByMeta/index.cjs.map +1 -0
- package/dist/esm/cli/react-intlayer.mjs +5 -5
- package/dist/esm/cli/react-intlayer.mjs.map +1 -1
- package/dist/esm/client/index.mjs +2 -0
- package/dist/esm/client/index.mjs.map +1 -1
- package/dist/esm/client/useIntlayerAsync.mjs +34 -0
- package/dist/esm/client/useIntlayerAsync.mjs.map +1 -0
- package/dist/esm/distantDictionary/fetchDistantDictionary.mjs +36 -0
- package/dist/esm/distantDictionary/fetchDistantDictionary.mjs.map +1 -0
- package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -1
- package/dist/esm/editor/IntlayerEditorProvider.mjs +6 -2
- package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -1
- package/dist/esm/editor/renderContentEditor.mjs.map +1 -1
- package/dist/esm/getDictionary.mjs +1 -1
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/esm/getIntlayerAsync.mjs +19 -0
- package/dist/esm/getIntlayerAsync.mjs.map +1 -0
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/processDictionary/index.mjs +13 -13
- package/dist/esm/processDictionary/index.mjs.map +1 -1
- package/dist/esm/utils/PoweredByMeta/index.mjs +17 -0
- package/dist/esm/utils/PoweredByMeta/index.mjs.map +1 -0
- package/dist/types/client/index.d.ts +1 -0
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/client/useIntlayerAsync.d.ts +15 -0
- package/dist/types/client/useIntlayerAsync.d.ts.map +1 -0
- package/dist/types/distantDictionary/fetchDistantDictionary.d.ts +6 -0
- package/dist/types/distantDictionary/fetchDistantDictionary.d.ts.map +1 -0
- package/dist/types/editor/ContentSelectorWrapper.d.ts +1 -1
- package/dist/types/editor/ContentSelectorWrapper.d.ts.map +1 -1
- package/dist/types/editor/IntlayerEditorProvider.d.ts.map +1 -1
- package/dist/types/editor/renderContentEditor.d.ts +1 -1
- package/dist/types/editor/renderContentEditor.d.ts.map +1 -1
- package/dist/types/getIntlayer.d.ts +1 -2
- package/dist/types/getIntlayer.d.ts.map +1 -1
- package/dist/types/getIntlayerAsync.d.ts +13 -0
- package/dist/types/getIntlayerAsync.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/processDictionary/contentDictionary.d.ts +1 -1
- package/dist/types/processDictionary/contentDictionary.d.ts.map +1 -1
- package/dist/types/processDictionary/index.d.ts +2 -2
- package/dist/types/processDictionary/index.d.ts.map +1 -1
- package/dist/types/utils/PoweredByMeta/index.d.ts +3 -0
- package/dist/types/utils/PoweredByMeta/index.d.ts.map +1 -0
- package/package.json +15 -14
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<a href="https://www.npmjs.com/package/react-intlayer">
|
|
3
|
-
<img src="docs/assets/logo.png" width="500" alt="intlayer" />
|
|
3
|
+
<img src="https://raw.githubusercontent.com/aymericzip/intlayer/572ae9c9acafb74307b81530c1931a8e98990aef/docs/assets/logo.png" width="500" alt="intlayer" />
|
|
4
4
|
</a>
|
|
5
5
|
</div>
|
|
6
6
|
|
|
@@ -115,7 +115,7 @@ const config: IntlayerConfig = {
|
|
|
115
115
|
export default config;
|
|
116
116
|
```
|
|
117
117
|
|
|
118
|
-
To see all available parameters, refer to the [configuration documentation here](https://github.com/aymericzip/intlayer/blob/main/docs/
|
|
118
|
+
To see all available parameters, refer to the [configuration documentation here](https://github.com/aymericzip/intlayer/blob/main/docs/en/configuration.md).
|
|
119
119
|
|
|
120
120
|
## Step 3: Integrate Intlayer in Your CRA Configuration
|
|
121
121
|
|
|
@@ -174,7 +174,7 @@ const appContent = {
|
|
|
174
174
|
export default appContent;
|
|
175
175
|
```
|
|
176
176
|
|
|
177
|
-
[See how to declare your Intlayer declaration files](https://github.com/aymericzip/intlayer/blob/main/docs/
|
|
177
|
+
[See how to declare your Intlayer declaration files](https://github.com/aymericzip/intlayer/blob/main/docs/en/content_declaration/get_started.md)
|
|
178
178
|
|
|
179
179
|
## Step 5: Utilize Intlayer in Your Code
|
|
180
180
|
|
|
@@ -272,4 +272,4 @@ Ensure your TypeScript configuration includes the autogenerated types.
|
|
|
272
272
|
|
|
273
273
|
# Getting Started with Intlayer and Vite + React
|
|
274
274
|
|
|
275
|
-
For integration with Vite + React, refer to the [setup guide](https://github.com/aymericzip/intlayer/blob/main/docs/
|
|
275
|
+
For integration with Vite + React, refer to the [setup guide](https://github.com/aymericzip/intlayer/blob/main/docs/en/intlayer_with_vite_react.md)
|
|
@@ -48,13 +48,13 @@ switch (script) {
|
|
|
48
48
|
});
|
|
49
49
|
if (child.signal) {
|
|
50
50
|
if (child.signal === "SIGKILL") {
|
|
51
|
-
|
|
51
|
+
(0, import_config.appLogger)(`
|
|
52
52
|
The build failed because the process exited too early.
|
|
53
53
|
This probably means the system ran out of memory or someone called
|
|
54
54
|
\`kill -9\` on the process.
|
|
55
55
|
`);
|
|
56
56
|
} else if (child.signal === "SIGTERM") {
|
|
57
|
-
|
|
57
|
+
(0, import_config.appLogger)(`
|
|
58
58
|
The build failed because the process exited too early.
|
|
59
59
|
Someone might have called \`kill\` or \`killall\`, or the system could
|
|
60
60
|
be shutting down.
|
|
@@ -66,8 +66,8 @@ switch (script) {
|
|
|
66
66
|
break;
|
|
67
67
|
}
|
|
68
68
|
default:
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
(0, import_config.appLogger)(`Unknown script "${script}".`);
|
|
70
|
+
(0, import_config.appLogger)("Perhaps you need to update craco?");
|
|
71
71
|
break;
|
|
72
72
|
}
|
|
73
73
|
//# sourceMappingURL=react-intlayer.cjs.map
|
|
@@ -1 +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 { ESMxCJSRequire } from '@intlayer/config';\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 = ESMxCJSRequire.resolve(\n `@craco/craco/dist/scripts/${script}`\n );\n\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, {\n stdio: 'inherit',\n });\n\n if (child.signal) {\n if (child.signal === 'SIGKILL') {\n
|
|
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 { ESMxCJSRequire, appLogger } from '@intlayer/config';\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 = ESMxCJSRequire.resolve(\n `@craco/craco/dist/scripts/${script}`\n );\n\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, {\n stdio: 'inherit',\n });\n\n if (child.signal) {\n if (child.signal === 'SIGKILL') {\n appLogger(`\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 appLogger(`\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 appLogger(`Unknown script \"${script}\".`);\n appLogger('Perhaps you need to update craco?');\n break;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AASA,oBAA0C;AAC1C,yBAAkB;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,6BAAe;AAAA,MAChC,6BAA6B,MAAM;AAAA,IACrC;AAEA,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,mBAAAA,QAAM,KAAK,QAAQ,aAAa;AAAA,MAC5C,OAAO;AAAA,IACT,CAAC;AAED,QAAI,MAAM,QAAQ;AAChB,UAAI,MAAM,WAAW,WAAW;AAC9B,qCAAU;AAAA;AAAA;AAAA;AAAA,aAIL;AAAA,MACP,WAAW,MAAM,WAAW,WAAW;AACrC,qCAAU;AAAA;AAAA;AAAA;AAAA,aAIL;AAAA,MACP;AAEA,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,YAAQ,KAAK,MAAM,UAAU,MAAS;AACtC;AAAA,EACF;AAAA,EACA;AACE,iCAAU,mBAAmB,MAAM,IAAI;AACvC,iCAAU,mCAAmC;AAC7C;AACJ;","names":["spawn"]}
|
|
@@ -26,6 +26,7 @@ __export(client_exports, {
|
|
|
26
26
|
t: () => import_t.t,
|
|
27
27
|
useDictionary: () => import_useDictionary.useDictionary,
|
|
28
28
|
useIntlayer: () => import_useIntlayer.useIntlayer,
|
|
29
|
+
useIntlayerAsync: () => import_useIntlayerAsync.useIntlayerAsync,
|
|
29
30
|
useIntlayerContext: () => import_IntlayerProvider.useIntlayerContext,
|
|
30
31
|
useLocale: () => import_useLocale.useLocale,
|
|
31
32
|
useLocaleBase: () => import_useLocaleBase.useLocaleBase,
|
|
@@ -35,6 +36,7 @@ __export(client_exports, {
|
|
|
35
36
|
module.exports = __toCommonJS(client_exports);
|
|
36
37
|
var import_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
37
38
|
var import_useIntlayer = require('./useIntlayer.cjs');
|
|
39
|
+
var import_useIntlayerAsync = require('./useIntlayerAsync.cjs');
|
|
38
40
|
var import_useDictionary = require('./useDictionary.cjs');
|
|
39
41
|
var import_useLocaleBase = require('./useLocaleBase.cjs');
|
|
40
42
|
var import_useLocale = require('./useLocale.cjs');
|
|
@@ -52,6 +54,7 @@ var import_t = require('./t.cjs');
|
|
|
52
54
|
t,
|
|
53
55
|
useDictionary,
|
|
54
56
|
useIntlayer,
|
|
57
|
+
useIntlayerAsync,
|
|
55
58
|
useIntlayerContext,
|
|
56
59
|
useLocale,
|
|
57
60
|
useLocaleBase,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export {\n type IntlayerProviderProps,\n IntlayerClientContext,\n useIntlayerContext,\n IntlayerProvider,\n} from './IntlayerProvider';\nexport { useIntlayer } from './useIntlayer';\nexport { useDictionary } from './useDictionary';\nexport { useLocaleBase } from './useLocaleBase';\nexport { useLocale } from './useLocale';\nexport { useTraduction } from './useTraduction';\nexport {\n useLocaleCookie,\n localeCookie,\n setLocaleCookie,\n} from './useLocaleCookie';\nexport { getBrowserLocale } from './getBrowserLocale';\nexport { t } from './t';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAKO;AACP,yBAA4B;AAC5B,2BAA8B;AAC9B,2BAA8B;AAC9B,uBAA0B;AAC1B,2BAA8B;AAC9B,6BAIO;AACP,8BAAiC;AACjC,eAAkB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export {\n type IntlayerProviderProps,\n IntlayerClientContext,\n useIntlayerContext,\n IntlayerProvider,\n} from './IntlayerProvider';\nexport { useIntlayer } from './useIntlayer';\nexport { useIntlayerAsync } from './useIntlayerAsync';\nexport { useDictionary } from './useDictionary';\nexport { useLocaleBase } from './useLocaleBase';\nexport { useLocale } from './useLocale';\nexport { useTraduction } from './useTraduction';\nexport {\n useLocaleCookie,\n localeCookie,\n setLocaleCookie,\n} from './useLocaleCookie';\nexport { getBrowserLocale } from './getBrowserLocale';\nexport { t } from './t';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAKO;AACP,yBAA4B;AAC5B,8BAAiC;AACjC,2BAA8B;AAC9B,2BAA8B;AAC9B,uBAA0B;AAC1B,2BAA8B;AAC9B,6BAIO;AACP,8BAAiC;AACjC,eAAkB;","names":[]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var useIntlayerAsync_exports = {};
|
|
21
|
+
__export(useIntlayerAsync_exports, {
|
|
22
|
+
useIntlayerAsync: () => useIntlayerAsync
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useIntlayerAsync_exports);
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
var import_getIntlayer = require('../getIntlayer.cjs');
|
|
27
|
+
var import_getIntlayerAsync = require('../getIntlayerAsync.cjs');
|
|
28
|
+
var import_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
29
|
+
const useIntlayerAsync = (key, locale, isRenderEditor = true) => {
|
|
30
|
+
const { locale: currentLocale } = (0, import_react.useContext)(import_IntlayerProvider.IntlayerClientContext);
|
|
31
|
+
const localeTarget = locale ?? currentLocale;
|
|
32
|
+
const localeDictionary = (0, import_getIntlayer.getIntlayer)(key, localeTarget, isRenderEditor);
|
|
33
|
+
const [distantDictionary, setDistantDictionary] = (0, import_react.useState)(void 0);
|
|
34
|
+
const [isLoading, setIsLoading] = (0, import_react.useState)(false);
|
|
35
|
+
(0, import_react.useEffect)(() => {
|
|
36
|
+
setIsLoading(true);
|
|
37
|
+
(0, import_getIntlayerAsync.getIntlayerAsync)(key).then((distantDictionary2) => {
|
|
38
|
+
if (distantDictionary2) {
|
|
39
|
+
setDistantDictionary(distantDictionary2);
|
|
40
|
+
}
|
|
41
|
+
}).finally(() => {
|
|
42
|
+
setIsLoading(false);
|
|
43
|
+
});
|
|
44
|
+
}, []);
|
|
45
|
+
const dictionary = (0, import_react.useMemo)(
|
|
46
|
+
() => distantDictionary ?? localeDictionary,
|
|
47
|
+
[distantDictionary, localeDictionary]
|
|
48
|
+
);
|
|
49
|
+
return { ...dictionary, isLoading };
|
|
50
|
+
};
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
useIntlayerAsync
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=useIntlayerAsync.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useIntlayerAsync.ts"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport { useContext, useEffect, useMemo, useState } from 'react';\nimport {\n DataFromDictionaryKey,\n type DictionaryKeys,\n getIntlayer,\n} from '../getIntlayer';\nimport { getIntlayerAsync } from '../getIntlayerAsync';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\nexport type UseIntlayerAsync = <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = true,\n>(\n key: T,\n locale?: L,\n isRenderEditor?: R\n) => DataFromDictionaryKey<T, L, R> & { isLoading: boolean };\n\n/**\n * On the client side, Hook that picking one dictionary by its key and return the content\n *\n * This hook will prerender the locale dictionary and fetch simultaneously the distant dictionaries to hydrate it.\n *\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useIntlayerAsync: UseIntlayerAsync = <T extends DictionaryKeys>(\n key: T,\n locale?: Locales,\n isRenderEditor = true\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n const localeDictionary = getIntlayer(key, localeTarget, isRenderEditor);\n const [distantDictionary, setDistantDictionary] = useState<\n typeof localeDictionary | null | undefined\n >(undefined);\n const [isLoading, setIsLoading] = useState(false);\n\n useEffect(() => {\n setIsLoading(true);\n\n getIntlayerAsync(key)\n .then((distantDictionary) => {\n if (distantDictionary) {\n setDistantDictionary(distantDictionary);\n }\n })\n .finally(() => {\n setIsLoading(false);\n });\n }, []);\n\n const dictionary = useMemo(\n () => distantDictionary ?? localeDictionary,\n [distantDictionary, localeDictionary]\n );\n\n return { ...dictionary, isLoading };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAyD;AACzD,yBAIO;AACP,8BAAiC;AACjC,8BAAsC;AAoB/B,MAAM,mBAAqC,CAChD,KACA,QACA,iBAAiB,SACd;AACH,QAAM,EAAE,QAAQ,cAAc,QAAI,yBAAW,6CAAqB;AAClE,QAAM,eAAe,UAAU;AAC/B,QAAM,uBAAmB,gCAAY,KAAK,cAAc,cAAc;AACtE,QAAM,CAAC,mBAAmB,oBAAoB,QAAI,uBAEhD,MAAS;AACX,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,KAAK;AAEhD,8BAAU,MAAM;AACd,iBAAa,IAAI;AAEjB,kDAAiB,GAAG,EACjB,KAAK,CAACA,uBAAsB;AAC3B,UAAIA,oBAAmB;AACrB,6BAAqBA,kBAAiB;AAAA,MACxC;AAAA,IACF,CAAC,EACA,QAAQ,MAAM;AACb,mBAAa,KAAK;AAAA,IACpB,CAAC;AAAA,EACL,GAAG,CAAC,CAAC;AAEL,QAAM,iBAAa;AAAA,IACjB,MAAM,qBAAqB;AAAA,IAC3B,CAAC,mBAAmB,gBAAgB;AAAA,EACtC;AAEA,SAAO,EAAE,GAAG,YAAY,UAAU;AACpC;","names":["distantDictionary"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
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 fetchDistantDictionary_exports = {};
|
|
20
|
+
__export(fetchDistantDictionary_exports, {
|
|
21
|
+
fetchDistantDictionary: () => fetchDistantDictionary
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(fetchDistantDictionary_exports);
|
|
24
|
+
var import_client = require("@intlayer/config/client");
|
|
25
|
+
var import_libs = require("@intlayer/design-system/libs");
|
|
26
|
+
const fetchDistantDictionary = async (dictionaryKey) => {
|
|
27
|
+
try {
|
|
28
|
+
const config = (0, import_client.getConfiguration)();
|
|
29
|
+
const { clientId, clientSecret } = config.editor;
|
|
30
|
+
const intlayerAPI = (0, import_libs.getIntlayerAPI)(void 0, config);
|
|
31
|
+
if (!clientId || !clientSecret) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
"Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project."
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();
|
|
37
|
+
const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;
|
|
38
|
+
const getDictionaryResult = await intlayerAPI.dictionary.getDictionary(
|
|
39
|
+
dictionaryKey,
|
|
40
|
+
void 0,
|
|
41
|
+
{
|
|
42
|
+
headers: { Authorization: `Bearer ${oAuth2AccessToken}` }
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
const distantDictionary = getDictionaryResult.data;
|
|
46
|
+
if (!distantDictionary) {
|
|
47
|
+
throw new Error(`Dictionary ${dictionaryKey} not found on remote`);
|
|
48
|
+
}
|
|
49
|
+
return distantDictionary;
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error(error);
|
|
52
|
+
return void 0;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
fetchDistantDictionary
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=fetchDistantDictionary.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/distantDictionary/fetchDistantDictionary.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend not build yet\nimport { type DictionaryAPI } from '@intlayer/backend';\nimport { getConfiguration } from '@intlayer/config/client';\n// @ts-ignore @intlayer/design-system not build yet\nimport { getIntlayerAPI } from '@intlayer/design-system/libs';\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionary = async (\n dictionaryKey: string\n): Promise<DictionaryAPI> => {\n try {\n const config = getConfiguration();\n const { clientId, clientSecret } = config.editor;\n const intlayerAPI = getIntlayerAPI(undefined, config);\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project.'\n );\n }\n\n const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n // Fetch the dictionary\n const getDictionaryResult = await intlayerAPI.dictionary.getDictionary(\n dictionaryKey,\n undefined,\n {\n headers: { Authorization: `Bearer ${oAuth2AccessToken}` },\n }\n );\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(`Dictionary ${dictionaryKey} not found on remote`);\n }\n\n return distantDictionary;\n } catch (error) {\n console.error(error);\n return undefined;\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAiC;AAEjC,kBAA+B;AAKxB,MAAM,yBAAyB,OACpC,kBAC2B;AAC3B,MAAI;AACF,UAAM,aAAS,gCAAiB;AAChC,UAAM,EAAE,UAAU,aAAa,IAAI,OAAO;AAC1C,UAAM,kBAAc,4BAAe,QAAW,MAAM;AAEpD,QAAI,CAAC,YAAY,CAAC,cAAc;AAC9B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,oBAAoB,MAAM,YAAY,KAAK,qBAAqB;AAEtE,UAAM,oBAAoB,kBAAkB,MAAM;AAGlD,UAAM,sBAAsB,MAAM,YAAY,WAAW;AAAA,MACvD;AAAA,MACA;AAAA,MACA;AAAA,QACE,SAAS,EAAE,eAAe,UAAU,iBAAiB,GAAG;AAAA,MAC1D;AAAA,IACF;AAEA,UAAM,oBAAoB,oBAAoB;AAE9C,QAAI,CAAC,mBAAmB;AACtB,YAAM,IAAI,MAAM,cAAc,aAAa,sBAAsB;AAAA,IACnE;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,MAAM,KAAK;AACnB,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { type KeyPath } from '@intlayer/core';\nimport { type FC, type ReactNode } from 'react';\n\nexport type ContentSelectorWrapperProps = {\n children: ReactNode;\n
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { type KeyPath } from '@intlayer/core';\nimport { type FC, type ReactNode } from 'react';\n\nexport type ContentSelectorWrapperProps = {\n children: ReactNode;\n dictionaryKey: string;\n dictionaryPath: string;\n keyPath: KeyPath[];\n};\n\nexport const ContentSelectorWrapper: FC<ContentSelectorWrapperProps> = ({\n children,\n}) => <>{children}</>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAcM;AAFC,MAAM,yBAA0D,CAAC;AAAA,EACtE;AACF,MAAM,2EAAG,UAAS;","names":[]}
|
|
@@ -22,8 +22,12 @@ __export(IntlayerEditorProvider_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(IntlayerEditorProvider_exports);
|
|
24
24
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_PoweredByMeta = require('../utils/PoweredByMeta/index.cjs');
|
|
25
26
|
var import_ContentSelectorConnector = require('./ContentSelectorConnector.cjs');
|
|
26
|
-
const IntlayerEditorProvider = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime.
|
|
27
|
+
const IntlayerEditorProvider = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ContentSelectorConnector.ContentSelectorProvider, { children: [
|
|
28
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_PoweredByMeta.PoweredByMeta, {}),
|
|
29
|
+
children
|
|
30
|
+
] });
|
|
27
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
32
|
0 && (module.exports = {
|
|
29
33
|
IntlayerEditorProvider
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["import { FC, PropsWithChildren } from 'react';\nimport { ContentSelectorProvider } from './ContentSelectorConnector';\n\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => (\n <ContentSelectorProvider
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["import { FC, PropsWithChildren } from 'react';\nimport { PoweredByMeta } from '../utils/PoweredByMeta/index';\nimport { ContentSelectorProvider } from './ContentSelectorConnector';\n\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => (\n <ContentSelectorProvider>\n <PoweredByMeta />\n {children}\n </ContentSelectorProvider>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKE;AAJF,2BAA8B;AAC9B,sCAAwC;AAEjC,MAAM,yBAAgD,CAAC,EAAE,SAAS,MACvE,6CAAC,2DACC;AAAA,8CAAC,sCAAc;AAAA,EACd;AAAA,GACH;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/renderContentEditor.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport type { KeyPath } from '@intlayer/core';\nimport type { FC, ReactNode } from 'react';\nimport { ContentSelectorConnector } from './ContentSelectorConnector';\n\nconst {\n editor: { enabled },\n} = getConfiguration();\n\nexport type IntlayerEditorElementProps = {\n content: string;\n
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/renderContentEditor.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport type { KeyPath } from '@intlayer/core';\nimport type { FC, ReactNode } from 'react';\nimport { ContentSelectorConnector } from './ContentSelectorConnector';\n\nconst {\n editor: { enabled },\n} = getConfiguration();\n\nexport type IntlayerEditorElementProps = {\n content: string;\n dictionaryKey: string;\n dictionaryPath: string;\n keyPath: KeyPath[];\n isContentSelectable: boolean;\n};\n\nconst IntlayerEditorElement: FC<IntlayerEditorElementProps> = ({\n content,\n isContentSelectable,\n ...props\n}) => {\n if (enabled && isContentSelectable) {\n return (\n <ContentSelectorConnector {...props}>{content}</ContentSelectorConnector>\n );\n }\n return content;\n};\n\nexport type IntlayerNode<T = string> = ReactNode & {\n value: T;\n};\n\nexport const renderIntlayerEditor = (\n data: IntlayerEditorElementProps,\n isContentSelectable = true\n): IntlayerNode => {\n const Result = (\n <IntlayerEditorElement\n {...data}\n isContentSelectable={isContentSelectable}\n />\n );\n\n return { ...Result, value: data.content };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAwBM;AAxBN,oBAAiC;AAGjC,sCAAyC;AAEzC,MAAM;AAAA,EACJ,QAAQ,EAAE,QAAQ;AACpB,QAAI,gCAAiB;AAUrB,MAAM,wBAAwD,CAAC;AAAA,EAC7D;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,MAAI,WAAW,qBAAqB;AAClC,WACE,4CAAC,4DAA0B,GAAG,OAAQ,mBAAQ;AAAA,EAElD;AACA,SAAO;AACT;AAMO,MAAM,uBAAuB,CAClC,MACA,sBAAsB,SACL;AACjB,QAAM,SACJ;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ;AAAA;AAAA,EACF;AAGF,SAAO,EAAE,GAAG,QAAQ,OAAO,KAAK,QAAQ;AAC1C;","names":[]}
|
|
@@ -29,7 +29,7 @@ const recursiveTransformContent = (value, isRenderEditor = false) => {
|
|
|
29
29
|
if (typeof value === "function") {
|
|
30
30
|
return (props) => recursiveTransformContent(value(props), isRenderEditor);
|
|
31
31
|
} else if (typeof value === "object") {
|
|
32
|
-
if (typeof value.
|
|
32
|
+
if (typeof value.dictionaryKey !== "undefined") {
|
|
33
33
|
if (isRenderEditor) {
|
|
34
34
|
return (0, import_renderContentEditor.renderIntlayerEditor)(value);
|
|
35
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getDictionary.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Locales } from '@intlayer/config';\nimport type {\n DeclarationContent,\n DictionaryValue,\n NodeType,\n} from '@intlayer/core';\nimport { isValidElement, type ReactNode } from 'react';\nimport {\n type IntlayerNode,\n renderIntlayerEditor,\n} from './editor/renderContentEditor';\nimport { processDictionary } from './processDictionary/index';\n\ntype TransformNodeType<T, L extends Locales, R extends boolean> = T extends {\n [NodeType.Enumeration]: { '1': any };\n}\n ? (\n quantity: number\n ) => DeepTransformContent<T[NodeType.Enumeration]['1'], L, R>\n : T extends {\n [NodeType.Translation]: object;\n }\n ? L extends keyof T[NodeType.Translation]\n ? DeepTransformContent<T[NodeType.Translation][L], L, R>\n : never\n : T;\n\nexport type DeepTransformContent<\n T,\n L extends Locales,\n R extends boolean,\n> = T extends object // Check if the property is an object\n ? T extends (infer U)[] // If it's an array, infer the type of array elements\n ? DeepTransformContent<U, L, R>[] // Apply DeepTransformContent recursively to each element of the array\n : T extends {\n nodeType: NodeType | string;\n }\n ? TransformNodeType<T, L, R>\n : T extends { _owner: any; key: any; props: any; ref: any }\n ? ReactNode\n : {\n [K in keyof T]: DeepTransformContent<T[K], L, R>;\n }\n : T extends undefined\n ? never\n : R extends true\n ? IntlayerNode<T>\n : T;\n\n/**\n * Go through the object. If a object has a keyPath, render the intlayer editor if editor enabled.\n */\nexport const recursiveTransformContent = (\n value: any,\n isRenderEditor = false\n): object => {\n if (typeof value === 'function') {\n return (props: any) =>\n recursiveTransformContent(value(props), isRenderEditor);\n } else if (typeof value === 'object') {\n if (typeof value.
|
|
1
|
+
{"version":3,"sources":["../../src/getDictionary.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Locales } from '@intlayer/config';\nimport type {\n DeclarationContent,\n DictionaryValue,\n NodeType,\n} from '@intlayer/core';\nimport { isValidElement, type ReactNode } from 'react';\nimport {\n type IntlayerNode,\n renderIntlayerEditor,\n} from './editor/renderContentEditor';\nimport { processDictionary } from './processDictionary/index';\n\ntype TransformNodeType<T, L extends Locales, R extends boolean> = T extends {\n [NodeType.Enumeration]: { '1': any };\n}\n ? (\n quantity: number\n ) => DeepTransformContent<T[NodeType.Enumeration]['1'], L, R>\n : T extends {\n [NodeType.Translation]: object;\n }\n ? L extends keyof T[NodeType.Translation]\n ? DeepTransformContent<T[NodeType.Translation][L], L, R>\n : never\n : T;\n\nexport type DeepTransformContent<\n T,\n L extends Locales,\n R extends boolean,\n> = T extends object // Check if the property is an object\n ? T extends (infer U)[] // If it's an array, infer the type of array elements\n ? DeepTransformContent<U, L, R>[] // Apply DeepTransformContent recursively to each element of the array\n : T extends {\n nodeType: NodeType | string;\n }\n ? TransformNodeType<T, L, R>\n : T extends { _owner: any; key: any; props: any; ref: any }\n ? ReactNode\n : {\n [K in keyof T]: DeepTransformContent<T[K], L, R>;\n }\n : T extends undefined\n ? never\n : R extends true\n ? IntlayerNode<T>\n : T;\n\n/**\n * Go through the object. If a object has a keyPath, render the intlayer editor if editor enabled.\n */\nexport const recursiveTransformContent = (\n value: any,\n isRenderEditor = false\n): object => {\n if (typeof value === 'function') {\n return (props: any) =>\n recursiveTransformContent(value(props), isRenderEditor);\n } else if (typeof value === 'object') {\n if (typeof value.dictionaryKey !== 'undefined') {\n if (isRenderEditor) {\n return renderIntlayerEditor(value);\n }\n return value.content;\n } else if (Array.isArray(value)) {\n return value.map((el) => recursiveTransformContent(el, isRenderEditor));\n } else if (isValidElement(value)) {\n return value;\n }\n\n return Object.entries(value).reduce(\n (acc, [key, value]) => ({\n ...acc,\n [key]: recursiveTransformContent(value, isRenderEditor),\n }),\n {} as object\n );\n }\n\n return value;\n};\n\ntype DataFromDictionary<\n T extends DeclarationContent,\n K extends Locales,\n R extends boolean = false,\n> = DeepTransformContent<T['content'], K, R>;\n\nexport type UseDictionary = <\n T extends DeclarationContent,\n L extends Locales,\n R extends boolean = false,\n>(\n dictionary: T,\n locale?: L,\n isRenderEditor?: R\n) => DataFromDictionary<T, L, R>;\n\n/**\n * Hook that picks one dictionary by its id and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const getDictionary: UseDictionary = <\n T extends DeclarationContent,\n L extends Locales,\n R extends boolean = false,\n>(\n dictionary: T,\n locale?: L,\n isRenderEditor: R = false as R\n) => {\n const result = processDictionary(\n dictionary.content as DictionaryValue,\n dictionary.key,\n dictionary.filePath,\n [],\n locale\n );\n\n return recursiveTransformContent(\n result,\n isRenderEditor\n ) as DataFromDictionary<T, L, R>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,mBAA+C;AAC/C,iCAGO;AACP,+BAAkC;AAyC3B,MAAM,4BAA4B,CACvC,OACA,iBAAiB,UACN;AACX,MAAI,OAAO,UAAU,YAAY;AAC/B,WAAO,CAAC,UACN,0BAA0B,MAAM,KAAK,GAAG,cAAc;AAAA,EAC1D,WAAW,OAAO,UAAU,UAAU;AACpC,QAAI,OAAO,MAAM,kBAAkB,aAAa;AAC9C,UAAI,gBAAgB;AAClB,mBAAO,iDAAqB,KAAK;AAAA,MACnC;AACA,aAAO,MAAM;AAAA,IACf,WAAW,MAAM,QAAQ,KAAK,GAAG;AAC/B,aAAO,MAAM,IAAI,CAAC,OAAO,0BAA0B,IAAI,cAAc,CAAC;AAAA,IACxE,eAAW,6BAAe,KAAK,GAAG;AAChC,aAAO;AAAA,IACT;AAEA,WAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,MAC3B,CAAC,KAAK,CAAC,KAAKA,MAAK,OAAO;AAAA,QACtB,GAAG;AAAA,QACH,CAAC,GAAG,GAAG,0BAA0BA,QAAO,cAAc;AAAA,MACxD;AAAA,MACA,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;AAuBO,MAAM,gBAA+B,CAK1C,YACA,QACA,iBAAoB,UACjB;AACH,QAAM,aAAS;AAAA,IACb,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX,CAAC;AAAA,IACD;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":["value"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport {\n type DeepTransformContent,\n recursiveTransformContent,\n} from './getDictionary';\nimport { processDictionary } from './processDictionary/index';\n\n/**\n * Provides a fallback to string type if the generic type T is never,\n * otherwise returns T. This is useful for handling cases where no keys are found.\n * Example: StringFallback<never> -> string; StringFallback<'key'> -> 'key'\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\n\n/**\n * Represents the keys of the IntlayerDictionaryTypesConnector,\n * ensuring they are valid dictionary keys or fallback to string if none exist.\n *\n * Example:\n * ```ts\n * DictionaryKeys -> 'key1' | 'key2'\n * // or if IntlayerDictionaryTypesConnector is not defined,\n * DictionaryKeys -> string\n * ```\n */\nexport type DictionaryKeys = StringFallback<\n keyof IntlayerDictionaryTypesConnector\n>;\n\n/**\n * Represents the data type returned by the useIntlayer hook,\n * excluding the 'id' and 'filePath' keys from the dictionary content.\n */\
|
|
1
|
+
{"version":3,"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport {\n type DeepTransformContent,\n recursiveTransformContent,\n} from './getDictionary';\nimport { processDictionary } from './processDictionary/index';\n\n/**\n * Provides a fallback to string type if the generic type T is never,\n * otherwise returns T. This is useful for handling cases where no keys are found.\n * Example: StringFallback<never> -> string; StringFallback<'key'> -> 'key'\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\n\n/**\n * Represents the keys of the IntlayerDictionaryTypesConnector,\n * ensuring they are valid dictionary keys or fallback to string if none exist.\n *\n * Example:\n * ```ts\n * DictionaryKeys -> 'key1' | 'key2'\n * // or if IntlayerDictionaryTypesConnector is not defined,\n * DictionaryKeys -> string\n * ```\n */\nexport type DictionaryKeys = StringFallback<\n keyof IntlayerDictionaryTypesConnector\n>;\n\n/**\n * Represents the data type returned by the useIntlayer hook,\n * excluding the 'id' and 'filePath' keys from the dictionary content.\n */\nexport type DataFromDictionaryKey<\n T extends DictionaryKeys,\n K extends Locales,\n R extends boolean = false,\n> = DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content'], K, R>;\n\n/**\n * Type definition for the useIntlayer hook, which takes a dictionary ID and an optional locale,\n * and returns the deeply transformed dictionary content.\n *\n */\nexport type UseIntlayer = <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = false,\n>(\n key: T,\n locale?: L,\n isRenderEditor?: R\n) => DataFromDictionaryKey<T, L, R>;\n\nexport type UseIntlayerEditable = <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = true,\n>(\n key: T,\n locale?: L,\n isRenderEditor?: R\n) => DataFromDictionaryKey<T, L, R>;\n\nexport const getIntlayer: UseIntlayer = <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = false,\n>(\n key: T,\n locale?: L,\n isRenderEditor: R = false as R\n) => {\n const dictionary: Dictionary = dictionaries[key as keyof typeof dictionaries];\n\n if (!dictionary) {\n throw new Error(`Dictionary ${key} not found`, dictionaries);\n }\n\n const result = processDictionary(\n dictionary.content,\n dictionary.key,\n dictionary.filePath,\n [],\n locale\n );\n\n return recursiveTransformContent(\n result,\n isRenderEditor\n ) as DataFromDictionaryKey<T, L, R>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,gCAAyB;AAEzB,2BAGO;AACP,+BAAkC;AA2D3B,MAAM,cAA2B,CAKtC,KACA,QACA,iBAAoB,UACjB;AACH,QAAM,aAAyB,0BAAAA,QAAa,GAAgC;AAE5E,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,cAAc,GAAG,cAAc,0BAAAA,OAAY;AAAA,EAC7D;AAEA,QAAM,aAAS;AAAA,IACb,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX,CAAC;AAAA,IACD;AAAA,EACF;AAEA,aAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":["dictionaries"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var getIntlayerAsync_exports = {};
|
|
21
|
+
__export(getIntlayerAsync_exports, {
|
|
22
|
+
getIntlayerAsync: () => getIntlayerAsync
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(getIntlayerAsync_exports);
|
|
25
|
+
var import_fetchDistantDictionary = require('./distantDictionary/fetchDistantDictionary.cjs');
|
|
26
|
+
var import_getDictionary = require('./getDictionary.cjs');
|
|
27
|
+
const getIntlayerAsync = async (key, locale, isRenderEditor = true) => {
|
|
28
|
+
const jsonDistantDictionary = await (0, import_fetchDistantDictionary.fetchDistantDictionary)(key);
|
|
29
|
+
if (jsonDistantDictionary) {
|
|
30
|
+
return (0, import_getDictionary.getDictionary)(
|
|
31
|
+
jsonDistantDictionary,
|
|
32
|
+
locale,
|
|
33
|
+
isRenderEditor
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
};
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
getIntlayerAsync
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=getIntlayerAsync.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/getIntlayerAsync.ts"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport { DeclarationContent } from 'intlayer';\nimport { fetchDistantDictionary } from './distantDictionary/fetchDistantDictionary';\nimport { getDictionary } from './getDictionary';\nimport { DictionaryKeys, DataFromDictionaryKey } from './getIntlayer';\n\nexport type GetIntlayerAsync = <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = true,\n>(\n key: T,\n locale?: L,\n isRenderEditor?: R\n) => Promise<DataFromDictionaryKey<T, L, R> | null>;\n\n/**\n * On the client side, Hook that picking one dictionary by its key and return the content\n *\n * This hook will prerender the locale dictionary and fetch simultaneously the distant dictionaries to hydrate it.\n *\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const getIntlayerAsync: GetIntlayerAsync = async <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = true,\n>(\n key: T,\n locale?: L,\n isRenderEditor = true as R\n) => {\n const jsonDistantDictionary = await fetchDistantDictionary(key);\n\n if (jsonDistantDictionary) {\n return getDictionary(\n jsonDistantDictionary as unknown as DeclarationContent,\n locale,\n isRenderEditor\n ) as DataFromDictionaryKey<T, L, R>;\n }\n\n return null;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oCAAuC;AACvC,2BAA8B;AAqBvB,MAAM,mBAAqC,OAKhD,KACA,QACA,iBAAiB,SACd;AACH,QAAM,wBAAwB,UAAM,sDAAuB,GAAG;AAE9D,MAAI,uBAAuB;AACzB,eAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -29,6 +29,7 @@ __export(src_exports, {
|
|
|
29
29
|
t: () => import_client.t,
|
|
30
30
|
useDictionary: () => import_client.useDictionary,
|
|
31
31
|
useIntlayer: () => import_client.useIntlayer,
|
|
32
|
+
useIntlayerAsync: () => import_client.useIntlayerAsync,
|
|
32
33
|
useIntlayerContext: () => import_client.useIntlayerContext,
|
|
33
34
|
useLocale: () => import_client.useLocale,
|
|
34
35
|
useLocaleBase: () => import_client.useLocaleBase,
|
|
@@ -53,6 +54,7 @@ var import_getIntlayer = require('./getIntlayer.cjs');
|
|
|
53
54
|
t,
|
|
54
55
|
useDictionary,
|
|
55
56
|
useIntlayer,
|
|
57
|
+
useIntlayerAsync,
|
|
56
58
|
useIntlayerContext,
|
|
57
59
|
useLocale,
|
|
58
60
|
useLocaleBase,
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { getTranslation } from './getTranslation';\nexport {\n IntlayerProvider,\n type IntlayerProviderProps,\n IntlayerClientContext,\n useIntlayer,\n useDictionary,\n useLocale,\n useTraduction,\n useLocaleCookie,\n useIntlayerContext,\n localeCookie,\n setLocaleCookie,\n getBrowserLocale,\n useLocaleBase,\n t,\n} from './client/index';\nexport { getDictionary } from './getDictionary';\nexport { getIntlayer } from './getIntlayer';\nexport { type IntlayerNode } from './editor/renderContentEditor';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA+B;AAC/B,
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { getTranslation } from './getTranslation';\nexport {\n IntlayerProvider,\n type IntlayerProviderProps,\n IntlayerClientContext,\n useIntlayer,\n useIntlayerAsync,\n useDictionary,\n useLocale,\n useTraduction,\n useLocaleCookie,\n useIntlayerContext,\n localeCookie,\n setLocaleCookie,\n getBrowserLocale,\n useLocaleBase,\n t,\n} from './client/index';\nexport { getDictionary } from './getDictionary';\nexport { getIntlayer } from './getIntlayer';\nexport { type IntlayerNode } from './editor/renderContentEditor';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA+B;AAC/B,oBAgBO;AACP,2BAA8B;AAC9B,yBAA4B;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/processDictionary/contentDictionary.ts"],"sourcesContent":["import type { KeyPath, Locales } from '@intlayer/core';\nimport type { ReactNode } from 'react';\n\nexport type TransformedContentValue =\n | string\n | ReactNode\n | {\n [key: string]: TransformedContentValue;\n }\n | undefined\n | ((quantity: number) => TransformedContentValue);\n\nexport type TransformedContentObject = {\n
|
|
1
|
+
{"version":3,"sources":["../../../src/processDictionary/contentDictionary.ts"],"sourcesContent":["import type { KeyPath, Locales } from '@intlayer/core';\nimport type { ReactNode } from 'react';\n\nexport type TransformedContentValue =\n | string\n | ReactNode\n | {\n [key: string]: TransformedContentValue;\n }\n | undefined\n | ((quantity: number) => TransformedContentValue);\n\nexport type TransformedContentObject = {\n dictionaryKey: string;\n dictionaryPath: string;\n keyPath: KeyPath[];\n locale: Locales;\n content: TransformedContentValue | TransformedContentValue[] | undefined;\n};\n\nexport type TransformedContent =\n | Record<\n string,\n | TransformedContentValue\n | TransformedContentValue[]\n | TransformedContentObject\n | undefined\n >\n | ReactNode;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -30,7 +30,7 @@ var import_getTranslation = require('../getTranslation.cjs');
|
|
|
30
30
|
const {
|
|
31
31
|
internationalization: { defaultLocale }
|
|
32
32
|
} = (0, import_client.getConfiguration)();
|
|
33
|
-
const processTranslation = (languageContent, locale,
|
|
33
|
+
const processTranslation = (languageContent, locale, dictionaryKey, dictionaryPath, keyPath = []) => {
|
|
34
34
|
const translationResult = (0, import_getTranslation.getTranslation)(
|
|
35
35
|
languageContent,
|
|
36
36
|
locale
|
|
@@ -41,13 +41,13 @@ const processTranslation = (languageContent, locale, dictionaryId, dictionaryPat
|
|
|
41
41
|
];
|
|
42
42
|
return processDictionary(
|
|
43
43
|
translationResult,
|
|
44
|
-
|
|
44
|
+
dictionaryKey,
|
|
45
45
|
dictionaryPath,
|
|
46
46
|
resultKeyPath,
|
|
47
47
|
locale
|
|
48
48
|
);
|
|
49
49
|
};
|
|
50
|
-
const processEnumeration = (enumerationContent, locale,
|
|
50
|
+
const processEnumeration = (enumerationContent, locale, dictionaryKey, dictionaryPath, keyPath = []) => (quantity) => {
|
|
51
51
|
const enumerationResult = (0, import_getEnumeration.getEnumeration)(
|
|
52
52
|
enumerationContent,
|
|
53
53
|
quantity
|
|
@@ -62,20 +62,20 @@ const processEnumeration = (enumerationContent, locale, dictionaryId, dictionary
|
|
|
62
62
|
];
|
|
63
63
|
return processDictionary(
|
|
64
64
|
enumerationResult,
|
|
65
|
-
|
|
65
|
+
dictionaryKey,
|
|
66
66
|
dictionaryPath,
|
|
67
67
|
resultKeyPath,
|
|
68
68
|
locale
|
|
69
69
|
);
|
|
70
70
|
};
|
|
71
71
|
const isReactNode = (node) => typeof node?.key !== "undefined" && typeof node?.props !== "undefined";
|
|
72
|
-
const processNode = (field, locale,
|
|
72
|
+
const processNode = (field, locale, dictionaryKey, dictionaryPath, keyPath = []) => {
|
|
73
73
|
if (typeof field === "object") {
|
|
74
74
|
if (field.nodeType === import_core.NodeType.Translation) {
|
|
75
75
|
return processTranslation(
|
|
76
76
|
field[import_core.NodeType.Translation],
|
|
77
77
|
locale,
|
|
78
|
-
|
|
78
|
+
dictionaryKey,
|
|
79
79
|
dictionaryPath,
|
|
80
80
|
keyPath
|
|
81
81
|
);
|
|
@@ -84,7 +84,7 @@ const processNode = (field, locale, dictionaryId, dictionaryPath, keyPath = [])
|
|
|
84
84
|
return processEnumeration(
|
|
85
85
|
field[import_core.NodeType.Enumeration],
|
|
86
86
|
locale,
|
|
87
|
-
|
|
87
|
+
dictionaryKey,
|
|
88
88
|
dictionaryPath,
|
|
89
89
|
keyPath
|
|
90
90
|
);
|
|
@@ -93,7 +93,7 @@ const processNode = (field, locale, dictionaryId, dictionaryPath, keyPath = [])
|
|
|
93
93
|
return processDictionary(
|
|
94
94
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
95
95
|
field,
|
|
96
|
-
|
|
96
|
+
dictionaryKey,
|
|
97
97
|
dictionaryPath,
|
|
98
98
|
keyPath,
|
|
99
99
|
locale
|
|
@@ -125,7 +125,7 @@ const createReactElement = (element) => {
|
|
|
125
125
|
return (0, import_react.createElement)(type ?? "div", props, ...props.children);
|
|
126
126
|
};
|
|
127
127
|
const traceKeys = ["filePath", "nodeType"];
|
|
128
|
-
const processDictionary = (content,
|
|
128
|
+
const processDictionary = (content, dictionaryKey, dictionaryPath, keyPath = [], locale = defaultLocale) => {
|
|
129
129
|
if (isReactNode(content)) {
|
|
130
130
|
return createReactElement(
|
|
131
131
|
content
|
|
@@ -138,7 +138,7 @@ const processDictionary = (content, dictionaryId, dictionaryPath, keyPath = [],
|
|
|
138
138
|
return processNode(
|
|
139
139
|
content,
|
|
140
140
|
locale,
|
|
141
|
-
|
|
141
|
+
dictionaryKey,
|
|
142
142
|
dictionaryPath,
|
|
143
143
|
keyPath
|
|
144
144
|
);
|
|
@@ -151,7 +151,7 @@ const processDictionary = (content, dictionaryId, dictionaryPath, keyPath = [],
|
|
|
151
151
|
return processNode(
|
|
152
152
|
field,
|
|
153
153
|
locale,
|
|
154
|
-
|
|
154
|
+
dictionaryKey,
|
|
155
155
|
dictionaryPath,
|
|
156
156
|
resultKeyPath
|
|
157
157
|
);
|
|
@@ -170,7 +170,7 @@ const processDictionary = (content, dictionaryId, dictionaryPath, keyPath = [],
|
|
|
170
170
|
const nodeResult = processNode(
|
|
171
171
|
field,
|
|
172
172
|
locale,
|
|
173
|
-
|
|
173
|
+
dictionaryKey,
|
|
174
174
|
dictionaryPath,
|
|
175
175
|
resultKeyPath
|
|
176
176
|
);
|
|
@@ -182,7 +182,7 @@ const processDictionary = (content, dictionaryId, dictionaryPath, keyPath = [],
|
|
|
182
182
|
return {
|
|
183
183
|
content,
|
|
184
184
|
keyPath,
|
|
185
|
-
|
|
185
|
+
dictionaryKey,
|
|
186
186
|
dictionaryPath
|
|
187
187
|
};
|
|
188
188
|
};
|
|
@@ -1 +1 @@
|
|
|
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 findMatchingCondition,\n type KeyPath,\n type DictionaryValue,\n type TranslationContent,\n type EnumerationContent,\n type TypedNode,\n} from '@intlayer/core';\nimport { type ReactElement, createElement, type ReactNode } from 'react';\nimport { getEnumeration } from '../getEnumeration';\nimport { getTranslation } from '../getTranslation';\nimport type {\n TransformedContent,\n TransformedContentValue,\n} from './contentDictionary';\n\nconst {\n internationalization: { defaultLocale },\n} = getConfiguration();\n\nconst processTranslation = (\n languageContent: LanguageContent<DictionaryValue>,\n locale: Locales,\n dictionaryId: string,\n dictionaryPath?: string,\n keyPath: KeyPath[] = []\n): TransformedContent => {\n const translationResult: DictionaryValue = getTranslation<DictionaryValue>(\n languageContent,\n locale\n );\n\n const resultKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: locale },\n ];\n\n return processDictionary(\n translationResult,\n dictionaryId,\n dictionaryPath,\n resultKeyPath,\n locale\n );\n};\n\nconst processEnumeration =\n (\n enumerationContent: QuantityContent<DictionaryValue>,\n locale: Locales,\n dictionaryId: string,\n dictionaryPath?: string,\n keyPath: KeyPath[] = []\n ): TransformedContentValue =>\n (quantity: number): TransformedContentValue => {\n const enumerationResult: DictionaryValue = getEnumeration<DictionaryValue>(\n enumerationContent,\n quantity\n );\n\n const matchingCondition = findMatchingCondition(\n enumerationContent,\n quantity\n );\n\n const resultKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Enumeration, key: matchingCondition.toString() },\n ];\n\n return processDictionary(\n enumerationResult,\n dictionaryId,\n dictionaryPath,\n resultKeyPath,\n locale\n ) as TransformedContentValue;\n };\n\nconst isReactNode = (node: Record<string, unknown>): boolean =>\n typeof node?.key !== 'undefined' && typeof node?.props !== 'undefined';\n\nexport const processNode = (\n field: DictionaryValue | undefined,\n locale: Locales,\n dictionaryId: string,\n dictionaryPath?: string,\n keyPath: KeyPath[] = []\n): TransformedContentValue => {\n if (typeof field === 'object') {\n if (\n (field as TranslationContent<DictionaryValue>).nodeType ===\n NodeType.Translation\n ) {\n return processTranslation(\n field[\n NodeType.Translation as keyof typeof field\n ] as LanguageContent<DictionaryValue>,\n locale,\n dictionaryId,\n dictionaryPath,\n keyPath\n ) as TransformedContentValue;\n }\n\n if (\n (field as EnumerationContent<DictionaryValue>).nodeType ===\n NodeType.Enumeration\n ) {\n return processEnumeration(\n field[\n NodeType.Enumeration as keyof typeof field\n ] as QuantityContent<DictionaryValue>,\n locale,\n dictionaryId,\n dictionaryPath,\n keyPath\n );\n }\n }\n\n return processDictionary(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n field!,\n dictionaryId,\n dictionaryPath,\n keyPath,\n locale\n ) 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 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\nconst traceKeys: string[] = ['filePath', 'nodeType'];\n\n/**\n * Function that process a dictionary and return the result to be used in the application.\n */\nexport const processDictionary = (\n content: DictionaryValue,\n dictionaryId: string,\n dictionaryPath?: string,\n keyPath: KeyPath[] = [],\n locale: Locales = defaultLocale\n // eslint-disable-next-line sonarjs/cognitive-complexity\n): TransformedContent => {\n // If it's a React element, render it\n if (isReactNode(content as Record<string, unknown>)) {\n return createReactElement(\n content as unknown as ReactElement\n ) as unknown as TransformedContent;\n }\n\n if (content && typeof content === 'object') {\n const isArray = Array.isArray(content);\n\n let result: TransformedContent = {};\n\n if (typeof (content as TypedNode).nodeType !== 'undefined') {\n return processNode(\n content as DictionaryValue,\n locale,\n dictionaryId,\n dictionaryPath,\n keyPath\n ) as TransformedContent;\n } else if (isArray) {\n // Eslint fix because promises are awaited during build stage\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n result = (content as DictionaryValue[]).map((field, key) => {\n const resultKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key },\n ];\n\n return processNode(\n field,\n locale,\n dictionaryId,\n dictionaryPath,\n resultKeyPath\n );\n }) as TransformedContent;\n } else {\n // List each key in the content and process it\n for (const key of Object.keys(content)) {\n const field = content[key as keyof typeof content];\n\n if (traceKeys.includes(key)) {\n result[key] = field as TransformedContentValue;\n continue;\n }\n\n const resultKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n\n const nodeResult = processNode(\n field,\n locale,\n dictionaryId,\n dictionaryPath,\n resultKeyPath\n );\n\n result[key] = nodeResult;\n }\n }\n\n return result;\n }\n\n return {\n content: content as TransformedContentValue,\n keyPath,\n dictionaryId,\n dictionaryPath,\n };\n};\n"],"mappings":"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","names":["element"]}
|
|
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 findMatchingCondition,\n type KeyPath,\n type DictionaryValue,\n type TranslationContent,\n type EnumerationContent,\n type TypedNode,\n} from '@intlayer/core';\nimport { type ReactElement, createElement, type ReactNode } from 'react';\nimport { getEnumeration } from '../getEnumeration';\nimport { getTranslation } from '../getTranslation';\nimport type {\n TransformedContent,\n TransformedContentValue,\n} from './contentDictionary';\n\nconst {\n internationalization: { defaultLocale },\n} = getConfiguration();\n\nconst processTranslation = (\n languageContent: LanguageContent<DictionaryValue>,\n locale: Locales,\n dictionaryKey: string,\n dictionaryPath?: string,\n keyPath: KeyPath[] = []\n): TransformedContent => {\n const translationResult: DictionaryValue = getTranslation<DictionaryValue>(\n languageContent,\n locale\n );\n\n const resultKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: locale },\n ];\n\n return processDictionary(\n translationResult,\n dictionaryKey,\n dictionaryPath,\n resultKeyPath,\n locale\n );\n};\n\nconst processEnumeration =\n (\n enumerationContent: QuantityContent<DictionaryValue>,\n locale: Locales,\n dictionaryKey: string,\n dictionaryPath?: string,\n keyPath: KeyPath[] = []\n ): TransformedContentValue =>\n (quantity: number): TransformedContentValue => {\n const enumerationResult: DictionaryValue = getEnumeration<DictionaryValue>(\n enumerationContent,\n quantity\n );\n\n const matchingCondition = findMatchingCondition(\n enumerationContent,\n quantity\n );\n\n const resultKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Enumeration, key: matchingCondition.toString() },\n ];\n\n return processDictionary(\n enumerationResult,\n dictionaryKey,\n dictionaryPath,\n resultKeyPath,\n locale\n ) as TransformedContentValue;\n };\n\nconst isReactNode = (node: Record<string, unknown>): boolean =>\n typeof node?.key !== 'undefined' && typeof node?.props !== 'undefined';\n\nexport const processNode = (\n field: DictionaryValue | undefined,\n locale: Locales,\n dictionaryKey: string,\n dictionaryPath?: string,\n keyPath: KeyPath[] = []\n): TransformedContentValue => {\n if (typeof field === 'object') {\n if (\n (field as TranslationContent<DictionaryValue>).nodeType ===\n NodeType.Translation\n ) {\n return processTranslation(\n field[\n NodeType.Translation as keyof typeof field\n ] as LanguageContent<DictionaryValue>,\n locale,\n dictionaryKey,\n dictionaryPath,\n keyPath\n ) as TransformedContentValue;\n }\n\n if (\n (field as EnumerationContent<DictionaryValue>).nodeType ===\n NodeType.Enumeration\n ) {\n return processEnumeration(\n field[\n NodeType.Enumeration as keyof typeof field\n ] as QuantityContent<DictionaryValue>,\n locale,\n dictionaryKey,\n dictionaryPath,\n keyPath\n );\n }\n }\n\n return processDictionary(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n field!,\n dictionaryKey,\n dictionaryPath,\n keyPath,\n locale\n ) 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 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\nconst traceKeys: string[] = ['filePath', 'nodeType'];\n\n/**\n * Function that process a dictionary and return the result to be used in the application.\n */\nexport const processDictionary = (\n content: DictionaryValue,\n dictionaryKey: string,\n dictionaryPath?: string,\n keyPath: KeyPath[] = [],\n locale: Locales = defaultLocale\n): TransformedContent => {\n // If it's a React element, render it\n if (isReactNode(content as Record<string, unknown>)) {\n return createReactElement(\n content as unknown as ReactElement\n ) as unknown as TransformedContent;\n }\n\n if (content && typeof content === 'object') {\n const isArray = Array.isArray(content);\n\n let result: TransformedContent = {};\n\n if (typeof (content as TypedNode).nodeType !== 'undefined') {\n return processNode(\n content as DictionaryValue,\n locale,\n dictionaryKey,\n dictionaryPath,\n keyPath\n ) as TransformedContent;\n } else if (isArray) {\n // Eslint fix because promises are awaited during build stage\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n result = (content as DictionaryValue[]).map((field, key) => {\n const resultKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key },\n ];\n\n return processNode(\n field,\n locale,\n dictionaryKey,\n dictionaryPath,\n resultKeyPath\n );\n }) as TransformedContent;\n } else {\n // List each key in the content and process it\n for (const key of Object.keys(content)) {\n const field = content[key as keyof typeof content];\n\n if (traceKeys.includes(key)) {\n result[key] = field as TransformedContentValue;\n continue;\n }\n\n const resultKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n\n const nodeResult = processNode(\n field,\n locale,\n dictionaryKey,\n dictionaryPath,\n resultKeyPath\n );\n\n result[key] = nodeResult;\n }\n }\n\n return result;\n }\n\n return {\n content: content as TransformedContentValue,\n keyPath,\n dictionaryKey,\n dictionaryPath,\n };\n};\n"],"mappings":"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","names":["element"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var PoweredByMeta_exports = {};
|
|
21
|
+
__export(PoweredByMeta_exports, {
|
|
22
|
+
PoweredByMeta: () => PoweredByMeta
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(PoweredByMeta_exports);
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
const PoweredByMeta = () => {
|
|
27
|
+
if (process.env.NODE_ENV !== "production") return null;
|
|
28
|
+
(0, import_react.useEffect)(() => {
|
|
29
|
+
const metaTag = document.createElement("meta");
|
|
30
|
+
metaTag.name = "content-powered-by";
|
|
31
|
+
metaTag.content = "Intlayer - https://intlayer.org";
|
|
32
|
+
document.head.appendChild(metaTag);
|
|
33
|
+
}, []);
|
|
34
|
+
return null;
|
|
35
|
+
};
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
PoweredByMeta
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=index.cjs.map
|