@intlayer/chokidar 5.8.1 → 6.0.0-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/chokidar/watcher.cjs +15 -20
- package/dist/cjs/chokidar/watcher.cjs.map +1 -1
- package/dist/cjs/fetchDistantDictionaries.cjs +18 -37
- package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
- package/dist/cjs/{fetchDistantDictionaryKeys.cjs → fetchDistantDictionaryKeysAndUpdateTimestamp.cjs} +11 -19
- package/dist/cjs/fetchDistantDictionaryKeysAndUpdateTimestamp.cjs.map +1 -0
- package/dist/cjs/filterInvalidDictionaries.cjs +70 -0
- package/dist/cjs/filterInvalidDictionaries.cjs.map +1 -0
- package/dist/cjs/getBuiltFetchDictionariesPath.cjs +52 -0
- package/dist/cjs/getBuiltFetchDictionariesPath.cjs.map +1 -0
- package/dist/cjs/getBuiltRemoteDictionariesPath.cjs +51 -0
- package/dist/cjs/getBuiltRemoteDictionariesPath.cjs.map +1 -0
- package/dist/cjs/index.cjs +13 -11
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/index.cjs +4 -4
- package/dist/cjs/loadDictionaries/index.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +57 -17
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs +128 -53
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +108 -0
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -0
- package/dist/cjs/loadDictionaries/log.cjs +144 -0
- package/dist/cjs/loadDictionaries/log.cjs.map +1 -0
- package/dist/cjs/mergeDictionaries.cjs +18 -22
- package/dist/cjs/mergeDictionaries.cjs.map +1 -1
- package/dist/cjs/orderDictionaries.cjs +71 -0
- package/dist/cjs/orderDictionaries.cjs.map +1 -0
- package/dist/cjs/prepareContentDeclaration.cjs +4 -1
- package/dist/cjs/prepareContentDeclaration.cjs.map +1 -1
- package/dist/cjs/prepareIntlayer.cjs +9 -4
- package/dist/cjs/prepareIntlayer.cjs.map +1 -1
- package/dist/cjs/processPerLocaleDictionary.cjs.map +1 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.cjs +22 -8
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.cjs.map +1 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.cjs +44 -42
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.cjs.map +1 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeFetchDictionary.cjs +83 -0
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeFetchDictionary.cjs.map +1 -0
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.cjs +29 -21
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.cjs.map +1 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeRemoteDictionary.cjs +52 -0
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeRemoteDictionary.cjs.map +1 -0
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.cjs +44 -29
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs +39 -34
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs +4 -6
- package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_type/createType.cjs +17 -16
- package/dist/cjs/transpiler/dictionary_to_type/createType.cjs.map +1 -1
- package/dist/cjs/utils/formatter.cjs +50 -0
- package/dist/cjs/utils/formatter.cjs.map +1 -0
- package/dist/cjs/utils/parallelize.cjs +43 -0
- package/dist/cjs/utils/parallelize.cjs.map +1 -0
- package/dist/cjs/utils/runOnce.cjs +2 -1
- package/dist/cjs/utils/runOnce.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/dictionaryStatus.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/formatCode.cjs +7 -4
- package/dist/cjs/writeContentDeclaration/formatCode.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +6 -2
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +43 -25
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -1
- package/dist/esm/chokidar/watcher.mjs +16 -21
- package/dist/esm/chokidar/watcher.mjs.map +1 -1
- package/dist/esm/fetchDistantDictionaries.mjs +24 -28
- package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
- package/dist/esm/fetchDistantDictionaryKeysAndUpdateTimestamp.mjs +21 -0
- package/dist/esm/fetchDistantDictionaryKeysAndUpdateTimestamp.mjs.map +1 -0
- package/dist/esm/filterInvalidDictionaries.mjs +40 -0
- package/dist/esm/filterInvalidDictionaries.mjs.map +1 -0
- package/dist/esm/getBuiltFetchDictionariesPath.mjs +18 -0
- package/dist/esm/getBuiltFetchDictionariesPath.mjs.map +1 -0
- package/dist/esm/getBuiltRemoteDictionariesPath.mjs +17 -0
- package/dist/esm/getBuiltRemoteDictionariesPath.mjs.map +1 -0
- package/dist/esm/index.mjs +10 -9
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/loadDictionaries/index.mjs +2 -2
- package/dist/esm/loadDictionaries/index.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +61 -18
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadDictionaries.mjs +132 -53
- package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +73 -0
- package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -0
- package/dist/esm/loadDictionaries/log.mjs +125 -0
- package/dist/esm/loadDictionaries/log.mjs.map +1 -0
- package/dist/esm/mergeDictionaries.mjs +19 -23
- package/dist/esm/mergeDictionaries.mjs.map +1 -1
- package/dist/esm/orderDictionaries.mjs +37 -0
- package/dist/esm/orderDictionaries.mjs.map +1 -0
- package/dist/esm/prepareContentDeclaration.mjs +4 -1
- package/dist/esm/prepareContentDeclaration.mjs.map +1 -1
- package/dist/esm/prepareIntlayer.mjs +9 -4
- package/dist/esm/prepareIntlayer.mjs.map +1 -1
- package/dist/esm/processPerLocaleDictionary.mjs.map +1 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.mjs +25 -9
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.mjs.map +1 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.mjs +45 -43
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.mjs.map +1 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeFetchDictionary.mjs +58 -0
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeFetchDictionary.mjs.map +1 -0
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.mjs +29 -21
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.mjs.map +1 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeRemoteDictionary.mjs +28 -0
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeRemoteDictionary.mjs.map +1 -0
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.mjs +45 -30
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs +39 -34
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs +4 -6
- package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_type/createType.mjs +17 -16
- package/dist/esm/transpiler/dictionary_to_type/createType.mjs.map +1 -1
- package/dist/esm/utils/formatter.mjs +15 -0
- package/dist/esm/utils/formatter.mjs.map +1 -0
- package/dist/esm/utils/parallelize.mjs +9 -0
- package/dist/esm/utils/parallelize.mjs.map +1 -0
- package/dist/esm/utils/runOnce.mjs +2 -1
- package/dist/esm/utils/runOnce.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/formatCode.mjs +8 -5
- package/dist/esm/writeContentDeclaration/formatCode.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +6 -2
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeJSFile.mjs +40 -22
- package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -1
- package/dist/types/chokidar/watcher.d.ts.map +1 -1
- package/dist/types/fetchDistantDictionaries.d.ts +2 -1
- package/dist/types/fetchDistantDictionaries.d.ts.map +1 -1
- package/dist/types/fetchDistantDictionaryKeysAndUpdateTimestamp.d.ts +3 -0
- package/dist/types/fetchDistantDictionaryKeysAndUpdateTimestamp.d.ts.map +1 -0
- package/dist/types/filterInvalidDictionaries.d.ts +3 -0
- package/dist/types/filterInvalidDictionaries.d.ts.map +1 -0
- package/dist/types/getBuiltFetchDictionariesPath.d.ts +5 -0
- package/dist/types/getBuiltFetchDictionariesPath.d.ts.map +1 -0
- package/dist/types/getBuiltRemoteDictionariesPath.d.ts +5 -0
- package/dist/types/getBuiltRemoteDictionariesPath.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/loadDictionaries/index.d.ts +2 -2
- package/dist/types/loadDictionaries/index.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadContentDeclaration.d.ts +4 -1
- package/dist/types/loadDictionaries/loadContentDeclaration.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadDictionaries.d.ts +11 -1
- package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +6 -0
- package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -0
- package/dist/types/loadDictionaries/log.d.ts +19 -0
- package/dist/types/loadDictionaries/log.d.ts.map +1 -0
- package/dist/types/mergeDictionaries.d.ts +1 -1
- package/dist/types/mergeDictionaries.d.ts.map +1 -1
- package/dist/types/orderDictionaries.d.ts +10 -0
- package/dist/types/orderDictionaries.d.ts.map +1 -0
- package/dist/types/prepareContentDeclaration.d.ts.map +1 -1
- package/dist/types/prepareIntlayer.d.ts.map +1 -1
- package/dist/types/processPerLocaleDictionary.d.ts +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/index.d.ts +1 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/index.d.ts.map +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.d.ts +4 -3
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.d.ts.map +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.d.ts +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.d.ts.map +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeFetchDictionary.d.ts +23 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeFetchDictionary.d.ts.map +1 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.d.ts +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.d.ts.map +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeRemoteDictionary.d.ts +19 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeRemoteDictionary.d.ts.map +1 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.d.ts.map +1 -1
- package/dist/types/transpiler/dictionary_to_main/createDictionaryEntryPoint.d.ts +1 -1
- package/dist/types/transpiler/dictionary_to_main/createDictionaryEntryPoint.d.ts.map +1 -1
- package/dist/types/transpiler/dictionary_to_type/createModuleAugmentation.d.ts +1 -1
- package/dist/types/transpiler/dictionary_to_type/createModuleAugmentation.d.ts.map +1 -1
- package/dist/types/transpiler/dictionary_to_type/createType.d.ts +1 -1
- package/dist/types/transpiler/dictionary_to_type/createType.d.ts.map +1 -1
- package/dist/types/utils/formatter.d.ts +4 -0
- package/dist/types/utils/formatter.d.ts.map +1 -0
- package/dist/types/utils/parallelize.d.ts +2 -0
- package/dist/types/utils/parallelize.d.ts.map +1 -0
- package/dist/types/utils/runOnce.d.ts +1 -1
- package/dist/types/utils/runOnce.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/dictionaryStatus.d.ts +1 -1
- package/dist/types/writeContentDeclaration/dictionaryStatus.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/formatCode.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts +1 -1
- package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/writeJSFile.d.ts +1 -1
- package/dist/types/writeContentDeclaration/writeJSFile.d.ts.map +1 -1
- package/package.json +17 -15
- package/dist/cjs/checkDictionaryChanges.cjs +0 -58
- package/dist/cjs/checkDictionaryChanges.cjs.map +0 -1
- package/dist/cjs/fetchDistantDictionaryKeys.cjs.map +0 -1
- package/dist/cjs/getFilteredLocalesContent.cjs +0 -70
- package/dist/cjs/getFilteredLocalesContent.cjs.map +0 -1
- package/dist/cjs/loadDictionaries/loadDistantDictionaries.cjs +0 -44
- package/dist/cjs/loadDictionaries/loadDistantDictionaries.cjs.map +0 -1
- package/dist/cjs/log.cjs +0 -296
- package/dist/cjs/log.cjs.map +0 -1
- package/dist/esm/checkDictionaryChanges.mjs +0 -37
- package/dist/esm/checkDictionaryChanges.mjs.map +0 -1
- package/dist/esm/fetchDistantDictionaryKeys.mjs +0 -29
- package/dist/esm/fetchDistantDictionaryKeys.mjs.map +0 -1
- package/dist/esm/getFilteredLocalesContent.mjs +0 -49
- package/dist/esm/getFilteredLocalesContent.mjs.map +0 -1
- package/dist/esm/loadDictionaries/loadDistantDictionaries.mjs +0 -20
- package/dist/esm/loadDictionaries/loadDistantDictionaries.mjs.map +0 -1
- package/dist/esm/log.mjs +0 -262
- package/dist/esm/log.mjs.map +0 -1
- package/dist/types/checkDictionaryChanges.d.ts +0 -3
- package/dist/types/checkDictionaryChanges.d.ts.map +0 -1
- package/dist/types/fetchDistantDictionaryKeys.d.ts +0 -3
- package/dist/types/fetchDistantDictionaryKeys.d.ts.map +0 -1
- package/dist/types/getFilteredLocalesContent.d.ts +0 -4
- package/dist/types/getFilteredLocalesContent.d.ts.map +0 -1
- package/dist/types/loadDictionaries/loadDistantDictionaries.d.ts +0 -8
- package/dist/types/loadDictionaries/loadDistantDictionaries.d.ts.map +0 -1
- package/dist/types/log.d.ts +0 -45
- package/dist/types/log.d.ts.map +0 -1
|
@@ -0,0 +1,144 @@
|
|
|
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 log_exports = {};
|
|
20
|
+
__export(log_exports, {
|
|
21
|
+
DictionariesLogger: () => DictionariesLogger
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(log_exports);
|
|
24
|
+
var import_config = require("@intlayer/config");
|
|
25
|
+
class DictionariesLogger {
|
|
26
|
+
statuses = [];
|
|
27
|
+
spinnerTimer = null;
|
|
28
|
+
spinnerIndex = 0;
|
|
29
|
+
renderedLines = 0;
|
|
30
|
+
spinnerFrames = import_config.spinnerFrames;
|
|
31
|
+
isFinished = false;
|
|
32
|
+
prefix;
|
|
33
|
+
lastRenderedState = "";
|
|
34
|
+
constructor() {
|
|
35
|
+
const configuration = (0, import_config.getConfiguration)();
|
|
36
|
+
this.prefix = configuration.log.prefix;
|
|
37
|
+
}
|
|
38
|
+
update(newStatuses) {
|
|
39
|
+
if (this.isFinished) return;
|
|
40
|
+
for (const status of newStatuses) {
|
|
41
|
+
const index = this.statuses.findIndex(
|
|
42
|
+
(s) => s.dictionaryKey === status.dictionaryKey && s.type === status.type
|
|
43
|
+
);
|
|
44
|
+
if (index >= 0) {
|
|
45
|
+
this.statuses[index] = status;
|
|
46
|
+
} else {
|
|
47
|
+
this.statuses.push(status);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
this.startSpinner();
|
|
51
|
+
this.render();
|
|
52
|
+
}
|
|
53
|
+
finish() {
|
|
54
|
+
this.isFinished = true;
|
|
55
|
+
this.stopSpinner();
|
|
56
|
+
this.render();
|
|
57
|
+
}
|
|
58
|
+
startSpinner() {
|
|
59
|
+
if (this.spinnerTimer || this.isFinished) return;
|
|
60
|
+
this.spinnerTimer = setInterval(() => {
|
|
61
|
+
this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;
|
|
62
|
+
this.render();
|
|
63
|
+
}, 100);
|
|
64
|
+
}
|
|
65
|
+
stopSpinner() {
|
|
66
|
+
if (!this.spinnerTimer) return;
|
|
67
|
+
clearInterval(this.spinnerTimer);
|
|
68
|
+
this.spinnerTimer = null;
|
|
69
|
+
}
|
|
70
|
+
render() {
|
|
71
|
+
const { localTotal, localDone, remoteTotal, remoteDone } = this.computeProgress();
|
|
72
|
+
const frame = this.spinnerFrames[this.spinnerIndex];
|
|
73
|
+
const lines = [];
|
|
74
|
+
const isLocalDone = localDone === localTotal;
|
|
75
|
+
const isRemoteDone = remoteDone === remoteTotal;
|
|
76
|
+
if (isLocalDone) {
|
|
77
|
+
lines.push(
|
|
78
|
+
`${this.prefix} ${(0, import_config.colorize)("\u2714", import_config.ANSIColors.GREEN)} local dictionaries: ${localDone}/${localTotal}`
|
|
79
|
+
);
|
|
80
|
+
} else {
|
|
81
|
+
lines.push(
|
|
82
|
+
`${this.prefix} ${(0, import_config.colorize)(frame, import_config.ANSIColors.BLUE)} local dictionaries: ${localDone}/${localTotal}`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
if (remoteTotal > 0) {
|
|
86
|
+
if (isRemoteDone) {
|
|
87
|
+
lines.push(
|
|
88
|
+
`${this.prefix} ${(0, import_config.colorize)("\u2714", import_config.ANSIColors.GREEN)} remote dictionaries: ${remoteDone}/${remoteTotal}`
|
|
89
|
+
);
|
|
90
|
+
} else {
|
|
91
|
+
lines.push(
|
|
92
|
+
`${this.prefix} ${(0, import_config.colorize)(frame, import_config.ANSIColors.BLUE)} remote dictionaries: ${remoteDone}/${remoteTotal}`
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const currentState = lines.join("\n");
|
|
97
|
+
if (currentState === this.lastRenderedState) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
this.lastRenderedState = currentState;
|
|
101
|
+
if (this.renderedLines > 0) {
|
|
102
|
+
process.stdout.write(`\x1B[${this.renderedLines}F`);
|
|
103
|
+
}
|
|
104
|
+
const totalLinesToClear = Math.max(this.renderedLines, lines.length);
|
|
105
|
+
for (let i = 0; i < totalLinesToClear; i++) {
|
|
106
|
+
process.stdout.write("\x1B[2K");
|
|
107
|
+
const line = lines[i];
|
|
108
|
+
if (line !== void 0) {
|
|
109
|
+
process.stdout.write(line);
|
|
110
|
+
}
|
|
111
|
+
process.stdout.write("\n");
|
|
112
|
+
}
|
|
113
|
+
this.renderedLines = lines.length;
|
|
114
|
+
}
|
|
115
|
+
computeProgress() {
|
|
116
|
+
const localKeys = new Set(
|
|
117
|
+
this.statuses.filter((s) => s.type === "local").map((s) => s.dictionaryKey)
|
|
118
|
+
);
|
|
119
|
+
const localDoneKeys = new Set(
|
|
120
|
+
this.statuses.filter(
|
|
121
|
+
(s) => s.type === "local" && (s.status === "built" || s.status === "error")
|
|
122
|
+
).map((s) => s.dictionaryKey)
|
|
123
|
+
);
|
|
124
|
+
const remoteKeys = new Set(
|
|
125
|
+
this.statuses.filter((s) => s.type === "remote").map((s) => s.dictionaryKey)
|
|
126
|
+
);
|
|
127
|
+
const remoteDoneKeys = new Set(
|
|
128
|
+
this.statuses.filter(
|
|
129
|
+
(s) => s.type === "remote" && (s.status === "fetched" || s.status === "imported" || s.status === "error")
|
|
130
|
+
).map((s) => s.dictionaryKey)
|
|
131
|
+
);
|
|
132
|
+
return {
|
|
133
|
+
localTotal: localKeys.size,
|
|
134
|
+
localDone: localDoneKeys.size,
|
|
135
|
+
remoteTotal: remoteKeys.size,
|
|
136
|
+
remoteDone: remoteDoneKeys.size
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
141
|
+
0 && (module.exports = {
|
|
142
|
+
DictionariesLogger
|
|
143
|
+
});
|
|
144
|
+
//# sourceMappingURL=log.cjs.map
|
|
@@ -0,0 +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 lines.push(\n `${this.prefix} ${colorize('✔', ANSIColors.GREEN)} local dictionaries: ${localDone}/${localTotal}`\n );\n } else {\n lines.push(\n `${this.prefix} ${colorize(frame, ANSIColors.BLUE)} local dictionaries: ${localDone}/${localTotal}`\n );\n }\n\n if (remoteTotal > 0) {\n if (isRemoteDone) {\n lines.push(\n `${this.prefix} ${colorize('✔', ANSIColors.GREEN)} remote dictionaries: ${remoteDone}/${remoteTotal}`\n );\n } else {\n lines.push(\n `${this.prefix} ${colorize(frame, ANSIColors.BLUE)} remote dictionaries: ${remoteDone}/${remoteTotal}`\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":"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","names":[]}
|
|
@@ -35,13 +35,14 @@ var import_config = require("@intlayer/config");
|
|
|
35
35
|
var import_built = __toESM(require("@intlayer/config/built"));
|
|
36
36
|
var import_core = require("@intlayer/core");
|
|
37
37
|
var import_deepmerge = __toESM(require("deepmerge"));
|
|
38
|
+
var import_orderDictionaries = require('./orderDictionaries.cjs');
|
|
38
39
|
const checkTypesMatch = (obj1, obj2, dictionaryKey, path = []) => {
|
|
39
40
|
const appLogger = (0, import_config.getAppLogger)(import_built.default);
|
|
40
41
|
const type1 = (0, import_core.getNodeType)(obj1);
|
|
41
42
|
const type2 = (0, import_core.getNodeType)(obj2);
|
|
42
43
|
if (type1 !== type2) {
|
|
43
44
|
appLogger(
|
|
44
|
-
`Error: Dictionary
|
|
45
|
+
`Error: Dictionary ${(0, import_config.colorizeKey)(dictionaryKey)} has a multiple content files with type mismatch at path "${path.join(".")}": Cannot merge ${type1} with ${type2}`,
|
|
45
46
|
{
|
|
46
47
|
level: "error"
|
|
47
48
|
}
|
|
@@ -110,35 +111,30 @@ const arrayMerge = (destinationArray, sourceArray) => {
|
|
|
110
111
|
return result;
|
|
111
112
|
};
|
|
112
113
|
const mergeDictionaries = (dictionaries) => {
|
|
113
|
-
const
|
|
114
|
-
let
|
|
114
|
+
const orderedDictionaries = (0, import_orderDictionaries.orderDictionaries)(dictionaries, import_built.default);
|
|
115
|
+
let mergedContent = orderedDictionaries[0].content;
|
|
115
116
|
const mergeOptions = {
|
|
116
117
|
arrayMerge
|
|
117
118
|
};
|
|
118
|
-
for (let i = 1; i <
|
|
119
|
-
const currentDictionary =
|
|
119
|
+
for (let i = 1; i < orderedDictionaries.length; i++) {
|
|
120
|
+
const currentDictionary = orderedDictionaries[i];
|
|
120
121
|
checkTypesMatch(
|
|
121
|
-
|
|
122
|
-
currentDictionary,
|
|
122
|
+
mergedContent,
|
|
123
|
+
currentDictionary.content,
|
|
123
124
|
currentDictionary.key,
|
|
124
125
|
[]
|
|
125
126
|
);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
mergeOptions
|
|
132
|
-
);
|
|
133
|
-
} else {
|
|
134
|
-
mergedDictionaries = (0, import_deepmerge.default)(
|
|
135
|
-
currentDictionary,
|
|
136
|
-
mergedDictionaries,
|
|
137
|
-
mergeOptions
|
|
138
|
-
);
|
|
139
|
-
}
|
|
127
|
+
mergedContent = (0, import_deepmerge.default)(
|
|
128
|
+
currentDictionary.content,
|
|
129
|
+
mergedContent,
|
|
130
|
+
mergeOptions
|
|
131
|
+
);
|
|
140
132
|
}
|
|
141
|
-
return {
|
|
133
|
+
return {
|
|
134
|
+
key: orderedDictionaries[0].key,
|
|
135
|
+
content: mergedContent,
|
|
136
|
+
localIds: dictionaries.filter((dict) => dict.localId).map((dict) => dict.localId)
|
|
137
|
+
};
|
|
142
138
|
};
|
|
143
139
|
// Annotate the CommonJS export names for ESM import in node:
|
|
144
140
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mergeDictionaries.ts"],"sourcesContent":["import { getAppLogger } from '@intlayer/config';\nimport configuration from '@intlayer/config/built';\nimport type
|
|
1
|
+
{"version":3,"sources":["../../src/mergeDictionaries.ts"],"sourcesContent":["import { colorizeKey, getAppLogger } from '@intlayer/config';\nimport configuration from '@intlayer/config/built';\nimport { type Dictionary, getNodeType } from '@intlayer/core';\nimport merge, { Options } from 'deepmerge';\nimport { orderDictionaries } from './orderDictionaries';\n\nconst checkTypesMatch = (\n obj1: any,\n obj2: any,\n dictionaryKey: string,\n path: string[] = []\n): void => {\n const appLogger = getAppLogger(configuration);\n const type1 = getNodeType(obj1);\n const type2 = getNodeType(obj2);\n\n if (type1 !== type2) {\n appLogger(\n `Error: Dictionary ${colorizeKey(dictionaryKey)} has a multiple content files with type mismatch at path \"${path.join('.')}\": Cannot merge ${type1} with ${type2}`,\n {\n level: 'error',\n }\n );\n }\n\n if (type1 === 'object' && obj1 && obj2) {\n const allKeys = new Set([...Object.keys(obj1), ...Object.keys(obj2)]);\n for (const key of allKeys) {\n if (key in obj1 && key in obj2) {\n checkTypesMatch(obj1[key], obj2[key], dictionaryKey, [...path, key]);\n }\n }\n }\n};\n\n// Custom array merge strategy that merges arrays by key when present, otherwise by index\nconst arrayMerge = (destinationArray: any[], sourceArray: any[]): any[] => {\n const isObject = (value: unknown): value is Record<string, any> =>\n !!value && typeof value === 'object' && !Array.isArray(value);\n\n const getKey = (item: any): string | number | undefined => {\n if (!isObject(item)) return undefined;\n const key = (item as any).key;\n if (typeof key === 'string' || typeof key === 'number') return key;\n return undefined;\n };\n\n const result: any[] = [];\n\n // Build a lookup for destination keyed items and track usage of all destination indices\n const destKeyToIndex = new Map<string | number, number>();\n const destUsed: boolean[] = new Array(destinationArray.length).fill(false);\n for (let i = 0; i < destinationArray.length; i++) {\n const k = getKey(destinationArray[i]);\n if (k !== undefined && !destKeyToIndex.has(k)) {\n destKeyToIndex.set(k, i);\n }\n }\n\n // First pass: respect source (already merged) order\n for (let i = 0; i < sourceArray.length; i++) {\n const sourceItem = sourceArray[i];\n const sourceKey = getKey(sourceItem);\n\n if (sourceKey !== undefined && destKeyToIndex.has(sourceKey)) {\n const destIndex = destKeyToIndex.get(sourceKey)!;\n const destItem = destinationArray[destIndex];\n destUsed[destIndex] = true;\n\n if (isObject(destItem) && isObject(sourceItem)) {\n result.push(merge(sourceItem, destItem, { arrayMerge }));\n } else {\n // Prefer destination item (later dictionary) when primitive\n result.push(destItem !== undefined ? destItem : sourceItem);\n }\n continue;\n }\n\n // Fallback to index-based merge when no key match\n const destItem = destinationArray[i];\n if (destItem !== undefined && !destUsed[i]) {\n destUsed[i] = true;\n if (isObject(destItem) && isObject(sourceItem)) {\n result.push(merge(sourceItem, destItem, { arrayMerge }));\n } else if (destItem !== undefined) {\n result.push(destItem);\n } else {\n result.push(sourceItem);\n }\n } else {\n result.push(sourceItem);\n }\n }\n\n // Second pass: append remaining unused destination items (including keyed-only in destination or extra by index)\n for (let i = 0; i < destinationArray.length; i++) {\n if (!destUsed[i]) {\n result.push(destinationArray[i]);\n destUsed[i] = true;\n }\n }\n\n return result;\n};\n\nexport const mergeDictionaries = (dictionaries: Dictionary[]): Dictionary => {\n // Order dictionaries based on priority strategy\n const orderedDictionaries = orderDictionaries(dictionaries, configuration);\n\n let mergedContent: Dictionary['content'] = orderedDictionaries[0].content;\n\n // Configure deepmerge options with custom array merge strategy\n const mergeOptions: Options = {\n arrayMerge,\n };\n\n for (let i = 1; i < orderedDictionaries.length; i++) {\n const currentDictionary = orderedDictionaries[i];\n\n // Check types before merging\n checkTypesMatch(\n mergedContent,\n currentDictionary.content,\n currentDictionary.key,\n []\n );\n\n mergedContent = merge(\n currentDictionary.content,\n mergedContent,\n mergeOptions\n );\n }\n\n return {\n key: orderedDictionaries[0].key,\n content: mergedContent,\n localIds: dictionaries\n .filter((dict) => dict.localId)\n .map((dict) => dict.localId!),\n };\n};\n"],"mappings":"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","names":["configuration","destItem","merge"]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var orderDictionaries_exports = {};
|
|
30
|
+
__export(orderDictionaries_exports, {
|
|
31
|
+
orderDictionaries: () => orderDictionaries
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(orderDictionaries_exports);
|
|
34
|
+
var import_built = __toESM(require("@intlayer/config/built"));
|
|
35
|
+
const orderDictionaries = (dictionaries, configuration = import_built.default) => {
|
|
36
|
+
const { editor } = configuration;
|
|
37
|
+
const { dictionaryPriorityStrategy } = editor;
|
|
38
|
+
if (dictionaries.length <= 1) {
|
|
39
|
+
return dictionaries;
|
|
40
|
+
}
|
|
41
|
+
const withIndex = dictionaries.map((dict, index) => ({ dict, index }));
|
|
42
|
+
const getPriority = (d) => {
|
|
43
|
+
const p = d.priority ?? 0;
|
|
44
|
+
return Number.isFinite(p) ? p : 0;
|
|
45
|
+
};
|
|
46
|
+
const getLocationWeight = (d) => {
|
|
47
|
+
const location = d.location ?? "distant";
|
|
48
|
+
if (dictionaryPriorityStrategy === "distant_first") {
|
|
49
|
+
return location === "distant" ? 0 : 1;
|
|
50
|
+
}
|
|
51
|
+
return location === "locale" ? 0 : 1;
|
|
52
|
+
};
|
|
53
|
+
withIndex.sort((a, b) => {
|
|
54
|
+
const aAuto = a.dict.autoFilled ? 1 : 0;
|
|
55
|
+
const bAuto = b.dict.autoFilled ? 1 : 0;
|
|
56
|
+
if (aAuto !== bAuto) return aAuto - bAuto;
|
|
57
|
+
const aP = getPriority(a.dict);
|
|
58
|
+
const bP = getPriority(b.dict);
|
|
59
|
+
if (aP !== bP) return bP - aP;
|
|
60
|
+
const aLoc = getLocationWeight(a.dict);
|
|
61
|
+
const bLoc = getLocationWeight(b.dict);
|
|
62
|
+
if (aLoc !== bLoc) return aLoc - bLoc;
|
|
63
|
+
return a.index - b.index;
|
|
64
|
+
});
|
|
65
|
+
return withIndex.map(({ dict }) => dict);
|
|
66
|
+
};
|
|
67
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
68
|
+
0 && (module.exports = {
|
|
69
|
+
orderDictionaries
|
|
70
|
+
});
|
|
71
|
+
//# sourceMappingURL=orderDictionaries.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/orderDictionaries.ts"],"sourcesContent":["import intlayerConfig from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/core';\n\n/**\n * Orders dictionaries based on the dictionary priority strategy.\n *\n * @param dictionaries - Array of dictionaries to order\n * @param priorityStrategy - The priority strategy ('local_first' or 'distant_first')\n * @returns Ordered array of dictionaries\n */\nexport const orderDictionaries = (\n dictionaries: Dictionary[],\n configuration = intlayerConfig\n): Dictionary[] => {\n const { editor } = configuration;\n const { dictionaryPriorityStrategy } = editor;\n\n if (dictionaries.length <= 1) {\n return dictionaries;\n }\n\n // Stabilize original indices to preserve relative order for complete ties\n const withIndex = dictionaries.map((dict, index) => ({ dict, index }));\n\n const getPriority = (d: Dictionary): number => {\n const p = d.priority ?? 0;\n\n return Number.isFinite(p) ? p : 0;\n };\n\n const getLocationWeight = (d: Dictionary): number => {\n const location = d.location ?? 'distant';\n\n if (dictionaryPriorityStrategy === 'distant_first') {\n // distant should come first\n return location === 'distant' ? 0 : 1;\n }\n // default: local_first\n return location === 'locale' ? 0 : 1;\n };\n\n withIndex.sort((a, b) => {\n // 1) Non-autoFilled before autoFilled (autoFilled have lower precedence)\n const aAuto = a.dict.autoFilled ? 1 : 0;\n const bAuto = b.dict.autoFilled ? 1 : 0;\n if (aAuto !== bAuto) return aAuto - bAuto; // 0 before 1\n\n // 2) Higher priority first (larger number wins)\n const aP = getPriority(a.dict);\n const bP = getPriority(b.dict);\n if (aP !== bP) return bP - aP; // descending\n\n // 3) Location according to strategy\n const aLoc = getLocationWeight(a.dict);\n const bLoc = getLocationWeight(b.dict);\n if (aLoc !== bLoc) return aLoc - bLoc;\n\n // 4) Stable fallback by original index\n return a.index - b.index;\n });\n\n return withIndex.map(({ dict }) => dict);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2B;AAUpB,MAAM,oBAAoB,CAC/B,cACA,gBAAgB,aAAAA,YACC;AACjB,QAAM,EAAE,OAAO,IAAI;AACnB,QAAM,EAAE,2BAA2B,IAAI;AAEvC,MAAI,aAAa,UAAU,GAAG;AAC5B,WAAO;AAAA,EACT;AAGA,QAAM,YAAY,aAAa,IAAI,CAAC,MAAM,WAAW,EAAE,MAAM,MAAM,EAAE;AAErE,QAAM,cAAc,CAAC,MAA0B;AAC7C,UAAM,IAAI,EAAE,YAAY;AAExB,WAAO,OAAO,SAAS,CAAC,IAAI,IAAI;AAAA,EAClC;AAEA,QAAM,oBAAoB,CAAC,MAA0B;AACnD,UAAM,WAAW,EAAE,YAAY;AAE/B,QAAI,+BAA+B,iBAAiB;AAElD,aAAO,aAAa,YAAY,IAAI;AAAA,IACtC;AAEA,WAAO,aAAa,WAAW,IAAI;AAAA,EACrC;AAEA,YAAU,KAAK,CAAC,GAAG,MAAM;AAEvB,UAAM,QAAQ,EAAE,KAAK,aAAa,IAAI;AACtC,UAAM,QAAQ,EAAE,KAAK,aAAa,IAAI;AACtC,QAAI,UAAU,MAAO,QAAO,QAAQ;AAGpC,UAAM,KAAK,YAAY,EAAE,IAAI;AAC7B,UAAM,KAAK,YAAY,EAAE,IAAI;AAC7B,QAAI,OAAO,GAAI,QAAO,KAAK;AAG3B,UAAM,OAAO,kBAAkB,EAAE,IAAI;AACrC,UAAM,OAAO,kBAAkB,EAAE,IAAI;AACrC,QAAI,SAAS,KAAM,QAAO,OAAO;AAGjC,WAAO,EAAE,QAAQ,EAAE;AAAA,EACrB,CAAC;AAED,SAAO,UAAU,IAAI,CAAC,EAAE,KAAK,MAAM,IAAI;AACzC;","names":["intlayerConfig"]}
|
|
@@ -21,6 +21,7 @@ __export(prepareContentDeclaration_exports, {
|
|
|
21
21
|
prepareContentDeclaration: () => prepareContentDeclaration
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(prepareContentDeclaration_exports);
|
|
24
|
+
var import_config = require("@intlayer/config");
|
|
24
25
|
var import_core = require("@intlayer/core");
|
|
25
26
|
var import_fs = require("fs");
|
|
26
27
|
var import_path = require("path");
|
|
@@ -47,7 +48,9 @@ const writeFilePlugin = {
|
|
|
47
48
|
}
|
|
48
49
|
(0, import_fs.writeFileSync)(abolsuteFilePath, fileContent);
|
|
49
50
|
} catch (error) {
|
|
50
|
-
throw new Error(
|
|
51
|
+
throw new Error(
|
|
52
|
+
`${import_config.x} Error writing file to ${(0, import_config.colorizePath)(filePath)}: ${error}`
|
|
53
|
+
);
|
|
51
54
|
}
|
|
52
55
|
const transformedFileContent = {
|
|
53
56
|
nodeType: import_core.NodeType.File,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/prepareContentDeclaration.ts"],"sourcesContent":["import {\n deepTransformNode,\n NodeType,\n type Dictionary,\n type FileContent,\n type FileContentConstructor,\n type InsertionContent,\n type InsertionContentConstructor,\n type MarkdownContent,\n type MarkdownContentConstructor,\n type Plugins,\n} from '@intlayer/core';\nimport { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { join } from 'path';\n\n/**\n * Write file plugin\n */\n\nconst writeFilePlugin: Plugins = {\n id: 'write-file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.File,\n transform: (node: FileContent) => {\n const fileContent = node.content;\n const filePath = node.fixedPath;\n\n if (typeof fileContent !== 'string') {\n throw new Error('File content must be a string');\n }\n\n if (typeof filePath !== 'string') {\n throw new Error('File path must be a string');\n }\n\n // Write the file to the file system\n try {\n const abolsuteFilePath = join(process.cwd(), filePath);\n\n // Create the file directory if it doesn't exist\n const fileDirectory = join(process.cwd(), filePath);\n if (!fileDirectory.startsWith(process.cwd())) {\n throw new Error('File directory not found');\n }\n\n if (!existsSync(fileDirectory)) {\n mkdirSync(fileDirectory, { recursive: true });\n }\n\n // Write the file\n writeFileSync(abolsuteFilePath, fileContent);\n } catch (error) {\n throw new Error(
|
|
1
|
+
{"version":3,"sources":["../../src/prepareContentDeclaration.ts"],"sourcesContent":["import { colorizePath, x } from '@intlayer/config';\nimport {\n deepTransformNode,\n NodeType,\n type Dictionary,\n type FileContent,\n type FileContentConstructor,\n type InsertionContent,\n type InsertionContentConstructor,\n type MarkdownContent,\n type MarkdownContentConstructor,\n type Plugins,\n} from '@intlayer/core';\nimport { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { join } from 'path';\n\n/**\n * Write file plugin\n */\n\nconst writeFilePlugin: Plugins = {\n id: 'write-file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.File,\n transform: (node: FileContent) => {\n const fileContent = node.content;\n const filePath = node.fixedPath;\n\n if (typeof fileContent !== 'string') {\n throw new Error('File content must be a string');\n }\n\n if (typeof filePath !== 'string') {\n throw new Error('File path must be a string');\n }\n\n // Write the file to the file system\n try {\n const abolsuteFilePath = join(process.cwd(), filePath);\n\n // Create the file directory if it doesn't exist\n const fileDirectory = join(process.cwd(), filePath);\n if (!fileDirectory.startsWith(process.cwd())) {\n throw new Error('File directory not found');\n }\n\n if (!existsSync(fileDirectory)) {\n mkdirSync(fileDirectory, { recursive: true });\n }\n\n // Write the file\n writeFileSync(abolsuteFilePath, fileContent);\n } catch (error) {\n throw new Error(\n `${x} Error writing file to ${colorizePath(filePath)}: ${error}`\n );\n }\n\n const transformedFileContent: FileContentConstructor = {\n nodeType: NodeType.File,\n [NodeType.File]: node.file,\n };\n\n return transformedFileContent;\n },\n};\n\n/**\n * Markdown file plugin\n */\n\nconst mardownFilePlugin: Plugins = {\n id: 'markdown-file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const simplifiedMarkdownNode: MarkdownContentConstructor = {\n nodeType: NodeType.Markdown,\n [NodeType.Markdown]: deepTransformNode(node.markdown, props),\n };\n\n return simplifiedMarkdownNode;\n },\n};\n\n/**\n * Insertion file plugin\n */\n\nconst insertionFilePlugin: Plugins = {\n id: 'insertion-file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const simplifiedInsertionNode: InsertionContentConstructor = {\n nodeType: NodeType.Insertion,\n [NodeType.Insertion]: deepTransformNode(node.insertion, props),\n };\n\n return simplifiedInsertionNode;\n },\n};\n\nexport const prepareContentDeclaration = async (dictionary: Dictionary) =>\n deepTransformNode(dictionary, {\n dictionaryKey: dictionary.key,\n keyPath: [],\n plugins: [writeFilePlugin, mardownFilePlugin, insertionFilePlugin],\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAgC;AAChC,kBAWO;AACP,gBAAqD;AACrD,kBAAqB;AAMrB,MAAM,kBAA2B;AAAA,EAC/B,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,qBAAS;AAAA,EAC1D,WAAW,CAAC,SAAsB;AAChC,UAAM,cAAc,KAAK;AACzB,UAAM,WAAW,KAAK;AAEtB,QAAI,OAAO,gBAAgB,UAAU;AACnC,YAAM,IAAI,MAAM,+BAA+B;AAAA,IACjD;AAEA,QAAI,OAAO,aAAa,UAAU;AAChC,YAAM,IAAI,MAAM,4BAA4B;AAAA,IAC9C;AAGA,QAAI;AACF,YAAM,uBAAmB,kBAAK,QAAQ,IAAI,GAAG,QAAQ;AAGrD,YAAM,oBAAgB,kBAAK,QAAQ,IAAI,GAAG,QAAQ;AAClD,UAAI,CAAC,cAAc,WAAW,QAAQ,IAAI,CAAC,GAAG;AAC5C,cAAM,IAAI,MAAM,0BAA0B;AAAA,MAC5C;AAEA,UAAI,KAAC,sBAAW,aAAa,GAAG;AAC9B,iCAAU,eAAe,EAAE,WAAW,KAAK,CAAC;AAAA,MAC9C;AAGA,mCAAc,kBAAkB,WAAW;AAAA,IAC7C,SAAS,OAAO;AACd,YAAM,IAAI;AAAA,QACR,GAAG,eAAC,8BAA0B,4BAAa,QAAQ,CAAC,KAAK,KAAK;AAAA,MAChE;AAAA,IACF;AAEA,UAAM,yBAAiD;AAAA,MACrD,UAAU,qBAAS;AAAA,MACnB,CAAC,qBAAS,IAAI,GAAG,KAAK;AAAA,IACxB;AAEA,WAAO;AAAA,EACT;AACF;AAMA,MAAM,oBAA6B;AAAA,EACjC,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,qBAAS;AAAA,EAC1D,WAAW,CAAC,MAAuB,OAAOA,uBAAsB;AAC9D,UAAM,yBAAqD;AAAA,MACzD,UAAU,qBAAS;AAAA,MACnB,CAAC,qBAAS,QAAQ,GAAGA,mBAAkB,KAAK,UAAU,KAAK;AAAA,IAC7D;AAEA,WAAO;AAAA,EACT;AACF;AAMA,MAAM,sBAA+B;AAAA,EACnC,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,qBAAS;AAAA,EAC1D,WAAW,CAAC,MAAwB,OAAOA,uBAAsB;AAC/D,UAAM,0BAAuD;AAAA,MAC3D,UAAU,qBAAS;AAAA,MACnB,CAAC,qBAAS,SAAS,GAAGA,mBAAkB,KAAK,WAAW,KAAK;AAAA,IAC/D;AAEA,WAAO;AAAA,EACT;AACF;AAEO,MAAM,4BAA4B,OAAO,mBAC9C,+BAAkB,YAAY;AAAA,EAC5B,eAAe,WAAW;AAAA,EAC1B,SAAS,CAAC;AAAA,EACV,SAAS,CAAC,iBAAiB,mBAAmB,mBAAmB;AACnE,CAAC;","names":["deepTransformNode"]}
|
|
@@ -26,6 +26,7 @@ var import_cleanOutputDir = require('./cleanOutputDir.cjs');
|
|
|
26
26
|
var import_listDictionariesPath = require('./listDictionariesPath.cjs');
|
|
27
27
|
var import_loadDictionaries = require('./loadDictionaries/loadDictionaries.cjs');
|
|
28
28
|
var import_declaration_file_to_dictionary = require('./transpiler/declaration_file_to_dictionary/index.cjs');
|
|
29
|
+
var import_writeRemoteDictionary = require('./transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeRemoteDictionary.cjs');
|
|
29
30
|
var import_createDictionaryEntryPoint = require('./transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs');
|
|
30
31
|
var import_dictionary_to_type = require('./transpiler/dictionary_to_type/index.cjs');
|
|
31
32
|
var import_writeConfiguration = require('./writeConfiguration/index.cjs');
|
|
@@ -40,14 +41,18 @@ const prepareIntlayer = async (configuration = (0, import_config.getConfiguratio
|
|
|
40
41
|
configuration,
|
|
41
42
|
projectRequire
|
|
42
43
|
);
|
|
43
|
-
const dictionariesOutput = await (0, import_declaration_file_to_dictionary.buildDictionary)(
|
|
44
|
+
const dictionariesOutput = await (0, import_declaration_file_to_dictionary.buildDictionary)(
|
|
45
|
+
[...dictionaries.localDictionaries, ...dictionaries.remoteDictionaries],
|
|
46
|
+
configuration
|
|
47
|
+
);
|
|
48
|
+
await (0, import_writeRemoteDictionary.writeRemoteDictionary)(dictionaries.remoteDictionaries, configuration);
|
|
44
49
|
const dictionariesPaths = Object.values(
|
|
45
50
|
dictionariesOutput?.mergedDictionaries ?? {}
|
|
46
51
|
).map((dictionary) => dictionary.dictionaryPath);
|
|
47
|
-
(0, import_dictionary_to_type.createTypes)(dictionariesPaths);
|
|
48
|
-
(0, import_createDictionaryEntryPoint.createDictionaryEntryPoint)(configuration);
|
|
52
|
+
await (0, import_dictionary_to_type.createTypes)(dictionariesPaths);
|
|
53
|
+
await (0, import_createDictionaryEntryPoint.createDictionaryEntryPoint)(configuration);
|
|
49
54
|
appLogger("Dictionaries built");
|
|
50
|
-
(0, import_dictionary_to_type.createModuleAugmentation)(configuration);
|
|
55
|
+
await (0, import_dictionary_to_type.createModuleAugmentation)(configuration);
|
|
51
56
|
appLogger("Module augmentation built", {
|
|
52
57
|
isVerbose: true
|
|
53
58
|
});
|
|
@@ -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 clean = false\n) => {\n const appLogger = getAppLogger(configuration);\n\n if (clean) {\n cleanOutputDir(configuration);\n }\n\n const files: string[] = listDictionaries(configuration);\n\n const dictionaries = await loadDictionaries(\n files,\n configuration,\n projectRequire\n );\n\n // Build
|
|
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 { writeRemoteDictionary } from './transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeRemoteDictionary';\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 clean = false\n) => {\n const appLogger = getAppLogger(configuration);\n\n if (clean) {\n cleanOutputDir(configuration);\n }\n\n const files: string[] = listDictionaries(configuration);\n\n const dictionaries = await loadDictionaries(\n files,\n configuration,\n projectRequire\n );\n\n // Build local dictionaries\n const dictionariesOutput = await buildDictionary(\n [...dictionaries.localDictionaries, ...dictionaries.remoteDictionaries],\n configuration\n );\n\n // Write remote dictionaries\n // Used as cache for next fetch\n await writeRemoteDictionary(dictionaries.remoteDictionaries, configuration);\n\n const dictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n await createTypes(dictionariesPaths);\n\n await createDictionaryEntryPoint(configuration);\n\n appLogger('Dictionaries built');\n\n await 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,mCAAsC;AACtC,wCAA2C;AAC3C,gCAGO;AACP,gCAAmC;AAE5B,MAAM,kBAAkB,OAC7B,oBAAgC,gCAAiB,GACjD,iBAAiB,8BACjB,QAAQ,UACL;AACH,QAAM,gBAAY,4BAAa,aAAa;AAE5C,MAAI,OAAO;AACT,8CAAe,aAAa;AAAA,EAC9B;AAEA,QAAM,YAAkB,8CAAiB,aAAa;AAEtD,QAAM,eAAe,UAAM;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAGA,QAAM,qBAAqB,UAAM;AAAA,IAC/B,CAAC,GAAG,aAAa,mBAAmB,GAAG,aAAa,kBAAkB;AAAA,IACtE;AAAA,EACF;AAIA,YAAM,oDAAsB,aAAa,oBAAoB,aAAa;AAE1E,QAAM,oBAAoB,OAAO;AAAA,IAC/B,oBAAoB,sBAAsB,CAAC;AAAA,EAC7C,EAAE,IAAI,CAAC,eAAe,WAAW,cAAc;AAE/C,YAAM,uCAAY,iBAAiB;AAEnC,YAAM,8DAA2B,aAAa;AAE9C,YAAU,oBAAoB;AAE9B,YAAM,oDAAyB,aAAa;AAE5C,YAAU,6BAA6B;AAAA,IACrC,WAAW;AAAA,EACb,CAAC;AAED,oDAAmB,aAAa;AAEhC,YAAU,yBAAyB;AAAA,IACjC,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/processPerLocaleDictionary.ts"],"sourcesContent":["import { deepTransformNode, Plugins, t, type Dictionary } from '@intlayer/core';\n\n/**\n *\n * Should transform per
|
|
1
|
+
{"version":3,"sources":["../../src/processPerLocaleDictionary.ts"],"sourcesContent":["import { deepTransformNode, Plugins, t, type Dictionary } from '@intlayer/core';\n\n/**\n *\n * Should transform per local dictionaries to multi-local dictionaries\n *\n * Example:\n *\n * ```json5\n * // .intlayer/dictionaries/home.fr.json\n * { 'key': 'home', 'locale': 'fr', 'content': { 'example': \"value\", ... } },\n * ```\n *\n * Result:\n *\n * ```json5\n * // .intlayer/dictionaries/home.json\n * {\n * 'key': 'home',\n * 'content': {\n * 'example': {\n * 'nodeType': 'translation',\n * 'translation': {\n * 'fr': 'valeur',\n * }\n * }, ... } },\n * ```\n *\n * @param dictionary\n * @returns\n */\nexport const processPerLocaleDictionary = (dictionary: Dictionary) => {\n const isPerLocaleDictionary = typeof dictionary.locale === 'string';\n\n if (!isPerLocaleDictionary) {\n return dictionary;\n }\n\n const transformStringToTranslationPlugin: Plugins = {\n id: 'transform-string-to-translation-plugin',\n canHandle: (node) => typeof node === 'string' || typeof node === 'number',\n transform: (node: string | number) =>\n t({ [dictionary.locale as string]: node }),\n };\n\n return {\n ...dictionary,\n locale: undefined,\n content: deepTransformNode(dictionary.content, {\n dictionaryKey: dictionary.key,\n keyPath: [],\n plugins: [transformStringToTranslationPlugin],\n }),\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA+D;AA+BxD,MAAM,6BAA6B,CAAC,eAA2B;AACpE,QAAM,wBAAwB,OAAO,WAAW,WAAW;AAE3D,MAAI,CAAC,uBAAuB;AAC1B,WAAO;AAAA,EACT;AAEA,QAAM,qCAA8C;AAAA,IAClD,IAAI;AAAA,IACJ,WAAW,CAAC,SAAS,OAAO,SAAS,YAAY,OAAO,SAAS;AAAA,IACjE,WAAW,CAAC,aACV,eAAE,EAAE,CAAC,WAAW,MAAgB,GAAG,KAAK,CAAC;AAAA,EAC7C;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,QAAQ;AAAA,IACR,aAAS,+BAAkB,WAAW,SAAS;AAAA,MAC7C,eAAe,WAAW;AAAA,MAC1B,SAAS,CAAC;AAAA,MACV,SAAS,CAAC,kCAAkC;AAAA,IAC9C,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -23,26 +23,40 @@ __export(buildIntlayerDictionary_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(buildIntlayerDictionary_exports);
|
|
24
24
|
var import_config = require("@intlayer/config");
|
|
25
25
|
var import_writeDynamicDictionary = require('./writeDynamicDictionary.cjs');
|
|
26
|
+
var import_writeFetchDictionary = require('./writeFetchDictionary.cjs');
|
|
26
27
|
var import_writeMergedDictionary = require('./writeMergedDictionary.cjs');
|
|
27
28
|
var import_writeUnmergedDictionary = require('./writeUnmergedDictionary.cjs');
|
|
28
|
-
const buildIntlayerDictionary = async (
|
|
29
|
+
const buildIntlayerDictionary = async (localDictionariesEntries, configuration = (0, import_config.getConfiguration)(), formats = ["cjs", "esm"]) => {
|
|
30
|
+
const { importMode } = configuration.build;
|
|
29
31
|
const unmergedDictionaries = await (0, import_writeUnmergedDictionary.writeUnmergedDictionaries)(
|
|
30
|
-
|
|
32
|
+
localDictionariesEntries,
|
|
31
33
|
configuration
|
|
32
34
|
);
|
|
33
35
|
const mergedDictionaries = await (0, import_writeMergedDictionary.writeMergedDictionaries)(
|
|
34
36
|
unmergedDictionaries,
|
|
35
37
|
configuration
|
|
36
38
|
);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
let dynamicDictionaries = null;
|
|
40
|
+
if (importMode === "dynamic" || importMode === "live") {
|
|
41
|
+
dynamicDictionaries = await (0, import_writeDynamicDictionary.writeDynamicDictionary)(
|
|
42
|
+
mergedDictionaries,
|
|
43
|
+
configuration,
|
|
44
|
+
formats
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
let fetchDictionaries = null;
|
|
48
|
+
if (importMode === "live") {
|
|
49
|
+
fetchDictionaries = await (0, import_writeFetchDictionary.writeFetchDictionary)(
|
|
50
|
+
dynamicDictionaries,
|
|
51
|
+
configuration,
|
|
52
|
+
formats
|
|
53
|
+
);
|
|
54
|
+
}
|
|
42
55
|
return {
|
|
43
56
|
unmergedDictionaries,
|
|
44
57
|
mergedDictionaries,
|
|
45
|
-
dynamicDictionaries
|
|
58
|
+
dynamicDictionaries,
|
|
59
|
+
fetchDictionaries
|
|
46
60
|
};
|
|
47
61
|
};
|
|
48
62
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.ts"],"sourcesContent":["// @ts-ignore: @intlayer/backend is not built yet\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.ts"],"sourcesContent":["// @ts-ignore: @intlayer/backend is not built yet\nimport { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport {\n LocalizedDictionaryOutput,\n writeDynamicDictionary,\n} from './writeDynamicDictionary';\nimport { writeFetchDictionary } from './writeFetchDictionary';\nimport { writeMergedDictionaries } from './writeMergedDictionary';\nimport { writeUnmergedDictionaries } from './writeUnmergedDictionary';\n\n/**\n * This function transpile the bundled code to to make dictionaries as JSON files\n */\nexport const buildIntlayerDictionary = async (\n localDictionariesEntries: Dictionary[],\n configuration = getConfiguration(),\n formats: ('cjs' | 'esm')[] = ['cjs', 'esm']\n) => {\n const { importMode } = configuration.build;\n\n const unmergedDictionaries = await writeUnmergedDictionaries(\n localDictionariesEntries,\n configuration\n );\n\n const mergedDictionaries = await writeMergedDictionaries(\n unmergedDictionaries,\n configuration\n );\n\n let dynamicDictionaries: LocalizedDictionaryOutput | null = null;\n\n if (importMode === 'dynamic' || importMode === 'live') {\n dynamicDictionaries = await writeDynamicDictionary(\n mergedDictionaries,\n configuration,\n formats\n );\n }\n\n let fetchDictionaries: LocalizedDictionaryOutput | null = null;\n\n if (importMode === 'live') {\n fetchDictionaries = await writeFetchDictionary(\n dynamicDictionaries!,\n configuration,\n formats\n );\n }\n\n return {\n unmergedDictionaries,\n mergedDictionaries,\n dynamicDictionaries,\n fetchDictionaries,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAiC;AAEjC,oCAGO;AACP,kCAAqC;AACrC,mCAAwC;AACxC,qCAA0C;AAKnC,MAAM,0BAA0B,OACrC,0BACA,oBAAgB,gCAAiB,GACjC,UAA6B,CAAC,OAAO,KAAK,MACvC;AACH,QAAM,EAAE,WAAW,IAAI,cAAc;AAErC,QAAM,uBAAuB,UAAM;AAAA,IACjC;AAAA,IACA;AAAA,EACF;AAEA,QAAM,qBAAqB,UAAM;AAAA,IAC/B;AAAA,IACA;AAAA,EACF;AAEA,MAAI,sBAAwD;AAE5D,MAAI,eAAe,aAAa,eAAe,QAAQ;AACrD,0BAAsB,UAAM;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,MAAI,oBAAsD;AAE1D,MAAI,eAAe,QAAQ;AACzB,wBAAoB,UAAM;AAAA,MACxB;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|