Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
48 changes: 24 additions & 24 deletions apps/flutter_client_contract_test_service/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ packages:
dependency: transitive
description:
name: characters
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
url: "https://pub.dev"
source: hosted
version: "1.3.0"
version: "1.4.0"
checked_yaml:
dependency: transitive
description:
Expand Down Expand Up @@ -157,10 +157,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
url: "https://pub.dev"
source: hosted
version: "1.18.0"
version: "1.19.1"
connectivity_plus:
dependency: "direct main"
description:
Expand Down Expand Up @@ -311,10 +311,10 @@ packages:
dependency: "direct dev"
description:
name: http
sha256: d4872660c46d929f6b8a9ef4e7a7eff7e49bbf0c4ec3f385ee32df5119175139
sha256: fe7ab022b76f3034adc518fb6ea04a82387620e19977665ea18d30a1cf43442f
url: "https://pub.dev"
source: hosted
version: "1.1.2"
version: "1.3.0"
http_multi_server:
dependency: transitive
description:
Expand Down Expand Up @@ -377,14 +377,14 @@ packages:
path: "../../packages/common_client"
relative: true
source: path
version: "1.3.0"
version: "1.4.1"
launchdarkly_dart_common:
dependency: "direct overridden"
description:
path: "../../packages/common"
relative: true
source: path
version: "1.2.0"
version: "1.3.0"
launchdarkly_event_source_client:
dependency: "direct overridden"
description:
Expand All @@ -398,7 +398,7 @@ packages:
path: "../../packages/flutter_client_sdk"
relative: true
source: path
version: "4.7.0"
version: "4.9.0"
lints:
dependency: "direct dev"
description:
Expand Down Expand Up @@ -435,18 +435,18 @@ packages:
dependency: transitive
description:
name: material_color_utilities
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev"
source: hosted
version: "0.8.0"
version: "0.11.1"
meta:
dependency: transitive
description:
name: meta
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
url: "https://pub.dev"
source: hosted
version: "1.12.0"
version: "1.16.0"
mime:
dependency: transitive
description:
Expand Down Expand Up @@ -507,18 +507,18 @@ packages:
dependency: transitive
description:
name: package_info_plus
sha256: "88bc797f44a94814f2213db1c9bd5badebafdfb8290ca9f78d4b9ee2a3db4d79"
sha256: a75164ade98cb7d24cfd0a13c6408927c6b217fa60dee5a7ff5c116a58f28918
url: "https://pub.dev"
source: hosted
version: "5.0.1"
version: "8.0.2"
package_info_plus_platform_interface:
dependency: transitive
description:
name: package_info_plus_platform_interface
sha256: "9bc8ba46813a4cc42c66ab781470711781940780fd8beddd0c3da62506d3a6c6"
sha256: "6c935fb612dff8e3cc9632c2b301720c77450a126114126ffaafe28d2e87956c"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "3.2.0"
path:
dependency: transitive
description:
Expand Down Expand Up @@ -659,10 +659,10 @@ packages:
dependency: transitive
description:
name: shared_preferences_web
sha256: "7b15ffb9387ea3e237bb7a66b8a23d2147663d391cafc5c8f37b2e7b4bde5d21"
sha256: d762709c2bbe80626ecc819143013cc820fa49ca5e363620ee20a8b15a3e3daf
url: "https://pub.dev"
source: hosted
version: "2.2.2"
version: "2.2.1"
shared_preferences_windows:
dependency: transitive
description:
Expand Down Expand Up @@ -707,7 +707,7 @@ packages:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
version: "0.0.0"
source_gen:
dependency: transitive
description:
Expand Down Expand Up @@ -872,10 +872,10 @@ packages:
dependency: transitive
description:
name: web
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a"
url: "https://pub.dev"
source: hosted
version: "0.3.0"
version: "1.1.1"
web_socket_channel:
dependency: transitive
description:
Expand Down Expand Up @@ -933,5 +933,5 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.3.0-0 <4.0.0"
flutter: ">=3.16.0"
dart: ">=3.7.0-0 <4.0.0"
flutter: ">=3.19.0"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import '../../ld_logging.dart';
import 'stub_config.dart'
if (dart.library.io) 'io_config.dart'
if (dart.library.html) 'js_config.dart';
if (dart.library.js_interop) 'js_config.dart';

