Skip to content

Commit a10d7c6

Browse files
authored
Use @internal to cordon off internal-only Value APIs (#1379)
Lays the groundwork for #236 Note that we need to add a bunch of explicit @Nodoc annotations to work around dart-lang/dartdoc#2418 and dart-lang/dartdoc#2419.
1 parent 268f22e commit a10d7c6

32 files changed

+557
-751
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
* Fix a race condition where `meta.load-css()` could trigger an internal error
2323
when running in asynchronous mode.
2424

25+
### Dart API
26+
27+
* Use the `@internal` annotation to indicate which `Value` APIs are available
28+
for public use.
29+
2530
## 1.35.1
2631

2732
* Fix a bug where the quiet dependency flag didn't silence warnings in some

lib/sass.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ export 'src/exception.dart' show SassException;
2424
export 'src/importer.dart';
2525
export 'src/logger.dart';
2626
export 'src/syntax.dart';
27-
export 'src/value.dart' show ListSeparator;
28-
export 'src/value/external/value.dart';
27+
export 'src/value.dart';
2928
export 'src/visitor/serialize.dart' show OutputStyle;
3029
export 'src/warn.dart' show warn;
3130

lib/src/callable.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import 'package:meta/meta.dart';
77
import 'callable/async.dart';
88
import 'callable/built_in.dart';
99
import 'value.dart';
10-
import 'value/external/value.dart' as ext;
1110

1211
export 'callable/async.dart';
1312
export 'callable/async_built_in.dart';
@@ -67,7 +66,7 @@ export 'callable/user_defined.dart';
6766
abstract class Callable extends AsyncCallable {
6867
@Deprecated('Use `Callable.function` instead.')
6968
factory Callable(String name, String arguments,
70-
ext.Value callback(List<ext.Value> arguments)) =>
69+
Value callback(List<Value> arguments)) =>
7170
Callable.function(name, arguments, callback);
7271

7372
/// Creates a function with the given [name] and [arguments] that runs
@@ -113,7 +112,6 @@ abstract class Callable extends AsyncCallable {
113112
/// which provides access to keyword arguments using
114113
/// [SassArgumentList.keywords].
115114
factory Callable.function(String name, String arguments,
116-
ext.Value callback(List<ext.Value> arguments)) =>
117-
BuiltInCallable.function(
118-
name, arguments, (arguments) => callback(arguments) as Value);
115+
Value callback(List<Value> arguments)) =>
116+
BuiltInCallable.function(name, arguments, callback);
119117
}

lib/src/callable/async.dart

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import 'dart:async';
77
import 'package:meta/meta.dart';
88

99
import '../value.dart';
10-
import '../value/external/value.dart' as ext;
1110
import 'async_built_in.dart';
1211

1312
/// An interface for functions and mixins that can be invoked from Sass by
@@ -25,7 +24,7 @@ abstract class AsyncCallable {
2524

2625
@Deprecated('Use `AsyncCallable.function` instead.')
2726
factory AsyncCallable(String name, String arguments,
28-
FutureOr<ext.Value> callback(List<ext.Value> arguments)) =>
27+
FutureOr<Value> callback(List<Value> arguments)) =>
2928
AsyncCallable.function(name, arguments, callback);
3029

3130
/// Creates a callable with the given [name] and [arguments] that runs
@@ -36,10 +35,6 @@ abstract class AsyncCallable {
3635
///
3736
/// See [new Callable] for more details.
3837
factory AsyncCallable.function(String name, String arguments,
39-
FutureOr<ext.Value> callback(List<ext.Value> arguments)) =>
40-
AsyncBuiltInCallable.function(name, arguments, (arguments) {
41-
var result = callback(arguments);
42-
if (result is ext.Value) return result as Value;
43-
return result.then((value) => value as Value);
44-
});
38+
FutureOr<Value> callback(List<Value> arguments)) =>
39+
AsyncBuiltInCallable.function(name, arguments, callback);
4540
}

lib/src/exception.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ body::before {
7878
}
7979
}
8080

81-
/// A [SassException] that's also a [MultiSpanSassException].
81+
/// A [SassException] that's also a [MultiSourceSpanException].
8282
class MultiSpanSassException extends SassException
8383
implements MultiSourceSpanException {
8484
final String primaryLabel;

lib/src/functions/meta.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ final global = UnmodifiableListView([
4040
if (value is SassColor) return SassString("color", quotes: false);
4141
if (value is SassList) return SassString("list", quotes: false);
4242
if (value is SassMap) return SassString("map", quotes: false);
43-
if (value is SassNull) return SassString("null", quotes: false);
43+
if (value == sassNull) return SassString("null", quotes: false);
4444
if (value is SassNumber) return SassString("number", quotes: false);
4545
if (value is SassFunction) return SassString("function", quotes: false);
4646
assert(value is SassString);

lib/src/node/exports.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Exports {
1414
external set renderSync(Function function);
1515
external set info(String info);
1616
external set types(Types types);
17-
external set NULL(SassNull sassNull);
17+
external set NULL(Value sassNull);
1818
external set TRUE(SassBoolean sassTrue);
1919
external set FALSE(SassBoolean sassFalse);
2020
}

0 commit comments

Comments
 (0)