react-intlayer 2.0.13 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -49
- package/dist/cjs/client/IntlayerProvider.cjs +2 -2
- package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
- package/dist/cjs/client/getBrowserLocale.cjs.map +1 -1
- package/dist/cjs/client/index.cjs +6 -0
- package/dist/cjs/client/index.cjs.map +1 -1
- package/dist/cjs/client/t.cjs +37 -0
- package/dist/cjs/client/t.cjs.map +1 -0
- package/dist/cjs/client/useDictionary.cjs +37 -0
- package/dist/cjs/client/useDictionary.cjs.map +1 -0
- package/dist/cjs/client/useIntlayer.cjs +2 -2
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/index.cjs +4 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/processDictionary/index.cjs +3 -2
- package/dist/cjs/processDictionary/index.cjs.map +1 -1
- package/dist/cjs/server/index.cjs +6 -0
- package/dist/cjs/server/index.cjs.map +1 -1
- package/dist/cjs/server/serverContext.cjs.map +1 -1
- package/dist/cjs/server/t.cjs +36 -0
- package/dist/cjs/server/t.cjs.map +1 -0
- package/dist/cjs/server/useDictionary.cjs +35 -0
- package/dist/cjs/server/useDictionary.cjs.map +1 -0
- package/dist/cjs/server/useIntlayer.cjs +2 -2
- package/dist/cjs/server/useIntlayer.cjs.map +1 -1
- package/dist/cjs/useDictionaryBase.cjs +69 -0
- package/dist/cjs/useDictionaryBase.cjs.map +1 -0
- package/dist/cjs/useIntlayerBase.cjs +10 -29
- package/dist/cjs/useIntlayerBase.cjs.map +1 -1
- package/dist/cjs/vite/intlayerPlugin.cjs.map +1 -1
- package/dist/esm/client/IntlayerProvider.mjs +1 -1
- package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
- package/dist/esm/client/getBrowserLocale.mjs.map +1 -1
- package/dist/esm/client/index.mjs +4 -0
- package/dist/esm/client/index.mjs.map +1 -1
- package/dist/esm/client/t.mjs +14 -0
- package/dist/esm/client/t.mjs.map +1 -0
- package/dist/esm/client/useDictionary.mjs +14 -0
- package/dist/esm/client/useDictionary.mjs.map +1 -0
- package/dist/esm/client/useIntlayer.mjs +2 -2
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/index.mjs +5 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/processDictionary/index.mjs +3 -2
- package/dist/esm/processDictionary/index.mjs.map +1 -1
- package/dist/esm/server/index.mjs +4 -0
- package/dist/esm/server/index.mjs.map +1 -1
- package/dist/esm/server/serverContext.mjs.map +1 -1
- package/dist/esm/server/t.mjs +13 -0
- package/dist/esm/server/t.mjs.map +1 -0
- package/dist/esm/server/useDictionary.mjs +12 -0
- package/dist/esm/server/useDictionary.mjs.map +1 -0
- package/dist/esm/server/useIntlayer.mjs +2 -2
- package/dist/esm/server/useIntlayer.mjs.map +1 -1
- package/dist/esm/useDictionaryBase.mjs +45 -0
- package/dist/esm/useDictionaryBase.mjs.map +1 -0
- package/dist/esm/useIntlayerBase.mjs +12 -28
- package/dist/esm/useIntlayerBase.mjs.map +1 -1
- package/dist/esm/vite/intlayerPlugin.mjs.map +1 -1
- package/dist/types/cli/react-intlayer.d.ts +9 -0
- package/dist/types/cli/react-intlayer.d.ts.map +1 -0
- package/dist/types/client/IntlayerProvider.d.ts +25 -0
- package/dist/types/client/IntlayerProvider.d.ts.map +1 -0
- package/dist/{cjs → types}/client/getBrowserLocale.d.ts +5 -6
- package/dist/types/client/getBrowserLocale.d.ts.map +1 -0
- package/dist/types/client/index.d.ts +10 -0
- package/dist/types/client/index.d.ts.map +1 -0
- package/dist/types/client/t.d.ts +9 -0
- package/dist/types/client/t.d.ts.map +1 -0
- package/dist/types/client/useContent.d.ts +10 -0
- package/dist/types/client/useContent.d.ts.map +1 -0
- package/dist/types/client/useDictionary.d.ts +8 -0
- package/dist/types/client/useDictionary.d.ts.map +1 -0
- package/dist/types/client/useIntlayer.d.ts +8 -0
- package/dist/types/client/useIntlayer.d.ts.map +1 -0
- package/dist/types/client/useLocale.d.ts +11 -0
- package/dist/types/client/useLocale.d.ts.map +1 -0
- package/dist/types/client/useLocaleBase.d.ts +11 -0
- package/dist/types/client/useLocaleBase.d.ts.map +1 -0
- package/dist/types/client/useLocaleCookie.d.ts +17 -0
- package/dist/types/client/useLocaleCookie.d.ts.map +1 -0
- package/dist/{cjs → types}/client/useTraduction.d.ts +3 -5
- package/dist/types/client/useTraduction.d.ts.map +1 -0
- package/dist/types/craco/craco.config.d.ts +2 -0
- package/dist/types/craco/craco.config.d.ts.map +1 -0
- package/dist/types/craco/intlayerCracoPlugin.d.ts +24 -0
- package/dist/types/craco/intlayerCracoPlugin.d.ts.map +1 -0
- package/dist/{cjs → types}/getEnumeration.d.ts +3 -5
- package/dist/types/getEnumeration.d.ts.map +1 -0
- package/dist/{cjs → types}/getTranslation.d.ts +4 -6
- package/dist/types/getTranslation.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/processDictionary/contentDictionary.d.ts +14 -0
- package/dist/types/processDictionary/contentDictionary.d.ts.map +1 -0
- package/dist/types/processDictionary/index.d.ts +9 -0
- package/dist/types/processDictionary/index.d.ts.map +1 -0
- package/dist/types/server/IntlayerServerProvider.d.ts +34 -0
- package/dist/types/server/IntlayerServerProvider.d.ts.map +1 -0
- package/dist/types/server/getLocaleTranslation.d.ts +9 -0
- package/dist/types/server/getLocaleTranslation.d.ts.map +1 -0
- package/dist/types/server/index.d.ts +7 -0
- package/dist/types/server/index.d.ts.map +1 -0
- package/dist/{cjs → types}/server/serverContext.d.ts +4 -15
- package/dist/types/server/serverContext.d.ts.map +1 -0
- package/dist/types/server/t.d.ts +9 -0
- package/dist/types/server/t.d.ts.map +1 -0
- package/dist/types/server/useDictionary.d.ts +8 -0
- package/dist/types/server/useDictionary.d.ts.map +1 -0
- package/dist/types/server/useIntlayer.d.ts +8 -0
- package/dist/types/server/useIntlayer.d.ts.map +1 -0
- package/dist/{cjs → types}/server/useTraduction.d.ts +3 -5
- package/dist/types/server/useTraduction.d.ts.map +1 -0
- package/dist/types/useDictionaryBase.d.ts +37 -0
- package/dist/types/useDictionaryBase.d.ts.map +1 -0
- package/dist/types/useIntlayerBase.d.ts +39 -0
- package/dist/types/useIntlayerBase.d.ts.map +1 -0
- package/dist/{cjs → types}/vite/intlayerPlugin.d.ts +4 -5
- package/dist/types/vite/intlayerPlugin.d.ts.map +1 -0
- package/package.json +38 -28
- package/dist/cjs/cli/react-intlayer.d.ts +0 -1
- package/dist/cjs/client/IntlayerProvider.d.ts +0 -27
- package/dist/cjs/client/index.d.ts +0 -13
- package/dist/cjs/client/useContent.d.ts +0 -13
- package/dist/cjs/client/useIntlayer.d.ts +0 -14
- package/dist/cjs/client/useLocale.d.ts +0 -14
- package/dist/cjs/client/useLocaleBase.d.ts +0 -14
- package/dist/cjs/client/useLocaleCookie.d.ts +0 -19
- package/dist/cjs/craco/craco.config.d.ts +0 -2
- package/dist/cjs/craco/intlayerCracoPlugin.d.ts +0 -26
- package/dist/cjs/index.d.ts +0 -14
- package/dist/cjs/processDictionary/contentDictionary.d.ts +0 -16
- package/dist/cjs/processDictionary/index.d.ts +0 -12
- package/dist/cjs/server/IntlayerServerProvider.d.ts +0 -36
- package/dist/cjs/server/getLocaleTranslation.d.ts +0 -12
- package/dist/cjs/server/index.d.ts +0 -10
- package/dist/cjs/server/useIntlayer.d.ts +0 -14
- package/dist/cjs/useIntlayerBase.d.ts +0 -70
- package/dist/esm/cli/react-intlayer.d.mts +0 -1
- package/dist/esm/client/IntlayerProvider.d.mts +0 -27
- package/dist/esm/client/getBrowserLocale.d.mts +0 -26
- package/dist/esm/client/index.d.mts +0 -13
- package/dist/esm/client/useContent.d.mts +0 -13
- package/dist/esm/client/useIntlayer.d.mts +0 -14
- package/dist/esm/client/useLocale.d.mts +0 -14
- package/dist/esm/client/useLocaleBase.d.mts +0 -14
- package/dist/esm/client/useLocaleCookie.d.mts +0 -19
- package/dist/esm/client/useTraduction.d.mts +0 -26
- package/dist/esm/craco/craco.config.d.mts +0 -2
- package/dist/esm/craco/intlayerCracoPlugin.d.mts +0 -26
- package/dist/esm/getEnumeration.d.mts +0 -33
- package/dist/esm/getTranslation.d.mts +0 -27
- package/dist/esm/index.d.mts +0 -14
- package/dist/esm/processDictionary/contentDictionary.d.mts +0 -16
- package/dist/esm/processDictionary/index.d.mts +0 -12
- package/dist/esm/server/IntlayerServerProvider.d.mts +0 -36
- package/dist/esm/server/getLocaleTranslation.d.mts +0 -12
- package/dist/esm/server/index.d.mts +0 -10
- package/dist/esm/server/serverContext.d.mts +0 -35
- package/dist/esm/server/useIntlayer.d.mts +0 -14
- package/dist/esm/server/useTraduction.d.mts +0 -26
- package/dist/esm/useIntlayerBase.d.mts +0 -70
- package/dist/esm/vite/intlayerPlugin.d.mts +0 -17
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import "./chunk-ZD7AOCMD.mjs";
|
|
2
|
+
import { renderIntlayerEditor } from "intlayer-editor";
|
|
3
|
+
import { isValidElement } from "react";
|
|
4
|
+
import { processDictionary } from './processDictionary/index.mjs';
|
|
5
|
+
const recursiveTransformContent = (value, isContentSelectable = false) => {
|
|
6
|
+
if (typeof value === "function") {
|
|
7
|
+
return (props) => recursiveTransformContent(value(props), isContentSelectable);
|
|
8
|
+
} else if (typeof value === "object") {
|
|
9
|
+
if (typeof value.dictionaryId !== "undefined") {
|
|
10
|
+
return renderIntlayerEditor(value, isContentSelectable);
|
|
11
|
+
} else if (Array.isArray(value)) {
|
|
12
|
+
return value.map(
|
|
13
|
+
(el) => recursiveTransformContent(el, isContentSelectable)
|
|
14
|
+
);
|
|
15
|
+
} else if (isValidElement(value)) {
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
return Object.entries(value).reduce(
|
|
19
|
+
(acc, [key, value2]) => ({
|
|
20
|
+
...acc,
|
|
21
|
+
[key]: recursiveTransformContent(value2, isContentSelectable)
|
|
22
|
+
}),
|
|
23
|
+
{}
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
};
|
|
28
|
+
const useDictionaryBase = (dictionary, locale, isContentSelectable = false) => {
|
|
29
|
+
const result = processDictionary(
|
|
30
|
+
dictionary.content,
|
|
31
|
+
dictionary.key,
|
|
32
|
+
dictionary.filePath,
|
|
33
|
+
[],
|
|
34
|
+
locale
|
|
35
|
+
);
|
|
36
|
+
return recursiveTransformContent(
|
|
37
|
+
result,
|
|
38
|
+
isContentSelectable
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
recursiveTransformContent,
|
|
43
|
+
useDictionaryBase
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=useDictionaryBase.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/useDictionaryBase.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 { renderIntlayerEditor } from 'intlayer-editor';\nimport { isValidElement, type ReactNode } from 'react';\nimport { processDictionary } from './processDictionary/index';\n\nexport type IntlayerNode<T = string> = ReactNode & {\n value: T;\n};\n\ntype TransformNodeType<T, L extends Locales> = T extends {\n [NodeType.Enumeration]: { '1': any };\n}\n ? (quantity: number) => DeepTransformContent<T[NodeType.Enumeration]['1'], L>\n : T extends {\n [NodeType.Translation]: object;\n }\n ? L extends keyof T[NodeType.Translation]\n ? DeepTransformContent<T[NodeType.Translation][L], L>\n : never\n : T;\n\nexport type DeepTransformContent<T, L extends Locales> = 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>[] // Apply DeepTransformContent recursively to each element of the array\n : T extends {\n nodeType: NodeType | string;\n }\n ? TransformNodeType<T, L>\n : T extends { _owner: any; key: any; props: any; ref: any }\n ? ReactNode\n : {\n [K in keyof T]: DeepTransformContent<T[K], L>;\n }\n : T extends undefined\n ? never\n : IntlayerNode<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 isContentSelectable = false\n): object => {\n if (typeof value === 'function') {\n return (props: any) =>\n recursiveTransformContent(value(props), isContentSelectable);\n } else if (typeof value === 'object') {\n if (typeof value.dictionaryId !== 'undefined') {\n return renderIntlayerEditor(value, isContentSelectable);\n } else if (Array.isArray(value)) {\n return value.map((el) =>\n recursiveTransformContent(el, isContentSelectable)\n );\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, isContentSelectable),\n }),\n {} as object\n );\n }\n\n return value;\n};\n\ntype DataFromDictionary<\n T extends DeclarationContent,\n K extends Locales,\n> = DeepTransformContent<T['content'], K>;\n\nexport type UseDictionary = <T extends DeclarationContent, L extends Locales>(\n dictionary: T,\n locale?: L\n) => DataFromDictionary<T, L>;\n\n// Add description is JSDoc\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 useDictionaryBase: UseDictionary = <\n T extends DeclarationContent,\n L extends Locales,\n>(\n dictionary: T,\n locale?: L,\n isContentSelectable = false\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 isContentSelectable\n ) as DataFromDictionary<T, L>;\n};\n"],"mappings":";AAOA,SAAS,4BAA4B;AACrC,SAAS,sBAAsC;AAC/C,SAAS,yBAAyB;AAqC3B,MAAM,4BAA4B,CACvC,OACA,sBAAsB,UACX;AACX,MAAI,OAAO,UAAU,YAAY;AAC/B,WAAO,CAAC,UACN,0BAA0B,MAAM,KAAK,GAAG,mBAAmB;AAAA,EAC/D,WAAW,OAAO,UAAU,UAAU;AACpC,QAAI,OAAO,MAAM,iBAAiB,aAAa;AAC7C,aAAO,qBAAqB,OAAO,mBAAmB;AAAA,IACxD,WAAW,MAAM,QAAQ,KAAK,GAAG;AAC/B,aAAO,MAAM;AAAA,QAAI,CAAC,OAChB,0BAA0B,IAAI,mBAAmB;AAAA,MACnD;AAAA,IACF,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,mBAAmB;AAAA,MAC7D;AAAA,MACA,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;AAkBO,MAAM,oBAAmC,CAI9C,YACA,QACA,sBAAsB,UACnB;AACH,QAAM,SAAS;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,41 +1,25 @@
|
|
|
1
1
|
import "./chunk-ZD7AOCMD.mjs";
|
|
2
2
|
import dictionaries from "@intlayer/dictionaries-entry";
|
|
3
|
-
import { renderIntlayerEditor } from "intlayer-editor/client";
|
|
4
|
-
import { isValidElement } from "react";
|
|
5
3
|
import { processDictionary } from './processDictionary/index.mjs';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} else if (typeof value === "object" && Array.isArray(value)) {
|
|
12
|
-
return value.map(recursiveTransformContent);
|
|
13
|
-
} else if (typeof value === "object" && isValidElement(value)) {
|
|
14
|
-
return value;
|
|
15
|
-
} else if (typeof value === "object") {
|
|
16
|
-
return Object.entries(value).reduce(
|
|
17
|
-
(acc, [key, value2]) => ({
|
|
18
|
-
...acc,
|
|
19
|
-
[key]: recursiveTransformContent(value2)
|
|
20
|
-
}),
|
|
21
|
-
{}
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
return value.value;
|
|
25
|
-
};
|
|
26
|
-
const useIntlayerBase = (id, locale) => {
|
|
27
|
-
const dictionary = dictionaries[id];
|
|
4
|
+
import {
|
|
5
|
+
recursiveTransformContent
|
|
6
|
+
} from './useDictionaryBase.mjs';
|
|
7
|
+
const useIntlayerBase = (key, locale) => {
|
|
8
|
+
const dictionary = dictionaries[key];
|
|
28
9
|
const result = processDictionary(
|
|
29
|
-
dictionary,
|
|
30
|
-
|
|
10
|
+
dictionary.content,
|
|
11
|
+
dictionary.key,
|
|
31
12
|
dictionary.filePath,
|
|
32
13
|
[],
|
|
33
14
|
locale
|
|
34
15
|
);
|
|
35
|
-
|
|
16
|
+
const isContentSelectable = true;
|
|
17
|
+
return recursiveTransformContent(
|
|
18
|
+
result,
|
|
19
|
+
isContentSelectable
|
|
20
|
+
);
|
|
36
21
|
};
|
|
37
22
|
export {
|
|
38
|
-
recursiveTransformContent,
|
|
39
23
|
useIntlayerBase
|
|
40
24
|
};
|
|
41
25
|
//# sourceMappingURL=useIntlayerBase.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/useIntlayerBase.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/useIntlayerBase.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 { processDictionary } from './processDictionary/index';\nimport {\n type DeepTransformContent,\n recursiveTransformContent,\n} from './useDictionaryBase';\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 */\ntype DataFromDictionaryKey<\n T extends DictionaryKeys,\n K extends Locales,\n> = DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content'], K>;\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 = <T extends DictionaryKeys, L extends Locales>(\n key: T,\n locale?: L\n) => DataFromDictionaryKey<T, L>;\n\n/**\n * Hook that picks one dictionary by its ID and returns the content,\n * deeply transformed according to the dictionary structure and metadata.\n */\nexport const useIntlayerBase: UseIntlayer = <\n T extends DictionaryKeys,\n L extends Locales,\n>(\n key: T,\n locale?: L\n) => {\n const dictionary: Dictionary = dictionaries[key as keyof typeof dictionaries];\n\n const result = processDictionary(\n dictionary.content,\n dictionary.key,\n dictionary.filePath,\n [],\n locale\n );\n\n const isContentSelectable = true;\n\n return recursiveTransformContent(\n result,\n isContentSelectable\n ) as DataFromDictionaryKey<T, L>;\n};\n"],"mappings":";AAOA,OAAO,kBAAkB;AAEzB,SAAS,yBAAyB;AAClC;AAAA,EAEE;AAAA,OACK;AA+CA,MAAM,kBAA+B,CAI1C,KACA,WACG;AACH,QAAM,aAAyB,aAAa,GAAgC;AAE5E,QAAM,SAAS;AAAA,IACb,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX,CAAC;AAAA,IACD;AAAA,EACF;AAEA,QAAM,sBAAsB;AAE5B,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/vite/intlayerPlugin.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/vite/intlayerPlugin.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-object-type */\n\nimport { join, relative, resolve } from 'path';\nimport { watch } from '@intlayer/chokidar';\nimport { getConfiguration, formatEnvVariable } from '@intlayer/config';\nimport { loadEnv, type Plugin } from 'vite';\n\n// Plugin options type definition\ntype PluginOptions = {\n // Custom options for your plugin, if any\n};\n\n/**\n *\n * A Vite plugin that integrates IntLayer configuration into the build process\n *\n * ```ts\n * // Example usage of the plugin in a Vite configuration\n * export default defineConfig({\n * plugins: [ intLayerPlugin() ],\n * });\n * ```\n * */\nexport const intLayerPlugin = (_pluginOptions: PluginOptions = {}): Plugin => ({\n name: 'vite-intlayer-plugin',\n\n config: (config, { mode }) => {\n const intlayerConfig = getConfiguration();\n\n // Set all configuration values as environment variables\n const env = formatEnvVariable('vite');\n\n process.env = { ...process.env, ...loadEnv(mode, process.cwd()), ...env };\n\n const { mainDir, baseDir } = intlayerConfig.content;\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n // Update Vite's resolve alias\n config.resolve = {\n ...config.resolve,\n alias: {\n ...config.resolve?.alias,\n '@intlayer/dictionaries-entry': resolve(relativeDictionariesPath),\n },\n };\n\n const externals: string[] = (config.build?.rollupOptions?.external ??\n []) as string[];\n\n config.build = {\n ...config.build,\n rollupOptions: {\n ...config.build?.rollupOptions,\n external: [...externals, 'module'],\n },\n };\n\n return config;\n },\n\n buildStart: () => {\n // Code to run when Vite build starts\n watch({\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n persistent: (import.meta as any).env === 'development',\n });\n },\n configureServer: () => {\n // Custom server configuration, if needed\n },\n});\n"],"mappings":";AAEA,SAAS,MAAM,UAAU,eAAe;AACxC,SAAS,aAAa;AACtB,SAAS,kBAAkB,yBAAyB;AACpD,SAAS,eAA4B;AAkB9B,MAAM,iBAAiB,CAAC,iBAAgC,CAAC,OAAe;AAAA,EAC7E,MAAM;AAAA,EAEN,QAAQ,CAAC,QAAQ,EAAE,KAAK,MAAM;AAC5B,UAAM,iBAAiB,iBAAiB;AAGxC,UAAM,MAAM,kBAAkB,MAAM;AAEpC,YAAQ,MAAM,EAAE,GAAG,QAAQ,KAAK,GAAG,QAAQ,MAAM,QAAQ,IAAI,CAAC,GAAG,GAAG,IAAI;AAExE,UAAM,EAAE,SAAS,QAAQ,IAAI,eAAe;AAC5C,UAAM,mBAAmB,KAAK,SAAS,kBAAkB;AACzD,UAAM,2BAA2B,SAAS,SAAS,gBAAgB;AAGnE,WAAO,UAAU;AAAA,MACf,GAAG,OAAO;AAAA,MACV,OAAO;AAAA,QACL,GAAG,OAAO,SAAS;AAAA,QACnB,gCAAgC,QAAQ,wBAAwB;AAAA,MAClE;AAAA,IACF;AAEA,UAAM,YAAuB,OAAO,OAAO,eAAe,YACxD,CAAC;AAEH,WAAO,QAAQ;AAAA,MACb,GAAG,OAAO;AAAA,MACV,eAAe;AAAA,QACb,GAAG,OAAO,OAAO;AAAA,QACjB,UAAU,CAAC,GAAG,WAAW,QAAQ;AAAA,MACnC;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,MAAM;AAEhB,UAAM;AAAA;AAAA,MAEJ,YAAa,YAAoB,QAAQ;AAAA,IAC3C,CAAC;AAAA,EACH;AAAA,EACA,iBAAiB,MAAM;AAAA,EAEvB;AACF;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* To make the setup easier, we are using craco to override the webpack configuration.
|
|
4
|
+
* This script is used to run the craco scripts with the custom configuration.
|
|
5
|
+
*
|
|
6
|
+
* The script is based on the original craco script from create-react-app.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=react-intlayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-intlayer.d.ts","sourceRoot":"","sources":["../../../src/cli/react-intlayer.ts"],"names":[],"mappings":";AAEA;;;;;GAKG"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Locales } from '@intlayer/config/client';
|
|
2
|
+
import { type PropsWithChildren, type FC } from 'react';
|
|
3
|
+
type IntlayerValue = {
|
|
4
|
+
locale: Locales;
|
|
5
|
+
setLocale: (newLocale: Locales) => void;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Context that store the current locale on the client side
|
|
9
|
+
*/
|
|
10
|
+
export declare const IntlayerClientContext: import("react").Context<IntlayerValue>;
|
|
11
|
+
/**
|
|
12
|
+
* Hook that provides the current locale
|
|
13
|
+
*/
|
|
14
|
+
export declare const useIntlayerContext: () => IntlayerValue;
|
|
15
|
+
export type IntlayerProviderProps = PropsWithChildren & {
|
|
16
|
+
locale?: Locales;
|
|
17
|
+
setLocale?: (locale: Locales) => void;
|
|
18
|
+
editorEnabled?: boolean;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Provider that store the current locale on the client side
|
|
22
|
+
*/
|
|
23
|
+
export declare const IntlayerProvider: FC<IntlayerProviderProps>;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=IntlayerProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntlayerProvider.d.ts","sourceRoot":"","sources":["../../../src/client/IntlayerProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,EACL,KAAK,iBAAiB,EAItB,KAAK,EAAE,EAGR,MAAM,OAAO,CAAC;AAGf,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,wCAGhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,qBAA0C,CAAC;AAE1E,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,GAAG;IACtD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CA+CtD,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Locales } from '@intlayer/config/client';
|
|
2
|
-
|
|
3
|
-
declare enum LanguageDetector {
|
|
1
|
+
import { type Locales } from '@intlayer/config/client';
|
|
2
|
+
export declare enum LanguageDetector {
|
|
4
3
|
Querystring = "querystring",
|
|
5
4
|
Cookie = "cookie",
|
|
6
5
|
LocalStorage = "localStorage",
|
|
@@ -21,6 +20,6 @@ type LanguageDetectorOptions = {
|
|
|
21
20
|
* Core language detector function
|
|
22
21
|
* const detectedLanguages = detectLanguage(['LanguageDetector.Cookie', 'LanguageDetector.LocalStorage'], { lookupCookie: 'myCookie' });
|
|
23
22
|
*/
|
|
24
|
-
declare const getBrowserLocale: (userOptions?: LanguageDetectorOptions | undefined) => Locales;
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
export declare const getBrowserLocale: (userOptions?: LanguageDetectorOptions | undefined) => Locales;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=getBrowserLocale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getBrowserLocale.d.ts","sourceRoot":"","sources":["../../../src/client/getBrowserLocale.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGzE,oBAAY,gBAAgB;IAC1B,WAAW,gBAAgB;IAC3B,MAAM,WAAW;IACjB,YAAY,iBAAiB;IAC7B,cAAc,mBAAmB;IACjC,SAAS,cAAc;IACvB,OAAO,YAAY;CACpB;AAGD,KAAK,uBAAuB,GAAG;IAC7B,KAAK,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAC9B,CAAC;AA8JF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,iBACd,uBAAuB,GAAG,SAAS,KAC/C,OAMF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { type IntlayerProviderProps, IntlayerClientContext, useIntlayerContext, IntlayerProvider, } from './IntlayerProvider';
|
|
2
|
+
export { useIntlayer } from './useIntlayer';
|
|
3
|
+
export { useDictionary } from './useDictionary';
|
|
4
|
+
export { useLocaleBase } from './useLocaleBase';
|
|
5
|
+
export { useLocale } from './useLocale';
|
|
6
|
+
export { useTraduction } from './useTraduction';
|
|
7
|
+
export { useLocaleCookie, localeCookie, setLocaleCookie, } from './useLocaleCookie';
|
|
8
|
+
export { getBrowserLocale } from './getBrowserLocale';
|
|
9
|
+
export { t } from './t';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAC1B,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,eAAe,EACf,YAAY,EACZ,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Locales } from '@intlayer/config/client';
|
|
2
|
+
import type { LanguageContent } from '@intlayer/core';
|
|
3
|
+
/**
|
|
4
|
+
* On the client side, this function returns the translation of the provided multilang content.
|
|
5
|
+
*
|
|
6
|
+
* If the locale is not provided, it will use the locale from the client context
|
|
7
|
+
*/
|
|
8
|
+
export declare const t: <Content = string>(multilangContent: LanguageContent<Content>, locale?: Locales) => Content;
|
|
9
|
+
//# sourceMappingURL=t.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"t.d.ts","sourceRoot":"","sources":["../../../src/client/t.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAKtD;;;;GAIG;AACH,eAAO,MAAM,CAAC,GAAI,OAAO,6BACL,eAAe,CAAC,OAAO,CAAC,WACjC,OAAO,YAMjB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LanguageContent } from '@intlayer/core';
|
|
2
|
+
/**
|
|
3
|
+
* On the client side, hook to get the translation content based on the locale
|
|
4
|
+
*/
|
|
5
|
+
export declare const useContent: <Content>(languageContent: LanguageContent<Content>) => {
|
|
6
|
+
locale: import("intlayer").Locales;
|
|
7
|
+
content: Content;
|
|
8
|
+
t: <Content_1 = string>(languageContent: LanguageContent<Content_1>) => Content_1;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=useContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useContent.d.ts","sourceRoot":"","sources":["../../../src/client/useContent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAItD;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,mBACf,eAAe,CAAC,OAAO,CAAC;;;;CAW1C,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type UseDictionary } from '../useDictionaryBase';
|
|
2
|
+
/**
|
|
3
|
+
* On the server side, Hook that transform a dictionary and return the content
|
|
4
|
+
*
|
|
5
|
+
* If the locale is not provided, it will use the locale from the client context
|
|
6
|
+
*/
|
|
7
|
+
export declare const useDictionary: UseDictionary;
|
|
8
|
+
//# sourceMappingURL=useDictionary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDictionary.d.ts","sourceRoot":"","sources":["../../../src/client/useDictionary.ts"],"names":[],"mappings":"AAKA,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG7E;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,aAQ3B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type UseIntlayer } from '../useIntlayerBase';
|
|
2
|
+
/**
|
|
3
|
+
* On the client side, Hook that picking one dictionary by its key and return the content
|
|
4
|
+
*
|
|
5
|
+
* If the locale is not provided, it will use the locale from the client context
|
|
6
|
+
*/
|
|
7
|
+
export declare const useIntlayer: UseIntlayer;
|
|
8
|
+
//# sourceMappingURL=useIntlayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIntlayer.d.ts","sourceRoot":"","sources":["../../../src/client/useIntlayer.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,oBAAoB,CAAC;AAG5B;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,WAQzB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* On the client side, hook to get the current locale and all related fields
|
|
3
|
+
*/
|
|
4
|
+
export declare const useLocale: () => {
|
|
5
|
+
locale: import("intlayer").Locales;
|
|
6
|
+
defaultLocale: import("intlayer").Locales;
|
|
7
|
+
availableLocales: import("intlayer").Locales[];
|
|
8
|
+
localeList: import("intlayer").Locales[];
|
|
9
|
+
setLocale: (newLocale: import("intlayer").Locales) => void;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=useLocale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLocale.d.ts","sourceRoot":"","sources":["../../../src/client/useLocale.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;CAYrB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* On the client side, hook to get the current locale and all related fields
|
|
3
|
+
*/
|
|
4
|
+
export declare const useLocaleBase: () => {
|
|
5
|
+
locale: import("intlayer").Locales;
|
|
6
|
+
defaultLocale: import("intlayer").Locales;
|
|
7
|
+
availableLocales: import("intlayer").Locales[];
|
|
8
|
+
localeList: import("intlayer").Locales[];
|
|
9
|
+
setLocale: (newLocale: import("intlayer").Locales) => void;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=useLocaleBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLocaleBase.d.ts","sourceRoot":"","sources":["../../../src/client/useLocaleBase.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;CAUzB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Locales } from '@intlayer/config/client';
|
|
2
|
+
/**
|
|
3
|
+
* Get the locale cookie
|
|
4
|
+
*/
|
|
5
|
+
export declare const localeCookie: Locales | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Set the locale cookie
|
|
8
|
+
*/
|
|
9
|
+
export declare const setLocaleCookie: (locale: Locales) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Hook that provides the locale cookie and a function to set it
|
|
12
|
+
*/
|
|
13
|
+
export declare const useLocaleCookie: () => {
|
|
14
|
+
localeCookie: Locales;
|
|
15
|
+
setLocaleCookie: (locale: Locales) => void;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=useLocaleCookie.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLocaleCookie.d.ts","sourceRoot":"","sources":["../../../src/client/useLocaleCookie.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAoB,MAAM,yBAAyB,CAAC;AAazE;;GAEG;AACH,eAAO,MAAM,YAAY,EACrB,OAAO,GACP,SAAS,CAAC;AAEd;;GAEG;AACH,eAAO,MAAM,eAAe,WAAY,OAAO,SAE9C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe;;8BAPY,OAAO;CAU7C,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { LanguageContent } from '@intlayer/core';
|
|
2
|
-
|
|
1
|
+
import type { LanguageContent } from '@intlayer/core';
|
|
3
2
|
/**
|
|
4
3
|
* On the client side, Hook that picking one dictionary by its id and return the content.
|
|
5
4
|
*
|
|
@@ -21,6 +20,5 @@ import { LanguageContent } from '@intlayer/core';
|
|
|
21
20
|
* - this function will require each locale to be defined if defined in the project configuration.
|
|
22
21
|
* - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.
|
|
23
22
|
*/
|
|
24
|
-
declare const useTraduction: <Content = string>(languageContent: LanguageContent<Content>) => Content;
|
|
25
|
-
|
|
26
|
-
export { useTraduction };
|
|
23
|
+
export declare const useTraduction: <Content = string>(languageContent: LanguageContent<Content>) => Content;
|
|
24
|
+
//# sourceMappingURL=useTraduction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTraduction.d.ts","sourceRoot":"","sources":["../../../src/client/useTraduction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAKtD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,4BAClB,eAAe,CAAC,OAAO,CAAC,KACxC,OAIF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"craco.config.d.ts","sourceRoot":"","sources":["../../../src/craco/craco.config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { CracoConfig, CracoConfigOverride, CracoPlugin, WebpackConfigOverride } from '@craco/types';
|
|
2
|
+
import { type Configuration as WebpackConfig } from 'webpack';
|
|
3
|
+
export declare const overrideWebpackConfig: ({ webpackConfig, }: WebpackConfigOverride) => WebpackConfig;
|
|
4
|
+
export declare const overrideCracoConfig: ({ cracoConfig, }: CracoConfigOverride) => CracoConfig;
|
|
5
|
+
/**
|
|
6
|
+
* A CRACO plugin that adds the IntLayer configuration to the webpack configuration and sets the environment variables.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const cracoConfig: CracoConfig = {
|
|
12
|
+
* plugins: [
|
|
13
|
+
* {
|
|
14
|
+
* plugin: intlayerCracoPlugin(),
|
|
15
|
+
* },
|
|
16
|
+
* ],
|
|
17
|
+
* };
|
|
18
|
+
*
|
|
19
|
+
* export default cracoConfig;
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
export declare const plugin: CracoPlugin;
|
|
24
|
+
//# sourceMappingURL=intlayerCracoPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intlayerCracoPlugin.d.ts","sourceRoot":"","sources":["../../../src/craco/intlayerCracoPlugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAGtB,OAAgB,EAAE,KAAK,aAAa,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AASvE,eAAO,MAAM,qBAAqB,uBAE/B,qBAAqB,KAAG,aAoB1B,CAAC;AAGF,eAAO,MAAM,mBAAmB,qBAE7B,mBAAmB,KAAG,WAoBxB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,MAAM,EAAE,WAGpB,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { QuantityContent } from '@intlayer/core';
|
|
2
|
-
|
|
1
|
+
import { type QuantityContent } from '@intlayer/core';
|
|
3
2
|
/**
|
|
4
3
|
* Allow to pick a content based on a quantity.
|
|
5
4
|
*
|
|
@@ -28,6 +27,5 @@ import { QuantityContent } from '@intlayer/core';
|
|
|
28
27
|
* ```
|
|
29
28
|
*
|
|
30
29
|
*/
|
|
31
|
-
declare const getEnumeration: <Content>(enumerationContent: QuantityContent<Content>, quantity: number) => Content;
|
|
32
|
-
|
|
33
|
-
export { getEnumeration };
|
|
30
|
+
export declare const getEnumeration: <Content>(enumerationContent: QuantityContent<Content>, quantity: number) => Content;
|
|
31
|
+
//# sourceMappingURL=getEnumeration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,6 +1,5 @@
|
|
|
1
|
-
import { Locales } from '@intlayer/config/client';
|
|
2
|
-
import { LanguageContent } from '@intlayer/core';
|
|
3
|
-
|
|
1
|
+
import { type Locales } from '@intlayer/config/client';
|
|
2
|
+
import { type LanguageContent } from '@intlayer/core';
|
|
4
3
|
/**
|
|
5
4
|
*
|
|
6
5
|
* Allow to pick a content based on a locale.
|
|
@@ -22,6 +21,5 @@ import { LanguageContent } from '@intlayer/core';
|
|
|
22
21
|
* - this function will require each locale to be defined if defined in the project configuration.
|
|
23
22
|
* - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.
|
|
24
23
|
*/
|
|
25
|
-
declare const getTranslation: <Content = string>(languageContent: LanguageContent<Content>, locale?: Locales) => Content;
|
|
26
|
-
|
|
27
|
-
export { getTranslation };
|
|
24
|
+
export declare const getTranslation: <Content = string>(languageContent: LanguageContent<Content>, locale?: Locales) => Content;
|
|
25
|
+
//# sourceMappingURL=getTranslation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { getTranslation } from './getTranslation';
|
|
2
|
+
export { IntlayerProvider, type IntlayerProviderProps, IntlayerClientContext, useIntlayer, useDictionary, useLocale, useTraduction, useLocaleCookie, localeCookie, setLocaleCookie, getBrowserLocale, useLocaleBase, t, } from './client/index';
|
|
3
|
+
export { type IntlayerNode } from './useDictionaryBase';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,EAC1B,qBAAqB,EACrB,WAAW,EACX,aAAa,EACb,SAAS,EACT,aAAa,EACb,eAAe,EACf,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,CAAC,GACF,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
dictionaryId: 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
|
|
@@ -0,0 +1 @@
|
|
|
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,YAAY,EAAE,MAAM,CAAC;IACrB,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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
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, dictionaryId: 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, dictionaryId: string, dictionaryPath?: string, keyPath?: KeyPath[], locale?: Locales) => TransformedContent;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/processDictionary/index.ts"],"names":[],"mappings":"AACA,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,gBACD,MAAM,mBACH,MAAM,YACd,OAAO,EAAE,KACjB,uBAyCF,CAAC;AAyCF;;GAEG;AACH,eAAO,MAAM,iBAAiB,YACnB,eAAe,gBACV,MAAM,mBACH,MAAM,YACd,OAAO,EAAE,WACV,OAAO,KAEd,kBA0EF,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type Locales } from '@intlayer/config/client';
|
|
2
|
+
import type { FC, PropsWithChildren } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Context that store the current locale on the server side
|
|
5
|
+
*/
|
|
6
|
+
export declare const IntlayerServerContext: {
|
|
7
|
+
Provider: ({ children, value, }: {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
value: Locales;
|
|
10
|
+
}) => React.ReactNode;
|
|
11
|
+
Consumer: ({ children, }: {
|
|
12
|
+
children: (context: Locales) => React.ReactNode;
|
|
13
|
+
}) => React.ReactNode;
|
|
14
|
+
_storage: () => {
|
|
15
|
+
value: Locales;
|
|
16
|
+
};
|
|
17
|
+
_defaultValue: Locales;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Hook that provides the current locale
|
|
21
|
+
*/
|
|
22
|
+
export declare const useIntlayer: () => Locales;
|
|
23
|
+
/**
|
|
24
|
+
* Get the current locale
|
|
25
|
+
*/
|
|
26
|
+
export declare const locale: Locales;
|
|
27
|
+
export type IntlayerServerProviderProps = PropsWithChildren & {
|
|
28
|
+
locale?: Locales;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Provider that store the current locale on the server side
|
|
32
|
+
*/
|
|
33
|
+
export declare const IntlayerServerProvider: FC<IntlayerServerProviderProps>;
|
|
34
|
+
//# sourceMappingURL=IntlayerServerProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntlayerServerProvider.d.ts","sourceRoot":"","sources":["../../../src/server/IntlayerServerProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAoB,MAAM,yBAAyB,CAAC;AACzE,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAKnD;;GAEG;AACH,eAAO,MAAM,qBAAqB;;kBA4B4c,MAAO,SAAS;;UAAuB,MAAO,SAAS;;wCAA+E,MAAO,SAAS;UAAS,MAAO,SAAS;;;;;CA3BhnB,CAAC;AAE9C;;GAEG;AACH,eAAO,MAAM,WAAW,eAAgD,CAAC;AAEzE;;GAEG;AACH,eAAO,MAAM,MAAM,SAA0C,CAAC;AAE9D,MAAM,MAAM,2BAA2B,GAAG,iBAAiB,GAAG;IAC5D,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CAOlE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type LanguageContent } from '@intlayer/core';
|
|
2
|
+
/**
|
|
3
|
+
* On the server side, get the translation content based on the locale
|
|
4
|
+
*/
|
|
5
|
+
export declare const getLocaleTranslation: <Content>(languageContent: LanguageContent<Content>) => {
|
|
6
|
+
locale: import("intlayer").Locales;
|
|
7
|
+
content: Content;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=getLocaleTranslation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLocaleTranslation.d.ts","sourceRoot":"","sources":["../../../src/server/getLocaleTranslation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,eAAe,EAAyB,MAAM,gBAAgB,CAAC;AAI7E;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,mBACzB,eAAe,CAAC,OAAO,CAAC;;;CAY1C,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { getLocaleTranslation as getLocaleContent } from './getLocaleTranslation';
|
|
2
|
+
export { useTraduction } from './useTraduction';
|
|
3
|
+
export { IntlayerServerContext as IntlayerServer, locale, IntlayerServerProvider, } from './IntlayerServerProvider';
|
|
4
|
+
export { useIntlayer } from './useIntlayer';
|
|
5
|
+
export { useDictionary } from './useDictionary';
|
|
6
|
+
export { t } from './t';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,qBAAqB,IAAI,cAAc,EACvC,MAAM,EACN,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC"}
|
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Creates a new datastore for a given server context.
|
|
3
|
-
* Attempts to closely mimic the `createContext` API.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* const IntlayerServer = createServerContext<string | null>(null);
|
|
7
|
-
*
|
|
8
|
-
* <IntlayerServer.Provider value={locale}>
|
|
9
|
-
* {children}
|
|
10
|
-
* </IntlayerServer.Provider>
|
|
11
|
-
*/
|
|
12
|
-
declare const createServerContext: <T>(defaultValue?: T) => ServerContext<T>;
|
|
1
|
+
export declare const createServerContext: <T>(defaultValue?: T) => ServerContext<T>;
|
|
13
2
|
/**
|
|
14
3
|
* Fetches a value present in a given server context.
|
|
15
4
|
* Attempts to closely mimic the `useContext` API.
|
|
@@ -17,7 +6,7 @@ declare const createServerContext: <T>(defaultValue?: T) => ServerContext<T>;
|
|
|
17
6
|
* @example
|
|
18
7
|
* getServerContext(IntlayerServer);
|
|
19
8
|
*/
|
|
20
|
-
declare const getServerContext: <T>({ _storage, _defaultValue, }: ServerContext<T>) => T
|
|
9
|
+
export declare const getServerContext: <T>({ _storage, _defaultValue, }: ServerContext<T>) => T;
|
|
21
10
|
type ServerContext<T> = {
|
|
22
11
|
Provider: ({ children, value, }: {
|
|
23
12
|
children: React.ReactNode;
|
|
@@ -31,5 +20,5 @@ type ServerContext<T> = {
|
|
|
31
20
|
};
|
|
32
21
|
_defaultValue: T | undefined;
|
|
33
22
|
};
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=serverContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverContext.d.ts","sourceRoot":"","sources":["../../../src/server/serverContext.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,mBAAmB,GAAI,CAAC,iBAAiB,CAAC,KAAG,aAAa,CAAC,CAAC,CAsBxE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,gCAG/B,aAAa,CAAC,CAAC,CAAC,MAKlB,CAAC;AAEF,KAAK,aAAa,CAAC,CAAC,IAAI;IACtB,QAAQ,EAAE,CAAC,EACT,QAAQ,EACR,KAAK,GACN,EAAE;QACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;QAC1B,KAAK,EAAE,CAAC,CAAC;KACV,KAAK,KAAK,CAAC,SAAS,CAAC;IACtB,QAAQ,EAAE,CAAC,EACT,QAAQ,GACT,EAAE;QACD,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,SAAS,KAAK,KAAK,CAAC,SAAS,CAAC;KACvD,KAAK,KAAK,CAAC,SAAS,CAAC;IACtB,QAAQ,EAAE,MAAM;QAAE,KAAK,EAAE,CAAC,GAAG,SAAS,CAAA;KAAE,CAAC;IACzC,aAAa,EAAE,CAAC,GAAG,SAAS,CAAC;CAC9B,CAAC"}
|