Skip to content

Commit f26a3d2

Browse files
committed
Simplify web code http requests
1 parent b9a6d1e commit f26a3d2

File tree

8 files changed

+6423
-3684
lines changed

8 files changed

+6423
-3684
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: 6401 additions & 3639 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: 7 additions & 5 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 get;
68

79
import 'highlight.dart' as highlight;
810
import 'search.dart' as search;
@@ -45,17 +47,17 @@ void initializeSidebars() {
4547
if (aboveSidebarPath != null &&
4648
aboveSidebarPath.isNotEmpty &&
4749
leftSidebar != null) {
48-
HttpRequest.getString('$baseHref$aboveSidebarPath').then((content) {
49-
leftSidebar.setInnerHtml(content, treeSanitizer: sanitizer);
50+
http.get(Uri.parse('$baseHref$aboveSidebarPath')).then((content) {
51+
leftSidebar.setInnerHtml(content.body, treeSanitizer: sanitizer);
5052
});
5153
}
5254
final belowSidebarPath = mainContent.dataset['below-sidebar'];
5355
final rightSidebar = document.querySelector('#dartdoc-sidebar-right');
5456
if (belowSidebarPath != null &&
5557
belowSidebarPath.isNotEmpty &&
5658
rightSidebar != null) {
57-
HttpRequest.getString('$baseHref$belowSidebarPath').then((content) {
58-
rightSidebar.setInnerHtml(content, treeSanitizer: sanitizer);
59+
http.get(Uri.parse('$baseHref$belowSidebarPath')).then((content) {
60+
rightSidebar.setInnerHtml(content.body, treeSanitizer: sanitizer);
5961
});
6062
}
6163
}

web/search.dart

Lines changed: 5 additions & 8 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 get;
1010

1111
final String _htmlBase = () {
1212
final body = document.querySelector('body')!;
@@ -35,16 +35,13 @@ 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) {
38+
http.get(Uri.parse('${_htmlBase}index.json')).then((response) {
39+
if (response.statusCode == 404) {
4240
disableSearch();
4341
return;
4442
}
4543

46-
var text = await response.text;
47-
final index = Index.fromJson(text);
44+
final index = Index.fromJson(response.body);
4845

4946
// Navigate to the first result from the 'search' query parameter
5047
// if specified and found.

web/sig.txt

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

web/web_interop.dart

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

0 commit comments

Comments
 (0)