@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
package/dist/esm/build.mjs
CHANGED
|
@@ -1,24 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { processContentDeclaration } from "./buildIntlayerDictionary/processContentDeclaration.mjs";
|
|
3
|
-
import { generateDictionaryListContent } from "./createDictionaryEntryPoint/generateDictionaryListContent.mjs";
|
|
4
|
-
import { getBuiltDictionariesPath } from "./createDictionaryEntryPoint/getBuiltDictionariesPath.mjs";
|
|
5
|
-
import { getBuiltDynamicDictionariesPath } from "./createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs";
|
|
6
|
-
import { getBuiltFetchDictionariesPath } from "./createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs";
|
|
7
|
-
import { getBuiltRemoteDictionariesPath } from "./createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs";
|
|
8
|
-
import { getBuiltUnmergedDictionariesPath } from "./createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs";
|
|
9
|
-
import { createDictionaryEntryPoint } from "./createDictionaryEntryPoint/createDictionaryEntryPoint.mjs";
|
|
10
|
-
import { createModuleAugmentation, getTypeName } from "./createType/createModuleAugmentation.mjs";
|
|
11
|
-
import { createTypes, generateTypeScriptType } from "./createType/createType.mjs";
|
|
12
|
-
import { formatLocalDictionaries, loadContentDeclarations } from "./loadDictionaries/loadContentDeclaration.mjs";
|
|
13
|
-
import { formatDistantDictionaries, loadRemoteDictionaries } from "./loadDictionaries/loadRemoteDictionaries.mjs";
|
|
14
|
-
import { loadDictionaries } from "./loadDictionaries/loadDictionaries.mjs";
|
|
15
|
-
import { loadLocalDictionaries } from "./loadDictionaries/loadLocalDictionaries.mjs";
|
|
16
|
-
import { isCachedConfigurationUpToDate, writeConfiguration } from "./writeConfiguration/index.mjs";
|
|
17
|
-
import { prepareIntlayer } from "./prepareIntlayer.mjs";
|
|
18
|
-
import { detectExportedComponentName } from "./writeContentDeclaration/detectExportedComponentName.mjs";
|
|
19
|
-
import { detectFormatCommand } from "./writeContentDeclaration/detectFormatCommand.mjs";
|
|
20
|
-
import { transformJSFile } from "./writeContentDeclaration/transformJSFile.mjs";
|
|
21
|
-
import { writeJSFile } from "./writeContentDeclaration/writeJSFile.mjs";
|
|
22
|
-
import { writeContentDeclaration } from "./writeContentDeclaration/writeContentDeclaration.mjs";
|
|
23
|
-
|
|
24
|
-
export { buildDictionary, createDictionaryEntryPoint, createModuleAugmentation, createTypes, detectExportedComponentName, detectFormatCommand, formatDistantDictionaries, formatLocalDictionaries, generateDictionaryListContent, generateTypeScriptType, getBuiltDictionariesPath, getBuiltDynamicDictionariesPath, getBuiltFetchDictionariesPath, getBuiltRemoteDictionariesPath, getBuiltUnmergedDictionariesPath, getTypeName, isCachedConfigurationUpToDate, loadContentDeclarations, loadDictionaries, loadLocalDictionaries, loadRemoteDictionaries, prepareIntlayer, processContentDeclaration, transformJSFile, writeConfiguration, writeContentDeclaration, writeJSFile };
|
|
1
|
+
import{buildDictionary as e}from"./buildIntlayerDictionary/buildIntlayerDictionary.mjs";import{processContentDeclaration as t}from"./buildIntlayerDictionary/processContentDeclaration.mjs";import{cleanOutputDir as n}from"./cleanOutputDir.mjs";import{generateDictionaryListContent as r}from"./createDictionaryEntryPoint/generateDictionaryListContent.mjs";import{getBuiltDictionariesPath as i}from"./createDictionaryEntryPoint/getBuiltDictionariesPath.mjs";import{getBuiltDynamicDictionariesPath as a}from"./createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs";import{getBuiltFetchDictionariesPath as o}from"./createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs";import{getBuiltRemoteDictionariesPath as s}from"./createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs";import{getBuiltUnmergedDictionariesPath as c}from"./createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs";import{createDictionaryEntryPoint as l}from"./createDictionaryEntryPoint/createDictionaryEntryPoint.mjs";import{createModuleAugmentation as u,getTypeName as d}from"./createType/createModuleAugmentation.mjs";import{createTypes as f,generateTypeScriptType as p}from"./createType/createType.mjs";import{formatDictionaries as m,formatDictionariesOutput as h,formatDictionary as g,formatDictionaryOutput as _}from"./formatDictionary.mjs";import{formatLocalDictionaries as v,loadContentDeclarations as y}from"./loadDictionaries/loadContentDeclaration.mjs";import{formatDistantDictionaries as b,loadRemoteDictionaries as x}from"./loadDictionaries/loadRemoteDictionaries.mjs";import{loadDictionaries as S}from"./loadDictionaries/loadDictionaries.mjs";import{loadLocalDictionaries as C}from"./loadDictionaries/loadLocalDictionaries.mjs";import{isCachedConfigurationUpToDate as w,writeConfiguration as T}from"./writeConfiguration/index.mjs";import{prepareIntlayer as E}from"./prepareIntlayer.mjs";import{detectExportedComponentName as D}from"./writeContentDeclaration/detectExportedComponentName.mjs";import{detectFormatCommand as O}from"./writeContentDeclaration/detectFormatCommand.mjs";import{transformJSFile as k}from"./writeContentDeclaration/transformJSFile.mjs";import{writeJSFile as A}from"./writeContentDeclaration/writeJSFile.mjs";import{writeContentDeclaration as j}from"./writeContentDeclaration/writeContentDeclaration.mjs";export{e as buildDictionary,n as cleanOutputDir,l as createDictionaryEntryPoint,u as createModuleAugmentation,f as createTypes,D as detectExportedComponentName,O as detectFormatCommand,m as formatDictionaries,h as formatDictionariesOutput,g as formatDictionary,_ as formatDictionaryOutput,b as formatDistantDictionaries,v as formatLocalDictionaries,r as generateDictionaryListContent,p as generateTypeScriptType,i as getBuiltDictionariesPath,a as getBuiltDynamicDictionariesPath,o as getBuiltFetchDictionariesPath,s as getBuiltRemoteDictionariesPath,c as getBuiltUnmergedDictionariesPath,d as getTypeName,w as isCachedConfigurationUpToDate,y as loadContentDeclarations,S as loadDictionaries,C as loadLocalDictionaries,x as loadRemoteDictionaries,E as prepareIntlayer,t as processContentDeclaration,k as transformJSFile,T as writeConfiguration,j as writeContentDeclaration,A as writeJSFile};
|
|
@@ -1,52 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { writeFetchDictionary } from "./writeFetchDictionary.mjs";
|
|
3
|
-
import { writeMergedDictionaries } from "./writeMergedDictionary.mjs";
|
|
4
|
-
import { writeUnmergedDictionaries } from "./writeUnmergedDictionary.mjs";
|
|
5
|
-
import { DefaultValues, getConfiguration } from "@intlayer/config";
|
|
6
|
-
import { getUnmergedDictionaries } from "@intlayer/unmerged-dictionaries-entry";
|
|
7
|
-
|
|
8
|
-
//#region src/buildIntlayerDictionary/buildIntlayerDictionary.ts
|
|
9
|
-
/**
|
|
10
|
-
* This function transpile the bundled code to to make dictionaries as JSON files
|
|
11
|
-
*/
|
|
12
|
-
const buildDictionary = async (localDictionariesEntries, configuration = getConfiguration(), formats = ["cjs", "esm"], importOtherDictionaries = true) => {
|
|
13
|
-
const importMode = configuration.build.importMode ?? configuration.dictionary?.importMode ?? DefaultValues.Dictionary.IMPORT_MODE;
|
|
14
|
-
const unmergedDictionariesToUpdate = [...localDictionariesEntries];
|
|
15
|
-
if (importOtherDictionaries) {
|
|
16
|
-
const prevUnmergedDictionaries = getUnmergedDictionaries(configuration);
|
|
17
|
-
for (const dictionaryToWrite of localDictionariesEntries) {
|
|
18
|
-
const allPrebuiltUnmergedDictionaries = prevUnmergedDictionaries[dictionaryToWrite.key];
|
|
19
|
-
if (allPrebuiltUnmergedDictionaries?.length > 0) {
|
|
20
|
-
const otherUnmergedDictionaries = allPrebuiltUnmergedDictionaries.filter((unmergedDictionary) => unmergedDictionary.localId !== dictionaryToWrite.localId);
|
|
21
|
-
unmergedDictionariesToUpdate.push(...otherUnmergedDictionaries);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
const unmergedDictionaries = await writeUnmergedDictionaries(unmergedDictionariesToUpdate, configuration);
|
|
26
|
-
const mergedDictionaries = await writeMergedDictionaries(unmergedDictionaries, configuration);
|
|
27
|
-
const dictionariesToBuildDynamic = {};
|
|
28
|
-
const keysToBuildFetch = /* @__PURE__ */ new Set();
|
|
29
|
-
for (const [key, mergedResult] of Object.entries(mergedDictionaries)) {
|
|
30
|
-
const mode = mergedResult.dictionary.importMode ?? importMode;
|
|
31
|
-
if (mode === "dynamic" || mode === "fetch") dictionariesToBuildDynamic[key] = mergedResult;
|
|
32
|
-
if (mode === "fetch") keysToBuildFetch.add(key);
|
|
33
|
-
}
|
|
34
|
-
let dynamicDictionaries = null;
|
|
35
|
-
if (Object.keys(dictionariesToBuildDynamic).length > 0) dynamicDictionaries = await writeDynamicDictionary(dictionariesToBuildDynamic, configuration, formats);
|
|
36
|
-
let fetchDictionaries = null;
|
|
37
|
-
if (dynamicDictionaries && keysToBuildFetch.size > 0) {
|
|
38
|
-
const dictionariesToBuildFetch = {};
|
|
39
|
-
for (const key of keysToBuildFetch) if (dynamicDictionaries[key]) dictionariesToBuildFetch[key] = dynamicDictionaries[key];
|
|
40
|
-
if (Object.keys(dictionariesToBuildFetch).length > 0) fetchDictionaries = await writeFetchDictionary(dictionariesToBuildFetch, configuration, formats);
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
unmergedDictionaries,
|
|
44
|
-
mergedDictionaries,
|
|
45
|
-
dynamicDictionaries,
|
|
46
|
-
fetchDictionaries
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
//#endregion
|
|
51
|
-
export { buildDictionary };
|
|
1
|
+
import{writeDynamicDictionary as e}from"./writeDynamicDictionary.mjs";import{writeFetchDictionary as t}from"./writeFetchDictionary.mjs";import{writeMergedDictionaries as n}from"./writeMergedDictionary.mjs";import{writeUnmergedDictionaries as r}from"./writeUnmergedDictionary.mjs";import{DefaultValues as i}from"@intlayer/config/client";import{getConfiguration as a}from"@intlayer/config/node";import{getUnmergedDictionaries as o}from"@intlayer/unmerged-dictionaries-entry";const s=async(s,c=a(),l=[`cjs`,`esm`],u=!0)=>{let d=c.build.importMode??c.dictionary?.importMode??i.Dictionary.IMPORT_MODE,f=[...s];if(u){let e=o(c);for(let t of s){let n=e[t.key];if(n?.length>0){let e=n.filter(e=>e.localId!==t.localId);f.push(...e)}}}let p=await r(f,c),m=await n(p,c),h={},g=new Set;for(let[e,t]of Object.entries(m)){let n=t.dictionary.importMode??d;(n===`dynamic`||n===`fetch`)&&(h[e]=t),n===`fetch`&&g.add(e)}let _=null;Object.keys(h).length>0&&(_=await e(h,c,l));let v=null;if(_&&g.size>0){let e={};for(let t of g)_[t]&&(e[t]=_[t]);Object.keys(e).length>0&&(v=await t(e,c,l))}return{unmergedDictionaries:p,mergedDictionaries:m,dynamicDictionaries:_,fetchDictionaries:v}};export{s as buildDictionary};
|
|
52
2
|
//# sourceMappingURL=buildIntlayerDictionary.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildIntlayerDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/buildIntlayerDictionary.ts"],"sourcesContent":["import { DefaultValues
|
|
1
|
+
{"version":3,"file":"buildIntlayerDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/buildIntlayerDictionary.ts"],"sourcesContent":["import { DefaultValues } from '@intlayer/config/client';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { Dictionary } from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport {\n type LocalizedDictionaryOutput,\n writeDynamicDictionary,\n} from './writeDynamicDictionary';\nimport { writeFetchDictionary } from './writeFetchDictionary';\nimport { writeMergedDictionaries } from './writeMergedDictionary';\nimport { writeUnmergedDictionaries } from './writeUnmergedDictionary';\n\n/**\n * This function transpile the bundled code to to make dictionaries as JSON files\n */\nexport const buildDictionary = async (\n localDictionariesEntries: Dictionary[],\n configuration = getConfiguration(),\n formats: ('cjs' | 'esm')[] = ['cjs', 'esm'],\n importOtherDictionaries = true\n) => {\n const importMode =\n configuration.build.importMode ??\n configuration.dictionary?.importMode ??\n DefaultValues.Dictionary.IMPORT_MODE;\n\n const unmergedDictionariesToUpdate: Dictionary[] = [\n ...localDictionariesEntries,\n ];\n\n if (importOtherDictionaries) {\n const prevUnmergedDictionaries: Record<string, Dictionary[]> =\n getUnmergedDictionaries(configuration);\n\n // Reinsert other dictionaries with the same key to avoid merging errors\n for (const dictionaryToWrite of localDictionariesEntries) {\n const allPrebuiltUnmergedDictionaries =\n prevUnmergedDictionaries[dictionaryToWrite.key];\n\n if (allPrebuiltUnmergedDictionaries?.length > 0) {\n // Do not add the same dictionary again by filtering out the one with the same localId\n const otherUnmergedDictionaries =\n allPrebuiltUnmergedDictionaries.filter(\n (unmergedDictionary) =>\n unmergedDictionary.localId !== dictionaryToWrite.localId\n );\n\n unmergedDictionariesToUpdate.push(...otherUnmergedDictionaries);\n }\n }\n }\n\n const unmergedDictionaries = await writeUnmergedDictionaries(\n unmergedDictionariesToUpdate,\n configuration\n );\n\n const mergedDictionaries = await writeMergedDictionaries(\n unmergedDictionaries,\n configuration\n );\n\n const dictionariesToBuildDynamic: typeof mergedDictionaries = {};\n const keysToBuildFetch = new Set<string>();\n\n for (const [key, mergedResult] of Object.entries(mergedDictionaries)) {\n const dictionary = mergedResult.dictionary;\n const mode = dictionary.importMode ?? importMode;\n\n if (mode === 'dynamic' || mode === 'fetch') {\n dictionariesToBuildDynamic[key] = mergedResult;\n }\n\n if (mode === 'fetch') {\n keysToBuildFetch.add(key);\n }\n }\n\n let dynamicDictionaries: LocalizedDictionaryOutput | null = null;\n\n if (Object.keys(dictionariesToBuildDynamic).length > 0) {\n dynamicDictionaries = await writeDynamicDictionary(\n dictionariesToBuildDynamic,\n configuration,\n formats\n );\n }\n\n let fetchDictionaries: LocalizedDictionaryOutput | null = null;\n\n if (dynamicDictionaries && keysToBuildFetch.size > 0) {\n const dictionariesToBuildFetch: LocalizedDictionaryOutput = {};\n\n for (const key of keysToBuildFetch) {\n if (dynamicDictionaries[key]) {\n dictionariesToBuildFetch[key] = dynamicDictionaries[key];\n }\n }\n\n if (Object.keys(dictionariesToBuildFetch).length > 0) {\n fetchDictionaries = await writeFetchDictionary(\n dictionariesToBuildFetch,\n configuration,\n formats\n );\n }\n }\n\n return {\n unmergedDictionaries,\n mergedDictionaries,\n dynamicDictionaries,\n fetchDictionaries,\n };\n};\n"],"mappings":"ydAeA,MAAa,EAAkB,MAC7B,EACA,EAAgB,GAAkB,CAClC,EAA6B,CAAC,MAAO,MAAM,CAC3C,EAA0B,KACvB,CACH,IAAM,EACJ,EAAc,MAAM,YACpB,EAAc,YAAY,YAC1B,EAAc,WAAW,YAErB,EAA6C,CACjD,GAAG,EACJ,CAED,GAAI,EAAyB,CAC3B,IAAM,EACJ,EAAwB,EAAc,CAGxC,IAAK,IAAM,KAAqB,EAA0B,CACxD,IAAM,EACJ,EAAyB,EAAkB,KAE7C,GAAI,GAAiC,OAAS,EAAG,CAE/C,IAAM,EACJ,EAAgC,OAC7B,GACC,EAAmB,UAAY,EAAkB,QACpD,CAEH,EAA6B,KAAK,GAAG,EAA0B,GAKrE,IAAM,EAAuB,MAAM,EACjC,EACA,EACD,CAEK,EAAqB,MAAM,EAC/B,EACA,EACD,CAEK,EAAwD,EAAE,CAC1D,EAAmB,IAAI,IAE7B,IAAK,GAAM,CAAC,EAAK,KAAiB,OAAO,QAAQ,EAAmB,CAAE,CAEpE,IAAM,EADa,EAAa,WACR,YAAc,GAElC,IAAS,WAAa,IAAS,WACjC,EAA2B,GAAO,GAGhC,IAAS,SACX,EAAiB,IAAI,EAAI,CAI7B,IAAI,EAAwD,KAExD,OAAO,KAAK,EAA2B,CAAC,OAAS,IACnD,EAAsB,MAAM,EAC1B,EACA,EACA,EACD,EAGH,IAAI,EAAsD,KAE1D,GAAI,GAAuB,EAAiB,KAAO,EAAG,CACpD,IAAM,EAAsD,EAAE,CAE9D,IAAK,IAAM,KAAO,EACZ,EAAoB,KACtB,EAAyB,GAAO,EAAoB,IAIpD,OAAO,KAAK,EAAyB,CAAC,OAAS,IACjD,EAAoB,MAAM,EACxB,EACA,EACA,EACD,EAIL,MAAO,CACL,uBACA,qBACA,sBACA,oBACD"}
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { processContentDeclaration } from "./processContentDeclaration.mjs";
|
|
3
|
-
|
|
4
|
-
export { buildDictionary, processContentDeclaration };
|
|
1
|
+
import{buildDictionary as e}from"./buildIntlayerDictionary.mjs";import{processContentDeclaration as t}from"./processContentDeclaration.mjs";export{e as buildDictionary,t as processContentDeclaration};
|
|
@@ -1,25 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { resolveObjectPromises } from "../utils/resolveObjectPromises.mjs";
|
|
3
|
-
import { logger } from "@intlayer/config/client";
|
|
4
|
-
|
|
5
|
-
//#region src/buildIntlayerDictionary/processContentDeclaration.ts
|
|
6
|
-
/**
|
|
7
|
-
* Function to load, process the module and return the Intlayer Dictionary from the module file
|
|
8
|
-
*/
|
|
9
|
-
const processContentDeclaration = async (contentDeclaration, configuration) => {
|
|
10
|
-
try {
|
|
11
|
-
const resolvedContent = await resolveObjectPromises(contentDeclaration.content);
|
|
12
|
-
const isAutoDecorateContentEnabled = contentDeclaration.contentAutoTransformation ?? configuration.dictionary?.contentAutoTransformation ?? false;
|
|
13
|
-
const decoratedContent = isAutoDecorateContentEnabled ? autoDecorateContent(resolvedContent, isAutoDecorateContentEnabled) : resolvedContent;
|
|
14
|
-
return {
|
|
15
|
-
...contentDeclaration,
|
|
16
|
-
content: decoratedContent
|
|
17
|
-
};
|
|
18
|
-
} catch (error) {
|
|
19
|
-
logger(error, { level: "error" });
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
export { processContentDeclaration };
|
|
1
|
+
import{autoDecorateContent as e}from"../utils/autoDecorateContent.mjs";import{resolveObjectPromises as t}from"../utils/resolveObjectPromises.mjs";import{logger as n}from"@intlayer/config/client";const r=async(r,i)=>{try{let n=await t(r.content),a=r.contentAutoTransformation??i.dictionary?.contentAutoTransformation??!1,o=a?e(n,a):n;return{...r,content:o}}catch(e){n(e,{level:`error`})}};export{r as processContentDeclaration};
|
|
25
2
|
//# sourceMappingURL=processContentDeclaration.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processContentDeclaration.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/processContentDeclaration.ts"],"sourcesContent":["import { logger } from '@intlayer/config/client';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { autoDecorateContent } from '../utils/autoDecorateContent';\nimport { resolveObjectPromises } from '../utils/resolveObjectPromises';\n\n/**\n * Function to load, process the module and return the Intlayer Dictionary from the module file\n */\nexport const processContentDeclaration = async (\n contentDeclaration: Dictionary,\n configuration: IntlayerConfig\n): Promise<Dictionary | undefined> => {\n try {\n const resolvedContent = (await resolveObjectPromises(\n contentDeclaration.content\n )) as Dictionary['content'];\n\n const isAutoDecorateContentEnabled =\n contentDeclaration.contentAutoTransformation ??\n configuration.dictionary?.contentAutoTransformation ??\n false;\n\n const decoratedContent = isAutoDecorateContentEnabled\n ? autoDecorateContent(resolvedContent, isAutoDecorateContentEnabled)\n : resolvedContent;\n\n return {\n ...contentDeclaration,\n content: decoratedContent,\n } as Dictionary;\n } catch (error) {\n logger(error, {\n level: 'error',\n });\n }\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"processContentDeclaration.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/processContentDeclaration.ts"],"sourcesContent":["import { logger } from '@intlayer/config/client';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { autoDecorateContent } from '../utils/autoDecorateContent';\nimport { resolveObjectPromises } from '../utils/resolveObjectPromises';\n\n/**\n * Function to load, process the module and return the Intlayer Dictionary from the module file\n */\nexport const processContentDeclaration = async (\n contentDeclaration: Dictionary,\n configuration: IntlayerConfig\n): Promise<Dictionary | undefined> => {\n try {\n const resolvedContent = (await resolveObjectPromises(\n contentDeclaration.content\n )) as Dictionary['content'];\n\n const isAutoDecorateContentEnabled =\n contentDeclaration.contentAutoTransformation ??\n configuration.dictionary?.contentAutoTransformation ??\n false;\n\n const decoratedContent = isAutoDecorateContentEnabled\n ? autoDecorateContent(resolvedContent, isAutoDecorateContentEnabled)\n : resolvedContent;\n\n return {\n ...contentDeclaration,\n content: decoratedContent,\n } as Dictionary;\n } catch (error) {\n logger(error, {\n level: 'error',\n });\n }\n};\n"],"mappings":"mMAQA,MAAa,EAA4B,MACvC,EACA,IACoC,CACpC,GAAI,CACF,IAAM,EAAmB,MAAM,EAC7B,EAAmB,QACpB,CAEK,EACJ,EAAmB,2BACnB,EAAc,YAAY,2BAC1B,GAEI,EAAmB,EACrB,EAAoB,EAAiB,EAA6B,CAClE,EAEJ,MAAO,CACL,GAAG,EACH,QAAS,EACV,OACM,EAAO,CACd,EAAO,EAAO,CACZ,MAAO,QACR,CAAC"}
|
|
@@ -1,76 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { mkdir } from "node:fs/promises";
|
|
6
|
-
import { relative, resolve } from "node:path";
|
|
7
|
-
import { getPerLocaleDictionary } from "@intlayer/core";
|
|
8
|
-
|
|
9
|
-
//#region src/buildIntlayerDictionary/writeDynamicDictionary.ts
|
|
10
|
-
/**
|
|
11
|
-
* This function generates the content of the dictionary list file
|
|
12
|
-
*/
|
|
13
|
-
const generateDictionaryEntryPoint = (localizedDictionariesPathsRecord, format = "esm", configuration = getConfiguration()) => {
|
|
14
|
-
const { dynamicDictionariesDir } = configuration.system;
|
|
15
|
-
let content = "";
|
|
16
|
-
const formattedDictionaryMap = Object.entries(localizedDictionariesPathsRecord).filter((entry) => Boolean(entry[1])).sort(([a], [b]) => String(a).localeCompare(String(b))).map(([locale, dictionary]) => {
|
|
17
|
-
const relativePath = normalizePath(relative(dynamicDictionariesDir, dictionary.dictionaryPath));
|
|
18
|
-
if (format === "esm") return ` '${locale}': () => import('./${relativePath}', { assert: { type: 'json' }}).then(mod => mod.default)`;
|
|
19
|
-
return ` '${locale}': () => Promise.resolve(require('./${relativePath}'))`;
|
|
20
|
-
}).join(",\n");
|
|
21
|
-
content += `const content = {\n${formattedDictionaryMap}\n};\n`;
|
|
22
|
-
if (format === "esm") content += `export default content;\n`;
|
|
23
|
-
if (format === "cjs") content += `module.exports = content;\n`;
|
|
24
|
-
return content;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Write the localized dictionaries to the dictionariesDir
|
|
28
|
-
* @param mergedDictionaries - The merged dictionaries
|
|
29
|
-
* @param configuration - The configuration
|
|
30
|
-
* @returns The final dictionaries
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```ts
|
|
34
|
-
* const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
|
|
35
|
-
* const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);
|
|
36
|
-
* console.log(finalDictionaries);
|
|
37
|
-
*
|
|
38
|
-
* // .intlayer/dynamic_dictionaries/home.json
|
|
39
|
-
* // { key: 'home', content: { ... } },
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
const writeDynamicDictionary = async (mergedDictionaries, configuration = getConfiguration(), formats = ["cjs", "esm"]) => {
|
|
43
|
-
const { locales, defaultLocale } = configuration.internationalization;
|
|
44
|
-
const { dynamicDictionariesDir } = configuration.system;
|
|
45
|
-
await mkdir(resolve(dynamicDictionariesDir), { recursive: true });
|
|
46
|
-
const resultDictionariesPaths = {};
|
|
47
|
-
await parallelize(Object.entries(mergedDictionaries).sort(([a], [b]) => String(a).localeCompare(String(b))), async ([key, dictionaryEntry]) => {
|
|
48
|
-
if (key === "undefined") return;
|
|
49
|
-
const localizedDictionariesPathsRecord = {};
|
|
50
|
-
await parallelize(locales, async (locale) => {
|
|
51
|
-
const localizedDictionary = getPerLocaleDictionary(dictionaryEntry.dictionary, locale, defaultLocale);
|
|
52
|
-
const outputFileName = `${key}.${locale}.json`;
|
|
53
|
-
const resultFilePath = resolve(dynamicDictionariesDir, outputFileName);
|
|
54
|
-
await writeJsonIfChanged(resultFilePath, localizedDictionary).catch((err) => {
|
|
55
|
-
console.error(`Error creating localized ${outputFileName}:`, err);
|
|
56
|
-
});
|
|
57
|
-
localizedDictionariesPathsRecord[locale] = {
|
|
58
|
-
dictionaryPath: resultFilePath,
|
|
59
|
-
dictionary: localizedDictionary
|
|
60
|
-
};
|
|
61
|
-
});
|
|
62
|
-
resultDictionariesPaths[key] = localizedDictionariesPathsRecord;
|
|
63
|
-
await parallelize(formats, async (format) => {
|
|
64
|
-
const extension = format === "cjs" ? "cjs" : "mjs";
|
|
65
|
-
const content = generateDictionaryEntryPoint(localizedDictionariesPathsRecord, format, configuration);
|
|
66
|
-
await writeFileIfChanged(resolve(dynamicDictionariesDir, `${key}.${extension}`), content).catch((err) => {
|
|
67
|
-
console.error(`Error creating dynamic ${colorizePath(resolve(dynamicDictionariesDir, `${key}.${extension}`))}:`, err);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
return resultDictionariesPaths;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
//#endregion
|
|
75
|
-
export { generateDictionaryEntryPoint, writeDynamicDictionary };
|
|
1
|
+
import{parallelize as e}from"../utils/parallelize.mjs";import{writeFileIfChanged as t}from"../writeFileIfChanged.mjs";import{writeJsonIfChanged as n}from"../writeJsonIfChanged.mjs";import{getConfiguration as r}from"@intlayer/config/node";import{mkdir as i}from"node:fs/promises";import{relative as a,resolve as o}from"node:path";import{colorizePath as s}from"@intlayer/config/logger";import{normalizePath as c}from"@intlayer/config/utils";import{getPerLocaleDictionary as l}from"@intlayer/core/plugins";const u=(e,t=`esm`,n=r())=>{let{dynamicDictionariesDir:i}=n.system,o=``,s=Object.entries(e).filter(e=>!!e[1]).sort(([e],[t])=>String(e).localeCompare(String(t))).map(([e,n])=>{let r=c(a(i,n.dictionaryPath));return t===`esm`?` '${e}': () => import('./${r}', { assert: { type: 'json' }}).then(mod => mod.default)`:` '${e}': () => Promise.resolve(require('./${r}'))`}).join(`,
|
|
2
|
+
`);return o+=`const content = {\n${s}\n};\n`,t===`esm`&&(o+=`export default content;
|
|
3
|
+
`),t===`cjs`&&(o+=`module.exports = content;
|
|
4
|
+
`),o},d=async(a,c=r(),d=[`cjs`,`esm`])=>{let{locales:f,defaultLocale:p}=c.internationalization,{dynamicDictionariesDir:m}=c.system;await i(o(m),{recursive:!0});let h={};return await e(Object.entries(a).sort(([e],[t])=>String(e).localeCompare(String(t))),async([r,i])=>{if(r===`undefined`)return;let a={};await e(f,async e=>{let t=l(i.dictionary,e,p),s=`${r}.${e}.json`,c=o(m,s);await n(c,t).catch(e=>{console.error(`Error creating localized ${s}:`,e)}),a[e]={dictionaryPath:c,dictionary:t}}),h[r]=a,await e(d,async e=>{let n=e===`cjs`?`cjs`:`mjs`,i=u(a,e,c);await t(o(m,`${r}.${n}`),i).catch(e=>{console.error(`Error creating dynamic ${s(o(m,`${r}.${n}`))}:`,e)})})}),h};export{u as generateDictionaryEntryPoint,d as writeDynamicDictionary};
|
|
76
5
|
//# sourceMappingURL=writeDynamicDictionary.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeDynamicDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport {
|
|
1
|
+
{"version":3,"file":"writeDynamicDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { normalizePath } from '@intlayer/config/utils';\nimport { getPerLocaleDictionary } from '@intlayer/core/plugins';\nimport type { Dictionary, Locale } from '@intlayer/types';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { MergedDictionaryOutput } from './writeMergedDictionary';\n\nexport type DictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type LocalizedDictionaryResult = Partial<\n Record<Locale, DictionaryResult>\n>;\n\nexport type LocalizedDictionaryOutput = Record<\n string,\n LocalizedDictionaryResult\n>;\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryEntryPoint = (\n localizedDictionariesPathsRecord: LocalizedDictionaryResult,\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { dynamicDictionariesDir } = configuration.system;\n\n let content = '';\n\n // Format Dictionary Map - map locales to functions\n const formattedDictionaryMap: string = Object.entries(\n localizedDictionariesPathsRecord\n )\n // The following filter/sort preserve determinism of the generated map\n // when files are built in parallel or across different Node versions.\n .filter((entry): entry is [string, DictionaryResult] => Boolean(entry[1]))\n .sort(([a], [b]) => String(a).localeCompare(String(b)))\n .map(([locale, dictionary]) => {\n const relativePath = normalizePath(\n relative(dynamicDictionariesDir, dictionary.dictionaryPath)\n );\n\n if (format === 'esm') {\n return ` '${locale}': () => import('./${relativePath}', { assert: { type: 'json' }}).then(mod => mod.default)`;\n }\n\n return ` '${locale}': () => Promise.resolve(require('./${relativePath}'))`;\n })\n .join(',\\n');\n\n content += `const content = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n if (format === 'esm') content += `export default content;\\n`;\n if (format === 'cjs') content += `module.exports = content;\\n`;\n\n return content;\n};\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dynamic_dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeDynamicDictionary = async (\n mergedDictionaries: MergedDictionaryOutput,\n configuration = getConfiguration(),\n formats: ('cjs' | 'esm')[] = ['cjs', 'esm']\n): Promise<LocalizedDictionaryOutput> => {\n const { locales, defaultLocale } = configuration.internationalization;\n const { dynamicDictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dynamicDictionariesDir), { recursive: true });\n\n const resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Merge dictionaries with the same key and write to dictionariesDir\n await parallelize(\n Object.entries(mergedDictionaries).sort(([a], [b]) =>\n String(a).localeCompare(String(b))\n ),\n async ([key, dictionaryEntry]) => {\n if (key === 'undefined') return;\n\n const localizedDictionariesPathsRecord: LocalizedDictionaryResult = {};\n\n await parallelize(locales, async (locale) => {\n const localizedDictionary = getPerLocaleDictionary(\n dictionaryEntry.dictionary,\n locale,\n defaultLocale\n );\n\n const outputFileName = `${key}.${locale}.json`;\n const resultFilePath = resolve(dynamicDictionariesDir, outputFileName);\n\n // Write the localized dictionary\n await writeJsonIfChanged(resultFilePath, localizedDictionary).catch(\n (err) => {\n console.error(`Error creating localized ${outputFileName}:`, err);\n }\n );\n\n localizedDictionariesPathsRecord[locale] = {\n dictionaryPath: resultFilePath,\n dictionary: localizedDictionary,\n };\n });\n\n resultDictionariesPaths[key] = localizedDictionariesPathsRecord;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(\n localizedDictionariesPathsRecord,\n format,\n configuration\n );\n\n await writeFileIfChanged(\n resolve(dynamicDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating dynamic ${colorizePath(resolve(dynamicDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n"],"mappings":"ufA6BA,MAAa,GACX,EACA,EAAwB,MACxB,EAAgB,GAAkB,GACvB,CACX,GAAM,CAAE,0BAA2B,EAAc,OAE7C,EAAU,GAGR,EAAiC,OAAO,QAC5C,EACD,CAGE,OAAQ,GAA+C,EAAQ,EAAM,GAAI,CACzE,MAAM,CAAC,GAAI,CAAC,KAAO,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CAAC,CACtD,KAAK,CAAC,EAAQ,KAAgB,CAC7B,IAAM,EAAe,EACnB,EAAS,EAAwB,EAAW,eAAe,CAC5D,CAMD,OAJI,IAAW,MACN,MAAM,EAAO,qBAAqB,EAAa,0DAGjD,MAAM,EAAO,sCAAsC,EAAa,MACvE,CACD,KAAK;EAAM,CAOd,MALA,IAAW,sBAAsB,EAAuB,QAEpD,IAAW,QAAO,GAAW;GAC7B,IAAW,QAAO,GAAW;GAE1B,GAmBI,EAAyB,MACpC,EACA,EAAgB,GAAkB,CAClC,EAA6B,CAAC,MAAO,MAAM,GACJ,CACvC,GAAM,CAAE,UAAS,iBAAkB,EAAc,qBAC3C,CAAE,0BAA2B,EAAc,OAGjD,MAAM,EAAM,EAAQ,EAAuB,CAAE,CAAE,UAAW,GAAM,CAAC,CAEjE,IAAM,EAAqD,EAAE,CA0D7D,OAvDA,MAAM,EACJ,OAAO,QAAQ,EAAmB,CAAC,MAAM,CAAC,GAAI,CAAC,KAC7C,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CACnC,CACD,MAAO,CAAC,EAAK,KAAqB,CAChC,GAAI,IAAQ,YAAa,OAEzB,IAAM,EAA8D,EAAE,CAEtE,MAAM,EAAY,EAAS,KAAO,IAAW,CAC3C,IAAM,EAAsB,EAC1B,EAAgB,WAChB,EACA,EACD,CAEK,EAAiB,GAAG,EAAI,GAAG,EAAO,OAClC,EAAiB,EAAQ,EAAwB,EAAe,CAGtE,MAAM,EAAmB,EAAgB,EAAoB,CAAC,MAC3D,GAAQ,CACP,QAAQ,MAAM,4BAA4B,EAAe,GAAI,EAAI,EAEpE,CAED,EAAiC,GAAU,CACzC,eAAgB,EAChB,WAAY,EACb,EACD,CAEF,EAAwB,GAAO,EAE/B,MAAM,EAAY,EAAS,KAAO,IAAW,CAC3C,IAAM,EAAY,IAAW,MAAQ,MAAQ,MACvC,EAAU,EACd,EACA,EACA,EACD,CAED,MAAM,EACJ,EAAQ,EAAwB,GAAG,EAAI,GAAG,IAAY,CACtD,EACD,CAAC,MAAO,GAAQ,CACf,QAAQ,MACN,0BAA0B,EAAa,EAAQ,EAAwB,GAAG,EAAI,GAAG,IAAY,CAAC,CAAC,GAC/F,EACD,EACD,EACF,EAEL,CAEM"}
|
|
@@ -1,60 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { relative, resolve } from "node:path";
|
|
6
|
-
|
|
7
|
-
//#region src/buildIntlayerDictionary/writeFetchDictionary.ts
|
|
8
|
-
/**
|
|
9
|
-
* This function generates the content of the dictionary list file
|
|
10
|
-
*/
|
|
11
|
-
const generateDictionaryEntryPoint = (localedDictionariesPathsRecord, format = "esm", configuration = getConfiguration()) => {
|
|
12
|
-
const { fetchDictionariesDir } = configuration.system;
|
|
13
|
-
const { liveSyncURL } = configuration.editor;
|
|
14
|
-
let content = "";
|
|
15
|
-
const formattedDictionaryMap = Object.entries(localedDictionariesPathsRecord).map(([locale, dictionary]) => {
|
|
16
|
-
const relativePath = normalizePath(relative(fetchDictionariesDir, dictionary.dictionaryPath));
|
|
17
|
-
if (format === "esm") return ` '${locale}': () => (async () => { try {return await fetch('${liveSyncURL}/dictionaries/${dictionary.dictionary.key}/${locale}').then(res => res.json())} catch (_error) {return await import('./${relativePath}', { assert: { type: 'json' }}).then(mod => mod.default)}})()`;
|
|
18
|
-
return ` '${locale}': () => (async () => { try {return await fetch('${liveSyncURL}/dictionaries/${dictionary.dictionary.key}/${locale}').then(res => res.json())} catch (_error) {return Promise.resolve(require('./${relativePath}'))}})()`;
|
|
19
|
-
}).join(",\n");
|
|
20
|
-
content += `const content = {\n${formattedDictionaryMap}\n};\n`;
|
|
21
|
-
if (format === "esm") content += `export default content;\n`;
|
|
22
|
-
if (format === "cjs") content += `module.exports = content;\n`;
|
|
23
|
-
return content;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Write the localized dictionaries to the dictionariesDir
|
|
27
|
-
* @param mergedDictionaries - The merged dictionaries
|
|
28
|
-
* @param configuration - The configuration
|
|
29
|
-
* @returns The final dictionaries
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```ts
|
|
33
|
-
* const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
|
|
34
|
-
* const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);
|
|
35
|
-
* console.log(finalDictionaries);
|
|
36
|
-
*
|
|
37
|
-
* // .intlayer/fetch_dictionaries/home.json
|
|
38
|
-
* // { key: 'home', content: { ... } },
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
const writeFetchDictionary = async (dynamicDictionaries, configuration = getConfiguration(), formats = ["cjs", "esm"]) => {
|
|
42
|
-
const { fetchDictionariesDir } = configuration.system;
|
|
43
|
-
await mkdir(resolve(fetchDictionariesDir), { recursive: true });
|
|
44
|
-
const resultDictionariesPaths = {};
|
|
45
|
-
await parallelize(Object.entries(dynamicDictionaries), async ([key, localedDictionariesPathsRecord]) => {
|
|
46
|
-
if (key === "undefined") return;
|
|
47
|
-
await parallelize(formats, async (format) => {
|
|
48
|
-
const extension = format === "cjs" ? "cjs" : "mjs";
|
|
49
|
-
const content = generateDictionaryEntryPoint(localedDictionariesPathsRecord, format, configuration);
|
|
50
|
-
await writeFileIfChanged(resolve(fetchDictionariesDir, `${key}.${extension}`), content).catch((err) => {
|
|
51
|
-
console.error(`Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${key}.${extension}`))}:`, err);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
return resultDictionariesPaths;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
//#endregion
|
|
59
|
-
export { generateDictionaryEntryPoint, writeFetchDictionary };
|
|
1
|
+
import{parallelize as e}from"../utils/parallelize.mjs";import{writeFileIfChanged as t}from"../writeFileIfChanged.mjs";import{getConfiguration as n}from"@intlayer/config/node";import{mkdir as r}from"node:fs/promises";import{relative as i,resolve as a}from"node:path";import{colorizePath as o}from"@intlayer/config/logger";import{normalizePath as s}from"@intlayer/config/utils";const c=(e,t=`esm`,r=n())=>{let{fetchDictionariesDir:a}=r.system,{liveSyncURL:o}=r.editor,c=``,l=Object.entries(e).map(([e,n])=>{let r=s(i(a,n.dictionaryPath));return t===`esm`?` '${e}': () => (async () => { try {return await fetch('${o}/dictionaries/${n.dictionary.key}/${e}').then(res => res.json())} catch (_error) {return await import('./${r}', { assert: { type: 'json' }}).then(mod => mod.default)}})()`:` '${e}': () => (async () => { try {return await fetch('${o}/dictionaries/${n.dictionary.key}/${e}').then(res => res.json())} catch (_error) {return Promise.resolve(require('./${r}'))}})()`}).join(`,
|
|
2
|
+
`);return c+=`const content = {\n${l}\n};\n`,t===`esm`&&(c+=`export default content;
|
|
3
|
+
`),t===`cjs`&&(c+=`module.exports = content;
|
|
4
|
+
`),c},l=async(i,s=n(),l=[`cjs`,`esm`])=>{let{fetchDictionariesDir:u}=s.system;return await r(a(u),{recursive:!0}),await e(Object.entries(i),async([n,r])=>{n!==`undefined`&&await e(l,async e=>{let i=e===`cjs`?`cjs`:`mjs`,l=c(r,e,s);await t(a(u,`${n}.${i}`),l).catch(e=>{console.error(`Error creating fetch ${o(a(u,`${n}.${i}`))}:`,e)})})}),{}};export{c as generateDictionaryEntryPoint,l as writeFetchDictionary};
|
|
60
5
|
//# sourceMappingURL=writeFetchDictionary.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeFetchDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport {
|
|
1
|
+
{"version":3,"file":"writeFetchDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { normalizePath } from '@intlayer/config/utils';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport type {\n LocalizedDictionaryOutput,\n LocalizedDictionaryResult,\n} from './writeDynamicDictionary';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryEntryPoint = (\n localedDictionariesPathsRecord: LocalizedDictionaryResult,\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { fetchDictionariesDir } = configuration.system;\n const { liveSyncURL } = configuration.editor;\n\n let content = '';\n\n const formattedDictionaryMap: string = Object.entries(\n localedDictionariesPathsRecord\n )\n .map(([locale, dictionary]) => {\n const relativePath = normalizePath(\n relative(fetchDictionariesDir, dictionary.dictionaryPath)\n );\n\n if (format === 'esm') {\n return ` '${locale}': () => (async () => { try {return await fetch('${liveSyncURL}/dictionaries/${dictionary.dictionary.key}/${locale}').then(res => res.json())} catch (_error) {return await import('./${relativePath}', { assert: { type: 'json' }}).then(mod => mod.default)}})()`;\n }\n\n return ` '${locale}': () => (async () => { try {return await fetch('${liveSyncURL}/dictionaries/${dictionary.dictionary.key}/${locale}').then(res => res.json())} catch (_error) {return Promise.resolve(require('./${relativePath}'))}})()`;\n })\n .join(',\\n');\n\n content += `const content = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n if (format === 'esm') content += `export default content;\\n`;\n if (format === 'cjs') content += `module.exports = content;\\n`;\n\n return content;\n};\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/fetch_dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeFetchDictionary = async (\n dynamicDictionaries: LocalizedDictionaryOutput,\n configuration = getConfiguration(),\n formats: ('cjs' | 'esm')[] = ['cjs', 'esm']\n): Promise<LocalizedDictionaryOutput> => {\n const { fetchDictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(fetchDictionariesDir), { recursive: true });\n\n const resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Write entry points for each dictionary in parallel\n await parallelize(\n Object.entries(dynamicDictionaries),\n async ([key, localedDictionariesPathsRecord]) => {\n if (key === 'undefined') return;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(\n localedDictionariesPathsRecord,\n format,\n configuration\n );\n\n await writeFileIfChanged(\n resolve(fetchDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n"],"mappings":"wXAeA,MAAa,GACX,EACA,EAAwB,MACxB,EAAgB,GAAkB,GACvB,CACX,GAAM,CAAE,wBAAyB,EAAc,OACzC,CAAE,eAAgB,EAAc,OAElC,EAAU,GAER,EAAiC,OAAO,QAC5C,EACD,CACE,KAAK,CAAC,EAAQ,KAAgB,CAC7B,IAAM,EAAe,EACnB,EAAS,EAAsB,EAAW,eAAe,CAC1D,CAMD,OAJI,IAAW,MACN,MAAM,EAAO,mDAAmD,EAAY,gBAAgB,EAAW,WAAW,IAAI,GAAG,EAAO,qEAAqE,EAAa,+DAGpN,MAAM,EAAO,mDAAmD,EAAY,gBAAgB,EAAW,WAAW,IAAI,GAAG,EAAO,gFAAgF,EAAa,WACpO,CACD,KAAK;EAAM,CAOd,MALA,IAAW,sBAAsB,EAAuB,QAEpD,IAAW,QAAO,GAAW;GAC7B,IAAW,QAAO,GAAW;GAE1B,GAmBI,EAAuB,MAClC,EACA,EAAgB,GAAkB,CAClC,EAA6B,CAAC,MAAO,MAAM,GACJ,CACvC,GAAM,CAAE,wBAAyB,EAAc,OAkC/C,OA/BA,MAAM,EAAM,EAAQ,EAAqB,CAAE,CAAE,UAAW,GAAM,CAAC,CAK/D,MAAM,EACJ,OAAO,QAAQ,EAAoB,CACnC,MAAO,CAAC,EAAK,KAAoC,CAC3C,IAAQ,aAEZ,MAAM,EAAY,EAAS,KAAO,IAAW,CAC3C,IAAM,EAAY,IAAW,MAAQ,MAAQ,MACvC,EAAU,EACd,EACA,EACA,EACD,CAED,MAAM,EACJ,EAAQ,EAAsB,GAAG,EAAI,GAAG,IAAY,CACpD,EACD,CAAC,MAAO,GAAQ,CACf,QAAQ,MACN,wBAAwB,EAAa,EAAQ,EAAsB,GAAG,EAAI,GAAG,IAAY,CAAC,CAAC,GAC3F,EACD,EACD,EACF,EAEL,CA3B0D,EAAE"}
|
|
@@ -1,45 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { writeJsonIfChanged } from "../writeJsonIfChanged.mjs";
|
|
3
|
-
import { colorizePath, getConfiguration } from "@intlayer/config";
|
|
4
|
-
import { mkdir } from "node:fs/promises";
|
|
5
|
-
import { resolve } from "node:path";
|
|
6
|
-
import { mergeDictionaries, normalizeDictionaries } from "@intlayer/core";
|
|
7
|
-
|
|
8
|
-
//#region src/buildIntlayerDictionary/writeMergedDictionary.ts
|
|
9
|
-
/**
|
|
10
|
-
* Write the merged dictionaries to the dictionariesDir
|
|
11
|
-
* @param groupedDictionaries - The grouped dictionaries
|
|
12
|
-
* @param configuration - The configuration
|
|
13
|
-
* @returns The merged dictionaries
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```ts
|
|
17
|
-
* const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
|
|
18
|
-
* const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);
|
|
19
|
-
* console.log(finalDictionaries);
|
|
20
|
-
*
|
|
21
|
-
* // .intlayer/dictionary/home.json
|
|
22
|
-
* // { key: 'home', content: { ... } },
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
const writeMergedDictionaries = async (groupedDictionaries, configuration = getConfiguration()) => {
|
|
26
|
-
const { dictionariesDir } = configuration.system;
|
|
27
|
-
await mkdir(resolve(dictionariesDir), { recursive: true });
|
|
28
|
-
const results = await parallelize(Object.entries(groupedDictionaries), async ([key, dictionariesEntry]) => {
|
|
29
|
-
if (key === "undefined") return;
|
|
30
|
-
const mergedDictionary = mergeDictionaries(normalizeDictionaries(dictionariesEntry.dictionaries, configuration));
|
|
31
|
-
const resultFilePath = resolve(dictionariesDir, `${key}.json`);
|
|
32
|
-
await writeJsonIfChanged(resultFilePath, mergedDictionary).catch((err) => {
|
|
33
|
-
console.error(`Error creating merged ${colorizePath(resultFilePath)}:`, err);
|
|
34
|
-
});
|
|
35
|
-
return [key, {
|
|
36
|
-
dictionaryPath: resultFilePath,
|
|
37
|
-
dictionary: mergedDictionary
|
|
38
|
-
}];
|
|
39
|
-
});
|
|
40
|
-
return Object.fromEntries(results.filter(Boolean));
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
//#endregion
|
|
44
|
-
export { writeMergedDictionaries };
|
|
1
|
+
import{parallelize as e}from"../utils/parallelize.mjs";import{writeJsonIfChanged as t}from"../writeJsonIfChanged.mjs";import{getConfiguration as n}from"@intlayer/config/node";import{mkdir as r}from"node:fs/promises";import{resolve as i}from"node:path";import{colorizePath as a}from"@intlayer/config/logger";import{mergeDictionaries as o,normalizeDictionaries as s}from"@intlayer/core/dictionaryManipulator";const c=async(c,l=n())=>{let{dictionariesDir:u}=l.system;await r(i(u),{recursive:!0});let d=await e(Object.entries(c),async([e,n])=>{if(e===`undefined`)return;let r=o(s(n.dictionaries,l)),c=i(u,`${e}.json`);return await t(c,r).catch(e=>{console.error(`Error creating merged ${a(c)}:`,e)}),[e,{dictionaryPath:c,dictionary:r}]});return Object.fromEntries(d.filter(Boolean))};export{c as writeMergedDictionaries};
|
|
45
2
|
//# sourceMappingURL=writeMergedDictionary.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeMergedDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath
|
|
1
|
+
{"version":3,"file":"writeMergedDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport {\n mergeDictionaries,\n normalizeDictionaries,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { Dictionary } from '@intlayer/types';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { UnmergedDictionaryOutput } from './writeUnmergedDictionary';\n\nexport type MergedDictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type MergedDictionaryOutput = Record<string, MergedDictionaryResult>;\n\n/**\n * Write the merged dictionaries to the dictionariesDir\n * @param groupedDictionaries - The grouped dictionaries\n * @param configuration - The configuration\n * @returns The merged dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dictionary/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeMergedDictionaries = async (\n groupedDictionaries: UnmergedDictionaryOutput,\n configuration = getConfiguration()\n): Promise<MergedDictionaryOutput> => {\n const { dictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionariesEntry]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n MergedDictionaryResult,\n ];\n }\n\n const normalizedDictionaries = normalizeDictionaries(\n dictionariesEntry.dictionaries,\n configuration\n );\n\n const mergedDictionary = mergeDictionaries(normalizedDictionaries);\n\n const outputFileName = `${key}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n // Write the merged dictionary\n await writeJsonIfChanged(resultFilePath, mergedDictionary).catch(\n (err) => {\n console.error(\n `Error creating merged ${colorizePath(resultFilePath)}:`,\n err\n );\n }\n );\n\n return [\n key,\n {\n dictionaryPath: resultFilePath,\n dictionary: mergedDictionary,\n } as MergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<readonly [string, MergedDictionaryResult]>\n );\n};\n"],"mappings":"uZAoCA,MAAa,EAA0B,MACrC,EACA,EAAgB,GAAkB,GACE,CACpC,GAAM,CAAE,mBAAoB,EAAc,OAG1C,MAAM,EAAM,EAAQ,EAAgB,CAAE,CAAE,UAAW,GAAM,CAAC,CAE1D,IAAM,EAAU,MAAM,EACpB,OAAO,QAAQ,EAAoB,CACnC,MAAO,CAAC,EAAK,KAAuB,CAClC,GAAI,IAAQ,YACV,OAWF,IAAM,EAAmB,EALM,EAC7B,EAAkB,aAClB,EACD,CAEiE,CAG5D,EAAiB,EAAQ,EADR,GAAG,EAAI,OACiC,CAY/D,OATA,MAAM,EAAmB,EAAgB,EAAiB,CAAC,MACxD,GAAQ,CACP,QAAQ,MACN,yBAAyB,EAAa,EAAe,CAAC,GACtD,EACD,EAEJ,CAEM,CACL,EACA,CACE,eAAgB,EAChB,WAAY,EACb,CACF,EAEJ,CAED,OAAO,OAAO,YACZ,EAAQ,OAAO,QAAQ,CACxB"}
|
|
@@ -1,49 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { writeJsonIfChanged } from "../writeJsonIfChanged.mjs";
|
|
3
|
-
import { filterInvalidDictionaries } from "../filterInvalidDictionaries.mjs";
|
|
4
|
-
import { groupDictionariesByKey } from "./writeUnmergedDictionary.mjs";
|
|
5
|
-
import { formatDistantDictionaries } from "../loadDictionaries/loadRemoteDictionaries.mjs";
|
|
6
|
-
import { colorizePath, getConfiguration, x } from "@intlayer/config";
|
|
7
|
-
import { mkdir } from "node:fs/promises";
|
|
8
|
-
import { resolve } from "node:path";
|
|
9
|
-
import { orderDictionaries } from "@intlayer/core";
|
|
10
|
-
|
|
11
|
-
//#region src/buildIntlayerDictionary/writeRemoteDictionary.ts
|
|
12
|
-
/**
|
|
13
|
-
* Write the localized dictionaries to the dictionariesDir
|
|
14
|
-
* @param mergedDictionaries - The merged dictionaries
|
|
15
|
-
* @param configuration - The configuration
|
|
16
|
-
* @returns The final dictionaries
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
|
|
21
|
-
* const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);
|
|
22
|
-
* console.log(finalDictionaries);
|
|
23
|
-
*
|
|
24
|
-
* // .intlayer/fetch_dictionaries/home.json
|
|
25
|
-
* // { key: 'home', content: { ... } },
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
const writeRemoteDictionary = async (remoteDictionaries, configuration = getConfiguration()) => {
|
|
29
|
-
const { remoteDictionariesDir } = configuration.system;
|
|
30
|
-
await mkdir(resolve(remoteDictionariesDir), { recursive: true });
|
|
31
|
-
const groupedDictionaries = groupDictionariesByKey(filterInvalidDictionaries(remoteDictionaries, configuration));
|
|
32
|
-
const results = await parallelize(Object.entries(groupedDictionaries), async ([key, dictionaries]) => {
|
|
33
|
-
if (key === "undefined") return;
|
|
34
|
-
const orderedDictionaries = orderDictionaries(formatDistantDictionaries(dictionaries), configuration);
|
|
35
|
-
const unmergedFilePath = resolve(remoteDictionariesDir, `${key}.json`);
|
|
36
|
-
await writeJsonIfChanged(unmergedFilePath, orderedDictionaries).catch((err) => {
|
|
37
|
-
console.error(`${x} Error creating unmerged ${colorizePath(unmergedFilePath)}:`, err);
|
|
38
|
-
});
|
|
39
|
-
return [key, {
|
|
40
|
-
dictionaryPath: unmergedFilePath,
|
|
41
|
-
dictionaries
|
|
42
|
-
}];
|
|
43
|
-
});
|
|
44
|
-
return Object.fromEntries(results.filter(Boolean));
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
//#endregion
|
|
48
|
-
export { writeRemoteDictionary };
|
|
1
|
+
import{parallelize as e}from"../utils/parallelize.mjs";import{writeJsonIfChanged as t}from"../writeJsonIfChanged.mjs";import{filterInvalidDictionaries as n}from"../filterInvalidDictionaries.mjs";import{groupDictionariesByKey as r}from"./writeUnmergedDictionary.mjs";import{formatDistantDictionaries as i}from"../loadDictionaries/loadRemoteDictionaries.mjs";import{getConfiguration as a}from"@intlayer/config/node";import{mkdir as o}from"node:fs/promises";import{resolve as s}from"node:path";import{colorizePath as c,x as l}from"@intlayer/config/logger";import{orderDictionaries as u}from"@intlayer/core/dictionaryManipulator";const d=async(d,f=a())=>{let{remoteDictionariesDir:p}=f.system;await o(s(p),{recursive:!0});let m=r(n(d,f)),h=await e(Object.entries(m),async([e,n])=>{if(e===`undefined`)return;let r=u(i(n),f),a=s(p,`${e}.json`);return await t(a,r).catch(e=>{console.error(`${l} Error creating unmerged ${c(a)}:`,e)}),[e,{dictionaryPath:a,dictionaries:n}]});return Object.fromEntries(h.filter(Boolean))};export{d as writeRemoteDictionary};
|
|
49
2
|
//# sourceMappingURL=writeRemoteDictionary.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeRemoteDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeRemoteDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath,
|
|
1
|
+
{"version":3,"file":"writeRemoteDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeRemoteDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath, x } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { orderDictionaries } from '@intlayer/core/dictionaryManipulator';\nimport type { Dictionary } from '@intlayer/types';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { formatDistantDictionaries } from '../loadDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport {\n groupDictionariesByKey,\n type UnmergedDictionaryResult,\n} from './writeUnmergedDictionary';\n\nexport type RemoteDictionaryResult = {\n dictionaryPath: string;\n dictionaries: Dictionary[];\n};\n\nexport type RemoteDictionaryOutput = Record<string, RemoteDictionaryResult>;\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/fetch_dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeRemoteDictionary = async (\n remoteDictionaries: Dictionary[],\n configuration = getConfiguration()\n): Promise<RemoteDictionaryOutput> => {\n const { remoteDictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(remoteDictionariesDir), { recursive: true });\n\n const filteredDictionaries = filterInvalidDictionaries(\n remoteDictionaries,\n configuration\n );\n\n // Group dictionaries by key and write to unmergedDictionariesDir\n const groupedDictionaries = groupDictionariesByKey(filteredDictionaries);\n\n // Merge dictionaries with the same key and write to dictionariesDir\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionaries]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n UnmergedDictionaryResult,\n ];\n }\n\n const formattedDictionaries = formatDistantDictionaries(dictionaries);\n\n const orderedDictionaries = orderDictionaries(\n formattedDictionaries,\n configuration\n );\n\n const outputFileName = `${key}.json`;\n const unmergedFilePath = resolve(remoteDictionariesDir, outputFileName);\n\n // Write the grouped dictionaries\n await writeJsonIfChanged(unmergedFilePath, orderedDictionaries).catch(\n (err) => {\n console.error(\n `${x} Error creating unmerged ${colorizePath(unmergedFilePath)}:`,\n err\n );\n }\n );\n\n return [\n key,\n {\n dictionaryPath: unmergedFilePath,\n dictionaries,\n } as UnmergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<\n readonly [string, UnmergedDictionaryResult]\n >\n );\n};\n"],"mappings":"knBAsCA,MAAa,EAAwB,MACnC,EACA,EAAgB,GAAkB,GACE,CACpC,GAAM,CAAE,yBAA0B,EAAc,OAGhD,MAAM,EAAM,EAAQ,EAAsB,CAAE,CAAE,UAAW,GAAM,CAAC,CAQhE,IAAM,EAAsB,EANC,EAC3B,EACA,EACD,CAGuE,CAGlE,EAAU,MAAM,EACpB,OAAO,QAAQ,EAAoB,CACnC,MAAO,CAAC,EAAK,KAAkB,CAC7B,GAAI,IAAQ,YACV,OAQF,IAAM,EAAsB,EAFE,EAA0B,EAAa,CAInE,EACD,CAGK,EAAmB,EAAQ,EADV,GAAG,EAAI,OACyC,CAYvE,OATA,MAAM,EAAmB,EAAkB,EAAoB,CAAC,MAC7D,GAAQ,CACP,QAAQ,MACN,GAAG,EAAE,2BAA2B,EAAa,EAAiB,CAAC,GAC/D,EACD,EAEJ,CAEM,CACL,EACA,CACE,eAAgB,EAChB,eACD,CACF,EAEJ,CAED,OAAO,OAAO,YACZ,EAAQ,OAAO,QAAQ,CAGxB"}
|