@intlayer/chokidar 3.3.2 → 3.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/chokidar/watcher.cjs +5 -2
- package/dist/cjs/chokidar/watcher.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs +17 -13
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
- package/dist/esm/chokidar/watcher.mjs +5 -2
- package/dist/esm/chokidar/watcher.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadDictionaries.mjs +17 -13
- package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
- package/dist/types/chokidar/watcher.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -1
- package/package.json +18 -18
|
@@ -47,18 +47,21 @@ const watch = (options) => {
|
|
|
47
47
|
verbose: true
|
|
48
48
|
});
|
|
49
49
|
const { watchedFilesPatternWithPath, baseDir } = content;
|
|
50
|
-
(0, import_cleanOutputDir.cleanOutputDir)();
|
|
51
50
|
const files = import_fast_glob.default.sync(watchedFilesPatternWithPath);
|
|
52
51
|
return (0, import_chokidar.watch)(watchedFilesPatternWithPath, {
|
|
53
|
-
persistent:
|
|
52
|
+
persistent: false,
|
|
54
53
|
// Make the watcher persistent
|
|
55
54
|
ignoreInitial: true,
|
|
56
55
|
// Process existing files
|
|
57
56
|
...options
|
|
58
57
|
}).on("ready", async () => {
|
|
58
|
+
(0, import_cleanOutputDir.cleanOutputDir)();
|
|
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
|
await (0, import_dictionary_to_type.createTypes)(dictionariesPaths);
|
|
62
|
+
console.info(
|
|
63
|
+
`${LOG_PREFIX}${dictionariesPaths.length} dictionaries built`
|
|
64
|
+
);
|
|
62
65
|
(0, import_dictionary_to_type.createModuleAugmentation)();
|
|
63
66
|
(0, import_createDictionaryList.createDictionaryList)();
|
|
64
67
|
}).on("add", async (filePath) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import { relative } from 'path';\nimport { getConfiguration } 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 { loadDictionaries } from '../loadDictionaries/loadDictionaries';\nimport { loadLocalDictionaries } from '../loadDictionaries/loadLocalDictionaries';\nimport { buildDictionary } from '../transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryList } from '../transpiler/dictionary_to_main/createDictionaryList';\nimport {\n createTypes,\n createModuleAugmentation,\n} from '../transpiler/dictionary_to_type/index';\n\nconst LOG_PREFIX = '[intlayer] ';\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: ChokidarOptions) => {\n const { content } = getConfiguration({\n verbose: true,\n });\n\n const { watchedFilesPatternWithPath, baseDir } = content;\n\n
|
|
1
|
+
{"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import { relative } from 'path';\nimport { getConfiguration } 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 { loadDictionaries } from '../loadDictionaries/loadDictionaries';\nimport { loadLocalDictionaries } from '../loadDictionaries/loadLocalDictionaries';\nimport { buildDictionary } from '../transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryList } from '../transpiler/dictionary_to_main/createDictionaryList';\nimport {\n createTypes,\n createModuleAugmentation,\n} from '../transpiler/dictionary_to_type/index';\n\nconst LOG_PREFIX = '[intlayer] ';\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: ChokidarOptions) => {\n const { content } = getConfiguration({\n verbose: true,\n });\n\n const { watchedFilesPatternWithPath, baseDir } = content;\n\n const files: string[] = fg.sync(watchedFilesPatternWithPath);\n\n /** @ts-ignore remove error Expected 0-1 arguments, but got 2. */\n return chokidarWatch(watchedFilesPatternWithPath, {\n persistent: false, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n ...options,\n })\n .on('ready', async () => {\n cleanOutputDir();\n\n const dictionaries = await loadDictionaries(files);\n\n // Build locale dictionaries\n const dictionariesPaths = await buildDictionary(dictionaries);\n\n await createTypes(dictionariesPaths);\n\n console.info(\n `${LOG_PREFIX}${dictionariesPaths.length} dictionaries built`\n );\n\n createModuleAugmentation();\n\n createDictionaryList();\n })\n .on('add', async (filePath) => {\n // Process the file with the functionToRun\n console.info(\n `${LOG_PREFIX}Additional file detected: `,\n relative(baseDir, filePath)\n );\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n\n const dictionaries = await buildDictionary(localeDictionaries);\n\n await createTypes(dictionaries);\n\n createModuleAugmentation();\n\n createDictionaryList();\n })\n .on('change', async (filePath) => {\n // Process the file with the functionToRun\n console.info('Change detected: ', relative(baseDir, filePath));\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n const dictionaries = await buildDictionary(localeDictionaries);\n\n await createTypes(dictionaries);\n console.info(`${LOG_PREFIX}TypeScript types built`);\n })\n .on('error', (error) => {\n console.error('Watcher error:', error);\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAyB;AACzB,oBAAiC;AAEjC,sBAA6D;AAC7D,uBAAe;AACf,4BAA+B;AAC/B,8BAAiC;AACjC,mCAAsC;AACtC,4CAAgC;AAChC,kCAAqC;AACrC,gCAGO;AAEP,MAAM,aAAa;AAGZ,MAAM,QAAQ,CAAC,YAA8B;AAClD,QAAM,EAAE,QAAQ,QAAI,g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
|
|
56
56
|
let mergedDictionaries = localDictionaries;
|
|
57
57
|
if (editor.clientId && editor.clientSecret) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (editor.dictionaryPriorityStrategy === "distant_first") {
|
|
65
|
-
mergedDictionaries = (0, import_deepmerge.default)(localDictionaries, distantDictionaries, {
|
|
66
|
-
arrayMerge: (0, import_mergeDictionaries.mergeByKey)("key")
|
|
67
|
-
});
|
|
68
|
-
} else {
|
|
69
|
-
mergedDictionaries = (0, import_deepmerge.default)(distantDictionaries, localDictionaries, {
|
|
70
|
-
arrayMerge: (0, import_mergeDictionaries.mergeByKey)("key")
|
|
58
|
+
try {
|
|
59
|
+
distantDictionaryKeys = await (0, import_fetchDistantDictionaryKeys.fetchDistantDictionaryKeys)();
|
|
60
|
+
const orderedDistantDictionaryKeys = distantDictionaryKeys.sort(import_utils.sortAlphabetically);
|
|
61
|
+
import_log.logger.addDictionaryKeys("distant", orderedDistantDictionaryKeys);
|
|
62
|
+
distantDictionaries = await (0, import_loadDistantDictionaries.loadDistantDictionaries)({
|
|
63
|
+
dictionaryKeys: orderedDistantDictionaryKeys
|
|
71
64
|
});
|
|
65
|
+
if (editor.dictionaryPriorityStrategy === "distant_first") {
|
|
66
|
+
mergedDictionaries = (0, import_deepmerge.default)(localDictionaries, distantDictionaries, {
|
|
67
|
+
arrayMerge: (0, import_mergeDictionaries.mergeByKey)("key")
|
|
68
|
+
});
|
|
69
|
+
} else {
|
|
70
|
+
mergedDictionaries = (0, import_deepmerge.default)(distantDictionaries, localDictionaries, {
|
|
71
|
+
arrayMerge: (0, import_mergeDictionaries.mergeByKey)("key")
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.error("Error during fetching distant dictionaries");
|
|
72
76
|
}
|
|
73
77
|
}
|
|
74
78
|
import_log.logger.stop();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend not build yet\nimport { type DictionaryAPI } from '@intlayer/backend';\nimport { 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\nconst LOG_PREFIX = '[intlayer] ';\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string\n): Promise<Dictionary[]> => {\n try {\n const { editor } = getConfiguration();\n\n console.info(`${LOG_PREFIX}Dictionaries:`);\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 for (const dict of localDictionaries) {\n logger.updateStatus(dict.key, 'local', { status: 'built' });\n }\n\n let distantDictionaries: DictionaryAPI[] = [];\n let distantDictionaryKeys: string[] = [];\n let mergedDictionaries = localDictionaries;\n\n if (editor.clientId && editor.clientSecret) {\n // Fetch distant dictionary keys\n
|
|
1
|
+
{"version":3,"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend not build yet\nimport { type DictionaryAPI } from '@intlayer/backend';\nimport { 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\nconst LOG_PREFIX = '[intlayer] ';\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string\n): Promise<Dictionary[]> => {\n try {\n const { editor } = getConfiguration();\n\n console.info(`${LOG_PREFIX}Dictionaries:`);\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 for (const dict of localDictionaries) {\n logger.updateStatus(dict.key, 'local', { status: 'built' });\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 console.error('Error during fetching distant dictionaries');\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":";;;;;;;;;;;;;;;;;;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AAAA,MAC5D;AAAA,IACF;AAGA,sBAAO,KAAK;AAEZ,WAAO;AAAA,EACT,SAAS,OAAO;AAEd,sBAAO,KAAK;AAEZ,UAAM;AAAA,EACR;AACF;","names":["merge"]}
|
|
@@ -17,18 +17,21 @@ const watch = (options) => {
|
|
|
17
17
|
verbose: true
|
|
18
18
|
});
|
|
19
19
|
const { watchedFilesPatternWithPath, baseDir } = content;
|
|
20
|
-
cleanOutputDir();
|
|
21
20
|
const files = fg.sync(watchedFilesPatternWithPath);
|
|
22
21
|
return chokidarWatch(watchedFilesPatternWithPath, {
|
|
23
|
-
persistent:
|
|
22
|
+
persistent: false,
|
|
24
23
|
// Make the watcher persistent
|
|
25
24
|
ignoreInitial: true,
|
|
26
25
|
// Process existing files
|
|
27
26
|
...options
|
|
28
27
|
}).on("ready", async () => {
|
|
28
|
+
cleanOutputDir();
|
|
29
29
|
const dictionaries = await loadDictionaries(files);
|
|
30
30
|
const dictionariesPaths = await buildDictionary(dictionaries);
|
|
31
31
|
await createTypes(dictionariesPaths);
|
|
32
|
+
console.info(
|
|
33
|
+
`${LOG_PREFIX}${dictionariesPaths.length} dictionaries built`
|
|
34
|
+
);
|
|
32
35
|
createModuleAugmentation();
|
|
33
36
|
createDictionaryList();
|
|
34
37
|
}).on("add", async (filePath) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import { relative } from 'path';\nimport { getConfiguration } 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 { loadDictionaries } from '../loadDictionaries/loadDictionaries';\nimport { loadLocalDictionaries } from '../loadDictionaries/loadLocalDictionaries';\nimport { buildDictionary } from '../transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryList } from '../transpiler/dictionary_to_main/createDictionaryList';\nimport {\n createTypes,\n createModuleAugmentation,\n} from '../transpiler/dictionary_to_type/index';\n\nconst LOG_PREFIX = '[intlayer] ';\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: ChokidarOptions) => {\n const { content } = getConfiguration({\n verbose: true,\n });\n\n const { watchedFilesPatternWithPath, baseDir } = content;\n\n
|
|
1
|
+
{"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import { relative } from 'path';\nimport { getConfiguration } 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 { loadDictionaries } from '../loadDictionaries/loadDictionaries';\nimport { loadLocalDictionaries } from '../loadDictionaries/loadLocalDictionaries';\nimport { buildDictionary } from '../transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryList } from '../transpiler/dictionary_to_main/createDictionaryList';\nimport {\n createTypes,\n createModuleAugmentation,\n} from '../transpiler/dictionary_to_type/index';\n\nconst LOG_PREFIX = '[intlayer] ';\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: ChokidarOptions) => {\n const { content } = getConfiguration({\n verbose: true,\n });\n\n const { watchedFilesPatternWithPath, baseDir } = content;\n\n const files: string[] = fg.sync(watchedFilesPatternWithPath);\n\n /** @ts-ignore remove error Expected 0-1 arguments, but got 2. */\n return chokidarWatch(watchedFilesPatternWithPath, {\n persistent: false, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n ...options,\n })\n .on('ready', async () => {\n cleanOutputDir();\n\n const dictionaries = await loadDictionaries(files);\n\n // Build locale dictionaries\n const dictionariesPaths = await buildDictionary(dictionaries);\n\n await createTypes(dictionariesPaths);\n\n console.info(\n `${LOG_PREFIX}${dictionariesPaths.length} dictionaries built`\n );\n\n createModuleAugmentation();\n\n createDictionaryList();\n })\n .on('add', async (filePath) => {\n // Process the file with the functionToRun\n console.info(\n `${LOG_PREFIX}Additional file detected: `,\n relative(baseDir, filePath)\n );\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n\n const dictionaries = await buildDictionary(localeDictionaries);\n\n await createTypes(dictionaries);\n\n createModuleAugmentation();\n\n createDictionaryList();\n })\n .on('change', async (filePath) => {\n // Process the file with the functionToRun\n console.info('Change detected: ', relative(baseDir, filePath));\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n const dictionaries = await buildDictionary(localeDictionaries);\n\n await createTypes(dictionaries);\n console.info(`${LOG_PREFIX}TypeScript types built`);\n })\n .on('error', (error) => {\n console.error('Watcher error:', error);\n });\n};\n"],"mappings":"AAAA,SAAS,gBAAgB;AACzB,SAAS,wBAAwB;AAEjC,SAA+B,SAAS,qBAAqB;AAC7D,OAAO,QAAQ;AACf,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,6BAA6B;AACtC,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP,MAAM,aAAa;AAGZ,MAAM,QAAQ,CAAC,YAA8B;AAClD,QAAM,EAAE,QAAQ,IAAI,iBAAiB;AAAA,IACnC,SAAS;AAAA,EACX,CAAC;AAED,QAAM,EAAE,6BAA6B,QAAQ,IAAI;AAEjD,QAAM,QAAkB,GAAG,KAAK,2BAA2B;AAG3D,SAAO,cAAc,6BAA6B;AAAA,IAChD,YAAY;AAAA;AAAA,IACZ,eAAe;AAAA;AAAA,IACf,GAAG;AAAA,EACL,CAAC,EACE,GAAG,SAAS,YAAY;AACvB,mBAAe;AAEf,UAAM,eAAe,MAAM,iBAAiB,KAAK;AAGjD,UAAM,oBAAoB,MAAM,gBAAgB,YAAY;AAE5D,UAAM,YAAY,iBAAiB;AAEnC,YAAQ;AAAA,MACN,GAAG,UAAU,GAAG,kBAAkB,MAAM;AAAA,IAC1C;AAEA,6BAAyB;AAEzB,yBAAqB;AAAA,EACvB,CAAC,EACA,GAAG,OAAO,OAAO,aAAa;AAE7B,YAAQ;AAAA,MACN,GAAG,UAAU;AAAA,MACb,SAAS,SAAS,QAAQ;AAAA,IAC5B;AAEA,UAAM,qBAAqB,MAAM,sBAAsB,QAAQ;AAE/D,UAAM,eAAe,MAAM,gBAAgB,kBAAkB;AAE7D,UAAM,YAAY,YAAY;AAE9B,6BAAyB;AAEzB,yBAAqB;AAAA,EACvB,CAAC,EACA,GAAG,UAAU,OAAO,aAAa;AAEhC,YAAQ,KAAK,qBAAqB,SAAS,SAAS,QAAQ,CAAC;AAE7D,UAAM,qBAAqB,MAAM,sBAAsB,QAAQ;AAC/D,UAAM,eAAe,MAAM,gBAAgB,kBAAkB;AAE7D,UAAM,YAAY,YAAY;AAC9B,YAAQ,KAAK,GAAG,UAAU,wBAAwB;AAAA,EACpD,CAAC,EACA,GAAG,SAAS,CAAC,UAAU;AACtB,YAAQ,MAAM,kBAAkB,KAAK;AAAA,EACvC,CAAC;AACL;","names":[]}
|
|
@@ -22,20 +22,24 @@ const loadDictionaries = async (contentDeclarationsPaths) => {
|
|
|
22
22
|
let distantDictionaryKeys = [];
|
|
23
23
|
let mergedDictionaries = localDictionaries;
|
|
24
24
|
if (editor.clientId && editor.clientSecret) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (editor.dictionaryPriorityStrategy === "distant_first") {
|
|
32
|
-
mergedDictionaries = merge(localDictionaries, distantDictionaries, {
|
|
33
|
-
arrayMerge: mergeByKey("key")
|
|
34
|
-
});
|
|
35
|
-
} else {
|
|
36
|
-
mergedDictionaries = merge(distantDictionaries, localDictionaries, {
|
|
37
|
-
arrayMerge: mergeByKey("key")
|
|
25
|
+
try {
|
|
26
|
+
distantDictionaryKeys = await fetchDistantDictionaryKeys();
|
|
27
|
+
const orderedDistantDictionaryKeys = distantDictionaryKeys.sort(sortAlphabetically);
|
|
28
|
+
logger.addDictionaryKeys("distant", orderedDistantDictionaryKeys);
|
|
29
|
+
distantDictionaries = await loadDistantDictionaries({
|
|
30
|
+
dictionaryKeys: orderedDistantDictionaryKeys
|
|
38
31
|
});
|
|
32
|
+
if (editor.dictionaryPriorityStrategy === "distant_first") {
|
|
33
|
+
mergedDictionaries = merge(localDictionaries, distantDictionaries, {
|
|
34
|
+
arrayMerge: mergeByKey("key")
|
|
35
|
+
});
|
|
36
|
+
} else {
|
|
37
|
+
mergedDictionaries = merge(distantDictionaries, localDictionaries, {
|
|
38
|
+
arrayMerge: mergeByKey("key")
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error("Error during fetching distant dictionaries");
|
|
39
43
|
}
|
|
40
44
|
}
|
|
41
45
|
logger.stop();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend not build yet\nimport { type DictionaryAPI } from '@intlayer/backend';\nimport { 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\nconst LOG_PREFIX = '[intlayer] ';\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string\n): Promise<Dictionary[]> => {\n try {\n const { editor } = getConfiguration();\n\n console.info(`${LOG_PREFIX}Dictionaries:`);\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 for (const dict of localDictionaries) {\n logger.updateStatus(dict.key, 'local', { status: 'built' });\n }\n\n let distantDictionaries: DictionaryAPI[] = [];\n let distantDictionaryKeys: string[] = [];\n let mergedDictionaries = localDictionaries;\n\n if (editor.clientId && editor.clientSecret) {\n // Fetch distant dictionary keys\n
|
|
1
|
+
{"version":3,"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend not build yet\nimport { type DictionaryAPI } from '@intlayer/backend';\nimport { 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\nconst LOG_PREFIX = '[intlayer] ';\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string\n): Promise<Dictionary[]> => {\n try {\n const { editor } = getConfiguration();\n\n console.info(`${LOG_PREFIX}Dictionaries:`);\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 for (const dict of localDictionaries) {\n logger.updateStatus(dict.key, 'local', { status: 'built' });\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 console.error('Error during fetching distant dictionaries');\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":"AAEA,SAAS,wBAAwB;AAEjC,OAAO,WAAW;AAClB,SAAS,kCAAkC;AAC3C,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,0BAA0B;AACnC,SAAS,+BAA+B;AACxC,SAAS,+BAA+B;AAExC,MAAM,aAAa;AAEZ,MAAM,mBAAmB,OAC9B,6BAC0B;AAC1B,MAAI;AACF,UAAM,EAAE,OAAO,IAAI,iBAAiB;AAEpC,YAAQ,KAAK,GAAG,UAAU,eAAe;AAEzC,UAAM,QAAQ,MAAM,QAAQ,wBAAwB,IAChD,2BACA,CAAC,wBAAwB;AAE7B,UAAM,oBACJ,MAAM,wBAAwB,KAAK;AACrC,UAAM,sBAAsB,kBAAkB,IAAI,CAAC,SAAS,KAAK,GAAG;AAGpE,WAAO,KAAK,qBAAqB,CAAC,CAAC;AAGnC,eAAW,QAAQ,mBAAmB;AACpC,aAAO,aAAa,KAAK,KAAK,SAAS,EAAE,QAAQ,QAAQ,CAAC;AAAA,IAC5D;AAEA,QAAI,sBAAuC,CAAC;AAC5C,QAAI,wBAAkC,CAAC;AACvC,QAAI,qBAAqB;AAEzB,QAAI,OAAO,YAAY,OAAO,cAAc;AAC1C,UAAI;AAEF,gCAAwB,MAAM,2BAA2B;AAEzD,cAAM,+BACJ,sBAAsB,KAAK,kBAAkB;AAE/C,eAAO,kBAAkB,WAAW,4BAA4B;AAGhE,8BAAsB,MAAM,wBAAwB;AAAA,UAClD,gBAAgB;AAAA,QAClB,CAAC;AACD,YAAI,OAAO,+BAA+B,iBAAiB;AAEzD,+BAAqB,MAAM,mBAAmB,qBAAqB;AAAA,YACjE,YAAY,WAAW,KAAK;AAAA,UAC9B,CAAC;AAAA,QACH,OAAO;AAEL,+BAAqB,MAAM,qBAAqB,mBAAmB;AAAA,YACjE,YAAY,WAAW,KAAK;AAAA,UAC9B,CAAC;AAAA,QACH;AAAA,MACF,SAAS,OAAO;AACd,gBAAQ,MAAM,4CAA4C;AAAA,MAC5D;AAAA,IACF;AAGA,WAAO,KAAK;AAEZ,WAAO;AAAA,EACT,SAAS,OAAO;AAEd,WAAO,KAAK;AAEZ,UAAM;AAAA,EACR;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watcher.d.ts","sourceRoot":"","sources":["../../../src/chokidar/watcher.ts"],"names":[],"mappings":"AAEA,2FAA2F;AAC3F,OAAO,EAAE,KAAK,eAAe,EAA0B,MAAM,UAAU,CAAC;AAexE,eAAO,MAAM,KAAK,aAAc,eAAe,
|
|
1
|
+
{"version":3,"file":"watcher.d.ts","sourceRoot":"","sources":["../../../src/chokidar/watcher.ts"],"names":[],"mappings":"AAEA,2FAA2F;AAC3F,OAAO,EAAE,KAAK,eAAe,EAA0B,MAAM,UAAU,CAAC;AAexE,eAAO,MAAM,KAAK,aAAc,eAAe,QA+D9C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadDictionaries.d.ts","sourceRoot":"","sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAW5C,eAAO,MAAM,gBAAgB,6BACD,MAAM,EAAE,GAAG,MAAM,KAC1C,OAAO,CAAC,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"loadDictionaries.d.ts","sourceRoot":"","sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAW5C,eAAO,MAAM,gBAAgB,6BACD,MAAM,EAAE,GAAG,MAAM,KAC1C,OAAO,CAAC,UAAU,EAAE,CAkEtB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/chokidar",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Chokidar application for IntLayer - Transpile IntLayer declaration files into dictionaries.",
|
|
6
6
|
"keywords": [
|
|
@@ -68,35 +68,35 @@
|
|
|
68
68
|
"quicktype-core": "^23.0.170",
|
|
69
69
|
"react": "^18.3.1",
|
|
70
70
|
"rimraf": "^6.0.1",
|
|
71
|
-
"@intlayer/backend": "^3.3.
|
|
72
|
-
"@intlayer/config": "^3.3.
|
|
73
|
-
"@intlayer/core": "^3.3.
|
|
74
|
-
"@intlayer/design-system": "^3.3.
|
|
75
|
-
"intlayer": "^3.3.
|
|
71
|
+
"@intlayer/backend": "^3.3.3",
|
|
72
|
+
"@intlayer/config": "^3.3.3",
|
|
73
|
+
"@intlayer/core": "^3.3.3",
|
|
74
|
+
"@intlayer/design-system": "^3.3.3",
|
|
75
|
+
"intlayer": "^3.3.3"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
|
-
"@changesets/cli": "2.27.
|
|
78
|
+
"@changesets/cli": "2.27.10",
|
|
79
79
|
"@types/crypto-js": "^4.2.2",
|
|
80
|
-
"@types/node": "^22.
|
|
80
|
+
"@types/node": "^22.10.1",
|
|
81
81
|
"concurrently": "^9.1.0",
|
|
82
|
-
"eslint": "^9.
|
|
82
|
+
"eslint": "^9.16.0",
|
|
83
83
|
"node-polyfill-webpack-plugin": "^4.0.0",
|
|
84
|
-
"prettier": "^3.
|
|
84
|
+
"prettier": "^3.4.1",
|
|
85
85
|
"tsc-alias": "^1.8.10",
|
|
86
86
|
"tsup": "^8.3.5",
|
|
87
|
-
"typescript": "^5.
|
|
87
|
+
"typescript": "^5.7.2",
|
|
88
88
|
"webpack-watch-files-plugin": "^1.2.1",
|
|
89
89
|
"@utils/eslint-config": "^1.0.4",
|
|
90
|
-
"@utils/ts-config": "^1.0.4",
|
|
91
90
|
"@utils/ts-config-types": "^1.0.4",
|
|
92
|
-
"@utils/tsup-config": "^1.0.4"
|
|
91
|
+
"@utils/tsup-config": "^1.0.4",
|
|
92
|
+
"@utils/ts-config": "^1.0.4"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
|
-
"@intlayer/backend": "^3.3.
|
|
96
|
-
"@intlayer/config": "^3.3.
|
|
97
|
-
"@intlayer/
|
|
98
|
-
"@intlayer/
|
|
99
|
-
"intlayer": "^3.3.
|
|
95
|
+
"@intlayer/backend": "^3.3.3",
|
|
96
|
+
"@intlayer/config": "^3.3.3",
|
|
97
|
+
"@intlayer/core": "^3.3.3",
|
|
98
|
+
"@intlayer/design-system": "^3.3.3",
|
|
99
|
+
"intlayer": "^3.3.3"
|
|
100
100
|
},
|
|
101
101
|
"engines": {
|
|
102
102
|
"node": ">=14.18"
|