@intlayer/chokidar 5.3.5 → 5.3.6
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/cleanOutputDir.cjs +3 -4
- package/dist/cjs/cleanOutputDir.cjs.map +1 -1
- package/dist/cjs/getBuiltDictionariesPath.cjs +2 -3
- package/dist/cjs/getBuiltDictionariesPath.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +2 -2
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs +7 -4
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
- package/dist/cjs/log.cjs +5 -5
- package/dist/cjs/log.cjs.map +1 -1
- package/dist/cjs/prepareContentDeclaration.cjs.map +1 -1
- package/dist/cjs/prepareIntlayer.cjs +11 -7
- package/dist/cjs/prepareIntlayer.cjs.map +1 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.cjs +5 -3
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.cjs.map +1 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.cjs +2 -4
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.cjs.map +1 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.cjs +4 -5
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.cjs.map +1 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/index.cjs +4 -6
- package/dist/cjs/transpiler/declaration_file_to_dictionary/index.cjs.map +1 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.cjs +4 -4
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.cjs.map +1 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.cjs +4 -4
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs +22 -14
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs +19 -18
- package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_type/createType.cjs +2 -3
- package/dist/cjs/transpiler/dictionary_to_type/createType.cjs.map +1 -1
- package/dist/esm/cleanOutputDir.mjs +3 -4
- package/dist/esm/cleanOutputDir.mjs.map +1 -1
- package/dist/esm/getBuiltDictionariesPath.mjs +2 -3
- package/dist/esm/getBuiltDictionariesPath.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +3 -3
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadDictionaries.mjs +8 -5
- package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
- package/dist/esm/log.mjs +5 -5
- package/dist/esm/log.mjs.map +1 -1
- package/dist/esm/prepareContentDeclaration.mjs.map +1 -1
- package/dist/esm/prepareIntlayer.mjs +12 -7
- package/dist/esm/prepareIntlayer.mjs.map +1 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.mjs +5 -3
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.mjs.map +1 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.mjs +2 -4
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.mjs.map +1 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.mjs +4 -5
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.mjs.map +1 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/index.mjs +4 -6
- package/dist/esm/transpiler/declaration_file_to_dictionary/index.mjs.map +1 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.mjs +4 -4
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.mjs.map +1 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.mjs +4 -4
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs +22 -14
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs +19 -18
- package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_type/createType.mjs +6 -4
- package/dist/esm/transpiler/dictionary_to_type/createType.mjs.map +1 -1
- package/dist/types/cleanOutputDir.d.ts +1 -1
- package/dist/types/cleanOutputDir.d.ts.map +1 -1
- package/dist/types/getBuiltDictionariesPath.d.ts +1 -1
- package/dist/types/getBuiltDictionariesPath.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadContentDeclaration.d.ts +1 -1
- package/dist/types/loadDictionaries/loadContentDeclaration.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadDictionaries.d.ts +1 -1
- package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -1
- package/dist/types/log.d.ts +3 -2
- package/dist/types/log.d.ts.map +1 -1
- package/dist/types/prepareIntlayer.d.ts +1 -1
- package/dist/types/prepareIntlayer.d.ts.map +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.d.ts +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.d.ts.map +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.d.ts +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.d.ts.map +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.d.ts +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.d.ts.map +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/index.d.ts +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/index.d.ts.map +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.d.ts +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.d.ts.map +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.d.ts +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.d.ts.map +1 -1
- package/dist/types/transpiler/dictionary_to_main/createDictionaryEntryPoint.d.ts +1 -1
- package/dist/types/transpiler/dictionary_to_main/createDictionaryEntryPoint.d.ts.map +1 -1
- package/dist/types/transpiler/dictionary_to_type/createModuleAugmentation.d.ts +1 -1
- package/dist/types/transpiler/dictionary_to_type/createModuleAugmentation.d.ts.map +1 -1
- package/dist/types/transpiler/dictionary_to_type/createType.d.ts +2 -1
- package/dist/types/transpiler/dictionary_to_type/createType.d.ts.map +1 -1
- package/package.json +14 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/core';\nimport { createI18nextDictionaries } from './convertContentDeclarationInto18nDictionaries';\nimport {\n writeDictionary,\n type DictionariesDeclaration,\n} from './writeDictionary';\n\n/**\n * This function transpile content declaration to i18n dictionaries\n */\nexport const buildI18nDictionary = async (\n contentDeclarations: Dictionary[]\n) => {\n // Create dictionaries for each nested content and format them\n const dictionariesDeclaration: DictionariesDeclaration =\n contentDeclarations.reduce((acc, dictionary) => {\n const { key, content } = dictionary;\n const i18Content = createI18nextDictionaries(content);\n\n return {\n ...acc,\n [key]: i18Content,\n };\n }, {});\n\n // Write the dictionaries to the file system\n const dictionariesPaths: string[] = await writeDictionary(\n dictionariesDeclaration\n );\n\n return dictionariesPaths;\n};\n"],"mappings":"AACA,SAAS,iCAAiC;AAC1C;AAAA,EACE;AAAA,OAEK;
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/core';\nimport { createI18nextDictionaries } from './convertContentDeclarationInto18nDictionaries';\nimport {\n writeDictionary,\n type DictionariesDeclaration,\n} from './writeDictionary';\nimport { getConfiguration } from '@intlayer/config';\n\n/**\n * This function transpile content declaration to i18n dictionaries\n */\nexport const buildI18nDictionary = async (\n contentDeclarations: Dictionary[],\n configuration = getConfiguration()\n) => {\n // Create dictionaries for each nested content and format them\n const dictionariesDeclaration: DictionariesDeclaration =\n contentDeclarations.reduce((acc, dictionary) => {\n const { key, content } = dictionary;\n const i18Content = createI18nextDictionaries(content, configuration);\n\n return {\n ...acc,\n [key]: i18Content,\n };\n }, {});\n\n // Write the dictionaries to the file system\n const dictionariesPaths: string[] = await writeDictionary(\n dictionariesDeclaration,\n configuration\n );\n\n return dictionariesPaths;\n};\n"],"mappings":"AACA,SAAS,iCAAiC;AAC1C;AAAA,EACE;AAAA,OAEK;AACP,SAAS,wBAAwB;AAK1B,MAAM,sBAAsB,OACjC,qBACA,gBAAgB,iBAAiB,MAC9B;AAEH,QAAM,0BACJ,oBAAoB,OAAO,CAAC,KAAK,eAAe;AAC9C,UAAM,EAAE,KAAK,QAAQ,IAAI;AACzB,UAAM,aAAa,0BAA0B,SAAS,aAAa;AAEnE,WAAO;AAAA,MACL,GAAG;AAAA,MACH,CAAC,GAAG,GAAG;AAAA,IACT;AAAA,EACF,GAAG,CAAC,CAAC;AAGP,QAAM,oBAA8B,MAAM;AAAA,IACxC;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -3,9 +3,6 @@ import {
|
|
|
3
3
|
NodeType
|
|
4
4
|
} from "@intlayer/core";
|
|
5
5
|
import { convertPluralsValues } from "./convertPluralsValues.mjs";
|
|
6
|
-
const {
|
|
7
|
-
internationalization: { locales }
|
|
8
|
-
} = getConfiguration();
|
|
9
6
|
const isReactNode = (node) => typeof node?.key !== "undefined" && typeof node?.props !== "undefined" && typeof node?.type !== "undefined";
|
|
10
7
|
const buildDictionary = (content, locale) => {
|
|
11
8
|
if (
|
|
@@ -67,7 +64,8 @@ const buildDictionary = (content, locale) => {
|
|
|
67
64
|
}
|
|
68
65
|
return content;
|
|
69
66
|
};
|
|
70
|
-
const createI18nextDictionaries = (content) => {
|
|
67
|
+
const createI18nextDictionaries = (content, configuration = getConfiguration()) => {
|
|
68
|
+
const { locales } = configuration.internationalization;
|
|
71
69
|
const result = locales.reduce(
|
|
72
70
|
(acc, locale) => ({
|
|
73
71
|
...acc,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.ts"],"sourcesContent":["import { getConfiguration, type Locales } from '@intlayer/config';\nimport {\n NodeType,\n type TranslationContent,\n type EnumerationContent,\n type TypedNode,\n type ContentNode,\n} from '@intlayer/core';\nimport { convertPluralsValues } from './convertPluralsValues';\n\ntype Dictionary = Record<string, unknown>;\nexport type I18nextDictionariesOutput = Partial<Record<Locales, Dictionary>>;\n\nconst
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.ts"],"sourcesContent":["import { getConfiguration, type Locales } from '@intlayer/config';\nimport {\n NodeType,\n type TranslationContent,\n type EnumerationContent,\n type TypedNode,\n type ContentNode,\n} from '@intlayer/core';\nimport { convertPluralsValues } from './convertPluralsValues';\n\ntype Dictionary = Record<string, unknown>;\nexport type I18nextDictionariesOutput = Partial<Record<Locales, Dictionary>>;\n\nconst isReactNode = (node: Record<string, unknown>): boolean =>\n typeof node?.key !== 'undefined' &&\n typeof node?.props !== 'undefined' &&\n typeof node?.type !== 'undefined';\n\n// Build dictionary for a specific locale\nconst buildDictionary = (content: ContentNode, locale: Locales): unknown => {\n if (\n // Translation node\n content &&\n (content as TypedNode).nodeType === NodeType.Translation\n ) {\n const contentState = (content as TranslationContent)[NodeType.Translation];\n const result = contentState[locale as keyof typeof contentState];\n\n return buildDictionary(result as ContentNode, locale);\n } else if (\n // Translation node\n content &&\n (content as TypedNode).nodeType === NodeType.Enumeration\n ) {\n const plurals: Record<string, unknown> = {};\n\n Object.keys(\n (content as EnumerationContent<unknown>)[NodeType.Enumeration]\n ).forEach((quantity) => {\n const letterNumber = convertPluralsValues(quantity);\n\n const value = (content as EnumerationContent<unknown>)[\n quantity as keyof EnumerationContent<unknown>\n ];\n\n plurals[`${letterNumber}_${letterNumber}`] = buildDictionary(\n value as ContentNode,\n locale\n );\n });\n\n return plurals;\n } else if (\n // React element node\n isReactNode(content as Record<string, unknown>)\n ) {\n return JSON.stringify(content);\n } else if (\n // Nested object\n typeof content === 'object' &&\n Array.isArray(content)\n ) {\n const result: unknown[] = [];\n\n Object.keys(content).forEach((dictionaryValue) => {\n result.push(\n buildDictionary(\n content[dictionaryValue as keyof typeof content] as ContentNode,\n locale\n )\n );\n });\n\n return result;\n } else if (\n // Nested object\n typeof content === 'object'\n ) {\n const result: Record<string, unknown> = {};\n\n Object.keys(content as Record<string, unknown>).forEach(\n (dictionaryValue) => {\n result[dictionaryValue] = buildDictionary(\n content?.[\n dictionaryValue as keyof typeof content\n ] as unknown as ContentNode,\n locale\n );\n }\n );\n\n return result;\n }\n\n return content;\n};\n\nexport const createI18nextDictionaries = (\n content: ContentNode,\n configuration = getConfiguration()\n): I18nextDictionariesOutput => {\n const { locales } = configuration.internationalization;\n\n // Map dictionaries for each locale\n const result: I18nextDictionariesOutput = locales.reduce(\n (acc, locale) => ({\n ...acc,\n [locale]: buildDictionary(content, locale),\n }),\n {}\n );\n\n return result;\n};\n"],"mappings":"AAAA,SAAS,wBAAsC;AAC/C;AAAA,EACE;AAAA,OAKK;AACP,SAAS,4BAA4B;AAKrC,MAAM,cAAc,CAAC,SACnB,OAAO,MAAM,QAAQ,eACrB,OAAO,MAAM,UAAU,eACvB,OAAO,MAAM,SAAS;AAGxB,MAAM,kBAAkB,CAAC,SAAsB,WAA6B;AAC1E;AAAA;AAAA,IAEE,WACC,QAAsB,aAAa,SAAS;AAAA,IAC7C;AACA,UAAM,eAAgB,QAA+B,SAAS,WAAW;AACzE,UAAM,SAAS,aAAa,MAAmC;AAE/D,WAAO,gBAAgB,QAAuB,MAAM;AAAA,EACtD;AAAA;AAAA,IAEE,WACC,QAAsB,aAAa,SAAS;AAAA,IAC7C;AACA,UAAM,UAAmC,CAAC;AAE1C,WAAO;AAAA,MACJ,QAAwC,SAAS,WAAW;AAAA,IAC/D,EAAE,QAAQ,CAAC,aAAa;AACtB,YAAM,eAAe,qBAAqB,QAAQ;AAElD,YAAM,QAAS,QACb,QACF;AAEA,cAAQ,GAAG,YAAY,IAAI,YAAY,EAAE,IAAI;AAAA,QAC3C;AAAA,QACA;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AAAA;AAAA,IAEE,YAAY,OAAkC;AAAA,IAC9C;AACA,WAAO,KAAK,UAAU,OAAO;AAAA,EAC/B;AAAA;AAAA,IAEE,OAAO,YAAY,YACnB,MAAM,QAAQ,OAAO;AAAA,IACrB;AACA,UAAM,SAAoB,CAAC;AAE3B,WAAO,KAAK,OAAO,EAAE,QAAQ,CAAC,oBAAoB;AAChD,aAAO;AAAA,QACL;AAAA,UACE,QAAQ,eAAuC;AAAA,UAC/C;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AAAA;AAAA,IAEE,OAAO,YAAY;AAAA,IACnB;AACA,UAAM,SAAkC,CAAC;AAEzC,WAAO,KAAK,OAAkC,EAAE;AAAA,MAC9C,CAAC,oBAAoB;AACnB,eAAO,eAAe,IAAI;AAAA,UACxB,UACE,eACF;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,MAAM,4BAA4B,CACvC,SACA,gBAAgB,iBAAiB,MACH;AAC9B,QAAM,EAAE,QAAQ,IAAI,cAAc;AAGlC,QAAM,SAAoC,QAAQ;AAAA,IAChD,CAAC,KAAK,YAAY;AAAA,MAChB,GAAG;AAAA,MACH,CAAC,MAAM,GAAG,gBAAgB,SAAS,MAAM;AAAA,IAC3C;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SAAO;AACT;","names":[]}
|
package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.mjs
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { mkdir, writeFile } from "fs/promises";
|
|
2
2
|
import { resolve } from "path";
|
|
3
3
|
import { getConfiguration } from "@intlayer/config";
|
|
4
|
-
const
|
|
5
|
-
const { i18nextResourcesDir } = content;
|
|
6
|
-
const writeDictionary = async (dictionariesDeclaration) => {
|
|
4
|
+
const writeDictionary = async (dictionariesDeclaration, configuration = getConfiguration()) => {
|
|
5
|
+
const { i18nextResourcesDir } = configuration.content;
|
|
7
6
|
const resultDictionariesPaths = [];
|
|
8
7
|
for (const [nameSpace, localContent] of Object.entries(
|
|
9
8
|
dictionariesDeclaration
|
|
10
9
|
)) {
|
|
11
|
-
for await (const [locale,
|
|
12
|
-
const contentString = JSON.stringify(
|
|
10
|
+
for await (const [locale, content] of Object.entries(localContent)) {
|
|
11
|
+
const contentString = JSON.stringify(content);
|
|
13
12
|
const outputFileName = `${nameSpace}.json`;
|
|
14
13
|
const resultDirPath = resolve(i18nextResourcesDir, locale);
|
|
15
14
|
const resultFilePath = resolve(resultDirPath, outputFileName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.ts"],"sourcesContent":["import { mkdir, writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport type { I18nextDictionariesOutput } from './convertContentDeclarationInto18nDictionaries';\n\
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.ts"],"sourcesContent":["import { mkdir, writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport type { I18nextDictionariesOutput } from './convertContentDeclarationInto18nDictionaries';\n\nexport type DictionariesDeclaration = Record<string, I18nextDictionariesOutput>;\n\n/**\n * This function writes the dictionaries to the file system\n */\nexport const writeDictionary = async (\n dictionariesDeclaration: DictionariesDeclaration,\n configuration = getConfiguration()\n) => {\n const { i18nextResourcesDir } = configuration.content;\n\n const resultDictionariesPaths: string[] = [];\n\n for (const [nameSpace, localContent] of Object.entries(\n dictionariesDeclaration\n )) {\n for await (const [locale, content] of Object.entries(localContent)) {\n const contentString = JSON.stringify(content);\n\n const outputFileName = `${nameSpace}.json`;\n const resultDirPath = resolve(i18nextResourcesDir, locale);\n const resultFilePath = resolve(resultDirPath, outputFileName);\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resultDirPath, { recursive: true });\n\n // Create the json file\n await writeFile(resultFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating ${outputFileName}:`, err);\n });\n\n resultDictionariesPaths.push(resultFilePath);\n }\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":"AAAA,SAAS,OAAO,iBAAiB;AACjC,SAAS,eAAe;AACxB,SAAS,wBAAwB;AAQ1B,MAAM,kBAAkB,OAC7B,yBACA,gBAAgB,iBAAiB,MAC9B;AACH,QAAM,EAAE,oBAAoB,IAAI,cAAc;AAE9C,QAAM,0BAAoC,CAAC;AAE3C,aAAW,CAAC,WAAW,YAAY,KAAK,OAAO;AAAA,IAC7C;AAAA,EACF,GAAG;AACD,qBAAiB,CAAC,QAAQ,OAAO,KAAK,OAAO,QAAQ,YAAY,GAAG;AAClE,YAAM,gBAAgB,KAAK,UAAU,OAAO;AAE5C,YAAM,iBAAiB,GAAG,SAAS;AACnC,YAAM,gBAAgB,QAAQ,qBAAqB,MAAM;AACzD,YAAM,iBAAiB,QAAQ,eAAe,cAAc;AAG5D,YAAM,MAAM,eAAe,EAAE,WAAW,KAAK,CAAC;AAG9C,YAAM,UAAU,gBAAgB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACpE,gBAAQ,MAAM,kBAAkB,cAAc,KAAK,GAAG;AAAA,MACxD,CAAC;AAED,8BAAwB,KAAK,cAAc;AAAA,IAC7C;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { getConfiguration } from "@intlayer/config";
|
|
2
2
|
import { buildI18nDictionary } from "./i18next_dictionary/index.mjs";
|
|
3
3
|
import { buildIntlayerDictionary } from "./intlayer_dictionary/index.mjs";
|
|
4
|
-
const {
|
|
5
|
-
|
|
6
|
-
} = getConfiguration();
|
|
7
|
-
const buildDictionary = async (dictionaries) => {
|
|
4
|
+
const buildDictionary = async (dictionaries, configuration = getConfiguration()) => {
|
|
5
|
+
const { dictionaryOutput } = configuration.content;
|
|
8
6
|
if (dictionaryOutput.includes("i18next")) {
|
|
9
|
-
await buildI18nDictionary(dictionaries);
|
|
7
|
+
await buildI18nDictionary(dictionaries, configuration);
|
|
10
8
|
}
|
|
11
9
|
if (dictionaryOutput.includes("intlayer")) {
|
|
12
|
-
return await buildIntlayerDictionary(dictionaries);
|
|
10
|
+
return await buildIntlayerDictionary(dictionaries, configuration);
|
|
13
11
|
}
|
|
14
12
|
return [];
|
|
15
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/declaration_file_to_dictionary/index.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { buildI18nDictionary } from './i18next_dictionary/index';\nimport { buildIntlayerDictionary } from './intlayer_dictionary/index';\n\
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/declaration_file_to_dictionary/index.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { buildI18nDictionary } from './i18next_dictionary/index';\nimport { buildIntlayerDictionary } from './intlayer_dictionary/index';\n\nexport const buildDictionary = async (\n dictionaries: Dictionary[],\n configuration = getConfiguration()\n): Promise<string[]> => {\n const { dictionaryOutput } = configuration.content;\n\n if (dictionaryOutput.includes('i18next')) {\n await buildI18nDictionary(dictionaries, configuration);\n }\n\n if (dictionaryOutput.includes('intlayer')) {\n return await buildIntlayerDictionary(dictionaries, configuration);\n }\n\n return [];\n};\n"],"mappings":"AAAA,SAAS,wBAAwB;AAEjC,SAAS,2BAA2B;AACpC,SAAS,+BAA+B;AAEjC,MAAM,kBAAkB,OAC7B,cACA,gBAAgB,iBAAiB,MACX;AACtB,QAAM,EAAE,iBAAiB,IAAI,cAAc;AAE3C,MAAI,iBAAiB,SAAS,SAAS,GAAG;AACxC,UAAM,oBAAoB,cAAc,aAAa;AAAA,EACvD;AAEA,MAAI,iBAAiB,SAAS,UAAU,GAAG;AACzC,WAAO,MAAM,wBAAwB,cAAc,aAAa;AAAA,EAClE;AAEA,SAAO,CAAC;AACV;","names":[]}
|
|
@@ -2,12 +2,12 @@ import { mkdir } from "fs/promises";
|
|
|
2
2
|
import { resolve } from "path";
|
|
3
3
|
import { getConfiguration } from "@intlayer/config";
|
|
4
4
|
import { writeDictionary } from "./writeDictionary.mjs";
|
|
5
|
-
const
|
|
6
|
-
const { dictionariesDir } = content;
|
|
7
|
-
const buildIntlayerDictionary = async (contentDeclarations) => {
|
|
5
|
+
const buildIntlayerDictionary = async (contentDeclarations, configuration = getConfiguration()) => {
|
|
6
|
+
const { dictionariesDir } = configuration.content;
|
|
8
7
|
await mkdir(resolve(dictionariesDir), { recursive: true });
|
|
9
8
|
const dictionariesPaths = await writeDictionary(
|
|
10
|
-
contentDeclarations
|
|
9
|
+
contentDeclarations,
|
|
10
|
+
configuration
|
|
11
11
|
);
|
|
12
12
|
return dictionariesPaths;
|
|
13
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.ts"],"sourcesContent":["import { mkdir } from 'fs/promises';\nimport { resolve } from 'path';\n// @ts-ignore: @intlayer/backend is not built yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { writeDictionary } from './writeDictionary';\n\
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.ts"],"sourcesContent":["import { mkdir } from 'fs/promises';\nimport { resolve } from 'path';\n// @ts-ignore: @intlayer/backend is not built yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { writeDictionary } from './writeDictionary';\n\n/**\n * This function transpile the bundled code to to make dictionaries as JSON files\n */\nexport const buildIntlayerDictionary = async (\n contentDeclarations: (DictionaryAPI | Dictionary)[],\n configuration = getConfiguration()\n) => {\n const { dictionariesDir } = configuration.content;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n const dictionariesPaths: string[] = await writeDictionary(\n contentDeclarations as Dictionary[],\n configuration\n );\n\n return dictionariesPaths;\n};\n"],"mappings":"AAAA,SAAS,aAAa;AACtB,SAAS,eAAe;AAGxB,SAAS,wBAAwB;AAEjC,SAAS,uBAAuB;AAKzB,MAAM,0BAA0B,OACrC,qBACA,gBAAgB,iBAAiB,MAC9B;AACH,QAAM,EAAE,gBAAgB,IAAI,cAAc;AAG1C,QAAM,MAAM,QAAQ,eAAe,GAAG,EAAE,WAAW,KAAK,CAAC;AAEzD,QAAM,oBAA8B,MAAM;AAAA,IACxC;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { writeFile } from "fs/promises";
|
|
2
2
|
import { resolve } from "path";
|
|
3
3
|
import { getConfiguration } from "@intlayer/config";
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const writeDictionary = async (dictionaries, configuration = getConfiguration()) => {
|
|
5
|
+
const { dictionariesDir } = configuration.content;
|
|
6
6
|
const resultDictionariesPaths = [];
|
|
7
7
|
for await (const dictionaryContent of dictionaries) {
|
|
8
|
-
const
|
|
9
|
-
const contentString =
|
|
8
|
+
const isDevelopment = process.env.NODE_ENV === "development";
|
|
9
|
+
const contentString = isDevelopment ? JSON.stringify(dictionaryContent, null, 2) : JSON.stringify(dictionaryContent);
|
|
10
10
|
const key = dictionaryContent.key;
|
|
11
11
|
const outputFileName = `${key}.json`;
|
|
12
12
|
const resultFilePath = resolve(dictionariesDir, outputFileName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.ts"],"sourcesContent":["import { writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\n\
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.ts"],"sourcesContent":["import { writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\n\nexport const writeDictionary = async (\n dictionaries: Dictionary[],\n configuration = getConfiguration()\n) => {\n const { dictionariesDir } = configuration.content;\n const resultDictionariesPaths: string[] = [];\n\n for await (const dictionaryContent of dictionaries) {\n const isDevelopment = process.env.NODE_ENV === 'development';\n const contentString = isDevelopment\n ? JSON.stringify(dictionaryContent, null, 2)\n : JSON.stringify(dictionaryContent);\n\n const key = dictionaryContent.key;\n const outputFileName = `${key}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n // Create the json file\n await writeFile(resultFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating ${outputFileName}:`, err);\n });\n\n resultDictionariesPaths.push(resultFilePath);\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":"AAAA,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,wBAAwB;AAG1B,MAAM,kBAAkB,OAC7B,cACA,gBAAgB,iBAAiB,MAC9B;AACH,QAAM,EAAE,gBAAgB,IAAI,cAAc;AAC1C,QAAM,0BAAoC,CAAC;AAE3C,mBAAiB,qBAAqB,cAAc;AAClD,UAAM,gBAAgB,QAAQ,IAAI,aAAa;AAC/C,UAAM,gBAAgB,gBAClB,KAAK,UAAU,mBAAmB,MAAM,CAAC,IACzC,KAAK,UAAU,iBAAiB;AAEpC,UAAM,MAAM,kBAAkB;AAC9B,UAAM,iBAAiB,GAAG,GAAG;AAC7B,UAAM,iBAAiB,QAAQ,iBAAiB,cAAc;AAG9D,UAAM,UAAU,gBAAgB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACpE,cAAQ,MAAM,kBAAkB,cAAc,KAAK,GAAG;AAAA,IACxD,CAAC;AAED,4BAAwB,KAAK,cAAc;AAAA,EAC7C;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -3,10 +3,9 @@ import { basename, extname, relative, resolve } from "path";
|
|
|
3
3
|
import { getConfiguration } from "@intlayer/config";
|
|
4
4
|
import { getBuiltDictionariesPath } from "../../getBuiltDictionariesPath.mjs";
|
|
5
5
|
import { getFileHash } from "../../utils.mjs";
|
|
6
|
-
const
|
|
7
|
-
const { mainDir } = content;
|
|
8
|
-
|
|
9
|
-
let content2 = "";
|
|
6
|
+
const generateDictionaryListContent = (dictionaries, format = "esm", configuration = getConfiguration()) => {
|
|
7
|
+
const { mainDir } = configuration.content;
|
|
8
|
+
let content = "";
|
|
10
9
|
const dictionariesRef = dictionaries.map((dictionaryPath) => ({
|
|
11
10
|
relativePath: relative(mainDir, dictionaryPath),
|
|
12
11
|
id: basename(dictionaryPath, extname(dictionaryPath)),
|
|
@@ -16,34 +15,43 @@ const generateDictionaryListContent = (dictionaries, format = "esm") => {
|
|
|
16
15
|
}));
|
|
17
16
|
dictionariesRef.forEach((dictionary) => {
|
|
18
17
|
if (format === "esm")
|
|
19
|
-
|
|
18
|
+
content += `import ${dictionary.hash} from '${dictionary.relativePath}';
|
|
20
19
|
`;
|
|
21
20
|
if (format === "cjs")
|
|
22
|
-
|
|
21
|
+
content += `const ${dictionary.hash} = require('${dictionary.relativePath}');
|
|
23
22
|
`;
|
|
24
23
|
});
|
|
25
|
-
|
|
24
|
+
content += "\n";
|
|
26
25
|
const formattedDictionaryMap = dictionariesRef.map((dictionary) => ` "${dictionary.id}": ${dictionary.hash}`).join(",\n");
|
|
27
26
|
if (format === "esm")
|
|
28
|
-
|
|
27
|
+
content += `export default {
|
|
29
28
|
${formattedDictionaryMap}
|
|
30
29
|
};
|
|
31
30
|
`;
|
|
32
31
|
if (format === "cjs")
|
|
33
|
-
|
|
32
|
+
content += `module.exports = {
|
|
34
33
|
${formattedDictionaryMap}
|
|
35
34
|
};
|
|
36
35
|
`;
|
|
37
|
-
return
|
|
36
|
+
return content;
|
|
38
37
|
};
|
|
39
|
-
const createDictionaryEntryPoint = () => {
|
|
38
|
+
const createDictionaryEntryPoint = (configuration = getConfiguration()) => {
|
|
39
|
+
const { mainDir } = configuration.content;
|
|
40
40
|
if (!existsSync(mainDir)) {
|
|
41
41
|
mkdirSync(mainDir, { recursive: true });
|
|
42
42
|
}
|
|
43
|
-
const dictionariesPath = getBuiltDictionariesPath();
|
|
44
|
-
const cjsContent = generateDictionaryListContent(
|
|
43
|
+
const dictionariesPath = getBuiltDictionariesPath(configuration);
|
|
44
|
+
const cjsContent = generateDictionaryListContent(
|
|
45
|
+
dictionariesPath,
|
|
46
|
+
"cjs",
|
|
47
|
+
configuration
|
|
48
|
+
);
|
|
45
49
|
writeFileSync(resolve(mainDir, "dictionaries.cjs"), cjsContent);
|
|
46
|
-
const esmContent = generateDictionaryListContent(
|
|
50
|
+
const esmContent = generateDictionaryListContent(
|
|
51
|
+
dictionariesPath,
|
|
52
|
+
"esm",
|
|
53
|
+
configuration
|
|
54
|
+
);
|
|
47
55
|
writeFileSync(resolve(mainDir, "dictionaries.mjs"), esmContent);
|
|
48
56
|
};
|
|
49
57
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/createDictionaryEntryPoint.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { basename, extname, relative, resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport { getBuiltDictionariesPath } from '../../getBuiltDictionariesPath';\nimport { getFileHash } from '../../utils';\n\
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/createDictionaryEntryPoint.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { basename, extname, relative, resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport { getBuiltDictionariesPath } from '../../getBuiltDictionariesPath';\nimport { getFileHash } from '../../utils';\n\n/**\n * This function generates the content of the dictionary list file\n */\nconst generateDictionaryListContent = (\n dictionaries: string[],\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { mainDir } = configuration.content;\n\n let content = '';\n\n const dictionariesRef = dictionaries.map((dictionaryPath) => ({\n relativePath: relative(mainDir, dictionaryPath),\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n if (format === 'esm')\n content += `import ${dictionary.hash} from '${dictionary.relativePath}';\\n`;\n if (format === 'cjs')\n content += `const ${dictionary.hash} = require('${dictionary.relativePath}');\\n`;\n });\n\n content += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": ${dictionary.hash}`)\n .join(',\\n');\n\n if (format === 'esm')\n content += `export default {\\n${formattedDictionaryMap}\\n};\\n`;\n if (format === 'cjs')\n content += `module.exports = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n return content;\n};\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const createDictionaryEntryPoint = (\n configuration = getConfiguration()\n) => {\n const { mainDir } = configuration.content;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n const dictionariesPath: string[] = getBuiltDictionariesPath(configuration);\n\n // Create the dictionary list file\n const cjsContent = generateDictionaryListContent(\n dictionariesPath,\n 'cjs',\n configuration\n );\n writeFileSync(resolve(mainDir, 'dictionaries.cjs'), cjsContent);\n\n const esmContent = generateDictionaryListContent(\n dictionariesPath,\n 'esm',\n configuration\n );\n writeFileSync(resolve(mainDir, 'dictionaries.mjs'), esmContent);\n};\n"],"mappings":"AAAA,SAAS,YAAY,WAAW,qBAAqB;AACrD,SAAS,UAAU,SAAS,UAAU,eAAe;AACrD,SAAS,wBAAwB;AACjC,SAAS,gCAAgC;AACzC,SAAS,mBAAmB;AAK5B,MAAM,gCAAgC,CACpC,cACA,SAAwB,OACxB,gBAAgB,iBAAiB,MACtB;AACX,QAAM,EAAE,QAAQ,IAAI,cAAc;AAElC,MAAI,UAAU;AAEd,QAAM,kBAAkB,aAAa,IAAI,CAAC,oBAAoB;AAAA,IAC5D,cAAc,SAAS,SAAS,cAAc;AAAA,IAC9C,IAAI,SAAS,gBAAgB,QAAQ,cAAc,CAAC;AAAA;AAAA,IACpD,MAAM,IAAI,YAAY,cAAc,CAAC;AAAA;AAAA,EACvC,EAAE;AAGF,kBAAgB,QAAQ,CAAC,eAAe;AACtC,QAAI,WAAW;AACb,iBAAW,UAAU,WAAW,IAAI,UAAU,WAAW,YAAY;AAAA;AACvE,QAAI,WAAW;AACb,iBAAW,SAAS,WAAW,IAAI,eAAe,WAAW,YAAY;AAAA;AAAA,EAC7E,CAAC;AAED,aAAW;AAGX,QAAM,yBAAiC,gBACpC,IAAI,CAAC,eAAe,MAAM,WAAW,EAAE,MAAM,WAAW,IAAI,EAAE,EAC9D,KAAK,KAAK;AAEb,MAAI,WAAW;AACb,eAAW;AAAA,EAAqB,sBAAsB;AAAA;AAAA;AACxD,MAAI,WAAW;AACb,eAAW;AAAA,EAAuB,sBAAsB;AAAA;AAAA;AAE1D,SAAO;AACT;AAKO,MAAM,6BAA6B,CACxC,gBAAgB,iBAAiB,MAC9B;AACH,QAAM,EAAE,QAAQ,IAAI,cAAc;AAGlC,MAAI,CAAC,WAAW,OAAO,GAAG;AACxB,cAAU,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACxC;AAEA,QAAM,mBAA6B,yBAAyB,aAAa;AAGzE,QAAM,aAAa;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,gBAAc,QAAQ,SAAS,kBAAkB,GAAG,UAAU;AAE9D,QAAM,aAAa;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,gBAAc,QAAQ,SAAS,kBAAkB,GAAG,UAAU;AAChE;","names":[]}
|
|
@@ -3,19 +3,19 @@ import { basename, extname, join, relative } from "path";
|
|
|
3
3
|
import { Locales, getConfiguration } from "@intlayer/config";
|
|
4
4
|
import fg from "fast-glob";
|
|
5
5
|
import { getFileHash, kebabCaseToCamelCase } from "../../utils.mjs";
|
|
6
|
-
const { content, internationalization } = getConfiguration();
|
|
7
|
-
const { moduleAugmentationDir, typesDir } = content;
|
|
8
|
-
const { locales, requiredLocales, strictMode } = internationalization;
|
|
9
6
|
const getTypeName = (key) => `${kebabCaseToCamelCase(key)}Content`;
|
|
10
|
-
const formatLocales = (
|
|
7
|
+
const formatLocales = (locales) => locales.map((locale) => {
|
|
11
8
|
for (const key in Locales) {
|
|
12
9
|
if (Locales[key] === locale) {
|
|
13
10
|
return `Locales.${key}`;
|
|
14
11
|
}
|
|
15
12
|
}
|
|
16
13
|
}).join(" | ");
|
|
17
|
-
const generateTypeIndexContent = (typeFiles) => {
|
|
18
|
-
|
|
14
|
+
const generateTypeIndexContent = (typeFiles, configuration = getConfiguration()) => {
|
|
15
|
+
const { content, internationalization } = configuration;
|
|
16
|
+
const { moduleAugmentationDir } = content;
|
|
17
|
+
const { locales, requiredLocales, strictMode } = internationalization;
|
|
18
|
+
let fileContent = "/* eslint-disable */\nimport { Locales } from 'intlayer';\n";
|
|
19
19
|
const dictionariesRef = typeFiles.map((dictionaryPath) => ({
|
|
20
20
|
relativePath: `./${relative(moduleAugmentationDir, dictionaryPath)}`,
|
|
21
21
|
id: basename(dictionaryPath, extname(dictionaryPath)),
|
|
@@ -24,10 +24,10 @@ const generateTypeIndexContent = (typeFiles) => {
|
|
|
24
24
|
// Get the hash of the dictionary to avoid conflicts
|
|
25
25
|
}));
|
|
26
26
|
dictionariesRef.forEach((dictionary) => {
|
|
27
|
-
|
|
27
|
+
fileContent += `import ${dictionary.hash} from '${dictionary.relativePath}';
|
|
28
28
|
`;
|
|
29
29
|
});
|
|
30
|
-
|
|
30
|
+
fileContent += "\n";
|
|
31
31
|
const formattedDictionaryMap = dictionariesRef.map((dictionary) => ` "${dictionary.id}": typeof ${dictionary.hash};`).join("\n");
|
|
32
32
|
const requiredLocalesValues = requiredLocales.length > 0 ? requiredLocales.filter(
|
|
33
33
|
(locale) => locales.map((locale2) => String(locale2)).includes(String(locale))
|
|
@@ -35,27 +35,28 @@ const generateTypeIndexContent = (typeFiles) => {
|
|
|
35
35
|
const formattedLocales = formatLocales(locales);
|
|
36
36
|
const formattedRequiredLocales = formatLocales(requiredLocalesValues);
|
|
37
37
|
const strictModeRecord = strictMode === "strict" ? `interface IConfigLocales<Content> extends Record<DeclaredLocales, Content> {}` : strictMode === "inclusive" ? `interface IConfigLocales<Content> extends Record<ExtractedLocales, Content>, Partial<Record<ExcludedLocales, Content>> {}` : `interface IConfigLocales<Content> extends Partial<Record<Locales, Content>> {}`;
|
|
38
|
-
|
|
38
|
+
fileContent += `declare module 'intlayer' {
|
|
39
39
|
`;
|
|
40
|
-
|
|
40
|
+
fileContent += ` interface IntlayerDictionaryTypesConnector {
|
|
41
41
|
${formattedDictionaryMap}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
`;
|
|
45
|
-
|
|
45
|
+
fileContent += ` type DeclaredLocales = ${formattedLocales};
|
|
46
46
|
`;
|
|
47
|
-
|
|
47
|
+
fileContent += ` type RequiredLocales = ${formattedRequiredLocales};
|
|
48
48
|
`;
|
|
49
|
-
|
|
49
|
+
fileContent += ` type ExtractedLocales = Extract<Locales, RequiredLocales>;
|
|
50
50
|
`;
|
|
51
|
-
|
|
51
|
+
fileContent += ` type ExcludedLocales = Exclude<Locales, RequiredLocales>;
|
|
52
52
|
`;
|
|
53
|
-
|
|
53
|
+
fileContent += ` ${strictModeRecord}
|
|
54
54
|
`;
|
|
55
|
-
|
|
56
|
-
return
|
|
55
|
+
fileContent += `}`;
|
|
56
|
+
return fileContent;
|
|
57
57
|
};
|
|
58
|
-
const createModuleAugmentation = () => {
|
|
58
|
+
const createModuleAugmentation = (configuration = getConfiguration()) => {
|
|
59
|
+
const { moduleAugmentationDir, typesDir } = configuration.content;
|
|
59
60
|
if (!existsSync(moduleAugmentationDir)) {
|
|
60
61
|
mkdirSync(moduleAugmentationDir, { recursive: true });
|
|
61
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createModuleAugmentation.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { basename, extname, join, relative } from 'path';\nimport { Locales, getConfiguration } from '@intlayer/config';\nimport fg from 'fast-glob';\nimport { getFileHash, kebabCaseToCamelCase } from '../../utils';\n\
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createModuleAugmentation.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { basename, extname, join, relative } from 'path';\nimport { Locales, getConfiguration } from '@intlayer/config';\nimport fg from 'fast-glob';\nimport { getFileHash, kebabCaseToCamelCase } from '../../utils';\n\nexport const getTypeName = (key: string): string =>\n `${kebabCaseToCamelCase(key)}Content`;\n\nconst formatLocales = (locales: Locales[]): string =>\n locales\n .map((locale) => {\n for (const key in Locales) {\n if (Locales[key as keyof typeof Locales] === locale) {\n return `Locales.${key}`;\n }\n }\n })\n .join(' | ');\n\n/**\n * This function generates the content of the module augmentation file\n */\nconst generateTypeIndexContent = (\n typeFiles: string[],\n configuration = getConfiguration()\n): string => {\n const { content, internationalization } = configuration;\n const { moduleAugmentationDir } = content;\n const { locales, requiredLocales, strictMode } = internationalization;\n\n let fileContent =\n \"/* eslint-disable */\\nimport { Locales } from 'intlayer';\\n\";\n\n const dictionariesRef = typeFiles.map((dictionaryPath) => ({\n relativePath: `./${relative(moduleAugmentationDir, dictionaryPath)}`,\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id (without the extension)\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n fileContent += `import ${dictionary.hash} from '${dictionary.relativePath}';\\n`;\n });\n\n fileContent += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": typeof ${dictionary.hash};`)\n .join('\\n');\n\n const requiredLocalesValues =\n requiredLocales.length > 0\n ? requiredLocales.filter((locale) =>\n locales.map((locale) => String(locale)).includes(String(locale))\n )\n : locales;\n\n const formattedLocales = formatLocales(locales);\n const formattedRequiredLocales = formatLocales(requiredLocalesValues);\n\n const strictModeRecord =\n strictMode === 'strict'\n ? `interface IConfigLocales<Content> extends Record<DeclaredLocales, Content> {}`\n : strictMode === 'inclusive'\n ? `interface IConfigLocales<Content> extends Record<ExtractedLocales, Content>, Partial<Record<ExcludedLocales, Content>> {}`\n : `interface IConfigLocales<Content> extends Partial<Record<Locales, Content>> {}`;\n\n /**\n * Write the module augmentation to extend the intlayer module with the dictionaries types\n * Will suggest the type resulting of the dictionaries\n *\n * declare module 'intlayer' {\n * interface IntlayerDictionaryTypesConnector = {\n * dictionaries: {\n * id: DictionaryType;\n * }\n * }\n *\n * type ConfigLocales = Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH;\n * type ExtractedLocales = Extract<Locales, ConfigLocales>;\n *\n * interface IConfigLocales<Content> extends Record<ExtractedLocales, Content>, Partial<Record<ExcludedLocales, Content>> {}\n *\n *\n * }\n * See https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation\n */\n fileContent += `declare module 'intlayer' {\\n`;\n fileContent += ` interface IntlayerDictionaryTypesConnector {\\n${formattedDictionaryMap}\\n }\\n\\n`;\n fileContent += ` type DeclaredLocales = ${formattedLocales};\\n`;\n fileContent += ` type RequiredLocales = ${formattedRequiredLocales};\\n`;\n fileContent += ` type ExtractedLocales = Extract<Locales, RequiredLocales>;\\n`;\n fileContent += ` type ExcludedLocales = Exclude<Locales, RequiredLocales>;\\n`;\n fileContent += ` ${strictModeRecord}\\n`;\n fileContent += `}`;\n\n return fileContent;\n};\n\n/**\n * This function generates a index file merging all the types\n */\nexport const createModuleAugmentation = (\n configuration = getConfiguration()\n) => {\n const { moduleAugmentationDir, typesDir } = configuration.content;\n\n // Create main directory if it doesn't exist\n if (!existsSync(moduleAugmentationDir)) {\n mkdirSync(moduleAugmentationDir, { recursive: true });\n }\n\n const dictionariesTypesDefinitions: string[] = fg.sync(`${typesDir}/*.ts`, {\n ignore: ['**/*.d.ts'],\n });\n // Create the dictionary list file\n\n const tsContent = generateTypeIndexContent(dictionariesTypesDefinitions);\n writeFileSync(join(moduleAugmentationDir, 'intlayer.d.ts'), tsContent);\n};\n"],"mappings":"AAAA,SAAS,YAAY,WAAW,qBAAqB;AACrD,SAAS,UAAU,SAAS,MAAM,gBAAgB;AAClD,SAAS,SAAS,wBAAwB;AAC1C,OAAO,QAAQ;AACf,SAAS,aAAa,4BAA4B;AAE3C,MAAM,cAAc,CAAC,QAC1B,GAAG,qBAAqB,GAAG,CAAC;AAE9B,MAAM,gBAAgB,CAAC,YACrB,QACG,IAAI,CAAC,WAAW;AACf,aAAW,OAAO,SAAS;AACzB,QAAI,QAAQ,GAA2B,MAAM,QAAQ;AACnD,aAAO,WAAW,GAAG;AAAA,IACvB;AAAA,EACF;AACF,CAAC,EACA,KAAK,KAAK;AAKf,MAAM,2BAA2B,CAC/B,WACA,gBAAgB,iBAAiB,MACtB;AACX,QAAM,EAAE,SAAS,qBAAqB,IAAI;AAC1C,QAAM,EAAE,sBAAsB,IAAI;AAClC,QAAM,EAAE,SAAS,iBAAiB,WAAW,IAAI;AAEjD,MAAI,cACF;AAEF,QAAM,kBAAkB,UAAU,IAAI,CAAC,oBAAoB;AAAA,IACzD,cAAc,KAAK,SAAS,uBAAuB,cAAc,CAAC;AAAA,IAClE,IAAI,SAAS,gBAAgB,QAAQ,cAAc,CAAC;AAAA;AAAA,IACpD,MAAM,IAAI,YAAY,cAAc,CAAC;AAAA;AAAA,EACvC,EAAE;AAGF,kBAAgB,QAAQ,CAAC,eAAe;AACtC,mBAAe,UAAU,WAAW,IAAI,UAAU,WAAW,YAAY;AAAA;AAAA,EAC3E,CAAC;AAED,iBAAe;AAGf,QAAM,yBAAiC,gBACpC,IAAI,CAAC,eAAe,QAAQ,WAAW,EAAE,aAAa,WAAW,IAAI,GAAG,EACxE,KAAK,IAAI;AAEZ,QAAM,wBACJ,gBAAgB,SAAS,IACrB,gBAAgB;AAAA,IAAO,CAAC,WACtB,QAAQ,IAAI,CAACA,YAAW,OAAOA,OAAM,CAAC,EAAE,SAAS,OAAO,MAAM,CAAC;AAAA,EACjE,IACA;AAEN,QAAM,mBAAmB,cAAc,OAAO;AAC9C,QAAM,2BAA2B,cAAc,qBAAqB;AAEpE,QAAM,mBACJ,eAAe,WACX,kFACA,eAAe,cACb,8HACA;AAsBR,iBAAe;AAAA;AACf,iBAAe;AAAA,EAAmD,sBAAsB;AAAA;AAAA;AAAA;AACxF,iBAAe,4BAA4B,gBAAgB;AAAA;AAC3D,iBAAe,4BAA4B,wBAAwB;AAAA;AACnE,iBAAe;AAAA;AACf,iBAAe;AAAA;AACf,iBAAe,KAAK,gBAAgB;AAAA;AACpC,iBAAe;AAEf,SAAO;AACT;AAKO,MAAM,2BAA2B,CACtC,gBAAgB,iBAAiB,MAC9B;AACH,QAAM,EAAE,uBAAuB,SAAS,IAAI,cAAc;AAG1D,MAAI,CAAC,WAAW,qBAAqB,GAAG;AACtC,cAAU,uBAAuB,EAAE,WAAW,KAAK,CAAC;AAAA,EACtD;AAEA,QAAM,+BAAyC,GAAG,KAAK,GAAG,QAAQ,SAAS;AAAA,IACzE,QAAQ,CAAC,WAAW;AAAA,EACtB,CAAC;AAGD,QAAM,YAAY,yBAAyB,4BAA4B;AACvE,gBAAc,KAAK,uBAAuB,eAAe,GAAG,SAAS;AACvE;","names":["locale"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, writeFileSync } from "fs";
|
|
2
2
|
import { resolve } from "path";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import {
|
|
4
|
+
getConfiguration,
|
|
5
|
+
ESMxCJSRequire
|
|
6
|
+
} from "@intlayer/config";
|
|
6
7
|
const requireUncached = (module) => {
|
|
7
8
|
delete ESMxCJSRequire.cache[ESMxCJSRequire.resolve(module)];
|
|
8
9
|
return ESMxCJSRequire(module);
|
|
@@ -18,7 +19,8 @@ const generateTypeScriptType = (dictionary) => {
|
|
|
18
19
|
export default ${jsonString} as const;
|
|
19
20
|
`;
|
|
20
21
|
};
|
|
21
|
-
const createTypes = (dictionariesPaths) => {
|
|
22
|
+
const createTypes = (dictionariesPaths, configuration = getConfiguration()) => {
|
|
23
|
+
const { typesDir } = configuration.content;
|
|
22
24
|
const resultTypesPaths = [];
|
|
23
25
|
if (!existsSync(typesDir)) {
|
|
24
26
|
mkdirSync(typesDir, { recursive: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createType.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { resolve } from 'path';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createType.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { resolve } from 'path';\nimport {\n getConfiguration,\n ESMxCJSRequire,\n IntlayerConfig,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\n\nconst requireUncached = (module: string) => {\n delete ESMxCJSRequire.cache[ESMxCJSRequire.resolve(module)];\n return ESMxCJSRequire(module);\n};\n\nexport const generateTypeScriptType = (dictionary: Dictionary) => {\n const jsonString = JSON.stringify(dictionary, null, 2)\n // Remove quotes from keys only if they are valid identifiers.\n .replace(/\"([^\"]+)\":/g, (_, key) => {\n // Valid identifier: must start with a letter, underscore, or dollar sign,\n // followed by letters, digits, underscores, or dollar signs.\n if (/^[$A-Za-z_][0-9A-Za-z_$]*$/.test(key)) {\n return `${key}:`;\n }\n // Otherwise, keep the quotes\n return `\"${key}\":`;\n });\n\n return `/* eslint-disable */\\nexport default ${jsonString} as const;\\n`;\n};\n/**\n * This function generates a TypeScript type definition from a JSON object\n */\nexport const createTypes = (\n dictionariesPaths: string[],\n configuration: IntlayerConfig = getConfiguration()\n): string[] => {\n const { typesDir } = configuration.content;\n const resultTypesPaths: string[] = [];\n\n // Create type folders if they don't exist\n if (!existsSync(typesDir)) {\n mkdirSync(typesDir, { recursive: true });\n }\n\n for (const dictionaryPath of dictionariesPaths) {\n const dictionary: Dictionary = requireUncached(dictionaryPath);\n\n if (!dictionary.key) {\n // Skip dictionary if it doesn't have a key, if not exported as default etc\n continue;\n }\n\n const typeDefinition: string = generateTypeScriptType(dictionary);\n\n const outputPath: string = resolve(typesDir, `${dictionary.key}.ts`);\n\n writeFileSync(outputPath, typeDefinition);\n\n resultTypesPaths.push(outputPath);\n }\n\n return resultTypesPaths;\n};\n"],"mappings":"AAAA,SAAS,YAAY,WAAW,qBAAqB;AACrD,SAAS,eAAe;AACxB;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAGP,MAAM,kBAAkB,CAAC,WAAmB;AAC1C,SAAO,eAAe,MAAM,eAAe,QAAQ,MAAM,CAAC;AAC1D,SAAO,eAAe,MAAM;AAC9B;AAEO,MAAM,yBAAyB,CAAC,eAA2B;AAChE,QAAM,aAAa,KAAK,UAAU,YAAY,MAAM,CAAC,EAElD,QAAQ,eAAe,CAAC,GAAG,QAAQ;AAGlC,QAAI,6BAA6B,KAAK,GAAG,GAAG;AAC1C,aAAO,GAAG,GAAG;AAAA,IACf;AAEA,WAAO,IAAI,GAAG;AAAA,EAChB,CAAC;AAEH,SAAO;AAAA,iBAAwC,UAAU;AAAA;AAC3D;AAIO,MAAM,cAAc,CACzB,mBACA,gBAAgC,iBAAiB,MACpC;AACb,QAAM,EAAE,SAAS,IAAI,cAAc;AACnC,QAAM,mBAA6B,CAAC;AAGpC,MAAI,CAAC,WAAW,QAAQ,GAAG;AACzB,cAAU,UAAU,EAAE,WAAW,KAAK,CAAC;AAAA,EACzC;AAEA,aAAW,kBAAkB,mBAAmB;AAC9C,UAAM,aAAyB,gBAAgB,cAAc;AAE7D,QAAI,CAAC,WAAW,KAAK;AAEnB;AAAA,IACF;AAEA,UAAM,iBAAyB,uBAAuB,UAAU;AAEhE,UAAM,aAAqB,QAAQ,UAAU,GAAG,WAAW,GAAG,KAAK;AAEnE,kBAAc,YAAY,cAAc;AAExC,qBAAiB,KAAK,UAAU;AAAA,EAClC;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const cleanOutputDir: () => void;
|
|
1
|
+
export declare const cleanOutputDir: (configuration?: import("@intlayer/config").IntlayerConfig) => void;
|
|
2
2
|
//# sourceMappingURL=cleanOutputDir.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanOutputDir.d.ts","sourceRoot":"","sources":["../../src/cleanOutputDir.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"cleanOutputDir.d.ts","sourceRoot":"","sources":["../../src/cleanOutputDir.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,GAAI,yDAAkC,SAgBhE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This function generates a list of dictionaries in the main directory
|
|
3
3
|
*/
|
|
4
|
-
export declare const getBuiltDictionariesPath: () => string[];
|
|
4
|
+
export declare const getBuiltDictionariesPath: (configuration?: import("@intlayer/config").IntlayerConfig) => string[];
|
|
5
5
|
//# sourceMappingURL=getBuiltDictionariesPath.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBuiltDictionariesPath.d.ts","sourceRoot":"","sources":["../../src/getBuiltDictionariesPath.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getBuiltDictionariesPath.d.ts","sourceRoot":"","sources":["../../src/getBuiltDictionariesPath.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,eAAO,MAAM,wBAAwB,GACnC,yDAAkC,aAYnC,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Dictionary } from '@intlayer/core';
|
|
2
|
-
export declare const loadContentDeclarations: (contentDeclarationFilePath: string[]) => Promise<Dictionary[]>;
|
|
2
|
+
export declare const loadContentDeclarations: (contentDeclarationFilePath: string[], projectRequire?: NodeJS.Require) => Promise<Dictionary[]>;
|
|
3
3
|
//# sourceMappingURL=loadContentDeclaration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadContentDeclaration.d.ts","sourceRoot":"","sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,eAAO,MAAM,uBAAuB,GAClC,4BAA4B,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"loadContentDeclaration.d.ts","sourceRoot":"","sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,eAAO,MAAM,uBAAuB,GAClC,4BAA4B,MAAM,EAAE,EACpC,+BAA+B,KAC9B,OAAO,CAAC,UAAU,EAAE,CAwBtB,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Dictionary } from '@intlayer/core';
|
|
2
|
-
export declare const loadDictionaries: (contentDeclarationsPaths: string[] | string) => Promise<Dictionary[]>;
|
|
2
|
+
export declare const loadDictionaries: (contentDeclarationsPaths: string[] | string, configuration?: import("@intlayer/config").IntlayerConfig, projectRequire?: NodeJS.Require) => Promise<Dictionary[]>;
|
|
3
3
|
//# sourceMappingURL=loadDictionaries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadDictionaries.d.ts","sourceRoot":"","sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AASjD,eAAO,MAAM,gBAAgB,GAC3B,0BAA0B,MAAM,EAAE,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"loadDictionaries.d.ts","sourceRoot":"","sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AASjD,eAAO,MAAM,gBAAgB,GAC3B,0BAA0B,MAAM,EAAE,GAAG,MAAM,EAC3C,yDAAkC,EAClC,+BAA+B,KAC9B,OAAO,CAAC,UAAU,EAAE,CA6EtB,CAAC"}
|
package/dist/types/log.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type IntlayerConfig } from '@intlayer/config';
|
|
1
2
|
export type State = {
|
|
2
3
|
type: 'local' | 'distant';
|
|
3
4
|
status: 'pending' | 'fetching' | 'fetched' | 'error' | 'imported' | 'built';
|
|
@@ -19,11 +20,11 @@ declare class Logger {
|
|
|
19
20
|
private originalStdoutWrite;
|
|
20
21
|
private extraLines;
|
|
21
22
|
private isUpdating;
|
|
22
|
-
private config
|
|
23
|
+
private config?;
|
|
23
24
|
private static instance;
|
|
24
25
|
private constructor();
|
|
25
26
|
static getInstance(): Logger;
|
|
26
|
-
init(localDictionariesKeys: string[], distantDictionariesKeys: string[]): void;
|
|
27
|
+
init(localDictionariesKeys: string[], distantDictionariesKeys: string[], configuration?: IntlayerConfig): void;
|
|
27
28
|
addDictionaryKeys(type: 'local' | 'distant', dictionaryKeys: string[]): void;
|
|
28
29
|
private startSpinner;
|
|
29
30
|
private stopSpinner;
|
package/dist/types/log.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/log.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/log.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAoB,MAAM,kBAAkB,CAAC;AAGzE,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1B,MAAM,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,OAAO,CAAC;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,KAAK,EAAE,CAAC;CAChB,CAAC;AAaF,cAAM,MAAM;IACV,OAAO,CAAC,oBAAoB,CAA4B;IACxD,OAAO,CAAC,YAAY,CAA+B;IACnD,OAAO,CAAC,sBAAsB,CAAa;IAC3C,OAAO,CAAC,iBAAiB,CAAa;IACtC,OAAO,CAAC,cAAc,CAAa;IACnC,OAAO,CAAC,mBAAmB,CAMX;IAChB,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,MAAM,CAAC,CAAiB;IAGhC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAS;IAEhC,OAAO;WAEO,WAAW,IAAI,MAAM;IAO5B,IAAI,CACT,qBAAqB,EAAE,MAAM,EAAE,EAC/B,uBAAuB,EAAE,MAAM,EAAE,EACjC,aAAa,GAAE,cAAmC;IAiD7C,iBAAiB,CACtB,IAAI,EAAE,OAAO,GAAG,SAAS,EACzB,cAAc,EAAE,MAAM,EAAE;IA8C1B,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,YAAY;IAgEb,IAAI;IAIJ,YAAY,CACjB,YAAY,EAAE;QACZ,aAAa,EAAE,MAAM,CAAC;QACtB,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;QAC1B,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;KACxB,EAAE;IA+CL,OAAO,CAAC,aAAa;IAWrB,OAAO,CAAC,aAAa;IAmCrB,OAAO,CAAC,oBAAoB;IA4BrB,WAAW;CAGnB;AAED,eAAO,MAAM,MAAM,QAAuB,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type IntlayerConfig } from '@intlayer/config';
|
|
2
|
-
export declare const prepareIntlayer: (configuration?: IntlayerConfig) => Promise<void>;
|
|
2
|
+
export declare const prepareIntlayer: (configuration?: IntlayerConfig, projectRequire?: NodeJS.Require) => Promise<void>;
|
|
3
3
|
//# sourceMappingURL=prepareIntlayer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareIntlayer.d.ts","sourceRoot":"","sources":["../../src/prepareIntlayer.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"prepareIntlayer.d.ts","sourceRoot":"","sources":["../../src/prepareIntlayer.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EAGpB,MAAM,kBAAkB,CAAC;AAY1B,eAAO,MAAM,eAAe,GAC1B,gBAAe,cAAmC,EAClD,+BAA+B,kBAoChC,CAAC"}
|
|
@@ -2,5 +2,5 @@ import type { Dictionary } from '@intlayer/core';
|
|
|
2
2
|
/**
|
|
3
3
|
* This function transpile content declaration to i18n dictionaries
|
|
4
4
|
*/
|
|
5
|
-
export declare const buildI18nDictionary: (contentDeclarations: Dictionary[]) => Promise<string[]>;
|
|
5
|
+
export declare const buildI18nDictionary: (contentDeclarations: Dictionary[], configuration?: import("@intlayer/config").IntlayerConfig) => Promise<string[]>;
|
|
6
6
|
//# sourceMappingURL=buildI18nextDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildI18nextDictionary.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"buildI18nextDictionary.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAQjD;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAC9B,qBAAqB,UAAU,EAAE,EACjC,yDAAkC,sBAqBnC,CAAC"}
|
|
@@ -2,6 +2,6 @@ import { type Locales } from '@intlayer/config';
|
|
|
2
2
|
import { type ContentNode } from '@intlayer/core';
|
|
3
3
|
type Dictionary = Record<string, unknown>;
|
|
4
4
|
export type I18nextDictionariesOutput = Partial<Record<Locales, Dictionary>>;
|
|
5
|
-
export declare const createI18nextDictionaries: (content: ContentNode) => I18nextDictionariesOutput;
|
|
5
|
+
export declare const createI18nextDictionaries: (content: ContentNode, configuration?: import("@intlayer/config").IntlayerConfig) => I18nextDictionariesOutput;
|
|
6
6
|
export {};
|
|
7
7
|
//# sourceMappingURL=convertContentDeclarationInto18nDictionaries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertContentDeclarationInto18nDictionaries.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,gBAAgB,CAAC;AAGxB,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC1C,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"convertContentDeclarationInto18nDictionaries.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,gBAAgB,CAAC;AAGxB,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC1C,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;AAsF7E,eAAO,MAAM,yBAAyB,GACpC,SAAS,WAAW,EACpB,yDAAkC,KACjC,yBAaF,CAAC"}
|
package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export type DictionariesDeclaration = Record<string, I18nextDictionariesOutput>;
|
|
|
3
3
|
/**
|
|
4
4
|
* This function writes the dictionaries to the file system
|
|
5
5
|
*/
|
|
6
|
-
export declare const writeDictionary: (dictionariesDeclaration: DictionariesDeclaration) => Promise<string[]>;
|
|
6
|
+
export declare const writeDictionary: (dictionariesDeclaration: DictionariesDeclaration, configuration?: import("@intlayer/config").IntlayerConfig) => Promise<string[]>;
|
|
7
7
|
//# sourceMappingURL=writeDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeDictionary.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAC;
|
|
1
|
+
{"version":3,"file":"writeDictionary.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAC;AAEhG,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,eAAe,GAC1B,yBAAyB,uBAAuB,EAChD,yDAAkC,sBA6BnC,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Dictionary } from '@intlayer/core';
|
|
2
|
-
export declare const buildDictionary: (dictionaries: Dictionary[]) => Promise<string[]>;
|
|
2
|
+
export declare const buildDictionary: (dictionaries: Dictionary[], configuration?: import("@intlayer/config").IntlayerConfig) => Promise<string[]>;
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/declaration_file_to_dictionary/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/declaration_file_to_dictionary/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAIjD,eAAO,MAAM,eAAe,GAC1B,cAAc,UAAU,EAAE,EAC1B,yDAAkC,KACjC,OAAO,CAAC,MAAM,EAAE,CAYlB,CAAC"}
|
|
@@ -3,5 +3,5 @@ import type { Dictionary } from '@intlayer/core';
|
|
|
3
3
|
/**
|
|
4
4
|
* This function transpile the bundled code to to make dictionaries as JSON files
|
|
5
5
|
*/
|
|
6
|
-
export declare const buildIntlayerDictionary: (contentDeclarations: (DictionaryAPI | Dictionary)[]) => Promise<string[]>;
|
|
6
|
+
export declare const buildIntlayerDictionary: (contentDeclarations: (DictionaryAPI | Dictionary)[], configuration?: import("@intlayer/config").IntlayerConfig) => Promise<string[]>;
|
|
7
7
|
//# sourceMappingURL=buildIntlayerDictionary.d.ts.map
|