Skip to content

Commit 83e8d08

Browse files
authored
remove the dependency on package:web (#931)
* remote package:http from package:intl * remove the dependency on package:web
1 parent dc71245 commit 83e8d08

10 files changed

+51
-16
lines changed

pkgs/intl/CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## 0.20.2-wip
1+
## 0.20.2
22
* Remove the dependency on `package:http`.
3+
* Remove the dependency on `package:web`.
34

45
## 0.20.1
56
* Upgrade `package:web` dependency constraint to `1.1.0`, fixes issue

pkgs/intl/lib/intl_browser.dart

+12-11
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@
44

55
/// This provides facilities for Internationalization that are only available
66
/// when running in the web browser. You should import only one of this or
7-
/// intl_standalone.dart. Right now the only thing provided here is the
8-
/// ability to find the default locale from the browser.
7+
/// intl_standalone.dart. Right now the only thing provided here is the ability
8+
/// to find the default locale from the browser.
99
library;
1010

11-
import 'package:web/web.dart';
1211
import 'intl.dart';
12+
import 'src/web.dart';
1313

14-
// TODO(alanknight): The need to do this by forcing the user to specially
15-
// import a particular library is a horrible hack, only done because there
16-
// seems to be no graceful way to do this at all. Either mirror access on
17-
// dart2js or the ability to do spawnUri in the browser would be promising
18-
// as ways to get rid of this requirement.
19-
/// Find the system locale, accessed as window.navigator.language, and
20-
/// set it as the default for internationalization operations in the
21-
/// [Intl.systemLocale] variable.
14+
// TODO(alanknight): The need to do this by forcing the user to specially import
15+
// a particular library is a horrible hack, only done because there seems to be
16+
// no graceful way to do this at all. Either mirror access on dart2js or the
17+
// ability to do spawnUri in the browser would be promising as ways to get rid
18+
// of this requirement.
19+
20+
/// Find the system locale, accessed as window.navigator.language, and set it as
21+
/// the default for internationalization operations in the [Intl.systemLocale]
22+
/// variable.
2223
Future<String> findSystemLocale() {
2324
Intl.systemLocale = Intl.canonicalizedLocale(window.navigator.language);
2425
return Future.value(Intl.systemLocale);

pkgs/intl/lib/intl_standalone.dart

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
library;
1010

1111
import 'dart:io';
12+
1213
import 'intl.dart';
1314

1415
// TODO(alanknight): The need to do this by forcing the user to specially

pkgs/intl/lib/message_format.dart

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
library;
1111

1212
import 'dart:collection';
13+
1314
import 'intl.dart';
1415

1516
/// **MessageFormat grammar:**

pkgs/intl/lib/src/file_data_reader.dart

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ library;
99
import 'dart:io';
1010

1111
import 'package:path/path.dart';
12+
1213
import 'intl_helpers.dart';
1314

1415
class FileDataReader implements LocaleDataReader {

pkgs/intl/lib/src/http_request_data_reader.dart

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ library;
99
import 'dart:async';
1010
import 'dart:js_interop';
1111

12-
import 'package:web/web.dart';
13-
1412
import 'intl_helpers.dart';
13+
import 'web.dart';
1514

1615
class HttpRequestDataReader implements LocaleDataReader {
1716
/// The base url from which we read the data.

pkgs/intl/lib/src/intl/number_format_parser.dart

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
4+
45
import 'dart:math';
56

67
import 'package:intl/number_symbols.dart';

pkgs/intl/lib/src/lazy_locale_data.dart

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
library;
99

1010
import 'dart:convert';
11+
1112
import 'intl_helpers.dart';
1213

1314
/// This implements the very basic map-type operations which are used

pkgs/intl/lib/src/web.dart

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// Note: the contents of this file have been inlined from package:web/web.dart.
6+
// We may periodically want to re-sync this, and / or look there when necessary
7+
// to expose additional API.
8+
9+
import 'dart:js_interop';
10+
11+
@JS()
12+
external Window get window;
13+
14+
extension type Window._(JSObject _) implements JSObject {
15+
external Navigator get navigator;
16+
17+
external JSPromise<Response> fetch(
18+
JSAny /*RequestInfo*/ input, [
19+
JSObject /*RequestInit*/ init,
20+
]);
21+
}
22+
23+
extension type Navigator._(JSObject _) implements JSObject {
24+
external String get language;
25+
}
26+
27+
extension type Response._(JSObject _) implements JSObject {
28+
external int get status;
29+
external JSPromise<JSString> text();
30+
}

pkgs/intl/pubspec.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: intl
2-
version: 0.20.2-wip
2+
version: 0.20.2
33
description: >-
44
Contains code to deal with internationalized/localized messages, date and
55
number formatting and parsing, bi-directional text, and other
@@ -18,7 +18,6 @@ dependencies:
1818
clock: ^1.1.0
1919
meta: ^1.3.0
2020
path: ^1.8.0
21-
web: ^1.1.0
2221

2322
dev_dependencies:
2423
benchmark_harness: ^2.2.0

0 commit comments

Comments
 (0)