Skip to content

Commit ff2b369

Browse files
authored
Merge pull request #162 from AngleSharp/devel
Release 1.3.0
2 parents 23eb162 + 653b95a commit ff2b369

56 files changed

Lines changed: 7113 additions & 340 deletions

Some content is hidden

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

‎.github/workflows/ci.yml‎

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,8 @@ on: [push, pull_request]
44

55
env:
66
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7-
DOCS_PATH: ${{ secrets.DOCS_PATH }}
8-
DOCS_BRANCH: ${{ secrets.DOCS_BRANCH }}
97

108
jobs:
11-
can_document:
12-
runs-on: ubuntu-latest
13-
outputs:
14-
value: ${{ steps.check_job.outputs.value }}
15-
steps:
16-
- name: Checks whether documentation can be built
17-
id: check_job
18-
run: |
19-
echo "value: ${{ env.DOCS_PATH != null && github.ref == env.DOCS_BRANCH }}"
20-
echo "value=${{ env.DOCS_PATH != null && github.ref == env.DOCS_BRANCH }}" >> "$GITHUB_OUTPUT"
21-
22-
documentation:
23-
needs: [can_document]
24-
runs-on: ubuntu-latest
25-
if: needs.can_document.outputs.value == 'true'
26-
27-
steps:
28-
- uses: actions/checkout@v7
29-
30-
- name: Use Node.js
31-
uses: actions/setup-node@v7
32-
with:
33-
node-version: "20.x"
34-
registry-url: 'https://registry.npmjs.org'
35-
36-
- name: Install Dependencies
37-
run: |
38-
cd $DOCS_PATH
39-
npm install
40-
41-
- name: Deploy Doclet
42-
run: |
43-
cd $DOCS_PATH
44-
npx pilet publish --fresh --url https://feed.piral.cloud/api/v1/pilet/anglesharp --api-key ${{ secrets.PIRAL_FEED_KEY }}
45-
469
linux:
4710
runs-on: ubuntu-latest
4811

@@ -55,7 +18,7 @@ jobs:
5518
10.0.x
5619
5720
- name: Build
58-
run: ./build.sh -AngleSharpVersion 1.10.0
21+
run: ./build.sh -AngleSharpVersion 1.11.0
5922

6023
windows:
6124
runs-on: windows-latest
@@ -85,9 +48,9 @@ jobs:
8548
NUGET_API_KEY: ${{ steps.nuget_login.outputs.NUGET_API_KEY }}
8649
run: |
8750
if ($env:GITHUB_REF -eq "refs/heads/main") {
88-
.\build.ps1 -Target Publish -AngleSharpVersion 1.10.0
51+
.\build.ps1 -Target Publish -AngleSharpVersion 1.11.0
8952
} elseif ($env:GITHUB_REF -eq "refs/heads/devel") {
90-
.\build.ps1 -Target PrePublish -AngleSharpVersion 1.10.0
53+
.\build.ps1 -Target PrePublish -AngleSharpVersion 1.11.0
9154
} else {
92-
.\build.ps1 -AngleSharpVersion 1.10.0
55+
.\build.ps1 -AngleSharpVersion 1.11.0
9356
}

