Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/js_interop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ jobs:
strategy:
fail-fast: false
matrix:
sdk: ['3.10', beta, dev]
# Add back in 3.12 when it's stable
sdk: [beta, dev]
test_config: ['-p chrome', '-p chrome -c dart2wasm', '-p node']

steps:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/js_interop_gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ jobs:
strategy:
fail-fast: false
matrix:
sdk: ['3.10', dev]
# Add back in 3.12 when it's stable
sdk: [beta, dev]
test_config: ['', '-p chrome', '-p chrome -c dart2wasm']

steps:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ jobs:
strategy:
fail-fast: false
matrix:
sdk: ['3.10', beta, dev]
test_config: ['-p chrome', '-p chrome -c dart2wasm']
# Add back in 3.12 when it's stable
sdk: [beta, dev]
test_config: ['-p chrome -c dart2js', '-p chrome -c dart2wasm', '-p vm']

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/web_generator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ jobs:
strategy:
fail-fast: false
matrix:
sdk: ['3.10', dev]
# Add back in 3.12 when it's stable
sdk: [beta, dev]

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
Expand All @@ -51,6 +52,9 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- uses: dart-lang/setup-dart@65eb853c7ba17dde3be364c3d2858773e7144260
with:
# Drop this when 3.12 is stable
sdk: dev

- run: npm install
- run: dart pub get
Expand All @@ -66,6 +70,9 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- uses: dart-lang/setup-dart@65eb853c7ba17dde3be364c3d2858773e7144260
with:
# Drop this when 3.12 is stable
sdk: dev

- run: npm install
- run: dart pub get
Expand Down
2 changes: 1 addition & 1 deletion js_interop/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Utility APIs for dart:js_interop and dart:js_interop_unsafe.
repository: https://github.com/dart-lang/web

environment:
sdk: ^3.10.0
sdk: ^3.12.0-0

dev_dependencies:
test: ^1.26.0
8 changes: 4 additions & 4 deletions js_interop_gen/lib/src/ast/declarations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ sealed class TypeDeclaration extends NestableDeclaration
this.constructors = const [],
this.parent,
this.documentation,
required ID id,
}) : _id = id;
required this._id,
});

/// [useFirstExtendeeAsRepType] is used to assert that the extension type
/// generated has a representation type of the first member of [extendees]
Expand Down Expand Up @@ -644,13 +644,13 @@ class NamespaceDeclaration extends NestableDeclaration
NamespaceDeclaration({
required this.name,
this.exported = true,
required ID id,
required this._id,
this.dartName,
this.topLevelDeclarations = const {},
this.namespaceDeclarations = const {},
this.nestableDeclarations = const {},
this.documentation,
}) : _id = id;
});

@override
ExtensionType emit([covariant DeclarationOptions? options]) {
Expand Down
58 changes: 58 additions & 0 deletions js_interop_gen/lib/src/elements.dart
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,28 @@ class Parameter {
}
}

class IterableInfo {
final RawType? keyType;
final RawType valueType;
final bool isAsync;

IterableInfo({this.keyType, required this.valueType, required this.isAsync});
}

class MaplikeInfo {
final RawType keyType;
final RawType valueType;
final bool isReadOnly;
final bool isFromIterable;

MaplikeInfo({
required this.keyType,
required this.valueType,
required this.isReadOnly,
required this.isFromIterable,
});
}

class PartialInterfacelike {
final String name;
final String type;
Expand All @@ -316,6 +338,8 @@ class PartialInterfacelike {
final List<Property> extensionProperties = [];
final MdnInterface? mdnInterface;
OverridableConstructor? constructor;
IterableInfo? iterableInfo;
MaplikeInfo? maplikeInfo;

factory PartialInterfacelike(
idl.Interfacelike interfacelike,
Expand Down Expand Up @@ -475,9 +499,43 @@ class PartialInterfacelike {
);
break;
case 'maplike':
final decl = member as idl.MemberDeclaration;
final types =
((decl.idlType as JSAny) as JSArray<idl.IDLType>).toDart;
if (types.length != 2) {
throw Exception('Unexpected number of type arguments for maplike');
}
maplikeInfo = MaplikeInfo(
keyType: _getRawType(types[0]),
valueType: _getRawType(types[1]),
isReadOnly: decl.readonly,
isFromIterable: false,
);
break;
case 'setlike':
break;
case 'iterable':
case 'async_iterable':
final decl = member as idl.MemberDeclaration;
final types =
((decl.idlType as JSAny) as JSArray<idl.IDLType>).toDart;
RawType? keyType;
late RawType valueType;

if (types.length == 1) {
valueType = _getRawType(types[0]);
} else if (types.length == 2) {
keyType = _getRawType(types[0]);
valueType = _getRawType(types[1]);
} else {
throw Exception('Unexpected number of type arguments for iterable');
}

iterableInfo = IterableInfo(
keyType: keyType,
valueType: valueType,
isAsync: decl.async,
);
break;
default:
throw Exception('Unrecognized member type $type');
Expand Down
2 changes: 1 addition & 1 deletion js_interop_gen/lib/src/sdk_version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:yaml/yaml.dart';
///
/// For the purposes of code generation and tooling, we treat this as the
/// language version of the SDK.
final dartLanguageVersion = Version(3, 10, 0);
final dartLanguageVersion = Version(3, 12, 0);

/// Derives the language version from an SDK constraint.
Version deriveLanguageVersion(VersionConstraint constraint) {
Expand Down
Loading
Loading