Merge branch 'master' into modern-envoy

This commit is contained in:
Moritz 2025-02-21 14:14:46 +01:00 committed by GitHub
commit 2d91e189be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 26 additions and 20 deletions

View File

@ -7,6 +7,7 @@
* Upgrade to `package:lints` version 5.0.0 and Dart SDK version 3.5.0.
* Upgrade `example/grpc-web` code.
* Update xhr transport to migrate off legacy JS/HTML apis.
* Use `package:web` to get `HttpStatus`
## 4.0.1

View File

@ -14,9 +14,7 @@
// limitations under the License.
import 'dart:async';
// ignore: deprecated_member_use (#756)
import 'dart:html';
import 'package:web/web.dart';
import 'src/generated/echo.pbgrpc.dart';
class EchoApp {
@ -57,13 +55,23 @@ class EchoApp {
}
void _addMessage(String message, String cssClass) {
final classes = cssClass.split(' ');
querySelector('#first')!.after(DivElement()
..classes.add('row')
..append(Element.tag('h2')
..append(SpanElement()
..classes.add('label')
..classes.addAll(classes)
document.querySelector('#first')!.after(HTMLDivElement()
..classList.add('row')
..append(HTMLHeadingElement.h2()
..append(HTMLSpanElement()
..classList.add('label')
..classList.addAll(cssClass)
..text = message)));
}
}
// The documentation of DOMTokenList.add implies it can handle multiple classes,
// but in Chrome at least it does not.
extension AddAll on DOMTokenList {
void addAll(String cssClass) {
final classes = cssClass.split(' ');
for (final c in classes) {
add(c);
}
}
}

View File

@ -9,6 +9,7 @@ dependencies:
grpc:
path: ../../
protobuf: ^3.0.0
web: ^1.1.0
dev_dependencies:
build_runner: ^2.4.13

View File

@ -12,23 +12,20 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ignore: deprecated_member_use (#756)
import 'dart:html';
import 'package:grpc/grpc_web.dart';
import 'package:grpc_web/app.dart';
import 'package:grpc_web/src/generated/echo.pbgrpc.dart';
import 'package:web/web.dart';
void main() {
final channel = GrpcWebClientChannel.xhr(Uri.parse('http://localhost:8080'));
final service = EchoServiceClient(channel);
final app = EchoApp(service);
final button = querySelector('#send') as ButtonElement;
final button = document.querySelector('#send') as HTMLButtonElement;
button.onClick.listen((e) async {
final msg = querySelector('#msg') as TextInputElement;
final value = msg.value!.trim();
final msg = document.querySelector('#msg') as HTMLInputElement;
final value = msg.value.trim();
msg.value = '';
if (value.isEmpty) return;

View File

@ -13,4 +13,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
export 'io_bits_io.dart' if (dart.library.html) 'io_bits_web.dart';
export 'io_bits_io.dart' if (dart.library.js_interop) 'io_bits_web.dart';

View File

@ -13,8 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// ignore: deprecated_member_use (#756)
export 'dart:html' show HttpStatus;
export 'package:web/web.dart' show HttpStatus;
/// Unavailable on the web
class InternetAddress {}