Skip to content

Commit 1216e03

Browse files
authored
Merge pull request #132 from Rexios80/add-missing-getters
Fix issues with new js interop
2 parents 2971261 + 0e15616 commit 1216e03

File tree

10 files changed

+93
-2
lines changed

10 files changed

+93
-2
lines changed

lib/src/generated/event/event.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ extension type event._(JSObject _) implements JSObject {
4242
);
4343
external static void trigger(
4444
JSObject /*Object<null>*/ instance,
45-
String eventName,
45+
String eventName, [
4646
JSAny? /*UNPARSED:...?*/ eventArgs,
47-
);
47+
]);
4848
external static MapsEventListener addDomListener(
4949
JSObject /*Object<null>*/ instance,
5050
String eventName,

lib/src/generated/image_overlay/map_type.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,30 @@ extension type MapType._(JSObject _) implements JSObject {
2424
String? name,
2525
Projection? projection,
2626
});
27+
Element? Function(
28+
Point? tileCoord,
29+
num? zoom,
30+
Document? ownerDocument,
31+
) get getTile {
32+
final function = (getProperty('getTile'.toJS) as JSObject)
33+
.callMethod('bind'.toJS, [this].toJS) as JSFunction;
34+
return (tileCoord, zoom, ownerDocument) => function.callAsFunction(
35+
null, tileCoord, zoom?.toJS, ownerDocument) as Element?;
36+
}
37+
2738
void set getTile(
2839
Element? Function(
2940
Point tileCoord,
3041
num zoom,
3142
Document ownerDocument,
3243
) getTile) =>
3344
setProperty('getTile'.toJS, getTile.toJS);
45+
void Function([Element? tile]) get releaseTile {
46+
final function = (getProperty('releaseTile'.toJS) as JSObject)
47+
.callMethod('bind'.toJS, [this].toJS) as JSFunction;
48+
return ([tile]) => function.callAsFunction(null, tile);
49+
}
50+
3451
void set releaseTile(
3552
void Function(
3653
Element? tile,

lib/src/generated/image_overlay/projection.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,32 @@ part of '../image_overlay.dart';
1616

1717
extension type Projection._(JSObject _) implements JSObject {
1818
factory Projection() => JSObject() as Projection;
19+
Point? Function(
20+
LatLngOrLatLngLiteral latLng, [
21+
Point? point,
22+
]) get fromLatLngToPoint {
23+
final function = (getProperty('fromLatLngToPoint'.toJS) as JSObject)
24+
.callMethod('bind'.toJS, [this].toJS) as JSFunction;
25+
return (latLng, [point]) =>
26+
function.callAsFunction(null, latLng, point) as Point?;
27+
}
28+
1929
void set fromLatLngToPoint(
2030
Point? Function(
2131
LatLngOrLatLngLiteral latLng, [
2232
Point? point,
2333
]) fromLatLngToPoint) =>
2434
setProperty('fromLatLngToPoint'.toJS, fromLatLngToPoint.toJS);
35+
LatLng? Function(
36+
Point? pixel, [
37+
bool? noClampNoWrap,
38+
]) get fromPointToLatLng {
39+
final function = (getProperty('fromPointToLatLng'.toJS) as JSObject)
40+
.callMethod('bind'.toJS, [this].toJS) as JSFunction;
41+
return (pixel, [noClampNoWrap]) =>
42+
function.callAsFunction(null, pixel, noClampNoWrap?.toJS) as LatLng?;
43+
}
44+
2545
void set fromPointToLatLng(
2646
LatLng? Function(
2747
Point pixel, [

lib/src/generated/marker.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import 'dart:async' show Stream, StreamController;
1616
import 'dart:js_interop';
17+
import 'dart:js_interop_unsafe' show JSObjectUnsafeUtilExtension;
1718

1819
import 'coordinates.dart' show LatLng, LatLngOrLatLngLiteral, Point, Size;
1920
import 'event.dart' show MVCObject, MapsEventListener, event;

lib/src/generated/marker/marker.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ extension type Marker._(MVCObject _) implements MVCObject {
1919
external Marker([
2020
MarkerOptions? opts,
2121
]);
22+
bool isDraggableDefined() => callMethod('getDraggable'.toJS) != null;
23+
2224
external static int get MAX_ZINDEX;
2325
@JS('getAnimation')
2426
external Animation? _getAnimation();

lib/src/generated/polygon.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import 'dart:async' show Stream, StreamController;
1616
import 'dart:js_interop';
17+
import 'dart:js_interop_unsafe' show JSObjectUnsafeUtilExtension;
1718

1819
import 'coordinates.dart'
1920
show

lib/src/generated/polygon/circle.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ extension type Circle._(MVCObject _) implements MVCObject {
2222
external Circle.js([
2323
JSAny? /*(Circle|CircleLiteral|CircleOptions)?*/ circleOrCircleOptions,
2424
]);
25+
bool isDraggableDefined() => callMethod('getDraggable'.toJS) != null;
26+
2527
@JS('getBounds')
2628
external LatLngBounds? _getBounds();
2729
LatLngBounds? get bounds => _getBounds();

lib/src/generated/polygon/polygon.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ extension type Polygon._(MVCObject _) implements MVCObject {
1919
external Polygon([
2020
PolygonOptions? opts,
2121
]);
22+
bool isDraggableDefined() => callMethod('getDraggable'.toJS) != null;
23+
2224
@JS('getDraggable')
2325
external bool _getDraggable();
2426
bool get draggable => _getDraggable();

lib/src/generated/polygon/polyline.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ extension type Polyline._(MVCObject _) implements MVCObject {
1919
external Polyline([
2020
PolylineOptions? opts,
2121
]);
22+
bool isDraggableDefined() => callMethod('getDraggable'.toJS) != null;
23+
2224
@JS('getDraggable')
2325
external bool _getDraggable();
2426
bool get draggable => _getDraggable();

tool/generate_lib.dart

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,10 @@ extension LatLngBoundsOrLatLngBoundsLiteral$Ext on LatLngBoundsOrLatLngBoundsLit
510510
' external Circle.copy(Circle circle);',
511511
' external Circle.copyLiteral(CircleLiteral circle);',
512512
]);
513+
customCode.add('''
514+
bool isDraggableDefined() => callMethod('getDraggable'.toJS) != null;
515+
''');
516+
customDependencies.add('JSObjectUnsafeUtilExtension');
513517

514518
case 'Projection':
515519
customDependencies.addAll([
@@ -521,10 +525,24 @@ extension LatLngBoundsOrLatLngBoundsLiteral$Ext on LatLngBoundsOrLatLngBoundsLit
521525
customConstructors
522526
.add('factory Projection() => JSObject() as Projection;');
523527
customCode.add('''
528+
Point? Function(
529+
LatLngOrLatLngLiteral latLng, [
530+
Point? point,
531+
]) get fromLatLngToPoint {
532+
final function = (getProperty('fromLatLngToPoint'.toJS) as JSObject).callMethod('bind'.toJS, [this].toJS) as JSFunction;
533+
return (latLng, [point]) => function.callAsFunction(null, latLng, point) as Point?;
534+
}
524535
void set fromLatLngToPoint(Point? Function(
525536
LatLngOrLatLngLiteral latLng, [
526537
Point? point,
527538
]) fromLatLngToPoint) => setProperty('fromLatLngToPoint'.toJS, fromLatLngToPoint.toJS);
539+
LatLng? Function(
540+
Point? pixel, [
541+
bool? noClampNoWrap,
542+
]) get fromPointToLatLng {
543+
final function = (getProperty('fromPointToLatLng'.toJS) as JSObject).callMethod('bind'.toJS, [this].toJS) as JSFunction;
544+
return (pixel, [noClampNoWrap]) => function.callAsFunction(null, pixel, noClampNoWrap?.toJS) as LatLng?;
545+
}
528546
void set fromPointToLatLng(LatLng? Function(
529547
Point pixel, [
530548
bool? noClampNoWrap,
@@ -551,11 +569,23 @@ extension LatLngBoundsOrLatLngBoundsLiteral$Ext on LatLngBoundsOrLatLngBoundsLit
551569
'Document',
552570
]);
553571
customCode.add('''
572+
Element? Function(
573+
Point? tileCoord,
574+
num? zoom,
575+
Document? ownerDocument,
576+
) get getTile {
577+
final function = (getProperty('getTile'.toJS) as JSObject).callMethod('bind'.toJS, [this].toJS) as JSFunction;
578+
return (tileCoord, zoom, ownerDocument) => function.callAsFunction(null, tileCoord, zoom?.toJS, ownerDocument) as Element?;
579+
}
554580
void set getTile(Element? Function(
555581
Point tileCoord,
556582
num zoom,
557583
Document ownerDocument,
558584
) getTile) => setProperty('getTile'.toJS, getTile.toJS);
585+
void Function([Element? tile]) get releaseTile {
586+
final function = (getProperty('releaseTile'.toJS) as JSObject).callMethod('bind'.toJS, [this].toJS) as JSFunction;
587+
return ([tile]) => function.callAsFunction(null, tile);
588+
}
559589
void set releaseTile(void Function(
560590
Element? tile,
561591
) releaseTile) => setProperty('releaseTile'.toJS, releaseTile.toJS);
@@ -618,6 +648,20 @@ extension LatLngBoundsOrLatLngBoundsLiteral$Ext on LatLngBoundsOrLatLngBoundsLit
618648
case 'DataGeometryCollection':
619649
methods.removeWhere(
620650
(e) => {'forEachLatLng', 'getType'}.contains(e.method.name));
651+
case 'event':
652+
final triggerMethod =
653+
methods.firstWhere((e) => e.method.name == 'trigger');
654+
final eventArgsParameter = triggerMethod.method.parameters
655+
.firstWhere((e) => e.name == 'eventArgs');
656+
triggerMethod.method.parameters.remove(eventArgsParameter);
657+
triggerMethod.method.optionalParameters.add(eventArgsParameter);
658+
case 'Marker':
659+
case 'Polyline':
660+
case 'Polygon':
661+
customCode.add('''
662+
bool isDraggableDefined() => callMethod('getDraggable'.toJS) != null;
663+
''');
664+
customDependencies.add('JSObjectUnsafeUtilExtension');
621665
}
622666
for (final method in methods) {
623667
if (method.method.returnType.startsWith('JSPromise<') &&

0 commit comments

Comments
 (0)