@intlayer/chokidar 6.0.0-canary.2 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/chokidar/watcher.cjs +4 -4
- package/dist/cjs/chokidar/watcher.cjs.map +1 -1
- package/dist/cjs/fetchDistantDictionaries.cjs +3 -25
- package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
- package/dist/cjs/index.cjs +2 -5
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +1 -1
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs +19 -21
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +13 -4
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/log.cjs +47 -12
- package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
- package/dist/cjs/prepareIntlayer.cjs +52 -9
- package/dist/cjs/prepareIntlayer.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs +5 -1
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs +3 -1
- package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs.map +1 -1
- package/dist/cjs/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/buildIntlayerDictionary.cjs +3 -3
- package/dist/cjs/transpiler/intlayer_dictionary/buildIntlayerDictionary.cjs.map +1 -0
- package/dist/cjs/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/index.cjs +3 -3
- package/dist/cjs/transpiler/intlayer_dictionary/index.cjs.map +1 -0
- package/dist/cjs/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/processContentDeclaration.cjs +1 -1
- package/dist/cjs/transpiler/intlayer_dictionary/processContentDeclaration.cjs.map +1 -0
- package/dist/cjs/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeDynamicDictionary.cjs +19 -10
- package/dist/cjs/transpiler/intlayer_dictionary/writeDynamicDictionary.cjs.map +1 -0
- package/dist/cjs/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeFetchDictionary.cjs +9 -3
- package/dist/cjs/transpiler/intlayer_dictionary/writeFetchDictionary.cjs.map +1 -0
- package/dist/cjs/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeMergedDictionary.cjs +12 -8
- package/dist/cjs/transpiler/intlayer_dictionary/writeMergedDictionary.cjs.map +1 -0
- package/dist/cjs/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeRemoteDictionary.cjs +9 -7
- package/dist/cjs/transpiler/intlayer_dictionary/writeRemoteDictionary.cjs.map +1 -0
- package/dist/cjs/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeUnmergedDictionary.cjs +12 -8
- package/dist/cjs/transpiler/intlayer_dictionary/writeUnmergedDictionary.cjs.map +1 -0
- package/dist/cjs/writeConfiguration/index.cjs +5 -6
- package/dist/cjs/writeConfiguration/index.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +1 -5
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
- package/dist/cjs/writeFileIfChanged.cjs +46 -0
- package/dist/cjs/writeFileIfChanged.cjs.map +1 -0
- package/dist/cjs/{transpiler/declaration_file_to_dictionary/i18next_dictionary/convertPluralsValues.cjs → writeJsonIfChanged.cjs} +11 -14
- package/dist/cjs/writeJsonIfChanged.cjs.map +1 -0
- package/dist/esm/chokidar/watcher.mjs +1 -1
- package/dist/esm/chokidar/watcher.mjs.map +1 -1
- package/dist/esm/fetchDistantDictionaries.mjs +5 -32
- package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -3
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +1 -1
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadDictionaries.mjs +19 -21
- package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +14 -5
- package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/log.mjs +50 -13
- package/dist/esm/loadDictionaries/log.mjs.map +1 -1
- package/dist/esm/prepareIntlayer.mjs +53 -8
- package/dist/esm/prepareIntlayer.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs +6 -2
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs +4 -2
- package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs.map +1 -1
- package/dist/esm/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/buildIntlayerDictionary.mjs +2 -2
- package/dist/esm/transpiler/intlayer_dictionary/buildIntlayerDictionary.mjs.map +1 -0
- package/dist/esm/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/index.mjs +1 -1
- package/dist/esm/transpiler/intlayer_dictionary/index.mjs.map +1 -0
- package/dist/esm/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/processContentDeclaration.mjs +1 -1
- package/dist/esm/transpiler/intlayer_dictionary/processContentDeclaration.mjs.map +1 -0
- package/dist/esm/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeDynamicDictionary.mjs +25 -12
- package/dist/esm/transpiler/intlayer_dictionary/writeDynamicDictionary.mjs.map +1 -0
- package/dist/esm/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeFetchDictionary.mjs +15 -5
- package/dist/esm/transpiler/intlayer_dictionary/writeFetchDictionary.mjs.map +1 -0
- package/dist/esm/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeMergedDictionary.mjs +14 -10
- package/dist/esm/transpiler/intlayer_dictionary/writeMergedDictionary.mjs.map +1 -0
- package/dist/esm/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeRemoteDictionary.mjs +11 -9
- package/dist/esm/transpiler/intlayer_dictionary/writeRemoteDictionary.mjs.map +1 -0
- package/dist/esm/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeUnmergedDictionary.mjs +14 -10
- package/dist/esm/transpiler/intlayer_dictionary/writeUnmergedDictionary.mjs.map +1 -0
- package/dist/esm/writeConfiguration/index.mjs +5 -6
- package/dist/esm/writeConfiguration/index.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +1 -5
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
- package/dist/esm/writeFileIfChanged.mjs +22 -0
- package/dist/esm/writeFileIfChanged.mjs.map +1 -0
- package/dist/esm/writeJsonIfChanged.mjs +10 -0
- package/dist/esm/writeJsonIfChanged.mjs.map +1 -0
- package/dist/types/fetchDistantDictionaries.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadDictionaries.d.ts +4 -0
- package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +5 -1
- package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -1
- package/dist/types/loadDictionaries/log.d.ts +7 -0
- package/dist/types/loadDictionaries/log.d.ts.map +1 -1
- package/dist/types/prepareIntlayer.d.ts.map +1 -1
- package/dist/types/transpiler/dictionary_to_main/createDictionaryEntryPoint.d.ts.map +1 -1
- package/dist/types/transpiler/dictionary_to_type/createModuleAugmentation.d.ts.map +1 -1
- package/dist/types/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/buildIntlayerDictionary.d.ts +1 -1
- package/dist/types/transpiler/intlayer_dictionary/buildIntlayerDictionary.d.ts.map +1 -0
- package/dist/types/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/index.d.ts +1 -1
- package/dist/types/transpiler/intlayer_dictionary/index.d.ts.map +1 -0
- package/dist/types/transpiler/intlayer_dictionary/processContentDeclaration.d.ts.map +1 -0
- package/dist/types/transpiler/intlayer_dictionary/writeDynamicDictionary.d.ts.map +1 -0
- package/dist/types/transpiler/intlayer_dictionary/writeFetchDictionary.d.ts.map +1 -0
- package/dist/types/transpiler/intlayer_dictionary/writeMergedDictionary.d.ts.map +1 -0
- package/dist/types/transpiler/intlayer_dictionary/writeRemoteDictionary.d.ts.map +1 -0
- package/dist/types/transpiler/intlayer_dictionary/writeUnmergedDictionary.d.ts.map +1 -0
- package/dist/types/writeConfiguration/index.d.ts +1 -1
- package/dist/types/writeConfiguration/index.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -1
- package/dist/types/writeFileIfChanged.d.ts +4 -0
- package/dist/types/writeFileIfChanged.d.ts.map +1 -0
- package/dist/types/writeJsonIfChanged.d.ts +4 -0
- package/dist/types/writeJsonIfChanged.d.ts.map +1 -0
- package/package.json +16 -16
- package/dist/cjs/fetchDistantDictionaryKeysAndUpdateTimestamp.cjs +0 -45
- package/dist/cjs/fetchDistantDictionaryKeysAndUpdateTimestamp.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.cjs +0 -46
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.cjs +0 -103
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertPluralsValues.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/index.cjs +0 -23
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/index.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.cjs +0 -51
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/index.cjs +0 -40
- package/dist/cjs/transpiler/declaration_file_to_dictionary/index.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.cjs +0 -30
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/index.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeFetchDictionary.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeRemoteDictionary.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.cjs +0 -52
- package/dist/cjs/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.cjs.map +0 -1
- package/dist/esm/fetchDistantDictionaryKeysAndUpdateTimestamp.mjs +0 -21
- package/dist/esm/fetchDistantDictionaryKeysAndUpdateTimestamp.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.mjs +0 -24
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.mjs +0 -81
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertPluralsValues.mjs +0 -13
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertPluralsValues.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/index.mjs +0 -2
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/index.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.mjs +0 -27
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/index.mjs +0 -16
- package/dist/esm/transpiler/declaration_file_to_dictionary/index.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.mjs +0 -6
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/index.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeFetchDictionary.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeRemoteDictionary.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.mjs +0 -28
- package/dist/esm/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.mjs.map +0 -1
- package/dist/types/fetchDistantDictionaryKeysAndUpdateTimestamp.d.ts +0 -3
- package/dist/types/fetchDistantDictionaryKeysAndUpdateTimestamp.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.d.ts +0 -6
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.d.ts +0 -7
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertPluralsValues.d.ts +0 -2
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertPluralsValues.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/index.d.ts +0 -2
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/index.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.d.ts +0 -7
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/index.d.ts +0 -8
- package/dist/types/transpiler/declaration_file_to_dictionary/index.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.d.ts +0 -2
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/index.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeFetchDictionary.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeRemoteDictionary.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.d.ts +0 -7
- package/dist/types/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.d.ts.map +0 -1
- /package/dist/types/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/processContentDeclaration.d.ts +0 -0
- /package/dist/types/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeDynamicDictionary.d.ts +0 -0
- /package/dist/types/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeFetchDictionary.d.ts +0 -0
- /package/dist/types/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeMergedDictionary.d.ts +0 -0
- /package/dist/types/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeRemoteDictionary.d.ts +0 -0
- /package/dist/types/transpiler/{declaration_file_to_dictionary/intlayer_dictionary → intlayer_dictionary}/writeUnmergedDictionary.d.ts +0 -0
|
@@ -32,9 +32,9 @@ var import_getBuiltDictionariesPath = require('../getBuiltDictionariesPath.cjs')
|
|
|
32
32
|
var import_listDictionariesPath = require('../listDictionariesPath.cjs');
|
|
33
33
|
var import_loadLocalDictionaries = require('../loadDictionaries/loadLocalDictionaries.cjs');
|
|
34
34
|
var import_prepareIntlayer = require('../prepareIntlayer.cjs');
|
|
35
|
-
var import_declaration_file_to_dictionary = require('../transpiler/declaration_file_to_dictionary/index.cjs');
|
|
36
35
|
var import_createDictionaryEntryPoint = require('../transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs');
|
|
37
36
|
var import_dictionary_to_type = require('../transpiler/dictionary_to_type/index.cjs');
|
|
37
|
+
var import_buildIntlayerDictionary = require('../transpiler/intlayer_dictionary/buildIntlayerDictionary.cjs');
|
|
38
38
|
var import_formatter = require('../utils/formatter.cjs');
|
|
39
39
|
const recentlyAddedFiles = /* @__PURE__ */ new Set();
|
|
40
40
|
const handleAdditionalContentDeclarationFile = async (filePath, configuration) => {
|
|
@@ -44,7 +44,7 @@ const handleAdditionalContentDeclarationFile = async (filePath, configuration) =
|
|
|
44
44
|
isVerbose: true
|
|
45
45
|
});
|
|
46
46
|
const localeDictionaries = await (0, import_loadLocalDictionaries.loadLocalDictionaries)(filePath);
|
|
47
|
-
const dictionariesOutput = await (0,
|
|
47
|
+
const dictionariesOutput = await (0, import_buildIntlayerDictionary.buildDictionary)(localeDictionaries, config);
|
|
48
48
|
const dictionariesPaths = Object.values(
|
|
49
49
|
dictionariesOutput?.mergedDictionaries ?? {}
|
|
50
50
|
).map((dictionary) => dictionary.dictionaryPath);
|
|
@@ -66,7 +66,7 @@ const handleUnlikedContentDeclarationFile = async (filePath, configuration) => {
|
|
|
66
66
|
});
|
|
67
67
|
const files = (0, import_listDictionariesPath.listDictionaries)(configuration);
|
|
68
68
|
const localeDictionaries = await (0, import_loadLocalDictionaries.loadLocalDictionaries)(files);
|
|
69
|
-
const dictionariesOutput = await (0,
|
|
69
|
+
const dictionariesOutput = await (0, import_buildIntlayerDictionary.buildDictionary)(localeDictionaries, config);
|
|
70
70
|
const dictionariesPaths = Object.values(
|
|
71
71
|
dictionariesOutput?.mergedDictionaries ?? {}
|
|
72
72
|
).map((dictionary) => dictionary.dictionaryPath);
|
|
@@ -87,7 +87,7 @@ const handleContentDeclarationFileChange = async (filePath, configuration) => {
|
|
|
87
87
|
isVerbose: true
|
|
88
88
|
});
|
|
89
89
|
const localeDictionaries = await (0, import_loadLocalDictionaries.loadLocalDictionaries)(filePath);
|
|
90
|
-
const dictionariesOutput = await (0,
|
|
90
|
+
const dictionariesOutput = await (0, import_buildIntlayerDictionary.buildDictionary)(localeDictionaries, config);
|
|
91
91
|
const updatedDictionariesPaths = Object.values(
|
|
92
92
|
dictionariesOutput?.mergedDictionaries ?? {}
|
|
93
93
|
).map((dictionary) => dictionary.dictionaryPath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import {\n GetConfigurationOptions,\n type IntlayerConfig,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport { basename } from 'path';\n/** @ts-ignore remove error Module '\"chokidar\"' has no exported member 'ChokidarOptions' */\nimport { type ChokidarOptions, watch as chokidarWatch } from 'chokidar';\nimport { getBuiltDictionariesPath } from '../getBuiltDictionariesPath';\nimport { listDictionaries } from '../listDictionariesPath';\nimport { loadLocalDictionaries } from '../loadDictionaries/loadLocalDictionaries';\nimport { prepareIntlayer } from '../prepareIntlayer';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import {\n GetConfigurationOptions,\n type IntlayerConfig,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport { basename } from 'path';\n/** @ts-ignore remove error Module '\"chokidar\"' has no exported member 'ChokidarOptions' */\nimport { type ChokidarOptions, watch as chokidarWatch } from 'chokidar';\nimport { getBuiltDictionariesPath } from '../getBuiltDictionariesPath';\nimport { listDictionaries } from '../listDictionariesPath';\nimport { loadLocalDictionaries } from '../loadDictionaries/loadLocalDictionaries';\nimport { prepareIntlayer } from '../prepareIntlayer';\nimport { createDictionaryEntryPoint } from '../transpiler/dictionary_to_main/createDictionaryEntryPoint';\nimport {\n createModuleAugmentation,\n createTypes,\n} from '../transpiler/dictionary_to_type/index';\nimport { buildDictionary } from '../transpiler/intlayer_dictionary/buildIntlayerDictionary';\nimport { formatPath } from '../utils/formatter';\n\nconst recentlyAddedFiles = new Set<string>();\n\nexport const handleAdditionalContentDeclarationFile = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const config = configuration ?? getConfiguration();\n const appLogger = getAppLogger(config);\n\n // Process the file with the functionToRun\n appLogger(`Additional file detected: ${formatPath(filePath)}`, {\n isVerbose: true,\n });\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n\n const dictionariesOutput = await buildDictionary(localeDictionaries, config);\n\n const dictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n await createTypes(dictionariesPaths);\n\n await createDictionaryEntryPoint();\n\n appLogger('Dictionaries built', {\n isVerbose: true,\n });\n\n createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n};\n\nexport const handleUnlikedContentDeclarationFile = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const config = configuration ?? getConfiguration();\n const appLogger = getAppLogger(config);\n\n // Process the file with the functionToRun\n appLogger(`Unlinked detected: ${formatPath(filePath)}`, {\n isVerbose: true,\n });\n\n const files: string[] = listDictionaries(configuration);\n\n const localeDictionaries = await loadLocalDictionaries(files);\n\n const dictionariesOutput = await buildDictionary(localeDictionaries, config);\n\n const dictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n await createTypes(dictionariesPaths);\n\n await createDictionaryEntryPoint();\n\n appLogger('Dictionaries rebuilt', {\n isVerbose: true,\n });\n\n await createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n};\n\nexport const handleContentDeclarationFileChange = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const config = configuration ?? getConfiguration();\n const appLogger = getAppLogger(config);\n\n // Process the file with the functionToRun\n appLogger(`Change detected: ${formatPath(filePath)}`, {\n isVerbose: true,\n });\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n\n const dictionariesOutput = await buildDictionary(localeDictionaries, config);\n const updatedDictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n const allDictionariesPaths: string[] = getBuiltDictionariesPath();\n\n createTypes(updatedDictionariesPaths);\n appLogger('TypeScript types built', {\n isVerbose: true,\n });\n\n if (\n updatedDictionariesPaths.some(\n (updatedDictionaryPath) =>\n !allDictionariesPaths.includes(updatedDictionaryPath)\n )\n ) {\n await createDictionaryEntryPoint();\n\n appLogger('Dictionary list built', {\n isVerbose: true,\n });\n }\n};\n\ntype WatchOptions = ChokidarOptions & {\n configuration?: IntlayerConfig;\n configOptions?: GetConfigurationOptions;\n};\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const configuration = options?.configuration ?? getConfiguration();\n const appLogger = getAppLogger(configuration);\n\n const { watch: isWatchMode, watchedFilesPatternWithPath } =\n configuration.content;\n\n /** @ts-ignore remove error Expected 0-1 arguments, but got 2. */\n return chokidarWatch(watchedFilesPatternWithPath, {\n persistent: isWatchMode, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n ...options,\n })\n .on('add', async (filePath) => {\n const fileName = basename(filePath);\n recentlyAddedFiles.add(fileName);\n\n await handleAdditionalContentDeclarationFile(filePath, configuration);\n\n setTimeout(() => recentlyAddedFiles.delete(fileName), 1000); // Allow time for unlink to trigger if it's a move\n })\n .on(\n 'change',\n async (filePath) =>\n await handleContentDeclarationFileChange(filePath, configuration)\n )\n .on('unlink', async (filePath) => {\n setTimeout(async () => {\n const fileName = basename(filePath);\n\n if (recentlyAddedFiles.has(fileName)) {\n // The file was moved, so ignore unlink\n return;\n }\n\n await handleUnlikedContentDeclarationFile(filePath, configuration);\n }, 300); // Allow time for unlink to trigger if it's a move\n })\n .on('error', async (error) => {\n appLogger('Watcher error: ' + error, {\n level: 'error',\n });\n\n appLogger('Restarting watcher');\n\n await prepareIntlayer(configuration);\n });\n};\n\nexport const buildAndWatchIntlayer = async (options?: WatchOptions) => {\n const configuration =\n options?.configuration ?? getConfiguration(options?.configOptions);\n\n await prepareIntlayer(configuration);\n\n if (configuration.content.watch || options.persistent) {\n // Start watching (assuming watch is also async)\n watch({ ...options, configuration });\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKO;AACP,kBAAyB;AAEzB,sBAA6D;AAC7D,sCAAyC;AACzC,kCAAiC;AACjC,mCAAsC;AACtC,6BAAgC;AAChC,wCAA2C;AAC3C,gCAGO;AACP,qCAAgC;AAChC,uBAA2B;AAE3B,MAAM,qBAAqB,oBAAI,IAAY;AAEpC,MAAM,yCAAyC,OACpD,UACA,kBACG;AACH,QAAM,SAAS,qBAAiB,gCAAiB;AACjD,QAAM,gBAAY,4BAAa,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AM,oCAAoC,UAAU,aAAa;AAAA,IACnE,GAAG,GAAG;AAAA,EACR,CAAC,EACA,GAAG,SAAS,OAAO,UAAU;AAC5B,cAAU,oBAAoB,OAAO;AAAA,MACnC,OAAO;AAAA,IACT,CAAC;AAED,cAAU,oBAAoB;AAE9B,cAAM,wCAAgB,aAAa;AAAA,EACrC,CAAC;AACL;AAEO,MAAM,wBAAwB,OAAO,YAA2B;AACrE,QAAM,gBACJ,SAAS,qBAAiB,gCAAiB,SAAS,aAAa;AAEnE,YAAM,wCAAgB,aAAa;AAEnC,MAAI,cAAc,QAAQ,SAAS,QAAQ,YAAY;AAErD,UAAM,EAAE,GAAG,SAAS,cAAc,CAAC;AAAA,EACrC;AACF;","names":["chokidarWatch"]}
|
|
@@ -28,16 +28,7 @@ const fetchDistantDictionaries = async (options, onStatusUpdate) => {
|
|
|
28
28
|
const config = (0, import_config.getConfiguration)();
|
|
29
29
|
const appLogger = (0, import_config.getAppLogger)(config);
|
|
30
30
|
try {
|
|
31
|
-
const
|
|
32
|
-
const authAPI = (0, import_api.getOAuthAPI)(config);
|
|
33
|
-
const dictionaryAPI = (0, import_api.getDictionaryAPI)(void 0, config);
|
|
34
|
-
if (!clientId || !clientSecret) {
|
|
35
|
-
throw new Error(
|
|
36
|
-
"Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project."
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
const oAuth2TokenResult = await authAPI.getOAuth2AccessToken();
|
|
40
|
-
const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;
|
|
31
|
+
const intlayerAPI = (0, import_api.getIntlayerAPIProxy)(void 0, config);
|
|
41
32
|
const distantDictionariesKeys = options.dictionaryKeys;
|
|
42
33
|
const processDictionary = async (dictionaryKey) => {
|
|
43
34
|
onStatusUpdate?.([
|
|
@@ -48,17 +39,7 @@ const fetchDistantDictionaries = async (options, onStatusUpdate) => {
|
|
|
48
39
|
}
|
|
49
40
|
]);
|
|
50
41
|
try {
|
|
51
|
-
const getDictionaryResult = await
|
|
52
|
-
dictionaryKey,
|
|
53
|
-
void 0,
|
|
54
|
-
{
|
|
55
|
-
...oAuth2AccessToken && {
|
|
56
|
-
headers: {
|
|
57
|
-
Authorization: `Bearer ${oAuth2AccessToken}`
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
);
|
|
42
|
+
const getDictionaryResult = await intlayerAPI.dictionary.getDictionary(dictionaryKey);
|
|
62
43
|
const distantDictionary = getDictionaryResult.data;
|
|
63
44
|
if (!distantDictionary) {
|
|
64
45
|
throw new Error(`Dictionary ${dictionaryKey} not found on remote`);
|
|
@@ -88,10 +69,7 @@ const fetchDistantDictionaries = async (options, onStatusUpdate) => {
|
|
|
88
69
|
);
|
|
89
70
|
return filteredResult;
|
|
90
71
|
} catch (error) {
|
|
91
|
-
appLogger(
|
|
92
|
-
`${(0, import_config.colorize)("\u2717", import_config.ANSIColors.RED)} Failed to fetch distant dictionaries`,
|
|
93
|
-
{ level: "error" }
|
|
94
|
-
);
|
|
72
|
+
appLogger(`${import_config.x} Failed to fetch distant dictionaries`, { level: "error" });
|
|
95
73
|
return [];
|
|
96
74
|
}
|
|
97
75
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fetchDistantDictionaries.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/fetchDistantDictionaries.ts"],"sourcesContent":["import { getIntlayerAPIProxy } from '@intlayer/api';\n// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getAppLogger, getConfiguration, x } from '@intlayer/config';\nimport { DictionariesStatus } from './loadDictionaries';\nimport { parallelize } from './utils/parallelize';\n\ntype FetchDistantDictionariesOptions = {\n dictionaryKeys: string[];\n newDictionariesPath?: string;\n logPrefix?: string;\n};\n\n/**\n * Fetch distant dictionaries and update the logger with their statuses.\n */\nexport const fetchDistantDictionaries = async (\n options: FetchDistantDictionariesOptions,\n onStatusUpdate?: (status: DictionariesStatus[]) => void\n): Promise<DictionaryAPI[]> => {\n const config = getConfiguration();\n const appLogger = getAppLogger(config);\n try {\n const intlayerAPI = getIntlayerAPIProxy(undefined, config);\n\n const distantDictionariesKeys = options.dictionaryKeys;\n // Process dictionaries in parallel with a concurrency limit\n const processDictionary = async (\n dictionaryKey: string\n ): Promise<DictionaryAPI | undefined> => {\n onStatusUpdate?.([\n {\n dictionaryKey,\n type: 'remote',\n status: 'fetching',\n },\n ]);\n\n try {\n // Fetch the dictionary\n const getDictionaryResult =\n await intlayerAPI.dictionary.getDictionary(dictionaryKey);\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(`Dictionary ${dictionaryKey} not found on remote`);\n }\n\n onStatusUpdate?.([\n { dictionaryKey, type: 'remote', status: 'fetched' },\n ]);\n\n return distantDictionary;\n } catch (error) {\n onStatusUpdate?.([\n {\n dictionaryKey,\n type: 'remote',\n status: 'error',\n error: `Error fetching dictionary ${dictionaryKey}: ${error}`,\n },\n ]);\n return undefined;\n }\n };\n\n const result = await parallelize(\n distantDictionariesKeys,\n async (dictionaryKey) => await processDictionary(dictionaryKey)\n );\n\n // Remove undefined values\n const filteredResult = result.filter(\n (dict: DictionaryAPI | undefined): dict is DictionaryAPI =>\n dict !== undefined\n );\n\n return filteredResult;\n } catch (error) {\n appLogger(`${x} Failed to fetch distant dictionaries`, { level: 'error' });\n return [];\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAoC;AAGpC,oBAAkD;AAElD,yBAA4B;AAWrB,MAAM,2BAA2B,OACtC,SACA,mBAC6B;AAC7B,QAAM,aAAS,gCAAiB;AAChC,QAAM,gBAAY,4BAAa,MAAM;AACrC,MAAI;AACF,UAAM,kBAAc,gCAAoB,QAAW,MAAM;AAEzD,UAAM,0BAA0B,QAAQ;AAExC,UAAM,oBAAoB,OACxB,kBACuC;AACvC,uBAAiB;AAAA,QACf;AAAA,UACE;AAAA,UACA,MAAM;AAAA,UACN,QAAQ;AAAA,QACV;AAAA,MACF,CAAC;AAED,UAAI;AAEF,cAAM,sBACJ,MAAM,YAAY,WAAW,cAAc,aAAa;AAE1D,cAAM,oBAAoB,oBAAoB;AAE9C,YAAI,CAAC,mBAAmB;AACtB,gBAAM,IAAI,MAAM,cAAc,aAAa,sBAAsB;AAAA,QACnE;AAEA,yBAAiB;AAAA,UACf,EAAE,eAAe,MAAM,UAAU,QAAQ,UAAU;AAAA,QACrD,CAAC;AAED,eAAO;AAAA,MACT,SAAS,OAAO;AACd,yBAAiB;AAAA,UACf;AAAA,YACE;AAAA,YACA,MAAM;AAAA,YACN,QAAQ;AAAA,YACR,OAAO,6BAA6B,aAAa,KAAK,KAAK;AAAA,UAC7D;AAAA,QACF,CAAC;AACD,eAAO;AAAA,MACT;AAAA,IACF;AAEA,UAAM,SAAS,UAAM;AAAA,MACnB;AAAA,MACA,OAAO,kBAAkB,MAAM,kBAAkB,aAAa;AAAA,IAChE;AAGA,UAAM,iBAAiB,OAAO;AAAA,MAC5B,CAAC,SACC,SAAS;AAAA,IACb;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,cAAU,GAAG,eAAC,yCAAyC,EAAE,OAAO,QAAQ,CAAC;AACzE,WAAO,CAAC;AAAA,EACV;AACF;","names":[]}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -19,12 +19,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var index_exports = {};
|
|
20
20
|
__export(index_exports, {
|
|
21
21
|
buildAndWatchIntlayer: () => import_watcher.buildAndWatchIntlayer,
|
|
22
|
-
buildDictionary: () =>
|
|
22
|
+
buildDictionary: () => import_buildIntlayerDictionary.buildDictionary,
|
|
23
23
|
cleanOutputDir: () => import_cleanOutputDir.cleanOutputDir,
|
|
24
24
|
createDictionaryEntryPoint: () => import_dictionary_to_main.createDictionaryEntryPoint,
|
|
25
25
|
createModuleAugmentation: () => import_createModuleAugmentation.createModuleAugmentation,
|
|
26
26
|
fetchDistantDictionaries: () => import_fetchDistantDictionaries.fetchDistantDictionaries,
|
|
27
|
-
fetchDistantDictionaryKeysAndUpdateTimestamp: () => import_fetchDistantDictionaryKeysAndUpdateTimestamp.fetchDistantDictionaryKeysAndUpdateTimestamp,
|
|
28
27
|
formatLocale: () => import_formatter.formatLocale,
|
|
29
28
|
formatPath: () => import_formatter.formatPath,
|
|
30
29
|
generateDictionaryListContent: () => import_dictionary_to_main.generateDictionaryListContent,
|
|
@@ -56,7 +55,6 @@ module.exports = __toCommonJS(index_exports);
|
|
|
56
55
|
var import_watcher = require('./chokidar/watcher.cjs');
|
|
57
56
|
var import_cleanOutputDir = require('./cleanOutputDir.cjs');
|
|
58
57
|
var import_fetchDistantDictionaries = require('./fetchDistantDictionaries.cjs');
|
|
59
|
-
var import_fetchDistantDictionaryKeysAndUpdateTimestamp = require('./fetchDistantDictionaryKeysAndUpdateTimestamp.cjs');
|
|
60
58
|
var import_getBuiltDictionariesPath = require('./getBuiltDictionariesPath.cjs');
|
|
61
59
|
var import_getBuiltUnmergedDictionariesPath = require('./getBuiltUnmergedDictionariesPath.cjs');
|
|
62
60
|
var import_listDictionariesPath = require('./listDictionariesPath.cjs');
|
|
@@ -67,9 +65,9 @@ var import_prepareContentDeclaration = require('./prepareContentDeclaration.cjs'
|
|
|
67
65
|
var import_prepareIntlayer = require('./prepareIntlayer.cjs');
|
|
68
66
|
var import_processPerLocaleDictionary = require('./processPerLocaleDictionary.cjs');
|
|
69
67
|
var import_reduceDictionaryContent = require('./reduceDictionaryContent/reduceDictionaryContent.cjs');
|
|
70
|
-
var import_declaration_file_to_dictionary = require('./transpiler/declaration_file_to_dictionary/index.cjs');
|
|
71
68
|
var import_dictionary_to_main = require('./transpiler/dictionary_to_main/index.cjs');
|
|
72
69
|
var import_createModuleAugmentation = require('./transpiler/dictionary_to_type/createModuleAugmentation.cjs');
|
|
70
|
+
var import_buildIntlayerDictionary = require('./transpiler/intlayer_dictionary/buildIntlayerDictionary.cjs');
|
|
73
71
|
var import_formatter = require('./utils/formatter.cjs');
|
|
74
72
|
var import_getFileHash = require('./utils/getFileHash.cjs');
|
|
75
73
|
var import_kebabCaseToCamelCase = require('./utils/kebabCaseToCamelCase.cjs');
|
|
@@ -86,7 +84,6 @@ var import_writeContentDeclaration = require('./writeContentDeclaration/index.cj
|
|
|
86
84
|
createDictionaryEntryPoint,
|
|
87
85
|
createModuleAugmentation,
|
|
88
86
|
fetchDistantDictionaries,
|
|
89
|
-
fetchDistantDictionaryKeysAndUpdateTimestamp,
|
|
90
87
|
formatLocale,
|
|
91
88
|
formatPath,
|
|
92
89
|
generateDictionaryListContent,
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n buildAndWatchIntlayer,\n handleAdditionalContentDeclarationFile,\n handleContentDeclarationFileChange,\n watch,\n} from './chokidar/watcher';\nexport { cleanOutputDir } from './cleanOutputDir';\nexport { fetchDistantDictionaries } from './fetchDistantDictionaries';\nexport {
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n buildAndWatchIntlayer,\n handleAdditionalContentDeclarationFile,\n handleContentDeclarationFileChange,\n watch,\n} from './chokidar/watcher';\nexport { cleanOutputDir } from './cleanOutputDir';\nexport { fetchDistantDictionaries } from './fetchDistantDictionaries';\nexport { getBuiltDictionariesPath } from './getBuiltDictionariesPath';\nexport { getBuiltUnmergedDictionariesPath } from './getBuiltUnmergedDictionariesPath';\nexport { listDictionaries } from './listDictionariesPath';\nexport {\n listGitFiles,\n listGitLines,\n type DiffMode,\n type ListGitFilesOptions,\n type ListGitLinesOptions,\n} from './listGitFiles';\nexport {\n loadDictionaries,\n loadLocalDictionaries,\n loadRemoteDictionaries,\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 {\n createDictionaryEntryPoint,\n generateDictionaryListContent,\n} from './transpiler/dictionary_to_main';\nexport { createModuleAugmentation } from './transpiler/dictionary_to_type/createModuleAugmentation';\nexport { buildDictionary } from './transpiler/intlayer_dictionary/buildIntlayerDictionary';\nexport { formatLocale, formatPath } from './utils/formatter';\nexport { getFileHash } from './utils/getFileHash';\nexport { kebabCaseToCamelCase } from './utils/kebabCaseToCamelCase';\nexport { parallelize } from './utils/parallelize';\nexport { resolveObjectPromises } from './utils/resolveObjectPromises';\nexport { runOnce } from './utils/runOnce';\nexport { sortAlphabetically } from './utils/sortAlphabetically';\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;AAAA;AAAA;AAAA;AAAA;AAAA,qBAKO;AACP,4BAA+B;AAC/B,sCAAyC;AACzC,sCAAyC;AACzC,8CAAiD;AACjD,kCAAiC;AACjC,0BAMO;AACP,8BAIO;AACP,+BAAkC;AAClC,uCAA0C;AAC1C,6BAAgC;AAChC,wCAA2C;AAC3C,qCAAwC;AACxC,gCAGO;AACP,sCAAyC;AACzC,qCAAgC;AAChC,uBAAyC;AACzC,yBAA4B;AAC5B,kCAAqC;AACrC,yBAA4B;AAC5B,mCAAsC;AACtC,qBAAwB;AACxB,gCAAmC;AACnC,qCAGO;","names":[]}
|
|
@@ -25,7 +25,7 @@ module.exports = __toCommonJS(loadContentDeclaration_exports);
|
|
|
25
25
|
var import_config = require("@intlayer/config");
|
|
26
26
|
var import_path = require("path");
|
|
27
27
|
var import_filterInvalidDictionaries = require('../filterInvalidDictionaries.cjs');
|
|
28
|
-
var import_processContentDeclaration = require('../transpiler/
|
|
28
|
+
var import_processContentDeclaration = require('../transpiler/intlayer_dictionary/processContentDeclaration.cjs');
|
|
29
29
|
var import_parallelize = require('../utils/parallelize.cjs');
|
|
30
30
|
const formatLocalDictionaries = (dictionariesRecord) => Object.entries(dictionariesRecord).map(([relativePath, dict]) => ({
|
|
31
31
|
...dict,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"sourcesContent":["import {\n ESMxCJSRequire,\n getConfiguration,\n IntlayerConfig,\n loadExternalFile,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { relative } from 'path';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { processContentDeclaration } from '../transpiler/
|
|
1
|
+
{"version":3,"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"sourcesContent":["import {\n ESMxCJSRequire,\n getConfiguration,\n IntlayerConfig,\n loadExternalFile,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { relative } from 'path';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { processContentDeclaration } from '../transpiler/intlayer_dictionary/processContentDeclaration';\nimport { parallelize } from '../utils/parallelize';\nimport { DictionariesStatus } from './loadDictionaries';\n\nexport const formatLocalDictionaries = (\n dictionariesRecord: Record<string, Dictionary>\n): Dictionary[] =>\n Object.entries(dictionariesRecord).map(([relativePath, dict]) => ({\n ...dict,\n localId: `${dict.key}::local::${relativePath}`,\n location: 'locale' as const,\n filePath: relativePath,\n }));\n\nexport const loadContentDeclarations = async (\n contentDeclarationFilePath: string[],\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire,\n onStatusUpdate?: (status: DictionariesStatus[]) => void\n): Promise<Dictionary[]> => {\n const dictionariesRecord = contentDeclarationFilePath.reduce(\n (acc, path) => {\n const relativePath = relative(configuration.content.baseDir, path);\n return {\n ...acc,\n [relativePath]: loadExternalFile(path, undefined, projectRequire),\n };\n },\n {} as Record<string, Dictionary>\n );\n const contentDeclarations: Dictionary[] =\n formatLocalDictionaries(dictionariesRecord);\n\n const listFoundDictionaries = contentDeclarations.map((declaration) => ({\n dictionaryKey: declaration.key,\n type: 'local' as const,\n status: 'found' as const,\n }));\n\n onStatusUpdate?.(listFoundDictionaries);\n\n const processedDictionaries = await parallelize(\n contentDeclarations,\n async (contentDeclaration): Promise<Dictionary | undefined> => {\n if (!contentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: contentDeclaration.key,\n type: 'local',\n status: 'building',\n },\n ]);\n\n const processedContentDeclaration = await processContentDeclaration(\n contentDeclaration as Dictionary\n );\n\n if (!processedContentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: processedContentDeclaration.key,\n type: 'local',\n status: 'built',\n },\n ]);\n\n return processedContentDeclaration;\n }\n );\n\n return filterInvalidDictionaries(processedDictionaries);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKO;AAEP,kBAAyB;AACzB,uCAA0C;AAC1C,uCAA0C;AAC1C,yBAA4B;AAGrB,MAAM,0BAA0B,CACrC,uBAEA,OAAO,QAAQ,kBAAkB,EAAE,IAAI,CAAC,CAAC,cAAc,IAAI,OAAO;AAAA,EAChE,GAAG;AAAA,EACH,SAAS,GAAG,KAAK,GAAG,YAAY,YAAY;AAAA,EAC5C,UAAU;AAAA,EACV,UAAU;AACZ,EAAE;AAEG,MAAM,0BAA0B,OACrC,4BACA,oBAAgC,gCAAiB,GACjD,iBAAiB,8BACjB,mBAC0B;AAC1B,QAAM,qBAAqB,2BAA2B;AAAA,IACpD,CAAC,KAAK,SAAS;AACb,YAAM,mBAAe,sBAAS,cAAc,QAAQ,SAAS,IAAI;AACjE,aAAO;AAAA,QACL,GAAG;AAAA,QACH,CAAC,YAAY,OAAG,gCAAiB,MAAM,QAAW,cAAc;AAAA,MAClE;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AACA,QAAM,sBACJ,wBAAwB,kBAAkB;AAE5C,QAAM,wBAAwB,oBAAoB,IAAI,CAAC,iBAAiB;AAAA,IACtE,eAAe,YAAY;AAAA,IAC3B,MAAM;AAAA,IACN,QAAQ;AAAA,EACV,EAAE;AAEF,mBAAiB,qBAAqB;AAEtC,QAAM,wBAAwB,UAAM;AAAA,IAClC;AAAA,IACA,OAAO,uBAAwD;AAC7D,UAAI,CAAC,oBAAoB;AACvB,eAAO;AAAA,MACT;AAEA,uBAAiB;AAAA,QACf;AAAA,UACE,eAAe,mBAAmB;AAAA,UAClC,MAAM;AAAA,UACN,QAAQ;AAAA,QACV;AAAA,MACF,CAAC;AAED,YAAM,8BAA8B,UAAM;AAAA,QACxC;AAAA,MACF;AAEA,UAAI,CAAC,6BAA6B;AAChC,eAAO;AAAA,MACT;AAEA,uBAAiB;AAAA,QACf;AAAA,UACE,eAAe,4BAA4B;AAAA,UAC3C,MAAM;AAAA,UACN,QAAQ;AAAA,QACV;AAAA,MACF,CAAC;AAED,aAAO;AAAA,IACT;AAAA,EACF;AAEA,aAAO,4DAA0B,qBAAqB;AACxD;","names":[]}
|
|
@@ -22,7 +22,7 @@ __export(loadDictionaries_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(loadDictionaries_exports);
|
|
24
24
|
var import_config = require("@intlayer/config");
|
|
25
|
-
var
|
|
25
|
+
var import_filterInvalidDictionaries = require('../filterInvalidDictionaries.cjs');
|
|
26
26
|
var import_loadContentDeclaration = require('./loadContentDeclaration.cjs');
|
|
27
27
|
var import_loadRemoteDictionaries = require('./loadRemoteDictionaries.cjs');
|
|
28
28
|
var import_log = require('./log.cjs');
|
|
@@ -119,6 +119,7 @@ const printSummary = (configuration = (0, import_config.getConfiguration)()) =>
|
|
|
119
119
|
}
|
|
120
120
|
};
|
|
121
121
|
const loadDictionaries = async (contentDeclarationsPaths, configuration = (0, import_config.getConfiguration)(), projectRequire = import_config.ESMxCJSRequire) => {
|
|
122
|
+
const loadDictionariesStartTime = Date.now();
|
|
122
123
|
const appLogger = (0, import_config.getAppLogger)(configuration);
|
|
123
124
|
appLogger("Dictionaries:", { isVerbose: true });
|
|
124
125
|
const files = Array.isArray(contentDeclarationsPaths) ? contentDeclarationsPaths : [contentDeclarationsPaths];
|
|
@@ -128,24 +129,8 @@ const loadDictionaries = async (contentDeclarationsPaths, configuration = (0, im
|
|
|
128
129
|
projectRequire,
|
|
129
130
|
setLoadDictionariesStatus
|
|
130
131
|
);
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
const hasContent = Boolean(dict.content);
|
|
134
|
-
if (!hasContent) {
|
|
135
|
-
appLogger(
|
|
136
|
-
[
|
|
137
|
-
"Content declaration has no exported content",
|
|
138
|
-
dict.filePath ? (0, import_node_path.relative)(configuration.content.baseDir, dict.filePath) : ""
|
|
139
|
-
],
|
|
140
|
-
{ level: "error" }
|
|
141
|
-
);
|
|
142
|
-
} else if (!hasKey) {
|
|
143
|
-
appLogger(["Content declaration has no key", dict.filePath], {
|
|
144
|
-
level: "error"
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
return hasKey && hasContent;
|
|
148
|
-
});
|
|
132
|
+
const localDictionariesTime = Date.now();
|
|
133
|
+
const filteredLocalDictionaries = (0, import_filterInvalidDictionaries.filterInvalidDictionaries)(localDictionaries);
|
|
149
134
|
const localDictionariesStatus = filteredLocalDictionaries.map(
|
|
150
135
|
(dict) => ({
|
|
151
136
|
dictionaryKey: dict.key,
|
|
@@ -157,18 +142,31 @@ const loadDictionaries = async (contentDeclarationsPaths, configuration = (0, im
|
|
|
157
142
|
const hasRemoteDictionaries = Boolean(
|
|
158
143
|
configuration.editor.clientId && configuration.editor.clientSecret
|
|
159
144
|
);
|
|
145
|
+
if (hasRemoteDictionaries) {
|
|
146
|
+
logger.setExpectRemote(true);
|
|
147
|
+
}
|
|
160
148
|
let remoteDictionaries = [];
|
|
161
149
|
if (hasRemoteDictionaries) {
|
|
162
150
|
remoteDictionaries = await (0, import_loadRemoteDictionaries.loadRemoteDictionaries)(
|
|
163
151
|
configuration,
|
|
164
|
-
setLoadDictionariesStatus
|
|
152
|
+
setLoadDictionariesStatus,
|
|
153
|
+
{
|
|
154
|
+
onStartRemoteCheck: () => logger.startRemoteCheck(),
|
|
155
|
+
onStopRemoteCheck: () => logger.stopRemoteCheck(),
|
|
156
|
+
onError: () => logger.setRemoteError()
|
|
157
|
+
}
|
|
165
158
|
);
|
|
166
159
|
}
|
|
160
|
+
const remoteDictionariesTime = Date.now();
|
|
167
161
|
logger.finish();
|
|
168
162
|
printSummary(configuration);
|
|
169
163
|
return {
|
|
170
164
|
localDictionaries: filteredLocalDictionaries,
|
|
171
|
-
remoteDictionaries
|
|
165
|
+
remoteDictionaries,
|
|
166
|
+
time: {
|
|
167
|
+
localDictionaries: localDictionariesTime - loadDictionariesStartTime,
|
|
168
|
+
remoteDictionaries: remoteDictionariesTime - localDictionariesTime
|
|
169
|
+
}
|
|
172
170
|
};
|
|
173
171
|
};
|
|
174
172
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n ESMxCJSRequire,\n getAppLogger,\n getConfiguration,\n type IntlayerConfig,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { relative } from 'node:path';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n let updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const idx = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (idx >= 0) {\n updated[idx] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig = getConfiguration()) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const s of loadDictionariesStatus) {\n const rec = byKey.get(s.dictionaryKey) ?? {};\n if (s.type === 'local') rec.local = s.status;\n if (s.type === 'remote') rec.remote = s.status;\n byKey.set(s.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n}> => {\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n projectRequire,\n setLoadDictionariesStatus\n );\n\n const filteredLocalDictionaries = localDictionaries.filter((dict) => {\n const hasKey = Boolean(dict.key);\n const hasContent = Boolean(dict.content);\n\n if (!hasContent) {\n appLogger(\n [\n 'Content declaration has no exported content',\n dict.filePath\n ? relative(configuration.content.baseDir, dict.filePath)\n : '',\n ],\n { level: 'error' }\n );\n } else if (!hasKey) {\n appLogger(['Content declaration has no key', dict.filePath], {\n level: 'error',\n });\n }\n\n return hasKey && hasContent;\n });\n\n const localDictionariesStatus = filteredLocalDictionaries.map(\n (dict) =>\n ({\n dictionaryKey: dict.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n let remoteDictionaries: Dictionary[] = [];\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus\n );\n }\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries: filteredLocalDictionaries,\n remoteDictionaries,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBASO;AAEP,uBAAyB;AACzB,oCAAwC;AACxC,oCAAuC;AACvC,iBAAmC;AAiBnC,IAAI,yBAA+C,CAAC;AACpD,MAAM,SAAS,IAAI,8BAAmB;AAEtC,MAAM,4BAA4B,CAAC,aAAmC;AACpE,MAAI,UAAgC,CAAC,GAAG,sBAAsB;AAE9D,aAAW,YAAY,UAAU;AAC/B,UAAM,MAAM,QAAQ;AAAA,MAClB,CAAC,MACC,EAAE,kBAAkB,SAAS,iBAAiB,EAAE,SAAS,SAAS;AAAA,IACtE;AACA,QAAI,OAAO,GAAG;AACZ,cAAQ,GAAG,IAAI;AAAA,IACjB,OAAO;AACL,cAAQ,KAAK,QAAQ;AAAA,IACvB;AAAA,EACF;AAEA,2BAAyB;AACzB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IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,4BAA4B,kBAAkB,OAAO,CAAC,SAAS;AACnE,UAAM,SAAS,QAAQ,KAAK,GAAG;AAC/B,UAAM,aAAa,QAAQ,KAAK,OAAO;AAEvC,QAAI,CAAC,YAAY;AACf;AAAA,QACE;AAAA,UACE;AAAA,UACA,KAAK,eACD,2BAAS,cAAc,QAAQ,SAAS,KAAK,QAAQ,IACrD;AAAA,QACN;AAAA,QACA,EAAE,OAAO,QAAQ;AAAA,MACnB;AAAA,IACF,WAAW,CAAC,QAAQ;AAClB,gBAAU,CAAC,kCAAkC,KAAK,QAAQ,GAAG;AAAA,QAC3D,OAAO;AAAA,MACT,CAAC;AAAA,IACH;AAEA,WAAO,UAAU;AAAA,EACnB,CAAC;AAED,QAAM,0BAA0B,0BAA0B;AAAA,IACxD,CAAC,UACE;AAAA,MACC,eAAe,KAAK;AAAA,MACpB,MAAM;AAAA,MACN,QAAQ;AAAA,IACV;AAAA,EACJ;AAEA,4BAA0B,uBAAuB;AAEjD,QAAM,wBAAwB;AAAA,IAC5B,cAAc,OAAO,YAAY,cAAc,OAAO;AAAA,EACxD;AAEA,MAAI,qBAAmC,CAAC;AACxC,MAAI,uBAAuB;AACzB,yBAAqB,UAAM;AAAA,MACzB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAGA,SAAO,OAAO;AAEd,eAAa,aAAa;AAE1B,SAAO;AAAA,IACL,mBAAmB;AAAA,IACnB;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n ESMxCJSRequire,\n getAppLogger,\n getConfiguration,\n type IntlayerConfig,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n let updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const idx = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (idx >= 0) {\n updated[idx] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig = getConfiguration()) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const s of loadDictionariesStatus) {\n const rec = byKey.get(s.dictionaryKey) ?? {};\n if (s.type === 'local') rec.local = s.status;\n if (s.type === 'remote') rec.remote = s.status;\n byKey.set(s.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n time: {\n localDictionaries: number;\n remoteDictionaries: number;\n };\n}> => {\n const loadDictionariesStartTime = Date.now();\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n projectRequire,\n setLoadDictionariesStatus\n );\n\n const localDictionariesTime = Date.now();\n\n const filteredLocalDictionaries =\n filterInvalidDictionaries(localDictionaries);\n\n const localDictionariesStatus = filteredLocalDictionaries.map(\n (dict) =>\n ({\n dictionaryKey: dict.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n if (hasRemoteDictionaries) {\n // We expect to fetch remote dictionaries soon; suppress a transient local-only render\n logger.setExpectRemote(true);\n }\n\n let remoteDictionaries: Dictionary[] = [];\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus,\n {\n onStartRemoteCheck: () => logger.startRemoteCheck(),\n onStopRemoteCheck: () => logger.stopRemoteCheck(),\n onError: () => logger.setRemoteError(),\n }\n );\n }\n const remoteDictionariesTime = Date.now();\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries: filteredLocalDictionaries,\n remoteDictionaries,\n time: {\n localDictionaries: localDictionariesTime - loadDictionariesStartTime,\n remoteDictionaries: remoteDictionariesTime - localDictionariesTime,\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBASO;AAEP,uCAA0C;AAC1C,oCAAwC;AACxC,oCAAuC;AACvC,iBAAmC;AAiBnC,IAAI,yBAA+C,CAAC;AACpD,MAAM,SAAS,IAAI,8BAAmB;AAEtC,MAAM,4BAA4B,CAAC,aAAmC;AACpE,MAAI,UAAgC,CAAC,GAAG,sBAAsB;AAE9D,aAAW,YAAY,UAAU;AAC/B,UAAM,MAAM,QAAQ;A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|
});
|
|
34
34
|
module.exports = __toCommonJS(loadRemoteDictionaries_exports);
|
|
35
|
+
var import_api = require("@intlayer/api");
|
|
35
36
|
var import_config = require("@intlayer/config");
|
|
36
37
|
var import_remote_dictionaries_entry = __toESM(require("@intlayer/remote-dictionaries-entry"));
|
|
37
38
|
var import_fetchDistantDictionaries = require('../fetchDistantDictionaries.cjs');
|
|
38
|
-
var import_fetchDistantDictionaryKeysAndUpdateTimestamp = require('../fetchDistantDictionaryKeysAndUpdateTimestamp.cjs');
|
|
39
39
|
var import_sortAlphabetically = require('../utils/sortAlphabetically.cjs');
|
|
40
40
|
const formatDistantDictionaries = (dictionaries) => dictionaries.map((dict) => ({
|
|
41
41
|
...dict,
|
|
42
42
|
localId: `${dict.key}::remote::${dict.id}`,
|
|
43
43
|
location: "distant"
|
|
44
44
|
}));
|
|
45
|
-
const loadRemoteDictionaries = async (configuration = (0, import_config.getConfiguration)(), onStatusUpdate) => {
|
|
45
|
+
const loadRemoteDictionaries = async (configuration = (0, import_config.getConfiguration)(), onStatusUpdate, options) => {
|
|
46
46
|
const appLogger = (0, import_config.getAppLogger)(configuration);
|
|
47
47
|
const { editor } = configuration;
|
|
48
48
|
const hasRemoteDictionaries = Boolean(editor.clientId && editor.clientSecret);
|
|
49
49
|
if (!hasRemoteDictionaries) return [];
|
|
50
50
|
try {
|
|
51
|
-
|
|
51
|
+
options?.onStartRemoteCheck?.();
|
|
52
|
+
const intlayerAPI = (0, import_api.getIntlayerAPIProxy)(void 0, configuration);
|
|
53
|
+
const getDictionariesKeysResult = await intlayerAPI.dictionary.getDictionariesUpdateTimestamp();
|
|
54
|
+
const distantDictionaryUpdateTimeStamp = getDictionariesKeysResult.data;
|
|
55
|
+
if (!distantDictionaryUpdateTimeStamp) {
|
|
56
|
+
throw new Error("No distant dictionaries found");
|
|
57
|
+
}
|
|
52
58
|
const dictionariesKeysToFetch = Object.entries(
|
|
53
59
|
distantDictionaryUpdateTimeStamp
|
|
54
60
|
).filter(([dictionaryKey, remoteUpdatedAt]) => {
|
|
@@ -96,8 +102,11 @@ const loadRemoteDictionaries = async (configuration = (0, import_config.getConfi
|
|
|
96
102
|
);
|
|
97
103
|
return [...cachedDictionaries, ...distantDictionaries];
|
|
98
104
|
} catch (error) {
|
|
99
|
-
|
|
105
|
+
console.error(error);
|
|
106
|
+
options?.onError?.(error);
|
|
100
107
|
return [];
|
|
108
|
+
} finally {
|
|
109
|
+
options?.onStopRemoteCheck?.();
|
|
101
110
|
}
|
|
102
111
|
};
|
|
103
112
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/loadDictionaries/loadRemoteDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getAppLogger, getConfiguration
|
|
1
|
+
{"version":3,"sources":["../../../src/loadDictionaries/loadRemoteDictionaries.ts"],"sourcesContent":["import { getIntlayerAPIProxy } from '@intlayer/api';\n// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getAppLogger, getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport remoteDictionariesRecord from '@intlayer/remote-dictionaries-entry';\nimport { fetchDistantDictionaries } from '../fetchDistantDictionaries';\nimport { DictionariesStatus } from '../loadDictionaries/loadDictionaries';\nimport { sortAlphabetically } from '../utils/sortAlphabetically';\n\nexport const formatDistantDictionaries = (\n dictionaries: DictionaryAPI[]\n): Dictionary[] =>\n dictionaries.map((dict) => ({\n ...dict,\n localId: `${dict.key}::remote::${dict.id}`,\n location: 'distant' as const,\n }));\n\nexport const loadRemoteDictionaries = async (\n configuration = getConfiguration(),\n onStatusUpdate?: (status: DictionariesStatus[]) => void,\n options?: {\n onStartRemoteCheck?: () => void;\n onStopRemoteCheck?: () => void;\n onError?: (error: Error) => void;\n }\n): Promise<DictionaryAPI[]> => {\n const appLogger = getAppLogger(configuration);\n\n const { editor } = configuration;\n\n const hasRemoteDictionaries = Boolean(editor.clientId && editor.clientSecret);\n\n if (!hasRemoteDictionaries) return [];\n\n try {\n options?.onStartRemoteCheck?.();\n\n const intlayerAPI = getIntlayerAPIProxy(undefined, configuration);\n\n // Get the list of dictionary keys\n const getDictionariesKeysResult =\n await intlayerAPI.dictionary.getDictionariesUpdateTimestamp();\n\n const distantDictionaryUpdateTimeStamp = getDictionariesKeysResult.data;\n\n if (!distantDictionaryUpdateTimeStamp) {\n throw new Error('No distant dictionaries found');\n }\n\n const dictionariesKeysToFetch = Object.entries(\n distantDictionaryUpdateTimeStamp\n )\n .filter(([dictionaryKey, remoteUpdatedAt]) => {\n // If remote doesn't provide updatedAt, fetch to be safe\n if (!remoteUpdatedAt) return true;\n\n // If no local cache exists, fetch\n const local = (remoteDictionariesRecord as any)[dictionaryKey];\n if (!local) return true;\n\n const localUpdatedAtRaw = (local as any)?.updatedAt as\n | number\n | string\n | undefined;\n const localUpdatedAt =\n typeof localUpdatedAtRaw === 'number'\n ? localUpdatedAtRaw\n : localUpdatedAtRaw\n ? new Date(localUpdatedAtRaw).getTime()\n : undefined;\n\n // If local timestamp missing or older than remote, fetch\n if (typeof localUpdatedAt !== 'number') return true;\n return remoteUpdatedAt > localUpdatedAt;\n })\n .map(([dictionaryKey]) => dictionaryKey);\n\n const cachedDictionaries = Object.entries(remoteDictionariesRecord)\n .filter(([key, dictionary]) => {\n const remoteUpdatedAt = distantDictionaryUpdateTimeStamp[key];\n const localUpdatedAtRaw = (dictionary as any)?.updatedAt as\n | number\n | string\n | undefined;\n const localUpdatedAt =\n typeof localUpdatedAtRaw === 'number'\n ? localUpdatedAtRaw\n : localUpdatedAtRaw\n ? new Date(localUpdatedAtRaw).getTime()\n : undefined;\n // Consider as cached/imported when local exists and is up-to-date or newer\n return (\n typeof localUpdatedAt === 'number' &&\n typeof remoteUpdatedAt === 'number' &&\n localUpdatedAt >= remoteUpdatedAt\n );\n })\n .map(([, dictionary]) => dictionary as any);\n\n // Report cached as already imported\n if (cachedDictionaries.length > 0) {\n onStatusUpdate?.(\n cachedDictionaries.map((d) => ({\n dictionaryKey: d.key,\n type: 'remote',\n status: 'imported',\n }))\n );\n }\n\n const orderedDistantDictionaryKeys =\n dictionariesKeysToFetch.sort(sortAlphabetically);\n\n // Report pending for keys to be fetched so totals are visible immediately\n if (orderedDistantDictionaryKeys.length > 0) {\n onStatusUpdate?.(\n orderedDistantDictionaryKeys.map((key) => ({\n dictionaryKey: key,\n type: 'remote',\n status: 'pending',\n }))\n );\n }\n\n const distantDictionariesData = await fetchDistantDictionaries(\n {\n dictionaryKeys: orderedDistantDictionaryKeys,\n },\n onStatusUpdate\n );\n\n const distantDictionaries: DictionaryAPI[] = formatDistantDictionaries(\n distantDictionariesData\n );\n\n return [...cachedDictionaries, ...distantDictionaries];\n } catch (error) {\n console.error(error);\n options?.onError?.(error as Error);\n return [];\n } finally {\n options?.onStopRemoteCheck?.();\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAoC;AAGpC,oBAA+C;AAE/C,uCAAqC;AACrC,sCAAyC;AAEzC,gCAAmC;AAE5B,MAAM,4BAA4B,CACvC,iBAEA,aAAa,IAAI,CAAC,UAAU;AAAA,EAC1B,GAAG;AAAA,EACH,SAAS,GAAG,KAAK,GAAG,aAAa,KAAK,EAAE;AAAA,EACxC,UAAU;AACZ,EAAE;AAEG,MAAM,yBAAyB,OACpC,oBAAgB,gCAAiB,GACjC,gBACA,YAK6B;AAC7B,QAAM,gBAAY,4BAAa,aAAa;AAE5C,QAAM,EAAE,OAAO,IAAI;AAEnB,QAAM,wBAAwB,QAAQ,OAAO,YAAY,OAAO,YAAY;AAE5E,MAAI,CAAC,sBAAuB,QAAO,CAAC;AAEpC,MAAI;AACF,aAAS,qBAAqB;AAE9B,UAAM,kBAAc,gCAAoB,QAAW,aAAa;AAGhE,UAAM,4BACJ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I,CAAC,SAAS;AAAA,UACzC,eAAe;AAAA,UACf,MAAM;AAAA,UACN,QAAQ;AAAA,QACV,EAAE;AAAA,MACJ;AAAA,IACF;AAEA,UAAM,0BAA0B,UAAM;AAAA,MACpC;AAAA,QACE,gBAAgB;AAAA,MAClB;AAAA,MACA;AAAA,IACF;AAEA,UAAM,sBAAuC;AAAA,MAC3C;AAAA,IACF;AAEA,WAAO,CAAC,GAAG,oBAAoB,GAAG,mBAAmB;AAAA,EACvD,SAAS,OAAO;AACd,YAAQ,MAAM,KAAK;AACnB,aAAS,UAAU,KAAc;AACjC,WAAO,CAAC;AAAA,EACV,UAAE;AACA,aAAS,oBAAoB;AAAA,EAC/B;AACF;","names":["remoteDictionariesRecord"]}
|
|
@@ -31,10 +31,25 @@ class DictionariesLogger {
|
|
|
31
31
|
isFinished = false;
|
|
32
32
|
prefix;
|
|
33
33
|
lastRenderedState = "";
|
|
34
|
+
remoteCheckInProgress = false;
|
|
35
|
+
expectRemote = false;
|
|
36
|
+
remoteError = false;
|
|
34
37
|
constructor() {
|
|
35
38
|
const configuration = (0, import_config.getConfiguration)();
|
|
36
39
|
this.prefix = configuration.log.prefix;
|
|
37
40
|
}
|
|
41
|
+
setExpectRemote(expect) {
|
|
42
|
+
this.expectRemote = expect;
|
|
43
|
+
}
|
|
44
|
+
startRemoteCheck() {
|
|
45
|
+
if (this.isFinished) return;
|
|
46
|
+
this.remoteCheckInProgress = true;
|
|
47
|
+
this.startSpinner();
|
|
48
|
+
this.render();
|
|
49
|
+
}
|
|
50
|
+
stopRemoteCheck() {
|
|
51
|
+
this.remoteCheckInProgress = false;
|
|
52
|
+
}
|
|
38
53
|
update(newStatuses) {
|
|
39
54
|
if (this.isFinished) return;
|
|
40
55
|
for (const status of newStatuses) {
|
|
@@ -47,6 +62,10 @@ class DictionariesLogger {
|
|
|
47
62
|
this.statuses.push(status);
|
|
48
63
|
}
|
|
49
64
|
}
|
|
65
|
+
const { remoteTotal } = this.computeProgress();
|
|
66
|
+
if (this.expectRemote && !this.remoteCheckInProgress && remoteTotal === 0) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
50
69
|
this.startSpinner();
|
|
51
70
|
this.render();
|
|
52
71
|
}
|
|
@@ -67,29 +86,45 @@ class DictionariesLogger {
|
|
|
67
86
|
clearInterval(this.spinnerTimer);
|
|
68
87
|
this.spinnerTimer = null;
|
|
69
88
|
}
|
|
89
|
+
setRemoteError = (_error) => {
|
|
90
|
+
this.remoteError = true;
|
|
91
|
+
this.render();
|
|
92
|
+
};
|
|
70
93
|
render() {
|
|
71
94
|
const { localTotal, localDone, remoteTotal, remoteDone } = this.computeProgress();
|
|
72
95
|
const frame = this.spinnerFrames[this.spinnerIndex];
|
|
96
|
+
const clock = (0, import_config.colorize)(frame, import_config.ANSIColors.BLUE);
|
|
73
97
|
const lines = [];
|
|
74
98
|
const isLocalDone = localDone === localTotal;
|
|
75
99
|
const isRemoteDone = remoteDone === remoteTotal;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
100
|
+
const suppressLocalWhileCheckingRemote = this.expectRemote && this.remoteCheckInProgress && remoteTotal === 0;
|
|
101
|
+
if (!suppressLocalWhileCheckingRemote) {
|
|
102
|
+
if (isLocalDone) {
|
|
103
|
+
lines.push(
|
|
104
|
+
`${this.prefix} ${import_config.v} Local dictionaries: ${(0, import_config.colorize)(`${localDone}`, import_config.ANSIColors.GREEN)}${(0, import_config.colorize)(`/${localTotal}`, import_config.ANSIColors.GREY)}`
|
|
105
|
+
);
|
|
106
|
+
} else {
|
|
107
|
+
lines.push(
|
|
108
|
+
`${this.prefix} ${clock} Local dictionaries: ${(0, import_config.colorize)(`${localDone}`, import_config.ANSIColors.BLUE)}${(0, import_config.colorize)(`/${localTotal}`, import_config.ANSIColors.GREY)}`
|
|
109
|
+
);
|
|
110
|
+
}
|
|
84
111
|
}
|
|
85
|
-
if (remoteTotal > 0) {
|
|
86
|
-
if (
|
|
112
|
+
if (remoteTotal > 0 || this.remoteCheckInProgress || this.remoteError) {
|
|
113
|
+
if (this.remoteError) {
|
|
114
|
+
lines.push(
|
|
115
|
+
`${this.prefix} ${import_config.x} Remote dictionaries: ${(0, import_config.colorize)("Failed to fetch", import_config.ANSIColors.RED)}`
|
|
116
|
+
);
|
|
117
|
+
} else if (remoteTotal === 0) {
|
|
118
|
+
lines.push(
|
|
119
|
+
`${this.prefix} ${clock} Remote dictionaries: ${(0, import_config.colorize)("Check server", import_config.ANSIColors.BLUE)}`
|
|
120
|
+
);
|
|
121
|
+
} else if (isRemoteDone) {
|
|
87
122
|
lines.push(
|
|
88
|
-
`${this.prefix} ${(0, import_config.colorize)(
|
|
123
|
+
`${this.prefix} ${import_config.v} Remote dictionaries: ${(0, import_config.colorize)(`${remoteDone}`, import_config.ANSIColors.GREEN)}${(0, import_config.colorize)(`/${remoteTotal}`, import_config.ANSIColors.GREY)}`
|
|
89
124
|
);
|
|
90
125
|
} else {
|
|
91
126
|
lines.push(
|
|
92
|
-
`${this.prefix} ${(0, import_config.colorize)(
|
|
127
|
+
`${this.prefix} ${clock} Remote dictionaries: ${(0, import_config.colorize)(`${remoteDone}`, import_config.ANSIColors.BLUE)}${(0, import_config.colorize)(`/${remoteTotal}`, import_config.ANSIColors.GREY)}`
|
|
93
128
|
);
|
|
94
129
|
}
|
|
95
130
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/loadDictionaries/log.ts"],"sourcesContent":["import {\n ANSIColors,\n colorize,\n getConfiguration,\n spinnerFrames,\n} from '@intlayer/config';\nimport type { DictionariesStatus } from './loadDictionaries';\n\nexport class DictionariesLogger {\n private statuses: DictionariesStatus[] = [];\n private spinnerTimer: NodeJS.Timeout | null = null;\n private spinnerIndex = 0;\n private renderedLines = 0;\n private readonly spinnerFrames = spinnerFrames;\n private isFinished = false;\n private readonly prefix: string;\n private lastRenderedState: string = '';\n\n constructor() {\n const configuration = getConfiguration();\n this.prefix = configuration.log.prefix;\n }\n\n update(newStatuses: DictionariesStatus[]) {\n if (this.isFinished) return;\n for (const status of newStatuses) {\n const index = this.statuses.findIndex(\n (s) =>\n s.dictionaryKey === status.dictionaryKey && s.type === status.type\n );\n if (index >= 0) {\n this.statuses[index] = status;\n } else {\n this.statuses.push(status);\n }\n }\n\n this.startSpinner();\n this.render();\n }\n\n finish() {\n this.isFinished = true;\n this.stopSpinner();\n // Render final state and keep it visible\n this.render();\n }\n\n private startSpinner() {\n if (this.spinnerTimer || this.isFinished) return;\n this.spinnerTimer = setInterval(() => {\n this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;\n this.render();\n }, 100);\n }\n\n private stopSpinner() {\n if (!this.spinnerTimer) return;\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n }\n\n private render() {\n const { localTotal, localDone, remoteTotal, remoteDone } =\n this.computeProgress();\n\n const frame = this.spinnerFrames[this.spinnerIndex];\n const lines: string[] = [];\n\n const isLocalDone = localDone === localTotal;\n const isRemoteDone = remoteDone === remoteTotal;\n\n if (isLocalDone) {\n
|
|
1
|
+
{"version":3,"sources":["../../../src/loadDictionaries/log.ts"],"sourcesContent":["import {\n ANSIColors,\n colorize,\n getConfiguration,\n spinnerFrames,\n v,\n x,\n} from '@intlayer/config';\nimport type { DictionariesStatus } from './loadDictionaries';\n\nexport class DictionariesLogger {\n private statuses: DictionariesStatus[] = [];\n private spinnerTimer: NodeJS.Timeout | null = null;\n private spinnerIndex = 0;\n private renderedLines = 0;\n private readonly spinnerFrames = spinnerFrames;\n private isFinished = false;\n private readonly prefix: string;\n private lastRenderedState: string = '';\n private remoteCheckInProgress = false;\n private expectRemote = false;\n private remoteError = false;\n\n constructor() {\n const configuration = getConfiguration();\n this.prefix = configuration.log.prefix;\n }\n\n setExpectRemote(expect: boolean) {\n this.expectRemote = expect;\n }\n\n startRemoteCheck() {\n if (this.isFinished) return;\n this.remoteCheckInProgress = true;\n this.startSpinner();\n this.render();\n }\n\n stopRemoteCheck() {\n this.remoteCheckInProgress = false;\n }\n\n update(newStatuses: DictionariesStatus[]) {\n if (this.isFinished) return;\n for (const status of newStatuses) {\n const index = this.statuses.findIndex(\n (s) =>\n s.dictionaryKey === status.dictionaryKey && s.type === status.type\n );\n if (index >= 0) {\n this.statuses[index] = status;\n } else {\n this.statuses.push(status);\n }\n }\n\n // If we expect remote fetch later, avoid rendering a local-only line first\n const { remoteTotal } = this.computeProgress();\n if (this.expectRemote && !this.remoteCheckInProgress && remoteTotal === 0) {\n // Do not start spinner or render yet; wait until remote check starts\n return;\n }\n\n this.startSpinner();\n this.render();\n }\n\n finish() {\n this.isFinished = true;\n this.stopSpinner();\n // Render final state and keep it visible\n this.render();\n }\n\n private startSpinner() {\n if (this.spinnerTimer || this.isFinished) return;\n this.spinnerTimer = setInterval(() => {\n this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;\n this.render();\n }, 100);\n }\n\n private stopSpinner() {\n if (!this.spinnerTimer) return;\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n }\n\n public setRemoteError = (_error?: Error) => {\n this.remoteError = true;\n this.render();\n };\n\n private render() {\n const { localTotal, localDone, remoteTotal, remoteDone } =\n this.computeProgress();\n\n const frame = this.spinnerFrames[this.spinnerIndex];\n const clock = colorize(frame, ANSIColors.BLUE);\n const lines: string[] = [];\n\n const isLocalDone = localDone === localTotal;\n const isRemoteDone = remoteDone === remoteTotal;\n\n const suppressLocalWhileCheckingRemote =\n this.expectRemote && this.remoteCheckInProgress && remoteTotal === 0;\n\n if (!suppressLocalWhileCheckingRemote) {\n if (isLocalDone) {\n lines.push(\n `${this.prefix} ${v} Local dictionaries: ${colorize(`${localDone}`, ANSIColors.GREEN)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Local dictionaries: ${colorize(`${localDone}`, ANSIColors.BLUE)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Single remote line: show error, check, or progress counts\n if (remoteTotal > 0 || this.remoteCheckInProgress || this.remoteError) {\n if (this.remoteError) {\n lines.push(\n `${this.prefix} ${x} Remote dictionaries: ${colorize('Failed to fetch', ANSIColors.RED)}`\n );\n } else if (remoteTotal === 0) {\n lines.push(\n `${this.prefix} ${clock} Remote dictionaries: ${colorize('Check server', ANSIColors.BLUE)}`\n );\n } else if (isRemoteDone) {\n lines.push(\n `${this.prefix} ${v} Remote dictionaries: ${colorize(`${remoteDone}`, ANSIColors.GREEN)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Remote dictionaries: ${colorize(`${remoteDone}`, ANSIColors.BLUE)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Check if the state has changed to avoid duplicate rendering\n const currentState = lines.join('\\n');\n if (currentState === this.lastRenderedState) {\n return;\n }\n this.lastRenderedState = currentState;\n\n if (this.renderedLines > 0) {\n process.stdout.write(`\\x1b[${this.renderedLines}F`);\n }\n\n const totalLinesToClear = Math.max(this.renderedLines, lines.length);\n for (let i = 0; i < totalLinesToClear; i++) {\n process.stdout.write('\\x1b[2K');\n const line = lines[i];\n if (line !== undefined) {\n process.stdout.write(line);\n }\n process.stdout.write('\\n');\n }\n\n this.renderedLines = lines.length;\n }\n\n private computeProgress() {\n const localKeys = new Set(\n this.statuses\n .filter((s) => s.type === 'local')\n .map((s) => s.dictionaryKey)\n );\n\n const localDoneKeys = new Set(\n this.statuses\n .filter(\n (s) =>\n s.type === 'local' && (s.status === 'built' || s.status === 'error')\n )\n .map((s) => s.dictionaryKey)\n );\n\n const remoteKeys = new Set(\n this.statuses\n .filter((s) => s.type === 'remote')\n .map((s) => s.dictionaryKey)\n );\n\n const remoteDoneKeys = new Set(\n this.statuses\n .filter(\n (s) =>\n s.type === 'remote' &&\n (s.status === 'fetched' ||\n s.status === 'imported' ||\n s.status === 'error')\n )\n .map((s) => s.dictionaryKey)\n );\n\n return {\n localTotal: localKeys.size,\n localDone: localDoneKeys.size,\n remoteTotal: remoteKeys.size,\n remoteDone: remoteDoneKeys.size,\n } as const;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAOO;AAGA,MAAM,mBAAmB;AAAA,EACtB,WAAiC,CAAC;AAAA,EAClC,eAAsC;AAAA,EACtC,eAAe;AAAA,EACf,gBAAgB;AAAA,EACP,gBAAgB;AAAA,EACzB,aAAa;AAAA,EACJ;AAAA,EACT,oBAA4B;AAAA,EAC5B,wBAAwB;AAAA,EACxB,eAAe;AAAA,EACf,cAAc;AAAA,EAEtB,cAAc;AACZ,UAAM,oBAAgB,gCAAiB;AACvC,SAAK,SAAS,cAAc,IAAI;AAAA,EAClC;AAAA,EAEA,gBAAgB,QAAiB;AAC/B,SAAK,eAAe;AAAA,EACtB;AAAA,EAEA,mBAAmB;AACjB,QAAI,KAAK,WAAY;AACrB,SAAK,wBAAwB;AAC7B,SAAK,aAAa;AAClB,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,kBAAkB;AAChB,SAAK,wBAAwB;AAAA,EAC/B;AAAA,EAEA,OAAO,aAAmC;AACxC,QAAI,KAAK,WAAY;AACrB,eAAW,UAAU,aAAa;AAChC,YAAM,QAAQ,KAAK,SAAS;AAAA,QAC1B,CAAC,MACC,EAAE,kBAAkB,OAAO,iBAAiB,EAAE,SAAS,OAAO;AAAA,MAClE;AACA,UAAI,SAAS,GAAG;AACd,aAAK,SAAS,KAAK,IAAI;AAAA,MACzB,OAAO;AACL,aAAK,SAAS,KAAK,MAAM;AAAA,MAC3B;AAAA,IACF;AAGA,UAAM,EAAE,YAAY,IAAI,KAAK,gBAAgB;AAC7C,QAAI,KAAK,gBAAgB,CAAC,KAAK,yBAAyB,gBAAgB,GAAG;AAEzE;AAAA,IACF;AAEA,SAAK,aAAa;AAClB,SAAK,OAAO;AAA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