‎CHANGELOG.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
# 1.3.0
2+
3+
Released on Tuesday, November 24 2026.
4+
5+
- Fixed a module with a top-level `await` blocking the page for many seconds
6+
- Fixed import map entries of a prefix not being used
7+
- Fixed an `import()` of a module that could not be fetched not rejecting with a `TypeError`
8+
- Fixed the DOM of libraries registered by a creator only being missing
9+
- Fixed an object getting the prototype of an unrelated class of another library
10+
- Updated a WebIDL namespace to be a plain object, whose members are no longer members of the window too
11+
- Updated minimum version of AngleSharp to 1.11.0
12+
- Added `WithJs(DomRegistration)` to register the DOM of libraries declared for a scripting engine (#152)
13+
- Added `SharedWorker`, which the scripts of an origin creating it for the same address
14+
- Added CSS module scripts (`import sheet from './a.css' with { type: 'css' }`), whose default export is a constructed style sheet
15+
- Added `import.meta.resolve()`
16+
- Added interfaces of a namespace (`[DomExposed("WebAssembly")]` puts `WebAssembly.Module` there instead of on the window)
17+
- Added delegates of the DOM as functions of scripts
18+
- Added `BigInteger` as BigInt, `Memory<Byte>` as an ArrayBuffer
19+
- Added exceptions of the DOM (e.g. `WebAssembly.RuntimeError`) being errors of their class
20+
- Added the Web Cryptography API (`crypto.subtle`, also in workers; not on .NET Framework)
21+
122
# 1.2.3
223

324
Released on Sunday, November 22 2026.

‎docs/README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
We have more detailed information regarding the following subjects:
44

55
- [Getting Started](general/01-Basics.md)
6+
- [API Documentation](tutorials/01-API.md)
7+
- [Examples](tutorials/02-Examples.md)
8+
- [Frequently Asked Questions](tutorials/03-Questions.md)

‎docs/general/01-Basics.md‎

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ section: "AngleSharp.Js"
44
---
55
# Getting Started
66

7-
AngleSharp.Js runs JavaScript against an AngleSharp document. It integrates the
8-
[Jint](https://github.com/sebastienros/jint) interpreter with AngleSharp, so scripts can
9-
read and change the same DOM that your .NET code uses. This is useful when processing pages
10-
whose behavior depends on script execution, evaluating a snippet in a document context, or
11-
hosting JavaScript APIs alongside your application.
7+
AngleSharp.Js runs JavaScript against an AngleSharp document. It integrates the [Jint](https://github.com/sebastienros/jint) interpreter with AngleSharp, so scripts can read and change the same DOM that your .NET code uses. This is useful when processing pages whose behavior depends on script execution, evaluating a snippet in a document context, or hosting JavaScript APIs alongside your application.
128

139
## Install and configure
1410

@@ -18,13 +14,9 @@ Install the package:
1814
Install-Package AngleSharp.Js
1915
```
2016

21-
Add `WithJs()` to the AngleSharp configuration. Add `WithEventLoop()` when scripts, events,
22-
or resource callbacks must run in the browser-like task queue. Add a loader when the document
23-
needs to fetch external scripts or other resources.
17+
Add `WithJs()` to the AngleSharp configuration. Add `WithEventLoop()` when scripts, events, or resource callbacks must run in the browser-like task queue. Add a loader when the document needs to fetch external scripts or other resources.
2418

25-
For many real-world scripts, `WithJs()` alone is not enough. AngleSharp.Js exposes interfaces
26-
from the AngleSharp services present in the browsing context, so you usually want to include
27-
AngleSharp.Io and AngleSharp.Css to provide most of the required API surface.
19+
For many real-world scripts, `WithJs()` alone is not enough. AngleSharp.Js exposes interfaces from the AngleSharp services present in the browsing context, so you usually want to include AngleSharp.Io and AngleSharp.Css to provide most of the required API surface.
2820

2921
```cs
3022
var configuration = Configuration.Default
@@ -42,12 +34,9 @@ var document = await context.OpenAsync("https://example.com");
4234
await document.WaitUntilAvailable();
4335
```
4436

45-
Some highly specialized scripts may also depend on additional AngleSharp packages. For example,
46-
in niche scenarios, libraries such as AngleSharp.Wasm can be relevant.
37+
Some highly specialized scripts may also depend on additional AngleSharp packages. For example, in niche scenarios, libraries such as AngleSharp.Wasm can be relevant.
4738

48-
`WithJs()` registers the JavaScript scripting service, support for inline event attributes
49-
such as `onclick`, a navigation handler for `javascript:` URLs, and a default `navigator`
50-
when the configuration does not already provide one.
39+
`WithJs()` registers the JavaScript scripting service, support for inline event attributes such as `onclick`, a navigation handler for `javascript:` URLs, structured cloning (for `postMessage` and workers) and the host for custom elements. It does not register a loader, an event loop or a navigator; `WithNavigator()` from AngleSharp.Io provides a full `navigator`.
5140

5241
### Customize the event loop
5342

@@ -93,11 +82,21 @@ var configuration = Configuration.Default
9382
});
9483
```
9584

85+
### Configure the Jint engine
86+
87+
Register an `EngineCreator` to construct the Jint engine yourself, for example to limit the statements, time or memory a script may use. The delegate runs once per window and must build the engine from the supplied options:
88+
89+
```cs
90+
var configuration = Configuration.Default
91+
.With(new EngineCreator((window, options) => new Jint.Engine(options
92+
.MaxStatements(1_000_000)
93+
.TimeoutInterval(TimeSpan.FromSeconds(5)))))
94+
.WithJs();
95+
```
96+
9697
## Execute JavaScript
9798

98-
HTML `<script>` elements execute while AngleSharp processes the document. For a script you
99-
want to run yourself, call `ExecuteScript` on the document. The return value is converted to
100-
the corresponding .NET value where possible.
99+
HTML `<script>` elements execute while AngleSharp processes the document. For a script you want to run yourself, call `ExecuteScript` on the document. The return value is converted to the corresponding .NET value where possible: numbers become `Double`, DOM objects the AngleSharp objects, `undefined` the string `"undefined"`, and other objects stay Jint values.
101100

102101
```cs
103102
var document = await BrowsingContext.New(Configuration.Default.WithJs())
@@ -199,7 +198,9 @@ example, adding CSS support also makes its AngleSharp DOM types available to scr
199198

200199
In addition to the DOM provided by AngleSharp, the package supplies:
201200

202-
- `console.log`, `atob`, `btoa`, `DOMParser`, `Image`, `screen`, and `XMLHttpRequest`.
201+
- `console`, `atob`, `btoa`, `structuredClone`, `queueMicrotask`, `DOMParser`, `Image`, `Audio`, and `screen`.
202+
- `requestAnimationFrame`, `requestIdleCallback`, `performance`, `crypto`, `TextEncoder`, and `TextDecoder`.
203+
- `Worker`, `SharedWorker`, `MessageChannel`, and `window.postMessage`.
203204
- `javascript:` URL navigation.
204205
- Inline event-handler attributes and DOM event callbacks.
205206
- ES modules and import maps through Jint's module loader.
@@ -214,13 +215,13 @@ they meet a script's needs:
214215
| `DOMParser` | `parseFromString` creates a document through the configured `IDocumentFactory`. The requested MIME type must be supported by that configuration. |
215216
| `Image` | Creates an AngleSharp `<img>` element; optional width and height become its display dimensions. |
216217
| `window.postMessage` | Queues a `message` event on the current window. It requires an event loop; it does not transfer objects, deliver to another browsing context, or enforce `targetOrigin`. |
217-
| `XMLHttpRequest` | Supports `open`, `send`, request headers, status, text responses, and lifecycle events through the configured document loader. |
218-
| `console` | Supports `console.log` only. |
218+
| `console` | All methods are available; their arguments (or, for `count`/`time*`, the formatted result) are passed to the `IConsoleLogger`. The severity is not distinguished. |
219219
| `screen` | Exposes fixed 1920-by-1080 dimensions and 24-bit color depth for compatibility. |
220220

221-
To replace the supplied behavior, register your own compatible AngleSharp service before
222-
calling `WithJs()`. In particular, `WithJs()` preserves an existing `INavigator`, and the
223-
`WithEventLoop` overloads accept either an existing `IEventLoop` or a factory for one.
221+
APIs such as `fetch`, `XMLHttpRequest`, `WebSocket` and `localStorage` come from AngleSharp.Io, and `getComputedStyle` or `matchMedia` from AngleSharp.Css. They appear once the respective
222+
services are registered (e.g. `WithRequesters()` or `WithCss()`).
223+
224+
The `WithEventLoop` overloads accept either an existing `IEventLoop` or a factory for one.
224225

225226
## Supported behavior and limitations
226227

@@ -231,15 +232,13 @@ complete browser parity.
231232

232233
Notable limitations include:
233234

234-
- The package does not calculate layout. Its `scroll*`, `client*`, and `offset*` element
235-
properties return `0`.
236-
- The default `navigator` is intentionally minimal. Its platform is empty, registration
237-
methods are no-ops, and its user-agent value is a fixed compatibility string.
238-
- Network-backed features such as external scripts and `XMLHttpRequest` require suitable
239-
AngleSharp requesters and resource loading configuration.
240-
- `XMLHttpRequest` currently provides text responses only. Its `response`, `responseXML`, and
241-
`upload` properties are unavailable, `responseType` always has its empty value, and its
242-
`timeout` and `withCredentials` settings do not affect requests.
243-
- The JavaScript engine executes application-provided or page-provided code in your process.
244-
Treat untrusted scripts as untrusted code and apply the constraints appropriate to your
245-
application.
235+
- The package does not calculate layout. Its `scroll*`, `client*`, and `offset*` element properties return `0`.
236+
- Without AngleSharp.Io's `WithNavigator()`, `navigator` is minimal (e.g. an empty `userAgent`).
237+
- Network-backed features such as external scripts, modules, workers, `fetch` and `XMLHttpRequest` require suitable AngleSharp requesters and resource loading configuration.
238+
- The JavaScript engine executes application-provided or page-provided code in your process. Treat untrusted scripts as untrusted code and apply the constraints appropriate to your application.
239+
240+
## Where to go next
241+
242+
- [API Documentation](../tutorials/01-API.md) lists every public type and how .NET types map to JavaScript.
243+
- [Examples](../tutorials/02-Examples.md) has ready-to-use recipes.
244+
- [Frequently Asked Questions](../tutorials/03-Questions.md) covers common pitfalls.

0 commit comments

Comments
 (0)