Revert "Reland "[pkg:js/dart:js_interop] Move annotations to dart:_js_annotations""
This reverts commit 9e1997971e6abb3283567adb5480fbb0fb0cb040.
Reason for revert: Breaks Dart -> Engine roll?
See:
https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20linux_web_engine/1821/overview
https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20Engine%20Drone/666824/overview
Original change's description:
> Reland "[pkg:js/dart:js_interop] Move annotations to dart:_js_annotations"
>
> This is a reland of commit fbe9c2197221a9aca98ae4aaa766164e8ab12d78
>
> This fixes the issue with the duplicate allowPlatformPrivateLibraryAccess.
>
> Original change's description:
> > [pkg:js/dart:js_interop] Move annotations to dart:_js_annotations
> >
> > This moves package:js annotations to the internal library that
> > Flutter has been using already. This gives us a single location
> > for all package:js annotations. We also introduce a @JS annotation
> > in dart:js_interop since we can no longer use dart:_js_annotations
> > to avoid the breaking change in semantics.
> >
> > CoreLibraryReviewExempt: Backend-specific internal library.
> > Change-Id: I9ca55c807d7d192004a6da99f63a72d598fe4f12
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284760
> > Commit-Queue: Srujan Gaddam <srujzs@google.com>
> > Reviewed-by: Samuel Rawlins <srawlins@google.com>
> > Reviewed-by: Johnni Winther <johnniwinther@google.com>
> > Reviewed-by: Joshua Litt <joshualitt@google.com>
>
> CoreLibraryReviewExempt: Relanding.
> Change-Id: I40ff2a00682fccbd7dd44a364b5046aaac0f3bac
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293203
> Reviewed-by: Joshua Litt <joshualitt@google.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Samuel Rawlins <srawlins@google.com>
Change-Id: Ide8609575c73d714f3ae4f9ea9ffc74e228fa189
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293962
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
diff --git a/pkg/_js_interop_checks/lib/src/js_interop.dart b/pkg/_js_interop_checks/lib/src/js_interop.dart
index 5620e4c..c3be7f1 100644
--- a/pkg/_js_interop_checks/lib/src/js_interop.dart
+++ b/pkg/_js_interop_checks/lib/src/js_interop.dart
@@ -5,33 +5,33 @@
import 'package:kernel/kernel.dart';
import 'package:kernel/util/graph.dart' as kernel_graph;
-/// Returns true iff the node has an `@JS(...)` annotation from the internal
-/// `dart:_js_annotations` or `dart:js_interop`.
+/// Returns true iff the node has an `@JS(...)` annotation from `package:js` or
+/// from the internal `dart:_js_annotations`.
bool hasJSInteropAnnotation(Annotatable a) =>
- a.annotations.any(_isJSInteropAnnotation);
+ a.annotations.any(_isPublicJSAnnotation);
-/// Returns true iff the node has an `@JS(...)` annotation from
-/// `dart:js_interop`.
-bool hasDartJSInteropAnnotation(Annotatable a) =>
- a.annotations.any(_isDartJSInteropAnnotation);
-
-/// Returns true iff the node has an `@anonymous` annotation from the internal
+/// Returns true iff the node has an `@JS(...)` annotation from the internal
/// `dart:_js_annotations`.
+bool hasInternalJSInteropAnnotation(Annotatable a) =>
+ a.annotations.any(_isInternalJSAnnotation);
+
+/// Returns true iff the node has an `@anonymous` annotation from `package:js`
+/// or from the internal `dart:_js_annotations`.
bool hasAnonymousAnnotation(Annotatable a) =>
a.annotations.any(_isAnonymousAnnotation);
-/// Returns true iff the node has an `@staticInterop` annotation from the
-/// internal `dart:_js_annotations`.
+/// Returns true iff the node has an `@staticInterop` annotation from
+/// `package:js` or from the internal `dart:_js_annotations`.
bool hasStaticInteropAnnotation(Annotatable a) =>
a.annotations.any(_isStaticInteropAnnotation);
-/// Returns true iff the node has an `@trustTypes` annotation from the internal
-/// `dart:_js_annotations`.
+/// Returns true iff the node has an `@trustTypes` annotation from
+/// `package:js` or from the internal `dart:_js_annotations`.
bool hasTrustTypesAnnotation(Annotatable a) =>
a.annotations.any(_isTrustTypesAnnotation);
-/// Returns true iff the node has an `@JSExport(...)` annotation from the
-/// internal `dart:_js_annotations`.
+/// Returns true iff the node has an `@JSExport(...)` annotation from
+/// `package:js` or from the internal `dart:_js_annotations`.
bool hasJSExportAnnotation(Annotatable a) =>
a.annotations.any(_isJSExportAnnotation);
@@ -53,7 +53,7 @@
String getJSName(Annotatable a) {
String jsClass = '';
for (var annotation in a.annotations) {
- if (_isJSInteropAnnotation(annotation)) {
+ if (_isPublicJSAnnotation(annotation)) {
var jsClasses = stringAnnotationValues(annotation);
if (jsClasses.isNotEmpty) {
jsClass = jsClasses[0];
@@ -102,29 +102,30 @@
return jsExportValue;
}
+final _packageJs = Uri.parse('package:js/js.dart');
final _internalJs = Uri.parse('dart:_js_annotations');
final _jsHelper = Uri.parse('dart:_js_helper');
final _jsInterop = Uri.parse('dart:js_interop');
/// Returns true if [value] is the interop annotation whose class is
-/// [annotationClassName] from `dart:_js_annotations` or `dart:js_interop`.
+/// [annotationClassName] from `package:js` or from `dart:_js_annotations`.
///
-/// If [dartJsInteropOnly] is true, we only check if it's the annotation from
-/// `dart:js_interop`.
+/// If [internalJsOnly] is true, we only check if it's the annotation from
+/// `dart:_js_annotations`.
bool _isInteropAnnotation(Expression value, String annotationClassName,
- {bool dartJsInteropOnly = false}) {
+ {bool internalJsOnly = false}) {
var c = annotationClass(value);
if (c == null || c.name != annotationClassName) return false;
var importUri = c.enclosingLibrary.importUri;
- if (dartJsInteropOnly) return importUri == _jsInterop;
- return importUri == _internalJs || importUri == _jsInterop;
+ if (internalJsOnly) return importUri == _internalJs;
+ return importUri == _packageJs || importUri == _internalJs;
}
-bool _isJSInteropAnnotation(Expression value) =>
- _isInteropAnnotation(value, 'JS');
+bool _isInternalJSAnnotation(Expression value) =>
+ _isInteropAnnotation(value, 'JS', internalJsOnly: true);
-bool _isDartJSInteropAnnotation(Expression value) =>
- _isInteropAnnotation(value, 'JS', dartJsInteropOnly: true);
+bool _isPublicJSAnnotation(Expression value) =>
+ _isInteropAnnotation(value, 'JS');
bool _isAnonymousAnnotation(Expression value) =>
_isInteropAnnotation(value, '_Anonymous');
@@ -159,10 +160,9 @@
///
/// For example:
///
-/// - `@JS()` would return the "JS" class in "dart:_js_annotations".
-/// - `@anonymous` would return the "_Anonymous" class in "dart:_js_annotations".
-/// - `@staticInterop` would return the "_StaticInterop" class in
-/// "dart:_js_annotations".
+/// - `@JS()` would return the "JS" class in "package:js".
+/// - `@anonymous` would return the "_Anonymous" class in "package:js".
+/// - `@staticInterop` would return the "_StaticInterop" class in "package:js".
/// - `@Native` would return the "Native" class in "dart:_js_helper".
///
/// This function works regardless of whether the CFE is evaluating constants,
diff --git a/pkg/_js_interop_checks/lib/src/transformations/js_util_optimizer.dart b/pkg/_js_interop_checks/lib/src/transformations/js_util_optimizer.dart
index 484a887..fc58818 100644
--- a/pkg/_js_interop_checks/lib/src/transformations/js_util_optimizer.dart
+++ b/pkg/_js_interop_checks/lib/src/transformations/js_util_optimizer.dart
@@ -11,7 +11,7 @@
show
getJSName,
hasAnonymousAnnotation,
- hasDartJSInteropAnnotation,
+ hasInternalJSInteropAnnotation,
hasJSInteropAnnotation,
hasNativeAnnotation,
hasObjectLiteralAnnotation,
@@ -69,6 +69,11 @@
late InlineExtensionIndex _inlineExtensionIndex;
+ static const Set<String> _existingJsAnnotationsUsers = {
+ 'dart:_engine',
+ 'dart:ui'
+ };
+
JsUtilOptimizer(this._coreTypes, ClassHierarchy hierarchy)
: _callMethodTarget =
_coreTypes.index.getTopLevelProcedure('dart:js_util', 'callMethod'),
@@ -228,8 +233,17 @@
if (!node.isInlineClassMember &&
node.enclosingClass == null &&
- (hasDartJSInteropAnnotation(node) ||
- hasDartJSInteropAnnotation(node.enclosingLibrary))) {
+ ((hasInternalJSInteropAnnotation(node) ||
+ hasInternalJSInteropAnnotation(node.enclosingLibrary)) &&
+ !_existingJsAnnotationsUsers
+ .contains(node.enclosingLibrary.importUri.toString()))) {
+ // Top-level external member. We only lower top-levels if we're using the
+ // `dart:_js_annotations`' `@JS` annotation to avoid a breaking change for
+ // `package:js` users. There are some internal libraries that already use
+ // this library, so we exclude them here.
+ // TODO(srujzs): When they're ready to migrate to sound semantics, we
+ // should remove this exception.
+
// If the `@JS` value of the node has any '.'s, we take the entries
// before the last '.' to determine the dotted prefix name.
var jsName = getJSName(node);
@@ -878,24 +892,24 @@
}
bool isJSInteropMember(Procedure node) {
- if (hasDartJSInteropAnnotation(node) ||
- hasDartJSInteropAnnotation(node.enclosingLibrary) ||
+ if (hasInternalJSInteropAnnotation(node) ||
+ hasInternalJSInteropAnnotation(node.enclosingLibrary) ||
(node.enclosingClass != null &&
- hasDartJSInteropAnnotation(node.enclosingClass!))) {
+ hasInternalJSInteropAnnotation(node.enclosingClass!))) {
return true;
}
if (node.isExtensionMember) {
final annotatable = getExtensionAnnotatable(node.reference);
if (annotatable != null) {
- return hasDartJSInteropAnnotation(annotatable);
+ return hasInternalJSInteropAnnotation(annotatable);
}
}
if (node.isInlineClassMember) {
final cls = getInlineClass(node.reference);
if (cls != null) {
- return hasDartJSInteropAnnotation(cls);
+ return hasInternalJSInteropAnnotation(cls);
}
}
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 4a555ae..e4c492f 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -2014,8 +2014,8 @@
/// The name of the class used to JS annotate an element.
static const String _jsClassName = 'JS';
- /// The name of `_js_annotations` library, used to define JS annotations.
- static const String _jsLibName = '_js_annotations';
+ /// The name of `js` library, used to define JS annotations.
+ static const String _jsLibName = 'js';
/// The name of `meta` library, used to define analysis annotations.
static const String _metaLibName = 'meta';
diff --git a/pkg/compiler/lib/src/common/elements.dart b/pkg/compiler/lib/src/common/elements.dart
index 6d094e3..b127137 100644
--- a/pkg/compiler/lib/src/common/elements.dart
+++ b/pkg/compiler/lib/src/common/elements.dart
@@ -143,6 +143,10 @@
late final LibraryEntity? dartJsUtilLibrary =
_env.lookupLibrary(Uris.dart_js_util);
+ /// The package:js library.
+ late final LibraryEntity? packageJsLibrary =
+ _env.lookupLibrary(Uris.package_js);
+
/// The dart:_js_annotations library.
late final LibraryEntity? dartJsAnnotationsLibrary =
_env.lookupLibrary(Uris.dart__js_annotations);
@@ -1049,17 +1053,35 @@
class KCommonElements extends CommonElements {
KCommonElements(super.dartTypes, super.env);
- late final ClassEntity? jsAnnotationClass =
+ // From package:js
+
+ late final ClassEntity? jsAnnotationClass1 =
+ _findClassOrNull(packageJsLibrary, 'JS');
+
+ late final ClassEntity? jsAnonymousClass1 =
+ _findClassOrNull(packageJsLibrary, '_Anonymous');
+
+ // From dart:_js_annotations
+
+ late final ClassEntity? jsAnnotationClass2 =
_findClassOrNull(dartJsAnnotationsLibrary, 'JS');
- late final ClassEntity? jsAnonymousClass =
+ late final ClassEntity? jsAnonymousClass2 =
_findClassOrNull(dartJsAnnotationsLibrary, '_Anonymous');
/// Returns `true` if [cls] is a @JS() annotation.
- bool isJsAnnotationClass(ClassEntity cls) => cls == jsAnnotationClass;
+ ///
+ /// The class can come from either `package:js` or `dart:_js_annotations`.
+ bool isJsAnnotationClass(ClassEntity cls) {
+ return cls == jsAnnotationClass1 || cls == jsAnnotationClass2;
+ }
/// Returns `true` if [cls] is an @anonymous annotation.
- bool isJsAnonymousClass(ClassEntity cls) => cls == jsAnonymousClass;
+ ///
+ /// The class can come from either `package:js` or `dart:_js_annotations`.
+ bool isJsAnonymousClass(ClassEntity cls) {
+ return cls == jsAnonymousClass1 || cls == jsAnonymousClass2;
+ }
late final ClassEntity pragmaClass = _findClass(coreLibrary, 'pragma');
diff --git a/pkg/compiler/lib/src/common/names.dart b/pkg/compiler/lib/src/common/names.dart
index 9eb2979..6a05d788 100644
--- a/pkg/compiler/lib/src/common/names.dart
+++ b/pkg/compiler/lib/src/common/names.dart
@@ -266,6 +266,9 @@
/// The URI for 'dart:js_util'.
static final Uri dart_js_util = Uri(scheme: 'dart', path: 'js_util');
+ /// The URI for 'package:js'.
+ static final Uri package_js = Uri(scheme: 'package', path: 'js/js.dart');
+
/// The URI for 'dart:_js_annotations'.
static final Uri dart__js_annotations =
Uri(scheme: 'dart', path: '_js_annotations');
diff --git a/pkg/compiler/lib/src/ir/annotations.dart b/pkg/compiler/lib/src/ir/annotations.dart
index 8c4b8ff..e52d0c5 100644
--- a/pkg/compiler/lib/src/ir/annotations.dart
+++ b/pkg/compiler/lib/src/ir/annotations.dart
@@ -332,13 +332,9 @@
String? _getJsInteropName(ir.Constant constant) {
if (constant is ir.InstanceConstant &&
constant.classNode.name == 'JS' &&
- (constant.classNode.enclosingLibrary.importUri ==
- Uris.dart__js_annotations ||
- // TODO(srujzs): For now, this allows using `dart:js_interop`'s `@JS`
- // for `package:js` classes. In the future, we should either further
- // dedup or disallow this.
+ (constant.classNode.enclosingLibrary.importUri == Uris.package_js ||
constant.classNode.enclosingLibrary.importUri ==
- Uris.dart__js_interop)) {
+ Uris.dart__js_annotations)) {
assert(constant.fieldValues.length == 1);
ir.Constant fieldValue = constant.fieldValues.values.single;
if (fieldValue is ir.NullConstant) {
@@ -353,15 +349,17 @@
bool _isAnonymousJsInterop(ir.Constant constant) {
return constant is ir.InstanceConstant &&
constant.classNode.name == '_Anonymous' &&
- constant.classNode.enclosingLibrary.importUri ==
- Uris.dart__js_annotations;
+ (constant.classNode.enclosingLibrary.importUri == Uris.package_js ||
+ constant.classNode.enclosingLibrary.importUri ==
+ Uris.dart__js_annotations);
}
bool _isStaticInterop(ir.Constant constant) {
return constant is ir.InstanceConstant &&
constant.classNode.name == '_StaticInterop' &&
- constant.classNode.enclosingLibrary.importUri ==
- Uris.dart__js_annotations;
+ (constant.classNode.enclosingLibrary.importUri == Uris.package_js ||
+ constant.classNode.enclosingLibrary.importUri ==
+ Uris.dart__js_annotations);
}
bool _isJsInteropObjectLiteral(ir.Constant constant) {
diff --git a/pkg/compiler/lib/src/js_backend/native_data.dart b/pkg/compiler/lib/src/js_backend/native_data.dart
index 56af23b..faccfbc 100644
--- a/pkg/compiler/lib/src/js_backend/native_data.dart
+++ b/pkg/compiler/lib/src/js_backend/native_data.dart
@@ -225,9 +225,8 @@
// consider these valid JS members?
if (memberIsIgnorable(node)) return;
jsInteropMembers[map.getMember(node)] = name;
- if (isJsInteropObjectLiteral) {
+ if (isJsInteropObjectLiteral)
jsInteropObjectLiterals.add(map.getMember(node));
- }
});
return NativeBasicData(
diff --git a/pkg/compiler/lib/src/kernel/dart2js_target.dart b/pkg/compiler/lib/src/kernel/dart2js_target.dart
index aaf045a..feba344 100644
--- a/pkg/compiler/lib/src/kernel/dart2js_target.dart
+++ b/pkg/compiler/lib/src/kernel/dart2js_target.dart
@@ -129,8 +129,7 @@
super.allowPlatformPrivateLibraryAccess(importer, imported) ||
maybeEnableNative(importer) ||
(importer.isScheme('package') &&
- (importer.path.startsWith('dart2js_runtime_metrics/') ||
- importer.path == 'js/js.dart'));
+ importer.path.startsWith('dart2js_runtime_metrics/'));
@override
bool enableNative(Uri uri) => maybeEnableNative(uri);
diff --git a/pkg/compiler/lib/src/kernel/native_basic_data.dart b/pkg/compiler/lib/src/kernel/native_basic_data.dart
index 2887162..2276e60 100644
--- a/pkg/compiler/lib/src/kernel/native_basic_data.dart
+++ b/pkg/compiler/lib/src/kernel/native_basic_data.dart
@@ -40,8 +40,10 @@
String? annotationName;
for (ConstantValue value in metadata) {
String? name = readAnnotationName(commonElements.dartTypes, spannable,
- value, commonElements.jsAnnotationClass!,
- defaultValue: '');
+ value, commonElements.jsAnnotationClass1!, defaultValue: '') ??
+ readAnnotationName(commonElements.dartTypes, spannable, value,
+ commonElements.jsAnnotationClass2!,
+ defaultValue: '');
if (annotationName == null) {
annotationName = name;
} else if (name != null) {
diff --git a/pkg/dart2wasm/lib/js_runtime_generator.dart b/pkg/dart2wasm/lib/js_runtime_generator.dart
index 5f81356..0986daf 100644
--- a/pkg/dart2wasm/lib/js_runtime_generator.dart
+++ b/pkg/dart2wasm/lib/js_runtime_generator.dart
@@ -903,11 +903,11 @@
Component component, CoreTypes coreTypes, ClassHierarchy classHierarchy) {
Set<Library> transitiveImportingJSInterop = {
...?calculateTransitiveImportsOfJsInteropIfUsed(
+ component, Uri.parse("package:js/js.dart")),
+ ...?calculateTransitiveImportsOfJsInteropIfUsed(
component, Uri.parse("dart:_js_annotations")),
...?calculateTransitiveImportsOfJsInteropIfUsed(
component, Uri.parse("dart:_js_helper")),
- ...?calculateTransitiveImportsOfJsInteropIfUsed(
- component, Uri.parse("dart:js_interop")),
};
Map<Procedure, String> jsInteropMethods = {};
jsInteropMethods = _performJSInteropTransformations(
diff --git a/pkg/dart2wasm/lib/target.dart b/pkg/dart2wasm/lib/target.dart
index a91718f..54194cf 100644
--- a/pkg/dart2wasm/lib/target.dart
+++ b/pkg/dart2wasm/lib/target.dart
@@ -87,8 +87,7 @@
bool allowPlatformPrivateLibraryAccess(Uri importer, Uri imported) =>
super.allowPlatformPrivateLibraryAccess(importer, imported) ||
- importer.path.contains('tests/web/wasm') ||
- importer.isScheme('package') && importer.path == 'js/js.dart';
+ importer.path.contains('tests/web/wasm');
void _patchHostEndian(CoreTypes coreTypes) {
// Fix Endian.host to be a const field equal to Endian.little instead of
@@ -155,9 +154,9 @@
ChangedStructureNotifier? changedStructureNotifier}) {
Set<Library> transitiveImportingJSInterop = {
...?jsInteropHelper.calculateTransitiveImportsOfJsInteropIfUsed(
- component, Uri.parse("dart:_js_annotations")),
+ component, Uri.parse("package:js/js.dart")),
...?jsInteropHelper.calculateTransitiveImportsOfJsInteropIfUsed(
- component, Uri.parse("dart:js_interop")),
+ component, Uri.parse("dart:_js_annotations"))
};
if (transitiveImportingJSInterop.isEmpty) {
logger?.call("Skipped JS interop transformations");
diff --git a/pkg/dev_compiler/lib/src/kernel/compiler.dart b/pkg/dev_compiler/lib/src/kernel/compiler.dart
index 1bf42d6..4b503fe 100644
--- a/pkg/dev_compiler/lib/src/kernel/compiler.dart
+++ b/pkg/dev_compiler/lib/src/kernel/compiler.dart
@@ -2833,7 +2833,7 @@
js_ast.LiteralString? _emitJSInteropExternalStaticMemberName(NamedNode n) {
if (!usesJSInterop(n)) return null;
if (n is Member && !n.isExternal) return null;
- var name = _annotationName(n, isJSInteropAnnotation) ?? getTopLevelName(n);
+ var name = _annotationName(n, isPublicJSAnnotation) ?? getTopLevelName(n);
assert(!name.contains('.'),
'JS interop checker rejects dotted names on static class members');
return js.escapedString(name, "'");
@@ -2909,9 +2909,8 @@
String? _jsNameWithoutGlobal(NamedNode n) {
if (!usesJSInterop(n)) return null;
- var libraryJSName = _annotationName(getLibrary(n), isJSInteropAnnotation);
- var jsName =
- _annotationName(n, isJSInteropAnnotation) ?? getTopLevelName(n);
+ var libraryJSName = _annotationName(getLibrary(n), isPublicJSAnnotation);
+ var jsName = _annotationName(n, isPublicJSAnnotation) ?? getTopLevelName(n);
return libraryJSName != null ? '$libraryJSName.$jsName' : jsName;
}
diff --git a/pkg/dev_compiler/lib/src/kernel/js_interop.dart b/pkg/dev_compiler/lib/src/kernel/js_interop.dart
index e0172a4..a9663a5 100644
--- a/pkg/dev_compiler/lib/src/kernel/js_interop.dart
+++ b/pkg/dev_compiler/lib/src/kernel/js_interop.dart
@@ -7,7 +7,7 @@
import 'kernel_helpers.dart';
/// Returns true if [library] is one of the [candidates].
-/// The latter should be a list, e.g.,: ['dart:js', 'dart:_js_annotations'].
+/// The latter should be a list, e.g.,: ['dart:js', 'package:js'].
bool _isLibrary(Library library, List<String> candidates) {
var uri = library.importUri;
var scheme = uri.scheme;
@@ -21,17 +21,13 @@
return false;
}
-/// Returns true if [library] represents any library from
-/// `dart:_foreign_helper`, `dart:_js_annotations`, `dart:_js_helper`, or
-/// `dart:js_interop`.
+/// Returns true if [library] represents any library from `package:js` or is the
+/// internal `dart:_js_helper` library.
bool _isJSLibrary(Library library) => _isLibrary(library, [
- 'dart:_foreign_helper',
- 'dart:_js_annotations',
+ 'package:js',
'dart:_js_helper',
- // TODO(srujzs): For now, this allows using `dart:js_interop`'s `@JS` for
- // `package:js` classes. In the future, we should either further dedup or
- // disallow this.
- 'dart:js_interop',
+ 'dart:_foreign_helper',
+ 'dart:_js_annotations'
]);
/// Whether [node] is a direct call to `allowInterop`.
@@ -71,9 +67,8 @@
bool isJSAnnotation(Expression value) =>
_annotationIsFromJSLibrary('JS', value) || isJSName(value);
-/// Returns [true] if [value] is the `JS` annotation from
-/// `dart:_js_annotations` or `dart:js_interop`.
-bool isJSInteropAnnotation(Expression value) =>
+/// Returns [true] if [value] is the `JS` annotation from `package:js`.
+bool isPublicJSAnnotation(Expression value) =>
_annotationIsFromJSLibrary('JS', value);
bool _isJSAnonymousAnnotation(Expression value) =>
@@ -83,7 +78,7 @@
_annotationIsFromJSLibrary('_StaticInterop', value);
/// Whether [value] is a `@JSExportName` (internal annotation used in SDK
-/// instead of `@JS` from `dart:_js_annotations`).
+/// instead of `@JS` from `package:js`).
bool isJSExportNameAnnotation(Expression value) =>
isBuiltinAnnotation(value, '_foreign_helper', 'JSExportName');
@@ -130,20 +125,18 @@
bool hasObjectLiteralAnnotation(Annotatable a) =>
a.annotations.any(isObjectLiteralAnnotation);
-/// Returns true iff the class has an `@JS(...)` annotation from
-/// `dart:_js_annotations` or `dart:js_interop`.
+/// Returns true iff the class has an `@JS(...)` annotation from `package:js`.
///
-/// Note: usually [usesJSInterop] should be used instead of this.
+/// Note: usually [_usesJSInterop] should be used instead of this.
//
// TODO(jmesserly): I think almost all uses of this should be replaced with
-// [usesJSInterop], which also checks that the library is marked with `@JS`.
+// [_usesJSInterop], which also checks that the library is marked with `@JS`.
//
// Right now we have inconsistencies: sometimes we'll respect `@JS` on the
// class itself, other places we require it on the library. Also members are
// inconsistent: sometimes they need to have `@JS` on them, other times they
// need to be `external` in an `@JS` class.
-bool hasJSInteropAnnotation(Class c) =>
- c.annotations.any(isJSInteropAnnotation);
+bool hasJSInteropAnnotation(Class c) => c.annotations.any(isPublicJSAnnotation);
/// Returns true iff this element is a JS interop member.
///
@@ -154,11 +147,11 @@
/// the class or library.
bool usesJSInterop(NamedNode n) {
if (n is Member && n.isExternal) {
- return n.enclosingLibrary.annotations.any(isJSInteropAnnotation) ||
- n.annotations.any(isJSInteropAnnotation) ||
- (n.enclosingClass?.annotations.any(isJSInteropAnnotation) ?? false);
+ return n.enclosingLibrary.annotations.any(isPublicJSAnnotation) ||
+ n.annotations.any(isPublicJSAnnotation) ||
+ (n.enclosingClass?.annotations.any(isPublicJSAnnotation) ?? false);
} else if (n is Class) {
- return n.annotations.any(isJSInteropAnnotation);
+ return n.annotations.any(isPublicJSAnnotation);
}
return false;
}
diff --git a/pkg/dev_compiler/lib/src/kernel/kernel_helpers.dart b/pkg/dev_compiler/lib/src/kernel/kernel_helpers.dart
index 3182a20..39026d4 100644
--- a/pkg/dev_compiler/lib/src/kernel/kernel_helpers.dart
+++ b/pkg/dev_compiler/lib/src/kernel/kernel_helpers.dart
@@ -101,9 +101,8 @@
///
/// For example:
///
-/// - `@JS()` would return the "JS" class in "dart:_js_annotations".
-/// - `@anonymous` would return the "_Anonymous" class in
-/// "dart:_js_annotations".
+/// - `@JS()` would return the "JS" class in "package:js".
+/// - `@anonymous` would return the "_Anonymous" class in "package:js".
///
/// This function works regardless of whether the CFE is evaluating constants,
/// or whether the constant is a field reference (such as "anonymous" above).
diff --git a/pkg/dev_compiler/lib/src/kernel/target.dart b/pkg/dev_compiler/lib/src/kernel/target.dart
index 7dd162c..f3dd50d 100644
--- a/pkg/dev_compiler/lib/src/kernel/target.dart
+++ b/pkg/dev_compiler/lib/src/kernel/target.dart
@@ -145,8 +145,7 @@
super.allowPlatformPrivateLibraryAccess(importer, imported) ||
_allowedTestLibrary(importer) ||
(importer.isScheme('package') &&
- (importer.path.startsWith('dart2js_runtime_metrics/') ||
- importer.path == 'js/js.dart'));
+ importer.path.startsWith('dart2js_runtime_metrics/'));
@override
bool get nativeExtensionExpectsString => false;
diff --git a/pkg/front_end/testcases/dart2js/inline_class/external.dart.strong.expect b/pkg/front_end/testcases/dart2js/inline_class/external.dart.strong.expect
index 4f4c762..d445d81 100644
--- a/pkg/front_end/testcases/dart2js/inline_class/external.dart.strong.expect
+++ b/pkg/front_end/testcases/dart2js/inline_class/external.dart.strong.expect
@@ -1,7 +1,7 @@
@#C2
library static_interop /*isNonNullableByDefault*/;
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "package:js/js.dart";
@@ -79,7 +79,7 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
+ #C2 = js::JS {name:#C1}
#C3 = static-tearoff self::B|staticMethod
#C4 = static-tearoff self::B|staticGenericMethod
#C5 = instantiation #C4 <core::String>
@@ -88,5 +88,5 @@
Constructor coverage from constants:
org-dartlang-testcase:///external.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/dart2js/inline_class/external.dart.strong.transformed.expect b/pkg/front_end/testcases/dart2js/inline_class/external.dart.strong.transformed.expect
index 1ba0250..0b3b191 100644
--- a/pkg/front_end/testcases/dart2js/inline_class/external.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/dart2js/inline_class/external.dart.strong.transformed.expect
@@ -1,7 +1,7 @@
@#C2
library static_interop /*isNonNullableByDefault*/;
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "dart:js_util" as js_;
@@ -94,7 +94,7 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
+ #C2 = js::JS {name:#C1}
#C3 = static-tearoff self::B|staticMethod
#C4 = static-tearoff self::B|staticGenericMethod
#C5 = instantiation #C4 <core::String>
@@ -103,5 +103,5 @@
Constructor coverage from constants:
org-dartlang-testcase:///external.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/dart2js/inline_class/external.dart.weak.expect b/pkg/front_end/testcases/dart2js/inline_class/external.dart.weak.expect
index 9a283a7..f620a48 100644
--- a/pkg/front_end/testcases/dart2js/inline_class/external.dart.weak.expect
+++ b/pkg/front_end/testcases/dart2js/inline_class/external.dart.weak.expect
@@ -1,7 +1,7 @@
@#C2
library static_interop /*isNonNullableByDefault*/;
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "package:js/js.dart";
@@ -79,7 +79,7 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
+ #C2 = js::JS {name:#C1}
#C3 = static-tearoff self::B|staticMethod
#C4 = static-tearoff self::B|staticGenericMethod
#C5 = instantiation #C4 <core::String*>
@@ -88,5 +88,5 @@
Constructor coverage from constants:
org-dartlang-testcase:///external.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/dart2js/inline_class/external.dart.weak.modular.expect b/pkg/front_end/testcases/dart2js/inline_class/external.dart.weak.modular.expect
index 9a283a7..f620a48 100644
--- a/pkg/front_end/testcases/dart2js/inline_class/external.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/dart2js/inline_class/external.dart.weak.modular.expect
@@ -1,7 +1,7 @@
@#C2
library static_interop /*isNonNullableByDefault*/;
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "package:js/js.dart";
@@ -79,7 +79,7 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
+ #C2 = js::JS {name:#C1}
#C3 = static-tearoff self::B|staticMethod
#C4 = static-tearoff self::B|staticGenericMethod
#C5 = instantiation #C4 <core::String*>
@@ -88,5 +88,5 @@
Constructor coverage from constants:
org-dartlang-testcase:///external.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/dart2js/inline_class/external.dart.weak.outline.expect b/pkg/front_end/testcases/dart2js/inline_class/external.dart.weak.outline.expect
index d79dda2..e505260 100644
--- a/pkg/front_end/testcases/dart2js/inline_class/external.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/dart2js/inline_class/external.dart.weak.outline.expect
@@ -1,7 +1,7 @@
-@_js_annotations::JS::•()
+@js::JS::•()
library static_interop /*isNonNullableByDefault*/;
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "package:js/js.dart";
@@ -10,7 +10,7 @@
synthetic constructor •() → self::A
;
}
-@_js::JS::•()
+@js::JS::•()
inline class B /* declaredRepresentationType = self::A */ {
get field = self::B|get#field;
set field = self::B|set#field;
diff --git a/pkg/front_end/testcases/dart2js/inline_class/external.dart.weak.transformed.expect b/pkg/front_end/testcases/dart2js/inline_class/external.dart.weak.transformed.expect
index a02f5d2..afecb08 100644
--- a/pkg/front_end/testcases/dart2js/inline_class/external.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/dart2js/inline_class/external.dart.weak.transformed.expect
@@ -1,7 +1,7 @@
@#C2
library static_interop /*isNonNullableByDefault*/;
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "dart:js_util" as js_;
@@ -94,7 +94,7 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
+ #C2 = js::JS {name:#C1}
#C3 = static-tearoff self::B|staticMethod
#C4 = static-tearoff self::B|staticGenericMethod
#C5 = instantiation #C4 <core::String*>
@@ -103,5 +103,5 @@
Constructor coverage from constants:
org-dartlang-testcase:///external.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/dartdevc/inline_class/external.dart.strong.expect b/pkg/front_end/testcases/dartdevc/inline_class/external.dart.strong.expect
index 4f4c762..d445d81 100644
--- a/pkg/front_end/testcases/dartdevc/inline_class/external.dart.strong.expect
+++ b/pkg/front_end/testcases/dartdevc/inline_class/external.dart.strong.expect
@@ -1,7 +1,7 @@
@#C2
library static_interop /*isNonNullableByDefault*/;
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "package:js/js.dart";
@@ -79,7 +79,7 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
+ #C2 = js::JS {name:#C1}
#C3 = static-tearoff self::B|staticMethod
#C4 = static-tearoff self::B|staticGenericMethod
#C5 = instantiation #C4 <core::String>
@@ -88,5 +88,5 @@
Constructor coverage from constants:
org-dartlang-testcase:///external.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/dartdevc/inline_class/external.dart.strong.transformed.expect b/pkg/front_end/testcases/dartdevc/inline_class/external.dart.strong.transformed.expect
index 1ba0250..0b3b191 100644
--- a/pkg/front_end/testcases/dartdevc/inline_class/external.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/dartdevc/inline_class/external.dart.strong.transformed.expect
@@ -1,7 +1,7 @@
@#C2
library static_interop /*isNonNullableByDefault*/;
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "dart:js_util" as js_;
@@ -94,7 +94,7 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
+ #C2 = js::JS {name:#C1}
#C3 = static-tearoff self::B|staticMethod
#C4 = static-tearoff self::B|staticGenericMethod
#C5 = instantiation #C4 <core::String>
@@ -103,5 +103,5 @@
Constructor coverage from constants:
org-dartlang-testcase:///external.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/dartdevc/inline_class/external.dart.weak.expect b/pkg/front_end/testcases/dartdevc/inline_class/external.dart.weak.expect
index 9a283a7..f620a48 100644
--- a/pkg/front_end/testcases/dartdevc/inline_class/external.dart.weak.expect
+++ b/pkg/front_end/testcases/dartdevc/inline_class/external.dart.weak.expect
@@ -1,7 +1,7 @@
@#C2
library static_interop /*isNonNullableByDefault*/;
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "package:js/js.dart";
@@ -79,7 +79,7 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
+ #C2 = js::JS {name:#C1}
#C3 = static-tearoff self::B|staticMethod
#C4 = static-tearoff self::B|staticGenericMethod
#C5 = instantiation #C4 <core::String*>
@@ -88,5 +88,5 @@
Constructor coverage from constants:
org-dartlang-testcase:///external.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/dartdevc/inline_class/external.dart.weak.modular.expect b/pkg/front_end/testcases/dartdevc/inline_class/external.dart.weak.modular.expect
index 9a283a7..f620a48 100644
--- a/pkg/front_end/testcases/dartdevc/inline_class/external.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/dartdevc/inline_class/external.dart.weak.modular.expect
@@ -1,7 +1,7 @@
@#C2
library static_interop /*isNonNullableByDefault*/;
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "package:js/js.dart";
@@ -79,7 +79,7 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
+ #C2 = js::JS {name:#C1}
#C3 = static-tearoff self::B|staticMethod
#C4 = static-tearoff self::B|staticGenericMethod
#C5 = instantiation #C4 <core::String*>
@@ -88,5 +88,5 @@
Constructor coverage from constants:
org-dartlang-testcase:///external.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/dartdevc/inline_class/external.dart.weak.outline.expect b/pkg/front_end/testcases/dartdevc/inline_class/external.dart.weak.outline.expect
index 159e93b..a0ccff2 100644
--- a/pkg/front_end/testcases/dartdevc/inline_class/external.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/dartdevc/inline_class/external.dart.weak.outline.expect
@@ -1,7 +1,7 @@
-@_js_annotations::JS::•()
+@js::JS::•()
library static_interop /*isNonNullableByDefault*/;
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "package:js/js.dart";
@@ -10,7 +10,7 @@
synthetic constructor •() → self::A
;
}
-@_js::JS::•()
+@js::JS::•()
inline class B /* declaredRepresentationType = self::A */ {
get field = self::B|get#field;
set field = self::B|set#field;
diff --git a/pkg/front_end/testcases/dartdevc/inline_class/external.dart.weak.transformed.expect b/pkg/front_end/testcases/dartdevc/inline_class/external.dart.weak.transformed.expect
index a02f5d2..afecb08 100644
--- a/pkg/front_end/testcases/dartdevc/inline_class/external.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/dartdevc/inline_class/external.dart.weak.transformed.expect
@@ -1,7 +1,7 @@
@#C2
library static_interop /*isNonNullableByDefault*/;
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "dart:js_util" as js_;
@@ -94,7 +94,7 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
+ #C2 = js::JS {name:#C1}
#C3 = static-tearoff self::B|staticMethod
#C4 = static-tearoff self::B|staticGenericMethod
#C5 = instantiation #C4 <core::String*>
@@ -103,5 +103,5 @@
Constructor coverage from constants:
org-dartlang-testcase:///external.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/dartdevc/static_interop_erasure/main.dart.strong.expect b/pkg/front_end/testcases/dartdevc/static_interop_erasure/main.dart.strong.expect
index c1d8d97..8eff892 100644
--- a/pkg/front_end/testcases/dartdevc/static_interop_erasure/main.dart.strong.expect
+++ b/pkg/front_end/testcases/dartdevc/static_interop_erasure/main.dart.strong.expect
@@ -12,7 +12,7 @@
@#C2
library static_interop /*isNonNullableByDefault*/;
import self as sta;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "dart:js_util" as js_;
@@ -39,14 +39,14 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
+ #C2 = js::JS {name:#C1}
#C3 = "JSClass"
- #C4 = _js::JS {name:#C3}
- #C5 = _js::_StaticInterop {}
+ #C4 = js::JS {name:#C3}
+ #C5 = js::_StaticInterop {}
}
Constructor coverage from constants:
org-dartlang-testcase:///main_lib.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/dartdevc/static_interop_erasure/main.dart.strong.transformed.expect b/pkg/front_end/testcases/dartdevc/static_interop_erasure/main.dart.strong.transformed.expect
index c1d8d97..8eff892 100644
--- a/pkg/front_end/testcases/dartdevc/static_interop_erasure/main.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/dartdevc/static_interop_erasure/main.dart.strong.transformed.expect
@@ -12,7 +12,7 @@
@#C2
library static_interop /*isNonNullableByDefault*/;
import self as sta;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "dart:js_util" as js_;
@@ -39,14 +39,14 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
+ #C2 = js::JS {name:#C1}
#C3 = "JSClass"
- #C4 = _js::JS {name:#C3}
- #C5 = _js::_StaticInterop {}
+ #C4 = js::JS {name:#C3}
+ #C5 = js::_StaticInterop {}
}
Constructor coverage from constants:
org-dartlang-testcase:///main_lib.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/dartdevc/static_interop_erasure/main.dart.weak.expect b/pkg/front_end/testcases/dartdevc/static_interop_erasure/main.dart.weak.expect
index c1d8d97..8eff892 100644
--- a/pkg/front_end/testcases/dartdevc/static_interop_erasure/main.dart.weak.expect
+++ b/pkg/front_end/testcases/dartdevc/static_interop_erasure/main.dart.weak.expect
@@ -12,7 +12,7 @@
@#C2
library static_interop /*isNonNullableByDefault*/;
import self as sta;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "dart:js_util" as js_;
@@ -39,14 +39,14 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
+ #C2 = js::JS {name:#C1}
#C3 = "JSClass"
- #C4 = _js::JS {name:#C3}
- #C5 = _js::_StaticInterop {}
+ #C4 = js::JS {name:#C3}
+ #C5 = js::_StaticInterop {}
}
Constructor coverage from constants:
org-dartlang-testcase:///main_lib.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/dartdevc/static_interop_erasure/main.dart.weak.outline.expect b/pkg/front_end/testcases/dartdevc/static_interop_erasure/main.dart.weak.outline.expect
index 279a973..39440eb 100644
--- a/pkg/front_end/testcases/dartdevc/static_interop_erasure/main.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/dartdevc/static_interop_erasure/main.dart.weak.outline.expect
@@ -9,7 +9,7 @@
@#C2
library static_interop /*isNonNullableByDefault*/;
import self as self2;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "dart:js_util" as js_;
@@ -34,14 +34,14 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
+ #C2 = js::JS {name:#C1}
#C3 = "JSClass"
- #C4 = _js::JS {name:#C3}
- #C5 = _js::_StaticInterop {}
+ #C4 = js::JS {name:#C3}
+ #C5 = js::_StaticInterop {}
}
Constructor coverage from constants:
org-dartlang-testcase:///main_lib.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/dartdevc/static_interop_erasure/main.dart.weak.transformed.expect b/pkg/front_end/testcases/dartdevc/static_interop_erasure/main.dart.weak.transformed.expect
index c1d8d97..8eff892 100644
--- a/pkg/front_end/testcases/dartdevc/static_interop_erasure/main.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/dartdevc/static_interop_erasure/main.dart.weak.transformed.expect
@@ -12,7 +12,7 @@
@#C2
library static_interop /*isNonNullableByDefault*/;
import self as sta;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "dart:js_util" as js_;
@@ -39,14 +39,14 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
+ #C2 = js::JS {name:#C1}
#C3 = "JSClass"
- #C4 = _js::JS {name:#C3}
- #C5 = _js::_StaticInterop {}
+ #C4 = js::JS {name:#C3}
+ #C5 = js::_StaticInterop {}
}
Constructor coverage from constants:
org-dartlang-testcase:///main_lib.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.strong.expect b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.strong.expect
index bafa6dc..899feae 100644
--- a/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.strong.expect
+++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.strong.expect
@@ -10,7 +10,7 @@
// ^
//
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "package:js/js.dart";
@@ -28,12 +28,12 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
- #C3 = _js::_Anonymous {}
+ #C2 = js::JS {name:#C1}
+ #C3 = js::_Anonymous {}
}
Constructor coverage from constants:
org-dartlang-testcase:///issue46123.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.strong.transformed.expect b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.strong.transformed.expect
index bafa6dc..899feae 100644
--- a/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.strong.transformed.expect
@@ -10,7 +10,7 @@
// ^
//
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "package:js/js.dart";
@@ -28,12 +28,12 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
- #C3 = _js::_Anonymous {}
+ #C2 = js::JS {name:#C1}
+ #C3 = js::_Anonymous {}
}
Constructor coverage from constants:
org-dartlang-testcase:///issue46123.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.expect b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.expect
index bafa6dc..899feae 100644
--- a/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.expect
+++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.expect
@@ -10,7 +10,7 @@
// ^
//
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "package:js/js.dart";
@@ -28,12 +28,12 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
- #C3 = _js::_Anonymous {}
+ #C2 = js::JS {name:#C1}
+ #C3 = js::_Anonymous {}
}
Constructor coverage from constants:
org-dartlang-testcase:///issue46123.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.modular.expect b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.modular.expect
index bafa6dc..899feae 100644
--- a/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.modular.expect
@@ -10,7 +10,7 @@
// ^
//
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "package:js/js.dart";
@@ -28,12 +28,12 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
- #C3 = _js::_Anonymous {}
+ #C2 = js::JS {name:#C1}
+ #C3 = js::_Anonymous {}
}
Constructor coverage from constants:
org-dartlang-testcase:///issue46123.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.outline.expect b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.outline.expect
index f44a2d1..d79fbe5 100644
--- a/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.outline.expect
@@ -1,12 +1,12 @@
library /*isNonNullableByDefault*/;
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "package:js/js.dart";
-@_js::JS::•()
-@_js::anonymous
+@js::JS::•()
+@js::anonymous
class ParallaxOptions extends core::Object {
external static factory •() → self::ParallaxOptions;
static method _#new#tearOff() → self::ParallaxOptions
diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.transformed.expect b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.transformed.expect
index bafa6dc..899feae 100644
--- a/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.transformed.expect
@@ -10,7 +10,7 @@
// ^
//
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "package:js/js.dart";
@@ -28,12 +28,12 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
- #C3 = _js::_Anonymous {}
+ #C2 = js::JS {name:#C1}
+ #C3 = js::_Anonymous {}
}
Constructor coverage from constants:
org-dartlang-testcase:///issue46123.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.strong.expect b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.strong.expect
index d51f34d..e249fb3 100644
--- a/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.strong.expect
+++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.strong.expect
@@ -10,7 +10,7 @@
// ^
//
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "package:js/js.dart";
@@ -28,12 +28,12 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
- #C3 = _js::_Anonymous {}
+ #C2 = js::JS {name:#C1}
+ #C3 = js::_Anonymous {}
}
Constructor coverage from constants:
org-dartlang-testcase:///issue46123b.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.strong.transformed.expect b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.strong.transformed.expect
index d51f34d..e249fb3 100644
--- a/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.strong.transformed.expect
@@ -10,7 +10,7 @@
// ^
//
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "package:js/js.dart";
@@ -28,12 +28,12 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
- #C3 = _js::_Anonymous {}
+ #C2 = js::JS {name:#C1}
+ #C3 = js::_Anonymous {}
}
Constructor coverage from constants:
org-dartlang-testcase:///issue46123b.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.expect b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.expect
index d51f34d..e249fb3 100644
--- a/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.expect
+++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.expect
@@ -10,7 +10,7 @@
// ^
//
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "package:js/js.dart";
@@ -28,12 +28,12 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
- #C3 = _js::_Anonymous {}
+ #C2 = js::JS {name:#C1}
+ #C3 = js::_Anonymous {}
}
Constructor coverage from constants:
org-dartlang-testcase:///issue46123b.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.modular.expect b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.modular.expect
index d51f34d..e249fb3 100644
--- a/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.modular.expect
@@ -10,7 +10,7 @@
// ^
//
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "package:js/js.dart";
@@ -28,12 +28,12 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
- #C3 = _js::_Anonymous {}
+ #C2 = js::JS {name:#C1}
+ #C3 = js::_Anonymous {}
}
Constructor coverage from constants:
org-dartlang-testcase:///issue46123b.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.outline.expect b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.outline.expect
index 8e8875b..a49e2c0 100644
--- a/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.outline.expect
@@ -1,12 +1,12 @@
library /*isNonNullableByDefault*/;
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "package:js/js.dart";
-@_js::JS::•()
-@_js::anonymous
+@js::JS::•()
+@js::anonymous
class ParallaxOptions extends core::Object /*hasConstConstructor*/ {
external const constructor •() → self::ParallaxOptions;
static method _#new#tearOff() → self::ParallaxOptions
diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.transformed.expect b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.transformed.expect
index d51f34d..e249fb3 100644
--- a/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.transformed.expect
@@ -10,7 +10,7 @@
// ^
//
import self as self;
-import "dart:_js_annotations" as _js;
+import "package:js/js.dart" as js;
import "dart:core" as core;
import "package:js/js.dart";
@@ -28,12 +28,12 @@
constants {
#C1 = null
- #C2 = _js::JS {name:#C1}
- #C3 = _js::_Anonymous {}
+ #C2 = js::JS {name:#C1}
+ #C3 = js::_Anonymous {}
}
Constructor coverage from constants:
org-dartlang-testcase:///issue46123b.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/incremental/js_interop_change.yaml b/pkg/front_end/testcases/incremental/js_interop_change.yaml
index 78f2081..9b4a276 100644
--- a/pkg/front_end/testcases/incremental/js_interop_change.yaml
+++ b/pkg/front_end/testcases/incremental/js_interop_change.yaml
@@ -79,7 +79,14 @@
eval('''function JSClass() {}''');
}
js/lib/js.dart: |
- export 'dart:_js_annotations' show JS, staticInterop;
+ class JS {
+ final String? name;
+ const JS([this.name]);
+ }
+ class _StaticInterop {
+ const _StaticInterop();
+ }
+ const _StaticInterop staticInterop = _StaticInterop();
.dart_tool/package_config.json: |
{
"configVersion": 2,
diff --git a/pkg/front_end/testcases/incremental/js_interop_change.yaml.world.1.expect b/pkg/front_end/testcases/incremental/js_interop_change.yaml.world.1.expect
index 863880df..531fc4c 100644
--- a/pkg/front_end/testcases/incremental/js_interop_change.yaml.world.1.expect
+++ b/pkg/front_end/testcases/incremental/js_interop_change.yaml.world.1.expect
@@ -1,10 +1,22 @@
main = main::main;
library from "package:js/js.dart" as js {
-additionalExports = (_js::staticInterop,
- _js::JS)
- export "dart:_js_annotations" show JS, staticInterop;
-
+ class JS extends dart.core::Object /*hasConstConstructor*/ {
+ final field dart.core::String? name;
+ const constructor •([dart.core::String? name = #C1]) → js::JS
+ : js::JS::name = name, super dart.core::Object::•()
+ ;
+ static method _#new#tearOff([dart.core::String? name = #C1]) → js::JS
+ return new js::JS::•(name);
+ }
+ class _StaticInterop extends dart.core::Object /*hasConstConstructor*/ {
+ const constructor •() → js::_StaticInterop
+ : super dart.core::Object::•()
+ ;
+ static method _#new#tearOff() → js::_StaticInterop
+ return new js::_StaticInterop::•();
+ }
+ static const field js::_StaticInterop staticInterop = #C2;
}
library from "org-dartlang-test:///lib1.dart" as lib1 {
@@ -33,13 +45,13 @@
return sta::StaticJSClass::•();
static set topLevelSetter((sta::StaticJSClass) → void f) → void {}
}
-@#C2
+@#C3
library static_interop from "org-dartlang-test:///lib2.dart" as sta {
import "package:js/js.dart";
- @#C4
@#C5
+ @#C2
class StaticJSClass extends dart.core::Object {
static factory •() → sta::StaticJSClass
return dart.js_util::_callConstructorUnchecked0<sta::StaticJSClass>(dart.js_util::_getPropertyTrustType<dart.core::Object>(dart.js_util::globalThis, "JSClass"));
@@ -51,7 +63,7 @@
static method _#factory#tearOff() → sta::StaticJSClass
return sta::StaticJSClass::factory();
}
- @#C2
+ @#C3
external static method eval(dart.core::String code) → void;
static method setUp() → void {
sta::eval("function JSClass() {}");
@@ -93,10 +105,10 @@
}
constants {
#C1 = null
- #C2 = _js_annotations::JS {name:#C1}
- #C3 = "JSClass"
- #C4 = _js_annotations::JS {name:#C3}
- #C5 = _js_annotations::_StaticInterop {}
+ #C2 = js::_StaticInterop {}
+ #C3 = js::JS {name:#C1}
+ #C4 = "JSClass"
+ #C5 = js::JS {name:#C4}
#C6 = static-tearoff lib1::topLevelMethod
#C7 = static-tearoff lib1::Class::staticMethod
}
@@ -104,6 +116,10 @@
Constructor coverage from constants:
org-dartlang-test:///lib2.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-test:///js/lib/js.dart:3:9)
+- Object. (from org-dartlang-sdk:///lib/core/object.dart)
+
+org-dartlang-test:///js/lib/js.dart:
+- _StaticInterop. (from org-dartlang-test:///js/lib/js.dart:6:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/front_end/testcases/incremental/js_interop_change.yaml.world.2.expect b/pkg/front_end/testcases/incremental/js_interop_change.yaml.world.2.expect
index 5205713..115e8c9 100644
--- a/pkg/front_end/testcases/incremental/js_interop_change.yaml.world.2.expect
+++ b/pkg/front_end/testcases/incremental/js_interop_change.yaml.world.2.expect
@@ -1,10 +1,22 @@
main = main::main;
library from "package:js/js.dart" as js {
-additionalExports = (_js::staticInterop,
- _js::JS)
- export "dart:_js_annotations" show JS, staticInterop;
-
+ class JS extends dart.core::Object /*hasConstConstructor*/ {
+ final field dart.core::String? name;
+ const constructor •([dart.core::String? name = #C1]) → js::JS
+ : js::JS::name = name, super dart.core::Object::•()
+ ;
+ static method _#new#tearOff([dart.core::String? name = #C1]) → js::JS
+ return new js::JS::•(name);
+ }
+ class _StaticInterop extends dart.core::Object /*hasConstConstructor*/ {
+ const constructor •() → js::_StaticInterop
+ : super dart.core::Object::•()
+ ;
+ static method _#new#tearOff() → js::_StaticInterop
+ return new js::_StaticInterop::•();
+ }
+ static const field js::_StaticInterop staticInterop = #C2;
}
library from "org-dartlang-test:///lib1.dart" as lib1 {
@@ -33,13 +45,13 @@
return sta::StaticJSClass::•();
static set topLevelSetter((sta::StaticJSClass) → void f) → void {}
}
-@#C2
+@#C3
library static_interop from "org-dartlang-test:///lib2.dart" as sta {
import "package:js/js.dart";
- @#C4
@#C5
+ @#C2
class StaticJSClass extends dart.core::Object {
static factory •() → sta::StaticJSClass
return dart.js_util::_callConstructorUnchecked0<sta::StaticJSClass>(dart.js_util::_getPropertyTrustType<dart.core::Object>(dart.js_util::globalThis, "JSClass"));
@@ -51,7 +63,7 @@
static method _#factory#tearOff() → sta::StaticJSClass
return sta::StaticJSClass::factory();
}
- @#C2
+ @#C3
external static method eval(dart.core::String code) → void;
static method setUp() → void {
sta::eval("function JSClass() {}");
@@ -94,10 +106,10 @@
}
constants {
#C1 = null
- #C2 = _js_annotations::JS {name:#C1}
- #C3 = "JSClass"
- #C4 = _js_annotations::JS {name:#C3}
- #C5 = _js_annotations::_StaticInterop {}
+ #C2 = js::_StaticInterop {}
+ #C3 = js::JS {name:#C1}
+ #C4 = "JSClass"
+ #C5 = js::JS {name:#C4}
#C6 = static-tearoff lib1::topLevelMethod
#C7 = static-tearoff lib1::Class::staticMethod
}
@@ -105,6 +117,10 @@
Constructor coverage from constants:
org-dartlang-test:///lib2.dart:
-- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
+- JS. (from org-dartlang-test:///js/lib/js.dart:3:9)
+- Object. (from org-dartlang-sdk:///lib/core/object.dart)
+
+org-dartlang-test:///js/lib/js.dart:
+- _StaticInterop. (from org-dartlang-test:///js/lib/js.dart:6:9)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)
diff --git a/pkg/js/CHANGELOG.md b/pkg/js/CHANGELOG.md
index 9bbfddfa..b580d15 100644
--- a/pkg/js/CHANGELOG.md
+++ b/pkg/js/CHANGELOG.md
@@ -3,7 +3,6 @@
- Remove dependency on `dart:js`.
- Update SDK lower constraint to 3.0.0-217.0.dev.
- Update SDK upper constraint to 4.0.0.
-- Moved annotations to single location in `dart:_js_annotations`.
## 0.6.7
diff --git a/pkg/js/lib/js.dart b/pkg/js/lib/js.dart
index 856a5b3..b6897c5 100644
--- a/pkg/js/lib/js.dart
+++ b/pkg/js/lib/js.dart
@@ -2,9 +2,89 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+/// Annotations to mark interfaces to JavaScript.
library js;
-// ignore: EXPORT_INTERNAL_LIBRARY
-export 'dart:_js_annotations'
- show JS, anonymous, staticInterop, trustTypes, JSExport;
+import 'package:meta/meta.dart';
+
export 'dart:js_util' show allowInterop, allowInteropCaptureThis;
+
+/// An annotation that indicates a library, class, or member is implemented
+/// directly in JavaScript.
+///
+/// All external members of a class or library with this annotation implicitly
+/// have it as well.
+///
+/// Specifying [name] customizes the JavaScript name to use. By default the
+/// dart name is used. It is not valid to specify a custom [name] for class
+/// instance members.
+class JS {
+ final String? name;
+ const JS([this.name]);
+}
+
+class _Anonymous {
+ const _Anonymous();
+}
+
+class _StaticInterop {
+ const _StaticInterop();
+}
+
+/// An annotation that indicates a [JS] annotated class is structural and does
+/// not have a known JavaScript prototype.
+///
+/// A class marked with [anonymous] must have an unnamed factory constructor
+/// with no positional arguments, only named arguments. Invoking the constructor
+/// desugars to creating a JavaScript object literal with name-value pairs
+/// corresponding to the parameter names and values.
+const _Anonymous anonymous = _Anonymous();
+
+/// [staticInterop] enables the [JS] annotated class to be treated as a "static"
+/// interop class.
+///
+/// These classes allow interop with native types, like the ones in `dart:html`.
+/// These classes should not contain any instance members, inherited or
+/// otherwise, and should instead use static extension members.
+const _StaticInterop staticInterop = _StaticInterop();
+
+/// NOTE: [trustTypes] is an experimental annotation that may disappear at any
+/// point in time. It exists solely to help users who wish to migrate classes
+/// from the older style of JS interop to the new static interop model but wish
+/// to preserve the older semantics for type checks. This annotation must be
+/// used alongside [staticInterop] and it affects any external methods in any
+/// extension to the static interop class.
+@experimental
+class _TrustTypes {
+ const _TrustTypes();
+}
+
+const _TrustTypes trustTypes = _TrustTypes();
+
+/// Annotation to mark Dart classes as exportable and allow instance members to
+/// be wrapped with an object literal.
+///
+/// Dart classes with this annotation can be used for exporting in `js_util`'s
+/// `createDartExport`, which returns a JS object that forwards to the Dart
+/// class. You may either annotate specific instance members to only export
+/// those members or you can annotate the entire class (which will export all
+/// instance members) to mark the class as exportable.
+///
+/// Classes and mixins in the hierarchy are included only if they are annotated
+/// or specific members in them are annotated. If a superclass does not have an
+/// annotation anywhere, its members are not included. Only concrete instance
+/// members can and will be exported, and it's an error to annotate other
+/// members with this annotation. In order to do renaming for members, you can
+/// provide a name for the `@JSExport` on the members e.g.
+/// ```
+/// class Export {
+/// @JSExport('printHelloWorld')
+/// void printMessage() => print('Hello World!');
+/// }
+/// ```
+/// which will then set 'printHelloWorld' to forward to `printMessage` in the
+/// object literal.
+class JSExport {
+ final String name;
+ const JSExport([this.name = '']);
+}
diff --git a/pkg/js/pubspec.yaml b/pkg/js/pubspec.yaml
index 805522a..b746a97 100644
--- a/pkg/js/pubspec.yaml
+++ b/pkg/js/pubspec.yaml
@@ -3,14 +3,12 @@
description: Annotations to create static Dart interfaces for JavaScript APIs.
repository: https://github.com/dart-lang/sdk/tree/main/pkg/js
-# We export `dart:_js_annotations` in this library.
-analyzer:
- errors:
- export_internal_library: ignore
-
environment:
sdk: ">=3.0.0-217.0.dev <4.0.0"
+dependencies:
+ meta: ^1.7.0
+
# We use 'any' version constraints here as we get our package versions from
# the dart-lang/sdk repo's DEPS file. Note that this is a special case; the
# best practice for packages is to specify their compatible version ranges.
diff --git a/sdk/lib/_internal/js_shared/lib/js_interop_patch.dart b/sdk/lib/_internal/js_shared/lib/js_interop_patch.dart
index cdb7c82..7d5ffb1 100644
--- a/sdk/lib/_internal/js_shared/lib/js_interop_patch.dart
+++ b/sdk/lib/_internal/js_shared/lib/js_interop_patch.dart
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'dart:_foreign_helper' as foreign_helper;
+import 'dart:_foreign_helper' show JS;
import 'dart:_internal' show patch;
import 'dart:_js_types';
import 'dart:js_util';
@@ -15,8 +15,7 @@
bool get isUndefined => this == null || typeofEquals(this, 'undefined');
@patch
- bool get isNull =>
- this == null || foreign_helper.JS('bool', '# === null', this);
+ bool get isNull => this == null || JS('bool', '# === null', this);
}
/// [JSExportedDartFunction] <-> [Function]
diff --git a/sdk/lib/js/_js_annotations.dart b/sdk/lib/js/_js_annotations.dart
index 8733bcd6..f053d6e 100644
--- a/sdk/lib/js/_js_annotations.dart
+++ b/sdk/lib/js/_js_annotations.dart
@@ -2,21 +2,13 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-/// Annotations to mark interfaces to JavaScript. All of these annotations are
-/// exported via `package:js`.
+// An implementation of the JS interop classes which are usable from the
+// Dart SDK. These types need to stay in-sync with
+// https://github.com/dart-lang/sdk/blob/master/pkg/js/lib/js.dart
library _js_annotations;
export 'dart:js_util' show allowInterop, allowInteropCaptureThis;
-/// An annotation that indicates a library, class, or member is implemented
-/// directly in JavaScript.
-///
-/// All external members of a class or library with this annotation implicitly
-/// have it as well.
-///
-/// Specifying [name] customizes the JavaScript name to use. By default the
-/// dart name is used. It is not valid to specify a custom [name] for class
-/// instance members.
class JS {
final String? name;
const JS([this.name]);
@@ -30,58 +22,10 @@
const _StaticInterop();
}
-/// An annotation that indicates a [JS] annotated class is structural and does
-/// not have a known JavaScript prototype.
-///
-/// A class marked with [anonymous] must have an unnamed factory constructor
-/// with no positional arguments, only named arguments. Invoking the constructor
-/// desugars to creating a JavaScript object literal with name-value pairs
-/// corresponding to the parameter names and values.
const _Anonymous anonymous = _Anonymous();
-/// [staticInterop] enables the [JS] annotated class to be treated as a "static"
-/// interop class.
-///
-/// These classes allow interop with native types, like the ones in `dart:html`.
-/// These classes should not contain any instance members, inherited or
-/// otherwise, and should instead use static extension members.
const _StaticInterop staticInterop = _StaticInterop();
-/// NOTE: [trustTypes] is an experimental annotation that may disappear at any
-/// point in time. It exists solely to help users who wish to migrate classes
-/// from the older style of JS interop to the new static interop model but wish
-/// to preserve the older semantics for type checks. This annotation must be
-/// used alongside [staticInterop] and it affects any external methods in any
-/// extension to the static interop class.
-class _TrustTypes {
- const _TrustTypes();
-}
-
-const _TrustTypes trustTypes = _TrustTypes();
-
-/// Annotation to mark Dart classes as exportable and allow instance members to
-/// be wrapped with an object literal.
-///
-/// Dart classes with this annotation can be used for exporting in `js_util`'s
-/// `createDartExport`, which returns a JS object that forwards to the Dart
-/// class. You may either annotate specific instance members to only export
-/// those members or you can annotate the entire class (which will export all
-/// instance members) to mark the class as exportable.
-///
-/// Classes and mixins in the hierarchy are included only if they are annotated
-/// or specific members in them are annotated. If a superclass does not have an
-/// annotation anywhere, its members are not included. Only concrete instance
-/// members can and will be exported, and it's an error to annotate other
-/// members with this annotation. In order to do renaming for members, you can
-/// provide a name for the `@JSExport` on the members e.g.
-/// ```
-/// class Export {
-/// @JSExport('printHelloWorld')
-/// void printMessage() => print('Hello World!');
-/// }
-/// ```
-/// which will then set 'printHelloWorld' to forward to `printMessage` in the
-/// object literal.
class JSExport {
final String name;
const JSExport([this.name = '']);
diff --git a/sdk/lib/js_interop/js_interop.dart b/sdk/lib/js_interop/js_interop.dart
index 539cd87..eeecbab 100644
--- a/sdk/lib/js_interop/js_interop.dart
+++ b/sdk/lib/js_interop/js_interop.dart
@@ -21,30 +21,11 @@
import 'dart:_js_types' as js_types;
import 'dart:typed_data';
-/// The annotation for JS interop members.
-///
-/// This is meant to signify that a given library, top-level external member, or
-/// inline class is a JS interop declaration.
-///
-/// Specifying [name] customizes the JavaScript name to use. This can be used in
-/// the following scenarios:
-///
-/// - Namespacing all the external top-level members, static members, and
-/// constructors of a library by annotating the library with a custom name.
-/// - Namespacing all the external static members and constructors of an inline
-/// class by annotating the inline class with a custom name.
-/// - Renaming external members by annotating the member with a custom name.
-///
-/// In the case where [name] is not specified, we default to the Dart name for
-/// inline classes and external members.
-///
-/// Note: `package:js` has a `@JS` annotation as well. Unlike that annotation,
-/// this is meant for inline classes, and will result in more type-checking for
-/// external top-level members.
-class JS {
- final String? name;
- const JS([this.name]);
-}
+/// Export the `dart:_js_annotations` version of the `@JS` annotation. This is
+/// mostly identical to the `package:js` version, except this is meant to be used
+/// for sound top-level external members and inline classes instead of the
+/// `package:js` classes.
+export 'dart:_js_annotations' show JS;
/// The annotation for object literal constructors.
///
diff --git a/tests/lib/js/static_interop_test/js_types_test.dart b/tests/lib/js/static_interop_test/js_types_test.dart
index 4a656ab..9c27359 100644
--- a/tests/lib/js/static_interop_test/js_types_test.dart
+++ b/tests/lib/js/static_interop_test/js_types_test.dart
@@ -9,7 +9,7 @@
import 'dart:typed_data';
import 'package:expect/minitest.dart';
-import 'package:js/js.dart' as js;
+import 'package:js/js.dart';
@JS()
external void eval(String code);
@@ -20,8 +20,8 @@
@JS()
external JSObject obj;
-@js.JS()
-@js.staticInterop
+@JS()
+@staticInterop
class SimpleObject {}
extension SimpleObjectExtension on SimpleObject {
diff --git a/tests/web/native/static_interop_erasure/factory_stub_test.dart b/tests/web/native/static_interop_erasure/factory_stub_test.dart
index 9979170..121be04 100644
--- a/tests/web/native/static_interop_erasure/factory_stub_test.dart
+++ b/tests/web/native/static_interop_erasure/factory_stub_test.dart
@@ -12,7 +12,7 @@
import 'package:js/js.dart';
-import '../native_testing.dart' hide JS;
+import '../native_testing.dart';
import '../native_testing.dart' as native_testing;
import 'factory_stub_lib.dart';
diff --git a/tests/web/native/static_interop_erasure/type_test.dart b/tests/web/native/static_interop_erasure/type_test.dart
index 911a610..d0ed176 100644
--- a/tests/web/native/static_interop_erasure/type_test.dart
+++ b/tests/web/native/static_interop_erasure/type_test.dart
@@ -14,7 +14,7 @@
import 'package:expect/minitest.dart';
import 'package:js/js.dart';
-import '../native_testing.dart' hide JS;
+import '../native_testing.dart';
import '../native_testing.dart' as native_testing;
NativeClass makeNativeClass() native;
diff --git a/tests/web/native/static_interop_erasure/use_erased_type_members_test.dart b/tests/web/native/static_interop_erasure/use_erased_type_members_test.dart
index c05c740..061dbe3 100644
--- a/tests/web/native/static_interop_erasure/use_erased_type_members_test.dart
+++ b/tests/web/native/static_interop_erasure/use_erased_type_members_test.dart
@@ -13,7 +13,7 @@
import 'package:expect/minitest.dart';
import 'package:js/js.dart';
-import '../native_testing.dart' hide JS;
+import '../native_testing.dart';
import '../native_testing.dart' as native_testing;
NativeClass makeNativeClass() native;
diff --git a/tests/web/wasm/js_util_test.dart b/tests/web/wasm/js_util_test.dart
index 40829a3..89ec2f1 100644
--- a/tests/web/wasm/js_util_test.dart
+++ b/tests/web/wasm/js_util_test.dart
@@ -8,7 +8,7 @@
import 'package:async_helper/async_helper.dart';
import 'package:expect/expect.dart';
-import 'package:js/js.dart' hide JS;
+import 'package:js/js.dart';
@JS()
external void eval(String code);
diff --git a/tests/web_2/native/static_interop_erasure/factory_stub_test.dart b/tests/web_2/native/static_interop_erasure/factory_stub_test.dart
index 77b61cd..215481a 100644
--- a/tests/web_2/native/static_interop_erasure/factory_stub_test.dart
+++ b/tests/web_2/native/static_interop_erasure/factory_stub_test.dart
@@ -14,7 +14,7 @@
import 'package:js/js.dart';
-import '../native_testing.dart' hide JS;
+import '../native_testing.dart';
import '../native_testing.dart' as native_testing;
import 'factory_stub_lib.dart';
diff --git a/tests/web_2/native/static_interop_erasure/type_test.dart b/tests/web_2/native/static_interop_erasure/type_test.dart
index 8c0d3f8..bd3c684 100644
--- a/tests/web_2/native/static_interop_erasure/type_test.dart
+++ b/tests/web_2/native/static_interop_erasure/type_test.dart
@@ -15,7 +15,7 @@
import 'package:expect/minitest.dart';
import 'package:js/js.dart';
-import '../native_testing.dart' hide JS;
+import '../native_testing.dart';
import '../native_testing.dart' as native_testing;
NativeClass makeNativeClass() native;
diff --git a/tests/web_2/native/static_interop_erasure/use_erased_type_members_test.dart b/tests/web_2/native/static_interop_erasure/use_erased_type_members_test.dart
index 7675ad3..b3b9303 100644
--- a/tests/web_2/native/static_interop_erasure/use_erased_type_members_test.dart
+++ b/tests/web_2/native/static_interop_erasure/use_erased_type_members_test.dart
@@ -15,7 +15,7 @@
import 'package:expect/minitest.dart';
import 'package:js/js.dart';
-import '../native_testing.dart' hide JS;
+import '../native_testing.dart';
import '../native_testing.dart' as native_testing;
NativeClass makeNativeClass() native;