evaluateBundleEntry method
Evaluate the entry module of bundle in the worker.
The whole graph is already compiled and registered, so this runs the entry without parsing anything and without a single module round trip. Throws a JSError when the instance was built without a bundle.
Implementation
Future<dynamic> evaluateBundleEntry() async {
if (bundle == null) {
throw JSError('IsolateQjs was created without a module bundle');
}
_ensureEngine();
final evaluatePort = ReceivePort();
final sendPort = await _sendPort!;
final msg = {
#type: #evaluateBundleEntry,
#port: evaluatePort.sendPort,
};
if (_hostFunctions.isNotEmpty && !_hostFunctionsBound) {
msg[#functions] = _encodeData(_hostFunctions);
_hostFunctionsBound = true;
}
sendPort.send(msg);
final result = await evaluatePort.first;
evaluatePort.close();
if (result is Map && result.containsKey(#error)) {
throw _decodeData(result[#error]);
}
return _decodeData(result);
}