@intlayer/chokidar 5.5.2 → 5.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/cjs/chokidar/watcher.cjs +12 -3
  2. package/dist/cjs/chokidar/watcher.cjs.map +1 -1
  3. package/dist/cjs/cleanOutputDir.cjs +20 -3
  4. package/dist/cjs/cleanOutputDir.cjs.map +1 -1
  5. package/dist/cjs/getBuiltDynamicDictionariesPath.cjs +52 -0
  6. package/dist/cjs/getBuiltDynamicDictionariesPath.cjs.map +1 -0
  7. package/dist/cjs/{filterDictionaryLocales.cjs → getFilteredLocalesContent.cjs} +24 -12
  8. package/dist/cjs/getFilteredLocalesContent.cjs.map +1 -0
  9. package/dist/cjs/index.cjs +9 -3
  10. package/dist/cjs/index.cjs.map +1 -1
  11. package/dist/cjs/prepareIntlayer.cjs +5 -5
  12. package/dist/cjs/prepareIntlayer.cjs.map +1 -1
  13. package/dist/cjs/transpiler/declaration_file_to_dictionary/index.cjs +0 -1
  14. package/dist/cjs/transpiler/declaration_file_to_dictionary/index.cjs.map +1 -1
  15. package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.cjs +19 -8
  16. package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.cjs.map +1 -1
  17. package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.cjs +30 -0
  18. package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.cjs.map +1 -0
  19. package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.cjs +107 -0
  20. package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.cjs.map +1 -0
  21. package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.cjs +59 -0
  22. package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.cjs.map +1 -0
  23. package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.cjs +65 -0
  24. package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.cjs.map +1 -0
  25. package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs +44 -35
  26. package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs.map +1 -1
  27. package/dist/cjs/transpiler/dictionary_to_main/generateDictionaryListContent.cjs +1 -1
  28. package/dist/cjs/transpiler/dictionary_to_main/generateDictionaryListContent.cjs.map +1 -1
  29. package/dist/esm/chokidar/watcher.mjs +12 -3
  30. package/dist/esm/chokidar/watcher.mjs.map +1 -1
  31. package/dist/esm/cleanOutputDir.mjs +21 -4
  32. package/dist/esm/cleanOutputDir.mjs.map +1 -1
  33. package/dist/esm/getBuiltDynamicDictionariesPath.mjs +18 -0
  34. package/dist/esm/getBuiltDynamicDictionariesPath.mjs.map +1 -0
  35. package/dist/esm/getFilteredLocalesContent.mjs +49 -0
  36. package/dist/esm/getFilteredLocalesContent.mjs.map +1 -0
  37. package/dist/esm/index.mjs +6 -2
  38. package/dist/esm/index.mjs.map +1 -1
  39. package/dist/esm/prepareIntlayer.mjs +5 -5
  40. package/dist/esm/prepareIntlayer.mjs.map +1 -1
  41. package/dist/esm/transpiler/declaration_file_to_dictionary/index.mjs +0 -1
  42. package/dist/esm/transpiler/declaration_file_to_dictionary/index.mjs.map +1 -1
  43. package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.mjs +19 -8
  44. package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.mjs.map +1 -1
  45. package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.mjs +6 -0
  46. package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.mjs.map +1 -0
  47. package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.mjs +82 -0
  48. package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.mjs.map +1 -0
  49. package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.mjs +35 -0
  50. package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.mjs.map +1 -0
  51. package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.mjs +41 -0
  52. package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.mjs.map +1 -0
  53. package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs +44 -35
  54. package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs.map +1 -1
  55. package/dist/esm/transpiler/dictionary_to_main/generateDictionaryListContent.mjs +1 -1
  56. package/dist/esm/transpiler/dictionary_to_main/generateDictionaryListContent.mjs.map +1 -1
  57. package/dist/types/chokidar/watcher.d.ts.map +1 -1
  58. package/dist/types/cleanOutputDir.d.ts.map +1 -1
  59. package/dist/types/getBuiltDynamicDictionariesPath.d.ts +5 -0
  60. package/dist/types/getBuiltDynamicDictionariesPath.d.ts.map +1 -0
  61. package/dist/types/getFilteredLocalesContent.d.ts +4 -0
  62. package/dist/types/getFilteredLocalesContent.d.ts.map +1 -0
  63. package/dist/types/index.d.ts +3 -1
  64. package/dist/types/index.d.ts.map +1 -1
  65. package/dist/types/transpiler/declaration_file_to_dictionary/index.d.ts +5 -1
  66. package/dist/types/transpiler/declaration_file_to_dictionary/index.d.ts.map +1 -1
  67. package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.d.ts +5 -1
  68. package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.d.ts.map +1 -1
  69. package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.d.ts +2 -0
  70. package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.d.ts.map +1 -0
  71. package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.d.ts +31 -0
  72. package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.d.ts.map +1 -0
  73. package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.d.ts +25 -0
  74. package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.d.ts.map +1 -0
  75. package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.d.ts +28 -0
  76. package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.d.ts.map +1 -0
  77. package/dist/types/transpiler/dictionary_to_main/createDictionaryEntryPoint.d.ts +1 -1
  78. package/dist/types/transpiler/dictionary_to_main/createDictionaryEntryPoint.d.ts.map +1 -1
  79. package/package.json +14 -14
  80. package/dist/cjs/filterDictionaryLocales.cjs.map +0 -1
  81. package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.cjs +0 -95
  82. package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.cjs.map +0 -1
  83. package/dist/esm/filterDictionaryLocales.mjs +0 -37
  84. package/dist/esm/filterDictionaryLocales.mjs.map +0 -1
  85. package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.mjs +0 -69
  86. package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.mjs.map +0 -1
  87. package/dist/types/filterDictionaryLocales.d.ts +0 -4
  88. package/dist/types/filterDictionaryLocales.d.ts.map +0 -1
  89. package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.d.ts +0 -41
  90. package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.d.ts.map +0 -1
