react-intlayer 4.1.10 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cjs/{getEnumeration.cjs → IntlayerNode.cjs} +14 -13
- package/dist/cjs/IntlayerNode.cjs.map +1 -0
- package/dist/cjs/UI/ContentSelector.cjs.map +1 -1
- package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
- package/dist/cjs/client/index.cjs +2 -5
- package/dist/cjs/client/index.cjs.map +1 -1
- package/dist/cjs/client/t.cjs +2 -2
- package/dist/cjs/client/t.cjs.map +1 -1
- package/dist/cjs/client/useContent.cjs +2 -2
- package/dist/cjs/client/useContent.cjs.map +1 -1
- package/dist/cjs/client/useDictionary.cjs +3 -3
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs +7 -4
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useIntlayerAsync.cjs +3 -4
- package/dist/cjs/client/useIntlayerAsync.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs +1 -1
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocaleCookie.cjs.map +1 -1
- package/dist/cjs/client/useTraduction.cjs +5 -5
- package/dist/cjs/client/useTraduction.cjs.map +1 -1
- package/dist/cjs/editor/ContentSelectorWrapper.cjs +1 -3
- package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -1
- package/dist/cjs/editor/IntlayerEditorProvider.cjs +3 -1
- package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +1 -1
- package/dist/cjs/editor/renderContentEditor.cjs +5 -4
- package/dist/cjs/editor/renderContentEditor.cjs.map +1 -1
- package/dist/cjs/getDictionary.cjs +13 -13
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs +10 -29
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/index.cjs +5 -13
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/{getIntlayerAsync.cjs → markdown/MarkdownProvider.cjs} +18 -19
- package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -0
- package/dist/cjs/{server/useTraduction.cjs → markdown/MarkdownRenderer.cjs} +17 -12
- package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -0
- package/dist/cjs/markdown/index.cjs +27 -0
- package/dist/cjs/markdown/index.cjs.map +1 -0
- package/dist/cjs/{getTranslation.cjs → markdown/renderMarkdown.cjs} +13 -16
- package/dist/cjs/markdown/renderMarkdown.cjs.map +1 -0
- package/dist/cjs/plugins.cjs +85 -0
- package/dist/cjs/plugins.cjs.map +1 -0
- package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -1
- package/dist/cjs/server/index.cjs +2 -8
- package/dist/cjs/server/index.cjs.map +1 -1
- package/dist/cjs/server/t.cjs +5 -3
- package/dist/cjs/server/t.cjs.map +1 -1
- package/dist/cjs/server/useDictionary.cjs +2 -2
- package/dist/cjs/server/useDictionary.cjs.map +1 -1
- package/dist/cjs/server/useIntlayer.cjs +2 -2
- package/dist/cjs/server/useIntlayer.cjs.map +1 -1
- package/dist/esm/IntlayerNode.mjs +16 -0
- package/dist/esm/IntlayerNode.mjs.map +1 -0
- package/dist/esm/UI/ContentSelector.mjs.map +1 -1
- package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
- package/dist/esm/client/index.mjs +1 -3
- package/dist/esm/client/index.mjs.map +1 -1
- package/dist/esm/client/t.mjs +1 -1
- package/dist/esm/client/t.mjs.map +1 -1
- package/dist/esm/client/useContent.mjs +3 -3
- package/dist/esm/client/useContent.mjs.map +1 -1
- package/dist/esm/client/useDictionary.mjs +3 -3
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs +8 -7
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useIntlayerAsync.mjs +5 -5
- package/dist/esm/client/useIntlayerAsync.mjs.map +1 -1
- package/dist/esm/client/useLocale.mjs +1 -1
- package/dist/esm/client/useLocale.mjs.map +1 -1
- package/dist/esm/client/useLocaleCookie.mjs.map +1 -1
- package/dist/esm/client/useTraduction.mjs +3 -3
- package/dist/esm/client/useTraduction.mjs.map +1 -1
- package/dist/esm/editor/ContentSelectorWrapper.mjs +1 -3
- package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -1
- package/dist/esm/editor/IntlayerEditorProvider.mjs +3 -1
- package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -1
- package/dist/esm/editor/renderContentEditor.mjs +5 -4
- package/dist/esm/editor/renderContentEditor.mjs.map +1 -1
- package/dist/esm/getDictionary.mjs +18 -14
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs +15 -20
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/esm/index.mjs +3 -9
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/markdown/MarkdownProvider.mjs +19 -0
- package/dist/esm/markdown/MarkdownProvider.mjs.map +1 -0
- package/dist/esm/markdown/MarkdownRenderer.mjs +16 -0
- package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -0
- package/dist/esm/markdown/index.mjs +4 -0
- package/dist/esm/markdown/index.mjs.map +1 -0
- package/dist/esm/markdown/renderMarkdown.mjs +11 -0
- package/dist/esm/markdown/renderMarkdown.mjs.map +1 -0
- package/dist/esm/plugins.mjs +61 -0
- package/dist/esm/plugins.mjs.map +1 -0
- package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
- package/dist/esm/server/index.mjs +1 -5
- package/dist/esm/server/index.mjs.map +1 -1
- package/dist/esm/server/t.mjs +4 -2
- package/dist/esm/server/t.mjs.map +1 -1
- package/dist/esm/server/useDictionary.mjs +2 -2
- package/dist/esm/server/useDictionary.mjs.map +1 -1
- package/dist/esm/server/useIntlayer.mjs +2 -4
- package/dist/esm/server/useIntlayer.mjs.map +1 -1
- package/dist/types/IntlayerNode.d.ts +9 -0
- package/dist/types/IntlayerNode.d.ts.map +1 -0
- package/dist/types/UI/ContentSelector.d.ts +1 -1
- package/dist/types/UI/ContentSelector.d.ts.map +1 -1
- package/dist/types/client/IntlayerProvider.d.ts +4 -4
- package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +0 -1
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/client/t.d.ts +1 -1
- package/dist/types/client/t.d.ts.map +1 -1
- package/dist/types/client/useContent.d.ts +1 -1
- package/dist/types/client/useDictionary.d.ts +3 -2
- package/dist/types/client/useDictionary.d.ts.map +1 -1
- package/dist/types/client/useIntlayer.d.ts +4 -2
- package/dist/types/client/useIntlayer.d.ts.map +1 -1
- package/dist/types/client/useIntlayerAsync.d.ts +4 -5
- package/dist/types/client/useIntlayerAsync.d.ts.map +1 -1
- package/dist/types/client/useLocale.d.ts +3 -3
- package/dist/types/client/useLocale.d.ts.map +1 -1
- package/dist/types/client/useLocaleBase.d.ts +2 -2
- package/dist/types/client/useLocaleCookie.d.ts +4 -4
- package/dist/types/client/useLocaleCookie.d.ts.map +1 -1
- package/dist/types/client/useTraduction.d.ts +3 -3
- package/dist/types/client/useTraduction.d.ts.map +1 -1
- package/dist/types/editor/ContentSelectorWrapper.d.ts +2 -8
- 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 +3 -7
- package/dist/types/editor/renderContentEditor.d.ts.map +1 -1
- package/dist/types/getDictionary.d.ts +4 -12
- package/dist/types/getDictionary.d.ts.map +1 -1
- package/dist/types/getIntlayer.d.ts +4 -34
- package/dist/types/getIntlayer.d.ts.map +1 -1
- package/dist/types/index.d.ts +8 -5
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownProvider.d.ts +9 -0
- package/dist/types/markdown/MarkdownProvider.d.ts.map +1 -0
- package/dist/types/markdown/MarkdownRenderer.d.ts +5 -0
- package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -0
- package/dist/types/markdown/index.d.ts +4 -0
- package/dist/types/markdown/index.d.ts.map +1 -0
- package/dist/types/markdown/renderMarkdown.d.ts +3 -0
- package/dist/types/markdown/renderMarkdown.d.ts.map +1 -0
- package/dist/types/plugins.d.ts +48 -0
- package/dist/types/plugins.d.ts.map +1 -0
- package/dist/types/server/IntlayerServerProvider.d.ts +7 -7
- package/dist/types/server/IntlayerServerProvider.d.ts.map +1 -1
- package/dist/types/server/index.d.ts +0 -2
- package/dist/types/server/index.d.ts.map +1 -1
- package/dist/types/server/t.d.ts +20 -4
- package/dist/types/server/t.d.ts.map +1 -1
- package/dist/types/server/useDictionary.d.ts +3 -2
- package/dist/types/server/useDictionary.d.ts.map +1 -1
- package/dist/types/server/useIntlayer.d.ts +3 -2
- package/dist/types/server/useIntlayer.d.ts.map +1 -1
- package/package.json +16 -16
- package/dist/cjs/getEnumeration.cjs.map +0 -1
- package/dist/cjs/getIntlayerAsync.cjs.map +0 -1
- package/dist/cjs/getTranslation.cjs.map +0 -1
- package/dist/cjs/processDictionary/contentDictionary.cjs +0 -17
- package/dist/cjs/processDictionary/contentDictionary.cjs.map +0 -1
- package/dist/cjs/processDictionary/index.cjs +0 -201
- package/dist/cjs/processDictionary/index.cjs.map +0 -1
- package/dist/cjs/recursiveTransformContent.cjs +0 -54
- package/dist/cjs/recursiveTransformContent.cjs.map +0 -1
- package/dist/cjs/server/getLocaleTranslation.cjs +0 -43
- package/dist/cjs/server/getLocaleTranslation.cjs.map +0 -1
- package/dist/cjs/server/useTraduction.cjs.map +0 -1
- package/dist/esm/getEnumeration.mjs +0 -12
- package/dist/esm/getEnumeration.mjs.map +0 -1
- package/dist/esm/getIntlayerAsync.mjs +0 -18
- package/dist/esm/getIntlayerAsync.mjs.map +0 -1
- package/dist/esm/getTranslation.mjs +0 -14
- package/dist/esm/getTranslation.mjs.map +0 -1
- package/dist/esm/processDictionary/contentDictionary.mjs +0 -1
- package/dist/esm/processDictionary/contentDictionary.mjs.map +0 -1
- package/dist/esm/processDictionary/index.mjs +0 -179
- package/dist/esm/processDictionary/index.mjs.map +0 -1
- package/dist/esm/recursiveTransformContent.mjs +0 -32
- package/dist/esm/recursiveTransformContent.mjs.map +0 -1
- package/dist/esm/server/getLocaleTranslation.mjs +0 -19
- package/dist/esm/server/getLocaleTranslation.mjs.map +0 -1
- package/dist/esm/server/useTraduction.mjs +0 -11
- package/dist/esm/server/useTraduction.mjs.map +0 -1
- package/dist/types/getEnumeration.d.ts +0 -31
- package/dist/types/getEnumeration.d.ts.map +0 -1
- package/dist/types/getIntlayerAsync.d.ts +0 -13
- package/dist/types/getIntlayerAsync.d.ts.map +0 -1
- package/dist/types/getTranslation.d.ts +0 -25
- package/dist/types/getTranslation.d.ts.map +0 -1
- package/dist/types/processDictionary/contentDictionary.d.ts +0 -14
- package/dist/types/processDictionary/contentDictionary.d.ts.map +0 -1
- package/dist/types/processDictionary/index.d.ts +0 -9
- package/dist/types/processDictionary/index.d.ts.map +0 -1
- package/dist/types/recursiveTransformContent.d.ts +0 -27
- package/dist/types/recursiveTransformContent.d.ts.map +0 -1
- package/dist/types/server/getLocaleTranslation.d.ts +0 -9
- package/dist/types/server/getLocaleTranslation.d.ts.map +0 -1
- package/dist/types/server/useTraduction.d.ts +0 -24
- package/dist/types/server/useTraduction.d.ts.map +0 -1
|
@@ -1,54 +0,0 @@
|
|
|
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 recursiveTransformContent_exports = {};
|
|
20
|
-
__export(recursiveTransformContent_exports, {
|
|
21
|
-
recursiveTransformContent: () => recursiveTransformContent
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(recursiveTransformContent_exports);
|
|
24
|
-
var import_react = require("react");
|
|
25
|
-
var import_renderContentEditor = require('./editor/renderContentEditor.cjs');
|
|
26
|
-
const recursiveTransformContent = (value, isRenderEditor = false) => {
|
|
27
|
-
if (typeof value === "function") {
|
|
28
|
-
return (props) => recursiveTransformContent(value(props), isRenderEditor);
|
|
29
|
-
} else if (typeof value === "object") {
|
|
30
|
-
if (typeof value.dictionaryKey !== "undefined") {
|
|
31
|
-
if (isRenderEditor) {
|
|
32
|
-
return (0, import_renderContentEditor.renderIntlayerEditor)(value);
|
|
33
|
-
}
|
|
34
|
-
return value.content;
|
|
35
|
-
} else if (Array.isArray(value)) {
|
|
36
|
-
return value.map((el) => recursiveTransformContent(el, isRenderEditor));
|
|
37
|
-
} else if ((0, import_react.isValidElement)(value)) {
|
|
38
|
-
return value;
|
|
39
|
-
}
|
|
40
|
-
return Object.entries(value).reduce(
|
|
41
|
-
(acc, [key, value2]) => ({
|
|
42
|
-
...acc,
|
|
43
|
-
[key]: recursiveTransformContent(value2, isRenderEditor)
|
|
44
|
-
}),
|
|
45
|
-
{}
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
return value;
|
|
49
|
-
};
|
|
50
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
-
0 && (module.exports = {
|
|
52
|
-
recursiveTransformContent
|
|
53
|
-
});
|
|
54
|
-
//# sourceMappingURL=recursiveTransformContent.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/recursiveTransformContent.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Locales } from '@intlayer/config';\nimport type { NodeType } from '@intlayer/core';\nimport { isValidElement, type ReactNode } from 'react';\nimport {\n type IntlayerNode,\n renderIntlayerEditor,\n} from './editor/renderContentEditor';\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"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA+C;AAC/C,iCAGO;AAyCA,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;","names":["value"]}
|
|
@@ -1,43 +0,0 @@
|
|
|
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 getLocaleTranslation_exports = {};
|
|
20
|
-
__export(getLocaleTranslation_exports, {
|
|
21
|
-
getLocaleTranslation: () => getLocaleTranslation
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(getLocaleTranslation_exports);
|
|
24
|
-
var import_client = require("@intlayer/config/client");
|
|
25
|
-
var import_core = require("@intlayer/core");
|
|
26
|
-
var import_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
|
|
27
|
-
var import_serverContext = require('./serverContext.cjs');
|
|
28
|
-
const getLocaleTranslation = (languageContent) => {
|
|
29
|
-
const locale = (0, import_serverContext.getServerContext)(import_IntlayerServerProvider.IntlayerServerContext);
|
|
30
|
-
const content = (0, import_core.getTranslationContent)(
|
|
31
|
-
languageContent,
|
|
32
|
-
locale ?? (0, import_client.getConfiguration)().internationalization.defaultLocale
|
|
33
|
-
);
|
|
34
|
-
return {
|
|
35
|
-
locale,
|
|
36
|
-
content
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
-
0 && (module.exports = {
|
|
41
|
-
getLocaleTranslation
|
|
42
|
-
});
|
|
43
|
-
//# sourceMappingURL=getLocaleTranslation.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/useTraduction.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport type { LanguageContent } from '@intlayer/core';\nimport { getTranslation } from '../getTranslation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, hook to get the translation content based on the locale\n *\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```ts\n * const content = useTraduction<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const useTraduction = <Content = string>(\n languageContent: LanguageContent<Content>\n) => {\n const locale = getServerContext<Locales>(IntlayerServerContext);\n\n return getTranslation(languageContent, locale);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,4BAA+B;AAC/B,oCAAsC;AACtC,2BAAiC;AAuB1B,MAAM,gBAAgB,CAC3B,oBACG;AACH,QAAM,aAAS,uCAA0B,mDAAqB;AAE9D,aAAO,sCAAe,iBAAiB,MAAM;AAC/C;","names":[]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { getEnumerationContent } from "@intlayer/core";
|
|
2
|
-
const getEnumeration = (enumerationContent, quantity) => {
|
|
3
|
-
const result = getEnumerationContent(
|
|
4
|
-
enumerationContent,
|
|
5
|
-
quantity
|
|
6
|
-
);
|
|
7
|
-
return result;
|
|
8
|
-
};
|
|
9
|
-
export {
|
|
10
|
-
getEnumeration
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=getEnumeration.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getEnumeration.ts"],"sourcesContent":["import { type QuantityContent, getEnumerationContent } from '@intlayer/core';\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 return result;\n};\n"],"mappings":"AAAA,SAA+B,6BAA6B;AA8BrD,MAAM,iBAAiB,CAC5B,oBACA,aACY;AACZ,QAAM,SAAkB;AAAA,IACtB;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { fetchDistantDictionary } from "@intlayer/api";
|
|
3
|
-
import { getDictionary } from "./getDictionary.mjs";
|
|
4
|
-
const getIntlayerAsync = async (key, locale, isRenderEditor = true) => {
|
|
5
|
-
const jsonDistantDictionary = await fetchDistantDictionary(key);
|
|
6
|
-
if (jsonDistantDictionary) {
|
|
7
|
-
return getDictionary(
|
|
8
|
-
jsonDistantDictionary,
|
|
9
|
-
locale,
|
|
10
|
-
isRenderEditor
|
|
11
|
-
);
|
|
12
|
-
}
|
|
13
|
-
return null;
|
|
14
|
-
};
|
|
15
|
-
export {
|
|
16
|
-
getIntlayerAsync
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=getIntlayerAsync.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getIntlayerAsync.ts"],"sourcesContent":["'use client';\n\nimport { fetchDistantDictionary } from '@intlayer/api';\nimport type { Locales } from '@intlayer/config/client';\nimport { DeclarationContent } from 'intlayer';\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":";AAEA,SAAS,8BAA8B;AAGvC,SAAS,qBAAqB;AAqBvB,MAAM,mBAAqC,OAKhD,KACA,QACA,iBAAiB,SACd;AACH,QAAM,wBAAwB,MAAM,uBAAuB,GAAG;AAE9D,MAAI,uBAAuB;AACzB,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { getConfiguration } from "@intlayer/config/client";
|
|
2
|
-
import { getTranslationContent } from "@intlayer/core";
|
|
3
|
-
const getTranslation = (languageContent, locale) => {
|
|
4
|
-
const { defaultLocale } = getConfiguration().internationalization;
|
|
5
|
-
const result = getTranslationContent(
|
|
6
|
-
languageContent,
|
|
7
|
-
locale ?? defaultLocale
|
|
8
|
-
);
|
|
9
|
-
return result;
|
|
10
|
-
};
|
|
11
|
-
export {
|
|
12
|
-
getTranslation
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=getTranslation.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getTranslation.ts"],"sourcesContent":["import { type Locales, getConfiguration } from '@intlayer/config/client';\nimport { type LanguageContent, getTranslationContent } from '@intlayer/core';\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 return result;\n};\n"],"mappings":"AAAA,SAAuB,wBAAwB;AAC/C,SAA+B,6BAA6B;AAuBrD,MAAM,iBAAiB,CAC5B,iBACA,WACY;AACZ,QAAM,EAAE,cAAc,IAAI,iBAAiB,EAAE;AAE7C,QAAM,SAAkB;AAAA,IACtB;AAAA,IACA,UAAU;AAAA,EACZ;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=contentDictionary.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { getConfiguration } from "@intlayer/config/client";
|
|
2
|
-
import {
|
|
3
|
-
NodeType,
|
|
4
|
-
findMatchingCondition
|
|
5
|
-
} from "@intlayer/core";
|
|
6
|
-
import { createElement } from "react";
|
|
7
|
-
import { getEnumeration } from "../getEnumeration.mjs";
|
|
8
|
-
import { getTranslation } from "../getTranslation.mjs";
|
|
9
|
-
const {
|
|
10
|
-
internationalization: { defaultLocale }
|
|
11
|
-
} = getConfiguration();
|
|
12
|
-
const processTranslation = (languageContent, locale, dictionaryKey, dictionaryPath, keyPath = []) => {
|
|
13
|
-
const translationResult = getTranslation(
|
|
14
|
-
languageContent,
|
|
15
|
-
locale
|
|
16
|
-
);
|
|
17
|
-
const resultKeyPath = [
|
|
18
|
-
...keyPath,
|
|
19
|
-
{ type: NodeType.Translation, key: locale }
|
|
20
|
-
];
|
|
21
|
-
return processDictionary(
|
|
22
|
-
translationResult,
|
|
23
|
-
dictionaryKey,
|
|
24
|
-
dictionaryPath,
|
|
25
|
-
resultKeyPath,
|
|
26
|
-
locale
|
|
27
|
-
);
|
|
28
|
-
};
|
|
29
|
-
const processEnumeration = (enumerationContent, locale, dictionaryKey, dictionaryPath, keyPath = []) => (quantity) => {
|
|
30
|
-
const enumerationResult = getEnumeration(
|
|
31
|
-
enumerationContent,
|
|
32
|
-
quantity
|
|
33
|
-
);
|
|
34
|
-
const matchingCondition = findMatchingCondition(
|
|
35
|
-
enumerationContent,
|
|
36
|
-
quantity
|
|
37
|
-
);
|
|
38
|
-
const resultKeyPath = [
|
|
39
|
-
...keyPath,
|
|
40
|
-
{ type: NodeType.Enumeration, key: matchingCondition.toString() }
|
|
41
|
-
];
|
|
42
|
-
return processDictionary(
|
|
43
|
-
enumerationResult,
|
|
44
|
-
dictionaryKey,
|
|
45
|
-
dictionaryPath,
|
|
46
|
-
resultKeyPath,
|
|
47
|
-
locale
|
|
48
|
-
);
|
|
49
|
-
};
|
|
50
|
-
const isReactNode = (node) => typeof node?.key !== "undefined" && typeof node?.props !== "undefined";
|
|
51
|
-
const processNode = (field, locale, dictionaryKey, dictionaryPath, keyPath = []) => {
|
|
52
|
-
if (typeof field === "object") {
|
|
53
|
-
if (field.nodeType === NodeType.Translation) {
|
|
54
|
-
return processTranslation(
|
|
55
|
-
field[NodeType.Translation],
|
|
56
|
-
locale,
|
|
57
|
-
dictionaryKey,
|
|
58
|
-
dictionaryPath,
|
|
59
|
-
keyPath
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
if (field.nodeType === NodeType.Enumeration) {
|
|
63
|
-
return processEnumeration(
|
|
64
|
-
field[NodeType.Enumeration],
|
|
65
|
-
locale,
|
|
66
|
-
dictionaryKey,
|
|
67
|
-
dictionaryPath,
|
|
68
|
-
keyPath
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return processDictionary(
|
|
73
|
-
field,
|
|
74
|
-
dictionaryKey,
|
|
75
|
-
dictionaryPath,
|
|
76
|
-
keyPath,
|
|
77
|
-
locale
|
|
78
|
-
);
|
|
79
|
-
};
|
|
80
|
-
const createReactElement = (element) => {
|
|
81
|
-
if (typeof element === "string") {
|
|
82
|
-
return element;
|
|
83
|
-
}
|
|
84
|
-
const convertChildrenAsArray = (element2) => {
|
|
85
|
-
if (element2?.props && typeof element2.props.children === "object") {
|
|
86
|
-
const childrenResult = [];
|
|
87
|
-
const { children } = element2.props;
|
|
88
|
-
Object.keys(children ?? {}).forEach((key) => {
|
|
89
|
-
childrenResult.push(
|
|
90
|
-
createReactElement((children ?? {})[key])
|
|
91
|
-
);
|
|
92
|
-
});
|
|
93
|
-
return {
|
|
94
|
-
...element2,
|
|
95
|
-
props: { ...element2.props, children: childrenResult }
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
return {
|
|
99
|
-
...element2,
|
|
100
|
-
props: { ...element2.props, children: element2.props.children }
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
const fixedElement = convertChildrenAsArray(
|
|
104
|
-
element
|
|
105
|
-
);
|
|
106
|
-
const { type, props } = fixedElement;
|
|
107
|
-
return createElement(
|
|
108
|
-
type ?? "div",
|
|
109
|
-
props,
|
|
110
|
-
...props.children
|
|
111
|
-
);
|
|
112
|
-
};
|
|
113
|
-
const traceKeys = ["filePath", "nodeType"];
|
|
114
|
-
const processDictionary = (content, dictionaryKey, dictionaryPath, keyPath = [], locale = defaultLocale) => {
|
|
115
|
-
if (isReactNode(content)) {
|
|
116
|
-
return createReactElement(
|
|
117
|
-
content
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
if (content && typeof content === "object") {
|
|
121
|
-
const isArray = Array.isArray(content);
|
|
122
|
-
let result = {};
|
|
123
|
-
if (typeof content.nodeType !== "undefined") {
|
|
124
|
-
return processNode(
|
|
125
|
-
content,
|
|
126
|
-
locale,
|
|
127
|
-
dictionaryKey,
|
|
128
|
-
dictionaryPath,
|
|
129
|
-
keyPath
|
|
130
|
-
);
|
|
131
|
-
} else if (isArray) {
|
|
132
|
-
result = content.map((field, key) => {
|
|
133
|
-
const resultKeyPath = [
|
|
134
|
-
...keyPath,
|
|
135
|
-
{ type: NodeType.Array, key }
|
|
136
|
-
];
|
|
137
|
-
return processNode(
|
|
138
|
-
field,
|
|
139
|
-
locale,
|
|
140
|
-
dictionaryKey,
|
|
141
|
-
dictionaryPath,
|
|
142
|
-
resultKeyPath
|
|
143
|
-
);
|
|
144
|
-
});
|
|
145
|
-
} else {
|
|
146
|
-
for (const key of Object.keys(content)) {
|
|
147
|
-
const field = content[key];
|
|
148
|
-
if (traceKeys.includes(key)) {
|
|
149
|
-
result[key] = field;
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
const resultKeyPath = [
|
|
153
|
-
...keyPath,
|
|
154
|
-
{ type: NodeType.Object, key }
|
|
155
|
-
];
|
|
156
|
-
const nodeResult = processNode(
|
|
157
|
-
field,
|
|
158
|
-
locale,
|
|
159
|
-
dictionaryKey,
|
|
160
|
-
dictionaryPath,
|
|
161
|
-
resultKeyPath
|
|
162
|
-
);
|
|
163
|
-
result[key] = nodeResult;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return result;
|
|
167
|
-
}
|
|
168
|
-
return {
|
|
169
|
-
content,
|
|
170
|
-
keyPath,
|
|
171
|
-
dictionaryKey,
|
|
172
|
-
dictionaryPath
|
|
173
|
-
};
|
|
174
|
-
};
|
|
175
|
-
export {
|
|
176
|
-
processDictionary,
|
|
177
|
-
processNode
|
|
178
|
-
};
|
|
179
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/processDictionary/index.ts"],"sourcesContent":["import { 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, JSX } 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 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 = (\n element: ReactElement<{ children?: ReactNode }>\n ): ReactElement<{ children?: ReactNode }> => {\n if (element?.props && typeof element.props.children === 'object') {\n const childrenResult: ReactNode[] = [];\n const { children } = element.props;\n\n // Create the children elements recursively, if any\n Object.keys(children ?? {}).forEach((key) => {\n childrenResult.push(\n createReactElement((children ?? {})[key as keyof typeof children])\n );\n });\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: element.props.children },\n };\n };\n\n const fixedElement = convertChildrenAsArray(\n element as ReactElement<{ children?: ReactNode }>\n );\n\n const { type, props } = fixedElement;\n\n // Create and return the React element\n return createElement(\n type ?? 'div',\n props,\n ...(props.children as ReactNode[])\n );\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\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"]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { isValidElement } from "react";
|
|
2
|
-
import {
|
|
3
|
-
renderIntlayerEditor
|
|
4
|
-
} from "./editor/renderContentEditor.mjs";
|
|
5
|
-
const recursiveTransformContent = (value, isRenderEditor = false) => {
|
|
6
|
-
if (typeof value === "function") {
|
|
7
|
-
return (props) => recursiveTransformContent(value(props), isRenderEditor);
|
|
8
|
-
} else if (typeof value === "object") {
|
|
9
|
-
if (typeof value.dictionaryKey !== "undefined") {
|
|
10
|
-
if (isRenderEditor) {
|
|
11
|
-
return renderIntlayerEditor(value);
|
|
12
|
-
}
|
|
13
|
-
return value.content;
|
|
14
|
-
} else if (Array.isArray(value)) {
|
|
15
|
-
return value.map((el) => recursiveTransformContent(el, isRenderEditor));
|
|
16
|
-
} else if (isValidElement(value)) {
|
|
17
|
-
return value;
|
|
18
|
-
}
|
|
19
|
-
return Object.entries(value).reduce(
|
|
20
|
-
(acc, [key, value2]) => ({
|
|
21
|
-
...acc,
|
|
22
|
-
[key]: recursiveTransformContent(value2, isRenderEditor)
|
|
23
|
-
}),
|
|
24
|
-
{}
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
return value;
|
|
28
|
-
};
|
|
29
|
-
export {
|
|
30
|
-
recursiveTransformContent
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=recursiveTransformContent.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/recursiveTransformContent.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Locales } from '@intlayer/config';\nimport type { NodeType } from '@intlayer/core';\nimport { isValidElement, type ReactNode } from 'react';\nimport {\n type IntlayerNode,\n renderIntlayerEditor,\n} from './editor/renderContentEditor';\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"],"mappings":"AAGA,SAAS,sBAAsC;AAC/C;AAAA,EAEE;AAAA,OACK;AAyCA,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,eAAO,qBAAqB,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,WAAW,eAAe,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;","names":["value"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { getConfiguration } from "@intlayer/config/client";
|
|
2
|
-
import { getTranslationContent } from "@intlayer/core";
|
|
3
|
-
import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
|
|
4
|
-
import { getServerContext } from "./serverContext.mjs";
|
|
5
|
-
const getLocaleTranslation = (languageContent) => {
|
|
6
|
-
const locale = getServerContext(IntlayerServerContext);
|
|
7
|
-
const content = getTranslationContent(
|
|
8
|
-
languageContent,
|
|
9
|
-
locale ?? getConfiguration().internationalization.defaultLocale
|
|
10
|
-
);
|
|
11
|
-
return {
|
|
12
|
-
locale,
|
|
13
|
-
content
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export {
|
|
17
|
-
getLocaleTranslation
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=getLocaleTranslation.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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,SAAS,wBAAwB;AACjC,SAA+B,6BAA6B;AAC5D,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAK1B,MAAM,uBAAuB,CAClC,oBACG;AACH,QAAM,SAAS,iBAAiB,qBAAqB;AACrD,QAAM,UAAU;AAAA,IACd;AAAA,IACA,UAAU,iBAAiB,EAAE,qBAAqB;AAAA,EACpD;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { getTranslation } from "../getTranslation.mjs";
|
|
2
|
-
import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
|
|
3
|
-
import { getServerContext } from "./serverContext.mjs";
|
|
4
|
-
const useTraduction = (languageContent) => {
|
|
5
|
-
const locale = getServerContext(IntlayerServerContext);
|
|
6
|
-
return getTranslation(languageContent, locale);
|
|
7
|
-
};
|
|
8
|
-
export {
|
|
9
|
-
useTraduction
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=useTraduction.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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":"AAEA,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAuB1B,MAAM,gBAAgB,CAC3B,oBACG;AACH,QAAM,SAAS,iBAA0B,qBAAqB;AAE9D,SAAO,eAAe,iBAAiB,MAAM;AAC/C;","names":[]}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { type QuantityContent } from '@intlayer/core';
|
|
2
|
-
/**
|
|
3
|
-
* Allow to pick a content based on a quantity.
|
|
4
|
-
*
|
|
5
|
-
* Return either the content editor, or the content itself depending on the configuration.
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
*
|
|
9
|
-
* ```ts
|
|
10
|
-
* const content = getEnumeration({
|
|
11
|
-
* '<=-2.3': 'You have less than -2.3',
|
|
12
|
-
* '<1': 'You have less than one',
|
|
13
|
-
* '2': 'You have two',
|
|
14
|
-
* '>=3': 'You have three or more',
|
|
15
|
-
* }, 2);
|
|
16
|
-
* // 'You have two'
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* The order of the keys will define the priority of the content.
|
|
20
|
-
*
|
|
21
|
-
* ```ts
|
|
22
|
-
* const content = getEnumeration({
|
|
23
|
-
* '<4': 'You have less than four',
|
|
24
|
-
* '2': 'You have two',
|
|
25
|
-
* }, 2);
|
|
26
|
-
* // 'You have less than four'
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
*/
|
|
30
|
-
export declare const getEnumeration: <Content>(enumerationContent: QuantityContent<Content>, quantity: number) => Content;
|
|
31
|
-
//# sourceMappingURL=getEnumeration.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getEnumeration.d.ts","sourceRoot":"","sources":["../../src/getEnumeration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAyB,MAAM,gBAAgB,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,sBAChB,eAAe,CAAC,OAAO,CAAC,YAClC,MAAM,KACf,OAOF,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Locales } from '@intlayer/config/client';
|
|
2
|
-
import { DictionaryKeys, DataFromDictionaryKey } from './getIntlayer';
|
|
3
|
-
export type GetIntlayerAsync = <T extends DictionaryKeys, L extends Locales, R extends boolean = true>(key: T, locale?: L, isRenderEditor?: R) => Promise<DataFromDictionaryKey<T, L, R> | null>;
|
|
4
|
-
/**
|
|
5
|
-
* On the client side, Hook that picking one dictionary by its key and return the content
|
|
6
|
-
*
|
|
7
|
-
* This hook will prerender the locale dictionary and fetch simultaneously the distant dictionaries to hydrate it.
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* If the locale is not provided, it will use the locale from the client context
|
|
11
|
-
*/
|
|
12
|
-
export declare const getIntlayerAsync: GetIntlayerAsync;
|
|
13
|
-
//# sourceMappingURL=getIntlayerAsync.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getIntlayerAsync.d.ts","sourceRoot":"","sources":["../../src/getIntlayerAsync.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGvD,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtE,MAAM,MAAM,gBAAgB,GAAG,CAC7B,CAAC,SAAS,cAAc,EACxB,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,GAAG,IAAI,EAExB,GAAG,EAAE,CAAC,EACN,MAAM,CAAC,EAAE,CAAC,EACV,cAAc,CAAC,EAAE,CAAC,KACf,OAAO,CAAC,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;AAEpD;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,EAAE,gBAoB9B,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { type Locales } from '@intlayer/config/client';
|
|
2
|
-
import { type LanguageContent } from '@intlayer/core';
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* Allow to pick a content based on a locale.
|
|
6
|
-
* If not locale found, it will return the content related to the default locale.
|
|
7
|
-
*
|
|
8
|
-
* Return either the content editor, or the content itself depending on the configuration.
|
|
9
|
-
*
|
|
10
|
-
* Usage:
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* const content = getTranslation<string>({
|
|
14
|
-
* en: 'Hello',
|
|
15
|
-
* fr: 'Bonjour',
|
|
16
|
-
* }, 'fr');
|
|
17
|
-
* // 'Bonjour'
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* Using TypeScript:
|
|
21
|
-
* - this function will require each locale to be defined if defined in the project configuration.
|
|
22
|
-
* - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.
|
|
23
|
-
*/
|
|
24
|
-
export declare const getTranslation: <Content = string>(languageContent: LanguageContent<Content>, locale?: Locales) => Content;
|
|
25
|
-
//# sourceMappingURL=getTranslation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getTranslation.d.ts","sourceRoot":"","sources":["../../src/getTranslation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAoB,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,KAAK,eAAe,EAAyB,MAAM,gBAAgB,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,4BACnB,eAAe,CAAC,OAAO,CAAC,WAChC,OAAO,KACf,OASF,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { KeyPath, Locales } from '@intlayer/core';
|
|
2
|
-
import type { ReactNode } from 'react';
|
|
3
|
-
export type TransformedContentValue = string | ReactNode | {
|
|
4
|
-
[key: string]: TransformedContentValue;
|
|
5
|
-
} | undefined | ((quantity: number) => TransformedContentValue);
|
|
6
|
-
export type TransformedContentObject = {
|
|
7
|
-
dictionaryKey: string;
|
|
8
|
-
dictionaryPath: string;
|
|
9
|
-
keyPath: KeyPath[];
|
|
10
|
-
locale: Locales;
|
|
11
|
-
content: TransformedContentValue | TransformedContentValue[] | undefined;
|
|
12
|
-
};
|
|
13
|
-
export type TransformedContent = Record<string, TransformedContentValue | TransformedContentValue[] | TransformedContentObject | undefined> | ReactNode;
|
|
14
|
-
//# sourceMappingURL=contentDictionary.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contentDictionary.d.ts","sourceRoot":"","sources":["../../../src/processDictionary/contentDictionary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,uBAAuB,GAC/B,MAAM,GACN,SAAS,GACT;IACE,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB,CAAC;CACxC,GACD,SAAS,GACT,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,uBAAuB,CAAC,CAAC;AAEpD,MAAM,MAAM,wBAAwB,GAAG;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,uBAAuB,GAAG,uBAAuB,EAAE,GAAG,SAAS,CAAC;CAC1E,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAC1B,MAAM,CACJ,MAAM,EACJ,uBAAuB,GACvB,uBAAuB,EAAE,GACzB,wBAAwB,GACxB,SAAS,CACZ,GACD,SAAS,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type Locales } from '@intlayer/config/client';
|
|
2
|
-
import { type KeyPath, type DictionaryValue } from '@intlayer/core';
|
|
3
|
-
import type { TransformedContent, TransformedContentValue } from './contentDictionary';
|
|
4
|
-
export declare const processNode: (field: DictionaryValue | undefined, locale: Locales, dictionaryKey: string, dictionaryPath?: string, keyPath?: KeyPath[]) => TransformedContentValue;
|
|
5
|
-
/**
|
|
6
|
-
* Function that process a dictionary and return the result to be used in the application.
|
|
7
|
-
*/
|
|
8
|
-
export declare const processDictionary: (content: DictionaryValue, dictionaryKey: string, dictionaryPath?: string, keyPath?: KeyPath[], locale?: Locales) => TransformedContent;
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/processDictionary/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAoB,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAKL,KAAK,OAAO,EACZ,KAAK,eAAe,EAIrB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,qBAAqB,CAAC;AAoE7B,eAAO,MAAM,WAAW,UACf,eAAe,GAAG,SAAS,UAC1B,OAAO,iBACA,MAAM,mBACJ,MAAM,YACd,OAAO,EAAE,KACjB,uBAwCF,CAAC;AAmDF;;GAEG;AACH,eAAO,MAAM,iBAAiB,YACnB,eAAe,iBACT,MAAM,mBACJ,MAAM,YACd,OAAO,EAAE,WACV,OAAO,KACd,kBA0EF,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { Locales } from '@intlayer/config';
|
|
2
|
-
import type { NodeType } from '@intlayer/core';
|
|
3
|
-
import { type ReactNode } from 'react';
|
|
4
|
-
import { type IntlayerNode } from './editor/renderContentEditor';
|
|
5
|
-
type TransformNodeType<T, L extends Locales, R extends boolean> = T extends {
|
|
6
|
-
[NodeType.Enumeration]: {
|
|
7
|
-
'1': any;
|
|
8
|
-
};
|
|
9
|
-
} ? (quantity: number) => DeepTransformContent<T[NodeType.Enumeration]['1'], L, R> : T extends {
|
|
10
|
-
[NodeType.Translation]: object;
|
|
11
|
-
} ? L extends keyof T[NodeType.Translation] ? DeepTransformContent<T[NodeType.Translation][L], L, R> : never : T;
|
|
12
|
-
export type DeepTransformContent<T, L extends Locales, R extends boolean> = T extends object ? T extends (infer U)[] ? DeepTransformContent<U, L, R>[] : T extends {
|
|
13
|
-
nodeType: NodeType | string;
|
|
14
|
-
} ? TransformNodeType<T, L, R> : T extends {
|
|
15
|
-
_owner: any;
|
|
16
|
-
key: any;
|
|
17
|
-
props: any;
|
|
18
|
-
ref: any;
|
|
19
|
-
} ? ReactNode : {
|
|
20
|
-
[K in keyof T]: DeepTransformContent<T[K], L, R>;
|
|
21
|
-
} : T extends undefined ? never : R extends true ? IntlayerNode<T> : T;
|
|
22
|
-
/**
|
|
23
|
-
* Go through the object. If a object has a keyPath, render the intlayer editor if editor enabled.
|
|
24
|
-
*/
|
|
25
|
-
export declare const recursiveTransformContent: (value: any, isRenderEditor?: boolean) => object;
|
|
26
|
-
export {};
|
|
27
|
-
//# sourceMappingURL=recursiveTransformContent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"recursiveTransformContent.d.ts","sourceRoot":"","sources":["../../src/recursiveTransformContent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EACL,KAAK,YAAY,EAElB,MAAM,8BAA8B,CAAC;AAEtC,KAAK,iBAAiB,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,EAAE,CAAC,SAAS,OAAO,IAAI,CAAC,SAAS;IAC1E,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QAAE,GAAG,EAAE,GAAG,CAAA;KAAE,CAAC;CACtC,GACG,CACE,QAAQ,EAAE,MAAM,KACb,oBAAoB,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAC7D,CAAC,SAAS;IACN,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAChC,GACD,CAAC,SAAS,MAAM,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,GACrC,oBAAoB,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GACtD,KAAK,GACP,CAAC,CAAC;AAER,MAAM,MAAM,oBAAoB,CAC9B,CAAC,EACD,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,IACf,CAAC,SAAS,MAAM,GAChB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GACnB,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,GAC/B,CAAC,SAAS;IACN,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAC;CAC7B,GACD,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAC1B,CAAC,SAAS;IAAE,MAAM,EAAE,GAAG,CAAC;IAAC,GAAG,EAAE,GAAG,CAAC;IAAC,KAAK,EAAE,GAAG,CAAC;IAAC,GAAG,EAAE,GAAG,CAAA;CAAE,GACvD,SAAS,GACT;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;CACjD,GACP,CAAC,SAAS,SAAS,GACjB,KAAK,GACL,CAAC,SAAS,IAAI,GACZ,YAAY,CAAC,CAAC,CAAC,GACf,CAAC,CAAC;AAEV;;GAEG;AACH,eAAO,MAAM,yBAAyB,UAC7B,GAAG,+BAET,MA0BF,CAAC"}
|