Skip to content

Commit

Permalink
Switch http requests in web code to package:http
Browse files Browse the repository at this point in the history
  • Loading branch information
parlough committed Dec 29, 2023
1 parent b9a6d1e commit a845d39
Show file tree
Hide file tree
Showing 8 changed files with 6,449 additions and 3,695 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 8.0.4-wip

* Require Dart 3.2 or later.
* Remove explicit library names. (#3609)

## 8.0.3
Expand Down
10,076 changes: 6,428 additions & 3,648 deletions lib/resources/docs.dart.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions lib/resources/docs.dart.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: A non-interactive HTML documentation generator for Dart source code
repository: https://github.com/dart-lang/dartdoc

environment:
sdk: ^3.0.0
sdk: ^3.2.0

dependencies:
analyzer: ^6.3.0
Expand All @@ -25,7 +25,7 @@ dependencies:
dev_dependencies:
async: ^2.11.0
dart_style: ^2.3.1
http: ">=0.13.6 <2.0.0"
http: ^1.1.2
js: ^0.6.7
lints: ^3.0.0
matcher: ^0.12.15
Expand Down
8 changes: 5 additions & 3 deletions web/docs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// 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:html';
import 'dart:html' hide HttpRequest;

import 'package:http/http.dart' as http show read;

import 'highlight.dart' as highlight;
import 'search.dart' as search;
Expand Down Expand Up @@ -45,7 +47,7 @@ void initializeSidebars() {
if (aboveSidebarPath != null &&
aboveSidebarPath.isNotEmpty &&
leftSidebar != null) {
HttpRequest.getString('$baseHref$aboveSidebarPath').then((content) {
http.read(Uri.parse('$baseHref$aboveSidebarPath')).then((content) {
leftSidebar.setInnerHtml(content, treeSanitizer: sanitizer);
});
}
Expand All @@ -54,7 +56,7 @@ void initializeSidebars() {
if (belowSidebarPath != null &&
belowSidebarPath.isNotEmpty &&
rightSidebar != null) {
HttpRequest.getString('$baseHref$belowSidebarPath').then((content) {
http.read(Uri.parse('$baseHref$belowSidebarPath')).then((content) {
rightSidebar.setInnerHtml(content, treeSanitizer: sanitizer);
});
}
Expand Down
18 changes: 6 additions & 12 deletions web/search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import 'dart:convert';
import 'dart:html';
import 'package:dartdoc/src/search.dart';

import 'web_interop.dart';
import 'package:dartdoc/src/search.dart';
import 'package:http/http.dart' as http show read;

final String _htmlBase = () {
final body = document.querySelector('body')!;
Expand Down Expand Up @@ -35,16 +35,8 @@ void init() {
searchSidebar?.placeholder = 'Failed to initialize search';
}

window.fetch('${_htmlBase}index.json').then((response) async {
response = response as FetchResponse;
var code = response.status;
if (code == 404) {
disableSearch();
return;
}

var text = await response.text;
final index = Index.fromJson(text);
http.read(Uri.parse('${_htmlBase}index.json')).then((response) {
final index = Index.fromJson(response);

// Navigate to the first result from the 'search' query parameter
// if specified and found.
Expand All @@ -71,6 +63,8 @@ void init() {
if (searchSidebar != null) {
_Search(index).initialize(searchSidebar);
}
}).catchError((_) {
disableSearch();
});
}

Expand Down
2 changes: 1 addition & 1 deletion web/sig.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8C67B39F09940FC20D8C13F6BBE0B1EE
51B7F201B78DED71A64BF38FC05AA595
23 changes: 0 additions & 23 deletions web/web_interop.dart

This file was deleted.

0 comments on commit a845d39

Please sign in to comment.