@intlayer/chokidar 5.4.2 → 5.5.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 +10 -8
- package/dist/cjs/checkDictionaryChanges.cjs.map +1 -1
- package/dist/cjs/chokidar/watcher.cjs +26 -27
- package/dist/cjs/chokidar/watcher.cjs.map +1 -1
- package/dist/cjs/cleanOutputDir.cjs +7 -9
- package/dist/cjs/cleanOutputDir.cjs.map +1 -1
- package/dist/cjs/fetchDistantDictionaries.cjs +8 -6
- package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
- package/dist/cjs/filterDictionaryLocales.cjs +58 -0
- package/dist/cjs/filterDictionaryLocales.cjs.map +1 -0
- package/dist/cjs/getBuiltUnmergedDictionariesPath.cjs +51 -0
- package/dist/cjs/getBuiltUnmergedDictionariesPath.cjs.map +1 -0
- package/dist/cjs/getContentDeclarationFileTemplate/cjsTemplate.md +9 -0
- package/dist/cjs/getContentDeclarationFileTemplate/esmTemplate.md +9 -0
- package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +62 -0
- package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -0
- package/dist/cjs/getContentDeclarationFileTemplate/tsTemplate.md +8 -0
- package/dist/cjs/index.cjs +21 -6
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/listGitFiles.cjs +100 -0
- package/dist/cjs/listGitFiles.cjs.map +1 -0
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs +4 -25
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadDistantDictionaries.cjs +7 -1
- package/dist/cjs/loadDictionaries/loadDistantDictionaries.cjs.map +1 -1
- package/dist/cjs/mergeDictionaries.cjs +44 -23
- package/dist/cjs/mergeDictionaries.cjs.map +1 -1
- package/dist/cjs/prepareIntlayer.cjs +6 -5
- package/dist/cjs/prepareIntlayer.cjs.map +1 -1
- package/dist/cjs/processPerLocaleDictionary.cjs +49 -0
- package/dist/cjs/processPerLocaleDictionary.cjs.map +1 -0
- package/dist/cjs/reduceDictionaryContent/applyMask.cjs +50 -0
- package/dist/cjs/reduceDictionaryContent/applyMask.cjs.map +1 -0
- package/dist/cjs/reduceDictionaryContent/buildMask.cjs +49 -0
- package/dist/cjs/reduceDictionaryContent/buildMask.cjs.map +1 -0
- package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs +35 -0
- package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs.map +1 -0
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.cjs +4 -4
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.cjs.map +1 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.cjs +56 -8
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.cjs.map +1 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.cjs +4 -4
- package/dist/cjs/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs +21 -1
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/formatCode.cjs +73 -0
- package/dist/cjs/writeContentDeclaration/formatCode.cjs.map +1 -0
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +36 -37
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +379 -0
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -0
- package/dist/esm/checkDictionaryChanges.mjs +10 -5
- package/dist/esm/checkDictionaryChanges.mjs.map +1 -1
- package/dist/esm/chokidar/watcher.mjs +18 -19
- package/dist/esm/chokidar/watcher.mjs.map +1 -1
- package/dist/esm/cleanOutputDir.mjs +7 -9
- package/dist/esm/cleanOutputDir.mjs.map +1 -1
- package/dist/esm/fetchDistantDictionaries.mjs +8 -6
- package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
- package/dist/esm/filterDictionaryLocales.mjs +37 -0
- package/dist/esm/filterDictionaryLocales.mjs.map +1 -0
- package/dist/esm/getBuiltUnmergedDictionariesPath.mjs +17 -0
- package/dist/esm/getBuiltUnmergedDictionariesPath.mjs.map +1 -0
- package/dist/esm/getContentDeclarationFileTemplate/cjsTemplate.md +9 -0
- package/dist/esm/getContentDeclarationFileTemplate/esmTemplate.md +9 -0
- package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +37 -0
- package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -0
- package/dist/esm/getContentDeclarationFileTemplate/tsTemplate.md +8 -0
- package/dist/esm/index.mjs +21 -9
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/listGitFiles.mjs +66 -0
- package/dist/esm/listGitFiles.mjs.map +1 -0
- package/dist/esm/loadDictionaries/loadDictionaries.mjs +7 -14
- package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadDistantDictionaries.mjs +7 -1
- package/dist/esm/loadDictionaries/loadDistantDictionaries.mjs.map +1 -1
- package/dist/esm/mergeDictionaries.mjs +43 -22
- package/dist/esm/mergeDictionaries.mjs.map +1 -1
- package/dist/esm/prepareIntlayer.mjs +5 -4
- package/dist/esm/prepareIntlayer.mjs.map +1 -1
- package/dist/esm/processPerLocaleDictionary.mjs +25 -0
- package/dist/esm/processPerLocaleDictionary.mjs.map +1 -0
- package/dist/esm/reduceDictionaryContent/applyMask.mjs +26 -0
- package/dist/esm/reduceDictionaryContent/applyMask.mjs.map +1 -0
- package/dist/esm/reduceDictionaryContent/buildMask.mjs +24 -0
- package/dist/esm/reduceDictionaryContent/buildMask.mjs.map +1 -0
- package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs +11 -0
- package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs.map +1 -0
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.mjs +4 -4
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.mjs.map +1 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.mjs +54 -8
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.mjs.map +1 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.mjs +4 -4
- package/dist/esm/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs +21 -1
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/formatCode.mjs +39 -0
- package/dist/esm/writeContentDeclaration/formatCode.mjs.map +1 -0
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +35 -36
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeJSFile.mjs +347 -0
- package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -0
- package/dist/types/checkDictionaryChanges.d.ts.map +1 -1
- package/dist/types/chokidar/watcher.d.ts +2 -1
- package/dist/types/chokidar/watcher.d.ts.map +1 -1
- package/dist/types/cleanOutputDir.d.ts.map +1 -1
- package/dist/types/fetchDistantDictionaries.d.ts.map +1 -1
- package/dist/types/filterDictionaryLocales.d.ts +4 -0
- package/dist/types/filterDictionaryLocales.d.ts.map +1 -0
- package/dist/types/getBuiltUnmergedDictionariesPath.d.ts +5 -0
- package/dist/types/getBuiltUnmergedDictionariesPath.d.ts.map +1 -0
- package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts +2 -0
- package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts.map +1 -0
- package/dist/types/index.d.ts +12 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/listGitFiles.d.ts +9 -0
- package/dist/types/listGitFiles.d.ts.map +1 -0
- package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadDistantDictionaries.d.ts.map +1 -1
- package/dist/types/mergeDictionaries.d.ts +2 -4
- package/dist/types/mergeDictionaries.d.ts.map +1 -1
- package/dist/types/prepareIntlayer.d.ts.map +1 -1
- package/dist/types/processPerLocaleDictionary.d.ts +32 -0
- package/dist/types/processPerLocaleDictionary.d.ts.map +1 -0
- package/dist/types/reduceDictionaryContent/applyMask.d.ts +3 -0
- package/dist/types/reduceDictionaryContent/applyMask.d.ts.map +1 -0
- package/dist/types/reduceDictionaryContent/buildMask.d.ts +5 -0
- package/dist/types/reduceDictionaryContent/buildMask.d.ts.map +1 -0
- package/dist/types/reduceDictionaryContent/reduceDictionaryContent.d.ts +3 -0
- package/dist/types/reduceDictionaryContent/reduceDictionaryContent.d.ts.map +1 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.d.ts +38 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.d.ts.map +1 -1
- package/dist/types/transpiler/dictionary_to_main/createDictionaryEntryPoint.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/formatCode.d.ts +2 -0
- package/dist/types/writeContentDeclaration/formatCode.d.ts.map +1 -0
- package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/writeJSFile.d.ts +9 -0
- package/dist/types/writeContentDeclaration/writeJSFile.d.ts.map +1 -0
- package/package.json +21 -13
|
@@ -22,14 +22,16 @@ __export(checkDictionaryChanges_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(checkDictionaryChanges_exports);
|
|
24
24
|
var import_api = require("@intlayer/api");
|
|
25
|
-
var import_buildIntlayerDictionary = require('./transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.cjs');
|
|
26
25
|
var import_config = require("@intlayer/config");
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
var import_buildIntlayerDictionary = require('./transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.cjs');
|
|
27
|
+
const writeDictionary = async (dictionary, configuration) => {
|
|
28
|
+
const appLogger = (0, import_config.getAppLogger)(configuration);
|
|
29
|
+
appLogger(`Writing dictionary ${dictionary.key}`);
|
|
29
30
|
await (0, import_buildIntlayerDictionary.buildIntlayerDictionary)([dictionary]);
|
|
30
31
|
};
|
|
31
32
|
const checkDictionaryChanges = async () => {
|
|
32
33
|
const configuration = (0, import_config.getConfiguration)();
|
|
34
|
+
const appLogger = (0, import_config.getAppLogger)(configuration);
|
|
33
35
|
const { editor } = configuration;
|
|
34
36
|
if (!editor.hotReload) return;
|
|
35
37
|
if (!editor.clientId) return;
|
|
@@ -37,16 +39,16 @@ const checkDictionaryChanges = async () => {
|
|
|
37
39
|
const eventSource = new import_api.IntlayerEventListener(configuration);
|
|
38
40
|
try {
|
|
39
41
|
await eventSource.initialize().then(() => {
|
|
40
|
-
|
|
42
|
+
appLogger("Connected to Intlayer. Hot reload enabled");
|
|
41
43
|
});
|
|
42
44
|
} catch (error) {
|
|
43
|
-
|
|
45
|
+
appLogger("Error initializing IntlayerEventListener:", {
|
|
44
46
|
level: "error"
|
|
45
47
|
});
|
|
46
48
|
}
|
|
47
|
-
eventSource.onDictionaryAdded = writeDictionary;
|
|
48
|
-
eventSource.onDictionaryChange = writeDictionary;
|
|
49
|
-
eventSource.onDictionaryDeleted = writeDictionary;
|
|
49
|
+
eventSource.onDictionaryAdded = (dictionary) => writeDictionary(dictionary, configuration);
|
|
50
|
+
eventSource.onDictionaryChange = (dictionary) => writeDictionary(dictionary, configuration);
|
|
51
|
+
eventSource.onDictionaryDeleted = (dictionary) => writeDictionary(dictionary, configuration);
|
|
50
52
|
return eventSource;
|
|
51
53
|
};
|
|
52
54
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -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 type { DictionaryAPI } from '@intlayer/backend';\nimport {
|
|
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 {\n getAppLogger,\n getConfiguration,\n IntlayerConfig,\n} from '@intlayer/config';\nimport { buildIntlayerDictionary } from './transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary';\n\nconst writeDictionary = async (\n dictionary: DictionaryAPI,\n configuration: IntlayerConfig\n) => {\n const appLogger = getAppLogger(configuration);\n appLogger(`Writing dictionary ${dictionary.key}`);\n await buildIntlayerDictionary([dictionary]);\n};\n\nexport const checkDictionaryChanges = async () => {\n const configuration = getConfiguration();\n const appLogger = getAppLogger(configuration);\n\n const { editor } = configuration;\n\n if (!editor.hotReload) return;\n if (!editor.clientId) return;\n if (!editor.clientSecret) return;\n\n const eventSource = new IntlayerEventListener(configuration);\n\n try {\n await eventSource.initialize().then(() => {\n appLogger('Connected to Intlayer. Hot reload enabled');\n });\n } catch (error) {\n appLogger('Error initializing IntlayerEventListener:', {\n level: 'error',\n });\n }\n\n eventSource.onDictionaryAdded = (dictionary) =>\n writeDictionary(dictionary, configuration);\n eventSource.onDictionaryChange = (dictionary) =>\n writeDictionary(dictionary, configuration);\n eventSource.onDictionaryDeleted = (dictionary) =>\n writeDictionary(dictionary, configuration);\n\n return eventSource;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAsC;AAGtC,oBAIO;AACP,qCAAwC;AAExC,MAAM,kBAAkB,OACtB,YACA,kBACG;AACH,QAAM,gBAAY,4BAAa,aAAa;AAC5C,YAAU,sBAAsB,WAAW,GAAG,EAAE;AAChD,YAAM,wDAAwB,CAAC,UAAU,CAAC;AAC5C;AAEO,MAAM,yBAAyB,YAAY;AAChD,QAAM,oBAAgB,gCAAiB;AACvC,QAAM,gBAAY,4BAAa,aAAa;AAE5C,QAAM,EAAE,OAAO,IAAI;AAEnB,MAAI,CAAC,OAAO,UAAW;AACvB,MAAI,CAAC,OAAO,SAAU;AACtB,MAAI,CAAC,OAAO,aAAc;AAE1B,QAAM,cAAc,IAAI,iCAAsB,aAAa;AAE3D,MAAI;AACF,UAAM,YAAY,WAAW,EAAE,KAAK,MAAM;AACxC,gBAAU,2CAA2C;AAAA,IACvD,CAAC;AAAA,EACH,SAAS,OAAO;AACd,cAAU,6CAA6C;AAAA,MACrD,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AAEA,cAAY,oBAAoB,CAAC,eAC/B,gBAAgB,YAAY,aAAa;AAC3C,cAAY,qBAAqB,CAAC,eAChC,gBAAgB,YAAY,aAAa;AAC3C,cAAY,sBAAsB,CAAC,eACjC,gBAAgB,YAAY,aAAa;AAE3C,SAAO;AACT;","names":[]}
|
|
@@ -25,22 +25,22 @@ __export(watcher_exports, {
|
|
|
25
25
|
watch: () => watch
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(watcher_exports);
|
|
28
|
-
var import_path = require("path");
|
|
29
28
|
var import_config = require("@intlayer/config");
|
|
29
|
+
var import_path = require("path");
|
|
30
30
|
var import_chokidar = require("chokidar");
|
|
31
31
|
var import_getBuiltDictionariesPath = require('../getBuiltDictionariesPath.cjs');
|
|
32
|
+
var import_listDictionariesPath = require('../listDictionariesPath.cjs');
|
|
32
33
|
var import_loadLocalDictionaries = require('../loadDictionaries/loadLocalDictionaries.cjs');
|
|
34
|
+
var import_prepareIntlayer = require('../prepareIntlayer.cjs');
|
|
33
35
|
var import_declaration_file_to_dictionary = require('../transpiler/declaration_file_to_dictionary/index.cjs');
|
|
34
36
|
var import_createDictionaryEntryPoint = require('../transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs');
|
|
35
37
|
var import_dictionary_to_type = require('../transpiler/dictionary_to_type/index.cjs');
|
|
36
|
-
var import_prepareIntlayer = require('../prepareIntlayer.cjs');
|
|
37
|
-
var import_listDictionariesPath = require('../listDictionariesPath.cjs');
|
|
38
38
|
const recentlyAddedFiles = /* @__PURE__ */ new Set();
|
|
39
39
|
const handleAdditionalContentDeclarationFile = async (filePath, configuration) => {
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
40
|
+
const config = configuration ?? (0, import_config.getConfiguration)();
|
|
41
|
+
const appLogger = (0, import_config.getAppLogger)(config);
|
|
42
|
+
const { content } = config;
|
|
43
|
+
appLogger(
|
|
44
44
|
`Additional file detected: ${(0, import_path.relative)(content.baseDir, filePath)}`,
|
|
45
45
|
{
|
|
46
46
|
isVerbose: true
|
|
@@ -50,19 +50,19 @@ const handleAdditionalContentDeclarationFile = async (filePath, configuration) =
|
|
|
50
50
|
const dictionariesPaths = await (0, import_declaration_file_to_dictionary.buildDictionary)(localeDictionaries);
|
|
51
51
|
(0, import_dictionary_to_type.createTypes)(dictionariesPaths);
|
|
52
52
|
(0, import_createDictionaryEntryPoint.createDictionaryEntryPoint)();
|
|
53
|
-
|
|
53
|
+
appLogger("Dictionaries built", {
|
|
54
54
|
isVerbose: true
|
|
55
55
|
});
|
|
56
56
|
(0, import_dictionary_to_type.createModuleAugmentation)();
|
|
57
|
-
|
|
57
|
+
appLogger("Module augmentation built", {
|
|
58
58
|
isVerbose: true
|
|
59
59
|
});
|
|
60
60
|
};
|
|
61
61
|
const handleUnlikedContentDeclarationFile = async (filePath, configuration) => {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
62
|
+
const config = configuration ?? (0, import_config.getConfiguration)();
|
|
63
|
+
const appLogger = (0, import_config.getAppLogger)(config);
|
|
64
|
+
const { content } = config;
|
|
65
|
+
appLogger(`Unlinked detected: ${(0, import_path.relative)(content.baseDir, filePath)}`, {
|
|
66
66
|
isVerbose: true
|
|
67
67
|
});
|
|
68
68
|
const files = (0, import_listDictionariesPath.listDictionaries)(configuration);
|
|
@@ -70,41 +70,40 @@ const handleUnlikedContentDeclarationFile = async (filePath, configuration) => {
|
|
|
70
70
|
const dictionariesPaths = await (0, import_declaration_file_to_dictionary.buildDictionary)(localeDictionaries);
|
|
71
71
|
(0, import_dictionary_to_type.createTypes)(dictionariesPaths);
|
|
72
72
|
(0, import_createDictionaryEntryPoint.createDictionaryEntryPoint)();
|
|
73
|
-
|
|
73
|
+
appLogger("Dictionaries rebuilt", {
|
|
74
74
|
isVerbose: true
|
|
75
75
|
});
|
|
76
76
|
(0, import_dictionary_to_type.createModuleAugmentation)();
|
|
77
|
-
|
|
77
|
+
appLogger("Module augmentation built", {
|
|
78
78
|
isVerbose: true
|
|
79
79
|
});
|
|
80
80
|
};
|
|
81
81
|
const handleContentDeclarationFileChange = async (filePath, configuration) => {
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
82
|
+
const config = configuration ?? (0, import_config.getConfiguration)();
|
|
83
|
+
const appLogger = (0, import_config.getAppLogger)(config);
|
|
84
|
+
const { content } = config;
|
|
85
|
+
appLogger(`Change detected: ${(0, import_path.relative)(content.baseDir, filePath)}`, {
|
|
86
86
|
isVerbose: true
|
|
87
87
|
});
|
|
88
88
|
const localeDictionaries = await (0, import_loadLocalDictionaries.loadLocalDictionaries)(filePath);
|
|
89
89
|
const updatedDictionariesPaths = await (0, import_declaration_file_to_dictionary.buildDictionary)(localeDictionaries);
|
|
90
90
|
const allDictionariesPaths = (0, import_getBuiltDictionariesPath.getBuiltDictionariesPath)();
|
|
91
91
|
(0, import_dictionary_to_type.createTypes)(updatedDictionariesPaths);
|
|
92
|
-
|
|
92
|
+
appLogger("TypeScript types built", {
|
|
93
93
|
isVerbose: true
|
|
94
94
|
});
|
|
95
95
|
if (updatedDictionariesPaths.some(
|
|
96
96
|
(updatedDictionaryPath) => !allDictionariesPaths.includes(updatedDictionaryPath)
|
|
97
97
|
)) {
|
|
98
98
|
(0, import_createDictionaryEntryPoint.createDictionaryEntryPoint)();
|
|
99
|
-
|
|
99
|
+
appLogger("Dictionary list built", {
|
|
100
100
|
isVerbose: true
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
};
|
|
104
104
|
const watch = (options) => {
|
|
105
|
-
const configuration = options?.configuration ?? (0, import_config.getConfiguration)(
|
|
106
|
-
|
|
107
|
-
});
|
|
105
|
+
const configuration = options?.configuration ?? (0, import_config.getConfiguration)();
|
|
106
|
+
const appLogger = (0, import_config.getAppLogger)(configuration);
|
|
108
107
|
const { watch: isWatchMode, watchedFilesPatternWithPath } = configuration.content;
|
|
109
108
|
return (0, import_chokidar.watch)(watchedFilesPatternWithPath, {
|
|
110
109
|
persistent: isWatchMode,
|
|
@@ -129,15 +128,15 @@ const watch = (options) => {
|
|
|
129
128
|
await handleUnlikedContentDeclarationFile(filePath, configuration);
|
|
130
129
|
}, 300);
|
|
131
130
|
}).on("error", async (error) => {
|
|
132
|
-
|
|
131
|
+
appLogger("Watcher error: " + error, {
|
|
133
132
|
level: "error"
|
|
134
133
|
});
|
|
135
|
-
|
|
134
|
+
appLogger("Restarting watcher");
|
|
136
135
|
await (0, import_prepareIntlayer.prepareIntlayer)(configuration);
|
|
137
136
|
});
|
|
138
137
|
};
|
|
139
138
|
const buildAndWatchIntlayer = async (options) => {
|
|
140
|
-
const configuration = options?.configuration ?? (0, import_config.getConfiguration)();
|
|
139
|
+
const configuration = options?.configuration ?? (0, import_config.getConfiguration)(options?.configOptions);
|
|
141
140
|
await (0, import_prepareIntlayer.prepareIntlayer)(configuration);
|
|
142
141
|
if (configuration.content.watch || options.persistent) {
|
|
143
142
|
watch({ ...options, configuration });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import {\n GetConfigurationOptions,\n type IntlayerConfig,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport { basename, relative } from 'path';\n/** @ts-ignore remove error Module '\"chokidar\"' has no exported member 'ChokidarOptions' */\nimport { type ChokidarOptions, watch as chokidarWatch } from 'chokidar';\nimport { getBuiltDictionariesPath } from '../getBuiltDictionariesPath';\nimport { listDictionaries } from '../listDictionariesPath';\nimport { loadLocalDictionaries } from '../loadDictionaries/loadLocalDictionaries';\nimport { prepareIntlayer } from '../prepareIntlayer';\nimport { buildDictionary } from '../transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryEntryPoint } from '../transpiler/dictionary_to_main/createDictionaryEntryPoint';\nimport {\n createModuleAugmentation,\n createTypes,\n} from '../transpiler/dictionary_to_type/index';\n\nconst recentlyAddedFiles = new Set<string>();\n\nexport const handleAdditionalContentDeclarationFile = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const config = configuration ?? getConfiguration();\n const appLogger = getAppLogger(config);\n const { content } = config;\n\n // Process the file with the functionToRun\n appLogger(\n `Additional file detected: ${relative(content.baseDir, filePath)}`,\n {\n isVerbose: true,\n }\n );\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n\n const dictionariesPaths = await buildDictionary(localeDictionaries);\n\n createTypes(dictionariesPaths);\n\n createDictionaryEntryPoint();\n\n appLogger('Dictionaries built', {\n isVerbose: true,\n });\n\n createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n};\n\nexport const handleUnlikedContentDeclarationFile = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const config = configuration ?? getConfiguration();\n const appLogger = getAppLogger(config);\n const { content } = config;\n\n // Process the file with the functionToRun\n appLogger(`Unlinked detected: ${relative(content.baseDir, filePath)}`, {\n isVerbose: true,\n });\n\n const files: string[] = listDictionaries(configuration);\n\n const localeDictionaries = await loadLocalDictionaries(files);\n\n const dictionariesPaths = await buildDictionary(localeDictionaries);\n\n createTypes(dictionariesPaths);\n\n createDictionaryEntryPoint();\n\n appLogger('Dictionaries rebuilt', {\n isVerbose: true,\n });\n\n createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n};\n\nexport const handleContentDeclarationFileChange = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const config = configuration ?? getConfiguration();\n const appLogger = getAppLogger(config);\n const { content } = config;\n\n // Process the file with the functionToRun\n appLogger(`Change detected: ${relative(content.baseDir, filePath)}`, {\n isVerbose: true,\n });\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n\n const updatedDictionariesPaths = await buildDictionary(localeDictionaries);\n const allDictionariesPaths: string[] = getBuiltDictionariesPath();\n\n createTypes(updatedDictionariesPaths);\n appLogger('TypeScript types built', {\n isVerbose: true,\n });\n\n if (\n updatedDictionariesPaths.some(\n (updatedDictionaryPath) =>\n !allDictionariesPaths.includes(updatedDictionaryPath)\n )\n ) {\n createDictionaryEntryPoint();\n\n appLogger('Dictionary list built', {\n isVerbose: true,\n });\n }\n};\n\ntype WatchOptions = ChokidarOptions & {\n configuration?: IntlayerConfig;\n configOptions?: GetConfigurationOptions;\n};\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const configuration = options?.configuration ?? getConfiguration();\n const appLogger = getAppLogger(configuration);\n\n const { watch: isWatchMode, watchedFilesPatternWithPath } =\n configuration.content;\n\n /** @ts-ignore remove error Expected 0-1 arguments, but got 2. */\n return chokidarWatch(watchedFilesPatternWithPath, {\n persistent: isWatchMode, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n ...options,\n })\n .on('add', async (filePath) => {\n const fileName = basename(filePath);\n recentlyAddedFiles.add(fileName);\n\n await handleAdditionalContentDeclarationFile(filePath, configuration);\n\n setTimeout(() => recentlyAddedFiles.delete(fileName), 1000); // Allow time for unlink to trigger if it's a move\n })\n .on(\n 'change',\n async (filePath) =>\n await handleContentDeclarationFileChange(filePath, configuration)\n )\n .on('unlink', async (filePath) => {\n setTimeout(async () => {\n const fileName = basename(filePath);\n\n if (recentlyAddedFiles.has(fileName)) {\n // The file was moved, so ignore unlink\n return;\n }\n\n await handleUnlikedContentDeclarationFile(filePath, configuration);\n }, 300); // Allow time for unlink to trigger if it's a move\n })\n .on('error', async (error) => {\n appLogger('Watcher error: ' + error, {\n level: 'error',\n });\n\n appLogger('Restarting watcher');\n\n await prepareIntlayer(configuration);\n });\n};\n\nexport const buildAndWatchIntlayer = async (options?: WatchOptions) => {\n const configuration =\n options?.configuration ?? getConfiguration(options?.configOptions);\n\n await prepareIntlayer(configuration);\n\n if (configuration.content.watch || options.persistent) {\n // Start watching (assuming watch is also async)\n watch({ ...options, configuration });\n }\n};\n"],"mappings":"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","names":["chokidarWatch"]}
|
|
@@ -21,18 +21,16 @@ __export(cleanOutputDir_exports, {
|
|
|
21
21
|
cleanOutputDir: () => cleanOutputDir
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(cleanOutputDir_exports);
|
|
24
|
-
var import_fs = require("fs");
|
|
25
24
|
var import_config = require("@intlayer/config");
|
|
25
|
+
var import_fs = require("fs");
|
|
26
26
|
var import_createDictionaryEntryPoint = require('./transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs');
|
|
27
27
|
const cleanOutputDir = (configuration = (0, import_config.getConfiguration)()) => {
|
|
28
|
-
const {
|
|
29
|
-
if ((0, import_fs.existsSync)(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
(0, import_fs.rmSync)(typesDir, { recursive: true });
|
|
35
|
-
}
|
|
28
|
+
const { dictionariesDir, typesDir } = configuration.content;
|
|
29
|
+
if ((0, import_fs.existsSync)(dictionariesDir)) {
|
|
30
|
+
(0, import_fs.rmSync)(dictionariesDir, { recursive: true });
|
|
31
|
+
}
|
|
32
|
+
if ((0, import_fs.existsSync)(typesDir)) {
|
|
33
|
+
(0, import_fs.rmSync)(typesDir, { recursive: true });
|
|
36
34
|
}
|
|
37
35
|
(0, import_createDictionaryEntryPoint.createDictionaryEntryPoint)(configuration);
|
|
38
36
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { existsSync, rmSync } from 'fs';\nimport { createDictionaryEntryPoint } from './transpiler/dictionary_to_main/createDictionaryEntryPoint';\n\nexport const cleanOutputDir = (configuration = getConfiguration()) => {\n const { dictionariesDir, typesDir } = configuration.content;\n\n if (existsSync(dictionariesDir)) {\n // Delete the dictionary directory\n rmSync(dictionariesDir, { recursive: true });\n }\n\n // Delete the types directory\n if (existsSync(typesDir)) {\n rmSync(typesDir, { recursive: true });\n }\n\n createDictionaryEntryPoint(configuration);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,gBAAmC;AACnC,wCAA2C;AAEpC,MAAM,iBAAiB,CAAC,oBAAgB,gCAAiB,MAAM;AACpE,QAAM,EAAE,iBAAiB,SAAS,IAAI,cAAc;AAEpD,UAAI,sBAAW,eAAe,GAAG;AAE/B,0BAAO,iBAAiB,EAAE,WAAW,KAAK,CAAC;AAAA,EAC7C;AAGA,UAAI,sBAAW,QAAQ,GAAG;AACxB,0BAAO,UAAU,EAAE,WAAW,KAAK,CAAC;AAAA,EACtC;AAEA,oEAA2B,aAAa;AAC1C;","names":[]}
|
|
@@ -36,16 +36,18 @@ var import_config = require("@intlayer/config");
|
|
|
36
36
|
var import_p_limit = __toESM(require("p-limit"));
|
|
37
37
|
var import_log = require('./log.cjs');
|
|
38
38
|
const fetchDistantDictionaries = async (options) => {
|
|
39
|
+
const config = (0, import_config.getConfiguration)();
|
|
40
|
+
const appLogger = (0, import_config.getAppLogger)(config);
|
|
39
41
|
try {
|
|
40
|
-
const config = (0, import_config.getConfiguration)();
|
|
41
42
|
const { clientId, clientSecret } = config.editor;
|
|
42
|
-
const
|
|
43
|
+
const authAPI = (0, import_api.getAuthAPI)(void 0, config);
|
|
44
|
+
const dictionaryAPI = (0, import_api.getDictionaryAPI)(void 0, config);
|
|
43
45
|
if (!clientId || !clientSecret) {
|
|
44
46
|
throw new Error(
|
|
45
47
|
"Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project."
|
|
46
48
|
);
|
|
47
49
|
}
|
|
48
|
-
const oAuth2TokenResult = await
|
|
50
|
+
const oAuth2TokenResult = await authAPI.getOAuth2AccessToken();
|
|
49
51
|
const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;
|
|
50
52
|
const distantDictionariesKeys = options.dictionaryKeys;
|
|
51
53
|
const limit = (0, import_p_limit.default)(5);
|
|
@@ -58,7 +60,7 @@ const fetchDistantDictionaries = async (options) => {
|
|
|
58
60
|
}
|
|
59
61
|
]);
|
|
60
62
|
try {
|
|
61
|
-
const getDictionaryResult = await
|
|
63
|
+
const getDictionaryResult = await dictionaryAPI.getDictionary(
|
|
62
64
|
dictionaryKey,
|
|
63
65
|
void 0,
|
|
64
66
|
{
|
|
@@ -96,7 +98,7 @@ const fetchDistantDictionaries = async (options) => {
|
|
|
96
98
|
for (const statusObj of statuses) {
|
|
97
99
|
const currentState = statusObj.state.find((s) => s.type === "distant");
|
|
98
100
|
if (currentState && currentState.errorMessage) {
|
|
99
|
-
|
|
101
|
+
appLogger(currentState.errorMessage, { level: "error" });
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
const filteredResult = result.filter(
|
|
@@ -104,7 +106,7 @@ const fetchDistantDictionaries = async (options) => {
|
|
|
104
106
|
);
|
|
105
107
|
return filteredResult;
|
|
106
108
|
} catch (error) {
|
|
107
|
-
|
|
109
|
+
appLogger(error, { level: "error" });
|
|
108
110
|
return [];
|
|
109
111
|
}
|
|
110
112
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fetchDistantDictionaries.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/fetchDistantDictionaries.ts"],"sourcesContent":["import { getAuthAPI, getDictionaryAPI } from '@intlayer/api';\n// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getAppLogger, getConfiguration } from '@intlayer/config';\nimport pLimit from 'p-limit';\nimport { logger } from './log';\n\ntype FetchDistantDictionariesOptions = {\n dictionaryKeys: string[];\n newDictionariesPath?: string;\n logPrefix?: string;\n};\n\n/**\n * Fetch distant dictionaries and update the logger with their statuses.\n */\nexport const fetchDistantDictionaries = async (\n options: FetchDistantDictionariesOptions\n): Promise<DictionaryAPI[]> => {\n const config = getConfiguration();\n const appLogger = getAppLogger(config);\n try {\n const { clientId, clientSecret } = config.editor;\n const authAPI = getAuthAPI(undefined, config);\n const dictionaryAPI = getDictionaryAPI(undefined, config);\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project.'\n );\n }\n\n const oAuth2TokenResult = await authAPI.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n const distantDictionariesKeys = options.dictionaryKeys;\n\n // Process dictionaries in parallel with a concurrency limit\n const limit = pLimit(5); // Limit the number of concurrent requests\n\n const processDictionary = async (\n dictionaryKey: string\n ): Promise<DictionaryAPI | undefined> => {\n logger.updateStatus([\n {\n dictionaryKey,\n type: 'distant',\n status: { status: 'fetching' },\n },\n ]);\n\n try {\n // Fetch the dictionary\n const getDictionaryResult = await dictionaryAPI.getDictionary(\n dictionaryKey,\n undefined,\n {\n headers: { Authorization: `Bearer ${oAuth2AccessToken}` },\n }\n );\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(`Dictionary ${dictionaryKey} not found on remote`);\n }\n\n logger.updateStatus([\n { dictionaryKey, type: 'distant', status: { status: 'imported' } },\n ]);\n\n return distantDictionary;\n } catch (error) {\n logger.updateStatus([\n {\n dictionaryKey,\n type: 'distant',\n status: {\n status: 'error',\n error: error as Error,\n errorMessage: `${options?.logPrefix ?? ''}Error fetching dictionary ${dictionaryKey}: ${error}`,\n },\n },\n ]);\n return undefined;\n }\n };\n\n const fetchPromises = distantDictionariesKeys.map((dictionaryKey) =>\n limit(async () => await processDictionary(dictionaryKey))\n );\n\n const result = await Promise.all(fetchPromises);\n\n // Output any error messages\n const statuses = logger.getStatuses();\n for (const statusObj of statuses) {\n const currentState = statusObj.state.find((s) => s.type === 'distant');\n if (currentState && currentState.errorMessage) {\n appLogger(currentState.errorMessage, { level: 'error' });\n }\n }\n\n // Remove undefined values\n const filteredResult = result.filter(\n (dict): dict is DictionaryAPI => dict !== undefined\n );\n\n return filteredResult;\n } catch (error) {\n appLogger(error, { level: 'error' });\n return [];\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA6C;AAG7C,oBAA+C;AAC/C,qBAAmB;AACnB,iBAAuB;AAWhB,MAAM,2BAA2B,OACtC,YAC6B;AAC7B,QAAM,aAAS,gCAAiB;AAChC,QAAM,gBAAY,4BAAa,MAAM;AACrC,MAAI;AACF,UAAM,EAAE,UAAU,aAAa,IAAI,OAAO;AAC1C,UAAM,cAAU,uBAAW,QAAW,MAAM;AAC5C,UAAM,oBAAgB,6BAAiB,QAAW,MAAM;AAExD,QAAI,CAAC,YAAY,CAAC,cAAc;AAC9B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,oBAAoB,MAAM,QAAQ,qBAAqB;AAE7D,UAAM,oBAAoB,kBAAkB,MAAM;AAElD,UAAM,0BAA0B,QAAQ;AAGxC,UAAM,YAAQ,eAAAA,SAAO,CAAC;AAEtB,UAAM,oBAAoB,OACxB,kBACuC;AACvC,wBAAO,aAAa;AAAA,QAClB;AAAA,UACE;AAAA,UACA,MAAM;AAAA,UACN,QAAQ,EAAE,QAAQ,WAAW;AAAA,QAC/B;AAAA,MACF,CAAC;AAED,UAAI;AAEF,cAAM,sBAAsB,MAAM,cAAc;AAAA,UAC9C;AAAA,UACA;AAAA,UACA;AAAA,YACE,SAAS,EAAE,eAAe,UAAU,iBAAiB,GAAG;AAAA,UAC1D;AAAA,QACF;AAEA,cAAM,oBAAoB,oBAAoB;AAE9C,YAAI,CAAC,mBAAmB;AACtB,gBAAM,IAAI,MAAM,cAAc,aAAa,sBAAsB;AAAA,QACnE;AAEA,0BAAO,aAAa;AAAA,UAClB,EAAE,eAAe,MAAM,WAAW,QAAQ,EAAE,QAAQ,WAAW,EAAE;AAAA,QACnE,CAAC;AAED,eAAO;AAAA,MACT,SAAS,OAAO;AACd,0BAAO,aAAa;AAAA,UAClB;AAAA,YACE;AAAA,YACA,MAAM;AAAA,YACN,QAAQ;AAAA,cACN,QAAQ;AAAA,cACR;AAAA,cACA,cAAc,GAAG,SAAS,aAAa,EAAE,6BAA6B,aAAa,KAAK,KAAK;AAAA,YAC/F;AAAA,UACF;AAAA,QACF,CAAC;AACD,eAAO;AAAA,MACT;AAAA,IACF;AAEA,UAAM,gBAAgB,wBAAwB;AAAA,MAAI,CAAC,kBACjD,MAAM,YAAY,MAAM,kBAAkB,aAAa,CAAC;AAAA,IAC1D;AAEA,UAAM,SAAS,MAAM,QAAQ,IAAI,aAAa;AAG9C,UAAM,WAAW,kBAAO,YAAY;AACpC,eAAW,aAAa,UAAU;AAChC,YAAM,eAAe,UAAU,MAAM,KAAK,CAAC,MAAM,EAAE,SAAS,SAAS;AACrE,UAAI,gBAAgB,aAAa,cAAc;AAC7C,kBAAU,aAAa,cAAc,EAAE,OAAO,QAAQ,CAAC;AAAA,MACzD;AAAA,IACF;AAGA,UAAM,iBAAiB,OAAO;AAAA,MAC5B,CAAC,SAAgC,SAAS;AAAA,IAC5C;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,cAAU,OAAO,EAAE,OAAO,QAAQ,CAAC;AACnC,WAAO,CAAC;AAAA,EACV;AACF;","names":["pLimit"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var filterDictionaryLocales_exports = {};
|
|
20
|
+
__export(filterDictionaryLocales_exports, {
|
|
21
|
+
filterDictionaryLocales: () => filterDictionaryLocales
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(filterDictionaryLocales_exports);
|
|
24
|
+
var import_core = require("@intlayer/core");
|
|
25
|
+
const filterTranlationsPlugin = (locales) => ({
|
|
26
|
+
id: "filter-translations-plugin",
|
|
27
|
+
canHandle: (node) => typeof node === "object" && node?.nodeType === import_core.NodeType.Translation,
|
|
28
|
+
transform: (node, props, deepTransformNode2) => {
|
|
29
|
+
const translationMap = node.translation;
|
|
30
|
+
const filteredTranslationMap = Object.fromEntries(
|
|
31
|
+
Object.entries(translationMap).filter(
|
|
32
|
+
([key]) => locales.includes(key)
|
|
33
|
+
)
|
|
34
|
+
);
|
|
35
|
+
return {
|
|
36
|
+
...node,
|
|
37
|
+
translation: deepTransformNode2(filteredTranslationMap, {
|
|
38
|
+
...props,
|
|
39
|
+
keyPath: [
|
|
40
|
+
...props.keyPath,
|
|
41
|
+
{ type: import_core.NodeType.Object, key: import_core.NodeType.Translation }
|
|
42
|
+
]
|
|
43
|
+
})
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const filterDictionaryLocales = (dictionary, locales) => {
|
|
48
|
+
return (0, import_core.deepTransformNode)(dictionary, {
|
|
49
|
+
plugins: [filterTranlationsPlugin(locales)],
|
|
50
|
+
dictionaryKey: dictionary.key,
|
|
51
|
+
keyPath: []
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
filterDictionaryLocales
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=filterDictionaryLocales.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/filterDictionaryLocales.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport {\n deepTransformNode,\n Dictionary,\n NodeType,\n Plugins,\n} from '@intlayer/core';\n\nconst filterTranlationsPlugin = (locales: Locales[]): Plugins => ({\n id: 'filter-translations-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Translation,\n transform: (node, props, deepTransformNode) => {\n const translationMap = node.translation as Record<Locales, string>;\n\n const filteredTranslationMap = Object.fromEntries(\n Object.entries(translationMap).filter(([key]) =>\n locales.includes(key as Locales)\n )\n );\n\n return {\n ...node,\n translation: deepTransformNode(filteredTranslationMap, {\n ...props,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Object, key: NodeType.Translation },\n ],\n }),\n };\n },\n});\n\nexport const filterDictionaryLocales = (\n dictionary: Dictionary,\n locales: Locales[]\n) => {\n return deepTransformNode(dictionary, {\n plugins: [filterTranlationsPlugin(locales)],\n dictionaryKey: dictionary.key,\n keyPath: [],\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAKO;AAEP,MAAM,0BAA0B,CAAC,aAAiC;AAAA,EAChE,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,qBAAS;AAAA,EAC1D,WAAW,CAAC,MAAM,OAAOA,uBAAsB;AAC7C,UAAM,iBAAiB,KAAK;AAE5B,UAAM,yBAAyB,OAAO;AAAA,MACpC,OAAO,QAAQ,cAAc,EAAE;AAAA,QAAO,CAAC,CAAC,GAAG,MACzC,QAAQ,SAAS,GAAc;AAAA,MACjC;AAAA,IACF;AAEA,WAAO;AAAA,MACL,GAAG;AAAA,MACH,aAAaA,mBAAkB,wBAAwB;AAAA,QACrD,GAAG;AAAA,QACH,SAAS;AAAA,UACP,GAAG,MAAM;AAAA,UACT,EAAE,MAAM,qBAAS,QAAQ,KAAK,qBAAS,YAAY;AAAA,QACrD;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,MAAM,0BAA0B,CACrC,YACA,YACG;AACH,aAAO,+BAAkB,YAAY;AAAA,IACnC,SAAS,CAAC,wBAAwB,OAAO,CAAC;AAAA,IAC1C,eAAe,WAAW;AAAA,IAC1B,SAAS,CAAC;AAAA,EACZ,CAAC;AACH;","names":["deepTransformNode"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var getBuiltUnmergedDictionariesPath_exports = {};
|
|
30
|
+
__export(getBuiltUnmergedDictionariesPath_exports, {
|
|
31
|
+
getBuiltUnmergedDictionariesPath: () => getBuiltUnmergedDictionariesPath
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(getBuiltUnmergedDictionariesPath_exports);
|
|
34
|
+
var import_config = require("@intlayer/config");
|
|
35
|
+
var import_fast_glob = __toESM(require("fast-glob"));
|
|
36
|
+
var import_fs = require("fs");
|
|
37
|
+
const getBuiltUnmergedDictionariesPath = (configuration = (0, import_config.getConfiguration)()) => {
|
|
38
|
+
const { unmergedDictionariesDir, mainDir } = configuration.content;
|
|
39
|
+
if (!(0, import_fs.existsSync)(mainDir)) {
|
|
40
|
+
(0, import_fs.mkdirSync)(mainDir, { recursive: true });
|
|
41
|
+
}
|
|
42
|
+
const dictionariesPath = import_fast_glob.default.sync(
|
|
43
|
+
`${unmergedDictionariesDir}/**/*.json`
|
|
44
|
+
);
|
|
45
|
+
return dictionariesPath;
|
|
46
|
+
};
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
getBuiltUnmergedDictionariesPath
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=getBuiltUnmergedDictionariesPath.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/getBuiltUnmergedDictionariesPath.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport fg from 'fast-glob';\nimport { existsSync, mkdirSync } from 'fs';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltUnmergedDictionariesPath = (\n configuration = getConfiguration()\n) => {\n const { unmergedDictionariesDir, mainDir } = configuration.content;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n const dictionariesPath: string[] = fg.sync(\n `${unmergedDictionariesDir}/**/*.json`\n );\n\n return dictionariesPath;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,uBAAe;AACf,gBAAsC;AAK/B,MAAM,mCAAmC,CAC9C,oBAAgB,gCAAiB,MAC9B;AACH,QAAM,EAAE,yBAAyB,QAAQ,IAAI,cAAc;AAG3D,MAAI,KAAC,sBAAW,OAAO,GAAG;AACxB,6BAAU,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACxC;AAEA,QAAM,mBAA6B,iBAAAA,QAAG;AAAA,IACpC,GAAG,uBAAuB;AAAA,EAC5B;AAEA,SAAO;AACT;","names":["fg"]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var getContentDeclarationFileTemplate_exports = {};
|
|
20
|
+
__export(getContentDeclarationFileTemplate_exports, {
|
|
21
|
+
getContentDeclarationFileTemplate: () => getContentDeclarationFileTemplate
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(getContentDeclarationFileTemplate_exports);
|
|
24
|
+
var import_promises = require("fs/promises");
|
|
25
|
+
var import_path = require("path");
|
|
26
|
+
var import_url = require("url");
|
|
27
|
+
var import_utils = require('../utils.cjs');
|
|
28
|
+
const import_meta = {};
|
|
29
|
+
const getContentDeclarationFileTemplate = async (key, format, fileParams = {}) => {
|
|
30
|
+
const dirname = __dirname ?? (0, import_url.fileURLToPath)(import_meta.url);
|
|
31
|
+
let fileTemplate = "./esmTemplate.md";
|
|
32
|
+
if (format === "ts") {
|
|
33
|
+
fileTemplate = "./tsTemplate.md";
|
|
34
|
+
} else if (format === "cjs") {
|
|
35
|
+
fileTemplate = "./cjsTemplate.md";
|
|
36
|
+
}
|
|
37
|
+
const fileContent = await (0, import_promises.readFile)((0, import_path.join)(dirname, fileTemplate), "utf-8");
|
|
38
|
+
const camelCaseKey = (0, import_utils.kebabCaseToCamelCase)(key);
|
|
39
|
+
const nonCapitalizedCamelCaseKey = camelCaseKey.charAt(0).toLowerCase() + camelCaseKey.slice(1);
|
|
40
|
+
const fileParmsString = Object.entries(fileParams).filter(([, value]) => value !== void 0).map(([key2, value]) => {
|
|
41
|
+
if (typeof value === "object") {
|
|
42
|
+
return `
|
|
43
|
+
${key2}: ${JSON.stringify(value)},`;
|
|
44
|
+
}
|
|
45
|
+
if (typeof value === "boolean" || typeof value === "number") {
|
|
46
|
+
return `
|
|
47
|
+
${key2}: ${value},`;
|
|
48
|
+
}
|
|
49
|
+
if (typeof value === "string") {
|
|
50
|
+
return `
|
|
51
|
+
${key2}: '${value}',`;
|
|
52
|
+
}
|
|
53
|
+
return `
|
|
54
|
+
${key2}: ${value},`;
|
|
55
|
+
}).join("");
|
|
56
|
+
return fileContent.replace("{{key}}", key).replaceAll("{{name}}", nonCapitalizedCamelCaseKey).replace("{{fileParams}}", fileParmsString);
|
|
57
|
+
};
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
getContentDeclarationFileTemplate
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=getContentDeclarationFileTemplate.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.ts"],"sourcesContent":["import { readFile } from 'fs/promises';\nimport { join } from 'path';\nimport { fileURLToPath } from 'url';\nimport { kebabCaseToCamelCase } from '../utils';\n\nexport const getContentDeclarationFileTemplate = async (\n key: string,\n format: 'ts' | 'cjs' | 'esm',\n fileParams: Record<string, any> = {}\n) => {\n const dirname = __dirname ?? fileURLToPath(import.meta.url);\n\n let fileTemplate = './esmTemplate.md';\n\n if (format === 'ts') {\n fileTemplate = './tsTemplate.md';\n } else if (format === 'cjs') {\n fileTemplate = './cjsTemplate.md';\n }\n\n const fileContent = await readFile(join(dirname, fileTemplate), 'utf-8');\n const camelCaseKey = kebabCaseToCamelCase(key);\n const nonCapitalizedCamelCaseKey =\n camelCaseKey.charAt(0).toLowerCase() + camelCaseKey.slice(1);\n\n const fileParmsString = Object.entries(fileParams)\n .filter(([, value]) => value !== undefined)\n .map(([key, value]) => {\n if (typeof value === 'object') {\n return `\\n${key}: ${JSON.stringify(value)},`;\n }\n\n if (typeof value === 'boolean' || typeof value === 'number') {\n return `\\n${key}: ${value},`;\n }\n\n if (typeof value === 'string') {\n return `\\n${key}: '${value}',`;\n }\n\n return `\\n${key}: ${value},`;\n })\n .join('');\n\n return fileContent\n .replace('{{key}}', key)\n .replaceAll('{{name}}', nonCapitalizedCamelCaseKey)\n .replace('{{fileParams}}', fileParmsString);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAyB;AACzB,kBAAqB;AACrB,iBAA8B;AAC9B,mBAAqC;AAHrC;AAKO,MAAM,oCAAoC,OAC/C,KACA,QACA,aAAkC,CAAC,MAChC;AACH,QAAM,UAAU,iBAAa,0BAAc,YAAY,GAAG;AAE1D,MAAI,eAAe;AAEnB,MAAI,WAAW,MAAM;AACnB,mBAAe;AAAA,EACjB,WAAW,WAAW,OAAO;AAC3B,mBAAe;AAAA,EACjB;AAEA,QAAM,cAAc,UAAM,8BAAS,kBAAK,SAAS,YAAY,GAAG,OAAO;AACvE,QAAM,mBAAe,mCAAqB,GAAG;AAC7C,QAAM,6BACJ,aAAa,OAAO,CAAC,EAAE,YAAY,IAAI,aAAa,MAAM,CAAC;AAE7D,QAAM,kBAAkB,OAAO,QAAQ,UAAU,EAC9C,OAAO,CAAC,CAAC,EAAE,KAAK,MAAM,UAAU,MAAS,EACzC,IAAI,CAAC,CAACA,MAAK,KAAK,MAAM;AACrB,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO;AAAA,EAAKA,IAAG,KAAK,KAAK,UAAU,KAAK,CAAC;AAAA,IAC3C;AAEA,QAAI,OAAO,UAAU,aAAa,OAAO,UAAU,UAAU;AAC3D,aAAO;AAAA,EAAKA,IAAG,KAAK,KAAK;AAAA,IAC3B;AAEA,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO;AAAA,EAAKA,IAAG,MAAM,KAAK;AAAA,IAC5B;AAEA,WAAO;AAAA,EAAKA,IAAG,KAAK,KAAK;AAAA,EAC3B,CAAC,EACA,KAAK,EAAE;AAEV,SAAO,YACJ,QAAQ,WAAW,GAAG,EACtB,WAAW,YAAY,0BAA0B,EACjD,QAAQ,kBAAkB,eAAe;AAC9C;","names":["key"]}
|