@intlayer/chokidar 6.1.6 → 7.0.0-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{cjs → assets}/getContentDeclarationFileTemplate/cjsTemplate.txt +3 -2
- package/dist/{cjs → assets}/getContentDeclarationFileTemplate/esmTemplate.txt +2 -1
- package/dist/{cjs → assets}/getContentDeclarationFileTemplate/jsonTemplate.txt +2 -1
- package/dist/{cjs → assets}/getContentDeclarationFileTemplate/tsTemplate.txt +2 -1
- package/dist/cjs/_virtual/_utils_asset.cjs +104 -0
- package/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs +42 -80
- package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/index.cjs +5 -25
- package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs +21 -42
- package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +79 -116
- package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +62 -86
- package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +48 -69
- package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs +42 -52
- package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs +60 -82
- package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs.map +1 -1
- package/dist/cjs/cleanOutputDir.cjs +20 -60
- package/dist/cjs/cleanOutputDir.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +64 -103
- package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs +41 -73
- package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs +19 -49
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs +20 -50
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs +20 -50
- package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs +19 -49
- package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs +19 -49
- package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/index.cjs +15 -35
- package/dist/cjs/createType/createModuleAugmentation.cjs +56 -108
- package/dist/cjs/createType/createModuleAugmentation.cjs.map +1 -1
- package/dist/cjs/createType/createType.cjs +29 -58
- package/dist/cjs/createType/createType.cjs.map +1 -1
- package/dist/cjs/createType/index.cjs +7 -25
- package/dist/cjs/fetchDistantDictionaries.cjs +49 -77
- package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
- package/dist/cjs/filterInvalidDictionaries.cjs +26 -59
- package/dist/cjs/filterInvalidDictionaries.cjs.map +1 -1
- package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +32 -68
- package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -1
- package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +32 -51
- package/dist/cjs/handleAdditionalContentDeclarationFile.cjs.map +1 -1
- package/dist/cjs/handleContentDeclarationFileChange.cjs +35 -56
- package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -1
- package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs +36 -0
- package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs.map +1 -0
- package/dist/cjs/index.cjs +103 -156
- package/dist/cjs/listDictionariesPath.cjs +27 -59
- package/dist/cjs/listDictionariesPath.cjs.map +1 -1
- package/dist/cjs/listGitFiles.cjs +93 -162
- package/dist/cjs/listGitFiles.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +70 -0
- package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs.map +1 -0
- package/dist/cjs/loadDictionaries/index.cjs +11 -29
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +68 -90
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs +111 -166
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs +27 -53
- package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +60 -102
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/log.cjs +107 -182
- package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
- package/dist/cjs/prepareIntlayer.cjs +73 -130
- package/dist/cjs/prepareIntlayer.cjs.map +1 -1
- package/dist/cjs/reduceDictionaryContent/applyMask.cjs +27 -61
- package/dist/cjs/reduceDictionaryContent/applyMask.cjs.map +1 -1
- package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs +10 -32
- package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs.map +1 -1
- package/dist/cjs/utils/chunkJSON.cjs +329 -0
- package/dist/cjs/utils/chunkJSON.cjs.map +1 -0
- package/dist/cjs/utils/extractErrorMessage.cjs +92 -135
- package/dist/cjs/utils/extractErrorMessage.cjs.map +1 -1
- package/dist/cjs/utils/formatter.cjs +19 -49
- package/dist/cjs/utils/formatter.cjs.map +1 -1
- package/dist/cjs/utils/getChunk.cjs +34 -0
- package/dist/cjs/utils/getChunk.cjs.map +1 -0
- package/dist/cjs/utils/getFileHash.cjs +9 -40
- package/dist/cjs/utils/getFileHash.cjs.map +1 -1
- package/dist/cjs/utils/getFormatFromExtension.cjs +23 -54
- package/dist/cjs/utils/getFormatFromExtension.cjs.map +1 -1
- package/dist/cjs/utils/kebabCaseToCamelCase.cjs +11 -36
- package/dist/cjs/utils/kebabCaseToCamelCase.cjs.map +1 -1
- package/dist/cjs/utils/pLimit.cjs +128 -0
- package/dist/cjs/utils/pLimit.cjs.map +1 -0
- package/dist/cjs/utils/parallelize.cjs +10 -169
- package/dist/cjs/utils/parallelize.cjs.map +1 -1
- package/dist/cjs/utils/parallelizeGlobal.cjs +29 -0
- package/dist/cjs/utils/parallelizeGlobal.cjs.map +1 -0
- package/dist/cjs/utils/reduceObjectFormat.cjs +31 -0
- package/dist/cjs/utils/reduceObjectFormat.cjs.map +1 -0
- package/dist/cjs/utils/resolveObjectPromises.cjs +18 -48
- package/dist/cjs/utils/resolveObjectPromises.cjs.map +1 -1
- package/dist/cjs/utils/runOnce.cjs +80 -57
- package/dist/cjs/utils/runOnce.cjs.map +1 -1
- package/dist/cjs/utils/runParallel.cjs +163 -74
- package/dist/cjs/utils/runParallel.cjs.map +1 -1
- package/dist/cjs/utils/sortAlphabetically.cjs +5 -27
- package/dist/cjs/utils/sortAlphabetically.cjs.map +1 -1
- package/dist/cjs/utils/splitTextByLine.cjs +11 -0
- package/dist/cjs/utils/splitTextByLine.cjs.map +1 -0
- package/dist/cjs/utils/verifyIdenticObjectFormat copy.cjs +54 -0
- package/dist/cjs/utils/verifyIdenticObjectFormat copy.cjs.map +1 -0
- package/dist/cjs/utils/verifyIdenticObjectFormat.cjs +60 -0
- package/dist/cjs/utils/verifyIdenticObjectFormat.cjs.map +1 -0
- package/dist/cjs/watcher.cjs +61 -83
- package/dist/cjs/watcher.cjs.map +1 -1
- package/dist/cjs/writeConfiguration/index.cjs +15 -35
- package/dist/cjs/writeConfiguration/index.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs +25 -51
- package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/dictionaryStatus.cjs +0 -17
- package/dist/cjs/writeContentDeclaration/index.cjs +9 -33
- package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs +77 -0
- package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -0
- package/dist/cjs/writeContentDeclaration/transformJSFile.cjs +1731 -755
- package/dist/cjs/writeContentDeclaration/transformJSFile.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +113 -112
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +56 -66
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -1
- package/dist/cjs/writeFileIfChanged.cjs +10 -43
- package/dist/cjs/writeFileIfChanged.cjs.map +1 -1
- package/dist/cjs/writeJsonIfChanged.cjs +14 -31
- package/dist/cjs/writeJsonIfChanged.cjs.map +1 -1
- package/dist/esm/_virtual/_utils_asset.mjs +100 -0
- package/dist/esm/_virtual/rolldown_runtime.mjs +8 -0
- package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs +35 -54
- package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/index.mjs +4 -3
- package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs +18 -17
- package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +69 -91
- package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +53 -61
- package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs +40 -42
- package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs +35 -25
- package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs +53 -56
- package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs.map +1 -1
- package/dist/esm/cleanOutputDir.mjs +17 -36
- package/dist/esm/cleanOutputDir.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs +51 -70
- package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs +36 -47
- package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs +14 -14
- package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs +15 -15
- package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs +15 -15
- package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs +14 -14
- package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs +14 -14
- package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/index.mjs +9 -8
- package/dist/esm/createType/createModuleAugmentation.mjs +48 -71
- package/dist/esm/createType/createModuleAugmentation.mjs.map +1 -1
- package/dist/esm/createType/createType.mjs +24 -35
- package/dist/esm/createType/createType.mjs.map +1 -1
- package/dist/esm/createType/index.mjs +4 -3
- package/dist/esm/fetchDistantDictionaries.mjs +45 -52
- package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
- package/dist/esm/filterInvalidDictionaries.mjs +22 -37
- package/dist/esm/filterInvalidDictionaries.mjs.map +1 -1
- package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +31 -42
- package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -1
- package/dist/esm/handleAdditionalContentDeclarationFile.mjs +27 -24
- package/dist/esm/handleAdditionalContentDeclarationFile.mjs.map +1 -1
- package/dist/esm/handleContentDeclarationFileChange.mjs +30 -29
- package/dist/esm/handleContentDeclarationFileChange.mjs.map +1 -1
- package/dist/esm/handleUnlinkedContentDeclarationFile.mjs +34 -0
- package/dist/esm/handleUnlinkedContentDeclarationFile.mjs.map +1 -0
- package/dist/esm/index.mjs +39 -99
- package/dist/esm/listDictionariesPath.mjs +24 -24
- package/dist/esm/listDictionariesPath.mjs.map +1 -1
- package/dist/esm/listGitFiles.mjs +83 -124
- package/dist/esm/listGitFiles.mjs.map +1 -1
- package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +66 -0
- package/dist/esm/loadDictionaries/getIntlayerBundle.mjs.map +1 -0
- package/dist/esm/loadDictionaries/index.mjs +6 -5
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +61 -70
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadDictionaries.mjs +105 -146
- package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs +23 -31
- package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +52 -74
- package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/log.mjs +105 -165
- package/dist/esm/loadDictionaries/log.mjs.map +1 -1
- package/dist/esm/prepareIntlayer.mjs +64 -97
- package/dist/esm/prepareIntlayer.mjs.map +1 -1
- package/dist/esm/reduceDictionaryContent/applyMask.mjs +26 -37
- package/dist/esm/reduceDictionaryContent/applyMask.mjs.map +1 -1
- package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs +7 -7
- package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs.map +1 -1
- package/dist/esm/utils/chunkJSON.mjs +327 -0
- package/dist/esm/utils/chunkJSON.mjs.map +1 -0
- package/dist/esm/utils/extractErrorMessage.mjs +91 -111
- package/dist/esm/utils/extractErrorMessage.mjs.map +1 -1
- package/dist/esm/utils/formatter.mjs +10 -12
- package/dist/esm/utils/formatter.mjs.map +1 -1
- package/dist/esm/utils/getChunk.mjs +34 -0
- package/dist/esm/utils/getChunk.mjs.map +1 -0
- package/dist/esm/utils/getFileHash.mjs +6 -5
- package/dist/esm/utils/getFileHash.mjs.map +1 -1
- package/dist/esm/utils/getFormatFromExtension.mjs +21 -29
- package/dist/esm/utils/getFormatFromExtension.mjs.map +1 -1
- package/dist/esm/utils/kebabCaseToCamelCase.mjs +10 -12
- package/dist/esm/utils/kebabCaseToCamelCase.mjs.map +1 -1
- package/dist/esm/utils/pLimit.mjs +126 -0
- package/dist/esm/utils/pLimit.mjs.map +1 -0
- package/dist/esm/utils/parallelize.mjs +10 -144
- package/dist/esm/utils/parallelize.mjs.map +1 -1
- package/dist/esm/utils/parallelizeGlobal.mjs +27 -0
- package/dist/esm/utils/parallelizeGlobal.mjs.map +1 -0
- package/dist/esm/utils/reduceObjectFormat.mjs +30 -0
- package/dist/esm/utils/reduceObjectFormat.mjs.map +1 -0
- package/dist/esm/utils/resolveObjectPromises.mjs +17 -24
- package/dist/esm/utils/resolveObjectPromises.mjs.map +1 -1
- package/dist/esm/utils/runOnce.mjs +76 -33
- package/dist/esm/utils/runOnce.mjs.map +1 -1
- package/dist/esm/utils/runParallel.mjs +160 -40
- package/dist/esm/utils/runParallel.mjs.map +1 -1
- package/dist/esm/utils/sortAlphabetically.mjs +4 -3
- package/dist/esm/utils/sortAlphabetically.mjs.map +1 -1
- package/dist/esm/utils/splitTextByLine.mjs +10 -0
- package/dist/esm/utils/splitTextByLine.mjs.map +1 -0
- package/dist/esm/utils/verifyIdenticObjectFormat copy.mjs +53 -0
- package/dist/esm/utils/verifyIdenticObjectFormat copy.mjs.map +1 -0
- package/dist/esm/utils/verifyIdenticObjectFormat.mjs +59 -0
- package/dist/esm/utils/verifyIdenticObjectFormat.mjs.map +1 -0
- package/dist/esm/watcher.mjs +53 -58
- package/dist/esm/watcher.mjs.map +1 -1
- package/dist/esm/writeConfiguration/index.mjs +11 -10
- package/dist/esm/writeConfiguration/index.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs +24 -27
- package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/dictionaryStatus.mjs +0 -1
- package/dist/esm/writeContentDeclaration/index.mjs +6 -7
- package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +71 -0
- package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs.map +1 -0
- package/dist/esm/writeContentDeclaration/transformJSFile.mjs +1726 -735
- package/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +105 -76
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeJSFile.mjs +48 -46
- package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -1
- package/dist/esm/writeFileIfChanged.mjs +7 -18
- package/dist/esm/writeFileIfChanged.mjs.map +1 -1
- package/dist/esm/writeJsonIfChanged.mjs +14 -7
- package/dist/esm/writeJsonIfChanged.mjs.map +1 -1
- package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +14 -7
- package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/index.d.ts +3 -3
- package/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts +7 -2
- package/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +14 -10
- package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +8 -3
- package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +12 -7
- package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts +8 -2
- package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts +10 -6
- package/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts.map +1 -1
- package/dist/types/cleanOutputDir.d.ts +6 -1
- package/dist/types/cleanOutputDir.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +6 -1
- package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +6 -1
- package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts +7 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts +7 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts +7 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts +7 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts +7 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/index.d.ts +8 -8
- package/dist/types/createType/createModuleAugmentation.d.ts +8 -5
- package/dist/types/createType/createModuleAugmentation.d.ts.map +1 -1
- package/dist/types/createType/createType.d.ts +7 -4
- package/dist/types/createType/createType.d.ts.map +1 -1
- package/dist/types/createType/index.d.ts +3 -3
- package/dist/types/fetchDistantDictionaries.d.ts +10 -7
- package/dist/types/fetchDistantDictionaries.d.ts.map +1 -1
- package/dist/types/filterInvalidDictionaries.d.ts +7 -4
- package/dist/types/filterInvalidDictionaries.d.ts.map +1 -1
- package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts +6 -2
- package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts.map +1 -1
- package/dist/types/handleAdditionalContentDeclarationFile.d.ts +6 -2
- package/dist/types/handleAdditionalContentDeclarationFile.d.ts.map +1 -1
- package/dist/types/handleContentDeclarationFileChange.d.ts +6 -2
- package/dist/types/handleContentDeclarationFileChange.d.ts.map +1 -1
- package/dist/types/handleUnlinkedContentDeclarationFile.d.ts +7 -0
- package/dist/types/handleUnlinkedContentDeclarationFile.d.ts.map +1 -0
- package/dist/types/index.d.ts +49 -33
- package/dist/types/listDictionariesPath.d.ts +7 -2
- package/dist/types/listDictionariesPath.d.ts.map +1 -1
- package/dist/types/listGitFiles.d.ts +24 -12
- package/dist/types/listGitFiles.d.ts.map +1 -1
- package/dist/types/loadDictionaries/getIntlayerBundle.d.ts +11 -0
- package/dist/types/loadDictionaries/getIntlayerBundle.d.ts.map +1 -0
- package/dist/types/loadDictionaries/index.d.ts +5 -5
- package/dist/types/loadDictionaries/loadContentDeclaration.d.ts +8 -5
- package/dist/types/loadDictionaries/loadContentDeclaration.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadDictionaries.d.ts +18 -14
- package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadLocalDictionaries.d.ts +6 -3
- package/dist/types/loadDictionaries/loadLocalDictionaries.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +13 -8
- package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -1
- package/dist/types/loadDictionaries/log.d.ts +28 -24
- package/dist/types/loadDictionaries/log.d.ts.map +1 -1
- package/dist/types/prepareIntlayer.d.ts +12 -2
- package/dist/types/prepareIntlayer.d.ts.map +1 -1
- package/dist/types/reduceDictionaryContent/applyMask.d.ts +6 -2
- package/dist/types/reduceDictionaryContent/applyMask.d.ts.map +1 -1
- package/dist/types/reduceDictionaryContent/reduceDictionaryContent.d.ts +6 -2
- package/dist/types/reduceDictionaryContent/reduceDictionaryContent.d.ts.map +1 -1
- package/dist/types/utils/chunkJSON.d.ts +56 -0
- package/dist/types/utils/chunkJSON.d.ts.map +1 -0
- package/dist/types/utils/extractErrorMessage.d.ts +4 -1
- package/dist/types/utils/extractErrorMessage.d.ts.map +1 -1
- package/dist/types/utils/formatter.d.ts +8 -3
- package/dist/types/utils/formatter.d.ts.map +1 -1
- package/dist/types/utils/getChunk.d.ts +11 -0
- package/dist/types/utils/getChunk.d.ts.map +1 -0
- package/dist/types/utils/getFileHash.d.ts +4 -1
- package/dist/types/utils/getFileHash.d.ts.map +1 -1
- package/dist/types/utils/getFormatFromExtension.d.ts +7 -4
- package/dist/types/utils/getFormatFromExtension.d.ts.map +1 -1
- package/dist/types/utils/kebabCaseToCamelCase.d.ts +4 -1
- package/dist/types/utils/kebabCaseToCamelCase.d.ts.map +1 -1
- package/dist/types/utils/pLimit.d.ts +16 -0
- package/dist/types/utils/pLimit.d.ts.map +1 -0
- package/dist/types/utils/parallelize.d.ts +4 -13
- package/dist/types/utils/parallelize.d.ts.map +1 -1
- package/dist/types/utils/parallelizeGlobal.d.ts +22 -0
- package/dist/types/utils/parallelizeGlobal.d.ts.map +1 -0
- package/dist/types/utils/reduceObjectFormat.d.ts +17 -0
- package/dist/types/utils/reduceObjectFormat.d.ts.map +1 -0
- package/dist/types/utils/resolveObjectPromises.d.ts +4 -1
- package/dist/types/utils/resolveObjectPromises.d.ts.map +1 -1
- package/dist/types/utils/runOnce.d.ts +23 -2
- package/dist/types/utils/runOnce.d.ts.map +1 -1
- package/dist/types/utils/runParallel.d.ts +9 -6
- package/dist/types/utils/runParallel.d.ts.map +1 -1
- package/dist/types/utils/sortAlphabetically.d.ts +4 -1
- package/dist/types/utils/sortAlphabetically.d.ts.map +1 -1
- package/dist/types/utils/splitTextByLine.d.ts +5 -0
- package/dist/types/utils/splitTextByLine.d.ts.map +1 -0
- package/dist/types/utils/verifyIdenticObjectFormat copy.d.ts +23 -0
- package/dist/types/utils/verifyIdenticObjectFormat copy.d.ts.map +1 -0
- package/dist/types/utils/verifyIdenticObjectFormat.d.ts +23 -0
- package/dist/types/utils/verifyIdenticObjectFormat.d.ts.map +1 -0
- package/dist/types/watcher.d.ts +13 -9
- package/dist/types/watcher.d.ts.map +1 -1
- package/dist/types/writeConfiguration/index.d.ts +6 -2
- package/dist/types/writeConfiguration/index.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/detectExportedComponentName.d.ts +4 -1
- package/dist/types/writeContentDeclaration/detectExportedComponentName.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/dictionaryStatus.d.ts +4 -1
- package/dist/types/writeContentDeclaration/dictionaryStatus.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/index.d.ts +6 -7
- package/dist/types/writeContentDeclaration/processContentDeclarationContent.d.ts +7 -0
- package/dist/types/writeContentDeclaration/processContentDeclarationContent.d.ts.map +1 -0
- package/dist/types/writeContentDeclaration/transformJSFile.d.ts +33 -6
- package/dist/types/writeContentDeclaration/transformJSFile.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts +14 -6
- package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/writeJSFile.d.ts +7 -3
- package/dist/types/writeContentDeclaration/writeJSFile.d.ts.map +1 -1
- package/dist/types/writeFileIfChanged.d.ts +7 -2
- package/dist/types/writeFileIfChanged.d.ts.map +1 -1
- package/dist/types/writeJsonIfChanged.d.ts +7 -2
- package/dist/types/writeJsonIfChanged.d.ts.map +1 -1
- package/package.json +48 -54
- package/LICENSE +0 -202
- package/dist/cjs/buildIntlayerDictionary/index.cjs.map +0 -1
- package/dist/cjs/createDictionaryEntryPoint/index.cjs.map +0 -1
- package/dist/cjs/createType/index.cjs.map +0 -1
- package/dist/cjs/handleUnlikedContentDeclarationFile.cjs +0 -57
- package/dist/cjs/handleUnlikedContentDeclarationFile.cjs.map +0 -1
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/loadDictionaries/index.cjs.map +0 -1
- package/dist/cjs/mergeDictionaries.cjs +0 -143
- package/dist/cjs/mergeDictionaries.cjs.map +0 -1
- package/dist/cjs/orderDictionaries.cjs +0 -71
- package/dist/cjs/orderDictionaries.cjs.map +0 -1
- package/dist/cjs/prepareContentDeclaration.cjs +0 -93
- package/dist/cjs/prepareContentDeclaration.cjs.map +0 -1
- package/dist/cjs/processPerLocaleDictionary.cjs +0 -49
- package/dist/cjs/processPerLocaleDictionary.cjs.map +0 -1
- package/dist/cjs/utils/getExtention.cjs +0 -37
- package/dist/cjs/utils/getExtention.cjs.map +0 -1
- package/dist/cjs/writeContentDeclaration/dictionaryStatus.cjs.map +0 -1
- package/dist/cjs/writeContentDeclaration/formatCode.cjs +0 -78
- package/dist/cjs/writeContentDeclaration/formatCode.cjs.map +0 -1
- package/dist/cjs/writeContentDeclaration/index.cjs.map +0 -1
- package/dist/esm/buildIntlayerDictionary/index.mjs.map +0 -1
- package/dist/esm/createDictionaryEntryPoint/index.mjs.map +0 -1
- package/dist/esm/createType/index.mjs.map +0 -1
- package/dist/esm/getContentDeclarationFileTemplate/cjsTemplate.txt +0 -9
- package/dist/esm/getContentDeclarationFileTemplate/esmTemplate.txt +0 -9
- package/dist/esm/getContentDeclarationFileTemplate/jsonTemplate.txt +0 -5
- package/dist/esm/getContentDeclarationFileTemplate/tsTemplate.txt +0 -8
- package/dist/esm/handleUnlikedContentDeclarationFile.mjs +0 -33
- package/dist/esm/handleUnlikedContentDeclarationFile.mjs.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/loadDictionaries/index.mjs.map +0 -1
- package/dist/esm/mergeDictionaries.mjs +0 -109
- package/dist/esm/mergeDictionaries.mjs.map +0 -1
- package/dist/esm/orderDictionaries.mjs +0 -37
- package/dist/esm/orderDictionaries.mjs.map +0 -1
- package/dist/esm/prepareContentDeclaration.mjs +0 -72
- package/dist/esm/prepareContentDeclaration.mjs.map +0 -1
- package/dist/esm/processPerLocaleDictionary.mjs +0 -25
- package/dist/esm/processPerLocaleDictionary.mjs.map +0 -1
- package/dist/esm/utils/getExtention.mjs +0 -13
- package/dist/esm/utils/getExtention.mjs.map +0 -1
- package/dist/esm/writeContentDeclaration/dictionaryStatus.mjs.map +0 -1
- package/dist/esm/writeContentDeclaration/formatCode.mjs +0 -44
- package/dist/esm/writeContentDeclaration/formatCode.mjs.map +0 -1
- package/dist/esm/writeContentDeclaration/index.mjs.map +0 -1
- package/dist/types/buildIntlayerDictionary/index.d.ts.map +0 -1
- package/dist/types/createDictionaryEntryPoint/index.d.ts.map +0 -1
- package/dist/types/createType/index.d.ts.map +0 -1
- package/dist/types/handleUnlikedContentDeclarationFile.d.ts +0 -3
- package/dist/types/handleUnlikedContentDeclarationFile.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/loadDictionaries/index.d.ts.map +0 -1
- package/dist/types/mergeDictionaries.d.ts +0 -3
- package/dist/types/mergeDictionaries.d.ts.map +0 -1
- package/dist/types/orderDictionaries.d.ts +0 -10
- package/dist/types/orderDictionaries.d.ts.map +0 -1
- package/dist/types/prepareContentDeclaration.d.ts +0 -3
- package/dist/types/prepareContentDeclaration.d.ts.map +0 -1
- package/dist/types/processPerLocaleDictionary.d.ts +0 -32
- package/dist/types/processPerLocaleDictionary.d.ts.map +0 -1
- package/dist/types/utils/getExtention.d.ts +0 -3
- package/dist/types/utils/getExtention.d.ts.map +0 -1
- package/dist/types/writeContentDeclaration/formatCode.d.ts +0 -2
- package/dist/types/writeContentDeclaration/formatCode.d.ts.map +0 -1
- package/dist/types/writeContentDeclaration/index.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunkJSON.mjs","names":["output: string[]","patches: Patch[]","testPatch: SetPatch","rootType: RootType","sourceString: string","chunks: JsonChunk[]","currentChunk: JsonChunk","root: any","parts: string[]","output: any[]"],"sources":["../../../src/utils/chunkJSON.ts"],"sourcesContent":["/**\n * Split & reassemble JSON by character budget.\n * - Measures serialized size using JSON.stringify(..).length (characters).\n * - Ensures each chunk is itself valid JSON.\n * - Very large strings are split into safe pieces using getChunk and re-concatenated on assemble.\n * - Protects against circular structures (JSON can't serialize those anyway).\n */\n\nimport { getChunk } from './getChunk';\n\ntype JSONPrimitive = string | number | boolean | null;\ntype JSONValue = JSONPrimitive | JSONObject | JSONArray;\n\nexport type JSONObject = {\n [k: string]: JSONValue;\n};\n\ntype JSONArray = JSONValue[];\n\ntype Path = Array<string | number>;\n\ntype SetPatch = { op: 'set'; path: Path; value: JSONValue };\ntype StrAppendPatch = {\n op: 'str-append';\n path: Path;\n value: string; // part of a longer string\n index: number;\n total: number;\n};\ntype Patch = SetPatch | StrAppendPatch;\n\ntype RootType = 'object' | 'array';\n\nexport type JsonChunk = {\n schemaVersion: 1;\n index: number;\n total: number;\n rootType: RootType;\n checksum: string; // hash of the full original JSON string\n entries: Patch[];\n};\n\nconst isObject = (val: unknown): val is Record<string, unknown> => {\n return typeof val === 'object' && val !== null && !Array.isArray(val);\n};\n\nconst computeDjb2 = (str: string): string => {\n // Simple 32-bit hash; deterministic & fast\n let hash = 5381;\n\n for (let i = 0; i < str.length; i++) {\n hash = ((hash << 5) + hash) ^ str.charCodeAt(i);\n }\n\n // convert to unsigned hex\n return (hash >>> 0).toString(16).padStart(8, '0');\n};\n\nconst setAtPath = (root: any, path: Path, value: JSONValue) => {\n let current = root;\n\n for (let i = 0; i < path.length - 1; i++) {\n const key = path[i];\n const nextKey = path[i + 1];\n const isNextIndex = typeof nextKey === 'number';\n\n if (typeof key === 'number') {\n if (!Array.isArray(current)) {\n throw new Error(`Expected array at path segment ${i}`);\n }\n\n if (current[key] === undefined) {\n current[key] = isNextIndex ? [] : {};\n }\n\n current = current[key];\n } else {\n if (!isObject(current)) {\n throw new Error(`Expected object at path segment ${i}`);\n }\n\n if (!(key in current)) {\n (current as any)[key] = isNextIndex ? [] : {};\n }\n\n current = (current as any)[key];\n }\n }\n\n const last = path[path.length - 1];\n\n if (typeof last === 'number') {\n if (!Array.isArray(current)) {\n throw new Error(`Expected array at final segment`);\n }\n\n current[last] = value as any;\n } else {\n if (!isObject(current)) {\n throw new Error(`Expected object at final segment`);\n }\n\n (current as any)[last] = value as any;\n }\n};\n\nconst pathKey = (path: Path): string => {\n // stable key for grouping string parts\n return JSON.stringify(path);\n};\n\n/**\n * Split a string into parts using getChunk with a charLength budget per part.\n */\nconst splitStringByBudget = (\n str: string,\n maxCharsPerPart: number\n): string[] => {\n if (maxCharsPerPart <= 0) {\n throw new Error('maxChars must be > 0');\n }\n\n const output: string[] = [];\n let offset = 0;\n\n while (offset < str.length) {\n const part = getChunk(str, {\n charStart: offset,\n charLength: maxCharsPerPart,\n });\n\n if (!part) break;\n\n output.push(part);\n offset += part.length;\n }\n\n return output;\n};\n\n/**\n * Flatten JSON into patches (leaf writes). Strings too large to fit in a single\n * chunk are yielded as multiple str-append patches.\n */\nconst flattenToPatches = (\n value: JSONValue,\n maxCharsPerChunk: number,\n path: Path = [],\n seen = new WeakSet<object>()\n): Patch[] => {\n // Conservative per-entry cap so a single entry fits into an empty chunk with envelope overhead.\n // (Envelope ~ a few hundred chars; we keep a comfortable margin.)\n const maxStringPiece = Math.max(\n 1,\n Math.floor((maxCharsPerChunk - 400) * 0.8)\n );\n\n const patches: Patch[] = [];\n\n const walk = (currentValue: JSONValue, currentPath: Path) => {\n if (typeof currentValue === 'string') {\n // If the serialized patch wouldn't fit, split the string into multiple parts\n // and encode as a split-node sentinel with numbered keys.\n const testPatch: SetPatch = {\n op: 'set',\n path: currentPath,\n value: currentValue,\n };\n const testLen = JSON.stringify(testPatch).length + 150; // margin\n\n if (testLen <= maxCharsPerChunk) {\n patches.push(testPatch);\n return;\n }\n\n // Use getChunk-based splitting to produce stable parts\n const parts = splitStringByBudget(currentValue, maxStringPiece);\n\n // Emit split-node metadata and parts as individual leaf writes\n patches.push({\n op: 'set',\n path: [...currentPath, '__splittedType'],\n value: 'string',\n });\n patches.push({\n op: 'set',\n path: [...currentPath, '__total'],\n value: parts.length,\n });\n\n for (let i = 0; i < parts.length; i++) {\n patches.push({\n op: 'set',\n path: [...currentPath, String(i + 1)],\n value: parts[i],\n });\n }\n\n return;\n }\n\n if (currentValue === null || typeof currentValue !== 'object') {\n patches.push({ op: 'set', path: currentPath, value: currentValue });\n return;\n }\n\n if (seen.has(currentValue as object)) {\n throw new Error('Cannot serialize circular structures to JSON.');\n }\n\n seen.add(currentValue as object);\n\n if (Array.isArray(currentValue)) {\n for (let i = 0; i < currentValue.length; i++) {\n walk(currentValue[i] as JSONValue, [...currentPath, i]);\n }\n } else {\n for (const key of Object.keys(currentValue)) {\n walk((currentValue as JSONObject)[key], [...currentPath, key]);\n }\n }\n\n seen.delete(currentValue as object);\n };\n\n walk(value, path);\n return patches;\n};\n\n/**\n * Split JSON into chunks constrained by character count of serialized chunk.\n */\nexport const chunkJSON = (\n value: JSONObject | JSONArray,\n maxChars: number\n): JsonChunk[] => {\n if (!isObject(value) && !Array.isArray(value)) {\n throw new Error('Root must be an object or array.');\n }\n\n if (maxChars < 500) {\n // You can lower this if you truly need; recommended to keep some envelope headroom.\n throw new Error('maxChars is too small. Use at least 500 characters.');\n }\n\n const rootType: RootType = Array.isArray(value) ? 'array' : 'object';\n let sourceString: string;\n\n try {\n sourceString = JSON.stringify(value);\n } catch {\n // Provide a deterministic error message for circular refs\n throw new Error('Cannot serialize circular structures to JSON.');\n }\n\n const checksum = computeDjb2(sourceString);\n const allPatches = flattenToPatches(value as JSONValue, maxChars);\n\n const chunks: JsonChunk[] = [];\n let currentChunk: JsonChunk = {\n schemaVersion: 1,\n index: 0, // provisional\n total: 0, // provisional\n rootType,\n checksum,\n entries: [],\n };\n\n const emptyEnvelopeSize = JSON.stringify({\n ...currentChunk,\n entries: [],\n }).length;\n\n const tryFlush = () => {\n if (currentChunk.entries.length > 0) {\n chunks.push(currentChunk);\n currentChunk = {\n schemaVersion: 1,\n index: 0,\n total: 0,\n rootType,\n checksum,\n entries: [],\n };\n }\n };\n\n for (const patch of allPatches) {\n // Would adding this patch exceed maxChars?\n const withPatchSize =\n emptyEnvelopeSize +\n JSON.stringify(currentChunk.entries).length + // current entries array\n (currentChunk.entries.length ? 1 : 0) + // possible comma\n JSON.stringify(patch).length;\n\n if (withPatchSize <= maxChars) {\n currentChunk.entries.push(patch);\n } else {\n // Start a new chunk if current has items\n if (currentChunk.entries.length > 0) {\n tryFlush();\n }\n\n // Ensure single patch fits into an empty chunk\n const singleSize = emptyEnvelopeSize + JSON.stringify([patch]).length;\n\n if (singleSize > maxChars) {\n // This should only happen for massive strings, which we pre-split;\n // if it happens for a non-string, we cannot split further.\n throw new Error(\n 'A single entry exceeds maxChars and cannot be split. Reduce entry size or increase maxChars.'\n );\n }\n\n currentChunk.entries.push(patch);\n }\n }\n\n tryFlush();\n\n // Ensure at least one chunk exists (even for empty root)\n if (chunks.length === 0) {\n chunks.push({\n schemaVersion: 1,\n index: 0,\n total: 0, // provisional\n rootType,\n checksum,\n entries: [],\n });\n }\n\n // Finalize indices & totals\n const totalChunks = chunks.length;\n\n chunks.forEach((chunk, index) => {\n chunk.index = index;\n chunk.total = totalChunks;\n });\n\n return chunks;\n};\n\n/**\n * Reassemble JSON from chunks.\n * - Validates checksums and indices.\n * - Applies 'set' patches and merges string pieces from 'str-append'.\n */\n/**\n * Reconstruct content from a single chunk without validation.\n * Useful for processing individual chunks in a pipeline where you don't have all chunks yet.\n * Note: This will only reconstruct the partial content contained in this chunk.\n */\nexport const reconstructFromSingleChunk = (\n chunk: JsonChunk\n): JSONObject | JSONArray => {\n const root: any = chunk.rootType === 'array' ? [] : {};\n\n // Apply all 'set' patches from this chunk\n for (const entry of chunk.entries) {\n if (entry.op === 'set') {\n setAtPath(root, entry.path, entry.value);\n }\n }\n\n // Reconcile split-node sentinels for strings/arrays\n // When reconstructing from a single chunk, we may have incomplete split nodes\n const reconcileSplitNodes = (node: any): any => {\n if (node === null || typeof node !== 'object') return node;\n\n if (Array.isArray(node)) {\n for (let i = 0; i < node.length; i++) {\n node[i] = reconcileSplitNodes(node[i]);\n }\n return node;\n }\n\n // string split-node\n if ((node as any)['__splittedType'] === 'string') {\n const total = (node as any)['__total'];\n\n if (typeof total !== 'number' || total <= 0) {\n // Invalid split node, return as-is\n return node;\n }\n\n const parts: string[] = [];\n let hasAllParts = true;\n\n for (let i = 1; i <= total; i++) {\n const piece = (node as any)[String(i)];\n\n if (typeof piece !== 'string') {\n hasAllParts = false;\n break;\n }\n\n parts.push(piece);\n }\n\n // Only reconstruct if we have all parts, otherwise return the node as-is\n if (hasAllParts) {\n return parts.join('');\n }\n\n return node;\n }\n\n // array split-node (optional support)\n if ((node as any)['__splittedType'] === 'array') {\n const total = (node as any)['__total'];\n\n if (typeof total !== 'number' || total < 0) {\n // Invalid split node, return as-is\n return node;\n }\n\n const output: any[] = [];\n let hasAllParts = true;\n\n for (let i = 1; i <= total; i++) {\n const slice = (node as any)[String(i)];\n\n if (!Array.isArray(slice)) {\n hasAllParts = false;\n break;\n }\n\n for (let j = 0; j < slice.length; j++) {\n output.push(reconcileSplitNodes(slice[j]));\n }\n }\n\n // Only reconstruct if we have all parts\n if (hasAllParts) {\n return output;\n }\n\n return node;\n }\n\n // walk normal object\n for (const key of Object.keys(node)) {\n node[key] = reconcileSplitNodes(node[key]);\n }\n\n return node;\n };\n\n return reconcileSplitNodes(root);\n};\n\nexport const assembleJSON = (chunks: JsonChunk[]): JSONObject | JSONArray => {\n if (!chunks || chunks.length === 0) {\n throw new Error('No chunks provided.');\n }\n\n // Basic validation & sort\n const sorted = [...chunks].sort((a, b) => a.index - b.index);\n const { checksum, rootType } = sorted[0];\n const schemaVersion = 1;\n\n for (let i = 0; i < sorted.length; i++) {\n const chunk = sorted[i];\n\n if (chunk.schemaVersion !== schemaVersion) {\n console.error('Unsupported schemaVersion.', {\n cause: chunk,\n schemaVersion,\n });\n throw new Error('Unsupported schemaVersion.');\n }\n\n if (chunk.rootType !== rootType) {\n console.error('Chunks rootType mismatch.', {\n cause: chunk,\n rootType,\n });\n throw new Error('Chunks rootType mismatch.');\n }\n\n if (chunk.checksum !== checksum) {\n console.error('Chunks checksum mismatch (different source objects?).', {\n cause: chunk,\n checksum,\n });\n throw new Error('Chunks checksum mismatch (different source objects?).');\n }\n\n if (chunk.index !== i) {\n console.error('Chunk indices are not contiguous or sorted.', {\n cause: chunk,\n index: chunk.index,\n i,\n });\n throw new Error('Chunk indices are not contiguous or sorted.');\n }\n\n // Defer total check until after reconstruction to prefer more specific errors\n }\n\n const root: any = rootType === 'array' ? [] : {};\n\n // Collect string parts by path\n const stringParts = new Map<\n string,\n { path: Path; total: number; received: StrAppendPatch[] }\n >();\n\n const applySet = (patch: SetPatch) =>\n setAtPath(root, patch.path, patch.value);\n\n for (const chunk of sorted) {\n for (const entry of chunk.entries) {\n if (entry.op === 'set') {\n applySet(entry);\n } else {\n const key = pathKey(entry.path);\n const record = stringParts.get(key) ?? {\n path: entry.path,\n total: entry.total,\n received: [],\n };\n\n if (record.total !== entry.total) {\n throw new Error('Inconsistent string part totals for a path.');\n }\n\n record.received.push(entry);\n stringParts.set(key, record);\n }\n }\n }\n\n // Stitch strings\n for (const { path, total, received } of stringParts.values()) {\n if (received.length !== total) {\n throw new Error('Missing string parts for a path; incomplete chunk set.');\n }\n\n received.sort((a, b) => a.index - b.index);\n const fullString = received.map((part) => part.value).join('');\n setAtPath(root, path, fullString);\n }\n\n // Reconcile split-node sentinels for strings/arrays after all patches applied\n const reconcileSplitNodes = (node: any): any => {\n if (node === null || typeof node !== 'object') return node;\n\n if (Array.isArray(node)) {\n for (let i = 0; i < node.length; i++) {\n node[i] = reconcileSplitNodes(node[i]);\n }\n return node;\n }\n\n // string split-node\n if ((node as any)['__splittedType'] === 'string') {\n const total = (node as any)['__total'];\n\n if (typeof total !== 'number' || total <= 0) {\n throw new Error('Invalid split-node total for a path.');\n }\n\n const parts: string[] = [];\n\n for (let i = 1; i <= total; i++) {\n const piece = (node as any)[String(i)];\n\n if (typeof piece !== 'string') {\n throw new Error(\n 'Missing string parts for a path; incomplete chunk set.'\n );\n }\n\n parts.push(piece);\n }\n\n return parts.join('');\n }\n\n // array split-node (optional support)\n if ((node as any)['__splittedType'] === 'array') {\n const total = (node as any)['__total'];\n\n if (typeof total !== 'number' || total < 0) {\n throw new Error('Invalid split-node total for a path.');\n }\n\n const output: any[] = [];\n\n for (let i = 1; i <= total; i++) {\n const slice = (node as any)[String(i)];\n\n if (!Array.isArray(slice)) {\n throw new Error(\n 'Missing string parts for a path; incomplete chunk set.'\n );\n }\n\n for (let j = 0; j < slice.length; j++) {\n output.push(reconcileSplitNodes(slice[j]));\n }\n }\n\n return output;\n }\n\n // walk normal object\n for (const key of Object.keys(node)) {\n node[key] = reconcileSplitNodes(node[key]);\n }\n\n return node;\n };\n\n const reconciled = reconcileSplitNodes(root);\n\n // Now validate totals match provided count\n for (let i = 0; i < sorted.length; i++) {\n const chunk = sorted[i];\n\n if (chunk.total !== sorted.length) {\n throw new Error(\n `Chunk total does not match provided count. Expected ${sorted.length}, but chunk ${i} has total=${chunk.total}`\n );\n }\n }\n\n return reconciled;\n};\n\n/* -------------------------------------------\n * Example usage\n * -------------------------------------------\nconst big: JSONObject = {\n title: \"Document\",\n content: \"…a very very long text…\",\n items: Array.from({ length: 2000 }, (_, i) => ({ id: i, label: `Item ${i}` }))\n};\n\n// Split to ~16k-char chunks\nconst chunks = chunkJSON(big, 16_000);\n\n// Send each `chunks[i]` as JSON to your backend.\n// Later, reassemble:\nconst restored = assembleJSON(chunks);\nconsole.log(JSON.stringify(restored) === JSON.stringify(big)); // true\n*/\n"],"mappings":";;;AA0CA,MAAM,YAAY,QAAiD;AACjE,QAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,CAAC,MAAM,QAAQ,IAAI;;AAGvE,MAAM,eAAe,QAAwB;CAE3C,IAAI,OAAO;AAEX,MAAK,IAAI,IAAI,GAAG,IAAI,IAAI,QAAQ,IAC9B,SAAS,QAAQ,KAAK,OAAQ,IAAI,WAAW,EAAE;AAIjD,SAAQ,SAAS,GAAG,SAAS,GAAG,CAAC,SAAS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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const fromMessage = tryParseJsonString(cleaned);
|
|
90
|
-
if (fromMessage) return trimToSingleLine(fromMessage);
|
|
91
|
-
const fromCause = extractErrorMessage(error.cause);
|
|
92
|
-
if (fromCause && fromCause !== "An unknown error occurred")
|
|
93
|
-
return trimToSingleLine(fromCause);
|
|
94
|
-
return trimToSingleLine(cleaned);
|
|
95
|
-
}
|
|
96
|
-
const seen = /* @__PURE__ */ new Set();
|
|
97
|
-
const fromObject = pickFieldsFromObject(error, seen);
|
|
98
|
-
if (fromObject) {
|
|
99
|
-
const cleaned = sanitizeUnexpectedTokenMessage(fromObject);
|
|
100
|
-
return tryParseJsonString(cleaned) ?? trimToSingleLine(cleaned);
|
|
101
|
-
}
|
|
102
|
-
try {
|
|
103
|
-
const serialized = JSON.stringify(error);
|
|
104
|
-
return trimToSingleLine(serialized);
|
|
105
|
-
} catch {
|
|
106
|
-
return trimToSingleLine(String(error));
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return "An unknown error occurred";
|
|
110
|
-
};
|
|
111
|
-
export {
|
|
112
|
-
extractErrorMessage
|
|
3
|
+
const trimToSingleLine = (text) => text.split(/\r?\n/).map((s) => s.trim()).filter(Boolean)[0] ?? text.trim();
|
|
4
|
+
const looksLikeJson = (value) => {
|
|
5
|
+
const s = value.trim();
|
|
6
|
+
if (!s) return false;
|
|
7
|
+
const first = s[0];
|
|
8
|
+
return first === "{" || first === "[" || first === "\"";
|
|
9
|
+
};
|
|
10
|
+
const sanitizeUnexpectedTokenMessage = (text) => {
|
|
11
|
+
const t = text.trim();
|
|
12
|
+
if (/Unexpected token/i.test(t) && /not valid JSON/i.test(t)) {
|
|
13
|
+
const quoted = t.match(/"([^"]+)"/);
|
|
14
|
+
if (quoted?.[1]) return quoted[1];
|
|
15
|
+
const afterColon = t.split(":").slice(1).join(":").trim();
|
|
16
|
+
if (afterColon) return afterColon;
|
|
17
|
+
}
|
|
18
|
+
return t;
|
|
19
|
+
};
|
|
20
|
+
const pickFieldsFromObject = (value, seen) => {
|
|
21
|
+
if (!value || typeof value !== "object") return void 0;
|
|
22
|
+
if (seen.has(value)) return void 0;
|
|
23
|
+
seen.add(value);
|
|
24
|
+
const obj = value;
|
|
25
|
+
if (typeof obj.message === "string" && obj.message.trim()) return obj.message;
|
|
26
|
+
if (typeof obj.error_description === "string" && obj.error_description.trim()) return obj.error_description;
|
|
27
|
+
if (typeof obj.error === "string" && obj.error.trim()) return obj.error;
|
|
28
|
+
const title = typeof obj.title === "string" ? obj.title.trim() : "";
|
|
29
|
+
const code = typeof obj.code === "string" ? obj.code.trim() : "";
|
|
30
|
+
if (title && code) return `${title} (${code})`;
|
|
31
|
+
if (title) return title;
|
|
32
|
+
if (code) return code;
|
|
33
|
+
if (typeof obj.statusText === "string" && obj.statusText.trim()) return obj.statusText;
|
|
34
|
+
const response = obj.response;
|
|
35
|
+
if (response && typeof response === "object") {
|
|
36
|
+
const data$1 = response.data;
|
|
37
|
+
const fromData$1 = pickFieldsFromObject(data$1, seen);
|
|
38
|
+
if (fromData$1) return fromData$1;
|
|
39
|
+
}
|
|
40
|
+
const data = obj.data;
|
|
41
|
+
const fromData = pickFieldsFromObject(data, seen);
|
|
42
|
+
if (fromData) return fromData;
|
|
43
|
+
const cause = obj.cause;
|
|
44
|
+
const fromCause = pickFieldsFromObject(cause, seen) ?? (typeof cause?.message === "string" ? cause.message : void 0);
|
|
45
|
+
if (fromCause) return fromCause;
|
|
46
|
+
const errors = obj.errors;
|
|
47
|
+
if (Array.isArray(errors)) for (const item of errors) {
|
|
48
|
+
const fromItem = pickFieldsFromObject(item, seen);
|
|
49
|
+
if (fromItem) return fromItem;
|
|
50
|
+
if (typeof item?.message === "string") return item.message;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const tryParseJsonString = (maybeJson) => {
|
|
54
|
+
if (!looksLikeJson(maybeJson)) return void 0;
|
|
55
|
+
try {
|
|
56
|
+
const parsed = JSON.parse(maybeJson);
|
|
57
|
+
const picked = pickFieldsFromObject(parsed, /* @__PURE__ */ new Set());
|
|
58
|
+
if (picked) return picked;
|
|
59
|
+
if (typeof parsed === "string") return parsed;
|
|
60
|
+
return;
|
|
61
|
+
} catch {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
if (typeof error === "string") {
|
|
66
|
+
const cleaned = sanitizeUnexpectedTokenMessage(error);
|
|
67
|
+
return tryParseJsonString(cleaned) ?? trimToSingleLine(cleaned);
|
|
68
|
+
}
|
|
69
|
+
if (error && typeof error === "object") {
|
|
70
|
+
if (error instanceof Error) {
|
|
71
|
+
const cleaned = sanitizeUnexpectedTokenMessage(error.message);
|
|
72
|
+
const fromMessage = tryParseJsonString(cleaned);
|
|
73
|
+
if (fromMessage) return trimToSingleLine(fromMessage);
|
|
74
|
+
const fromCause = extractErrorMessage(error.cause);
|
|
75
|
+
if (fromCause && fromCause !== "An unknown error occurred") return trimToSingleLine(fromCause);
|
|
76
|
+
return trimToSingleLine(cleaned);
|
|
77
|
+
}
|
|
78
|
+
const fromObject = pickFieldsFromObject(error, /* @__PURE__ */ new Set());
|
|
79
|
+
if (fromObject) {
|
|
80
|
+
const cleaned = sanitizeUnexpectedTokenMessage(fromObject);
|
|
81
|
+
return tryParseJsonString(cleaned) ?? trimToSingleLine(cleaned);
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
return trimToSingleLine(JSON.stringify(error));
|
|
85
|
+
} catch {
|
|
86
|
+
return trimToSingleLine(String(error));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return "An unknown error occurred";
|
|
113
90
|
};
|
|
91
|
+
|
|
92
|
+
//#endregion
|
|
93
|
+
export { extractErrorMessage };
|
|
114
94
|
//# sourceMappingURL=extractErrorMessage.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/extractErrorMessage.ts"],"sourcesContent":["export const extractErrorMessage = (error: unknown): string => {\n const trimToSingleLine = (text: string): string =>\n text\n .split(/\\r?\\n/)\n .map((s) => s.trim())\n .filter(Boolean)[0] ?? text.trim();\n\n const looksLikeJson = (value: string): boolean => {\n const s = value.trim();\n if (!s) return false;\n const first = s[0];\n return first === '{' || first === '[' || first === '\"';\n };\n\n const sanitizeUnexpectedTokenMessage = (text: string): string => {\n // If the text mentions an invalid JSON parse, try to extract the meaningful part\n const t = text.trim();\n if (/Unexpected token/i.test(t) && /not valid JSON/i.test(t)) {\n const quoted = t.match(/\"([^\"]+)\"/);\n if (quoted
|
|
1
|
+
{"version":3,"file":"extractErrorMessage.mjs","names":["data","fromData"],"sources":["../../../src/utils/extractErrorMessage.ts"],"sourcesContent":["export const extractErrorMessage = (error: unknown): string => {\n const trimToSingleLine = (text: string): string =>\n text\n .split(/\\r?\\n/)\n .map((s) => s.trim())\n .filter(Boolean)[0] ?? text.trim();\n\n const looksLikeJson = (value: string): boolean => {\n const s = value.trim();\n if (!s) return false;\n const first = s[0];\n return first === '{' || first === '[' || first === '\"';\n };\n\n const sanitizeUnexpectedTokenMessage = (text: string): string => {\n // If the text mentions an invalid JSON parse, try to extract the meaningful part\n const t = text.trim();\n if (/Unexpected token/i.test(t) && /not valid JSON/i.test(t)) {\n const quoted = t.match(/\"([^\"]+)\"/);\n if (quoted?.[1]) return quoted[1];\n // Fallback: drop the leading parser error description\n const afterColon = t.split(':').slice(1).join(':').trim();\n if (afterColon) return afterColon;\n }\n return t;\n };\n\n const pickFieldsFromObject = (\n value: unknown,\n seen: Set<unknown>\n ): string | undefined => {\n if (!value || typeof value !== 'object') return undefined;\n if (seen.has(value)) return undefined;\n seen.add(value);\n\n const obj = value as Record<string, unknown>;\n\n // Check for message first (highest priority)\n if (typeof obj.message === 'string' && obj.message.trim()) {\n return obj.message;\n }\n\n // Check for error_description\n if (\n typeof obj.error_description === 'string' &&\n obj.error_description.trim()\n ) {\n return obj.error_description;\n }\n\n // Check for error\n if (typeof obj.error === 'string' && obj.error.trim()) {\n return obj.error;\n }\n\n // Handle title and code combination\n const title = typeof obj.title === 'string' ? obj.title.trim() : '';\n const code = typeof obj.code === 'string' ? obj.code.trim() : '';\n\n if (title && code) {\n return `${title} (${code})`;\n }\n\n if (title) {\n return title;\n }\n\n if (code) {\n return code;\n }\n\n // Check for statusText\n if (typeof obj.statusText === 'string' && obj.statusText.trim()) {\n return obj.statusText;\n }\n\n // Common nested structures (Axios/Fetch-like)\n const response = obj.response as Record<string, unknown> | undefined;\n if (response && typeof response === 'object') {\n const data = response.data as unknown;\n const fromData = pickFieldsFromObject(data, seen);\n if (fromData) return fromData;\n }\n\n const data = obj.data as unknown;\n const fromData = pickFieldsFromObject(data, seen);\n if (fromData) return fromData;\n\n // Nested cause chain\n const cause = (obj as { cause?: unknown }).cause;\n const fromCause =\n pickFieldsFromObject(cause, seen) ??\n (typeof (cause as any)?.message === 'string'\n ? (cause as any).message\n : undefined);\n if (fromCause) return fromCause;\n\n // Arrays of errors\n const errors = obj.errors as unknown;\n if (Array.isArray(errors)) {\n for (const item of errors) {\n const fromItem = pickFieldsFromObject(item, seen);\n if (fromItem) return fromItem;\n if (typeof (item as any)?.message === 'string')\n return (item as any).message;\n }\n }\n\n return undefined;\n };\n\n const tryParseJsonString = (maybeJson: string): string | undefined => {\n if (!looksLikeJson(maybeJson)) return undefined;\n try {\n const parsed = JSON.parse(maybeJson);\n const picked = pickFieldsFromObject(parsed, new Set());\n if (picked) return picked;\n if (typeof parsed === 'string') return parsed;\n return undefined;\n } catch {\n return undefined;\n }\n };\n\n if (typeof error === 'string') {\n const cleaned = sanitizeUnexpectedTokenMessage(error);\n return tryParseJsonString(cleaned) ?? trimToSingleLine(cleaned);\n }\n\n if (error && typeof error === 'object') {\n // Native Error instance\n if (error instanceof Error) {\n const cleaned = sanitizeUnexpectedTokenMessage(error.message);\n const fromMessage = tryParseJsonString(cleaned);\n if (fromMessage) return trimToSingleLine(fromMessage);\n // Dive into cause when present\n const fromCause = extractErrorMessage(error.cause as unknown);\n if (fromCause && fromCause !== 'An unknown error occurred')\n return trimToSingleLine(fromCause);\n return trimToSingleLine(cleaned);\n }\n\n // Generic object\n const seen = new Set<unknown>();\n const fromObject = pickFieldsFromObject(error, seen);\n if (fromObject) {\n const cleaned = sanitizeUnexpectedTokenMessage(fromObject);\n return tryParseJsonString(cleaned) ?? trimToSingleLine(cleaned);\n }\n\n try {\n const serialized = JSON.stringify(error);\n return trimToSingleLine(serialized);\n } catch {\n return trimToSingleLine(String(error));\n }\n }\n\n return 'An unknown error occurred';\n};\n"],"mappings":";AAAA,MAAa,uBAAuB,UAA2B;CAC7D,MAAM,oBAAoB,SACxB,KACG,MAAM,QAAQ,CACd,KAAK,MAAM,EAAE,MAAM,CAAC,CACpB,OAAO,QAAQ,CAAC,MAAM,KAAK,MAAM;CAEtC,MAAM,iBAAiB,UAA2B;EAChD,MAAM,IAAI,MAAM,MAAM;AACtB,MAAI,CAAC,EAAG,QAAO;EACf,MAAM,QAAQ,EAAE;AAChB,SAAO,UAAU,O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F,UAAO,iBADY,KAAK,UAAU,MAAM,CACL;UAC7B;AACN,UAAO,iBAAiB,OAAO,MAAM,CAAC;;;AAI1C,QAAO"}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { ANSIColors, colorize, colorizePath
|
|
1
|
+
import { ANSIColors, colorize, colorizePath } from "@intlayer/config";
|
|
2
|
+
import { relative } from "node:path";
|
|
2
3
|
import configuration from "@intlayer/config/built";
|
|
3
4
|
import { getLocaleName } from "@intlayer/core";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
).map(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
formatLocale,
|
|
13
|
-
formatPath
|
|
14
|
-
};
|
|
5
|
+
import { Locales } from "@intlayer/types";
|
|
6
|
+
|
|
7
|
+
//#region src/utils/formatter.ts
|
|
8
|
+
const formatPath = (path, color) => [path].flat().map((path$1) => path$1.startsWith("/") ? relative(configuration.content.baseDir, path$1) : path$1).map((relativePath) => color === false ? relativePath : colorizePath(relativePath, color)).join(`, `);
|
|
9
|
+
const formatLocale = (locale, color = ANSIColors.GREEN) => [locale].flat().map((locale$1) => `${getLocaleName(locale$1, Locales.ENGLISH)} (${locale$1})`).map((text) => color === false ? text : colorize(text, color)).join(`, `);
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { formatLocale, formatPath };
|
|
15
13
|
//# sourceMappingURL=formatter.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/formatter.ts"],"sourcesContent":["import { ANSIColors, colorize, colorizePath
|
|
1
|
+
{"version":3,"file":"formatter.mjs","names":["path","locale"],"sources":["../../../src/utils/formatter.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport { ANSIColors, colorize, colorizePath } from '@intlayer/config';\nimport configuration from '@intlayer/config/built';\nimport { getLocaleName } from '@intlayer/core';\nimport { Locales, type LocalesValues } from '@intlayer/types';\n\nexport const formatPath = (\n path: string | string[],\n color?: ANSIColors | false\n) =>\n [path]\n .flat()\n .map((path) =>\n path.startsWith('/')\n ? relative(configuration.content.baseDir, path)\n : path\n )\n .map((relativePath) =>\n color === false ? relativePath : colorizePath(relativePath, color)\n )\n .join(`, `);\n\nexport const formatLocale = (\n locale: LocalesValues | LocalesValues[],\n color: ANSIColors | false = ANSIColors.GREEN\n) =>\n [locale]\n .flat()\n .map((locale) => `${getLocaleName(locale, Locales.ENGLISH)} (${locale})`)\n .map((text) => (color === false ? text : colorize(text, color)))\n .join(`, `);\n"],"mappings":";;;;;;;AAMA,MAAa,cACX,MACA,UAEA,CAAC,KAAK,CACH,MAAM,CACN,KAAK,WACJA,OAAK,WAAW,IAAI,GAChB,SAAS,cAAc,QAAQ,SAASA,OAAK,GAC7CA,OACL,CACA,KAAK,iBACJ,UAAU,QAAQ,eAAe,aAAa,cAAc,MAAM,CACnE,CACA,KAAK,KAAK;AAEf,MAAa,gBACX,QACA,QAA4B,WAAW,UAEvC,CAAC,OAAO,CACL,MAAM,CACN,KAAK,aAAW,GAAG,cAAcC,UAAQ,QAAQ,QAAQ,CAAC,IAAIA,SAAO,GAAG,CACxE,KAAK,SAAU,UAAU,QAAQ,OAAO,SAAS,MAAM,MAAM,CAAE,CAC/D,KAAK,KAAK"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { splitTextByLines } from "./splitTextByLine.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/getChunk.ts
|
|
4
|
+
const getChunk = (text, options = {}) => {
|
|
5
|
+
const { lineStart, lineLength, charStart, charLength } = options;
|
|
6
|
+
if (lineStart === void 0 && lineLength === void 0 && charStart === void 0 && charLength === void 0) return text;
|
|
7
|
+
const lines = splitTextByLines(text);
|
|
8
|
+
const getCharIndexOfLineStart = (lineNumber) => {
|
|
9
|
+
if (lineNumber <= 0) return 0;
|
|
10
|
+
let idx = 0;
|
|
11
|
+
for (let i = 0; i < Math.min(lineNumber, lines.length); i++) idx += lines[i].length;
|
|
12
|
+
return idx;
|
|
13
|
+
};
|
|
14
|
+
const getCharIndexOfLineEnd = (lineNumber) => {
|
|
15
|
+
if (lineNumber >= lines.length) return text.length;
|
|
16
|
+
const line = lines[lineNumber];
|
|
17
|
+
return getCharIndexOfLineStart(lineNumber) + line.length;
|
|
18
|
+
};
|
|
19
|
+
let effectiveStart = 0;
|
|
20
|
+
let effectiveEnd = text.length;
|
|
21
|
+
if (lineStart !== void 0) effectiveStart = Math.max(effectiveStart, getCharIndexOfLineStart(lineStart));
|
|
22
|
+
if (charStart !== void 0) effectiveStart = Math.max(effectiveStart, charStart);
|
|
23
|
+
if (lineLength !== void 0) {
|
|
24
|
+
const endLine = (lineStart ?? 0) + lineLength - 1;
|
|
25
|
+
effectiveEnd = Math.min(effectiveEnd, getCharIndexOfLineEnd(endLine));
|
|
26
|
+
}
|
|
27
|
+
if (charLength !== void 0) effectiveEnd = Math.min(effectiveEnd, (charStart ?? effectiveStart) + charLength);
|
|
28
|
+
if (effectiveStart >= effectiveEnd) return "";
|
|
29
|
+
return text.slice(effectiveStart, effectiveEnd);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { getChunk };
|
|
34
|
+
//# sourceMappingURL=getChunk.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getChunk.mjs","names":[],"sources":["../../../src/utils/getChunk.ts"],"sourcesContent":["import { splitTextByLines } from './splitTextByLine';\n\ntype TrunkOptions = {\n lineStart?: number;\n lineLength?: number;\n charStart?: number;\n charLength?: number;\n};\n\nexport const getChunk = (text: string, options: TrunkOptions = {}): string => {\n const { lineStart, lineLength, charStart, charLength } = options;\n\n // Fast-path: if no filters were provided, return the whole text\n if (\n lineStart === undefined &&\n lineLength === undefined &&\n charStart === undefined &&\n charLength === undefined\n ) {\n return text;\n }\n\n // ---------------------------------------------------------------------------\n // Utility helpers to convert between line numbers and absolute char indices\n // ---------------------------------------------------------------------------\n const lines = splitTextByLines(text);\n\n const getCharIndexOfLineStart = (lineNumber: number): number => {\n if (lineNumber <= 0) return 0;\n // Sum the length of every previous line\n let idx = 0;\n for (let i = 0; i < Math.min(lineNumber, lines.length); i++) {\n idx += lines[i].length;\n }\n return idx;\n };\n\n const getCharIndexOfLineEnd = (lineNumber: number): number => {\n // If the requested line number exceeds the number of lines, clamp to the last character\n if (lineNumber >= lines.length) {\n return text.length;\n }\n const line = lines[lineNumber];\n const lineEnd = getCharIndexOfLineStart(lineNumber) + line.length;\n\n return lineEnd;\n };\n\n // ---------------------------------------------------------------------------\n // Compute the effective (inclusive) charStart/charEnd for the requested slice\n // ---------------------------------------------------------------------------\n let effectiveStart = 0; // inclusive\n let effectiveEnd = text.length; // exclusive\n\n // Apply line boundaries if provided\n if (lineStart !== undefined) {\n effectiveStart = Math.max(\n effectiveStart,\n getCharIndexOfLineStart(lineStart)\n );\n }\n\n // Apply character boundaries if provided\n if (charStart !== undefined) {\n effectiveStart = Math.max(effectiveStart, charStart);\n }\n\n // Apply line length boundary from lineStart (or 0)\n if (lineLength !== undefined) {\n const endLine = (lineStart ?? 0) + lineLength - 1;\n effectiveEnd = Math.min(effectiveEnd, getCharIndexOfLineEnd(endLine));\n }\n\n // Apply character length boundary from effectiveStart\n if (charLength !== undefined) {\n effectiveEnd = Math.min(\n effectiveEnd,\n (charStart ?? effectiveStart) + charLength\n );\n }\n\n // If bounds do not overlap, return empty string\n if (effectiveStart >= effectiveEnd) {\n return '';\n }\n\n return text.slice(effectiveStart, effectiveEnd);\n};\n"],"mappings":";;;AASA,MAAa,YAAY,MAAc,UAAwB,EAAE,KAAa;CAC5E,MAAM,EAAE,WAAW,YAAY,WAAW,eAAe;AAGzD,KACE,cAAc,UACd,eAAe,UACf,cAAc,UACd,eAAe,OAEf,QAAO;CAMT,MAAM,QAAQ,iBAAiB,KAAK;CAEpC,MAAM,2BAA2B,eAA+B;AAC9D,MAAI,cAAc,EAAG,QAAO;EAE5B,IAAI,MAAM;AACV,OAAK,IAAI,IAAI,GAAG,IAAI,KAAK,IAAI,YAAY,MAAM,OAAO,EAAE,IACtD,QAAO,MAAM,GAAG;AAElB,SAAO;;CAGT,MAAM,yBAAyB,eAA+B;AAE5D,MAAI,cAAc,MAAM,OACtB,QAAO,KAAK;EAEd,MAAM,OAAO,MAAM;AAGnB,SAFgB,wBAAwB,WAAW,GAAG,KAAK;;CAQ7D,IAAI,iBAAiB;CACrB,IAAI,eAAe,KAAK;AAGxB,KAAI,cAAc,OAChB,kBAAiB,KAAK,IACpB,gBACA,wBAAwB,UAAU,CACnC;AAIH,KAAI,cAAc,OAChB,kBAAiB,KAAK,IAAI,gBAAgB,UAAU;AAItD,KAAI,eAAe,QAAW;EAC5B,MAAM,WAAW,aAAa,KAAK,aAAa;AAChD,iBAAe,KAAK,IAAI,cAAc,sBAAsB,QAAQ,CAAC;;AAIvE,KAAI,eAAe,OACjB,gBAAe,KAAK,IAClB,eACC,aAAa,kBAAkB,WACjC;AAIH,KAAI,kBAAkB,aACpB,QAAO;AAGT,QAAO,KAAK,MAAM,gBAAgB,aAAa"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import crypto from "crypto-js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/getFileHash.ts
|
|
2
4
|
const getFileHash = (filePath) => {
|
|
3
|
-
|
|
4
|
-
return hash.toString(crypto.enc.Base64).replace(/[^A-Z\d]/gi, "").substring(0, 20);
|
|
5
|
-
};
|
|
6
|
-
export {
|
|
7
|
-
getFileHash
|
|
5
|
+
return crypto.SHA3(filePath).toString(crypto.enc.Base64).replace(/[^A-Z\d]/gi, "").substring(0, 20);
|
|
8
6
|
};
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { getFileHash };
|
|
9
10
|
//# sourceMappingURL=getFileHash.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/getFileHash.ts"],"sourcesContent":["import crypto from 'crypto-js';\n\nexport const getFileHash = (filePath: string) => {\n const hash = crypto.SHA3(filePath);\n\n return hash\n .toString(crypto.enc.Base64)\n .replace(/[^A-Z\\d]/gi, '')\n .substring(0, 20);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getFileHash.mjs","names":[],"sources":["../../../src/utils/getFileHash.ts"],"sourcesContent":["import crypto from 'crypto-js';\n\nexport const getFileHash = (filePath: string) => {\n const hash = crypto.SHA3(filePath);\n\n return hash\n .toString(crypto.enc.Base64)\n .replace(/[^A-Z\\d]/gi, '')\n .substring(0, 20);\n};\n"],"mappings":";;;AAEA,MAAa,eAAe,aAAqB;AAG/C,QAFa,OAAO,KAAK,SAAS,CAG/B,SAAS,OAAO,IAAI,OAAO,CAC3B,QAAQ,cAAc,GAAG,CACzB,UAAU,GAAG,GAAG"}
|
|
@@ -1,34 +1,26 @@
|
|
|
1
|
+
//#region src/utils/getFormatFromExtension.ts
|
|
1
2
|
const getFormatFromExtension = (extension) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
case ".json5":
|
|
13
|
-
return "json";
|
|
14
|
-
}
|
|
15
|
-
return "esm";
|
|
3
|
+
switch (extension) {
|
|
4
|
+
case ".ts":
|
|
5
|
+
case ".tsx": return "ts";
|
|
6
|
+
case ".cjs":
|
|
7
|
+
case ".cjsx": return "cjs";
|
|
8
|
+
case ".mjs": return "esm";
|
|
9
|
+
case ".json":
|
|
10
|
+
case ".json5": return "json";
|
|
11
|
+
}
|
|
12
|
+
return "esm";
|
|
16
13
|
};
|
|
17
14
|
const getExtensionFromFormat = (format) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
case "esm":
|
|
26
|
-
return ".mjs";
|
|
27
|
-
}
|
|
28
|
-
return ".mjs";
|
|
29
|
-
};
|
|
30
|
-
export {
|
|
31
|
-
getExtensionFromFormat,
|
|
32
|
-
getFormatFromExtension
|
|
15
|
+
switch (format) {
|
|
16
|
+
case "ts": return ".ts";
|
|
17
|
+
case "cjs": return ".cjs";
|
|
18
|
+
case "json": return ".json";
|
|
19
|
+
case "esm": return ".mjs";
|
|
20
|
+
}
|
|
21
|
+
return ".mjs";
|
|
33
22
|
};
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { getExtensionFromFormat, getFormatFromExtension };
|
|
34
26
|
//# sourceMappingURL=getFormatFromExtension.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/getFormatFromExtension.ts"],"sourcesContent":["export type Format = 'ts' | 'cjs' | 'esm' | 'json';\nexport type Extension =\n | '.ts'\n | '.tsx'\n | '.js'\n | '.jsx'\n | '.cjs'\n | '.cjsx'\n | '.mjs'\n | '.mjsx'\n | '.json'\n | '.json5';\n\nexport const getFormatFromExtension = (extension: Extension): Format => {\n switch (extension) {\n case '.ts':\n case '.tsx':\n return 'ts';\n case '.cjs':\n case '.cjsx':\n return 'cjs';\n case '.mjs':\n return 'esm';\n case '.json':\n case '.json5':\n return 'json';\n }\n\n return 'esm';\n};\n\nexport const getExtensionFromFormat = (format: Format): Extension => {\n switch (format) {\n case 'ts':\n return '.ts';\n case 'cjs':\n return '.cjs';\n case 'json':\n return '.json';\n case 'esm':\n return '.mjs';\n }\n\n return '.mjs';\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getFormatFromExtension.mjs","names":[],"sources":["../../../src/utils/getFormatFromExtension.ts"],"sourcesContent":["export type Format = 'ts' | 'cjs' | 'esm' | 'json';\nexport type Extension =\n | '.ts'\n | '.tsx'\n | '.js'\n | '.jsx'\n | '.cjs'\n | '.cjsx'\n | '.mjs'\n | '.mjsx'\n | '.json'\n | '.json5';\n\nexport const getFormatFromExtension = (extension: Extension): Format => {\n switch (extension) {\n case '.ts':\n case '.tsx':\n return 'ts';\n case '.cjs':\n case '.cjsx':\n return 'cjs';\n case '.mjs':\n return 'esm';\n case '.json':\n case '.json5':\n return 'json';\n }\n\n return 'esm';\n};\n\nexport const getExtensionFromFormat = (format: Format): Extension => {\n switch (format) {\n case 'ts':\n return '.ts';\n case 'cjs':\n return '.cjs';\n case 'json':\n return '.json';\n case 'esm':\n return '.mjs';\n }\n\n return '.mjs';\n};\n"],"mappings":";AAaA,MAAa,0BAA0B,cAAiC;AACtE,SAAQ,WAAR;EACE,KAAK;EACL,KAAK,OACH,QAAO;EACT,KAAK;EACL,KAAK,QACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK;EACL,KAAK,SACH,QAAO;;AAGX,QAAO;;AAGT,MAAa,0BAA0B,WAA8B;AACnE,SAAQ,QAAR;EACE,KAAK,KACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,MACH,QAAO;;AAGX,QAAO"}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
+
//#region src/utils/kebabCaseToCamelCase.ts
|
|
1
2
|
const kebabCaseToCamelCase = (name) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
);
|
|
9
|
-
return capitalized;
|
|
10
|
-
}).join("");
|
|
11
|
-
};
|
|
12
|
-
export {
|
|
13
|
-
kebabCaseToCamelCase
|
|
3
|
+
return name.split(/[^a-zA-Z0-9]+/).filter(Boolean).map((word) => {
|
|
4
|
+
const lowerWord = word.toLowerCase();
|
|
5
|
+
let capitalized = lowerWord.charAt(0).toUpperCase() + lowerWord.slice(1);
|
|
6
|
+
capitalized = capitalized.replace(/(\d)([a-z])/g, (_, number, char) => number + char.toUpperCase());
|
|
7
|
+
return capitalized;
|
|
8
|
+
}).join("");
|
|
14
9
|
};
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { kebabCaseToCamelCase };
|
|
15
13
|
//# sourceMappingURL=kebabCaseToCamelCase.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/kebabCaseToCamelCase.ts"],"sourcesContent":["export const kebabCaseToCamelCase = (name: string): string => {\n return name\n .split(/[^a-zA-Z0-9]+/) // Split on any non-alphanumeric character\n .filter(Boolean) // Remove any empty strings\n .map((word) => {\n // Convert the entire word to lowercase first\n const lowerWord = word.toLowerCase();\n\n // Capitalize the first character\n let capitalized = lowerWord.charAt(0).toUpperCase() + lowerWord.slice(1);\n\n // Capitalize any letter that follows a number\n capitalized = capitalized.replace(\n /(\\d)([a-z])/g,\n (_, number, char) => number + char.toUpperCase()\n );\n\n return capitalized;\n })\n .join(''); // Concatenate all parts into a single string\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"kebabCaseToCamelCase.mjs","names":[],"sources":["../../../src/utils/kebabCaseToCamelCase.ts"],"sourcesContent":["export const kebabCaseToCamelCase = (name: string): string => {\n return name\n .split(/[^a-zA-Z0-9]+/) // Split on any non-alphanumeric character\n .filter(Boolean) // Remove any empty strings\n .map((word) => {\n // Convert the entire word to lowercase first\n const lowerWord = word.toLowerCase();\n\n // Capitalize the first character\n let capitalized = lowerWord.charAt(0).toUpperCase() + lowerWord.slice(1);\n\n // Capitalize any letter that follows a number\n capitalized = capitalized.replace(\n /(\\d)([a-z])/g,\n (_, number, char) => number + char.toUpperCase()\n );\n\n return capitalized;\n })\n .join(''); // Concatenate all parts into a single string\n};\n"],"mappings":";AAAA,MAAa,wBAAwB,SAAyB;AAC5D,QAAO,KACJ,MAAM,gBAAgB,CACtB,OAAO,QAAQ,CACf,KAAK,SAAS;EAEb,MAAM,YAAY,KAAK,aAAa;EAGpC,IAAI,cAAc,UAAU,OAAO,EAAE,CAAC,aAAa,GAAG,UAAU,MAAM,EAAE;AAGxE,gBAAc,YAAY,QACxB,iBACC,GAAG,QAAQ,SAAS,SAAS,KAAK,aAAa,CACjD;AAED,SAAO;GACP,CACD,KAAK,GAAG"}
|