Skip to content

Commit a845d39

Browse files
committed
Switch http requests in web code to package:http
1 parent b9a6d1e commit a845d39

File tree

8 files changed

+6449
-3695
lines changed

8 files changed

+6449
-3695
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 8.0.4-wip
22

3+
* Require Dart 3.2 or later.
34
* Remove explicit library names. (#3609)
45

56
## 8.0.3

lib/resources/docs.dart.js

Lines changed: 6428 additions & 3648 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/resources/docs.dart.js.map

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: A non-interactive HTML documentation generator for Dart source code
44
repository: https://github.com/dart-lang/dartdoc
55

66
environment:
7-
sdk: ^3.0.0
7+
sdk: ^3.2.0
88

99
dependencies:
1010
analyzer: ^6.3.0
@@ -25,7 +25,7 @@ dependencies:
2525
dev_dependencies:
2626
async: ^2.11.0
2727
dart_style: ^2.3.1
28-
http: ">=0.13.6 <2.0.0"
28+
http: ^1.1.2
2929
js: ^0.6.7
3030
lints: ^3.0.0
3131
matcher: ^0.12.15

web/docs.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
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.
44

5-
import 'dart:html';
5+
import 'dart:html' hide HttpRequest;
6+
7+
import 'package:http/http.dart' as http show read;
68

79
import 'highlight.dart' as highlight;
810
import 'search.dart' as search;
@@ -45,7 +47,7 @@ void initializeSidebars() {
4547
if (aboveSidebarPath != null &&
4648
aboveSidebarPath.isNotEmpty &&
4749
leftSidebar != null) {
48-
HttpRequest.getString('$baseHref$aboveSidebarPath').then((content) {
50+
http.read(Uri.parse('$baseHref$aboveSidebarPath')).then((content) {
4951
leftSidebar.setInnerHtml(content, treeSanitizer: sanitizer);
5052
});
5153
}
@@ -54,7 +56,7 @@ void initializeSidebars() {
5456
if (belowSidebarPath != null &&
5557
belowSidebarPath.isNotEmpty &&
5658
rightSidebar != null) {
57-
HttpRequest.getString('$baseHref$belowSidebarPath').then((content) {
59+
http.read(Uri.parse('$baseHref$belowSidebarPath')).then((content) {
5860
rightSidebar.setInnerHtml(content, treeSanitizer: sanitizer);
5961
});
6062
}

web/search.dart

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
import 'dart:convert';
66
import 'dart:html';
7-
import 'package:dartdoc/src/search.dart';
87

9-
import 'web_interop.dart';
8+
import 'package:dartdoc/src/search.dart';
9+
import 'package:http/http.dart' as http show read;
1010

1111
final String _htmlBase = () {
1212
final body = document.querySelector('body')!;
@@ -35,16 +35,8 @@ void init() {
3535
searchSidebar?.placeholder = 'Failed to initialize search';
3636
}
3737

38-
window.fetch('${_htmlBase}index.json').then((response) async {
39-
response = response as FetchResponse;
40-
var code = response.status;
41-
if (code == 404) {
42-
disableSearch();
43-
return;
44-
}
45-
46-
var text = await response.text;
47-
final index = Index.fromJson(text);
38+
http.read(Uri.parse('${_htmlBase}index.json')).then((response) {
39+
final index = Index.fromJson(response);
4840

4941
// Navigate to the first result from the 'search' query parameter
5042
// if specified and found.
@@ -71,6 +63,8 @@ void init() {
7163
if (searchSidebar != null) {
7264
_Search(index).initialize(searchSidebar);
7365
}
66+
}).catchError((_) {
67+
disableSearch();
7468
});
7569
}
7670

web/sig.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8C67B39F09940FC20D8C13F6BBE0B1EE
1+
51B7F201B78DED71A64BF38FC05AA595

web/web_interop.dart

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)