Skip to content

Commit 9542f14

Browse files
committed
Improves CI and documentation
1 parent 2995b6a commit 9542f14

48 files changed

Lines changed: 533 additions & 379 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/FUNDING.yml

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

.github/workflows/dart.yml

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,70 @@
11
name: Dart CI
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
env:
10+
PANA_SCORE_MAX_DIFFERENCE: 20
411

512
jobs:
13+
format:
14+
name: Verify code formatting
15+
runs-on: ubuntu-slim
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: dart-lang/setup-dart@v1
19+
- name: Install dependencies
20+
run: dart --version && dart pub get
21+
- name: Verify formatting
22+
run: dart format --set-exit-if-changed .
23+
lints:
24+
name: Analyze source code
25+
needs: [format]
26+
runs-on: ubuntu-slim
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
sdk: [3.6, stable, beta, dev]
31+
steps:
32+
- uses: actions/checkout@v3
33+
- uses: dart-lang/setup-dart@v1
34+
with:
35+
sdk: ${{ matrix.sdk }}
36+
- name: Install dependencies
37+
run: dart --version && dart pub get
38+
- name: Analyze project source
39+
run: dart analyze
40+
package_health:
41+
name: Analyze package health
42+
needs: [lints]
43+
runs-on: ubuntu-slim
44+
steps:
45+
- uses: actions/checkout@v3
46+
- uses: dart-lang/setup-dart@v1
47+
- name: Install dependencies
48+
run: dart --version && dart pub get && dart pub global activate pana
49+
- name: Run package analyzer
50+
run: dart pub global run pana --exit-code-threshold $PANA_SCORE_MAX_DIFFERENCE
651
test:
7-
runs-on: ${{ matrix.os }}
52+
name: Run tests
53+
needs: [lints]
54+
runs-on: ubuntu-latest
855
strategy:
56+
fail-fast: false
957
matrix:
10-
os: [ubuntu-latest]
11-
sdk: [3.0, stable, beta, dev]
58+
sdk: [stable, beta, dev]
1259
steps:
1360
- uses: actions/checkout@v3
1461
- uses: dart-lang/setup-dart@v1
1562
with:
1663
sdk: ${{ matrix.sdk }}
64+
- uses: browser-actions/setup-chrome@v2
1765
- name: Install dependencies
18-
run: dart pub get
19-
- name: Run tests
20-
run: dart test --platform vm
66+
run: dart --version && dart pub get
67+
- name: Run tests (VM)
68+
run: dart test --platform vm
69+
- name: Run tests (Chrome, JS)
70+
run: dart test --platform chrome --compiler dart2js

.github/workflows/publish.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Publish to pub.dev
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+'
7+
8+
jobs:
9+
publish:
10+
permissions:
11+
id-token: write
12+
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1
13+
with:
14+
environment: pub.dev

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
## 2.2.7
2+
* Improves documentation and tests.
3+
14
## 2.2.6
2-
* Removes an unnecesary dependency.
5+
* Removes an unnecessary dependency.
36

