Skip to content

Commit

Permalink
🚨 Fix browser extension lints.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chralu committed May 28, 2024
1 parent cd30dfc commit 216c412
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
24 changes: 8 additions & 16 deletions lib/infrastructure/rpc/browser_extension_aws.js.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ external int get windowIdCurrent;

bool get isWebBrowserExtension => browserExtension != null;

/**
* https://developer.chrome.com/docs/extensions/reference/api/runtime?type-Port#type-Port
*/
/// https://developer.chrome.com/docs/extensions/reference/api/runtime?type-Port#type-Port
@JS('runtime.Port')
class BrowserExtensionPort {
@JS('onMessage')
Expand All @@ -54,31 +52,27 @@ class BrowserExtensionPort {
get onDisconnect;

@JS('disconnect')
external disconnect();
external void disconnect();

@JS('postMessage')
external postMessage(dynamic message);
external void postMessage(dynamic message);
}

/**
* https://developer.chrome.com/docs/extensions/reference/api/events?type-Event#type-Event
*/
/// https://developer.chrome.com/docs/extensions/reference/api/events?type-Event#type-Event
@JS()
class BrowserExtensionEvent<H extends Function> {
@JS('addListener')
external addListener(
external void addListener(
H callback,
);

@JS('removeListener')
external removeListener(
external void removeListener(
H callback,
);
}

/**
* https://developer.chrome.com/docs/extensions/reference/api/runtime?type-MessageSender#type-MessageSender
*/
/// https://developer.chrome.com/docs/extensions/reference/api/runtime?type-MessageSender#type-MessageSender
@JS()
class BrowserExtensionMessageSender {
@JS('origin')
Expand All @@ -88,9 +82,7 @@ class BrowserExtensionMessageSender {
external BrowserExtensionTab? get tab;
}

/**
* https://developer.chrome.com/docs/extensions/reference/api/tabs#type-Tab
*/
/// https://developer.chrome.com/docs/extensions/reference/api/tabs#type-Tab
@JS()
class BrowserExtensionTab {
@JS('id')
Expand Down
8 changes: 5 additions & 3 deletions lib/infrastructure/rpc/browser_extension_aws.web.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: avoid_web_libraries_in_flutter, avoid_print

import 'dart:async';
import 'dart:js';

Expand Down Expand Up @@ -78,15 +80,15 @@ class BrowserExtensionMessagePortStreamChannel
port.onMessage.addListener(
allowInterop((message, _) {
if (message == null) return;
print('Wallet message received ${message}');
print('Wallet message received $message');
_in.add(message);
print('Wallet message received done ${message}');
print('Wallet message received done $message');
}),
);
print('Wallet Init WebMessage PortStreamchannel 1 ');

_out.stream.listen((event) {
print('Wallet response sent ${event}');
print('Wallet response sent $event');
port.postMessage(event);
});

Expand Down

0 comments on commit 216c412

Please sign in to comment.