@intlayer/core 5.0.2 → 5.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/dictionaryManipulator/getSectionType.cjs.map +1 -1
- package/dist/cjs/interpreter/getDictionary.cjs.map +1 -1
- package/dist/cjs/interpreter/getIntlayer.cjs.map +1 -1
- package/dist/cjs/interpreter/getNesting.cjs.map +1 -1
- package/dist/cjs/transpiler/condition/condition.cjs +1 -4
- package/dist/cjs/transpiler/condition/condition.cjs.map +1 -1
- package/dist/cjs/transpiler/enumeration/enumeration.cjs +1 -4
- package/dist/cjs/transpiler/enumeration/enumeration.cjs.map +1 -1
- package/dist/cjs/transpiler/markdown/markdown.cjs +1 -4
- package/dist/cjs/transpiler/markdown/markdown.cjs.map +1 -1
- package/dist/cjs/transpiler/nesting/nesting.cjs +3 -6
- package/dist/cjs/transpiler/nesting/nesting.cjs.map +1 -1
- package/dist/cjs/transpiler/translation/translation.cjs +1 -4
- package/dist/cjs/transpiler/translation/translation.cjs.map +1 -1
- package/dist/cjs/transpiler/translation/types.cjs.map +1 -1
- package/dist/cjs/types/dictionary.cjs.map +1 -1
- package/dist/cjs/types/nodeType.cjs +8 -2
- package/dist/cjs/types/nodeType.cjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getSectionType.mjs.map +1 -1
- package/dist/esm/interpreter/getDictionary.mjs.map +1 -1
- package/dist/esm/interpreter/getIntlayer.mjs.map +1 -1
- package/dist/esm/interpreter/getNesting.mjs.map +1 -1
- package/dist/esm/transpiler/condition/condition.mjs +5 -5
- package/dist/esm/transpiler/condition/condition.mjs.map +1 -1
- package/dist/esm/transpiler/enumeration/enumeration.mjs +2 -5
- package/dist/esm/transpiler/enumeration/enumeration.mjs.map +1 -1
- package/dist/esm/transpiler/markdown/markdown.mjs +5 -5
- package/dist/esm/transpiler/markdown/markdown.mjs.map +1 -1
- package/dist/esm/transpiler/nesting/nesting.mjs +7 -7
- package/dist/esm/transpiler/nesting/nesting.mjs.map +1 -1
- package/dist/esm/transpiler/translation/translation.mjs +2 -5
- package/dist/esm/transpiler/translation/translation.mjs.map +1 -1
- package/dist/esm/types/nodeType.mjs +6 -1
- package/dist/esm/types/nodeType.mjs.map +1 -1
- package/dist/types/dictionaryManipulator/getSectionType.d.ts.map +1 -1
- package/dist/types/interpreter/getDictionary.d.ts +1 -1
- package/dist/types/interpreter/getDictionary.d.ts.map +1 -1
- package/dist/types/interpreter/getIntlayer.d.ts.map +1 -1
- package/dist/types/interpreter/getNesting.d.ts.map +1 -1
- package/dist/types/transpiler/condition/condition.d.ts +3 -13
- package/dist/types/transpiler/condition/condition.d.ts.map +1 -1
- package/dist/types/transpiler/enumeration/enumeration.d.ts +3 -24
- package/dist/types/transpiler/enumeration/enumeration.d.ts.map +1 -1
- package/dist/types/transpiler/markdown/markdown.d.ts +2 -5
- package/dist/types/transpiler/markdown/markdown.d.ts.map +1 -1
- package/dist/types/transpiler/nesting/nesting.d.ts +2 -5
- package/dist/types/transpiler/nesting/nesting.d.ts.map +1 -1
- package/dist/types/transpiler/translation/translation.d.ts +3 -2
- package/dist/types/transpiler/translation/translation.d.ts.map +1 -1
- package/dist/types/transpiler/translation/types.d.ts +7 -35
- package/dist/types/transpiler/translation/types.d.ts.map +1 -1
- package/dist/types/types/dictionary.d.ts +12 -14
- package/dist/types/types/dictionary.d.ts.map +1 -1
- package/dist/types/types/nodeType.d.ts +6 -0
- package/dist/types/types/nodeType.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/dictionaryManipulator/getSectionType.ts"],"sourcesContent":["import type {\n TranslationContent,\n EnumerationContent,\n ConditionContent,\n MarkdownContent,\n NestedContent,\n} from '../transpiler';\nimport { NodeType, type DictionaryKeys } from '../types';\nimport type { ContentNode } from '../types/dictionary';\nimport { isValidElement } from '../utils/isValidReactElement';\n\nexport const getSectionType = (section: ContentNode): NodeType => {\n if (typeof section === 'string') {\n return NodeType.Text;\n }\n\n if (
|
|
1
|
+
{"version":3,"sources":["../../../src/dictionaryManipulator/getSectionType.ts"],"sourcesContent":["import type {\n TranslationContent,\n EnumerationContent,\n ConditionContent,\n MarkdownContent,\n NestedContent,\n} from '../transpiler';\nimport { NodeType, type DictionaryKeys } from '../types';\nimport type { ContentNode } from '../types/dictionary';\nimport { isValidElement } from '../utils/isValidReactElement';\n\nexport const getSectionType = (section: ContentNode): NodeType => {\n if (typeof section === 'string') {\n return NodeType.Text;\n }\n\n if ((section as TranslationContent)?.nodeType === NodeType.Translation) {\n return NodeType.Translation;\n }\n\n if ((section as EnumerationContent)?.nodeType === NodeType.Enumeration) {\n return NodeType.Enumeration;\n }\n\n if ((section as ConditionContent)?.nodeType === NodeType.Condition) {\n return NodeType.Condition;\n }\n\n if ((section as MarkdownContent)?.nodeType === NodeType.Markdown) {\n return NodeType.Markdown;\n }\n\n if (\n (section as NestedContent<DictionaryKeys>)?.nodeType === NodeType.Nested\n ) {\n return NodeType.Nested;\n }\n\n if (Array.isArray(section)) {\n return NodeType.Array;\n }\n\n if (isValidElement(section)) {\n return NodeType.ReactNode;\n }\n\n return NodeType.Object;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,mBAA8C;AAE9C,iCAA+B;AAExB,MAAM,iBAAiB,CAAC,YAAmC;AAChE,MAAI,OAAO,YAAY,UAAU;AAC/B,WAAO,sBAAS;AAAA,EAClB;AAEA,MAAK,SAAgC,aAAa,sBAAS,aAAa;AACtE,WAAO,sBAAS;AAAA,EAClB;AAEA,MAAK,SAAgC,aAAa,sBAAS,aAAa;AACtE,WAAO,sBAAS;AAAA,EAClB;AAEA,MAAK,SAA8B,aAAa,sBAAS,WAAW;AAClE,WAAO,sBAAS;AAAA,EAClB;AAEA,MAAK,SAA6B,aAAa,sBAAS,UAAU;AAChE,WAAO,sBAAS;AAAA,EAClB;AAEA,MACG,SAA2C,aAAa,sBAAS,QAClE;AACA,WAAO,sBAAS;AAAA,EAClB;AAEA,MAAI,MAAM,QAAQ,OAAO,GAAG;AAC1B,WAAO,sBAAS;AAAA,EAClB;AAEA,UAAI,2CAAe,OAAO,GAAG;AAC3B,WAAO,sBAAS;AAAA,EAClB;AAEA,SAAO,sBAAS;AAClB;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/interpreter/getDictionary.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Locales, LocalesValues } from '@intlayer/config/client';\nimport type { Dictionary } from '../types';\nimport { getContent } from './getContent/getContent';\nimport type { Plugins, NodeProps, DeepTransformContent } from './getContent';\n\n/**\n * Transforms a dictionary in a single pass, applying each plugin as needed.\n *\n * @param dictionary The dictionary to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n * @param additionalPlugins An array of NodeTransformer that define how to transform recognized nodes.\n * If omitted, we’ll use a default set of plugins.\n */\nexport const getDictionary = <\n T extends Dictionary
|
|
1
|
+
{"version":3,"sources":["../../../src/interpreter/getDictionary.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Locales, LocalesValues } from '@intlayer/config/client';\nimport type { Dictionary } from '../types';\nimport { getContent } from './getContent/getContent';\nimport type { Plugins, NodeProps, DeepTransformContent } from './getContent';\n\n/**\n * Transforms a dictionary in a single pass, applying each plugin as needed.\n *\n * @param dictionary The dictionary to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n * @param additionalPlugins An array of NodeTransformer that define how to transform recognized nodes.\n * If omitted, we’ll use a default set of plugins.\n */\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = Locales,\n>(\n dictionary: T,\n locale?: L,\n plugins?: Plugins[]\n) => {\n const props: NodeProps = {\n dictionaryKey: dictionary.key,\n dictionaryPath: dictionary.filePath,\n keyPath: [],\n plugins,\n };\n\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n return getContent(\n dictionary.content,\n props,\n locale\n ) as any as DeepTransformContent<T['content']>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAA2B;AAWpB,MAAM,gBAAgB,CAI3B,YACA,QACA,YACG;AACH,QAAM,QAAmB;AAAA,IACvB,eAAe,WAAW;AAAA,IAC1B,gBAAgB,WAAW;AAAA,IAC3B,SAAS,CAAC;AAAA,IACV;AAAA,EACF;AAGA,aAAO;AAAA,IACL,WAAW;AAAA,IACX;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/interpreter/getIntlayer.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { LocalesValues } from '@intlayer/config';\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 { Dictionary, DictionaryKeys } from '../types';\nimport { getDictionary } from './getDictionary';\n// @ts-ignore intlayer declared for module augmentation\nimport { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type { DeepTransformContent, Plugins } from './getContent/plugins';\n\nexport const getIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: L,\n plugins?: Plugins[]\n) => {\n const dictionary = dictionaries[key as T];\n\n if (!dictionary) {\n throw new Error(`Dictionary ${key as string} not found`, dictionaries);\n }\n\n return getDictionary(\n dictionary as
|
|
1
|
+
{"version":3,"sources":["../../../src/interpreter/getIntlayer.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/import/no-cycle */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { LocalesValues } from '@intlayer/config';\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 { Dictionary, DictionaryKeys } from '../types';\nimport { getDictionary } from './getDictionary';\n// @ts-ignore intlayer declared for module augmentation\nimport { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type { DeepTransformContent, Plugins } from './getContent/plugins';\n\nexport const getIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: L,\n plugins?: Plugins[]\n) => {\n const dictionary = dictionaries[key as T];\n\n if (!dictionary) {\n throw new Error(`Dictionary ${key as string} not found`, dictionaries);\n }\n\n return getDictionary(\n dictionary as Dictionary,\n locale,\n plugins\n ) as any as DeepTransformContent<\n IntlayerDictionaryTypesConnector[T]['content']\n >;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,gCAAyB;AAEzB,2BAA8B;AAKvB,MAAM,cAAc,CACzB,KACA,QACA,YACG;AACH,QAAM,aAAa,0BAAAA,QAAa,GAAQ;AAExC,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,cAAc,GAAa,cAAc,0BAAAA,OAAY;AAAA,EACvE;AAEA,aAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAGF;","names":["dictionaries"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/interpreter/getNesting.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { ValidDotPathsFor } from '../transpiler';\nimport type { DictionaryKeys } from '../types';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n} from './getContent';\nimport { getIntlayer } from './getIntlayer';\n// @ts-ignore intlayer declared for module augmentation\nimport { IntlayerDictionaryTypesConnector } from 'intlayer';\n\ntype GetSubPath<T, P> = P extends `${infer K}.${infer Rest}`\n ? K extends keyof T\n ? GetSubPath<T[K], Rest>\n : never\n : P extends keyof T\n ? T[P]\n : T;\n\nexport type GetNestingResult<\n K extends DictionaryKeys,\n P = undefined,\n S = IInterpreterPluginState,\n> = GetSubPath<\n DeepTransformContent<IntlayerDictionaryTypesConnector[K]['content'], S>,\n P\n>;\n\n/**\n * Allow to extract the content of another dictionary.\n *\n * Usage:\n * ```ts\n * const content = getNesting(\"dictionaryKey\", \"path.to.content\");\n * // 'Example content'\n * ```\n */\nexport const getNesting = <K extends DictionaryKeys, P>(\n dictionaryKey: K,\n path?: P extends ValidDotPathsFor<K> ? P : never,\n props?: NodeProps\n): GetNestingResult<K, P> => {\n const dictionary = getIntlayer(dictionaryKey, props?.locale, props?.plugins);\n\n if (typeof path === 'string') {\n const pathArray = (path as string).split('.');\n let current: any = dictionary;\n\n for (const key of pathArray) {\n // Safely traverse down the object using the path\n current = current?.[key];\n // If we cannot find the path, return the whole dictionary as a fallback\n if (current === undefined) {\n return dictionary as any;\n }\n }\n\n return current;\n }\n\n // Default or error handling if path is not a string or otherwise undefined\n return dictionary as any;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../../src/interpreter/getNesting.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/import/no-cycle */\nimport type { ValidDotPathsFor } from '../transpiler';\nimport type { DictionaryKeys } from '../types';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n} from './getContent';\nimport { getIntlayer } from './getIntlayer';\n// @ts-ignore intlayer declared for module augmentation\nimport { IntlayerDictionaryTypesConnector } from 'intlayer';\n\ntype GetSubPath<T, P> = P extends `${infer K}.${infer Rest}`\n ? K extends keyof T\n ? GetSubPath<T[K], Rest>\n : never\n : P extends keyof T\n ? T[P]\n : T;\n\nexport type GetNestingResult<\n K extends DictionaryKeys,\n P = undefined,\n S = IInterpreterPluginState,\n> = GetSubPath<\n DeepTransformContent<IntlayerDictionaryTypesConnector[K]['content'], S>,\n P\n>;\n\n/**\n * Allow to extract the content of another dictionary.\n *\n * Usage:\n * ```ts\n * const content = getNesting(\"dictionaryKey\", \"path.to.content\");\n * // 'Example content'\n * ```\n */\nexport const getNesting = <K extends DictionaryKeys, P>(\n dictionaryKey: K,\n path?: P extends ValidDotPathsFor<K> ? P : never,\n props?: NodeProps\n): GetNestingResult<K, P> => {\n const dictionary = getIntlayer(dictionaryKey, props?.locale, props?.plugins);\n\n if (typeof path === 'string') {\n const pathArray = (path as string).split('.');\n let current: any = dictionary;\n\n for (const key of pathArray) {\n // Safely traverse down the object using the path\n current = current?.[key];\n // If we cannot find the path, return the whole dictionary as a fallback\n if (current === undefined) {\n return dictionary as any;\n }\n }\n\n return current;\n }\n\n // Default or error handling if path is not a string or otherwise undefined\n return dictionary as any;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,yBAA4B;AA8BrB,MAAM,aAAa,CACxB,eACA,MACA,UAC2B;AAC3B,QAAM,iBAAa,gCAAY,eAAe,OAAO,QAAQ,OAAO,OAAO;AAE3E,MAAI,OAAO,SAAS,UAAU;AAC5B,UAAM,YAAa,KAAgB,MAAM,GAAG;AAC5C,QAAI,UAAe;AAEnB,eAAW,OAAO,WAAW;AAE3B,gBAAU,UAAU,GAAG;AAEvB,UAAI,YAAY,QAAW;AACzB,eAAO;AAAA,MACT;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAGA,SAAO;AACT;","names":[]}
|
|
@@ -22,10 +22,7 @@ __export(condition_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(condition_exports);
|
|
24
24
|
var import_types = require('../../types/index.cjs');
|
|
25
|
-
const condition = (content) => (
|
|
26
|
-
nodeType: import_types.NodeType.Condition,
|
|
27
|
-
[import_types.NodeType.Condition]: { ...content }
|
|
28
|
-
});
|
|
25
|
+
const condition = (content) => (0, import_types.formatNodeType)(import_types.NodeType.Condition, content);
|
|
29
26
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
27
|
0 && (module.exports = {
|
|
31
28
|
cond
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/condition/condition.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/condition/condition.ts"],"sourcesContent":["import {\n formatNodeType,\n NodeType,\n type TypedNodeModel,\n} from '../../types/index';\n\nexport type ConditionContentStates<Content> = Record<`${boolean}`, Content> & {\n fallback?: Content;\n};\n\nexport type ConditionContent<Content = unknown> = TypedNodeModel<\n NodeType.Condition,\n ConditionContentStates<Content>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a condition.\n *\n * Usage:\n *\n * ```ts\n * cond({\n * 'true': 'The condition is validated',\n * 'false': 'The condition is not validated',\n * });\n * ```\n *\n * The last key provided will be used as the fallback value.\n *\n */\nconst condition = <Content>(content?: ConditionContentStates<Content>) =>\n formatNodeType(NodeType.Condition, content);\n\nexport { condition as cond };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAIO;AA4BP,MAAM,YAAY,CAAU,gBAC1B,6BAAe,sBAAS,WAAW,OAAO;","names":[]}
|
|
@@ -22,10 +22,7 @@ __export(enumeration_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(enumeration_exports);
|
|
24
24
|
var import_types = require('../../types/index.cjs');
|
|
25
|
-
const enumeration = (content) => (
|
|
26
|
-
nodeType: import_types.NodeType.Enumeration,
|
|
27
|
-
[import_types.NodeType.Enumeration]: { ...content }
|
|
28
|
-
});
|
|
25
|
+
const enumeration = (content) => (0, import_types.formatNodeType)(import_types.NodeType.Enumeration, content);
|
|
29
26
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
27
|
0 && (module.exports = {
|
|
31
28
|
enu
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/enumeration/enumeration.ts"],"sourcesContent":["import { NodeType } from '../../types/index';\n\ntype Positif = number | `${number}`;\ntype Negatif = `-${number}`;\ntype Numbers = Positif | Negatif;\n\ntype Equal = Numbers;\ntype EqualString = `=${Numbers}`;\ntype Superior = `>${Numbers}`;\ntype SuperiorOrEqual = `>=${Numbers}`;\ntype Inferior = `<${Numbers}`;\ntype InferiorOrEqual = `<=${Numbers}`;\n\nexport type EnterFormat =\n | Equal\n | EqualString\n | Superior\n | SuperiorOrEqual\n | Inferior\n | InferiorOrEqual;\n\nexport type EnumerationContentState<Content> = Partial<\n Record<EnterFormat, Content>\n> & {\n fallback?: Content;\n};\n\nexport type EnumerationContent<Content = unknown> =
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/enumeration/enumeration.ts"],"sourcesContent":["import { formatNodeType, NodeType, TypedNodeModel } from '../../types/index';\n\ntype Positif = number | `${number}`;\ntype Negatif = `-${number}`;\ntype Numbers = Positif | Negatif;\n\ntype Equal = Numbers;\ntype EqualString = `=${Numbers}`;\ntype Superior = `>${Numbers}`;\ntype SuperiorOrEqual = `>=${Numbers}`;\ntype Inferior = `<${Numbers}`;\ntype InferiorOrEqual = `<=${Numbers}`;\n\nexport type EnterFormat =\n | Equal\n | EqualString\n | Superior\n | SuperiorOrEqual\n | Inferior\n | InferiorOrEqual;\n\nexport type EnumerationContentState<Content> = Partial<\n Record<EnterFormat, Content>\n> & {\n fallback?: Content;\n};\n\nexport type EnumerationContent<Content = unknown> = TypedNodeModel<\n NodeType.Enumeration,\n EnumerationContentState<Content>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * enu({\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 * });\n * ```\n *\n * > The order of the keys will define the priority of the content.\n *\n */\nconst enumeration = <Content>(content?: EnumerationContentState<Content>) =>\n formatNodeType(NodeType.Enumeration, content);\n\nexport { enumeration as enu };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAyD;AAmDzD,MAAM,cAAc,CAAU,gBAC5B,6BAAe,sBAAS,aAAa,OAAO;","names":[]}
|
|
@@ -22,10 +22,7 @@ __export(markdown_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(markdown_exports);
|
|
24
24
|
var import_types = require('../../types/index.cjs');
|
|
25
|
-
const markdown = (content) => (
|
|
26
|
-
nodeType: import_types.NodeType.Markdown,
|
|
27
|
-
[import_types.NodeType.Markdown]: content
|
|
28
|
-
});
|
|
25
|
+
const markdown = (content) => (0, import_types.formatNodeType)(import_types.NodeType.Markdown, content);
|
|
29
26
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
27
|
0 && (module.exports = {
|
|
31
28
|
md
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/markdown/markdown.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/markdown/markdown.ts"],"sourcesContent":["import {\n formatNodeType,\n NodeType,\n type TypedNodeModel,\n} from '../../types/index';\n\nexport type MarkdownContentState = string;\n\nexport type MarkdownContent = TypedNodeModel<\n NodeType.Markdown,\n MarkdownContentState\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * markdown('## Hello world!');\n * ```\n *\n */\nconst markdown = (content: string): MarkdownContent =>\n formatNodeType(NodeType.Markdown, content);\n\nexport { markdown as md };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAIO;AAqBP,MAAM,WAAW,CAAC,gBAChB,6BAAe,sBAAS,UAAU,OAAO;","names":[]}
|
|
@@ -22,12 +22,9 @@ __export(nesting_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(nesting_exports);
|
|
24
24
|
var import_types = require('../../types/index.cjs');
|
|
25
|
-
const nesting = (dictionaryKey, path) => ({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
dictionaryKey,
|
|
29
|
-
path
|
|
30
|
-
}
|
|
25
|
+
const nesting = (dictionaryKey, path) => (0, import_types.formatNodeType)(import_types.NodeType.Nested, {
|
|
26
|
+
dictionaryKey,
|
|
27
|
+
path
|
|
31
28
|
});
|
|
32
29
|
// Annotate the CommonJS export names for ESM import in node:
|
|
33
30
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/nesting/nesting.ts"],"sourcesContent":["// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type { DictionaryKeys } from '../../types/dictionary';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/nesting/nesting.ts"],"sourcesContent":["// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type { DictionaryKeys } from '../../types/dictionary';\nimport {\n formatNodeType,\n NodeType,\n type TypedNodeModel,\n} from '../../types/index';\nimport type { DeepTransformContent } from '../../interpreter';\n\n/**\n * Recursively builds dot-notation strings for all valid paths in T.\n * Example:\n * type X = { a: { b: { c: string }}, d: number };\n * DotPath<X> = \"a\" | \"a.b\" | \"a.b.c\" | \"d\"\n */\nexport type DotPath<T> = T extends object\n ? {\n [K in keyof T & (string | number)]: T[K] extends object\n ? // Either just K, or K + '.' + deeper path\n `${K}` | `${K}.${DotPath<T[K]>}`\n : `${K}`;\n }[keyof T & (string | number)]\n : never;\n\ntype DeepReplace<T, From, To> = T extends From\n ? To\n : T extends object\n ? { [K in keyof T]: DeepReplace<T[K], From, To> }\n : T;\n\n/** Build all valid dot-notation strings for a dictionary entry. */\nexport type ValidDotPathsFor<K extends DictionaryKeys> = DotPath<\n DeepReplace<\n DeepTransformContent<IntlayerDictionaryTypesConnector[K]['content']>,\n // Replace ReactElement type with string\n {\n type: any;\n props: any;\n key: any;\n },\n string\n >\n>;\n\nexport type NestedContentState<K extends DictionaryKeys> = {\n dictionaryKey: K;\n\n /**\n * Path must match existing keys in IntlayerDictionaryTypesConnector[K].\n * Can be either:\n * - \"dot.dot.dot\" format\n */\n path?: ValidDotPathsFor<K>;\n};\n\nexport type NestedContent<K extends DictionaryKeys = never> = TypedNodeModel<\n NodeType.Nested,\n NestedContentState<K>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to extract the content of another dictionary and nest it in the current dictionary.\n *\n * Usage:\n *\n * ```ts\n * nest(\"dictionaryKey\");\n * nest(\"dictionaryKey\", \"path.to.content\");\n * ```\n *\n * The order of the keys will define the priority of the content.\n *\n */\nconst nesting = <K extends DictionaryKeys>(\n dictionaryKey: K,\n path?: ValidDotPathsFor<K>\n): NestedContent<K> =>\n formatNodeType(NodeType.Nested, {\n dictionaryKey,\n path,\n });\n\nexport { nesting as nest };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAIO;AAqEP,MAAM,UAAU,CACd,eACA,aAEA,6BAAe,sBAAS,QAAQ;AAAA,EAC9B;AAAA,EACA;AACF,CAAC;","names":[]}
|
|
@@ -22,10 +22,7 @@ __export(translation_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(translation_exports);
|
|
24
24
|
var import_types = require('../../types/index.cjs');
|
|
25
|
-
const translation = (content) => (
|
|
26
|
-
nodeType: import_types.NodeType.Translation,
|
|
27
|
-
[import_types.NodeType.Translation]: content
|
|
28
|
-
});
|
|
25
|
+
const translation = (content) => (0, import_types.formatNodeType)(import_types.NodeType.Translation, content);
|
|
29
26
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
27
|
0 && (module.exports = {
|
|
31
28
|
t
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/translation/translation.ts"],"sourcesContent":["import { NodeType } from '../../types/index';\nimport type { LanguageContent, TranslationContent } from './types';\n\n/**\n *\n * Function intended to be used to build intlayer dictionaries.\n *\n * Get the content of a translation based on the locale.\n *\n * Usage:\n *\n * ```ts\n * translation<string>({\n * \"en\": \"Hello\",\n * \"fr\": \"Bonjour\",\n * // ... any other available locale\n * })\n * ```\n *\n * Using TypeScript:\n * - this function 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 */\nconst translation =
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/translation/translation.ts"],"sourcesContent":["import { formatNodeType, NodeType } from '../../types/index';\nimport type { LanguageContent, TranslationContent } from './types';\n\n/**\n *\n * Function intended to be used to build intlayer dictionaries.\n *\n * Get the content of a translation based on the locale.\n *\n * Usage:\n *\n * ```ts\n * translation<string>({\n * \"en\": \"Hello\",\n * \"fr\": \"Bonjour\",\n * // ... any other available locale\n * })\n * ```\n *\n * Using TypeScript:\n * - this function 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 */\nconst translation = <\n Content = unknown,\n ContentRecord extends LanguageContent<Content> = LanguageContent<Content>,\n>(\n content: ContentRecord\n) =>\n formatNodeType(NodeType.Translation, content) satisfies TranslationContent<\n Content,\n ContentRecord\n >;\n\nexport { translation as t };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAyC;AAuBzC,MAAM,cAAc,CAIlB,gBAEA,6BAAe,sBAAS,aAAa,OAAO;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/translation/types.ts"],"sourcesContent":["/** @ts-nocheck */\n\nimport type { LocalesValues } from '@intlayer/config/client';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IConfigLocales } from 'intlayer';\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/translation/types.ts"],"sourcesContent":["/** @ts-nocheck */\n\nimport type { LocalesValues } from '@intlayer/config/client';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IConfigLocales } from 'intlayer';\nimport { NodeType, TypedNodeModel } from '../../types/index';\n\n/**\n * If module augmented, it will return the configured locales such as Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH | ...\n * If not, it will return never\n */\nexport type ConfigLocales = keyof IConfigLocales<unknown>;\n\n/**\n * Record of locales and content\n *\n * const myVar1: TranslationContentState<string> = {\n * \"en\": \"\",\n * \"fr\": \"\"\n * }\n *\n * const myVar2: TranslationContentState<{age: number, name: string}> = {\n * \"en\": {age: 1, name: \"test\"},\n * \"fr\": {age: 1, name: \"test\"}\n * }\n */\nexport type TranslationContentState<Content = unknown> = {\n [locale in LocalesValues]?: Content;\n};\n\nexport type LanguageContent<Content = unknown> =\n keyof IConfigLocales<unknown> extends never\n ? TranslationContentState<Content> // Fall including all locales as optional\n : IConfigLocales<Content>;\n\nexport type TranslationContent<\n Content = unknown,\n RecordContent extends LanguageContent<Content> = LanguageContent<Content>,\n> = TypedNodeModel<NodeType.Translation, RecordContent>;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/types/dictionary.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n// @ts-ignore intlayer declared for module augmentation\nimport { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type {\n ConditionContent,\n EnumerationContent,\n MarkdownContent,\n NestedContent,\n TranslationContent,\n} from '../transpiler/index';\n\n/**\n * Provides a fallback to string type if the generic type T is
|
|
1
|
+
{"version":3,"sources":["../../../src/types/dictionary.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n// @ts-ignore intlayer declared for module augmentation\nimport { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type {\n ConditionContent,\n EnumerationContent,\n MarkdownContent,\n NestedContent,\n TranslationContent,\n} from '../transpiler/index';\n\n/**\n * Provides a fallback to string type if the generic type T is undefined,\n * otherwise returns T. This is useful for handling cases where no keys are found.\n * Example: StringFallback<undefined> -> string; StringFallback<'key'> -> 'key'\n */\nexport type StringFallback<T> = T extends undefined ? 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\nexport type TypedNode<NodeType = undefined> =\n | TranslationContent<NodeType>\n | EnumerationContent<NodeType>\n | ConditionContent<NodeType>\n | MarkdownContent\n | NestedContent<DictionaryKeys>;\n\ntype FetchableContentNode<NodeType> = (\n args?: any\n) => ContentNode<NodeType> | Promise<ContentNode<NodeType>>;\n\nexport type ContentNode<NodeType = undefined, FetchableNode = false> =\n | NodeType\n | TypedNode<NodeType>\n | ((args?: any) => ContentNode<NodeType>)\n | (FetchableNode extends true ? FetchableContentNode<NodeType> : undefined);\n\n// Utility types (unchanged)\ntype IsArray<T> = T extends any[] ? true : false;\n\ntype ReplaceContentValueArray<T, FetchableNode> = T extends (infer U)[]\n ? ReplaceContentValue<U, FetchableNode>[]\n : ReplaceContentValue<T, FetchableNode>;\n\ntype ReplaceContentValueObject<T, FetchableNode> = {\n [K in keyof T]: ReplaceContentValue<T[K], FetchableNode>;\n};\n\n// Modified: allow a full ContentNode wrapper OR an object shape when T is an object\ntype ReplaceContentValue<\n NodeType,\n FetchableNode = true,\n> = NodeType extends object\n ? IsArray<NodeType> extends true\n ? ReplaceContentValueArray<NodeType, FetchableNode>\n :\n | ContentNode<NodeType, FetchableNode>\n | ReplaceContentValueObject<NodeType, FetchableNode>\n : ContentNode<NodeType, FetchableNode>;\n\nexport type Dictionary<ContentType = undefined, FetchableNode = false> = {\n $schema?: string;\n key: string;\n title?: string;\n description?: string;\n availableVersions?: string[];\n version?: string;\n filePath?: string;\n tags?: string[];\n content: ContentType extends undefined // Applying the generic to replace ContentValue with Replacement\n ? any\n : ReplaceContentValue<ContentType, FetchableNode> | ContentType;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -18,7 +18,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var nodeType_exports = {};
|
|
20
20
|
__export(nodeType_exports, {
|
|
21
|
-
NodeType: () => NodeType
|
|
21
|
+
NodeType: () => NodeType,
|
|
22
|
+
formatNodeType: () => formatNodeType
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(nodeType_exports);
|
|
24
25
|
var NodeType = /* @__PURE__ */ ((NodeType2) => {
|
|
@@ -33,8 +34,13 @@ var NodeType = /* @__PURE__ */ ((NodeType2) => {
|
|
|
33
34
|
NodeType2["Markdown"] = "markdown";
|
|
34
35
|
return NodeType2;
|
|
35
36
|
})(NodeType || {});
|
|
37
|
+
const formatNodeType = (nodeType, content) => ({
|
|
38
|
+
nodeType,
|
|
39
|
+
[nodeType]: content
|
|
40
|
+
});
|
|
36
41
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
42
|
0 && (module.exports = {
|
|
38
|
-
NodeType
|
|
43
|
+
NodeType,
|
|
44
|
+
formatNodeType
|
|
39
45
|
});
|
|
40
46
|
//# sourceMappingURL=nodeType.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/types/nodeType.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/types/nodeType.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nexport enum NodeType {\n Translation = 'translation',\n Enumeration = 'enumeration',\n Condition = 'condition',\n Object = 'object',\n Array = 'array',\n Text = 'text',\n Nested = 'nested',\n ReactNode = 'reactNode',\n Markdown = 'markdown',\n}\n\nexport type TypedNodeModel<T extends NodeType, Content> = {\n nodeType: T | `${T}`;\n} & {\n [K in T]: Content;\n};\n\nexport const formatNodeType = <T extends NodeType, Content = any>(\n nodeType: T | `${T}`,\n content: Content\n) =>\n ({\n nodeType,\n [nodeType]: content,\n }) as TypedNodeModel<T, Content>;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACO,IAAK,WAAL,kBAAKA,cAAL;AACL,EAAAA,UAAA,iBAAc;AACd,EAAAA,UAAA,iBAAc;AACd,EAAAA,UAAA,eAAY;AACZ,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,WAAQ;AACR,EAAAA,UAAA,UAAO;AACP,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,eAAY;AACZ,EAAAA,UAAA,cAAW;AATD,SAAAA;AAAA,GAAA;AAkBL,MAAM,iBAAiB,CAC5B,UACA,aAEC;AAAA,EACC;AAAA,EACA,CAAC,QAAQ,GAAG;AACd;","names":["NodeType"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/dictionaryManipulator/getSectionType.ts"],"sourcesContent":["import type {\n TranslationContent,\n EnumerationContent,\n ConditionContent,\n MarkdownContent,\n NestedContent,\n} from '../transpiler';\nimport { NodeType, type DictionaryKeys } from '../types';\nimport type { ContentNode } from '../types/dictionary';\nimport { isValidElement } from '../utils/isValidReactElement';\n\nexport const getSectionType = (section: ContentNode): NodeType => {\n if (typeof section === 'string') {\n return NodeType.Text;\n }\n\n if (
|
|
1
|
+
{"version":3,"sources":["../../../src/dictionaryManipulator/getSectionType.ts"],"sourcesContent":["import type {\n TranslationContent,\n EnumerationContent,\n ConditionContent,\n MarkdownContent,\n NestedContent,\n} from '../transpiler';\nimport { NodeType, type DictionaryKeys } from '../types';\nimport type { ContentNode } from '../types/dictionary';\nimport { isValidElement } from '../utils/isValidReactElement';\n\nexport const getSectionType = (section: ContentNode): NodeType => {\n if (typeof section === 'string') {\n return NodeType.Text;\n }\n\n if ((section as TranslationContent)?.nodeType === NodeType.Translation) {\n return NodeType.Translation;\n }\n\n if ((section as EnumerationContent)?.nodeType === NodeType.Enumeration) {\n return NodeType.Enumeration;\n }\n\n if ((section as ConditionContent)?.nodeType === NodeType.Condition) {\n return NodeType.Condition;\n }\n\n if ((section as MarkdownContent)?.nodeType === NodeType.Markdown) {\n return NodeType.Markdown;\n }\n\n if (\n (section as NestedContent<DictionaryKeys>)?.nodeType === NodeType.Nested\n ) {\n return NodeType.Nested;\n }\n\n if (Array.isArray(section)) {\n return NodeType.Array;\n }\n\n if (isValidElement(section)) {\n return NodeType.ReactNode;\n }\n\n return NodeType.Object;\n};\n"],"mappings":"AAOA,SAAS,gBAAqC;AAE9C,SAAS,sBAAsB;AAExB,MAAM,iBAAiB,CAAC,YAAmC;AAChE,MAAI,OAAO,YAAY,UAAU;AAC/B,WAAO,SAAS;AAAA,EAClB;AAEA,MAAK,SAAgC,aAAa,SAAS,aAAa;AACtE,WAAO,SAAS;AAAA,EAClB;AAEA,MAAK,SAAgC,aAAa,SAAS,aAAa;AACtE,WAAO,SAAS;AAAA,EAClB;AAEA,MAAK,SAA8B,aAAa,SAAS,WAAW;AAClE,WAAO,SAAS;AAAA,EAClB;AAEA,MAAK,SAA6B,aAAa,SAAS,UAAU;AAChE,WAAO,SAAS;AAAA,EAClB;AAEA,MACG,SAA2C,aAAa,SAAS,QAClE;AACA,WAAO,SAAS;AAAA,EAClB;AAEA,MAAI,MAAM,QAAQ,OAAO,GAAG;AAC1B,WAAO,SAAS;AAAA,EAClB;AAEA,MAAI,eAAe,OAAO,GAAG;AAC3B,WAAO,SAAS;AAAA,EAClB;AAEA,SAAO,SAAS;AAClB;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/interpreter/getDictionary.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Locales, LocalesValues } from '@intlayer/config/client';\nimport type { Dictionary } from '../types';\nimport { getContent } from './getContent/getContent';\nimport type { Plugins, NodeProps, DeepTransformContent } from './getContent';\n\n/**\n * Transforms a dictionary in a single pass, applying each plugin as needed.\n *\n * @param dictionary The dictionary to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n * @param additionalPlugins An array of NodeTransformer that define how to transform recognized nodes.\n * If omitted, we’ll use a default set of plugins.\n */\nexport const getDictionary = <\n T extends Dictionary
|
|
1
|
+
{"version":3,"sources":["../../../src/interpreter/getDictionary.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Locales, LocalesValues } from '@intlayer/config/client';\nimport type { Dictionary } from '../types';\nimport { getContent } from './getContent/getContent';\nimport type { Plugins, NodeProps, DeepTransformContent } from './getContent';\n\n/**\n * Transforms a dictionary in a single pass, applying each plugin as needed.\n *\n * @param dictionary The dictionary to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n * @param additionalPlugins An array of NodeTransformer that define how to transform recognized nodes.\n * If omitted, we’ll use a default set of plugins.\n */\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = Locales,\n>(\n dictionary: T,\n locale?: L,\n plugins?: Plugins[]\n) => {\n const props: NodeProps = {\n dictionaryKey: dictionary.key,\n dictionaryPath: dictionary.filePath,\n keyPath: [],\n plugins,\n };\n\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n return getContent(\n dictionary.content,\n props,\n locale\n ) as any as DeepTransformContent<T['content']>;\n};\n"],"mappings":"AAGA,SAAS,kBAAkB;AAWpB,MAAM,gBAAgB,CAI3B,YACA,QACA,YACG;AACH,QAAM,QAAmB;AAAA,IACvB,eAAe,WAAW;AAAA,IAC1B,gBAAgB,WAAW;AAAA,IAC3B,SAAS,CAAC;AAAA,IACV;AAAA,EACF;AAGA,SAAO;AAAA,IACL,WAAW;AAAA,IACX;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/interpreter/getIntlayer.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { LocalesValues } from '@intlayer/config';\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 { Dictionary, DictionaryKeys } from '../types';\nimport { getDictionary } from './getDictionary';\n// @ts-ignore intlayer declared for module augmentation\nimport { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type { DeepTransformContent, Plugins } from './getContent/plugins';\n\nexport const getIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: L,\n plugins?: Plugins[]\n) => {\n const dictionary = dictionaries[key as T];\n\n if (!dictionary) {\n throw new Error(`Dictionary ${key as string} not found`, dictionaries);\n }\n\n return getDictionary(\n dictionary as
|
|
1
|
+
{"version":3,"sources":["../../../src/interpreter/getIntlayer.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/import/no-cycle */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { LocalesValues } from '@intlayer/config';\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 { Dictionary, DictionaryKeys } from '../types';\nimport { getDictionary } from './getDictionary';\n// @ts-ignore intlayer declared for module augmentation\nimport { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type { DeepTransformContent, Plugins } from './getContent/plugins';\n\nexport const getIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: L,\n plugins?: Plugins[]\n) => {\n const dictionary = dictionaries[key as T];\n\n if (!dictionary) {\n throw new Error(`Dictionary ${key as string} not found`, dictionaries);\n }\n\n return getDictionary(\n dictionary as Dictionary,\n locale,\n plugins\n ) as any as DeepTransformContent<\n IntlayerDictionaryTypesConnector[T]['content']\n >;\n};\n"],"mappings":"AAQA,OAAO,kBAAkB;AAEzB,SAAS,qBAAqB;AAKvB,MAAM,cAAc,CACzB,KACA,QACA,YACG;AACH,QAAM,aAAa,aAAa,GAAQ;AAExC,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,cAAc,GAAa,cAAc,YAAY;AAAA,EACvE;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAGF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/interpreter/getNesting.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { ValidDotPathsFor } from '../transpiler';\nimport type { DictionaryKeys } from '../types';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n} from './getContent';\nimport { getIntlayer } from './getIntlayer';\n// @ts-ignore intlayer declared for module augmentation\nimport { IntlayerDictionaryTypesConnector } from 'intlayer';\n\ntype GetSubPath<T, P> = P extends `${infer K}.${infer Rest}`\n ? K extends keyof T\n ? GetSubPath<T[K], Rest>\n : never\n : P extends keyof T\n ? T[P]\n : T;\n\nexport type GetNestingResult<\n K extends DictionaryKeys,\n P = undefined,\n S = IInterpreterPluginState,\n> = GetSubPath<\n DeepTransformContent<IntlayerDictionaryTypesConnector[K]['content'], S>,\n P\n>;\n\n/**\n * Allow to extract the content of another dictionary.\n *\n * Usage:\n * ```ts\n * const content = getNesting(\"dictionaryKey\", \"path.to.content\");\n * // 'Example content'\n * ```\n */\nexport const getNesting = <K extends DictionaryKeys, P>(\n dictionaryKey: K,\n path?: P extends ValidDotPathsFor<K> ? P : never,\n props?: NodeProps\n): GetNestingResult<K, P> => {\n const dictionary = getIntlayer(dictionaryKey, props?.locale, props?.plugins);\n\n if (typeof path === 'string') {\n const pathArray = (path as string).split('.');\n let current: any = dictionary;\n\n for (const key of pathArray) {\n // Safely traverse down the object using the path\n current = current?.[key];\n // If we cannot find the path, return the whole dictionary as a fallback\n if (current === undefined) {\n return dictionary as any;\n }\n }\n\n return current;\n }\n\n // Default or error handling if path is not a string or otherwise undefined\n return dictionary as any;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/interpreter/getNesting.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/import/no-cycle */\nimport type { ValidDotPathsFor } from '../transpiler';\nimport type { DictionaryKeys } from '../types';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n} from './getContent';\nimport { getIntlayer } from './getIntlayer';\n// @ts-ignore intlayer declared for module augmentation\nimport { IntlayerDictionaryTypesConnector } from 'intlayer';\n\ntype GetSubPath<T, P> = P extends `${infer K}.${infer Rest}`\n ? K extends keyof T\n ? GetSubPath<T[K], Rest>\n : never\n : P extends keyof T\n ? T[P]\n : T;\n\nexport type GetNestingResult<\n K extends DictionaryKeys,\n P = undefined,\n S = IInterpreterPluginState,\n> = GetSubPath<\n DeepTransformContent<IntlayerDictionaryTypesConnector[K]['content'], S>,\n P\n>;\n\n/**\n * Allow to extract the content of another dictionary.\n *\n * Usage:\n * ```ts\n * const content = getNesting(\"dictionaryKey\", \"path.to.content\");\n * // 'Example content'\n * ```\n */\nexport const getNesting = <K extends DictionaryKeys, P>(\n dictionaryKey: K,\n path?: P extends ValidDotPathsFor<K> ? P : never,\n props?: NodeProps\n): GetNestingResult<K, P> => {\n const dictionary = getIntlayer(dictionaryKey, props?.locale, props?.plugins);\n\n if (typeof path === 'string') {\n const pathArray = (path as string).split('.');\n let current: any = dictionary;\n\n for (const key of pathArray) {\n // Safely traverse down the object using the path\n current = current?.[key];\n // If we cannot find the path, return the whole dictionary as a fallback\n if (current === undefined) {\n return dictionary as any;\n }\n }\n\n return current;\n }\n\n // Default or error handling if path is not a string or otherwise undefined\n return dictionary as any;\n};\n"],"mappings":"AASA,SAAS,mBAAmB;AA8BrB,MAAM,aAAa,CACxB,eACA,MACA,UAC2B;AAC3B,QAAM,aAAa,YAAY,eAAe,OAAO,QAAQ,OAAO,OAAO;AAE3E,MAAI,OAAO,SAAS,UAAU;AAC5B,UAAM,YAAa,KAAgB,MAAM,GAAG;AAC5C,QAAI,UAAe;AAEnB,eAAW,OAAO,WAAW;AAE3B,gBAAU,UAAU,GAAG;AAEvB,UAAI,YAAY,QAAW;AACzB,eAAO;AAAA,MACT;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAGA,SAAO;AACT;","names":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {
|
|
2
|
+
formatNodeType,
|
|
3
|
+
NodeType
|
|
4
|
+
} from "../../types/index.mjs";
|
|
5
|
+
const condition = (content) => formatNodeType(NodeType.Condition, content);
|
|
6
6
|
export {
|
|
7
7
|
condition as cond
|
|
8
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/condition/condition.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/condition/condition.ts"],"sourcesContent":["import {\n formatNodeType,\n NodeType,\n type TypedNodeModel,\n} from '../../types/index';\n\nexport type ConditionContentStates<Content> = Record<`${boolean}`, Content> & {\n fallback?: Content;\n};\n\nexport type ConditionContent<Content = unknown> = TypedNodeModel<\n NodeType.Condition,\n ConditionContentStates<Content>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a condition.\n *\n * Usage:\n *\n * ```ts\n * cond({\n * 'true': 'The condition is validated',\n * 'false': 'The condition is not validated',\n * });\n * ```\n *\n * The last key provided will be used as the fallback value.\n *\n */\nconst condition = <Content>(content?: ConditionContentStates<Content>) =>\n formatNodeType(NodeType.Condition, content);\n\nexport { condition as cond };\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AA4BP,MAAM,YAAY,CAAU,YAC1B,eAAe,SAAS,WAAW,OAAO;","names":[]}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { NodeType } from "../../types/index.mjs";
|
|
2
|
-
const enumeration = (content) => (
|
|
3
|
-
nodeType: NodeType.Enumeration,
|
|
4
|
-
[NodeType.Enumeration]: { ...content }
|
|
5
|
-
});
|
|
1
|
+
import { formatNodeType, NodeType } from "../../types/index.mjs";
|
|
2
|
+
const enumeration = (content) => formatNodeType(NodeType.Enumeration, content);
|
|
6
3
|
export {
|
|
7
4
|
enumeration as enu
|
|
8
5
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/enumeration/enumeration.ts"],"sourcesContent":["import { NodeType } from '../../types/index';\n\ntype Positif = number | `${number}`;\ntype Negatif = `-${number}`;\ntype Numbers = Positif | Negatif;\n\ntype Equal = Numbers;\ntype EqualString = `=${Numbers}`;\ntype Superior = `>${Numbers}`;\ntype SuperiorOrEqual = `>=${Numbers}`;\ntype Inferior = `<${Numbers}`;\ntype InferiorOrEqual = `<=${Numbers}`;\n\nexport type EnterFormat =\n | Equal\n | EqualString\n | Superior\n | SuperiorOrEqual\n | Inferior\n | InferiorOrEqual;\n\nexport type EnumerationContentState<Content> = Partial<\n Record<EnterFormat, Content>\n> & {\n fallback?: Content;\n};\n\nexport type EnumerationContent<Content = unknown> =
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/enumeration/enumeration.ts"],"sourcesContent":["import { formatNodeType, NodeType, TypedNodeModel } from '../../types/index';\n\ntype Positif = number | `${number}`;\ntype Negatif = `-${number}`;\ntype Numbers = Positif | Negatif;\n\ntype Equal = Numbers;\ntype EqualString = `=${Numbers}`;\ntype Superior = `>${Numbers}`;\ntype SuperiorOrEqual = `>=${Numbers}`;\ntype Inferior = `<${Numbers}`;\ntype InferiorOrEqual = `<=${Numbers}`;\n\nexport type EnterFormat =\n | Equal\n | EqualString\n | Superior\n | SuperiorOrEqual\n | Inferior\n | InferiorOrEqual;\n\nexport type EnumerationContentState<Content> = Partial<\n Record<EnterFormat, Content>\n> & {\n fallback?: Content;\n};\n\nexport type EnumerationContent<Content = unknown> = TypedNodeModel<\n NodeType.Enumeration,\n EnumerationContentState<Content>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * enu({\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 * });\n * ```\n *\n * > The order of the keys will define the priority of the content.\n *\n */\nconst enumeration = <Content>(content?: EnumerationContentState<Content>) =>\n formatNodeType(NodeType.Enumeration, content);\n\nexport { enumeration as enu };\n"],"mappings":"AAAA,SAAS,gBAAgB,gBAAgC;AAmDzD,MAAM,cAAc,CAAU,YAC5B,eAAe,SAAS,aAAa,OAAO;","names":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {
|
|
2
|
+
formatNodeType,
|
|
3
|
+
NodeType
|
|
4
|
+
} from "../../types/index.mjs";
|
|
5
|
+
const markdown = (content) => formatNodeType(NodeType.Markdown, content);
|
|
6
6
|
export {
|
|
7
7
|
markdown as md
|
|
8
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/markdown/markdown.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/markdown/markdown.ts"],"sourcesContent":["import {\n formatNodeType,\n NodeType,\n type TypedNodeModel,\n} from '../../types/index';\n\nexport type MarkdownContentState = string;\n\nexport type MarkdownContent = TypedNodeModel<\n NodeType.Markdown,\n MarkdownContentState\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * markdown('## Hello world!');\n * ```\n *\n */\nconst markdown = (content: string): MarkdownContent =>\n formatNodeType(NodeType.Markdown, content);\n\nexport { markdown as md };\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAqBP,MAAM,WAAW,CAAC,YAChB,eAAe,SAAS,UAAU,OAAO;","names":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import {
|
|
2
|
+
formatNodeType,
|
|
3
|
+
NodeType
|
|
4
|
+
} from "../../types/index.mjs";
|
|
5
|
+
const nesting = (dictionaryKey, path) => formatNodeType(NodeType.Nested, {
|
|
6
|
+
dictionaryKey,
|
|
7
|
+
path
|
|
8
8
|
});
|
|
9
9
|
export {
|
|
10
10
|
nesting as nest
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/nesting/nesting.ts"],"sourcesContent":["// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type { DictionaryKeys } from '../../types/dictionary';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/nesting/nesting.ts"],"sourcesContent":["// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type { DictionaryKeys } from '../../types/dictionary';\nimport {\n formatNodeType,\n NodeType,\n type TypedNodeModel,\n} from '../../types/index';\nimport type { DeepTransformContent } from '../../interpreter';\n\n/**\n * Recursively builds dot-notation strings for all valid paths in T.\n * Example:\n * type X = { a: { b: { c: string }}, d: number };\n * DotPath<X> = \"a\" | \"a.b\" | \"a.b.c\" | \"d\"\n */\nexport type DotPath<T> = T extends object\n ? {\n [K in keyof T & (string | number)]: T[K] extends object\n ? // Either just K, or K + '.' + deeper path\n `${K}` | `${K}.${DotPath<T[K]>}`\n : `${K}`;\n }[keyof T & (string | number)]\n : never;\n\ntype DeepReplace<T, From, To> = T extends From\n ? To\n : T extends object\n ? { [K in keyof T]: DeepReplace<T[K], From, To> }\n : T;\n\n/** Build all valid dot-notation strings for a dictionary entry. */\nexport type ValidDotPathsFor<K extends DictionaryKeys> = DotPath<\n DeepReplace<\n DeepTransformContent<IntlayerDictionaryTypesConnector[K]['content']>,\n // Replace ReactElement type with string\n {\n type: any;\n props: any;\n key: any;\n },\n string\n >\n>;\n\nexport type NestedContentState<K extends DictionaryKeys> = {\n dictionaryKey: K;\n\n /**\n * Path must match existing keys in IntlayerDictionaryTypesConnector[K].\n * Can be either:\n * - \"dot.dot.dot\" format\n */\n path?: ValidDotPathsFor<K>;\n};\n\nexport type NestedContent<K extends DictionaryKeys = never> = TypedNodeModel<\n NodeType.Nested,\n NestedContentState<K>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to extract the content of another dictionary and nest it in the current dictionary.\n *\n * Usage:\n *\n * ```ts\n * nest(\"dictionaryKey\");\n * nest(\"dictionaryKey\", \"path.to.content\");\n * ```\n *\n * The order of the keys will define the priority of the content.\n *\n */\nconst nesting = <K extends DictionaryKeys>(\n dictionaryKey: K,\n path?: ValidDotPathsFor<K>\n): NestedContent<K> =>\n formatNodeType(NodeType.Nested, {\n dictionaryKey,\n path,\n });\n\nexport { nesting as nest };\n"],"mappings":"AAGA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAqEP,MAAM,UAAU,CACd,eACA,SAEA,eAAe,SAAS,QAAQ;AAAA,EAC9B;AAAA,EACA;AACF,CAAC;","names":[]}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { NodeType } from "../../types/index.mjs";
|
|
2
|
-
const translation = (content) => (
|
|
3
|
-
nodeType: NodeType.Translation,
|
|
4
|
-
[NodeType.Translation]: content
|
|
5
|
-
});
|
|
1
|
+
import { formatNodeType, NodeType } from "../../types/index.mjs";
|
|
2
|
+
const translation = (content) => formatNodeType(NodeType.Translation, content);
|
|
6
3
|
export {
|
|
7
4
|
translation as t
|
|
8
5
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/translation/translation.ts"],"sourcesContent":["import { NodeType } from '../../types/index';\nimport type { LanguageContent, TranslationContent } from './types';\n\n/**\n *\n * Function intended to be used to build intlayer dictionaries.\n *\n * Get the content of a translation based on the locale.\n *\n * Usage:\n *\n * ```ts\n * translation<string>({\n * \"en\": \"Hello\",\n * \"fr\": \"Bonjour\",\n * // ... any other available locale\n * })\n * ```\n *\n * Using TypeScript:\n * - this function 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 */\nconst translation =
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/translation/translation.ts"],"sourcesContent":["import { formatNodeType, NodeType } from '../../types/index';\nimport type { LanguageContent, TranslationContent } from './types';\n\n/**\n *\n * Function intended to be used to build intlayer dictionaries.\n *\n * Get the content of a translation based on the locale.\n *\n * Usage:\n *\n * ```ts\n * translation<string>({\n * \"en\": \"Hello\",\n * \"fr\": \"Bonjour\",\n * // ... any other available locale\n * })\n * ```\n *\n * Using TypeScript:\n * - this function 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 */\nconst translation = <\n Content = unknown,\n ContentRecord extends LanguageContent<Content> = LanguageContent<Content>,\n>(\n content: ContentRecord\n) =>\n formatNodeType(NodeType.Translation, content) satisfies TranslationContent<\n Content,\n ContentRecord\n >;\n\nexport { translation as t };\n"],"mappings":"AAAA,SAAS,gBAAgB,gBAAgB;AAuBzC,MAAM,cAAc,CAIlB,YAEA,eAAe,SAAS,aAAa,OAAO;","names":[]}
|
|
@@ -10,7 +10,12 @@ var NodeType = /* @__PURE__ */ ((NodeType2) => {
|
|
|
10
10
|
NodeType2["Markdown"] = "markdown";
|
|
11
11
|
return NodeType2;
|
|
12
12
|
})(NodeType || {});
|
|
13
|
+
const formatNodeType = (nodeType, content) => ({
|
|
14
|
+
nodeType,
|
|
15
|
+
[nodeType]: content
|
|
16
|
+
});
|
|
13
17
|
export {
|
|
14
|
-
NodeType
|
|
18
|
+
NodeType,
|
|
19
|
+
formatNodeType
|
|
15
20
|
};
|
|
16
21
|
//# sourceMappingURL=nodeType.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/types/nodeType.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/types/nodeType.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nexport enum NodeType {\n Translation = 'translation',\n Enumeration = 'enumeration',\n Condition = 'condition',\n Object = 'object',\n Array = 'array',\n Text = 'text',\n Nested = 'nested',\n ReactNode = 'reactNode',\n Markdown = 'markdown',\n}\n\nexport type TypedNodeModel<T extends NodeType, Content> = {\n nodeType: T | `${T}`;\n} & {\n [K in T]: Content;\n};\n\nexport const formatNodeType = <T extends NodeType, Content = any>(\n nodeType: T | `${T}`,\n content: Content\n) =>\n ({\n nodeType,\n [nodeType]: content,\n }) as TypedNodeModel<T, Content>;\n"],"mappings":"AACO,IAAK,WAAL,kBAAKA,cAAL;AACL,EAAAA,UAAA,iBAAc;AACd,EAAAA,UAAA,iBAAc;AACd,EAAAA,UAAA,eAAY;AACZ,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,WAAQ;AACR,EAAAA,UAAA,UAAO;AACP,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,eAAY;AACZ,EAAAA,UAAA,cAAW;AATD,SAAAA;AAAA,GAAA;AAkBL,MAAM,iBAAiB,CAC5B,UACA,aAEC;AAAA,EACC;AAAA,EACA,CAAC,QAAQ,GAAG;AACd;","names":["NodeType"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSectionType.d.ts","sourceRoot":"","sources":["../../../src/dictionaryManipulator/getSectionType.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAuB,MAAM,UAAU,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGvD,eAAO,MAAM,cAAc,YAAa,WAAW,KAAG,
|
|
1
|
+
{"version":3,"file":"getSectionType.d.ts","sourceRoot":"","sources":["../../../src/dictionaryManipulator/getSectionType.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAuB,MAAM,UAAU,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGvD,eAAO,MAAM,cAAc,YAAa,WAAW,KAAG,QAoCrD,CAAC"}
|
|
@@ -9,5 +9,5 @@ import type { Plugins, DeepTransformContent } from './getContent';
|
|
|
9
9
|
* @param additionalPlugins An array of NodeTransformer that define how to transform recognized nodes.
|
|
10
10
|
* If omitted, we’ll use a default set of plugins.
|
|
11
11
|
*/
|
|
12
|
-
export declare const getDictionary: <T extends Dictionary
|
|
12
|
+
export declare const getDictionary: <T extends Dictionary, L extends LocalesValues = Locales>(dictionary: T, locale?: L, plugins?: Plugins[]) => DeepTransformContent<T["content"]>;
|
|
13
13
|
//# sourceMappingURL=getDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDictionary.d.ts","sourceRoot":"","sources":["../../../src/interpreter/getDictionary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,KAAK,EAAE,OAAO,EAAa,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAE7E;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GACxB,CAAC,SAAS,UAAU,
|
|
1
|
+
{"version":3,"file":"getDictionary.d.ts","sourceRoot":"","sources":["../../../src/interpreter/getDictionary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,KAAK,EAAE,OAAO,EAAa,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAE7E;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GACxB,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,aAAa,wBAEX,CAAC,WACJ,CAAC,YACA,OAAO,EAAE,KAcP,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,CAC9C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIntlayer.d.ts","sourceRoot":"","sources":["../../../src/interpreter/getIntlayer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getIntlayer.d.ts","sourceRoot":"","sources":["../../../src/interpreter/getIntlayer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAOtD,OAAO,KAAK,EAAc,cAAc,EAAE,MAAM,UAAU,CAAC;AAG3D,OAAO,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE1E,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,cAAc,EAAE,CAAC,SAAS,aAAa,OACtE,CAAC,WACG,CAAC,YACA,OAAO,EAAE,KAYP,oBAAoB,CAC9B,gCAAgC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAEjD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNesting.d.ts","sourceRoot":"","sources":["../../../src/interpreter/getNesting.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getNesting.d.ts","sourceRoot":"","sources":["../../../src/interpreter/getNesting.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EACV,oBAAoB,EACpB,uBAAuB,EACvB,SAAS,EACV,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAE5D,KAAK,UAAU,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,IAAI,MAAM,IAAI,EAAE,GACxD,CAAC,SAAS,MAAM,CAAC,GACf,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GACtB,KAAK,GACP,CAAC,SAAS,MAAM,CAAC,GACf,CAAC,CAAC,CAAC,CAAC,GACJ,CAAC,CAAC;AAER,MAAM,MAAM,gBAAgB,CAC1B,CAAC,SAAS,cAAc,EACxB,CAAC,GAAG,SAAS,EACb,CAAC,GAAG,uBAAuB,IACzB,UAAU,CACZ,oBAAoB,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,EACvE,CAAC,CACF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,cAAc,EAAE,CAAC,iBACrC,CAAC,SACT,CAAC,SAAS,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,UACxC,SAAS,KAChB,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAqBvB,CAAC"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { NodeType } from '../../types/index';
|
|
1
|
+
import { NodeType, type TypedNodeModel } from '../../types/index';
|
|
2
2
|
export type ConditionContentStates<Content> = Record<`${boolean}`, Content> & {
|
|
3
3
|
fallback?: Content;
|
|
4
4
|
};
|
|
5
|
-
export type ConditionContent<Content = unknown> =
|
|
6
|
-
nodeType: NodeType.Condition;
|
|
7
|
-
[NodeType.Condition]: ConditionContentStates<Content>;
|
|
8
|
-
};
|
|
5
|
+
export type ConditionContent<Content = unknown> = TypedNodeModel<NodeType.Condition, ConditionContentStates<Content>>;
|
|
9
6
|
/**
|
|
10
7
|
* Function intended to be used to build intlayer dictionaries.
|
|
11
8
|
*
|
|
@@ -23,13 +20,6 @@ export type ConditionContent<Content = unknown> = {
|
|
|
23
20
|
* The last key provided will be used as the fallback value.
|
|
24
21
|
*
|
|
25
22
|
*/
|
|
26
|
-
declare const condition: <Content>(content?: ConditionContentStates<Content>) =>
|
|
27
|
-
nodeType: NodeType;
|
|
28
|
-
condition: {
|
|
29
|
-
false: Content;
|
|
30
|
-
true: Content;
|
|
31
|
-
fallback?: Content;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
23
|
+
declare const condition: <Content>(content?: ConditionContentStates<Content>) => TypedNodeModel<NodeType.Condition, ConditionContentStates<Content>>;
|
|
34
24
|
export { condition as cond };
|
|
35
25
|
//# sourceMappingURL=condition.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"condition.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/condition/condition.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"condition.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/condition/condition.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EACR,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,sBAAsB,CAAC,OAAO,IAAI,MAAM,CAAC,GAAG,OAAO,EAAE,EAAE,OAAO,CAAC,GAAG;IAC5E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,OAAO,GAAG,OAAO,IAAI,cAAc,CAC9D,QAAQ,CAAC,SAAS,EAClB,sBAAsB,CAAC,OAAO,CAAC,CAChC,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,QAAA,MAAM,SAAS,GAAI,OAAO,YAAY,sBAAsB,CAAC,OAAO,CAAC,wEACxB,CAAC;AAE9C,OAAO,EAAE,SAAS,IAAI,IAAI,EAAE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NodeType } from '../../types/index';
|
|
1
|
+
import { NodeType, TypedNodeModel } from '../../types/index';
|
|
2
2
|
type Positif = number | `${number}`;
|
|
3
3
|
type Negatif = `-${number}`;
|
|
4
4
|
type Numbers = Positif | Negatif;
|
|
@@ -12,10 +12,7 @@ export type EnterFormat = Equal | EqualString | Superior | SuperiorOrEqual | Inf
|
|
|
12
12
|
export type EnumerationContentState<Content> = Partial<Record<EnterFormat, Content>> & {
|
|
13
13
|
fallback?: Content;
|
|
14
14
|
};
|
|
15
|
-
export type EnumerationContent<Content = unknown> =
|
|
16
|
-
nodeType: NodeType.Enumeration;
|
|
17
|
-
[NodeType.Enumeration]: EnumerationContentState<Content>;
|
|
18
|
-
};
|
|
15
|
+
export type EnumerationContent<Content = unknown> = TypedNodeModel<NodeType.Enumeration, EnumerationContentState<Content>>;
|
|
19
16
|
/**
|
|
20
17
|
* Function intended to be used to build intlayer dictionaries.
|
|
21
18
|
*
|
|
@@ -35,24 +32,6 @@ export type EnumerationContent<Content = unknown> = {
|
|
|
35
32
|
* > The order of the keys will define the priority of the content.
|
|
36
33
|
*
|
|
37
34
|
*/
|
|
38
|
-
declare const enumeration: <Content>(content?: EnumerationContentState<Content>) =>
|
|
39
|
-
nodeType: NodeType;
|
|
40
|
-
enumeration: {
|
|
41
|
-
[x: number]: Content;
|
|
42
|
-
[x: `${number}`]: Content;
|
|
43
|
-
[x: `-${number}`]: Content;
|
|
44
|
-
[x: `=${number}`]: Content;
|
|
45
|
-
[x: `=-${number}`]: Content;
|
|
46
|
-
[x: `>${number}`]: Content;
|
|
47
|
-
[x: `>-${number}`]: Content;
|
|
48
|
-
[x: `>=${number}`]: Content;
|
|
49
|
-
[x: `>=-${number}`]: Content;
|
|
50
|
-
[x: `<${number}`]: Content;
|
|
51
|
-
[x: `<-${number}`]: Content;
|
|
52
|
-
[x: `<=${number}`]: Content;
|
|
53
|
-
[x: `<=-${number}`]: Content;
|
|
54
|
-
fallback?: Content;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
35
|
+
declare const enumeration: <Content>(content?: EnumerationContentState<Content>) => TypedNodeModel<NodeType.Enumeration, EnumerationContentState<Content>>;
|
|
57
36
|
export { enumeration as enu };
|
|
58
37
|
//# sourceMappingURL=enumeration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enumeration.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/enumeration/enumeration.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"enumeration.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/enumeration/enumeration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,QAAQ,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE7E,KAAK,OAAO,GAAG,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;AACpC,KAAK,OAAO,GAAG,IAAI,MAAM,EAAE,CAAC;AAC5B,KAAK,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAEjC,KAAK,KAAK,GAAG,OAAO,CAAC;AACrB,KAAK,WAAW,GAAG,IAAI,OAAO,EAAE,CAAC;AACjC,KAAK,QAAQ,GAAG,IAAI,OAAO,EAAE,CAAC;AAC9B,KAAK,eAAe,GAAG,KAAK,OAAO,EAAE,CAAC;AACtC,KAAK,QAAQ,GAAG,IAAI,OAAO,EAAE,CAAC;AAC9B,KAAK,eAAe,GAAG,KAAK,OAAO,EAAE,CAAC;AAEtC,MAAM,MAAM,WAAW,GACnB,KAAK,GACL,WAAW,GACX,QAAQ,GACR,eAAe,GACf,QAAQ,GACR,eAAe,CAAC;AAEpB,MAAM,MAAM,uBAAuB,CAAC,OAAO,IAAI,OAAO,CACpD,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAC7B,GAAG;IACF,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAAC,OAAO,GAAG,OAAO,IAAI,cAAc,CAChE,QAAQ,CAAC,WAAW,EACpB,uBAAuB,CAAC,OAAO,CAAC,CACjC,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,QAAA,MAAM,WAAW,GAAI,OAAO,YAAY,uBAAuB,CAAC,OAAO,CAAC,2EACzB,CAAC;AAEhD,OAAO,EAAE,WAAW,IAAI,GAAG,EAAE,CAAC"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { NodeType } from '../../types/index';
|
|
1
|
+
import { NodeType, type TypedNodeModel } from '../../types/index';
|
|
2
2
|
export type MarkdownContentState = string;
|
|
3
|
-
export type MarkdownContent =
|
|
4
|
-
nodeType: NodeType.Markdown;
|
|
5
|
-
[NodeType.Markdown]: MarkdownContentState;
|
|
6
|
-
};
|
|
3
|
+
export type MarkdownContent = TypedNodeModel<NodeType.Markdown, MarkdownContentState>;
|
|
7
4
|
/**
|
|
8
5
|
* Function intended to be used to build intlayer dictionaries.
|
|
9
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/markdown/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/markdown/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EACR,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAE1C,MAAM,MAAM,eAAe,GAAG,cAAc,CAC1C,QAAQ,CAAC,QAAQ,EACjB,oBAAoB,CACrB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,QAAQ,YAAa,MAAM,KAAG,eACQ,CAAC;AAE7C,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IntlayerDictionaryTypesConnector } from 'intlayer';
|
|
2
2
|
import type { DictionaryKeys } from '../../types/dictionary';
|
|
3
|
-
import { NodeType } from '../../types/index';
|
|
3
|
+
import { NodeType, type TypedNodeModel } from '../../types/index';
|
|
4
4
|
import type { DeepTransformContent } from '../../interpreter';
|
|
5
5
|
/**
|
|
6
6
|
* Recursively builds dot-notation strings for all valid paths in T.
|
|
@@ -30,10 +30,7 @@ export type NestedContentState<K extends DictionaryKeys> = {
|
|
|
30
30
|
*/
|
|
31
31
|
path?: ValidDotPathsFor<K>;
|
|
32
32
|
};
|
|
33
|
-
export type NestedContent<K extends DictionaryKeys = never> =
|
|
34
|
-
nodeType: NodeType.Nested;
|
|
35
|
-
[NodeType.Nested]: NestedContentState<K>;
|
|
36
|
-
};
|
|
33
|
+
export type NestedContent<K extends DictionaryKeys = never> = TypedNodeModel<NodeType.Nested, NestedContentState<K>>;
|
|
37
34
|
/**
|
|
38
35
|
* Function intended to be used to build intlayer dictionaries.
|
|
39
36
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nesting.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/nesting/nesting.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,
|
|
1
|
+
{"version":3,"file":"nesting.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/nesting/nesting.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAEL,QAAQ,EACR,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GACrC;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAEnD,AADA,0CAA0C;IAC1C,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAChC,GAAG,CAAC,EAAE;CACX,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,GAC9B,KAAK,CAAC;AAEV,KAAK,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,IAAI,CAAC,SAAS,IAAI,GAC1C,EAAE,GACF,CAAC,SAAS,MAAM,GACd;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC;CAAE,GAC/C,CAAC,CAAC;AAER,mEAAmE;AACnE,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,cAAc,IAAI,OAAO,CAC9D,WAAW,CACT,oBAAoB,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAEpE;IACE,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,GAAG,CAAC;IACX,GAAG,EAAE,GAAG,CAAC;CACV,EACD,MAAM,CACP,CACF,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,cAAc,IAAI;IACzD,aAAa,EAAE,CAAC,CAAC;IAEjB;;;;OAIG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,cAAc,GAAG,KAAK,IAAI,cAAc,CAC1E,QAAQ,CAAC,MAAM,EACf,kBAAkB,CAAC,CAAC,CAAC,CACtB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,OAAO,GAAI,CAAC,SAAS,cAAc,iBACxB,CAAC,SACT,gBAAgB,CAAC,CAAC,CAAC,KACzB,aAAa,CAAC,CAAC,CAId,CAAC;AAEL,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { NodeType } from '../../types/index';
|
|
2
|
+
import type { LanguageContent } from './types';
|
|
2
3
|
/**
|
|
3
4
|
*
|
|
4
5
|
* Function intended to be used to build intlayer dictionaries.
|
|
@@ -19,6 +20,6 @@ import type { LanguageContent, TranslationContent } from './types';
|
|
|
19
20
|
* - this function require each locale to be defined if defined in the project configuration.
|
|
20
21
|
* - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.
|
|
21
22
|
*/
|
|
22
|
-
declare const translation: <Content =
|
|
23
|
+
declare const translation: <Content = unknown, ContentRecord extends LanguageContent<Content> = import("intlayer").IConfigLocales<Content>>(content: ContentRecord) => import("../..").TypedNodeModel<NodeType.Translation, ContentRecord>;
|
|
23
24
|
export { translation as t };
|
|
24
25
|
//# sourceMappingURL=translation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translation.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/translation/translation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"translation.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/translation/translation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAsB,MAAM,SAAS,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,QAAA,MAAM,WAAW,GACf,OAAO,YACP,aAAa,SAAS,eAAe,CAAC,OAAO,CAAC,wDAErC,aAAa,wEAKrB,CAAC;AAEJ,OAAO,EAAE,WAAW,IAAI,CAAC,EAAE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @ts-nocheck */
|
|
2
2
|
import type { LocalesValues } from '@intlayer/config/client';
|
|
3
3
|
import type { IConfigLocales } from 'intlayer';
|
|
4
|
-
import
|
|
4
|
+
import { NodeType, TypedNodeModel } from '../../types/index';
|
|
5
5
|
/**
|
|
6
6
|
* If module augmented, it will return the configured locales such as Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH | ...
|
|
7
7
|
* If not, it will return never
|
|
@@ -10,47 +10,19 @@ export type ConfigLocales = keyof IConfigLocales<unknown>;
|
|
|
10
10
|
/**
|
|
11
11
|
* Record of locales and content
|
|
12
12
|
*
|
|
13
|
-
* const myVar1:
|
|
13
|
+
* const myVar1: TranslationContentState<string> = {
|
|
14
14
|
* "en": "",
|
|
15
15
|
* "fr": ""
|
|
16
16
|
* }
|
|
17
17
|
*
|
|
18
|
-
* const myVar2:
|
|
18
|
+
* const myVar2: TranslationContentState<{age: number, name: string}> = {
|
|
19
19
|
* "en": {age: 1, name: "test"},
|
|
20
20
|
* "fr": {age: 1, name: "test"}
|
|
21
21
|
* }
|
|
22
22
|
*/
|
|
23
|
-
export type TranslationContentState<Content = unknown> =
|
|
24
|
-
|
|
25
|
-
* Valid
|
|
26
|
-
* const test: CustomizableLanguageContent<string, Locales.ENGLISH | Locales.FRENCH> = {
|
|
27
|
-
* "en": "test",
|
|
28
|
-
* "fr": "test"
|
|
29
|
-
* }
|
|
30
|
-
*
|
|
31
|
-
* const test: CustomizableLanguageContent<number> = {
|
|
32
|
-
* "fr": 1,
|
|
33
|
-
* "en": 1,
|
|
34
|
-
* ... any other available locale
|
|
35
|
-
* }
|
|
36
|
-
*
|
|
37
|
-
* Invalid
|
|
38
|
-
*
|
|
39
|
-
* const test: CustomizableLanguageContent<string> = {
|
|
40
|
-
* "en": "test",
|
|
41
|
-
* "fr": "test",
|
|
42
|
-
* "sss": "test" // Does not exist in Locales
|
|
43
|
-
* }
|
|
44
|
-
*
|
|
45
|
-
* const test: CustomizableLanguageContent<string, Locales.ENGLISH | Locales.FRENCH> = {
|
|
46
|
-
* "fr": "test"
|
|
47
|
-
* // Locales.ENGLISH is missing
|
|
48
|
-
* }
|
|
49
|
-
*
|
|
50
|
-
*/
|
|
51
|
-
export type LanguageContent<Content = string> = ConfigLocales extends never ? TranslationContentState<Content> : IConfigLocales<Content>;
|
|
52
|
-
export type TranslationContent<Content = unknown> = {
|
|
53
|
-
nodeType: NodeType.Translation;
|
|
54
|
-
[NodeType.Translation]: LanguageContent<Content>;
|
|
23
|
+
export type TranslationContentState<Content = unknown> = {
|
|
24
|
+
[locale in LocalesValues]?: Content;
|
|
55
25
|
};
|
|
26
|
+
export type LanguageContent<Content = unknown> = keyof IConfigLocales<unknown> extends never ? TranslationContentState<Content> : IConfigLocales<Content>;
|
|
27
|
+
export type TranslationContent<Content = unknown, RecordContent extends LanguageContent<Content> = LanguageContent<Content>> = TypedNodeModel<NodeType.Translation, RecordContent>;
|
|
56
28
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/translation/types.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAElB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/translation/types.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAElB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE7D;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;AAE1D;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,uBAAuB,CAAC,OAAO,GAAG,OAAO,IAAI;KACtD,MAAM,IAAI,aAAa,CAAC,CAAC,EAAE,OAAO;CACpC,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,OAAO,GAAG,OAAO,IAC3C,MAAM,cAAc,CAAC,OAAO,CAAC,SAAS,KAAK,GACvC,uBAAuB,CAAC,OAAO,CAAC,GAChC,cAAc,CAAC,OAAO,CAAC,CAAC;AAE9B,MAAM,MAAM,kBAAkB,CAC5B,OAAO,GAAG,OAAO,EACjB,aAAa,SAAS,eAAe,CAAC,OAAO,CAAC,GAAG,eAAe,CAAC,OAAO,CAAC,IACvE,cAAc,CAAC,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { IntlayerDictionaryTypesConnector } from 'intlayer';
|
|
2
2
|
import type { ConditionContent, EnumerationContent, MarkdownContent, NestedContent, TranslationContent } from '../transpiler/index';
|
|
3
3
|
/**
|
|
4
|
-
* Provides a fallback to string type if the generic type T is
|
|
4
|
+
* Provides a fallback to string type if the generic type T is undefined,
|
|
5
5
|
* otherwise returns T. This is useful for handling cases where no keys are found.
|
|
6
|
-
* Example: StringFallback<
|
|
6
|
+
* Example: StringFallback<undefined> -> string; StringFallback<'key'> -> 'key'
|
|
7
7
|
*/
|
|
8
|
-
export type StringFallback<T> = T extends
|
|
8
|
+
export type StringFallback<T> = T extends undefined ? string : T;
|
|
9
9
|
/**
|
|
10
10
|
* Represents the keys of the IntlayerDictionaryTypesConnector,
|
|
11
11
|
* ensuring they are valid dictionary keys or fallback to string if none exist.
|
|
@@ -18,18 +18,16 @@ export type StringFallback<T> = T extends never ? string : T;
|
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
export type DictionaryKeys = StringFallback<keyof IntlayerDictionaryTypesConnector>;
|
|
21
|
-
export type TypedNode<NodeType =
|
|
22
|
-
|
|
23
|
-
export type
|
|
24
|
-
export type ContentNode<NodeType = BaseNode, FetchableNode = false> = NodeType | TypedNode<NodeType> | {
|
|
25
|
-
[paramKey: string | number]: ContentNode;
|
|
26
|
-
} | ((args?: any) => ContentNode<NodeType>) | (FetchableNode extends true ? FetchableContentNode<NodeType> : never);
|
|
21
|
+
export type TypedNode<NodeType = undefined> = TranslationContent<NodeType> | EnumerationContent<NodeType> | ConditionContent<NodeType> | MarkdownContent | NestedContent<DictionaryKeys>;
|
|
22
|
+
type FetchableContentNode<NodeType> = (args?: any) => ContentNode<NodeType> | Promise<ContentNode<NodeType>>;
|
|
23
|
+
export type ContentNode<NodeType = undefined, FetchableNode = false> = NodeType | TypedNode<NodeType> | ((args?: any) => ContentNode<NodeType>) | (FetchableNode extends true ? FetchableContentNode<NodeType> : undefined);
|
|
27
24
|
type IsArray<T> = T extends any[] ? true : false;
|
|
28
|
-
type ReplaceContentValueArray<T> = T extends (infer U)[] ? ReplaceContentValue<U>[] : ReplaceContentValue<T>;
|
|
29
|
-
type
|
|
30
|
-
[
|
|
25
|
+
type ReplaceContentValueArray<T, FetchableNode> = T extends (infer U)[] ? ReplaceContentValue<U, FetchableNode>[] : ReplaceContentValue<T, FetchableNode>;
|
|
26
|
+
type ReplaceContentValueObject<T, FetchableNode> = {
|
|
27
|
+
[K in keyof T]: ReplaceContentValue<T[K], FetchableNode>;
|
|
31
28
|
};
|
|
32
|
-
|
|
29
|
+
type ReplaceContentValue<NodeType, FetchableNode = true> = NodeType extends object ? IsArray<NodeType> extends true ? ReplaceContentValueArray<NodeType, FetchableNode> : ContentNode<NodeType, FetchableNode> | ReplaceContentValueObject<NodeType, FetchableNode> : ContentNode<NodeType, FetchableNode>;
|
|
30
|
+
export type Dictionary<ContentType = undefined, FetchableNode = false> = {
|
|
33
31
|
$schema?: string;
|
|
34
32
|
key: string;
|
|
35
33
|
title?: string;
|
|
@@ -38,7 +36,7 @@ export type Dictionary<NodeType = undefined, FetchableNode = false> = {
|
|
|
38
36
|
version?: string;
|
|
39
37
|
filePath?: string;
|
|
40
38
|
tags?: string[];
|
|
41
|
-
content:
|
|
39
|
+
content: ContentType extends undefined ? any : ReplaceContentValue<ContentType, FetchableNode> | ContentType;
|
|
42
40
|
};
|
|
43
41
|
export {};
|
|
44
42
|
//# sourceMappingURL=dictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary.d.ts","sourceRoot":"","sources":["../../../src/types/dictionary.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAE7B;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"dictionary.d.ts","sourceRoot":"","sources":["../../../src/types/dictionary.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAE7B;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,MAAM,GAAG,CAAC,CAAC;AAEjE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,cAAc,GAAG,cAAc,CACzC,MAAM,gCAAgC,CACvC,CAAC;AAEF,MAAM,MAAM,SAAS,CAAC,QAAQ,GAAG,SAAS,IACtC,kBAAkB,CAAC,QAAQ,CAAC,GAC5B,kBAAkB,CAAC,QAAQ,CAAC,GAC5B,gBAAgB,CAAC,QAAQ,CAAC,GAC1B,eAAe,GACf,aAAa,CAAC,cAAc,CAAC,CAAC;AAElC,KAAK,oBAAoB,CAAC,QAAQ,IAAI,CACpC,IAAI,CAAC,EAAE,GAAG,KACP,WAAW,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;AAE5D,MAAM,MAAM,WAAW,CAAC,QAAQ,GAAG,SAAS,EAAE,aAAa,GAAG,KAAK,IAC/D,QAAQ,GACR,SAAS,CAAC,QAAQ,CAAC,GACnB,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,WAAW,CAAC,QAAQ,CAAC,CAAC,GACvC,CAAC,aAAa,SAAS,IAAI,GAAG,oBAAoB,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC,CAAC;AAG9E,KAAK,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,EAAE,GAAG,IAAI,GAAG,KAAK,CAAC;AAEjD,KAAK,wBAAwB,CAAC,CAAC,EAAE,aAAa,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GACnE,mBAAmB,CAAC,CAAC,EAAE,aAAa,CAAC,EAAE,GACvC,mBAAmB,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;AAE1C,KAAK,yBAAyB,CAAC,CAAC,EAAE,aAAa,IAAI;KAChD,CAAC,IAAI,MAAM,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC;CACzD,CAAC;AAGF,KAAK,mBAAmB,CACtB,QAAQ,EACR,aAAa,GAAG,IAAI,IAClB,QAAQ,SAAS,MAAM,GACvB,OAAO,CAAC,QAAQ,CAAC,SAAS,IAAI,GAC5B,wBAAwB,CAAC,QAAQ,EAAE,aAAa,CAAC,GAE7C,WAAW,CAAC,QAAQ,EAAE,aAAa,CAAC,GACpC,yBAAyB,CAAC,QAAQ,EAAE,aAAa,CAAC,GACxD,WAAW,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;AAEzC,MAAM,MAAM,UAAU,CAAC,WAAW,GAAG,SAAS,EAAE,aAAa,GAAG,KAAK,IAAI;IACvE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,WAAW,SAAS,SAAS,GAClC,GAAG,GACH,mBAAmB,CAAC,WAAW,EAAE,aAAa,CAAC,GAAG,WAAW,CAAC;CACnE,CAAC"}
|
|
@@ -9,4 +9,10 @@ export declare enum NodeType {
|
|
|
9
9
|
ReactNode = "reactNode",
|
|
10
10
|
Markdown = "markdown"
|
|
11
11
|
}
|
|
12
|
+
export type TypedNodeModel<T extends NodeType, Content> = {
|
|
13
|
+
nodeType: T | `${T}`;
|
|
14
|
+
} & {
|
|
15
|
+
[K in T]: Content;
|
|
16
|
+
};
|
|
17
|
+
export declare const formatNodeType: <T extends NodeType, Content = any>(nodeType: T | `${T}`, content: Content) => TypedNodeModel<T, Content>;
|
|
12
18
|
//# sourceMappingURL=nodeType.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeType.d.ts","sourceRoot":"","sources":["../../../src/types/nodeType.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nodeType.d.ts","sourceRoot":"","sources":["../../../src/types/nodeType.ts"],"names":[],"mappings":"AACA,oBAAY,QAAQ;IAClB,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;IAC3B,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,SAAS,cAAc;IACvB,QAAQ,aAAa;CACtB;AAED,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,QAAQ,EAAE,OAAO,IAAI;IACxD,QAAQ,EAAE,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC;CACtB,GAAG;KACD,CAAC,IAAI,CAAC,GAAG,OAAO;CAClB,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,QAAQ,EAAE,OAAO,kBAC9C,CAAC,GAAG,GAAG,CAAC,EAAE,WACX,OAAO,KAKV,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/core",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.",
|
|
6
6
|
"keywords": [
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@formatjs/intl-localematcher": "^0.5.10",
|
|
62
62
|
"negotiator": "^1.0.0",
|
|
63
|
-
"@intlayer/api": "5.0.
|
|
64
|
-
"@intlayer/config": "5.0.
|
|
65
|
-
"@intlayer/dictionaries-entry": "5.0.
|
|
63
|
+
"@intlayer/api": "5.0.4",
|
|
64
|
+
"@intlayer/config": "5.0.4",
|
|
65
|
+
"@intlayer/dictionaries-entry": "5.0.4"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@types/negotiator": "^0.6.3",
|
|
@@ -81,10 +81,10 @@
|
|
|
81
81
|
"@utils/tsup-config": "1.0.4"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
|
-
"@intlayer/api": "5.0.
|
|
85
|
-
"@intlayer/config": "5.0.
|
|
86
|
-
"@intlayer/dictionaries-entry": "5.0.
|
|
87
|
-
"intlayer": "5.0.
|
|
84
|
+
"@intlayer/api": "5.0.4",
|
|
85
|
+
"@intlayer/config": "5.0.4",
|
|
86
|
+
"@intlayer/dictionaries-entry": "5.0.4",
|
|
87
|
+
"intlayer": "5.0.4"
|
|
88
88
|
},
|
|
89
89
|
"engines": {
|
|
90
90
|
"node": ">=14.18"
|