@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.mjs","names":[],"sources":["../../../src/loadDictionaries/log.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n ANSIColors,\n colorize,\n extractErrorMessage,\n spinnerFrames,\n v,\n x,\n} from '@intlayer/config/client';\nimport type { DictionariesStatus } from './loadDictionaries';\n\nexport class DictionariesLogger {\n private statuses: DictionariesStatus[] = [];\n private spinnerTimer: NodeJS.Timeout | null = null;\n private spinnerIndex = 0;\n private renderedLines = 0;\n private readonly spinnerFrames = spinnerFrames;\n private isFinished = false;\n private readonly prefix: string;\n private lastRenderedState: string = '';\n private remoteCheckInProgress = false;\n private expectRemote = false;\n private remoteError: string | undefined;\n private pluginTotal = 0;\n private pluginDone = 0;\n private pluginError: string | undefined;\n\n constructor() {\n this.prefix = configuration?.log?.prefix ?? '';\n }\n\n setExpectRemote(expect: boolean) {\n this.expectRemote = expect;\n }\n\n startRemoteCheck() {\n if (this.isFinished) return;\n this.remoteCheckInProgress = true;\n this.startSpinner();\n this.render();\n }\n\n stopRemoteCheck() {\n this.remoteCheckInProgress = false;\n }\n\n update(newStatuses: DictionariesStatus[]) {\n if (this.isFinished) return;\n for (const status of newStatuses) {\n const index = this.statuses.findIndex(\n (s) =>\n s.dictionaryKey === status.dictionaryKey && s.type === status.type\n );\n if (index >= 0) {\n this.statuses[index] = status;\n } else {\n this.statuses.push(status);\n }\n }\n\n // If we expect remote fetch later, avoid rendering a local-only line first\n const { remoteTotal } = this.computeProgress();\n if (this.expectRemote && !this.remoteCheckInProgress && remoteTotal === 0) {\n // Do not start spinner or render yet; wait until remote check starts\n return;\n }\n\n this.startSpinner();\n this.render();\n }\n\n finish() {\n this.isFinished = true;\n this.stopSpinner();\n // Render final state and keep it visible\n this.render();\n }\n\n private startSpinner() {\n if (this.spinnerTimer || this.isFinished) return;\n this.spinnerTimer = setInterval(() => {\n this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;\n this.render();\n }, 100);\n }\n\n private stopSpinner() {\n if (!this.spinnerTimer) return;\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n }\n\n public setRemoteError = (error?: Error) => {\n this.remoteError = extractErrorMessage(error);\n // Avoid rendering a transient remote-only line while the remote check flag is still true\n // Ensure local + remote are rendered together after a failure\n this.stopRemoteCheck();\n this.render();\n };\n\n setPluginTotal(total: number) {\n if (this.isFinished) return;\n this.pluginTotal = total;\n if (total > 0) {\n this.startSpinner();\n }\n this.render();\n }\n\n setPluginDone(done: number) {\n if (this.isFinished) return;\n this.pluginDone = done;\n this.render();\n }\n\n setPluginError(error?: Error) {\n if (this.isFinished) return;\n this.pluginError = extractErrorMessage(error);\n this.render();\n }\n\n private render() {\n const {\n localTotal,\n localDone,\n remoteTotal,\n remoteDone,\n pluginTotal,\n pluginDone,\n } = this.computeProgress();\n\n const frame = this.spinnerFrames[this.spinnerIndex];\n const clock = colorize(frame, ANSIColors.BLUE);\n const lines: string[] = [];\n\n const isLocalDone = localDone === localTotal;\n const isRemoteDone = remoteDone === remoteTotal;\n const isPluginDone = pluginDone === pluginTotal;\n\n const suppressLocalWhileCheckingRemote =\n this.expectRemote && this.remoteCheckInProgress && remoteTotal === 0;\n\n if (!suppressLocalWhileCheckingRemote) {\n if (isLocalDone) {\n lines.push(\n `${this.prefix} ${v} Local content: ${colorize(`${localDone}`, ANSIColors.GREEN)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Local content: ${colorize(`${localDone}`, ANSIColors.BLUE)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Single remote line: show error, check, or progress counts\n if (remoteTotal > 0 || this.remoteCheckInProgress || this.remoteError) {\n if (this.remoteError) {\n lines.push(\n `${this.prefix} ${x} Remote content: ${colorize(\n this.remoteError,\n ANSIColors.RED\n )}`\n );\n } else if (remoteTotal === 0) {\n lines.push(\n `${this.prefix} ${clock} Remote content: ${colorize('Check server', ANSIColors.BLUE)}`\n );\n } else if (isRemoteDone) {\n lines.push(\n `${this.prefix} ${v} Remote content: ${colorize(`${remoteDone}`, ANSIColors.GREEN)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Remote content: ${colorize(`${remoteDone}`, ANSIColors.BLUE)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Plugin line: show error or progress counts\n if (pluginTotal > 0 || this.pluginError) {\n if (this.pluginError) {\n lines.push(\n `${this.prefix} ${x} Plugin content: ${colorize(\n this.pluginError,\n ANSIColors.RED\n )}`\n );\n } else if (isPluginDone) {\n lines.push(\n `${this.prefix} ${v} Plugin content: ${colorize(`${pluginDone}`, ANSIColors.GREEN)}${colorize(`/${pluginTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Plugin content: ${colorize(`${pluginDone}`, ANSIColors.BLUE)}${colorize(`/${pluginTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Check if the state has changed to avoid duplicate rendering\n const currentState = lines.join('\\n');\n if (currentState === this.lastRenderedState) {\n return;\n }\n this.lastRenderedState = currentState;\n\n if (this.renderedLines > 0) {\n process.stdout.write(`\\x1b[${this.renderedLines}F`);\n }\n\n const totalLinesToClear = Math.max(this.renderedLines, lines.length);\n for (let i = 0; i < totalLinesToClear; i++) {\n process.stdout.write('\\x1b[2K');\n const line = lines[i];\n if (line !== undefined) {\n process.stdout.write(line);\n }\n process.stdout.write('\\n');\n }\n\n this.renderedLines = lines.length;\n }\n\n private computeProgress() {\n const localKeys = new Set(\n this.statuses\n .filter((s) => s.type === 'local')\n .map((s) => s.dictionaryKey)\n );\n\n const localDoneKeys = new Set(\n this.statuses\n .filter(\n (s) =>\n s.type === 'local' && (s.status === 'built' || s.status === 'error')\n )\n .map((s) => s.dictionaryKey)\n );\n\n const remoteKeys = new Set(\n this.statuses\n .filter((s) => s.type === 'remote')\n .map((s) => s.dictionaryKey)\n );\n\n const remoteDoneKeys = new Set(\n this.statuses\n .filter(\n (s) =>\n s.type === 'remote' &&\n (s.status === 'fetched' ||\n s.status === 'imported' ||\n s.status === 'error')\n )\n .map((s) => s.dictionaryKey)\n );\n\n return {\n localTotal: localKeys.size,\n localDone: localDoneKeys.size,\n remoteTotal: remoteKeys.size,\n remoteDone: remoteDoneKeys.size,\n pluginTotal: this.pluginTotal,\n pluginDone: this.pluginDone,\n } as const;\n }\n}\n"],"mappings":";;;;AAWA,IAAa,qBAAb,MAAgC;CAC9B,AAAQ,WAAiC,EAAE;CAC3C,AAAQ,eAAsC;CAC9C,AAAQ,eAAe;CACvB,AAAQ,gBAAgB;CACxB,AAAiB,gBAAgB;CACjC,AAAQ,aAAa;CACrB,AAAiB;CACjB,AAAQ,oBAA4B;CACpC,AAAQ,wBAAwB;CAChC,AAAQ,eAAe;CACvB,AAAQ;CACR,AAAQ,cAAc;CACtB,AAAQ,aAAa;CACrB,AAAQ;CAER,cAAc;AACZ,OAAK,SAAS,eAAe,KAAK,UAAU;;CAG9C,gBAAgB,QAAiB;AAC/B,OAAK,eAAe;;CAGtB,mBAAmB;AACjB,MAAI,KAAK,WAAY;AACrB,OAAK,wBAAwB;AAC7B,OAAK,cAAc;AACnB,OAAK,QAAQ;;CAGf,kBAAkB;AAChB,OAAK,wBAAwB;;CAG/B,OAAO,aAAmC;AACxC,MAAI,KAAK,WAAY;AACrB,OAAK,MAAM,UAAU,aAAa;GAChC,MAAM,QAAQ,KAAK,SAAS,WACzB,MACC,EAAE,kBAAkB,OAAO,iBAAiB,EAAE,SAAS,OAAO,KACjE;AACD,OAAI,SAAS,EACX,MAAK,SAAS,SAAS;OAEvB,MAAK,SAAS,KAAK,OAAO;;EAK9B,MAAM,EAAE,gBAAgB,KAAK,iBAAiB;AAC9C,MAAI,KAAK,gBAA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AK,cAAc,GAAG;EAGrD,MAAM,oBAAoB,KAAK,IAAI,KAAK,eAAe,MAAM,OAAO;AACpE,OAAK,IAAI,IAAI,GAAG,IAAI,mBAAmB,KAAK;AAC1C,WAAQ,OAAO,MAAM,UAAU;GAC/B,MAAM,OAAO,MAAM;AACnB,OAAI,SAAS,OACX,SAAQ,OAAO,MAAM,KAAK;AAE5B,WAAQ,OAAO,MAAM,KAAK;;AAG5B,OAAK,gBAAgB,MAAM;;CAG7B,AAAQ,kBAAkB;EACxB,MAAM,YAAY,IAAI,IACpB,KAAK,SACF,QAAQ,MAAM,EAAE,SAAS,QAAQ,CACjC,KAAK,MAAM,EAAE,cAAc,CAC/B;EAED,MAAM,gBAAgB,IAAI,IACxB,KAAK,SACF,QACE,MACC,EAAE,SAAS,YAAY,EAAE,WAAW,WAAW,EAAE,WAAW,SAC/D,CACA,KAAK,MAAM,EAAE,cAAc,CAC/B;EAED,MAAM,aAAa,IAAI,IACrB,KAAK,SACF,QAAQ,MAAM,EAAE,SAAS,SAAS,CAClC,KAAK,MAAM,EAAE,cAAc,CAC/B;EAED,MAAM,iBAAiB,IAAI,IACzB,KAAK,SACF,QACE,MACC,EAAE,SAAS,aACV,EAAE,WAAW,aACZ,EAAE,WAAW,cACb,EAAE,WAAW,SAClB,CACA,KAAK,MAAM,EAAE,cAAc,CAC/B;AAED,SAAO;GACL,YAAY,UAAU;GACtB,WAAW,cAAc;GACzB,aAAa,WAAW;GACxB,YAAY,eAAe;GAC3B,aAAa,KAAK;GAClB,YAAY,KAAK;GAClB"}
|
|
1
|
+
{"version":3,"file":"log.mjs","names":[],"sources":["../../../src/loadDictionaries/log.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n ANSIColors,\n colorize,\n extractErrorMessage,\n spinnerFrames,\n v,\n x,\n} from '@intlayer/config/client';\nimport type { DictionariesStatus } from './loadDictionaries';\n\nexport class DictionariesLogger {\n private statuses: DictionariesStatus[] = [];\n private spinnerTimer: NodeJS.Timeout | null = null;\n private spinnerIndex = 0;\n private renderedLines = 0;\n private readonly spinnerFrames = spinnerFrames;\n private isFinished = false;\n private readonly prefix: string;\n private lastRenderedState: string = '';\n private remoteCheckInProgress = false;\n private expectRemote = false;\n private remoteError: string | undefined;\n private pluginTotal = 0;\n private pluginDone = 0;\n private pluginError: string | undefined;\n\n constructor() {\n this.prefix = configuration?.log?.prefix ?? '';\n }\n\n setExpectRemote(expect: boolean) {\n this.expectRemote = expect;\n }\n\n startRemoteCheck() {\n if (this.isFinished) return;\n this.remoteCheckInProgress = true;\n this.startSpinner();\n this.render();\n }\n\n stopRemoteCheck() {\n this.remoteCheckInProgress = false;\n }\n\n update(newStatuses: DictionariesStatus[]) {\n if (this.isFinished) return;\n for (const status of newStatuses) {\n const index = this.statuses.findIndex(\n (s) =>\n s.dictionaryKey === status.dictionaryKey && s.type === status.type\n );\n if (index >= 0) {\n this.statuses[index] = status;\n } else {\n this.statuses.push(status);\n }\n }\n\n // If we expect remote fetch later, avoid rendering a local-only line first\n const { remoteTotal } = this.computeProgress();\n if (this.expectRemote && !this.remoteCheckInProgress && remoteTotal === 0) {\n // Do not start spinner or render yet; wait until remote check starts\n return;\n }\n\n this.startSpinner();\n this.render();\n }\n\n finish() {\n this.isFinished = true;\n this.stopSpinner();\n // Render final state and keep it visible\n this.render();\n }\n\n private startSpinner() {\n if (this.spinnerTimer || this.isFinished) return;\n this.spinnerTimer = setInterval(() => {\n this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;\n this.render();\n }, 100);\n }\n\n private stopSpinner() {\n if (!this.spinnerTimer) return;\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n }\n\n public setRemoteError = (error?: Error) => {\n this.remoteError = extractErrorMessage(error);\n // Avoid rendering a transient remote-only line while the remote check flag is still true\n // Ensure local + remote are rendered together after a failure\n this.stopRemoteCheck();\n this.render();\n };\n\n setPluginTotal(total: number) {\n if (this.isFinished) return;\n this.pluginTotal = total;\n if (total > 0) {\n this.startSpinner();\n }\n this.render();\n }\n\n setPluginDone(done: number) {\n if (this.isFinished) return;\n this.pluginDone = done;\n this.render();\n }\n\n setPluginError(error?: Error) {\n if (this.isFinished) return;\n this.pluginError = extractErrorMessage(error);\n this.render();\n }\n\n private render() {\n const {\n localTotal,\n localDone,\n remoteTotal,\n remoteDone,\n pluginTotal,\n pluginDone,\n } = this.computeProgress();\n\n const frame = this.spinnerFrames[this.spinnerIndex];\n const clock = colorize(frame, ANSIColors.BLUE);\n const lines: string[] = [];\n\n const isLocalDone = localDone === localTotal;\n const isRemoteDone = remoteDone === remoteTotal;\n const isPluginDone = pluginDone === pluginTotal;\n\n const suppressLocalWhileCheckingRemote =\n this.expectRemote && this.remoteCheckInProgress && remoteTotal === 0;\n\n if (!suppressLocalWhileCheckingRemote) {\n if (isLocalDone) {\n lines.push(\n `${this.prefix} ${v} Local content: ${colorize(`${localDone}`, ANSIColors.GREEN)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Local content: ${colorize(`${localDone}`, ANSIColors.BLUE)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Single remote line: show error, check, or progress counts\n if (remoteTotal > 0 || this.remoteCheckInProgress || this.remoteError) {\n if (this.remoteError) {\n lines.push(\n `${this.prefix} ${x} Remote content: ${colorize(\n this.remoteError,\n ANSIColors.RED\n )}`\n );\n } else if (remoteTotal === 0) {\n lines.push(\n `${this.prefix} ${clock} Remote content: ${colorize('Check server', ANSIColors.BLUE)}`\n );\n } else if (isRemoteDone) {\n lines.push(\n `${this.prefix} ${v} Remote content: ${colorize(`${remoteDone}`, ANSIColors.GREEN)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Remote content: ${colorize(`${remoteDone}`, ANSIColors.BLUE)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Plugin line: show error or progress counts\n if (pluginTotal > 0 || this.pluginError) {\n if (this.pluginError) {\n lines.push(\n `${this.prefix} ${x} Plugin content: ${colorize(\n this.pluginError,\n ANSIColors.RED\n )}`\n );\n } else if (isPluginDone) {\n lines.push(\n `${this.prefix} ${v} Plugin content: ${colorize(`${pluginDone}`, ANSIColors.GREEN)}${colorize(`/${pluginTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Plugin content: ${colorize(`${pluginDone}`, ANSIColors.BLUE)}${colorize(`/${pluginTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Check if the state has changed to avoid duplicate rendering\n const currentState = lines.join('\\n');\n if (currentState === this.lastRenderedState) {\n return;\n }\n this.lastRenderedState = currentState;\n\n if (this.renderedLines > 0) {\n process.stdout.write(`\\x1b[${this.renderedLines}F`);\n }\n\n const totalLinesToClear = Math.max(this.renderedLines, lines.length);\n for (let i = 0; i < totalLinesToClear; i++) {\n process.stdout.write('\\x1b[2K');\n const line = lines[i];\n if (line !== undefined) {\n process.stdout.write(line);\n }\n process.stdout.write('\\n');\n }\n\n this.renderedLines = lines.length;\n }\n\n private computeProgress() {\n const localKeys = new Set(\n this.statuses\n .filter((s) => s.type === 'local')\n .map((s) => s.dictionaryKey)\n );\n\n const localDoneKeys = new Set(\n this.statuses\n .filter(\n (s) =>\n s.type === 'local' && (s.status === 'built' || s.status === 'error')\n )\n .map((s) => s.dictionaryKey)\n );\n\n const remoteKeys = new Set(\n this.statuses\n .filter((s) => s.type === 'remote')\n .map((s) => s.dictionaryKey)\n );\n\n const remoteDoneKeys = new Set(\n this.statuses\n .filter(\n (s) =>\n s.type === 'remote' &&\n (s.status === 'fetched' ||\n s.status === 'imported' ||\n s.status === 'error')\n )\n .map((s) => s.dictionaryKey)\n );\n\n return {\n localTotal: localKeys.size,\n localDone: localDoneKeys.size,\n remoteTotal: remoteKeys.size,\n remoteDone: remoteDoneKeys.size,\n pluginTotal: this.pluginTotal,\n pluginDone: this.pluginDone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EAAE,SAAW,YACb,EAAE,SAAW,SAClB,CACA,IAAK,GAAM,EAAE,cAAc,CAC/B,CAED,MAAO,CACL,WAAY,EAAU,KACtB,UAAW,EAAc,KACzB,YAAa,EAAW,KACxB,WAAY,EAAe,KAC3B,YAAa,KAAK,YAClB,WAAY,KAAK,WAClB"}
|
|
@@ -1,93 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createDictionaryEntryPoint } from "./createDictionaryEntryPoint/createDictionaryEntryPoint.mjs";
|
|
3
|
-
import { createModuleAugmentation } from "./createType/createModuleAugmentation.mjs";
|
|
4
|
-
import { createTypes } from "./createType/createType.mjs";
|
|
5
|
-
import { loadDictionaries } from "./loadDictionaries/loadDictionaries.mjs";
|
|
6
|
-
import { writeRemoteDictionary } from "./buildIntlayerDictionary/writeRemoteDictionary.mjs";
|
|
7
|
-
import { cleanOutputDir } from "./cleanOutputDir.mjs";
|
|
8
|
-
import { listDictionariesWithStats } from "./listDictionariesPath.mjs";
|
|
9
|
-
import { runOnce } from "./utils/runOnce.mjs";
|
|
10
|
-
import { isCachedConfigurationUpToDate, writeConfiguration } from "./writeConfiguration/index.mjs";
|
|
11
|
-
import { ANSIColors, cacheDisk, colorize, getAppLogger } from "@intlayer/config";
|
|
12
|
-
import { stat } from "node:fs/promises";
|
|
13
|
-
import { join } from "node:path";
|
|
14
|
-
import packageJson from "@intlayer/config/package.json" with { type: "json" };
|
|
15
|
-
|
|
16
|
-
//#region src/prepareIntlayer.ts
|
|
17
|
-
const DEFAULT_PREPARE_INTLAYER_OPTIONS = {
|
|
18
|
-
clean: false,
|
|
19
|
-
format: ["cjs", "esm"],
|
|
20
|
-
cacheTimeoutMs: 1e3 * 60 * 60
|
|
21
|
-
};
|
|
22
|
-
const prepareIntlayer = async (configuration, options) => {
|
|
23
|
-
const appLogger = getAppLogger(configuration);
|
|
24
|
-
const sentinelPath = join(configuration.system.cacheDir, "intlayer-prepared.lock");
|
|
25
|
-
const versionCache = cacheDisk(configuration, ["intlayer-version"]);
|
|
26
|
-
const intlayerCacheVersion = await versionCache.get();
|
|
27
|
-
const isCorrectVersion = Boolean(intlayerCacheVersion && intlayerCacheVersion === packageJson.version);
|
|
28
|
-
const isConfigSimilar = await isCachedConfigurationUpToDate(configuration);
|
|
29
|
-
const dictionariesWithStats = await listDictionariesWithStats(configuration);
|
|
30
|
-
let isDictionaryChanged = false;
|
|
31
|
-
try {
|
|
32
|
-
const sentinelStats = await stat(sentinelPath);
|
|
33
|
-
isDictionaryChanged = dictionariesWithStats.some((dictionary) => dictionary.stats.mtime.getTime() > sentinelStats.mtime.getTime());
|
|
34
|
-
} catch {}
|
|
35
|
-
const hasPluginLoadDictionaries = configuration.plugins?.some((plugin) => Boolean(plugin.loadDictionaries));
|
|
36
|
-
const { clean, format, forceRun, onIsCached, cacheTimeoutMs } = {
|
|
37
|
-
...DEFAULT_PREPARE_INTLAYER_OPTIONS,
|
|
38
|
-
forceRun: !isCorrectVersion || !isConfigSimilar || isDictionaryChanged || hasPluginLoadDictionaries,
|
|
39
|
-
...options ?? {}
|
|
40
|
-
};
|
|
41
|
-
await runOnce(sentinelPath, async () => {
|
|
42
|
-
if (clean || !isCorrectVersion) await cleanOutputDir(configuration);
|
|
43
|
-
await versionCache.set(packageJson.version);
|
|
44
|
-
const preparationStartMs = Date.now();
|
|
45
|
-
appLogger(["Preparing Intlayer", colorize(`(v${packageJson.version})`, ANSIColors.GREY_DARK)]);
|
|
46
|
-
await writeConfiguration(configuration);
|
|
47
|
-
const configurationWrittenTime = Date.now();
|
|
48
|
-
appLogger(["Configuration written", colorize(`(${configurationWrittenTime - preparationStartMs}ms)`, ANSIColors.GREY_DARK)], { isVerbose: true });
|
|
49
|
-
const dictionaries = await loadDictionaries(dictionariesWithStats.map((dictionary) => dictionary.path), configuration);
|
|
50
|
-
const dictionariesLoadedTime = Date.now();
|
|
51
|
-
appLogger(["Content loaded", colorize([dictionaries.remoteDictionaries.length + dictionaries.pluginDictionaries.length > 0 ? [
|
|
52
|
-
`(Total: ${dictionariesLoadedTime - configurationWrittenTime}ms`,
|
|
53
|
-
dictionaries.localDictionaries.length > 0 ? ` - Local: ${dictionaries.time.localDictionaries}ms` : "",
|
|
54
|
-
dictionaries.remoteDictionaries.length > 0 ? ` - Remote: ${dictionaries.time.remoteDictionaries}ms` : "",
|
|
55
|
-
dictionaries.pluginDictionaries.length > 0 ? ` - Plugin: ${dictionaries.time.pluginDictionaries}ms` : "",
|
|
56
|
-
`)`
|
|
57
|
-
].join("") : `(${dictionariesLoadedTime - configurationWrittenTime}ms)`].join(""), ANSIColors.GREY_DARK)], { isVerbose: true });
|
|
58
|
-
const dictionariesOutput = await buildDictionary([
|
|
59
|
-
...dictionaries.localDictionaries,
|
|
60
|
-
...dictionaries.remoteDictionaries,
|
|
61
|
-
...dictionaries.pluginDictionaries
|
|
62
|
-
], configuration, format, false);
|
|
63
|
-
await writeRemoteDictionary(dictionaries.remoteDictionaries, configuration);
|
|
64
|
-
await createTypes(Object.values(dictionariesOutput?.mergedDictionaries ?? {}).map((dictionary) => dictionary.dictionary), configuration);
|
|
65
|
-
await createDictionaryEntryPoint(configuration);
|
|
66
|
-
const dictionariesBuiltTime = Date.now();
|
|
67
|
-
appLogger(["Dictionaries built", colorize(`(${dictionariesBuiltTime - preparationStartMs}ms)`, ANSIColors.GREY_DARK)]);
|
|
68
|
-
await createModuleAugmentation(configuration);
|
|
69
|
-
appLogger(["Module augmentation built", colorize(`(${Date.now() - dictionariesBuiltTime}ms)`, ANSIColors.GREY_DARK)], { isVerbose: true });
|
|
70
|
-
for await (const plugin of configuration.plugins ?? []) {
|
|
71
|
-
const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;
|
|
72
|
-
await plugin.afterBuild?.({
|
|
73
|
-
dictionaries: {
|
|
74
|
-
unmergedDictionaries,
|
|
75
|
-
mergedDictionaries
|
|
76
|
-
},
|
|
77
|
-
configuration
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
appLogger([`Done`, colorize(`${Date.now() - preparationStartMs}ms`, ANSIColors.GREEN)], {
|
|
81
|
-
level: "info",
|
|
82
|
-
isVerbose: true
|
|
83
|
-
});
|
|
84
|
-
}, {
|
|
85
|
-
forceRun,
|
|
86
|
-
onIsCached,
|
|
87
|
-
cacheTimeoutMs
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
//#endregion
|
|
92
|
-
export { prepareIntlayer };
|
|
1
|
+
import{buildDictionary as e}from"./buildIntlayerDictionary/buildIntlayerDictionary.mjs";import{cleanOutputDir as t}from"./cleanOutputDir.mjs";import{createDictionaryEntryPoint as n}from"./createDictionaryEntryPoint/createDictionaryEntryPoint.mjs";import{createModuleAugmentation as r}from"./createType/createModuleAugmentation.mjs";import{createTypes as i}from"./createType/createType.mjs";import{loadDictionaries as a}from"./loadDictionaries/loadDictionaries.mjs";import{writeRemoteDictionary as o}from"./buildIntlayerDictionary/writeRemoteDictionary.mjs";import{listDictionariesWithStats as s}from"./listDictionariesPath.mjs";import{runOnce as c}from"./utils/runOnce.mjs";import{isCachedConfigurationUpToDate as l,writeConfiguration as u}from"./writeConfiguration/index.mjs";import{stat as d}from"node:fs/promises";import{join as f}from"node:path";import{ANSIColors as p,colorize as m,getAppLogger as h}from"@intlayer/config/logger";import{cacheDisk as g}from"@intlayer/config/utils";import _ from"@intlayer/config/package.json"with{type:"json"};const v={clean:!1,format:[`cjs`,`esm`],cacheTimeoutMs:1e3*60*60},y=async(y,b)=>{let x=h(y),S=f(y.system.cacheDir,`intlayer-prepared.lock`),C=g(y,[`intlayer-version`]),w=await C.get(),T=!!(w&&w===_.version),E=await l(y),D=await s(y),O=!1;try{let e=await d(S);O=D.some(t=>t.stats.mtime.getTime()>e.mtime.getTime())}catch{}let k=y.plugins?.some(e=>!!e.loadDictionaries),{clean:A,format:j,forceRun:M,onIsCached:N,cacheTimeoutMs:P}={...v,forceRun:!T||!E||O||k,...b??{}};await c(S,async()=>{(A||!T)&&await t(y),await C.set(_.version);let s=Date.now();x([`Preparing Intlayer`,m(`(v${_.version})`,p.GREY_DARK)]),await u(y);let c=Date.now();x([`Configuration written`,m(`(${c-s}ms)`,p.GREY_DARK)],{isVerbose:!0});let l=await a(D.map(e=>e.path),y),d=Date.now();x([`Content loaded`,m([l.remoteDictionaries.length+l.pluginDictionaries.length>0?[`(Total: ${d-c}ms`,l.localDictionaries.length>0?` - Local: ${l.time.localDictionaries}ms`:``,l.remoteDictionaries.length>0?` - Remote: ${l.time.remoteDictionaries}ms`:``,l.pluginDictionaries.length>0?` - Plugin: ${l.time.pluginDictionaries}ms`:``,`)`].join(``):`(${d-c}ms)`].join(``),p.GREY_DARK)],{isVerbose:!0});let f=await e([...l.localDictionaries,...l.remoteDictionaries,...l.pluginDictionaries],y,j,!1);await o(l.remoteDictionaries,y),await i(Object.values(f?.mergedDictionaries??{}).map(e=>e.dictionary),y),await n(y);let h=Date.now();x([`Dictionaries built`,m(`(${h-s}ms)`,p.GREY_DARK)]),await r(y),x([`Module augmentation built`,m(`(${Date.now()-h}ms)`,p.GREY_DARK)],{isVerbose:!0});for await(let e of y.plugins??[]){let{unmergedDictionaries:t,mergedDictionaries:n}=f;await e.afterBuild?.({dictionaries:{unmergedDictionaries:t,mergedDictionaries:n},configuration:y})}x([`Done`,m(`${Date.now()-s}ms`,p.GREEN)],{level:`info`,isVerbose:!0})},{forceRun:M,onIsCached:N,cacheTimeoutMs:P})};export{y as prepareIntlayer};
|
|
93
2
|
//# sourceMappingURL=prepareIntlayer.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareIntlayer.mjs","names":[],"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import { stat } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport {\n ANSIColors,\n cacheDisk,\n // checkVersionsConsistency,\n colorize,\n getAppLogger,\n} from '@intlayer/config';\nimport packageJson from '@intlayer/config/package.json' with { type: 'json' };\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { writeRemoteDictionary } from './buildIntlayerDictionary/writeRemoteDictionary';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { createModuleAugmentation, createTypes } from './createType/index';\nimport { listDictionariesWithStats } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { runOnce } from './utils/runOnce';\nimport {\n isCachedConfigurationUpToDate,\n writeConfiguration,\n} from './writeConfiguration';\n\ntype PrepareIntlayerOptions = {\n clean?: boolean;\n format?: ('cjs' | 'esm')[];\n forceRun?: boolean;\n cacheTimeoutMs?: number;\n onIsCached?: () => void | Promise<void>;\n};\n\nconst DEFAULT_PREPARE_INTLAYER_OPTIONS = {\n clean: false,\n format: ['cjs', 'esm'],\n cacheTimeoutMs: 1000 * 60 * 60, // 1 hour\n} satisfies PrepareIntlayerOptions;\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig,\n options?: PrepareIntlayerOptions\n) => {\n const appLogger = getAppLogger(configuration);\n\n const sentinelPath = join(\n configuration.system.cacheDir,\n 'intlayer-prepared.lock'\n );\n // Clean output dir if the intlayer version has changed\n const versionCache = cacheDisk(configuration, ['intlayer-version']);\n const intlayerCacheVersion = await versionCache.get();\n const isCorrectVersion = Boolean(\n intlayerCacheVersion && intlayerCacheVersion === packageJson.version\n );\n\n const isConfigSimilar = await isCachedConfigurationUpToDate(configuration);\n\n // Check if any dictionary has been changed to force a new rebuild\n const dictionariesWithStats = await listDictionariesWithStats(configuration);\n let isDictionaryChanged = false;\n try {\n // Try catch as sentinel file may not exist yet\n const sentinelStats = await stat(sentinelPath);\n isDictionaryChanged = dictionariesWithStats.some(\n (dictionary) =>\n dictionary.stats.mtime.getTime() > sentinelStats.mtime.getTime()\n );\n } catch {}\n\n const hasPluginLoadDictionaries = configuration.plugins?.some((plugin) =>\n Boolean(plugin.loadDictionaries)\n ); // Disable cache if any plugin because it can have custom behavior\n\n const { clean, format, forceRun, onIsCached, cacheTimeoutMs } = {\n ...DEFAULT_PREPARE_INTLAYER_OPTIONS,\n forceRun:\n !isCorrectVersion ||\n !isConfigSimilar ||\n isDictionaryChanged ||\n hasPluginLoadDictionaries,\n ...(options ?? {}),\n };\n\n // Skip preparation if it has already been done recently\n await runOnce(\n sentinelPath,\n async () => {\n // comment because of issue with next and webpack\n // await checkVersionsConsistency(configuration);\n\n if (clean || !isCorrectVersion) {\n await cleanOutputDir(configuration);\n }\n\n await versionCache.set(packageJson.version);\n\n const preparationStartMs = Date.now();\n\n appLogger([\n 'Preparing Intlayer',\n colorize(`(v${packageJson.version})`, ANSIColors.GREY_DARK),\n ]);\n\n await writeConfiguration(configuration);\n\n const configurationWrittenTime = Date.now();\n\n appLogger(\n [\n 'Configuration written',\n colorize(\n `(${configurationWrittenTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n const contentDeclarationPaths = dictionariesWithStats.map(\n (dictionary) => dictionary.path\n );\n\n const dictionaries = await loadDictionaries(\n contentDeclarationPaths,\n configuration\n );\n\n const dictionariesLoadedTime = Date.now();\n\n appLogger(\n [\n 'Content loaded',\n colorize(\n [\n dictionaries.remoteDictionaries.length +\n dictionaries.pluginDictionaries.length >\n 0\n ? [\n `(Total: ${dictionariesLoadedTime - configurationWrittenTime}ms`,\n dictionaries.localDictionaries.length > 0\n ? ` - Local: ${dictionaries.time.localDictionaries}ms`\n : '',\n dictionaries.remoteDictionaries.length > 0\n ? ` - Remote: ${dictionaries.time.remoteDictionaries}ms`\n : '',\n dictionaries.pluginDictionaries.length > 0\n ? ` - Plugin: ${dictionaries.time.pluginDictionaries}ms`\n : '',\n `)`,\n ].join('')\n : `(${dictionariesLoadedTime - configurationWrittenTime}ms)`,\n ].join(''),\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Build local dictionaries\n const dictionariesOutput = await buildDictionary(\n [\n ...dictionaries.localDictionaries,\n ...dictionaries.remoteDictionaries,\n ...dictionaries.pluginDictionaries,\n ],\n configuration,\n format,\n false\n );\n\n // Write remote dictionaries\n // Used as cache for next fetch\n await writeRemoteDictionary(\n dictionaries.remoteDictionaries,\n configuration\n );\n\n const dictionariesToBuild = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionary);\n\n await createTypes(dictionariesToBuild, configuration);\n\n await createDictionaryEntryPoint(configuration);\n\n const dictionariesBuiltTime = Date.now();\n\n appLogger([\n 'Dictionaries built',\n colorize(\n `(${dictionariesBuiltTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ]);\n\n await createModuleAugmentation(configuration);\n\n const moduleAugmentationBuiltTime = Date.now();\n\n appLogger(\n [\n 'Module augmentation built',\n colorize(\n `(${moduleAugmentationBuiltTime - dictionariesBuiltTime}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Plugin transformation\n // Allow plugins to post-process the final build output (e.g., write back ICU JSON)\n for await (const plugin of configuration.plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration,\n });\n }\n\n const preparationElapsedMs = Date.now() - preparationStartMs;\n appLogger(\n [`Done`, colorize(`${preparationElapsedMs}ms`, ANSIColors.GREEN)],\n {\n level: 'info',\n isVerbose: true,\n }\n );\n },\n {\n forceRun,\n onIsCached,\n cacheTimeoutMs,\n }\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAgCA,MAAM,mCAAmC;CACvC,OAAO;CACP,QAAQ,CAAC,OAAO,MAAM;CACtB,gBAAgB,MAAO,KAAK;CAC7B;AAED,MAAa,kBAAkB,OAC7B,eACA,YACG;CACH,MAAM,YAAY,aAAa,cAAc;CAE7C,MAAM,eAAe,KACnB,cAA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Aa,kBAAkB,SAAS,IACpC,aAAa,aAAa,KAAK,kBAAkB,MACjD;GACJ,aAAa,mBAAmB,SAAS,IACrC,cAAc,aAAa,KAAK,mBAAmB,MACnD;GACJ,aAAa,mBAAmB,SAAS,IACrC,cAAc,aAAa,KAAK,mBAAmB,MACnD;GACJ;GACD,CAAC,KAAK,GAAG,GACV,IAAI,yBAAyB,yBAAyB,KAC3D,CAAC,KAAK,GAAG,EACV,WAAW,UACZ,CACF,EACD,EACE,WAAW,MACZ,CACF;EAGD,MAAM,qBAAqB,MAAM,gBAC/B;GACE,GAAG,aAAa;GAChB,GAAG,aAAa;GAChB,GAAG,aAAa;GACjB,EACD,eACA,QACA,MACD;AAID,QAAM,sBACJ,aAAa,oBACb,cACD;AAMD,QAAM,YAJsB,OAAO,OACjC,oBAAoB,sBAAsB,EAAE,CAC7C,CAAC,KAAK,eAAe,WAAW,WAAW,EAEL,cAAc;AAErD,QAAM,2BAA2B,cAAc;EAE/C,MAAM,wBAAwB,KAAK,KAAK;AAExC,YAAU,CACR,sBACA,SACE,IAAI,wBAAwB,mBAAmB,MAC/C,WAAW,UACZ,CACF,CAAC;AAEF,QAAM,yBAAyB,cAAc;AAI7C,YACE,CACE,6BACA,SACE,IAN8B,KAAK,KAAK,GAMN,sBAAsB,MACxD,WAAW,UACZ,CACF,EACD,EACE,WAAW,MACZ,CACF;AAID,aAAW,MAAM,UAAU,cAAc,WAAW,EAAE,EAAE;GACtD,MAAM,EAAE,sBAAsB,uBAAuB;AAErD,SAAM,OAAO,aAAa;IACxB,cAAc;KACZ;KACA;KACD;IACD;IACD,CAAC;;AAIJ,YACE,CAAC,QAAQ,SAAS,GAFS,KAAK,KAAK,GAAG,mBAEE,KAAK,WAAW,MAAM,CAAC,EACjE;GACE,OAAO;GACP,WAAW;GACZ,CACF;IAEH;EACE;EACA;EACA;EACD,CACF"}
|
|
1
|
+
{"version":3,"file":"prepareIntlayer.mjs","names":[],"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import { stat } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { ANSIColors, colorize, getAppLogger } from '@intlayer/config/logger';\nimport packageJson from '@intlayer/config/package.json' with { type: 'json' };\nimport { cacheDisk } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { writeRemoteDictionary } from './buildIntlayerDictionary/writeRemoteDictionary';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { createModuleAugmentation, createTypes } from './createType/index';\nimport { listDictionariesWithStats } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { runOnce } from './utils/runOnce';\nimport {\n isCachedConfigurationUpToDate,\n writeConfiguration,\n} from './writeConfiguration';\n\ntype PrepareIntlayerOptions = {\n clean?: boolean;\n format?: ('cjs' | 'esm')[];\n forceRun?: boolean;\n cacheTimeoutMs?: number;\n onIsCached?: () => void | Promise<void>;\n};\n\nconst DEFAULT_PREPARE_INTLAYER_OPTIONS = {\n clean: false,\n format: ['cjs', 'esm'],\n cacheTimeoutMs: 1000 * 60 * 60, // 1 hour\n} satisfies PrepareIntlayerOptions;\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig,\n options?: PrepareIntlayerOptions\n) => {\n const appLogger = getAppLogger(configuration);\n\n const sentinelPath = join(\n configuration.system.cacheDir,\n 'intlayer-prepared.lock'\n );\n // Clean output dir if the intlayer version has changed\n const versionCache = cacheDisk(configuration, ['intlayer-version']);\n const intlayerCacheVersion = await versionCache.get();\n const isCorrectVersion = Boolean(\n intlayerCacheVersion && intlayerCacheVersion === packageJson.version\n );\n\n const isConfigSimilar = await isCachedConfigurationUpToDate(configuration);\n\n // Check if any dictionary has been changed to force a new rebuild\n const dictionariesWithStats = await listDictionariesWithStats(configuration);\n let isDictionaryChanged = false;\n try {\n // Try catch as sentinel file may not exist yet\n const sentinelStats = await stat(sentinelPath);\n isDictionaryChanged = dictionariesWithStats.some(\n (dictionary) =>\n dictionary.stats.mtime.getTime() > sentinelStats.mtime.getTime()\n );\n } catch {}\n\n const hasPluginLoadDictionaries = configuration.plugins?.some((plugin) =>\n Boolean(plugin.loadDictionaries)\n ); // Disable cache if any plugin because it can have custom behavior\n\n const { clean, format, forceRun, onIsCached, cacheTimeoutMs } = {\n ...DEFAULT_PREPARE_INTLAYER_OPTIONS,\n forceRun:\n !isCorrectVersion ||\n !isConfigSimilar ||\n isDictionaryChanged ||\n hasPluginLoadDictionaries,\n ...(options ?? {}),\n };\n\n // Skip preparation if it has already been done recently\n await runOnce(\n sentinelPath,\n async () => {\n // comment because of issue with next and webpack\n // await checkVersionsConsistency(configuration);\n\n if (clean || !isCorrectVersion) {\n await cleanOutputDir(configuration);\n }\n\n await versionCache.set(packageJson.version);\n\n const preparationStartMs = Date.now();\n\n appLogger([\n 'Preparing Intlayer',\n colorize(`(v${packageJson.version})`, ANSIColors.GREY_DARK),\n ]);\n\n await writeConfiguration(configuration);\n\n const configurationWrittenTime = Date.now();\n\n appLogger(\n [\n 'Configuration written',\n colorize(\n `(${configurationWrittenTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n const contentDeclarationPaths = dictionariesWithStats.map(\n (dictionary) => dictionary.path\n );\n\n const dictionaries = await loadDictionaries(\n contentDeclarationPaths,\n configuration\n );\n\n const dictionariesLoadedTime = Date.now();\n\n appLogger(\n [\n 'Content loaded',\n colorize(\n [\n dictionaries.remoteDictionaries.length +\n dictionaries.pluginDictionaries.length >\n 0\n ? [\n `(Total: ${dictionariesLoadedTime - configurationWrittenTime}ms`,\n dictionaries.localDictionaries.length > 0\n ? ` - Local: ${dictionaries.time.localDictionaries}ms`\n : '',\n dictionaries.remoteDictionaries.length > 0\n ? ` - Remote: ${dictionaries.time.remoteDictionaries}ms`\n : '',\n dictionaries.pluginDictionaries.length > 0\n ? ` - Plugin: ${dictionaries.time.pluginDictionaries}ms`\n : '',\n `)`,\n ].join('')\n : `(${dictionariesLoadedTime - configurationWrittenTime}ms)`,\n ].join(''),\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Build local dictionaries\n const dictionariesOutput = await buildDictionary(\n [\n ...dictionaries.localDictionaries,\n ...dictionaries.remoteDictionaries,\n ...dictionaries.pluginDictionaries,\n ],\n configuration,\n format,\n false\n );\n\n // Write remote dictionaries\n // Used as cache for next fetch\n await writeRemoteDictionary(\n dictionaries.remoteDictionaries,\n configuration\n );\n\n const dictionariesToBuild = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionary);\n\n await createTypes(dictionariesToBuild, configuration);\n\n await createDictionaryEntryPoint(configuration);\n\n const dictionariesBuiltTime = Date.now();\n\n appLogger([\n 'Dictionaries built',\n colorize(\n `(${dictionariesBuiltTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ]);\n\n await createModuleAugmentation(configuration);\n\n const moduleAugmentationBuiltTime = Date.now();\n\n appLogger(\n [\n 'Module augmentation built',\n colorize(\n `(${moduleAugmentationBuiltTime - dictionariesBuiltTime}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Plugin transformation\n // Allow plugins to post-process the final build output (e.g., write back ICU JSON)\n for await (const plugin of configuration.plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration,\n });\n }\n\n const preparationElapsedMs = Date.now() - preparationStartMs;\n appLogger(\n [`Done`, colorize(`${preparationElapsedMs}ms`, ANSIColors.GREEN)],\n {\n level: 'info',\n isVerbose: true,\n }\n );\n },\n {\n forceRun,\n onIsCached,\n cacheTimeoutMs,\n }\n );\n};\n"],"mappings":"whCA2BA,MAAM,EAAm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@
|
|
|
1
|
-
|
|
2
|
-
const applyMask = (full, mask) => {
|
|
3
|
-
if (mask === true) return full;
|
|
4
|
-
if (Array.isArray(mask) && Array.isArray(full)) return mask.map((m, i) => applyMask(full[i], m));
|
|
5
|
-
if (full && typeof full === "object" && "nodeType" in full) {
|
|
6
|
-
if (mask && typeof mask === "object") return full;
|
|
7
|
-
return full;
|
|
8
|
-
}
|
|
9
|
-
if (mask && typeof mask === "object" && full && typeof full === "object") {
|
|
10
|
-
const out = {};
|
|
11
|
-
const maskEntries = Object.entries(mask);
|
|
12
|
-
const allChildrenAreArrays = maskEntries.every(([, value]) => Array.isArray(value));
|
|
13
|
-
for (const [k, m] of maskEntries) {
|
|
14
|
-
const fullValue = full[k];
|
|
15
|
-
if (Array.isArray(m) && Array.isArray(fullValue)) {
|
|
16
|
-
const isTranslationNode = (val) => !!val && typeof val === "object" && "nodeType" in val;
|
|
17
|
-
const isArrayOfTranslationNodes = fullValue.every((item) => isTranslationNode(item));
|
|
18
|
-
if (!allChildrenAreArrays && !isArrayOfTranslationNodes) continue;
|
|
19
|
-
}
|
|
20
|
-
out[k] = applyMask(fullValue, m);
|
|
21
|
-
}
|
|
22
|
-
return out;
|
|
23
|
-
}
|
|
24
|
-
return full;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
export { applyMask };
|
|
1
|
+
const e=(t,n)=>{if(n===!0)return t;if(Array.isArray(n)&&Array.isArray(t))return n.map((n,r)=>e(t[r],n));if(t&&typeof t==`object`&&`nodeType`in t)return t;if(n&&typeof n==`object`&&t&&typeof t==`object`){let r={},i=Object.entries(n),a=i.every(([,e])=>Array.isArray(e));for(let[n,o]of i){let i=t[n];if(Array.isArray(o)&&Array.isArray(i)){let e=e=>!!e&&typeof e==`object`&&`nodeType`in e,t=i.every(t=>e(t));if(!a&&!t)continue}r[n]=e(i,o)}return r}return t};export{e as applyMask};
|
|
29
2
|
//# sourceMappingURL=applyMask.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyMask.mjs","names":[],"sources":["../../../src/reduceDictionaryContent/applyMask.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types';\n\nexport const applyMask = (full: Dictionary, mask: any): Dictionary => {\n // the mask \"true\" → we don't filter\n if (mask === true) {\n return full;\n }\n\n // arrays\n if (Array.isArray(mask) && Array.isArray(full)) {\n return mask.map((m, i) => applyMask(full[i], m)) as any;\n }\n\n // handle node with nodeType property\n if (full && typeof full === 'object' && 'nodeType' in full) {\n if (mask && typeof mask === 'object') {\n return full; // Keep the full object with nodeType intact\n }\n return full;\n }\n\n // generic object\n if (mask && typeof mask === 'object' && full && typeof full === 'object') {\n const out: any = {};\n const maskEntries = Object.entries(mask);\n const allChildrenAreArrays = maskEntries.every(([, value]) =>\n Array.isArray(value)\n );\n\n for (const [k, m] of maskEntries) {\n const fullValue = (full as any)[k];\n\n // If this child is an array, decide preservation rules.\n // - Preserve when all children at this level are arrays in the mask\n // - Also preserve when the array is an array of translation nodes\n if (Array.isArray(m) && Array.isArray(fullValue)) {\n const isTranslationNode = (val: unknown): boolean =>\n !!val && typeof val === 'object' && 'nodeType' in (val as any);\n const isArrayOfTranslationNodes = fullValue.every((item: any) =>\n isTranslationNode(item)\n );\n\n if (!allChildrenAreArrays && !isArrayOfTranslationNodes) {\n continue; // skip incidental arrays when mixed with non-arrays\n }\n }\n\n out[k] = applyMask(fullValue, m);\n }\n return out;\n }\n\n // unexpected case: we return the original value\n return full;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"applyMask.mjs","names":[],"sources":["../../../src/reduceDictionaryContent/applyMask.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types';\n\nexport const applyMask = (full: Dictionary, mask: any): Dictionary => {\n // the mask \"true\" → we don't filter\n if (mask === true) {\n return full;\n }\n\n // arrays\n if (Array.isArray(mask) && Array.isArray(full)) {\n return mask.map((m, i) => applyMask(full[i], m)) as any;\n }\n\n // handle node with nodeType property\n if (full && typeof full === 'object' && 'nodeType' in full) {\n if (mask && typeof mask === 'object') {\n return full; // Keep the full object with nodeType intact\n }\n return full;\n }\n\n // generic object\n if (mask && typeof mask === 'object' && full && typeof full === 'object') {\n const out: any = {};\n const maskEntries = Object.entries(mask);\n const allChildrenAreArrays = maskEntries.every(([, value]) =>\n Array.isArray(value)\n );\n\n for (const [k, m] of maskEntries) {\n const fullValue = (full as any)[k];\n\n // If this child is an array, decide preservation rules.\n // - Preserve when all children at this level are arrays in the mask\n // - Also preserve when the array is an array of translation nodes\n if (Array.isArray(m) && Array.isArray(fullValue)) {\n const isTranslationNode = (val: unknown): boolean =>\n !!val && typeof val === 'object' && 'nodeType' in (val as any);\n const isArrayOfTranslationNodes = fullValue.every((item: any) =>\n isTranslationNode(item)\n );\n\n if (!allChildrenAreArrays && !isArrayOfTranslationNodes) {\n continue; // skip incidental arrays when mixed with non-arrays\n }\n }\n\n out[k] = applyMask(fullValue, m);\n }\n return out;\n }\n\n // unexpected case: we return the original value\n return full;\n};\n"],"mappings":"AAEA,MAAa,GAAa,EAAkB,IAA0B,CAEpE,GAAI,IAAS,GACX,OAAO,EAIT,GAAI,MAAM,QAAQ,EAAK,EAAI,MAAM,QAAQ,EAAK,CAC5C,OAAO,EAAK,KAAK,EAAG,IAAM,EAAU,EAAK,GAAI,EAAE,CAAC,CAIlD,GAAI,GAAQ,OAAO,GAAS,UAAY,aAAc,EAIpD,OAFS,EAMX,GAAI,GAAQ,OAAO,GAAS,UAAY,GAAQ,OAAO,GAAS,SAAU,CACxE,IAAM,EAAW,EAAE,CACb,EAAc,OAAO,QAAQ,EAAK,CAClC,EAAuB,EAAY,OAAO,EAAG,KACjD,MAAM,QAAQ,EAAM,CACrB,CAED,IAAK,GAAM,CAAC,EAAG,KAAM,EAAa,CAChC,IAAM,EAAa,EAAa,GAKhC,GAAI,MAAM,QAAQ,EAAE,EAAI,MAAM,QAAQ,EAAU,CAAE,CAChD,IAAM,EAAqB,GACzB,CAAC,CAAC,GAAO,OAAO,GAAQ,UAAY,aAAe,EAC/C,EAA4B,EAAU,MAAO,GACjD,EAAkB,EAAK,CACxB,CAED,GAAI,CAAC,GAAwB,CAAC,EAC5B,SAIJ,EAAI,GAAK,EAAU,EAAW,EAAE,CAElC,OAAO,EAIT,OAAO"}
|
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getMaskContent } from "@intlayer/core";
|
|
3
|
-
|
|
4
|
-
//#region src/reduceDictionaryContent/reduceDictionaryContent.ts
|
|
5
|
-
const reduceDictionaryContent = (fullDictionary, partialDictionary) => {
|
|
6
|
-
return applyMask(fullDictionary, getMaskContent(partialDictionary));
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
//#endregion
|
|
10
|
-
export { reduceDictionaryContent };
|
|
1
|
+
import{applyMask as e}from"./applyMask.mjs";import{getMaskContent as t}from"@intlayer/core/plugins";const n=(n,r)=>e(n,t(r));export{n as reduceDictionaryContent};
|
|
11
2
|
//# sourceMappingURL=reduceDictionaryContent.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reduceDictionaryContent.mjs","names":[],"sources":["../../../src/reduceDictionaryContent/reduceDictionaryContent.ts"],"sourcesContent":["import { getMaskContent } from '@intlayer/core';\nimport type { Dictionary } from '@intlayer/types';\nimport { applyMask } from './applyMask';\n\nexport const reduceDictionaryContent = (\n fullDictionary: Dictionary,\n partialDictionary: Dictionary\n) => {\n const mask = getMaskContent(partialDictionary);\n const result = applyMask(fullDictionary, mask);\n\n return result;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"reduceDictionaryContent.mjs","names":[],"sources":["../../../src/reduceDictionaryContent/reduceDictionaryContent.ts"],"sourcesContent":["import { getMaskContent } from '@intlayer/core/plugins';\nimport type { Dictionary } from '@intlayer/types';\nimport { applyMask } from './applyMask';\n\nexport const reduceDictionaryContent = (\n fullDictionary: Dictionary,\n partialDictionary: Dictionary\n) => {\n const mask = getMaskContent(partialDictionary);\n const result = applyMask(fullDictionary, mask);\n\n return result;\n};\n"],"mappings":"oGAIA,MAAa,GACX,EACA,IAGe,EAAU,EADZ,EAAe,EAAkB,CACA"}
|
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { basename, dirname, extname } from "node:path";
|
|
3
|
-
|
|
4
|
-
//#region src/transformFiles/extractDictionaryKey.ts
|
|
5
|
-
const extractDictionaryKey = (filePath, fileText) => {
|
|
6
|
-
const componentName = detectExportedComponentName(fileText);
|
|
7
|
-
if (componentName) return componentName;
|
|
8
|
-
let baseName = basename(filePath, extname(filePath));
|
|
9
|
-
if (baseName === "index") baseName = basename(dirname(filePath));
|
|
10
|
-
return baseName;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
//#endregion
|
|
14
|
-
export { extractDictionaryKey };
|
|
1
|
+
import{detectExportedComponentName as e}from"../writeContentDeclaration/detectExportedComponentName.mjs";import{basename as t,dirname as n,extname as r}from"node:path";const i=(i,a)=>{let o=e(a);if(o)return o;let s=t(i,r(i));return s===`index`&&(s=t(n(i))),s};export{i as extractDictionaryKey};
|
|
15
2
|
//# sourceMappingURL=extractDictionaryKey.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractDictionaryKey.mjs","names":[],"sources":["../../../src/transformFiles/extractDictionaryKey.ts"],"sourcesContent":["import { basename, dirname, extname } from 'node:path';\nimport { detectExportedComponentName } from '../writeContentDeclaration/detectExportedComponentName';\n\nexport const extractDictionaryKey = (\n filePath: string,\n fileText: string\n): string => {\n const componentName = detectExportedComponentName(fileText);\n if (componentName) {\n return componentName;\n }\n\n const ext = extname(filePath);\n let baseName = basename(filePath, ext);\n\n if (baseName === 'index') {\n baseName = basename(dirname(filePath));\n }\n\n return baseName;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"extractDictionaryKey.mjs","names":[],"sources":["../../../src/transformFiles/extractDictionaryKey.ts"],"sourcesContent":["import { basename, dirname, extname } from 'node:path';\nimport { detectExportedComponentName } from '../writeContentDeclaration/detectExportedComponentName';\n\nexport const extractDictionaryKey = (\n filePath: string,\n fileText: string\n): string => {\n const componentName = detectExportedComponentName(fileText);\n if (componentName) {\n return componentName;\n }\n\n const ext = extname(filePath);\n let baseName = basename(filePath, ext);\n\n if (baseName === 'index') {\n baseName = basename(dirname(filePath));\n }\n\n return baseName;\n};\n"],"mappings":"wKAGA,MAAa,GACX,EACA,IACW,CACX,IAAM,EAAgB,EAA4B,EAAS,CAC3D,GAAI,EACF,OAAO,EAIT,IAAI,EAAW,EAAS,EADZ,EAAQ,EAAS,CACS,CAMtC,OAJI,IAAa,UACf,EAAW,EAAS,EAAQ,EAAS,CAAC,EAGjC"}
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ATTRIBUTES_TO_EXTRACT, extractIntlayer, generateKey, shouldExtract, transformFiles } from "./transformFiles.mjs";
|
|
3
|
-
|
|
4
|
-
export { ATTRIBUTES_TO_EXTRACT, extractDictionaryKey, extractIntlayer, generateKey, shouldExtract, transformFiles };
|
|
1
|
+
import{extractDictionaryKey as e}from"./extractDictionaryKey.mjs";import{ATTRIBUTES_TO_EXTRACT as t,extractIntlayer as n,generateKey as r,shouldExtract as i,transformFiles as a}from"./transformFiles.mjs";export{t as ATTRIBUTES_TO_EXTRACT,e as extractDictionaryKey,n as extractIntlayer,r as generateKey,i as shouldExtract,a as transformFiles};
|
|
@@ -1,245 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { writeContentDeclaration } from "../writeContentDeclaration/writeContentDeclaration.mjs";
|
|
3
|
-
import { extractDictionaryKey } from "./extractDictionaryKey.mjs";
|
|
4
|
-
import { ANSIColors, camelCaseToKebabCase, colorizePath, getAppLogger, getConfiguration } from "@intlayer/config";
|
|
5
|
-
import fs from "node:fs/promises";
|
|
6
|
-
import { basename, dirname, extname, join, relative, resolve } from "node:path";
|
|
7
|
-
import { Node, Project, SyntaxKind } from "ts-morph";
|
|
8
|
-
import { execSync } from "node:child_process";
|
|
9
|
-
|
|
10
|
-
//#region src/transformFiles/transformFiles.ts
|
|
11
|
-
/**
|
|
12
|
-
* Attributes that should be extracted for localization
|
|
13
|
-
*/
|
|
14
|
-
const ATTRIBUTES_TO_EXTRACT = [
|
|
15
|
-
"title",
|
|
16
|
-
"placeholder",
|
|
17
|
-
"alt",
|
|
18
|
-
"aria-label",
|
|
19
|
-
"label"
|
|
20
|
-
];
|
|
21
|
-
/**
|
|
22
|
-
* Default function to determine if a string should be extracted for localization
|
|
23
|
-
*/
|
|
24
|
-
const shouldExtract = (text) => {
|
|
25
|
-
const trimmed = text.trim();
|
|
26
|
-
if (!trimmed) return false;
|
|
27
|
-
if (!trimmed.includes(" ")) return false;
|
|
28
|
-
if (!/^[A-Z]/.test(trimmed)) return false;
|
|
29
|
-
if (trimmed.startsWith("{") || trimmed.startsWith("v-")) return false;
|
|
30
|
-
return true;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Generate a unique key from text for use as a dictionary key
|
|
34
|
-
*/
|
|
35
|
-
const generateKey = (text, existingKeys) => {
|
|
36
|
-
let key = text.replace(/\s+/g, " ").replace(/_+/g, " ").replace(/-+/g, " ").replace(/[^a-zA-Z0-9 ]/g, "").trim().split(" ").filter(Boolean).slice(0, 5).map((word, index) => index === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("");
|
|
37
|
-
if (!key) key = "content";
|
|
38
|
-
if (existingKeys.has(key)) {
|
|
39
|
-
let i = 1;
|
|
40
|
-
while (existingKeys.has(`${key}${i}`)) i++;
|
|
41
|
-
key = `${key}${i}`;
|
|
42
|
-
}
|
|
43
|
-
return key;
|
|
44
|
-
};
|
|
45
|
-
const writeContentHelper = async (extractedContent, componentKey, filePath, configuration, outputDir) => {
|
|
46
|
-
const { defaultLocale } = configuration.internationalization;
|
|
47
|
-
const { baseDir, fileExtensions } = configuration.content;
|
|
48
|
-
const isPerLocaleFile = configuration?.dictionary?.locale;
|
|
49
|
-
const dirName = outputDir ? resolve(outputDir) : dirname(filePath);
|
|
50
|
-
const baseName = basename(filePath, extname(filePath));
|
|
51
|
-
const contentFilePath = join(dirName, `${baseName.charAt(0).toLowerCase() + baseName.slice(1)}.${fileExtensions[0]}`);
|
|
52
|
-
const relativeContentFilePath = relative(baseDir, contentFilePath);
|
|
53
|
-
let dictionary;
|
|
54
|
-
if (isPerLocaleFile) dictionary = {
|
|
55
|
-
key: componentKey,
|
|
56
|
-
content: extractedContent,
|
|
57
|
-
locale: defaultLocale,
|
|
58
|
-
filePath: relativeContentFilePath
|
|
59
|
-
};
|
|
60
|
-
else {
|
|
61
|
-
const multilingualContent = {};
|
|
62
|
-
for (const [key, value] of Object.entries(extractedContent)) multilingualContent[key] = {
|
|
63
|
-
nodeType: "translation",
|
|
64
|
-
translation: { [defaultLocale]: value }
|
|
65
|
-
};
|
|
66
|
-
dictionary = {
|
|
67
|
-
key: componentKey,
|
|
68
|
-
content: multilingualContent,
|
|
69
|
-
filePath: relativeContentFilePath
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
const relativeDir = relative(baseDir, dirName);
|
|
73
|
-
await writeContentDeclaration(dictionary, configuration, { newDictionariesPath: relativeDir });
|
|
74
|
-
return contentFilePath;
|
|
75
|
-
};
|
|
76
|
-
const extractTsContent = (sourceFile, existingKeys) => {
|
|
77
|
-
const extractedContent = {};
|
|
78
|
-
const replacements = [];
|
|
79
|
-
sourceFile.forEachDescendant((node) => {
|
|
80
|
-
if (Node.isJsxText(node)) {
|
|
81
|
-
const text = node.getText();
|
|
82
|
-
if (shouldExtract(text)) {
|
|
83
|
-
const key = generateKey(text, existingKeys);
|
|
84
|
-
existingKeys.add(key);
|
|
85
|
-
extractedContent[key] = text.replace(/\s+/g, " ").trim();
|
|
86
|
-
replacements.push({
|
|
87
|
-
node,
|
|
88
|
-
key,
|
|
89
|
-
type: "jsx-text"
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
} else if (Node.isJsxAttribute(node)) {
|
|
93
|
-
const name = node.getNameNode().getText();
|
|
94
|
-
if (ATTRIBUTES_TO_EXTRACT.includes(name)) {
|
|
95
|
-
const initializer = node.getInitializer();
|
|
96
|
-
if (Node.isStringLiteral(initializer)) {
|
|
97
|
-
const text = initializer.getLiteralValue();
|
|
98
|
-
if (shouldExtract(text)) {
|
|
99
|
-
const key = generateKey(text, existingKeys);
|
|
100
|
-
existingKeys.add(key);
|
|
101
|
-
extractedContent[key] = text.trim();
|
|
102
|
-
replacements.push({
|
|
103
|
-
node,
|
|
104
|
-
key,
|
|
105
|
-
type: "jsx-attribute"
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
} else if (Node.isStringLiteral(node)) {
|
|
111
|
-
const text = node.getLiteralValue();
|
|
112
|
-
if (shouldExtract(text)) {
|
|
113
|
-
const parent = node.getParent();
|
|
114
|
-
if (parent?.getKindName() === "ImportDeclaration" || parent?.getKindName() === "ImportSpecifier" || parent?.getKindName() === "ModuleSpecifier") return;
|
|
115
|
-
if (Node.isJsxAttribute(parent)) return;
|
|
116
|
-
if (Node.isCallExpression(parent)) {
|
|
117
|
-
if (parent.getExpression().getText().includes("console.log")) return;
|
|
118
|
-
}
|
|
119
|
-
if (Node.isPropertyAssignment(parent)) {
|
|
120
|
-
if (parent.getNameNode() === node) return;
|
|
121
|
-
}
|
|
122
|
-
const key = generateKey(text, existingKeys);
|
|
123
|
-
existingKeys.add(key);
|
|
124
|
-
extractedContent[key] = text.trim();
|
|
125
|
-
replacements.push({
|
|
126
|
-
node,
|
|
127
|
-
key,
|
|
128
|
-
type: "string-literal"
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
return {
|
|
134
|
-
extractedContent,
|
|
135
|
-
replacements
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
const processTsxFile = async (filePath, componentKey, packageName, project, save = true) => {
|
|
139
|
-
let sourceFile;
|
|
140
|
-
try {
|
|
141
|
-
sourceFile = project.addSourceFileAtPath(filePath);
|
|
142
|
-
} catch {
|
|
143
|
-
sourceFile = project.getSourceFileOrThrow(filePath);
|
|
144
|
-
}
|
|
145
|
-
const isSolid = packageName === "solid-intlayer";
|
|
146
|
-
const { extractedContent, replacements } = extractTsContent(sourceFile, /* @__PURE__ */ new Set());
|
|
147
|
-
if (Object.keys(extractedContent).length === 0) return null;
|
|
148
|
-
for (const { node, key, type } of replacements) {
|
|
149
|
-
const contentAccess = isSolid ? `content().${key}` : `content.${key}`;
|
|
150
|
-
if (type === "jsx-text" && Node.isJsxText(node)) node.replaceWithText(`{${contentAccess}}`);
|
|
151
|
-
else if (type === "jsx-attribute" && Node.isJsxAttribute(node)) node.setInitializer(`{${contentAccess}.value}`);
|
|
152
|
-
else if (type === "string-literal" && Node.isStringLiteral(node)) node.replaceWithText(`${contentAccess}.value`);
|
|
153
|
-
}
|
|
154
|
-
const importDecl = sourceFile.getImportDeclaration((d) => d.getModuleSpecifierValue() === packageName);
|
|
155
|
-
if (!importDecl) sourceFile.addImportDeclaration({
|
|
156
|
-
namedImports: ["useIntlayer"],
|
|
157
|
-
moduleSpecifier: packageName
|
|
158
|
-
});
|
|
159
|
-
else if (!importDecl.getNamedImports().some((n) => n.getName() === "useIntlayer")) importDecl.addNamedImport("useIntlayer");
|
|
160
|
-
sourceFile.getFunctions().forEach((f) => {
|
|
161
|
-
f.getBody()?.asKind(SyntaxKind.Block)?.insertStatements(0, `const content = useIntlayer("${componentKey}");`);
|
|
162
|
-
});
|
|
163
|
-
sourceFile.getVariableDeclarations().forEach((v) => {
|
|
164
|
-
const init = v.getInitializer();
|
|
165
|
-
if (Node.isArrowFunction(init) || Node.isFunctionExpression(init)) {
|
|
166
|
-
const body = init.getBody();
|
|
167
|
-
if (Node.isBlock(body)) {
|
|
168
|
-
if (body.getText().includes("return") || body.getText().includes("use")) body.insertStatements(0, `const content = useIntlayer("${componentKey}");`);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
if (save) await sourceFile.save();
|
|
173
|
-
return extractedContent;
|
|
174
|
-
};
|
|
175
|
-
const extractIntlayer = async (filePath, packageName, options, project) => {
|
|
176
|
-
const saveComponent = !options?.declarationOnly;
|
|
177
|
-
const writeContent = !options?.codeOnly;
|
|
178
|
-
const configuration = getConfiguration(options?.configOptions);
|
|
179
|
-
const appLogger = getAppLogger(configuration);
|
|
180
|
-
const { baseDir } = configuration.content;
|
|
181
|
-
const _project = project || new Project({ skipAddingFilesFromTsConfig: true });
|
|
182
|
-
const baseName = extractDictionaryKey(filePath, (await fs.readFile(filePath)).toString());
|
|
183
|
-
const componentKey = camelCaseToKebabCase(baseName);
|
|
184
|
-
const ext = extname(filePath);
|
|
185
|
-
let extractedContent = null;
|
|
186
|
-
if (ext === ".vue") try {
|
|
187
|
-
const { processVueFile } = await import("@intlayer/vue-transformer");
|
|
188
|
-
extractedContent = await processVueFile(filePath, componentKey, packageName, {
|
|
189
|
-
generateKey,
|
|
190
|
-
shouldExtract,
|
|
191
|
-
extractTsContent
|
|
192
|
-
}, saveComponent);
|
|
193
|
-
} catch (error) {
|
|
194
|
-
if (error.code === "ERR_MODULE_NOT_FOUND" || error.message?.includes("Cannot find module")) throw new Error(`Please install ${colorizePath("@intlayer/vue-transformer", ANSIColors.YELLOW)} to process Vue files.`);
|
|
195
|
-
throw error;
|
|
196
|
-
}
|
|
197
|
-
else if (ext === ".svelte") try {
|
|
198
|
-
const { processSvelteFile } = await import("@intlayer/svelte-transformer");
|
|
199
|
-
extractedContent = await processSvelteFile(filePath, componentKey, packageName, {
|
|
200
|
-
generateKey,
|
|
201
|
-
shouldExtract,
|
|
202
|
-
extractTsContent
|
|
203
|
-
}, saveComponent);
|
|
204
|
-
} catch (error) {
|
|
205
|
-
if (error.code === "ERR_MODULE_NOT_FOUND" || error.message?.includes("Cannot find module")) throw new Error(`Please install ${colorizePath("@intlayer/svelte-transformer", ANSIColors.YELLOW)} to process Svelte files.`);
|
|
206
|
-
throw error;
|
|
207
|
-
}
|
|
208
|
-
else if ([
|
|
209
|
-
".tsx",
|
|
210
|
-
".jsx",
|
|
211
|
-
".ts",
|
|
212
|
-
".js"
|
|
213
|
-
].includes(ext)) extractedContent = await processTsxFile(filePath, componentKey, packageName, _project, saveComponent);
|
|
214
|
-
if (!extractedContent) {
|
|
215
|
-
appLogger(`No extractable text found in ${baseName}`);
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
if (writeContent) {
|
|
219
|
-
const contentFilePath = await writeContentHelper(extractedContent, componentKey, filePath, configuration, options?.outputDir);
|
|
220
|
-
appLogger(`Created content file: ${colorizePath(relative(configuration.content.baseDir, contentFilePath))}`);
|
|
221
|
-
}
|
|
222
|
-
if (saveComponent) {
|
|
223
|
-
try {
|
|
224
|
-
const formatCommand = detectFormatCommand(configuration);
|
|
225
|
-
if (formatCommand) execSync(formatCommand.replace("{{file}}", filePath), {
|
|
226
|
-
stdio: "ignore",
|
|
227
|
-
cwd: baseDir
|
|
228
|
-
});
|
|
229
|
-
} catch {}
|
|
230
|
-
appLogger(`Updated component: ${colorizePath(relative(baseDir, filePath))}`);
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
const transformFiles = async (filePaths, packageName, options) => {
|
|
234
|
-
const appLogger = getAppLogger(getConfiguration(options?.configOptions));
|
|
235
|
-
const project = new Project({ skipAddingFilesFromTsConfig: true });
|
|
236
|
-
for (const filePath of filePaths) try {
|
|
237
|
-
await extractIntlayer(filePath, packageName, options, project);
|
|
238
|
-
} catch (error) {
|
|
239
|
-
appLogger(`Failed to transform ${filePath}: ${error.message}`);
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
//#endregion
|
|
244
|
-
export { ATTRIBUTES_TO_EXTRACT, extractIntlayer, generateKey, shouldExtract, transformFiles };
|
|
1
|
+
import{detectFormatCommand as e}from"../writeContentDeclaration/detectFormatCommand.mjs";import{writeContentDeclaration as t}from"../writeContentDeclaration/writeContentDeclaration.mjs";import{extractDictionaryKey as n}from"./extractDictionaryKey.mjs";import{getConfiguration as r}from"@intlayer/config/node";import i from"node:fs/promises";import{basename as a,dirname as o,extname as s,join as c,relative as l,resolve as u}from"node:path";import{ANSIColors as d,colorizePath as f,getAppLogger as p}from"@intlayer/config/logger";import{camelCaseToKebabCase as m}from"@intlayer/config/utils";import{Node as h,Project as g,SyntaxKind as _}from"ts-morph";import{execSync as v}from"node:child_process";const y=[`title`,`placeholder`,`alt`,`aria-label`,`label`],b=e=>{let t=e.trim();return!(!t||!t.includes(` `)||!/^[A-Z]/.test(t)||t.startsWith(`{`)||t.startsWith(`v-`))},x=(e,t)=>{let n=e.replace(/\s+/g,` `).replace(/_+/g,` `).replace(/-+/g,` `).replace(/[^a-zA-Z0-9 ]/g,``).trim().split(` `).filter(Boolean).slice(0,5).map((e,t)=>t===0?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``);if(n||=`content`,t.has(n)){let e=1;for(;t.has(`${n}${e}`);)e++;n=`${n}${e}`}return n},S=async(e,n,r,i,d)=>{let{defaultLocale:f}=i.internationalization,{baseDir:p,fileExtensions:m}=i.content,h=i?.dictionary?.locale,g=d?u(d):o(r),_=a(r,s(r)),v=c(g,`${_.charAt(0).toLowerCase()+_.slice(1)}.${m[0]}`),y=l(p,v),b;if(h)b={key:n,content:e,locale:f,filePath:y};else{let t={};for(let[n,r]of Object.entries(e))t[n]={nodeType:`translation`,translation:{[f]:r}};b={key:n,content:t,filePath:y}}let x=l(p,g);return await t(b,i,{newDictionariesPath:x}),v},C=(e,t)=>{let n={},r=[];return e.forEachDescendant(e=>{if(h.isJsxText(e)){let i=e.getText();if(b(i)){let a=x(i,t);t.add(a),n[a]=i.replace(/\s+/g,` `).trim(),r.push({node:e,key:a,type:`jsx-text`})}}else if(h.isJsxAttribute(e)){let i=e.getNameNode().getText();if(y.includes(i)){let i=e.getInitializer();if(h.isStringLiteral(i)){let a=i.getLiteralValue();if(b(a)){let i=x(a,t);t.add(i),n[i]=a.trim(),r.push({node:e,key:i,type:`jsx-attribute`})}}}}else if(h.isStringLiteral(e)){let i=e.getLiteralValue();if(b(i)){let a=e.getParent();if(a?.getKindName()===`ImportDeclaration`||a?.getKindName()===`ImportSpecifier`||a?.getKindName()===`ModuleSpecifier`||h.isJsxAttribute(a)||h.isCallExpression(a)&&a.getExpression().getText().includes(`console.log`)||h.isPropertyAssignment(a)&&a.getNameNode()===e)return;let o=x(i,t);t.add(o),n[o]=i.trim(),r.push({node:e,key:o,type:`string-literal`})}}}),{extractedContent:n,replacements:r}},w=async(e,t,n,r,i=!0)=>{let a;try{a=r.addSourceFileAtPath(e)}catch{a=r.getSourceFileOrThrow(e)}let o=n===`solid-intlayer`,{extractedContent:s,replacements:c}=C(a,new Set);if(Object.keys(s).length===0)return null;for(let{node:e,key:t,type:n}of c){let r=o?`content().${t}`:`content.${t}`;n===`jsx-text`&&h.isJsxText(e)?e.replaceWithText(`{${r}}`):n===`jsx-attribute`&&h.isJsxAttribute(e)?e.setInitializer(`{${r}.value}`):n===`string-literal`&&h.isStringLiteral(e)&&e.replaceWithText(`${r}.value`)}let l=a.getImportDeclaration(e=>e.getModuleSpecifierValue()===n);return l?l.getNamedImports().some(e=>e.getName()===`useIntlayer`)||l.addNamedImport(`useIntlayer`):a.addImportDeclaration({namedImports:[`useIntlayer`],moduleSpecifier:n}),a.getFunctions().forEach(e=>{e.getBody()?.asKind(_.Block)?.insertStatements(0,`const content = useIntlayer("${t}");`)}),a.getVariableDeclarations().forEach(e=>{let n=e.getInitializer();if(h.isArrowFunction(n)||h.isFunctionExpression(n)){let e=n.getBody();h.isBlock(e)&&(e.getText().includes(`return`)||e.getText().includes(`use`))&&e.insertStatements(0,`const content = useIntlayer("${t}");`)}}),i&&await a.save(),s},T=async(t,a,o,c)=>{let u=!o?.declarationOnly,h=!o?.codeOnly,_=r(o?.configOptions),y=p(_),{baseDir:T}=_.content,E=c||new g({skipAddingFilesFromTsConfig:!0}),D=n(t,(await i.readFile(t)).toString()),O=m(D),k=s(t),A=null;if(k===`.vue`)try{let{processVueFile:e}=await import(`@intlayer/vue-transformer`);A=await e(t,O,a,{generateKey:x,shouldExtract:b,extractTsContent:C},u)}catch(e){throw e.code===`ERR_MODULE_NOT_FOUND`||e.message?.includes(`Cannot find module`)?Error(`Please install ${f(`@intlayer/vue-transformer`,d.YELLOW)} to process Vue files.`):e}else if(k===`.svelte`)try{let{processSvelteFile:e}=await import(`@intlayer/svelte-transformer`);A=await e(t,O,a,{generateKey:x,shouldExtract:b,extractTsContent:C},u)}catch(e){throw e.code===`ERR_MODULE_NOT_FOUND`||e.message?.includes(`Cannot find module`)?Error(`Please install ${f(`@intlayer/svelte-transformer`,d.YELLOW)} to process Svelte files.`):e}else [`.tsx`,`.jsx`,`.ts`,`.js`].includes(k)&&(A=await w(t,O,a,E,u));if(!A){y(`No extractable text found in ${D}`);return}if(h){let e=await S(A,O,t,_,o?.outputDir);y(`Created content file: ${f(l(_.content.baseDir,e))}`)}if(u){try{let n=e(_);n&&v(n.replace(`{{file}}`,t),{stdio:`ignore`,cwd:T})}catch{}y(`Updated component: ${f(l(T,t))}`)}},E=async(e,t,n)=>{let i=p(r(n?.configOptions)),a=new g({skipAddingFilesFromTsConfig:!0});for(let r of e)try{await T(r,t,n,a)}catch(e){i(`Failed to transform ${r}: ${e.message}`)}};export{y as ATTRIBUTES_TO_EXTRACT,T as extractIntlayer,x as generateKey,b as shouldExtract,E as transformFiles};
|
|
245
2
|
//# sourceMappingURL=transformFiles.mjs.map
|