@intlayer/chokidar 6.1.6 → 7.0.0-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{cjs → 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
|
@@ -1,105 +1,72 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ANSIColors,
|
|
3
|
-
ESMxCJSRequire,
|
|
4
|
-
colorize,
|
|
5
|
-
getAppLogger,
|
|
6
|
-
getConfiguration
|
|
7
|
-
} from "@intlayer/config";
|
|
8
|
-
import packageJson from "@intlayer/config/package.json" with { type: "json" };
|
|
9
|
-
import { buildDictionary } from "./buildIntlayerDictionary/buildIntlayerDictionary.mjs";
|
|
10
|
-
import { writeRemoteDictionary } from "./buildIntlayerDictionary/writeRemoteDictionary.mjs";
|
|
11
1
|
import { cleanOutputDir } from "./cleanOutputDir.mjs";
|
|
2
|
+
import { buildDictionary } from "./buildIntlayerDictionary/buildIntlayerDictionary.mjs";
|
|
12
3
|
import { createDictionaryEntryPoint } from "./createDictionaryEntryPoint/createDictionaryEntryPoint.mjs";
|
|
13
|
-
import { createModuleAugmentation
|
|
4
|
+
import { createModuleAugmentation } from "./createType/createModuleAugmentation.mjs";
|
|
5
|
+
import { createTypes } from "./createType/createType.mjs";
|
|
14
6
|
import { listDictionaries } from "./listDictionariesPath.mjs";
|
|
15
7
|
import { loadDictionaries } from "./loadDictionaries/loadDictionaries.mjs";
|
|
8
|
+
import { writeRemoteDictionary } from "./buildIntlayerDictionary/writeRemoteDictionary.mjs";
|
|
9
|
+
import { runOnce } from "./utils/runOnce.mjs";
|
|
16
10
|
import { writeConfiguration } from "./writeConfiguration/index.mjs";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
await writeConfiguration(configuration);
|
|
28
|
-
const configurationWrittenTime = Date.now();
|
|
29
|
-
appLogger(
|
|
30
|
-
[
|
|
31
|
-
"Configuration written",
|
|
32
|
-
colorize(
|
|
33
|
-
`(${configurationWrittenTime - preparationStartMs}ms)`,
|
|
34
|
-
ANSIColors.GREY_DARK
|
|
35
|
-
)
|
|
36
|
-
],
|
|
37
|
-
{
|
|
38
|
-
isVerbose: true
|
|
39
|
-
}
|
|
40
|
-
);
|
|
41
|
-
const files = listDictionaries(configuration);
|
|
42
|
-
const dictionaries = await loadDictionaries(
|
|
43
|
-
files,
|
|
44
|
-
configuration,
|
|
45
|
-
projectRequire
|
|
46
|
-
);
|
|
47
|
-
const dictionariesLoadedTime = Date.now();
|
|
48
|
-
appLogger(
|
|
49
|
-
[
|
|
50
|
-
"Content loaded",
|
|
51
|
-
colorize(
|
|
52
|
-
[
|
|
53
|
-
dictionaries.remoteDictionaries.length > 0 ? ` (Total: ${dictionariesLoadedTime - configurationWrittenTime}ms - Local: ${dictionaries.time.localDictionaries}ms - Remote: ${dictionaries.time.remoteDictionaries}ms)` : `(${dictionariesLoadedTime - configurationWrittenTime}ms)`
|
|
54
|
-
].join(""),
|
|
55
|
-
ANSIColors.GREY_DARK
|
|
56
|
-
)
|
|
57
|
-
],
|
|
58
|
-
{
|
|
59
|
-
isVerbose: true
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
const dictionariesOutput = await buildDictionary(
|
|
63
|
-
[...dictionaries.localDictionaries, ...dictionaries.remoteDictionaries],
|
|
64
|
-
configuration,
|
|
65
|
-
format,
|
|
66
|
-
false
|
|
67
|
-
);
|
|
68
|
-
await writeRemoteDictionary(dictionaries.remoteDictionaries, configuration);
|
|
69
|
-
const dictionariesPaths = Object.values(
|
|
70
|
-
dictionariesOutput?.mergedDictionaries ?? {}
|
|
71
|
-
).map((dictionary) => dictionary.dictionaryPath);
|
|
72
|
-
await createTypes(dictionariesPaths);
|
|
73
|
-
await createDictionaryEntryPoint(configuration);
|
|
74
|
-
const dictionariesBuiltTime = Date.now();
|
|
75
|
-
appLogger([
|
|
76
|
-
"Dictionaries built",
|
|
77
|
-
colorize(
|
|
78
|
-
`(${dictionariesBuiltTime - preparationStartMs}ms)`,
|
|
79
|
-
ANSIColors.GREY_DARK
|
|
80
|
-
)
|
|
81
|
-
]);
|
|
82
|
-
await createModuleAugmentation(configuration);
|
|
83
|
-
const moduleAugmentationBuiltTime = Date.now();
|
|
84
|
-
appLogger(
|
|
85
|
-
[
|
|
86
|
-
"Module augmentation built",
|
|
87
|
-
colorize(
|
|
88
|
-
`(${moduleAugmentationBuiltTime - dictionariesBuiltTime}ms)`,
|
|
89
|
-
ANSIColors.GREY_DARK
|
|
90
|
-
)
|
|
91
|
-
],
|
|
92
|
-
{
|
|
93
|
-
isVerbose: true
|
|
94
|
-
}
|
|
95
|
-
);
|
|
96
|
-
const preparationElapsedMs = Date.now() - preparationStartMs;
|
|
97
|
-
appLogger([`Done`, colorize(`${preparationElapsedMs}ms`, ANSIColors.GREEN)], {
|
|
98
|
-
level: "info",
|
|
99
|
-
isVerbose: true
|
|
100
|
-
});
|
|
11
|
+
import { ANSIColors, colorize, getAppLogger } from "@intlayer/config";
|
|
12
|
+
import { join } from "node:path";
|
|
13
|
+
import packageJson from "@intlayer/config/package.json" with { type: "json" };
|
|
14
|
+
|
|
15
|
+
//#region src/prepareIntlayer.ts
|
|
16
|
+
const DEFAULT_PREPARE_INTLAYER_OPTIONS = {
|
|
17
|
+
clean: false,
|
|
18
|
+
format: ["cjs", "esm"],
|
|
19
|
+
forceRun: false
|
|
101
20
|
};
|
|
102
|
-
|
|
103
|
-
|
|
21
|
+
const prepareIntlayer = async (configuration, options) => {
|
|
22
|
+
const { clean, format, forceRun, onIsCached } = {
|
|
23
|
+
...DEFAULT_PREPARE_INTLAYER_OPTIONS,
|
|
24
|
+
...options ?? {}
|
|
25
|
+
};
|
|
26
|
+
const appLogger = getAppLogger(configuration);
|
|
27
|
+
await runOnce(join(configuration.content.cacheDir, "intlayer-prepared.lock"), async () => {
|
|
28
|
+
const { plugins } = configuration;
|
|
29
|
+
const preparationStartMs = Date.now();
|
|
30
|
+
appLogger(["Preparing Intlayer", colorize(`(v${packageJson.version})`, ANSIColors.GREY_DARK)]);
|
|
31
|
+
if (clean) cleanOutputDir(configuration);
|
|
32
|
+
await writeConfiguration(configuration);
|
|
33
|
+
const configurationWrittenTime = Date.now();
|
|
34
|
+
appLogger(["Configuration written", colorize(`(${configurationWrittenTime - preparationStartMs}ms)`, ANSIColors.GREY_DARK)], { isVerbose: true });
|
|
35
|
+
const dictionaries = await loadDictionaries(await listDictionaries(configuration), configuration);
|
|
36
|
+
const dictionariesLoadedTime = Date.now();
|
|
37
|
+
appLogger(["Content loaded", colorize([dictionaries.remoteDictionaries.length > 0 ? ` (Total: ${dictionariesLoadedTime - configurationWrittenTime}ms - Local: ${dictionaries.time.localDictionaries}ms - Remote: ${dictionaries.time.remoteDictionaries}ms)` : `(${dictionariesLoadedTime - configurationWrittenTime}ms)`].join(""), ANSIColors.GREY_DARK)], { isVerbose: true });
|
|
38
|
+
const dictionariesOutput = await buildDictionary([
|
|
39
|
+
...dictionaries.localDictionaries,
|
|
40
|
+
...dictionaries.remoteDictionaries,
|
|
41
|
+
...dictionaries.pluginDictionaries
|
|
42
|
+
], configuration, format, false);
|
|
43
|
+
await writeRemoteDictionary(dictionaries.remoteDictionaries, configuration);
|
|
44
|
+
await createTypes(Object.values(dictionariesOutput?.mergedDictionaries ?? {}).map((dictionary) => dictionary.dictionaryPath), configuration);
|
|
45
|
+
await createDictionaryEntryPoint(configuration);
|
|
46
|
+
const dictionariesBuiltTime = Date.now();
|
|
47
|
+
appLogger(["Dictionaries built", colorize(`(${dictionariesBuiltTime - preparationStartMs}ms)`, ANSIColors.GREY_DARK)]);
|
|
48
|
+
await createModuleAugmentation(configuration);
|
|
49
|
+
appLogger(["Module augmentation built", colorize(`(${Date.now() - dictionariesBuiltTime}ms)`, ANSIColors.GREY_DARK)], { isVerbose: true });
|
|
50
|
+
for await (const plugin of plugins ?? []) {
|
|
51
|
+
const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;
|
|
52
|
+
await plugin.afterBuild?.({
|
|
53
|
+
dictionaries: {
|
|
54
|
+
unmergedDictionaries,
|
|
55
|
+
mergedDictionaries
|
|
56
|
+
},
|
|
57
|
+
configuration
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
appLogger([`Done`, colorize(`${Date.now() - preparationStartMs}ms`, ANSIColors.GREEN)], {
|
|
61
|
+
level: "info",
|
|
62
|
+
isVerbose: true
|
|
63
|
+
});
|
|
64
|
+
}, {
|
|
65
|
+
forceRun,
|
|
66
|
+
onIsCached
|
|
67
|
+
});
|
|
104
68
|
};
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
export { prepareIntlayer };
|
|
105
72
|
//# sourceMappingURL=prepareIntlayer.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"prepareIntlayer.mjs","names":[],"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { ANSIColors, colorize, getAppLogger } 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 { listDictionaries } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { runOnce } from './utils/runOnce';\nimport { writeConfiguration } from './writeConfiguration';\n\ntype PrepareIntlayerOptions = {\n clean?: boolean;\n format?: ('cjs' | 'esm')[];\n forceRun?: boolean;\n onIsCached?: () => void | Promise<void>;\n};\n\nconst DEFAULT_PREPARE_INTLAYER_OPTIONS = {\n clean: false,\n format: ['cjs', 'esm'],\n forceRun: false,\n} satisfies PrepareIntlayerOptions;\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig,\n options?: PrepareIntlayerOptions\n) => {\n const { clean, format, forceRun, onIsCached } = {\n ...DEFAULT_PREPARE_INTLAYER_OPTIONS,\n ...(options ?? {}),\n };\n const appLogger = getAppLogger(configuration);\n\n const sentinelPath = join(\n configuration.content.cacheDir,\n 'intlayer-prepared.lock'\n );\n\n // Skip preparation if it has already been done recently\n await runOnce(\n sentinelPath,\n async () => {\n const { plugins } = configuration;\n\n const preparationStartMs = Date.now();\n\n appLogger([\n 'Preparing Intlayer',\n colorize(`(v${packageJson.version})`, ANSIColors.GREY_DARK),\n ]);\n\n if (clean) {\n cleanOutputDir(configuration);\n }\n\n 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 files: string[] = await listDictionaries(configuration);\n\n const dictionaries = await loadDictionaries(files, configuration);\n\n const dictionariesLoadedTime = Date.now();\n\n appLogger(\n [\n 'Content loaded',\n colorize(\n [\n dictionaries.remoteDictionaries.length > 0\n ? ` (Total: ${dictionariesLoadedTime - configurationWrittenTime}ms - Local: ${dictionaries.time.localDictionaries}ms - Remote: ${dictionaries.time.remoteDictionaries}ms)`\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 dictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n await createTypes(dictionariesPaths, 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 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 { forceRun, onIsCached }\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,MAAM,mCAAmC;CACvC,OAAO;CACP,QAAQ,CAAC,OAAO,MAAM;CACtB,UAAU;CACX;AAED,MAAa,kBAAkB,OAC7B,eACA,YACG;CACH,MAAM,EAAE,OAAO,QAAQ,UAAU,eAAe;EAC9C,GAAG;EACH,GAAI,WAAW,EAAE;EAClB;CACD,MAAM,YAAY,aAAa,cAAc;AAQ7C,OAAM,QANe,KACnB,cAAc,QAAQ,UACtB,yBACD,EAKC,YAAY;EACV,MAAM,EAAE,YAAY;EAEpB,MAAM,qBAAqB,KAAK,KAAK;AAErC,YAAU,CACR,sBACA,SAAS,KAAK,YAAY,QAAQ,IAAI,WAAW,UAAU,CAC5D,CAAC;AAEF,MAAI,MACF,gBAAe,cAAc;AAG/B,QAAM,mBAAmB,cAAc;EAEvC,MAAM,2BAA2B,KAAK,KAAK;AAE3C,YACE,CACE,yBACA,SACE,IAAI,2BAA2B,mBAAmB,MAClD,WAAW,UACZ,CACF,EACD,EACE,WAAW,MACZ,CACF;EAID,MAAM,eAAe,MAAM,iBAFH,MAAM,iBAAiB,cAAc,EAEV,cAAc;EAEjE,MAAM,yBAAyB,KAAK,KAAK;AAEzC,YACE,CACE,kBACA,SACE,CACE,aAAa,mBAAmB,SAAS,IACrC,YAAY,yBAAyB,yBAAyB,cAAc,aAAa,KAAK,kBAAkB,eAAe,aAAa,KAAK,mBAAmB,OACpK,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,YAJoB,OAAO,OAC/B,oBAAoB,sBAAsB,EAAE,CAC7C,CAAC,KAAK,eAAe,WAAW,eAAe,EAEX,cAAc;AAEnD,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,WAAW,EAAE,EAAE;GACxC,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;EAAE;EAAU;EAAY,CACzB"}
|
|
@@ -1,40 +1,29 @@
|
|
|
1
|
+
//#region src/reduceDictionaryContent/applyMask.ts
|
|
1
2
|
const applyMask = (full, mask) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const isArrayOfTranslationNodes = fullValue.every(
|
|
25
|
-
(item) => isTranslationNode(item)
|
|
26
|
-
);
|
|
27
|
-
if (!allChildrenAreArrays && !isArrayOfTranslationNodes) {
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
out[k] = applyMask(fullValue, m);
|
|
32
|
-
}
|
|
33
|
-
return out;
|
|
34
|
-
}
|
|
35
|
-
return full;
|
|
36
|
-
};
|
|
37
|
-
export {
|
|
38
|
-
applyMask
|
|
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;
|
|
39
25
|
};
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { applyMask };
|
|
40
29
|
//# sourceMappingURL=applyMask.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/reduceDictionaryContent/applyMask.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/
|
|
1
|
+
{"version":3,"file":"applyMask.mjs","names":["out: any"],"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,aAAa,MAAkB,SAA0B;AAEpE,KAAI,SAAS,KACX,QAAO;AAIT,KAAI,MAAM,QAAQ,KAAK,IAAI,MAAM,QAAQ,KAAK,CAC5C,QAAO,KAAK,KAAK,GAAG,MAAM,UAAU,KAAK,IAAI,EAAE,CAAC;AAIlD,KAAI,QAAQ,OAAO,SAAS,YAAY,cAAc,MAAM;AAC1D,MAAI,QAAQ,OAAO,SAAS,SAC1B,QAAO;AAET,SAAO;;AAIT,KAAI,QAAQ,OAAO,SAAS,YAAY,QAAQ,OAAO,SAAS,UAAU;EACxE,MAAMA,MAAW,EAAE;EACnB,MAAM,cAAc,OAAO,QAAQ,KAAK;EACxC,MAAM,uBAAuB,YAAY,OAAO,GAAG,WACjD,MAAM,QAAQ,MAAM,CACrB;AAED,OAAK,MAAM,CAAC,GAAG,MAAM,aAAa;GAChC,MAAM,YAAa,KAAa;AAKhC,OAAI,MAAM,QAAQ,EAAE,IAAI,MAAM,QAAQ,UAAU,EAAE;IAChD,MAAM,qBAAqB,QACzB,CAAC,CAAC,OAAO,OAAO,QAAQ,YAAY,cAAe;IACrD,MAAM,4BAA4B,UAAU,OAAO,SACjD,kBAAkB,KAAK,CACxB;AAED,QAAI,CAAC,wBAAwB,CAAC,0BAC5B;;AAIJ,OAAI,KAAK,UAAU,WAAW,EAAE;;AAElC,SAAO;;AAIT,QAAO"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { getMaskContent } from "@intlayer/core";
|
|
2
1
|
import { applyMask } from "./applyMask.mjs";
|
|
2
|
+
import { getMaskContent } from "@intlayer/core";
|
|
3
|
+
|
|
4
|
+
//#region src/reduceDictionaryContent/reduceDictionaryContent.ts
|
|
3
5
|
const reduceDictionaryContent = (fullDictionary, partialDictionary) => {
|
|
4
|
-
|
|
5
|
-
const result = applyMask(fullDictionary, mask);
|
|
6
|
-
return result;
|
|
7
|
-
};
|
|
8
|
-
export {
|
|
9
|
-
reduceDictionaryContent
|
|
6
|
+
return applyMask(fullDictionary, getMaskContent(partialDictionary));
|
|
10
7
|
};
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { reduceDictionaryContent };
|
|
11
11
|
//# sourceMappingURL=reduceDictionaryContent.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/reduceDictionaryContent/reduceDictionaryContent.ts"],"sourcesContent":["import { type Dictionary
|
|
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":";;;;AAIA,MAAa,2BACX,gBACA,sBACG;AAIH,QAFe,UAAU,gBADZ,eAAe,kBAAkB,CACA"}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { getChunk } from "./getChunk.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/chunkJSON.ts
|
|
4
|
+
const isObject = (val) => {
|
|
5
|
+
return typeof val === "object" && val !== null && !Array.isArray(val);
|
|
6
|
+
};
|
|
7
|
+
const computeDjb2 = (str) => {
|
|
8
|
+
let hash = 5381;
|
|
9
|
+
for (let i = 0; i < str.length; i++) hash = (hash << 5) + hash ^ str.charCodeAt(i);
|
|
10
|
+
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
11
|
+
};
|
|
12
|
+
const setAtPath = (root, path, value) => {
|
|
13
|
+
let current = root;
|
|
14
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
15
|
+
const key = path[i];
|
|
16
|
+
const isNextIndex = typeof path[i + 1] === "number";
|
|
17
|
+
if (typeof key === "number") {
|
|
18
|
+
if (!Array.isArray(current)) throw new Error(`Expected array at path segment ${i}`);
|
|
19
|
+
if (current[key] === void 0) current[key] = isNextIndex ? [] : {};
|
|
20
|
+
current = current[key];
|
|
21
|
+
} else {
|
|
22
|
+
if (!isObject(current)) throw new Error(`Expected object at path segment ${i}`);
|
|
23
|
+
if (!(key in current)) current[key] = isNextIndex ? [] : {};
|
|
24
|
+
current = current[key];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const last = path[path.length - 1];
|
|
28
|
+
if (typeof last === "number") {
|
|
29
|
+
if (!Array.isArray(current)) throw new Error(`Expected array at final segment`);
|
|
30
|
+
current[last] = value;
|
|
31
|
+
} else {
|
|
32
|
+
if (!isObject(current)) throw new Error(`Expected object at final segment`);
|
|
33
|
+
current[last] = value;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const pathKey = (path) => {
|
|
37
|
+
return JSON.stringify(path);
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Split a string into parts using getChunk with a charLength budget per part.
|
|
41
|
+
*/
|
|
42
|
+
const splitStringByBudget = (str, maxCharsPerPart) => {
|
|
43
|
+
if (maxCharsPerPart <= 0) throw new Error("maxChars must be > 0");
|
|
44
|
+
const output = [];
|
|
45
|
+
let offset = 0;
|
|
46
|
+
while (offset < str.length) {
|
|
47
|
+
const part = getChunk(str, {
|
|
48
|
+
charStart: offset,
|
|
49
|
+
charLength: maxCharsPerPart
|
|
50
|
+
});
|
|
51
|
+
if (!part) break;
|
|
52
|
+
output.push(part);
|
|
53
|
+
offset += part.length;
|
|
54
|
+
}
|
|
55
|
+
return output;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Flatten JSON into patches (leaf writes). Strings too large to fit in a single
|
|
59
|
+
* chunk are yielded as multiple str-append patches.
|
|
60
|
+
*/
|
|
61
|
+
const flattenToPatches = (value, maxCharsPerChunk, path = [], seen = /* @__PURE__ */ new WeakSet()) => {
|
|
62
|
+
const maxStringPiece = Math.max(1, Math.floor((maxCharsPerChunk - 400) * .8));
|
|
63
|
+
const patches = [];
|
|
64
|
+
const walk = (currentValue, currentPath) => {
|
|
65
|
+
if (typeof currentValue === "string") {
|
|
66
|
+
const testPatch = {
|
|
67
|
+
op: "set",
|
|
68
|
+
path: currentPath,
|
|
69
|
+
value: currentValue
|
|
70
|
+
};
|
|
71
|
+
if (JSON.stringify(testPatch).length + 150 <= maxCharsPerChunk) {
|
|
72
|
+
patches.push(testPatch);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const parts = splitStringByBudget(currentValue, maxStringPiece);
|
|
76
|
+
patches.push({
|
|
77
|
+
op: "set",
|
|
78
|
+
path: [...currentPath, "__splittedType"],
|
|
79
|
+
value: "string"
|
|
80
|
+
});
|
|
81
|
+
patches.push({
|
|
82
|
+
op: "set",
|
|
83
|
+
path: [...currentPath, "__total"],
|
|
84
|
+
value: parts.length
|
|
85
|
+
});
|
|
86
|
+
for (let i = 0; i < parts.length; i++) patches.push({
|
|
87
|
+
op: "set",
|
|
88
|
+
path: [...currentPath, String(i + 1)],
|
|
89
|
+
value: parts[i]
|
|
90
|
+
});
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (currentValue === null || typeof currentValue !== "object") {
|
|
94
|
+
patches.push({
|
|
95
|
+
op: "set",
|
|
96
|
+
path: currentPath,
|
|
97
|
+
value: currentValue
|
|
98
|
+
});
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (seen.has(currentValue)) throw new Error("Cannot serialize circular structures to JSON.");
|
|
102
|
+
seen.add(currentValue);
|
|
103
|
+
if (Array.isArray(currentValue)) for (let i = 0; i < currentValue.length; i++) walk(currentValue[i], [...currentPath, i]);
|
|
104
|
+
else for (const key of Object.keys(currentValue)) walk(currentValue[key], [...currentPath, key]);
|
|
105
|
+
seen.delete(currentValue);
|
|
106
|
+
};
|
|
107
|
+
walk(value, path);
|
|
108
|
+
return patches;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Split JSON into chunks constrained by character count of serialized chunk.
|
|
112
|
+
*/
|
|
113
|
+
const chunkJSON = (value, maxChars) => {
|
|
114
|
+
if (!isObject(value) && !Array.isArray(value)) throw new Error("Root must be an object or array.");
|
|
115
|
+
if (maxChars < 500) throw new Error("maxChars is too small. Use at least 500 characters.");
|
|
116
|
+
const rootType = Array.isArray(value) ? "array" : "object";
|
|
117
|
+
let sourceString;
|
|
118
|
+
try {
|
|
119
|
+
sourceString = JSON.stringify(value);
|
|
120
|
+
} catch {
|
|
121
|
+
throw new Error("Cannot serialize circular structures to JSON.");
|
|
122
|
+
}
|
|
123
|
+
const checksum = computeDjb2(sourceString);
|
|
124
|
+
const allPatches = flattenToPatches(value, maxChars);
|
|
125
|
+
const chunks = [];
|
|
126
|
+
let currentChunk = {
|
|
127
|
+
schemaVersion: 1,
|
|
128
|
+
index: 0,
|
|
129
|
+
total: 0,
|
|
130
|
+
rootType,
|
|
131
|
+
checksum,
|
|
132
|
+
entries: []
|
|
133
|
+
};
|
|
134
|
+
const emptyEnvelopeSize = JSON.stringify({
|
|
135
|
+
...currentChunk,
|
|
136
|
+
entries: []
|
|
137
|
+
}).length;
|
|
138
|
+
const tryFlush = () => {
|
|
139
|
+
if (currentChunk.entries.length > 0) {
|
|
140
|
+
chunks.push(currentChunk);
|
|
141
|
+
currentChunk = {
|
|
142
|
+
schemaVersion: 1,
|
|
143
|
+
index: 0,
|
|
144
|
+
total: 0,
|
|
145
|
+
rootType,
|
|
146
|
+
checksum,
|
|
147
|
+
entries: []
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
for (const patch of allPatches) if (emptyEnvelopeSize + JSON.stringify(currentChunk.entries).length + (currentChunk.entries.length ? 1 : 0) + JSON.stringify(patch).length <= maxChars) currentChunk.entries.push(patch);
|
|
152
|
+
else {
|
|
153
|
+
if (currentChunk.entries.length > 0) tryFlush();
|
|
154
|
+
if (emptyEnvelopeSize + JSON.stringify([patch]).length > maxChars) throw new Error("A single entry exceeds maxChars and cannot be split. Reduce entry size or increase maxChars.");
|
|
155
|
+
currentChunk.entries.push(patch);
|
|
156
|
+
}
|
|
157
|
+
tryFlush();
|
|
158
|
+
if (chunks.length === 0) chunks.push({
|
|
159
|
+
schemaVersion: 1,
|
|
160
|
+
index: 0,
|
|
161
|
+
total: 0,
|
|
162
|
+
rootType,
|
|
163
|
+
checksum,
|
|
164
|
+
entries: []
|
|
165
|
+
});
|
|
166
|
+
const totalChunks = chunks.length;
|
|
167
|
+
chunks.forEach((chunk, index) => {
|
|
168
|
+
chunk.index = index;
|
|
169
|
+
chunk.total = totalChunks;
|
|
170
|
+
});
|
|
171
|
+
return chunks;
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* Reassemble JSON from chunks.
|
|
175
|
+
* - Validates checksums and indices.
|
|
176
|
+
* - Applies 'set' patches and merges string pieces from 'str-append'.
|
|
177
|
+
*/
|
|
178
|
+
/**
|
|
179
|
+
* Reconstruct content from a single chunk without validation.
|
|
180
|
+
* Useful for processing individual chunks in a pipeline where you don't have all chunks yet.
|
|
181
|
+
* Note: This will only reconstruct the partial content contained in this chunk.
|
|
182
|
+
*/
|
|
183
|
+
const reconstructFromSingleChunk = (chunk) => {
|
|
184
|
+
const root = chunk.rootType === "array" ? [] : {};
|
|
185
|
+
for (const entry of chunk.entries) if (entry.op === "set") setAtPath(root, entry.path, entry.value);
|
|
186
|
+
const reconcileSplitNodes = (node) => {
|
|
187
|
+
if (node === null || typeof node !== "object") return node;
|
|
188
|
+
if (Array.isArray(node)) {
|
|
189
|
+
for (let i = 0; i < node.length; i++) node[i] = reconcileSplitNodes(node[i]);
|
|
190
|
+
return node;
|
|
191
|
+
}
|
|
192
|
+
if (node["__splittedType"] === "string") {
|
|
193
|
+
const total = node["__total"];
|
|
194
|
+
if (typeof total !== "number" || total <= 0) return node;
|
|
195
|
+
const parts = [];
|
|
196
|
+
let hasAllParts = true;
|
|
197
|
+
for (let i = 1; i <= total; i++) {
|
|
198
|
+
const piece = node[String(i)];
|
|
199
|
+
if (typeof piece !== "string") {
|
|
200
|
+
hasAllParts = false;
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
parts.push(piece);
|
|
204
|
+
}
|
|
205
|
+
if (hasAllParts) return parts.join("");
|
|
206
|
+
return node;
|
|
207
|
+
}
|
|
208
|
+
if (node["__splittedType"] === "array") {
|
|
209
|
+
const total = node["__total"];
|
|
210
|
+
if (typeof total !== "number" || total < 0) return node;
|
|
211
|
+
const output = [];
|
|
212
|
+
let hasAllParts = true;
|
|
213
|
+
for (let i = 1; i <= total; i++) {
|
|
214
|
+
const slice = node[String(i)];
|
|
215
|
+
if (!Array.isArray(slice)) {
|
|
216
|
+
hasAllParts = false;
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
for (let j = 0; j < slice.length; j++) output.push(reconcileSplitNodes(slice[j]));
|
|
220
|
+
}
|
|
221
|
+
if (hasAllParts) return output;
|
|
222
|
+
return node;
|
|
223
|
+
}
|
|
224
|
+
for (const key of Object.keys(node)) node[key] = reconcileSplitNodes(node[key]);
|
|
225
|
+
return node;
|
|
226
|
+
};
|
|
227
|
+
return reconcileSplitNodes(root);
|
|
228
|
+
};
|
|
229
|
+
const assembleJSON = (chunks) => {
|
|
230
|
+
if (!chunks || chunks.length === 0) throw new Error("No chunks provided.");
|
|
231
|
+
const sorted = [...chunks].sort((a, b) => a.index - b.index);
|
|
232
|
+
const { checksum, rootType } = sorted[0];
|
|
233
|
+
const schemaVersion = 1;
|
|
234
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
235
|
+
const chunk = sorted[i];
|
|
236
|
+
if (chunk.schemaVersion !== schemaVersion) {
|
|
237
|
+
console.error("Unsupported schemaVersion.", {
|
|
238
|
+
cause: chunk,
|
|
239
|
+
schemaVersion
|
|
240
|
+
});
|
|
241
|
+
throw new Error("Unsupported schemaVersion.");
|
|
242
|
+
}
|
|
243
|
+
if (chunk.rootType !== rootType) {
|
|
244
|
+
console.error("Chunks rootType mismatch.", {
|
|
245
|
+
cause: chunk,
|
|
246
|
+
rootType
|
|
247
|
+
});
|
|
248
|
+
throw new Error("Chunks rootType mismatch.");
|
|
249
|
+
}
|
|
250
|
+
if (chunk.checksum !== checksum) {
|
|
251
|
+
console.error("Chunks checksum mismatch (different source objects?).", {
|
|
252
|
+
cause: chunk,
|
|
253
|
+
checksum
|
|
254
|
+
});
|
|
255
|
+
throw new Error("Chunks checksum mismatch (different source objects?).");
|
|
256
|
+
}
|
|
257
|
+
if (chunk.index !== i) {
|
|
258
|
+
console.error("Chunk indices are not contiguous or sorted.", {
|
|
259
|
+
cause: chunk,
|
|
260
|
+
index: chunk.index,
|
|
261
|
+
i
|
|
262
|
+
});
|
|
263
|
+
throw new Error("Chunk indices are not contiguous or sorted.");
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
const root = rootType === "array" ? [] : {};
|
|
267
|
+
const stringParts = /* @__PURE__ */ new Map();
|
|
268
|
+
const applySet = (patch) => setAtPath(root, patch.path, patch.value);
|
|
269
|
+
for (const chunk of sorted) for (const entry of chunk.entries) if (entry.op === "set") applySet(entry);
|
|
270
|
+
else {
|
|
271
|
+
const key = pathKey(entry.path);
|
|
272
|
+
const record = stringParts.get(key) ?? {
|
|
273
|
+
path: entry.path,
|
|
274
|
+
total: entry.total,
|
|
275
|
+
received: []
|
|
276
|
+
};
|
|
277
|
+
if (record.total !== entry.total) throw new Error("Inconsistent string part totals for a path.");
|
|
278
|
+
record.received.push(entry);
|
|
279
|
+
stringParts.set(key, record);
|
|
280
|
+
}
|
|
281
|
+
for (const { path, total, received } of stringParts.values()) {
|
|
282
|
+
if (received.length !== total) throw new Error("Missing string parts for a path; incomplete chunk set.");
|
|
283
|
+
received.sort((a, b) => a.index - b.index);
|
|
284
|
+
setAtPath(root, path, received.map((part) => part.value).join(""));
|
|
285
|
+
}
|
|
286
|
+
const reconcileSplitNodes = (node) => {
|
|
287
|
+
if (node === null || typeof node !== "object") return node;
|
|
288
|
+
if (Array.isArray(node)) {
|
|
289
|
+
for (let i = 0; i < node.length; i++) node[i] = reconcileSplitNodes(node[i]);
|
|
290
|
+
return node;
|
|
291
|
+
}
|
|
292
|
+
if (node["__splittedType"] === "string") {
|
|
293
|
+
const total = node["__total"];
|
|
294
|
+
if (typeof total !== "number" || total <= 0) throw new Error("Invalid split-node total for a path.");
|
|
295
|
+
const parts = [];
|
|
296
|
+
for (let i = 1; i <= total; i++) {
|
|
297
|
+
const piece = node[String(i)];
|
|
298
|
+
if (typeof piece !== "string") throw new Error("Missing string parts for a path; incomplete chunk set.");
|
|
299
|
+
parts.push(piece);
|
|
300
|
+
}
|
|
301
|
+
return parts.join("");
|
|
302
|
+
}
|
|
303
|
+
if (node["__splittedType"] === "array") {
|
|
304
|
+
const total = node["__total"];
|
|
305
|
+
if (typeof total !== "number" || total < 0) throw new Error("Invalid split-node total for a path.");
|
|
306
|
+
const output = [];
|
|
307
|
+
for (let i = 1; i <= total; i++) {
|
|
308
|
+
const slice = node[String(i)];
|
|
309
|
+
if (!Array.isArray(slice)) throw new Error("Missing string parts for a path; incomplete chunk set.");
|
|
310
|
+
for (let j = 0; j < slice.length; j++) output.push(reconcileSplitNodes(slice[j]));
|
|
311
|
+
}
|
|
312
|
+
return output;
|
|
313
|
+
}
|
|
314
|
+
for (const key of Object.keys(node)) node[key] = reconcileSplitNodes(node[key]);
|
|
315
|
+
return node;
|
|
316
|
+
};
|
|
317
|
+
const reconciled = reconcileSplitNodes(root);
|
|
318
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
319
|
+
const chunk = sorted[i];
|
|
320
|
+
if (chunk.total !== sorted.length) throw new Error(`Chunk total does not match provided count. Expected ${sorted.length}, but chunk ${i} has total=${chunk.total}`);
|
|
321
|
+
}
|
|
322
|
+
return reconciled;
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
//#endregion
|
|
326
|
+
export { assembleJSON, chunkJSON, reconstructFromSingleChunk };
|
|
327
|
+
//# sourceMappingURL=chunkJSON.mjs.map
|