Revert "Reland "[pkg:js/dart:js_interop] Move annotations to dart:_js_annotations""

This reverts commit 9e1997971e.

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 fbe9c21972
>
> 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>
This commit is contained in:
Zach Anderson 2023-04-06 14:43:18 +00:00 committed by Commit Queue
parent df761ba9e7
commit 4919729f00
61 changed files with 402 additions and 336 deletions

View file

@ -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 @@ bool hasObjectLiteralAnnotation(Annotatable a) =>
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 @@ String getJSExportName(Annotatable a) {
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 @@ bool _isObjectLiteralAnnotation(Expression value) {
///
/// 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,

View file

@ -11,7 +11,7 @@ import '../js_interop.dart'
show
getJSName,
hasAnonymousAnnotation,
hasDartJSInteropAnnotation,
hasInternalJSInteropAnnotation,
hasJSInteropAnnotation,
hasNativeAnnotation,
hasObjectLiteralAnnotation,
@ -69,6 +69,11 @@ class JsUtilOptimizer extends Transformer {
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 @@ class JsUtilOptimizer extends Transformer {
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 @@ class InlineExtensionIndex {
}
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);
}
}

View file

@ -2014,8 +2014,8 @@ class ElementAnnotationImpl implements ElementAnnotation {
/// 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';

View file

@ -143,6 +143,10 @@ abstract class CommonElements {
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 @@ abstract class CommonElements {
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');

View file

@ -266,6 +266,9 @@ class Uris {
/// 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');

View file

@ -332,13 +332,9 @@ String? _getReturnsAnnotation(ir.Constant constant) {
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 @@ String? _getJsInteropName(ir.Constant constant) {
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) {

View file

@ -225,9 +225,8 @@ class NativeBasicData {
// 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(

View file

@ -129,8 +129,7 @@ class Dart2jsTarget extends Target {
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);

View file

@ -40,8 +40,10 @@ class KernelAnnotationProcessor {
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) {

View file

@ -902,12 +902,12 @@ class JSRuntimeFinalizer {
JSRuntimeFinalizer createJSRuntimeFinalizer(
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(

View file

@ -87,8 +87,7 @@ class WasmTarget extends Target {
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 @@ class WasmTarget extends Target {
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");

View file

@ -2833,7 +2833,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
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 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
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;
}

View file

@ -7,7 +7,7 @@ import 'package:kernel/kernel.dart';
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 @@ bool _isLibrary(Library library, List<String> candidates) {
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 isJsRestAnnotation(Expression value) =>
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 @@ bool _isStaticInteropAnnotation(Expression value) =>
_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 isObjectLiteralAnnotation(Expression value) {
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 @@ bool hasJSInteropAnnotation(Class c) =>
/// 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;
}

View file

@ -101,9 +101,8 @@ bool isBuiltinAnnotation(
///
/// 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).

View file

@ -145,8 +145,7 @@ class DevCompilerTarget extends Target {
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;

View file

@ -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 @@ static method method(self::A a) → void {
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 @@ constants {
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)

View file

@ -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 @@ static method method(self::A a) → void {
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 @@ constants {
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)

View file

@ -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 @@ static method method(self::A a) → void {
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 @@ constants {
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)

View file

@ -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 @@ static method method(self::A a) → void {
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 @@ constants {
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)

View file

@ -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 @@ abstract class A extends core::Object {
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;

View file

@ -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 @@ static method method(self::A a) → void {
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 @@ constants {
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)

View file

@ -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 @@ static method method(self::A a) → void {
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 @@ constants {
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)

View file

@ -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 @@ static method method(self::A a) → void {
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 @@ constants {
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)

View file

@ -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 @@ static method method(self::A a) → void {
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 @@ constants {
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)

View file

@ -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 @@ static method method(self::A a) → void {
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 @@ constants {
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)

View file

@ -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 @@ abstract class A extends core::Object {
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;

View file

@ -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 @@ static method method(self::A a) → void {
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 @@ constants {
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)

View file

@ -12,7 +12,7 @@ static method main() → void {
@#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 @@ static method setUp() → void {
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)

View file

@ -12,7 +12,7 @@ static method main() → void {
@#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 @@ static method setUp() → void {
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)

View file

@ -12,7 +12,7 @@ static method main() → void {
@#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 @@ static method setUp() → void {
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)

View file

@ -9,7 +9,7 @@ static method main() → void
@#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 @@ static method setUp() → void
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)

View file

@ -12,7 +12,7 @@ static method main() → void {
@#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 @@ static method setUp() → void {
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)

View file

@ -10,7 +10,7 @@ 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";
@ -28,12 +28,12 @@ static method main() → dynamic {}
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)

View file

@ -10,7 +10,7 @@ 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";
@ -28,12 +28,12 @@ static method main() → dynamic {}
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)

View file

@ -10,7 +10,7 @@ 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";
@ -28,12 +28,12 @@ static method main() → dynamic {}
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)

View file

@ -10,7 +10,7 @@ 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";
@ -28,12 +28,12 @@ static method main() → dynamic {}
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)

View file

@ -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

View file

@ -10,7 +10,7 @@ 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";
@ -28,12 +28,12 @@ static method main() → dynamic {}
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)

View file

@ -10,7 +10,7 @@ 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";
@ -28,12 +28,12 @@ static method main() → dynamic {}
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)

View file

@ -10,7 +10,7 @@ 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";
@ -28,12 +28,12 @@ static method main() → dynamic {}
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)

View file

@ -10,7 +10,7 @@ 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";
@ -28,12 +28,12 @@ static method main() → dynamic {}
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)

View file

@ -10,7 +10,7 @@ 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";
@ -28,12 +28,12 @@ static method main() → dynamic {}
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)

View file

@ -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

View file

@ -10,7 +10,7 @@ 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";
@ -28,12 +28,12 @@ static method main() → dynamic {}
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)

View file

@ -79,7 +79,14 @@ worlds:
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,

View file

@ -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 @@ library from "org-dartlang-test:///lib1.dart" as lib1 {
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 @@ library static_interop from "org-dartlang-test:///lib2.dart" as sta {
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 @@ library from "org-dartlang-test:///main.dart" as main {
}
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 @@ constants {
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)

View file

@ -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 @@ library from "org-dartlang-test:///lib1.dart" as lib1 {
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 @@ library static_interop from "org-dartlang-test:///lib2.dart" as sta {
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 @@ library from "org-dartlang-test:///main.dart" as main {
}
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 @@ constants {
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)

View file

@ -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

View file

@ -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 = '']);
}

View file

@ -3,14 +3,12 @@ version: 0.6.9-dev
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.

View file

@ -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 @@ extension NullableUndefineableJSAnyExtension on JSAny? {
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]

View file

@ -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 @@ 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.
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 = '']);

View file

@ -21,30 +21,11 @@ library dart.js_interop;
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.
///

View file

@ -9,7 +9,7 @@ import 'dart:js_util';
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 @@ external JSAny any;
@JS()
external JSObject obj;
@js.JS()
@js.staticInterop
@JS()
@staticInterop
class SimpleObject {}
extension SimpleObjectExtension on SimpleObject {

View file

@ -12,7 +12,7 @@ import 'dart:_interceptors' show JavaScriptObject;
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';

View file

@ -14,7 +14,7 @@ import 'package:expect/expect.dart' show hasUnsoundNullSafety;
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;

View file

@ -13,7 +13,7 @@ import 'dart:_interceptors' show JavaScriptObject;
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;

View file

@ -8,7 +8,7 @@ import 'dart:typed_data';
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);

View file

@ -14,7 +14,7 @@ import 'dart:_interceptors' show JavaScriptObject;
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';

View file

@ -15,7 +15,7 @@ import 'dart:_interceptors' show JavaScriptObject;
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;

View file

@ -15,7 +15,7 @@ import 'dart:_interceptors' show JavaScriptObject;
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;