33// https://opensource.org/licenses/MIT.
44
55import 'dart:convert' ;
6- import 'dart:io' ;
7- import 'dart:isolate' ;
6+ import 'dart:isolate' if (dart.library.js) 'js/isolate.dart' ;
87import 'dart:typed_data' ;
98
10- import 'package:native_synchronization/mailbox.dart' ;
119import 'package:path/path.dart' as p;
1210import 'package:protobuf/protobuf.dart' ;
1311import 'package:pub_semver/pub_semver.dart' ;
1412import 'package:sass/sass.dart' as sass;
1513import 'package:sass/src/importer/node_package.dart' as npi;
1614
15+ import '../io.dart' ;
1716import '../logger.dart' ;
1817import '../value/function.dart' ;
1918import '../value/mixin.dart' ;
@@ -23,6 +22,7 @@ import 'host_callable.dart';
2322import 'importer/file.dart' ;
2423import 'importer/host.dart' ;
2524import 'logger.dart' ;
25+ import 'sync_receive_port.dart' ;
2626import 'util/proto_extensions.dart' ;
2727import 'utils.dart' ;
2828
@@ -35,8 +35,8 @@ final _outboundRequestId = 0;
3535/// A class that dispatches messages to and from the host for a single
3636/// compilation.
3737final class CompilationDispatcher {
38- /// The mailbox for receiving messages from the host.
39- final Mailbox _mailbox ;
38+ /// The synchronous receive port for receiving messages from the host.
39+ final SyncReceivePort _receivePort ;
4040
4141 /// The send port for sending messages to the host.
4242 final SendPort _sendPort;
@@ -52,8 +52,8 @@ final class CompilationDispatcher {
5252 late Uint8List _compilationIdVarint;
5353
5454 /// Creates a [CompilationDispatcher] that receives encoded protocol buffers
55- /// through [_mailbox ] and sends them through [_sendPort] .
56- CompilationDispatcher (this ._mailbox , this ._sendPort);
55+ /// through [_receivePort ] and sends them through [_sendPort] .
56+ CompilationDispatcher (this ._receivePort , this ._sendPort);
5757
5858 /// Listens for incoming `CompileRequests` and runs their compilations.
5959 void listen () {
@@ -384,9 +384,9 @@ final class CompilationDispatcher {
384384 /// Receive a packet from the host.
385385 Uint8List _receive () {
386386 try {
387- return _mailbox. take ();
387+ return _receivePort. receive ();
388388 } on StateError catch (_) {
389- // The [_mailbox ] has been closed, exit the current isolate immediately
389+ // The [SyncReceivePort ] has been closed, exit the current isolate immediately
390390 // to avoid bubble the error up as [SassException] during [_sendRequest].
391391 Isolate .exit ();
392392 }
0 commit comments