@intlayer/chokidar 5.5.1 → 5.5.3
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 +20 -3
- package/dist/cjs/cleanOutputDir.cjs.map +1 -1
- package/dist/cjs/filterDictionaryLocales.cjs +8 -8
- package/dist/cjs/filterDictionaryLocales.cjs.map +1 -1
- package/dist/cjs/index.cjs +16 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/prepareIntlayer.cjs +0 -3
- package/dist/cjs/prepareIntlayer.cjs.map +1 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.cjs +2 -0
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs +5 -37
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_main/generateDictionaryListContent.cjs +63 -0
- package/dist/cjs/transpiler/dictionary_to_main/generateDictionaryListContent.cjs.map +1 -0
- package/dist/cjs/transpiler/dictionary_to_main/index.cjs +3 -1
- package/dist/cjs/transpiler/dictionary_to_main/index.cjs.map +1 -1
- package/dist/esm/cleanOutputDir.mjs +21 -4
- package/dist/esm/cleanOutputDir.mjs.map +1 -1
- package/dist/esm/filterDictionaryLocales.mjs +8 -8
- package/dist/esm/filterDictionaryLocales.mjs.map +1 -1
- package/dist/esm/index.mjs +13 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/prepareIntlayer.mjs +0 -3
- package/dist/esm/prepareIntlayer.mjs.map +1 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.mjs +2 -0
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs +2 -34
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_main/generateDictionaryListContent.mjs +39 -0
- package/dist/esm/transpiler/dictionary_to_main/generateDictionaryListContent.mjs.map +1 -0
- package/dist/esm/transpiler/dictionary_to_main/index.mjs +1 -0
- package/dist/esm/transpiler/dictionary_to_main/index.mjs.map +1 -1
- package/dist/types/cleanOutputDir.d.ts.map +1 -1
- package/dist/types/filterDictionaryLocales.d.ts +2 -2
- package/dist/types/filterDictionaryLocales.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/prepareIntlayer.d.ts.map +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.map +1 -1
- package/dist/types/transpiler/dictionary_to_main/generateDictionaryListContent.d.ts +5 -0
- package/dist/types/transpiler/dictionary_to_main/generateDictionaryListContent.d.ts.map +1 -0
- package/dist/types/transpiler/dictionary_to_main/index.d.ts +1 -0
- package/dist/types/transpiler/dictionary_to_main/index.d.ts.map +1 -1
- package/package.json +13 -13
|
@@ -23,16 +23,33 @@ __export(cleanOutputDir_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(cleanOutputDir_exports);
|
|
24
24
|
var import_config = require("@intlayer/config");
|
|
25
25
|
var import_fs = require("fs");
|
|
26
|
-
var import_createDictionaryEntryPoint = require('./transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs');
|
|
27
26
|
const cleanOutputDir = (configuration = (0, import_config.getConfiguration)()) => {
|
|
28
|
-
const {
|
|
27
|
+
const {
|
|
28
|
+
dictionariesDir,
|
|
29
|
+
unmergedDictionariesDir,
|
|
30
|
+
mainDir,
|
|
31
|
+
typesDir,
|
|
32
|
+
configDir
|
|
33
|
+
} = configuration.content;
|
|
34
|
+
const appLogger = (0, import_config.getAppLogger)(configuration);
|
|
29
35
|
if ((0, import_fs.existsSync)(dictionariesDir)) {
|
|
30
36
|
(0, import_fs.rmSync)(dictionariesDir, { recursive: true });
|
|
31
37
|
}
|
|
38
|
+
if ((0, import_fs.existsSync)(unmergedDictionariesDir)) {
|
|
39
|
+
(0, import_fs.rmSync)(unmergedDictionariesDir, { recursive: true });
|
|
40
|
+
}
|
|
41
|
+
if ((0, import_fs.existsSync)(mainDir)) {
|
|
42
|
+
(0, import_fs.rmSync)(mainDir, { recursive: true });
|
|
43
|
+
}
|
|
32
44
|
if ((0, import_fs.existsSync)(typesDir)) {
|
|
33
45
|
(0, import_fs.rmSync)(typesDir, { recursive: true });
|
|
34
46
|
}
|
|
35
|
-
(0,
|
|
47
|
+
if ((0, import_fs.existsSync)(configDir)) {
|
|
48
|
+
(0, import_fs.rmSync)(configDir, { recursive: true });
|
|
49
|
+
}
|
|
50
|
+
appLogger("Output directory cleaned", {
|
|
51
|
+
isVerbose: true
|
|
52
|
+
});
|
|
36
53
|
};
|
|
37
54
|
// Annotate the CommonJS export names for ESM import in node:
|
|
38
55
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { existsSync, rmSync } from 'fs';\
|
|
1
|
+
{"version":3,"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { getAppLogger, getConfiguration } from '@intlayer/config';\nimport { existsSync, rmSync } from 'fs';\n\nexport const cleanOutputDir = (configuration = getConfiguration()) => {\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n mainDir,\n typesDir,\n configDir,\n } = configuration.content;\n\n const appLogger = getAppLogger(configuration);\n\n if (existsSync(dictionariesDir)) {\n // Delete the dictionary directory\n rmSync(dictionariesDir, { recursive: true });\n }\n\n if (existsSync(unmergedDictionariesDir)) {\n // Delete the unmerged dictionaries directory\n rmSync(unmergedDictionariesDir, { recursive: true });\n }\n\n // Delete the main directory\n if (existsSync(mainDir)) {\n rmSync(mainDir, { recursive: true });\n }\n\n // Delete the types directory\n if (existsSync(typesDir)) {\n rmSync(typesDir, { recursive: true });\n }\n\n // Delete the config directory\n if (existsSync(configDir)) {\n rmSync(configDir, { recursive: true });\n }\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+C;AAC/C,gBAAmC;AAE5B,MAAM,iBAAiB,CAAC,oBAAgB,gCAAiB,MAAM;AACpE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,cAAc;AAElB,QAAM,gBAAY,4BAAa,aAAa;AAE5C,UAAI,sBAAW,eAAe,GAAG;AAE/B,0BAAO,iBAAiB,EAAE,WAAW,KAAK,CAAC;AAAA,EAC7C;AAEA,UAAI,sBAAW,uBAAuB,GAAG;AAEvC,0BAAO,yBAAyB,EAAE,WAAW,KAAK,CAAC;AAAA,EACrD;AAGA,UAAI,sBAAW,OAAO,GAAG;AACvB,0BAAO,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACrC;AAGA,UAAI,sBAAW,QAAQ,GAAG;AACxB,0BAAO,UAAU,EAAE,WAAW,KAAK,CAAC;AAAA,EACtC;AAGA,UAAI,sBAAW,SAAS,GAAG;AACzB,0BAAO,WAAW,EAAE,WAAW,KAAK,CAAC;AAAA,EACvC;AAEA,YAAU,4BAA4B;AAAA,IACpC,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
|
|
@@ -27,7 +27,9 @@ const filterTranlationsPlugin = (locales) => ({
|
|
|
27
27
|
canHandle: (node) => typeof node === "object" && node?.nodeType === import_core.NodeType.Translation,
|
|
28
28
|
transform: (node, props, deepTransformNode2) => {
|
|
29
29
|
const translationMap = node.translation;
|
|
30
|
-
const
|
|
30
|
+
const localesArray = Array.isArray(locales) ? locales : [locales];
|
|
31
|
+
const isSingleLocale = localesArray.length === 1;
|
|
32
|
+
const filteredTranslationMap = isSingleLocale ? translationMap[localesArray[0]] : Object.fromEntries(
|
|
31
33
|
Object.entries(translationMap).filter(
|
|
32
34
|
([key]) => locales.includes(key)
|
|
33
35
|
)
|
|
@@ -44,13 +46,11 @@ const filterTranlationsPlugin = (locales) => ({
|
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
48
|
});
|
|
47
|
-
const filterDictionaryLocales = (dictionary, locales) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
});
|
|
53
|
-
};
|
|
49
|
+
const filterDictionaryLocales = (dictionary, locales) => (0, import_core.deepTransformNode)(dictionary, {
|
|
50
|
+
plugins: [filterTranlationsPlugin(locales)],
|
|
51
|
+
dictionaryKey: dictionary.key,
|
|
52
|
+
keyPath: []
|
|
53
|
+
});
|
|
54
54
|
// Annotate the CommonJS export names for ESM import in node:
|
|
55
55
|
0 && (module.exports = {
|
|
56
56
|
filterDictionaryLocales
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/filterDictionaryLocales.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport {\n deepTransformNode,\n
|
|
1
|
+
{"version":3,"sources":["../../src/filterDictionaryLocales.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport {\n deepTransformNode,\n NodeType,\n type Dictionary,\n type Plugins,\n} from '@intlayer/core';\n\nconst filterTranlationsPlugin = (locales: Locales[] | Locales): Plugins => ({\n id: 'filter-translations-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Translation,\n transform: (node, props, deepTransformNode) => {\n const translationMap = node.translation as Record<Locales, string>;\n\n const localesArray = Array.isArray(locales) ? locales : [locales];\n const isSingleLocale = localesArray.length === 1;\n\n const filteredTranslationMap = isSingleLocale\n ? translationMap[localesArray[0] as Locales]\n : Object.fromEntries(\n Object.entries(translationMap).filter(([key]) =>\n locales.includes(key as Locales)\n )\n );\n\n return {\n ...node,\n translation: deepTransformNode(filteredTranslationMap, {\n ...props,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Object, key: NodeType.Translation },\n ],\n }),\n };\n },\n});\n\nexport const filterDictionaryLocales = (\n dictionary: Dictionary,\n locales: Locales[] | Locales\n) =>\n deepTransformNode(dictionary, {\n plugins: [filterTranlationsPlugin(locales)],\n dictionaryKey: dictionary.key,\n keyPath: [],\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAKO;AAEP,MAAM,0BAA0B,CAAC,aAA2C;AAAA,EAC1E,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,qBAAS;AAAA,EAC1D,WAAW,CAAC,MAAM,OAAOA,uBAAsB;AAC7C,UAAM,iBAAiB,KAAK;AAE5B,UAAM,eAAe,MAAM,QAAQ,OAAO,IAAI,UAAU,CAAC,OAAO;AAChE,UAAM,iBAAiB,aAAa,WAAW;AAE/C,UAAM,yBAAyB,iBAC3B,eAAe,aAAa,CAAC,CAAY,IACzC,OAAO;AAAA,MACL,OAAO,QAAQ,cAAc,EAAE;AAAA,QAAO,CAAC,CAAC,GAAG,MACzC,QAAQ,SAAS,GAAc;AAAA,MACjC;AAAA,IACF;AAEJ,WAAO;AAAA,MACL,GAAG;AAAA,MACH,aAAaA,mBAAkB,wBAAwB;AAAA,QACrD,GAAG;AAAA,QACH,SAAS;AAAA,UACP,GAAG,MAAM;AAAA,UACT,EAAE,MAAM,qBAAS,QAAQ,KAAK,qBAAS,YAAY;AAAA,QACrD;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,MAAM,0BAA0B,CACrC,YACA,gBAEA,+BAAkB,YAAY;AAAA,EAC5B,SAAS,CAAC,wBAAwB,OAAO,CAAC;AAAA,EAC1C,eAAe,WAAW;AAAA,EAC1B,SAAS,CAAC;AACZ,CAAC;","names":["deepTransformNode"]}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -21,11 +21,16 @@ __export(index_exports, {
|
|
|
21
21
|
buildAndWatchIntlayer: () => import_watcher.buildAndWatchIntlayer,
|
|
22
22
|
buildDictionary: () => import_declaration_file_to_dictionary.buildDictionary,
|
|
23
23
|
checkDictionaryChanges: () => import_checkDictionaryChanges.checkDictionaryChanges,
|
|
24
|
-
|
|
24
|
+
cleanOutputDir: () => import_cleanOutputDir.cleanOutputDir,
|
|
25
|
+
createDictionaryEntryPoint: () => import_dictionary_to_main.createDictionaryEntryPoint,
|
|
25
26
|
createModuleAugmentation: () => import_createModuleAugmentation.createModuleAugmentation,
|
|
26
27
|
fetchDistantDictionaries: () => import_fetchDistantDictionaries.fetchDistantDictionaries,
|
|
27
28
|
fetchDistantDictionaryKeys: () => import_fetchDistantDictionaryKeys.fetchDistantDictionaryKeys,
|
|
28
29
|
filterDictionaryLocales: () => import_filterDictionaryLocales.filterDictionaryLocales,
|
|
30
|
+
generateDictionaryListContent: () => import_dictionary_to_main.generateDictionaryListContent,
|
|
31
|
+
getBuiltDictionariesPath: () => import_getBuiltDictionariesPath.getBuiltDictionariesPath,
|
|
32
|
+
getBuiltUnmergedDictionariesPath: () => import_getBuiltUnmergedDictionariesPath.getBuiltUnmergedDictionariesPath,
|
|
33
|
+
getFileHash: () => import_utils.getFileHash,
|
|
29
34
|
handleAdditionalContentDeclarationFile: () => import_watcher.handleAdditionalContentDeclarationFile,
|
|
30
35
|
handleContentDeclarationFileChange: () => import_watcher.handleContentDeclarationFileChange,
|
|
31
36
|
listDictionaries: () => import_listDictionariesPath.listDictionaries,
|
|
@@ -44,9 +49,12 @@ __export(index_exports, {
|
|
|
44
49
|
module.exports = __toCommonJS(index_exports);
|
|
45
50
|
var import_checkDictionaryChanges = require('./checkDictionaryChanges.cjs');
|
|
46
51
|
var import_watcher = require('./chokidar/watcher.cjs');
|
|
52
|
+
var import_cleanOutputDir = require('./cleanOutputDir.cjs');
|
|
47
53
|
var import_fetchDistantDictionaries = require('./fetchDistantDictionaries.cjs');
|
|
48
54
|
var import_fetchDistantDictionaryKeys = require('./fetchDistantDictionaryKeys.cjs');
|
|
49
55
|
var import_filterDictionaryLocales = require('./filterDictionaryLocales.cjs');
|
|
56
|
+
var import_getBuiltDictionariesPath = require('./getBuiltDictionariesPath.cjs');
|
|
57
|
+
var import_getBuiltUnmergedDictionariesPath = require('./getBuiltUnmergedDictionariesPath.cjs');
|
|
50
58
|
var import_listDictionariesPath = require('./listDictionariesPath.cjs');
|
|
51
59
|
var import_listGitFiles = require('./listGitFiles.cjs');
|
|
52
60
|
var import_loadDictionaries = require('./loadDictionaries/index.cjs');
|
|
@@ -56,19 +64,25 @@ var import_prepareIntlayer = require('./prepareIntlayer.cjs');
|
|
|
56
64
|
var import_processPerLocaleDictionary = require('./processPerLocaleDictionary.cjs');
|
|
57
65
|
var import_reduceDictionaryContent = require('./reduceDictionaryContent/reduceDictionaryContent.cjs');
|
|
58
66
|
var import_declaration_file_to_dictionary = require('./transpiler/declaration_file_to_dictionary/index.cjs');
|
|
59
|
-
var
|
|
67
|
+
var import_dictionary_to_main = require('./transpiler/dictionary_to_main/index.cjs');
|
|
60
68
|
var import_createModuleAugmentation = require('./transpiler/dictionary_to_type/createModuleAugmentation.cjs');
|
|
69
|
+
var import_utils = require('./utils.cjs');
|
|
61
70
|
var import_writeContentDeclaration = require('./writeContentDeclaration/index.cjs');
|
|
62
71
|
// Annotate the CommonJS export names for ESM import in node:
|
|
63
72
|
0 && (module.exports = {
|
|
64
73
|
buildAndWatchIntlayer,
|
|
65
74
|
buildDictionary,
|
|
66
75
|
checkDictionaryChanges,
|
|
76
|
+
cleanOutputDir,
|
|
67
77
|
createDictionaryEntryPoint,
|
|
68
78
|
createModuleAugmentation,
|
|
69
79
|
fetchDistantDictionaries,
|
|
70
80
|
fetchDistantDictionaryKeys,
|
|
71
81
|
filterDictionaryLocales,
|
|
82
|
+
generateDictionaryListContent,
|
|
83
|
+
getBuiltDictionariesPath,
|
|
84
|
+
getBuiltUnmergedDictionariesPath,
|
|
85
|
+
getFileHash,
|
|
72
86
|
handleAdditionalContentDeclarationFile,
|
|
73
87
|
handleContentDeclarationFileChange,
|
|
74
88
|
listDictionaries,
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { checkDictionaryChanges } from './checkDictionaryChanges';\nexport {\n buildAndWatchIntlayer,\n handleAdditionalContentDeclarationFile,\n handleContentDeclarationFileChange,\n watch,\n} from './chokidar/watcher';\nexport { fetchDistantDictionaries } from './fetchDistantDictionaries';\nexport { fetchDistantDictionaryKeys } from './fetchDistantDictionaryKeys';\nexport { filterDictionaryLocales } from './filterDictionaryLocales';\nexport { listDictionaries } from './listDictionariesPath';\nexport {\n listGitFiles,\n type DiffMode,\n type ListGitFilesOptions,\n} from './listGitFiles';\nexport {\n loadDictionaries,\n loadDistantDictionaries,\n loadLocalDictionaries,\n} from './loadDictionaries/index';\nexport { mergeDictionaries } from './mergeDictionaries';\nexport { prepareContentDeclaration } from './prepareContentDeclaration';\nexport { prepareIntlayer } from './prepareIntlayer';\nexport { processPerLocaleDictionary } from './processPerLocaleDictionary';\nexport { reduceDictionaryContent } from './reduceDictionaryContent/reduceDictionaryContent';\nexport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nexport {
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { checkDictionaryChanges } from './checkDictionaryChanges';\nexport {\n buildAndWatchIntlayer,\n handleAdditionalContentDeclarationFile,\n handleContentDeclarationFileChange,\n watch,\n} from './chokidar/watcher';\nexport { cleanOutputDir } from './cleanOutputDir';\nexport { fetchDistantDictionaries } from './fetchDistantDictionaries';\nexport { fetchDistantDictionaryKeys } from './fetchDistantDictionaryKeys';\nexport { filterDictionaryLocales } from './filterDictionaryLocales';\nexport { getBuiltDictionariesPath } from './getBuiltDictionariesPath';\nexport { getBuiltUnmergedDictionariesPath } from './getBuiltUnmergedDictionariesPath';\nexport { listDictionaries } from './listDictionariesPath';\nexport {\n listGitFiles,\n type DiffMode,\n type ListGitFilesOptions,\n} from './listGitFiles';\nexport {\n loadDictionaries,\n loadDistantDictionaries,\n loadLocalDictionaries,\n} from './loadDictionaries/index';\nexport { mergeDictionaries } from './mergeDictionaries';\nexport { prepareContentDeclaration } from './prepareContentDeclaration';\nexport { prepareIntlayer } from './prepareIntlayer';\nexport { processPerLocaleDictionary } from './processPerLocaleDictionary';\nexport { reduceDictionaryContent } from './reduceDictionaryContent/reduceDictionaryContent';\nexport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nexport {\n createDictionaryEntryPoint,\n generateDictionaryListContent,\n} from './transpiler/dictionary_to_main';\nexport { createModuleAugmentation } from './transpiler/dictionary_to_type/createModuleAugmentation';\nexport { getFileHash } from './utils';\nexport {\n writeContentDeclaration,\n type DictionaryStatus,\n} from './writeContentDeclaration';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAAuC;AACvC,qBAKO;AACP,4BAA+B;AAC/B,sCAAyC;AACzC,wCAA2C;AAC3C,qCAAwC;AACxC,sCAAyC;AACzC,8CAAiD;AACjD,kCAAiC;AACjC,0BAIO;AACP,8BAIO;AACP,+BAAkC;AAClC,uCAA0C;AAC1C,6BAAgC;AAChC,wCAA2C;AAC3C,qCAAwC;AACxC,4CAAgC;AAChC,gCAGO;AACP,sCAAyC;AACzC,mBAA4B;AAC5B,qCAGO;","names":[]}
|
|
@@ -32,9 +32,6 @@ var import_writeConfiguration = require('./writeConfiguration/index.cjs');
|
|
|
32
32
|
const prepareIntlayer = async (configuration = (0, import_config.getConfiguration)(), projectRequire = import_config.ESMxCJSRequire) => {
|
|
33
33
|
const appLogger = (0, import_config.getAppLogger)(configuration);
|
|
34
34
|
(0, import_cleanOutputDir.cleanOutputDir)(configuration);
|
|
35
|
-
appLogger("Output directory cleaned", {
|
|
36
|
-
isVerbose: true
|
|
37
|
-
});
|
|
38
35
|
const files = (0, import_listDictionariesPath.listDictionaries)(configuration);
|
|
39
36
|
const dictionaries = await (0, import_loadDictionaries.loadDictionaries)(
|
|
40
37
|
files,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import {\n ESMxCJSRequire,\n type IntlayerConfig,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { listDictionaries } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryEntryPoint } from './transpiler/dictionary_to_main/createDictionaryEntryPoint';\nimport {\n createModuleAugmentation,\n createTypes,\n} from './transpiler/dictionary_to_type/index';\nimport { writeConfiguration } from './writeConfiguration';\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire\n) => {\n const appLogger = getAppLogger(configuration);\n\n cleanOutputDir(configuration);\n\n
|
|
1
|
+
{"version":3,"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import {\n ESMxCJSRequire,\n type IntlayerConfig,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { listDictionaries } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryEntryPoint } from './transpiler/dictionary_to_main/createDictionaryEntryPoint';\nimport {\n createModuleAugmentation,\n createTypes,\n} from './transpiler/dictionary_to_type/index';\nimport { writeConfiguration } from './writeConfiguration';\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire\n) => {\n const appLogger = getAppLogger(configuration);\n\n cleanOutputDir(configuration);\n\n const files: string[] = listDictionaries(configuration);\n\n const dictionaries = await loadDictionaries(\n files,\n configuration,\n projectRequire\n );\n\n // Build locale dictionaries\n const dictionariesPaths = await buildDictionary(dictionaries, configuration);\n\n createTypes(dictionariesPaths, configuration);\n\n createDictionaryEntryPoint(configuration);\n\n appLogger('Dictionaries built');\n\n createModuleAugmentation(configuration);\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n\n writeConfiguration(configuration);\n\n appLogger('Configuration written', {\n isVerbose: true,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKO;AACP,4BAA+B;AAC/B,kCAAiC;AACjC,8BAAiC;AACjC,4CAAgC;AAChC,wCAA2C;AAC3C,gCAGO;AACP,gCAAmC;AAE5B,MAAM,kBAAkB,OAC7B,oBAAgC,gCAAiB,GACjD,iBAAiB,iCACd;AACH,QAAM,gBAAY,4BAAa,aAAa;AAE5C,4CAAe,aAAa;AAE5B,QAAM,YAAkB,8CAAiB,aAAa;AAEtD,QAAM,eAAe,UAAM;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAGA,QAAM,oBAAoB,UAAM,uDAAgB,cAAc,aAAa;AAE3E,6CAAY,mBAAmB,aAAa;AAE5C,oEAA2B,aAAa;AAExC,YAAU,oBAAoB;AAE9B,0DAAyB,aAAa;AAEtC,YAAU,6BAA6B;AAAA,IACrC,WAAW;AAAA,EACb,CAAC;AAED,oDAAmB,aAAa;AAEhC,YAAU,yBAAyB;AAAA,IACjC,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
|
package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.cjs
CHANGED
|
@@ -46,6 +46,7 @@ const writeUnmergedDictionaries = async (dictionaries, configuration = (0, impor
|
|
|
46
46
|
await (0, import_promises.mkdir)(unmergedDictionariesDir, { recursive: true });
|
|
47
47
|
const groupedDictionaries = groupDictionariesByKey(dictionaries);
|
|
48
48
|
for (const [key, dictionaries2] of Object.entries(groupedDictionaries)) {
|
|
49
|
+
if (key === "undefined") continue;
|
|
49
50
|
const isDevelopment = process.env.NODE_ENV === "development";
|
|
50
51
|
const contentString = isDevelopment ? JSON.stringify(dictionaries2, null, 2) : JSON.stringify(dictionaries2);
|
|
51
52
|
const outputFileName = `${key}.json`;
|
|
@@ -60,6 +61,7 @@ const writeFinalDictionaries = async (groupedDictionaries, configuration = (0, i
|
|
|
60
61
|
const { dictionariesDir } = configuration.content;
|
|
61
62
|
const resultDictionariesPaths = [];
|
|
62
63
|
for (const [key, dictionaries] of Object.entries(groupedDictionaries)) {
|
|
64
|
+
if (key === "undefined") continue;
|
|
63
65
|
const multiLocaleDictionaries = dictionaries.map(
|
|
64
66
|
(dictionary) => (0, import_processPerLocaleDictionary.processPerLocaleDictionary)(dictionary)
|
|
65
67
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { mkdir, writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { mergeDictionaries } from '../../../mergeDictionaries';\nimport { processPerLocaleDictionary } from '../../../processPerLocaleDictionary';\n\nconst groupDictionariesByKey = (\n dictionaries: Dictionary[]\n): Record<string, Dictionary[]> => {\n return dictionaries.reduce(\n (acc, dictionary) => {\n const key = dictionary.key;\n if (!acc[key]) {\n acc[key] = [];\n }\n acc[key].push(dictionary);\n return acc;\n },\n {} as Record<string, Dictionary[]>\n );\n};\n\n/**\n * Write the unmerged dictionaries to the unmergedDictionariesDir\n * @param dictionaries - The dictionaries to write\n * @param configuration - The configuration\n * @returns The grouped dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * console.log(unmergedDictionaries);\n *\n * // .intlayer/unmerged_dictionaries/home.json\n * // {\n * // [\n * // { key: 'home', content: { ... } },\n * // { key: 'home', content: { ... } },\n * // ],\n * // }\n * ```\n */\nexport const writeUnmergedDictionaries = async (\n dictionaries: Dictionary[],\n configuration = getConfiguration()\n): Promise<Record<string, Dictionary[]>> => {\n const { unmergedDictionariesDir } = configuration.content;\n\n // Create the merged dictionaries directory\n await mkdir(unmergedDictionariesDir, { recursive: true });\n\n // Group dictionaries by key and write to unmergedDictionariesDir\n const groupedDictionaries = groupDictionariesByKey(dictionaries);\n\n for (const [key, dictionaries] of Object.entries(groupedDictionaries)) {\n const isDevelopment = process.env.NODE_ENV === 'development';\n const contentString = isDevelopment\n ? JSON.stringify(dictionaries, null, 2)\n : JSON.stringify(dictionaries);\n\n const outputFileName = `${key}.json`;\n const unmergedFilePath = resolve(unmergedDictionariesDir, outputFileName);\n\n // Write the grouped dictionaries\n await writeFile(unmergedFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating unmerged ${outputFileName}:`, err);\n });\n }\n\n return groupedDictionaries;\n};\n\n/**\n * Write the final dictionaries to the dictionariesDir\n * @param groupedDictionaries - The grouped dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeFinalDictionaries = async (\n groupedDictionaries: Record<string, Dictionary[]>,\n configuration = getConfiguration()\n) => {\n const { dictionariesDir } = configuration.content;\n const resultDictionariesPaths: string[] = [];\n\n // Merge dictionaries with the same key and write to dictionariesDir\n for (const [key, dictionaries] of Object.entries(groupedDictionaries)) {\n const multiLocaleDictionaries = dictionaries.map((dictionary) =>\n processPerLocaleDictionary(dictionary)\n );\n const mergedDictionary = mergeDictionaries(multiLocaleDictionaries);\n\n const isDevelopment = process.env.NODE_ENV === 'development';\n const contentString = isDevelopment\n ? JSON.stringify(mergedDictionary, null, 2)\n : JSON.stringify(mergedDictionary);\n\n const outputFileName = `${key}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n // Write the merged dictionary\n await writeFile(resultFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating merged ${outputFileName}:`, err);\n });\n\n resultDictionariesPaths.push(resultFilePath);\n }\n\n return resultDictionariesPaths;\n};\n\nexport const writeDictionary = async (\n dictionaries: Dictionary[],\n configuration = getConfiguration()\n) => {\n const unmergedDictionaries = await writeUnmergedDictionaries(\n dictionaries,\n configuration\n );\n\n const finalDictionaries = await writeFinalDictionaries(\n unmergedDictionaries,\n configuration\n );\n\n return finalDictionaries;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AAEjC,sBAAiC;AACjC,kBAAwB;AACxB,+BAAkC;AAClC,wCAA2C;AAE3C,MAAM,yBAAyB,CAC7B,iBACiC;AACjC,SAAO,aAAa;AAAA,IAClB,CAAC,KAAK,eAAe;AACnB,YAAM,MAAM,WAAW;AACvB,UAAI,CAAC,IAAI,GAAG,GAAG;AACb,YAAI,GAAG,IAAI,CAAC;AAAA,MACd;AACA,UAAI,GAAG,EAAE,KAAK,UAAU;AACxB,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AACF;AAsBO,MAAM,4BAA4B,OACvC,cACA,oBAAgB,gCAAiB,MACS;AAC1C,QAAM,EAAE,wBAAwB,IAAI,cAAc;AAGlD,YAAM,uBAAM,yBAAyB,EAAE,WAAW,KAAK,CAAC;AAGxD,QAAM,sBAAsB,uBAAuB,YAAY;AAE/D,aAAW,CAAC,KAAKA,aAAY,KAAK,OAAO,QAAQ,mBAAmB,GAAG;AACrE,UAAM,gBAAgB,QAAQ,IAAI,aAAa;AAC/C,UAAM,gBAAgB,gBAClB,KAAK,UAAUA,eAAc,MAAM,CAAC,IACpC,KAAK,UAAUA,aAAY;AAE/B,UAAM,iBAAiB,GAAG,GAAG;AAC7B,UAAM,uBAAmB,qBAAQ,yBAAyB,cAAc;AAGxE,cAAM,2BAAU,kBAAkB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACtE,cAAQ,MAAM,2BAA2B,cAAc,KAAK,GAAG;AAAA,IACjE,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAkBO,MAAM,yBAAyB,OACpC,qBACA,oBAAgB,gCAAiB,MAC9B;AACH,QAAM,EAAE,gBAAgB,IAAI,cAAc;AAC1C,QAAM,0BAAoC,CAAC;AAG3C,aAAW,CAAC,KAAK,YAAY,KAAK,OAAO,QAAQ,mBAAmB,GAAG;AACrE,UAAM,0BAA0B,aAAa;AAAA,MAAI,CAAC,mBAChD,8DAA2B,UAAU;AAAA,IACvC;AACA,UAAM,uBAAmB,4CAAkB,uBAAuB;AAElE,UAAM,gBAAgB,QAAQ,IAAI,aAAa;AAC/C,UAAM,gBAAgB,gBAClB,KAAK,UAAU,kBAAkB,MAAM,CAAC,IACxC,KAAK,UAAU,gBAAgB;AAEnC,UAAM,iBAAiB,GAAG,GAAG;AAC7B,UAAM,qBAAiB,qBAAQ,iBAAiB,cAAc;AAG9D,cAAM,2BAAU,gBAAgB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACpE,cAAQ,MAAM,yBAAyB,cAAc,KAAK,GAAG;AAAA,IAC/D,CAAC;AAED,4BAAwB,KAAK,cAAc;AAAA,EAC7C;AAEA,SAAO;AACT;AAEO,MAAM,kBAAkB,OAC7B,cACA,oBAAgB,gCAAiB,MAC9B;AACH,QAAM,uBAAuB,MAAM;AAAA,IACjC;AAAA,IACA;AAAA,EACF;AAEA,QAAM,oBAAoB,MAAM;AAAA,IAC9B;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AACT;","names":["dictionaries"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { mkdir, writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { mergeDictionaries } from '../../../mergeDictionaries';\nimport { processPerLocaleDictionary } from '../../../processPerLocaleDictionary';\n\nconst groupDictionariesByKey = (\n dictionaries: Dictionary[]\n): Record<string, Dictionary[]> => {\n return dictionaries.reduce(\n (acc, dictionary) => {\n const key = dictionary.key;\n if (!acc[key]) {\n acc[key] = [];\n }\n acc[key].push(dictionary);\n return acc;\n },\n {} as Record<string, Dictionary[]>\n );\n};\n\n/**\n * Write the unmerged dictionaries to the unmergedDictionariesDir\n * @param dictionaries - The dictionaries to write\n * @param configuration - The configuration\n * @returns The grouped dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * console.log(unmergedDictionaries);\n *\n * // .intlayer/unmerged_dictionaries/home.json\n * // {\n * // [\n * // { key: 'home', content: { ... } },\n * // { key: 'home', content: { ... } },\n * // ],\n * // }\n * ```\n */\nexport const writeUnmergedDictionaries = async (\n dictionaries: Dictionary[],\n configuration = getConfiguration()\n): Promise<Record<string, Dictionary[]>> => {\n const { unmergedDictionariesDir } = configuration.content;\n\n // Create the merged dictionaries directory\n await mkdir(unmergedDictionariesDir, { recursive: true });\n\n // Group dictionaries by key and write to unmergedDictionariesDir\n const groupedDictionaries = groupDictionariesByKey(dictionaries);\n\n for (const [key, dictionaries] of Object.entries(groupedDictionaries)) {\n if (key === 'undefined') continue;\n\n const isDevelopment = process.env.NODE_ENV === 'development';\n const contentString = isDevelopment\n ? JSON.stringify(dictionaries, null, 2)\n : JSON.stringify(dictionaries);\n\n const outputFileName = `${key}.json`;\n const unmergedFilePath = resolve(unmergedDictionariesDir, outputFileName);\n\n // Write the grouped dictionaries\n await writeFile(unmergedFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating unmerged ${outputFileName}:`, err);\n });\n }\n\n return groupedDictionaries;\n};\n\n/**\n * Write the final dictionaries to the dictionariesDir\n * @param groupedDictionaries - The grouped dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeFinalDictionaries = async (\n groupedDictionaries: Record<string, Dictionary[]>,\n configuration = getConfiguration()\n) => {\n const { dictionariesDir } = configuration.content;\n const resultDictionariesPaths: string[] = [];\n\n // Merge dictionaries with the same key and write to dictionariesDir\n for (const [key, dictionaries] of Object.entries(groupedDictionaries)) {\n if (key === 'undefined') continue;\n\n const multiLocaleDictionaries = dictionaries.map((dictionary) =>\n processPerLocaleDictionary(dictionary)\n );\n const mergedDictionary = mergeDictionaries(multiLocaleDictionaries);\n\n const isDevelopment = process.env.NODE_ENV === 'development';\n const contentString = isDevelopment\n ? JSON.stringify(mergedDictionary, null, 2)\n : JSON.stringify(mergedDictionary);\n\n const outputFileName = `${key}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n // Write the merged dictionary\n await writeFile(resultFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating merged ${outputFileName}:`, err);\n });\n\n resultDictionariesPaths.push(resultFilePath);\n }\n\n return resultDictionariesPaths;\n};\n\nexport const writeDictionary = async (\n dictionaries: Dictionary[],\n configuration = getConfiguration()\n) => {\n const unmergedDictionaries = await writeUnmergedDictionaries(\n dictionaries,\n configuration\n );\n\n const finalDictionaries = await writeFinalDictionaries(\n unmergedDictionaries,\n configuration\n );\n\n return finalDictionaries;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AAEjC,sBAAiC;AACjC,kBAAwB;AACxB,+BAAkC;AAClC,wCAA2C;AAE3C,MAAM,yBAAyB,CAC7B,iBACiC;AACjC,SAAO,aAAa;AAAA,IAClB,CAAC,KAAK,eAAe;AACnB,YAAM,MAAM,WAAW;AACvB,UAAI,CAAC,IAAI,GAAG,GAAG;AACb,YAAI,GAAG,IAAI,CAAC;AAAA,MACd;AACA,UAAI,GAAG,EAAE,KAAK,UAAU;AACxB,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AACF;AAsBO,MAAM,4BAA4B,OACvC,cACA,oBAAgB,gCAAiB,MACS;AAC1C,QAAM,EAAE,wBAAwB,IAAI,cAAc;AAGlD,YAAM,uBAAM,yBAAyB,EAAE,WAAW,KAAK,CAAC;AAGxD,QAAM,sBAAsB,uBAAuB,YAAY;AAE/D,aAAW,CAAC,KAAKA,aAAY,KAAK,OAAO,QAAQ,mBAAmB,GAAG;AACrE,QAAI,QAAQ,YAAa;AAEzB,UAAM,gBAAgB,QAAQ,IAAI,aAAa;AAC/C,UAAM,gBAAgB,gBAClB,KAAK,UAAUA,eAAc,MAAM,CAAC,IACpC,KAAK,UAAUA,aAAY;AAE/B,UAAM,iBAAiB,GAAG,GAAG;AAC7B,UAAM,uBAAmB,qBAAQ,yBAAyB,cAAc;AAGxE,cAAM,2BAAU,kBAAkB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACtE,cAAQ,MAAM,2BAA2B,cAAc,KAAK,GAAG;AAAA,IACjE,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAkBO,MAAM,yBAAyB,OACpC,qBACA,oBAAgB,gCAAiB,MAC9B;AACH,QAAM,EAAE,gBAAgB,IAAI,cAAc;AAC1C,QAAM,0BAAoC,CAAC;AAG3C,aAAW,CAAC,KAAK,YAAY,KAAK,OAAO,QAAQ,mBAAmB,GAAG;AACrE,QAAI,QAAQ,YAAa;AAEzB,UAAM,0BAA0B,aAAa;AAAA,MAAI,CAAC,mBAChD,8DAA2B,UAAU;AAAA,IACvC;AACA,UAAM,uBAAmB,4CAAkB,uBAAuB;AAElE,UAAM,gBAAgB,QAAQ,IAAI,aAAa;AAC/C,UAAM,gBAAgB,gBAClB,KAAK,UAAU,kBAAkB,MAAM,CAAC,IACxC,KAAK,UAAU,gBAAgB;AAEnC,UAAM,iBAAiB,GAAG,GAAG;AAC7B,UAAM,qBAAiB,qBAAQ,iBAAiB,cAAc;AAG9D,cAAM,2BAAU,gBAAgB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACpE,cAAQ,MAAM,yBAAyB,cAAc,KAAK,GAAG;AAAA,IAC/D,CAAC;AAED,4BAAwB,KAAK,cAAc;AAAA,EAC7C;AAEA,SAAO;AACT;AAEO,MAAM,kBAAkB,OAC7B,cACA,oBAAgB,gCAAiB,MAC9B;AACH,QAAM,uBAAuB,MAAM;AAAA,IACjC;AAAA,IACA;AAAA,EACF;AAEA,QAAM,oBAAoB,MAAM;AAAA,IAC9B;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AACT;","names":["dictionaries"]}
|
|
@@ -26,39 +26,7 @@ var import_fs = require("fs");
|
|
|
26
26
|
var import_path = require("path");
|
|
27
27
|
var import_getBuiltDictionariesPath = require('../../getBuiltDictionariesPath.cjs');
|
|
28
28
|
var import_getBuiltUnmergedDictionariesPath = require('../../getBuiltUnmergedDictionariesPath.cjs');
|
|
29
|
-
var
|
|
30
|
-
const generateDictionaryListContent = (dictionaries, format = "esm", configuration = (0, import_config.getConfiguration)()) => {
|
|
31
|
-
const { mainDir } = configuration.content;
|
|
32
|
-
let content = "";
|
|
33
|
-
const dictionariesRef = dictionaries.map((dictionaryPath) => ({
|
|
34
|
-
relativePath: (0, import_path.relative)(mainDir, dictionaryPath),
|
|
35
|
-
id: (0, import_path.basename)(dictionaryPath, (0, import_path.extname)(dictionaryPath)),
|
|
36
|
-
// Get the base name as the dictionary id
|
|
37
|
-
hash: `_${(0, import_utils.getFileHash)(dictionaryPath)}`
|
|
38
|
-
// Get the hash of the dictionary to avoid conflicts
|
|
39
|
-
}));
|
|
40
|
-
dictionariesRef.forEach((dictionary) => {
|
|
41
|
-
if (format === "esm")
|
|
42
|
-
content += `import ${dictionary.hash} from '${dictionary.relativePath}';
|
|
43
|
-
`;
|
|
44
|
-
if (format === "cjs")
|
|
45
|
-
content += `const ${dictionary.hash} = require('${dictionary.relativePath}');
|
|
46
|
-
`;
|
|
47
|
-
});
|
|
48
|
-
content += "\n";
|
|
49
|
-
const formattedDictionaryMap = dictionariesRef.map((dictionary) => ` "${dictionary.id}": ${dictionary.hash}`).join(",\n");
|
|
50
|
-
if (format === "esm")
|
|
51
|
-
content += `export default {
|
|
52
|
-
${formattedDictionaryMap}
|
|
53
|
-
};
|
|
54
|
-
`;
|
|
55
|
-
if (format === "cjs")
|
|
56
|
-
content += `module.exports = {
|
|
57
|
-
${formattedDictionaryMap}
|
|
58
|
-
};
|
|
59
|
-
`;
|
|
60
|
-
return content;
|
|
61
|
-
};
|
|
29
|
+
var import_generateDictionaryListContent = require('./generateDictionaryListContent.cjs');
|
|
62
30
|
const createDictionaryEntryPoint = (configuration = (0, import_config.getConfiguration)(), dictionariesKeys) => {
|
|
63
31
|
const { mainDir } = configuration.content;
|
|
64
32
|
if (!(0, import_fs.existsSync)(mainDir)) {
|
|
@@ -70,20 +38,20 @@ const createDictionaryEntryPoint = (configuration = (0, import_config.getConfigu
|
|
|
70
38
|
(dictionaryPath) => dictionariesKeys.some((key) => dictionaryPath.endsWith(`${key}.json`))
|
|
71
39
|
);
|
|
72
40
|
}
|
|
73
|
-
const cjsContent = generateDictionaryListContent(
|
|
41
|
+
const cjsContent = (0, import_generateDictionaryListContent.generateDictionaryListContent)(
|
|
74
42
|
dictionariesPath,
|
|
75
43
|
"cjs",
|
|
76
44
|
configuration
|
|
77
45
|
);
|
|
78
46
|
(0, import_fs.writeFileSync)((0, import_path.resolve)(mainDir, "dictionaries.cjs"), cjsContent);
|
|
79
|
-
const esmContent = generateDictionaryListContent(
|
|
47
|
+
const esmContent = (0, import_generateDictionaryListContent.generateDictionaryListContent)(
|
|
80
48
|
dictionariesPath,
|
|
81
49
|
"esm",
|
|
82
50
|
configuration
|
|
83
51
|
);
|
|
84
52
|
(0, import_fs.writeFileSync)((0, import_path.resolve)(mainDir, "dictionaries.mjs"), esmContent);
|
|
85
53
|
const unmergedDictionariesPath = (0, import_getBuiltUnmergedDictionariesPath.getBuiltUnmergedDictionariesPath)(configuration);
|
|
86
|
-
const unmergedCjsContent = generateDictionaryListContent(
|
|
54
|
+
const unmergedCjsContent = (0, import_generateDictionaryListContent.generateDictionaryListContent)(
|
|
87
55
|
unmergedDictionariesPath,
|
|
88
56
|
"cjs",
|
|
89
57
|
configuration
|
|
@@ -92,7 +60,7 @@ const createDictionaryEntryPoint = (configuration = (0, import_config.getConfigu
|
|
|
92
60
|
(0, import_path.resolve)(mainDir, "unmerged_dictionaries.cjs"),
|
|
93
61
|
unmergedCjsContent
|
|
94
62
|
);
|
|
95
|
-
const unmergedEsmContent = generateDictionaryListContent(
|
|
63
|
+
const unmergedEsmContent = (0, import_generateDictionaryListContent.generateDictionaryListContent)(
|
|
96
64
|
unmergedDictionariesPath,
|
|
97
65
|
"esm",
|
|
98
66
|
configuration
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/createDictionaryEntryPoint.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/createDictionaryEntryPoint.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { resolve } from 'path';\nimport { getBuiltDictionariesPath } from '../../getBuiltDictionariesPath';\nimport { getBuiltUnmergedDictionariesPath } from '../../getBuiltUnmergedDictionariesPath';\nimport { generateDictionaryListContent } from './generateDictionaryListContent';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const createDictionaryEntryPoint = (\n configuration = getConfiguration(),\n dictionariesKeys?: string[]\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 let dictionariesPath: string[] = getBuiltDictionariesPath(configuration);\n\n if (dictionariesKeys) {\n dictionariesPath = dictionariesPath.filter((dictionaryPath) =>\n dictionariesKeys.some((key) => dictionaryPath.endsWith(`${key}.json`))\n );\n }\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 const unmergedDictionariesPath: string[] =\n getBuiltUnmergedDictionariesPath(configuration);\n\n const unmergedCjsContent = generateDictionaryListContent(\n unmergedDictionariesPath,\n 'cjs',\n configuration\n );\n writeFileSync(\n resolve(mainDir, 'unmerged_dictionaries.cjs'),\n unmergedCjsContent\n );\n\n const unmergedEsmContent = generateDictionaryListContent(\n unmergedDictionariesPath,\n 'esm',\n configuration\n );\n writeFileSync(\n resolve(mainDir, 'unmerged_dictionaries.mjs'),\n unmergedEsmContent\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,gBAAqD;AACrD,kBAAwB;AACxB,sCAAyC;AACzC,8CAAiD;AACjD,2CAA8C;AAKvC,MAAM,6BAA6B,CACxC,oBAAgB,gCAAiB,GACjC,qBACG;AACH,QAAM,EAAE,QAAQ,IAAI,cAAc;AAGlC,MAAI,KAAC,sBAAW,OAAO,GAAG;AACxB,6BAAU,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACxC;AAEA,MAAI,uBAA6B,0DAAyB,aAAa;AAEvE,MAAI,kBAAkB;AACpB,uBAAmB,iBAAiB;AAAA,MAAO,CAAC,mBAC1C,iBAAiB,KAAK,CAAC,QAAQ,eAAe,SAAS,GAAG,GAAG,OAAO,CAAC;AAAA,IACvE;AAAA,EACF;AAGA,QAAM,iBAAa;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,mCAAc,qBAAQ,SAAS,kBAAkB,GAAG,UAAU;AAE9D,QAAM,iBAAa;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,mCAAc,qBAAQ,SAAS,kBAAkB,GAAG,UAAU;AAE9D,QAAM,+BACJ,0EAAiC,aAAa;AAEhD,QAAM,yBAAqB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA;AAAA,QACE,qBAAQ,SAAS,2BAA2B;AAAA,IAC5C;AAAA,EACF;AAEA,QAAM,yBAAqB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA;AAAA,QACE,qBAAQ,SAAS,2BAA2B;AAAA,IAC5C;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var generateDictionaryListContent_exports = {};
|
|
20
|
+
__export(generateDictionaryListContent_exports, {
|
|
21
|
+
generateDictionaryListContent: () => generateDictionaryListContent
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(generateDictionaryListContent_exports);
|
|
24
|
+
var import_config = require("@intlayer/config");
|
|
25
|
+
var import_path = require("path");
|
|
26
|
+
var import_utils = require('../../utils.cjs');
|
|
27
|
+
const generateDictionaryListContent = (dictionaries, format = "esm", configuration = (0, import_config.getConfiguration)()) => {
|
|
28
|
+
const { mainDir } = configuration.content;
|
|
29
|
+
let content = "";
|
|
30
|
+
const dictionariesRef = dictionaries.map((dictionaryPath) => ({
|
|
31
|
+
relativePath: (0, import_path.relative)(mainDir, dictionaryPath),
|
|
32
|
+
id: (0, import_path.basename)(dictionaryPath, (0, import_path.extname)(dictionaryPath)),
|
|
33
|
+
// Get the base name as the dictionary id
|
|
34
|
+
hash: `_${(0, import_utils.getFileHash)(dictionaryPath)}`
|
|
35
|
+
// Get the hash of the dictionary to avoid conflicts
|
|
36
|
+
}));
|
|
37
|
+
dictionariesRef.forEach((dictionary) => {
|
|
38
|
+
if (format === "esm")
|
|
39
|
+
content += `import ${dictionary.hash} from '${dictionary.relativePath}' with { type: 'json' };
|
|
40
|
+
`;
|
|
41
|
+
if (format === "cjs")
|
|
42
|
+
content += `const ${dictionary.hash} = require('${dictionary.relativePath}');
|
|
43
|
+
`;
|
|
44
|
+
});
|
|
45
|
+
content += "\n";
|
|
46
|
+
const formattedDictionaryMap = dictionariesRef.map((dictionary) => ` "${dictionary.id}": ${dictionary.hash}`).join(",\n");
|
|
47
|
+
if (format === "esm")
|
|
48
|
+
content += `export default {
|
|
49
|
+
${formattedDictionaryMap}
|
|
50
|
+
};
|
|
51
|
+
`;
|
|
52
|
+
if (format === "cjs")
|
|
53
|
+
content += `module.exports = {
|
|
54
|
+
${formattedDictionaryMap}
|
|
55
|
+
};
|
|
56
|
+
`;
|
|
57
|
+
return content;
|
|
58
|
+
};
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {
|
|
61
|
+
generateDictionaryListContent
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=generateDictionaryListContent.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/generateDictionaryListContent.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { basename, extname, relative } from 'path';\nimport { getFileHash } from '../../utils';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const 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}' with { type: 'json' };\\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"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,kBAA4C;AAC5C,mBAA4B;AAKrB,MAAM,gCAAgC,CAC3C,cACA,SAAwB,OACxB,oBAAgB,gCAAiB,MACtB;AACX,QAAM,EAAE,QAAQ,IAAI,cAAc;AAElC,MAAI,UAAU;AAEd,QAAM,kBAAkB,aAAa,IAAI,CAAC,oBAAoB;AAAA,IAC5D,kBAAc,sBAAS,SAAS,cAAc;AAAA,IAC9C,QAAI,sBAAS,oBAAgB,qBAAQ,cAAc,CAAC;AAAA;AAAA,IACpD,MAAM,QAAI,0BAAY,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;","names":[]}
|
|
@@ -16,8 +16,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
16
16
|
var dictionary_to_main_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(dictionary_to_main_exports);
|
|
18
18
|
__reExport(dictionary_to_main_exports, require('./createDictionaryEntryPoint.cjs'), module.exports);
|
|
19
|
+
__reExport(dictionary_to_main_exports, require('./generateDictionaryListContent.cjs'), module.exports);
|
|
19
20
|
// Annotate the CommonJS export names for ESM import in node:
|
|
20
21
|
0 && (module.exports = {
|
|
21
|
-
...require('./createDictionaryEntryPoint.cjs')
|
|
22
|
+
...require('./createDictionaryEntryPoint.cjs'),
|
|
23
|
+
...require('./generateDictionaryListContent.cjs')
|
|
22
24
|
});
|
|
23
25
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/index.ts"],"sourcesContent":["export * from './createDictionaryEntryPoint';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,uCAAc,yCAAd;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/index.ts"],"sourcesContent":["export * from './createDictionaryEntryPoint';\nexport * from './generateDictionaryListContent';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,uCAAc,yCAAd;AACA,uCAAc,4CADd;","names":[]}
|
|
@@ -1,15 +1,32 @@
|
|
|
1
|
-
import { getConfiguration } from "@intlayer/config";
|
|
1
|
+
import { getAppLogger, getConfiguration } from "@intlayer/config";
|
|
2
2
|
import { existsSync, rmSync } from "fs";
|
|
3
|
-
import { createDictionaryEntryPoint } from "./transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs";
|
|
4
3
|
const cleanOutputDir = (configuration = getConfiguration()) => {
|
|
5
|
-
const {
|
|
4
|
+
const {
|
|
5
|
+
dictionariesDir,
|
|
6
|
+
unmergedDictionariesDir,
|
|
7
|
+
mainDir,
|
|
8
|
+
typesDir,
|
|
9
|
+
configDir
|
|
10
|
+
} = configuration.content;
|
|
11
|
+
const appLogger = getAppLogger(configuration);
|
|
6
12
|
if (existsSync(dictionariesDir)) {
|
|
7
13
|
rmSync(dictionariesDir, { recursive: true });
|
|
8
14
|
}
|
|
15
|
+
if (existsSync(unmergedDictionariesDir)) {
|
|
16
|
+
rmSync(unmergedDictionariesDir, { recursive: true });
|
|
17
|
+
}
|
|
18
|
+
if (existsSync(mainDir)) {
|
|
19
|
+
rmSync(mainDir, { recursive: true });
|
|
20
|
+
}
|
|
9
21
|
if (existsSync(typesDir)) {
|
|
10
22
|
rmSync(typesDir, { recursive: true });
|
|
11
23
|
}
|
|
12
|
-
|
|
24
|
+
if (existsSync(configDir)) {
|
|
25
|
+
rmSync(configDir, { recursive: true });
|
|
26
|
+
}
|
|
27
|
+
appLogger("Output directory cleaned", {
|
|
28
|
+
isVerbose: true
|
|
29
|
+
});
|
|
13
30
|
};
|
|
14
31
|
export {
|
|
15
32
|
cleanOutputDir
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { existsSync, rmSync } from 'fs';\
|
|
1
|
+
{"version":3,"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { getAppLogger, getConfiguration } from '@intlayer/config';\nimport { existsSync, rmSync } from 'fs';\n\nexport const cleanOutputDir = (configuration = getConfiguration()) => {\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n mainDir,\n typesDir,\n configDir,\n } = configuration.content;\n\n const appLogger = getAppLogger(configuration);\n\n if (existsSync(dictionariesDir)) {\n // Delete the dictionary directory\n rmSync(dictionariesDir, { recursive: true });\n }\n\n if (existsSync(unmergedDictionariesDir)) {\n // Delete the unmerged dictionaries directory\n rmSync(unmergedDictionariesDir, { recursive: true });\n }\n\n // Delete the main directory\n if (existsSync(mainDir)) {\n rmSync(mainDir, { recursive: true });\n }\n\n // Delete the types directory\n if (existsSync(typesDir)) {\n rmSync(typesDir, { recursive: true });\n }\n\n // Delete the config directory\n if (existsSync(configDir)) {\n rmSync(configDir, { recursive: true });\n }\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n};\n"],"mappings":"AAAA,SAAS,cAAc,wBAAwB;AAC/C,SAAS,YAAY,cAAc;AAE5B,MAAM,iBAAiB,CAAC,gBAAgB,iBAAiB,MAAM;AACpE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,cAAc;AAElB,QAAM,YAAY,aAAa,aAAa;AAE5C,MAAI,WAAW,eAAe,GAAG;AAE/B,WAAO,iBAAiB,EAAE,WAAW,KAAK,CAAC;AAAA,EAC7C;AAEA,MAAI,WAAW,uBAAuB,GAAG;AAEvC,WAAO,yBAAyB,EAAE,WAAW,KAAK,CAAC;AAAA,EACrD;AAGA,MAAI,WAAW,OAAO,GAAG;AACvB,WAAO,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACrC;AAGA,MAAI,WAAW,QAAQ,GAAG;AACxB,WAAO,UAAU,EAAE,WAAW,KAAK,CAAC;AAAA,EACtC;AAGA,MAAI,WAAW,SAAS,GAAG;AACzB,WAAO,WAAW,EAAE,WAAW,KAAK,CAAC;AAAA,EACvC;AAEA,YAAU,4BAA4B;AAAA,IACpC,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
|
|
@@ -7,7 +7,9 @@ const filterTranlationsPlugin = (locales) => ({
|
|
|
7
7
|
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeType.Translation,
|
|
8
8
|
transform: (node, props, deepTransformNode2) => {
|
|
9
9
|
const translationMap = node.translation;
|
|
10
|
-
const
|
|
10
|
+
const localesArray = Array.isArray(locales) ? locales : [locales];
|
|
11
|
+
const isSingleLocale = localesArray.length === 1;
|
|
12
|
+
const filteredTranslationMap = isSingleLocale ? translationMap[localesArray[0]] : Object.fromEntries(
|
|
11
13
|
Object.entries(translationMap).filter(
|
|
12
14
|
([key]) => locales.includes(key)
|
|
13
15
|
)
|
|
@@ -24,13 +26,11 @@ const filterTranlationsPlugin = (locales) => ({
|
|
|
24
26
|
};
|
|
25
27
|
}
|
|
26
28
|
});
|
|
27
|
-
const filterDictionaryLocales = (dictionary, locales) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
});
|
|
33
|
-
};
|
|
29
|
+
const filterDictionaryLocales = (dictionary, locales) => deepTransformNode(dictionary, {
|
|
30
|
+
plugins: [filterTranlationsPlugin(locales)],
|
|
31
|
+
dictionaryKey: dictionary.key,
|
|
32
|
+
keyPath: []
|
|
33
|
+
});
|
|
34
34
|
export {
|
|
35
35
|
filterDictionaryLocales
|
|
36
36
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/filterDictionaryLocales.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport {\n deepTransformNode,\n
|
|
1
|
+
{"version":3,"sources":["../../src/filterDictionaryLocales.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport {\n deepTransformNode,\n NodeType,\n type Dictionary,\n type Plugins,\n} from '@intlayer/core';\n\nconst filterTranlationsPlugin = (locales: Locales[] | Locales): Plugins => ({\n id: 'filter-translations-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Translation,\n transform: (node, props, deepTransformNode) => {\n const translationMap = node.translation as Record<Locales, string>;\n\n const localesArray = Array.isArray(locales) ? locales : [locales];\n const isSingleLocale = localesArray.length === 1;\n\n const filteredTranslationMap = isSingleLocale\n ? translationMap[localesArray[0] as Locales]\n : Object.fromEntries(\n Object.entries(translationMap).filter(([key]) =>\n locales.includes(key as Locales)\n )\n );\n\n return {\n ...node,\n translation: deepTransformNode(filteredTranslationMap, {\n ...props,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Object, key: NodeType.Translation },\n ],\n }),\n };\n },\n});\n\nexport const filterDictionaryLocales = (\n dictionary: Dictionary,\n locales: Locales[] | Locales\n) =>\n deepTransformNode(dictionary, {\n plugins: [filterTranlationsPlugin(locales)],\n dictionaryKey: dictionary.key,\n keyPath: [],\n });\n"],"mappings":"AACA;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAEP,MAAM,0BAA0B,CAAC,aAA2C;AAAA,EAC1E,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,SAAS;AAAA,EAC1D,WAAW,CAAC,MAAM,OAAOA,uBAAsB;AAC7C,UAAM,iBAAiB,KAAK;AAE5B,UAAM,eAAe,MAAM,QAAQ,OAAO,IAAI,UAAU,CAAC,OAAO;AAChE,UAAM,iBAAiB,aAAa,WAAW;AAE/C,UAAM,yBAAyB,iBAC3B,eAAe,aAAa,CAAC,CAAY,IACzC,OAAO;AAAA,MACL,OAAO,QAAQ,cAAc,EAAE;AAAA,QAAO,CAAC,CAAC,GAAG,MACzC,QAAQ,SAAS,GAAc;AAAA,MACjC;AAAA,IACF;AAEJ,WAAO;AAAA,MACL,GAAG;AAAA,MACH,aAAaA,mBAAkB,wBAAwB;AAAA,QACrD,GAAG;AAAA,QACH,SAAS;AAAA,UACP,GAAG,MAAM;AAAA,UACT,EAAE,MAAM,SAAS,QAAQ,KAAK,SAAS,YAAY;AAAA,QACrD;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,MAAM,0BAA0B,CACrC,YACA,YAEA,kBAAkB,YAAY;AAAA,EAC5B,SAAS,CAAC,wBAAwB,OAAO,CAAC;AAAA,EAC1C,eAAe,WAAW;AAAA,EAC1B,SAAS,CAAC;AACZ,CAAC;","names":["deepTransformNode"]}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -5,9 +5,12 @@ import {
|
|
|
5
5
|
handleContentDeclarationFileChange,
|
|
6
6
|
watch
|
|
7
7
|
} from "./chokidar/watcher.mjs";
|
|
8
|
+
import { cleanOutputDir } from "./cleanOutputDir.mjs";
|
|
8
9
|
import { fetchDistantDictionaries } from "./fetchDistantDictionaries.mjs";
|
|
9
10
|
import { fetchDistantDictionaryKeys } from "./fetchDistantDictionaryKeys.mjs";
|
|
10
11
|
import { filterDictionaryLocales } from "./filterDictionaryLocales.mjs";
|
|
12
|
+
import { getBuiltDictionariesPath } from "./getBuiltDictionariesPath.mjs";
|
|
13
|
+
import { getBuiltUnmergedDictionariesPath } from "./getBuiltUnmergedDictionariesPath.mjs";
|
|
11
14
|
import { listDictionaries } from "./listDictionariesPath.mjs";
|
|
12
15
|
import {
|
|
13
16
|
listGitFiles
|
|
@@ -23,8 +26,12 @@ import { prepareIntlayer } from "./prepareIntlayer.mjs";
|
|
|
23
26
|
import { processPerLocaleDictionary } from "./processPerLocaleDictionary.mjs";
|
|
24
27
|
import { reduceDictionaryContent } from "./reduceDictionaryContent/reduceDictionaryContent.mjs";
|
|
25
28
|
import { buildDictionary } from "./transpiler/declaration_file_to_dictionary/index.mjs";
|
|
26
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
createDictionaryEntryPoint,
|
|
31
|
+
generateDictionaryListContent
|
|
32
|
+
} from "./transpiler/dictionary_to_main/index.mjs";
|
|
27
33
|
import { createModuleAugmentation } from "./transpiler/dictionary_to_type/createModuleAugmentation.mjs";
|
|
34
|
+
import { getFileHash } from "./utils.mjs";
|
|
28
35
|
import {
|
|
29
36
|
writeContentDeclaration
|
|
30
37
|
} from "./writeContentDeclaration/index.mjs";
|
|
@@ -32,11 +39,16 @@ export {
|
|
|
32
39
|
buildAndWatchIntlayer,
|
|
33
40
|
buildDictionary,
|
|
34
41
|
checkDictionaryChanges,
|
|
42
|
+
cleanOutputDir,
|
|
35
43
|
createDictionaryEntryPoint,
|
|
36
44
|
createModuleAugmentation,
|
|
37
45
|
fetchDistantDictionaries,
|
|
38
46
|
fetchDistantDictionaryKeys,
|
|
39
47
|
filterDictionaryLocales,
|
|
48
|
+
generateDictionaryListContent,
|
|
49
|
+
getBuiltDictionariesPath,
|
|
50
|
+
getBuiltUnmergedDictionariesPath,
|
|
51
|
+
getFileHash,
|
|
40
52
|
handleAdditionalContentDeclarationFile,
|
|
41
53
|
handleContentDeclarationFileChange,
|
|
42
54
|
listDictionaries,
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { checkDictionaryChanges } from './checkDictionaryChanges';\nexport {\n buildAndWatchIntlayer,\n handleAdditionalContentDeclarationFile,\n handleContentDeclarationFileChange,\n watch,\n} from './chokidar/watcher';\nexport { fetchDistantDictionaries } from './fetchDistantDictionaries';\nexport { fetchDistantDictionaryKeys } from './fetchDistantDictionaryKeys';\nexport { filterDictionaryLocales } from './filterDictionaryLocales';\nexport { listDictionaries } from './listDictionariesPath';\nexport {\n listGitFiles,\n type DiffMode,\n type ListGitFilesOptions,\n} from './listGitFiles';\nexport {\n loadDictionaries,\n loadDistantDictionaries,\n loadLocalDictionaries,\n} from './loadDictionaries/index';\nexport { mergeDictionaries } from './mergeDictionaries';\nexport { prepareContentDeclaration } from './prepareContentDeclaration';\nexport { prepareIntlayer } from './prepareIntlayer';\nexport { processPerLocaleDictionary } from './processPerLocaleDictionary';\nexport { reduceDictionaryContent } from './reduceDictionaryContent/reduceDictionaryContent';\nexport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nexport {
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { checkDictionaryChanges } from './checkDictionaryChanges';\nexport {\n buildAndWatchIntlayer,\n handleAdditionalContentDeclarationFile,\n handleContentDeclarationFileChange,\n watch,\n} from './chokidar/watcher';\nexport { cleanOutputDir } from './cleanOutputDir';\nexport { fetchDistantDictionaries } from './fetchDistantDictionaries';\nexport { fetchDistantDictionaryKeys } from './fetchDistantDictionaryKeys';\nexport { filterDictionaryLocales } from './filterDictionaryLocales';\nexport { getBuiltDictionariesPath } from './getBuiltDictionariesPath';\nexport { getBuiltUnmergedDictionariesPath } from './getBuiltUnmergedDictionariesPath';\nexport { listDictionaries } from './listDictionariesPath';\nexport {\n listGitFiles,\n type DiffMode,\n type ListGitFilesOptions,\n} from './listGitFiles';\nexport {\n loadDictionaries,\n loadDistantDictionaries,\n loadLocalDictionaries,\n} from './loadDictionaries/index';\nexport { mergeDictionaries } from './mergeDictionaries';\nexport { prepareContentDeclaration } from './prepareContentDeclaration';\nexport { prepareIntlayer } from './prepareIntlayer';\nexport { processPerLocaleDictionary } from './processPerLocaleDictionary';\nexport { reduceDictionaryContent } from './reduceDictionaryContent/reduceDictionaryContent';\nexport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nexport {\n createDictionaryEntryPoint,\n generateDictionaryListContent,\n} from './transpiler/dictionary_to_main';\nexport { createModuleAugmentation } from './transpiler/dictionary_to_type/createModuleAugmentation';\nexport { getFileHash } from './utils';\nexport {\n writeContentDeclaration,\n type DictionaryStatus,\n} from './writeContentDeclaration';\n"],"mappings":"AAAA,SAAS,8BAA8B;AACvC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,SAAS,gCAAgC;AACzC,SAAS,kCAAkC;AAC3C,SAAS,+BAA+B;AACxC,SAAS,gCAAgC;AACzC,SAAS,wCAAwC;AACjD,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB;AAClC,SAAS,iCAAiC;AAC1C,SAAS,uBAAuB;AAChC,SAAS,kCAAkC;AAC3C,SAAS,+BAA+B;AACxC,SAAS,uBAAuB;AAChC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,gCAAgC;AACzC,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,OAEK;","names":[]}
|
|
@@ -16,9 +16,6 @@ import { writeConfiguration } from "./writeConfiguration/index.mjs";
|
|
|
16
16
|
const prepareIntlayer = async (configuration = getConfiguration(), projectRequire = ESMxCJSRequire) => {
|
|
17
17
|
const appLogger = getAppLogger(configuration);
|
|
18
18
|
cleanOutputDir(configuration);
|
|
19
|
-
appLogger("Output directory cleaned", {
|
|
20
|
-
isVerbose: true
|
|
21
|
-
});
|
|
22
19
|
const files = listDictionaries(configuration);
|
|
23
20
|
const dictionaries = await loadDictionaries(
|
|
24
21
|
files,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import {\n ESMxCJSRequire,\n type IntlayerConfig,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { listDictionaries } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryEntryPoint } from './transpiler/dictionary_to_main/createDictionaryEntryPoint';\nimport {\n createModuleAugmentation,\n createTypes,\n} from './transpiler/dictionary_to_type/index';\nimport { writeConfiguration } from './writeConfiguration';\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire\n) => {\n const appLogger = getAppLogger(configuration);\n\n cleanOutputDir(configuration);\n\n
|
|
1
|
+
{"version":3,"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import {\n ESMxCJSRequire,\n type IntlayerConfig,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { listDictionaries } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryEntryPoint } from './transpiler/dictionary_to_main/createDictionaryEntryPoint';\nimport {\n createModuleAugmentation,\n createTypes,\n} from './transpiler/dictionary_to_type/index';\nimport { writeConfiguration } from './writeConfiguration';\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire\n) => {\n const appLogger = getAppLogger(configuration);\n\n cleanOutputDir(configuration);\n\n const files: string[] = listDictionaries(configuration);\n\n const dictionaries = await loadDictionaries(\n files,\n configuration,\n projectRequire\n );\n\n // Build locale dictionaries\n const dictionariesPaths = await buildDictionary(dictionaries, configuration);\n\n createTypes(dictionariesPaths, configuration);\n\n createDictionaryEntryPoint(configuration);\n\n appLogger('Dictionaries built');\n\n createModuleAugmentation(configuration);\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n\n writeConfiguration(configuration);\n\n appLogger('Configuration written', {\n isVerbose: true,\n });\n};\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,kCAAkC;AAC3C;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;AAE5B,MAAM,kBAAkB,OAC7B,gBAAgC,iBAAiB,GACjD,iBAAiB,mBACd;AACH,QAAM,YAAY,aAAa,aAAa;AAE5C,iBAAe,aAAa;AAE5B,QAAM,QAAkB,iBAAiB,aAAa;AAEtD,QAAM,eAAe,MAAM;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAGA,QAAM,oBAAoB,MAAM,gBAAgB,cAAc,aAAa;AAE3E,cAAY,mBAAmB,aAAa;AAE5C,6BAA2B,aAAa;AAExC,YAAU,oBAAoB;AAE9B,2BAAyB,aAAa;AAEtC,YAAU,6BAA6B;AAAA,IACrC,WAAW;AAAA,EACb,CAAC;AAED,qBAAmB,aAAa;AAEhC,YAAU,yBAAyB;AAAA,IACjC,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
|
package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.mjs
CHANGED
|
@@ -21,6 +21,7 @@ const writeUnmergedDictionaries = async (dictionaries, configuration = getConfig
|
|
|
21
21
|
await mkdir(unmergedDictionariesDir, { recursive: true });
|
|
22
22
|
const groupedDictionaries = groupDictionariesByKey(dictionaries);
|
|
23
23
|
for (const [key, dictionaries2] of Object.entries(groupedDictionaries)) {
|
|
24
|
+
if (key === "undefined") continue;
|
|
24
25
|
const isDevelopment = process.env.NODE_ENV === "development";
|
|
25
26
|
const contentString = isDevelopment ? JSON.stringify(dictionaries2, null, 2) : JSON.stringify(dictionaries2);
|
|
26
27
|
const outputFileName = `${key}.json`;
|
|
@@ -35,6 +36,7 @@ const writeFinalDictionaries = async (groupedDictionaries, configuration = getCo
|
|
|
35
36
|
const { dictionariesDir } = configuration.content;
|
|
36
37
|
const resultDictionariesPaths = [];
|
|
37
38
|
for (const [key, dictionaries] of Object.entries(groupedDictionaries)) {
|
|
39
|
+
if (key === "undefined") continue;
|
|
38
40
|
const multiLocaleDictionaries = dictionaries.map(
|
|
39
41
|
(dictionary) => processPerLocaleDictionary(dictionary)
|
|
40
42
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { mkdir, writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { mergeDictionaries } from '../../../mergeDictionaries';\nimport { processPerLocaleDictionary } from '../../../processPerLocaleDictionary';\n\nconst groupDictionariesByKey = (\n dictionaries: Dictionary[]\n): Record<string, Dictionary[]> => {\n return dictionaries.reduce(\n (acc, dictionary) => {\n const key = dictionary.key;\n if (!acc[key]) {\n acc[key] = [];\n }\n acc[key].push(dictionary);\n return acc;\n },\n {} as Record<string, Dictionary[]>\n );\n};\n\n/**\n * Write the unmerged dictionaries to the unmergedDictionariesDir\n * @param dictionaries - The dictionaries to write\n * @param configuration - The configuration\n * @returns The grouped dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * console.log(unmergedDictionaries);\n *\n * // .intlayer/unmerged_dictionaries/home.json\n * // {\n * // [\n * // { key: 'home', content: { ... } },\n * // { key: 'home', content: { ... } },\n * // ],\n * // }\n * ```\n */\nexport const writeUnmergedDictionaries = async (\n dictionaries: Dictionary[],\n configuration = getConfiguration()\n): Promise<Record<string, Dictionary[]>> => {\n const { unmergedDictionariesDir } = configuration.content;\n\n // Create the merged dictionaries directory\n await mkdir(unmergedDictionariesDir, { recursive: true });\n\n // Group dictionaries by key and write to unmergedDictionariesDir\n const groupedDictionaries = groupDictionariesByKey(dictionaries);\n\n for (const [key, dictionaries] of Object.entries(groupedDictionaries)) {\n const isDevelopment = process.env.NODE_ENV === 'development';\n const contentString = isDevelopment\n ? JSON.stringify(dictionaries, null, 2)\n : JSON.stringify(dictionaries);\n\n const outputFileName = `${key}.json`;\n const unmergedFilePath = resolve(unmergedDictionariesDir, outputFileName);\n\n // Write the grouped dictionaries\n await writeFile(unmergedFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating unmerged ${outputFileName}:`, err);\n });\n }\n\n return groupedDictionaries;\n};\n\n/**\n * Write the final dictionaries to the dictionariesDir\n * @param groupedDictionaries - The grouped dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeFinalDictionaries = async (\n groupedDictionaries: Record<string, Dictionary[]>,\n configuration = getConfiguration()\n) => {\n const { dictionariesDir } = configuration.content;\n const resultDictionariesPaths: string[] = [];\n\n // Merge dictionaries with the same key and write to dictionariesDir\n for (const [key, dictionaries] of Object.entries(groupedDictionaries)) {\n const multiLocaleDictionaries = dictionaries.map((dictionary) =>\n processPerLocaleDictionary(dictionary)\n );\n const mergedDictionary = mergeDictionaries(multiLocaleDictionaries);\n\n const isDevelopment = process.env.NODE_ENV === 'development';\n const contentString = isDevelopment\n ? JSON.stringify(mergedDictionary, null, 2)\n : JSON.stringify(mergedDictionary);\n\n const outputFileName = `${key}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n // Write the merged dictionary\n await writeFile(resultFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating merged ${outputFileName}:`, err);\n });\n\n resultDictionariesPaths.push(resultFilePath);\n }\n\n return resultDictionariesPaths;\n};\n\nexport const writeDictionary = async (\n dictionaries: Dictionary[],\n configuration = getConfiguration()\n) => {\n const unmergedDictionaries = await writeUnmergedDictionaries(\n dictionaries,\n configuration\n );\n\n const finalDictionaries = await writeFinalDictionaries(\n unmergedDictionaries,\n configuration\n );\n\n return finalDictionaries;\n};\n"],"mappings":"AAAA,SAAS,wBAAwB;AAEjC,SAAS,OAAO,iBAAiB;AACjC,SAAS,eAAe;AACxB,SAAS,yBAAyB;AAClC,SAAS,kCAAkC;AAE3C,MAAM,yBAAyB,CAC7B,iBACiC;AACjC,SAAO,aAAa;AAAA,IAClB,CAAC,KAAK,eAAe;AACnB,YAAM,MAAM,WAAW;AACvB,UAAI,CAAC,IAAI,GAAG,GAAG;AACb,YAAI,GAAG,IAAI,CAAC;AAAA,MACd;AACA,UAAI,GAAG,EAAE,KAAK,UAAU;AACxB,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AACF;AAsBO,MAAM,4BAA4B,OACvC,cACA,gBAAgB,iBAAiB,MACS;AAC1C,QAAM,EAAE,wBAAwB,IAAI,cAAc;AAGlD,QAAM,MAAM,yBAAyB,EAAE,WAAW,KAAK,CAAC;AAGxD,QAAM,sBAAsB,uBAAuB,YAAY;AAE/D,aAAW,CAAC,KAAKA,aAAY,KAAK,OAAO,QAAQ,mBAAmB,GAAG;AACrE,UAAM,gBAAgB,QAAQ,IAAI,aAAa;AAC/C,UAAM,gBAAgB,gBAClB,KAAK,UAAUA,eAAc,MAAM,CAAC,IACpC,KAAK,UAAUA,aAAY;AAE/B,UAAM,iBAAiB,GAAG,GAAG;AAC7B,UAAM,mBAAmB,QAAQ,yBAAyB,cAAc;AAGxE,UAAM,UAAU,kBAAkB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACtE,cAAQ,MAAM,2BAA2B,cAAc,KAAK,GAAG;AAAA,IACjE,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAkBO,MAAM,yBAAyB,OACpC,qBACA,gBAAgB,iBAAiB,MAC9B;AACH,QAAM,EAAE,gBAAgB,IAAI,cAAc;AAC1C,QAAM,0BAAoC,CAAC;AAG3C,aAAW,CAAC,KAAK,YAAY,KAAK,OAAO,QAAQ,mBAAmB,GAAG;AACrE,UAAM,0BAA0B,aAAa;AAAA,MAAI,CAAC,eAChD,2BAA2B,UAAU;AAAA,IACvC;AACA,UAAM,mBAAmB,kBAAkB,uBAAuB;AAElE,UAAM,gBAAgB,QAAQ,IAAI,aAAa;AAC/C,UAAM,gBAAgB,gBAClB,KAAK,UAAU,kBAAkB,MAAM,CAAC,IACxC,KAAK,UAAU,gBAAgB;AAEnC,UAAM,iBAAiB,GAAG,GAAG;AAC7B,UAAM,iBAAiB,QAAQ,iBAAiB,cAAc;AAG9D,UAAM,UAAU,gBAAgB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACpE,cAAQ,MAAM,yBAAyB,cAAc,KAAK,GAAG;AAAA,IAC/D,CAAC;AAED,4BAAwB,KAAK,cAAc;AAAA,EAC7C;AAEA,SAAO;AACT;AAEO,MAAM,kBAAkB,OAC7B,cACA,gBAAgB,iBAAiB,MAC9B;AACH,QAAM,uBAAuB,MAAM;AAAA,IACjC;AAAA,IACA;AAAA,EACF;AAEA,QAAM,oBAAoB,MAAM;AAAA,IAC9B;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AACT;","names":["dictionaries"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { mkdir, writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { mergeDictionaries } from '../../../mergeDictionaries';\nimport { processPerLocaleDictionary } from '../../../processPerLocaleDictionary';\n\nconst groupDictionariesByKey = (\n dictionaries: Dictionary[]\n): Record<string, Dictionary[]> => {\n return dictionaries.reduce(\n (acc, dictionary) => {\n const key = dictionary.key;\n if (!acc[key]) {\n acc[key] = [];\n }\n acc[key].push(dictionary);\n return acc;\n },\n {} as Record<string, Dictionary[]>\n );\n};\n\n/**\n * Write the unmerged dictionaries to the unmergedDictionariesDir\n * @param dictionaries - The dictionaries to write\n * @param configuration - The configuration\n * @returns The grouped dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * console.log(unmergedDictionaries);\n *\n * // .intlayer/unmerged_dictionaries/home.json\n * // {\n * // [\n * // { key: 'home', content: { ... } },\n * // { key: 'home', content: { ... } },\n * // ],\n * // }\n * ```\n */\nexport const writeUnmergedDictionaries = async (\n dictionaries: Dictionary[],\n configuration = getConfiguration()\n): Promise<Record<string, Dictionary[]>> => {\n const { unmergedDictionariesDir } = configuration.content;\n\n // Create the merged dictionaries directory\n await mkdir(unmergedDictionariesDir, { recursive: true });\n\n // Group dictionaries by key and write to unmergedDictionariesDir\n const groupedDictionaries = groupDictionariesByKey(dictionaries);\n\n for (const [key, dictionaries] of Object.entries(groupedDictionaries)) {\n if (key === 'undefined') continue;\n\n const isDevelopment = process.env.NODE_ENV === 'development';\n const contentString = isDevelopment\n ? JSON.stringify(dictionaries, null, 2)\n : JSON.stringify(dictionaries);\n\n const outputFileName = `${key}.json`;\n const unmergedFilePath = resolve(unmergedDictionariesDir, outputFileName);\n\n // Write the grouped dictionaries\n await writeFile(unmergedFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating unmerged ${outputFileName}:`, err);\n });\n }\n\n return groupedDictionaries;\n};\n\n/**\n * Write the final dictionaries to the dictionariesDir\n * @param groupedDictionaries - The grouped dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeFinalDictionaries = async (\n groupedDictionaries: Record<string, Dictionary[]>,\n configuration = getConfiguration()\n) => {\n const { dictionariesDir } = configuration.content;\n const resultDictionariesPaths: string[] = [];\n\n // Merge dictionaries with the same key and write to dictionariesDir\n for (const [key, dictionaries] of Object.entries(groupedDictionaries)) {\n if (key === 'undefined') continue;\n\n const multiLocaleDictionaries = dictionaries.map((dictionary) =>\n processPerLocaleDictionary(dictionary)\n );\n const mergedDictionary = mergeDictionaries(multiLocaleDictionaries);\n\n const isDevelopment = process.env.NODE_ENV === 'development';\n const contentString = isDevelopment\n ? JSON.stringify(mergedDictionary, null, 2)\n : JSON.stringify(mergedDictionary);\n\n const outputFileName = `${key}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n // Write the merged dictionary\n await writeFile(resultFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating merged ${outputFileName}:`, err);\n });\n\n resultDictionariesPaths.push(resultFilePath);\n }\n\n return resultDictionariesPaths;\n};\n\nexport const writeDictionary = async (\n dictionaries: Dictionary[],\n configuration = getConfiguration()\n) => {\n const unmergedDictionaries = await writeUnmergedDictionaries(\n dictionaries,\n configuration\n );\n\n const finalDictionaries = await writeFinalDictionaries(\n unmergedDictionaries,\n configuration\n );\n\n return finalDictionaries;\n};\n"],"mappings":"AAAA,SAAS,wBAAwB;AAEjC,SAAS,OAAO,iBAAiB;AACjC,SAAS,eAAe;AACxB,SAAS,yBAAyB;AAClC,SAAS,kCAAkC;AAE3C,MAAM,yBAAyB,CAC7B,iBACiC;AACjC,SAAO,aAAa;AAAA,IAClB,CAAC,KAAK,eAAe;AACnB,YAAM,MAAM,WAAW;AACvB,UAAI,CAAC,IAAI,GAAG,GAAG;AACb,YAAI,GAAG,IAAI,CAAC;AAAA,MACd;AACA,UAAI,GAAG,EAAE,KAAK,UAAU;AACxB,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AACF;AAsBO,MAAM,4BAA4B,OACvC,cACA,gBAAgB,iBAAiB,MACS;AAC1C,QAAM,EAAE,wBAAwB,IAAI,cAAc;AAGlD,QAAM,MAAM,yBAAyB,EAAE,WAAW,KAAK,CAAC;AAGxD,QAAM,sBAAsB,uBAAuB,YAAY;AAE/D,aAAW,CAAC,KAAKA,aAAY,KAAK,OAAO,QAAQ,mBAAmB,GAAG;AACrE,QAAI,QAAQ,YAAa;AAEzB,UAAM,gBAAgB,QAAQ,IAAI,aAAa;AAC/C,UAAM,gBAAgB,gBAClB,KAAK,UAAUA,eAAc,MAAM,CAAC,IACpC,KAAK,UAAUA,aAAY;AAE/B,UAAM,iBAAiB,GAAG,GAAG;AAC7B,UAAM,mBAAmB,QAAQ,yBAAyB,cAAc;AAGxE,UAAM,UAAU,kBAAkB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACtE,cAAQ,MAAM,2BAA2B,cAAc,KAAK,GAAG;AAAA,IACjE,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAkBO,MAAM,yBAAyB,OACpC,qBACA,gBAAgB,iBAAiB,MAC9B;AACH,QAAM,EAAE,gBAAgB,IAAI,cAAc;AAC1C,QAAM,0BAAoC,CAAC;AAG3C,aAAW,CAAC,KAAK,YAAY,KAAK,OAAO,QAAQ,mBAAmB,GAAG;AACrE,QAAI,QAAQ,YAAa;AAEzB,UAAM,0BAA0B,aAAa;AAAA,MAAI,CAAC,eAChD,2BAA2B,UAAU;AAAA,IACvC;AACA,UAAM,mBAAmB,kBAAkB,uBAAuB;AAElE,UAAM,gBAAgB,QAAQ,IAAI,aAAa;AAC/C,UAAM,gBAAgB,gBAClB,KAAK,UAAU,kBAAkB,MAAM,CAAC,IACxC,KAAK,UAAU,gBAAgB;AAEnC,UAAM,iBAAiB,GAAG,GAAG;AAC7B,UAAM,iBAAiB,QAAQ,iBAAiB,cAAc;AAG9D,UAAM,UAAU,gBAAgB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACpE,cAAQ,MAAM,yBAAyB,cAAc,KAAK,GAAG;AAAA,IAC/D,CAAC;AAED,4BAAwB,KAAK,cAAc;AAAA,EAC7C;AAEA,SAAO;AACT;AAEO,MAAM,kBAAkB,OAC7B,cACA,gBAAgB,iBAAiB,MAC9B;AACH,QAAM,uBAAuB,MAAM;AAAA,IACjC;AAAA,IACA;AAAA,EACF;AAEA,QAAM,oBAAoB,MAAM;AAAA,IAC9B;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AACT;","names":["dictionaries"]}
|
|
@@ -1,41 +1,9 @@
|
|
|
1
1
|
import { getConfiguration } from "@intlayer/config";
|
|
2
2
|
import { existsSync, mkdirSync, writeFileSync } from "fs";
|
|
3
|
-
import {
|
|
3
|
+
import { resolve } from "path";
|
|
4
4
|
import { getBuiltDictionariesPath } from "../../getBuiltDictionariesPath.mjs";
|
|
5
5
|
import { getBuiltUnmergedDictionariesPath } from "../../getBuiltUnmergedDictionariesPath.mjs";
|
|
6
|
-
import {
|
|
7
|
-
const generateDictionaryListContent = (dictionaries, format = "esm", configuration = getConfiguration()) => {
|
|
8
|
-
const { mainDir } = configuration.content;
|
|
9
|
-
let content = "";
|
|
10
|
-
const dictionariesRef = dictionaries.map((dictionaryPath) => ({
|
|
11
|
-
relativePath: relative(mainDir, dictionaryPath),
|
|
12
|
-
id: basename(dictionaryPath, extname(dictionaryPath)),
|
|
13
|
-
// Get the base name as the dictionary id
|
|
14
|
-
hash: `_${getFileHash(dictionaryPath)}`
|
|
15
|
-
// Get the hash of the dictionary to avoid conflicts
|
|
16
|
-
}));
|
|
17
|
-
dictionariesRef.forEach((dictionary) => {
|
|
18
|
-
if (format === "esm")
|
|
19
|
-
content += `import ${dictionary.hash} from '${dictionary.relativePath}';
|
|
20
|
-
`;
|
|
21
|
-
if (format === "cjs")
|
|
22
|
-
content += `const ${dictionary.hash} = require('${dictionary.relativePath}');
|
|
23
|
-
`;
|
|
24
|
-
});
|
|
25
|
-
content += "\n";
|
|
26
|
-
const formattedDictionaryMap = dictionariesRef.map((dictionary) => ` "${dictionary.id}": ${dictionary.hash}`).join(",\n");
|
|
27
|
-
if (format === "esm")
|
|
28
|
-
content += `export default {
|
|
29
|
-
${formattedDictionaryMap}
|
|
30
|
-
};
|
|
31
|
-
`;
|
|
32
|
-
if (format === "cjs")
|
|
33
|
-
content += `module.exports = {
|
|
34
|
-
${formattedDictionaryMap}
|
|
35
|
-
};
|
|
36
|
-
`;
|
|
37
|
-
return content;
|
|
38
|
-
};
|
|
6
|
+
import { generateDictionaryListContent } from "./generateDictionaryListContent.mjs";
|
|
39
7
|
const createDictionaryEntryPoint = (configuration = getConfiguration(), dictionariesKeys) => {
|
|
40
8
|
const { mainDir } = configuration.content;
|
|
41
9
|
if (!existsSync(mainDir)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/createDictionaryEntryPoint.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/createDictionaryEntryPoint.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { resolve } from 'path';\nimport { getBuiltDictionariesPath } from '../../getBuiltDictionariesPath';\nimport { getBuiltUnmergedDictionariesPath } from '../../getBuiltUnmergedDictionariesPath';\nimport { generateDictionaryListContent } from './generateDictionaryListContent';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const createDictionaryEntryPoint = (\n configuration = getConfiguration(),\n dictionariesKeys?: string[]\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 let dictionariesPath: string[] = getBuiltDictionariesPath(configuration);\n\n if (dictionariesKeys) {\n dictionariesPath = dictionariesPath.filter((dictionaryPath) =>\n dictionariesKeys.some((key) => dictionaryPath.endsWith(`${key}.json`))\n );\n }\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 const unmergedDictionariesPath: string[] =\n getBuiltUnmergedDictionariesPath(configuration);\n\n const unmergedCjsContent = generateDictionaryListContent(\n unmergedDictionariesPath,\n 'cjs',\n configuration\n );\n writeFileSync(\n resolve(mainDir, 'unmerged_dictionaries.cjs'),\n unmergedCjsContent\n );\n\n const unmergedEsmContent = generateDictionaryListContent(\n unmergedDictionariesPath,\n 'esm',\n configuration\n );\n writeFileSync(\n resolve(mainDir, 'unmerged_dictionaries.mjs'),\n unmergedEsmContent\n );\n};\n"],"mappings":"AAAA,SAAS,wBAAwB;AACjC,SAAS,YAAY,WAAW,qBAAqB;AACrD,SAAS,eAAe;AACxB,SAAS,gCAAgC;AACzC,SAAS,wCAAwC;AACjD,SAAS,qCAAqC;AAKvC,MAAM,6BAA6B,CACxC,gBAAgB,iBAAiB,GACjC,qBACG;AACH,QAAM,EAAE,QAAQ,IAAI,cAAc;AAGlC,MAAI,CAAC,WAAW,OAAO,GAAG;AACxB,cAAU,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACxC;AAEA,MAAI,mBAA6B,yBAAyB,aAAa;AAEvE,MAAI,kBAAkB;AACpB,uBAAmB,iBAAiB;AAAA,MAAO,CAAC,mBAC1C,iBAAiB,KAAK,CAAC,QAAQ,eAAe,SAAS,GAAG,GAAG,OAAO,CAAC;AAAA,IACvE;AAAA,EACF;AAGA,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;AAE9D,QAAM,2BACJ,iCAAiC,aAAa;AAEhD,QAAM,qBAAqB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA;AAAA,IACE,QAAQ,SAAS,2BAA2B;AAAA,IAC5C;AAAA,EACF;AAEA,QAAM,qBAAqB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA;AAAA,IACE,QAAQ,SAAS,2BAA2B;AAAA,IAC5C;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { getConfiguration } from "@intlayer/config";
|
|
2
|
+
import { basename, extname, relative } from "path";
|
|
3
|
+
import { getFileHash } from "../../utils.mjs";
|
|
4
|
+
const generateDictionaryListContent = (dictionaries, format = "esm", configuration = getConfiguration()) => {
|
|
5
|
+
const { mainDir } = configuration.content;
|
|
6
|
+
let content = "";
|
|
7
|
+
const dictionariesRef = dictionaries.map((dictionaryPath) => ({
|
|
8
|
+
relativePath: relative(mainDir, dictionaryPath),
|
|
9
|
+
id: basename(dictionaryPath, extname(dictionaryPath)),
|
|
10
|
+
// Get the base name as the dictionary id
|
|
11
|
+
hash: `_${getFileHash(dictionaryPath)}`
|
|
12
|
+
// Get the hash of the dictionary to avoid conflicts
|
|
13
|
+
}));
|
|
14
|
+
dictionariesRef.forEach((dictionary) => {
|
|
15
|
+
if (format === "esm")
|
|
16
|
+
content += `import ${dictionary.hash} from '${dictionary.relativePath}' with { type: 'json' };
|
|
17
|
+
`;
|
|
18
|
+
if (format === "cjs")
|
|
19
|
+
content += `const ${dictionary.hash} = require('${dictionary.relativePath}');
|
|
20
|
+
`;
|
|
21
|
+
});
|
|
22
|
+
content += "\n";
|
|
23
|
+
const formattedDictionaryMap = dictionariesRef.map((dictionary) => ` "${dictionary.id}": ${dictionary.hash}`).join(",\n");
|
|
24
|
+
if (format === "esm")
|
|
25
|
+
content += `export default {
|
|
26
|
+
${formattedDictionaryMap}
|
|
27
|
+
};
|
|
28
|
+
`;
|
|
29
|
+
if (format === "cjs")
|
|
30
|
+
content += `module.exports = {
|
|
31
|
+
${formattedDictionaryMap}
|
|
32
|
+
};
|
|
33
|
+
`;
|
|
34
|
+
return content;
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
generateDictionaryListContent
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=generateDictionaryListContent.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/generateDictionaryListContent.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { basename, extname, relative } from 'path';\nimport { getFileHash } from '../../utils';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const 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}' with { type: 'json' };\\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"],"mappings":"AAAA,SAAS,wBAAwB;AACjC,SAAS,UAAU,SAAS,gBAAgB;AAC5C,SAAS,mBAAmB;AAKrB,MAAM,gCAAgC,CAC3C,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;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/index.ts"],"sourcesContent":["export * from './createDictionaryEntryPoint';\n"],"mappings":"AAAA,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/index.ts"],"sourcesContent":["export * from './createDictionaryEntryPoint';\nexport * from './generateDictionaryListContent';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanOutputDir.d.ts","sourceRoot":"","sources":["../../src/cleanOutputDir.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cleanOutputDir.d.ts","sourceRoot":"","sources":["../../src/cleanOutputDir.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc,GAAI,yDAAkC,SAuChE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Locales } from '@intlayer/config/client';
|
|
2
|
-
import { Dictionary } from '@intlayer/core';
|
|
3
|
-
export declare const filterDictionaryLocales: (dictionary: Dictionary, locales: Locales[]) => any;
|
|
2
|
+
import { type Dictionary } from '@intlayer/core';
|
|
3
|
+
export declare const filterDictionaryLocales: (dictionary: Dictionary, locales: Locales[] | Locales) => any;
|
|
4
4
|
//# sourceMappingURL=filterDictionaryLocales.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterDictionaryLocales.d.ts","sourceRoot":"","sources":["../../src/filterDictionaryLocales.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,
|
|
1
|
+
{"version":3,"file":"filterDictionaryLocales.d.ts","sourceRoot":"","sources":["../../src/filterDictionaryLocales.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAGL,KAAK,UAAU,EAEhB,MAAM,gBAAgB,CAAC;AAiCxB,eAAO,MAAM,uBAAuB,GAClC,YAAY,UAAU,EACtB,SAAS,OAAO,EAAE,GAAG,OAAO,QAM1B,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export { checkDictionaryChanges } from './checkDictionaryChanges';
|
|
2
2
|
export { buildAndWatchIntlayer, handleAdditionalContentDeclarationFile, handleContentDeclarationFileChange, watch, } from './chokidar/watcher';
|
|
3
|
+
export { cleanOutputDir } from './cleanOutputDir';
|
|
3
4
|
export { fetchDistantDictionaries } from './fetchDistantDictionaries';
|
|
4
5
|
export { fetchDistantDictionaryKeys } from './fetchDistantDictionaryKeys';
|
|
5
6
|
export { filterDictionaryLocales } from './filterDictionaryLocales';
|
|
7
|
+
export { getBuiltDictionariesPath } from './getBuiltDictionariesPath';
|
|
8
|
+
export { getBuiltUnmergedDictionariesPath } from './getBuiltUnmergedDictionariesPath';
|
|
6
9
|
export { listDictionaries } from './listDictionariesPath';
|
|
7
10
|
export { listGitFiles, type DiffMode, type ListGitFilesOptions, } from './listGitFiles';
|
|
8
11
|
export { loadDictionaries, loadDistantDictionaries, loadLocalDictionaries, } from './loadDictionaries/index';
|
|
@@ -12,7 +15,8 @@ export { prepareIntlayer } from './prepareIntlayer';
|
|
|
12
15
|
export { processPerLocaleDictionary } from './processPerLocaleDictionary';
|
|
13
16
|
export { reduceDictionaryContent } from './reduceDictionaryContent/reduceDictionaryContent';
|
|
14
17
|
export { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';
|
|
15
|
-
export { createDictionaryEntryPoint } from './transpiler/dictionary_to_main
|
|
18
|
+
export { createDictionaryEntryPoint, generateDictionaryListContent, } from './transpiler/dictionary_to_main';
|
|
16
19
|
export { createModuleAugmentation } from './transpiler/dictionary_to_type/createModuleAugmentation';
|
|
20
|
+
export { getFileHash } from './utils';
|
|
17
21
|
export { writeContentDeclaration, type DictionaryStatus, } from './writeContentDeclaration';
|
|
18
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EACL,qBAAqB,EACrB,sCAAsC,EACtC,kCAAkC,EAClC,KAAK,GACN,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EACL,YAAY,EACZ,KAAK,QAAQ,EACb,KAAK,mBAAmB,GACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAC;AACpF,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EACL,qBAAqB,EACrB,sCAAsC,EACtC,kCAAkC,EAClC,KAAK,GACN,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EACL,YAAY,EACZ,KAAK,QAAQ,EACb,KAAK,mBAAmB,GACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAC;AACpF,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,0DAA0D,CAAC;AACpG,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EACL,uBAAuB,EACvB,KAAK,gBAAgB,GACtB,MAAM,2BAA2B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,kBAkChC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeDictionary.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAsBjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,yBAAyB,GACpC,cAAc,UAAU,EAAE,EAC1B,yDAAkC,KACjC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"writeDictionary.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAsBjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,yBAAyB,GACpC,cAAc,UAAU,EAAE,EAC1B,yDAAkC,KACjC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CA2BtC,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,sBAAsB,GACjC,qBAAqB,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,EACjD,yDAAkC,sBA+BnC,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,cAAc,UAAU,EAAE,EAC1B,yDAAkC,sBAanC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDictionaryEntryPoint.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/dictionary_to_main/createDictionaryEntryPoint.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createDictionaryEntryPoint.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/dictionary_to_main/createDictionaryEntryPoint.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,eAAO,MAAM,0BAA0B,GACrC,yDAAkC,EAClC,mBAAmB,MAAM,EAAE,SAsD5B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function generates the content of the dictionary list file
|
|
3
|
+
*/
|
|
4
|
+
export declare const generateDictionaryListContent: (dictionaries: string[], format?: "cjs" | "esm", configuration?: import("@intlayer/config").IntlayerConfig) => string;
|
|
5
|
+
//# sourceMappingURL=generateDictionaryListContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateDictionaryListContent.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/dictionary_to_main/generateDictionaryListContent.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,eAAO,MAAM,6BAA6B,GACxC,cAAc,MAAM,EAAE,EACtB,SAAQ,KAAK,GAAG,KAAa,EAC7B,yDAAkC,KACjC,MAgCF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/dictionary_to_main/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/dictionary_to_main/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iCAAiC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/chokidar",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.",
|
|
6
6
|
"keywords": [
|
|
@@ -68,12 +68,12 @@
|
|
|
68
68
|
"fast-glob": "^3.3.3",
|
|
69
69
|
"p-limit": "^3.1.0",
|
|
70
70
|
"simple-git": "^3.27.0",
|
|
71
|
-
"@intlayer/
|
|
72
|
-
"@intlayer/
|
|
73
|
-
"@intlayer/
|
|
74
|
-
"@intlayer/dictionaries-entry": "5.5.
|
|
75
|
-
"
|
|
76
|
-
"intlayer": "5.5.
|
|
71
|
+
"@intlayer/api": "5.5.3",
|
|
72
|
+
"@intlayer/dictionaries-entry": "5.5.3",
|
|
73
|
+
"@intlayer/config": "5.5.3",
|
|
74
|
+
"@intlayer/unmerged-dictionaries-entry": "5.5.3",
|
|
75
|
+
"intlayer": "5.5.3",
|
|
76
|
+
"@intlayer/core": "5.5.3"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@changesets/cli": "2.28.1",
|
|
@@ -91,18 +91,18 @@
|
|
|
91
91
|
"tsup": "^8.4.0",
|
|
92
92
|
"typescript": "^5.8.2",
|
|
93
93
|
"@utils/eslint-config": "1.0.4",
|
|
94
|
-
"@
|
|
94
|
+
"@intlayer/backend": "5.5.3",
|
|
95
95
|
"@utils/ts-config-types": "1.0.4",
|
|
96
96
|
"@utils/tsup-config": "1.0.4",
|
|
97
|
-
"@
|
|
97
|
+
"@utils/ts-config": "1.0.4"
|
|
98
98
|
},
|
|
99
99
|
"peerDependencies": {
|
|
100
100
|
"fast-glob": "^3.3.3",
|
|
101
101
|
"react": ">=16.0.0",
|
|
102
|
-
"@intlayer/core": "5.5.
|
|
103
|
-
"@intlayer/
|
|
104
|
-
"@intlayer/
|
|
105
|
-
"intlayer": "5.5.
|
|
102
|
+
"@intlayer/core": "5.5.3",
|
|
103
|
+
"@intlayer/config": "5.5.3",
|
|
104
|
+
"@intlayer/api": "5.5.3",
|
|
105
|
+
"intlayer": "5.5.3"
|
|
106
106
|
},
|
|
107
107
|
"engines": {
|
|
108
108
|
"node": ">=14.18"
|