Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9d4dcca
Add DOM registration as an alternative to reflection
FlorianRappl Nov 16, 2026
db2224a
Added shared workers
FlorianRappl Nov 22, 2026
bb36958
Merge branch 'devel' into feature/aot-dom-registration
FlorianRappl Nov 22, 2026
5b9e800
Initial plan
FlorianRappl Nov 22, 2026
8112a52
Fix shared worker key compatibility with net462
FlorianRappl Nov 22, 2026
b451519
Merge pull request #161 from AngleSharp/copilot/fix-windows-github-ac…
FlorianRappl Nov 22, 2026
1cf7713
Improved web crypto
FlorianRappl Nov 22, 2026
7be766f
Conformance fixes and enhancements
FlorianRappl Nov 23, 2026
a29a0c9
Fixes for .NET 4.6.2
FlorianRappl Nov 23, 2026
69fb879
Support for .NET 4.6.2
FlorianRappl Nov 23, 2026
8a6f00b
Adjusted for .NET 4.6.2
FlorianRappl Nov 23, 2026
bf9edd0
Adjusted notation
FlorianRappl Nov 23, 2026
004d5f1
Adjusted message for .NET 4.6.2
FlorianRappl Nov 23, 2026
57f1bd8
Fixed unrelated type resolution
FlorianRappl Nov 23, 2026
ebacd45
Improved docs
FlorianRappl Nov 23, 2026
dfd5fb3
Updated release date
FlorianRappl Nov 23, 2026
434b95c
Merged
FlorianRappl Nov 23, 2026
5df055d
Included improvements for shared workers
FlorianRappl Nov 23, 2026
239da41
Removed docs
FlorianRappl Nov 24, 2026
8bc3c10
Updated for AoT registrations
FlorianRappl Nov 24, 2026
dec0eb5
Initial plan
FlorianRappl Nov 24, 2026
6d3d502
Serialize worker startup error callbacks
FlorianRappl Nov 24, 2026
653b95a
Merge pull request #163 from AngleSharp/copilot/fix-windows-github-ac…
FlorianRappl Nov 24, 2026
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
45 changes: 4 additions & 41 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,8 @@ on: [push, pull_request]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCS_PATH: ${{ secrets.DOCS_PATH }}
DOCS_BRANCH: ${{ secrets.DOCS_BRANCH }}

jobs:
can_document:
runs-on: ubuntu-latest
outputs:
value: ${{ steps.check_job.outputs.value }}
steps:
- name: Checks whether documentation can be built
id: check_job
run: |
echo "value: ${{ env.DOCS_PATH != null && github.ref == env.DOCS_BRANCH }}"
echo "value=${{ env.DOCS_PATH != null && github.ref == env.DOCS_BRANCH }}" >> "$GITHUB_OUTPUT"

documentation:
needs: [can_document]
runs-on: ubuntu-latest
if: needs.can_document.outputs.value == 'true'

steps:
- uses: actions/checkout@v7

- name: Use Node.js
uses: actions/setup-node@v7
with:
node-version: "20.x"
registry-url: 'https://registry.npmjs.org'

- name: Install Dependencies
run: |
cd $DOCS_PATH
npm install

- name: Deploy Doclet
run: |
cd $DOCS_PATH
npx pilet publish --fresh --url https://feed.piral.cloud/api/v1/pilet/anglesharp --api-key ${{ secrets.PIRAL_FEED_KEY }}

linux:
runs-on: ubuntu-latest

Expand All @@ -55,7 +18,7 @@ jobs:
10.0.x

- name: Build
run: ./build.sh -AngleSharpVersion 1.10.0
run: ./build.sh -AngleSharpVersion 1.11.0

windows:
runs-on: windows-latest
Expand Down Expand Up @@ -85,9 +48,9 @@ jobs:
NUGET_API_KEY: ${{ steps.nuget_login.outputs.NUGET_API_KEY }}
run: |
if ($env:GITHUB_REF -eq "refs/heads/main") {
.\build.ps1 -Target Publish -AngleSharpVersion 1.10.0
.\build.ps1 -Target Publish -AngleSharpVersion 1.11.0
} elseif ($env:GITHUB_REF -eq "refs/heads/devel") {
.\build.ps1 -Target PrePublish -AngleSharpVersion 1.10.0
.\build.ps1 -Target PrePublish -AngleSharpVersion 1.11.0
} else {
.\build.ps1 -AngleSharpVersion 1.10.0
.\build.ps1 -AngleSharpVersion 1.11.0
}
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# 1.3.0

Released on Tuesday, November 24 2026.

