From 30261d0d7030213a567ff6ace9a9c53cec9d6b1a Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Mon, 14 Nov 2022 12:16:44 -0800 Subject: [PATCH 1/3] Move to modern Dart style and lints Added package:lints/recommended and fixed all the lint warnings. API BREAK: EventSourceReadyState values are now camelCase instead of SCREAMING_CAPS. --- analysis_options.yaml | 1 + example/client_browser.dart | 7 +- lib/eventsource.dart | 58 +++--- lib/io_server.dart | 7 +- lib/publisher.dart | 20 +-- lib/src/decoder.dart | 20 ++- lib/src/encoder.dart | 12 +- lib/src/event_cache.dart | 4 +- pubspec.lock | 341 ++++++++++++++++++++++++++++++++++++ pubspec.yaml | 2 +- test/codec_test.dart | 30 ++-- 11 files changed, 425 insertions(+), 77 deletions(-) create mode 100644 analysis_options.yaml create mode 100644 pubspec.lock diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..572dd23 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1 @@ +include: package:lints/recommended.yaml diff --git a/example/client_browser.dart b/example/client_browser.dart index d77aeca..2aab88a 100644 --- a/example/client_browser.dart +++ b/example/client_browser.dart @@ -6,8 +6,9 @@ main() async { // approach. This will change once https://github.com/dart-lang/http/issues/1 // is fixed. - EventSource eventSource = await EventSource - .connect("http://example.org/events", client: new BrowserClient()); + EventSource eventSource = await EventSource.connect( + "http://example.org/events", + client: BrowserClient()); // listen for events eventSource.listen((Event event) { print("New event:"); @@ -20,7 +21,7 @@ main() async { String lastId = "iknowmylastid"; eventSource = await EventSource.connect( "http://example.org/events", - client: new BrowserClient(), + client: BrowserClient(), lastEventId: lastId, ); // listen for events diff --git a/lib/eventsource.dart b/lib/eventsource.dart index 9825c60..cd0b9f7 100644 --- a/lib/eventsource.dart +++ b/lib/eventsource.dart @@ -6,16 +6,20 @@ import "dart:async"; import "dart:convert"; import "package:http/http.dart" as http; -import "package:http/src/utils.dart" show encodingForCharset; import "package:http_parser/http_parser.dart" show MediaType; import "src/event.dart"; import "src/decoder.dart"; enum EventSourceReadyState { - CONNECTING, - OPEN, - CLOSED, + connecting, + open, + closed, +} + +Encoding encodingForCharset(String? charset, [Encoding fallback = latin1]) { + if (charset == null) return fallback; + return Encoding.getByName(charset) ?? fallback; } class EventSourceSubscriptionException extends Event implements Exception { @@ -38,23 +42,23 @@ class EventSource extends Stream { EventSourceReadyState get readyState => _readyState; - Stream get onOpen => this.where((e) => e.event == "open"); - Stream get onMessage => this.where((e) => e.event == "message"); - Stream get onError => this.where((e) => e.event == "error"); + Stream get onOpen => where((e) => e.event == "open"); + Stream get onMessage => where((e) => e.event == "message"); + Stream get onError => where((e) => e.event == "error"); // internal attributes - StreamController _streamController = - new StreamController.broadcast(); + final StreamController _streamController = + StreamController.broadcast(); - EventSourceReadyState _readyState = EventSourceReadyState.CLOSED; + EventSourceReadyState _readyState = EventSourceReadyState.closed; http.Client client; Duration _retryDelay = const Duration(milliseconds: 3000); String? _lastEventId; late EventSourceDecoder _decoder; - String _body; - String _method; + final String _body; + final String _method; /// Create a new EventSource by connecting to the specified url. static Future connect(url, @@ -65,31 +69,31 @@ class EventSource extends Stream { String? method}) async { // parameter initialization url = url is Uri ? url : Uri.parse(url); - client = client ?? new http.Client(); + client = client ?? http.Client(); body = body ?? ""; method = method ?? "GET"; - EventSource es = new EventSource._internal( - url, client, lastEventId, headers, body, method); + EventSource es = + EventSource._internal(url, client, lastEventId, headers, body, method); await es._start(); return es; } EventSource._internal(this.url, this.client, this._lastEventId, this.headers, this._body, this._method) { - _decoder = new EventSourceDecoder(retryIndicator: _updateRetryDelay); + _decoder = EventSourceDecoder(retryIndicator: _updateRetryDelay); } // proxy the listen call to the controller's listen call @override - StreamSubscription listen(void onData(Event event)?, - {Function? onError, void onDone()?, bool? cancelOnError}) => + StreamSubscription listen(void Function(Event event)? onData, + {Function? onError, void Function()? onDone, bool? cancelOnError}) => _streamController.stream.listen(onData, onError: onError, onDone: onDone, cancelOnError: cancelOnError); /// Attempt to start a new connection. Future _start() async { - _readyState = EventSourceReadyState.CONNECTING; - var request = new http.Request(_method, url); + _readyState = EventSourceReadyState.connecting; + var request = http.Request(_method, url); request.headers["Cache-Control"] = "no-cache"; request.headers["Accept"] = "text/event-stream"; if (_lastEventId?.isNotEmpty == true) { @@ -105,9 +109,9 @@ class EventSource extends Stream { // server returned an error var bodyBytes = await response.stream.toBytes(); String body = _encodingForHeaders(response.headers).decode(bodyBytes); - throw new EventSourceSubscriptionException(response.statusCode, body); + throw EventSourceSubscriptionException(response.statusCode, body); } - _readyState = EventSourceReadyState.OPEN; + _readyState = EventSourceReadyState.open; // start streaming the data response.stream.transform(_decoder).listen((Event event) { _streamController.add(event); @@ -115,16 +119,16 @@ class EventSource extends Stream { }, cancelOnError: true, onError: _retry, - onDone: () => _readyState = EventSourceReadyState.CLOSED); + onDone: () => _readyState = EventSourceReadyState.closed); } /// Retries until a new connection is established. Uses exponential backoff. Future _retry(dynamic e) async { - _readyState = EventSourceReadyState.CONNECTING; + _readyState = EventSourceReadyState.connecting; // try reopening with exponential backoff Duration backoff = _retryDelay; while (true) { - await new Future.delayed(backoff); + await Future.delayed(backoff); try { await _start(); break; @@ -151,6 +155,6 @@ Encoding _encodingForHeaders(Map headers) => /// Defaults to `application/octet-stream`. MediaType _contentTypeForHeaders(Map headers) { var contentType = headers['content-type']; - if (contentType != null) return new MediaType.parse(contentType); - return new MediaType("application", "octet-stream"); + if (contentType != null) return MediaType.parse(contentType); + return MediaType("application", "octet-stream"); } diff --git a/lib/io_server.dart b/lib/io_server.dart index 72c0fa6..87bb492 100644 --- a/lib/io_server.dart +++ b/lib/io_server.dart @@ -5,14 +5,13 @@ import "dart:io" as io; import "package:sync/waitgroup.dart"; import "publisher.dart"; -import "src/event.dart"; import "src/encoder.dart"; /// Create a handler to serve [io.HttpRequest] objects for the specified /// channel. /// This method can be passed to the [io.HttpServer.listen] method. Function createIoHandler(EventSourcePublisher publisher, - {String channel: "", bool gzip: false}) { + {String channel = "", bool gzip = false}) { void ioHandler(io.HttpRequest request) { io.HttpResponse response = request.response; @@ -30,13 +29,13 @@ Function createIoHandler(EventSourcePublisher publisher, if (useGzip) response.headers.set("Content-Encoding", "gzip"); // a wait group to keep track of flushes in order not to close while // flushing - WaitGroup flushes = new WaitGroup(); + WaitGroup flushes = WaitGroup(); // flush the headers flushes.add(1); response.flush().then((_) => flushes.done()); // create encoder for this connection - var encodedSink = new EventSourceEncoder(compressed: useGzip) + var encodedSink = EventSourceEncoder(compressed: useGzip) .startChunkedConversion(response); // define the methods for pushing events and closing the connection diff --git a/lib/publisher.dart b/lib/publisher.dart index 8a0a5bc..1ac4070 100644 --- a/lib/publisher.dart +++ b/lib/publisher.dart @@ -27,31 +27,31 @@ class EventSourcePublisher extends Sink { /// If your Event's id properties are not incremental using /// [Comparable.compare], set [comparableIds] to false. EventSourcePublisher({ - int cacheCapacity: 0, - bool comparableIds: false, - bool enableLogging: true, + int cacheCapacity = 0, + bool comparableIds = false, + bool enableLogging = true, }) { if (cacheCapacity > 0) { - _cache = new EventCache(cacheCapacity: cacheCapacity); + _cache = EventCache(cacheCapacity: cacheCapacity); } if (enableLogging) { - logger = new log.Logger("EventSourceServer"); + logger = log.Logger("EventSourceServer"); } } - Map> _subsByChannel = {}; + final Map> _subsByChannel = {}; /// Creates a Sink for the specified channel. /// The `add` and `remove` methods of this channel are equivalent to the /// respective methods of this class with the specific channel passed along. - Sink channel(String channel) => new ProxySink( + Sink channel(String channel) => ProxySink( onAdd: (e) => add(e, channels: [channel]), onClose: () => close(channels: [channel])); /// Add a publication to the specified channels. /// By default, only adds to the default channel. @override - void add(Event event, {Iterable channels: const [""]}) { + void add(Event event, {Iterable channels = const [""]}) { for (String channel in channels) { List? subs = _subsByChannel[channel]; if (subs == null) { @@ -70,7 +70,7 @@ class EventSourcePublisher extends Sink { /// All the connections with the subscribers to this channels will be closed. /// By default only closes the default channel. @override - void close({Iterable channels: const [""]}) { + void close({Iterable channels = const [""]}) { for (String channel in channels) { List? subs = _subsByChannel[channel]; if (subs == null) { @@ -97,7 +97,7 @@ class EventSourcePublisher extends Sink { }) { _logFine("New subscriber on channel $channel."); // create a sink for the subscription - ProxySink sub = new ProxySink(onAdd: onEvent, onClose: onClose); + ProxySink sub = ProxySink(onAdd: onEvent, onClose: onClose); // save the subscription _subsByChannel.putIfAbsent(channel, () => []).add(sub); // replay past events diff --git a/lib/src/decoder.dart b/lib/src/decoder.dart index 92ddc7e..5399e23 100644 --- a/lib/src/decoder.dart +++ b/lib/src/decoder.dart @@ -12,20 +12,21 @@ class EventSourceDecoder implements StreamTransformer, Event> { EventSourceDecoder({this.retryIndicator}); + @override Stream bind(Stream> stream) { late StreamController controller; - controller = new StreamController(onListen: () { + controller = StreamController(onListen: () { // the event we are currently building - Event currentEvent = new Event(); + Event currentEvent = Event(); // the regexes we will use later - RegExp lineRegex = new RegExp(r"^([^:]*)(?::)?(?: )?(.*)?$"); - RegExp removeEndingNewlineRegex = new RegExp(r"^((?:.|\n)*)\n$"); + RegExp lineRegex = RegExp(r"^([^:]*)(?::)?(?: )?(.*)?$"); + RegExp removeEndingNewlineRegex = RegExp(r"^((?:.|\n)*)\n$"); // This stream will receive chunks of data that is not necessarily a // single event. So we build events on the fly and broadcast the event as // soon as we encounter a double newline, then we start a new one. stream - .transform(new Utf8Decoder()) - .transform(new LineSplitter()) + .transform(Utf8Decoder()) + .transform(LineSplitter()) .listen((String line) { if (line.isEmpty) { // event is done @@ -35,7 +36,7 @@ class EventSourceDecoder implements StreamTransformer, Event> { currentEvent.data = match?.group(1); } controller.add(currentEvent); - currentEvent = new Event(); + currentEvent = Event(); return; } // match the line prefix and the value using the regex @@ -51,13 +52,13 @@ class EventSourceDecoder implements StreamTransformer, Event> { currentEvent.event = value; break; case "data": - currentEvent.data = (currentEvent.data ?? "") + value + "\n"; + currentEvent.data = "${currentEvent.data ?? ""}$value\n"; break; case "id": currentEvent.id = value; break; case "retry": - retryIndicator?.call(new Duration(milliseconds: int.parse(value))); + retryIndicator?.call(Duration(milliseconds: int.parse(value))); break; } }); @@ -65,6 +66,7 @@ class EventSourceDecoder implements StreamTransformer, Event> { return controller.stream; } + @override StreamTransformer cast() => StreamTransformer.castFrom, Event, RS, RT>(this); } diff --git a/lib/src/encoder.dart b/lib/src/encoder.dart index fef91b3..1ba3b57 100644 --- a/lib/src/encoder.dart +++ b/lib/src/encoder.dart @@ -9,17 +9,17 @@ import "proxy_sink.dart"; class EventSourceEncoder extends Converter> { final bool compressed; - const EventSourceEncoder({bool this.compressed: false}); + const EventSourceEncoder({this.compressed = false}); - static Map _fields = { + static final Map _fields = { "id: ": (e) => e.id, "event: ": (e) => e.event, "data: ": (e) => e.data, }; @override - List convert(Event event) { - String payload = convertToString(event); + List convert(Event input) { + String payload = convertToString(input); List bytes = utf8.encode(payload); if (compressed) { bytes = gzip.encode(bytes); @@ -36,7 +36,7 @@ class EventSourceEncoder extends Converter> { } // multi-line values need the field prefix on every line value = value.replaceAll("\n", "\n$prefix"); - payload += prefix + value + "\n"; + payload += "$prefix$value\n"; } payload += "\n"; return payload; @@ -51,7 +51,7 @@ class EventSourceEncoder extends Converter> { } inputSink = utf8.encoder.startChunkedConversion(inputSink as Sink>); - return new ProxySink( + return ProxySink( onAdd: (Event event) => inputSink.add(convertToString(event)), onClose: () => inputSink.close()); } diff --git a/lib/src/event_cache.dart b/lib/src/event_cache.dart index 97136b9..bb4e5b4 100644 --- a/lib/src/event_cache.dart +++ b/lib/src/event_cache.dart @@ -8,9 +8,9 @@ import "event.dart"; class EventCache { final int? cacheCapacity; final bool comparableIds; - Map> _caches = >{}; + final Map> _caches = >{}; - EventCache({this.cacheCapacity, this.comparableIds: true}); + EventCache({this.cacheCapacity, this.comparableIds = true}); void replay(Sink sink, String lastEventId, [String channel = ""]) { List? cache = _caches[channel]; diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 0000000..db34616 --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,341 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + url: "https://pub.dartlang.org" + source: hosted + version: "50.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + url: "https://pub.dartlang.org" + source: hosted + version: "5.2.0" + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.1" + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.10.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + collection: + dependency: "direct main" + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.17.0" + convert: + dependency: transitive + description: + name: convert + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.1" + coverage: + dependency: transitive + description: + name: coverage + url: "https://pub.dartlang.org" + source: hosted + version: "1.6.1" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.2" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.4" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" + glob: + dependency: transitive + description: + name: glob + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + http: + dependency: "direct main" + description: + name: http + url: "https://pub.dartlang.org" + source: hosted + version: "0.13.5" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + url: "https://pub.dartlang.org" + source: hosted + version: "3.2.1" + http_parser: + dependency: "direct main" + description: + name: http_parser + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.2" + io: + dependency: transitive + description: + name: io + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.5" + lints: + dependency: "direct dev" + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + logging: + dependency: "direct main" + description: + name: logging + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.13" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.0" + mime: + dependency: transitive + description: + name: mime + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + node_preamble: + dependency: transitive + description: + name: node_preamble + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + package_config: + dependency: transitive + description: + name: package_config + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.2" + pool: + dependency: transitive + description: + name: pool + url: "https://pub.dartlang.org" + source: hosted + version: "1.5.1" + pub_semver: + dependency: transitive + description: + name: pub_semver + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.3" + shelf: + dependency: transitive + description: + name: shelf + url: "https://pub.dartlang.org" + source: hosted + version: "1.4.0" + shelf_packages_handler: + dependency: transitive + description: + name: shelf_packages_handler + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" + shelf_static: + dependency: transitive + description: + name: shelf_static + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" + source_map_stack_trace: + dependency: transitive + description: + name: source_map_stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + source_maps: + dependency: transitive + description: + name: source_maps + url: "https://pub.dartlang.org" + source: hosted + version: "0.10.11" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.9.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.11.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + sync: + dependency: "direct main" + description: + name: sync + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.1" + test: + dependency: "direct dev" + description: + name: test + url: "https://pub.dartlang.org" + source: hosted + version: "1.22.0" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.16" + test_core: + dependency: transitive + description: + name: test_core + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.20" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" + vm_service: + dependency: transitive + description: + name: vm_service + url: "https://pub.dartlang.org" + source: hosted + version: "9.4.0" + watcher: + dependency: transitive + description: + name: watcher + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" + webkit_inspection_protocol: + dependency: transitive + description: + name: webkit_inspection_protocol + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + yaml: + dependency: transitive + description: + name: yaml + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.1" +sdks: + dart: ">=2.18.0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index f8b0dea..ab72a00 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,6 @@ name: eventsource description: A client and server implementation of Server-Sent Events. version: 0.4.0 -author: Steven Roose homepage: https://github.com/stevenroose/dart-eventsource environment: @@ -15,4 +14,5 @@ dependencies: sync: ^0.3.0 dev_dependencies: + lints: ^2.0.1 test: ^1.17.11 diff --git a/test/codec_test.dart b/test/codec_test.dart index cd0a16b..f58fbf5 100644 --- a/test/codec_test.dart +++ b/test/codec_test.dart @@ -9,19 +9,19 @@ import "package:eventsource/src/decoder.dart"; import "package:eventsource/src/encoder.dart"; import "package:eventsource/src/event.dart"; -Map _VECTORS = { - new Event(id: "1", event: "Add", data: "This is a test"): +Map _vectors = { + Event(id: "1", event: "Add", data: "This is a test"): "id: 1\nevent: Add\ndata: This is a test\n\n", - new Event(data: "This message, it\nhas two lines."): + Event(data: "This message, it\nhas two lines."): "data: This message, it\ndata: has two lines.\n\n", }; void main() { group("encoder", () { test("vectors", () { - var encoder = new EventSourceEncoder(); - for (Event event in _VECTORS.keys) { - var encoded = _VECTORS[event]!; + var encoder = EventSourceEncoder(); + for (Event event in _vectors.keys) { + var encoded = _vectors[event]!; expect(encoder.convert(event), equals(utf8.encode(encoded))); } }); @@ -30,11 +30,11 @@ void main() { group("decoder", () { test("vectors", () async { - for (Event event in _VECTORS.keys) { - var encoded = _VECTORS[event]!; - var stream = new Stream.fromIterable([encoded]) - .transform(new Utf8Encoder()) - .transform(new EventSourceDecoder()); + for (Event event in _vectors.keys) { + var encoded = _vectors[event]!; + var stream = Stream.fromIterable([encoded]) + .transform(Utf8Encoder()) + .transform(EventSourceDecoder()); stream.listen(expectAsync1((decodedEvent) { expect(decodedEvent.id, equals(event.id)); expect(decodedEvent.event, equals(event.event)); @@ -43,15 +43,15 @@ void main() { } }); test("pass retry value", () async { - Event event = new Event(id: "1", event: "Add", data: "This is a test"); + Event event = Event(id: "1", event: "Add", data: "This is a test"); String encodedWithRetry = "id: 1\nevent: Add\ndata: This is a test\nretry: 100\n\n"; var changeRetryValue = expectAsync1((Duration value) { expect(value.inMilliseconds, equals(100)); }, count: 1); - var stream = new Stream.fromIterable([encodedWithRetry]) - .transform(new Utf8Encoder()) - .transform(new EventSourceDecoder(retryIndicator: changeRetryValue)); + var stream = Stream.fromIterable([encodedWithRetry]) + .transform(Utf8Encoder()) + .transform(EventSourceDecoder(retryIndicator: changeRetryValue)); stream.listen(expectAsync1((decodedEvent) { expect(decodedEvent.id, equals(event.id)); expect(decodedEvent.event, equals(event.event)); From 7c0b477bbc2305d3b347d90b66bf0c8189ae358a Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Mon, 14 Nov 2022 12:20:31 -0800 Subject: [PATCH 2/3] Update version number to reflect API break. --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d67aca..fff9fa9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.5.0 (2022-11-12) +- Updated to modern dart style and linting. +- API BREAK: EventSourceReadyState values are now camelCase. + ## 0.4.0 (2022-03-23) - Migrate to null-safety diff --git a/pubspec.yaml b/pubspec.yaml index ab72a00..22dec3a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: eventsource description: A client and server implementation of Server-Sent Events. -version: 0.4.0 +version: 0.5.0 homepage: https://github.com/stevenroose/dart-eventsource environment: From 9684ce24788ea4faab247eac617908d42ae30b11 Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Mon, 14 Nov 2022 12:27:04 -0800 Subject: [PATCH 3/3] Add pubspec.lock to .gitignore Also removed the pubspec.lock from checkin. --- .gitignore | 1 + pubspec.lock | 341 --------------------------------------------------- 2 files changed, 1 insertion(+), 341 deletions(-) delete mode 100644 pubspec.lock diff --git a/.gitignore b/.gitignore index 5506c67..754affa 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ build/ packages # Remove the following pattern if you wish to check in your lock file +pubspec.lock pubspec.lock.old # Files created by dart2js diff --git a/pubspec.lock b/pubspec.lock deleted file mode 100644 index db34616..0000000 --- a/pubspec.lock +++ /dev/null @@ -1,341 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - _fe_analyzer_shared: - dependency: transitive - description: - name: _fe_analyzer_shared - url: "https://pub.dartlang.org" - source: hosted - version: "50.0.0" - analyzer: - dependency: transitive - description: - name: analyzer - url: "https://pub.dartlang.org" - source: hosted - version: "5.2.0" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "2.3.1" - async: - dependency: transitive - description: - name: async - url: "https://pub.dartlang.org" - source: hosted - version: "2.10.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" - collection: - dependency: "direct main" - description: - name: collection - url: "https://pub.dartlang.org" - source: hosted - version: "1.17.0" - convert: - dependency: transitive - description: - name: convert - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.1" - coverage: - dependency: transitive - description: - name: coverage - url: "https://pub.dartlang.org" - source: hosted - version: "1.6.1" - crypto: - dependency: transitive - description: - name: crypto - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.2" - file: - dependency: transitive - description: - name: file - url: "https://pub.dartlang.org" - source: hosted - version: "6.1.4" - frontend_server_client: - dependency: transitive - description: - name: frontend_server_client - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.0" - glob: - dependency: transitive - description: - name: glob - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" - http: - dependency: "direct main" - description: - name: http - url: "https://pub.dartlang.org" - source: hosted - version: "0.13.5" - http_multi_server: - dependency: transitive - description: - name: http_multi_server - url: "https://pub.dartlang.org" - source: hosted - version: "3.2.1" - http_parser: - dependency: "direct main" - description: - name: http_parser - url: "https://pub.dartlang.org" - source: hosted - version: "4.0.2" - io: - dependency: transitive - description: - name: io - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.3" - js: - dependency: transitive - description: - name: js - url: "https://pub.dartlang.org" - source: hosted - version: "0.6.5" - lints: - dependency: "direct dev" - description: - name: lints - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - logging: - dependency: "direct main" - description: - name: logging - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - matcher: - dependency: transitive - description: - name: matcher - url: "https://pub.dartlang.org" - source: hosted - version: "0.12.13" - meta: - dependency: transitive - description: - name: meta - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.0" - mime: - dependency: transitive - description: - name: mime - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.2" - node_preamble: - dependency: transitive - description: - name: node_preamble - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - package_config: - dependency: transitive - description: - name: package_config - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - path: - dependency: transitive - description: - name: path - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.2" - pool: - dependency: transitive - description: - name: pool - url: "https://pub.dartlang.org" - source: hosted - version: "1.5.1" - pub_semver: - dependency: transitive - description: - name: pub_semver - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.3" - shelf: - dependency: transitive - description: - name: shelf - url: "https://pub.dartlang.org" - source: hosted - version: "1.4.0" - shelf_packages_handler: - dependency: transitive - description: - name: shelf_packages_handler - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.1" - shelf_static: - dependency: transitive - description: - name: shelf_static - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - shelf_web_socket: - dependency: transitive - description: - name: shelf_web_socket - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.3" - source_map_stack_trace: - dependency: transitive - description: - name: source_map_stack_trace - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" - source_maps: - dependency: transitive - description: - name: source_maps - url: "https://pub.dartlang.org" - source: hosted - version: "0.10.11" - source_span: - dependency: transitive - description: - name: source_span - url: "https://pub.dartlang.org" - source: hosted - version: "1.9.1" - stack_trace: - dependency: transitive - description: - name: stack_trace - url: "https://pub.dartlang.org" - source: hosted - version: "1.11.0" - stream_channel: - dependency: transitive - description: - name: stream_channel - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" - string_scanner: - dependency: transitive - description: - name: string_scanner - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - sync: - dependency: "direct main" - description: - name: sync - url: "https://pub.dartlang.org" - source: hosted - version: "0.3.0" - term_glyph: - dependency: transitive - description: - name: term_glyph - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - test: - dependency: "direct dev" - description: - name: test - url: "https://pub.dartlang.org" - source: hosted - version: "1.22.0" - test_api: - dependency: transitive - description: - name: test_api - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.16" - test_core: - dependency: transitive - description: - name: test_core - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.20" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" - vm_service: - dependency: transitive - description: - name: vm_service - url: "https://pub.dartlang.org" - source: hosted - version: "9.4.0" - watcher: - dependency: transitive - description: - name: watcher - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.2" - web_socket_channel: - dependency: transitive - description: - name: web_socket_channel - url: "https://pub.dartlang.org" - source: hosted - version: "2.2.0" - webkit_inspection_protocol: - dependency: transitive - description: - name: webkit_inspection_protocol - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - yaml: - dependency: transitive - description: - name: yaml - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.1" -sdks: - dart: ">=2.18.0 <3.0.0"