@intlayer/chokidar 6.0.0 → 6.0.2-canary.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/index.cjs +6 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/listDictionariesPath.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs +1 -1
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +4 -15
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/log.cjs +14 -9
- package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
- package/dist/cjs/prepareIntlayer.cjs +29 -9
- package/dist/cjs/prepareIntlayer.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs +20 -9
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_main/generateDictionaryListContent.cjs +19 -7
- package/dist/cjs/transpiler/dictionary_to_main/generateDictionaryListContent.cjs.map +1 -1
- package/dist/cjs/utils/extractErrorMessage.cjs +126 -0
- package/dist/cjs/utils/extractErrorMessage.cjs.map +1 -0
- package/dist/cjs/utils/getExtention.cjs +37 -0
- package/dist/cjs/utils/getExtention.cjs.map +1 -0
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +8 -7
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
- package/dist/esm/index.mjs +4 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/listDictionariesPath.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadDictionaries.mjs +1 -1
- package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +3 -4
- package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/log.mjs +14 -9
- package/dist/esm/loadDictionaries/log.mjs.map +1 -1
- package/dist/esm/prepareIntlayer.mjs +19 -9
- package/dist/esm/prepareIntlayer.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs +20 -9
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_main/generateDictionaryListContent.mjs +19 -7
- package/dist/esm/transpiler/dictionary_to_main/generateDictionaryListContent.mjs.map +1 -1
- package/dist/esm/utils/extractErrorMessage.mjs +102 -0
- package/dist/esm/utils/extractErrorMessage.mjs.map +1 -0
- package/dist/esm/utils/getExtention.mjs +13 -0
- package/dist/esm/utils/getExtention.mjs.map +1 -0
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +8 -7
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/listDictionariesPath.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -1
- package/dist/types/loadDictionaries/log.d.ts +1 -1
- package/dist/types/loadDictionaries/log.d.ts.map +1 -1
- package/dist/types/prepareIntlayer.d.ts.map +1 -1
- package/dist/types/transpiler/dictionary_to_main/createDictionaryEntryPoint.d.ts.map +1 -1
- package/dist/types/transpiler/dictionary_to_main/generateDictionaryListContent.d.ts +1 -1
- package/dist/types/transpiler/dictionary_to_main/generateDictionaryListContent.d.ts.map +1 -1
- package/dist/types/utils/extractErrorMessage.d.ts +2 -0
- package/dist/types/utils/extractErrorMessage.d.ts.map +1 -0
- package/dist/types/utils/getExtention.d.ts +3 -0
- package/dist/types/utils/getExtention.d.ts.map +1 -0
- package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -1
- package/package.json +16 -16
package/dist/cjs/index.cjs
CHANGED
|
@@ -23,12 +23,14 @@ __export(index_exports, {
|
|
|
23
23
|
cleanOutputDir: () => import_cleanOutputDir.cleanOutputDir,
|
|
24
24
|
createDictionaryEntryPoint: () => import_dictionary_to_main.createDictionaryEntryPoint,
|
|
25
25
|
createModuleAugmentation: () => import_createModuleAugmentation.createModuleAugmentation,
|
|
26
|
+
extractErrorMessage: () => import_extractErrorMessage.extractErrorMessage,
|
|
26
27
|
fetchDistantDictionaries: () => import_fetchDistantDictionaries.fetchDistantDictionaries,
|
|
27
28
|
formatLocale: () => import_formatter.formatLocale,
|
|
28
29
|
formatPath: () => import_formatter.formatPath,
|
|
29
30
|
generateDictionaryListContent: () => import_dictionary_to_main.generateDictionaryListContent,
|
|
30
31
|
getBuiltDictionariesPath: () => import_getBuiltDictionariesPath.getBuiltDictionariesPath,
|
|
31
32
|
getBuiltUnmergedDictionariesPath: () => import_getBuiltUnmergedDictionariesPath.getBuiltUnmergedDictionariesPath,
|
|
33
|
+
getExtension: () => import_getExtention.getExtension,
|
|
32
34
|
getFileHash: () => import_getFileHash.getFileHash,
|
|
33
35
|
handleAdditionalContentDeclarationFile: () => import_watcher.handleAdditionalContentDeclarationFile,
|
|
34
36
|
handleContentDeclarationFileChange: () => import_watcher.handleContentDeclarationFileChange,
|
|
@@ -68,7 +70,9 @@ var import_reduceDictionaryContent = require('./reduceDictionaryContent/reduceDi
|
|
|
68
70
|
var import_dictionary_to_main = require('./transpiler/dictionary_to_main/index.cjs');
|
|
69
71
|
var import_createModuleAugmentation = require('./transpiler/dictionary_to_type/createModuleAugmentation.cjs');
|
|
70
72
|
var import_buildIntlayerDictionary = require('./transpiler/intlayer_dictionary/buildIntlayerDictionary.cjs');
|
|
73
|
+
var import_extractErrorMessage = require('./utils/extractErrorMessage.cjs');
|
|
71
74
|
var import_formatter = require('./utils/formatter.cjs');
|
|
75
|
+
var import_getExtention = require('./utils/getExtention.cjs');
|
|
72
76
|
var import_getFileHash = require('./utils/getFileHash.cjs');
|
|
73
77
|
var import_kebabCaseToCamelCase = require('./utils/kebabCaseToCamelCase.cjs');
|
|
74
78
|
var import_parallelize = require('./utils/parallelize.cjs');
|
|
@@ -83,12 +87,14 @@ var import_writeContentDeclaration = require('./writeContentDeclaration/index.cj
|
|
|
83
87
|
cleanOutputDir,
|
|
84
88
|
createDictionaryEntryPoint,
|
|
85
89
|
createModuleAugmentation,
|
|
90
|
+
extractErrorMessage,
|
|
86
91
|
fetchDistantDictionaries,
|
|
87
92
|
formatLocale,
|
|
88
93
|
formatPath,
|
|
89
94
|
generateDictionaryListContent,
|
|
90
95
|
getBuiltDictionariesPath,
|
|
91
96
|
getBuiltUnmergedDictionariesPath,
|
|
97
|
+
getExtension,
|
|
92
98
|
getFileHash,
|
|
93
99
|
handleAdditionalContentDeclarationFile,
|
|
94
100
|
handleContentDeclarationFileChange,
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n buildAndWatchIntlayer,\n handleAdditionalContentDeclarationFile,\n handleContentDeclarationFileChange,\n watch,\n} from './chokidar/watcher';\nexport { cleanOutputDir } from './cleanOutputDir';\nexport { fetchDistantDictionaries } from './fetchDistantDictionaries';\nexport { getBuiltDictionariesPath } from './getBuiltDictionariesPath';\nexport { getBuiltUnmergedDictionariesPath } from './getBuiltUnmergedDictionariesPath';\nexport { listDictionaries } from './listDictionariesPath';\nexport {\n listGitFiles,\n listGitLines,\n type DiffMode,\n type ListGitFilesOptions,\n type ListGitLinesOptions,\n} from './listGitFiles';\nexport {\n loadDictionaries,\n loadLocalDictionaries,\n loadRemoteDictionaries,\n} from './loadDictionaries/index';\nexport { mergeDictionaries } from './mergeDictionaries';\nexport { prepareContentDeclaration } from './prepareContentDeclaration';\nexport { prepareIntlayer } from './prepareIntlayer';\nexport { processPerLocaleDictionary } from './processPerLocaleDictionary';\nexport { reduceDictionaryContent } from './reduceDictionaryContent/reduceDictionaryContent';\nexport {\n createDictionaryEntryPoint,\n generateDictionaryListContent,\n} from './transpiler/dictionary_to_main';\nexport { createModuleAugmentation } from './transpiler/dictionary_to_type/createModuleAugmentation';\nexport { buildDictionary } from './transpiler/intlayer_dictionary/buildIntlayerDictionary';\nexport { formatLocale, formatPath } from './utils/formatter';\nexport { getFileHash } from './utils/getFileHash';\nexport { kebabCaseToCamelCase } from './utils/kebabCaseToCamelCase';\nexport { parallelize } from './utils/parallelize';\nexport { resolveObjectPromises } from './utils/resolveObjectPromises';\nexport { runOnce } from './utils/runOnce';\nexport { sortAlphabetically } from './utils/sortAlphabetically';\nexport {\n writeContentDeclaration,\n type DictionaryStatus,\n} from './writeContentDeclaration';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAKO;AACP,4BAA+B;AAC/B,sCAAyC;AACzC,sCAAyC;AACzC,8CAAiD;AACjD,kCAAiC;AACjC,0BAMO;AACP,8BAIO;AACP,+BAAkC;AAClC,uCAA0C;AAC1C,6BAAgC;AAChC,wCAA2C;AAC3C,qCAAwC;AACxC,gCAGO;AACP,sCAAyC;AACzC,qCAAgC;AAChC,uBAAyC;AACzC,yBAA4B;AAC5B,kCAAqC;AACrC,yBAA4B;AAC5B,mCAAsC;AACtC,qBAAwB;AACxB,gCAAmC;AACnC,qCAGO;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n buildAndWatchIntlayer,\n handleAdditionalContentDeclarationFile,\n handleContentDeclarationFileChange,\n watch,\n} from './chokidar/watcher';\nexport { cleanOutputDir } from './cleanOutputDir';\nexport { fetchDistantDictionaries } from './fetchDistantDictionaries';\nexport { getBuiltDictionariesPath } from './getBuiltDictionariesPath';\nexport { getBuiltUnmergedDictionariesPath } from './getBuiltUnmergedDictionariesPath';\nexport { listDictionaries } from './listDictionariesPath';\nexport {\n listGitFiles,\n listGitLines,\n type DiffMode,\n type ListGitFilesOptions,\n type ListGitLinesOptions,\n} from './listGitFiles';\nexport {\n loadDictionaries,\n loadLocalDictionaries,\n loadRemoteDictionaries,\n} from './loadDictionaries/index';\nexport { mergeDictionaries } from './mergeDictionaries';\nexport { prepareContentDeclaration } from './prepareContentDeclaration';\nexport { prepareIntlayer } from './prepareIntlayer';\nexport { processPerLocaleDictionary } from './processPerLocaleDictionary';\nexport { reduceDictionaryContent } from './reduceDictionaryContent/reduceDictionaryContent';\nexport {\n createDictionaryEntryPoint,\n generateDictionaryListContent,\n} from './transpiler/dictionary_to_main';\nexport { createModuleAugmentation } from './transpiler/dictionary_to_type/createModuleAugmentation';\nexport { buildDictionary } from './transpiler/intlayer_dictionary/buildIntlayerDictionary';\nexport { extractErrorMessage } from './utils/extractErrorMessage';\nexport { formatLocale, formatPath } from './utils/formatter';\nexport { getExtension } from './utils/getExtention';\nexport { getFileHash } from './utils/getFileHash';\nexport { kebabCaseToCamelCase } from './utils/kebabCaseToCamelCase';\nexport { parallelize } from './utils/parallelize';\nexport { resolveObjectPromises } from './utils/resolveObjectPromises';\nexport { runOnce } from './utils/runOnce';\nexport { sortAlphabetically } from './utils/sortAlphabetically';\nexport {\n writeContentDeclaration,\n type DictionaryStatus,\n} from './writeContentDeclaration';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAKO;AACP,4BAA+B;AAC/B,sCAAyC;AACzC,sCAAyC;AACzC,8CAAiD;AACjD,kCAAiC;AACjC,0BAMO;AACP,8BAIO;AACP,+BAAkC;AAClC,uCAA0C;AAC1C,6BAAgC;AAChC,wCAA2C;AAC3C,qCAAwC;AACxC,gCAGO;AACP,sCAAyC;AACzC,qCAAgC;AAChC,iCAAoC;AACpC,uBAAyC;AACzC,0BAA6B;AAC7B,yBAA4B;AAC5B,kCAAqC;AACrC,yBAA4B;AAC5B,mCAAsC;AACtC,qBAAwB;AACxB,gCAAmC;AACnC,qCAGO;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/listDictionariesPath.ts"],"sourcesContent":["import { type IntlayerConfig, getConfiguration } from '@intlayer/config';\nimport fg from 'fast-glob';\n\nexport const listDictionaries = (\n configuration: IntlayerConfig = getConfiguration()\n) => {\n const files: string[] = fg.sync(\n configuration.content.watchedFilesPatternWithPath,\n {\n ignore: [\n '**/node_modules/**',\n '**/.git/**',\n '**/.github/**',\n '**/.next/**',\n '**/.expo/**',\n '**/.expo-shared/**',\n '**/.vercel/**',\n '**/.cache/**',\n '**/dist/**',\n '**/build/**',\n '**/.intlayer/**',\n ],\n }\n );\n\n return files;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAsD;AACtD,uBAAe;AAER,MAAM,mBAAmB,CAC9B,oBAAgC,gCAAiB,
|
|
1
|
+
{"version":3,"sources":["../../src/listDictionariesPath.ts"],"sourcesContent":["import { type IntlayerConfig, getConfiguration } from '@intlayer/config';\nimport fg from 'fast-glob';\n\nexport const listDictionaries = (\n configuration: IntlayerConfig = getConfiguration()\n): string[] => {\n const files: string[] = fg.sync(\n configuration.content.watchedFilesPatternWithPath,\n {\n ignore: [\n '**/node_modules/**',\n '**/.git/**',\n '**/.github/**',\n '**/.next/**',\n '**/.expo/**',\n '**/.expo-shared/**',\n '**/.vercel/**',\n '**/.cache/**',\n '**/dist/**',\n '**/build/**',\n '**/.intlayer/**',\n ],\n }\n );\n\n return files;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAsD;AACtD,uBAAe;AAER,MAAM,mBAAmB,CAC9B,oBAAgC,gCAAiB,MACpC;AACb,QAAM,QAAkB,iBAAAA,QAAG;AAAA,IACzB,cAAc,QAAQ;AAAA,IACtB;AAAA,MACE,QAAQ;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":["fg"]}
|
|
@@ -153,7 +153,7 @@ const loadDictionaries = async (contentDeclarationsPaths, configuration = (0, im
|
|
|
153
153
|
{
|
|
154
154
|
onStartRemoteCheck: () => logger.startRemoteCheck(),
|
|
155
155
|
onStopRemoteCheck: () => logger.stopRemoteCheck(),
|
|
156
|
-
onError: () => logger.setRemoteError()
|
|
156
|
+
onError: (e) => logger.setRemoteError(e)
|
|
157
157
|
}
|
|
158
158
|
);
|
|
159
159
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n ESMxCJSRequire,\n getAppLogger,\n getConfiguration,\n type IntlayerConfig,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n let updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const idx = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (idx >= 0) {\n updated[idx] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig = getConfiguration()) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const s of loadDictionariesStatus) {\n const rec = byKey.get(s.dictionaryKey) ?? {};\n if (s.type === 'local') rec.local = s.status;\n if (s.type === 'remote') rec.remote = s.status;\n byKey.set(s.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n time: {\n localDictionaries: number;\n remoteDictionaries: number;\n };\n}> => {\n const loadDictionariesStartTime = Date.now();\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n projectRequire,\n setLoadDictionariesStatus\n );\n\n const localDictionariesTime = Date.now();\n\n const filteredLocalDictionaries =\n filterInvalidDictionaries(localDictionaries);\n\n const localDictionariesStatus = filteredLocalDictionaries.map(\n (dict) =>\n ({\n dictionaryKey: dict.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n if (hasRemoteDictionaries) {\n // We expect to fetch remote dictionaries soon; suppress a transient local-only render\n logger.setExpectRemote(true);\n }\n\n let remoteDictionaries: Dictionary[] = [];\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus,\n {\n onStartRemoteCheck: () => logger.startRemoteCheck(),\n onStopRemoteCheck: () => logger.stopRemoteCheck(),\n onError: () => logger.setRemoteError(),\n }\n );\n }\n const remoteDictionariesTime = Date.now();\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries: filteredLocalDictionaries,\n remoteDictionaries,\n time: {\n localDictionaries: localDictionariesTime - loadDictionariesStartTime,\n remoteDictionaries: remoteDictionariesTime - localDictionariesTime,\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBASO;AAEP,uCAA0C;AAC1C,oCAAwC;AACxC,oCAAuC;AACvC,iBAAmC;AAiBnC,IAAI,yBAA+C,CAAC;AACpD,MAAM,SAAS,IAAI,8BAAmB;AAEtC,MAAM,4BAA4B,CAAC,aAAmC;AACpE,MAAI,UAAgC,CAAC,GAAG,sBAAsB;AAE9D,aAAW,YAAY,UAAU;AAC/B,UAAM,MAAM,QAAQ;AAAA,MAClB,CAAC,MACC,EAAE,kBAAkB,SAAS,iBAAiB,EAAE,SAAS,SAAS;AAAA,IACtE;AACA,QAAI,OAAO,GAAG;AACZ,cAAQ,GAAG,IAAI;AAAA,IACjB,OAAO;AACL,cAA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AM,QAAQ,wBAAwB,IAChD,2BACA,CAAC,wBAAwB;AAE7B,QAAM,oBAAkC,UAAM;AAAA,IAC5C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,wBAAwB,KAAK,IAAI;AAEvC,QAAM,gCACJ,4DAA0B,iBAAiB;AAE7C,QAAM,0BAA0B,0BAA0B;AAAA,IACxD,CAAC,UACE;AAAA,MACC,eAAe,KAAK;AAAA,MACpB,MAAM;AAAA,MACN,QAAQ;AAAA,IACV;AAAA,EACJ;AAEA,4BAA0B,uBAAuB;AAEjD,QAAM,wBAAwB;AAAA,IAC5B,cAAc,OAAO,YAAY,cAAc,OAAO;AAAA,EACxD;AAEA,MAAI,uBAAuB;AAEzB,WAAO,gBAAgB,IAAI;AAAA,EAC7B;AAEA,MAAI,qBAAmC,CAAC;AACxC,MAAI,uBAAuB;AACzB,yBAAqB,UAAM;AAAA,MACzB;AAAA,MACA;AAAA,MACA;AAAA,QACE,oBAAoB,MAAM,OAAO,iBAAiB;AAAA,QAClD,mBAAmB,MAAM,OAAO,gBAAgB;AAAA,QAChD,SAAS,MAAM,OAAO,eAAe;AAAA,MACvC;AAAA,IACF;AAAA,EACF;AACA,QAAM,yBAAyB,KAAK,IAAI;AAGxC,SAAO,OAAO;AAEd,eAAa,aAAa;AAE1B,SAAO;AAAA,IACL,mBAAmB;AAAA,IACnB;AAAA,IACA,MAAM;AAAA,MACJ,mBAAmB,wBAAwB;AAAA,MAC3C,oBAAoB,yBAAyB;AAAA,IAC/C;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n ESMxCJSRequire,\n getAppLogger,\n getConfiguration,\n type IntlayerConfig,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n let updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const idx = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (idx >= 0) {\n updated[idx] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig = getConfiguration()) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const s of loadDictionariesStatus) {\n const rec = byKey.get(s.dictionaryKey) ?? {};\n if (s.type === 'local') rec.local = s.status;\n if (s.type === 'remote') rec.remote = s.status;\n byKey.set(s.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n time: {\n localDictionaries: number;\n remoteDictionaries: number;\n };\n}> => {\n const loadDictionariesStartTime = Date.now();\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n projectRequire,\n setLoadDictionariesStatus\n );\n\n const localDictionariesTime = Date.now();\n\n const filteredLocalDictionaries =\n filterInvalidDictionaries(localDictionaries);\n\n const localDictionariesStatus = filteredLocalDictionaries.map(\n (dict) =>\n ({\n dictionaryKey: dict.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n if (hasRemoteDictionaries) {\n // We expect to fetch remote dictionaries soon; suppress a transient local-only render\n logger.setExpectRemote(true);\n }\n\n let remoteDictionaries: Dictionary[] = [];\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus,\n {\n onStartRemoteCheck: () => logger.startRemoteCheck(),\n onStopRemoteCheck: () => logger.stopRemoteCheck(),\n onError: (e) => logger.setRemoteError(e),\n }\n );\n }\n const remoteDictionariesTime = Date.now();\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries: filteredLocalDictionaries,\n remoteDictionaries,\n time: {\n localDictionaries: localDictionariesTime - loadDictionariesStartTime,\n remoteDictionaries: remoteDictionariesTime - localDictionariesTime,\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBASO;AAEP,uCAA0C;AAC1C,oCAAwC;AACxC,oCAAuC;AACvC,iBAAmC;AAiBnC,IAAI,yBAA+C,CAAC;AACpD,MAAM,SAAS,IAAI,8BAAmB;AAEtC,MAAM,4BAA4B,CAAC,aAAmC;AACpE,MAAI,UAAgC,CAAC,GAAG,sBAAsB;AAE9D,aAAW,YAA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-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
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
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var loadRemoteDictionaries_exports = {};
|
|
30
20
|
__export(loadRemoteDictionaries_exports, {
|
|
@@ -34,7 +24,7 @@ __export(loadRemoteDictionaries_exports, {
|
|
|
34
24
|
module.exports = __toCommonJS(loadRemoteDictionaries_exports);
|
|
35
25
|
var import_api = require("@intlayer/api");
|
|
36
26
|
var import_config = require("@intlayer/config");
|
|
37
|
-
var import_remote_dictionaries_entry =
|
|
27
|
+
var import_remote_dictionaries_entry = require("@intlayer/remote-dictionaries-entry");
|
|
38
28
|
var import_fetchDistantDictionaries = require('../fetchDistantDictionaries.cjs');
|
|
39
29
|
var import_sortAlphabetically = require('../utils/sortAlphabetically.cjs');
|
|
40
30
|
const formatDistantDictionaries = (dictionaries) => dictionaries.map((dict) => ({
|
|
@@ -43,8 +33,8 @@ const formatDistantDictionaries = (dictionaries) => dictionaries.map((dict) => (
|
|
|
43
33
|
location: "distant"
|
|
44
34
|
}));
|
|
45
35
|
const loadRemoteDictionaries = async (configuration = (0, import_config.getConfiguration)(), onStatusUpdate, options) => {
|
|
46
|
-
const appLogger = (0, import_config.getAppLogger)(configuration);
|
|
47
36
|
const { editor } = configuration;
|
|
37
|
+
const remoteDictionariesRecord = (0, import_remote_dictionaries_entry.getRemoteDictionaries)(configuration);
|
|
48
38
|
const hasRemoteDictionaries = Boolean(editor.clientId && editor.clientSecret);
|
|
49
39
|
if (!hasRemoteDictionaries) return [];
|
|
50
40
|
try {
|
|
@@ -59,14 +49,14 @@ const loadRemoteDictionaries = async (configuration = (0, import_config.getConfi
|
|
|
59
49
|
distantDictionaryUpdateTimeStamp
|
|
60
50
|
).filter(([dictionaryKey, remoteUpdatedAt]) => {
|
|
61
51
|
if (!remoteUpdatedAt) return true;
|
|
62
|
-
const local =
|
|
52
|
+
const local = remoteDictionariesRecord[dictionaryKey];
|
|
63
53
|
if (!local) return true;
|
|
64
54
|
const localUpdatedAtRaw = local?.updatedAt;
|
|
65
55
|
const localUpdatedAt = typeof localUpdatedAtRaw === "number" ? localUpdatedAtRaw : localUpdatedAtRaw ? new Date(localUpdatedAtRaw).getTime() : void 0;
|
|
66
56
|
if (typeof localUpdatedAt !== "number") return true;
|
|
67
57
|
return remoteUpdatedAt > localUpdatedAt;
|
|
68
58
|
}).map(([dictionaryKey]) => dictionaryKey);
|
|
69
|
-
const cachedDictionaries = Object.entries(
|
|
59
|
+
const cachedDictionaries = Object.entries(remoteDictionariesRecord).filter(([key, dictionary]) => {
|
|
70
60
|
const remoteUpdatedAt = distantDictionaryUpdateTimeStamp[key];
|
|
71
61
|
const localUpdatedAtRaw = dictionary?.updatedAt;
|
|
72
62
|
const localUpdatedAt = typeof localUpdatedAtRaw === "number" ? localUpdatedAtRaw : localUpdatedAtRaw ? new Date(localUpdatedAtRaw).getTime() : void 0;
|
|
@@ -102,7 +92,6 @@ const loadRemoteDictionaries = async (configuration = (0, import_config.getConfi
|
|
|
102
92
|
);
|
|
103
93
|
return [...cachedDictionaries, ...distantDictionaries];
|
|
104
94
|
} catch (error) {
|
|
105
|
-
console.error(error);
|
|
106
95
|
options?.onError?.(error);
|
|
107
96
|
return [];
|
|
108
97
|
} finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/loadDictionaries/loadRemoteDictionaries.ts"],"sourcesContent":["import { getIntlayerAPIProxy } from '@intlayer/api';\n// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/loadDictionaries/loadRemoteDictionaries.ts"],"sourcesContent":["import { getIntlayerAPIProxy } from '@intlayer/api';\n// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { getRemoteDictionaries } from '@intlayer/remote-dictionaries-entry';\nimport { fetchDistantDictionaries } from '../fetchDistantDictionaries';\nimport { DictionariesStatus } from '../loadDictionaries/loadDictionaries';\nimport { sortAlphabetically } from '../utils/sortAlphabetically';\n\nexport const formatDistantDictionaries = (\n dictionaries: DictionaryAPI[]\n): Dictionary[] =>\n dictionaries.map((dict) => ({\n ...dict,\n localId: `${dict.key}::remote::${dict.id}`,\n location: 'distant' as const,\n }));\n\nexport const loadRemoteDictionaries = async (\n configuration = getConfiguration(),\n onStatusUpdate?: (status: DictionariesStatus[]) => void,\n options?: {\n onStartRemoteCheck?: () => void;\n onStopRemoteCheck?: () => void;\n onError?: (error: Error) => void;\n }\n): Promise<DictionaryAPI[]> => {\n const { editor } = configuration;\n const remoteDictionariesRecord = getRemoteDictionaries(configuration);\n\n const hasRemoteDictionaries = Boolean(editor.clientId && editor.clientSecret);\n\n if (!hasRemoteDictionaries) return [];\n\n try {\n options?.onStartRemoteCheck?.();\n\n const intlayerAPI = getIntlayerAPIProxy(undefined, configuration);\n\n // Get the list of dictionary keys\n const getDictionariesKeysResult =\n await intlayerAPI.dictionary.getDictionariesUpdateTimestamp();\n\n const distantDictionaryUpdateTimeStamp: Record<string, number> | null =\n getDictionariesKeysResult.data;\n\n if (!distantDictionaryUpdateTimeStamp) {\n throw new Error('No distant dictionaries found');\n }\n\n const dictionariesKeysToFetch = Object.entries(\n distantDictionaryUpdateTimeStamp\n )\n .filter(([dictionaryKey, remoteUpdatedAt]) => {\n // If remote doesn't provide updatedAt, fetch to be safe\n if (!remoteUpdatedAt) return true;\n\n // If no local cache exists, fetch\n const local = (remoteDictionariesRecord as any)[dictionaryKey];\n if (!local) return true;\n\n const localUpdatedAtRaw = (local as any)?.updatedAt as\n | number\n | string\n | undefined;\n const localUpdatedAt =\n typeof localUpdatedAtRaw === 'number'\n ? localUpdatedAtRaw\n : localUpdatedAtRaw\n ? new Date(localUpdatedAtRaw).getTime()\n : undefined;\n\n // If local timestamp missing or older than remote, fetch\n if (typeof localUpdatedAt !== 'number') return true;\n return remoteUpdatedAt > localUpdatedAt;\n })\n .map(([dictionaryKey]) => dictionaryKey);\n\n const cachedDictionaries = Object.entries(remoteDictionariesRecord)\n .filter(([key, dictionary]) => {\n const remoteUpdatedAt = distantDictionaryUpdateTimeStamp[key];\n const localUpdatedAtRaw = (dictionary as any)?.updatedAt as\n | number\n | string\n | undefined;\n const localUpdatedAt =\n typeof localUpdatedAtRaw === 'number'\n ? localUpdatedAtRaw\n : localUpdatedAtRaw\n ? new Date(localUpdatedAtRaw).getTime()\n : undefined;\n // Consider as cached/imported when local exists and is up-to-date or newer\n return (\n typeof localUpdatedAt === 'number' &&\n typeof remoteUpdatedAt === 'number' &&\n localUpdatedAt >= remoteUpdatedAt\n );\n })\n .map(([, dictionary]) => dictionary as any);\n\n // Report cached as already imported\n if (cachedDictionaries.length > 0) {\n onStatusUpdate?.(\n cachedDictionaries.map((d) => ({\n dictionaryKey: d.key,\n type: 'remote',\n status: 'imported',\n }))\n );\n }\n\n const orderedDistantDictionaryKeys =\n dictionariesKeysToFetch.sort(sortAlphabetically);\n\n // Report pending for keys to be fetched so totals are visible immediately\n if (orderedDistantDictionaryKeys.length > 0) {\n onStatusUpdate?.(\n orderedDistantDictionaryKeys.map((key) => ({\n dictionaryKey: key,\n type: 'remote',\n status: 'pending',\n }))\n );\n }\n\n const distantDictionariesData = await fetchDistantDictionaries(\n {\n dictionaryKeys: orderedDistantDictionaryKeys,\n },\n onStatusUpdate\n );\n\n const distantDictionaries: DictionaryAPI[] = formatDistantDictionaries(\n distantDictionariesData\n );\n\n return [...cachedDictionaries, ...distantDictionaries];\n } catch (error) {\n options?.onError?.(error as Error);\n return [];\n } finally {\n options?.onStopRemoteCheck?.();\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAoC;AAGpC,oBAAiC;AAEjC,uCAAsC;AACtC,sCAAyC;AAEzC,gCAAmC;AAE5B,MAAM,4BAA4B,CACvC,iBAEA,aAAa,IAAI,CAAC,UAAU;AAAA,EAC1B,GAAG;AAAA,EACH,SAAS,GAAG,KAAK,GAAG,aAAa,KAAK,EAAE;AAAA,EACxC,UAAU;AACZ,EAAE;AAEG,MAAM,yBAAyB,OACpC,oBAAgB,gCAAiB,GACjC,gBACA,YAK6B;AAC7B,QAAM,EAAE,OAAO,IAAI;AACnB,QAAM,+BAA2B,wDAAsB,aAAa;AAEpE,QAAM,wBAAwB,QAAQ,OAAO,YAAY,OAAO,YAAY;AAE5E,MAAI,CAAC,sBAAuB,QAAO,CAAC;AAEpC,MAAI;AACF,aAAS,qBAAqB;AAE9B,UAAM,kBAAc,gCAAoB,QAAW,aAAa;AAGhE,UAAM,4BACJ,MAAM,YAAY,WAAW,+BAA+B;AAE9D,UAAM,mCACJ,0BAA0B;AAE5B,QAAI,CAAC,kCAAkC;AACrC,YAAM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,UAAM,0BAA0B,UAAM;AAAA,MACpC;AAAA,QACE,gBAAgB;AAAA,MAClB;AAAA,MACA;AAAA,IACF;AAEA,UAAM,sBAAuC;AAAA,MAC3C;AAAA,IACF;AAEA,WAAO,CAAC,GAAG,oBAAoB,GAAG,mBAAmB;AAAA,EACvD,SAAS,OAAO;AACd,aAAS,UAAU,KAAc;AACjC,WAAO,CAAC;AAAA,EACV,UAAE;AACA,aAAS,oBAAoB;AAAA,EAC/B;AACF;","names":[]}
|
|
@@ -22,6 +22,7 @@ __export(log_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(log_exports);
|
|
24
24
|
var import_config = require("@intlayer/config");
|
|
25
|
+
var import_extractErrorMessage = require('../utils/extractErrorMessage.cjs');
|
|
25
26
|
class DictionariesLogger {
|
|
26
27
|
statuses = [];
|
|
27
28
|
spinnerTimer = null;
|
|
@@ -33,7 +34,7 @@ class DictionariesLogger {
|
|
|
33
34
|
lastRenderedState = "";
|
|
34
35
|
remoteCheckInProgress = false;
|
|
35
36
|
expectRemote = false;
|
|
36
|
-
remoteError
|
|
37
|
+
remoteError;
|
|
37
38
|
constructor() {
|
|
38
39
|
const configuration = (0, import_config.getConfiguration)();
|
|
39
40
|
this.prefix = configuration.log.prefix;
|
|
@@ -86,8 +87,9 @@ class DictionariesLogger {
|
|
|
86
87
|
clearInterval(this.spinnerTimer);
|
|
87
88
|
this.spinnerTimer = null;
|
|
88
89
|
}
|
|
89
|
-
setRemoteError = (
|
|
90
|
-
this.remoteError =
|
|
90
|
+
setRemoteError = (error) => {
|
|
91
|
+
this.remoteError = (0, import_extractErrorMessage.extractErrorMessage)(error);
|
|
92
|
+
this.stopRemoteCheck();
|
|
91
93
|
this.render();
|
|
92
94
|
};
|
|
93
95
|
render() {
|
|
@@ -101,30 +103,33 @@ class DictionariesLogger {
|
|
|
101
103
|
if (!suppressLocalWhileCheckingRemote) {
|
|
102
104
|
if (isLocalDone) {
|
|
103
105
|
lines.push(
|
|
104
|
-
`${this.prefix} ${import_config.v} Local
|
|
106
|
+
`${this.prefix} ${import_config.v} Local content: ${(0, import_config.colorize)(`${localDone}`, import_config.ANSIColors.GREEN)}${(0, import_config.colorize)(`/${localTotal}`, import_config.ANSIColors.GREY)}`
|
|
105
107
|
);
|
|
106
108
|
} else {
|
|
107
109
|
lines.push(
|
|
108
|
-
`${this.prefix} ${clock} Local
|
|
110
|
+
`${this.prefix} ${clock} Local content: ${(0, import_config.colorize)(`${localDone}`, import_config.ANSIColors.BLUE)}${(0, import_config.colorize)(`/${localTotal}`, import_config.ANSIColors.GREY)}`
|
|
109
111
|
);
|
|
110
112
|
}
|
|
111
113
|
}
|
|
112
114
|
if (remoteTotal > 0 || this.remoteCheckInProgress || this.remoteError) {
|
|
113
115
|
if (this.remoteError) {
|
|
114
116
|
lines.push(
|
|
115
|
-
`${this.prefix} ${import_config.x} Remote
|
|
117
|
+
`${this.prefix} ${import_config.x} Remote content: ${(0, import_config.colorize)(
|
|
118
|
+
this.remoteError,
|
|
119
|
+
import_config.ANSIColors.RED
|
|
120
|
+
)}`
|
|
116
121
|
);
|
|
117
122
|
} else if (remoteTotal === 0) {
|
|
118
123
|
lines.push(
|
|
119
|
-
`${this.prefix} ${clock} Remote
|
|
124
|
+
`${this.prefix} ${clock} Remote content: ${(0, import_config.colorize)("Check server", import_config.ANSIColors.BLUE)}`
|
|
120
125
|
);
|
|
121
126
|
} else if (isRemoteDone) {
|
|
122
127
|
lines.push(
|
|
123
|
-
`${this.prefix} ${import_config.v} Remote
|
|
128
|
+
`${this.prefix} ${import_config.v} Remote content: ${(0, import_config.colorize)(`${remoteDone}`, import_config.ANSIColors.GREEN)}${(0, import_config.colorize)(`/${remoteTotal}`, import_config.ANSIColors.GREY)}`
|
|
124
129
|
);
|
|
125
130
|
} else {
|
|
126
131
|
lines.push(
|
|
127
|
-
`${this.prefix} ${clock} Remote
|
|
132
|
+
`${this.prefix} ${clock} Remote content: ${(0, import_config.colorize)(`${remoteDone}`, import_config.ANSIColors.BLUE)}${(0, import_config.colorize)(`/${remoteTotal}`, import_config.ANSIColors.GREY)}`
|
|
128
133
|
);
|
|
129
134
|
}
|
|
130
135
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/loadDictionaries/log.ts"],"sourcesContent":["import {\n ANSIColors,\n colorize,\n getConfiguration,\n spinnerFrames,\n v,\n x,\n} from '@intlayer/config';\nimport type { DictionariesStatus } from './loadDictionaries';\n\nexport class DictionariesLogger {\n private statuses: DictionariesStatus[] = [];\n private spinnerTimer: NodeJS.Timeout | null = null;\n private spinnerIndex = 0;\n private renderedLines = 0;\n private readonly spinnerFrames = spinnerFrames;\n private isFinished = false;\n private readonly prefix: string;\n private lastRenderedState: string = '';\n private remoteCheckInProgress = false;\n private expectRemote = false;\n private remoteError = false;\n\n constructor() {\n const configuration = getConfiguration();\n this.prefix = configuration.log.prefix;\n }\n\n setExpectRemote(expect: boolean) {\n this.expectRemote = expect;\n }\n\n startRemoteCheck() {\n if (this.isFinished) return;\n this.remoteCheckInProgress = true;\n this.startSpinner();\n this.render();\n }\n\n stopRemoteCheck() {\n this.remoteCheckInProgress = false;\n }\n\n update(newStatuses: DictionariesStatus[]) {\n if (this.isFinished) return;\n for (const status of newStatuses) {\n const index = this.statuses.findIndex(\n (s) =>\n s.dictionaryKey === status.dictionaryKey && s.type === status.type\n );\n if (index >= 0) {\n this.statuses[index] = status;\n } else {\n this.statuses.push(status);\n }\n }\n\n // If we expect remote fetch later, avoid rendering a local-only line first\n const { remoteTotal } = this.computeProgress();\n if (this.expectRemote && !this.remoteCheckInProgress && remoteTotal === 0) {\n // Do not start spinner or render yet; wait until remote check starts\n return;\n }\n\n this.startSpinner();\n this.render();\n }\n\n finish() {\n this.isFinished = true;\n this.stopSpinner();\n // Render final state and keep it visible\n this.render();\n }\n\n private startSpinner() {\n if (this.spinnerTimer || this.isFinished) return;\n this.spinnerTimer = setInterval(() => {\n this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;\n this.render();\n }, 100);\n }\n\n private stopSpinner() {\n if (!this.spinnerTimer) return;\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n }\n\n public setRemoteError = (_error?: Error) => {\n this.remoteError = true;\n this.render();\n };\n\n private render() {\n const { localTotal, localDone, remoteTotal, remoteDone } =\n this.computeProgress();\n\n const frame = this.spinnerFrames[this.spinnerIndex];\n const clock = colorize(frame, ANSIColors.BLUE);\n const lines: string[] = [];\n\n const isLocalDone = localDone === localTotal;\n const isRemoteDone = remoteDone === remoteTotal;\n\n const suppressLocalWhileCheckingRemote =\n this.expectRemote && this.remoteCheckInProgress && remoteTotal === 0;\n\n if (!suppressLocalWhileCheckingRemote) {\n if (isLocalDone) {\n lines.push(\n `${this.prefix} ${v} Local dictionaries: ${colorize(`${localDone}`, ANSIColors.GREEN)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Local dictionaries: ${colorize(`${localDone}`, ANSIColors.BLUE)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Single remote line: show error, check, or progress counts\n if (remoteTotal > 0 || this.remoteCheckInProgress || this.remoteError) {\n if (this.remoteError) {\n lines.push(\n `${this.prefix} ${x} Remote dictionaries: ${colorize('Failed to fetch', ANSIColors.RED)}`\n );\n } else if (remoteTotal === 0) {\n lines.push(\n `${this.prefix} ${clock} Remote dictionaries: ${colorize('Check server', ANSIColors.BLUE)}`\n );\n } else if (isRemoteDone) {\n lines.push(\n `${this.prefix} ${v} Remote dictionaries: ${colorize(`${remoteDone}`, ANSIColors.GREEN)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Remote dictionaries: ${colorize(`${remoteDone}`, ANSIColors.BLUE)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Check if the state has changed to avoid duplicate rendering\n const currentState = lines.join('\\n');\n if (currentState === this.lastRenderedState) {\n return;\n }\n this.lastRenderedState = currentState;\n\n if (this.renderedLines > 0) {\n process.stdout.write(`\\x1b[${this.renderedLines}F`);\n }\n\n const totalLinesToClear = Math.max(this.renderedLines, lines.length);\n for (let i = 0; i < totalLinesToClear; i++) {\n process.stdout.write('\\x1b[2K');\n const line = lines[i];\n if (line !== undefined) {\n process.stdout.write(line);\n }\n process.stdout.write('\\n');\n }\n\n this.renderedLines = lines.length;\n }\n\n private computeProgress() {\n const localKeys = new Set(\n this.statuses\n .filter((s) => s.type === 'local')\n .map((s) => s.dictionaryKey)\n );\n\n const localDoneKeys = new Set(\n this.statuses\n .filter(\n (s) =>\n s.type === 'local' && (s.status === 'built' || s.status === 'error')\n )\n .map((s) => s.dictionaryKey)\n );\n\n const remoteKeys = new Set(\n this.statuses\n .filter((s) => s.type === 'remote')\n .map((s) => s.dictionaryKey)\n );\n\n const remoteDoneKeys = new Set(\n this.statuses\n .filter(\n (s) =>\n s.type === 'remote' &&\n (s.status === 'fetched' ||\n s.status === 'imported' ||\n s.status === 'error')\n )\n .map((s) => s.dictionaryKey)\n );\n\n return {\n localTotal: localKeys.size,\n localDone: localDoneKeys.size,\n remoteTotal: remoteKeys.size,\n remoteDone: remoteDoneKeys.size,\n } as const;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAOO;AAGA,MAAM,mBAAmB;AAAA,EACtB,WAAiC,CAAC;AAAA,EAClC,eAAsC;AAAA,EACtC,eAAe;AAAA,EACf,gBAAgB;AAAA,EACP,gBAAgB;AAAA,EACzB,aAAa;AAAA,EACJ;AAAA,EACT,oBAA4B;AAAA,EAC5B,wBAAwB;AAAA,EACxB,eAAe;AAAA,EACf,cAAc;AAAA,EAEtB,cAAc;AACZ,UAAM,oBAAgB,gCAAiB;AACvC,SAAK,SAAS,cAAc,IAAI;AAAA,EAClC;AAAA,EAEA,gBAAgB,QAAiB;AAC/B,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cACb,EAAE,WAAW;AAAA,MACnB,EACC,IAAI,CAAC,MAAM,EAAE,aAAa;AAAA,IAC/B;AAEA,WAAO;AAAA,MACL,YAAY,UAAU;AAAA,MACtB,WAAW,cAAc;AAAA,MACzB,aAAa,WAAW;AAAA,MACxB,YAAY,eAAe;AAAA,IAC7B;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/loadDictionaries/log.ts"],"sourcesContent":["import {\n ANSIColors,\n colorize,\n getConfiguration,\n spinnerFrames,\n v,\n x,\n} from '@intlayer/config';\nimport { extractErrorMessage } from '../utils/extractErrorMessage';\nimport type { DictionariesStatus } from './loadDictionaries';\n\nexport class DictionariesLogger {\n private statuses: DictionariesStatus[] = [];\n private spinnerTimer: NodeJS.Timeout | null = null;\n private spinnerIndex = 0;\n private renderedLines = 0;\n private readonly spinnerFrames = spinnerFrames;\n private isFinished = false;\n private readonly prefix: string;\n private lastRenderedState: string = '';\n private remoteCheckInProgress = false;\n private expectRemote = false;\n private remoteError: string | undefined;\n\n constructor() {\n const configuration = getConfiguration();\n this.prefix = configuration.log.prefix;\n }\n\n setExpectRemote(expect: boolean) {\n this.expectRemote = expect;\n }\n\n startRemoteCheck() {\n if (this.isFinished) return;\n this.remoteCheckInProgress = true;\n this.startSpinner();\n this.render();\n }\n\n stopRemoteCheck() {\n this.remoteCheckInProgress = false;\n }\n\n update(newStatuses: DictionariesStatus[]) {\n if (this.isFinished) return;\n for (const status of newStatuses) {\n const index = this.statuses.findIndex(\n (s) =>\n s.dictionaryKey === status.dictionaryKey && s.type === status.type\n );\n if (index >= 0) {\n this.statuses[index] = status;\n } else {\n this.statuses.push(status);\n }\n }\n\n // If we expect remote fetch later, avoid rendering a local-only line first\n const { remoteTotal } = this.computeProgress();\n if (this.expectRemote && !this.remoteCheckInProgress && remoteTotal === 0) {\n // Do not start spinner or render yet; wait until remote check starts\n return;\n }\n\n this.startSpinner();\n this.render();\n }\n\n finish() {\n this.isFinished = true;\n this.stopSpinner();\n // Render final state and keep it visible\n this.render();\n }\n\n private startSpinner() {\n if (this.spinnerTimer || this.isFinished) return;\n this.spinnerTimer = setInterval(() => {\n this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;\n this.render();\n }, 100);\n }\n\n private stopSpinner() {\n if (!this.spinnerTimer) return;\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n }\n\n public setRemoteError = (error?: Error) => {\n this.remoteError = extractErrorMessage(error);\n // Avoid rendering a transient remote-only line while the remote check flag is still true\n // Ensure local + remote are rendered together after a failure\n this.stopRemoteCheck();\n this.render();\n };\n\n private render() {\n const { localTotal, localDone, remoteTotal, remoteDone } =\n this.computeProgress();\n\n const frame = this.spinnerFrames[this.spinnerIndex];\n const clock = colorize(frame, ANSIColors.BLUE);\n const lines: string[] = [];\n\n const isLocalDone = localDone === localTotal;\n const isRemoteDone = remoteDone === remoteTotal;\n\n const suppressLocalWhileCheckingRemote =\n this.expectRemote && this.remoteCheckInProgress && remoteTotal === 0;\n\n if (!suppressLocalWhileCheckingRemote) {\n if (isLocalDone) {\n lines.push(\n `${this.prefix} ${v} Local content: ${colorize(`${localDone}`, ANSIColors.GREEN)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Local content: ${colorize(`${localDone}`, ANSIColors.BLUE)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Single remote line: show error, check, or progress counts\n if (remoteTotal > 0 || this.remoteCheckInProgress || this.remoteError) {\n if (this.remoteError) {\n lines.push(\n `${this.prefix} ${x} Remote content: ${colorize(\n this.remoteError,\n ANSIColors.RED\n )}`\n );\n } else if (remoteTotal === 0) {\n lines.push(\n `${this.prefix} ${clock} Remote content: ${colorize('Check server', ANSIColors.BLUE)}`\n );\n } else if (isRemoteDone) {\n lines.push(\n `${this.prefix} ${v} Remote content: ${colorize(`${remoteDone}`, ANSIColors.GREEN)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Remote content: ${colorize(`${remoteDone}`, ANSIColors.BLUE)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Check if the state has changed to avoid duplicate rendering\n const currentState = lines.join('\\n');\n if (currentState === this.lastRenderedState) {\n return;\n }\n this.lastRenderedState = currentState;\n\n if (this.renderedLines > 0) {\n process.stdout.write(`\\x1b[${this.renderedLines}F`);\n }\n\n const totalLinesToClear = Math.max(this.renderedLines, lines.length);\n for (let i = 0; i < totalLinesToClear; i++) {\n process.stdout.write('\\x1b[2K');\n const line = lines[i];\n if (line !== undefined) {\n process.stdout.write(line);\n }\n process.stdout.write('\\n');\n }\n\n this.renderedLines = lines.length;\n }\n\n private computeProgress() {\n const localKeys = new Set(\n this.statuses\n .filter((s) => s.type === 'local')\n .map((s) => s.dictionaryKey)\n );\n\n const localDoneKeys = new Set(\n this.statuses\n .filter(\n (s) =>\n s.type === 'local' && (s.status === 'built' || s.status === 'error')\n )\n .map((s) => s.dictionaryKey)\n );\n\n const remoteKeys = new Set(\n this.statuses\n .filter((s) => s.type === 'remote')\n .map((s) => s.dictionaryKey)\n );\n\n const remoteDoneKeys = new Set(\n this.statuses\n .filter(\n (s) =>\n s.type === 'remote' &&\n (s.status === 'fetched' ||\n s.status === 'imported' ||\n s.status === 'error')\n )\n .map((s) => s.dictionaryKey)\n );\n\n return {\n localTotal: localKeys.size,\n localDone: localDoneKeys.size,\n remoteTotal: remoteKeys.size,\n remoteDone: remoteDoneKeys.size,\n } as const;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAOO;AACP,iCAAoC;AAG7B,MAAM,mBAAmB;AAAA,EACtB,WAAiC,CAAC;AAAA,EAClC,eAAsC;AAAA,EACtC,eAAe;AAAA,EACf,gBAAgB;AAAA,EACP,gBAAgB;AAAA,EACzB,aAAa;AAAA,EACJ;AA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,aAAa,IAAI;AAAA,MACrB,KAAK,SACF,OAAO,CAAC,MAAM,EAAE,SAAS,QAAQ,EACjC,IAAI,CAAC,MAAM,EAAE,aAAa;AAAA,IAC/B;AAEA,UAAM,iBAAiB,IAAI;AAAA,MACzB,KAAK,SACF;AAAA,QACC,CAAC,MACC,EAAE,SAAS,aACV,EAAE,WAAW,aACZ,EAAE,WAAW,cACb,EAAE,WAAW;AAAA,MACnB,EACC,IAAI,CAAC,MAAM,EAAE,aAAa;AAAA,IAC/B;AAEA,WAAO;AAAA,MACL,YAAY,UAAU;AAAA,MACtB,WAAW,cAAc;AAAA,MACzB,aAAa,WAAW;AAAA,MACxB,YAAY,eAAe;AAAA,IAC7B;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
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
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var prepareIntlayer_exports = {};
|
|
20
30
|
__export(prepareIntlayer_exports, {
|
|
@@ -22,6 +32,7 @@ __export(prepareIntlayer_exports, {
|
|
|
22
32
|
});
|
|
23
33
|
module.exports = __toCommonJS(prepareIntlayer_exports);
|
|
24
34
|
var import_config = require("@intlayer/config");
|
|
35
|
+
var import_package = __toESM(require("@intlayer/config/package.json"));
|
|
25
36
|
var import_cleanOutputDir = require('./cleanOutputDir.cjs');
|
|
26
37
|
var import_listDictionariesPath = require('./listDictionariesPath.cjs');
|
|
27
38
|
var import_loadDictionaries = require('./loadDictionaries/loadDictionaries.cjs');
|
|
@@ -33,6 +44,10 @@ var import_writeConfiguration = require('./writeConfiguration/index.cjs');
|
|
|
33
44
|
const prepareIntlayer = async (configuration = (0, import_config.getConfiguration)(), projectRequire = import_config.ESMxCJSRequire, clean = false) => {
|
|
34
45
|
const appLogger = (0, import_config.getAppLogger)(configuration);
|
|
35
46
|
const preparationStartMs = Date.now();
|
|
47
|
+
appLogger([
|
|
48
|
+
"Preparing Intlayer",
|
|
49
|
+
(0, import_config.colorize)(`(v${import_package.default.version})`, import_config.ANSIColors.GREY_DARK)
|
|
50
|
+
]);
|
|
36
51
|
if (clean) {
|
|
37
52
|
(0, import_cleanOutputDir.cleanOutputDir)(configuration);
|
|
38
53
|
}
|
|
@@ -43,15 +58,20 @@ const prepareIntlayer = async (configuration = (0, import_config.getConfiguratio
|
|
|
43
58
|
projectRequire
|
|
44
59
|
);
|
|
45
60
|
const dictionariesLoadedTime = Date.now();
|
|
46
|
-
appLogger(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
61
|
+
appLogger(
|
|
62
|
+
[
|
|
63
|
+
"Content loaded",
|
|
64
|
+
(0, import_config.colorize)(
|
|
65
|
+
[
|
|
66
|
+
dictionaries.remoteDictionaries.length > 0 ? ` (Total: ${dictionariesLoadedTime - preparationStartMs}ms - Local: ${dictionaries.time.localDictionaries}ms - Remote: ${dictionaries.time.remoteDictionaries}ms)` : `(${dictionariesLoadedTime - preparationStartMs}ms)`
|
|
67
|
+
].join(""),
|
|
68
|
+
import_config.ANSIColors.GREY_DARK
|
|
69
|
+
)
|
|
70
|
+
],
|
|
71
|
+
{
|
|
72
|
+
isVerbose: true
|
|
73
|
+
}
|
|
74
|
+
);
|
|
55
75
|
const dictionariesOutput = await (0, import_buildIntlayerDictionary.buildDictionary)(
|
|
56
76
|
[...dictionaries.localDictionaries, ...dictionaries.remoteDictionaries],
|
|
57
77
|
configuration
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import {\n ANSIColors,\n ESMxCJSRequire,\n type IntlayerConfig,\n colorize,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { listDictionaries } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { createDictionaryEntryPoint } from './transpiler/dictionary_to_main/createDictionaryEntryPoint';\nimport {\n createModuleAugmentation,\n createTypes,\n} from './transpiler/dictionary_to_type/index';\nimport { buildDictionary } from './transpiler/intlayer_dictionary/buildIntlayerDictionary';\nimport { writeRemoteDictionary } from './transpiler/intlayer_dictionary/writeRemoteDictionary';\nimport { writeConfiguration } from './writeConfiguration';\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire,\n clean = false\n) => {\n const appLogger = getAppLogger(configuration);\n const preparationStartMs = Date.now();\n\n if (clean) {\n cleanOutputDir(configuration);\n }\n\n const files: string[] = listDictionaries(configuration);\n\n const dictionaries = await loadDictionaries(\n files,\n configuration,\n projectRequire\n );\n\n const dictionariesLoadedTime = Date.now();\n\n appLogger([\n
|
|
1
|
+
{"version":3,"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import {\n ANSIColors,\n ESMxCJSRequire,\n type IntlayerConfig,\n colorize,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport packageJson from '@intlayer/config/package.json' with { type: 'json' };\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { listDictionaries } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { createDictionaryEntryPoint } from './transpiler/dictionary_to_main/createDictionaryEntryPoint';\nimport {\n createModuleAugmentation,\n createTypes,\n} from './transpiler/dictionary_to_type/index';\nimport { buildDictionary } from './transpiler/intlayer_dictionary/buildIntlayerDictionary';\nimport { writeRemoteDictionary } from './transpiler/intlayer_dictionary/writeRemoteDictionary';\nimport { writeConfiguration } from './writeConfiguration';\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire,\n clean = false\n) => {\n const appLogger = getAppLogger(configuration);\n const preparationStartMs = Date.now();\n\n appLogger([\n 'Preparing Intlayer',\n colorize(`(v${packageJson.version})`, ANSIColors.GREY_DARK),\n ]);\n\n if (clean) {\n cleanOutputDir(configuration);\n }\n\n const files: string[] = listDictionaries(configuration);\n\n const dictionaries = await loadDictionaries(\n files,\n configuration,\n projectRequire\n );\n\n const dictionariesLoadedTime = Date.now();\n\n appLogger(\n [\n 'Content loaded',\n colorize(\n [\n dictionaries.remoteDictionaries.length > 0\n ? ` (Total: ${dictionariesLoadedTime - preparationStartMs}ms - Local: ${dictionaries.time.localDictionaries}ms - Remote: ${dictionaries.time.remoteDictionaries}ms)`\n : `(${dictionariesLoadedTime - preparationStartMs}ms)`,\n ].join(''),\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Build local dictionaries\n const dictionariesOutput = await buildDictionary(\n [...dictionaries.localDictionaries, ...dictionaries.remoteDictionaries],\n configuration\n );\n\n // Write remote dictionaries\n // Used as cache for next fetch\n await writeRemoteDictionary(dictionaries.remoteDictionaries, configuration);\n\n const dictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n await createTypes(dictionariesPaths);\n\n await createDictionaryEntryPoint(configuration);\n\n const dictionariesBuiltTime = Date.now();\n\n appLogger([\n 'Dictionaries built',\n colorize(\n `(${dictionariesBuiltTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ]);\n\n await createModuleAugmentation(configuration);\n\n const moduleAugmentationBuiltTime = Date.now();\n\n appLogger(\n [\n 'Module augmentation built',\n colorize(\n `(${moduleAugmentationBuiltTime - dictionariesBuiltTime}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n await writeConfiguration(configuration);\n\n const configurationWrittenTime = Date.now();\n\n appLogger(\n [\n 'Configuration written',\n colorize(\n `(${configurationWrittenTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n const preparationElapsedMs = Date.now() - preparationStartMs;\n appLogger([`Done`, colorize(`${preparationElapsedMs}ms`, ANSIColors.GREEN)], {\n level: 'info',\n isVerbose: true,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAOO;AACP,qBAAwB;AACxB,4BAA+B;AAC/B,kCAAiC;AACjC,8BAAiC;AACjC,wCAA2C;AAC3C,gCAGO;AACP,qCAAgC;AAChC,mCAAsC;AACtC,gCAAmC;AAE5B,MAAM,kBAAkB,OAC7B,oBAAgC,gCAAiB,GACjD,iBAAiB,8BACjB,QAAQ,UACL;AACH,QAAM,gBAAY,4BAAa,aAAa;AAC5C,QAAM,qBAAqB,KAAK,IAAI;AAEpC,YAAU;AAAA,IACR;AAAA,QACA,wBAAS,KAAK,eAAAA,QAAY,OAAO,KAAK,yBAAW,SAAS;AAAA,EAC5D,CAAC;AAED,MAAI,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K,IAAI;AAE1C;AAAA,IACE;AAAA,MACE;AAAA,UACA;AAAA,QACE,IAAI,2BAA2B,kBAAkB;AAAA,QACjD,yBAAW;AAAA,MACb;AAAA,IACF;AAAA,IACA;AAAA,MACE,WAAW;AAAA,IACb;AAAA,EACF;AAEA,QAAM,uBAAuB,KAAK,IAAI,IAAI;AAC1C,YAAU,CAAC,YAAQ,wBAAS,GAAG,oBAAoB,MAAM,yBAAW,KAAK,CAAC,GAAG;AAAA,IAC3E,OAAO;AAAA,IACP,WAAW;AAAA,EACb,CAAC;AACH;","names":["packageJson"]}
|
|
@@ -38,8 +38,13 @@ const filterDictionaries = (paths, keys) => {
|
|
|
38
38
|
(path) => keys.some((key) => path.endsWith(`${key}.json`))
|
|
39
39
|
);
|
|
40
40
|
};
|
|
41
|
-
const writeDictionaryFiles = async (paths, fileName, format, configuration = (0, import_config.getConfiguration)()) => {
|
|
42
|
-
const content = (0, import_generateDictionaryListContent.generateDictionaryListContent)(
|
|
41
|
+
const writeDictionaryFiles = async (paths, fileName, functionName, format, configuration = (0, import_config.getConfiguration)()) => {
|
|
42
|
+
const content = (0, import_generateDictionaryListContent.generateDictionaryListContent)(
|
|
43
|
+
paths,
|
|
44
|
+
functionName,
|
|
45
|
+
format,
|
|
46
|
+
configuration
|
|
47
|
+
);
|
|
43
48
|
const extension = format === "cjs" ? "cjs" : "mjs";
|
|
44
49
|
const { mainDir } = configuration.content;
|
|
45
50
|
await (0, import_writeFileIfChanged.writeFileIfChanged)(
|
|
@@ -47,7 +52,8 @@ const writeDictionaryFiles = async (paths, fileName, format, configuration = (0,
|
|
|
47
52
|
content
|
|
48
53
|
);
|
|
49
54
|
};
|
|
50
|
-
const createDictionaryEntryPoint = async (configuration = (0, import_config.getConfiguration)(), dictionariesKeys, formats
|
|
55
|
+
const createDictionaryEntryPoint = async (configuration = (0, import_config.getConfiguration)(), dictionariesKeys, formats) => {
|
|
56
|
+
const outputFormats = formats ?? configuration.build.outputFormat;
|
|
51
57
|
const { mainDir } = configuration.content;
|
|
52
58
|
await (0, import_promises.mkdir)(mainDir, { recursive: true });
|
|
53
59
|
const remoteDictionariesPath = (0, import_getBuiltRemoteDictionariesPath.getBuiltRemoteDictionariesPath)(configuration);
|
|
@@ -57,35 +63,40 @@ const createDictionaryEntryPoint = async (configuration = (0, import_config.getC
|
|
|
57
63
|
);
|
|
58
64
|
const unmergedDictionariesPath = (0, import_getBuiltUnmergedDictionariesPath.getBuiltUnmergedDictionariesPath)(configuration);
|
|
59
65
|
const writeOperations = [
|
|
60
|
-
...
|
|
66
|
+
...outputFormats.map((format) => ({
|
|
61
67
|
paths: remoteDictionariesPath,
|
|
68
|
+
functionName: "getRemoteDictionaries",
|
|
62
69
|
fileName: "remote_dictionaries",
|
|
63
70
|
format
|
|
64
71
|
})),
|
|
65
|
-
...
|
|
72
|
+
...outputFormats.map((format) => ({
|
|
66
73
|
paths: dictionariesPath,
|
|
74
|
+
functionName: "getDictionaries",
|
|
67
75
|
fileName: "dictionaries",
|
|
68
76
|
format
|
|
69
77
|
})),
|
|
70
|
-
...
|
|
78
|
+
...outputFormats.map((format) => ({
|
|
71
79
|
paths: unmergedDictionariesPath,
|
|
80
|
+
functionName: "getUnmergedDictionaries",
|
|
72
81
|
fileName: "unmerged_dictionaries",
|
|
73
82
|
format
|
|
74
83
|
})),
|
|
75
|
-
...
|
|
84
|
+
...outputFormats.map((format) => ({
|
|
76
85
|
paths: (0, import_getBuiltDynamicDictionariesPath.getBuiltDynamicDictionariesPath)(configuration, format),
|
|
86
|
+
functionName: "getDynamicDictionaries",
|
|
77
87
|
fileName: "dynamic_dictionaries",
|
|
78
88
|
format
|
|
79
89
|
})),
|
|
80
|
-
...
|
|
90
|
+
...outputFormats.map((format) => ({
|
|
81
91
|
paths: (0, import_getBuiltFetchDictionariesPath.getBuiltFetchDictionariesPath)(configuration, format),
|
|
92
|
+
functionName: "getFetchDictionaries",
|
|
82
93
|
fileName: "fetch_dictionaries",
|
|
83
94
|
format
|
|
84
95
|
}))
|
|
85
96
|
];
|
|
86
97
|
await (0, import_parallelize.parallelize)(
|
|
87
98
|
writeOperations,
|
|
88
|
-
async ({ paths, fileName, format }) => writeDictionaryFiles(paths, fileName, format, configuration)
|
|
99
|
+
async ({ paths, fileName, format, functionName }) => writeDictionaryFiles(paths, fileName, functionName, format, configuration)
|
|
89
100
|
);
|
|
90
101
|
};
|
|
91
102
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/createDictionaryEntryPoint.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { mkdir } from 'fs/promises';\nimport { resolve } from 'path';\nimport { getBuiltDictionariesPath } from '../../getBuiltDictionariesPath';\nimport { getBuiltDynamicDictionariesPath } from '../../getBuiltDynamicDictionariesPath';\nimport { getBuiltFetchDictionariesPath } from '../../getBuiltFetchDictionariesPath';\nimport { getBuiltRemoteDictionariesPath } from '../../getBuiltRemoteDictionariesPath';\nimport { getBuiltUnmergedDictionariesPath } from '../../getBuiltUnmergedDictionariesPath';\nimport { parallelize } from '../../utils/parallelize';\nimport { writeFileIfChanged } from '../../writeFileIfChanged';\nimport { generateDictionaryListContent } from './generateDictionaryListContent';\n\nconst filterDictionaries = (paths: string[], keys?: string[]) => {\n if (!keys) return paths;\n return paths.filter((path) =>\n keys.some((key) => path.endsWith(`${key}.json`))\n );\n};\n\nconst writeDictionaryFiles = async (\n paths: string[],\n fileName: string,\n format: 'cjs' | 'esm',\n configuration = getConfiguration()\n) => {\n const content = generateDictionaryListContent(paths
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/createDictionaryEntryPoint.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { mkdir } from 'fs/promises';\nimport { resolve } from 'path';\nimport { getBuiltDictionariesPath } from '../../getBuiltDictionariesPath';\nimport { getBuiltDynamicDictionariesPath } from '../../getBuiltDynamicDictionariesPath';\nimport { getBuiltFetchDictionariesPath } from '../../getBuiltFetchDictionariesPath';\nimport { getBuiltRemoteDictionariesPath } from '../../getBuiltRemoteDictionariesPath';\nimport { getBuiltUnmergedDictionariesPath } from '../../getBuiltUnmergedDictionariesPath';\nimport { parallelize } from '../../utils/parallelize';\nimport { writeFileIfChanged } from '../../writeFileIfChanged';\nimport { generateDictionaryListContent } from './generateDictionaryListContent';\n\nconst filterDictionaries = (paths: string[], keys?: string[]) => {\n if (!keys) return paths;\n return paths.filter((path) =>\n keys.some((key) => path.endsWith(`${key}.json`))\n );\n};\n\nconst writeDictionaryFiles = async (\n paths: string[],\n fileName: string,\n functionName: string,\n format: 'cjs' | 'esm',\n configuration = getConfiguration()\n) => {\n const content = generateDictionaryListContent(\n paths,\n functionName,\n format,\n configuration\n );\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const { mainDir } = configuration.content;\n\n await writeFileIfChanged(\n resolve(mainDir, `${fileName}.${extension}`),\n content\n );\n};\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const createDictionaryEntryPoint = async (\n configuration = getConfiguration(),\n dictionariesKeys?: string[],\n formats?: ('cjs' | 'esm')[]\n) => {\n const outputFormats = formats ?? configuration.build.outputFormat;\n const { mainDir } = configuration.content;\n\n await mkdir(mainDir, { recursive: true });\n\n const remoteDictionariesPath = getBuiltRemoteDictionariesPath(configuration);\n const dictionariesPath = filterDictionaries(\n getBuiltDictionariesPath(configuration),\n dictionariesKeys\n );\n const unmergedDictionariesPath =\n getBuiltUnmergedDictionariesPath(configuration);\n\n const writeOperations = [\n ...outputFormats.map((format) => ({\n paths: remoteDictionariesPath,\n functionName: 'getRemoteDictionaries',\n fileName: 'remote_dictionaries' as const,\n format,\n })),\n ...outputFormats.map((format) => ({\n paths: dictionariesPath,\n functionName: 'getDictionaries',\n fileName: 'dictionaries' as const,\n format,\n })),\n ...outputFormats.map((format) => ({\n paths: unmergedDictionariesPath,\n functionName: 'getUnmergedDictionaries',\n fileName: 'unmerged_dictionaries' as const,\n format,\n })),\n ...outputFormats.map((format) => ({\n paths: getBuiltDynamicDictionariesPath(configuration, format),\n functionName: 'getDynamicDictionaries',\n fileName: 'dynamic_dictionaries' as const,\n format,\n })),\n ...outputFormats.map((format) => ({\n paths: getBuiltFetchDictionariesPath(configuration, format),\n functionName: 'getFetchDictionaries',\n fileName: 'fetch_dictionaries' as const,\n format,\n })),\n ];\n\n await parallelize(\n writeOperations,\n async ({ paths, fileName, format, functionName }) =>\n writeDictionaryFiles(paths, fileName, functionName, format, configuration)\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,sBAAsB;AACtB,kBAAwB;AACxB,sCAAyC;AACzC,6CAAgD;AAChD,2CAA8C;AAC9C,4CAA+C;AAC/C,8CAAiD;AACjD,yBAA4B;AAC5B,gCAAmC;AACnC,2CAA8C;AAE9C,MAAM,qBAAqB,CAAC,OAAiB,SAAoB;AAC/D,MAAI,CAAC,KAAM,QAAO;AAClB,SAAO,MAAM;AAAA,IAAO,CAAC,SACnB,KAAK,KAAK,CAAC,QAAQ,KAAK,SAAS,GAAG,GAAG,OAAO,CAAC;AAAA,EACjD;AACF;AAEA,MAAM,uBAAuB,OAC3B,OACA,UACA,cACA,QACA,oBAAgB,gCAAiB,MAC9B;AACH,QAAM,cAAU;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,QAAM,YAAY,WAAW,QAAQ,QAAQ;AAE7C,QAAM,EAAE,QAAQ,IAAI,cAAc;AAElC,YAAM;AAAA,QACJ,qBAAQ,SAAS,GAAG,QAAQ,IAAI,SAAS,EAAE;AAAA,IAC3C;AAAA,EACF;AACF;AAKO,MAAM,6BAA6B,OACxC,oBAAgB,gCAAiB,GACjC,kBACA,YACG;AACH,QAAM,gBAAgB,WAAW,cAAc,MAAM;AACrD,QAAM,EAAE,QAAQ,IAAI,cAAc;AAElC,YAAM,uBAAM,SAAS,EAAE,WAAW,KAAK,CAAC;AAExC,QAAM,6BAAyB,sEAA+B,aAAa;AAC3E,QAAM,mBAAmB;AAAA,QACvB,0DAAyB,aAAa;AAAA,IACtC;AAAA,EACF;AACA,QAAM,+BACJ,0EAAiC,aAAa;AAEhD,QAAM,kBAAkB;AAAA,IACtB,GAAG,cAAc,IAAI,CAAC,YAAY;AAAA,MAChC,OAAO;AAAA,MACP,cAAc;AAAA,MACd,UAAU;AAAA,MACV;AAAA,IACF,EAAE;AAAA,IACF,GAAG,cAAc,IAAI,CAAC,YAAY;AAAA,MAChC,OAAO;AAAA,MACP,cAAc;AAAA,MACd,UAAU;AAAA,MACV;AAAA,IACF,EAAE;AAAA,IACF,GAAG,cAAc,IAAI,CAAC,YAAY;AAAA,MAChC,OAAO;AAAA,MACP,cAAc;AAAA,MACd,UAAU;AAAA,MACV;AAAA,IACF,EAAE;AAAA,IACF,GAAG,cAAc,IAAI,CAAC,YAAY;AAAA,MAChC,WAAO,wEAAgC,eAAe,MAAM;AAAA,MAC5D,cAAc;AAAA,MACd,UAAU;AAAA,MACV;AAAA,IACF,EAAE;AAAA,IACF,GAAG,cAAc,IAAI,CAAC,YAAY;AAAA,MAChC,WAAO,oEAA8B,eAAe,MAAM;AAAA,MAC1D,cAAc;AAAA,MACd,UAAU;AAAA,MACV;AAAA,IACF,EAAE;AAAA,EACJ;AAEA,YAAM;AAAA,IACJ;AAAA,IACA,OAAO,EAAE,OAAO,UAAU,QAAQ,aAAa,MAC7C,qBAAqB,OAAO,UAAU,cAAc,QAAQ,aAAa;AAAA,EAC7E;AACF;","names":[]}
|
|
@@ -24,7 +24,7 @@ module.exports = __toCommonJS(generateDictionaryListContent_exports);
|
|
|
24
24
|
var import_config = require("@intlayer/config");
|
|
25
25
|
var import_path = require("path");
|
|
26
26
|
var import_getFileHash = require('../../utils/getFileHash.cjs');
|
|
27
|
-
const generateDictionaryListContent = (dictionaries, format = "esm", configuration = (0, import_config.getConfiguration)()) => {
|
|
27
|
+
const generateDictionaryListContent = (dictionaries, functionName, format = "esm", configuration = (0, import_config.getConfiguration)()) => {
|
|
28
28
|
const { mainDir } = configuration.content;
|
|
29
29
|
let content = "";
|
|
30
30
|
const dictionariesRef = dictionaries.map((dictionaryPath) => ({
|
|
@@ -44,16 +44,28 @@ const generateDictionaryListContent = (dictionaries, format = "esm", configurati
|
|
|
44
44
|
});
|
|
45
45
|
content += "\n";
|
|
46
46
|
const formattedDictionaryMap = dictionariesRef.map((dictionary) => ` "${dictionary.id}": ${dictionary.hash}`).join(",\n");
|
|
47
|
-
|
|
48
|
-
content += `export default {
|
|
47
|
+
content += `const dictionaries = {
|
|
49
48
|
${formattedDictionaryMap}
|
|
50
49
|
};
|
|
51
50
|
`;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
content += `const ${functionName} = () => dictionaries;
|
|
52
|
+
`;
|
|
53
|
+
if (format === "esm") {
|
|
54
|
+
content += `
|
|
55
|
+
`;
|
|
56
|
+
content += `export { ${functionName} };
|
|
57
|
+
`;
|
|
58
|
+
content += `export default dictionaries;
|
|
56
59
|
`;
|
|
60
|
+
}
|
|
61
|
+
if (format === "cjs") {
|
|
62
|
+
content += `
|
|
63
|
+
`;
|
|
64
|
+
content += `module.exports.${functionName} = ${functionName};
|
|
65
|
+
`;
|
|
66
|
+
content += `module.exports = dictionaries;
|
|
67
|
+
`;
|
|
68
|
+
}
|
|
57
69
|
return content;
|
|
58
70
|
};
|
|
59
71
|
// Annotate the CommonJS export names for ESM import in node:
|