- Fixed a module with a top-level `await` blocking the page for many seconds
- Fixed import map entries of a prefix not being used
- Fixed an `import()` of a module that could not be fetched not rejecting with a `TypeError`
- Fixed the DOM of libraries registered by a creator only being missing
- Fixed an object getting the prototype of an unrelated class of another library
- Updated a WebIDL namespace to be a plain object, whose members are no longer members of the window too
- Updated minimum version of AngleSharp to 1.11.0
- Added `WithJs(DomRegistration)` to register the DOM of libraries declared for a scripting engine (#152)
- Added `SharedWorker`, which the scripts of an origin creating it for the same address
- Added CSS module scripts (`import sheet from './a.css' with { type: 'css' }`), whose default export is a constructed style sheet
- Added `import.meta.resolve()`
- Added interfaces of a namespace (`[DomExposed("WebAssembly")]` puts `WebAssembly.Module` there instead of on the window)
- Added delegates of the DOM as functions of scripts
- Added `BigInteger` as BigInt, `Memory<Byte>` as an ArrayBuffer
- Added exceptions of the DOM (e.g. `WebAssembly.RuntimeError`) being errors of their class
- Added the Web Cryptography API (`crypto.subtle`, also in workers; not on .NET Framework)

# 1.2.3

Released on Sunday, November 22 2026.
Expand Down
3 changes: 3 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
We have more detailed information regarding the following subjects:

- [Getting Started](general/01-Basics.md)
- [API Documentation](tutorials/01-API.md)
- [Examples](tutorials/02-Examples.md)
- [Frequently Asked Questions](tutorials/03-Questions.md)
73 changes: 36 additions & 37 deletions docs/general/01-Basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ section: "AngleSharp.Js"
---
# Getting Started

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.
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.

## Install and configure

Expand All @@ -18,13 +14,9 @@ Install the package:
Install-Package AngleSharp.Js
```

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.
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.

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.
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.

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

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

`WithJs()` registers the JavaScript scripting service, support for inline event attributes
such as `onclick`, a navigation handler for `javascript:` URLs, and a default `navigator`
when the configuration does not already provide one.
`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`.

### Customize the event loop

Expand Down Expand Up @@ -93,11 +82,21 @@ var configuration = Configuration.Default
});
```

### Configure the Jint engine

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:

```cs
var configuration = Configuration.Default
.With(new EngineCreator((window, options) => new Jint.Engine(options
.MaxStatements(1_000_000)
.TimeoutInterval(TimeSpan.FromSeconds(5)))))
.WithJs();
```

## Execute JavaScript

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.
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.

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

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

- `console.log`, `atob`, `btoa`, `DOMParser`, `Image`, `screen`, and `XMLHttpRequest`.
- `console`, `atob`, `btoa`, `structuredClone`, `queueMicrotask`, `DOMParser`, `Image`, `Audio`, and `screen`.
- `requestAnimationFrame`, `requestIdleCallback`, `performance`, `crypto`, `TextEncoder`, and `TextDecoder`.
- `Worker`, `SharedWorker`, `MessageChannel`, and `window.postMessage`.
- `javascript:` URL navigation.
- Inline event-handler attributes and DOM event callbacks.
- ES modules and import maps through Jint's module loader.
Expand All @@ -214,13 +215,13 @@ they meet a script's needs:
| `DOMParser` | `parseFromString` creates a document through the configured `IDocumentFactory`. The requested MIME type must be supported by that configuration. |
| `Image` | Creates an AngleSharp `<img>` element; optional width and height become its display dimensions. |
| `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`. |
| `XMLHttpRequest` | Supports `open`, `send`, request headers, status, text responses, and lifecycle events through the configured document loader. |
| `console` | Supports `console.log` only. |
| `console` | All methods are available; their arguments (or, for `count`/`time*`, the formatted result) are passed to the `IConsoleLogger`. The severity is not distinguished. |
| `screen` | Exposes fixed 1920-by-1080 dimensions and 24-bit color depth for compatibility. |

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

The `WithEventLoop` overloads accept either an existing `IEventLoop` or a factory for one.

## Supported behavior and limitations

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

Notable limitations include:

- The package does not calculate layout. Its `scroll*`, `client*`, and `offset*` element
properties return `0`.
- The default `navigator` is intentionally minimal. Its platform is empty, registration
methods are no-ops, and its user-agent value is a fixed compatibility string.
- Network-backed features such as external scripts and `XMLHttpRequest` require suitable
AngleSharp requesters and resource loading configuration.
- `XMLHttpRequest` currently provides text responses only. Its `response`, `responseXML`, and
`upload` properties are unavailable, `responseType` always has its empty value, and its
`timeout` and `withCredentials` settings do not affect requests.
- 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.
- The package does not calculate layout. Its `scroll*`, `client*`, and `offset*` element properties return `0`.
- Without AngleSharp.Io's `WithNavigator()`, `navigator` is minimal (e.g. an empty `userAgent`).
- Network-backed features such as external scripts, modules, workers, `fetch` and `XMLHttpRequest` require suitable AngleSharp requesters and resource loading configuration.
- 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.

## Where to go next

- [API Documentation](../tutorials/01-API.md) lists every public type and how .NET types map to JavaScript.
- [Examples](../tutorials/02-Examples.md) has ready-to-use recipes.
- [Frequently Asked Questions](../tutorials/03-Questions.md) covers common pitfalls.
Loading