@intlayer/chokidar 8.1.2 → 8.1.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/assets/installSkills/skills/angular.md +3 -0
- package/dist/assets/installSkills/skills/astro.md +3 -0
- package/dist/assets/installSkills/skills/cli.md +7 -4
- package/dist/assets/installSkills/skills/config.md +3 -0
- package/dist/assets/installSkills/skills/content.md +3 -0
- package/dist/assets/installSkills/skills/next_js.md +3 -0
- package/dist/assets/installSkills/skills/preact.md +3 -2
- package/dist/assets/installSkills/skills/react.md +3 -0
- package/dist/assets/installSkills/skills/solid.md +3 -0
- package/dist/assets/installSkills/skills/svelte.md +3 -0
- package/dist/assets/installSkills/skills/usage.md +2 -0
- package/dist/assets/installSkills/skills/vue.md +3 -0
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
- package/dist/cjs/_virtual/_utils_asset.cjs +2 -98
- package/dist/cjs/build.cjs +1 -51
- package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs +1 -53
- package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/index.cjs +1 -6
- package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs +1 -26
- package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +4 -78
- package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +4 -62
- package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +1 -46
- package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs +1 -50
- package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs +1 -59
- package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs.map +1 -1
- package/dist/cjs/cleanOutputDir.cjs +1 -30
- package/dist/cjs/cleanOutputDir.cjs.map +1 -1
- package/dist/cjs/cleanRemovedContentDeclaration.cjs +1 -96
- package/dist/cjs/cleanRemovedContentDeclaration.cjs.map +1 -1
- package/dist/cjs/cli.cjs +1 -21
- package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +1 -70
- package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs +7 -41
- package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs +1 -23
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs +1 -24
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs +1 -24
- package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs +1 -23
- package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs +1 -23
- package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/index.cjs +1 -16
- package/dist/cjs/createType/createModuleAugmentation.cjs +9 -110
- package/dist/cjs/createType/createModuleAugmentation.cjs.map +1 -1
- package/dist/cjs/createType/createType.cjs +1 -29
- package/dist/cjs/createType/createType.cjs.map +1 -1
- package/dist/cjs/createType/index.cjs +1 -8
- package/dist/cjs/fetchDistantDictionaries.cjs +1 -50
- package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
- package/dist/cjs/filterInvalidDictionaries.cjs +1 -49
- package/dist/cjs/filterInvalidDictionaries.cjs.map +1 -1
- package/dist/cjs/formatDictionary.cjs +1 -49
- package/dist/cjs/formatDictionary.cjs.map +1 -1
- package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +1 -39
- package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -1
- package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +1 -34
- package/dist/cjs/handleAdditionalContentDeclarationFile.cjs.map +1 -1
- package/dist/cjs/handleContentDeclarationFileChange.cjs +1 -49
- package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -1
- package/dist/cjs/handleContentDeclarationFileMoved.cjs +1 -24
- package/dist/cjs/handleContentDeclarationFileMoved.cjs.map +1 -1
- package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs +1 -37
- package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -131
- package/dist/cjs/init/index.cjs +1 -242
- package/dist/cjs/init/index.cjs.map +1 -1
- package/dist/cjs/init/utils/configManipulation.cjs +1 -164
- package/dist/cjs/init/utils/configManipulation.cjs.map +1 -1
- package/dist/cjs/init/utils/fileSystem.cjs +1 -30
- package/dist/cjs/init/utils/fileSystem.cjs.map +1 -1
- package/dist/cjs/init/utils/index.cjs +1 -13
- package/dist/cjs/init/utils/jsonParser.cjs +3 -42
- package/dist/cjs/init/utils/jsonParser.cjs.map +1 -1
- package/dist/cjs/init/utils/tsConfig.cjs +1 -18
- package/dist/cjs/init/utils/tsConfig.cjs.map +1 -1
- package/dist/cjs/initConfig/index.cjs +1 -38
- package/dist/cjs/initConfig/index.cjs.map +1 -1
- package/dist/cjs/installSkills/index.cjs +1 -172
- package/dist/cjs/installSkills/index.cjs.map +1 -1
- package/dist/cjs/listDictionariesPath.cjs +1 -41
- package/dist/cjs/listDictionariesPath.cjs.map +1 -1
- package/dist/cjs/listGitFiles.cjs +5 -95
- package/dist/cjs/listGitFiles.cjs.map +1 -1
- package/dist/cjs/listProjects.cjs +1 -47
- package/dist/cjs/listProjects.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +1 -66
- package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/index.cjs +1 -12
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +2 -72
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs +1 -125
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs +1 -28
- package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +1 -61
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/log.cjs +3 -135
- package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
- package/dist/cjs/prepareIntlayer.cjs +1 -95
- package/dist/cjs/prepareIntlayer.cjs.map +1 -1
- package/dist/cjs/reduceDictionaryContent/applyMask.cjs +1 -30
- package/dist/cjs/reduceDictionaryContent/applyMask.cjs.map +1 -1
- package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs +1 -12
- package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs.map +1 -1
- package/dist/cjs/transformFiles/extractDictionaryKey.cjs +1 -16
- package/dist/cjs/transformFiles/extractDictionaryKey.cjs.map +1 -1
- package/dist/cjs/transformFiles/index.cjs +1 -10
- package/dist/cjs/transformFiles/transformFiles.cjs +1 -251
- package/dist/cjs/transformFiles/transformFiles.cjs.map +1 -1
- package/dist/cjs/utils/autoDecorateContent.cjs +1 -87
- package/dist/cjs/utils/autoDecorateContent.cjs.map +1 -1
- package/dist/cjs/utils/buildFilesList.cjs +1 -50
- package/dist/cjs/utils/buildFilesList.cjs.map +1 -1
- package/dist/cjs/utils/chunkJSON.cjs +1 -336
- package/dist/cjs/utils/chunkJSON.cjs.map +1 -1
- package/dist/cjs/utils/formatter.cjs +1 -16
- package/dist/cjs/utils/formatter.cjs.map +1 -1
- package/dist/cjs/utils/getChunk.cjs +1 -34
- package/dist/cjs/utils/getChunk.cjs.map +1 -1
- package/dist/cjs/utils/getComponentTransformPattern.cjs +1 -48
- package/dist/cjs/utils/getComponentTransformPattern.cjs.map +1 -1
- package/dist/cjs/utils/getFileHash.cjs +1 -12
- package/dist/cjs/utils/getFileHash.cjs.map +1 -1
- package/dist/cjs/utils/getFormatFromExtension.cjs +1 -31
- package/dist/cjs/utils/getFormatFromExtension.cjs.map +1 -1
- package/dist/cjs/utils/index.cjs +1 -46
- package/dist/cjs/utils/pLimit.cjs +1 -128
- package/dist/cjs/utils/pLimit.cjs.map +1 -1
- package/dist/cjs/utils/parallelize.cjs +1 -11
- package/dist/cjs/utils/parallelize.cjs.map +1 -1
- package/dist/cjs/utils/parallelizeGlobal.cjs +1 -29
- package/dist/cjs/utils/parallelizeGlobal.cjs.map +1 -1
- package/dist/cjs/utils/reduceObjectFormat.cjs +1 -31
- package/dist/cjs/utils/reduceObjectFormat.cjs.map +1 -1
- package/dist/cjs/utils/resolveObjectPromises.cjs +1 -21
- package/dist/cjs/utils/resolveObjectPromises.cjs.map +1 -1
- package/dist/cjs/utils/runOnce.cjs +1 -95
- package/dist/cjs/utils/runOnce.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/bin.cjs +1 -54
- package/dist/cjs/utils/runParallel/bin.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/bootstrap.cjs +1 -24
- package/dist/cjs/utils/runParallel/bootstrap.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/index.cjs +1 -110
- package/dist/cjs/utils/runParallel/index.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/pidTree.cjs +1 -145
- package/dist/cjs/utils/runParallel/pidTree.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/ps.cjs +1 -49
- package/dist/cjs/utils/runParallel/ps.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/runTask.cjs +1 -154
- package/dist/cjs/utils/runParallel/runTask.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/spawnPosix.cjs +1 -59
- package/dist/cjs/utils/runParallel/spawnPosix.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/spawnWin32.cjs +1 -43
- package/dist/cjs/utils/runParallel/spawnWin32.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/wmic.cjs +1 -52
- package/dist/cjs/utils/runParallel/wmic.cjs.map +1 -1
- package/dist/cjs/utils/sortAlphabetically.cjs +1 -7
- package/dist/cjs/utils/sortAlphabetically.cjs.map +1 -1
- package/dist/cjs/utils/splitTextByLine.cjs +1 -11
- package/dist/cjs/utils/splitTextByLine.cjs.map +1 -1
- package/dist/cjs/utils/verifyIdenticObjectFormat.cjs +1 -60
- package/dist/cjs/utils/verifyIdenticObjectFormat.cjs.map +1 -1
- package/dist/cjs/watcher.cjs +1 -95
- package/dist/cjs/watcher.cjs.map +1 -1
- package/dist/cjs/writeConfiguration/index.cjs +1 -34
- package/dist/cjs/writeConfiguration/index.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs +1 -28
- package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/detectFormatCommand.cjs +1 -31
- package/dist/cjs/writeContentDeclaration/detectFormatCommand.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/index.cjs +1 -12
- package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs +1 -93
- package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/transformJSFile.cjs +2 -1775
- package/dist/cjs/writeContentDeclaration/transformJSFile.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs +1 -77
- package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +1 -123
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +1 -71
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -1
- package/dist/cjs/writeFileIfChanged.cjs +1 -12
- package/dist/cjs/writeFileIfChanged.cjs.map +1 -1
- package/dist/cjs/writeJsonIfChanged.cjs +1 -17
- package/dist/cjs/writeJsonIfChanged.cjs.map +1 -1
- package/dist/esm/_virtual/_rolldown/runtime.mjs +1 -8
- package/dist/esm/_virtual/_utils_asset.mjs +2 -97
- package/dist/esm/build.mjs +1 -24
- package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs +1 -51
- package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/index.mjs +1 -4
- package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs +1 -24
- package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +4 -75
- package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +4 -59
- package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs +1 -44
- package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs +1 -48
- package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs +1 -56
- package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs.map +1 -1
- package/dist/esm/cleanOutputDir.mjs +1 -28
- package/dist/esm/cleanOutputDir.mjs.map +1 -1
- package/dist/esm/cleanRemovedContentDeclaration.mjs +1 -93
- package/dist/esm/cleanRemovedContentDeclaration.mjs.map +1 -1
- package/dist/esm/cli.mjs +1 -8
- package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs +1 -68
- package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs +7 -39
- package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs +1 -20
- package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs +1 -21
- package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs +1 -21
- package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs +1 -20
- package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs +1 -20
- package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/index.mjs +1 -9
- package/dist/esm/createType/createModuleAugmentation.mjs +9 -106
- package/dist/esm/createType/createModuleAugmentation.mjs.map +1 -1
- package/dist/esm/createType/createType.mjs +1 -26
- package/dist/esm/createType/createType.mjs.map +1 -1
- package/dist/esm/createType/index.mjs +1 -4
- package/dist/esm/fetchDistantDictionaries.mjs +1 -48
- package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
- package/dist/esm/filterInvalidDictionaries.mjs +1 -46
- package/dist/esm/filterInvalidDictionaries.mjs.map +1 -1
- package/dist/esm/formatDictionary.mjs +1 -44
- package/dist/esm/formatDictionary.mjs.map +1 -1
- package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +1 -37
- package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -1
- package/dist/esm/handleAdditionalContentDeclarationFile.mjs +1 -32
- package/dist/esm/handleAdditionalContentDeclarationFile.mjs.map +1 -1
- package/dist/esm/handleContentDeclarationFileChange.mjs +1 -47
- package/dist/esm/handleContentDeclarationFileChange.mjs.map +1 -1
- package/dist/esm/handleContentDeclarationFileMoved.mjs +1 -22
- package/dist/esm/handleContentDeclarationFileMoved.mjs.map +1 -1
- package/dist/esm/handleUnlinkedContentDeclarationFile.mjs +1 -35
- package/dist/esm/handleUnlinkedContentDeclarationFile.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -57
- package/dist/esm/init/index.mjs +1 -240
- package/dist/esm/init/index.mjs.map +1 -1
- package/dist/esm/init/utils/configManipulation.mjs +1 -161
- package/dist/esm/init/utils/configManipulation.mjs.map +1 -1
- package/dist/esm/init/utils/fileSystem.mjs +1 -26
- package/dist/esm/init/utils/fileSystem.mjs.map +1 -1
- package/dist/esm/init/utils/index.mjs +1 -6
- package/dist/esm/init/utils/jsonParser.mjs +3 -40
- package/dist/esm/init/utils/jsonParser.mjs.map +1 -1
- package/dist/esm/init/utils/tsConfig.mjs +1 -16
- package/dist/esm/init/utils/tsConfig.mjs.map +1 -1
- package/dist/esm/initConfig/index.mjs +1 -36
- package/dist/esm/initConfig/index.mjs.map +1 -1
- package/dist/esm/installSkills/index.mjs +1 -167
- package/dist/esm/installSkills/index.mjs.map +1 -1
- package/dist/esm/listDictionariesPath.mjs +1 -37
- package/dist/esm/listDictionariesPath.mjs.map +1 -1
- package/dist/esm/listGitFiles.mjs +5 -90
- package/dist/esm/listGitFiles.mjs.map +1 -1
- package/dist/esm/listProjects.mjs +1 -43
- package/dist/esm/listProjects.mjs.map +1 -1
- package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +1 -65
- package/dist/esm/loadDictionaries/getIntlayerBundle.mjs.map +1 -1
- package/dist/esm/loadDictionaries/index.mjs +1 -6
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +2 -69
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadDictionaries.mjs +1 -123
- package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs +1 -26
- package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +1 -58
- package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/log.mjs +3 -132
- package/dist/esm/loadDictionaries/log.mjs.map +1 -1
- package/dist/esm/prepareIntlayer.mjs +1 -92
- package/dist/esm/prepareIntlayer.mjs.map +1 -1
- package/dist/esm/reduceDictionaryContent/applyMask.mjs +1 -28
- package/dist/esm/reduceDictionaryContent/applyMask.mjs.map +1 -1
- package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs +1 -10
- package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs.map +1 -1
- package/dist/esm/transformFiles/extractDictionaryKey.mjs +1 -14
- package/dist/esm/transformFiles/extractDictionaryKey.mjs.map +1 -1
- package/dist/esm/transformFiles/index.mjs +1 -4
- package/dist/esm/transformFiles/transformFiles.mjs +1 -244
- package/dist/esm/transformFiles/transformFiles.mjs.map +1 -1
- package/dist/esm/utils/autoDecorateContent.mjs +1 -85
- package/dist/esm/utils/autoDecorateContent.mjs.map +1 -1
- package/dist/esm/utils/buildFilesList.mjs +1 -47
- package/dist/esm/utils/buildFilesList.mjs.map +1 -1
- package/dist/esm/utils/chunkJSON.mjs +1 -333
- package/dist/esm/utils/chunkJSON.mjs.map +1 -1
- package/dist/esm/utils/formatter.mjs +1 -12
- package/dist/esm/utils/formatter.mjs.map +1 -1
- package/dist/esm/utils/getChunk.mjs +1 -33
- package/dist/esm/utils/getChunk.mjs.map +1 -1
- package/dist/esm/utils/getComponentTransformPattern.mjs +1 -44
- package/dist/esm/utils/getComponentTransformPattern.mjs.map +1 -1
- package/dist/esm/utils/getFileHash.mjs +1 -9
- package/dist/esm/utils/getFileHash.mjs.map +1 -1
- package/dist/esm/utils/getFormatFromExtension.mjs +1 -28
- package/dist/esm/utils/getFormatFromExtension.mjs.map +1 -1
- package/dist/esm/utils/index.mjs +1 -20
- package/dist/esm/utils/pLimit.mjs +1 -125
- package/dist/esm/utils/pLimit.mjs.map +1 -1
- package/dist/esm/utils/parallelize.mjs +1 -10
- package/dist/esm/utils/parallelize.mjs.map +1 -1
- package/dist/esm/utils/parallelizeGlobal.mjs +1 -26
- package/dist/esm/utils/parallelizeGlobal.mjs.map +1 -1
- package/dist/esm/utils/reduceObjectFormat.mjs +1 -29
- package/dist/esm/utils/reduceObjectFormat.mjs.map +1 -1
- package/dist/esm/utils/resolveObjectPromises.mjs +1 -19
- package/dist/esm/utils/resolveObjectPromises.mjs.map +1 -1
- package/dist/esm/utils/runOnce.mjs +1 -92
- package/dist/esm/utils/runOnce.mjs.map +1 -1
- package/dist/esm/utils/runParallel/bin.mjs +1 -52
- package/dist/esm/utils/runParallel/bin.mjs.map +1 -1
- package/dist/esm/utils/runParallel/bootstrap.mjs +1 -22
- package/dist/esm/utils/runParallel/bootstrap.mjs.map +1 -1
- package/dist/esm/utils/runParallel/index.mjs +1 -108
- package/dist/esm/utils/runParallel/index.mjs.map +1 -1
- package/dist/esm/utils/runParallel/pidTree.mjs +1 -142
- package/dist/esm/utils/runParallel/pidTree.mjs.map +1 -1
- package/dist/esm/utils/runParallel/ps.mjs +1 -46
- package/dist/esm/utils/runParallel/ps.mjs.map +1 -1
- package/dist/esm/utils/runParallel/runTask.mjs +1 -152
- package/dist/esm/utils/runParallel/runTask.mjs.map +1 -1
- package/dist/esm/utils/runParallel/spawnPosix.mjs +1 -57
- package/dist/esm/utils/runParallel/spawnPosix.mjs.map +1 -1
- package/dist/esm/utils/runParallel/spawnWin32.mjs +1 -41
- package/dist/esm/utils/runParallel/spawnWin32.mjs.map +1 -1
- package/dist/esm/utils/runParallel/wmic.mjs +1 -49
- package/dist/esm/utils/runParallel/wmic.mjs.map +1 -1
- package/dist/esm/utils/sortAlphabetically.mjs +1 -5
- package/dist/esm/utils/sortAlphabetically.mjs.map +1 -1
- package/dist/esm/utils/splitTextByLine.mjs +1 -9
- package/dist/esm/utils/splitTextByLine.mjs.map +1 -1
- package/dist/esm/utils/verifyIdenticObjectFormat.mjs +1 -58
- package/dist/esm/utils/verifyIdenticObjectFormat.mjs.map +1 -1
- package/dist/esm/watcher.mjs +1 -92
- package/dist/esm/watcher.mjs.map +1 -1
- package/dist/esm/writeConfiguration/index.mjs +1 -31
- package/dist/esm/writeConfiguration/index.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs +1 -26
- package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/detectFormatCommand.mjs +1 -29
- package/dist/esm/writeContentDeclaration/detectFormatCommand.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/index.mjs +1 -7
- package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +1 -91
- package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/transformJSFile.mjs +2 -1773
- package/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/transformJSONFile.mjs +1 -75
- package/dist/esm/writeContentDeclaration/transformJSONFile.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +1 -121
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeJSFile.mjs +1 -69
- package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -1
- package/dist/esm/writeFileIfChanged.mjs +1 -10
- package/dist/esm/writeFileIfChanged.mjs.map +1 -1
- package/dist/esm/writeJsonIfChanged.mjs +1 -16
- package/dist/esm/writeJsonIfChanged.mjs.map +1 -1
- package/dist/types/build.d.ts +3 -1
- package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -1
- package/dist/types/fetchDistantDictionaries.d.ts.map +1 -1
- package/dist/types/index.d.ts +16 -24
- package/dist/types/initConfig/index.d.ts +1 -1
- package/dist/types/initConfig/index.d.ts.map +1 -1
- package/dist/types/listGitFiles.d.ts.map +1 -1
- package/dist/types/loadDictionaries/getIntlayerBundle.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadContentDeclaration.d.ts.map +1 -1
- package/dist/types/prepareIntlayer.d.ts.map +1 -1
- package/dist/types/transformFiles/transformFiles.d.ts +1 -1
- package/dist/types/transformFiles/transformFiles.d.ts.map +1 -1
- package/dist/types/utils/formatter.d.ts +1 -1
- package/dist/types/watcher.d.ts +1 -1
- package/dist/types/writeContentDeclaration/processContentDeclarationContent.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/transformJSFile.d.ts.map +1 -1
- package/package.json +10 -15
|
@@ -1,70 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { processContentDeclaration } from "../buildIntlayerDictionary/processContentDeclaration.mjs";
|
|
4
|
-
import { getIntlayerBundle } from "./getIntlayerBundle.mjs";
|
|
5
|
-
import { cacheDisk, getProjectRequire, loadExternalFile } from "@intlayer/config";
|
|
6
|
-
import { writeFile } from "node:fs/promises";
|
|
7
|
-
import { join, relative } from "node:path";
|
|
8
|
-
|
|
9
|
-
//#region src/loadDictionaries/loadContentDeclaration.ts
|
|
10
|
-
const formatLocalDictionaries = (dictionariesRecord, configuration) => Object.entries(dictionariesRecord).map(([relativePath, dict]) => ({
|
|
11
|
-
...dict,
|
|
12
|
-
location: dict.location ?? configuration.dictionary?.location ?? "local",
|
|
13
|
-
localId: `${dict.key}::local::${relativePath}`,
|
|
14
|
-
filePath: relativePath
|
|
15
|
-
}));
|
|
16
|
-
const loadContentDeclarations = async (contentDeclarationFilePath, configuration, onStatusUpdate) => {
|
|
17
|
-
const { build, system } = configuration;
|
|
18
|
-
const { set, isValid, clear } = cacheDisk(configuration, ["intlayer-bundle"], { ttlMs: 1e3 * 60 * 60 * 24 * 5 });
|
|
19
|
-
const filePath = join(system.cacheDir, "intlayer-bundle.cjs");
|
|
20
|
-
if (!await isValid()) {
|
|
21
|
-
await writeFile(filePath, await getIntlayerBundle(configuration));
|
|
22
|
-
await set("ok");
|
|
23
|
-
}
|
|
24
|
-
try {
|
|
25
|
-
const dictionariesPromises = contentDeclarationFilePath.map(async (path) => {
|
|
26
|
-
return {
|
|
27
|
-
relativePath: relative(configuration.content.baseDir, path),
|
|
28
|
-
dictionary: await loadExternalFile(path, {
|
|
29
|
-
projectRequire: build.require ?? getProjectRequire(),
|
|
30
|
-
buildOptions: { banner: { js: [`globalThis.INTLAYER_FILE_PATH = '${path}';`, `globalThis.INTLAYER_BASE_DIR = '${configuration.content.baseDir}';`].join("\n") } },
|
|
31
|
-
aliases: { intlayer: filePath }
|
|
32
|
-
})
|
|
33
|
-
};
|
|
34
|
-
});
|
|
35
|
-
const contentDeclarations = formatLocalDictionaries((await Promise.all(dictionariesPromises)).reduce((acc, { relativePath, dictionary }) => {
|
|
36
|
-
acc[relativePath] = dictionary;
|
|
37
|
-
return acc;
|
|
38
|
-
}, {}), configuration).filter((dictionary) => dictionary.location !== "remote");
|
|
39
|
-
const listFoundDictionaries = contentDeclarations.map((declaration) => ({
|
|
40
|
-
dictionaryKey: declaration.key,
|
|
41
|
-
type: "local",
|
|
42
|
-
status: "found"
|
|
43
|
-
}));
|
|
44
|
-
onStatusUpdate?.(listFoundDictionaries);
|
|
45
|
-
return filterInvalidDictionaries(await parallelize(contentDeclarations, async (contentDeclaration) => {
|
|
46
|
-
if (!contentDeclaration) return;
|
|
47
|
-
onStatusUpdate?.([{
|
|
48
|
-
dictionaryKey: contentDeclaration.key,
|
|
49
|
-
type: "local",
|
|
50
|
-
status: "building"
|
|
51
|
-
}]);
|
|
52
|
-
const processedContentDeclaration = await processContentDeclaration(contentDeclaration, configuration);
|
|
53
|
-
if (!processedContentDeclaration) return;
|
|
54
|
-
onStatusUpdate?.([{
|
|
55
|
-
dictionaryKey: processedContentDeclaration.key,
|
|
56
|
-
type: "local",
|
|
57
|
-
status: "built"
|
|
58
|
-
}]);
|
|
59
|
-
return processedContentDeclaration;
|
|
60
|
-
}), configuration, { checkSchema: false });
|
|
61
|
-
} catch {
|
|
62
|
-
console.error("Error loading content declarations");
|
|
63
|
-
await clear();
|
|
64
|
-
}
|
|
65
|
-
return [];
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
//#endregion
|
|
69
|
-
export { formatLocalDictionaries, loadContentDeclarations };
|
|
1
|
+
import{parallelize as e}from"../utils/parallelize.mjs";import{filterInvalidDictionaries as t}from"../filterInvalidDictionaries.mjs";import{processContentDeclaration as n}from"../buildIntlayerDictionary/processContentDeclaration.mjs";import{getIntlayerBundle as r}from"./getIntlayerBundle.mjs";import{writeFile as i}from"node:fs/promises";import{join as a,relative as o}from"node:path";import{cacheDisk as s,getProjectRequire as c}from"@intlayer/config/utils";import{loadExternalFile as l}from"@intlayer/config/file";const u=(e,t)=>Object.entries(e).map(([e,n])=>({...n,location:n.location??t.dictionary?.location??`local`,localId:`${n.key}::local::${e}`,filePath:e})),d=async(d,f,p)=>{let{build:m,system:h}=f,{set:g,isValid:_,clear:v}=s(f,[`intlayer-bundle`],{ttlMs:1e3*60*60*24*5}),y=a(h.cacheDir,`intlayer-bundle.cjs`);await _()||(await i(y,await r(f)),await g(`ok`));try{let r=d.map(async e=>({relativePath:o(f.content.baseDir,e),dictionary:await l(e,{projectRequire:m.require??c(),buildOptions:{banner:{js:[`globalThis.INTLAYER_FILE_PATH = '${e}';`,`globalThis.INTLAYER_BASE_DIR = '${f.content.baseDir}';`].join(`
|
|
2
|
+
`)}},aliases:{intlayer:y}})})),i=u((await Promise.all(r)).reduce((e,{relativePath:t,dictionary:n})=>(e[t]=n,e),{}),f).filter(e=>e.location!==`remote`),a=i.map(e=>({dictionaryKey:e.key,type:`local`,status:`found`}));return p?.(a),t(await e(i,async e=>{if(!e)return;p?.([{dictionaryKey:e.key,type:`local`,status:`building`}]);let t=await n(e,f);if(t)return p?.([{dictionaryKey:t.key,type:`local`,status:`built`}]),t}),f,{checkSchema:!1})}catch{console.error(`Error loading content declarations`),await v()}return[]};export{u as formatLocalDictionaries,d as loadContentDeclarations};
|
|
70
3
|
//# sourceMappingURL=loadContentDeclaration.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadContentDeclaration.mjs","names":[],"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport {
|
|
1
|
+
{"version":3,"file":"loadContentDeclaration.mjs","names":[],"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport { loadExternalFile } from '@intlayer/config/file';\nimport { cacheDisk, getProjectRequire } from '@intlayer/config/utils';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { processContentDeclaration } from '../buildIntlayerDictionary/processContentDeclaration';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { getIntlayerBundle } from './getIntlayerBundle';\nimport type { DictionariesStatus } from './loadDictionaries';\n\nexport const formatLocalDictionaries = (\n dictionariesRecord: Record<string, Dictionary>,\n configuration: IntlayerConfig\n): Dictionary[] =>\n Object.entries(dictionariesRecord).map(([relativePath, dict]) => ({\n ...dict,\n location: dict.location ?? configuration.dictionary?.location ?? 'local',\n localId: `${dict.key}::local::${relativePath}`,\n filePath: relativePath,\n }));\n\nexport const loadContentDeclarations = async (\n contentDeclarationFilePath: string[],\n configuration: IntlayerConfig,\n onStatusUpdate?: (status: DictionariesStatus[]) => void\n): Promise<Dictionary[]> => {\n const { build, system } = configuration;\n\n const { set, isValid, clear } = cacheDisk(\n configuration,\n ['intlayer-bundle'],\n {\n ttlMs: 1000 * 60 * 60 * 24 * 5, // 5 days\n }\n );\n\n const filePath = join(system.cacheDir, 'intlayer-bundle.cjs');\n const hasIntlayerBundle = await isValid();\n\n // If cache is invalid, write the intlayer bundle to the cache\n if (!hasIntlayerBundle) {\n const intlayerBundle = await getIntlayerBundle(configuration);\n await writeFile(filePath, intlayerBundle);\n await set('ok');\n }\n\n try {\n const dictionariesPromises = contentDeclarationFilePath.map(\n async (path) => {\n const relativePath = relative(configuration.content.baseDir, path);\n\n const dictionary = await loadExternalFile(path, {\n projectRequire: build.require ?? getProjectRequire(),\n buildOptions: {\n banner: {\n js: [\n `globalThis.INTLAYER_FILE_PATH = '${path}';`,\n `globalThis.INTLAYER_BASE_DIR = '${configuration.content.baseDir}';`,\n ].join('\\n'),\n },\n },\n aliases: {\n intlayer: filePath,\n },\n });\n\n return { relativePath, dictionary };\n }\n );\n\n const dictionariesArray = await Promise.all(dictionariesPromises);\n const dictionariesRecord = dictionariesArray.reduce(\n (acc, { relativePath, dictionary }) => {\n acc[relativePath] = dictionary;\n return acc;\n },\n {} as Record<string, Dictionary>\n );\n\n const contentDeclarations: Dictionary[] = formatLocalDictionaries(\n dictionariesRecord,\n configuration\n ).filter((dictionary) => dictionary.location !== 'remote');\n\n const listFoundDictionaries = contentDeclarations.map((declaration) => ({\n dictionaryKey: declaration.key,\n type: 'local' as const,\n status: 'found' as const,\n }));\n\n onStatusUpdate?.(listFoundDictionaries);\n\n const processedDictionaries = await parallelize(\n contentDeclarations,\n async (contentDeclaration): Promise<Dictionary | undefined> => {\n if (!contentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: contentDeclaration.key,\n type: 'local',\n status: 'building',\n },\n ]);\n\n const processedContentDeclaration = await processContentDeclaration(\n contentDeclaration as Dictionary,\n configuration\n );\n\n if (!processedContentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: processedContentDeclaration.key,\n type: 'local',\n status: 'built',\n },\n ]);\n\n return processedContentDeclaration;\n }\n );\n\n return filterInvalidDictionaries(processedDictionaries, configuration, {\n checkSchema: false,\n });\n } catch {\n console.error('Error loading content declarations');\n await clear();\n }\n\n return [];\n};\n"],"mappings":"ogBAWA,MAAa,GACX,EACA,IAEA,OAAO,QAAQ,EAAmB,CAAC,KAAK,CAAC,EAAc,MAAW,CAChE,GAAG,EACH,SAAU,EAAK,UAAY,EAAc,YAAY,UAAY,QACjE,QAAS,GAAG,EAAK,IAAI,WAAW,IAChC,SAAU,EACX,EAAE,CAEQ,EAA0B,MACrC,EACA,EACA,IAC0B,CAC1B,GAAM,CAAE,QAAO,UAAW,EAEpB,CAAE,MAAK,UAAS,SAAU,EAC9B,EACA,CAAC,kBAAkB,CACnB,CACE,MAAO,IAAO,GAAK,GAAK,GAAK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from "./loadContentDeclaration.mjs";
|
|
3
|
-
import { formatDictionaries } from "../formatDictionary.mjs";
|
|
4
|
-
import { loadRemoteDictionaries } from "./loadRemoteDictionaries.mjs";
|
|
5
|
-
import { DictionariesLogger } from "./log.mjs";
|
|
6
|
-
import { ANSIColors, colon, colorize, colorizeKey, getAppLogger } from "@intlayer/config/client";
|
|
7
|
-
|
|
8
|
-
//#region src/loadDictionaries/loadDictionaries.ts
|
|
9
|
-
let loadDictionariesStatus = [];
|
|
10
|
-
const logger$1 = new DictionariesLogger();
|
|
11
|
-
const setLoadDictionariesStatus = (statuses) => {
|
|
12
|
-
const updated = [...loadDictionariesStatus];
|
|
13
|
-
for (const incoming of statuses) {
|
|
14
|
-
const index = updated.findIndex((s) => s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type);
|
|
15
|
-
if (index >= 0) updated[index] = incoming;
|
|
16
|
-
else updated.push(incoming);
|
|
17
|
-
}
|
|
18
|
-
loadDictionariesStatus = updated;
|
|
19
|
-
logger$1.update(statuses);
|
|
20
|
-
return updated;
|
|
21
|
-
};
|
|
22
|
-
const iconFor = (status) => {
|
|
23
|
-
switch (status) {
|
|
24
|
-
case "built":
|
|
25
|
-
case "imported":
|
|
26
|
-
case "fetched": return "✔";
|
|
27
|
-
case "error": return "✖";
|
|
28
|
-
default: return "⏲";
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
const colorFor = (status) => {
|
|
32
|
-
switch (status) {
|
|
33
|
-
case "built":
|
|
34
|
-
case "imported":
|
|
35
|
-
case "fetched": return ANSIColors.GREEN;
|
|
36
|
-
case "error": return ANSIColors.RED;
|
|
37
|
-
default: return ANSIColors.BLUE;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
const printSummary = (configuration) => {
|
|
41
|
-
if (configuration.log.mode !== "verbose") return;
|
|
42
|
-
const appLogger = getAppLogger(configuration);
|
|
43
|
-
const byKey = /* @__PURE__ */ new Map();
|
|
44
|
-
for (const status of loadDictionariesStatus) {
|
|
45
|
-
const rec = byKey.get(status.dictionaryKey) ?? {};
|
|
46
|
-
if (status.type === "local") rec.local = status.status;
|
|
47
|
-
if (status.type === "remote") rec.remote = status.status;
|
|
48
|
-
byKey.set(status.dictionaryKey, rec);
|
|
49
|
-
}
|
|
50
|
-
const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));
|
|
51
|
-
let maxLocalLabelLen = 0;
|
|
52
|
-
for (const key of keys) {
|
|
53
|
-
const rec = byKey.get(key);
|
|
54
|
-
if (rec.local) {
|
|
55
|
-
const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;
|
|
56
|
-
if (visibleLocal.length > maxLocalLabelLen) maxLocalLabelLen = visibleLocal.length;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
for (const key of keys) {
|
|
60
|
-
const rec = byKey.get(key);
|
|
61
|
-
const labels = [];
|
|
62
|
-
if (rec.local) {
|
|
63
|
-
const inner = colorize(`${iconFor(rec.local)} ${rec.local}`, colorFor(rec.local));
|
|
64
|
-
const coloredLocal = `${ANSIColors.GREY}[` + colorize("local: ", ANSIColors.GREY) + inner + `${ANSIColors.GREY}]${ANSIColors.RESET}`;
|
|
65
|
-
const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;
|
|
66
|
-
const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);
|
|
67
|
-
labels.push(coloredLocal + " ".repeat(pad));
|
|
68
|
-
} else labels.push(" ".repeat(maxLocalLabelLen));
|
|
69
|
-
if (rec.remote) {
|
|
70
|
-
const inner = colorize(`${iconFor(rec.remote)} ${rec.remote}`, colorFor(rec.remote));
|
|
71
|
-
labels.push(`${ANSIColors.GREY}[` + colorize("distant: ", ANSIColors.GREY) + inner + `${ANSIColors.GREY}]${ANSIColors.RESET}`);
|
|
72
|
-
}
|
|
73
|
-
appLogger(` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(" ")}`);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
const loadDictionaries = async (contentDeclarationsPaths, configuration) => {
|
|
77
|
-
const { plugins } = configuration;
|
|
78
|
-
const loadDictionariesStartTime = Date.now();
|
|
79
|
-
getAppLogger(configuration)("Dictionaries:", { isVerbose: true });
|
|
80
|
-
const loadPluginDictionariesPromise = (plugins ?? []).filter((plugin) => plugin.loadDictionaries).map(async (plugin, index) => {
|
|
81
|
-
try {
|
|
82
|
-
return await plugin.loadDictionaries?.({ configuration }) ?? [];
|
|
83
|
-
} catch (error) {
|
|
84
|
-
logger$1.setPluginError(error);
|
|
85
|
-
return [];
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
const pluginDictionaries = await Promise.all(loadPluginDictionariesPromise).then((dictionaries) => dictionaries.flat()).then((dictionaries) => filterInvalidDictionaries(dictionaries, configuration)).then((dictionaries) => formatDictionaries(dictionaries));
|
|
89
|
-
logger$1.setPluginTotal(pluginDictionaries.length);
|
|
90
|
-
logger$1.setPluginDone(pluginDictionaries.length);
|
|
91
|
-
const pluginDictionariesTime = Date.now();
|
|
92
|
-
const localDictionaries = await loadContentDeclarations(Array.isArray(contentDeclarationsPaths) ? contentDeclarationsPaths : [contentDeclarationsPaths], configuration, setLoadDictionariesStatus).then((dictionaries) => filterInvalidDictionaries(dictionaries, configuration)).then((dictionaries) => formatDictionaries(dictionaries));
|
|
93
|
-
const localDictionariesTime = Date.now();
|
|
94
|
-
setLoadDictionariesStatus(localDictionaries.map((dictionary) => ({
|
|
95
|
-
dictionaryKey: dictionary.key,
|
|
96
|
-
type: "local",
|
|
97
|
-
status: "built"
|
|
98
|
-
})));
|
|
99
|
-
const hasRemoteDictionaries = Boolean(configuration.editor.clientId && configuration.editor.clientSecret);
|
|
100
|
-
if (hasRemoteDictionaries) logger$1.setExpectRemote(true);
|
|
101
|
-
let remoteDictionaries = [];
|
|
102
|
-
if (hasRemoteDictionaries) remoteDictionaries = await loadRemoteDictionaries(configuration, setLoadDictionariesStatus, {
|
|
103
|
-
onStartRemoteCheck: () => logger$1.startRemoteCheck(),
|
|
104
|
-
onStopRemoteCheck: () => logger$1.stopRemoteCheck(),
|
|
105
|
-
onError: (e) => logger$1.setRemoteError(e)
|
|
106
|
-
}).then((dictionaries) => filterInvalidDictionaries(dictionaries, configuration)).then((dictionaries) => formatDictionaries(dictionaries));
|
|
107
|
-
const remoteDictionariesTime = Date.now();
|
|
108
|
-
logger$1.finish();
|
|
109
|
-
printSummary(configuration);
|
|
110
|
-
return {
|
|
111
|
-
localDictionaries,
|
|
112
|
-
remoteDictionaries,
|
|
113
|
-
pluginDictionaries,
|
|
114
|
-
time: {
|
|
115
|
-
localDictionaries: localDictionariesTime - pluginDictionariesTime,
|
|
116
|
-
remoteDictionaries: remoteDictionariesTime - localDictionariesTime,
|
|
117
|
-
pluginDictionaries: pluginDictionariesTime - loadDictionariesStartTime
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
//#endregion
|
|
123
|
-
export { loadDictionaries };
|
|
1
|
+
import{filterInvalidDictionaries as e}from"../filterInvalidDictionaries.mjs";import{formatDictionaries as t}from"../formatDictionary.mjs";import{loadContentDeclarations as n}from"./loadContentDeclaration.mjs";import{loadRemoteDictionaries as r}from"./loadRemoteDictionaries.mjs";import{DictionariesLogger as i}from"./log.mjs";import{ANSIColors as a,colon as o,colorize as s,colorizeKey as c,getAppLogger as l}from"@intlayer/config/client";let u=[];const d=new i,f=e=>{let t=[...u];for(let n of e){let e=t.findIndex(e=>e.dictionaryKey===n.dictionaryKey&&e.type===n.type);e>=0?t[e]=n:t.push(n)}return u=t,d.update(e),t},p=e=>{switch(e){case`built`:case`imported`:case`fetched`:return`✔`;case`error`:return`✖`;default:return`⏲`}},m=e=>{switch(e){case`built`:case`imported`:case`fetched`:return a.GREEN;case`error`:return a.RED;default:return a.BLUE}},h=e=>{if(e.log.mode!==`verbose`)return;let t=l(e),n=new Map;for(let e of u){let t=n.get(e.dictionaryKey)??{};e.type===`local`&&(t.local=e.status),e.type===`remote`&&(t.remote=e.status),n.set(e.dictionaryKey,t)}let r=Array.from(n.keys()).sort((e,t)=>e.localeCompare(t)),i=0;for(let e of r){let t=n.get(e);if(t.local){let e=`[local: ${p(t.local)} ${t.local}]`;e.length>i&&(i=e.length)}}for(let e of r){let l=n.get(e),u=[];if(l.local){let e=s(`${p(l.local)} ${l.local}`,m(l.local)),t=`${a.GREY}[`+s(`local: `,a.GREY)+e+`${a.GREY}]${a.RESET}`,n=`[local: ${p(l.local)} ${l.local}]`,r=Math.max(0,i-n.length);u.push(t+` `.repeat(r))}else u.push(` `.repeat(i));if(l.remote){let e=s(`${p(l.remote)} ${l.remote}`,m(l.remote));u.push(`${a.GREY}[`+s(`distant: `,a.GREY)+e+`${a.GREY}]${a.RESET}`)}t(` - ${o(c(e),{colSize:r})} ${u.join(` `)}`)}},g=async(i,a)=>{let{plugins:o}=a,s=Date.now();l(a)(`Dictionaries:`,{isVerbose:!0});let c=(o??[]).filter(e=>e.loadDictionaries).map(async e=>{try{return await e.loadDictionaries?.({configuration:a})??[]}catch(e){return d.setPluginError(e),[]}}),u=await Promise.all(c).then(e=>e.flat()).then(t=>e(t,a)).then(e=>t(e));d.setPluginTotal(u.length),d.setPluginDone(u.length);let p=Date.now(),m=await n(Array.isArray(i)?i:[i],a,f).then(t=>e(t,a)).then(e=>t(e)),g=Date.now();f(m.map(e=>({dictionaryKey:e.key,type:`local`,status:`built`})));let _=!!(a.editor.clientId&&a.editor.clientSecret);_&&d.setExpectRemote(!0);let v=[];_&&(v=await r(a,f,{onStartRemoteCheck:()=>d.startRemoteCheck(),onStopRemoteCheck:()=>d.stopRemoteCheck(),onError:e=>d.setRemoteError(e)}).then(t=>e(t,a)).then(e=>t(e)));let y=Date.now();return d.finish(),h(a),{localDictionaries:m,remoteDictionaries:v,pluginDictionaries:u,time:{localDictionaries:g-p,remoteDictionaries:y-g,pluginDictionaries:p-s}}};export{g as loadDictionaries};
|
|
124
2
|
//# sourceMappingURL=loadDictionaries.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadDictionaries.mjs","names":["logger"],"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["import {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n getAppLogger,\n} from '@intlayer/config/client';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { formatDictionaries } from '../formatDictionary';\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 const updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const index = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (index >= 0) {\n updated[index] = 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) => {\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 status of loadDictionariesStatus) {\n const rec = byKey.get(status.dictionaryKey) ?? {};\n if (status.type === 'local') rec.local = status.status;\n if (status.type === 'remote') rec.remote = status.status;\n byKey.set(status.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\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n pluginDictionaries: Dictionary[];\n time: {\n localDictionaries: number;\n remoteDictionaries: number;\n pluginDictionaries: number;\n };\n}> => {\n const { plugins } = configuration;\n const loadDictionariesStartTime = Date.now();\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n // Load additional dictionaries via plugins (e.g., ICU JSON ingestion)\n const pluginsWithLoadDictionaries = (plugins ?? []).filter(\n (plugin) => plugin.loadDictionaries\n );\n\n const loadPluginDictionariesPromise = pluginsWithLoadDictionaries.map(\n async (plugin, index) => {\n try {\n const res = await plugin.loadDictionaries?.({\n configuration,\n });\n\n return (res as Dictionary[] | undefined) ?? [];\n } catch (error) {\n logger.setPluginError(error as Error);\n\n return [];\n }\n }\n );\n\n const pluginDictionaries: Dictionary[] = await Promise.all(\n loadPluginDictionariesPromise as Promise<Dictionary[]>[]\n )\n .then((dictionaries) => dictionaries.flat())\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n\n logger.setPluginTotal(pluginDictionaries.length);\n logger.setPluginDone(pluginDictionaries.length);\n\n const pluginDictionariesTime = Date.now();\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n setLoadDictionariesStatus\n )\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n\n const localDictionariesTime = Date.now();\n\n const localDictionariesStatus = localDictionaries.map(\n (dictionary) =>\n ({\n dictionaryKey: dictionary.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\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 .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\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,\n remoteDictionaries,\n pluginDictionaries,\n time: {\n localDictionaries: localDictionariesTime - pluginDictionariesTime,\n remoteDictionaries: remoteDictionariesTime - localDictionariesTime,\n pluginDictionaries: pluginDictionariesTime - loadDictionariesStartTime,\n },\n };\n};\n"],"mappings":";;;;;;;;AA6BA,IAAI,yBAA+C,EAAE;AACrD,MAAMA,WAAS,IAAI,oBAAoB;AAEvC,MAAM,6BAA6B,aAAmC;CACpE,MAAM,UAAgC,CAAC,GAAG,uBAAuB;AAEjE,MAAK,MAAM,YAAY,UAAU;EAC/B,MAAM,QAAQ,QAAQ,WACnB,MACC,EAAE,kBAAkB,SAAS,iBAAiB,EAAE,SAAS,SAAS,KACrE;AACD,MAAI,SAAS,EACX,SAAQ,SAAS;MAEjB,SAAQ,KAAK,SAAS;;AAI1B,0BAAyB;AACzB,UAAO,OAAO,SAAS;AAEvB,QAAO;;AAQT,MAAM,WAAW,WAAyC;AACxD,SAAQ,QAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK,UACH,QAAO;EACT,KAAK,QACH,QAAO;EACT,QACE,QAAO;;;AAIb,MAAM,YAA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,CACE,MAAM,iBACL,0BAA0B,cAAc,cAAc,CACvD,CACA,MAAM,iBAAiB,mBAAmB,aAAa,CAAC;CAE3D,MAAM,wBAAwB,KAAK,KAAK;AAWxC,2BATgC,kBAAkB,KAC/C,gBACE;EACC,eAAe,WAAW;EAC1B,MAAM;EACN,QAAQ;EACT,EACJ,CAEiD;CAElD,MAAM,wBAAwB,QAC5B,cAAc,OAAO,YAAY,cAAc,OAAO,aACvD;AAED,KAAI,sBAEF,UAAO,gBAAgB,KAAK;CAG9B,IAAI,qBAAmC,EAAE;AAEzC,KAAI,sBACF,sBAAqB,MAAM,uBACzB,eACA,2BACA;EACE,0BAA0BA,SAAO,kBAAkB;EACnD,yBAAyBA,SAAO,iBAAiB;EACjD,UAAU,MAAMA,SAAO,eAAe,EAAE;EACzC,CACF,CACE,MAAM,iBACL,0BAA0B,cAAc,cAAc,CACvD,CACA,MAAM,iBAAiB,mBAAmB,aAAa,CAAC;CAG7D,MAAM,yBAAyB,KAAK,KAAK;AAGzC,UAAO,QAAQ;AAEf,cAAa,cAAc;AAE3B,QAAO;EACL;EACA;EACA;EACA,MAAM;GACJ,mBAAmB,wBAAwB;GAC3C,oBAAoB,yBAAyB;GAC7C,oBAAoB,yBAAyB;GAC9C;EACF"}
|
|
1
|
+
{"version":3,"file":"loadDictionaries.mjs","names":["logger"],"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["import {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n getAppLogger,\n} from '@intlayer/config/client';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { formatDictionaries } from '../formatDictionary';\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 const updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const index = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (index >= 0) {\n updated[index] = 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) => {\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 status of loadDictionariesStatus) {\n const rec = byKey.get(status.dictionaryKey) ?? {};\n if (status.type === 'local') rec.local = status.status;\n if (status.type === 'remote') rec.remote = status.status;\n byKey.set(status.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\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n pluginDictionaries: Dictionary[];\n time: {\n localDictionaries: number;\n remoteDictionaries: number;\n pluginDictionaries: number;\n };\n}> => {\n const { plugins } = configuration;\n const loadDictionariesStartTime = Date.now();\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n // Load additional dictionaries via plugins (e.g., ICU JSON ingestion)\n const pluginsWithLoadDictionaries = (plugins ?? []).filter(\n (plugin) => plugin.loadDictionaries\n );\n\n const loadPluginDictionariesPromise = pluginsWithLoadDictionaries.map(\n async (plugin) => {\n try {\n const res = await plugin.loadDictionaries?.({\n configuration,\n });\n\n return (res as Dictionary[] | undefined) ?? [];\n } catch (error) {\n logger.setPluginError(error as Error);\n\n return [];\n }\n }\n );\n\n const pluginDictionaries: Dictionary[] = await Promise.all(\n loadPluginDictionariesPromise as Promise<Dictionary[]>[]\n )\n .then((dictionaries) => dictionaries.flat())\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n\n logger.setPluginTotal(pluginDictionaries.length);\n logger.setPluginDone(pluginDictionaries.length);\n\n const pluginDictionariesTime = Date.now();\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n setLoadDictionariesStatus\n )\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n\n const localDictionariesTime = Date.now();\n\n const localDictionariesStatus = localDictionaries.map(\n (dictionary) =>\n ({\n dictionaryKey: dictionary.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\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 .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\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,\n remoteDictionaries,\n pluginDictionaries,\n time: {\n localDictionaries: localDictionariesTime - pluginDictionariesTime,\n remoteDictionaries: remoteDictionariesTime - localDictionariesTime,\n pluginDictionaries: pluginDictionariesTime - loadDictionariesStartTime,\n },\n };\n};\n"],"mappings":"ubA6BA,IAAI,EAA+C,EAAE,CACrD,MAAMA,EAAS,IAAI,EAEb,EAA6B,GAAmC,CACpE,IAAM,EAAgC,CAAC,GAAG,EAAuB,CAEjE,IAAK,IAAM,KAAY,EAAU,CAC/B,IAAM,EAAQ,EAAQ,UACnB,GACC,EAAE,gBAAkB,EAAS,eAAiB,EAAE,OAAS,EAAS,KACrE,CACG,GAAS,EACX,EAAQ,GAAS,EAEjB,EAAQ,KAAK,EAAS,CAO1B,MAHA,GAAyB,EACzB,EAAO,OAAO,EAAS,CAEhB,GAQH,EAAW,GAAyC,CACxD,OAAQ,EAAR,CACE,IAAK,QACL,IAAK,WACL,IAAK,UACH,MAAO,IACT,IAAK,QACH,MAAO,IACT,QACE,MAAO,MAIP,EAAY,GAAyC,CACzD,OAAQ,EAAR,CACE,IAAK,QACL,IAAK,WACL,IAAK,UACH,OAAO,EAAW,MACpB,IAAK,QACH,OAAO,EAAW,IACpB,QACE,OAAO,EAAW,OAIlB,EAAgB,GAAkC,CACtD,GAAI,EAAc,IAAI,OAAS,UAAW,OAE1C,IAAM,EAAY,EAAa,EAAc,CAGvC,EAAQ,IAAI,IAClB,IAAK,IAAM,KAAU,EAAwB,CAC3C,IAAM,EAAM,EAAM,IAAI,EAAO,cAAc,EAAI,EAAE,CAC7C,EAAO,OAAS,UAAS,EAAI,MAAQ,EAAO,QAC5C,EAAO,OAAS,WAAU,EAAI,OAAS,EAAO,QAClD,EAAM,IAAI,EAAO,cAAe,EAAI,CAGtC,IAAM,EAAO,MAAM,KAAK,EAAM,MAAM,CAAC,CAAC,MAAM,EAAG,IAAM,EAAE,cAAc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,mBAAoB,EAAyB,EAC7C,mBAAoB,EAAyB,EAC9C,CACF"}
|
|
@@ -1,27 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { mkdir } from "node:fs/promises";
|
|
3
|
-
import { relative, resolve } from "node:path";
|
|
4
|
-
|
|
5
|
-
//#region src/loadDictionaries/loadLocalDictionaries.ts
|
|
6
|
-
const loadLocalDictionaries = async (contentDeclarationsPaths, configuration) => {
|
|
7
|
-
const { content, system } = configuration;
|
|
8
|
-
const { baseDir } = content;
|
|
9
|
-
const { dictionariesDir } = system;
|
|
10
|
-
if (typeof contentDeclarationsPaths === "string") contentDeclarationsPaths = [contentDeclarationsPaths];
|
|
11
|
-
await mkdir(resolve(dictionariesDir), { recursive: true });
|
|
12
|
-
const result = [];
|
|
13
|
-
for await (const contentDeclarationPath of contentDeclarationsPaths) {
|
|
14
|
-
const dictionary = await loadContentDeclarations([contentDeclarationPath], configuration);
|
|
15
|
-
const relativeFilePath = relative(baseDir, contentDeclarationPath);
|
|
16
|
-
const dictionaryWithPath = {
|
|
17
|
-
...dictionary[0],
|
|
18
|
-
filePath: relativeFilePath
|
|
19
|
-
};
|
|
20
|
-
result.push(dictionaryWithPath);
|
|
21
|
-
}
|
|
22
|
-
return result;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
//#endregion
|
|
26
|
-
export { loadLocalDictionaries };
|
|
1
|
+
import{loadContentDeclarations as e}from"./loadContentDeclaration.mjs";import{mkdir as t}from"node:fs/promises";import{relative as n,resolve as r}from"node:path";const i=async(i,a)=>{let{content:o,system:s}=a,{baseDir:c}=o,{dictionariesDir:l}=s;typeof i==`string`&&(i=[i]),await t(r(l),{recursive:!0});let u=[];for await(let t of i){let r=await e([t],a),i=n(c,t),o={...r[0],filePath:i};u.push(o)}return u};export{i as loadLocalDictionaries};
|
|
27
2
|
//# sourceMappingURL=loadLocalDictionaries.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadLocalDictionaries.mjs","names":[],"sources":["../../../src/loadDictionaries/loadLocalDictionaries.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { loadContentDeclarations } from './loadContentDeclaration';\n\nexport const loadLocalDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig\n): Promise<Dictionary[]> => {\n const { content, system } = configuration;\n const { baseDir } = content;\n const { dictionariesDir } = system;\n\n if (typeof contentDeclarationsPaths === 'string') {\n contentDeclarationsPaths = [contentDeclarationsPaths];\n }\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n const result: Dictionary[] = [];\n\n for await (const contentDeclarationPath of contentDeclarationsPaths) {\n const dictionary = await loadContentDeclarations(\n [contentDeclarationPath],\n configuration\n );\n\n const relativeFilePath = relative(baseDir, contentDeclarationPath);\n\n const dictionaryWithPath: Dictionary = {\n ...dictionary[0],\n filePath: relativeFilePath,\n };\n\n result.push(dictionaryWithPath);\n }\n\n return result;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"loadLocalDictionaries.mjs","names":[],"sources":["../../../src/loadDictionaries/loadLocalDictionaries.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { loadContentDeclarations } from './loadContentDeclaration';\n\nexport const loadLocalDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig\n): Promise<Dictionary[]> => {\n const { content, system } = configuration;\n const { baseDir } = content;\n const { dictionariesDir } = system;\n\n if (typeof contentDeclarationsPaths === 'string') {\n contentDeclarationsPaths = [contentDeclarationsPaths];\n }\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n const result: Dictionary[] = [];\n\n for await (const contentDeclarationPath of contentDeclarationsPaths) {\n const dictionary = await loadContentDeclarations(\n [contentDeclarationPath],\n configuration\n );\n\n const relativeFilePath = relative(baseDir, contentDeclarationPath);\n\n const dictionaryWithPath: Dictionary = {\n ...dictionary[0],\n filePath: relativeFilePath,\n };\n\n result.push(dictionaryWithPath);\n }\n\n return result;\n};\n"],"mappings":"kKAKA,MAAa,EAAwB,MACnC,EACA,IAC0B,CAC1B,GAAM,CAAE,UAAS,UAAW,EACtB,CAAE,WAAY,EACd,CAAE,mBAAoB,EAExB,OAAO,GAA6B,WACtC,EAA2B,CAAC,EAAyB,EAIvD,MAAM,EAAM,EAAQ,EAAgB,CAAE,CAAE,UAAW,GAAM,CAAC,CAE1D,IAAM,EAAuB,EAAE,CAE/B,UAAW,IAAM,KAA0B,EAA0B,CACnE,IAAM,EAAa,MAAM,EACvB,CAAC,EAAuB,CACxB,EACD,CAEK,EAAmB,EAAS,EAAS,EAAuB,CAE5D,EAAiC,CACrC,GAAG,EAAW,GACd,SAAU,EACX,CAED,EAAO,KAAK,EAAmB,CAGjC,OAAO"}
|
|
@@ -1,59 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { sortAlphabetically } from "../utils/sortAlphabetically.mjs";
|
|
3
|
-
import { getConfiguration } from "@intlayer/config";
|
|
4
|
-
import { getIntlayerAPIProxy } from "@intlayer/api";
|
|
5
|
-
import { getRemoteDictionaries } from "@intlayer/remote-dictionaries-entry";
|
|
6
|
-
|
|
7
|
-
//#region src/loadDictionaries/loadRemoteDictionaries.ts
|
|
8
|
-
const formatDistantDictionaries = (dictionaries) => dictionaries.map((dict) => ({
|
|
9
|
-
...dict,
|
|
10
|
-
localId: `${dict.key}::remote::${dict.id}`,
|
|
11
|
-
location: "remote"
|
|
12
|
-
}));
|
|
13
|
-
const loadRemoteDictionaries = async (configuration = getConfiguration(), onStatusUpdate, options) => {
|
|
14
|
-
const { editor } = configuration;
|
|
15
|
-
const remoteDictionariesRecord = getRemoteDictionaries(configuration);
|
|
16
|
-
if (!Boolean(editor.clientId && editor.clientSecret)) return [];
|
|
17
|
-
try {
|
|
18
|
-
options?.onStartRemoteCheck?.();
|
|
19
|
-
const distantDictionaryUpdateTimeStamp = (await getIntlayerAPIProxy(void 0, configuration).dictionary.getDictionariesUpdateTimestamp()).data;
|
|
20
|
-
if (!distantDictionaryUpdateTimeStamp) throw new Error("No distant dictionaries found");
|
|
21
|
-
const dictionariesIdToFetch = Object.entries(distantDictionaryUpdateTimeStamp).filter(([dictionaryId, data]) => {
|
|
22
|
-
if (!data.updatedAt) return true;
|
|
23
|
-
const local = remoteDictionariesRecord[data.key]?.find((dictionary) => dictionary.id === dictionaryId);
|
|
24
|
-
if (!local) return true;
|
|
25
|
-
const localUpdatedAtRaw = local?.updatedAt;
|
|
26
|
-
const localUpdatedAt = typeof localUpdatedAtRaw === "number" ? localUpdatedAtRaw : localUpdatedAtRaw ? new Date(localUpdatedAtRaw).getTime() : void 0;
|
|
27
|
-
if (typeof localUpdatedAt !== "number") return true;
|
|
28
|
-
return data.updatedAt > localUpdatedAt;
|
|
29
|
-
});
|
|
30
|
-
const cachedDictionaries = Object.values(remoteDictionariesRecord).flat().filter((dictionary) => {
|
|
31
|
-
const remoteUpdatedAt = distantDictionaryUpdateTimeStamp[dictionary.id].updatedAt;
|
|
32
|
-
const localUpdatedAtRaw = dictionary.updatedAt;
|
|
33
|
-
const localUpdatedAt = typeof localUpdatedAtRaw === "number" ? localUpdatedAtRaw : localUpdatedAtRaw ? new Date(localUpdatedAtRaw).getTime() : void 0;
|
|
34
|
-
return typeof localUpdatedAt === "number" && typeof remoteUpdatedAt === "number" && localUpdatedAt >= remoteUpdatedAt;
|
|
35
|
-
});
|
|
36
|
-
if (cachedDictionaries.length > 0) onStatusUpdate?.(cachedDictionaries.map((dictionary) => ({
|
|
37
|
-
dictionaryKey: dictionary.key,
|
|
38
|
-
type: "remote",
|
|
39
|
-
status: "imported"
|
|
40
|
-
})));
|
|
41
|
-
const orderedDistantDictionaryKeys = dictionariesIdToFetch.map(([, data]) => data.key).sort(sortAlphabetically);
|
|
42
|
-
if (orderedDistantDictionaryKeys.length > 0) onStatusUpdate?.(orderedDistantDictionaryKeys.map((key) => ({
|
|
43
|
-
dictionaryKey: key,
|
|
44
|
-
type: "remote",
|
|
45
|
-
status: "pending"
|
|
46
|
-
})));
|
|
47
|
-
const distantDictionaries = formatDistantDictionaries(await fetchDistantDictionaries({ dictionaryKeys: orderedDistantDictionaryKeys }, onStatusUpdate));
|
|
48
|
-
return [...cachedDictionaries, ...distantDictionaries];
|
|
49
|
-
} catch (error) {
|
|
50
|
-
options?.onError?.(error);
|
|
51
|
-
return [];
|
|
52
|
-
} finally {
|
|
53
|
-
options?.onStopRemoteCheck?.();
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
//#endregion
|
|
58
|
-
export { formatDistantDictionaries, loadRemoteDictionaries };
|
|
1
|
+
import{fetchDistantDictionaries as e}from"../fetchDistantDictionaries.mjs";import{sortAlphabetically as t}from"../utils/sortAlphabetically.mjs";import{getConfiguration as n}from"@intlayer/config/node";import{getIntlayerAPIProxy as r}from"@intlayer/api";import{getRemoteDictionaries as i}from"@intlayer/remote-dictionaries-entry";const a=e=>e.map(e=>({...e,localId:`${e.key}::remote::${e.id}`,location:`remote`})),o=async(o=n(),s,c)=>{let{editor:l}=o,u=i(o);if(!(l.clientId&&l.clientSecret))return[];try{c?.onStartRemoteCheck?.();let n=(await r(void 0,o).dictionary.getDictionariesUpdateTimestamp()).data;if(!n)throw Error(`No distant dictionaries found`);let i=Object.entries(n).filter(([e,t])=>{if(!t.updatedAt)return!0;let n=u[t.key]?.find(t=>t.id===e);if(!n)return!0;let r=n?.updatedAt,i=typeof r==`number`?r:r?new Date(r).getTime():void 0;return typeof i==`number`?t.updatedAt>i:!0}),l=Object.values(u).flat().filter(e=>{let t=n[e.id].updatedAt,r=e.updatedAt,i=typeof r==`number`?r:r?new Date(r).getTime():void 0;return typeof i==`number`&&typeof t==`number`&&i>=t});l.length>0&&s?.(l.map(e=>({dictionaryKey:e.key,type:`remote`,status:`imported`})));let d=i.map(([,e])=>e.key).sort(t);d.length>0&&s?.(d.map(e=>({dictionaryKey:e,type:`remote`,status:`pending`})));let f=a(await e({dictionaryKeys:d},s));return[...l,...f]}catch(e){return c?.onError?.(e),[]}finally{c?.onStopRemoteCheck?.()}};export{a as formatDistantDictionaries,o as loadRemoteDictionaries};
|
|
59
2
|
//# sourceMappingURL=loadRemoteDictionaries.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadRemoteDictionaries.mjs","names":[],"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 { getRemoteDictionaries } from '@intlayer/remote-dictionaries-entry';\nimport type { Dictionary, DictionaryId, DictionaryKey } from '@intlayer/types';\nimport { fetchDistantDictionaries } from '../fetchDistantDictionaries';\nimport type { DictionariesStatus } from '../loadDictionaries/loadDictionaries';\nimport { sortAlphabetically } from '../utils/sortAlphabetically';\n\nexport const formatDistantDictionaries = (\n dictionaries: (DictionaryAPI | Dictionary)[]\n): Dictionary[] =>\n dictionaries.map((dict) => ({\n ...dict,\n localId: `${dict.key}::remote::${dict.id}`,\n location: 'remote' 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<Dictionary[]> => {\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<\n DictionaryId,\n { key: DictionaryKey; updatedAt: number }\n > | null = getDictionariesKeysResult.data;\n\n if (!distantDictionaryUpdateTimeStamp) {\n throw new Error('No distant dictionaries found');\n }\n\n const dictionariesIdToFetch = Object.entries(\n distantDictionaryUpdateTimeStamp\n ).filter(([dictionaryId, data]) => {\n // If remote doesn't provide updatedAt, fetch to be safe\n if (!data.updatedAt) return true;\n\n // If no local cache exists, fetch\n const local: Dictionary | undefined = remoteDictionariesRecord[\n data.key\n ]?.find((dictionary) => dictionary.id === dictionaryId);\n if (!local) return true;\n\n const localUpdatedAtRaw = (local as any)?.updatedAt as\n | number\n | string\n | undefined;\n\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\n return data.updatedAt > localUpdatedAt;\n });\n\n const flatRemoteDictionariesRecord: DictionaryAPI[] = Object.values(\n remoteDictionariesRecord\n ).flat();\n\n const cachedDictionaries: Dictionary[] =\n flatRemoteDictionariesRecord.filter((dictionary) => {\n const remoteUpdatedAt =\n distantDictionaryUpdateTimeStamp[dictionary.id!].updatedAt;\n\n const localUpdatedAtRaw = dictionary.updatedAt;\n\n const localUpdatedAt =\n typeof localUpdatedAtRaw === 'number'\n ? localUpdatedAtRaw\n : localUpdatedAtRaw\n ? new Date(localUpdatedAtRaw).getTime()\n : undefined;\n\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\n // Report cached as already imported\n if (cachedDictionaries.length > 0) {\n onStatusUpdate?.(\n cachedDictionaries.map((dictionary) => ({\n dictionaryKey: dictionary.key,\n type: 'remote',\n status: 'imported',\n }))\n );\n }\n\n const orderedDistantDictionaryKeys = dictionariesIdToFetch\n .map(([, data]) => data.key)\n .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: Dictionary[] = 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":"
|
|
1
|
+
{"version":3,"file":"loadRemoteDictionaries.mjs","names":[],"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/node';\nimport { getRemoteDictionaries } from '@intlayer/remote-dictionaries-entry';\nimport type { Dictionary, DictionaryId, DictionaryKey } from '@intlayer/types';\nimport { fetchDistantDictionaries } from '../fetchDistantDictionaries';\nimport type { DictionariesStatus } from '../loadDictionaries/loadDictionaries';\nimport { sortAlphabetically } from '../utils/sortAlphabetically';\n\nexport const formatDistantDictionaries = (\n dictionaries: (DictionaryAPI | Dictionary)[]\n): Dictionary[] =>\n dictionaries.map((dict) => ({\n ...dict,\n localId: `${dict.key}::remote::${dict.id}`,\n location: 'remote' 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<Dictionary[]> => {\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<\n DictionaryId,\n { key: DictionaryKey; updatedAt: number }\n > | null = getDictionariesKeysResult.data;\n\n if (!distantDictionaryUpdateTimeStamp) {\n throw new Error('No distant dictionaries found');\n }\n\n const dictionariesIdToFetch = Object.entries(\n distantDictionaryUpdateTimeStamp\n ).filter(([dictionaryId, data]) => {\n // If remote doesn't provide updatedAt, fetch to be safe\n if (!data.updatedAt) return true;\n\n // If no local cache exists, fetch\n const local: Dictionary | undefined = remoteDictionariesRecord[\n data.key\n ]?.find((dictionary) => dictionary.id === dictionaryId);\n if (!local) return true;\n\n const localUpdatedAtRaw = (local as any)?.updatedAt as\n | number\n | string\n | undefined;\n\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\n return data.updatedAt > localUpdatedAt;\n });\n\n const flatRemoteDictionariesRecord: DictionaryAPI[] = Object.values(\n remoteDictionariesRecord\n ).flat();\n\n const cachedDictionaries: Dictionary[] =\n flatRemoteDictionariesRecord.filter((dictionary) => {\n const remoteUpdatedAt =\n distantDictionaryUpdateTimeStamp[dictionary.id!].updatedAt;\n\n const localUpdatedAtRaw = dictionary.updatedAt;\n\n const localUpdatedAt =\n typeof localUpdatedAtRaw === 'number'\n ? localUpdatedAtRaw\n : localUpdatedAtRaw\n ? new Date(localUpdatedAtRaw).getTime()\n : undefined;\n\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\n // Report cached as already imported\n if (cachedDictionaries.length > 0) {\n onStatusUpdate?.(\n cachedDictionaries.map((dictionary) => ({\n dictionaryKey: dictionary.key,\n type: 'remote',\n status: 'imported',\n }))\n );\n }\n\n const orderedDistantDictionaryKeys = dictionariesIdToFetch\n .map(([, data]) => data.key)\n .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: Dictionary[] = 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":"yUAUA,MAAa,EACX,GAEA,EAAa,IAAK,IAAU,CAC1B,GAAG,EACH,QAAS,GAAG,EAAK,IAAI,YAAY,EAAK,KACtC,SAAU,SACX,EAAE,CAEQ,EAAyB,MACpC,EAAgB,GAAkB,CAClC,EACA,IAK0B,CAC1B,GAAM,CAAE,UAAW,EACb,EAA2B,EAAsB,EAAc,CAIrE,GAAI,EAFkC,EAAO,UAAY,EAAO,cAEpC,MAAO,EAAE,CAErC,GAAI,CACF,GAAS,sBAAsB,CAQ/B,IAAM,GAFJ,MAJkB,EAAoB,IAAA,GAAW,EAAc,CAI7C,WAAW,gCAAgC,EAK1B,KAErC,GAAI,CAAC,EACH,MAAU,MAAM,gCAAgC,CAGlD,IAAM,E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DictionariesLogger = class {
|
|
6
|
-
statuses = [];
|
|
7
|
-
spinnerTimer = null;
|
|
8
|
-
spinnerIndex = 0;
|
|
9
|
-
renderedLines = 0;
|
|
10
|
-
spinnerFrames = spinnerFrames;
|
|
11
|
-
isFinished = false;
|
|
12
|
-
prefix;
|
|
13
|
-
lastRenderedState = "";
|
|
14
|
-
remoteCheckInProgress = false;
|
|
15
|
-
expectRemote = false;
|
|
16
|
-
remoteError;
|
|
17
|
-
pluginTotal = 0;
|
|
18
|
-
pluginDone = 0;
|
|
19
|
-
pluginError;
|
|
20
|
-
constructor() {
|
|
21
|
-
this.prefix = configuration?.log?.prefix ?? "";
|
|
22
|
-
}
|
|
23
|
-
setExpectRemote(expect) {
|
|
24
|
-
this.expectRemote = expect;
|
|
25
|
-
}
|
|
26
|
-
startRemoteCheck() {
|
|
27
|
-
if (this.isFinished) return;
|
|
28
|
-
this.remoteCheckInProgress = true;
|
|
29
|
-
this.startSpinner();
|
|
30
|
-
this.render();
|
|
31
|
-
}
|
|
32
|
-
stopRemoteCheck() {
|
|
33
|
-
this.remoteCheckInProgress = false;
|
|
34
|
-
}
|
|
35
|
-
update(newStatuses) {
|
|
36
|
-
if (this.isFinished) return;
|
|
37
|
-
for (const status of newStatuses) {
|
|
38
|
-
const index = this.statuses.findIndex((s) => s.dictionaryKey === status.dictionaryKey && s.type === status.type);
|
|
39
|
-
if (index >= 0) this.statuses[index] = status;
|
|
40
|
-
else this.statuses.push(status);
|
|
41
|
-
}
|
|
42
|
-
const { remoteTotal } = this.computeProgress();
|
|
43
|
-
if (this.expectRemote && !this.remoteCheckInProgress && remoteTotal === 0) return;
|
|
44
|
-
this.startSpinner();
|
|
45
|
-
this.render();
|
|
46
|
-
}
|
|
47
|
-
finish() {
|
|
48
|
-
this.isFinished = true;
|
|
49
|
-
this.stopSpinner();
|
|
50
|
-
this.render();
|
|
51
|
-
}
|
|
52
|
-
startSpinner() {
|
|
53
|
-
if (this.spinnerTimer || this.isFinished) return;
|
|
54
|
-
this.spinnerTimer = setInterval(() => {
|
|
55
|
-
this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;
|
|
56
|
-
this.render();
|
|
57
|
-
}, 100);
|
|
58
|
-
}
|
|
59
|
-
stopSpinner() {
|
|
60
|
-
if (!this.spinnerTimer) return;
|
|
61
|
-
clearInterval(this.spinnerTimer);
|
|
62
|
-
this.spinnerTimer = null;
|
|
63
|
-
}
|
|
64
|
-
setRemoteError = (error) => {
|
|
65
|
-
this.remoteError = extractErrorMessage(error);
|
|
66
|
-
this.stopRemoteCheck();
|
|
67
|
-
this.render();
|
|
68
|
-
};
|
|
69
|
-
setPluginTotal(total) {
|
|
70
|
-
if (this.isFinished) return;
|
|
71
|
-
this.pluginTotal = total;
|
|
72
|
-
if (total > 0) this.startSpinner();
|
|
73
|
-
this.render();
|
|
74
|
-
}
|
|
75
|
-
setPluginDone(done) {
|
|
76
|
-
if (this.isFinished) return;
|
|
77
|
-
this.pluginDone = done;
|
|
78
|
-
this.render();
|
|
79
|
-
}
|
|
80
|
-
setPluginError(error) {
|
|
81
|
-
if (this.isFinished) return;
|
|
82
|
-
this.pluginError = extractErrorMessage(error);
|
|
83
|
-
this.render();
|
|
84
|
-
}
|
|
85
|
-
render() {
|
|
86
|
-
const { localTotal, localDone, remoteTotal, remoteDone, pluginTotal, pluginDone } = this.computeProgress();
|
|
87
|
-
const frame = this.spinnerFrames[this.spinnerIndex];
|
|
88
|
-
const clock = colorize(frame, ANSIColors.BLUE);
|
|
89
|
-
const lines = [];
|
|
90
|
-
const isLocalDone = localDone === localTotal;
|
|
91
|
-
const isRemoteDone = remoteDone === remoteTotal;
|
|
92
|
-
const isPluginDone = pluginDone === pluginTotal;
|
|
93
|
-
if (!(this.expectRemote && this.remoteCheckInProgress && remoteTotal === 0)) if (isLocalDone) lines.push(`${this.prefix} ${v} Local content: ${colorize(`${localDone}`, ANSIColors.GREEN)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`);
|
|
94
|
-
else lines.push(`${this.prefix} ${clock} Local content: ${colorize(`${localDone}`, ANSIColors.BLUE)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`);
|
|
95
|
-
if (remoteTotal > 0 || this.remoteCheckInProgress || this.remoteError) if (this.remoteError) lines.push(`${this.prefix} ${x} Remote content: ${colorize(this.remoteError, ANSIColors.RED)}`);
|
|
96
|
-
else if (remoteTotal === 0) lines.push(`${this.prefix} ${clock} Remote content: ${colorize("Check server", ANSIColors.BLUE)}`);
|
|
97
|
-
else if (isRemoteDone) lines.push(`${this.prefix} ${v} Remote content: ${colorize(`${remoteDone}`, ANSIColors.GREEN)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`);
|
|
98
|
-
else lines.push(`${this.prefix} ${clock} Remote content: ${colorize(`${remoteDone}`, ANSIColors.BLUE)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`);
|
|
99
|
-
if (pluginTotal > 0 || this.pluginError) if (this.pluginError) lines.push(`${this.prefix} ${x} Plugin content: ${colorize(this.pluginError, ANSIColors.RED)}`);
|
|
100
|
-
else if (isPluginDone) lines.push(`${this.prefix} ${v} Plugin content: ${colorize(`${pluginDone}`, ANSIColors.GREEN)}${colorize(`/${pluginTotal}`, ANSIColors.GREY)}`);
|
|
101
|
-
else lines.push(`${this.prefix} ${clock} Plugin content: ${colorize(`${pluginDone}`, ANSIColors.BLUE)}${colorize(`/${pluginTotal}`, ANSIColors.GREY)}`);
|
|
102
|
-
const currentState = lines.join("\n");
|
|
103
|
-
if (currentState === this.lastRenderedState) return;
|
|
104
|
-
this.lastRenderedState = currentState;
|
|
105
|
-
if (this.renderedLines > 0) process.stdout.write(`\x1b[${this.renderedLines}F`);
|
|
106
|
-
const totalLinesToClear = Math.max(this.renderedLines, lines.length);
|
|
107
|
-
for (let i = 0; i < totalLinesToClear; i++) {
|
|
108
|
-
process.stdout.write("\x1B[2K");
|
|
109
|
-
const line = lines[i];
|
|
110
|
-
if (line !== void 0) process.stdout.write(line);
|
|
111
|
-
process.stdout.write("\n");
|
|
112
|
-
}
|
|
113
|
-
this.renderedLines = lines.length;
|
|
114
|
-
}
|
|
115
|
-
computeProgress() {
|
|
116
|
-
const localKeys = new Set(this.statuses.filter((s) => s.type === "local").map((s) => s.dictionaryKey));
|
|
117
|
-
const localDoneKeys = new Set(this.statuses.filter((s) => s.type === "local" && (s.status === "built" || s.status === "error")).map((s) => s.dictionaryKey));
|
|
118
|
-
const remoteKeys = new Set(this.statuses.filter((s) => s.type === "remote").map((s) => s.dictionaryKey));
|
|
119
|
-
const remoteDoneKeys = new Set(this.statuses.filter((s) => s.type === "remote" && (s.status === "fetched" || s.status === "imported" || s.status === "error")).map((s) => s.dictionaryKey));
|
|
120
|
-
return {
|
|
121
|
-
localTotal: localKeys.size,
|
|
122
|
-
localDone: localDoneKeys.size,
|
|
123
|
-
remoteTotal: remoteKeys.size,
|
|
124
|
-
remoteDone: remoteDoneKeys.size,
|
|
125
|
-
pluginTotal: this.pluginTotal,
|
|
126
|
-
pluginDone: this.pluginDone
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
//#endregion
|
|
132
|
-
export { DictionariesLogger };
|
|
1
|
+
import{ANSIColors as e,colorize as t,extractErrorMessage as n,spinnerFrames as r,v as i,x as a}from"@intlayer/config/client";import o from"@intlayer/config/built";var s=class{statuses=[];spinnerTimer=null;spinnerIndex=0;renderedLines=0;spinnerFrames=r;isFinished=!1;prefix;lastRenderedState=``;remoteCheckInProgress=!1;expectRemote=!1;remoteError;pluginTotal=0;pluginDone=0;pluginError;constructor(){this.prefix=o?.log?.prefix??``}setExpectRemote(e){this.expectRemote=e}startRemoteCheck(){this.isFinished||(this.remoteCheckInProgress=!0,this.startSpinner(),this.render())}stopRemoteCheck(){this.remoteCheckInProgress=!1}update(e){if(this.isFinished)return;for(let t of e){let e=this.statuses.findIndex(e=>e.dictionaryKey===t.dictionaryKey&&e.type===t.type);e>=0?this.statuses[e]=t:this.statuses.push(t)}let{remoteTotal:t}=this.computeProgress();this.expectRemote&&!this.remoteCheckInProgress&&t===0||(this.startSpinner(),this.render())}finish(){this.isFinished=!0,this.stopSpinner(),this.render()}startSpinner(){this.spinnerTimer||this.isFinished||(this.spinnerTimer=setInterval(()=>{this.spinnerIndex=(this.spinnerIndex+1)%this.spinnerFrames.length,this.render()},100))}stopSpinner(){this.spinnerTimer&&=(clearInterval(this.spinnerTimer),null)}setRemoteError=e=>{this.remoteError=n(e),this.stopRemoteCheck(),this.render()};setPluginTotal(e){this.isFinished||(this.pluginTotal=e,e>0&&this.startSpinner(),this.render())}setPluginDone(e){this.isFinished||(this.pluginDone=e,this.render())}setPluginError(e){this.isFinished||(this.pluginError=n(e),this.render())}render(){let{localTotal:n,localDone:r,remoteTotal:o,remoteDone:s,pluginTotal:c,pluginDone:l}=this.computeProgress(),u=this.spinnerFrames[this.spinnerIndex],d=t(u,e.BLUE),f=[],p=r===n,m=s===o,h=l===c;this.expectRemote&&this.remoteCheckInProgress&&o===0||(p?f.push(`${this.prefix} ${i} Local content: ${t(`${r}`,e.GREEN)}${t(`/${n}`,e.GREY)}`):f.push(`${this.prefix} ${d} Local content: ${t(`${r}`,e.BLUE)}${t(`/${n}`,e.GREY)}`)),(o>0||this.remoteCheckInProgress||this.remoteError)&&(this.remoteError?f.push(`${this.prefix} ${a} Remote content: ${t(this.remoteError,e.RED)}`):o===0?f.push(`${this.prefix} ${d} Remote content: ${t(`Check server`,e.BLUE)}`):m?f.push(`${this.prefix} ${i} Remote content: ${t(`${s}`,e.GREEN)}${t(`/${o}`,e.GREY)}`):f.push(`${this.prefix} ${d} Remote content: ${t(`${s}`,e.BLUE)}${t(`/${o}`,e.GREY)}`)),(c>0||this.pluginError)&&(this.pluginError?f.push(`${this.prefix} ${a} Plugin content: ${t(this.pluginError,e.RED)}`):h?f.push(`${this.prefix} ${i} Plugin content: ${t(`${l}`,e.GREEN)}${t(`/${c}`,e.GREY)}`):f.push(`${this.prefix} ${d} Plugin content: ${t(`${l}`,e.BLUE)}${t(`/${c}`,e.GREY)}`));let g=f.join(`
|
|
2
|
+
`);if(g===this.lastRenderedState)return;this.lastRenderedState=g,this.renderedLines>0&&process.stdout.write(`\x1b[${this.renderedLines}F`);let _=Math.max(this.renderedLines,f.length);for(let e=0;e<_;e++){process.stdout.write(`\x1B[2K`);let t=f[e];t!==void 0&&process.stdout.write(t),process.stdout.write(`
|
|
3
|
+
`)}this.renderedLines=f.length}computeProgress(){let e=new Set(this.statuses.filter(e=>e.type===`local`).map(e=>e.dictionaryKey)),t=new Set(this.statuses.filter(e=>e.type===`local`&&(e.status===`built`||e.status===`error`)).map(e=>e.dictionaryKey)),n=new Set(this.statuses.filter(e=>e.type===`remote`).map(e=>e.dictionaryKey)),r=new Set(this.statuses.filter(e=>e.type===`remote`&&(e.status===`fetched`||e.status===`imported`||e.status===`error`)).map(e=>e.dictionaryKey));return{localTotal:e.size,localDone:t.size,remoteTotal:n.size,remoteDone:r.size,pluginTotal:this.pluginTotal,pluginDone:this.pluginDone}}};export{s as DictionariesLogger};
|
|
133
4
|
//# sourceMappingURL=log.mjs.map
|