@@ -0,0 +1,59 @@
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 writeMergedDictionary_exports = {};
20
+ __export(writeMergedDictionary_exports, {
21
+ writeMergedDictionaries: () => writeMergedDictionaries
22
+ });
23
+ module.exports = __toCommonJS(writeMergedDictionary_exports);
24
+ var import_config = require("@intlayer/config");
25
+ var import_promises = require("fs/promises");
26
+ var import_path = require("path");
27
+ var import_mergeDictionaries = require('../../../mergeDictionaries.cjs');
28
+ var import_processPerLocaleDictionary = require('../../../processPerLocaleDictionary.cjs');
29
+ var import_formatDictionaryText = require('./formatDictionaryText.cjs');
30
+ const writeMergedDictionaries = async (groupedDictionaries, configuration = (0, import_config.getConfiguration)()) => {
31
+ const { dictionariesDir } = configuration.content;
32
+ await (0, import_promises.mkdir)((0, import_path.resolve)(dictionariesDir), { recursive: true });
33
+ let resultDictionariesPaths = {};
34
+ for await (const [key, dictionariesEntry] of Object.entries(
35
+ groupedDictionaries
36
+ )) {
37
+ if (key === "undefined") continue;
38
+ const multiLocaleDictionaries = dictionariesEntry.dictionaries.map(
39
+ (dictionary) => (0, import_processPerLocaleDictionary.processPerLocaleDictionary)(dictionary)
40
+ );
41
+ const mergedDictionary = (0, import_mergeDictionaries.mergeDictionaries)(multiLocaleDictionaries);
42
+ const contentString = (0, import_formatDictionaryText.formatDictionaryText)(mergedDictionary);
43
+ const outputFileName = `${key}.json`;
44
+ const resultFilePath = (0, import_path.resolve)(dictionariesDir, outputFileName);
45
+ await (0, import_promises.writeFile)(resultFilePath, contentString, "utf8").catch((err) => {
46
+ console.error(`Error creating merged ${outputFileName}:`, err);
47
+ });
48
+ resultDictionariesPaths[key] = {
49
+ dictionaryPath: resultFilePath,
50
+ dictionary: mergedDictionary
51
+ };
52
+ }
53
+ return resultDictionariesPaths;
54
+ };
55
+ // Annotate the CommonJS export names for ESM import in node:
56
+ 0 && (module.exports = {
57
+ writeMergedDictionaries
58
+ });
59
+ //# sourceMappingURL=writeMergedDictionary.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { mkdir, writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { mergeDictionaries } from '../../../mergeDictionaries';\nimport { processPerLocaleDictionary } from '../../../processPerLocaleDictionary';\nimport { formatDictionaryText } from './formatDictionaryText';\nimport { UnmergedDictionaryOutput } from './writeUnmergedDictionary';\n\nexport type MergedDictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type MergedDictionaryOutput = Record<string, MergedDictionaryResult>;\n\n/**\n * Write the merged dictionaries to the dictionariesDir\n * @param groupedDictionaries - The grouped dictionaries\n * @param configuration - The configuration\n * @returns The merged dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeMergedDictionaries = async (\n groupedDictionaries: UnmergedDictionaryOutput,\n configuration = getConfiguration()\n): Promise<MergedDictionaryOutput> => {\n const { dictionariesDir } = configuration.content;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n let resultDictionariesPaths: MergedDictionaryOutput = {};\n\n // Merge dictionaries with the same key and write to dictionariesDir\n for await (const [key, dictionariesEntry] of Object.entries(\n groupedDictionaries\n )) {\n if (key === 'undefined') continue;\n\n const multiLocaleDictionaries = dictionariesEntry.dictionaries.map(\n (dictionary) => processPerLocaleDictionary(dictionary)\n );\n\n const mergedDictionary = mergeDictionaries(multiLocaleDictionaries);\n\n const contentString = formatDictionaryText(mergedDictionary);\n\n const outputFileName = `${key}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n // Write the merged dictionary\n await writeFile(resultFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating merged ${outputFileName}:`, err);\n });\n\n resultDictionariesPaths[key] = {\n dictionaryPath: resultFilePath,\n dictionary: mergedDictionary,\n };\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AAEjC,sBAAiC;AACjC,kBAAwB;AACxB,+BAAkC;AAClC,wCAA2C;AAC3C,kCAAqC;AA0B9B,MAAM,0BAA0B,OACrC,qBACA,oBAAgB,gCAAiB,MACG;AACpC,QAAM,EAAE,gBAAgB,IAAI,cAAc;AAG1C,YAAM,2BAAM,qBAAQ,eAAe,GAAG,EAAE,WAAW,KAAK,CAAC;AAEzD,MAAI,0BAAkD,CAAC;AAGvD,mBAAiB,CAAC,KAAK,iBAAiB,KAAK,OAAO;AAAA,IAClD;AAAA,EACF,GAAG;AACD,QAAI,QAAQ,YAAa;AAEzB,UAAM,0BAA0B,kBAAkB,aAAa;AAAA,MAC7D,CAAC,mBAAe,8DAA2B,UAAU;AAAA,IACvD;AAEA,UAAM,uBAAmB,4CAAkB,uBAAuB;AAElE,UAAM,oBAAgB,kDAAqB,gBAAgB;AAE3D,UAAM,iBAAiB,GAAG,GAAG;AAC7B,UAAM,qBAAiB,qBAAQ,iBAAiB,cAAc;AAG9D,cAAM,2BAAU,gBAAgB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACpE,cAAQ,MAAM,yBAAyB,cAAc,KAAK,GAAG;AAAA,IAC/D,CAAC;AAED,4BAAwB,GAAG,IAAI;AAAA,MAC7B,gBAAgB;AAAA,MAChB,YAAY;AAAA,IACd;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,65 @@
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 writeUnmergedDictionary_exports = {};
20
+ __export(writeUnmergedDictionary_exports, {
21
+ writeUnmergedDictionaries: () => writeUnmergedDictionaries
22
+ });
23
+ module.exports = __toCommonJS(writeUnmergedDictionary_exports);
24
+ var import_config = require("@intlayer/config");
25
+ var import_promises = require("fs/promises");
26
+ var import_path = require("path");
27
+ var import_formatDictionaryText = require('./formatDictionaryText.cjs');
28
+ const groupDictionariesByKey = (dictionaries) => {
29
+ return dictionaries.reduce(
30
+ (acc, dictionary) => {
31
+ const key = dictionary.key;
32
+ if (!acc[key]) {
33
+ acc[key] = [];
34
+ }
35
+ acc[key].push(dictionary);
36
+ return acc;
37
+ },
38
+ {}
39
+ );
40
+ };
41
+ const writeUnmergedDictionaries = async (dictionaries, configuration = (0, import_config.getConfiguration)()) => {
42
+ const { unmergedDictionariesDir } = configuration.content;
43
+ await (0, import_promises.mkdir)((0, import_path.resolve)(unmergedDictionariesDir), { recursive: true });
44
+ const groupedDictionaries = groupDictionariesByKey(dictionaries);
45
+ let resultDictionariesPaths = {};
46
+ for await (const [key, dictionaries2] of Object.entries(groupedDictionaries)) {
47
+ if (key === "undefined") continue;
48
+ const contentString = (0, import_formatDictionaryText.formatDictionaryText)(dictionaries2);
49
+ const outputFileName = `${key}.json`;
50
+ const unmergedFilePath = (0, import_path.resolve)(unmergedDictionariesDir, outputFileName);
51
+ await (0, import_promises.writeFile)(unmergedFilePath, contentString, "utf8").catch((err) => {
52
+ console.error(`Error creating unmerged ${outputFileName}:`, err);
53
+ });
54
+ resultDictionariesPaths[key] = {
55
+ dictionaryPath: unmergedFilePath,
56
+ dictionaries: dictionaries2
57
+ };
58
+ }
59
+ return resultDictionariesPaths;
60
+ };
61
+ // Annotate the CommonJS export names for ESM import in node:
62
+ 0 && (module.exports = {
63
+ writeUnmergedDictionaries
64
+ });
65
+ //# sourceMappingURL=writeUnmergedDictionary.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { mkdir, writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { formatDictionaryText } from './formatDictionaryText';\n\nconst groupDictionariesByKey = (\n dictionaries: Dictionary[]\n): Record<string, Dictionary[]> => {\n return dictionaries.reduce(\n (acc, dictionary) => {\n const key = dictionary.key;\n if (!acc[key]) {\n acc[key] = [];\n }\n acc[key].push(dictionary);\n return acc;\n },\n {} as Record<string, Dictionary[]>\n );\n};\n\nexport type UnmergedDictionaryResult = {\n dictionaryPath: string;\n dictionaries: Dictionary[];\n};\n\nexport type UnmergedDictionaryOutput = Record<string, UnmergedDictionaryResult>;\n\n/**\n * Write the unmerged dictionaries to the unmergedDictionariesDir\n * @param dictionaries - The dictionaries to write\n * @param configuration - The configuration\n * @returns The grouped dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * console.log(unmergedDictionaries);\n *\n * // .intlayer/unmerged_dictionaries/home.json\n * // {\n * // [\n * // { key: 'home', content: { ... } },\n * // { key: 'home', content: { ... } },\n * // ],\n * // }\n * ```\n */\nexport const writeUnmergedDictionaries = async (\n dictionaries: Dictionary[],\n configuration = getConfiguration()\n): Promise<UnmergedDictionaryOutput> => {\n const { unmergedDictionariesDir } = configuration.content;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(unmergedDictionariesDir), { recursive: true });\n\n // Group dictionaries by key and write to unmergedDictionariesDir\n const groupedDictionaries = groupDictionariesByKey(dictionaries);\n\n let resultDictionariesPaths: UnmergedDictionaryOutput = {};\n\n for await (const [key, dictionaries] of Object.entries(groupedDictionaries)) {\n if (key === 'undefined') continue;\n\n const contentString = formatDictionaryText(dictionaries);\n\n const outputFileName = `${key}.json`;\n const unmergedFilePath = resolve(unmergedDictionariesDir, outputFileName);\n\n // Write the grouped dictionaries\n await writeFile(unmergedFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating unmerged ${outputFileName}:`, err);\n });\n\n resultDictionariesPaths[key] = {\n dictionaryPath: unmergedFilePath,\n dictionaries: dictionaries,\n };\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AAEjC,sBAAiC;AACjC,kBAAwB;AACxB,kCAAqC;AAErC,MAAM,yBAAyB,CAC7B,iBACiC;AACjC,SAAO,aAAa;AAAA,IAClB,CAAC,KAAK,eAAe;AACnB,YAAM,MAAM,WAAW;AACvB,UAAI,CAAC,IAAI,GAAG,GAAG;AACb,YAAI,GAAG,IAAI,CAAC;AAAA,MACd;AACA,UAAI,GAAG,EAAE,KAAK,UAAU;AACxB,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AACF;AA6BO,MAAM,4BAA4B,OACvC,cACA,oBAAgB,gCAAiB,MACK;AACtC,QAAM,EAAE,wBAAwB,IAAI,cAAc;AAGlD,YAAM,2BAAM,qBAAQ,uBAAuB,GAAG,EAAE,WAAW,KAAK,CAAC;AAGjE,QAAM,sBAAsB,uBAAuB,YAAY;AAE/D,MAAI,0BAAoD,CAAC;AAEzD,mBAAiB,CAAC,KAAKA,aAAY,KAAK,OAAO,QAAQ,mBAAmB,GAAG;AAC3E,QAAI,QAAQ,YAAa;AAEzB,UAAM,oBAAgB,kDAAqBA,aAAY;AAEvD,UAAM,iBAAiB,GAAG,GAAG;AAC7B,UAAM,uBAAmB,qBAAQ,yBAAyB,cAAc;AAGxE,cAAM,2BAAU,kBAAkB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACtE,cAAQ,MAAM,2BAA2B,cAAc,KAAK,GAAG;AAAA,IACjE,CAAC;AAED,4BAAwB,GAAG,IAAI;AAAA,MAC7B,gBAAgB;AAAA,MAChB,cAAcA;AAAA,IAChB;AAAA,EACF;AAEA,SAAO;AACT;","names":["dictionaries"]}
@@ -25,50 +25,59 @@ var import_config = require("@intlayer/config");
25
25
  var import_fs = require("fs");
26
26
  var import_path = require("path");
27
27
  var import_getBuiltDictionariesPath = require('../../getBuiltDictionariesPath.cjs');
28
+ var import_getBuiltDynamicDictionariesPath = require('../../getBuiltDynamicDictionariesPath.cjs');
28
29
  var import_getBuiltUnmergedDictionariesPath = require('../../getBuiltUnmergedDictionariesPath.cjs');
29
30
  var import_generateDictionaryListContent = require('./generateDictionaryListContent.cjs');
