scan static method

Future<PluginRegistry> scan({
  1. required String lookupPath,
  2. List<String> lookupExts = const ['.dart', '.dill'],
})

Implementation

static Future<PluginRegistry> scan({
  required String lookupPath,
  List<String> lookupExts = const ['.dart', '.dill'],
}) async {
  var res = await _findAllPluginFiles(p.absolute(lookupPath), lookupExts)
      .map(
        (e) async {
          var iip = ManagerIntercom(e.uri);
          await iip.initialize(timeout: Duration(seconds: 2));
          return iip;
        },
      )
      .asyncMap((e) => e.then(
            (e) async {
              var res = Tuple2(
                  await e.sendWaitWhere(
                    Message(MessageType.INTRO_REQUEST),
                    Filters.ofType([MessageType.PLUGIN_INTRO]),
                  ),
                  e.uri);
              e.close();
              return res;
            },
          ))
      .map((e) => KnownPlugin.forPlugin(
            Plugin.fromJson(assertTyped(e.item1.content)),
            e.item2,
          ))
      .toList();

  return PluginRegistry.__(res);
}