Skip to content

Simplify web code http requests and use static interop #3613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
@@ -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
@@ -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
8 changes: 5 additions & 3 deletions web/docs.dart
Original file line number Diff line number Diff line change
@@ -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;
@@ -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);
});
}
@@ -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);
});
}
18 changes: 6 additions & 12 deletions web/search.dart
Original file line number Diff line number Diff line change
@@ -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')!;
@@ -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.
@@ -71,6 +63,8 @@ void init() {
if (searchSidebar != null) {
_Search(index).initialize(searchSidebar);
}
}).catchError((_) {
disableSearch();
});
}

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.