| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:isolate'; | 6 import 'dart:isolate'; |
| 7 | 7 |
| 8 import 'package:barback/barback.dart'; | 8 import 'package:barback/barback.dart'; |
| 9 // TODO(nweiz): don't import from "src" once issue 14966 is fixed. | 9 // TODO(nweiz): don't import from "src" once issue 14966 is fixed. |
| 10 import 'package:barback/src/internal_asset.dart'; | 10 import 'package:barback/src/internal_asset.dart'; |
| 11 | 11 |
| 12 import '../serialize.dart'; | 12 import '../serialize.dart'; |
| 13 import 'get_input_transform.dart'; | 13 import 'get_input_transform.dart'; |
| 14 | 14 |
| 15 /// Serialize the methods shared between [AggregateTransform] and | 15 /// Serialize the methods shared between [AggregateTransform] and |
| 16 /// [DeclaringAggregateTransform]. | 16 /// [DeclaringAggregateTransform]. |
| 17 /// | 17 /// |
| 18 /// [additionalFields] contains additional serialized fields to add to the | 18 /// [additionalFields] contains additional serialized fields to add to the |
| 19 /// serialized transform. [methodHandlers] is a set of additional methods. Each | 19 /// serialized transform. [methodHandlers] is a set of additional methods. Each |
| 20 /// value should take a JSON message and return the response (which may be a | 20 /// value should take a JSON message and return the response (which may be a |
| 21 /// Future). | 21 /// Future). |
| 22 Map _serializeBaseAggregateTransform(transform, Map additionalFields, | 22 Map _serializeBaseAggregateTransform(transform, |
| 23 Map<String, dynamic> additionalFields, |
| 23 Map<String, Function> methodHandlers) { | 24 Map<String, Function> methodHandlers) { |
| 24 var receivePort = new ReceivePort(); | 25 var receivePort = new ReceivePort(); |
| 25 receivePort.listen((wrappedMessage) { | 26 receivePort.listen((wrappedMessage) { |
| 26 respond(wrappedMessage, (message) { | 27 respond(wrappedMessage, (message) { |
| 27 var handler = methodHandlers[message['type']]; | 28 var handler = methodHandlers[message['type']]; |
| 28 if (handler != null) return handler(message); | 29 if (handler != null) return handler(message); |
| 29 | 30 |
| 30 if (message['type'] == 'consumePrimary') { | 31 if (message['type'] == 'consumePrimary') { |
| 31 transform.consumePrimary(deserializeId(message['assetId'])); | 32 transform.consumePrimary(deserializeId(message['assetId'])); |
| 32 return null; | 33 return null; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 transform['primaryIds'], deserializeId), | 160 transform['primaryIds'], deserializeId), |
| 160 super(transform); | 161 super(transform); |
| 161 | 162 |
| 162 void declareOutput(AssetId id) { | 163 void declareOutput(AssetId id) { |
| 163 call(_port, { | 164 call(_port, { |
| 164 'type': 'declareOutput', | 165 'type': 'declareOutput', |
| 165 'output': serializeId(id) | 166 'output': serializeId(id) |
| 166 }); | 167 }); |
| 167 } | 168 } |
| 168 } | 169 } |
| OLD | NEW |