@intlayer/chokidar 8.2.4 → 8.3.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/build.cjs +1 -1
- package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs +1 -1
- package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +4 -4
- package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +2 -2
- package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs.map +1 -1
- package/dist/cjs/cleanOutputDir.cjs.map +1 -1
- package/dist/cjs/cleanRemovedContentDeclaration.cjs +1 -1
- package/dist/cjs/cleanRemovedContentDeclaration.cjs.map +1 -1
- package/dist/cjs/cli.cjs +1 -1
- package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +1 -1
- package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createType/createModuleAugmentation.cjs +2 -2
- package/dist/cjs/createType/createModuleAugmentation.cjs.map +1 -1
- package/dist/cjs/createType/createType.cjs.map +1 -1
- package/dist/cjs/detectFormatCommand.cjs +1 -1
- package/dist/cjs/detectFormatCommand.cjs.map +1 -1
- package/dist/cjs/fetchDistantDictionaries.cjs +1 -1
- package/dist/cjs/filterInvalidDictionaries.cjs.map +1 -1
- package/dist/cjs/formatDictionary.cjs.map +1 -1
- package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +7 -1
- package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -1
- package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +1 -1
- package/dist/cjs/handleAdditionalContentDeclarationFile.cjs.map +1 -1
- package/dist/cjs/handleContentDeclarationFileChange.cjs +1 -1
- package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -1
- package/dist/cjs/handleContentDeclarationFileMoved.cjs +1 -1
- package/dist/cjs/handleContentDeclarationFileMoved.cjs.map +1 -1
- package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs +1 -1
- package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs.map +1 -1
- package/dist/cjs/init/index.cjs +1 -1
- package/dist/cjs/initConfig/index.cjs +1 -1
- package/dist/cjs/listDictionariesPath.cjs.map +1 -1
- package/dist/cjs/listGitFiles.cjs +3 -3
- package/dist/cjs/listProjects.cjs +1 -1
- package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +1 -1
- package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/index.cjs +1 -1
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +2 -2
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs +1 -1
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/logTypeScriptErrors.cjs.map +1 -1
- package/dist/cjs/logConfigDetails.cjs +2 -1
- package/dist/cjs/logConfigDetails.cjs.map +1 -1
- package/dist/cjs/prepareIntlayer.cjs +1 -1
- package/dist/cjs/prepareIntlayer.cjs.map +1 -1
- package/dist/cjs/reduceDictionaryContent/applyMask.cjs.map +1 -1
- package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs.map +1 -1
- package/dist/cjs/utils/autoDecorateContent.cjs +1 -1
- package/dist/cjs/utils/autoDecorateContent.cjs.map +1 -1
- package/dist/cjs/utils/buildFilesList.cjs +1 -1
- package/dist/cjs/utils/buildFilesList.cjs.map +1 -1
- package/dist/cjs/utils/formatter.cjs +1 -1
- package/dist/cjs/utils/formatter.cjs.map +1 -1
- package/dist/cjs/utils/getComponentTransformPattern.cjs +1 -1
- package/dist/cjs/utils/getComponentTransformPattern.cjs.map +1 -1
- package/dist/cjs/utils/getContentExtension.cjs +2 -0
- package/dist/cjs/utils/getContentExtension.cjs.map +1 -0
- package/dist/cjs/utils/getFormatFromExtension.cjs +1 -1
- package/dist/cjs/utils/getFormatFromExtension.cjs.map +1 -1
- package/dist/cjs/utils/index.cjs +1 -1
- package/dist/cjs/utils/resolveRelativePath.cjs +2 -0
- package/dist/cjs/utils/resolveRelativePath.cjs.map +1 -0
- package/dist/cjs/watcher.cjs +1 -1
- package/dist/cjs/watcher.cjs.map +1 -1
- package/dist/cjs/writeConfiguration/index.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs +1 -1
- package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/transformJSFile.cjs +3 -1
- package/dist/cjs/writeContentDeclaration/transformJSFile.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs +1 -1
- package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +1 -1
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +1 -1
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -1
- package/dist/esm/build.mjs +1 -1
- package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs +1 -1
- package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +4 -4
- package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +2 -2
- package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs +1 -1
- package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs +1 -1
- package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs.map +1 -1
- package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs.map +1 -1
- package/dist/esm/cleanOutputDir.mjs.map +1 -1
- package/dist/esm/cleanRemovedContentDeclaration.mjs +1 -1
- package/dist/esm/cleanRemovedContentDeclaration.mjs.map +1 -1
- package/dist/esm/cli.mjs +1 -1
- package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs +1 -1
- package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs.map +1 -1
- package/dist/esm/createType/createModuleAugmentation.mjs +2 -2
- package/dist/esm/createType/createModuleAugmentation.mjs.map +1 -1
- package/dist/esm/createType/createType.mjs.map +1 -1
- package/dist/esm/detectFormatCommand.mjs +1 -1
- package/dist/esm/detectFormatCommand.mjs.map +1 -1
- package/dist/esm/fetchDistantDictionaries.mjs +1 -1
- package/dist/esm/filterInvalidDictionaries.mjs.map +1 -1
- package/dist/esm/formatDictionary.mjs.map +1 -1
- package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +7 -1
- package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -1
- package/dist/esm/handleAdditionalContentDeclarationFile.mjs +1 -1
- package/dist/esm/handleAdditionalContentDeclarationFile.mjs.map +1 -1
- package/dist/esm/handleContentDeclarationFileChange.mjs +1 -1
- package/dist/esm/handleContentDeclarationFileChange.mjs.map +1 -1
- package/dist/esm/handleContentDeclarationFileMoved.mjs +1 -1
- package/dist/esm/handleContentDeclarationFileMoved.mjs.map +1 -1
- package/dist/esm/handleUnlinkedContentDeclarationFile.mjs +1 -1
- package/dist/esm/handleUnlinkedContentDeclarationFile.mjs.map +1 -1
- package/dist/esm/init/index.mjs +1 -1
- package/dist/esm/initConfig/index.mjs +1 -1
- package/dist/esm/listDictionariesPath.mjs.map +1 -1
- package/dist/esm/listGitFiles.mjs +4 -4
- package/dist/esm/listProjects.mjs +1 -1
- package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +1 -1
- package/dist/esm/loadDictionaries/getIntlayerBundle.mjs.map +1 -1
- package/dist/esm/loadDictionaries/index.mjs +1 -1
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +2 -2
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadDictionaries.mjs +1 -1
- package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/logTypeScriptErrors.mjs.map +1 -1
- package/dist/esm/logConfigDetails.mjs +2 -1
- package/dist/esm/logConfigDetails.mjs.map +1 -1
- package/dist/esm/prepareIntlayer.mjs +1 -1
- package/dist/esm/prepareIntlayer.mjs.map +1 -1
- package/dist/esm/reduceDictionaryContent/applyMask.mjs.map +1 -1
- package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs.map +1 -1
- package/dist/esm/utils/autoDecorateContent.mjs +1 -1
- package/dist/esm/utils/autoDecorateContent.mjs.map +1 -1
- package/dist/esm/utils/buildFilesList.mjs +1 -1
- package/dist/esm/utils/buildFilesList.mjs.map +1 -1
- package/dist/esm/utils/formatter.mjs +1 -1
- package/dist/esm/utils/formatter.mjs.map +1 -1
- package/dist/esm/utils/getComponentTransformPattern.mjs +1 -1
- package/dist/esm/utils/getComponentTransformPattern.mjs.map +1 -1
- package/dist/esm/utils/getContentExtension.mjs +2 -0
- package/dist/esm/utils/getContentExtension.mjs.map +1 -0
- package/dist/esm/utils/getFormatFromExtension.mjs +1 -1
- package/dist/esm/utils/getFormatFromExtension.mjs.map +1 -1
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/utils/resolveRelativePath.mjs +2 -0
- package/dist/esm/utils/resolveRelativePath.mjs.map +1 -0
- package/dist/esm/watcher.mjs +1 -1
- package/dist/esm/watcher.mjs.map +1 -1
- package/dist/esm/writeConfiguration/index.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +1 -1
- package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/transformJSFile.mjs +3 -1
- package/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/transformJSONFile.mjs +1 -1
- package/dist/esm/writeContentDeclaration/transformJSONFile.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +1 -1
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeJSFile.mjs +1 -1
- package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -1
- package/dist/types/build.d.ts +2 -2
- package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +3 -3
- package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts +2 -1
- package/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +5 -4
- package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +3 -3
- package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +3 -3
- package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts +3 -3
- package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts +2 -1
- package/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts.map +1 -1
- package/dist/types/cleanOutputDir.d.ts +1 -1
- package/dist/types/cleanRemovedContentDeclaration.d.ts +1 -1
- package/dist/types/cleanRemovedContentDeclaration.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +2 -2
- package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +2 -2
- package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts +1 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts +1 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts +1 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts +1 -1
- package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts +1 -1
- package/dist/types/createType/createModuleAugmentation.d.ts +1 -1
- package/dist/types/createType/createModuleAugmentation.d.ts.map +1 -1
- package/dist/types/createType/createType.d.ts +2 -1
- package/dist/types/createType/createType.d.ts.map +1 -1
- package/dist/types/detectFormatCommand.d.ts +1 -1
- package/dist/types/filterInvalidDictionaries.d.ts +2 -1
- package/dist/types/filterInvalidDictionaries.d.ts.map +1 -1
- package/dist/types/formatDictionary.d.ts +21 -20
- package/dist/types/formatDictionary.d.ts.map +1 -1
- package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts +1 -1
- package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts.map +1 -1
- package/dist/types/handleAdditionalContentDeclarationFile.d.ts +1 -1
- package/dist/types/handleContentDeclarationFileChange.d.ts +1 -1
- package/dist/types/handleContentDeclarationFileMoved.d.ts +1 -1
- package/dist/types/handleUnlinkedContentDeclarationFile.d.ts +1 -1
- package/dist/types/listDictionariesPath.d.ts +1 -1
- package/dist/types/loadDictionaries/getIntlayerBundle.d.ts +1 -1
- package/dist/types/loadDictionaries/index.d.ts +2 -2
- package/dist/types/loadDictionaries/loadContentDeclaration.d.ts +5 -2
- package/dist/types/loadDictionaries/loadContentDeclaration.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadDictionaries.d.ts +2 -1
- package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadLocalDictionaries.d.ts +2 -1
- package/dist/types/loadDictionaries/loadLocalDictionaries.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +3 -3
- package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -1
- package/dist/types/loadDictionaries/logTypeScriptErrors.d.ts +1 -1
- package/dist/types/logConfigDetails.d.ts.map +1 -1
- package/dist/types/prepareIntlayer.d.ts +1 -1
- package/dist/types/reduceDictionaryContent/applyMask.d.ts +1 -1
- package/dist/types/reduceDictionaryContent/reduceDictionaryContent.d.ts +1 -1
- package/dist/types/utils/buildFilesList.d.ts.map +1 -1
- package/dist/types/utils/formatter.d.ts +1 -1
- package/dist/types/utils/formatter.d.ts.map +1 -1
- package/dist/types/utils/getComponentTransformPattern.d.ts +1 -1
- package/dist/types/utils/getComponentTransformPattern.d.ts.map +1 -1
- package/dist/types/utils/getContentExtension.d.ts +15 -0
- package/dist/types/utils/getContentExtension.d.ts.map +1 -0
- package/dist/types/utils/getFormatFromExtension.d.ts +2 -2
- package/dist/types/utils/getFormatFromExtension.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +3 -1
- package/dist/types/utils/resolveRelativePath.d.ts +5 -0
- package/dist/types/utils/resolveRelativePath.d.ts.map +1 -0
- package/dist/types/watcher.d.ts +1 -1
- package/dist/types/writeConfiguration/index.d.ts +1 -1
- package/dist/types/writeContentDeclaration/processContentDeclarationContent.d.ts +1 -1
- package/dist/types/writeContentDeclaration/processContentDeclarationContent.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/transformJSFile.d.ts +3 -2
- package/dist/types/writeContentDeclaration/transformJSFile.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/transformJSONFile.d.ts +2 -2
- package/dist/types/writeContentDeclaration/transformJSONFile.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts +4 -1
- package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/writeJSFile.d.ts +3 -2
- package/dist/types/writeContentDeclaration/writeJSFile.d.ts.map +1 -1
- package/package.json +20 -19
- package/dist/assets/getContentDeclarationFileTemplate/cjsTemplate.txt +0 -10
- package/dist/assets/getContentDeclarationFileTemplate/esmTemplate.txt +0 -10
- package/dist/assets/getContentDeclarationFileTemplate/jsonTemplate.txt +0 -6
- package/dist/assets/getContentDeclarationFileTemplate/tsTemplate.txt +0 -9
package/dist/esm/init/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{initConfig as e}from"../initConfig/index.mjs";import{updateNextConfig as t,updateViteConfig as n}from"./utils/configManipulation.mjs";import{ensureDirectory as r,exists as i,readFileFromRoot as a,writeFileToRoot as o}from"./utils/fileSystem.mjs";import{parseJSONWithComments as s}from"./utils/jsonParser.mjs";import{findTsConfigFiles as c}from"./utils/tsConfig.mjs";import{
|
|
1
|
+
import{initConfig as e}from"../initConfig/index.mjs";import{updateNextConfig as t,updateViteConfig as n}from"./utils/configManipulation.mjs";import{ensureDirectory as r,exists as i,readFileFromRoot as a,writeFileToRoot as o}from"./utils/fileSystem.mjs";import{parseJSONWithComments as s}from"./utils/jsonParser.mjs";import{findTsConfigFiles as c}from"./utils/tsConfig.mjs";import{join as l}from"node:path";import{ANSIColors as u,colorize as d,colorizePath as f,logger as p,v as m,x as h}from"@intlayer/config/logger";import{getConfiguration as g}from"@intlayer/config/node";import{getAlias as _}from"@intlayer/config/utils";const v={NextJS:`https://intlayer.org/doc/environment/nextjs.md`,NextJS_15:`https://intlayer.org/doc/environment/nextjs/15.md`,NextJS_14:`https://intlayer.org/doc/environment/nextjs/14.md`,CRA:`https://intlayer.org/doc/environment/create-react-app.md`,Astro:`https://intlayer.org/doc/environment/astro.md`,ViteAndReact:`https://intlayer.org/doc/environment/vite-and-react.md`,ViteAndReact_ReactRouterV7:`https://intlayer.org/doc/environment/vite-and-react/react-router-v7.md`,ViteAndReact_ReactRouterV7_FSRoutes:`https://intlayer.org/doc/environment/vite-and-react/react-router-v7-fs-routes.md`,ViteAndVue:`https://intlayer.org/doc/environment/vite-and-vue.md`,ViteAndSolid:`https://intlayer.org/doc/environment/vite-and-solid.md`,ViteAndSvelte:`https://intlayer.org/doc/environment/vite-and-svelte.md`,ViteAndPreact:`https://intlayer.org/doc/environment/vite-and-preact.md`,TanStackRouter:`https://intlayer.org/doc/environment/tanstack.md`,NuxtAndVue:`https://intlayer.org/doc/environment/nuxt-and-vue.md`,Angular:`https://intlayer.org/doc/environment/angular.md`,SvelteKit:`https://intlayer.org/doc/environment/sveltekit.md`,ReactNativeAndExpo:`https://intlayer.org/doc/environment/react-native-and-expo.md`,Lynx:`https://intlayer.org/doc/environment/lynx-and-react.md`,Express:`https://intlayer.org/doc/environment/express.md`,NestJS:`https://intlayer.org/doc/environment/nestjs.md`,Fastify:`https://intlayer.org/doc/environment/fastify.md`,Default:`https://intlayer.org/doc/get-started`,NextIntl:`https://intlayer.org/blog/intlayer-with-next-intl.md`,ReactI18Next:`https://intlayer.org/blog/intlayer-with-react-i18next.md`,ReactIntl:`https://intlayer.org/blog/intlayer-with-react-intl.md`,NextI18Next:`https://intlayer.org/blog/intlayer-with-next-i18next.md`,VueI18n:`https://intlayer.org/blog/intlayer-with-vue-i18n.md`},y=e=>{let t={...e.dependencies,...e.devDependencies},n=(e,t)=>!e||typeof e!=`string`?!1:RegExp(`^[\\^~]?${t}(?:\\.|$)`).test(e);if(t[`@lynx-js/react`]||t[`@lynx-js/core`])return v.Lynx;if(t[`react-native`]||t.expo)return v.ReactNativeAndExpo;if(t.next){let e=t.next;return n(e,14)?v.NextJS_14:n(e,15)?v.NextJS_15:v.NextJS}if(t.nuxt)return v.NuxtAndVue;if(t.astro)return v.Astro;if(t[`@sveltejs/kit`])return v.SvelteKit;if(t[`@tanstack/react-router`])return v.TanStackRouter;let r=t[`react-router`];if(r&&typeof r==`string`){if(t[`@react-router/fs-routes`])return v.ViteAndReact_ReactRouterV7_FSRoutes;if(n(r,7))return v.ViteAndReact_ReactRouterV7}return t.vite?t.vue?v.ViteAndVue:t[`solid-js`]?v.ViteAndSolid:t.svelte?v.ViteAndSvelte:t.preact?v.ViteAndPreact:v.ViteAndReact:t[`react-scripts`]?v.CRA:t[`@angular/core`]?v.Angular:t[`@nestjs/core`]?v.NestJS:t.express?v.Express:t.fastify?v.Fastify:t[`next-intl`]?v.NextIntl:t[`react-i18next`]||t.i18next?v.ReactI18Next:t[`react-intl`]?v.ReactIntl:t[`next-i18next`]?v.NextI18Next:t[`vue-i18n`]?v.VueI18n:v.Default},b=async v=>{p(d(`Checking Intlayer configuration...`,u.CYAN));let b=`package.json`;await i(v,b)||(p(`${h} No ${f(`package.json`)} found. Please run this script from the project root.`,{level:`error`}),process.exit(1));let x=await a(v,b),S;try{S=JSON.parse(x)}catch{p(`${h} Could not parse ${f(`package.json`)}.`,{level:`error`}),process.exit(1)}let C=y(S),w=`.gitignore`;if(await i(v,w)){let e=await a(v,w);e.includes(`intlayer`)?p(`${m} ${f(w)} already includes .intlayer`):(await o(v,w,`${e}\n# Intlayer\n.intlayer\n`),p(`${m} Added ${f(`.intlayer`)} to ${f(w)}`))}let T=`.vscode`,E=l(T,`extensions.json`),D=`intlayer.intlayer-vs-code-extension`;try{let e={recommendations:[]};await i(v,E)?e=s(await a(v,E)):await r(v,T),e.recommendations||=[],e.recommendations.includes(D)?p(`${m} ${f(E)} already includes ${d(D,u.MAGENTA)}`):(e.recommendations.push(D),await o(v,E,JSON.stringify(e,null,2)),p(`${m} Added ${d(D,u.MAGENTA)} to ${f(E)}`))}catch{p(`${h} Could not update ${f(E)}. You may need to add ${d(D,u.MAGENTA)} manually.`,{level:`warn`})}let O=await c(v),k=!1;for(let e of O)if(await i(v,e)){k=!0;try{let t=s(await a(v,e)),n=`.intlayer/**/*.ts`,r=!1;t.include&&(Array.isArray(t.include)&&!t.include.some(e=>e.includes(`.intlayer`))?(t.include.push(n),r=!0):t.include.includes(n)&&p(`${m} ${f(e)} already includes intlayer types`)),r&&(await o(v,e,JSON.stringify(t,null,2)),p(`${m} Updated ${f(e)} to include intlayer types`))}catch{p(`${h} Could not parse or update ${f(e)}. You may need to add ${f(`.intlayer/types/**/*.ts`)} manually.`,{level:`warn`})}}await e(k?`intlayer.config.ts`:`intlayer.config.mjs`,v);let A=!1;for(let e of[`vite.config.ts`,`vite.config.js`,`vite.config.mjs`])if(await i(v,e)){A=!0;let t=await a(v,e);t.includes(`vite-intlayer`)||(await o(v,e,n(t,e.split(`.`).pop())),p(`${m} Updated ${f(e)} to include Intlayer plugin`));break}for(let e of[`next.config.js`,`next.config.mjs`,`next.config.ts`])if(await i(v,e)){A=!0;let n=await a(v,e);n.includes(`next-intlayer`)||(await o(v,e,t(n,e.split(`.`).pop())),p(`${m} Updated ${f(e)} to include Intlayer plugin`));break}for(let e of[`webpack.config.js`,`webpack.config.ts`,`webpack.config.mjs`,`webpack.config.cjs`])if(await i(v,e)){A=!0,p(`${m} Found ${f(e)}. Make sure to configure aliases manually or use the Intlayer Webpack plugin.`);break}if(!A){let e=_({configuration:g({baseDir:v})});if(k&&O.length>0){let t=O.find(e=>e===`tsconfig.json`)||O[0],n=s(await a(v,t));n.compilerOptions??={},n.compilerOptions.paths??={};let r=!1;Object.entries(e).forEach(([e,t])=>{n.compilerOptions.paths[e]||(n.compilerOptions.paths[e]=[t],r=!0)}),r&&(await o(v,t,JSON.stringify(n,null,2)),p(`${m} Updated ${f(t)} to include Intlayer aliases`))}else{let t=`jsconfig.json`;if(await i(v,t)){let n=s(await a(v,t));n.compilerOptions??={},n.compilerOptions.paths??={};let r=!1;Object.entries(e).forEach(([e,t])=>{n.compilerOptions.paths[e]||(n.compilerOptions.paths[e]=[t],r=!0)}),r&&(await o(v,t,JSON.stringify(n,null,2)),p(`${m} Updated ${f(t)} to include Intlayer aliases`))}else{S.imports??={};let t=!1;Object.entries(e).forEach(([e,n])=>{let r=e.replace(`@`,`#`),i=n.startsWith(`.`)?n:`./${n}`;S.imports[r]||(S.imports[r]=i,t=!0)}),t&&(await o(v,b,JSON.stringify(S,null,2)),p(`${m} Updated ${f(b)} to include Intlayer imports`))}}}p(`${m} ${d(`Intlayer init setup complete.`,u.GREEN)}`),p([d(`Next →`,u.MAGENTA),d(`Follow the instructions in the documentation to complete the setup:`,u.GREY_LIGHT),f(C)])};export{b as initIntlayer};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{readAsset as e}from"../_virtual/_utils_asset.mjs";import{
|
|
1
|
+
import{readAsset as e}from"../_virtual/_utils_asset.mjs";import{writeFile as t}from"node:fs/promises";import{join as n,relative as r}from"node:path";import{colorizePath as i,logger as a,v as o}from"@intlayer/config/logger";import{searchConfigurationFile as s}from"@intlayer/config/node";const c=process.cwd(),l=async(e,r)=>await t(n(c,e),r,`utf8`),u=e=>{switch(e){case`ts`:return`./templates/ts.txt`;case`cjs`:return`./templates/cjs.txt`;case`mjs`:return`./templates/mjs.txt`;case`js`:return`./templates/mjs.txt`;case`json`:return`./templates/json.txt`;default:return`./templates/ts.txt`}},d=async(t,n)=>{let{configurationFilePath:c}=s(n);if(c){a(`${o} ${i(r(n,c))} already exists`);return}await l(t,e(u(t.split(`.`).pop()))),a(`Created ${t}`)};export{d as initConfig};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listDictionariesPath.mjs","names":[],"sources":["../../src/listDictionariesPath.ts"],"sourcesContent":["import { stat } from 'node:fs/promises';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\n\n/**\n * List all dictionaries absolute paths in the project\n * @param configuration - The configuration object\n * @returns An array of dictionary paths\n */\nexport const listDictionaries = async (\n configuration: IntlayerConfig\n): Promise<string[]> => {\n const { watchedFilesPatternWithPath, excludedPath } = configuration.content;\n\n const filePromises = watchedFilesPatternWithPath.map(async (pattern) => {\n // Identify the static part of the path (before any wildcards like *)\n // e.g. \"/Users/.../design-system/dist/esm/**/*.content.ts\" -> \"/Users/.../design-system/dist/esm/\"\n const magicIndex = pattern.search(/[*?{}(]/);\n const basePattern =\n magicIndex > -1 ? pattern.slice(0, magicIndex) : pattern;\n\n // Filter the global ignored list for this specific pattern\n const applicableIgnore = excludedPath.filter((excludePattern) => {\n // Heuristic: Extract the key directory name from the glob\n // e.g. \"**/dist/**\" -> \"dist\", \"**/node_modules/**\" -> \"node_modules\"\n const cleanName = excludePattern.replace(/\\*\\*/g, '').replace(/\\//g, '');\n\n // If the explicit base path contains the excluded directory (e.g. \".../dist/...\"),\n // we assume you explicitly want it, so we REMOVE it from the ignore list.\n // We check for `/${cleanName}/` to ensure we match whole folder names.\n if (cleanName && basePattern.includes(`/${cleanName}/`)) {\n return false; // Drop this exclude rule\n }\n\n return true; // Keep this exclude rule\n });\n\n // Run fast-glob with the customized ignore list\n return fg(pattern, {\n ignore: applicableIgnore,\n absolute: true,\n dot: true,\n });\n });\n\n const filesArrays = await Promise.all(filePromises);\n\n // Flatten and deduplicate\n const uniqueFiles = Array.from(new Set(filesArrays.flat()));\n\n return uniqueFiles;\n};\n\nexport const listDictionariesWithStats = async (\n configuration: IntlayerConfig\n) => {\n const files = await listDictionaries(configuration);\n\n return Promise.all(\n files.map(async (file) => ({ path: file, stats: await stat(file) }))\n );\n};\n"],"mappings":"iEASA,MAAa,EAAmB,KAC9B,IACsB,CACtB,GAAM,CAAE,8BAA6B,gBAAiB,EAAc,QAE9D,EAAe,EAA4B,IAAI,KAAO,IAAY,CAGtE,IAAM,EAAa,EAAQ,OAAO,UAAU,CACtC,EACJ,EAAa,GAAK,EAAQ,MAAM,EAAG,EAAW,CAAG,EAmBnD,OAAO,EAAG,EAAS,CACjB,OAjBuB,EAAa,OAAQ,GAAmB,CAG/D,IAAM,EAAY,EAAe,QAAQ,QAAS,GAAG,CAAC,QAAQ,MAAO,GAAG,CASxE,MAJA,EAAI,GAAa,EAAY,SAAS,IAAI,EAAU,GAAG,GAKvD,CAKA,SAAU,GACV,IAAK,GACN,CAAC,EACF,CAEI,EAAc,MAAM,QAAQ,IAAI,EAAa,CAKnD,OAFoB,MAAM,KAAK,IAAI,IAAI,EAAY,MAAM,CAAC,CAAC,EAKhD,EAA4B,KACvC,IACG,CACH,IAAM,EAAQ,MAAM,EAAiB,EAAc,CAEnD,OAAO,QAAQ,IACb,EAAM,IAAI,KAAO,KAAU,CAAE,KAAM,EAAM,MAAO,MAAM,EAAK,EAAK,CAAE,EAAE,CACrE"}
|
|
1
|
+
{"version":3,"file":"listDictionariesPath.mjs","names":[],"sources":["../../src/listDictionariesPath.ts"],"sourcesContent":["import { stat } from 'node:fs/promises';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport fg from 'fast-glob';\n\n/**\n * List all dictionaries absolute paths in the project\n * @param configuration - The configuration object\n * @returns An array of dictionary paths\n */\nexport const listDictionaries = async (\n configuration: IntlayerConfig\n): Promise<string[]> => {\n const { watchedFilesPatternWithPath, excludedPath } = configuration.content;\n\n const filePromises = watchedFilesPatternWithPath.map(async (pattern) => {\n // Identify the static part of the path (before any wildcards like *)\n // e.g. \"/Users/.../design-system/dist/esm/**/*.content.ts\" -> \"/Users/.../design-system/dist/esm/\"\n const magicIndex = pattern.search(/[*?{}(]/);\n const basePattern =\n magicIndex > -1 ? pattern.slice(0, magicIndex) : pattern;\n\n // Filter the global ignored list for this specific pattern\n const applicableIgnore = excludedPath.filter((excludePattern) => {\n // Heuristic: Extract the key directory name from the glob\n // e.g. \"**/dist/**\" -> \"dist\", \"**/node_modules/**\" -> \"node_modules\"\n const cleanName = excludePattern.replace(/\\*\\*/g, '').replace(/\\//g, '');\n\n // If the explicit base path contains the excluded directory (e.g. \".../dist/...\"),\n // we assume you explicitly want it, so we REMOVE it from the ignore list.\n // We check for `/${cleanName}/` to ensure we match whole folder names.\n if (cleanName && basePattern.includes(`/${cleanName}/`)) {\n return false; // Drop this exclude rule\n }\n\n return true; // Keep this exclude rule\n });\n\n // Run fast-glob with the customized ignore list\n return fg(pattern, {\n ignore: applicableIgnore,\n absolute: true,\n dot: true,\n });\n });\n\n const filesArrays = await Promise.all(filePromises);\n\n // Flatten and deduplicate\n const uniqueFiles = Array.from(new Set(filesArrays.flat()));\n\n return uniqueFiles;\n};\n\nexport const listDictionariesWithStats = async (\n configuration: IntlayerConfig\n) => {\n const files = await listDictionaries(configuration);\n\n return Promise.all(\n files.map(async (file) => ({ path: file, stats: await stat(file) }))\n );\n};\n"],"mappings":"iEASA,MAAa,EAAmB,KAC9B,IACsB,CACtB,GAAM,CAAE,8BAA6B,gBAAiB,EAAc,QAE9D,EAAe,EAA4B,IAAI,KAAO,IAAY,CAGtE,IAAM,EAAa,EAAQ,OAAO,UAAU,CACtC,EACJ,EAAa,GAAK,EAAQ,MAAM,EAAG,EAAW,CAAG,EAmBnD,OAAO,EAAG,EAAS,CACjB,OAjBuB,EAAa,OAAQ,GAAmB,CAG/D,IAAM,EAAY,EAAe,QAAQ,QAAS,GAAG,CAAC,QAAQ,MAAO,GAAG,CASxE,MAJA,EAAI,GAAa,EAAY,SAAS,IAAI,EAAU,GAAG,GAKvD,CAKA,SAAU,GACV,IAAK,GACN,CAAC,EACF,CAEI,EAAc,MAAM,QAAQ,IAAI,EAAa,CAKnD,OAFoB,MAAM,KAAK,IAAI,IAAI,EAAY,MAAM,CAAC,CAAC,EAKhD,EAA4B,KACvC,IACG,CACH,IAAM,EAAQ,MAAM,EAAiB,EAAc,CAEnD,OAAO,QAAQ,IACb,EAAM,IAAI,KAAO,KAAU,CAAE,KAAM,EAAM,MAAO,MAAM,EAAK,EAAK,CAAE,EAAE,CACrE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{join as e}from"node:path";import{getAppLogger as t}from"@intlayer/config/logger";import{readFileSync as n}from"node:fs";import r from"
|
|
1
|
+
import{join as e}from"node:path";import{getAppLogger as t}from"@intlayer/config/logger";import{readFileSync as n}from"node:fs";import r from"simple-git";import i from"@intlayer/config/built";const a=async()=>{try{return(await r().revparse([`--show-toplevel`])).trim()}catch(e){return t(i)(`Error getting git root directory: ${e}`,{level:`error`}),null}},o=async({mode:t,baseRef:n=`origin/main`,currentRef:i=`HEAD`,absolute:o=!0})=>{try{let s=r(),c=new Set;if(t.includes(`untracked`)&&(await s.status()).not_added.forEach(e=>{c.add(e)}),t.includes(`uncommitted`)&&(await s.diff([`--name-only`,`HEAD`])).split(`
|
|
2
2
|
`).filter(Boolean).forEach(e=>{c.add(e)}),t.includes(`unpushed`)&&(await s.diff([`--name-only`,`@{push}...HEAD`])).split(`
|
|
3
|
-
`).filter(Boolean).forEach(e=>{c.add(e)}),t.includes(`gitDiff`)&&(await s.fetch(n),(await s.diff([`--name-only`,`${n}...${
|
|
4
|
-
`).filter(Boolean).forEach(e=>{c.add(e)})),o){let t=await a();return t?Array.from(c).map(n=>e(t,n)):[]}return Array.from(c)}catch(e){console.warn(`Failed to get changes list:`,e)}},s=async(e,{mode:t,baseRef:
|
|
5
|
-
`).forEach((e,t)=>{s.add(t+1)})}catch{}return t.includes(`uncommitted`)&&c(await o.diff([`--unified=0`,`HEAD`,`--`,e])),t.includes(`unpushed`)&&c(await o.diff([`--unified=0`,`@{push}...HEAD`,`--`,e])),t.includes(`gitDiff`)&&(await o.fetch(
|
|
3
|
+
`).filter(Boolean).forEach(e=>{c.add(e)}),t.includes(`gitDiff`)&&(await s.fetch(n),(await s.diff([`--name-only`,`${n}...${i}`])).split(`
|
|
4
|
+
`).filter(Boolean).forEach(e=>{c.add(e)})),o){let t=await a();return t?Array.from(c).map(n=>e(t,n)):[]}return Array.from(c)}catch(e){console.warn(`Failed to get changes list:`,e)}},s=async(e,{mode:t,baseRef:i=`origin/main`,currentRef:a=`HEAD`})=>{let o=r(),s=new Set,c=e=>{let t=/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/g,n;for(;(n=t.exec(e))!==null;){let e=n[2]?Number(n[2]):1,t=Number(n[3]),r=n[4]?Number(n[4]):1;if(r>0)for(let e=0;e<r;e++)s.add(t+e);e>0&&r===0&&(t>1&&s.add(t-1),s.add(t))}};if(t.includes(`untracked`)&&(await o.status()).not_added.includes(e))try{n(e,`utf-8`).split(`
|
|
5
|
+
`).forEach((e,t)=>{s.add(t+1)})}catch{}return t.includes(`uncommitted`)&&c(await o.diff([`--unified=0`,`HEAD`,`--`,e])),t.includes(`unpushed`)&&c(await o.diff([`--unified=0`,`@{push}...HEAD`,`--`,e])),t.includes(`gitDiff`)&&(await o.fetch(i),c(await o.diff([`--unified=0`,`${i}...${a}`,`--`,e]))),Array.from(s).sort((e,t)=>e-t)};export{o as listGitFiles,s as listGitLines};
|
|
6
6
|
//# sourceMappingURL=listGitFiles.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{dirname as e}from"node:path";import t from"fast-glob";import{configurationFilesCandidates as n}from"@intlayer/config/node";import r from"simple-git";const i=async e=>{try{return(await(e?r(e):r()).revparse([`--show-toplevel`])).trim()}catch{return null}},a=async r=>{let a=r?.baseDir??process.cwd();if(r?.gitRoot){let e=await i(a);e&&(a=e)}let o=await t(n.map(e=>`**/${e}`),{cwd:a,absolute:!0,ignore:[`**/node_modules/**`,`**/.git/**`],dot:!0}),s=[...new Set(o.map(t=>e(t)))];return{searchDir:a,projectsPath:s.sort()}};export{a as listProjects};
|
|
2
2
|
//# sourceMappingURL=listProjects.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__require as e}from"../_virtual/_rolldown/runtime.mjs";import{readFile as t}from"node:fs/promises";import{join as n}from"node:path";import{configESMxCJSRequire as r,getProjectRequire as i,isESModule as a}from"@intlayer/config/utils";import{bundleFile as o}from"@intlayer/config/file";import{builtinModules as s,createRequire as c}from"node:module";const l=(e,t)=>({name:`rewrite-paths`,setup(n){n.onResolve({filter:/.*/},n=>{let r=e[n.path];if(t?.includes(n.path))return null;if(r)return{path:r,namespace:`intlayer-replace-modules`,external:!0};for(let t of Object.keys(e))if(n.path===t||n.path.startsWith(`${t}/`)){let r=n.path.slice(t.length);return{path:e[t]+r,namespace:`intlayer-replace-modules`,external:!0}}})}}),u=async u=>{let d=i(u.
|
|
1
|
+
import{__require as e}from"../_virtual/_rolldown/runtime.mjs";import{readFile as t}from"node:fs/promises";import{join as n}from"node:path";import{configESMxCJSRequire as r,getProjectRequire as i,isESModule as a}from"@intlayer/config/utils";import{bundleFile as o}from"@intlayer/config/file";import{builtinModules as s,createRequire as c}from"node:module";const l=(e,t)=>({name:`rewrite-paths`,setup(n){n.onResolve({filter:/.*/},n=>{let r=e[n.path];if(t?.includes(n.path))return null;if(r)return{path:r,namespace:`intlayer-replace-modules`,external:!0};for(let t of Object.keys(e))if(n.path===t||n.path.startsWith(`${t}/`)){let r=n.path.slice(t.length);return{path:e[t]+r,namespace:`intlayer-replace-modules`,external:!0}}})}}),u=async u=>{let d=i(u.system.baseDir),f=r,p=a?c(import.meta.url):e,m=n(u.system.configDir,`configuration.json`),h={defu:f.resolve(`defu`),esbuild:f.resolve(`esbuild`),"@intlayer/config/built":m,"@intlayer/config/utils":p.resolve(`@intlayer/config/utils`),"@intlayer/config/client":p.resolve(`@intlayer/config/client`),"@intlayer/config/logger":p.resolve(`@intlayer/config/logger`),"@intlayer/core/file":p.resolve(`@intlayer/core/file`)},g=d.resolve(`intlayer`);return await o(await t(g,`utf-8`),g,{external:[...s,...s.map(e=>`node:${e}`)],minify:!0,plugins:[l(h)]})??``};export{u as getIntlayerBundle};
|
|
2
2
|
//# sourceMappingURL=getIntlayerBundle.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIntlayerBundle.mjs","names":[],"sources":["../../../src/loadDictionaries/getIntlayerBundle.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { builtinModules, createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { bundleFile, type ESBuildPlugin } from '@intlayer/config/file';\nimport {\n configESMxCJSRequire,\n getProjectRequire,\n isESModule,\n} from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types';\n\n/**\n * Rewrites selected bare specifiers (and any of their subpaths) to absolute file paths,\n * using the provided localeRequire (either createRequire(import.meta.url) or require).\n *\n * Example:\n * rewritePathsPlugin([\"@intlayer/config\", \"@intlayer/core\"], localeRequire)\n * …will also rewrite \"@intlayer/core/file\" etc.\n */\nconst rewritePathsPlugin = (\n replaceModules: Record<string, string>,\n excludeModules?: string[]\n): ESBuildPlugin => {\n return {\n name: 'rewrite-paths',\n setup(build) {\n build.onResolve({ filter: /.*/ }, (args) => {\n const exact = replaceModules[args.path];\n\n if (excludeModules?.includes(args.path)) {\n return null;\n }\n\n if (exact) {\n return {\n path: exact,\n namespace: 'intlayer-replace-modules',\n external: true, // ← prevents onLoad requirement\n };\n }\n\n // Optional: support subpaths like \"@intlayer/core/xyz\"\n for (const key of Object.keys(replaceModules)) {\n if (args.path === key || args.path.startsWith(`${key}/`)) {\n const sub = args.path.slice(key.length); // '' or '/...'\n return {\n path: replaceModules[key] + sub,\n namespace: 'intlayer-replace-modules',\n external: true, // ← prevents onLoad requirement\n };\n }\n }\n });\n },\n };\n};\n\n/**\n * Get the intlayer bundle to embed @intlayer/core and be able to mock @intlayer/config/built to mock the configuration file.\n */\nexport const getIntlayerBundle = async (configuration: IntlayerConfig) => {\n const rootRequire = getProjectRequire(configuration.
|
|
1
|
+
{"version":3,"file":"getIntlayerBundle.mjs","names":[],"sources":["../../../src/loadDictionaries/getIntlayerBundle.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { builtinModules, createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { bundleFile, type ESBuildPlugin } from '@intlayer/config/file';\nimport {\n configESMxCJSRequire,\n getProjectRequire,\n isESModule,\n} from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Rewrites selected bare specifiers (and any of their subpaths) to absolute file paths,\n * using the provided localeRequire (either createRequire(import.meta.url) or require).\n *\n * Example:\n * rewritePathsPlugin([\"@intlayer/config\", \"@intlayer/core\"], localeRequire)\n * …will also rewrite \"@intlayer/core/file\" etc.\n */\nconst rewritePathsPlugin = (\n replaceModules: Record<string, string>,\n excludeModules?: string[]\n): ESBuildPlugin => {\n return {\n name: 'rewrite-paths',\n setup(build) {\n build.onResolve({ filter: /.*/ }, (args) => {\n const exact = replaceModules[args.path];\n\n if (excludeModules?.includes(args.path)) {\n return null;\n }\n\n if (exact) {\n return {\n path: exact,\n namespace: 'intlayer-replace-modules',\n external: true, // ← prevents onLoad requirement\n };\n }\n\n // Optional: support subpaths like \"@intlayer/core/xyz\"\n for (const key of Object.keys(replaceModules)) {\n if (args.path === key || args.path.startsWith(`${key}/`)) {\n const sub = args.path.slice(key.length); // '' or '/...'\n return {\n path: replaceModules[key] + sub,\n namespace: 'intlayer-replace-modules',\n external: true, // ← prevents onLoad requirement\n };\n }\n }\n });\n },\n };\n};\n\n/**\n * Get the intlayer bundle to embed @intlayer/core and be able to mock @intlayer/config/built to mock the configuration file.\n */\nexport const getIntlayerBundle = async (configuration: IntlayerConfig) => {\n const rootRequire = getProjectRequire(configuration.system.baseDir);\n const configPackageRequire = configESMxCJSRequire;\n const localRequire = isESModule ? createRequire(import.meta.url) : require;\n\n const configurationPath = join(\n configuration.system.configDir,\n `configuration.json`\n );\n\n const replaceModules = {\n defu: configPackageRequire.resolve('defu'),\n esbuild: configPackageRequire.resolve('esbuild'),\n '@intlayer/config/built': configurationPath,\n '@intlayer/config/utils': localRequire.resolve('@intlayer/config/utils'),\n '@intlayer/config/client': localRequire.resolve('@intlayer/config/client'),\n '@intlayer/config/logger': localRequire.resolve('@intlayer/config/logger'),\n '@intlayer/core/file': localRequire.resolve('@intlayer/core/file'),\n };\n\n const filePath = rootRequire.resolve('intlayer');\n const code = await readFile(filePath, 'utf-8');\n\n const output = await bundleFile(code, filePath, {\n external: [\n ...builtinModules,\n ...builtinModules.map((mod) => `node:${mod}`),\n ],\n minify: true,\n plugins: [rewritePathsPlugin(replaceModules)],\n });\n\n return output ?? '';\n};\n"],"mappings":"mWAmBA,MAAM,GACJ,EACA,KAEO,CACL,KAAM,gBACN,MAAM,EAAO,CACX,EAAM,UAAU,CAAE,OAAQ,KAAM,CAAG,GAAS,CAC1C,IAAM,EAAQ,EAAe,EAAK,MAElC,GAAI,GAAgB,SAAS,EAAK,KAAK,CACrC,OAAO,KAGT,GAAI,EACF,MAAO,CACL,KAAM,EACN,UAAW,2BACX,SAAU,GACX,CAIH,IAAK,IAAM,KAAO,OAAO,KAAK,EAAe,CAC3C,GAAI,EAAK,OAAS,GAAO,EAAK,KAAK,WAAW,GAAG,EAAI,GAAG,CAAE,CACxD,IAAM,EAAM,EAAK,KAAK,MAAM,EAAI,OAAO,CACvC,MAAO,CACL,KAAM,EAAe,GAAO,EAC5B,UAAW,2BACX,SAAU,GACX,GAGL,EAEL,EAMU,EAAoB,KAAO,IAAkC,CACxE,IAAM,EAAc,EAAkB,EAAc,OAAO,QAAQ,CAC7D,EAAuB,EACvB,EAAe,EAAa,EAAc,OAAO,KAAK,IAAI,CAAA,EAE1D,EAAoB,EACxB,EAAc,OAAO,UACrB,qBACD,CAEK,EAAiB,CACrB,KAAM,EAAqB,QAAQ,OAAO,CAC1C,QAAS,EAAqB,QAAQ,UAAU,CAChD,yBAA0B,EAC1B,yBAA0B,EAAa,QAAQ,yBAAyB,CACxE,0BAA2B,EAAa,QAAQ,0BAA0B,CAC1E,0BAA2B,EAAa,QAAQ,0BAA0B,CAC1E,sBAAuB,EAAa,QAAQ,sBAAsB,CACnE,CAEK,EAAW,EAAY,QAAQ,WAAW,CAYhD,OATe,MAAM,EAFR,MAAM,EAAS,EAAU,QAAQ,CAER,EAAU,CAC9C,SAAU,CACR,GAAG,EACH,GAAG,EAAe,IAAK,GAAQ,QAAQ,IAAM,CAC9C,CACD,OAAQ,GACR,QAAS,CAAC,EAAmB,EAAe,CAAC,CAC9C,CAAC,EAEe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ensureIntlayerBundle as e,formatLocalDictionaries as t,loadContentDeclaration as n,loadContentDeclarations as r}from"./loadContentDeclaration.mjs";import{loadLocalDictionaries as i}from"./loadLocalDictionaries.mjs";import{formatDistantDictionaries as a,loadRemoteDictionaries as o}from"./loadRemoteDictionaries.mjs";import{loadDictionaries as s}from"./loadDictionaries.mjs";export{e as ensureIntlayerBundle,a as formatDistantDictionaries,t as formatLocalDictionaries,n as loadContentDeclaration,r as loadContentDeclarations,s as loadDictionaries,i as loadLocalDictionaries,o as loadRemoteDictionaries};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{parallelize as e}from"../utils/parallelize.mjs";import{filterInvalidDictionaries as t}from"../filterInvalidDictionaries.mjs";import{processContentDeclaration as n}from"../buildIntlayerDictionary/processContentDeclaration.mjs";import{getIntlayerBundle as r}from"./getIntlayerBundle.mjs";import{logTypeScriptErrors as i}from"./logTypeScriptErrors.mjs";import{writeFile as a}from"node:fs/promises";import{join as o,relative as s}from"node:path";import{cacheDisk as c,getProjectRequire as l}from"@intlayer/config/utils";import{loadExternalFile as u}from"@intlayer/config/file";const d=(e,t)=>Object.entries(e).map(([e,n])=>({...n,location:n.location??t.dictionary?.location??`local`,localId:`${n.key}::local::${e}`,filePath:e})),f=async
|
|
2
|
-
`)}},aliases:{intlayer:
|
|
1
|
+
import{parallelize as e}from"../utils/parallelize.mjs";import{filterInvalidDictionaries as t}from"../filterInvalidDictionaries.mjs";import{processContentDeclaration as n}from"../buildIntlayerDictionary/processContentDeclaration.mjs";import{getIntlayerBundle as r}from"./getIntlayerBundle.mjs";import{logTypeScriptErrors as i}from"./logTypeScriptErrors.mjs";import{writeFile as a}from"node:fs/promises";import{join as o,relative as s}from"node:path";import{cacheDisk as c,getProjectRequire as l}from"@intlayer/config/utils";import{loadExternalFile as u}from"@intlayer/config/file";const d=(e,t)=>Object.entries(e).map(([e,n])=>({...n,location:n.location??t.dictionary?.location??`local`,localId:`${n.key}::local::${e}`,filePath:e})),f=async e=>{let{system:t}=e,{set:n,isValid:i}=c(e,[`intlayer-bundle`],{ttlMs:1e3*60*60*24*5}),s=o(t.cacheDir,`intlayer-bundle.cjs`);return await i()||(await a(s,await r(e)),await n(`ok`)),s},p=async(e,t,n)=>{let{build:r}=t,i=n??await f(t);try{return await u(e,{projectRequire:r.require??l(),buildOptions:{banner:{js:[`globalThis.INTLAYER_FILE_PATH = '${e}';`,`globalThis.INTLAYER_BASE_DIR = '${t.system.baseDir}';`].join(`
|
|
2
|
+
`)}},aliases:{intlayer:i}})}catch(t){console.error(`Error loading content declaration at ${e}:`,t);return}},m=async(r,a,o)=>{let{build:c,system:l}=a;c.checkTypes&&i(r,a).catch(e=>{console.error(`Error during TypeScript validation:`,e)});let u=await f(a);try{let i=r.map(async e=>({relativePath:s(a.system.baseDir,e),dictionary:await p(e,a,u)})),c=d((await Promise.all(i)).reduce((e,{relativePath:t,dictionary:n})=>(n&&(e[t]=n),e),{}),a).filter(e=>e.location!==`remote`),l=c.map(e=>({dictionaryKey:e.key,type:`local`,status:`found`}));return o?.(l),t(await e(c,async e=>{if(!e)return;o?.([{dictionaryKey:e.key,type:`local`,status:`building`}]);let t=await n(e,a);if(t)return o?.([{dictionaryKey:t.key,type:`local`,status:`built`}]),t}),a,{checkSchema:!1})}catch{console.error(`Error loading content declarations`)}return[]};export{f as ensureIntlayerBundle,d as formatLocalDictionaries,p as loadContentDeclaration,m as loadContentDeclarations};
|
|
3
3
|
//# sourceMappingURL=loadContentDeclaration.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadContentDeclaration.mjs","names":[],"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport { loadExternalFile } from '@intlayer/config/file';\nimport { cacheDisk, getProjectRequire } from '@intlayer/config/utils';\nimport type {
|
|
1
|
+
{"version":3,"file":"loadContentDeclaration.mjs","names":[],"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport { loadExternalFile } from '@intlayer/config/file';\nimport { cacheDisk, getProjectRequire } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { processContentDeclaration } from '../buildIntlayerDictionary/processContentDeclaration';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { getIntlayerBundle } from './getIntlayerBundle';\nimport type { DictionariesStatus } from './loadDictionaries';\nimport { logTypeScriptErrors } from './logTypeScriptErrors';\n\nexport const formatLocalDictionaries = (\n dictionariesRecord: Record<string, Dictionary>,\n configuration: IntlayerConfig\n): Dictionary[] =>\n Object.entries(dictionariesRecord).map(([relativePath, dict]) => ({\n ...dict,\n location: dict.location ?? configuration.dictionary?.location ?? 'local',\n localId: `${dict.key}::local::${relativePath}`,\n filePath: relativePath,\n }));\n\nexport const ensureIntlayerBundle = async (\n configuration: IntlayerConfig\n): Promise<string> => {\n const { system } = configuration;\n\n const { set, isValid } = cacheDisk(configuration, ['intlayer-bundle'], {\n ttlMs: 1000 * 60 * 60 * 24 * 5, // 5 days\n });\n\n const filePath = join(system.cacheDir, 'intlayer-bundle.cjs');\n const hasIntlayerBundle = await isValid();\n\n if (!hasIntlayerBundle) {\n const intlayerBundle = await getIntlayerBundle(configuration);\n await writeFile(filePath, intlayerBundle);\n await set('ok');\n }\n\n return filePath;\n};\n\nexport const loadContentDeclaration = async (\n path: string,\n configuration: IntlayerConfig,\n bundleFilePath?: string\n): Promise<Dictionary | undefined> => {\n const { build } = configuration;\n\n const resolvedBundleFilePath =\n bundleFilePath ?? (await ensureIntlayerBundle(configuration));\n\n try {\n const dictionary = await loadExternalFile(path, {\n projectRequire: build.require ?? getProjectRequire(),\n buildOptions: {\n banner: {\n js: [\n `globalThis.INTLAYER_FILE_PATH = '${path}';`,\n `globalThis.INTLAYER_BASE_DIR = '${configuration.system.baseDir}';`,\n ].join('\\n'),\n },\n },\n aliases: {\n intlayer: resolvedBundleFilePath,\n },\n });\n\n return dictionary;\n } catch (error) {\n console.error(`Error loading content declaration at ${path}:`, error);\n return undefined;\n }\n};\n\nexport const loadContentDeclarations = async (\n contentDeclarationFilePath: string[],\n configuration: IntlayerConfig,\n onStatusUpdate?: (status: DictionariesStatus[]) => void\n): Promise<Dictionary[]> => {\n const { build, system } = configuration;\n\n // Check for TypeScript warnings before we build\n if (build.checkTypes) {\n logTypeScriptErrors(contentDeclarationFilePath, configuration).catch(\n (e) => {\n console.error('Error during TypeScript validation:', e);\n }\n );\n }\n\n const bundleFilePath = await ensureIntlayerBundle(configuration);\n\n try {\n const dictionariesPromises = contentDeclarationFilePath.map(\n async (path) => {\n const relativePath = relative(configuration.system.baseDir, path);\n\n const dictionary = await loadContentDeclaration(\n path,\n configuration,\n bundleFilePath\n );\n\n return { relativePath, dictionary };\n }\n );\n\n const dictionariesArray = await Promise.all(dictionariesPromises);\n const dictionariesRecord = dictionariesArray.reduce(\n (acc, { relativePath, dictionary }) => {\n if (dictionary) {\n acc[relativePath] = dictionary;\n }\n return acc;\n },\n {} as Record<string, Dictionary>\n );\n\n const contentDeclarations: Dictionary[] = formatLocalDictionaries(\n dictionariesRecord,\n configuration\n ).filter((dictionary) => dictionary.location !== 'remote');\n\n const listFoundDictionaries = contentDeclarations.map((declaration) => ({\n dictionaryKey: declaration.key,\n type: 'local' as const,\n status: 'found' as const,\n }));\n\n onStatusUpdate?.(listFoundDictionaries);\n\n const processedDictionaries = await parallelize(\n contentDeclarations,\n async (contentDeclaration): Promise<Dictionary | undefined> => {\n if (!contentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: contentDeclaration.key,\n type: 'local',\n status: 'building',\n },\n ]);\n\n const processedContentDeclaration = await processContentDeclaration(\n contentDeclaration as Dictionary,\n configuration\n );\n\n if (!processedContentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: processedContentDeclaration.key,\n type: 'local',\n status: 'built',\n },\n ]);\n\n return processedContentDeclaration;\n }\n );\n\n return filterInvalidDictionaries(processedDictionaries, configuration, {\n checkSchema: false,\n });\n } catch {\n console.error('Error loading content declarations');\n }\n\n return [];\n};\n"],"mappings":"okBAaA,MAAa,GACX,EACA,IAEA,OAAO,QAAQ,EAAmB,CAAC,KAAK,CAAC,EAAc,MAAW,CAChE,GAAG,EACH,SAAU,EAAK,UAAY,EAAc,YAAY,UAAY,QACjE,QAAS,GAAG,EAAK,IAAI,WAAW,IAChC,SAAU,EACX,EAAE,CAEQ,EAAuB,KAClC,IACoB,CACpB,GAAM,CAAE,UAAW,EAEb,CAAE,MAAK,WAAY,EAAU,EAAe,CAAC,kBAAkB,CAAE,CACrE,MAAO,IAAO,GAAK,GAAK,GAA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C,EACA,KAAO,IAAwD,CAC7D,GAAI,CAAC,EACH,OAGF,IAAiB,CACf,CACE,cAAe,EAAmB,IAClC,KAAM,QACN,OAAQ,WACT,CACF,CAAC,CAEF,IAAM,EAA8B,MAAM,EACxC,EACA,EACD,CAEI,KAYL,OARA,IAAiB,CACf,CACE,cAAe,EAA4B,IAC3C,KAAM,QACN,OAAQ,QACT,CACF,CAAC,CAEK,GAEV,CAEuD,EAAe,CACrE,YAAa,GACd,CAAC,MACI,CACN,QAAQ,MAAM,qCAAqC,CAGrD,MAAO,EAAE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{filterInvalidDictionaries as e}from"../filterInvalidDictionaries.mjs";import{
|
|
1
|
+
import{filterInvalidDictionaries as e}from"../filterInvalidDictionaries.mjs";import{loadContentDeclarations as t}from"./loadContentDeclaration.mjs";import{formatDictionaries as n}from"../formatDictionary.mjs";import{loadRemoteDictionaries as r}from"./loadRemoteDictionaries.mjs";import{DictionariesLogger as i}from"./log.mjs";import{ANSIColors as a,colon as o,colorize as s,colorizeKey as c,getAppLogger as l}from"@intlayer/config/logger";let u=[];const d=new i,f=e=>{let t=[...u];for(let n of e){let e=t.findIndex(e=>e.dictionaryKey===n.dictionaryKey&&e.type===n.type);e>=0?t[e]=n:t.push(n)}return u=t,d.update(e),t},p=e=>{switch(e){case`built`:case`imported`:case`fetched`:return`✔`;case`error`:return`✖`;default:return`⏲`}},m=e=>{switch(e){case`built`:case`imported`:case`fetched`:return a.GREEN;case`error`:return a.RED;default:return a.BLUE}},h=e=>{if(e.log.mode!==`verbose`)return;let t=l(e),n=new Map;for(let e of u){let t=n.get(e.dictionaryKey)??{};e.type===`local`&&(t.local=e.status),e.type===`remote`&&(t.remote=e.status),n.set(e.dictionaryKey,t)}let r=Array.from(n.keys()).sort((e,t)=>e.localeCompare(t)),i=0;for(let e of r){let t=n.get(e);if(t.local){let e=`[local: ${p(t.local)} ${t.local}]`;e.length>i&&(i=e.length)}}for(let e of r){let l=n.get(e),u=[];if(l.local){let e=s(`${p(l.local)} ${l.local}`,m(l.local)),t=`${a.GREY}[`+s(`local: `,a.GREY)+e+`${a.GREY}]${a.RESET}`,n=`[local: ${p(l.local)} ${l.local}]`,r=Math.max(0,i-n.length);u.push(t+` `.repeat(r))}else u.push(` `.repeat(i));if(l.remote){let e=s(`${p(l.remote)} ${l.remote}`,m(l.remote));u.push(`${a.GREY}[`+s(`distant: `,a.GREY)+e+`${a.GREY}]${a.RESET}`)}t(` - ${o(c(e),{colSize:r})} ${u.join(` `)}`)}},g=async(i,a)=>{let{plugins:o}=a,s=Date.now();l(a)(`Dictionaries:`,{isVerbose:!0});let c=(o??[]).filter(e=>e.loadDictionaries).map(async e=>{try{return await e.loadDictionaries?.({configuration:a})??[]}catch(e){return d.setPluginError(e),[]}}),u=await Promise.all(c).then(e=>e.flat()).then(t=>e(t,a)).then(e=>n(e));d.setPluginTotal(u.length),d.setPluginDone(u.length);let p=Date.now(),m=await t(Array.isArray(i)?i:[i],a,f).then(t=>e(t,a)).then(e=>n(e)),g=Date.now();f(m.map(e=>({dictionaryKey:e.key,type:`local`,status:`built`})));let _=!!(a.editor.clientId&&a.editor.clientSecret);_&&d.setExpectRemote(!0);let v=[];_&&(v=await r(a,f,{onStartRemoteCheck:()=>d.startRemoteCheck(),onStopRemoteCheck:()=>d.stopRemoteCheck(),onError:e=>d.setRemoteError(e)}).then(t=>e(t,a)).then(e=>n(e)));let y=Date.now();return d.finish(),h(a),{localDictionaries:m,remoteDictionaries:v,pluginDictionaries:u,time:{localDictionaries:g-p,remoteDictionaries:y-g,pluginDictionaries:p-s}}};export{g as loadDictionaries};
|
|
2
2
|
//# sourceMappingURL=loadDictionaries.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadDictionaries.mjs","names":["logger"],"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["import {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { formatDictionaries } from '../formatDictionary';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n const updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const index = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (index >= 0) {\n updated[index] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const status of loadDictionariesStatus) {\n const rec = byKey.get(status.dictionaryKey) ?? {};\n if (status.type === 'local') rec.local = status.status;\n if (status.type === 'remote') rec.remote = status.status;\n byKey.set(status.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n pluginDictionaries: Dictionary[];\n time: {\n localDictionaries: number;\n remoteDictionaries: number;\n pluginDictionaries: number;\n };\n}> => {\n const { plugins } = configuration;\n const loadDictionariesStartTime = Date.now();\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n // Load additional dictionaries via plugins (e.g., ICU JSON ingestion)\n const pluginsWithLoadDictionaries = (plugins ?? []).filter(\n (plugin) => plugin.loadDictionaries\n );\n\n const loadPluginDictionariesPromise = pluginsWithLoadDictionaries.map(\n async (plugin) => {\n try {\n const res = await plugin.loadDictionaries?.({\n configuration,\n });\n\n return (res as Dictionary[] | undefined) ?? [];\n } catch (error) {\n logger.setPluginError(error as Error);\n\n return [];\n }\n }\n );\n\n const pluginDictionaries: Dictionary[] = await Promise.all(\n loadPluginDictionariesPromise as Promise<Dictionary[]>[]\n )\n .then((dictionaries) => dictionaries.flat())\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n\n logger.setPluginTotal(pluginDictionaries.length);\n logger.setPluginDone(pluginDictionaries.length);\n\n const pluginDictionariesTime = Date.now();\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n setLoadDictionariesStatus\n )\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n\n const localDictionariesTime = Date.now();\n\n const localDictionariesStatus = localDictionaries.map(\n (dictionary) =>\n ({\n dictionaryKey: dictionary.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n if (hasRemoteDictionaries) {\n // We expect to fetch remote dictionaries soon; suppress a transient local-only render\n logger.setExpectRemote(true);\n }\n\n let remoteDictionaries: Dictionary[] = [];\n\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus,\n {\n onStartRemoteCheck: () => logger.startRemoteCheck(),\n onStopRemoteCheck: () => logger.stopRemoteCheck(),\n onError: (e) => logger.setRemoteError(e),\n }\n )\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n }\n\n const remoteDictionariesTime = Date.now();\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries,\n remoteDictionaries,\n pluginDictionaries,\n time: {\n localDictionaries: localDictionariesTime - pluginDictionariesTime,\n remoteDictionaries: remoteDictionariesTime - localDictionariesTime,\n pluginDictionaries: pluginDictionariesTime - loadDictionariesStartTime,\n },\n };\n};\n"],"mappings":"ubA6BA,IAAI,EAA+C,EAAE,CACrD,MAAMA,EAAS,IAAI,EAEb,EAA6B,GAAmC,CACpE,IAAM,EAAgC,CAAC,GAAG,EAAuB,CAEjE,IAAK,IAAM,KAAY,EAAU,CAC/B,IAAM,EAAQ,EAAQ,UACnB,GACC,EAAE,gBAAkB,EAAS,eAAiB,EAAE,OAAS,EAAS,KACrE,CACG,GAAS,EACX,EAAQ,GAAS,EAEjB,EAAQ,KAAK,EAAS,CAO1B,MAHA,GAAyB,EACzB,EAAO,OAAO,EAAS,CAEhB,GAQH,EAAW,GAAyC,CACxD,OAAQ,EAAR,CACE,IAAK,QACL,IAAK,WACL,IAAK,UACH,MAAO,IACT,IAAK,QACH,MAAO,IACT,QACE,MAAO,MAIP,EAAY,GAAyC,CACzD,OAAQ,EAAR,CACE,IAAK,QACL,IAAK,WACL,IAAK,UACH,OAAO,EAAW,MACpB,IAAK,QACH,OAAO,EAAW,IACpB,QACE,OAAO,EAAW,OAIlB,EAAgB,GAAkC,CACtD,GAAI,EAAc,IAAI,OAAS,UAAW,OAE1C,IAAM,EAAY,EAAa,EAAc,CAGvC,EAAQ,I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B,CACnD,sBAAyBA,EAAO,iBAAiB,CACjD,QAAU,GAAMA,EAAO,eAAe,EAAE,CACzC,CACF,CACE,KAAM,GACL,EAA0B,EAAc,EAAc,CACvD,CACA,KAAM,GAAiB,EAAmB,EAAa,CAAC,EAG7D,IAAM,EAAyB,KAAK,KAAK,CAOzC,OAJA,EAAO,QAAQ,CAEf,EAAa,EAAc,CAEpB,CACL,oBACA,qBACA,qBACA,KAAM,CACJ,kBAAmB,EAAwB,EAC3C,mBAAoB,EAAyB,EAC7C,mBAAoB,EAAyB,EAC9C,CACF"}
|
|
1
|
+
{"version":3,"file":"loadDictionaries.mjs","names":["logger"],"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["import {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { formatDictionaries } from '../formatDictionary';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n const updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const index = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (index >= 0) {\n updated[index] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const status of loadDictionariesStatus) {\n const rec = byKey.get(status.dictionaryKey) ?? {};\n if (status.type === 'local') rec.local = status.status;\n if (status.type === 'remote') rec.remote = status.status;\n byKey.set(status.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n pluginDictionaries: Dictionary[];\n time: {\n localDictionaries: number;\n remoteDictionaries: number;\n pluginDictionaries: number;\n };\n}> => {\n const { plugins } = configuration;\n const loadDictionariesStartTime = Date.now();\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n // Load additional dictionaries via plugins (e.g., ICU JSON ingestion)\n const pluginsWithLoadDictionaries = (plugins ?? []).filter(\n (plugin) => plugin.loadDictionaries\n );\n\n const loadPluginDictionariesPromise = pluginsWithLoadDictionaries.map(\n async (plugin) => {\n try {\n const res = await plugin.loadDictionaries?.({\n configuration,\n });\n\n return (res as Dictionary[] | undefined) ?? [];\n } catch (error) {\n logger.setPluginError(error as Error);\n\n return [];\n }\n }\n );\n\n const pluginDictionaries: Dictionary[] = await Promise.all(\n loadPluginDictionariesPromise as Promise<Dictionary[]>[]\n )\n .then((dictionaries) => dictionaries.flat())\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n\n logger.setPluginTotal(pluginDictionaries.length);\n logger.setPluginDone(pluginDictionaries.length);\n\n const pluginDictionariesTime = Date.now();\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n setLoadDictionariesStatus\n )\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n\n const localDictionariesTime = Date.now();\n\n const localDictionariesStatus = localDictionaries.map(\n (dictionary) =>\n ({\n dictionaryKey: dictionary.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n if (hasRemoteDictionaries) {\n // We expect to fetch remote dictionaries soon; suppress a transient local-only render\n logger.setExpectRemote(true);\n }\n\n let remoteDictionaries: Dictionary[] = [];\n\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus,\n {\n onStartRemoteCheck: () => logger.startRemoteCheck(),\n onStopRemoteCheck: () => logger.stopRemoteCheck(),\n onError: (e) => logger.setRemoteError(e),\n }\n )\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n }\n\n const remoteDictionariesTime = Date.now();\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries,\n remoteDictionaries,\n pluginDictionaries,\n time: {\n localDictionaries: localDictionariesTime - pluginDictionariesTime,\n remoteDictionaries: remoteDictionariesTime - localDictionariesTime,\n pluginDictionaries: pluginDictionariesTime - loadDictionariesStartTime,\n },\n };\n};\n"],"mappings":"ubA8BA,IAAI,EAA+C,EAAE,CACrD,MAAMA,EAAS,IAAI,EAEb,EAA6B,GAAmC,CACpE,IAAM,EAAgC,CAAC,GAAG,EAAuB,CAEjE,IAAK,IAAM,KAAY,EAAU,CAC/B,IAAM,EAAQ,EAAQ,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,CAChD,EAAO,cAAc,EAAmB,OAAO,CAE/C,IAAM,EAAyB,KAAK,KAAK,CAMnC,EAAkC,MAAM,EAJhC,MAAM,QAAQ,EAAyB,CACjD,EACA,CAAC,EAAyB,CAI5B,EACA,EACD,CACE,KAAM,GACL,EAA0B,EAAc,EAAc,CACvD,CACA,KAAM,GAAiB,EAAmB,EAAa,CAAC,CAErD,EAAwB,KAAK,KAAK,CAWxC,EATgC,EAAkB,IAC/C,IACE,CACC,cAAe,EAAW,IAC1B,KAAM,QACN,OAAQ,QACT,EACJ,CAEiD,CAElD,IAAM,EAAwB,GAC5B,EAAc,OAAO,UAAY,EAAc,OAAO,cAGpD,GAEF,EAAO,gBAAgB,GAAK,CAG9B,IAAI,EAAmC,EAAE,CAErC,IACF,EAAqB,MAAM,EACzB,EACA,EACA,CACE,uBAA0BA,EAAO,kBAAkB,CACnD,sBAAyBA,EAAO,iBAAiB,CACjD,QAAU,GAAMA,EAAO,eAAe,EAAE,CACzC,CACF,CACE,KAAM,GACL,EAA0B,EAAc,EAAc,CACvD,CACA,KAAM,GAAiB,EAAmB,EAAa,CAAC,EAG7D,IAAM,EAAyB,KAAK,KAAK,CAOzC,OAJA,EAAO,QAAQ,CAEf,EAAa,EAAc,CAEpB,CACL,oBACA,qBACA,qBACA,KAAM,CACJ,kBAAmB,EAAwB,EAC3C,mBAAoB,EAAyB,EAC7C,mBAAoB,EAAyB,EAC9C,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadLocalDictionaries.mjs","names":[],"sources":["../../../src/loadDictionaries/loadLocalDictionaries.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport type { Dictionary
|
|
1
|
+
{"version":3,"file":"loadLocalDictionaries.mjs","names":[],"sources":["../../../src/loadDictionaries/loadLocalDictionaries.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { loadContentDeclarations } from './loadContentDeclaration';\n\nexport const loadLocalDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig\n): Promise<Dictionary[]> => {\n const { content, system } = configuration;\n const { baseDir } = content;\n const { dictionariesDir } = system;\n\n if (typeof contentDeclarationsPaths === 'string') {\n contentDeclarationsPaths = [contentDeclarationsPaths];\n }\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n const result: Dictionary[] = [];\n\n for await (const contentDeclarationPath of contentDeclarationsPaths) {\n const dictionary = await loadContentDeclarations(\n [contentDeclarationPath],\n configuration\n );\n\n const relativeFilePath = relative(baseDir, contentDeclarationPath);\n\n const dictionaryWithPath: Dictionary = {\n ...dictionary[0],\n filePath: relativeFilePath,\n };\n\n result.push(dictionaryWithPath);\n }\n\n return result;\n};\n"],"mappings":"kKAMA,MAAa,EAAwB,MACnC,EACA,IAC0B,CAC1B,GAAM,CAAE,UAAS,UAAW,EACtB,CAAE,WAAY,EACd,CAAE,mBAAoB,EAExB,OAAO,GAA6B,WACtC,EAA2B,CAAC,EAAyB,EAIvD,MAAM,EAAM,EAAQ,EAAgB,CAAE,CAAE,UAAW,GAAM,CAAC,CAE1D,IAAM,EAAuB,EAAE,CAE/B,UAAW,IAAM,KAA0B,EAA0B,CACnE,IAAM,EAAa,MAAM,EACvB,CAAC,EAAuB,CACxB,EACD,CAEK,EAAmB,EAAS,EAAS,EAAuB,CAE5D,EAAiC,CACrC,GAAG,EAAW,GACd,SAAU,EACX,CAED,EAAO,KAAK,EAAmB,CAGjC,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadRemoteDictionaries.mjs","names":[],"sources":["../../../src/loadDictionaries/loadRemoteDictionaries.ts"],"sourcesContent":["import { getIntlayerAPIProxy } from '@intlayer/api';\n// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { getRemoteDictionaries } from '@intlayer/remote-dictionaries-entry';\nimport type { Dictionary, DictionaryId, DictionaryKey } from '@intlayer/types';\nimport { fetchDistantDictionaries } from '../fetchDistantDictionaries';\nimport type { DictionariesStatus } from '../loadDictionaries/loadDictionaries';\nimport { sortAlphabetically } from '../utils/sortAlphabetically';\n\nexport const formatDistantDictionaries = (\n dictionaries: (DictionaryAPI | Dictionary)[]\n): Dictionary[] =>\n dictionaries.map((dict) => ({\n ...dict,\n localId: `${dict.key}::remote::${dict.id}`,\n location: 'remote' as const,\n }));\n\nexport const loadRemoteDictionaries = async (\n configuration = getConfiguration(),\n onStatusUpdate?: (status: DictionariesStatus[]) => void,\n options?: {\n onStartRemoteCheck?: () => void;\n onStopRemoteCheck?: () => void;\n onError?: (error: Error) => void;\n }\n): Promise<Dictionary[]> => {\n const { editor } = configuration;\n const remoteDictionariesRecord = getRemoteDictionaries(configuration);\n\n const hasRemoteDictionaries = Boolean(editor.clientId && editor.clientSecret);\n\n if (!hasRemoteDictionaries) return [];\n\n try {\n options?.onStartRemoteCheck?.();\n\n const intlayerAPI = getIntlayerAPIProxy(undefined, configuration);\n\n // Get the list of dictionary keys\n const getDictionariesKeysResult =\n await intlayerAPI.dictionary.getDictionariesUpdateTimestamp();\n\n const distantDictionaryUpdateTimeStamp: Record<\n DictionaryId,\n { key: DictionaryKey; updatedAt: number }\n > | null = getDictionariesKeysResult.data;\n\n if (!distantDictionaryUpdateTimeStamp) {\n throw new Error('No distant dictionaries found');\n }\n\n const dictionariesIdToFetch = Object.entries(\n distantDictionaryUpdateTimeStamp\n ).filter(([dictionaryId, data]) => {\n // If remote doesn't provide updatedAt, fetch to be safe\n if (!data.updatedAt) return true;\n\n // If no local cache exists, fetch\n const local: Dictionary | undefined = remoteDictionariesRecord[\n data.key\n ]?.find((dictionary) => dictionary.id === dictionaryId);\n if (!local) return true;\n\n const localUpdatedAtRaw = (local as any)?.updatedAt as\n | number\n | string\n | undefined;\n\n const localUpdatedAt =\n typeof localUpdatedAtRaw === 'number'\n ? localUpdatedAtRaw\n : localUpdatedAtRaw\n ? new Date(localUpdatedAtRaw).getTime()\n : undefined;\n\n // If local timestamp missing or older than remote, fetch\n if (typeof localUpdatedAt !== 'number') return true;\n\n return data.updatedAt > localUpdatedAt;\n });\n\n const flatRemoteDictionariesRecord: DictionaryAPI[] = Object.values(\n remoteDictionariesRecord\n ).flat();\n\n const cachedDictionaries: Dictionary[] =\n flatRemoteDictionariesRecord.filter((dictionary) => {\n const remoteUpdatedAt =\n distantDictionaryUpdateTimeStamp[dictionary.id!].updatedAt;\n\n const localUpdatedAtRaw = dictionary.updatedAt;\n\n const localUpdatedAt =\n typeof localUpdatedAtRaw === 'number'\n ? localUpdatedAtRaw\n : localUpdatedAtRaw\n ? new Date(localUpdatedAtRaw).getTime()\n : undefined;\n\n // Consider as cached/imported when local exists and is up-to-date or newer\n return (\n typeof localUpdatedAt === 'number' &&\n typeof remoteUpdatedAt === 'number' &&\n localUpdatedAt >= remoteUpdatedAt\n );\n });\n\n // Report cached as already imported\n if (cachedDictionaries.length > 0) {\n onStatusUpdate?.(\n cachedDictionaries.map((dictionary) => ({\n dictionaryKey: dictionary.key,\n type: 'remote',\n status: 'imported',\n }))\n );\n }\n\n const orderedDistantDictionaryKeys = dictionariesIdToFetch\n .map(([, data]) => data.key)\n .sort(sortAlphabetically);\n\n // Report pending for keys to be fetched so totals are visible immediately\n if (orderedDistantDictionaryKeys.length > 0) {\n onStatusUpdate?.(\n orderedDistantDictionaryKeys.map((key) => ({\n dictionaryKey: key,\n type: 'remote',\n status: 'pending',\n }))\n );\n }\n\n const distantDictionariesData = await fetchDistantDictionaries(\n {\n dictionaryKeys: orderedDistantDictionaryKeys,\n },\n onStatusUpdate\n );\n\n const distantDictionaries: Dictionary[] = formatDistantDictionaries(\n distantDictionariesData\n );\n\n return [...cachedDictionaries, ...distantDictionaries];\n } catch (error) {\n options?.on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M,SACN,OAAQ,WACT,EAAE,CACJ,CAGH,IAAM,EAA+B,EAClC,KAAK,EAAG,KAAU,EAAK,IAAI,CAC3B,KAAK,EAAmB,CAGvB,EAA6B,OAAS,GACxC,IACE,EAA6B,IAAK,IAAS,CACzC,cAAe,EACf,KAAM,SACN,OAAQ,UACT,EAAE,CACJ,CAUH,IAAM,EAAoC,EAPV,MAAM,EACpC,CACE,eAAgB,EACjB,CACD,EACD,CAIA,CAED,MAAO,CAAC,GAAG,EAAoB,GAAG,EAAoB,OAC/C,EAAO,CAEd,OADA,GAAS,UAAU,EAAe,CAC3B,EAAE,QACD,CACR,GAAS,qBAAqB"}
|
|
1
|
+
{"version":3,"file":"loadRemoteDictionaries.mjs","names":[],"sources":["../../../src/loadDictionaries/loadRemoteDictionaries.ts"],"sourcesContent":["import { getIntlayerAPIProxy } from '@intlayer/api';\n// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { getRemoteDictionaries } from '@intlayer/remote-dictionaries-entry';\nimport type { Dictionary, DictionaryId, DictionaryKey } from '@intlayer/types/dictionary';\nimport { fetchDistantDictionaries } from '../fetchDistantDictionaries';\nimport type { DictionariesStatus } from '../loadDictionaries/loadDictionaries';\nimport { sortAlphabetically } from '../utils/sortAlphabetically';\n\nexport const formatDistantDictionaries = (\n dictionaries: (DictionaryAPI | Dictionary)[]\n): Dictionary[] =>\n dictionaries.map((dict) => ({\n ...dict,\n localId: `${dict.key}::remote::${dict.id}`,\n location: 'remote' as const,\n }));\n\nexport const loadRemoteDictionaries = async (\n configuration = getConfiguration(),\n onStatusUpdate?: (status: DictionariesStatus[]) => void,\n options?: {\n onStartRemoteCheck?: () => void;\n onStopRemoteCheck?: () => void;\n onError?: (error: Error) => void;\n }\n): Promise<Dictionary[]> => {\n const { editor } = configuration;\n const remoteDictionariesRecord = getRemoteDictionaries(configuration);\n\n const hasRemoteDictionaries = Boolean(editor.clientId && editor.clientSecret);\n\n if (!hasRemoteDictionaries) return [];\n\n try {\n options?.onStartRemoteCheck?.();\n\n const intlayerAPI = getIntlayerAPIProxy(undefined, configuration);\n\n // Get the list of dictionary keys\n const getDictionariesKeysResult =\n await intlayerAPI.dictionary.getDictionariesUpdateTimestamp();\n\n const distantDictionaryUpdateTimeStamp: Record<\n DictionaryId,\n { key: DictionaryKey; updatedAt: number }\n > | null = getDictionariesKeysResult.data;\n\n if (!distantDictionaryUpdateTimeStamp) {\n throw new Error('No distant dictionaries found');\n }\n\n const dictionariesIdToFetch = Object.entries(\n distantDictionaryUpdateTimeStamp\n ).filter(([dictionaryId, data]) => {\n // If remote doesn't provide updatedAt, fetch to be safe\n if (!data.updatedAt) return true;\n\n // If no local cache exists, fetch\n const local: Dictionary | undefined = remoteDictionariesRecord[\n data.key\n ]?.find((dictionary) => dictionary.id === dictionaryId);\n if (!local) return true;\n\n const localUpdatedAtRaw = (local as any)?.updatedAt as\n | number\n | string\n | undefined;\n\n const localUpdatedAt =\n typeof localUpdatedAtRaw === 'number'\n ? localUpdatedAtRaw\n : localUpdatedAtRaw\n ? new Date(localUpdatedAtRaw).getTime()\n : undefined;\n\n // If local timestamp missing or older than remote, fetch\n if (typeof localUpdatedAt !== 'number') return true;\n\n return data.updatedAt > localUpdatedAt;\n });\n\n const flatRemoteDictionariesRecord: DictionaryAPI[] = Object.values(\n remoteDictionariesRecord\n ).flat();\n\n const cachedDictionaries: Dictionary[] =\n flatRemoteDictionariesRecord.filter((dictionary) => {\n const remoteUpdatedAt =\n distantDictionaryUpdateTimeStamp[dictionary.id!].updatedAt;\n\n const localUpdatedAtRaw = dictionary.updatedAt;\n\n const localUpdatedAt =\n typeof localUpdatedAtRaw === 'number'\n ? localUpdatedAtRaw\n : localUpdatedAtRaw\n ? new Date(localUpdatedAtRaw).getTime()\n : undefined;\n\n // Consider as cached/imported when local exists and is up-to-date or newer\n return (\n typeof localUpdatedAt === 'number' &&\n typeof remoteUpdatedAt === 'number' &&\n localUpdatedAt >= remoteUpdatedAt\n );\n });\n\n // Report cached as already imported\n if (cachedDictionaries.length > 0) {\n onStatusUpdate?.(\n cachedDictionaries.map((dictionary) => ({\n dictionaryKey: dictionary.key,\n type: 'remote',\n status: 'imported',\n }))\n );\n }\n\n const orderedDistantDictionaryKeys = dictionariesIdToFetch\n .map(([, data]) => data.key)\n .sort(sortAlphabetically);\n\n // Report pending for keys to be fetched so totals are visible immediately\n if (orderedDistantDictionaryKeys.length > 0) {\n onStatusUpdate?.(\n orderedDistantDictionaryKeys.map((key) => ({\n dictionaryKey: key,\n type: 'remote',\n status: 'pending',\n }))\n );\n }\n\n const distantDictionariesData = await fetchDistantDictionaries(\n {\n dictionaryKeys: orderedDistantDictionaryKeys,\n },\n onStatusUpdate\n );\n\n const distantDictionaries: Dictionary[] = formatDistantDictionaries(\n distantDictionariesData\n );\n\n return [...cachedDictionaries, ...distantDictionaries];\n } catch (error) {\n options?.onError?.(error as Error);\n return [];\n } finally {\n options?.onStopRemoteCheck?.();\n }\n};\n"],"mappings":"yUAUA,MAAa,EACX,GAEA,EAAa,IAAK,IAAU,CAC1B,GAAG,EACH,QAAS,GAAG,EAAK,IAAI,YAAY,EAAK,KACtC,SAAU,SACX,EAAE,CAEQ,EAAyB,MACpC,EAAgB,GAAkB,CAClC,EACA,IAK0B,CAC1B,GAAM,CAAE,UAAW,EACb,EAA2B,EAAsB,EAAc,CAIrE,GAAI,EAFkC,EAAO,UAAY,EAAO,cAEpC,MAAO,EAAE,CAErC,GAAI,CACF,GAAS,sBAAsB,CAQ/B,IAAM,GAFJ,MAJkB,EAAoB,IAAA,GAAW,EAAc,CAI7C,WAAW,gCAAgC,EAK1B,KAErC,GAAI,CAAC,EACH,MAAU,MAAM,gCAAgC,CAGlD,IAAM,EAAwB,OAAO,QACnC,EACD,CAAC,QAAQ,CAAC,EAAc,KAAU,CAEjC,GAAI,CAAC,EAAK,UAAW,MAAO,GAG5B,IAAM,EAAgC,EACpC,EAAK,MACJ,KAAM,GAAe,EAAW,KAAO,EAAa,CACvD,GAAI,CAAC,EAAO,MAAO,GAEnB,IAAM,EAAqB,GAAe,UAKpC,EACJ,OAAO,GAAsB,SACzB,EACA,EACE,IAAI,KAAK,EAAkB,CAAC,SAAS,CACrC,IAAA,GAKR,OAFI,OAAO,GAAmB,SAEvB,EAAK,UAAY,EAFuB,IAG/C,CAMI,EAJgD,OAAO,OAC3D,EACD,CAAC,MAAM,CAGuB,OAAQ,GAAe,CAClD,IAAM,EACJ,EAAiC,EAAW,IAAK,UAE7C,EAAoB,EAAW,UAE/B,EACJ,OAAO,GAAsB,SACzB,EACA,EACE,IAAI,KAAK,EAAkB,CAAC,SAAS,CACrC,IAAA,GAGR,OACE,OAAO,GAAmB,UAC1B,OAAO,GAAoB,UAC3B,GAAkB,GAEpB,CAGA,EAAmB,OAAS,GAC9B,IACE,EAAmB,IAAK,IAAgB,CACtC,cAAe,EAAW,IAC1B,KAAM,SACN,OAAQ,WACT,EAAE,CACJ,CAGH,IAAM,EAA+B,EAClC,KAAK,EAAG,KAAU,EAAK,IAAI,CAC3B,KAAK,EAAmB,CAGvB,EAA6B,OAAS,GACxC,IACE,EAA6B,IAAK,IAAS,CACzC,cAAe,EACf,KAAM,SACN,OAAQ,UACT,EAAE,CACJ,CAUH,IAAM,EAAoC,EAPV,MAAM,EACpC,CACE,eAAgB,EACjB,CACD,EACD,CAIA,CAED,MAAO,CAAC,GAAG,EAAoB,GAAG,EAAoB,OAC/C,EAAO,CAEd,OADA,GAAS,UAAU,EAAe,CAC3B,EAAE,QACD,CACR,GAAS,qBAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logTypeScriptErrors.mjs","names":[],"sources":["../../../src/loadDictionaries/logTypeScriptErrors.ts"],"sourcesContent":["import { dirname, extname } from 'node:path';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types';\n\nexport const logTypeScriptErrors = async (\n filePaths: string[],\n configuration: IntlayerConfig\n) => {\n const appLogger = getAppLogger(configuration);\n\n const filesToCheck = filePaths.filter((path) => {\n const ext = extname(path);\n\n return ['.ts', '.tsx', '.js', '.jsx', '.cjs', '.mjs', '.json'].includes(\n ext\n );\n });\n\n if (filesToCheck.length === 0) return;\n\n let ts: typeof import('typescript');\n\n try {\n ts = (await import('typescript')).default || (await import('typescript'));\n } catch {\n // TypeScript not installed, skip type checking\n\n return;\n }\n\n const configFileName = ts.findConfigFile(\n configuration.content?.baseDir ?? process.cwd(),\n ts.sys.fileExists,\n 'tsconfig.json'\n );\n\n let compilerOptions: any = {\n noEmit: true,\n\n allowJs: true,\n\n resolveJsonModule: true,\n };\n\n if (configFileName) {\n const configFileText = ts.sys.readFile(configFileName);\n\n if (configFileText) {\n const configJson = ts.parseConfigFileTextToJson(\n configFileName,\n\n configFileText\n );\n\n if (!configJson.error) {\n const parsedConfig = ts.parseJsonConfigFileContent(\n configJson.config,\n\n ts.sys,\n\n dirname(configFileName)\n );\n\n const { incremental, tsBuildInfoFile, ...restOptions } =\n parsedConfig.options;\n\n compilerOptions = { ...compilerOptions, ...restOptions, noEmit: true };\n }\n }\n }\n\n const program = ts.createProgram(filesToCheck, compilerOptions);\n\n filesToCheck.forEach((filePath) => {\n const sourceFile = program.getSourceFile(filePath);\n\n if (!sourceFile) return;\n\n const diagnostics = ts.getPreEmitDiagnostics(program, sourceFile);\n\n diagnostics.forEach((diagnostic) => {\n const message = ts.flattenDiagnosticMessageText(\n diagnostic.messageText,\n\n '\\n'\n );\n\n if (diagnostic.file && diagnostic.start !== undefined) {\n const { line, character } =\n diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);\n\n appLogger(\n `TS Error in ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`,\n\n { level: 'warn' }\n );\n }\n });\n });\n};\n"],"mappings":"wGAIA,MAAa,EAAsB,MACjC,EACA,IACG,CACH,IAAM,EAAY,EAAa,EAAc,CAEvC,EAAe,EAAU,OAAQ,GAAS,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rors.ts"],"sourcesContent":["import { dirname, extname } from 'node:path';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\nexport const logTypeScriptErrors = async (\n filePaths: string[],\n configuration: IntlayerConfig\n) => {\n const appLogger = getAppLogger(configuration);\n\n const filesToCheck = filePaths.filter((path) => {\n const ext = extname(path);\n\n return ['.ts', '.tsx', '.js', '.jsx', '.cjs', '.mjs', '.json'].includes(\n ext\n );\n });\n\n if (filesToCheck.length === 0) return;\n\n let ts: typeof import('typescript');\n\n try {\n ts = (await import('typescript')).default || (await import('typescript'));\n } catch {\n // TypeScript not installed, skip type checking\n\n return;\n }\n\n const configFileName = ts.findConfigFile(\n configuration.content?.baseDir ?? process.cwd(),\n ts.sys.fileExists,\n 'tsconfig.json'\n );\n\n let compilerOptions: any = {\n noEmit: true,\n\n allowJs: true,\n\n resolveJsonModule: true,\n };\n\n if (configFileName) {\n const configFileText = ts.sys.readFile(configFileName);\n\n if (configFileText) {\n const configJson = ts.parseConfigFileTextToJson(\n configFileName,\n\n configFileText\n );\n\n if (!configJson.error) {\n const parsedConfig = ts.parseJsonConfigFileContent(\n configJson.config,\n\n ts.sys,\n\n dirname(configFileName)\n );\n\n const { incremental, tsBuildInfoFile, ...restOptions } =\n parsedConfig.options;\n\n compilerOptions = { ...compilerOptions, ...restOptions, noEmit: true };\n }\n }\n }\n\n const program = ts.createProgram(filesToCheck, compilerOptions);\n\n filesToCheck.forEach((filePath) => {\n const sourceFile = program.getSourceFile(filePath);\n\n if (!sourceFile) return;\n\n const diagnostics = ts.getPreEmitDiagnostics(program, sourceFile);\n\n diagnostics.forEach((diagnostic) => {\n const message = ts.flattenDiagnosticMessageText(\n diagnostic.messageText,\n\n '\\n'\n );\n\n if (diagnostic.file && diagnostic.start !== undefined) {\n const { line, character } =\n diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);\n\n appLogger(\n `TS Error in ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`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G,EAAY,EAAE,KAAK,IAE3E,CAAE,MAAO,OAAQ,CAClB,GAEH,EACF"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import{formatPath as e}from"./utils/formatter.mjs";import{runOnce as t}from"./utils/runOnce.mjs";import{
|
|
1
|
+
import{formatPath as e}from"./utils/formatter.mjs";import{runOnce as t}from"./utils/runOnce.mjs";import{join as n,relative as r}from"node:path";import{ANSIColors as i,colorize as a,colorizePath as o,getAppLogger as s,x as c}from"@intlayer/config/logger";import{getConfigurationAndFilePath as l,intlayerConfigSchema as u}from"@intlayer/config/node";import{getEnvFilePath as d}from"@intlayer/config/env";const f=f=>{let{configuration:p,customConfiguration:m,numCustomConfiguration:h,configurationFilePath:g}=l(f),_=s(p);t(n(p.system.baseDir,`.intlayer`,`cache`,`intlayer-config-locaded.lock`),()=>{if(h===0)_(`Configuration file not found, using default configuration.`,{isVerbose:!0});else{let t=p.system.baseDir,n=r(t,g);if(h===1){let t=d(f?.env,f?.envFile);_(`Configuration loaded ${e(n)}${t?` - Env: ${e(t)}`:``}`,{isVerbose:!0})}else _(`Multiple configuration files found, using ${e(n)}.`,{isVerbose:!0})}if(m){let e=u.safeParse(m);e.success||_(`${c} Invalid configuration:\n${e.error.issues.map(e=>`${o(` - ${e.path.join(`.`)}:`)} ${a(e.message,i.GREY_DARK)}`).join(`
|
|
2
|
+
`)}`),m.compiler?.outputDir&&_(`${o(`compiler.outputDir`)} is deprecated, use ${o(`compiler.output`)} instead`),m.build?.importMode&&_(`${o(`build.importMode`)} is deprecated, use ${o(`dictionary.importMode`)} instead`),m.compiler?.transformPattern&&_(`${o(`compiler.transformPattern`)} is deprecated, use ${o(`build.traversePattern`)} instead`),m.compiler?.excludePattern&&_(`${o(`compiler.excludePattern`)} is deprecated, use ${o(`build.traversePattern`)} instead`)}},{cacheTimeoutMs:1e3*60})};export{f as logConfigDetails};
|
|
2
3
|
//# sourceMappingURL=logConfigDetails.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logConfigDetails.mjs","names":[],"sources":["../../src/logConfigDetails.ts"],"sourcesContent":["import { join, relative } from 'node:path';\nimport { getEnvFilePath } from '@intlayer/config/env';\nimport {
|
|
1
|
+
{"version":3,"file":"logConfigDetails.mjs","names":[],"sources":["../../src/logConfigDetails.ts"],"sourcesContent":["import { join, relative } from 'node:path';\nimport { getEnvFilePath } from '@intlayer/config/env';\nimport {\n ANSIColors,\n colorize,\n colorizePath,\n getAppLogger,\n x,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfigurationAndFilePath,\n intlayerConfigSchema,\n} from '@intlayer/config/node';\nimport { formatPath, runOnce } from './utils';\n\nexport const logConfigDetails = (options?: GetConfigurationOptions) => {\n const {\n configuration,\n customConfiguration,\n numCustomConfiguration,\n configurationFilePath,\n } = getConfigurationAndFilePath(options);\n const appLogger = getAppLogger(configuration);\n\n runOnce(\n join(\n configuration.system.baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-config-locaded.lock'\n ),\n () => {\n if (numCustomConfiguration === 0) {\n appLogger(\n 'Configuration file not found, using default configuration.',\n {\n isVerbose: true,\n }\n );\n } else {\n const baseDir = configuration.system.baseDir;\n const relativeOutputPath = relative(baseDir, configurationFilePath!);\n\n if (numCustomConfiguration === 1) {\n const dotEnvFilePath = getEnvFilePath(options?.env, options?.envFile);\n\n appLogger(\n `Configuration loaded ${formatPath(relativeOutputPath)}${dotEnvFilePath ? ` - Env: ${formatPath(dotEnvFilePath)}` : ''}`,\n {\n isVerbose: true,\n }\n );\n } else {\n appLogger(\n `Multiple configuration files found, using ${formatPath(relativeOutputPath)}.`,\n {\n isVerbose: true,\n }\n );\n }\n }\n\n if (customConfiguration) {\n const validation = intlayerConfigSchema.safeParse(customConfiguration);\n\n if (!validation.success) {\n const errorMessages = validation.error.issues\n .map((error) => {\n const path = colorizePath(` - ${error.path.join('.')}:`);\n const message = colorize(error.message, ANSIColors.GREY_DARK);\n return `${path} ${message}`;\n })\n .join('\\n');\n const errorMessage = `${x} Invalid configuration:\\n${errorMessages}`;\n\n appLogger(errorMessage);\n }\n\n // Deprecation warning: compiler.outputDir -> compiler.output\n if (customConfiguration.compiler?.outputDir) {\n appLogger(\n `${colorizePath('compiler.outputDir')} is deprecated, use ${colorizePath('compiler.output')} instead`\n );\n }\n if (customConfiguration.build?.importMode) {\n appLogger(\n `${colorizePath('build.importMode')} is deprecated, use ${colorizePath('dictionary.importMode')} instead`\n );\n }\n if (customConfiguration.compiler?.transformPattern) {\n appLogger(\n `${colorizePath('compiler.transformPattern')} is deprecated, use ${colorizePath('build.traversePattern')} instead`\n );\n }\n if (customConfiguration.compiler?.excludePattern) {\n appLogger(\n `${colorizePath('compiler.excludePattern')} is deprecated, use ${colorizePath('build.traversePattern')} instead`\n );\n }\n }\n },\n {\n cacheTimeoutMs: 1000 * 60, // 1 minute\n }\n );\n};\n"],"mappings":"kZAgBA,MAAa,EAAoB,GAAsC,CACrE,GAAM,CACJ,gBACA,sBACA,yBACA,yBACE,EAA4B,EAAQ,CAClC,EAAY,EAAa,EAAc,CAE7C,EACE,EACE,EAAc,OAAO,QACrB,YACA,QACA,+BACD,KACK,CACJ,GAAI,IAA2B,EAC7B,EACE,6DACA,CACE,UAAW,GACZ,CACF,KACI,CACL,IAAM,EAAU,EAAc,OAAO,QAC/B,EAAqB,EAAS,EAAS,EAAuB,CAEpE,GAAI,IAA2B,EAAG,CAChC,IAAM,EAAiB,EAAe,GAAS,IAAK,GAAS,QAAQ,CAErE,EACE,wBAAwB,EAAW,EAAmB,GAAG,EAAiB,WAAW,EAAW,EAAe,GAAK,KACpH,CACE,UAAW,GACZ,CACF,MAED,EACE,6CAA6C,EAAW,EAAmB,CAAC,GAC5E,CACE,UAAW,GACZ,CACF,CAIL,GAAI,EAAqB,CACvB,IAAM,EAAa,EAAqB,UAAU,EAAoB,CAEjE,EAAW,SAUd,EAFqB,GAAG,EAAE,2BAPJ,EAAW,MAAM,OACpC,IAAK,GAGG,GAFM,EAAa,MAAM,EAAM,KAAK,KAAK,IAAI,CAAC,GAAG,CAEzC,GADC,EAAS,EAAM,QAAS,EAAW,UAAU,GAE7D,CACD,KAAK;EAAK,GAGU,CAIrB,EAAoB,UAAU,WAChC,EACE,GAAG,EAAa,qBAAqB,CAAC,sBAAsB,EAAa,kBAAkB,CAAC,UAC7F,CAEC,EAAoB,OAAO,YAC7B,EACE,GAAG,EAAa,mBAAmB,CAAC,sBAAsB,EAAa,wBAAwB,CAAC,UACjG,CAEC,EAAoB,UAAU,kBAChC,EACE,GAAG,EAAa,4BAA4B,CAAC,sBAAsB,EAAa,wBAAwB,CAAC,UAC1G,CAEC,EAAoB,UAAU,gBAChC,EACE,GAAG,EAAa,0BAA0B,CAAC,sBAAsB,EAAa,wBAAwB,CAAC,UACxG,GAIP,CACE,eAAgB,IAAO,GACxB,CACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createDictionaryEntryPoint as e}from"./createDictionaryEntryPoint/createDictionaryEntryPoint.mjs";import{buildDictionary as t}from"./buildIntlayerDictionary/buildIntlayerDictionary.mjs";import{runOnce as n}from"./utils/runOnce.mjs";import{createModuleAugmentation as r}from"./createType/createModuleAugmentation.mjs";import{createTypes as i}from"./createType/createType.mjs";import{listDictionariesWithStats as a}from"./listDictionariesPath.mjs";import{loadDictionaries as o}from"./loadDictionaries/loadDictionaries.mjs";import{writeRemoteDictionary as s}from"./buildIntlayerDictionary/writeRemoteDictionary.mjs";import{cleanOutputDir as c}from"./cleanOutputDir.mjs";import{isCachedConfigurationUpToDate as l,writeConfiguration as u}from"./writeConfiguration/index.mjs";import{stat as d}from"node:fs/promises";import{join as f}from"node:path";import{ANSIColors as p,colorize as m,getAppLogger as h}from"@intlayer/config/logger";import{cacheDisk as g}from"@intlayer/config/utils";import _ from"@intlayer/config/package.json"with{type:"json"};const v={clean:!1,format:[`cjs`,`esm`],cacheTimeoutMs:1e3*60*60},y=async(y,b)=>{let x=h(y),S=f(y.system.cacheDir,`intlayer-prepared.lock`),C=g(y,[`intlayer-version`]),w=await C.get(),T=!!(w&&w===_.version),E=await l(y),D=await a(y),O=!1;try{let e=await d(S);O=D.some(t=>t.stats.mtime.getTime()>e.mtime.getTime())}catch{}let k=y.plugins?.some(e=>!!e.loadDictionaries),{clean:A,format:j,forceRun:M,onIsCached:N,cacheTimeoutMs:P}={...v,forceRun:!T||!E||O||k,...b??{}};await n(S,async()=>{(A||!T)&&await c(y),await C.set(_.version);let n=Date.now();x([`Preparing Intlayer`,m(`(v${_.version})`,p.GREY_DARK)]),await u(y);let a=Date.now();x([`Configuration written`,m(`(${a-n}ms)`,p.GREY_DARK)],{isVerbose:!0});let l=await o(D.map(e=>e.path),y),d=Date.now();x([`Content loaded`,m([l.remoteDictionaries.length+l.pluginDictionaries.length>0?[`(Total: ${d-a}ms`,l.localDictionaries.length>0?` - Local: ${l.time.localDictionaries}ms`:``,l.remoteDictionaries.length>0?` - Remote: ${l.time.remoteDictionaries}ms`:``,l.pluginDictionaries.length>0?` - Plugin: ${l.time.pluginDictionaries}ms`:``,`)`].join(``):`(${d-a}ms)`].join(``),p.GREY_DARK)],{isVerbose:!0});let f=await t([...l.localDictionaries,...l.remoteDictionaries,...l.pluginDictionaries],y,j,!1);await s(l.remoteDictionaries,y),await i(Object.values(f?.mergedDictionaries??{}).map(e=>e.dictionary),y),await e(y);let h=Date.now();x([`Dictionaries built`,m(`(${h-n}ms)`,p.GREY_DARK)]),await r(y),x([`Module augmentation built`,m(`(${Date.now()-h}ms)`,p.GREY_DARK)],{isVerbose:!0});for await(let e of y.plugins??[]){let{unmergedDictionaries:t,mergedDictionaries:n}=f;await e.afterBuild?.({dictionaries:{unmergedDictionaries:t,mergedDictionaries:n},configuration:y})}x([`Done`,m(`${Date.now()-n}ms`,p.GREEN)],{level:`info`,isVerbose:!0})},{forceRun:M,onIsCached:N,cacheTimeoutMs:P})};export{y as prepareIntlayer};
|
|
2
2
|
//# sourceMappingURL=prepareIntlayer.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareIntlayer.mjs","names":[],"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import { stat } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { ANSIColors, colorize, getAppLogger } from '@intlayer/config/logger';\nimport packageJson from '@intlayer/config/package.json' with { type: 'json' };\nimport { cacheDisk } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { writeRemoteDictionary } from './buildIntlayerDictionary/writeRemoteDictionary';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { createModuleAugmentation, createTypes } from './createType/index';\nimport { listDictionariesWithStats } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { runOnce } from './utils/runOnce';\nimport {\n isCachedConfigurationUpToDate,\n writeConfiguration,\n} from './writeConfiguration';\n\ntype PrepareIntlayerOptions = {\n clean?: boolean;\n format?: ('cjs' | 'esm')[];\n forceRun?: boolean;\n cacheTimeoutMs?: number;\n onIsCached?: () => void | Promise<void>;\n};\n\nconst DEFAULT_PREPARE_INTLAYER_OPTIONS = {\n clean: false,\n format: ['cjs', 'esm'],\n cacheTimeoutMs: 1000 * 60 * 60, // 1 hour\n} satisfies PrepareIntlayerOptions;\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig,\n options?: PrepareIntlayerOptions\n) => {\n const appLogger = getAppLogger(configuration);\n\n const sentinelPath = join(\n configuration.system.cacheDir,\n 'intlayer-prepared.lock'\n );\n // Clean output dir if the intlayer version has changed\n const versionCache = cacheDisk(configuration, ['intlayer-version']);\n const intlayerCacheVersion = await versionCache.get();\n const isCorrectVersion = Boolean(\n intlayerCacheVersion && intlayerCacheVersion === packageJson.version\n );\n\n const isConfigSimilar = await isCachedConfigurationUpToDate(configuration);\n\n // Check if any dictionary has been changed to force a new rebuild\n const dictionariesWithStats = await listDictionariesWithStats(configuration);\n let isDictionaryChanged = false;\n try {\n // Try catch as sentinel file may not exist yet\n const sentinelStats = await stat(sentinelPath);\n isDictionaryChanged = dictionariesWithStats.some(\n (dictionary) =>\n dictionary.stats.mtime.getTime() > sentinelStats.mtime.getTime()\n );\n } catch {}\n\n const hasPluginLoadDictionaries = configuration.plugins?.some((plugin) =>\n Boolean(plugin.loadDictionaries)\n ); // Disable cache if any plugin because it can have custom behavior\n\n const { clean, format, forceRun, onIsCached, cacheTimeoutMs } = {\n ...DEFAULT_PREPARE_INTLAYER_OPTIONS,\n forceRun:\n !isCorrectVersion ||\n !isConfigSimilar ||\n isDictionaryChanged ||\n hasPluginLoadDictionaries,\n ...(options ?? {}),\n };\n\n // Skip preparation if it has already been done recently\n await runOnce(\n sentinelPath,\n async () => {\n // comment because of issue with next and webpack\n // await checkVersionsConsistency(configuration);\n\n if (clean || !isCorrectVersion) {\n await cleanOutputDir(configuration);\n }\n\n await versionCache.set(packageJson.version);\n\n const preparationStartMs = Date.now();\n\n appLogger([\n 'Preparing Intlayer',\n colorize(`(v${packageJson.version})`, ANSIColors.GREY_DARK),\n ]);\n\n await writeConfiguration(configuration);\n\n const configurationWrittenTime = Date.now();\n\n appLogger(\n [\n 'Configuration written',\n colorize(\n `(${configurationWrittenTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n const contentDeclarationPaths = dictionariesWithStats.map(\n (dictionary) => dictionary.path\n );\n\n const dictionaries = await loadDictionaries(\n contentDeclarationPaths,\n configuration\n );\n\n const dictionariesLoadedTime = Date.now();\n\n appLogger(\n [\n 'Content loaded',\n colorize(\n [\n dictionaries.remoteDictionaries.length +\n dictionaries.pluginDictionaries.length >\n 0\n ? [\n `(Total: ${dictionariesLoadedTime - configurationWrittenTime}ms`,\n dictionaries.localDictionaries.length > 0\n ? ` - Local: ${dictionaries.time.localDictionaries}ms`\n : '',\n dictionaries.remoteDictionaries.length > 0\n ? ` - Remote: ${dictionaries.time.remoteDictionaries}ms`\n : '',\n dictionaries.pluginDictionaries.length > 0\n ? ` - Plugin: ${dictionaries.time.pluginDictionaries}ms`\n : '',\n `)`,\n ].join('')\n : `(${dictionariesLoadedTime - configurationWrittenTime}ms)`,\n ].join(''),\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Build local dictionaries\n const dictionariesOutput = await buildDictionary(\n [\n ...dictionaries.localDictionaries,\n ...dictionaries.remoteDictionaries,\n ...dictionaries.pluginDictionaries,\n ],\n configuration,\n format,\n false\n );\n\n // Write remote dictionaries\n // Used as cache for next fetch\n await writeRemoteDictionary(\n dictionaries.remoteDictionaries,\n configuration\n );\n\n const dictionariesToBuild = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionary);\n\n await createTypes(dictionariesToBuild, configuration);\n\n await createDictionaryEntryPoint(configuration);\n\n const dictionariesBuiltTime = Date.now();\n\n appLogger([\n 'Dictionaries built',\n colorize(\n `(${dictionariesBuiltTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ]);\n\n await createModuleAugmentation(configuration);\n\n const moduleAugmentationBuiltTime = Date.now();\n\n appLogger(\n [\n 'Module augmentation built',\n colorize(\n `(${moduleAugmentationBuiltTime - dictionariesBuiltTime}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Plugin transformation\n // Allow plugins to post-process the final build output (e.g., write back ICU JSON)\n for await (const plugin of configuration.plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration,\n });\n }\n\n const preparationElapsedMs = Date.now() - preparationStartMs;\n appLogger(\n [`Done`, colorize(`${preparationElapsedMs}ms`, ANSIColors.GREEN)],\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K,EAAW,MAAM,CAAC,CACjE,CACE,MAAO,OACP,UAAW,GACZ,CACF,EAEH,CACE,WACA,aACA,iBACD,CACF"}
|
|
1
|
+
{"version":3,"file":"prepareIntlayer.mjs","names":[],"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import { stat } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { ANSIColors, colorize, getAppLogger } from '@intlayer/config/logger';\nimport packageJson from '@intlayer/config/package.json' with { type: 'json' };\nimport { cacheDisk } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { writeRemoteDictionary } from './buildIntlayerDictionary/writeRemoteDictionary';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { createModuleAugmentation, createTypes } from './createType/index';\nimport { listDictionariesWithStats } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { runOnce } from './utils/runOnce';\nimport {\n isCachedConfigurationUpToDate,\n writeConfiguration,\n} from './writeConfiguration';\n\ntype PrepareIntlayerOptions = {\n clean?: boolean;\n format?: ('cjs' | 'esm')[];\n forceRun?: boolean;\n cacheTimeoutMs?: number;\n onIsCached?: () => void | Promise<void>;\n};\n\nconst DEFAULT_PREPARE_INTLAYER_OPTIONS = {\n clean: false,\n format: ['cjs', 'esm'],\n cacheTimeoutMs: 1000 * 60 * 60, // 1 hour\n} satisfies PrepareIntlayerOptions;\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig,\n options?: PrepareIntlayerOptions\n) => {\n const appLogger = getAppLogger(configuration);\n\n const sentinelPath = join(\n configuration.system.cacheDir,\n 'intlayer-prepared.lock'\n );\n // Clean output dir if the intlayer version has changed\n const versionCache = cacheDisk(configuration, ['intlayer-version']);\n const intlayerCacheVersion = await versionCache.get();\n const isCorrectVersion = Boolean(\n intlayerCacheVersion && intlayerCacheVersion === packageJson.version\n );\n\n const isConfigSimilar = await isCachedConfigurationUpToDate(configuration);\n\n // Check if any dictionary has been changed to force a new rebuild\n const dictionariesWithStats = await listDictionariesWithStats(configuration);\n let isDictionaryChanged = false;\n try {\n // Try catch as sentinel file may not exist yet\n const sentinelStats = await stat(sentinelPath);\n isDictionaryChanged = dictionariesWithStats.some(\n (dictionary) =>\n dictionary.stats.mtime.getTime() > sentinelStats.mtime.getTime()\n );\n } catch {}\n\n const hasPluginLoadDictionaries = configuration.plugins?.some((plugin) =>\n Boolean(plugin.loadDictionaries)\n ); // Disable cache if any plugin because it can have custom behavior\n\n const { clean, format, forceRun, onIsCached, cacheTimeoutMs } = {\n ...DEFAULT_PREPARE_INTLAYER_OPTIONS,\n forceRun:\n !isCorrectVersion ||\n !isConfigSimilar ||\n isDictionaryChanged ||\n hasPluginLoadDictionaries,\n ...(options ?? {}),\n };\n\n // Skip preparation if it has already been done recently\n await runOnce(\n sentinelPath,\n async () => {\n // comment because of issue with next and webpack\n // await checkVersionsConsistency(configuration);\n\n if (clean || !isCorrectVersion) {\n await cleanOutputDir(configuration);\n }\n\n await versionCache.set(packageJson.version);\n\n const preparationStartMs = Date.now();\n\n appLogger([\n 'Preparing Intlayer',\n colorize(`(v${packageJson.version})`, ANSIColors.GREY_DARK),\n ]);\n\n await writeConfiguration(configuration);\n\n const configurationWrittenTime = Date.now();\n\n appLogger(\n [\n 'Configuration written',\n colorize(\n `(${configurationWrittenTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n const contentDeclarationPaths = dictionariesWithStats.map(\n (dictionary) => dictionary.path\n );\n\n const dictionaries = await loadDictionaries(\n contentDeclarationPaths,\n configuration\n );\n\n const dictionariesLoadedTime = Date.now();\n\n appLogger(\n [\n 'Content loaded',\n colorize(\n [\n dictionaries.remoteDictionaries.length +\n dictionaries.pluginDictionaries.length >\n 0\n ? [\n `(Total: ${dictionariesLoadedTime - configurationWrittenTime}ms`,\n dictionaries.localDictionaries.length > 0\n ? ` - Local: ${dictionaries.time.localDictionaries}ms`\n : '',\n dictionaries.remoteDictionaries.length > 0\n ? ` - Remote: ${dictionaries.time.remoteDictionaries}ms`\n : '',\n dictionaries.pluginDictionaries.length > 0\n ? ` - Plugin: ${dictionaries.time.pluginDictionaries}ms`\n : '',\n `)`,\n ].join('')\n : `(${dictionariesLoadedTime - configurationWrittenTime}ms)`,\n ].join(''),\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Build local dictionaries\n const dictionariesOutput = await buildDictionary(\n [\n ...dictionaries.localDictionaries,\n ...dictionaries.remoteDictionaries,\n ...dictionaries.pluginDictionaries,\n ],\n configuration,\n format,\n false\n );\n\n // Write remote dictionaries\n // Used as cache for next fetch\n await writeRemoteDictionary(\n dictionaries.remoteDictionaries,\n configuration\n );\n\n const dictionariesToBuild = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionary);\n\n await createTypes(dictionariesToBuild, configuration);\n\n await createDictionaryEntryPoint(configuration);\n\n const dictionariesBuiltTime = Date.now();\n\n appLogger([\n 'Dictionaries built',\n colorize(\n `(${dictionariesBuiltTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ]);\n\n await createModuleAugmentation(configuration);\n\n const moduleAugmentationBuiltTime = Date.now();\n\n appLogger(\n [\n 'Module augmentation built',\n colorize(\n `(${moduleAugmentationBuiltTime - dictionariesBuiltTime}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Plugin transformation\n // Allow plugins to post-process the final build output (e.g., write back ICU JSON)\n for await (const plugin of configuration.plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration,\n });\n }\n\n const preparationElapsedMs = Date.now() - preparationStartMs;\n appLogger(\n [`Done`, colorize(`${preparationElapsedMs}ms`, ANSIColors.GREEN)],\n {\n level: 'info',\n isVerbose: true,\n }\n );\n },\n {\n forceRun,\n onIsCached,\n cacheTimeoutMs,\n }\n );\n};\n"],"mappings":"whCA2BA,MAAM,EAAmC,CACvC,MAAO,GACP,OAAQ,CAAC,MAAO,MAAM,CACtB,eAAgB,IAAO,GAAK,GAC7B,CAEY,EAAkB,MAC7B,EACA,IACG,CACH,IAAM,EAAY,EAAa,EAAc,CAEvC,EAAe,EACnB,EAAc,OAAO,SACrB,yBACD,CAEK,EAAe,EAAU,EAAe,CAAC,mBAAmB,CAAC,CAC7D,EAAuB,MAAM,EAAa,KAAK,CAC/C,EAAmB,GACvB,GAAwB,IAAyB,EAAY,SAGzD,EAAkB,MAAM,EAA8B,EAAc,CAGpE,EAAwB,MAAM,EAA0B,EAAc,CACxE,EAAsB,GAC1B,GAAI,CAEF,IAAM,EAAgB,MAAM,EAAK,EAAa,CAC9C,EAAsB,EAAsB,KACzC,GACC,EAAW,MAAM,MAAM,SAAS,CAAG,EAAc,MAAM,SAAS,CACnE,MACK,EAER,IAAM,EAA4B,EAAc,SAAS,KAAM,GAC7D,EAAQ,EAAO,iBAChB,CAEK,CAAE,QAAO,SAAQ,WAAU,aAAY,kBAAmB,CAC9D,GAAG,EACH,SACE,CAAC,GACD,CAAC,GACD,GACA,EACF,GAAI,GAAW,EAAE,CAClB,CAGD,MAAM,EACJ,EACA,SAAY,EAIN,GAAS,CAAC,IACZ,MAAM,EAAe,EAAc,CAGrC,MAAM,EAAa,IAAI,EAAY,QAAQ,CAE3C,IAAM,EAAqB,KAAK,KAAK,CAErC,EAAU,CACR,qBACA,EAAS,KAAK,EAAY,QAAQ,GAAI,EAAW,UAAU,CAC5D,CAAC,CAEF,MAAM,EAAmB,EAAc,CAEvC,IAAM,EAA2B,KAAK,KAAK,CAE3C,EACE,CACE,wBACA,EACE,IAAI,EAA2B,EAAmB,KAClD,EAAW,UACZ,CACF,C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,EACE,CAAC,OAAQ,EAAS,GAFS,KAAK,KAAK,CAAG,EAEE,IAAK,EAAW,MAAM,CAAC,CACjE,CACE,MAAO,OACP,UAAW,GACZ,CACF,EAEH,CACE,WACA,aACA,iBACD,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyMask.mjs","names":[],"sources":["../../../src/reduceDictionaryContent/applyMask.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types';\n\nexport const applyMask = (full: Dictionary, mask: any): Dictionary => {\n // the mask \"true\" → we don't filter\n if (mask === true) {\n return full;\n }\n\n // arrays\n if (Array.isArray(mask) && Array.isArray(full)) {\n return mask.map((m, i) => applyMask(full[i], m)) as any;\n }\n\n // handle node with nodeType property\n if (full && typeof full === 'object' && 'nodeType' in full) {\n if (mask && typeof mask === 'object') {\n return full; // Keep the full object with nodeType intact\n }\n return full;\n }\n\n // generic object\n if (mask && typeof mask === 'object' && full && typeof full === 'object') {\n const out: any = {};\n const maskEntries = Object.entries(mask);\n const allChildrenAreArrays = maskEntries.every(([, value]) =>\n Array.isArray(value)\n );\n\n for (const [k, m] of maskEntries) {\n const fullValue = (full as any)[k];\n\n // If this child is an array, decide preservation rules.\n // - Preserve when all children at this level are arrays in the mask\n // - Also preserve when the array is an array of translation nodes\n if (Array.isArray(m) && Array.isArray(fullValue)) {\n const isTranslationNode = (val: unknown): boolean =>\n !!val && typeof val === 'object' && 'nodeType' in (val as any);\n const isArrayOfTranslationNodes = fullValue.every((item: any) =>\n isTranslationNode(item)\n );\n\n if (!allChildrenAreArrays && !isArrayOfTranslationNodes) {\n continue; // skip incidental arrays when mixed with non-arrays\n }\n }\n\n out[k] = applyMask(fullValue, m);\n }\n return out;\n }\n\n // unexpected case: we return the original value\n return full;\n};\n"],"mappings":"AAEA,MAAa,GAAa,EAAkB,IAA0B,CAEpE,GAAI,IAAS,GACX,OAAO,EAIT,GAAI,MAAM,QAAQ,EAAK,EAAI,MAAM,QAAQ,EAAK,CAC5C,OAAO,EAAK,KAAK,EAAG,IAAM,EAAU,EAAK,GAAI,EAAE,CAAC,CAIlD,GAAI,GAAQ,OAAO,GAAS,UAAY,aAAc,EAIpD,OAFS,EAMX,GAAI,GAAQ,OAAO,GAAS,UAAY,GAAQ,OAAO,GAAS,SAAU,CACxE,IAAM,EAAW,EAAE,CACb,EAAc,OAAO,QAAQ,EAAK,CAClC,EAAuB,EAAY,OAAO,EAAG,KACjD,MAAM,QAAQ,EAAM,CACrB,CAED,IAAK,GAAM,CAAC,EAAG,KAAM,EAAa,CAChC,IAAM,EAAa,EAAa,GAKhC,GAAI,MAAM,QAAQ,EAAE,EAAI,MAAM,QAAQ,EAAU,CAAE,CAChD,IAAM,EAAqB,GACzB,CAAC,CAAC,GAAO,OAAO,GAAQ,UAAY,aAAe,EAC/C,EAA4B,EAAU,MAAO,GACjD,EAAkB,EAAK,CACxB,CAED,GAAI,CAAC,GAAwB,CAAC,EAC5B,SAIJ,EAAI,GAAK,EAAU,EAAW,EAAE,CAElC,OAAO,EAIT,OAAO"}
|
|
1
|
+
{"version":3,"file":"applyMask.mjs","names":[],"sources":["../../../src/reduceDictionaryContent/applyMask.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\n\nexport const applyMask = (full: Dictionary, mask: any): Dictionary => {\n // the mask \"true\" → we don't filter\n if (mask === true) {\n return full;\n }\n\n // arrays\n if (Array.isArray(mask) && Array.isArray(full)) {\n return mask.map((m, i) => applyMask(full[i], m)) as any;\n }\n\n // handle node with nodeType property\n if (full && typeof full === 'object' && 'nodeType' in full) {\n if (mask && typeof mask === 'object') {\n return full; // Keep the full object with nodeType intact\n }\n return full;\n }\n\n // generic object\n if (mask && typeof mask === 'object' && full && typeof full === 'object') {\n const out: any = {};\n const maskEntries = Object.entries(mask);\n const allChildrenAreArrays = maskEntries.every(([, value]) =>\n Array.isArray(value)\n );\n\n for (const [k, m] of maskEntries) {\n const fullValue = (full as any)[k];\n\n // If this child is an array, decide preservation rules.\n // - Preserve when all children at this level are arrays in the mask\n // - Also preserve when the array is an array of translation nodes\n if (Array.isArray(m) && Array.isArray(fullValue)) {\n const isTranslationNode = (val: unknown): boolean =>\n !!val && typeof val === 'object' && 'nodeType' in (val as any);\n const isArrayOfTranslationNodes = fullValue.every((item: any) =>\n isTranslationNode(item)\n );\n\n if (!allChildrenAreArrays && !isArrayOfTranslationNodes) {\n continue; // skip incidental arrays when mixed with non-arrays\n }\n }\n\n out[k] = applyMask(fullValue, m);\n }\n return out;\n }\n\n // unexpected case: we return the original value\n return full;\n};\n"],"mappings":"AAEA,MAAa,GAAa,EAAkB,IAA0B,CAEpE,GAAI,IAAS,GACX,OAAO,EAIT,GAAI,MAAM,QAAQ,EAAK,EAAI,MAAM,QAAQ,EAAK,CAC5C,OAAO,EAAK,KAAK,EAAG,IAAM,EAAU,EAAK,GAAI,EAAE,CAAC,CAIlD,GAAI,GAAQ,OAAO,GAAS,UAAY,aAAc,EAIpD,OAFS,EAMX,GAAI,GAAQ,OAAO,GAAS,UAAY,GAAQ,OAAO,GAAS,SAAU,CACxE,IAAM,EAAW,EAAE,CACb,EAAc,OAAO,QAAQ,EAAK,CAClC,EAAuB,EAAY,OAAO,EAAG,KACjD,MAAM,QAAQ,EAAM,CACrB,CAED,IAAK,GAAM,CAAC,EAAG,KAAM,EAAa,CAChC,IAAM,EAAa,EAAa,GAKhC,GAAI,MAAM,QAAQ,EAAE,EAAI,MAAM,QAAQ,EAAU,CAAE,CAChD,IAAM,EAAqB,GACzB,CAAC,CAAC,GAAO,OAAO,GAAQ,UAAY,aAAe,EAC/C,EAA4B,EAAU,MAAO,GACjD,EAAkB,EAAK,CACxB,CAED,GAAI,CAAC,GAAwB,CAAC,EAC5B,SAIJ,EAAI,GAAK,EAAU,EAAW,EAAE,CAElC,OAAO,EAIT,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reduceDictionaryContent.mjs","names":[],"sources":["../../../src/reduceDictionaryContent/reduceDictionaryContent.ts"],"sourcesContent":["import { getMaskContent } from '@intlayer/core/plugins';\nimport type { Dictionary } from '@intlayer/types';\nimport { applyMask } from './applyMask';\n\nexport const reduceDictionaryContent = (\n fullDictionary: Dictionary,\n partialDictionary: Dictionary\n) => {\n const mask = getMaskContent(partialDictionary);\n const result = applyMask(fullDictionary, mask);\n\n return result;\n};\n"],"mappings":"oGAIA,MAAa,GACX,EACA,IAGe,EAAU,EADZ,EAAe,EAAkB,CACA"}
|
|
1
|
+
{"version":3,"file":"reduceDictionaryContent.mjs","names":[],"sources":["../../../src/reduceDictionaryContent/reduceDictionaryContent.ts"],"sourcesContent":["import { getMaskContent } from '@intlayer/core/plugins';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { applyMask } from './applyMask';\n\nexport const reduceDictionaryContent = (\n fullDictionary: Dictionary,\n partialDictionary: Dictionary\n) => {\n const mask = getMaskContent(partialDictionary);\n const result = applyMask(fullDictionary, mask);\n\n return result;\n};\n"],"mappings":"oGAIA,MAAa,GACX,EACA,IAGe,EAAU,EADZ,EAAe,EAAkB,CACA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{getMarkdownMetadata as e}from"@intlayer/core/markdown";import{getInsertionValues as t,html as n,insert as r,md as i}from"@intlayer/core/transpiler";import{NodeType as a}from"@intlayer/types/nodeType";const o=e=>[/^\s*---/m,/^\s*#+\s/m,/^\s*[-*+]\s/m,/^\s*\d+\.\s/m,/^\s*>\s/m,/\[.+\]\(.+\)/,/!\[.+\]\(.+\)/,/`{1,3}.+`{1,3}/,/\*\*.+\*\*/,/__.+__/,/<(https?:\/\/[^\s>]+)>/].some(t=>t.test(e)),s=e=>t(e).length>0,c=e=>/<[a-zA-Z][a-zA-Z0-9\-.]*(\s+[^>]*)?\/?>/.test(e)||/<\/[a-zA-Z][a-zA-Z0-9\-.]*\s*>/.test(e),l=[a.HTML,a.Markdown,a.Insertion,a.File,a.ReactNode,a.Text,a.Number,a.Boolean,a.Null,a.Unknown],u=(t,a=!0)=>{if(a===!1)return t;let{markdown:d=!0,html:f=!0,insertion:p=!0}=typeof a==`object`?a:{};if(typeof t==`string`)return d&&o(t)?{...i(t),metadata:e(t)}:f&&c(t)?n(t):p&&s(t)?r(t):t;if(Array.isArray(t))return t.map(e=>u(e,a));if(t&&typeof t==`object`){if(`nodeType`in t){let e=t.nodeType;return l.includes(e)?t:e in t?{...t,[e]:u(t[e],a)}:t}let e={};for(let n of Object.keys(t))e[n]=u(t[n],a);return e}return t};export{u as autoDecorateContent};
|
|
2
2
|
//# sourceMappingURL=autoDecorateContent.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autoDecorateContent.mjs","names":[],"sources":["../../../src/utils/autoDecorateContent.ts"],"sourcesContent":["import { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport {\n getInsertionValues,\n html,\n insert,\n md,\n} from '@intlayer/core/transpiler';\nimport { NodeType } from '@intlayer/types';\n\n/**\n * Check if a string is a markdown string\n */\nconst isMarkdown = (str: string): boolean => {\n // Check for common markdown indicators\n const patterns = [\n /^\\s*---/m, // Front Matter\n /^\\s*#+\\s/m, // Headers: # Title\n /^\\s*[-*+]\\s/m, // Unordered lists: - Item or * Item\n /^\\s*\\d+\\.\\s/m, // Ordered lists: 1. Item\n /^\\s*>\\s/m, // Blockquotes: > Quote\n /\\[.+\\]\\(.+\\)/, // Links: [text](url)\n /!\\[.+\\]\\(.+\\)/, // Images: \n /`{1,3}.+`{1,3}/, // Code blocks or inline code: `code` or ```code```\n /\\*\\*.+\\*\\*/, // Bold: **text**\n /__.+__/, // Bold: __text__\n /<(https?:\\/\\/[^\\s>]+)>/, // Autolinks: <http://...>\n ];\n\n return patterns.some((pattern) => pattern.test(str));\n};\n\n/**\n * Check if a string is an insertion string\n */\nconst isInsertion = (str: string): boolean =>\n getInsertionValues(str).length > 0;\n\n/**\n * Check if a string is an HTML/JSX string\n * Matches:\n * - <Tag>\n * - </Tag>\n * - <Tag />\n * - <Tag attribute=\"value\">\n * - <Component.SubComponent>\n */\nconst isHTML = (str: string): boolean => {\n // 1. Matches opening or self-closing tags: <Tag ... > or <Tag ... />\n // - Must start with < followed by a letter (to avoid math comparisons like a < b)\n // - Allows alphanumeric, hyphens, and dots (for Namespaced components) in tag name\n // - Allows attributes until the closing >\n const openTagRegex = /<[a-zA-Z][a-zA-Z0-9\\-.]*(\\s+[^>]*)?\\/?>/;\n\n // 2. Matches closing tags: </Tag>\n const closeTagRegex = /<\\/[a-zA-Z][a-zA-Z0-9\\-.]*\\s*>/;\n\n return openTagRegex.test(str) || closeTagRegex.test(str);\n};\n\nconst leafNodeTypes: string[] = [\n NodeType.HTML,\n NodeType.Markdown,\n NodeType.Insertion,\n NodeType.File,\n NodeType.ReactNode,\n NodeType.Text,\n NodeType.Number,\n NodeType.Boolean,\n NodeType.Null,\n NodeType.Unknown,\n];\n\ntype AutoTransformationOptions = {\n markdown?: boolean;\n html?: boolean;\n insertion?: boolean;\n};\n\n/**\n * Automatically decorate content strings with md() or insert() if they match\n */\nexport const autoDecorateContent = (\n content: any,\n options: boolean | AutoTransformationOptions = true\n): any => {\n if (options === false) {\n return content;\n }\n\n const {\n markdown = true,\n html: htmlOption = true,\n insertion = true,\n } = typeof options === 'object' ? options : {};\n\n if (typeof content === 'string') {\n if (markdown && isMarkdown(content)) {\n const markdownNode = md(content);\n\n return {\n ...markdownNode,\n metadata: getMarkdownMetadata(content),\n };\n }\n\n if (htmlOption && isHTML(content)) {\n return html(content);\n }\n\n if (insertion && isInsertion(content)) {\n return insert(content);\n }\n\n return content;\n }\n\n if (Array.isArray(content)) {\n return content.map((item) => autoDecorateContent(item, options));\n }\n\n if (content && typeof content === 'object') {\n // If it's already a decorated node (has nodeType)\n if ('nodeType' in content) {\n const nodeType = content.nodeType;\n\n // If it's a leaf node type, don't re-decorate its content\n if (leafNodeTypes.includes(nodeType)) {\n return content;\n }\n\n // If it's a container node type (like translation, enumeration, etc.), recurse into its content field\n if (nodeType in content) {\n return {\n ...content,\n [nodeType]: autoDecorateContent(content[nodeType], options),\n };\n }\n\n return content;\n }\n\n // Plain object, recurse into all keys\n const result: Record<string, any> = {};\n for (const key of Object.keys(content)) {\n result[key] = autoDecorateContent(content[key], options);\n }\n return result;\n }\n\n return content;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"autoDecorateContent.mjs","names":[],"sources":["../../../src/utils/autoDecorateContent.ts"],"sourcesContent":["import { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport {\n getInsertionValues,\n html,\n insert,\n md,\n} from '@intlayer/core/transpiler';\nimport { NodeType } from '@intlayer/types/nodeType';\n\n/**\n * Check if a string is a markdown string\n */\nconst isMarkdown = (str: string): boolean => {\n // Check for common markdown indicators\n const patterns = [\n /^\\s*---/m, // Front Matter\n /^\\s*#+\\s/m, // Headers: # Title\n /^\\s*[-*+]\\s/m, // Unordered lists: - Item or * Item\n /^\\s*\\d+\\.\\s/m, // Ordered lists: 1. Item\n /^\\s*>\\s/m, // Blockquotes: > Quote\n /\\[.+\\]\\(.+\\)/, // Links: [text](url)\n /!\\[.+\\]\\(.+\\)/, // Images: \n /`{1,3}.+`{1,3}/, // Code blocks or inline code: `code` or ```code```\n /\\*\\*.+\\*\\*/, // Bold: **text**\n /__.+__/, // Bold: __text__\n /<(https?:\\/\\/[^\\s>]+)>/, // Autolinks: <http://...>\n ];\n\n return patterns.some((pattern) => pattern.test(str));\n};\n\n/**\n * Check if a string is an insertion string\n */\nconst isInsertion = (str: string): boolean =>\n getInsertionValues(str).length > 0;\n\n/**\n * Check if a string is an HTML/JSX string\n * Matches:\n * - <Tag>\n * - </Tag>\n * - <Tag />\n * - <Tag attribute=\"value\">\n * - <Component.SubComponent>\n */\nconst isHTML = (str: string): boolean => {\n // 1. Matches opening or self-closing tags: <Tag ... > or <Tag ... />\n // - Must start with < followed by a letter (to avoid math comparisons like a < b)\n // - Allows alphanumeric, hyphens, and dots (for Namespaced components) in tag name\n // - Allows attributes until the closing >\n const openTagRegex = /<[a-zA-Z][a-zA-Z0-9\\-.]*(\\s+[^>]*)?\\/?>/;\n\n // 2. Matches closing tags: </Tag>\n const closeTagRegex = /<\\/[a-zA-Z][a-zA-Z0-9\\-.]*\\s*>/;\n\n return openTagRegex.test(str) || closeTagRegex.test(str);\n};\n\nconst leafNodeTypes: string[] = [\n NodeType.HTML,\n NodeType.Markdown,\n NodeType.Insertion,\n NodeType.File,\n NodeType.ReactNode,\n NodeType.Text,\n NodeType.Number,\n NodeType.Boolean,\n NodeType.Null,\n NodeType.Unknown,\n];\n\ntype AutoTransformationOptions = {\n markdown?: boolean;\n html?: boolean;\n insertion?: boolean;\n};\n\n/**\n * Automatically decorate content strings with md() or insert() if they match\n */\nexport const autoDecorateContent = (\n content: any,\n options: boolean | AutoTransformationOptions = true\n): any => {\n if (options === false) {\n return content;\n }\n\n const {\n markdown = true,\n html: htmlOption = true,\n insertion = true,\n } = typeof options === 'object' ? options : {};\n\n if (typeof content === 'string') {\n if (markdown && isMarkdown(content)) {\n const markdownNode = md(content);\n\n return {\n ...markdownNode,\n metadata: getMarkdownMetadata(content),\n };\n }\n\n if (htmlOption && isHTML(content)) {\n return html(content);\n }\n\n if (insertion && isInsertion(content)) {\n return insert(content);\n }\n\n return content;\n }\n\n if (Array.isArray(content)) {\n return content.map((item) => autoDecorateContent(item, options));\n }\n\n if (content && typeof content === 'object') {\n // If it's already a decorated node (has nodeType)\n if ('nodeType' in content) {\n const nodeType = content.nodeType;\n\n // If it's a leaf node type, don't re-decorate its content\n if (leafNodeTypes.includes(nodeType)) {\n return content;\n }\n\n // If it's a container node type (like translation, enumeration, etc.), recurse into its content field\n if (nodeType in content) {\n return {\n ...content,\n [nodeType]: autoDecorateContent(content[nodeType], options),\n };\n }\n\n return content;\n }\n\n // Plain object, recurse into all keys\n const result: Record<string, any> = {};\n for (const key of Object.keys(content)) {\n result[key] = autoDecorateContent(content[key], options);\n }\n return result;\n }\n\n return content;\n};\n"],"mappings":"+MAYA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
+
import{join as e,normalize as t}from"node:path";import n from"fast-glob";const r=e=>Array.isArray(e)?e:[e],i=i=>{let{transformPattern:a,excludePattern:o,baseDir:s}=i,c=r(a).filter(e=>typeof e==`string`&&!e.startsWith(`!`)).map(t),l=[...r(o),...r(a).filter(e=>typeof e==`string`&&e.startsWith(`!`)).map(e=>e.slice(1))].filter(e=>typeof e==`string`).map(t);return n.sync(c,{cwd:s,ignore:l}).map(t=>e(s,t))};export{i as buildFilesList};
|
|
2
2
|
//# sourceMappingURL=buildFilesList.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildFilesList.mjs","names":[],"sources":["../../../src/utils/buildFilesList.ts"],"sourcesContent":["import { join } from 'node:path';\nimport fg from 'fast-glob';\n\n/**\n * Options for building the files list\n */\nexport type BuildFilesListOptions = {\n /**\n * Glob patterns to match files\n */\n transformPattern: string | string[];\n /**\n * Glob patterns to exclude files\n */\n excludePattern: string | string[];\n /**\n * Base directory for file resolution\n */\n baseDir: string;\n};\n\n/**\n * Normalizes a pattern value to an array\n */\nconst normalizeToArray = <T>(value: T | T[]): T[]
|
|
1
|
+
{"version":3,"file":"buildFilesList.mjs","names":[],"sources":["../../../src/utils/buildFilesList.ts"],"sourcesContent":["import { join, normalize } from 'node:path';\nimport fg from 'fast-glob';\n\n/**\n * Options for building the files list\n */\nexport type BuildFilesListOptions = {\n /**\n * Glob patterns to match files\n */\n transformPattern: string | string[];\n /**\n * Glob patterns to exclude files\n */\n excludePattern: string | string[];\n /**\n * Base directory for file resolution\n */\n baseDir: string;\n};\n\n/**\n * Normalizes a pattern value to an array\n */\nconst normalizeToArray = <T>(value: T | T[]): T[] =>\n Array.isArray(value) ? value : [value];\n\n/**\n * Builds a list of files matching the given patterns.\n *\n * This utility consolidates the file listing logic used across multiple compilers\n * (Vue, Svelte, Vite) to avoid code duplication.\n *\n * @param options - Configuration options for building the file list\n * @returns Array of absolute file paths matching the patterns\n *\n * @example\n * // Basic usage\n * const files = buildFilesList({\n * transformPattern: 'src/**\\/*.{ts,tsx}',\n * excludePattern: ['**\\/node_modules;\\/**'],\n * baseDir: '/path/to/project',\n * });\n *\n * @example\n * // With framework extension (Vue)\n * const files = buildFilesList({\n * transformPattern: 'src/**\\/*.{ts,tsx}',\n * excludePattern: ['**\\/node_modules\\/**'],\n * baseDir: '/path/to/project',\n * });\n */\nexport const buildFilesList = (options: BuildFilesListOptions): string[] => {\n const { transformPattern, excludePattern, baseDir } = options;\n\n // Ensure patterns are strings and not empty\n const patterns = normalizeToArray(transformPattern)\n .filter(\n (pattern): pattern is string =>\n typeof pattern === 'string' && !pattern.startsWith('!')\n )\n .map(normalize); // Ensure it works with Windows\n\n // Filter out undefined/null from the combined exclude list\n const excludePatterns = [\n ...normalizeToArray(excludePattern),\n ...normalizeToArray(transformPattern)\n .filter(\n (pattern): pattern is string =>\n typeof pattern === 'string' && pattern.startsWith('!')\n )\n .map((pattern) => pattern.slice(1)),\n ]\n .filter((pattern): pattern is string => typeof pattern === 'string')\n .map(normalize); // Ensure it works with Windows\n\n const files = fg\n .sync(patterns, {\n cwd: baseDir,\n ignore: excludePatterns,\n })\n .map((file) => join(baseDir, file));\n\n return files;\n};\n"],"mappings":"yEAwBA,MAAM,EAAuB,GAC3B,MAAM,QAAQ,EAAM,CAAG,EAAQ,CAAC,EAAM,CA2B3B,EAAkB,GAA6C,CAC1E,GAAM,CAAE,mBAAkB,iBAAgB,WAAY,EAGhD,EAAW,EAAiB,EAAiB,CAChD,OACE,GACC,OAAO,GAAY,UAAY,CAAC,EAAQ,WAAW,IAAI,CAC1D,CACA,IAAI,EAAU,CAGX,EAAkB,CACtB,GAAG,EAAiB,EAAe,CACnC,GAAG,EAAiB,EAAiB,CAClC,OACE,GACC,OAAO,GAAY,UAAY,EAAQ,WAAW,IAAI,CACzD,CACA,IAAK,GAAY,EAAQ,MAAM,EAAE,CAAC,CACtC,CACE,OAAQ,GAA+B,OAAO,GAAY,SAAS,CACnE,IAAI,EAAU,CASjB,OAPc,EACX,KAAK,EAAU,CACd,IAAK,EACL,OAAQ,EACT,CAAC,CACD,IAAK,GAAS,EAAK,EAAS,EAAK,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{relative as e}from"node:path";import{ANSIColors as t,colorize as n,colorizePath as r}from"@intlayer/config/logger";import i from"@intlayer/config/built";import{getLocaleName as a}from"@intlayer/core/localization";import
|
|
1
|
+
import{relative as e}from"node:path";import{ANSIColors as t,colorize as n,colorizePath as r}from"@intlayer/config/logger";import i from"@intlayer/config/built";import{getLocaleName as a}from"@intlayer/core/localization";import*as o from"@intlayer/types/locales";const s=(t,n)=>[t].flat().map(t=>t.startsWith(`/`)?e(i.system.baseDir,t):t).map(e=>n===!1?e:r(e,n)).join(`, `),c=(e,r=t.GREEN)=>[e].flat().map(e=>`${a(e,o.ENGLISH)} (${e})`).map(e=>r===!1?e:n(e,r)).join(`, `);export{c as formatLocale,s as formatPath};
|
|
2
2
|
//# sourceMappingURL=formatter.mjs.map
|