final class DefaultLoggingConfig {
final defaultLogLevel = LDLogLevel.info;
Expand Down
2 changes: 1 addition & 1 deletion packages/common/lib/src/network/http_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import '../config/defaults/common_default_config.dart';
import '../config/http_properties.dart';
import 'platform_client/stub_client.dart'
if (dart.library.io) 'platform_client/io_client.dart'
if (dart.library.html) 'platform_client/js_client.dart';
if (dart.library.js_interop) 'platform_client/js_client.dart';
import 'utils.dart';

/// Http requests methods supported by the HTTP client.
Expand Down
1 change: 1 addition & 0 deletions packages/common/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dependencies:
http_parser: ^4.0.0
uuid: ">= 3.0.7 <5.0.0"
crypto: ^3.0.3
web: ^1.1.1
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaces dart:html


dev_dependencies:
test: ^1.24.3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'stub_config.dart'
if (dart.library.io) 'io_config.dart'
if (dart.library.html) 'js_config.dart';
if (dart.library.js_interop) 'js_config.dart';

/// Configuration common to web and mobile is contained in this file.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'src/http_consts.dart';
import 'src/message_event.dart';
import 'src/sse_client_stub.dart'
if (dart.library.io) 'src/sse_client_http.dart'
if (dart.library.html) 'src/sse_client_html.dart';
if (dart.library.js_interop) 'src/sse_client_html.dart';

export 'src/message_event.dart' show MessageEvent;

Expand Down
21 changes: 11 additions & 10 deletions packages/event_source_client/lib/src/sse_client_html.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import 'dart:async';
import 'dart:html' as html;
import 'dart:js_interop';
import 'package:web/web.dart' as web;
import 'dart:math' as math;

import '../launchdarkly_event_source_client.dart';

import 'backoff.dart';
import 'message_event.dart' as ld_message_event;

/// An [SSEClient] that uses the [html.EventSource] available on most browsers for web platform support.
/// An [SSEClient] that uses the [web.EventSource] available on most browsers for web platform support.
class HtmlSseClient implements SSEClient {
/// The underlying eventsource
html.EventSource? _eventSource;
web.EventSource? _eventSource;

/// This controller is for the events going to the subscribers of this client.
late final StreamController<ld_message_event.MessageEvent>
Expand Down Expand Up @@ -53,26 +54,26 @@ class HtmlSseClient implements SSEClient {
}

void _setupConnection() {
_eventSource = html.EventSource(_uri.toString());
_eventSource = web.EventSource(_uri.toString());

for (var eventType in _eventTypes) {
_eventSource?.addEventListener(eventType, _handleMessageEvent);
_eventSource?.addEventListener(eventType, _handleMessageEvent.toJS);
}
_eventSource?.addEventListener('error', _handleError);
_eventSource?.addEventListener('error', _handleError.toJS);
}

void _handleError(html.Event event) {
void _handleError(web.Event event) {
// The browser event source errors are reasonably opaque, if we could
// determine the type of condition, then this is where we would
// determine if this was a temporary or permanent failure.
restart();
}

void _handleMessageEvent(html.Event event) {
void _handleMessageEvent(web.Event event) {
_activeSince = DateTime.now().millisecondsSinceEpoch;
final messageEvent = event as html.MessageEvent;
final messageEvent = event as web.MessageEvent;
final ldMessageEvent = ld_message_event.MessageEvent(
messageEvent.type, messageEvent.data, messageEvent.lastEventId);
messageEvent.type, (messageEvent.data as JSString).toDart, messageEvent.lastEventId);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cast should be done safer.

_messageEventsController.sink.add(ldMessageEvent);
}

Expand Down
27 changes: 6 additions & 21 deletions packages/flutter_client_sdk/example/.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,20 @@
# This file should be version controlled and should not be manually edited.

version:
revision: "0f7f08d5354856ea41930f2c178a96ca97518d5a"
channel: "master"
revision: "ea121f8859e4b13e47a8f845e4586164519588bc"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 0f7f08d5354856ea41930f2c178a96ca97518d5a
base_revision: 0f7f08d5354856ea41930f2c178a96ca97518d5a
- platform: android
create_revision: 0f7f08d5354856ea41930f2c178a96ca97518d5a
base_revision: 0f7f08d5354856ea41930f2c178a96ca97518d5a
- platform: ios
create_revision: 0f7f08d5354856ea41930f2c178a96ca97518d5a
base_revision: 0f7f08d5354856ea41930f2c178a96ca97518d5a
- platform: linux
create_revision: 0f7f08d5354856ea41930f2c178a96ca97518d5a
base_revision: 0f7f08d5354856ea41930f2c178a96ca97518d5a
- platform: macos
create_revision: 0f7f08d5354856ea41930f2c178a96ca97518d5a
base_revision: 0f7f08d5354856ea41930f2c178a96ca97518d5a
create_revision: ea121f8859e4b13e47a8f845e4586164519588bc
base_revision: ea121f8859e4b13e47a8f845e4586164519588bc
- platform: web
create_revision: 0f7f08d5354856ea41930f2c178a96ca97518d5a
base_revision: 0f7f08d5354856ea41930f2c178a96ca97518d5a
- platform: windows
create_revision: 0f7f08d5354856ea41930f2c178a96ca97518d5a
base_revision: 0f7f08d5354856ea41930f2c178a96ca97518d5a
create_revision: ea121f8859e4b13e47a8f845e4586164519588bc
base_revision: ea121f8859e4b13e47a8f845e4586164519588bc

# User provided section

Expand Down
25 changes: 2 additions & 23 deletions packages/flutter_client_sdk/example/web/index.html
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was regenerated.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<meta name="description" content="A new Flutter project.">

<!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="example">
<link rel="apple-touch-icon" href="icons/Icon-192.png">
Expand All @@ -31,29 +31,8 @@

<title>example</title>
<link rel="manifest" href="manifest.json">

<script>
// The value below is injected by flutter build, do not touch.
const serviceWorkerVersion = null;
</script>
<!-- This script adds the flutter initialization JS code -->
<script src="flutter.js" defer></script>
</head>
<body>
<script>
window.addEventListener('load', function(ev) {
// Download main.dart.js
_flutter.loader.loadEntrypoint({
serviceWorker: {
serviceWorkerVersion: serviceWorkerVersion,
},
onEntrypointLoaded: function(engineInitializer) {
engineInitializer.initializeEngine().then(function(appRunner) {
appRunner.runApp();
});
}
});
});
</script>
<script src="flutter_bootstrap.js" async></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'stub_config.dart'
if (dart.library.io) 'io_config.dart'
if (dart.library.html) 'js_config.dart';
if (dart.library.js_interop) 'js_config.dart';

/// Configuration common to web and mobile is contained in this file.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:flutter/scheduler.dart';
import 'connection_manager.dart';
import 'lifecycle/stub_lifecycle_listener.dart'
if (dart.library.io) 'lifecycle/io_lifecycle_listener.dart'
if (dart.library.html) 'lifecycle/js_lifecycle_listener.dart';
if (dart.library.js_interop) 'lifecycle/js_lifecycle_listener.dart';

/// This class detects the application and network state for flutter.
final class FlutterStateDetector implements StateDetector {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';
import 'dart:html' as html;
import 'dart:js_interop';
import 'package:web/web.dart' as web;

import 'package:flutter/widgets.dart';

Expand All @@ -11,17 +12,17 @@ class LDAppLifecycleListener {
LDAppLifecycleListener() {
_streamController = StreamController.broadcast();

void listenerFunc(event) =>
_streamController.add(html.document.hidden == true
void listenerFunc(web.Event event) =>
_streamController.add(web.document.hidden == true
? AppLifecycleState.hidden
: AppLifecycleState.resumed);

_streamController.onListen = () {
html.document.addEventListener('visibilitychange', listenerFunc);
// web.document.addEventListener('visibilitychange', listenerFunc.toJS);
};

_streamController.onCancel = () {
html.document.removeEventListener('visibilitychange', listenerFunc);
// web.document.removeEventListener('visibilitychange', listenerFunc.toJS);
};
}

Expand Down
1 change: 1 addition & 0 deletions packages/flutter_client_sdk/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies:
launchdarkly_common_client: 1.4.1
shared_preferences: ^2.2.2
connectivity_plus: ">=5.0.2 <7.0.0"
web: ^1.1.1

dev_dependencies:
flutter_test:
Expand Down
Loading