components/node_modules/vue-docgen-api/dist/utils/adaptExportsToIEV.js
/**
 * Resolves specified variables to their actual files
 * Useful when using intermeriary files like this
 *
 * ```js
 * export mixin from "path/to/mixin"
 * ```
 *
 * @param pathResolver
 * @param varToFilePath
 */
Resolves specified variables to their actual files
Useful when using intermeriary files like this



@param pathResolver
@param varToFilePath
Resolves specified variables to their actual files Useful when using intermeriary files like this @param pathResolver @param varToFilePath
function adaptExportsToIEV(pathResolver, varToFilePath, validExtends) {
    return __awaiter(this, void 0, void 0, function () {
        var filePathToVars;
        var _this = this;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    filePathToVars = new ts_map_1.default();
                    Object.keys(varToFilePath).forEach(function (k) {
                        var exportedVariable = varToFilePath[k];
                        exportedVariable.filePath.forEach(function (filePath) {
                            var exportToLocalMap = filePathToVars.get(filePath) || new ts_map_1.default();
                            exportToLocalMap.set(k, exportedVariable.exportName);
                            filePathToVars.set(filePath, exportToLocalMap);
                        });
                    });
                    return [4 , Promise.all(filePathToVars.entries().map(function (_a) {
                            var filePath = _a[0], exportToLocal = _a[1];
                            return __awaiter(_this, void 0, void 0, function () {
                                var exportedVariableNames_1, fullFilePath_1, source_1, astRemote, returnedVariables_1, e_1;
                                return __generator(this, function (_b) {
                                    switch (_b.label) {
                                        case 0:
                                            if (!(filePath && exportToLocal)) return [3 , 4];
                                            exportedVariableNames_1 = [];
                                            exportToLocal.forEach(function (exportedName) {
                                                if (exportedName) {
                                                    exportedVariableNames_1.push(exportedName);
                                                }
                                            });
                                            _b.label = 1;
                                        case 1:
                                            _b.trys.push([1, 3, , 4]);
                                            fullFilePath_1 = pathResolver(filePath);
                                            if (!validExtends(fullFilePath_1)) {
                                                return [2 ];
                                            }
                                            return [4 , read(fullFilePath_1, {
                                                    encoding: 'utf-8'
                                                })];
                                        case 2:
                                            source_1 = _b.sent();
                                            astRemote = cacher_1.default(function () { return recast_1.default.parse(source_1, { parser: babel_parser_1.default() }); }, source_1);
                                            returnedVariables_1 = resolveImmediatelyExported_1.default(astRemote, exportedVariableNames_1);
                                            if (Object.keys(returnedVariables_1).length) {
                                                exportToLocal.forEach(function (exported, local) {
                                                    if (exported && local) {
                                                        var aliasedVariable = returnedVariables_1[exported];
                                                        if (aliasedVariable) {
                                                            aliasedVariable.filePath = aliasedVariable.filePath.map(function (p) {
                                                                return pathResolver(p, path.dirname(fullFilePath_1));
                                                            });
                                                            varToFilePath[local] = aliasedVariable;
                                                        }
                                                    }
                                                });
                                            }
                                            return [3 , 4];
                                        case 3:
                                            e_1 = _b.sent();
                                            return [3 , 4];
                                        case 4: return [2 ];
                                    }
                                });
                            });
                        }))];
                case 1:
                    _a.sent();
                    return [2 ];
            }
        });
    });
}
function adaptExportsToIEV ( pathResolver , varToFilePath , validExtends ) { return __awaiter ( this , void 0 , void 0 , function ( ) { var filePathToVars ; var _this = this ; return __generator ( this , function ( _a ) { switch ( _a . label ) { case 0 : filePathToVars = new ts_map_1 . default ( ) ; Object . keys ( varToFilePath ) . forEach ( function ( k ) { var exportedVariable = varToFilePath [ k ] ; exportedVariable . filePath . forEach ( function ( filePath ) { var exportToLocalMap = filePathToVars . get ( filePath ) || new ts_map_1 . default ( ) ; exportToLocalMap . set ( k , exportedVariable . exportName ) ; filePathToVars . set ( filePath , exportToLocalMap ) ; } ) ; } ) ; return [ 4 , Promise . all ( filePathToVars . entries ( ) . map ( function ( _a ) { var filePath = _a [ 0 ] , exportToLocal = _a [ 1 ] ; return __awaiter ( _this , void 0 , void 0 , function ( ) { var exportedVariableNames_1 , fullFilePath_1 , source_1 , astRemote , returnedVariables_1 , e_1 ; return __generator ( this , function ( _b ) { switch ( _b . label ) { case 0 : if ( ! ( filePath && exportToLocal ) ) return [ 3 , 4 ] ; exportedVariableNames_1 = [ ] ; exportToLocal . forEach ( function ( exportedName ) { if ( exportedName ) { exportedVariableNames_1 . push ( exportedName ) ; } } ) ; _b . label = 1 ; case 1 : _b . trys . push ( [ 1 , 3 , , 4 ] ) ; fullFilePath_1 = pathResolver ( filePath ) ; if ( ! validExtends ( fullFilePath_1 ) ) { return [ 2 ] ; } return [ 4 , read ( fullFilePath_1 , { encoding : 'utf-8' } ) ] ; case 2 : source_1 = _b . sent ( ) ; astRemote = cacher_1 . default ( function ( ) { return recast_1 . default . parse ( source_1 , { parser : babel_parser_1 . default ( ) } ) ; } , source_1 ) ; returnedVariables_1 = resolveImmediatelyExported_1 . default ( astRemote , exportedVariableNames_1 ) ; if ( Object . keys ( returnedVariables_1 ) . length ) { exportToLocal . forEach ( function ( exported , local ) { if ( exported && local ) { var aliasedVariable = returnedVariables_1 [ exported ] ; if ( aliasedVariable ) { aliasedVariable . filePath = aliasedVariable . filePath . map ( function ( p ) { return pathResolver ( p , path . dirname ( fullFilePath_1 ) ) ; } ) ; varToFilePath [ local ] = aliasedVariable ; } } } ) ; } return [ 3 , 4 ] ; case 3 : e_1 = _b . sent ( ) ; return [ 3 , 4 ] ; case 4 : return [ 2 ] ; } } ) ; } ) ; } ) ) ] ; case 1 : _a . sent ( ) ; return [ 2 ] ; } } ) ; } ) ; }
Resolves specified variables to their actual files
 Useful when using intermeriary files like this
Resolves specified variables to their actual files Useful when using intermeriary files like this
// then roll though this map and replace varToFilePath elements with their final destinations // { //	nameOfVariable:{filePath:['filesWhereToFindIt'], exportedName:'nameUsedInExportThatCanBeUsedForFiltering'} // } /*yield*/ /*break*/ /*return*/ /*yield*/ /*break*/ /*break*/ /*return*/ // then roll though this map and replace varToFilePath elements with their final destinations // { //	nameOfVariable:{filePath:['filesWhereToFindIt'], exportedName:'nameUsedInExportThatCanBeUsedForFiltering'} // } /*return*/