@intlayer/chokidar 5.0.6 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/checkDictionaryChanges.cjs.map +1 -1
- package/dist/cjs/chokidar/watcher.cjs +4 -4
- package/dist/cjs/chokidar/watcher.cjs.map +1 -1
- package/dist/cjs/cleanOutputDir.cjs +2 -2
- package/dist/cjs/cleanOutputDir.cjs.map +1 -1
- package/dist/cjs/index.cjs +3 -3
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
- package/dist/cjs/log.cjs +1 -1
- package/dist/cjs/log.cjs.map +1 -1
- package/dist/cjs/mergeDictionaries.cjs.map +1 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.cjs.map +1 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/index.cjs.map +1 -1
- 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/processContentDeclaration.cjs.map +1 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_main/{createDictionaryList.cjs → createDictionaryEntryPoint.cjs} +7 -7
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs.map +1 -0
- package/dist/cjs/transpiler/dictionary_to_main/index.cjs +2 -2
- package/dist/cjs/transpiler/dictionary_to_main/index.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs +2 -0
- package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs.map +1 -1
- package/dist/esm/checkDictionaryChanges.mjs.map +1 -1
- package/dist/esm/chokidar/watcher.mjs +8 -5
- package/dist/esm/chokidar/watcher.mjs.map +1 -1
- package/dist/esm/cleanOutputDir.mjs +2 -2
- package/dist/esm/cleanOutputDir.mjs.map +1 -1
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
- package/dist/esm/log.mjs +1 -1
- package/dist/esm/log.mjs.map +1 -1
- package/dist/esm/mergeDictionaries.mjs.map +1 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.mjs.map +1 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/index.mjs.map +1 -1
- 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/processContentDeclaration.mjs.map +1 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_main/{createDictionaryList.mjs → createDictionaryEntryPoint.mjs} +3 -3
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs.map +1 -0
- package/dist/esm/transpiler/dictionary_to_main/index.mjs +1 -1
- package/dist/esm/transpiler/dictionary_to_main/index.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs +2 -0
- package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs.map +1 -1
- package/dist/types/chokidar/watcher.d.ts +1 -1
- package/dist/types/chokidar/watcher.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadDictionaries.d.ts +1 -1
- package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -1
- package/dist/types/mergeDictionaries.d.ts +1 -1
- package/dist/types/mergeDictionaries.d.ts.map +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.d.ts +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.d.ts.map +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/index.d.ts +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/index.d.ts.map +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.d.ts +2 -2
- 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/processContentDeclaration.d.ts.map +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.d.ts +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.d.ts.map +1 -1
- package/dist/types/transpiler/dictionary_to_main/createDictionaryEntryPoint.d.ts +5 -0
- package/dist/types/transpiler/dictionary_to_main/createDictionaryEntryPoint.d.ts.map +1 -0
- package/dist/types/transpiler/dictionary_to_main/index.d.ts +1 -1
- package/dist/types/transpiler/dictionary_to_main/index.d.ts.map +1 -1
- package/dist/types/transpiler/dictionary_to_type/createModuleAugmentation.d.ts.map +1 -1
- package/package.json +15 -15
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryList.cjs.map +0 -1
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryList.mjs.map +0 -1
- package/dist/types/transpiler/dictionary_to_main/createDictionaryList.d.ts +0 -5
- package/dist/types/transpiler/dictionary_to_main/createDictionaryList.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/checkDictionaryChanges.ts"],"sourcesContent":["import { IntlayerEventListener } from '@intlayer/api';\n// @ts-ignore: @intlayer/backend is not built yet\nimport { DictionaryAPI } from '@intlayer/backend';\nimport { buildIntlayerDictionary } from './transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary';\n\nconst writeDictionary = async (dictionary: DictionaryAPI) => {\n await buildIntlayerDictionary([dictionary]);\n};\n\nexport const checkDictionaryChanges = () => {\n const eventSource = new IntlayerEventListener();\n\n eventSource.initialize();\n\n eventSource.onDictionaryAdded = writeDictionary;\n eventSource.onDictionaryChange = writeDictionary;\n eventSource.onDictionaryDeleted = writeDictionary;\n\n return eventSource;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAsC;AAGtC,qCAAwC;AAExC,MAAM,kBAAkB,OAAO,eAA8B;AAC3D,YAAM,wDAAwB,CAAC,UAAU,CAAC;AAC5C;AAEO,MAAM,yBAAyB,MAAM;AAC1C,QAAM,cAAc,IAAI,iCAAsB;AAE9C,cAAY,WAAW;AAEvB,cAAY,oBAAoB;AAChC,cAAY,qBAAqB;AACjC,cAAY,sBAAsB;AAElC,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/checkDictionaryChanges.ts"],"sourcesContent":["import { IntlayerEventListener } from '@intlayer/api';\n// @ts-ignore: @intlayer/backend is not built yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { buildIntlayerDictionary } from './transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary';\n\nconst writeDictionary = async (dictionary: DictionaryAPI) => {\n await buildIntlayerDictionary([dictionary]);\n};\n\nexport const checkDictionaryChanges = () => {\n const eventSource = new IntlayerEventListener();\n\n eventSource.initialize();\n\n eventSource.onDictionaryAdded = writeDictionary;\n eventSource.onDictionaryChange = writeDictionary;\n eventSource.onDictionaryDeleted = writeDictionary;\n\n return eventSource;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAsC;AAGtC,qCAAwC;AAExC,MAAM,kBAAkB,OAAO,eAA8B;AAC3D,YAAM,wDAAwB,CAAC,UAAU,CAAC;AAC5C;AAEO,MAAM,yBAAyB,MAAM;AAC1C,QAAM,cAAc,IAAI,iCAAsB;AAE9C,cAAY,WAAW;AAEvB,cAAY,oBAAoB;AAChC,cAAY,qBAAqB;AACjC,cAAY,sBAAsB;AAElC,SAAO;AACT;","names":[]}
|
|
@@ -44,7 +44,7 @@ var import_getDictionariesPath = require('../getDictionariesPath.cjs');
|
|
|
44
44
|
var import_loadDictionaries = require('../loadDictionaries/loadDictionaries.cjs');
|
|
45
45
|
var import_loadLocalDictionaries = require('../loadDictionaries/loadLocalDictionaries.cjs');
|
|
46
46
|
var import_declaration_file_to_dictionary = require('../transpiler/declaration_file_to_dictionary/index.cjs');
|
|
47
|
-
var
|
|
47
|
+
var import_createDictionaryEntryPoint = require('../transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs');
|
|
48
48
|
var import_dictionary_to_type = require('../transpiler/dictionary_to_type/index.cjs');
|
|
49
49
|
const prepareIntlayer = async (configuration) => {
|
|
50
50
|
const { content } = configuration ?? (0, import_config.getConfiguration)({
|
|
@@ -59,7 +59,7 @@ const prepareIntlayer = async (configuration) => {
|
|
|
59
59
|
const dictionaries = await (0, import_loadDictionaries.loadDictionaries)(files);
|
|
60
60
|
const dictionariesPaths = await (0, import_declaration_file_to_dictionary.buildDictionary)(dictionaries);
|
|
61
61
|
(0, import_dictionary_to_type.createTypes)(dictionariesPaths);
|
|
62
|
-
(0,
|
|
62
|
+
(0, import_createDictionaryEntryPoint.createDictionaryEntryPoint)();
|
|
63
63
|
(0, import_config.appLogger)("Dictionaries built");
|
|
64
64
|
(0, import_dictionary_to_type.createModuleAugmentation)();
|
|
65
65
|
(0, import_config.appLogger)("Module augmentation built", {
|
|
@@ -79,7 +79,7 @@ const handleAdditionalContentDeclarationFile = async (filePath, configuration) =
|
|
|
79
79
|
const localeDictionaries = await (0, import_loadLocalDictionaries.loadLocalDictionaries)(filePath);
|
|
80
80
|
const dictionariesPaths = await (0, import_declaration_file_to_dictionary.buildDictionary)(localeDictionaries);
|
|
81
81
|
(0, import_dictionary_to_type.createTypes)(dictionariesPaths);
|
|
82
|
-
(0,
|
|
82
|
+
(0, import_createDictionaryEntryPoint.createDictionaryEntryPoint)();
|
|
83
83
|
(0, import_config.appLogger)("Dictionaries built", {
|
|
84
84
|
isVerbose: true
|
|
85
85
|
});
|
|
@@ -105,7 +105,7 @@ const handleContentDeclarationFileChange = async (filePath, configuration) => {
|
|
|
105
105
|
if (updatedDictionariesPaths.some(
|
|
106
106
|
(updatedDictionaryPath) => allDictionariesPaths.includes(updatedDictionaryPath)
|
|
107
107
|
)) {
|
|
108
|
-
(0,
|
|
108
|
+
(0, import_createDictionaryEntryPoint.createDictionaryEntryPoint)();
|
|
109
109
|
(0, import_config.appLogger)("Dictionary list built", {
|
|
110
110
|
isVerbose: true
|
|
111
111
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import { relative } from 'path';\nimport { appLogger
|
|
1
|
+
{"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import { relative } from 'path';\nimport {\n type IntlayerConfig,\n appLogger,\n getConfiguration,\n} from '@intlayer/config';\n/** @ts-ignore remove error Module '\"chokidar\"' has no exported member 'ChokidarOptions' */\nimport { type ChokidarOptions, watch as chokidarWatch } from 'chokidar';\nimport fg from 'fast-glob';\nimport { cleanOutputDir } from '../cleanOutputDir';\nimport { getDictionariesPath } from '../getDictionariesPath';\nimport { loadDictionaries } from '../loadDictionaries/loadDictionaries';\nimport { loadLocalDictionaries } from '../loadDictionaries/loadLocalDictionaries';\nimport { buildDictionary } from '../transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryEntryPoint } from '../transpiler/dictionary_to_main/createDictionaryEntryPoint';\nimport {\n createTypes,\n createModuleAugmentation,\n} from '../transpiler/dictionary_to_type/index';\n\nexport const prepareIntlayer = async (configuration?: IntlayerConfig) => {\n const { content } =\n configuration ??\n getConfiguration({\n verbose: true,\n });\n\n const { watchedFilesPatternWithPath } = content;\n\n cleanOutputDir();\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n\n const files: string[] = fg.sync(watchedFilesPatternWithPath);\n\n const dictionaries = await loadDictionaries(files);\n\n // Build locale dictionaries\n const dictionariesPaths = await buildDictionary(dictionaries);\n\n createTypes(dictionariesPaths);\n\n createDictionaryEntryPoint();\n\n appLogger('Dictionaries built');\n\n createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n};\n\nexport const handleAdditionalContentDeclarationFile = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const { content } =\n configuration ??\n getConfiguration({\n verbose: true,\n });\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 handleContentDeclarationFileChange = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const { content } =\n configuration ??\n getConfiguration({\n verbose: true,\n });\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 const updatedDictionariesPaths = await buildDictionary(localeDictionaries);\n const allDictionariesPaths: string[] = getDictionariesPath();\n\n createTypes(updatedDictionariesPaths);\n appLogger('TypeScript types built', {\n isVerbose: true,\n });\n\n if (\n updatedDictionariesPaths.some((updatedDictionaryPath) =>\n allDictionariesPaths.includes(updatedDictionaryPath)\n )\n ) {\n createDictionaryEntryPoint();\n\n appLogger('Dictionary list built', {\n isVerbose: true,\n });\n\n createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n }\n};\n\ntype WatchOptions = ChokidarOptions & {\n configuration?: IntlayerConfig;\n};\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const configuration =\n options?.configuration ??\n getConfiguration({\n verbose: true,\n });\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(\n 'add',\n async (filePath) =>\n await handleAdditionalContentDeclarationFile(filePath, configuration)\n )\n .on(\n 'change',\n async (filePath) =>\n await handleContentDeclarationFileChange(filePath, configuration)\n )\n .on('error', (error) =>\n appLogger('Watcher error: ' + error, {\n level: 'error',\n })\n );\n};\n\nexport const buildAndWatchIntlayer = async (options?: WatchOptions) => {\n const configuration = options?.configuration ?? getConfiguration();\n\n await prepareIntlayer(configuration);\n\n if (configuration.content.watch) {\n // Start watching (assuming watch is also async)\n watch({ ...options, configuration });\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAyB;AACzB,oBAIO;AAEP,sBAA6D;AAC7D,uBAAe;AACf,4BAA+B;AAC/B,iCAAoC;AACpC,8BAAiC;AACjC,mCAAsC;AACtC,4CAAgC;AAChC,wCAA2C;AAC3C,gCAGO;AAEA,MAAM,kBAAkB,OAAO,kBAAmC;AACvE,QAAM,EAAE,QAAQ,IACd,qBACA,gCAAiB;AAAA,IACf,SAAS;AAAA,EACX,CAAC;AAEH,QAAM,EAAE,4BAA4B,IAAI;AAExC,4CAAe;AAEf,+BAAU,4BAA4B;AAAA,IACpC,WAAW;AAAA,EACb,CAAC;AAED,QAAM,QAAkB,iBAAAA,QAAG,KAAK,2BAA2B;AAE3D,QAAM,eAAe,UAAM,0CAAiB,KAAK;AAGjD,QAAM,oBAAoB,UAAM,uDAAgB,YAAY;AAE5D,6CAAY,iBAAiB;AAE7B,oEAA2B;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OO,MAAM,QAAQ,CAAC,YAA2B;AAC/C,QAAM,gBACJ,SAAS,qBACT,gCAAiB;AAAA,IACf,SAAS;AAAA,EACX,CAAC;AAEH,QAAM,EAAE,OAAO,aAAa,4BAA4B,IACtD,cAAc;AAGhB,aAAO,gBAAAC,OAAc,6BAA6B;AAAA,IAChD,YAAY;AAAA;AAAA,IACZ,eAAe;AAAA;AAAA,IACf,GAAG;AAAA,EACL,CAAC,EACE;AAAA,IACC;AAAA,IACA,OAAO,aACL,MAAM,uCAAuC,UAAU,aAAa;AAAA,EACxE,EACC;AAAA,IACC;AAAA,IACA,OAAO,aACL,MAAM,mCAAmC,UAAU,aAAa;AAAA,EACpE,EACC;AAAA,IAAG;AAAA,IAAS,CAAC,cACZ,yBAAU,oBAAoB,OAAO;AAAA,MACnC,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACJ;AAEO,MAAM,wBAAwB,OAAO,YAA2B;AACrE,QAAM,gBAAgB,SAAS,qBAAiB,gCAAiB;AAEjE,QAAM,gBAAgB,aAAa;AAEnC,MAAI,cAAc,QAAQ,OAAO;AAE/B,UAAM,EAAE,GAAG,SAAS,cAAc,CAAC;AAAA,EACrC;AACF;","names":["fg","chokidarWatch"]}
|
|
@@ -23,7 +23,7 @@ __export(cleanOutputDir_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(cleanOutputDir_exports);
|
|
24
24
|
var import_fs = require("fs");
|
|
25
25
|
var import_config = require("@intlayer/config");
|
|
26
|
-
var
|
|
26
|
+
var import_createDictionaryEntryPoint = require('./transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs');
|
|
27
27
|
const cleanOutputDir = () => {
|
|
28
28
|
const { content } = (0, import_config.getConfiguration)();
|
|
29
29
|
const { resultDir, typesDir, dictionariesDir } = content;
|
|
@@ -35,7 +35,7 @@ const cleanOutputDir = () => {
|
|
|
35
35
|
(0, import_fs.rmSync)(typesDir, { recursive: true });
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
(0,
|
|
38
|
+
(0, import_createDictionaryEntryPoint.createDictionaryEntryPoint)();
|
|
39
39
|
};
|
|
40
40
|
// Annotate the CommonJS export names for ESM import in node:
|
|
41
41
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { existsSync, rmSync } from 'fs';\nimport { getConfiguration } from '@intlayer/config';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { existsSync, rmSync } from 'fs';\nimport { getConfiguration } from '@intlayer/config';\nimport { createDictionaryEntryPoint } from './transpiler/dictionary_to_main/createDictionaryEntryPoint';\n\nexport const cleanOutputDir = () => {\n const { content } = getConfiguration();\n\n const { resultDir, typesDir, dictionariesDir } = content;\n\n if (existsSync(resultDir)) {\n // Delete the dictionary directory\n if (existsSync(dictionariesDir)) {\n rmSync(dictionariesDir, { recursive: true });\n }\n\n // Delete the types directory\n if (existsSync(typesDir)) {\n rmSync(typesDir, { recursive: true });\n }\n }\n\n createDictionaryEntryPoint();\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAmC;AACnC,oBAAiC;AACjC,wCAA2C;AAEpC,MAAM,iBAAiB,MAAM;AAClC,QAAM,EAAE,QAAQ,QAAI,gCAAiB;AAErC,QAAM,EAAE,WAAW,UAAU,gBAAgB,IAAI;AAEjD,UAAI,sBAAW,SAAS,GAAG;AAEzB,YAAI,sBAAW,eAAe,GAAG;AAC/B,4BAAO,iBAAiB,EAAE,WAAW,KAAK,CAAC;AAAA,IAC7C;AAGA,YAAI,sBAAW,QAAQ,GAAG;AACxB,4BAAO,UAAU,EAAE,WAAW,KAAK,CAAC;AAAA,IACtC;AAAA,EACF;AAEA,oEAA2B;AAC7B;","names":[]}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -21,7 +21,7 @@ __export(index_exports, {
|
|
|
21
21
|
buildAndWatchIntlayer: () => import_watcher.buildAndWatchIntlayer,
|
|
22
22
|
buildDictionary: () => import_declaration_file_to_dictionary.buildDictionary,
|
|
23
23
|
checkDictionaryChanges: () => import_checkDictionaryChanges.checkDictionaryChanges,
|
|
24
|
-
|
|
24
|
+
createDictionaryEntryPoint: () => import_createDictionaryEntryPoint.createDictionaryEntryPoint,
|
|
25
25
|
createModuleAugmentation: () => import_createModuleAugmentation.createModuleAugmentation,
|
|
26
26
|
fetchDistantDictionaries: () => import_fetchDistantDictionaries.fetchDistantDictionaries,
|
|
27
27
|
handleAdditionalContentDeclarationFile: () => import_watcher.handleAdditionalContentDeclarationFile,
|
|
@@ -35,7 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(index_exports);
|
|
36
36
|
var import_watcher = require('./chokidar/watcher.cjs');
|
|
37
37
|
var import_declaration_file_to_dictionary = require('./transpiler/declaration_file_to_dictionary/index.cjs');
|
|
38
|
-
var
|
|
38
|
+
var import_createDictionaryEntryPoint = require('./transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs');
|
|
39
39
|
var import_createModuleAugmentation = require('./transpiler/dictionary_to_type/createModuleAugmentation.cjs');
|
|
40
40
|
var import_fetchDistantDictionaries = require('./fetchDistantDictionaries.cjs');
|
|
41
41
|
var import_loadDictionaries = require('./loadDictionaries/index.cjs');
|
|
@@ -45,7 +45,7 @@ var import_checkDictionaryChanges = require('./checkDictionaryChanges.cjs');
|
|
|
45
45
|
buildAndWatchIntlayer,
|
|
46
46
|
buildDictionary,
|
|
47
47
|
checkDictionaryChanges,
|
|
48
|
-
|
|
48
|
+
createDictionaryEntryPoint,
|
|
49
49
|
createModuleAugmentation,
|
|
50
50
|
fetchDistantDictionaries,
|
|
51
51
|
handleAdditionalContentDeclarationFile,
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n watch,\n prepareIntlayer,\n handleAdditionalContentDeclarationFile,\n handleContentDeclarationFileChange,\n buildAndWatchIntlayer,\n} from './chokidar/watcher';\nexport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nexport {
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n watch,\n prepareIntlayer,\n handleAdditionalContentDeclarationFile,\n handleContentDeclarationFileChange,\n buildAndWatchIntlayer,\n} from './chokidar/watcher';\nexport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nexport { createDictionaryEntryPoint } from './transpiler/dictionary_to_main/createDictionaryEntryPoint';\nexport { createModuleAugmentation } from './transpiler/dictionary_to_type/createModuleAugmentation';\nexport { fetchDistantDictionaries } from './fetchDistantDictionaries';\nexport {\n loadDistantDictionaries,\n loadDictionaries,\n loadLocalDictionaries,\n} from './loadDictionaries/index';\nexport { checkDictionaryChanges } from './checkDictionaryChanges';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAMO;AACP,4CAAgC;AAChC,wCAA2C;AAC3C,sCAAyC;AACzC,sCAAyC;AACzC,8BAIO;AACP,oCAAuC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { appLogger, getConfiguration } from '@intlayer/config';\nimport { Dictionary } from '@intlayer/core';\nimport merge from 'deepmerge';\nimport { fetchDistantDictionaryKeys } from '../fetchDistantDictionaryKeys';\nimport { logger } from '../log';\nimport { mergeByKey } from '../mergeDictionaries';\nimport { sortAlphabetically } from '../utils';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadDistantDictionaries } from './loadDistantDictionaries';\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string\n): Promise<Dictionary[]> => {\n try {\n const { editor } = getConfiguration();\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] =\n await loadContentDeclarations(files);\n const localDictionaryKeys = localDictionaries.map((dict) => dict.key);\n\n // Initialize the logger with both local and distant dictionaries\n logger.init(localDictionaryKeys, []);\n\n // Update logger statuses for local dictionaries\n logger.updateStatus(\n localDictionaries.map((dict) => ({\n dictionaryKey: dict.key,\n type: 'local',\n status: { status: 'built' },\n }))\n );\n\n let distantDictionaries: DictionaryAPI[] = [];\n let distantDictionaryKeys: string[] = [];\n let mergedDictionaries = localDictionaries;\n\n if (editor.clientId && editor.clientSecret) {\n try {\n // Fetch distant dictionary keys\n distantDictionaryKeys = await fetchDistantDictionaryKeys();\n\n const orderedDistantDictionaryKeys =\n distantDictionaryKeys.sort(sortAlphabetically);\n // Add distant dictionaries to the logger\n logger.addDictionaryKeys('distant', orderedDistantDictionaryKeys);\n\n // Fetch distant dictionaries\n distantDictionaries = await loadDistantDictionaries({\n dictionaryKeys: orderedDistantDictionaryKeys,\n });\n if (editor.dictionaryPriorityStrategy === 'distant_first') {\n // Merge the dictionaries\n mergedDictionaries = merge(localDictionaries, distantDictionaries, {\n arrayMerge: mergeByKey('key'),\n });\n } else {\n // Merge the dictionaries\n mergedDictionaries = merge(distantDictionaries, localDictionaries, {\n arrayMerge: mergeByKey('key'),\n });\n }\n } catch (_error) {\n appLogger('Error during fetching distant dictionaries', {\n level: 'error',\n });\n }\n }\n\n // Ensure the logger is stopped\n logger.stop();\n\n return mergedDictionaries;\n } catch (error) {\n // Ensure the logger is stopped\n logger.stop();\n\n throw error; // Re-throw the error after logging\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAA4C;AAE5C,uBAAkB;AAClB,wCAA2C;A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;AAAA,IACF;AAGA,sBAAO,KAAK;AAEZ,WAAO;AAAA,EACT,SAAS,OAAO;AAEd,sBAAO,KAAK;AAEZ,UAAM;AAAA,EACR;AACF;","names":["merge"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { appLogger, getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport merge from 'deepmerge';\nimport { fetchDistantDictionaryKeys } from '../fetchDistantDictionaryKeys';\nimport { logger } from '../log';\nimport { mergeByKey } from '../mergeDictionaries';\nimport { sortAlphabetically } from '../utils';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadDistantDictionaries } from './loadDistantDictionaries';\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string\n): Promise<Dictionary[]> => {\n try {\n const { editor } = getConfiguration();\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] =\n await loadContentDeclarations(files);\n const localDictionaryKeys = localDictionaries.map((dict) => dict.key);\n\n // Initialize the logger with both local and distant dictionaries\n logger.init(localDictionaryKeys, []);\n\n // Update logger statuses for local dictionaries\n logger.updateStatus(\n localDictionaries.map((dict) => ({\n dictionaryKey: dict.key,\n type: 'local',\n status: { status: 'built' },\n }))\n );\n\n let distantDictionaries: DictionaryAPI[] = [];\n let distantDictionaryKeys: string[] = [];\n let mergedDictionaries = localDictionaries;\n\n if (editor.clientId && editor.clientSecret) {\n try {\n // Fetch distant dictionary keys\n distantDictionaryKeys = await fetchDistantDictionaryKeys();\n\n const orderedDistantDictionaryKeys =\n distantDictionaryKeys.sort(sortAlphabetically);\n // Add distant dictionaries to the logger\n logger.addDictionaryKeys('distant', orderedDistantDictionaryKeys);\n\n // Fetch distant dictionaries\n distantDictionaries = await loadDistantDictionaries({\n dictionaryKeys: orderedDistantDictionaryKeys,\n });\n if (editor.dictionaryPriorityStrategy === 'distant_first') {\n // Merge the dictionaries\n mergedDictionaries = merge(localDictionaries, distantDictionaries, {\n arrayMerge: mergeByKey('key'),\n });\n } else {\n // Merge the dictionaries\n mergedDictionaries = merge(distantDictionaries, localDictionaries, {\n arrayMerge: mergeByKey('key'),\n });\n }\n } catch (_error) {\n appLogger('Error during fetching distant dictionaries', {\n level: 'error',\n });\n }\n }\n\n // Ensure the logger is stopped\n logger.stop();\n\n return mergedDictionaries;\n } catch (error) {\n // Ensure the logger is stopped\n logger.stop();\n\n throw error; // Re-throw the error after logging\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAA4C;AAE5C,uBAAkB;AAClB,wCAA2C;AAC3C,iBAAuB;AACvB,+BAA2B;AAC3B,mBAAmC;AACnC,oCAAwC;AACxC,qCAAwC;AAEjC,MAAM,mBAAmB,OAC9B,6BAC0B;AAC1B,MAAI;AACF,UAAM,EAAE,OAAO,QAAI,gCAAiB;AAEpC,iCAAU,iBAAiB,EAAE,WAAW,KAAK,CAAC;AAE9C,UAAM,QAAQ,MAAM,QAAQ,wBAAwB,IAChD,2BACA,CAAC,wBAAwB;AAE7B,UAAM,oBACJ,UAAM,uDAAwB,KAAK;AACrC,UAAM,sBAAsB,kBAAkB,IAAI,CAAC,SAAS,KAAK,GAAG;AAGpE,sBAAO,KAAK,qBAAqB,CAAC,CAAC;AAGnC,sBAAO;AAAA,MACL,kBAAkB,IAAI,CAAC,UAAU;AAAA,QAC/B,eAAe,KAAK;AAAA,QACpB,MAAM;AAAA,QACN,QAAQ,EAAE,QAAQ,QAAQ;AAAA,MAC5B,EAAE;AAAA,IACJ;AAEA,QAAI,sBAAuC,CAAC;AAC5C,QAAI,wBAAkC,CAAC;AACvC,QAAI,qBAAqB;AAEzB,QAAI,OAAO,YAAY,OAAO,cAAc;AAC1C,UAAI;AAEF,gCAAwB,UAAM,8DAA2B;AAEzD,cAAM,+BACJ,sBAAsB,KAAK,+BAAkB;AAE/C,0BAAO,kBAAkB,WAAW,4BAA4B;AAGhE,8BAAsB,UAAM,wDAAwB;AAAA,UAClD,gBAAgB;AAAA,QAClB,CAAC;AACD,YAAI,OAAO,+BAA+B,iBAAiB;AAEzD,mCAAqB,iBAAAA,SAAM,mBAAmB,qBAAqB;AAAA,YACjE,gBAAY,qCAAW,KAAK;AAAA,UAC9B,CAAC;AAAA,QACH,OAAO;AAEL,mCAAqB,iBAAAA,SAAM,qBAAqB,mBAAmB;AAAA,YACjE,gBAAY,qCAAW,KAAK;AAAA,UAC9B,CAAC;AAAA,QACH;AAAA,MACF,SAAS,QAAQ;AACf,qCAAU,8CAA8C;AAAA,UACtD,OAAO;AAAA,QACT,CAAC;AAAA,MACH;AAAA,IACF;AAGA,sBAAO,KAAK;AAEZ,WAAO;AAAA,EACT,SAAS,OAAO;AAEd,sBAAO,KAAK;AAEZ,UAAM;AAAA,EACR;AACF;","names":["merge"]}
|
package/dist/cjs/log.cjs
CHANGED
|
@@ -32,8 +32,8 @@ __export(log_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(log_exports);
|
|
34
34
|
var import_readline = __toESM(require("readline"));
|
|
35
|
-
var import_utils = require('./utils.cjs');
|
|
36
35
|
var import_config = require("@intlayer/config");
|
|
36
|
+
var import_utils = require('./utils.cjs');
|
|
37
37
|
const LINE_DETECTOR = "\u200B\u200B\u200B";
|
|
38
38
|
const SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
39
39
|
const RESET = "\x1B[0m";
|
package/dist/cjs/log.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/log.ts"],"sourcesContent":["import readline from 'readline';\nimport { sortAlphabetically } from './utils';\nimport { getConfiguration, IntlayerConfig } from '@intlayer/config';\n\nexport type State = {\n type: 'local' | 'distant';\n status: 'pending' | 'fetching' | 'fetched' | 'error' | 'imported' | 'built';\n icon?: string;\n error?: Error;\n errorMessage?: string;\n spinnerFrameIndex?: number;\n};\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n state: State[];\n};\n\nconst LINE_DETECTOR = '\\u200B\\u200B\\u200B'; // Three zero-width spaces\nconst SPINNER_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\n\n// ANSI color codes\nconst RESET = '\\x1b[0m';\nconst GREEN = '\\x1b[32m';\nconst RED = '\\x1b[31m';\nconst BLUE = '\\x1b[34m';\nconst GREY = '\\x1b[90m';\nconst GREY_DARK = '\\x1b[90m';\n\nclass Logger {\n private dictionariesStatuses: DictionariesStatus[] = [];\n private spinnerTimer: NodeJS.Timeout | null = null;\n private maxDictionaryKeyLength: number = 0;\n private previousLineCount: number = 0;\n private lineDifCounter: number = 0;\n private originalStdoutWrite:\n | ((\n chunk: string | Uint8Array, // `chunk` can be either a string or a Uint8Array\n encoding?: BufferEncoding, // `encoding` is optional and should be a BufferEncoding\n callback?: (err?: Error | null) => void // `callback` is optional and a function\n ) => boolean)\n | null = null;\n private extraLines: number = 0;\n private isUpdating: boolean = false;\n private config: IntlayerConfig;\n\n // Singleton instance\n private static instance: Logger;\n\n private constructor() {\n this.config = getConfiguration();\n }\n\n public static getInstance(): Logger {\n if (!Logger.instance) {\n Logger.instance = new Logger();\n }\n return Logger.instance;\n }\n\n public init(\n localDictionariesKeys: string[],\n distantDictionariesKeys: string[]\n ) {\n const allKeys = Array.from(\n new Set(\n [...localDictionariesKeys, ...distantDictionariesKeys].sort(\n sortAlphabetically\n )\n )\n );\n\n this.maxDictionaryKeyLength = allKeys.reduce(\n (max, key) => (key.length > max ? key.length : max),\n 0\n );\n\n this.dictionariesStatuses = allKeys.map((dictionaryKey) => {\n const states: State[] = [];\n\n if (localDictionariesKeys.includes(dictionaryKey)) {\n states.push({\n type: 'local',\n status: 'pending',\n spinnerFrameIndex: 0,\n });\n }\n if (distantDictionariesKeys.includes(dictionaryKey)) {\n states.push({\n type: 'distant',\n status: 'pending',\n spinnerFrameIndex: 0,\n });\n }\n\n return {\n dictionaryKey,\n state: states,\n };\n });\n\n // Start spinner timer\n this.startSpinner();\n\n // Update all status lines (this will output the initial statuses)\n this.updateAllStatusLines();\n }\n\n // New method to add dictionary keys after initialization\n public addDictionaryKeys(\n type: 'local' | 'distant',\n dictionaryKeys: string[]\n ) {\n for (const dictionaryKey of dictionaryKeys) {\n // Update maxDictionaryKeyLength if the new key is longer\n if (dictionaryKey.length > this.maxDictionaryKeyLength) {\n this.maxDictionaryKeyLength = dictionaryKey.length;\n }\n\n let statusObj = this.dictionariesStatuses.find(\n (ds) => ds.dictionaryKey === dictionaryKey\n );\n\n if (!statusObj) {\n // If the dictionaryKey doesn't exist yet, create a new DictionariesStatus\n\n statusObj = {\n dictionaryKey,\n state: [],\n };\n this.dictionariesStatuses.push(statusObj);\n\n const newState: State = {\n type,\n status: 'pending',\n spinnerFrameIndex: 0,\n };\n statusObj.state.push(newState);\n } else {\n const existingState = statusObj.state.find((s) => s.type === type);\n if (!existingState) {\n // Add new state for the type\n\n const newState: State = {\n type,\n status: 'pending',\n spinnerFrameIndex: 0,\n };\n statusObj.state.push(newState);\n }\n }\n }\n\n // Call updateAllStatusLines() to refresh the output\n this.updateAllStatusLines();\n }\n\n private startSpinner() {\n if (!this.spinnerTimer) {\n this.spinnerTimer = setInterval(() => {\n this.updateAllStatusLines();\n }, 100); // Update every 100ms\n }\n }\n\n private stopSpinner() {\n if (this.spinnerTimer) {\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n }\n }\n\n // Method to update the terminal output\n private updateOutput(content: string) {\n if (this.config.log.mode !== 'verbose') return;\n\n // Monkey-patch process.stdout.write to keep track of extra lines\n if (!this.originalStdoutWrite) {\n this.originalStdoutWrite = process.stdout.write.bind(process.stdout);\n this.extraLines = 0;\n\n const write = (\n chunk: string | Uint8Array, // `chunk` can be either a string or a Uint8Array\n encoding?: BufferEncoding, // `encoding` is optional and should be a BufferEncoding\n callback?: (err?: Error | null) => void // `callback` is optional and a function\n ) => {\n const str = typeof chunk === 'string' ? chunk : chunk.toString();\n const newLines = (str.match(/\\n/g) ?? []).length;\n\n // If the write is not initiated by Logger's updateOutput method\n if (!this.isUpdating) {\n this.extraLines += newLines;\n }\n\n return this.originalStdoutWrite!(chunk, encoding, callback);\n };\n\n process.stdout.write = write as typeof process.stdout.write;\n }\n\n // Set a flag to indicate that updateOutput is running\n this.isUpdating = true;\n\n // Adjust lineDifCounter if LINE_DETECTOR is not the first line\n const contentLines = content.split('\\n');\n const indexOfLineDetector = contentLines.indexOf(LINE_DETECTOR.trim());\n\n if (indexOfLineDetector > 0) {\n // LINE_DETECTOR is not at the first line\n this.lineDifCounter = indexOfLineDetector;\n } else {\n this.lineDifCounter = 0;\n }\n\n // Calculate total lines to move up\n const totalLinesToMoveUp =\n this.previousLineCount + this.lineDifCounter + this.extraLines;\n\n // Move cursor up by totalLinesToMoveUp\n readline.moveCursor(process.stdout, 0, -totalLinesToMoveUp);\n\n // Clear all lines downwards\n readline.clearScreenDown(process.stdout);\n\n // Write the updated content\n contentLines.forEach((line) => {\n process.stdout.write(`${line}\\x1b[K\\n`);\n });\n\n // Update previousLineCount\n this.previousLineCount = contentLines.length;\n\n // Reset extraLines counter and updating flag\n this.extraLines = 0;\n this.isUpdating = false;\n }\n\n public stop() {\n this.stopSpinner();\n }\n\n public updateStatus(\n dictionaries: {\n dictionaryKey: string;\n type: 'local' | 'distant';\n status: Partial<State>;\n }[]\n ) {\n for (const { dictionaryKey, type, status } of dictionaries) {\n const statusObj = this.dictionariesStatuses.find(\n (ds) => ds.dictionaryKey === dictionaryKey\n );\n if (statusObj) {\n const state = statusObj.state.find((s) => s.type === type);\n if (state) {\n // Update existing state\n Object.assign(state, status);\n } else {\n // If the state for this type doesn't exist yet, add it\n if (status.status === undefined) {\n status.status = 'pending'; // Provide default status\n }\n const newState: State = {\n type,\n status: status.status,\n icon: status.icon ?? '',\n error: status.error,\n errorMessage: status.errorMessage,\n spinnerFrameIndex: status.spinnerFrameIndex ?? 0,\n };\n statusObj.state.push(newState);\n }\n } else {\n // If the status object doesn't exist, create it\n const newState: State = {\n type,\n status: status.status ?? 'pending',\n icon: status.icon ?? '',\n error: status.error,\n errorMessage: status.errorMessage,\n spinnerFrameIndex: status.spinnerFrameIndex ?? 0,\n };\n this.dictionariesStatuses.push({\n dictionaryKey,\n state: [newState],\n });\n }\n }\n\n // Update the display after status change\n this.updateAllStatusLines();\n }\n\n private getStatusIcon(status: string): string {\n const statusIcons: Record<string, string> = {\n pending: '⏲',\n fetching: '', // Spinner handled separately\n built: '✔',\n imported: '✔',\n error: '✖',\n };\n return statusIcons[status] ?? '';\n }\n\n private getStatusLine(statusObj: DictionariesStatus): string {\n const keyPadding =\n this.maxDictionaryKeyLength - statusObj.dictionaryKey.length;\n const paddedKey = `${statusObj.dictionaryKey}${' '.repeat(keyPadding)}`;\n\n const states = statusObj.state.map((state) => {\n let colorStart = '';\n let colorEnd = '';\n let icon = this.getStatusIcon(state.status);\n if (state.status === 'fetching') {\n // Use spinner frame\n icon = SPINNER_FRAMES[state.spinnerFrameIndex! % SPINNER_FRAMES.length];\n colorStart = BLUE;\n colorEnd = RESET;\n } else if (state.status === 'error') {\n colorStart = RED;\n colorEnd = RESET;\n } else if (state.status === 'imported' || state.status === 'built') {\n colorStart = GREEN;\n colorEnd = RESET;\n } else {\n colorStart = GREY;\n colorEnd = RESET;\n }\n\n // Format the status block\n const statusBlock = `${GREY_DARK}[${state.type}: ${colorStart}${icon} ${state.status}${GREY_DARK}]${colorEnd}`;\n\n return `${colorStart}${statusBlock}${colorEnd}`;\n });\n\n return `${this.config.log.prefix}- ${paddedKey} ${states.join(' ')}`;\n }\n\n // Replace logUpdate calls with your custom methods\n private updateAllStatusLines() {\n const terminalHeight = process.stdout.rows;\n const maxVisibleLines = terminalHeight - 1;\n\n const lines = this.dictionariesStatuses.map((statusObj) => {\n statusObj.state.forEach((state) => {\n if (state.status === 'fetching') {\n // Update spinner frame\n state.spinnerFrameIndex =\n (state.spinnerFrameIndex! + 1) % SPINNER_FRAMES.length;\n }\n });\n return this.getStatusLine(statusObj);\n });\n\n let content;\n\n if (lines.length > maxVisibleLines) {\n const visibleLines = lines.slice(0, maxVisibleLines - 5);\n const summary = `${this.config.log.prefix}... and ${lines.length - visibleLines.length} more`;\n content = LINE_DETECTOR + visibleLines.join('\\n') + '\\n' + summary;\n } else {\n content = lines.join('\\n');\n }\n\n this.updateOutput(content);\n }\n\n public getStatuses() {\n return this.dictionariesStatuses;\n }\n}\n\nexport const logger = Logger.getInstance();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqB;AACrB,mBAAmC;AACnC,oBAAiD;AAgBjD,MAAM,gBAAgB;AACtB,MAAM,iBAAiB,CAAC,UAAK,UAAK,UAAK,UAAK,UAAK,UAAK,UAAK,UAAK,UAAK,QAAG;AAGxE,MAAM,QAAQ;AACd,MAAM,QAAQ;AACd,MAAM,MAAM;AACZ,MAAM,OAAO;AACb,MAAM,OAAO;AACb,MAAM,YAAY;AAElB,MAAM,OAAO;AAAA,EACH,uBAA6C,CAAC;AAAA,EAC9C,eAAsC;AAAA,EACtC,yBAAiC;AAAA,EACjC,oBAA4B;AAAA,EAC5B,iBAAyB;AAAA,EACzB,sBAMG;AAAA,EACH,aAAqB;AAAA,EACrB,aAAsB;AAAA,EACtB;AAAA;AAAA,EAGR,OAAe;AAAA,EAEP,cAAc;AACpB,SAAK,aAAS,gCAAiB;AAAA,EACjC;AAAA,EAEA,OAAc,cAAsB;AAClC,QAAI,CAAC,OAAO,UAAU;AACpB,aAAO,WAAW,IAAI,OAAO;AAAA,IAC/B;AACA,WAAO,OAAO;AAAA,EACh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BAAqB,IAAI,CAAC,cAAc;AACzD,gBAAU,MAAM,QAAQ,CAAC,UAAU;AACjC,YAAI,MAAM,WAAW,YAAY;AAE/B,gBAAM,qBACH,MAAM,oBAAqB,KAAK,eAAe;AAAA,QACpD;AAAA,MACF,CAAC;AACD,aAAO,KAAK,cAAc,SAAS;AAAA,IACrC,CAAC;AAED,QAAI;AAEJ,QAAI,MAAM,SAAS,iBAAiB;AAClC,YAAM,eAAe,MAAM,MAAM,GAAG,kBAAkB,CAAC;AACvD,YAAM,UAAU,GAAG,KAAK,OAAO,IAAI,MAAM,WAAW,MAAM,SAAS,aAAa,MAAM;AACtF,gBAAU,gBAAgB,aAAa,KAAK,IAAI,IAAI,OAAO;AAAA,IAC7D,OAAO;AACL,gBAAU,MAAM,KAAK,IAAI;AAAA,IAC3B;AAEA,SAAK,aAAa,OAAO;AAAA,EAC3B;AAAA,EAEO,cAAc;AACnB,WAAO,KAAK;AAAA,EACd;AACF;AAEO,MAAM,SAAS,OAAO,YAAY;","names":["readline"]}
|
|
1
|
+
{"version":3,"sources":["../../src/log.ts"],"sourcesContent":["import readline from 'readline';\nimport { type IntlayerConfig, getConfiguration } from '@intlayer/config';\nimport { sortAlphabetically } from './utils';\n\nexport type State = {\n type: 'local' | 'distant';\n status: 'pending' | 'fetching' | 'fetched' | 'error' | 'imported' | 'built';\n icon?: string;\n error?: Error;\n errorMessage?: string;\n spinnerFrameIndex?: number;\n};\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n state: State[];\n};\n\nconst LINE_DETECTOR = '\\u200B\\u200B\\u200B'; // Three zero-width spaces\nconst SPINNER_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\n\n// ANSI color codes\nconst RESET = '\\x1b[0m';\nconst GREEN = '\\x1b[32m';\nconst RED = '\\x1b[31m';\nconst BLUE = '\\x1b[34m';\nconst GREY = '\\x1b[90m';\nconst GREY_DARK = '\\x1b[90m';\n\nclass Logger {\n private dictionariesStatuses: DictionariesStatus[] = [];\n private spinnerTimer: NodeJS.Timeout | null = null;\n private maxDictionaryKeyLength: number = 0;\n private previousLineCount: number = 0;\n private lineDifCounter: number = 0;\n private originalStdoutWrite:\n | ((\n chunk: string | Uint8Array, // `chunk` can be either a string or a Uint8Array\n encoding?: BufferEncoding, // `encoding` is optional and should be a BufferEncoding\n callback?: (err?: Error | null) => void // `callback` is optional and a function\n ) => boolean)\n | null = null;\n private extraLines: number = 0;\n private isUpdating: boolean = false;\n private config: IntlayerConfig;\n\n // Singleton instance\n private static instance: Logger;\n\n private constructor() {\n this.config = getConfiguration();\n }\n\n public static getInstance(): Logger {\n if (!Logger.instance) {\n Logger.instance = new Logger();\n }\n return Logger.instance;\n }\n\n public init(\n localDictionariesKeys: string[],\n distantDictionariesKeys: string[]\n ) {\n const allKeys = Array.from(\n new Set(\n [...localDictionariesKeys, ...distantDictionariesKeys].sort(\n sortAlphabetically\n )\n )\n );\n\n this.maxDictionaryKeyLength = allKeys.reduce(\n (max, key) => (key.length > max ? key.length : max),\n 0\n );\n\n this.dictionariesStatuses = allKeys.map((dictionaryKey) => {\n const states: State[] = [];\n\n if (localDictionariesKeys.includes(dictionaryKey)) {\n states.push({\n type: 'local',\n status: 'pending',\n spinnerFrameIndex: 0,\n });\n }\n if (distantDictionariesKeys.includes(dictionaryKey)) {\n states.push({\n type: 'distant',\n status: 'pending',\n spinnerFrameIndex: 0,\n });\n }\n\n return {\n dictionaryKey,\n state: states,\n };\n });\n\n // Start spinner timer\n this.startSpinner();\n\n // Update all status lines (this will output the initial statuses)\n this.updateAllStatusLines();\n }\n\n // New method to add dictionary keys after initialization\n public addDictionaryKeys(\n type: 'local' | 'distant',\n dictionaryKeys: string[]\n ) {\n for (const dictionaryKey of dictionaryKeys) {\n // Update maxDictionaryKeyLength if the new key is longer\n if (dictionaryKey.length > this.maxDictionaryKeyLength) {\n this.maxDictionaryKeyLength = dictionaryKey.length;\n }\n\n let statusObj = this.dictionariesStatuses.find(\n (ds) => ds.dictionaryKey === dictionaryKey\n );\n\n if (!statusObj) {\n // If the dictionaryKey doesn't exist yet, create a new DictionariesStatus\n\n statusObj = {\n dictionaryKey,\n state: [],\n };\n this.dictionariesStatuses.push(statusObj);\n\n const newState: State = {\n type,\n status: 'pending',\n spinnerFrameIndex: 0,\n };\n statusObj.state.push(newState);\n } else {\n const existingState = statusObj.state.find((s) => s.type === type);\n if (!existingState) {\n // Add new state for the type\n\n const newState: State = {\n type,\n status: 'pending',\n spinnerFrameIndex: 0,\n };\n statusObj.state.push(newState);\n }\n }\n }\n\n // Call updateAllStatusLines() to refresh the output\n this.updateAllStatusLines();\n }\n\n private startSpinner() {\n if (!this.spinnerTimer) {\n this.spinnerTimer = setInterval(() => {\n this.updateAllStatusLines();\n }, 100); // Update every 100ms\n }\n }\n\n private stopSpinner() {\n if (this.spinnerTimer) {\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n }\n }\n\n // Method to update the terminal output\n private updateOutput(content: string) {\n if (this.config.log.mode !== 'verbose') return;\n\n // Monkey-patch process.stdout.write to keep track of extra lines\n if (!this.originalStdoutWrite) {\n this.originalStdoutWrite = process.stdout.write.bind(process.stdout);\n this.extraLines = 0;\n\n const write = (\n chunk: string | Uint8Array, // `chunk` can be either a string or a Uint8Array\n encoding?: BufferEncoding, // `encoding` is optional and should be a BufferEncoding\n callback?: (err?: Error | null) => void // `callback` is optional and a function\n ) => {\n const str = typeof chunk === 'string' ? chunk : chunk.toString();\n const newLines = (str.match(/\\n/g) ?? []).length;\n\n // If the write is not initiated by Logger's updateOutput method\n if (!this.isUpdating) {\n this.extraLines += newLines;\n }\n\n return this.originalStdoutWrite!(chunk, encoding, callback);\n };\n\n process.stdout.write = write as typeof process.stdout.write;\n }\n\n // Set a flag to indicate that updateOutput is running\n this.isUpdating = true;\n\n // Adjust lineDifCounter if LINE_DETECTOR is not the first line\n const contentLines = content.split('\\n');\n const indexOfLineDetector = contentLines.indexOf(LINE_DETECTOR.trim());\n\n if (indexOfLineDetector > 0) {\n // LINE_DETECTOR is not at the first line\n this.lineDifCounter = indexOfLineDetector;\n } else {\n this.lineDifCounter = 0;\n }\n\n // Calculate total lines to move up\n const totalLinesToMoveUp =\n this.previousLineCount + this.lineDifCounter + this.extraLines;\n\n // Move cursor up by totalLinesToMoveUp\n readline.moveCursor(process.stdout, 0, -totalLinesToMoveUp);\n\n // Clear all lines downwards\n readline.clearScreenDown(process.stdout);\n\n // Write the updated content\n contentLines.forEach((line) => {\n process.stdout.write(`${line}\\x1b[K\\n`);\n });\n\n // Update previousLineCount\n this.previousLineCount = contentLines.length;\n\n // Reset extraLines counter and updating flag\n this.extraLines = 0;\n this.isUpdating = false;\n }\n\n public stop() {\n this.stopSpinner();\n }\n\n public updateStatus(\n dictionaries: {\n dictionaryKey: string;\n type: 'local' | 'distant';\n status: Partial<State>;\n }[]\n ) {\n for (const { dictionaryKey, type, status } of dictionaries) {\n const statusObj = this.dictionariesStatuses.find(\n (ds) => ds.dictionaryKey === dictionaryKey\n );\n if (statusObj) {\n const state = statusObj.state.find((s) => s.type === type);\n if (state) {\n // Update existing state\n Object.assign(state, status);\n } else {\n // If the state for this type doesn't exist yet, add it\n if (status.status === undefined) {\n status.status = 'pending'; // Provide default status\n }\n const newState: State = {\n type,\n status: status.status,\n icon: status.icon ?? '',\n error: status.error,\n errorMessage: status.errorMessage,\n spinnerFrameIndex: status.spinnerFrameIndex ?? 0,\n };\n statusObj.state.push(newState);\n }\n } else {\n // If the status object doesn't exist, create it\n const newState: State = {\n type,\n status: status.status ?? 'pending',\n icon: status.icon ?? '',\n error: status.error,\n errorMessage: status.errorMessage,\n spinnerFrameIndex: status.spinnerFrameIndex ?? 0,\n };\n this.dictionariesStatuses.push({\n dictionaryKey,\n state: [newState],\n });\n }\n }\n\n // Update the display after status change\n this.updateAllStatusLines();\n }\n\n private getStatusIcon(status: string): string {\n const statusIcons: Record<string, string> = {\n pending: '⏲',\n fetching: '', // Spinner handled separately\n built: '✔',\n imported: '✔',\n error: '✖',\n };\n return statusIcons[status] ?? '';\n }\n\n private getStatusLine(statusObj: DictionariesStatus): string {\n const keyPadding =\n this.maxDictionaryKeyLength - statusObj.dictionaryKey.length;\n const paddedKey = `${statusObj.dictionaryKey}${' '.repeat(keyPadding)}`;\n\n const states = statusObj.state.map((state) => {\n let colorStart = '';\n let colorEnd = '';\n let icon = this.getStatusIcon(state.status);\n if (state.status === 'fetching') {\n // Use spinner frame\n icon = SPINNER_FRAMES[state.spinnerFrameIndex! % SPINNER_FRAMES.length];\n colorStart = BLUE;\n colorEnd = RESET;\n } else if (state.status === 'error') {\n colorStart = RED;\n colorEnd = RESET;\n } else if (state.status === 'imported' || state.status === 'built') {\n colorStart = GREEN;\n colorEnd = RESET;\n } else {\n colorStart = GREY;\n colorEnd = RESET;\n }\n\n // Format the status block\n const statusBlock = `${GREY_DARK}[${state.type}: ${colorStart}${icon} ${state.status}${GREY_DARK}]${colorEnd}`;\n\n return `${colorStart}${statusBlock}${colorEnd}`;\n });\n\n return `${this.config.log.prefix}- ${paddedKey} ${states.join(' ')}`;\n }\n\n // Replace logUpdate calls with your custom methods\n private updateAllStatusLines() {\n const terminalHeight = process.stdout.rows;\n const maxVisibleLines = terminalHeight - 1;\n\n const lines = this.dictionariesStatuses.map((statusObj) => {\n statusObj.state.forEach((state) => {\n if (state.status === 'fetching') {\n // Update spinner frame\n state.spinnerFrameIndex =\n (state.spinnerFrameIndex! + 1) % SPINNER_FRAMES.length;\n }\n });\n return this.getStatusLine(statusObj);\n });\n\n let content;\n\n if (lines.length > maxVisibleLines) {\n const visibleLines = lines.slice(0, maxVisibleLines - 5);\n const summary = `${this.config.log.prefix}... and ${lines.length - visibleLines.length} more`;\n content = LINE_DETECTOR + visibleLines.join('\\n') + '\\n' + summary;\n } else {\n content = lines.join('\\n');\n }\n\n this.updateOutput(content);\n }\n\n public getStatuses() {\n return this.dictionariesStatuses;\n }\n}\n\nexport const logger = Logger.getInstance();\n"],"mappings":";;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SAAK,aAAa,OAAO;AAAA,EAC3B;AAAA,EAEO,cAAc;AACnB,WAAO,KAAK;AAAA,EACd;AACF;AAEO,MAAM,SAAS,OAAO,YAAY;","names":["readline"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mergeDictionaries.ts"],"sourcesContent":["import merge, { Options } from 'deepmerge';\n\n// Custom array merge function that merges objects by 'key'\nexport const mergeByKey = <T extends { key: string }>(key: keyof T) => {\n return (target: T[], source: T[], options?: Options): T[] => {\n const destination: T[] = [];\n\n // Create a map for quick lookup\n const sourceMap = new Map<string, T>();\n source.forEach((item) => {\n sourceMap.set(item[key] as string, item);\n });\n\n target.forEach((targetItem) => {\n const sourceItem = sourceMap.get(targetItem[key] as string);\n if (sourceItem) {\n // Merge the two items and assert the type\n const mergedItem = merge(targetItem, sourceItem, options) as T;\n destination.push(mergedItem);\n // Remove the item from the source map to avoid duplicates\n sourceMap.delete(targetItem[key] as string);\n } else {\n destination.push(targetItem);\n }\n });\n\n // Add remaining items from source\n sourceMap.forEach((item) => {\n destination.push(item);\n });\n\n return destination;\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/mergeDictionaries.ts"],"sourcesContent":["import merge, { type Options } from 'deepmerge';\n\n// Custom array merge function that merges objects by 'key'\nexport const mergeByKey = <T extends { key: string }>(key: keyof T) => {\n return (target: T[], source: T[], options?: Options): T[] => {\n const destination: T[] = [];\n\n // Create a map for quick lookup\n const sourceMap = new Map<string, T>();\n source.forEach((item) => {\n sourceMap.set(item[key] as string, item);\n });\n\n target.forEach((targetItem) => {\n const sourceItem = sourceMap.get(targetItem[key] as string);\n if (sourceItem) {\n // Merge the two items and assert the type\n const mergedItem = merge(targetItem, sourceItem, options) as T;\n destination.push(mergedItem);\n // Remove the item from the source map to avoid duplicates\n sourceMap.delete(targetItem[key] as string);\n } else {\n destination.push(targetItem);\n }\n });\n\n // Add remaining items from source\n sourceMap.forEach((item) => {\n destination.push(item);\n });\n\n return destination;\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAoC;AAG7B,MAAM,aAAa,CAA4B,QAAiB;AACrE,SAAO,CAAC,QAAa,QAAa,YAA2B;AAC3D,UAAM,cAAmB,CAAC;AAG1B,UAAM,YAAY,oBAAI,IAAe;AACrC,WAAO,QAAQ,CAAC,SAAS;AACvB,gBAAU,IAAI,KAAK,GAAG,GAAa,IAAI;AAAA,IACzC,CAAC;AAED,WAAO,QAAQ,CAAC,eAAe;AAC7B,YAAM,aAAa,UAAU,IAAI,WAAW,GAAG,CAAW;AAC1D,UAAI,YAAY;AAEd,cAAM,iBAAa,iBAAAA,SAAM,YAAY,YAAY,OAAO;AACxD,oBAAY,KAAK,UAAU;AAE3B,kBAAU,OAAO,WAAW,GAAG,CAAW;AAAA,MAC5C,OAAO;AACL,oBAAY,KAAK,UAAU;AAAA,MAC7B;AAAA,IACF,CAAC;AAGD,cAAU,QAAQ,CAAC,SAAS;AAC1B,kBAAY,KAAK,IAAI;AAAA,IACvB,CAAC;AAED,WAAO;AAAA,EACT;AACF;","names":["merge"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.ts"],"sourcesContent":["import { mkdir, writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport { I18nextDictionariesOutput } from './convertContentDeclarationInto18nDictionaries';\n\nconst { content } = getConfiguration();\nconst { i18nextResourcesDir } = content;\n\nexport type DictionariesDeclaration = Record<string, I18nextDictionariesOutput>;\n\n/**\n * This function writes the dictionaries to the file system\n */\nexport const writeDictionary = async (\n dictionariesDeclaration: DictionariesDeclaration\n) => {\n const resultDictionariesPaths: string[] = [];\n\n for (const [nameSpace, localContent] of Object.entries(\n dictionariesDeclaration\n )) {\n for await (const [locale, content] of Object.entries(localContent)) {\n const contentString = JSON.stringify(content);\n\n const outputFileName = `${nameSpace}.json`;\n const resultDirPath = resolve(i18nextResourcesDir, locale);\n const resultFilePath = resolve(resultDirPath, outputFileName);\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resultDirPath, { recursive: true });\n\n // Create the json file\n await writeFile(resultFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating ${outputFileName}:`, err);\n });\n\n resultDictionariesPaths.push(resultFilePath);\n }\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAiC;AACjC,kBAAwB;AACxB,oBAAiC;AAGjC,MAAM,EAAE,QAAQ,QAAI,gCAAiB;AACrC,MAAM,EAAE,oBAAoB,IAAI;AAOzB,MAAM,kBAAkB,OAC7B,4BACG;AACH,QAAM,0BAAoC,CAAC;AAE3C,aAAW,CAAC,WAAW,YAAY,KAAK,OAAO;AAAA,IAC7C;AAAA,EACF,GAAG;AACD,qBAAiB,CAAC,QAAQA,QAAO,KAAK,OAAO,QAAQ,YAAY,GAAG;AAClE,YAAM,gBAAgB,KAAK,UAAUA,QAAO;AAE5C,YAAM,iBAAiB,GAAG,SAAS;AACnC,YAAM,oBAAgB,qBAAQ,qBAAqB,MAAM;AACzD,YAAM,qBAAiB,qBAAQ,eAAe,cAAc;AAG5D,gBAAM,uBAAM,eAAe,EAAE,WAAW,KAAK,CAAC;AAG9C,gBAAM,2BAAU,gBAAgB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACpE,gBAAQ,MAAM,kBAAkB,cAAc,KAAK,GAAG;AAAA,MACxD,CAAC;AAED,8BAAwB,KAAK,cAAc;AAAA,IAC7C;AAAA,EACF;AAEA,SAAO;AACT;","names":["content"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.ts"],"sourcesContent":["import { mkdir, writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport type { I18nextDictionariesOutput } from './convertContentDeclarationInto18nDictionaries';\n\nconst { content } = getConfiguration();\nconst { i18nextResourcesDir } = content;\n\nexport type DictionariesDeclaration = Record<string, I18nextDictionariesOutput>;\n\n/**\n * This function writes the dictionaries to the file system\n */\nexport const writeDictionary = async (\n dictionariesDeclaration: DictionariesDeclaration\n) => {\n const resultDictionariesPaths: string[] = [];\n\n for (const [nameSpace, localContent] of Object.entries(\n dictionariesDeclaration\n )) {\n for await (const [locale, content] of Object.entries(localContent)) {\n const contentString = JSON.stringify(content);\n\n const outputFileName = `${nameSpace}.json`;\n const resultDirPath = resolve(i18nextResourcesDir, locale);\n const resultFilePath = resolve(resultDirPath, outputFileName);\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resultDirPath, { recursive: true });\n\n // Create the json file\n await writeFile(resultFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating ${outputFileName}:`, err);\n });\n\n resultDictionariesPaths.push(resultFilePath);\n }\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAiC;AACjC,kBAAwB;AACxB,oBAAiC;AAGjC,MAAM,EAAE,QAAQ,QAAI,gCAAiB;AACrC,MAAM,EAAE,oBAAoB,IAAI;AAOzB,MAAM,kBAAkB,OAC7B,4BACG;AACH,QAAM,0BAAoC,CAAC;AAE3C,aAAW,CAAC,WAAW,YAAY,KAAK,OAAO;AAAA,IAC7C;AAAA,EACF,GAAG;AACD,qBAAiB,CAAC,QAAQA,QAAO,KAAK,OAAO,QAAQ,YAAY,GAAG;AAClE,YAAM,gBAAgB,KAAK,UAAUA,QAAO;AAE5C,YAAM,iBAAiB,GAAG,SAAS;AACnC,YAAM,oBAAgB,qBAAQ,qBAAqB,MAAM;AACzD,YAAM,qBAAiB,qBAAQ,eAAe,cAAc;AAG5D,gBAAM,uBAAM,eAAe,EAAE,WAAW,KAAK,CAAC;AAG9C,gBAAM,2BAAU,gBAAgB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACpE,gBAAQ,MAAM,kBAAkB,cAAc,KAAK,GAAG;AAAA,MACxD,CAAC;AAED,8BAAwB,KAAK,cAAc;AAAA,IAC7C;AAAA,EACF;AAEA,SAAO;AACT;","names":["content"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/declaration_file_to_dictionary/index.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { Dictionary } from '@intlayer/core';\nimport { buildI18nDictionary } from './i18next_dictionary/index';\nimport { buildIntlayerDictionary } from './intlayer_dictionary/index';\n\nconst {\n content: { dictionaryOutput },\n} = getConfiguration();\n\nexport const buildDictionary = async (\n contentDeclarationsPaths: Dictionary[]\n): Promise<string[]> => {\n if (dictionaryOutput.includes('i18next')) {\n await buildI18nDictionary(contentDeclarationsPaths);\n }\n\n if (dictionaryOutput.includes('intlayer')) {\n return await buildIntlayerDictionary(contentDeclarationsPaths);\n }\n\n return [];\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AAEjC,gCAAoC;AACpC,iCAAwC;AAExC,MAAM;AAAA,EACJ,SAAS,EAAE,iBAAiB;AAC9B,QAAI,gCAAiB;AAEd,MAAM,kBAAkB,OAC7B,6BACsB;AACtB,MAAI,iBAAiB,SAAS,SAAS,GAAG;AACxC,cAAM,+CAAoB,wBAAwB;AAAA,EACpD;AAEA,MAAI,iBAAiB,SAAS,UAAU,GAAG;AACzC,WAAO,UAAM,oDAAwB,wBAAwB;AAAA,EAC/D;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\nconst {\n content: { dictionaryOutput },\n} = getConfiguration();\n\nexport const buildDictionary = async (\n contentDeclarationsPaths: Dictionary[]\n): Promise<string[]> => {\n if (dictionaryOutput.includes('i18next')) {\n await buildI18nDictionary(contentDeclarationsPaths);\n }\n\n if (dictionaryOutput.includes('intlayer')) {\n return await buildIntlayerDictionary(contentDeclarationsPaths);\n }\n\n return [];\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AAEjC,gCAAoC;AACpC,iCAAwC;AAExC,MAAM;AAAA,EACJ,SAAS,EAAE,iBAAiB;AAC9B,QAAI,gCAAiB;AAEd,MAAM,kBAAkB,OAC7B,6BACsB;AACtB,MAAI,iBAAiB,SAAS,SAAS,GAAG;AACxC,cAAM,+CAAoB,wBAAwB;AAAA,EACpD;AAEA,MAAI,iBAAiB,SAAS,UAAU,GAAG;AACzC,WAAO,UAAM,oDAAwB,wBAAwB;AAAA,EAC/D;AAEA,SAAO,CAAC;AACV;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.ts"],"sourcesContent":["import { mkdir } from 'fs/promises';\nimport { resolve } from 'path';\
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.ts"],"sourcesContent":["import { mkdir } from 'fs/promises';\nimport { resolve } from 'path';\n// @ts-ignore: @intlayer/backend is not built yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { writeDictionary } from './writeDictionary';\n\nconst { content } = getConfiguration();\nconst { dictionariesDir } = content;\n\n/**\n * This function transpile the bundled code to to make dictionaries as JSON files\n */\nexport const buildIntlayerDictionary = async (\n contentDeclarations: (DictionaryAPI | Dictionary)[]\n) => {\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n const dictionariesPaths: string[] = await writeDictionary(\n contentDeclarations as Dictionary[]\n );\n\n return dictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAsB;AACtB,kBAAwB;AAGxB,oBAAiC;AAEjC,6BAAgC;AAEhC,MAAM,EAAE,QAAQ,QAAI,gCAAiB;AACrC,MAAM,EAAE,gBAAgB,IAAI;AAKrB,MAAM,0BAA0B,OACrC,wBACG;AAEH,YAAM,2BAAM,qBAAQ,eAAe,GAAG,EAAE,WAAW,KAAK,CAAC;AAEzD,QAAM,oBAA8B,UAAM;AAAA,IACxC;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.ts"],"sourcesContent":["import { logger } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\n\n/**\n * Helper that awaits either a synchronous or asynchronous value.\n */\nconst awaitFunction = async (fn: any) => {\n // Check if result is a Promise (Thenable)\n\n if (fn && typeof fn.then === 'function') {\n // It's a Promise, so wait for it to resolve\n await fn;\n }\n // If not a Promise, it will just execute without awaiting\n};\n\n/**\n * A more \"unified\" approach where each type (function, array, object, primitive)\n * is handled inside the main recursive body.\n */\nconst processFunctionResults = async <T = unknown>(entry: any): Promise<T> => {\n // If entry is a function, invoke it and process the result\n if (typeof entry === 'function') {\n const result = await awaitFunction(entry());\n // Recursively process the result in case it contains nested arrays/objects/functions\n return await processFunctionResults(result);\n }\n\n // If entry is an array, recursively process each item\n if (Array.isArray(entry)) {\n return Promise.all(\n entry.map(async (item) => await processFunctionResults(item))\n ) as unknown as T;\n }\n\n // If entry is an object, recursively process each property\n if (entry && typeof entry === 'object') {\n const result: Record<string, any> = {};\n // Use Promise.all to handle any async resolution for the properties\n const keys = Object.keys(entry);\n await Promise.all(\n keys.map(async (key) => {\n result[key] = await processFunctionResults(entry[key]);\n })\n );\n return result as T;\n }\n\n // Otherwise, it's a primitive value—just return as is\n return entry as T;\n};\n\n/**\n * Function to load, process the module and return the Intlayer Dictionary from the module file\n */\nexport const processContentDeclaration = async (\n contentDeclaration: Dictionary\n): Promise<Dictionary | undefined> => {\n try {\n const content = (await processFunctionResults(\n contentDeclaration.content\n )) as Dictionary['content'];\n\n return {\n ...contentDeclaration,\n content,\n } as Dictionary;\n } catch (error) {\n logger(error, {\n level: 'error',\n });\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAuB;AAMvB,MAAM,gBAAgB,OAAO,OAAY;AAGvC,MAAI,MAAM,OAAO,GAAG,SAAS,YAAY;AAEvC,UAAM;AAAA,EACR;AAEF;AAMA,MAAM,yBAAyB,OAAoB,UAA2B;AAE5E,MAAI,OAAO,UAAU,YAAY;AAC/B,UAAM,SAAS,MAAM,cAAc,MAAM,CAAC;AAE1C,WAAO,MAAM,uBAAuB,MAAM;AAAA,EAC5C;AAGA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,QAAQ;AAAA,MACb,MAAM,IAAI,OAAO,SAAS,MAAM,uBAAuB,IAAI,CAAC;AAAA,IAC9D;AAAA,EACF;AAGA,MAAI,SAAS,OAAO,UAAU,UAAU;AACtC,UAAM,SAA8B,CAAC;AAErC,UAAM,OAAO,OAAO,KAAK,KAAK;AAC9B,UAAM,QAAQ;AAAA,MACZ,KAAK,IAAI,OAAO,QAAQ;AACtB,eAAO,GAAG,IAAI,MAAM,uBAAuB,MAAM,GAAG,CAAC;AAAA,MACvD,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AAGA,SAAO;AACT;AAKO,MAAM,4BAA4B,OACvC,uBACoC;AACpC,MAAI;AACF,UAAM,UAAW,MAAM;AAAA,MACrB,mBAAmB;AAAA,IACrB;AAEA,WAAO;AAAA,MACL,GAAG;AAAA,MACH;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,8BAAO,OAAO;AAAA,MACZ,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.ts"],"sourcesContent":["import { mkdir, writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport { I18nextDictionariesOutput } from '../i18next_dictionary/convertContentDeclarationInto18nDictionaries';\n\nconst { content } = getConfiguration();\nconst { reactIntlMessagesDir } = content;\n\nexport type DictionariesDeclaration = Record<string, I18nextDictionariesOutput>;\n\n/**\n * This function writes the dictionaries to the file system\n */\nexport const writeDictionary = async (\n dictionariesDeclaration: DictionariesDeclaration\n) => {\n const resultDictionariesPaths: string[] = [];\n\n for (const [nameSpace, localContent] of Object.entries(\n dictionariesDeclaration\n )) {\n for await (const [locale, content] of Object.entries(localContent)) {\n const contentString = JSON.stringify(content);\n\n const outputFileName = `${nameSpace}.json`;\n const resultDirPath = resolve(reactIntlMessagesDir, locale);\n const resultFilePath = resolve(resultDirPath, outputFileName);\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resultDirPath, { recursive: true });\n\n // Create the json file\n await writeFile(resultFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating ${outputFileName}:`, err);\n });\n\n resultDictionariesPaths.push(resultFilePath);\n }\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAiC;AACjC,kBAAwB;AACxB,oBAAiC;AAGjC,MAAM,EAAE,QAAQ,QAAI,gCAAiB;AACrC,MAAM,EAAE,qBAAqB,IAAI;AAO1B,MAAM,kBAAkB,OAC7B,4BACG;AACH,QAAM,0BAAoC,CAAC;AAE3C,aAAW,CAAC,WAAW,YAAY,KAAK,OAAO;AAAA,IAC7C;AAAA,EACF,GAAG;AACD,qBAAiB,CAAC,QAAQA,QAAO,KAAK,OAAO,QAAQ,YAAY,GAAG;AAClE,YAAM,gBAAgB,KAAK,UAAUA,QAAO;AAE5C,YAAM,iBAAiB,GAAG,SAAS;AACnC,YAAM,oBAAgB,qBAAQ,sBAAsB,MAAM;AAC1D,YAAM,qBAAiB,qBAAQ,eAAe,cAAc;AAG5D,gBAAM,uBAAM,eAAe,EAAE,WAAW,KAAK,CAAC;AAG9C,gBAAM,2BAAU,gBAAgB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACpE,gBAAQ,MAAM,kBAAkB,cAAc,KAAK,GAAG;AAAA,MACxD,CAAC;AAED,8BAAwB,KAAK,cAAc;AAAA,IAC7C;AAAA,EACF;AAEA,SAAO;AACT;","names":["content"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.ts"],"sourcesContent":["import { mkdir, writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport type { I18nextDictionariesOutput } from '../i18next_dictionary/convertContentDeclarationInto18nDictionaries';\n\nconst { content } = getConfiguration();\nconst { reactIntlMessagesDir } = content;\n\nexport type DictionariesDeclaration = Record<string, I18nextDictionariesOutput>;\n\n/**\n * This function writes the dictionaries to the file system\n */\nexport const writeDictionary = async (\n dictionariesDeclaration: DictionariesDeclaration\n) => {\n const resultDictionariesPaths: string[] = [];\n\n for (const [nameSpace, localContent] of Object.entries(\n dictionariesDeclaration\n )) {\n for await (const [locale, content] of Object.entries(localContent)) {\n const contentString = JSON.stringify(content);\n\n const outputFileName = `${nameSpace}.json`;\n const resultDirPath = resolve(reactIntlMessagesDir, locale);\n const resultFilePath = resolve(resultDirPath, outputFileName);\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resultDirPath, { recursive: true });\n\n // Create the json file\n await writeFile(resultFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating ${outputFileName}:`, err);\n });\n\n resultDictionariesPaths.push(resultFilePath);\n }\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAiC;AACjC,kBAAwB;AACxB,oBAAiC;AAGjC,MAAM,EAAE,QAAQ,QAAI,gCAAiB;AACrC,MAAM,EAAE,qBAAqB,IAAI;AAO1B,MAAM,kBAAkB,OAC7B,4BACG;AACH,QAAM,0BAAoC,CAAC;AAE3C,aAAW,CAAC,WAAW,YAAY,KAAK,OAAO;AAAA,IAC7C;AAAA,EACF,GAAG;AACD,qBAAiB,CAAC,QAAQA,QAAO,KAAK,OAAO,QAAQ,YAAY,GAAG;AAClE,YAAM,gBAAgB,KAAK,UAAUA,QAAO;AAE5C,YAAM,iBAAiB,GAAG,SAAS;AACnC,YAAM,oBAAgB,qBAAQ,sBAAsB,MAAM;AAC1D,YAAM,qBAAiB,qBAAQ,eAAe,cAAc;AAG5D,gBAAM,uBAAM,eAAe,EAAE,WAAW,KAAK,CAAC;AAG9C,gBAAM,2BAAU,gBAAgB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACpE,gBAAQ,MAAM,kBAAkB,cAAc,KAAK,GAAG;AAAA,MACxD,CAAC;AAED,8BAAwB,KAAK,cAAc;AAAA,IAC7C;AAAA,EACF;AAEA,SAAO;AACT;","names":["content"]}
|
|
@@ -16,11 +16,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var createDictionaryEntryPoint_exports = {};
|
|
20
|
+
__export(createDictionaryEntryPoint_exports, {
|
|
21
|
+
createDictionaryEntryPoint: () => createDictionaryEntryPoint
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(createDictionaryEntryPoint_exports);
|
|
24
24
|
var import_fs = require("fs");
|
|
25
25
|
var import_path = require("path");
|
|
26
26
|
var import_config = require("@intlayer/config");
|
|
@@ -59,7 +59,7 @@ ${formattedDictionaryMap}
|
|
|
59
59
|
`;
|
|
60
60
|
return content2;
|
|
61
61
|
};
|
|
62
|
-
const
|
|
62
|
+
const createDictionaryEntryPoint = () => {
|
|
63
63
|
if (!(0, import_fs.existsSync)(mainDir)) {
|
|
64
64
|
(0, import_fs.mkdirSync)(mainDir, { recursive: true });
|
|
65
65
|
}
|
|
@@ -71,6 +71,6 @@ const createDictionaryList = () => {
|
|
|
71
71
|
};
|
|
72
72
|
// Annotate the CommonJS export names for ESM import in node:
|
|
73
73
|
0 && (module.exports = {
|
|
74
|
-
|
|
74
|
+
createDictionaryEntryPoint
|
|
75
75
|
});
|
|
76
|
-
//# sourceMappingURL=
|
|
76
|
+
//# sourceMappingURL=createDictionaryEntryPoint.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/createDictionaryEntryPoint.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { basename, extname, relative, resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport { getDictionariesPath } from '../../getDictionariesPath';\nimport { getFileHash } from '../../utils';\n\nconst { content } = getConfiguration();\nconst { mainDir } = content;\n\n/**\n * This function generates the content of the dictionary list file\n */\nconst generateDictionaryListContent = (\n dictionaries: string[],\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n let content = '';\n\n const dictionariesRef = dictionaries.map((dictionaryPath) => ({\n relativePath: relative(mainDir, dictionaryPath),\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n if (format === 'esm')\n content += `import ${dictionary.hash} from '${dictionary.relativePath}';\\n`;\n if (format === 'cjs')\n content += `const ${dictionary.hash} = require('${dictionary.relativePath}');\\n`;\n });\n\n content += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": ${dictionary.hash}`)\n .join(',\\n');\n\n if (format === 'esm')\n content += `export default {\\n${formattedDictionaryMap}\\n};\\n`;\n if (format === 'cjs')\n content += `module.exports = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n return content;\n};\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const createDictionaryEntryPoint = () => {\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n const dictionariesPath: string[] = getDictionariesPath();\n\n // Create the dictionary list file\n const cjsContent = generateDictionaryListContent(dictionariesPath, 'cjs');\n writeFileSync(resolve(mainDir, 'dictionaries.cjs'), cjsContent);\n\n const esmContent = generateDictionaryListContent(dictionariesPath, 'esm');\n writeFileSync(resolve(mainDir, 'dictionaries.mjs'), esmContent);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAqD;AACrD,kBAAqD;AACrD,oBAAiC;AACjC,iCAAoC;AACpC,mBAA4B;AAE5B,MAAM,EAAE,QAAQ,QAAI,gCAAiB;AACrC,MAAM,EAAE,QAAQ,IAAI;AAKpB,MAAM,gCAAgC,CACpC,cACA,SAAwB,UACb;AACX,MAAIA,WAAU;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,MAAAA,YAAW,UAAU,WAAW,IAAI,UAAU,WAAW,YAAY;AAAA;AACvE,QAAI,WAAW;AACb,MAAAA,YAAW,SAAS,WAAW,IAAI,eAAe,WAAW,YAAY;AAAA;AAAA,EAC7E,CAAC;AAED,EAAAA,YAAW;AAGX,QAAM,yBAAiC,gBACpC,IAAI,CAAC,eAAe,MAAM,WAAW,EAAE,MAAM,WAAW,IAAI,EAAE,EAC9D,KAAK,KAAK;AAEb,MAAI,WAAW;AACb,IAAAA,YAAW;AAAA,EAAqB,sBAAsB;AAAA;AAAA;AACxD,MAAI,WAAW;AACb,IAAAA,YAAW;AAAA,EAAuB,sBAAsB;AAAA;AAAA;AAE1D,SAAOA;AACT;AAKO,MAAM,6BAA6B,MAAM;AAE9C,MAAI,KAAC,sBAAW,OAAO,GAAG;AACxB,6BAAU,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACxC;AAEA,QAAM,uBAA6B,gDAAoB;AAGvD,QAAM,aAAa,8BAA8B,kBAAkB,KAAK;AACxE,mCAAc,qBAAQ,SAAS,kBAAkB,GAAG,UAAU;AAE9D,QAAM,aAAa,8BAA8B,kBAAkB,KAAK;AACxE,mCAAc,qBAAQ,SAAS,kBAAkB,GAAG,UAAU;AAChE;","names":["content"]}
|
|
@@ -15,9 +15,9 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
16
|
var dictionary_to_main_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(dictionary_to_main_exports);
|
|
18
|
-
__reExport(dictionary_to_main_exports, require('./
|
|
18
|
+
__reExport(dictionary_to_main_exports, require('./createDictionaryEntryPoint.cjs'), module.exports);
|
|
19
19
|
// Annotate the CommonJS export names for ESM import in node:
|
|
20
20
|
0 && (module.exports = {
|
|
21
|
-
...require('./
|
|
21
|
+
...require('./createDictionaryEntryPoint.cjs')
|
|
22
22
|
});
|
|
23
23
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/index.ts"],"sourcesContent":["export * from './
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/index.ts"],"sourcesContent":["export * from './createDictionaryEntryPoint';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,uCAAc,yCAAd;","names":[]}
|
|
@@ -74,6 +74,8 @@ ${formattedDictionaryMap}
|
|
|
74
74
|
content2 += ` type ConfigLocales = ${formatLocales};
|
|
75
75
|
`;
|
|
76
76
|
content2 += ` type ExtractedLocales = Extract<Locales, ConfigLocales>;
|
|
77
|
+
`;
|
|
78
|
+
content2 += ` type ExcludedLocales = Exclude<Locales, ConfigLocales>;
|
|
77
79
|
`;
|
|
78
80
|
content2 += ` ${strictModeRecord}
|
|
79
81
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createModuleAugmentation.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { basename, extname, join, relative } from 'path';\nimport { Locales, getConfiguration } from '@intlayer/config';\nimport fg from 'fast-glob';\nimport { getFileHash, kebabCaseToCamelCase } from '../../utils';\n\nconst { content, internationalization } = getConfiguration();\nconst { moduleAugmentationDir, typesDir } = content;\nconst { locales, strictMode } = internationalization;\n\nexport const getTypeName = (key: string): string =>\n `${kebabCaseToCamelCase(key)}Content`;\n\n/**\n * This function generates the content of the module augmentation file\n */\nconst generateTypeIndexContent = (typeFiles: string[]): string => {\n let content = \"/* eslint-disable */\\nimport { Locales } from 'intlayer';\\n\";\n\n const dictionariesRef = typeFiles.map((dictionaryPath) => ({\n relativePath: `./${relative(moduleAugmentationDir, dictionaryPath)}`,\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id (without the extension)\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n content += `import ${dictionary.hash} from '${dictionary.relativePath}';\\n`;\n });\n\n content += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": typeof ${dictionary.hash};`)\n .join('\\n');\n\n const formatLocales = locales\n .map((locale) => {\n for (const key in Locales) {\n if (Locales[key as keyof typeof Locales] === locale) {\n return `Locales.${key}`;\n }\n }\n })\n .join(' | ');\n\n const strictModeRecord =\n strictMode === 'strict'\n ? `interface IConfigLocales<Content> extends Record<ExtractedLocales, Content> {}`\n : strictMode === 'required_only'\n ? `interface IConfigLocales<Content> extends Record<ExtractedLocales, Content>, Partial<Record<ExcludedLocales, Content>> {}`\n : `interface IConfigLocales<Content> extends Partial<Record<Locales, Content>> {}`;\n\n /**\n * Write the module augmentation to extend the intlayer module with the dictionaries types\n * Will suggest the type resulting of the dictionaries\n *\n * declare module 'intlayer' {\n * interface IntlayerDictionaryTypesConnector = {\n * dictionaries: {\n * id: DictionaryType;\n * }\n * }\n *\n * type ConfigLocales = Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH;\n * type ExtractedLocales = Extract<Locales, ConfigLocales>;\n *\n * interface IConfigLocales<Content> extends Record<ExtractedLocales, Content>, Partial<Record<ExcludedLocales, Content>> {}\n *\n *\n * }\n * See https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation\n */\n content += `declare module 'intlayer' {\\n`;\n content += ` interface IntlayerDictionaryTypesConnector {\\n${formattedDictionaryMap}\\n }\\n\\n`;\n content += ` type ConfigLocales = ${formatLocales};\\n`;\n content += ` type ExtractedLocales = Extract<Locales, ConfigLocales>;\\n`;\n content += ` ${strictModeRecord}\\n`;\n content += `}`;\n\n return content;\n};\n\n/**\n * This function generates a index file merging all the types\n */\nexport const createModuleAugmentation = () => {\n // Create main directory if it doesn't exist\n if (!existsSync(moduleAugmentationDir)) {\n mkdirSync(moduleAugmentationDir, { recursive: true });\n }\n\n const dictionariesTypesDefinitions: string[] = fg.sync(`${typesDir}/*.ts`, {\n ignore: ['**/*.d.ts'],\n });\n // Create the dictionary list file\n\n const tsContent = generateTypeIndexContent(dictionariesTypesDefinitions);\n writeFileSync(join(moduleAugmentationDir, 'intlayer.d.ts'), tsContent);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAqD;AACrD,kBAAkD;AAClD,oBAA0C;AAC1C,uBAAe;AACf,mBAAkD;AAElD,MAAM,EAAE,SAAS,qBAAqB,QAAI,gCAAiB;AAC3D,MAAM,EAAE,uBAAuB,SAAS,IAAI;AAC5C,MAAM,EAAE,SAAS,WAAW,IAAI;AAEzB,MAAM,cAAc,CAAC,QAC1B,OAAG,mCAAqB,GAAG,CAAC;AAK9B,MAAM,2BAA2B,CAAC,cAAgC;AAChE,MAAIA,WAAU;AAEd,QAAM,kBAAkB,UAAU,IAAI,CAAC,oBAAoB;AAAA,IACzD,cAAc,SAAK,sBAAS,uBAAuB,cAAc,CAAC;AAAA,IAClE,QAAI,sBAAS,oBAAgB,qBAAQ,cAAc,CAAC;AAAA;AAAA,IACpD,MAAM,QAAI,0BAAY,cAAc,CAAC;AAAA;AAAA,EACvC,EAAE;AAGF,kBAAgB,QAAQ,CAAC,eAAe;AACtC,IAAAA,YAAW,UAAU,WAAW,IAAI,UAAU,WAAW,YAAY;AAAA;AAAA,EACvE,CAAC;AAED,EAAAA,YAAW;AAGX,QAAM,yBAAiC,gBACpC,IAAI,CAAC,eAAe,QAAQ,WAAW,EAAE,aAAa,WAAW,IAAI,GAAG,EACxE,KAAK,IAAI;AAEZ,QAAM,gBAAgB,QACnB,IAAI,CAAC,WAAW;AACf,eAAW,OAAO,uBAAS;AACzB,UAAI,sBAAQ,GAA2B,MAAM,QAAQ;AACnD,eAAO,WAAW,GAAG;AAAA,MACvB;AAAA,IACF;AAAA,EACF,CAAC,EACA,KAAK,KAAK;AAEb,QAAM,mBACJ,eAAe,WACX,mFACA,eAAe,kBACb,8HACA;AAsBR,EAAAA,YAAW;AAAA;AACX,EAAAA,YAAW;AAAA,EAAmD,sBAAsB;AAAA;AAAA;AAAA;AACpF,EAAAA,YAAW,0BAA0B,aAAa;AAAA;AAClD,EAAAA,YAAW;AAAA;AACX,EAAAA,YAAW,KAAK,gBAAgB;AAAA;AAChC,EAAAA,YAAW;AAEX,SAAOA;AACT;AAKO,MAAM,2BAA2B,MAAM;AAE5C,MAAI,KAAC,sBAAW,qBAAqB,GAAG;AACtC,6BAAU,uBAAuB,EAAE,WAAW,KAAK,CAAC;AAAA,EACtD;AAEA,QAAM,+BAAyC,iBAAAC,QAAG,KAAK,GAAG,QAAQ,SAAS;AAAA,IACzE,QAAQ,CAAC,WAAW;AAAA,EACtB,CAAC;AAGD,QAAM,YAAY,yBAAyB,4BAA4B;AACvE,mCAAc,kBAAK,uBAAuB,eAAe,GAAG,SAAS;AACvE;","names":["content","fg"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createModuleAugmentation.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { basename, extname, join, relative } from 'path';\nimport { Locales, getConfiguration } from '@intlayer/config';\nimport fg from 'fast-glob';\nimport { getFileHash, kebabCaseToCamelCase } from '../../utils';\n\nconst { content, internationalization } = getConfiguration();\nconst { moduleAugmentationDir, typesDir } = content;\nconst { locales, strictMode } = internationalization;\n\nexport const getTypeName = (key: string): string =>\n `${kebabCaseToCamelCase(key)}Content`;\n\n/**\n * This function generates the content of the module augmentation file\n */\nconst generateTypeIndexContent = (typeFiles: string[]): string => {\n let content = \"/* eslint-disable */\\nimport { Locales } from 'intlayer';\\n\";\n\n const dictionariesRef = typeFiles.map((dictionaryPath) => ({\n relativePath: `./${relative(moduleAugmentationDir, dictionaryPath)}`,\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id (without the extension)\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n content += `import ${dictionary.hash} from '${dictionary.relativePath}';\\n`;\n });\n\n content += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": typeof ${dictionary.hash};`)\n .join('\\n');\n\n const formatLocales = locales\n .map((locale) => {\n for (const key in Locales) {\n if (Locales[key as keyof typeof Locales] === locale) {\n return `Locales.${key}`;\n }\n }\n })\n .join(' | ');\n\n const strictModeRecord =\n strictMode === 'strict'\n ? `interface IConfigLocales<Content> extends Record<ExtractedLocales, Content> {}`\n : strictMode === 'required_only'\n ? `interface IConfigLocales<Content> extends Record<ExtractedLocales, Content>, Partial<Record<ExcludedLocales, Content>> {}`\n : `interface IConfigLocales<Content> extends Partial<Record<Locales, Content>> {}`;\n\n /**\n * Write the module augmentation to extend the intlayer module with the dictionaries types\n * Will suggest the type resulting of the dictionaries\n *\n * declare module 'intlayer' {\n * interface IntlayerDictionaryTypesConnector = {\n * dictionaries: {\n * id: DictionaryType;\n * }\n * }\n *\n * type ConfigLocales = Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH;\n * type ExtractedLocales = Extract<Locales, ConfigLocales>;\n *\n * interface IConfigLocales<Content> extends Record<ExtractedLocales, Content>, Partial<Record<ExcludedLocales, Content>> {}\n *\n *\n * }\n * See https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation\n */\n content += `declare module 'intlayer' {\\n`;\n content += ` interface IntlayerDictionaryTypesConnector {\\n${formattedDictionaryMap}\\n }\\n\\n`;\n content += ` type ConfigLocales = ${formatLocales};\\n`;\n content += ` type ExtractedLocales = Extract<Locales, ConfigLocales>;\\n`;\n content += ` type ExcludedLocales = Exclude<Locales, ConfigLocales>;\\n`;\n content += ` ${strictModeRecord}\\n`;\n content += `}`;\n\n return content;\n};\n\n/**\n * This function generates a index file merging all the types\n */\nexport const createModuleAugmentation = () => {\n // Create main directory if it doesn't exist\n if (!existsSync(moduleAugmentationDir)) {\n mkdirSync(moduleAugmentationDir, { recursive: true });\n }\n\n const dictionariesTypesDefinitions: string[] = fg.sync(`${typesDir}/*.ts`, {\n ignore: ['**/*.d.ts'],\n });\n // Create the dictionary list file\n\n const tsContent = generateTypeIndexContent(dictionariesTypesDefinitions);\n writeFileSync(join(moduleAugmentationDir, 'intlayer.d.ts'), tsContent);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAqD;AACrD,kBAAkD;AAClD,oBAA0C;AAC1C,uBAAe;AACf,mBAAkD;AAElD,MAAM,EAAE,SAAS,qBAAqB,QAAI,gCAAiB;AAC3D,MAAM,EAAE,uBAAuB,SAAS,IAAI;AAC5C,MAAM,EAAE,SAAS,WAAW,IAAI;AAEzB,MAAM,cAAc,CAAC,QAC1B,OAAG,mCAAqB,GAAG,CAAC;AAK9B,MAAM,2BAA2B,CAAC,cAAgC;AAChE,MAAIA,WAAU;AAEd,QAAM,kBAAkB,UAAU,IAAI,CAAC,oBAAoB;AAAA,IACzD,cAAc,SAAK,sBAAS,uBAAuB,cAAc,CAAC;AAAA,IAClE,QAAI,sBAAS,oBAAgB,qBAAQ,cAAc,CAAC;AAAA;AAAA,IACpD,MAAM,QAAI,0BAAY,cAAc,CAAC;AAAA;AAAA,EACvC,EAAE;AAGF,kBAAgB,QAAQ,CAAC,eAAe;AACtC,IAAAA,YAAW,UAAU,WAAW,IAAI,UAAU,WAAW,YAAY;AAAA;AAAA,EACvE,CAAC;AAED,EAAAA,YAAW;AAGX,QAAM,yBAAiC,gBACpC,IAAI,CAAC,eAAe,QAAQ,WAAW,EAAE,aAAa,WAAW,IAAI,GAAG,EACxE,KAAK,IAAI;AAEZ,QAAM,gBAAgB,QACnB,IAAI,CAAC,WAAW;AACf,eAAW,OAAO,uBAAS;AACzB,UAAI,sBAAQ,GAA2B,MAAM,QAAQ;AACnD,eAAO,WAAW,GAAG;AAAA,MACvB;AAAA,IACF;AAAA,EACF,CAAC,EACA,KAAK,KAAK;AAEb,QAAM,mBACJ,eAAe,WACX,mFACA,eAAe,kBACb,8HACA;AAsBR,EAAAA,YAAW;AAAA;AACX,EAAAA,YAAW;AAAA,EAAmD,sBAAsB;AAAA;AAAA;AAAA;AACpF,EAAAA,YAAW,0BAA0B,aAAa;AAAA;AAClD,EAAAA,YAAW;AAAA;AACX,EAAAA,YAAW;AAAA;AACX,EAAAA,YAAW,KAAK,gBAAgB;AAAA;AAChC,EAAAA,YAAW;AAEX,SAAOA;AACT;AAKO,MAAM,2BAA2B,MAAM;AAE5C,MAAI,KAAC,sBAAW,qBAAqB,GAAG;AACtC,6BAAU,uBAAuB,EAAE,WAAW,KAAK,CAAC;AAAA,EACtD;AAEA,QAAM,+BAAyC,iBAAAC,QAAG,KAAK,GAAG,QAAQ,SAAS;AAAA,IACzE,QAAQ,CAAC,WAAW;AAAA,EACtB,CAAC;AAGD,QAAM,YAAY,yBAAyB,4BAA4B;AACvE,mCAAc,kBAAK,uBAAuB,eAAe,GAAG,SAAS;AACvE;","names":["content","fg"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/checkDictionaryChanges.ts"],"sourcesContent":["import { IntlayerEventListener } from '@intlayer/api';\n// @ts-ignore: @intlayer/backend is not built yet\nimport { DictionaryAPI } from '@intlayer/backend';\nimport { buildIntlayerDictionary } from './transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary';\n\nconst writeDictionary = async (dictionary: DictionaryAPI) => {\n await buildIntlayerDictionary([dictionary]);\n};\n\nexport const checkDictionaryChanges = () => {\n const eventSource = new IntlayerEventListener();\n\n eventSource.initialize();\n\n eventSource.onDictionaryAdded = writeDictionary;\n eventSource.onDictionaryChange = writeDictionary;\n eventSource.onDictionaryDeleted = writeDictionary;\n\n return eventSource;\n};\n"],"mappings":"AAAA,SAAS,6BAA6B;AAGtC,SAAS,+BAA+B;AAExC,MAAM,kBAAkB,OAAO,eAA8B;AAC3D,QAAM,wBAAwB,CAAC,UAAU,CAAC;AAC5C;AAEO,MAAM,yBAAyB,MAAM;AAC1C,QAAM,cAAc,IAAI,sBAAsB;AAE9C,cAAY,WAAW;AAEvB,cAAY,oBAAoB;AAChC,cAAY,qBAAqB;AACjC,cAAY,sBAAsB;AAElC,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/checkDictionaryChanges.ts"],"sourcesContent":["import { IntlayerEventListener } from '@intlayer/api';\n// @ts-ignore: @intlayer/backend is not built yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { buildIntlayerDictionary } from './transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary';\n\nconst writeDictionary = async (dictionary: DictionaryAPI) => {\n await buildIntlayerDictionary([dictionary]);\n};\n\nexport const checkDictionaryChanges = () => {\n const eventSource = new IntlayerEventListener();\n\n eventSource.initialize();\n\n eventSource.onDictionaryAdded = writeDictionary;\n eventSource.onDictionaryChange = writeDictionary;\n eventSource.onDictionaryDeleted = writeDictionary;\n\n return eventSource;\n};\n"],"mappings":"AAAA,SAAS,6BAA6B;AAGtC,SAAS,+BAA+B;AAExC,MAAM,kBAAkB,OAAO,eAA8B;AAC3D,QAAM,wBAAwB,CAAC,UAAU,CAAC;AAC5C;AAEO,MAAM,yBAAyB,MAAM;AAC1C,QAAM,cAAc,IAAI,sBAAsB;AAE9C,cAAY,WAAW;AAEvB,cAAY,oBAAoB;AAChC,cAAY,qBAAqB;AACjC,cAAY,sBAAsB;AAElC,SAAO;AACT;","names":[]}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { relative } from "path";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
appLogger,
|
|
4
|
+
getConfiguration
|
|
5
|
+
} from "@intlayer/config";
|
|
3
6
|
import { watch as chokidarWatch } from "chokidar";
|
|
4
7
|
import fg from "fast-glob";
|
|
5
8
|
import { cleanOutputDir } from "../cleanOutputDir.mjs";
|
|
@@ -7,7 +10,7 @@ import { getDictionariesPath } from "../getDictionariesPath.mjs";
|
|
|
7
10
|
import { loadDictionaries } from "../loadDictionaries/loadDictionaries.mjs";
|
|
8
11
|
import { loadLocalDictionaries } from "../loadDictionaries/loadLocalDictionaries.mjs";
|
|
9
12
|
import { buildDictionary } from "../transpiler/declaration_file_to_dictionary/index.mjs";
|
|
10
|
-
import {
|
|
13
|
+
import { createDictionaryEntryPoint } from "../transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs";
|
|
11
14
|
import {
|
|
12
15
|
createTypes,
|
|
13
16
|
createModuleAugmentation
|
|
@@ -25,7 +28,7 @@ const prepareIntlayer = async (configuration) => {
|
|
|
25
28
|
const dictionaries = await loadDictionaries(files);
|
|
26
29
|
const dictionariesPaths = await buildDictionary(dictionaries);
|
|
27
30
|
createTypes(dictionariesPaths);
|
|
28
|
-
|
|
31
|
+
createDictionaryEntryPoint();
|
|
29
32
|
appLogger("Dictionaries built");
|
|
30
33
|
createModuleAugmentation();
|
|
31
34
|
appLogger("Module augmentation built", {
|
|
@@ -45,7 +48,7 @@ const handleAdditionalContentDeclarationFile = async (filePath, configuration) =
|
|
|
45
48
|
const localeDictionaries = await loadLocalDictionaries(filePath);
|
|
46
49
|
const dictionariesPaths = await buildDictionary(localeDictionaries);
|
|
47
50
|
createTypes(dictionariesPaths);
|
|
48
|
-
|
|
51
|
+
createDictionaryEntryPoint();
|
|
49
52
|
appLogger("Dictionaries built", {
|
|
50
53
|
isVerbose: true
|
|
51
54
|
});
|
|
@@ -71,7 +74,7 @@ const handleContentDeclarationFileChange = async (filePath, configuration) => {
|
|
|
71
74
|
if (updatedDictionariesPaths.some(
|
|
72
75
|
(updatedDictionaryPath) => allDictionariesPaths.includes(updatedDictionaryPath)
|
|
73
76
|
)) {
|
|
74
|
-
|
|
77
|
+
createDictionaryEntryPoint();
|
|
75
78
|
appLogger("Dictionary list built", {
|
|
76
79
|
isVerbose: true
|
|
77
80
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import { relative } from 'path';\nimport { appLogger
|
|
1
|
+
{"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import { relative } from 'path';\nimport {\n type IntlayerConfig,\n appLogger,\n getConfiguration,\n} from '@intlayer/config';\n/** @ts-ignore remove error Module '\"chokidar\"' has no exported member 'ChokidarOptions' */\nimport { type ChokidarOptions, watch as chokidarWatch } from 'chokidar';\nimport fg from 'fast-glob';\nimport { cleanOutputDir } from '../cleanOutputDir';\nimport { getDictionariesPath } from '../getDictionariesPath';\nimport { loadDictionaries } from '../loadDictionaries/loadDictionaries';\nimport { loadLocalDictionaries } from '../loadDictionaries/loadLocalDictionaries';\nimport { buildDictionary } from '../transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryEntryPoint } from '../transpiler/dictionary_to_main/createDictionaryEntryPoint';\nimport {\n createTypes,\n createModuleAugmentation,\n} from '../transpiler/dictionary_to_type/index';\n\nexport const prepareIntlayer = async (configuration?: IntlayerConfig) => {\n const { content } =\n configuration ??\n getConfiguration({\n verbose: true,\n });\n\n const { watchedFilesPatternWithPath } = content;\n\n cleanOutputDir();\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n\n const files: string[] = fg.sync(watchedFilesPatternWithPath);\n\n const dictionaries = await loadDictionaries(files);\n\n // Build locale dictionaries\n const dictionariesPaths = await buildDictionary(dictionaries);\n\n createTypes(dictionariesPaths);\n\n createDictionaryEntryPoint();\n\n appLogger('Dictionaries built');\n\n createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n};\n\nexport const handleAdditionalContentDeclarationFile = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const { content } =\n configuration ??\n getConfiguration({\n verbose: true,\n });\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 handleContentDeclarationFileChange = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const { content } =\n configuration ??\n getConfiguration({\n verbose: true,\n });\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 const updatedDictionariesPaths = await buildDictionary(localeDictionaries);\n const allDictionariesPaths: string[] = getDictionariesPath();\n\n createTypes(updatedDictionariesPaths);\n appLogger('TypeScript types built', {\n isVerbose: true,\n });\n\n if (\n updatedDictionariesPaths.some((updatedDictionaryPath) =>\n allDictionariesPaths.includes(updatedDictionaryPath)\n )\n ) {\n createDictionaryEntryPoint();\n\n appLogger('Dictionary list built', {\n isVerbose: true,\n });\n\n createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n }\n};\n\ntype WatchOptions = ChokidarOptions & {\n configuration?: IntlayerConfig;\n};\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const configuration =\n options?.configuration ??\n getConfiguration({\n verbose: true,\n });\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(\n 'add',\n async (filePath) =>\n await handleAdditionalContentDeclarationFile(filePath, configuration)\n )\n .on(\n 'change',\n async (filePath) =>\n await handleContentDeclarationFileChange(filePath, configuration)\n )\n .on('error', (error) =>\n appLogger('Watcher error: ' + error, {\n level: 'error',\n })\n );\n};\n\nexport const buildAndWatchIntlayer = async (options?: WatchOptions) => {\n const configuration = options?.configuration ?? getConfiguration();\n\n await prepareIntlayer(configuration);\n\n if (configuration.content.watch) {\n // Start watching (assuming watch is also async)\n watch({ ...options, configuration });\n }\n};\n"],"mappings":"AAAA,SAAS,gBAAgB;AACzB;AAAA,EAEE;AAAA,EACA;AAAA,OACK;AAEP,SAA+B,SAAS,qBAAqB;AAC7D,OAAO,QAAQ;AACf,SAAS,sBAAsB;AAC/B,SAAS,2BAA2B;AACpC,SAAS,wBAAwB;AACjC,SAAS,6BAA6B;AACtC,SAAS,uBAAuB;AAChC,SAAS,kCAAkC;AAC3C;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEA,MAAM,kBAAkB,OAAO,kBAAmC;AACvE,QAAM,EAAE,QAAQ,IACd,iBACA,iBAAiB;AAAA,IACf,SAAS;AAAA,EACX,CAAC;AAEH,QAAM,EAAE,4BAA4B,IAAI;AAExC,iBAAe;AAEf,YAAU,4BAA4B;AAAA,IACpC,WAAW;AAAA,EACb,CAAC;AAED,QAAM,QAAkB,GAAG,KAAK,2BAA2B;AAE3D,QAAM,eAAe,MAAM,iBAAiB,KAAK;AAGjD,QAAM,oBAAoB,MAAM,gBAAgB,YAAY;AAE5D,cAAY,iBAAiB;AAE7B,6BAA2B;AAE3B,YAAU,oBAAoB;AAE9B,2BAAyB;AAEzB,YAAU,6BAA6B;AAAA,IACrC,WAAW;AAAA,EAC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AAC;AAEH,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;AAAA,IACC;AAAA,IACA,OAAO,aACL,MAAM,uCAAuC,UAAU,aAAa;AAAA,EACxE,EACC;AAAA,IACC;AAAA,IACA,OAAO,aACL,MAAM,mCAAmC,UAAU,aAAa;AAAA,EACpE,EACC;AAAA,IAAG;AAAA,IAAS,CAAC,UACZ,UAAU,oBAAoB,OAAO;AAAA,MACnC,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACJ;AAEO,MAAM,wBAAwB,OAAO,YAA2B;AACrE,QAAM,gBAAgB,SAAS,iBAAiB,iBAAiB;AAEjE,QAAM,gBAAgB,aAAa;AAEnC,MAAI,cAAc,QAAQ,OAAO;AAE/B,UAAM,EAAE,GAAG,SAAS,cAAc,CAAC;AAAA,EACrC;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, rmSync } from "fs";
|
|
2
2
|
import { getConfiguration } from "@intlayer/config";
|
|
3
|
-
import {
|
|
3
|
+
import { createDictionaryEntryPoint } from "./transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs";
|
|
4
4
|
const cleanOutputDir = () => {
|
|
5
5
|
const { content } = getConfiguration();
|
|
6
6
|
const { resultDir, typesDir, dictionariesDir } = content;
|
|
@@ -12,7 +12,7 @@ const cleanOutputDir = () => {
|
|
|
12
12
|
rmSync(typesDir, { recursive: true });
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
createDictionaryEntryPoint();
|
|
16
16
|
};
|
|
17
17
|
export {
|
|
18
18
|
cleanOutputDir
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { existsSync, rmSync } from 'fs';\nimport { getConfiguration } from '@intlayer/config';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { existsSync, rmSync } from 'fs';\nimport { getConfiguration } from '@intlayer/config';\nimport { createDictionaryEntryPoint } from './transpiler/dictionary_to_main/createDictionaryEntryPoint';\n\nexport const cleanOutputDir = () => {\n const { content } = getConfiguration();\n\n const { resultDir, typesDir, dictionariesDir } = content;\n\n if (existsSync(resultDir)) {\n // Delete the dictionary directory\n if (existsSync(dictionariesDir)) {\n rmSync(dictionariesDir, { recursive: true });\n }\n\n // Delete the types directory\n if (existsSync(typesDir)) {\n rmSync(typesDir, { recursive: true });\n }\n }\n\n createDictionaryEntryPoint();\n};\n"],"mappings":"AAAA,SAAS,YAAY,cAAc;AACnC,SAAS,wBAAwB;AACjC,SAAS,kCAAkC;AAEpC,MAAM,iBAAiB,MAAM;AAClC,QAAM,EAAE,QAAQ,IAAI,iBAAiB;AAErC,QAAM,EAAE,WAAW,UAAU,gBAAgB,IAAI;AAEjD,MAAI,WAAW,SAAS,GAAG;AAEzB,QAAI,WAAW,eAAe,GAAG;AAC/B,aAAO,iBAAiB,EAAE,WAAW,KAAK,CAAC;AAAA,IAC7C;AAGA,QAAI,WAAW,QAAQ,GAAG;AACxB,aAAO,UAAU,EAAE,WAAW,KAAK,CAAC;AAAA,IACtC;AAAA,EACF;AAEA,6BAA2B;AAC7B;","names":[]}
|