47
## 2.2.5
58
* Updates the library for new Dart SDK and fixes most analyzer warnings.

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
[![Github Actions CI](https://github.com/dint-dev/universal_html/workflows/Dart%20CI/badge.svg)](https://github.com/dint-dev/universal_html/actions)
44

55
# Introduction
6-
A cross-platform `dart:html`:
6+
A cross-platform replacement for `dart:html` (or `package:web`):
77
* __Eases cross-platform development__
88
* You can use this package in browsers, mobile, desktop, and server-side VM, and Node.JS.
9-
* Just replace `dart:html` imports with `package:universal_html/html.dart`. Normal
9+
* Just replace `dart:html` / `package:web` imports with `package:universal_html/html.dart`. Normal
1010
_dart:html_ will continue to be used when application run in browsers.
1111
* __Extensive support for processing HTML and XML documents__
12-
* Parse, manipulate, and print [DOM nodes](https://api.dart.dev/stable/2.19.3/dart-html/Node-class.html).
12+
* Parse, manipulate, and print [DOM nodes](https://api.flutter.dev/flutter/dart-html/Node-class.html).
1313
* Find DOM nodes with [querySelectorAll](https://api.dart.dev/stable/2.19.3/dart-html/querySelectorAll.html)
1414
and other CSS query methods.
1515
* __EventSource streaming support__
@@ -35,12 +35,12 @@ which is documented in the relevant files.
3535
In `pubspec.yaml`:
3636
```yaml
3737
dependencies:
38-
universal_html: ^2.2.5
38+
universal_html: ^2.2.7
3939
```
4040
4141
## 2. Use
4242
```dart
43-
import "package:universal_html/html.dart";
43+
import "package:universal_html/universal_html.dart";
4444

4545
void main() {
4646
// Create a DOM tree

lib/html.dart

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
/// Cross-platform "dart:html" library.
16-
///
17-
/// You can choose from the following libraries:
18-
/// * `package:universal_html/html.dart`
19-
/// * `package:universal_html/prefer_sdk/html.dart`
20-
/// * `package:universal_html/prefer_universal/html.dart`
21-
///
22-
/// # Introduction
23-
///
24-
/// HTML elements and other resources for web-based applications that need to
25-
/// interact with the browser and the DOM (Document Object Model).
26-
///
27-
/// This library includes DOM element types, CSS styling, local storage,
28-
/// media, speech, events, and more.
29-
/// To get started,
30-
/// check out the [Element] class, the base class for many of the HTML
31-
/// DOM types.
32-
///
33-
/// For information on writing web apps with Dart, see https://webdev.dartlang.org.
15+
/// @nodoc
16+
@Deprecated('Replace with "package:universal_html/universal_html.dart.')
3417
library;
3518

36-
export 'src/_sdk/html.dart'
37-
if (dart.library.html) 'src/_sdk/html.dart' // Browser
38-
if (dart.library.io) 'src/html.dart' // VM
39-
if (dart.library.js) 'src/html.dart'; // Node.JS
19+
export 'universal_html.dart';

lib/src/_sdk_html_additions.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ abstract class EventSourceOutsideBrowser implements EventSource {
5252
FutureOr<void> Function(
5353
EventSourceOutsideBrowser eventSource,
5454
HttpClientRequest request,
55-
)?
56-
onHttpClientRequest;
55+
)? onHttpClientRequest;
5756

5857
/// A callback called when a [HttpClientResponse] arrives (only outside
5958
/// browsers).
@@ -63,8 +62,7 @@ abstract class EventSourceOutsideBrowser implements EventSource {
6362
EventSourceOutsideBrowser eventSource,
6463
HttpClientRequest request,
6564
HttpClientResponse response,
66-
)?
67-
onHttpClientResponse;
65+
)? onHttpClientResponse;
6866

6967
/// Current timeout.
7068
Duration retryDuration = Duration(seconds: 3);

lib/src/controller/internal_element_data.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
import 'package:universal_html/html.dart';
1616

1717
import 'internal_element_data_impl_others.dart'
18-
if (dart.library.html) 'internal_element_data_impl_browser.dart'
19-
as impl;
18+
if (dart.library.html) 'internal_element_data_impl_browser.dart' as impl;
2019

2120
/// Internal data of [Element].
2221
///

lib/src/controller/window_behavior.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ import 'package:universal_html/html.dart';
1919
import 'window_behavior_impl_browser.dart'
2020
if (dart.library.html) 'window_behavior_impl_browser.dart' // Browser
2121
if (dart.library.io) 'window_behavior_impl_others.dart' // VM
22-
if (dart.library.js) 'window_behavior_impl_others.dart'
23-
as impl; // Node.JS
22+
if (dart.library.js) 'window_behavior_impl_others.dart' as impl; // Node.JS
2423

2524
/// Defines behavior of the browser APIs (such as navigation events).
2625
///

lib/src/controller/window_behavior_impl_browser.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ Document newDocument({
2727

2828
HtmlDocument newHtmlDocument({required Window window, String? contentType}) {
2929
return DomParser().parseFromString(
30-
'<html></html>',
31-
contentType ?? 'text/html',
32-
)
33-
as HtmlDocument;
30+
'<html></html>',
31+
contentType ?? 'text/html',
32+
) as HtmlDocument;
3433
}
3534

3635
Navigator newNavigator({required Window window}) {

0 commit comments

Comments
 (0)