diff --git a/pkgs/intl/CHANGELOG.md b/pkgs/intl/CHANGELOG.md index 42c765e5..95411a3d 100644 --- a/pkgs/intl/CHANGELOG.md +++ b/pkgs/intl/CHANGELOG.md @@ -1,5 +1,6 @@ -## 0.20.2-wip +## 0.20.2 * Remove the dependency on `package:http`. + * Remove the dependency on `package:web`. ## 0.20.1 * Upgrade `package:web` dependency constraint to `1.1.0`, fixes issue diff --git a/pkgs/intl/lib/intl_browser.dart b/pkgs/intl/lib/intl_browser.dart index 9d50a52e..d2dd13d4 100644 --- a/pkgs/intl/lib/intl_browser.dart +++ b/pkgs/intl/lib/intl_browser.dart @@ -4,21 +4,22 @@ /// This provides facilities for Internationalization that are only available /// when running in the web browser. You should import only one of this or -/// intl_standalone.dart. Right now the only thing provided here is the -/// ability to find the default locale from the browser. +/// intl_standalone.dart. Right now the only thing provided here is the ability +/// to find the default locale from the browser. library; -import 'package:web/web.dart'; import 'intl.dart'; +import 'src/web.dart'; -// TODO(alanknight): The need to do this by forcing the user to specially -// import a particular library is a horrible hack, only done because there -// seems to be no graceful way to do this at all. Either mirror access on -// dart2js or the ability to do spawnUri in the browser would be promising -// as ways to get rid of this requirement. -/// Find the system locale, accessed as window.navigator.language, and -/// set it as the default for internationalization operations in the -/// [Intl.systemLocale] variable. +// TODO(alanknight): The need to do this by forcing the user to specially import +// a particular library is a horrible hack, only done because there seems to be +// no graceful way to do this at all. Either mirror access on dart2js or the +// ability to do spawnUri in the browser would be promising as ways to get rid +// of this requirement. + +/// Find the system locale, accessed as window.navigator.language, and set it as +/// the default for internationalization operations in the [Intl.systemLocale] +/// variable. Future findSystemLocale() { Intl.systemLocale = Intl.canonicalizedLocale(window.navigator.language); return Future.value(Intl.systemLocale); diff --git a/pkgs/intl/lib/intl_standalone.dart b/pkgs/intl/lib/intl_standalone.dart index 9e7ceaa8..605061f9 100644 --- a/pkgs/intl/lib/intl_standalone.dart +++ b/pkgs/intl/lib/intl_standalone.dart @@ -9,6 +9,7 @@ library; import 'dart:io'; + import 'intl.dart'; // TODO(alanknight): The need to do this by forcing the user to specially diff --git a/pkgs/intl/lib/message_format.dart b/pkgs/intl/lib/message_format.dart index 44df52c1..0cd845c2 100644 --- a/pkgs/intl/lib/message_format.dart +++ b/pkgs/intl/lib/message_format.dart @@ -10,6 +10,7 @@ library; import 'dart:collection'; + import 'intl.dart'; /// **MessageFormat grammar:** diff --git a/pkgs/intl/lib/src/file_data_reader.dart b/pkgs/intl/lib/src/file_data_reader.dart index c055b6e3..c8c4be5a 100644 --- a/pkgs/intl/lib/src/file_data_reader.dart +++ b/pkgs/intl/lib/src/file_data_reader.dart @@ -9,6 +9,7 @@ library; import 'dart:io'; import 'package:path/path.dart'; + import 'intl_helpers.dart'; class FileDataReader implements LocaleDataReader { diff --git a/pkgs/intl/lib/src/http_request_data_reader.dart b/pkgs/intl/lib/src/http_request_data_reader.dart index 499233f5..ca738433 100644 --- a/pkgs/intl/lib/src/http_request_data_reader.dart +++ b/pkgs/intl/lib/src/http_request_data_reader.dart @@ -9,9 +9,8 @@ library; import 'dart:async'; import 'dart:js_interop'; -import 'package:web/web.dart'; - import 'intl_helpers.dart'; +import 'web.dart'; class HttpRequestDataReader implements LocaleDataReader { /// The base url from which we read the data. diff --git a/pkgs/intl/lib/src/intl/number_format_parser.dart b/pkgs/intl/lib/src/intl/number_format_parser.dart index e867640d..fb60a7f5 100644 --- a/pkgs/intl/lib/src/intl/number_format_parser.dart +++ b/pkgs/intl/lib/src/intl/number_format_parser.dart @@ -1,6 +1,7 @@ // Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. + import 'dart:math'; import 'package:intl/number_symbols.dart'; diff --git a/pkgs/intl/lib/src/lazy_locale_data.dart b/pkgs/intl/lib/src/lazy_locale_data.dart index 81186679..58852c1d 100644 --- a/pkgs/intl/lib/src/lazy_locale_data.dart +++ b/pkgs/intl/lib/src/lazy_locale_data.dart @@ -8,6 +8,7 @@ library; import 'dart:convert'; + import 'intl_helpers.dart'; /// This implements the very basic map-type operations which are used diff --git a/pkgs/intl/lib/src/web.dart b/pkgs/intl/lib/src/web.dart new file mode 100644 index 00000000..365804c9 --- /dev/null +++ b/pkgs/intl/lib/src/web.dart @@ -0,0 +1,30 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Note: the contents of this file have been inlined from package:web/web.dart. +// We may periodically want to re-sync this, and / or look there when necessary +// to expose additional API. + +import 'dart:js_interop'; + +@JS() +external Window get window; + +extension type Window._(JSObject _) implements JSObject { + external Navigator get navigator; + + external JSPromise fetch( + JSAny /*RequestInfo*/ input, [ + JSObject /*RequestInit*/ init, + ]); +} + +extension type Navigator._(JSObject _) implements JSObject { + external String get language; +} + +extension type Response._(JSObject _) implements JSObject { + external int get status; + external JSPromise text(); +} diff --git a/pkgs/intl/pubspec.yaml b/pkgs/intl/pubspec.yaml index d0233b8d..2e2538c1 100644 --- a/pkgs/intl/pubspec.yaml +++ b/pkgs/intl/pubspec.yaml @@ -1,5 +1,5 @@ name: intl -version: 0.20.2-wip +version: 0.20.2 description: >- Contains code to deal with internationalized/localized messages, date and number formatting and parsing, bi-directional text, and other @@ -18,7 +18,6 @@ dependencies: clock: ^1.1.0 meta: ^1.3.0 path: ^1.8.0 - web: ^1.1.0 dev_dependencies: benchmark_harness: ^2.2.0