30
- const createDictionaryEntryPoint = (configuration = (0, import_config.getConfiguration)(), dictionariesKeys) => {
31
+ const filterDictionaries = (paths, keys) => {
32
+ if (!keys) return paths;
33
+ return paths.filter(
34
+ (path) => keys.some((key) => path.endsWith(`${key}.json`))
35
+ );
36
+ };
37
+ const writeDictionaryFiles = (paths, fileName, format, configuration = (0, import_config.getConfiguration)()) => {
38
+ const content = (0, import_generateDictionaryListContent.generateDictionaryListContent)(paths, format, configuration);
39
+ const extension = format === "cjs" ? "cjs" : "mjs";
40
+ const { mainDir } = configuration.content;
41
+ (0, import_fs.writeFileSync)((0, import_path.resolve)(mainDir, `${fileName}.${extension}`), content);
42
+ };
43
+ const createDictionaryEntryPoint = (configuration = (0, import_config.getConfiguration)(), dictionariesKeys, formats = ["cjs", "esm"]) => {
31
44
  const { mainDir } = configuration.content;
32
45
  if (!(0, import_fs.existsSync)(mainDir)) {
33
46
  (0, import_fs.mkdirSync)(mainDir, { recursive: true });
34
47
  }
35
- let dictionariesPath = (0, import_getBuiltDictionariesPath.getBuiltDictionariesPath)(configuration);
36
- if (dictionariesKeys) {
37
- dictionariesPath = dictionariesPath.filter(
38
- (dictionaryPath) => dictionariesKeys.some((key) => dictionaryPath.endsWith(`${key}.json`))
48
+ const dictionariesPath = filterDictionaries(
49
+ (0, import_getBuiltDictionariesPath.getBuiltDictionariesPath)(configuration),
50
+ dictionariesKeys
51
+ );
52
+ for (const format of formats) {
53
+ writeDictionaryFiles(
54
+ dictionariesPath,
55
+ "dictionaries",
56
+ format,
57
+ configuration
39
58
  );
40
59
  }
41
- const cjsContent = (0, import_generateDictionaryListContent.generateDictionaryListContent)(
42
- dictionariesPath,
43
- "cjs",
44
- configuration
45
- );
46
- (0, import_fs.writeFileSync)((0, import_path.resolve)(mainDir, "dictionaries.cjs"), cjsContent);
47
- const esmContent = (0, import_generateDictionaryListContent.generateDictionaryListContent)(
48
- dictionariesPath,
49
- "esm",
50
- configuration
51
- );
52
- (0, import_fs.writeFileSync)((0, import_path.resolve)(mainDir, "dictionaries.mjs"), esmContent);
53
60
  const unmergedDictionariesPath = (0, import_getBuiltUnmergedDictionariesPath.getBuiltUnmergedDictionariesPath)(configuration);
54
- const unmergedCjsContent = (0, import_generateDictionaryListContent.generateDictionaryListContent)(
55
- unmergedDictionariesPath,
56
- "cjs",
57
- configuration
58
- );
59
- (0, import_fs.writeFileSync)(
60
- (0, import_path.resolve)(mainDir, "unmerged_dictionaries.cjs"),
61
- unmergedCjsContent
62
- );
63
- const unmergedEsmContent = (0, import_generateDictionaryListContent.generateDictionaryListContent)(
64
- unmergedDictionariesPath,
65
- "esm",
66
- configuration
67
- );
68
- (0, import_fs.writeFileSync)(
69
- (0, import_path.resolve)(mainDir, "unmerged_dictionaries.mjs"),
70
- unmergedEsmContent
71
- );
61
+ for (const format of formats) {
62
+ writeDictionaryFiles(
63
+ unmergedDictionariesPath,
64
+ "unmerged_dictionaries",
65
+ format,
66
+ configuration
67
+ );
68
+ }
69
+ for (const format of formats) {
70
+ const dynamicDictionariesPathCJS = (0, import_getBuiltDynamicDictionariesPath.getBuiltDynamicDictionariesPath)(
71
+ configuration,
72
+ format
73
+ );
74
+ writeDictionaryFiles(
75
+ dynamicDictionariesPathCJS,
76
+ "dynamic_dictionaries",
77
+ format,
78
+ configuration
79
+ );
80
+ }
72
81
  };
73
82
  // Annotate the CommonJS export names for ESM import in node:
74
83
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/createDictionaryEntryPoint.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { resolve } from 'path';\nimport { getBuiltDictionariesPath } from '../../getBuiltDictionariesPath';\nimport { getBuiltUnmergedDictionariesPath } from '../../getBuiltUnmergedDictionariesPath';\nimport { generateDictionaryListContent } from './generateDictionaryListContent';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const createDictionaryEntryPoint = (\n configuration = getConfiguration(),\n dictionariesKeys?: string[]\n) => {\n const { mainDir } = configuration.content;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n let dictionariesPath: string[] = getBuiltDictionariesPath(configuration);\n\n if (dictionariesKeys) {\n dictionariesPath = dictionariesPath.filter((dictionaryPath) =>\n dictionariesKeys.some((key) => dictionaryPath.endsWith(`${key}.json`))\n );\n }\n\n // Create the dictionary list file\n const cjsContent = generateDictionaryListContent(\n dictionariesPath,\n 'cjs',\n configuration\n );\n writeFileSync(resolve(mainDir, 'dictionaries.cjs'), cjsContent);\n\n const esmContent = generateDictionaryListContent(\n dictionariesPath,\n 'esm',\n configuration\n );\n writeFileSync(resolve(mainDir, 'dictionaries.mjs'), esmContent);\n\n const unmergedDictionariesPath: string[] =\n getBuiltUnmergedDictionariesPath(configuration);\n\n const unmergedCjsContent = generateDictionaryListContent(\n unmergedDictionariesPath,\n 'cjs',\n configuration\n );\n writeFileSync(\n resolve(mainDir, 'unmerged_dictionaries.cjs'),\n unmergedCjsContent\n );\n\n const unmergedEsmContent = generateDictionaryListContent(\n unmergedDictionariesPath,\n 'esm',\n configuration\n );\n writeFileSync(\n resolve(mainDir, 'unmerged_dictionaries.mjs'),\n unmergedEsmContent\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,gBAAqD;AACrD,kBAAwB;AACxB,sCAAyC;AACzC,8CAAiD;AACjD,2CAA8C;AAKvC,MAAM,6BAA6B,CACxC,oBAAgB,gCAAiB,GACjC,qBACG;AACH,QAAM,EAAE,QAAQ,IAAI,cAAc;AAGlC,MAAI,KAAC,sBAAW,OAAO,GAAG;AACxB,6BAAU,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACxC;AAEA,MAAI,uBAA6B,0DAAyB,aAAa;AAEvE,MAAI,kBAAkB;AACpB,uBAAmB,iBAAiB;AAAA,MAAO,CAAC,mBAC1C,iBAAiB,KAAK,CAAC,QAAQ,eAAe,SAAS,GAAG,GAAG,OAAO,CAAC;AAAA,IACvE;AAAA,EACF;AAGA,QAAM,iBAAa;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,mCAAc,qBAAQ,SAAS,kBAAkB,GAAG,UAAU;AAE9D,QAAM,iBAAa;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,mCAAc,qBAAQ,SAAS,kBAAkB,GAAG,UAAU;AAE9D,QAAM,+BACJ,0EAAiC,aAAa;AAEhD,QAAM,yBAAqB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA;AAAA,QACE,qBAAQ,SAAS,2BAA2B;AAAA,IAC5C;AAAA,EACF;AAEA,QAAM,yBAAqB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA;AAAA,QACE,qBAAQ,SAAS,2BAA2B;AAAA,IAC5C;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/createDictionaryEntryPoint.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { resolve } from 'path';\nimport { getBuiltDictionariesPath } from '../../getBuiltDictionariesPath';\nimport { getBuiltDynamicDictionariesPath } from '../../getBuiltDynamicDictionariesPath';\nimport { getBuiltUnmergedDictionariesPath } from '../../getBuiltUnmergedDictionariesPath';\nimport { generateDictionaryListContent } from './generateDictionaryListContent';\n\nconst filterDictionaries = (paths: string[], keys?: string[]) => {\n if (!keys) return paths;\n return paths.filter((path) =>\n keys.some((key) => path.endsWith(`${key}.json`))\n );\n};\n\nconst writeDictionaryFiles = (\n paths: string[],\n fileName: string,\n format: 'cjs' | 'esm',\n configuration = getConfiguration()\n) => {\n const content = generateDictionaryListContent(paths, format, configuration);\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const { mainDir } = configuration.content;\n\n writeFileSync(resolve(mainDir, `${fileName}.${extension}`), content);\n};\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const createDictionaryEntryPoint = (\n configuration = getConfiguration(),\n dictionariesKeys?: string[],\n formats: ('cjs' | 'esm')[] = ['cjs', 'esm']\n) => {\n const { mainDir } = configuration.content;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n const dictionariesPath = filterDictionaries(\n getBuiltDictionariesPath(configuration),\n dictionariesKeys\n );\n\n for (const format of formats) {\n writeDictionaryFiles(\n dictionariesPath,\n 'dictionaries',\n format,\n configuration\n );\n }\n\n const unmergedDictionariesPath =\n getBuiltUnmergedDictionariesPath(configuration);\n\n for (const format of formats) {\n writeDictionaryFiles(\n unmergedDictionariesPath,\n 'unmerged_dictionaries',\n format,\n configuration\n );\n }\n\n for (const format of formats) {\n const dynamicDictionariesPathCJS = getBuiltDynamicDictionariesPath(\n configuration,\n format\n );\n\n writeDictionaryFiles(\n dynamicDictionariesPathCJS,\n 'dynamic_dictionaries',\n format,\n configuration\n );\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,gBAAqD;AACrD,kBAAwB;AACxB,sCAAyC;AACzC,6CAAgD;AAChD,8CAAiD;AACjD,2CAA8C;AAE9C,MAAM,qBAAqB,CAAC,OAAiB,SAAoB;AAC/D,MAAI,CAAC,KAAM,QAAO;AAClB,SAAO,MAAM;AAAA,IAAO,CAAC,SACnB,KAAK,KAAK,CAAC,QAAQ,KAAK,SAAS,GAAG,GAAG,OAAO,CAAC;AAAA,EACjD;AACF;AAEA,MAAM,uBAAuB,CAC3B,OACA,UACA,QACA,oBAAgB,gCAAiB,MAC9B;AACH,QAAM,cAAU,oEAA8B,OAAO,QAAQ,aAAa;AAC1E,QAAM,YAAY,WAAW,QAAQ,QAAQ;AAE7C,QAAM,EAAE,QAAQ,IAAI,cAAc;AAElC,mCAAc,qBAAQ,SAAS,GAAG,QAAQ,IAAI,SAAS,EAAE,GAAG,OAAO;AACrE;AAKO,MAAM,6BAA6B,CACxC,oBAAgB,gCAAiB,GACjC,kBACA,UAA6B,CAAC,OAAO,KAAK,MACvC;AACH,QAAM,EAAE,QAAQ,IAAI,cAAc;AAGlC,MAAI,KAAC,sBAAW,OAAO,GAAG;AACxB,6BAAU,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACxC;AAEA,QAAM,mBAAmB;AAAA,QACvB,0DAAyB,aAAa;AAAA,IACtC;AAAA,EACF;AAEA,aAAW,UAAU,SAAS;AAC5B;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,+BACJ,0EAAiC,aAAa;AAEhD,aAAW,UAAU,SAAS;AAC5B;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,aAAW,UAAU,SAAS;AAC5B,UAAM,iCAA6B;AAAA,MACjC;AAAA,MACA;AAAA,IACF;AAEA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -36,7 +36,7 @@ const generateDictionaryListContent = (dictionaries, format = "esm", configurati
36
36
  }));
37
37
  dictionariesRef.forEach((dictionary) => {
38
38
  if (format === "esm")
39
- content += `import ${dictionary.hash} from '${dictionary.relativePath}';
39
+ content += `import ${dictionary.hash} from '${dictionary.relativePath}' with { type: 'json' };
40
40
  `;
41
41
  if (format === "cjs")
42
42
  content += `const ${dictionary.hash} = require('${dictionary.relativePath}');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/generateDictionaryListContent.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { basename, extname, relative } from 'path';\nimport { getFileHash } from '../../utils';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryListContent = (\n dictionaries: string[],\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { mainDir } = configuration.content;\n\n let content = '';\n\n const dictionariesRef = dictionaries.map((dictionaryPath) => ({\n relativePath: relative(mainDir, dictionaryPath),\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n if (format === 'esm')\n content += `import ${dictionary.hash} from '${dictionary.relativePath}';\\n`;\n if (format === 'cjs')\n content += `const ${dictionary.hash} = require('${dictionary.relativePath}');\\n`;\n });\n\n content += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": ${dictionary.hash}`)\n .join(',\\n');\n\n if (format === 'esm')\n content += `export default {\\n${formattedDictionaryMap}\\n};\\n`;\n if (format === 'cjs')\n content += `module.exports = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n return content;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,kBAA4C;AAC5C,mBAA4B;AAKrB,MAAM,gCAAgC,CAC3C,cACA,SAAwB,OACxB,oBAAgB,gCAAiB,MACtB;AACX,QAAM,EAAE,QAAQ,IAAI,cAAc;AAElC,MAAI,UAAU;AAEd,QAAM,kBAAkB,aAAa,IAAI,CAAC,oBAAoB;AAAA,IAC5D,kBAAc,sBAAS,SAAS,cAAc;AAAA,IAC9C,QAAI,sBAAS,oBAAgB,qBAAQ,cAAc,CAAC;AAAA;AAAA,IACpD,MAAM,QAAI,0BAAY,cAAc,CAAC;AAAA;AAAA,EACvC,EAAE;AAGF,kBAAgB,QAAQ,CAAC,eAAe;AACtC,QAAI,WAAW;AACb,iBAAW,UAAU,WAAW,IAAI,UAAU,WAAW,YAAY;AAAA;AACvE,QAAI,WAAW;AACb,iBAAW,SAAS,WAAW,IAAI,eAAe,WAAW,YAAY;AAAA;AAAA,EAC7E,CAAC;AAED,aAAW;AAGX,QAAM,yBAAiC,gBACpC,IAAI,CAAC,eAAe,MAAM,WAAW,EAAE,MAAM,WAAW,IAAI,EAAE,EAC9D,KAAK,KAAK;AAEb,MAAI,WAAW;AACb,eAAW;AAAA,EAAqB,sBAAsB;AAAA;AAAA;AACxD,MAAI,WAAW;AACb,eAAW;AAAA,EAAuB,sBAAsB;AAAA;AAAA;AAE1D,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/generateDictionaryListContent.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { basename, extname, relative } from 'path';\nimport { getFileHash } from '../../utils';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryListContent = (\n dictionaries: string[],\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { mainDir } = configuration.content;\n\n let content = '';\n\n const dictionariesRef = dictionaries.map((dictionaryPath) => ({\n relativePath: relative(mainDir, dictionaryPath),\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n if (format === 'esm')\n content += `import ${dictionary.hash} from '${dictionary.relativePath}' with { type: 'json' };\\n`;\n if (format === 'cjs')\n content += `const ${dictionary.hash} = require('${dictionary.relativePath}');\\n`;\n });\n\n content += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": ${dictionary.hash}`)\n .join(',\\n');\n\n if (format === 'esm')\n content += `export default {\\n${formattedDictionaryMap}\\n};\\n`;\n if (format === 'cjs')\n content += `module.exports = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n return content;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,kBAA4C;AAC5C,mBAA4B;AAKrB,MAAM,gCAAgC,CAC3C,cACA,SAAwB,OACxB,oBAAgB,gCAAiB,MACtB;AACX,QAAM,EAAE,QAAQ,IAAI,cAAc;AAElC,MAAI,UAAU;AAEd,QAAM,kBAAkB,aAAa,IAAI,CAAC,oBAAoB;AAAA,IAC5D,kBAAc,sBAAS,SAAS,cAAc;AAAA,IAC9C,QAAI,sBAAS,oBAAgB,qBAAQ,cAAc,CAAC;AAAA;AAAA,IACpD,MAAM,QAAI,0BAAY,cAAc,CAAC;AAAA;AAAA,EACvC,EAAE;AAGF,kBAAgB,QAAQ,CAAC,eAAe;AACtC,QAAI,WAAW;AACb,iBAAW,UAAU,WAAW,IAAI,UAAU,WAAW,YAAY;AAAA;AACvE,QAAI,WAAW;AACb,iBAAW,SAAS,WAAW,IAAI,eAAe,WAAW,YAAY;AAAA;AAAA,EAC7E,CAAC;AAED,aAAW;AAGX,QAAM,yBAAiC,gBACpC,IAAI,CAAC,eAAe,MAAM,WAAW,EAAE,MAAM,WAAW,IAAI,EAAE,EAC9D,KAAK,KAAK;AAEb,MAAI,WAAW;AACb,eAAW;AAAA,EAAqB,sBAAsB;AAAA;AAAA;AACxD,MAAI,WAAW;AACb,eAAW;AAAA,EAAuB,sBAAsB;AAAA;AAAA;AAE1D,SAAO;AACT;","names":[]}
@@ -26,7 +26,10 @@ const handleAdditionalContentDeclarationFile = async (filePath, configuration) =
26
26
  }
27
27
  );
28
28
  const localeDictionaries = await loadLocalDictionaries(filePath);
29
- const dictionariesPaths = await buildDictionary(localeDictionaries);
29
+ const dictionariesOutput = await buildDictionary(localeDictionaries);
30
+ const dictionariesPaths = Object.values(
31
+ dictionariesOutput?.mergedDictionaries ?? {}
32
+ ).map((dictionary) => dictionary.dictionaryPath);
30
33
  createTypes(dictionariesPaths);
31
34
  createDictionaryEntryPoint();
32
35
  appLogger("Dictionaries built", {
@@ -46,7 +49,10 @@ const handleUnlikedContentDeclarationFile = async (filePath, configuration) => {
46
49
  });
47
50
  const files = listDictionaries(configuration);
48
51
  const localeDictionaries = await loadLocalDictionaries(files);
49
- const dictionariesPaths = await buildDictionary(localeDictionaries);
52
+ const dictionariesOutput = await buildDictionary(localeDictionaries);
53
+ const dictionariesPaths = Object.values(
54
+ dictionariesOutput?.mergedDictionaries ?? {}
55
+ ).map((dictionary) => dictionary.dictionaryPath);
50
56
  createTypes(dictionariesPaths);
51
57
  createDictionaryEntryPoint();
52
58
  appLogger("Dictionaries rebuilt", {
@@ -65,7 +71,10 @@ const handleContentDeclarationFileChange = async (filePath, configuration) => {
65
71
  isVerbose: true
66
72
  });
67
73
  const localeDictionaries = await loadLocalDictionaries(filePath);
68
- const updatedDictionariesPaths = await buildDictionary(localeDictionaries);
74
+ const dictionariesOutput = await buildDictionary(localeDictionaries);
75
+ const updatedDictionariesPaths = Object.values(
76
+ dictionariesOutput?.mergedDictionaries ?? {}
77
+ ).map((dictionary) => dictionary.dictionaryPath);
69
78
  const allDictionariesPaths = getBuiltDictionariesPath();
70
79
  createTypes(updatedDictionariesPaths);
71
80
  appLogger("TypeScript types built", {
@@ -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, relative } 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 { 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';\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 const { content } = config;\n\n // Process the file with the functionToRun\n appLogger(\n `Additional file detected: ${relative(content.baseDir, filePath)}`,\n {\n isVerbose: true,\n }\n );\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n\n const dictionariesPaths = await buildDictionary(localeDictionaries);\n\n createTypes(dictionariesPaths);\n\n 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 const { content } = config;\n\n // Process the file with the functionToRun\n appLogger(`Unlinked detected: ${relative(content.baseDir, filePath)}`, {\n isVerbose: true,\n });\n\n const files: string[] = listDictionaries(configuration);\n\n const localeDictionaries = await loadLocalDictionaries(files);\n\n const dictionariesPaths = await buildDictionary(localeDictionaries);\n\n createTypes(dictionariesPaths);\n\n createDictionaryEntryPoint();\n\n appLogger('Dictionaries rebuilt', {\n isVerbose: true,\n });\n\n 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 const { content } = config;\n\n // Process the file with the functionToRun\n appLogger(`Change detected: ${relative(content.baseDir, filePath)}`, {\n isVerbose: true,\n });\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n\n const updatedDictionariesPaths = await buildDictionary(localeDictionaries);\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 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,EAGE;AAAA,EACA;AAAA,OACK;AACP,SAAS,UAAU,gBAAgB;AAEnC,SAA+B,SAAS,qBAAqB;AAC7D,SAAS,gCAAgC;AACzC,SAAS,wBAAwB;AACjC,SAAS,6BAA6B;AACtC,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAChC,SAAS,kCAAkC;AAC3C;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP,MAAM,qBAAqB,oBAAI,IAAY;AAEpC,MAAM,yCAAyC,OACpD,UACA,kBACG;AACH,QAAM,SAAS,iBAAiB,iBAAiB;AACjD,QAAM,YAAY,aAAa,MAAM;AACrC,QAAM,EAAE,QAAQ,IAAI;AAGpB;AAAA,IACE,6BAA6B,SAAS,QAAQ,SAAS,QAAQ,CAAC;AAAA,IAChE;AAAA,MACE,WAAW;AAAA,IACb;AAAA,EACF;AAEA,QAAM,qBAAqB,MAAM,sBAAsB,QAAQ;AAE/D,QAAM,oBAAoB,MAAM,gBAAgB,kBAAkB;AAElE,cAAY,iBAAiB;AAE7B,6BAA2B;AAE3B,YAAU,sBAAsB;AAAA,IAC9B,WAAW;AAAA,EACb,CAAC;AAED,2BAAyB;AAEzB,YAAU,6BAA6B;AAAA,IACrC,WAAW;AAAA,EACb,CAAC;AACH;AAEO,MAAM,sCAAsC,OACjD,UACA,kBACG;AACH,QAAM,SAAS,iBAAiB,iBAAiB;AACjD,QAAM,YAAY,aAAa,MAAM;AACrC,QAAM,EAAE,QAAQ,IAAI;AAGpB,YAAU,sBAAsB,SAAS,QAAQ,SAAS,QAAQ,CAAC,IAAI;AAAA,IACrE,WAAW;AAAA,EACb,CAAC;AAED,QAAM,QAAkB,iBAAiB,aAAa;AAEtD,QAAM,qBAAqB,MAAM,sBAAsB,KAAK;AAE5D,QAAM,oBAAoB,MAAM,gBAAgB,kBAAkB;AAElE,cAAY,iBAAiB;AAE7B,6BAA2B;AAE3B,YAAU,wBAAwB;AAAA,IAChC,WAAW;AAAA,EACb,CAAC;AAED,2BAAyB;AAEzB,YAAU,6BAA6B;AAAA,IACrC,WAAW;AAAA,EACb,CAAC;AACH;AAEO,MAAM,qCAAqC,OAChD,UACA,kBACG;AACH,QAAM,SAAS,iBAAiB,iBAAiB;AACjD,QAAM,YAAY,aAAa,MAAM;AACrC,QAAM,EAAE,QAAQ,IAAI;AAGpB,YAAU,oBAAoB,SAAS,QAAQ,SAAS,QAAQ,CAAC,IAAI;AAAA,IACnE,WAAW;AAAA,EACb,CAAC;AAED,QAAM,qBAAqB,MAAM,sBAAsB,QAAQ;AAE/D,QAAM,2BAA2B,MAAM,gBAAgB,kBAAkB;AACzE,QAAM,uBAAiC,yBAAyB;AAEhE,cAAY,wBAAwB;AACpC,YAAU,0BAA0B;AAAA,IAClC,WAAW;AAAA,EACb,CAAC;AAED,MACE,yBAAyB;AAAA,IACvB,CAAC,0BACC,CAAC,qBAAqB,SAAS,qBAAqB;AAAA,EACxD,GACA;AACA,+BAA2B;AAE3B,cAAU,yBAAyB;AAAA,MACjC,WAAW;AAAA,IACb,CAAC;AAAA,EACH;AACF;AAQO,MAAM,QAAQ,CAAC,YAA2B;AAC/C,QAAM,gBAAgB,SAAS,iBAAiB,iBAAiB;AACjE,QAAM,YAAY,aAAa,aAAa;AAE5C,QAAM,EAAE,OAAO,aAAa,4BAA4B,IACtD,cAAc;AAGhB,SAAO,cAAc,6BAA6B;AAAA,IAChD,YAAY;AAAA;AAAA,IACZ,eAAe;AAAA;AAAA,IACf,GAAG;AAAA,EACL,CAAC,EACE,GAAG,OAAO,OAAO,aAAa;AAC7B,UAAM,WAAW,SAAS,QAAQ;AAClC,uBAAmB,IAAI,QAAQ;AAE/B,UAAM,uCAAuC,UAAU,aAAa;AAEpE,eAAW,MAAM,mBAAmB,OAAO,QAAQ,GAAG,GAAI;AAAA,EAC5D,CAAC,EACA;AAAA,IACC;AAAA,IACA,OAAO,aACL,MAAM,mCAAmC,UAAU,aAAa;AAAA,EACpE,EACC,GAAG,UAAU,OAAO,aAAa;AAChC,eAAW,YAAY;AACrB,YAAM,WAAW,SAAS,QAAQ;AAElC,UAAI,mBAAmB,IAAI,QAAQ,GAAG;AAEpC;AAAA,MACF;AAEA,YAAM,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,UAAM,gBAAgB,aAAa;AAAA,EACrC,CAAC;AACL;AAEO,MAAM,wBAAwB,OAAO,YAA2B;AACrE,QAAM,gBACJ,SAAS,iBAAiB,iBAAiB,SAAS,aAAa;AAEnE,QAAM,gBAAgB,aAAa;AAEnC,MAAI,cAAc,QAAQ,SAAS,QAAQ,YAAY;AAErD,UAAM,EAAE,GAAG,SAAS,cAAc,CAAC;AAAA,EACrC;AACF;","names":[]}
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, relative } 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 { 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';\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 const { content } = config;\n\n // Process the file with the functionToRun\n appLogger(\n `Additional file detected: ${relative(content.baseDir, filePath)}`,\n {\n isVerbose: true,\n }\n );\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n\n const dictionariesOutput = await buildDictionary(localeDictionaries);\n\n const dictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n createTypes(dictionariesPaths);\n\n 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 const { content } = config;\n\n // Process the file with the functionToRun\n appLogger(`Unlinked detected: ${relative(content.baseDir, 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);\n\n const dictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n createTypes(dictionariesPaths);\n\n createDictionaryEntryPoint();\n\n appLogger('Dictionaries rebuilt', {\n isVerbose: true,\n });\n\n 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 const { content } = config;\n\n // Process the file with the functionToRun\n appLogger(`Change detected: ${relative(content.baseDir, filePath)}`, {\n isVerbose: true,\n });\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n\n const dictionariesOutput = await buildDictionary(localeDictionaries);\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 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":"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","names":[]}
@@ -1,15 +1,32 @@
1
- import { getConfiguration } from "@intlayer/config";
1
+ import { getAppLogger, getConfiguration } from "@intlayer/config";
2
2
  import { existsSync, rmSync } from "fs";
3
- import { createDictionaryEntryPoint } from "./transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs";
4
3
  const cleanOutputDir = (configuration = getConfiguration()) => {
5
- const { dictionariesDir, typesDir } = configuration.content;
4
+ const {
5
+ dictionariesDir,
6
+ unmergedDictionariesDir,
7
+ mainDir,
8
+ typesDir,
9
+ configDir
10
+ } = configuration.content;
11
+ const appLogger = getAppLogger(configuration);
6
12
  if (existsSync(dictionariesDir)) {
7
13
  rmSync(dictionariesDir, { recursive: true });
8
14
  }
15
+ if (existsSync(unmergedDictionariesDir)) {
16
+ rmSync(unmergedDictionariesDir, { recursive: true });
17
+ }
18
+ if (existsSync(mainDir)) {
19
+ rmSync(mainDir, { recursive: true });
20
+ }
9
21
  if (existsSync(typesDir)) {
10
22
  rmSync(typesDir, { recursive: true });
11
23
  }
12
- createDictionaryEntryPoint(configuration);
24
+ if (existsSync(configDir)) {
25
+ rmSync(configDir, { recursive: true });
26
+ }
27
+ appLogger("Output directory cleaned", {
28
+ isVerbose: true
29
+ });
13
30
  };
14
31
  export {
15
32
  cleanOutputDir
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { existsSync, rmSync } from 'fs';\nimport { createDictionaryEntryPoint } from './transpiler/dictionary_to_main/createDictionaryEntryPoint';\n\nexport const cleanOutputDir = (configuration = getConfiguration()) => {\n const { dictionariesDir, typesDir } = configuration.content;\n\n if (existsSync(dictionariesDir)) {\n // Delete the dictionary directory\n rmSync(dictionariesDir, { recursive: true });\n }\n\n // Delete the types directory\n if (existsSync(typesDir)) {\n rmSync(typesDir, { recursive: true });\n }\n\n createDictionaryEntryPoint(configuration);\n};\n"],"mappings":"AAAA,SAAS,wBAAwB;AACjC,SAAS,YAAY,cAAc;AACnC,SAAS,kCAAkC;AAEpC,MAAM,iBAAiB,CAAC,gBAAgB,iBAAiB,MAAM;AACpE,QAAM,EAAE,iBAAiB,SAAS,IAAI,cAAc;AAEpD,MAAI,WAAW,eAAe,GAAG;AAE/B,WAAO,iBAAiB,EAAE,WAAW,KAAK,CAAC;AAAA,EAC7C;AAGA,MAAI,WAAW,QAAQ,GAAG;AACxB,WAAO,UAAU,EAAE,WAAW,KAAK,CAAC;AAAA,EACtC;AAEA,6BAA2B,aAAa;AAC1C;","names":[]}
1
+ {"version":3,"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { getAppLogger, getConfiguration } from '@intlayer/config';\nimport { existsSync, rmSync } from 'fs';\n\nexport const cleanOutputDir = (configuration = getConfiguration()) => {\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n mainDir,\n typesDir,\n configDir,\n } = configuration.content;\n\n const appLogger = getAppLogger(configuration);\n\n if (existsSync(dictionariesDir)) {\n // Delete the dictionary directory\n rmSync(dictionariesDir, { recursive: true });\n }\n\n if (existsSync(unmergedDictionariesDir)) {\n // Delete the unmerged dictionaries directory\n rmSync(unmergedDictionariesDir, { recursive: true });\n }\n\n // Delete the main directory\n if (existsSync(mainDir)) {\n rmSync(mainDir, { recursive: true });\n }\n\n // Delete the types directory\n if (existsSync(typesDir)) {\n rmSync(typesDir, { recursive: true });\n }\n\n // Delete the config directory\n if (existsSync(configDir)) {\n rmSync(configDir, { recursive: true });\n }\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n};\n"],"mappings":"AAAA,SAAS,cAAc,wBAAwB;AAC/C,SAAS,YAAY,cAAc;AAE5B,MAAM,iBAAiB,CAAC,gBAAgB,iBAAiB,MAAM;AACpE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,cAAc;AAElB,QAAM,YAAY,aAAa,aAAa;AAE5C,MAAI,WAAW,eAAe,GAAG;AAE/B,WAAO,iBAAiB,EAAE,WAAW,KAAK,CAAC;AAAA,EAC7C;AAEA,MAAI,WAAW,uBAAuB,GAAG;AAEvC,WAAO,yBAAyB,EAAE,WAAW,KAAK,CAAC;AAAA,EACrD;AAGA,MAAI,WAAW,OAAO,GAAG;AACvB,WAAO,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACrC;AAGA,MAAI,WAAW,QAAQ,GAAG;AACxB,WAAO,UAAU,EAAE,WAAW,KAAK,CAAC;AAAA,EACtC;AAGA,MAAI,WAAW,SAAS,GAAG;AACzB,WAAO,WAAW,EAAE,WAAW,KAAK,CAAC;AAAA,EACvC;AAEA,YAAU,4BAA4B;AAAA,IACpC,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
@@ -0,0 +1,18 @@
1
+ import { getConfiguration } from "@intlayer/config";
2
+ import fg from "fast-glob";
3
+ import { existsSync, mkdirSync } from "fs";
4
+ const getBuiltDynamicDictionariesPath = (configuration = getConfiguration(), format = "esm") => {
5
+ const { dynamicDictionariesDir, mainDir } = configuration.content;
6
+ if (!existsSync(mainDir)) {
7
+ mkdirSync(mainDir, { recursive: true });
8
+ }
9
+ const extension = format === "cjs" ? "cjs" : "mjs";
10
+ const dictionariesPath = fg.sync(
11
+ `${dynamicDictionariesDir}/**/*.${extension}`
12
+ );
13
+ return dictionariesPath;
14
+ };
15
+ export {
16
+ getBuiltDynamicDictionariesPath
17
+ };
18
+ //# sourceMappingURL=getBuiltDynamicDictionariesPath.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/getBuiltDynamicDictionariesPath.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport fg from 'fast-glob';\nimport { existsSync, mkdirSync } from 'fs';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltDynamicDictionariesPath = (\n configuration = getConfiguration(),\n format: 'cjs' | 'esm' = 'esm'\n) => {\n const { dynamicDictionariesDir, mainDir } = configuration.content;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const dictionariesPath: string[] = fg.sync(\n `${dynamicDictionariesDir}/**/*.${extension}`\n );\n\n return dictionariesPath;\n};\n"],"mappings":"AAAA,SAAS,wBAAwB;AACjC,OAAO,QAAQ;AACf,SAAS,YAAY,iBAAiB;AAK/B,MAAM,kCAAkC,CAC7C,gBAAgB,iBAAiB,GACjC,SAAwB,UACrB;AACH,QAAM,EAAE,wBAAwB,QAAQ,IAAI,cAAc;AAG1D,MAAI,CAAC,WAAW,OAAO,GAAG;AACxB,cAAU,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACxC;AAEA,QAAM,YAAY,WAAW,QAAQ,QAAQ;AAE7C,QAAM,mBAA6B,GAAG;AAAA,IACpC,GAAG,sBAAsB,SAAS,SAAS;AAAA,EAC7C;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,49 @@
1
+ import {
2
+ deepTransformNode,
3
+ NodeType
4
+ } from "@intlayer/core";
5
+ const filterTranlationsPlugin = (locales, fallback = void 0) => ({
6
+ id: "filter-translations-plugin",
7
+ canHandle: (node) => typeof node === "object" && node?.nodeType === NodeType.Translation,
8
+ transform: (node, props, deepTransformNode2) => {
9
+ const translationMap = node.translation;
10
+ const localesArray = Array.isArray(locales) ? locales : [locales];
11
+ const isSingleLocale = localesArray.length === 1;
12
+ if (isSingleLocale) {
13
+ let content = translationMap[localesArray[0]];
14
+ if (typeof content === "undefined" && fallback) {
15
+ content = translationMap[fallback];
16
+ }
17
+ return deepTransformNode2(content, props);
18
+ }
19
+ const filteredTranslationMap = Object.fromEntries(
20
+ Object.entries(translationMap).filter(
21
+ ([key]) => locales.includes(key)
22
+ )
23
+ );
24
+ return {
25
+ ...node,
26
+ translation: deepTransformNode2(filteredTranslationMap, {
27
+ ...props,
28
+ keyPath: [
29
+ ...props.keyPath,
30
+ { type: NodeType.Object, key: NodeType.Translation }
31
+ ]
32
+ })
33
+ };
34
+ }
35
+ });
36
+ const getFilteredLocalesContent = (node, locale, nodeProps, fallback) => {
37
+ const plugins = [
38
+ filterTranlationsPlugin(locale, fallback),
39
+ ...nodeProps.plugins ?? []
40
+ ];
41
+ return deepTransformNode(node, {
42
+ ...nodeProps,
43
+ plugins
44
+ });
45
+ };
46
+ export {
47
+ getFilteredLocalesContent
48
+ };
49
+ //# sourceMappingURL=getFilteredLocalesContent.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/getFilteredLocalesContent.ts"],"sourcesContent":["import type { Locales, LocalesValues } from '@intlayer/config/client';\nimport {\n ContentNode,\n deepTransformNode,\n NodeType,\n type NodeProps,\n type Plugins,\n} from '@intlayer/core';\n\nconst filterTranlationsPlugin = (\n locales: LocalesValues[] | LocalesValues,\n fallback: LocalesValues | undefined = undefined // fallback mean that if field is not translated, it will use the default locale,\n): Plugins => ({\n id: 'filter-translations-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Translation,\n transform: (node, props, deepTransformNode) => {\n const translationMap = node.translation as Record<Locales, string>;\n\n const localesArray = Array.isArray(locales) ? locales : [locales];\n const isSingleLocale = localesArray.length === 1;\n\n if (isSingleLocale) {\n let content = translationMap[localesArray[0] as Locales];\n\n if (typeof content === 'undefined' && fallback) {\n content = translationMap[fallback as Locales];\n }\n\n return deepTransformNode(content, props);\n }\n\n const filteredTranslationMap = Object.fromEntries(\n Object.entries(translationMap).filter(([key]) =>\n locales.includes(key as Locales)\n )\n );\n\n return {\n ...node,\n translation: deepTransformNode(filteredTranslationMap, {\n ...props,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Object, key: NodeType.Translation },\n ],\n }),\n };\n },\n});\n\nexport const getFilteredLocalesContent = (\n node: ContentNode,\n locale: LocalesValues | LocalesValues[],\n nodeProps: NodeProps,\n fallback?: LocalesValues // fallback mean that if field is not translated, it will use the default locale,\n) => {\n const plugins: Plugins[] = [\n filterTranlationsPlugin(locale, fallback),\n ...(nodeProps.plugins ?? []),\n ];\n\n return deepTransformNode(node, {\n ...nodeProps,\n plugins,\n });\n};\n"],"mappings":"AACA;AAAA,EAEE;AAAA,EACA;AAAA,OAGK;AAEP,MAAM,0BAA0B,CAC9B,SACA,WAAsC,YACzB;AAAA,EACb,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,SAAS;AAAA,EAC1D,WAAW,CAAC,MAAM,OAAOA,uBAAsB;AAC7C,UAAM,iBAAiB,KAAK;AAE5B,UAAM,eAAe,MAAM,QAAQ,OAAO,IAAI,UAAU,CAAC,OAAO;AAChE,UAAM,iBAAiB,aAAa,WAAW;AAE/C,QAAI,gBAAgB;AAClB,UAAI,UAAU,eAAe,aAAa,CAAC,CAAY;AAEvD,UAAI,OAAO,YAAY,eAAe,UAAU;AAC9C,kBAAU,eAAe,QAAmB;AAAA,MAC9C;AAEA,aAAOA,mBAAkB,SAAS,KAAK;AAAA,IACzC;AAEA,UAAM,yBAAyB,OAAO;AAAA,MACpC,OAAO,QAAQ,cAAc,EAAE;AAAA,QAAO,CAAC,CAAC,GAAG,MACzC,QAAQ,SAAS,GAAc;AAAA,MACjC;AAAA,IACF;AAEA,WAAO;AAAA,MACL,GAAG;AAAA,MACH,aAAaA,mBAAkB,wBAAwB;AAAA,QACrD,GAAG;AAAA,QACH,SAAS;AAAA,UACP,GAAG,MAAM;AAAA,UACT,EAAE,MAAM,SAAS,QAAQ,KAAK,SAAS,YAAY;AAAA,QACrD;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,MAAM,4BAA4B,CACvC,MACA,QACA,WACA,aACG;AACH,QAAM,UAAqB;AAAA,IACzB,wBAAwB,QAAQ,QAAQ;AAAA,IACxC,GAAI,UAAU,WAAW,CAAC;AAAA,EAC5B;AAEA,SAAO,kBAAkB,MAAM;AAAA,IAC7B,GAAG;AAAA,IACH;AAAA,EACF,CAAC;AACH;","names":["deepTransformNode"]}
@@ -5,11 +5,12 @@ import {
5
5
  handleContentDeclarationFileChange,
6
6
  watch
7
7
  } from "./chokidar/watcher.mjs";
8
+ import { cleanOutputDir } from "./cleanOutputDir.mjs";
8
9
  import { fetchDistantDictionaries } from "./fetchDistantDictionaries.mjs";
9
10
  import { fetchDistantDictionaryKeys } from "./fetchDistantDictionaryKeys.mjs";
10
- import { filterDictionaryLocales } from "./filterDictionaryLocales.mjs";
11
11
  import { getBuiltDictionariesPath } from "./getBuiltDictionariesPath.mjs";
12
12
  import { getBuiltUnmergedDictionariesPath } from "./getBuiltUnmergedDictionariesPath.mjs";
13
+ import { getFilteredLocalesContent } from "./getFilteredLocalesContent.mjs";
13
14
  import { listDictionaries } from "./listDictionariesPath.mjs";
14
15
  import {
15
16
  listGitFiles
@@ -30,6 +31,7 @@ import {
30
31
  generateDictionaryListContent
31
32
  } from "./transpiler/dictionary_to_main/index.mjs";
32
33
  import { createModuleAugmentation } from "./transpiler/dictionary_to_type/createModuleAugmentation.mjs";
34
+ import { getFileHash } from "./utils.mjs";
33
35
  import {
34
36
  writeContentDeclaration
35
37
  } from "./writeContentDeclaration/index.mjs";
@@ -37,14 +39,16 @@ export {
37
39
  buildAndWatchIntlayer,
38
40
  buildDictionary,
39
41
  checkDictionaryChanges,
42
+ cleanOutputDir,
40
43
  createDictionaryEntryPoint,
41
44
  createModuleAugmentation,
42
45
  fetchDistantDictionaries,
43
46
  fetchDistantDictionaryKeys,
44
- filterDictionaryLocales,
45
47
  generateDictionaryListContent,
46
48
  getBuiltDictionariesPath,
47
49
  getBuiltUnmergedDictionariesPath,
50
+ getFileHash,
51
+ getFilteredLocalesContent,
48
52
  handleAdditionalContentDeclarationFile,
49
53
  handleContentDeclarationFileChange,
50
54
  listDictionaries,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { checkDictionaryChanges } from './checkDictionaryChanges';\nexport {\n buildAndWatchIntlayer,\n handleAdditionalContentDeclarationFile,\n handleContentDeclarationFileChange,\n watch,\n} from './chokidar/watcher';\nexport { fetchDistantDictionaries } from './fetchDistantDictionaries';\nexport { fetchDistantDictionaryKeys } from './fetchDistantDictionaryKeys';\nexport { filterDictionaryLocales } from './filterDictionaryLocales';\nexport { getBuiltDictionariesPath } from './getBuiltDictionariesPath';\nexport { getBuiltUnmergedDictionariesPath } from './getBuiltUnmergedDictionariesPath';\nexport { listDictionaries } from './listDictionariesPath';\nexport {\n listGitFiles,\n type DiffMode,\n type ListGitFilesOptions,\n} from './listGitFiles';\nexport {\n loadDictionaries,\n loadDistantDictionaries,\n loadLocalDictionaries,\n} from './loadDictionaries/index';\nexport { mergeDictionaries } from './mergeDictionaries';\nexport { prepareContentDeclaration } from './prepareContentDeclaration';\nexport { prepareIntlayer } from './prepareIntlayer';\nexport { processPerLocaleDictionary } from './processPerLocaleDictionary';\nexport { reduceDictionaryContent } from './reduceDictionaryContent/reduceDictionaryContent';\nexport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nexport {\n createDictionaryEntryPoint,\n generateDictionaryListContent,\n} from './transpiler/dictionary_to_main';\nexport { createModuleAugmentation } from './transpiler/dictionary_to_type/createModuleAugmentation';\nexport {\n writeContentDeclaration,\n type DictionaryStatus,\n} from './writeContentDeclaration';\n"],"mappings":"AAAA,SAAS,8BAA8B;AACvC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gCAAgC;AACzC,SAAS,kCAAkC;AAC3C,SAAS,+BAA+B;AACxC,SAAS,gCAAgC;AACzC,SAAS,wCAAwC;AACjD,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB;AAClC,SAAS,iCAAiC;AAC1C,SAAS,uBAAuB;AAChC,SAAS,kCAAkC;AAC3C,SAAS,+BAA+B;AACxC,SAAS,uBAAuB;AAChC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,gCAAgC;AACzC;AAAA,EACE;AAAA,OAEK;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { checkDictionaryChanges } from './checkDictionaryChanges';\nexport {\n buildAndWatchIntlayer,\n handleAdditionalContentDeclarationFile,\n handleContentDeclarationFileChange,\n watch,\n} from './chokidar/watcher';\nexport { cleanOutputDir } from './cleanOutputDir';\nexport { fetchDistantDictionaries } from './fetchDistantDictionaries';\nexport { fetchDistantDictionaryKeys } from './fetchDistantDictionaryKeys';\nexport { getBuiltDictionariesPath } from './getBuiltDictionariesPath';\nexport { getBuiltUnmergedDictionariesPath } from './getBuiltUnmergedDictionariesPath';\nexport { getFilteredLocalesContent } from './getFilteredLocalesContent';\nexport { listDictionaries } from './listDictionariesPath';\nexport {\n listGitFiles,\n type DiffMode,\n type ListGitFilesOptions,\n} from './listGitFiles';\nexport {\n loadDictionaries,\n loadDistantDictionaries,\n loadLocalDictionaries,\n} from './loadDictionaries/index';\nexport { mergeDictionaries } from './mergeDictionaries';\nexport { prepareContentDeclaration } from './prepareContentDeclaration';\nexport { prepareIntlayer } from './prepareIntlayer';\nexport { processPerLocaleDictionary } from './processPerLocaleDictionary';\nexport { reduceDictionaryContent } from './reduceDictionaryContent/reduceDictionaryContent';\nexport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nexport {\n createDictionaryEntryPoint,\n generateDictionaryListContent,\n} from './transpiler/dictionary_to_main';\nexport { createModuleAugmentation } from './transpiler/dictionary_to_type/createModuleAugmentation';\nexport { getFileHash } from './utils';\nexport {\n writeContentDeclaration,\n type DictionaryStatus,\n} from './writeContentDeclaration';\n"],"mappings":"AAAA,SAAS,8BAA8B;AACvC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,SAAS,gCAAgC;AACzC,SAAS,kCAAkC;AAC3C,SAAS,gCAAgC;AACzC,SAAS,wCAAwC;AACjD,SAAS,iCAAiC;AAC1C,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB;AAClC,SAAS,iCAAiC;AAC1C,SAAS,uBAAuB;AAChC,SAAS,kCAAkC;AAC3C,SAAS,+BAA+B;AACxC,SAAS,uBAAuB;AAChC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,gCAAgC;AACzC,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,OAEK;","names":[]}
@@ -16,17 +16,17 @@ import { writeConfiguration } from "./writeConfiguration/index.mjs";
16
16
  const prepareIntlayer = async (configuration = getConfiguration(), projectRequire = ESMxCJSRequire) => {
17
17
  const appLogger = getAppLogger(configuration);
18
18
  cleanOutputDir(configuration);
19
- appLogger("Output directory cleaned", {
20
- isVerbose: true
21
- });
22
19
  const files = listDictionaries(configuration);
23
20
  const dictionaries = await loadDictionaries(
24
21
  files,
25
22
  configuration,
26
23
  projectRequire
27
24
  );
28
- const dictionariesPaths = await buildDictionary(dictionaries, configuration);
29
- createTypes(dictionariesPaths, configuration);
25
+ const dictionariesOutput = await buildDictionary(dictionaries, configuration);
26
+ const dictionariesPaths = Object.values(
27
+ dictionariesOutput?.mergedDictionaries ?? {}
28
+ ).map((dictionary) => dictionary.dictionaryPath);
29
+ createTypes(dictionariesPaths);
30
30
  createDictionaryEntryPoint(configuration);
31
31
  appLogger("Dictionaries built");
32
32
  createModuleAugmentation(configuration);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import {\n ESMxCJSRequire,\n type IntlayerConfig,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { listDictionaries } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryEntryPoint } from './transpiler/dictionary_to_main/createDictionaryEntryPoint';\nimport {\n createModuleAugmentation,\n createTypes,\n} from './transpiler/dictionary_to_type/index';\nimport { writeConfiguration } from './writeConfiguration';\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire\n) => {\n const appLogger = getAppLogger(configuration);\n\n cleanOutputDir(configuration);\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n\n const files: string[] = listDictionaries(configuration);\n\n const dictionaries = await loadDictionaries(\n files,\n configuration,\n projectRequire\n );\n\n // Build locale dictionaries\n const dictionariesPaths = await buildDictionary(dictionaries, configuration);\n\n createTypes(dictionariesPaths, configuration);\n\n createDictionaryEntryPoint(configuration);\n\n appLogger('Dictionaries built');\n\n createModuleAugmentation(configuration);\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n\n writeConfiguration(configuration);\n\n appLogger('Configuration written', {\n isVerbose: true,\n });\n};\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,kCAAkC;AAC3C;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;AAE5B,MAAM,kBAAkB,OAC7B,gBAAgC,iBAAiB,GACjD,iBAAiB,mBACd;AACH,QAAM,YAAY,aAAa,aAAa;AAE5C,iBAAe,aAAa;AAE5B,YAAU,4BAA4B;AAAA,IACpC,WAAW;AAAA,EACb,CAAC;AAED,QAAM,QAAkB,iBAAiB,aAAa;AAEtD,QAAM,eAAe,MAAM;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAGA,QAAM,oBAAoB,MAAM,gBAAgB,cAAc,aAAa;AAE3E,cAAY,mBAAmB,aAAa;AAE5C,6BAA2B,aAAa;AAExC,YAAU,oBAAoB;AAE9B,2BAAyB,aAAa;AAEtC,YAAU,6BAA6B;AAAA,IACrC,WAAW;AAAA,EACb,CAAC;AAED,qBAAmB,aAAa;AAEhC,YAAU,yBAAyB;AAAA,IACjC,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import {\n ESMxCJSRequire,\n type IntlayerConfig,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { listDictionaries } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryEntryPoint } from './transpiler/dictionary_to_main/createDictionaryEntryPoint';\nimport {\n createModuleAugmentation,\n createTypes,\n} from './transpiler/dictionary_to_type/index';\nimport { writeConfiguration } from './writeConfiguration';\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire\n) => {\n const appLogger = getAppLogger(configuration);\n\n cleanOutputDir(configuration);\n\n const files: string[] = listDictionaries(configuration);\n\n const dictionaries = await loadDictionaries(\n files,\n configuration,\n projectRequire\n );\n\n // Build locale dictionaries\n const dictionariesOutput = await buildDictionary(dictionaries, configuration);\n\n const dictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n createTypes(dictionariesPaths);\n\n createDictionaryEntryPoint(configuration);\n\n appLogger('Dictionaries built');\n\n createModuleAugmentation(configuration);\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n\n writeConfiguration(configuration);\n\n appLogger('Configuration written', {\n isVerbose: true,\n });\n};\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,kCAAkC;AAC3C;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;AAE5B,MAAM,kBAAkB,OAC7B,gBAAgC,iBAAiB,GACjD,iBAAiB,mBACd;AACH,QAAM,YAAY,aAAa,aAAa;AAE5C,iBAAe,aAAa;AAE5B,QAAM,QAAkB,iBAAiB,aAAa;AAEtD,QAAM,eAAe,MAAM;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAGA,QAAM,qBAAqB,MAAM,gBAAgB,cAAc,aAAa;AAE5E,QAAM,oBAAoB,OAAO;AAAA,IAC/B,oBAAoB,sBAAsB,CAAC;AAAA,EAC7C,EAAE,IAAI,CAAC,eAAe,WAAW,cAAc;AAE/C,cAAY,iBAAiB;AAE7B,6BAA2B,aAAa;AAExC,YAAU,oBAAoB;AAE9B,2BAAyB,aAAa;AAEtC,YAAU,6BAA6B;AAAA,IACrC,WAAW;AAAA,EACb,CAAC;AAED,qBAAmB,aAAa;AAEhC,YAAU,yBAAyB;AAAA,IACjC,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
@@ -9,7 +9,6 @@ const buildDictionary = async (dictionaries, configuration = getConfiguration())
9
9
  if (dictionaryOutput.includes("intlayer")) {
10
10
  return await buildIntlayerDictionary(dictionaries, configuration);
11
11
  }
12
- return [];
13
12
  };
14
13
  export {
15
14
  buildDictionary
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/transpiler/declaration_file_to_dictionary/index.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { buildI18nDictionary } from './i18next_dictionary/index';\nimport { buildIntlayerDictionary } from './intlayer_dictionary/index';\n\nexport const buildDictionary = async (\n dictionaries: Dictionary[],\n configuration = getConfiguration()\n): Promise<string[]> => {\n const { dictionaryOutput } = configuration.content;\n\n if (dictionaryOutput.includes('i18next')) {\n await buildI18nDictionary(dictionaries, configuration);\n }\n\n if (dictionaryOutput.includes('intlayer')) {\n return await buildIntlayerDictionary(dictionaries, configuration);\n }\n\n return [];\n};\n"],"mappings":"AAAA,SAAS,wBAAwB;AAEjC,SAAS,2BAA2B;AACpC,SAAS,+BAA+B;AAEjC,MAAM,kBAAkB,OAC7B,cACA,gBAAgB,iBAAiB,MACX;AACtB,QAAM,EAAE,iBAAiB,IAAI,cAAc;AAE3C,MAAI,iBAAiB,SAAS,SAAS,GAAG;AACxC,UAAM,oBAAoB,cAAc,aAAa;AAAA,EACvD;AAEA,MAAI,iBAAiB,SAAS,UAAU,GAAG;AACzC,WAAO,MAAM,wBAAwB,cAAc,aAAa;AAAA,EAClE;AAEA,SAAO,CAAC;AACV;","names":[]}
1
+ {"version":3,"sources":["../../../../src/transpiler/declaration_file_to_dictionary/index.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { buildI18nDictionary } from './i18next_dictionary/index';\nimport { buildIntlayerDictionary } from './intlayer_dictionary/index';\n\nexport const buildDictionary = async (\n dictionaries: Dictionary[],\n configuration = getConfiguration()\n) => {\n const { dictionaryOutput } = configuration.content;\n\n if (dictionaryOutput.includes('i18next')) {\n await buildI18nDictionary(dictionaries, configuration);\n }\n\n if (dictionaryOutput.includes('intlayer')) {\n return await buildIntlayerDictionary(dictionaries, configuration);\n }\n};\n"],"mappings":"AAAA,SAAS,wBAAwB;AAEjC,SAAS,2BAA2B;AACpC,SAAS,+BAA+B;AAEjC,MAAM,kBAAkB,OAC7B,cACA,gBAAgB,iBAAiB,MAC9B;AACH,QAAM,EAAE,iBAAiB,IAAI,cAAc;AAE3C,MAAI,iBAAiB,SAAS,SAAS,GAAG;AACxC,UAAM,oBAAoB,cAAc,aAAa;AAAA,EACvD;AAEA,MAAI,iBAAiB,SAAS,UAAU,GAAG;AACzC,WAAO,MAAM,wBAAwB,cAAc,aAAa;AAAA,EAClE;AACF;","names":[]}