ModuleManager constructor

ModuleManager(
  1. EngineContext _context,
  2. List<APIProvider>? packages
)

Implementation

ModuleManager(this._context, List<APIProvider>? packages)
    : _anrMonitor = ModuleAnrMonitor(_context) {
  if (packages == null) {
    return;
  }

  for (var provider in packages) {
    final nativeModuleGeneratorList = provider.nativeModuleGeneratorList;
    final jsModuleGeneratorList = provider.javaScriptModuleGeneratorList;
    final controllerGeneratorList = provider.controllerGeneratorList;

    for (var element in nativeModuleGeneratorList) {
      _nativeModule[element.name] = element.generateModule(_context);
    }

    for (var element in jsModuleGeneratorList) {
      _jsModule[element.name] = element.generateJsModule(_context);
    }

    // 只用来记录,方便给后续 checkApi 检查
    for (var element in controllerGeneratorList) {
      _controllerGenerator[element.name] = '';
    }
  }
}