createGruntChannel function

Future<DuplexChannel> createGruntChannel(
  1. GruntFactory<Grunt> fn, {
  2. required bool isProduction,
})

Implementation

Future<DuplexChannel> createGruntChannel(GruntFactory fn,
    {required bool isProduction}) async {
  print("Launching grunt channel!");
  var fullPath = "";
  final package = fn.package;
  final path = fn.key;
  if (isProduction == true) {
    fullPath = "/assets";
    if (fn.package != null) {
      fullPath += "/packages/${fn.package}";
    }
    fullPath += "/lib/${fn.key}.grunt.dart.js";
  } else {
    var childUrl = "";
    if (package != null) {
      childUrl += "/packages/$package";
    }
    childUrl += "/$path.grunt.dart.lib.js";
    fullPath =
        "/assets/packages/worker_service/lib/bootstrap_dev.js?grl=${Uri.encodeFull(childUrl)}";
  }
  var ww = web.Worker(fullPath);
  return WebDuplexChannel(ww, fn.encoding, debugLabel: 'main app');
}