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

This reverts commit 4919729f00.

This CL also adds back in logic to handle older package:js versions to avoid
failures in our static checking. It also supports dart:js_interop's @JS
annotation since it can now be used for @staticInterop classes.

CoreLibraryReviewExempt: Reland of backend-specific library changes.
Change-Id: I104653a9a6b2593f6bab658808287e2074c18550
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294130
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>
This commit is contained in:
Srujan Gaddam 2023-05-02 15:24:18 +00:00 committed by Commit Queue
parent 33cffa0b47
commit c4d354dc2a
64 changed files with 424 additions and 429 deletions

View file

@ -272,9 +272,9 @@ class JsInteropChecks extends RecursiveVisitor {
node.fileUri);
}
}
// For non-inline classes, `dart:_js_annotations`'s `@JS` can only be used
// For non-inline classes, `dart:js_interop`'s `@JS` can only be used
// with `@staticInterop`.
if (hasJSAnnotationsJSAnnotation(node)) {
if (hasDartJSInteropAnnotation(node)) {
_diagnosticsReporter.report(
messageJsInteropDartJsInteropAnnotationForStaticInteropOnly,
node.fileOffset,

View file

@ -5,37 +5,40 @@
import 'package:kernel/kernel.dart';
import 'package:kernel/util/graph.dart' as kernel_graph;
/// Returns true iff the node has an `@JS(...)` annotation from `package:js` or
/// from the internal `dart:_js_annotations`.
/// Returns true iff the node has an `@JS(...)` annotation from `package:js`,
/// `dart:_js_annotations`, or `dart:_js_interop`. Note that while `package:js`
/// has no annotations any more, it used to, so we still need to support those
/// versions.
bool hasJSInteropAnnotation(Annotatable a) =>
a.annotations.any(_isJSInteropAnnotation);
/// Returns true iff the node has an `@JS(...)` annotation from `package:js`.
/// Returns true iff the node has an `@JS(...)` annotation from `package:js` or
/// `dart:_js_annotations`.
bool hasPackageJSAnnotation(Annotatable a) =>
a.annotations.any(_isPackageJSAnnotation);
/// Returns true iff the node has an `@JS(...)` annotation from the internal
/// `dart:_js_annotations`.
bool hasJSAnnotationsJSAnnotation(Annotatable a) =>
a.annotations.any(_isJSAnnotationsJSAnnotation);
/// 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 `package:js`
/// or from the internal `dart:_js_annotations`.
/// or `dart:_js_annotations`.
bool hasAnonymousAnnotation(Annotatable a) =>
a.annotations.any(_isAnonymousAnnotation);
/// Returns true iff the node has an `@staticInterop` annotation from
/// `package:js` or from the internal `dart:_js_annotations`.
/// `package:js` or `dart:_js_annotations`.
bool hasStaticInteropAnnotation(Annotatable a) =>
a.annotations.any(_isStaticInteropAnnotation);
/// Returns true iff the node has an `@trustTypes` annotation from
/// `package:js` or from the internal `dart:_js_annotations`.
/// Returns true iff the node has an `@trustTypes` annotation from `package:js`
/// or `dart:_js_annotations`.
bool hasTrustTypesAnnotation(Annotatable a) =>
a.annotations.any(_isTrustTypesAnnotation);
/// Returns true iff the node has an `@JSExport(...)` annotation from
/// `package:js` or from the internal `dart:_js_annotations`.
/// `package:js` or `dart:_js_annotations`.
bool hasJSExportAnnotation(Annotatable a) =>
a.annotations.any(_isJSExportAnnotation);
@ -114,11 +117,11 @@ final _jsInterop = Uri.parse('dart:js_interop');
/// Returns true if [value] is the interop annotation whose class is
/// [annotationClassName] from [interopLibraries].
///
/// If [interopLibraries] is null, we check `package:js` and
/// `dart:_js_annotations`.
/// If [interopLibraries] is null, we check `package:js`,
/// `dart:_js_annotations`, and `dart:js_interop`.
bool _isInteropAnnotation(Expression value, String annotationClassName,
{Set<Uri>? interopLibraries}) {
interopLibraries ??= {_packageJs, _jsAnnotations};
interopLibraries ??= {_packageJs, _jsAnnotations, _jsInterop};
var c = annotationClass(value);
if (c == null || c.name != annotationClassName) return false;
var importUri = c.enclosingLibrary.importUri;
@ -129,10 +132,11 @@ bool _isJSInteropAnnotation(Expression value) =>
_isInteropAnnotation(value, 'JS');
bool _isPackageJSAnnotation(Expression value) =>
_isInteropAnnotation(value, 'JS', interopLibraries: {_packageJs});
_isInteropAnnotation(value, 'JS',
interopLibraries: {_packageJs, _jsAnnotations});
bool _isJSAnnotationsJSAnnotation(Expression value) =>
_isInteropAnnotation(value, 'JS', interopLibraries: {_jsAnnotations});
bool _isDartJSInteropAnnotation(Expression value) =>
_isInteropAnnotation(value, 'JS', interopLibraries: {_jsInterop});
bool _isAnonymousAnnotation(Expression value) =>
_isInteropAnnotation(value, '_Anonymous');
@ -167,9 +171,11 @@ bool _isObjectLiteralAnnotation(Expression value) {
///
/// For example:
///
/// - `@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".
/// - `@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".
/// - `@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,
hasJSAnnotationsJSAnnotation,
hasDartJSInteropAnnotation,
hasJSInteropAnnotation,
hasNativeAnnotation,
hasObjectLiteralAnnotation,
@ -69,11 +69,6 @@ class JsUtilOptimizer extends Transformer {
final InlineExtensionIndex _inlineExtensionIndex = InlineExtensionIndex();
static const Set<String> _existingJsAnnotationsUsers = {
'dart:_engine',
'dart:ui'
};
JsUtilOptimizer(this._coreTypes, ClassHierarchy hierarchy)
: _callMethodTarget =
_coreTypes.index.getTopLevelProcedure('dart:js_util', 'callMethod'),
@ -230,17 +225,8 @@ class JsUtilOptimizer extends Transformer {
if (!node.isInlineClassMember &&
node.enclosingClass == null &&
((hasJSAnnotationsJSAnnotation(node) ||
hasJSAnnotationsJSAnnotation(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.
(hasDartJSInteropAnnotation(node) ||
hasDartJSInteropAnnotation(node.enclosingLibrary))) {
// 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);
@ -897,24 +883,24 @@ class InlineExtensionIndex {
/// depending on the import. This is to avoid a breaking change in the
/// existing semantics of `@staticInterop`.**
bool canBeInvocationLevelLowered(Procedure node) {
if (hasJSAnnotationsJSAnnotation(node) ||
hasJSAnnotationsJSAnnotation(node.enclosingLibrary) ||
if (hasDartJSInteropAnnotation(node) ||
hasDartJSInteropAnnotation(node.enclosingLibrary) ||
(node.enclosingClass != null &&
hasJSAnnotationsJSAnnotation(node.enclosingClass!))) {
hasDartJSInteropAnnotation(node.enclosingClass!))) {
return true;
}
if (node.isExtensionMember) {
final annotatable = getExtensionAnnotatable(node);
if (annotatable != null) {
return hasJSAnnotationsJSAnnotation(annotatable);
return hasDartJSInteropAnnotation(annotatable);
}
}
if (node.isInlineClassMember) {
final cls = getInlineClass(node);
if (cls != null) {
return hasJSAnnotationsJSAnnotation(cls);
return hasDartJSInteropAnnotation(cls);
}
}

View file

@ -1981,8 +1981,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` library, used to define JS annotations.
static const String _jsLibName = 'js';
/// The name of `_js_annotations` library, used to define JS annotations.
static const String _jsLibName = '_js_annotations';
/// The name of `meta` library, used to define analysis annotations.
static const String _metaLibName = 'meta';

View file

@ -151,6 +151,10 @@ abstract class CommonElements {
late final LibraryEntity? dartJsAnnotationsLibrary =
_env.lookupLibrary(Uris.dart__js_annotations);
/// The dart:js_interop library.
late final LibraryEntity? dartJsInteropLibrary =
_env.lookupLibrary(Uris.dart__js_interop);
/// The `NativeTypedData` class from dart:typed_data.
ClassEntity get typedDataClass =>
_findClass(typedDataLibrary, 'NativeTypedData');
@ -1081,11 +1085,19 @@ class KCommonElements extends CommonElements {
late final ClassEntity? jsAnonymousClass2 =
_findClassOrNull(dartJsAnnotationsLibrary, '_Anonymous');
// From dart:js_interop
late final ClassEntity? jsAnnotationClass3 =
_findClassOrNull(dartJsInteropLibrary, 'JS');
/// Returns `true` if [cls] is a @JS() annotation.
///
/// The class can come from either `package:js` or `dart:_js_annotations`.
/// The class can come from either `package:js`, `dart:_js_annotations`, or
/// `dart:js_interop`.
bool isJsAnnotationClass(ClassEntity cls) {
return cls == jsAnnotationClass1 || cls == jsAnnotationClass2;
return cls == jsAnnotationClass1 ||
cls == jsAnnotationClass2 ||
cls == jsAnnotationClass3;
}
/// Returns `true` if [cls] is an @anonymous annotation.

View file

@ -334,7 +334,9 @@ String? _getJsInteropName(ir.Constant constant) {
constant.classNode.name == 'JS' &&
(constant.classNode.enclosingLibrary.importUri == Uris.package_js ||
constant.classNode.enclosingLibrary.importUri ==
Uris.dart__js_annotations)) {
Uris.dart__js_annotations ||
constant.classNode.enclosingLibrary.importUri ==
Uris.dart__js_interop)) {
assert(constant.fieldValues.length == 1);
ir.Constant fieldValue = constant.fieldValues.values.single;
if (fieldValue is ir.NullConstant) {

View file

@ -225,8 +225,9 @@ 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

@ -130,7 +130,8 @@ class Dart2jsTarget extends Target {
super.allowPlatformPrivateLibraryAccess(importer, imported) ||
maybeEnableNative(importer) ||
(importer.isScheme('package') &&
importer.path.startsWith('dart2js_runtime_metrics/'));
(importer.path.startsWith('dart2js_runtime_metrics/') ||
importer.path == 'js/js.dart'));
@override
bool enableNative(Uri uri) => maybeEnableNative(uri);

View file

@ -39,11 +39,20 @@ class KernelAnnotationProcessor {
KCommonElements commonElements = elementMap.commonElements;
String? annotationName;
for (ConstantValue value in metadata) {
String? name = readAnnotationName(commonElements.dartTypes, spannable,
value, commonElements.jsAnnotationClass1!, defaultValue: '') ??
readAnnotationName(commonElements.dartTypes, spannable, value,
commonElements.jsAnnotationClass2!,
String? name;
List<ClassEntity?> jsAnnotationClasses = [
commonElements.jsAnnotationClass1,
commonElements.jsAnnotationClass2,
commonElements.jsAnnotationClass3
];
for (ClassEntity? jsAnnotationClass in jsAnnotationClasses) {
if (jsAnnotationClass != null) {
name = readAnnotationName(
commonElements.dartTypes, spannable, value, jsAnnotationClass,
defaultValue: '');
if (name != null) break;
}
}
if (annotationName == null) {
annotationName = name;
} else if (name != null) {

View file

@ -18,12 +18,9 @@ import 'package:compiler/src/util/memory_compiler.dart';
void main() {
asyncTest(() async {
// TODO(srujzs): Uncomment these tests when we create a `dart:js_interop`
// `@JS` annotation. Currently these tests fail because
// `dart:_js_annotations`' `@JS` can only be used for static interop.
// await testClasses('package:js/js.dart', 'dart:_js_annotations');
await testClasses('package:js/js.dart', 'dart:_js_annotations');
await testClasses('package:js/js.dart', 'package:js/js.dart');
// await testClasses('dart:_js_annotations', 'dart:_js_annotations');
await testClasses('dart:_js_annotations', 'dart:_js_annotations');
});
}

View file

@ -71,6 +71,8 @@ RuntimeFinalizer createRuntimeFinalizer(
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

@ -92,7 +92,8 @@ class WasmTarget extends Target {
bool allowPlatformPrivateLibraryAccess(Uri importer, Uri imported) =>
super.allowPlatformPrivateLibraryAccess(importer, imported) ||
importer.path.contains('tests/web/wasm');
importer.path.contains('tests/web/wasm') ||
importer.isScheme('package') && importer.path == 'js/js.dart';
void _patchHostEndian(CoreTypes coreTypes) {
// Fix Endian.host to be a const field equal to Endian.little instead of
@ -161,7 +162,9 @@ class WasmTarget extends Target {
...?jsInteropHelper.calculateTransitiveImportsOfJsInteropIfUsed(
component, Uri.parse("package:js/js.dart")),
...?jsInteropHelper.calculateTransitiveImportsOfJsInteropIfUsed(
component, Uri.parse("dart:_js_annotations"))
component, Uri.parse("dart:_js_annotations")),
...?jsInteropHelper.calculateTransitiveImportsOfJsInteropIfUsed(
component, Uri.parse("dart:js_interop")),
};
if (transitiveImportingJSInterop.isEmpty) {
logger?.call("Skipped JS interop transformations");

View file

@ -2835,7 +2835,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, isPublicJSAnnotation) ?? getTopLevelName(n);
var name = _annotationName(n, isJSInteropAnnotation) ?? getTopLevelName(n);
assert(!name.contains('.'),
'JS interop checker rejects dotted names on static class members');
return js.escapedString(name, "'");
@ -2911,8 +2911,9 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
String? _jsNameWithoutGlobal(NamedNode n) {
if (!usesJSInterop(n)) return null;
var libraryJSName = _annotationName(getLibrary(n), isPublicJSAnnotation);
var jsName = _annotationName(n, isPublicJSAnnotation) ?? getTopLevelName(n);
var libraryJSName = _annotationName(getLibrary(n), isJSInteropAnnotation);
var jsName =
_annotationName(n, isJSInteropAnnotation) ?? 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', 'package:js'].
/// The latter should be a list, e.g.,: ['dart:js', 'dart:_js_annotations'].
bool _isLibrary(Library library, List<String> candidates) {
var uri = library.importUri;
var scheme = uri.scheme;
@ -21,13 +21,19 @@ bool _isLibrary(Library library, List<String> candidates) {
return false;
}
/// Returns true if [library] represents any library from `package:js` or is the
/// internal `dart:_js_helper` library.
/// Returns true if [library] represents any library from `package:js`,
/// `dart:_foreign_helper`, `dart:_js_annotations`, or `dart:_js_helper`, or
/// `dart:js_interop`.
bool _isJSLibrary(Library library) => _isLibrary(library, [
// While the annotations no longer live in `package:js`, this is needed to
// support older versions of the package.
'package:js',
'dart:_js_helper',
'dart:_foreign_helper',
'dart:_js_annotations'
'dart:_js_annotations',
'dart:_js_helper',
// This is to allow `dart:js_interop`'s `@JS` to work with
// `@staticInterop`.
'dart:js_interop',
]);
/// Whether [node] is a direct call to `allowInterop`.
@ -67,8 +73,9 @@ bool isJsRestAnnotation(Expression value) =>
bool isJSAnnotation(Expression value) =>
_annotationIsFromJSLibrary('JS', value) || isJSName(value);
/// Returns [true] if [value] is the `JS` annotation from `package:js`.
bool isPublicJSAnnotation(Expression value) =>
/// Returns [true] if [value] is the `JS` annotation from
/// `package:js`, `dart:_js_annotations`, or `dart:js_interop`.
bool isJSInteropAnnotation(Expression value) =>
_annotationIsFromJSLibrary('JS', value);
bool _isJSAnonymousAnnotation(Expression value) =>
@ -78,7 +85,7 @@ bool _isStaticInteropAnnotation(Expression value) =>
_annotationIsFromJSLibrary('_StaticInterop', value);
/// Whether [value] is a `@JSExportName` (internal annotation used in SDK
/// instead of `@JS` from `package:js`).
/// instead of `@JS` from `dart:_js_annotations`).
bool isJSExportNameAnnotation(Expression value) =>
isBuiltinAnnotation(value, '_foreign_helper', 'JSExportName');
@ -125,18 +132,20 @@ bool isObjectLiteralAnnotation(Expression value) {
bool hasObjectLiteralAnnotation(Annotatable a) =>
a.annotations.any(isObjectLiteralAnnotation);
/// Returns true iff the class has an `@JS(...)` annotation from `package:js`.
/// Returns true iff the class has an `@JS(...)` annotation from
/// `package:js`, `dart:_js_annotations`, or `dart:js_interop`.
///
/// 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(isPublicJSAnnotation);
bool hasJSInteropAnnotation(Class c) =>
c.annotations.any(isJSInteropAnnotation);
/// Returns true iff [c] is a class from `dart:_js_types` implemented using
/// `@staticInterop`.
@ -153,11 +162,11 @@ bool isDartJSTypesType(Class c) =>
/// the class or library.
bool usesJSInterop(NamedNode n) {
if (n is Member && n.isExternal) {
return n.enclosingLibrary.annotations.any(isPublicJSAnnotation) ||
n.annotations.any(isPublicJSAnnotation) ||
(n.enclosingClass?.annotations.any(isPublicJSAnnotation) ?? false);
return n.enclosingLibrary.annotations.any(isJSInteropAnnotation) ||
n.annotations.any(isJSInteropAnnotation) ||
(n.enclosingClass?.annotations.any(isJSInteropAnnotation) ?? false);
} else if (n is Class) {
return n.annotations.any(isPublicJSAnnotation);
return n.annotations.any(isJSInteropAnnotation);
}
return false;
}

View file

@ -101,8 +101,9 @@ bool isBuiltinAnnotation(
///
/// For example:
///
/// - `@JS()` would return the "JS" class in "package:js".
/// - `@anonymous` would return the "_Anonymous" class in "package:js".
/// - `@JS()` would return the "JS" class in "dart:_js_annotations".
/// - `@anonymous` would return the "_Anonymous" class in
/// "dart:_js_annotations".
///
/// 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

@ -147,7 +147,8 @@ class DevCompilerTarget extends Target {
super.allowPlatformPrivateLibraryAccess(importer, imported) ||
_allowedTestLibrary(importer) ||
(importer.isScheme('package') &&
importer.path.startsWith('dart2js_runtime_metrics/'));
(importer.path.startsWith('dart2js_runtime_metrics/') ||
importer.path == 'js/js.dart'));
@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 "dart:js_interop" as js_;
import "dart:core" as core;
import "dart:js_interop";
@ -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-sdk:///lib/js_interop/js_interop.dart)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)

View file

@ -1,9 +1,9 @@
@#C2
library static_interop /*isNonNullableByDefault*/;
import self as self;
import "dart:_js_annotations" as _js;
import "dart:js_interop" as js_;
import "dart:core" as core;
import "dart:js_util" as js_;
import "dart:js_util" as js_2;
import "dart:js_interop";
@ -34,41 +34,41 @@ inline class B /* declaredRepresentationType = self::A */ {
tearoff named = self::B|get#named;
}
static method B|(self::A a) → self::B
return js_::_callConstructorUnchecked1<self::B>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), a);
return js_2::_callConstructorUnchecked1<self::B>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), a);
static method B|get#(self::A a) → self::B
return self::B|(a);
static method B|named(core::int i) → self::B
return js_::_callConstructorUnchecked1<self::B>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), i);
return js_2::_callConstructorUnchecked1<self::B>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), i);
static method B|get#named(core::int i) → self::B
return self::B|named(i);
static method B|get#field(self::A #this) → self::A
return js_::getProperty<self::A>(#this, "field");
return js_2::getProperty<self::A>(#this, "field");
static method B|set#field(self::A #this, self::A #externalFieldValue) → void
return js_::_setPropertyUnchecked<self::A>(#this, "field", #externalFieldValue);
return js_2::_setPropertyUnchecked<self::A>(#this, "field", #externalFieldValue);
static method B|method(lowered final self::B #this) → self::A
return js_::_callMethodUnchecked0<self::A>(#this, "method");
return js_2::_callMethodUnchecked0<self::A>(#this, "method");
static method B|get#method(lowered final self::B #this) → () → self::A
return () → self::A => self::B|method(#this);
static method B|genericMethod<T extends core::Object? = dynamic>(lowered final self::B #this, self::B|genericMethod::T% t) → self::B|genericMethod::T%
return js_::callMethod<self::B|genericMethod::T%>(#this, "genericMethod", <dynamic>[t]);
return js_2::callMethod<self::B|genericMethod::T%>(#this, "genericMethod", <dynamic>[t]);
static method B|get#genericMethod(lowered final self::B #this) → <T extends core::Object? = dynamic>(T%) → T%
return <T extends core::Object? = dynamic>(T% t) → T% => self::B|genericMethod<T%>(#this, t);
static method B|get#getter(lowered final self::B #this) → self::B
return js_::getProperty<self::B>(#this, "getter");
return js_2::getProperty<self::B>(#this, "getter");
static method B|set#setter(lowered final self::B #this, self::B b) → void
return js_::setProperty<self::B>(#this, "setter", b);
return js_2::setProperty<self::B>(#this, "setter", b);
static get B|staticField() → self::A
return js_::getProperty<self::A>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticField");
return js_2::getProperty<self::A>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticField");
static set B|staticField(self::A #externalFieldValue) → void
return js_::_setPropertyUnchecked<self::A>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticField", #externalFieldValue);
return js_2::_setPropertyUnchecked<self::A>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticField", #externalFieldValue);
static method B|staticMethod() → self::A
return js_::_callMethodUnchecked0<self::A>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticMethod");
return js_2::_callMethodUnchecked0<self::A>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticMethod");
static method B|staticGenericMethod<T extends core::Object? = dynamic>(self::B|staticGenericMethod::T% t) → self::B|staticGenericMethod::T%
return js_::callMethod<self::B|staticGenericMethod::T%>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticGenericMethod", <dynamic>[t]);
return js_2::callMethod<self::B|staticGenericMethod::T%>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticGenericMethod", <dynamic>[t]);
static get B|staticGetter() → self::B
return js_::getProperty<self::B>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticGetter");
return js_2::getProperty<self::B>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticGetter");
static set B|staticSetter(self::B b) → void
return js_::setProperty<self::B>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticSetter", b);
return js_2::setProperty<self::B>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticSetter", b);
static method method(self::A a) → void {
self::B b1 = self::B|(a);
self::B b2 = self::B|named(0);
@ -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-sdk:///lib/js_interop/js_interop.dart)
- 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 "dart:js_interop" as js_;
import "dart:core" as core;
import "dart:js_interop";
@ -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-sdk:///lib/js_interop/js_interop.dart)
- 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 "dart:js_interop" as js_;
import "dart:core" as core;
import "dart:js_interop";
@ -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-sdk:///lib/js_interop/js_interop.dart)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)

View file

@ -1,7 +1,7 @@
@_js_annotations::JS::•()
@dart.js_interop::JS::•()
library static_interop /*isNonNullableByDefault*/;
import self as self;
import "dart:_js_annotations" as _js;
import "dart:js_interop" as js_;
import "dart:core" as core;
import "dart:js_interop";
@ -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,9 +1,9 @@
@#C2
library static_interop /*isNonNullableByDefault*/;
import self as self;
import "dart:_js_annotations" as _js;
import "dart:js_interop" as js_;
import "dart:core" as core;
import "dart:js_util" as js_;
import "dart:js_util" as js_2;
import "dart:js_interop";
@ -34,41 +34,41 @@ inline class B /* declaredRepresentationType = self::A */ {
tearoff named = self::B|get#named;
}
static method B|(self::A a) → self::B
return js_::_callConstructorUnchecked1<self::B>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), a);
return js_2::_callConstructorUnchecked1<self::B>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), a);
static method B|get#(self::A a) → self::B
return self::B|(a);
static method B|named(core::int i) → self::B
return js_::_callConstructorUnchecked1<self::B>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), i);
return js_2::_callConstructorUnchecked1<self::B>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), i);
static method B|get#named(core::int i) → self::B
return self::B|named(i);
static method B|get#field(self::A #this) → self::A
return js_::getProperty<self::A>(#this, "field");
return js_2::getProperty<self::A>(#this, "field");
static method B|set#field(self::A #this, self::A #externalFieldValue) → void
return js_::_setPropertyUnchecked<self::A>(#this, "field", #externalFieldValue);
return js_2::_setPropertyUnchecked<self::A>(#this, "field", #externalFieldValue);
static method B|method(lowered final self::B #this) → self::A
return js_::_callMethodUnchecked0<self::A>(#this, "method");
return js_2::_callMethodUnchecked0<self::A>(#this, "method");
static method B|get#method(lowered final self::B #this) → () → self::A
return () → self::A => self::B|method(#this);
static method B|genericMethod<T extends core::Object? = dynamic>(lowered final self::B #this, self::B|genericMethod::T% t) → self::B|genericMethod::T%
return js_::callMethod<self::B|genericMethod::T%>(#this, "genericMethod", <dynamic>[t]);
return js_2::callMethod<self::B|genericMethod::T%>(#this, "genericMethod", <dynamic>[t]);
static method B|get#genericMethod(lowered final self::B #this) → <T extends core::Object? = dynamic>(T%) → T%
return <T extends core::Object? = dynamic>(T% t) → T% => self::B|genericMethod<T%>(#this, t);
static method B|get#getter(lowered final self::B #this) → self::B
return js_::getProperty<self::B>(#this, "getter");
return js_2::getProperty<self::B>(#this, "getter");
static method B|set#setter(lowered final self::B #this, self::B b) → void
return js_::setProperty<self::B>(#this, "setter", b);
return js_2::setProperty<self::B>(#this, "setter", b);
static get B|staticField() → self::A
return js_::getProperty<self::A>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticField");
return js_2::getProperty<self::A>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticField");
static set B|staticField(self::A #externalFieldValue) → void
return js_::_setPropertyUnchecked<self::A>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticField", #externalFieldValue);
return js_2::_setPropertyUnchecked<self::A>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticField", #externalFieldValue);
static method B|staticMethod() → self::A
return js_::_callMethodUnchecked0<self::A>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticMethod");
return js_2::_callMethodUnchecked0<self::A>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticMethod");
static method B|staticGenericMethod<T extends core::Object? = dynamic>(self::B|staticGenericMethod::T% t) → self::B|staticGenericMethod::T%
return js_::callMethod<self::B|staticGenericMethod::T%>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticGenericMethod", <dynamic>[t]);
return js_2::callMethod<self::B|staticGenericMethod::T%>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticGenericMethod", <dynamic>[t]);
static get B|staticGetter() → self::B
return js_::getProperty<self::B>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticGetter");
return js_2::getProperty<self::B>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticGetter");
static set B|staticSetter(self::B b) → void
return js_::setProperty<self::B>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticSetter", b);
return js_2::setProperty<self::B>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticSetter", b);
static method method(self::A a) → void {
self::B b1 = self::B|(a);
self::B b2 = self::B|named(0);
@ -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-sdk:///lib/js_interop/js_interop.dart)
- 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 "dart:js_interop" as js_;
import "dart:core" as core;
import "dart:js_interop";
@ -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-sdk:///lib/js_interop/js_interop.dart)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)

View file

@ -1,9 +1,9 @@
@#C2
library static_interop /*isNonNullableByDefault*/;
import self as self;
import "dart:_js_annotations" as _js;
import "dart:js_interop" as js_;
import "dart:core" as core;
import "dart:js_util" as js_;
import "dart:js_util" as js_2;
import "dart:js_interop";
@ -34,41 +34,41 @@ inline class B /* declaredRepresentationType = self::A */ {
tearoff named = self::B|get#named;
}
static method B|(self::A a) → self::B
return js_::_callConstructorUnchecked1<self::B>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), a);
return js_2::_callConstructorUnchecked1<self::B>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), a);
static method B|get#(self::A a) → self::B
return self::B|(a);
static method B|named(core::int i) → self::B
return js_::_callConstructorUnchecked1<self::B>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), i);
return js_2::_callConstructorUnchecked1<self::B>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), i);
static method B|get#named(core::int i) → self::B
return self::B|named(i);
static method B|get#field(self::A #this) → self::A
return js_::getProperty<self::A>(#this, "field");
return js_2::getProperty<self::A>(#this, "field");
static method B|set#field(self::A #this, self::A #externalFieldValue) → void
return js_::_setPropertyUnchecked<self::A>(#this, "field", #externalFieldValue);
return js_2::_setPropertyUnchecked<self::A>(#this, "field", #externalFieldValue);
static method B|method(lowered final self::B #this) → self::A
return js_::_callMethodUnchecked0<self::A>(#this, "method");
return js_2::_callMethodUnchecked0<self::A>(#this, "method");
static method B|get#method(lowered final self::B #this) → () → self::A
return () → self::A => self::B|method(#this);
static method B|genericMethod<T extends core::Object? = dynamic>(lowered final self::B #this, self::B|genericMethod::T% t) → self::B|genericMethod::T%
return js_::callMethod<self::B|genericMethod::T%>(#this, "genericMethod", <dynamic>[t]);
return js_2::callMethod<self::B|genericMethod::T%>(#this, "genericMethod", <dynamic>[t]);
static method B|get#genericMethod(lowered final self::B #this) → <T extends core::Object? = dynamic>(T%) → T%
return <T extends core::Object? = dynamic>(T% t) → T% => self::B|genericMethod<T%>(#this, t);
static method B|get#getter(lowered final self::B #this) → self::B
return js_::getProperty<self::B>(#this, "getter");
return js_2::getProperty<self::B>(#this, "getter");
static method B|set#setter(lowered final self::B #this, self::B b) → void
return js_::setProperty<self::B>(#this, "setter", b);
return js_2::setProperty<self::B>(#this, "setter", b);
static get B|staticField() → self::A
return js_::getProperty<self::A>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticField");
return js_2::getProperty<self::A>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticField");
static set B|staticField(self::A #externalFieldValue) → void
return js_::_setPropertyUnchecked<self::A>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticField", #externalFieldValue);
return js_2::_setPropertyUnchecked<self::A>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticField", #externalFieldValue);
static method B|staticMethod() → self::A
return js_::_callMethodUnchecked0<self::A>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticMethod");
return js_2::_callMethodUnchecked0<self::A>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticMethod");
static method B|staticGenericMethod<T extends core::Object? = dynamic>(self::B|staticGenericMethod::T% t) → self::B|staticGenericMethod::T%
return js_::callMethod<self::B|staticGenericMethod::T%>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticGenericMethod", <dynamic>[t]);
return js_2::callMethod<self::B|staticGenericMethod::T%>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticGenericMethod", <dynamic>[t]);
static get B|staticGetter() → self::B
return js_::getProperty<self::B>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticGetter");
return js_2::getProperty<self::B>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticGetter");
static set B|staticSetter(self::B b) → void
return js_::setProperty<self::B>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticSetter", b);
return js_2::setProperty<self::B>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticSetter", b);
static method method(self::A a) → void {
self::B b1 = self::B|(a);
self::B b2 = self::B|named(0);
@ -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-sdk:///lib/js_interop/js_interop.dart)
- 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 "dart:js_interop" as js_;
import "dart:core" as core;
import "dart:js_interop";
@ -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-sdk:///lib/js_interop/js_interop.dart)
- 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 "dart:js_interop" as js_;
import "dart:core" as core;
import "dart:js_interop";
@ -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-sdk:///lib/js_interop/js_interop.dart)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)

View file

@ -1,7 +1,7 @@
@_js_annotations::JS::•()
@dart.js_interop::JS::•()
library static_interop /*isNonNullableByDefault*/;
import self as self;
import "dart:_js_annotations" as _js;
import "dart:js_interop" as js_;
import "dart:core" as core;
import "dart:js_interop";
@ -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,9 +1,9 @@
@#C2
library static_interop /*isNonNullableByDefault*/;
import self as self;
import "dart:_js_annotations" as _js;
import "dart:js_interop" as js_;
import "dart:core" as core;
import "dart:js_util" as js_;
import "dart:js_util" as js_2;
import "dart:js_interop";
@ -34,41 +34,41 @@ inline class B /* declaredRepresentationType = self::A */ {
tearoff named = self::B|get#named;
}
static method B|(self::A a) → self::B
return js_::_callConstructorUnchecked1<self::B>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), a);
return js_2::_callConstructorUnchecked1<self::B>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), a);
static method B|get#(self::A a) → self::B
return self::B|(a);
static method B|named(core::int i) → self::B
return js_::_callConstructorUnchecked1<self::B>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), i);
return js_2::_callConstructorUnchecked1<self::B>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), i);
static method B|get#named(core::int i) → self::B
return self::B|named(i);
static method B|get#field(self::A #this) → self::A
return js_::getProperty<self::A>(#this, "field");
return js_2::getProperty<self::A>(#this, "field");
static method B|set#field(self::A #this, self::A #externalFieldValue) → void
return js_::_setPropertyUnchecked<self::A>(#this, "field", #externalFieldValue);
return js_2::_setPropertyUnchecked<self::A>(#this, "field", #externalFieldValue);
static method B|method(lowered final self::B #this) → self::A
return js_::_callMethodUnchecked0<self::A>(#this, "method");
return js_2::_callMethodUnchecked0<self::A>(#this, "method");
static method B|get#method(lowered final self::B #this) → () → self::A
return () → self::A => self::B|method(#this);
static method B|genericMethod<T extends core::Object? = dynamic>(lowered final self::B #this, self::B|genericMethod::T% t) → self::B|genericMethod::T%
return js_::callMethod<self::B|genericMethod::T%>(#this, "genericMethod", <dynamic>[t]);
return js_2::callMethod<self::B|genericMethod::T%>(#this, "genericMethod", <dynamic>[t]);
static method B|get#genericMethod(lowered final self::B #this) → <T extends core::Object? = dynamic>(T%) → T%
return <T extends core::Object? = dynamic>(T% t) → T% => self::B|genericMethod<T%>(#this, t);
static method B|get#getter(lowered final self::B #this) → self::B
return js_::getProperty<self::B>(#this, "getter");
return js_2::getProperty<self::B>(#this, "getter");
static method B|set#setter(lowered final self::B #this, self::B b) → void
return js_::setProperty<self::B>(#this, "setter", b);
return js_2::setProperty<self::B>(#this, "setter", b);
static get B|staticField() → self::A
return js_::getProperty<self::A>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticField");
return js_2::getProperty<self::A>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticField");
static set B|staticField(self::A #externalFieldValue) → void
return js_::_setPropertyUnchecked<self::A>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticField", #externalFieldValue);
return js_2::_setPropertyUnchecked<self::A>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticField", #externalFieldValue);
static method B|staticMethod() → self::A
return js_::_callMethodUnchecked0<self::A>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticMethod");
return js_2::_callMethodUnchecked0<self::A>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticMethod");
static method B|staticGenericMethod<T extends core::Object? = dynamic>(self::B|staticGenericMethod::T% t) → self::B|staticGenericMethod::T%
return js_::callMethod<self::B|staticGenericMethod::T%>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticGenericMethod", <dynamic>[t]);
return js_2::callMethod<self::B|staticGenericMethod::T%>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticGenericMethod", <dynamic>[t]);
static get B|staticGetter() → self::B
return js_::getProperty<self::B>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticGetter");
return js_2::getProperty<self::B>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticGetter");
static set B|staticSetter(self::B b) → void
return js_::setProperty<self::B>(js_::_getPropertyTrustType<core::Object>(js_::globalThis, "B"), "staticSetter", b);
return js_2::setProperty<self::B>(js_2::_getPropertyTrustType<core::Object>(js_2::globalThis, "B"), "staticSetter", b);
static method method(self::A a) → void {
self::B b1 = self::B|(a);
self::B b2 = self::B|named(0);
@ -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-sdk:///lib/js_interop/js_interop.dart)
- 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 "package:js/js.dart" as js;
import "dart:_js_annotations" 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-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
- 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 "package:js/js.dart" as js;
import "dart:_js_annotations" 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-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
- 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 "package:js/js.dart" as js;
import "dart:_js_annotations" 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-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
- 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 "package:js/js.dart" as js;
import "dart:_js_annotations" 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-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
- 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 "package:js/js.dart" as js;
import "dart:_js_annotations" 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-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)

View file

@ -10,7 +10,7 @@ library /*isNonNullableByDefault*/;
// ^
//
import self as self;
import "package:js/js.dart" as js;
import "dart:_js_annotations" 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-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)

View file

@ -10,7 +10,7 @@ library /*isNonNullableByDefault*/;
// ^
//
import self as self;
import "package:js/js.dart" as js;
import "dart:_js_annotations" 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-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)

View file

@ -10,7 +10,7 @@ library /*isNonNullableByDefault*/;
// ^
//
import self as self;
import "package:js/js.dart" as js;
import "dart:_js_annotations" 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-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)

View file

@ -10,7 +10,7 @@ library /*isNonNullableByDefault*/;
// ^
//
import self as self;
import "package:js/js.dart" as js;
import "dart:_js_annotations" 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-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)

View file

@ -1,12 +1,12 @@
library /*isNonNullableByDefault*/;
import self as self;
import "package:js/js.dart" as js;
import "dart:_js_annotations" 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 "package:js/js.dart" as js;
import "dart:_js_annotations" 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-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)

View file

@ -10,7 +10,7 @@ library /*isNonNullableByDefault*/;
// ^
//
import self as self;
import "package:js/js.dart" as js;
import "dart:_js_annotations" 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-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)

View file

@ -10,7 +10,7 @@ library /*isNonNullableByDefault*/;
// ^
//
import self as self;
import "package:js/js.dart" as js;
import "dart:_js_annotations" 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-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)

View file

@ -10,7 +10,7 @@ library /*isNonNullableByDefault*/;
// ^
//
import self as self;
import "package:js/js.dart" as js;
import "dart:_js_annotations" 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-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)

View file

@ -10,7 +10,7 @@ library /*isNonNullableByDefault*/;
// ^
//
import self as self;
import "package:js/js.dart" as js;
import "dart:_js_annotations" 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-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)

View file

@ -1,12 +1,12 @@
library /*isNonNullableByDefault*/;
import self as self;
import "package:js/js.dart" as js;
import "dart:_js_annotations" 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 "package:js/js.dart" as js;
import "dart:_js_annotations" 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-testcase-sdk:///pkg/js/lib/js.dart:23:9)
- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)

View file

@ -79,14 +79,7 @@ worlds:
eval('''function JSClass() {}''');
}
js/lib/js.dart: |
class JS {
final String? name;
const JS([this.name]);
}
class _StaticInterop {
const _StaticInterop();
}
const _StaticInterop staticInterop = _StaticInterop();
export 'dart:_js_annotations' show JS, staticInterop;
.dart_tool/package_config.json: |
{
"configVersion": 2,

View file

@ -1,22 +1,10 @@
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 {
@ -45,13 +33,13 @@ library from "org-dartlang-test:///lib1.dart" as lib1 {
return sta::StaticJSClass::•();
static set topLevelSetter((sta::StaticJSClass) → void f) → void {}
}
@#C3
@#C2
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"));
@ -63,7 +51,7 @@ library static_interop from "org-dartlang-test:///lib2.dart" as sta {
static method _#factory#tearOff() → sta::StaticJSClass
return sta::StaticJSClass::factory();
}
@#C3
@#C2
external static method eval(dart.core::String code) → void;
static method setUp() → void {
sta::eval("function JSClass() {}");
@ -105,10 +93,10 @@ library from "org-dartlang-test:///main.dart" as main {
}
constants {
#C1 = null
#C2 = js::_StaticInterop {}
#C3 = js::JS {name:#C1}
#C4 = "JSClass"
#C5 = js::JS {name:#C4}
#C2 = _js_annotations::JS {name:#C1}
#C3 = "JSClass"
#C4 = _js_annotations::JS {name:#C3}
#C5 = _js_annotations::_StaticInterop {}
#C6 = static-tearoff lib1::topLevelMethod
#C7 = static-tearoff lib1::Class::staticMethod
}
@ -116,10 +104,6 @@ constants {
Constructor coverage from constants:
org-dartlang-test:///lib2.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)
- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)

View file

@ -1,22 +1,10 @@
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 {
@ -45,13 +33,13 @@ library from "org-dartlang-test:///lib1.dart" as lib1 {
return sta::StaticJSClass::•();
static set topLevelSetter((sta::StaticJSClass) → void f) → void {}
}
@#C3
@#C2
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"));
@ -63,7 +51,7 @@ library static_interop from "org-dartlang-test:///lib2.dart" as sta {
static method _#factory#tearOff() → sta::StaticJSClass
return sta::StaticJSClass::factory();
}
@#C3
@#C2
external static method eval(dart.core::String code) → void;
static method setUp() → void {
sta::eval("function JSClass() {}");
@ -106,10 +94,10 @@ library from "org-dartlang-test:///main.dart" as main {
}
constants {
#C1 = null
#C2 = js::_StaticInterop {}
#C3 = js::JS {name:#C1}
#C4 = "JSClass"
#C5 = js::JS {name:#C4}
#C2 = _js_annotations::JS {name:#C1}
#C3 = "JSClass"
#C4 = _js_annotations::JS {name:#C3}
#C5 = _js_annotations::_StaticInterop {}
#C6 = static-tearoff lib1::topLevelMethod
#C7 = static-tearoff lib1::Class::staticMethod
}
@ -117,10 +105,6 @@ constants {
Constructor coverage from constants:
org-dartlang-test:///lib2.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)
- JS. (from org-dartlang-sdk:///lib/js/_js_annotations.dart)
- Object. (from org-dartlang-sdk:///lib/core/object.dart)

View file

@ -3,6 +3,9 @@
- Remove dependency on `dart:js`.
- Update SDK lower constraint to 3.0.0-217.0.dev.
- Update SDK upper constraint to 4.0.0.
<!-- TODO(srujzs): Before publishing, update SDK lower constraint to match the
CL that does this. -->
- Moved annotations to single location in `dart:_js_annotations`.
## 0.6.7

View file

@ -2,89 +2,9 @@
// 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;
import 'package:meta/meta.dart';
// ignore: EXPORT_INTERNAL_LIBRARY
export 'dart:_js_annotations'
show JS, anonymous, staticInterop, trustTypes, JSExport;
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,12 +3,14 @@ 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' show JS;
import 'dart:_foreign_helper' as foreign_helper;
import 'dart:_internal' show patch;
import 'dart:_js_types';
import 'dart:js_util' as js_util;
@ -19,11 +19,12 @@ extension NullableUndefineableJSAnyExtension on JSAny? {
this == null || js_util.typeofEquals(this, 'undefined');
@patch
bool get isNull => this == null || JS('bool', '# === null', this);
bool get isNull =>
this == null || foreign_helper.JS('bool', '# === null', this);
@patch
JSBoolean typeofEquals(JSString typeString) =>
JS('bool', 'typeof # === #', this, typeString);
foreign_helper.JS('bool', 'typeof # === #', this, typeString);
@patch
Object? dartify() => js_util.dartify(this);
@ -39,7 +40,7 @@ extension NullableObjectUtilExtension on Object? {
extension JSObjectUtilExtension on JSObject {
@patch
JSBoolean instanceof(JSFunction constructor) =>
JS('bool', '# instanceof #', this, constructor);
foreign_helper.JS('bool', '# instanceof #', this, constructor);
}
/// [JSExportedDartFunction] <-> [Function]

View file

@ -3,10 +3,11 @@
// BSD-style license that can be found in the LICENSE file.
import 'dart:_internal' show patch;
import 'dart:_js_helper';
import 'dart:_js_helper' hide JS;
import 'dart:_js_helper' as js_helper;
import 'dart:_wasm';
import 'dart:async' show Completer;
import 'dart:js_interop' hide JS;
import 'dart:js_interop';
import 'dart:js_util' as js_util;
import 'dart:typed_data';
@ -32,8 +33,9 @@ extension NullableUndefineableJSAnyExtension on JSAny? {
bool get isNull => this == null || this!.toExternRef.isNull;
@patch
JSBoolean typeofEquals(JSString type) => _box<JSBoolean>(JS<WasmExternRef?>(
'(o, t) => typeof o === t', this?.toExternRef, type.toExternRef));
JSBoolean typeofEquals(JSString type) =>
_box<JSBoolean>(js_helper.JS<WasmExternRef?>(
'(o, t) => typeof o === t', this?.toExternRef, type.toExternRef));
@patch
Object? dartify() => js_util.dartify(this);
@ -49,7 +51,7 @@ extension NullableObjectUtilExtension on Object? {
extension JSObjectUtilExtension on JSObject {
@patch
JSBoolean instanceof(JSFunction constructor) =>
_box<JSBoolean>(JS<WasmExternRef?>(
_box<JSBoolean>(js_helper.JS<WasmExternRef?>(
'(o, c) => o instanceof c', toExternRef, constructor.toExternRef));
}

View file

@ -2,13 +2,21 @@
// 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.
// 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
/// Annotations to mark interfaces to JavaScript. All of these annotations are
/// exported via `package:js`.
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]);
@ -22,10 +30,58 @@ 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,12 +21,34 @@ library dart.js_interop;
import 'dart:_js_types' as js_types;
import 'dart:typed_data';
/// 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. Also allow use of `@staticInterop` classes with JS
/// types as well as export functionality.
export 'dart:_js_annotations' show JS, staticInterop, anonymous, JSExport;
/// Allow use of `@staticInterop` classes with JS types as well as export
/// functionality.
export 'dart:_js_annotations' show staticInterop, anonymous, JSExport;
/// 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` exports an `@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]);
}
/// The annotation for object literal constructors.
///

View file

@ -9,7 +9,6 @@ import 'dart:js_util';
import 'dart:typed_data';
import 'package:expect/minitest.dart';
import 'package:js/js.dart';
@JS()
external void eval(String code);

View file

@ -10,7 +10,6 @@ import 'dart:js_util' show newObject;
import 'dart:typed_data';
import 'package:expect/expect.dart';
import 'package:js/js.dart';
@JS()
external void eval(String code);

View file

@ -12,7 +12,7 @@ import 'dart:_interceptors' show JavaScriptObject;
import 'package:js/js.dart';
import '../native_testing.dart';
import '../native_testing.dart' hide JS;
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';
import '../native_testing.dart' hide JS;
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';
import '../native_testing.dart' hide JS;
import '../native_testing.dart' as native_testing;
NativeClass makeNativeClass() native;

View file

@ -8,7 +8,6 @@ import 'dart:typed_data';
import 'package:async_helper/async_helper.dart';
import 'package:expect/expect.dart';
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';
import '../native_testing.dart' hide JS;
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';
import '../native_testing.dart' hide JS;
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';
import '../native_testing.dart' hide JS;
import '../native_testing.dart' as native_testing;
NativeClass makeNativeClass() native;