diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..b41db9a
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,78 @@
+name: CI
+
+# The gate on every push but main's and on every pull request, on a clean Linux machine of a fixed release: the browser module's tests, the build with no warnings, the library's tests and the format check. A push to
+# candidate runs the full gate, which packs the package and checks its files, and keeps the package for the release to publish.
+on:
+ push:
+ branches-ignore: [main]
+ pull_request:
+
+permissions:
+ contents: read
+
+# A newer push to a pull request supersedes the older run; every commit on a branch keeps its own result.
+concurrency:
+ group: ci-${{ github.ref }}
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+
+# DOMQL.NET tests against a DOMQL checkout beside its own, formaui-net.DOMQL beside formaui-net.DOMQL.NET, at the release its package depends on.
+defaults:
+ run:
+ working-directory: formaui-net.DOMQL.NET
+
+# Each action is pinned to the commit of the release named in its comment.
+jobs:
+ gate:
+ name: Gate
+ runs-on: ubuntu-24.04
+ env:
+ CANDIDATE: ${{ github.event_name == 'push' && github.ref == 'refs/heads/candidate' }}
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ path: formaui-net.DOMQL.NET
+
+ # The tag of the DOMQL release the package depends on.
+ - name: Read the DOMQL release
+ id: domql
+ run: echo "tag=v$(grep -oP 'Include="formaui-net.DOMQL" Version="\K[^"]+' src/Forma.DOMQL.NET/Forma.DOMQL.NET.csproj)" >> "$GITHUB_OUTPUT"
+
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ repository: FormaUI/DOMQL
+ ref: ${{ steps.domql.outputs.tag }}
+ path: formaui-net.DOMQL
+
+ - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
+ with:
+ node-version: 24
+ cache: npm
+ cache-dependency-path: |
+ formaui-net.DOMQL.NET/tests/scripts/package-lock.json
+ formaui-net.DOMQL/package-lock.json
+
+ # The SDK global.json pins, which the build requires exactly.
+ - uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
+ with:
+ global-json-file: formaui-net.DOMQL.NET/global.json
+
+ - name: Gate
+ if: env.CANDIDATE != 'true'
+ shell: pwsh
+ run: ./build.ps1
+
+ - name: Full gate
+ if: env.CANDIDATE == 'true'
+ shell: pwsh
+ run: ./build.ps1 -Full
+
+ # The package the full gate built and checked, under the name a release reads it by, kept as long as GitHub allows.
+ - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
+ if: env.CANDIDATE == 'true'
+ with:
+ name: packages
+ path: |
+ formaui-net.DOMQL.NET/artifacts/*.nupkg
+ formaui-net.DOMQL.NET/artifacts/*.snupkg
+ if-no-files-found: error
+ retention-days: 90
diff --git a/.github/workflows/promotion.yml b/.github/workflows/promotion.yml
new file mode 100644
index 0000000..1bd9fad
--- /dev/null
+++ b/.github/workflows/promotion.yml
@@ -0,0 +1,31 @@
+name: Promotion
+
+# The promotion check on every pull request into main, from the FormaUI Versioning release DOMQL.NET follows: it comes from candidate, ci.yml's full gate passed on its head commit and kept the package, its
+# version is higher than every release's and on no feed, and its changelog entry is dated.
+on:
+ pull_request:
+ branches: [main]
+ types: [opened, edited, reopened, synchronize]
+
+permissions:
+ contents: read
+ actions: read
+ pull-requests: read
+
+# Each action is pinned to the commit of the release named in its comment.
+jobs:
+ promotion:
+ name: Promotion
+ runs-on: ubuntu-24.04
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ ref: ${{ github.event.pull_request.head.sha }}
+
+ # The version the package project declares, which the package carries.
+ - uses: FormaUI/Versioning/actions/promotion-check@68ff74cadbe94084384d29be93466713fd989b53 # v1.0.0-preview.1
+ with:
+ gate-workflow: ci.yml
+ version-command: >-
+ [regex]::Match((Get-Content src/Forma.DOMQL.NET/Forma.DOMQL.NET.csproj -Raw), '([^<]+)').Groups[1].Value
+ packages-artifact: packages
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..6b22953
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,67 @@
+name: Release
+
+# A release tag's push: the release check of the FormaUI Versioning release DOMQL.NET follows, then the package and its symbols the candidate's full gate built, attached to the tag's GitHub release with
+# their digests, and published from there to nuget.org through trusted publishing. A run that fails runs again for the same tag, publishing what the feed lacks.
+on:
+ push:
+ tags: ['v*']
+
+permissions:
+ contents: read
+
+# Each action is pinned to the commit of the release named in its comment.
+jobs:
+ release:
+ name: Release
+ runs-on: ubuntu-24.04
+ # Only a v* tag deploys to the release environment, and the feed's trusted-publishing policy names it, so only a release tag's run publishes.
+ environment: release
+ permissions:
+ contents: write
+ actions: read
+ pull-requests: read
+ id-token: write
+ steps:
+ # The whole history, so the check finds the tag's commit in main's.
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ fetch-depth: 0
+
+ # The version the package project declares, which the package carries.
+ - id: check
+ uses: FormaUI/Versioning/actions/release-check@68ff74cadbe94084384d29be93466713fd989b53 # v1.0.0-preview.1
+ with:
+ gate-workflow: ci.yml
+ version-command: >-
+ [regex]::Match((Get-Content src/Forma.DOMQL.NET/Forma.DOMQL.NET.csproj -Raw), '([^<]+)').Groups[1].Value
+ packages-artifact: packages
+
+ - id: packages
+ uses: FormaUI/Versioning/actions/release-packages@68ff74cadbe94084384d29be93466713fd989b53 # v1.0.0-preview.1
+ with:
+ gate-run-id: ${{ steps.check.outputs.gate-run-id }}
+ packages-artifact: packages
+ name: DOMQL.NET
+
+ - uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
+ with:
+ global-json-file: global.json
+
+ # A short-lived nuget.org key, for the account NUGET_USER names, whose trusted-publishing policy names this workflow.
+ - id: nuget
+ uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1.2.0
+ with:
+ user: ${{ vars.NUGET_USER }}
+
+ # The package and its symbols, past a version nuget.org holds already.
+ - name: Publish to nuget.org
+ shell: pwsh
+ env:
+ NUGET_API_KEY: ${{ steps.nuget.outputs.NUGET_API_KEY }}
+ PACKAGES: ${{ steps.packages.outputs.directory }}
+ VERSION: ${{ steps.check.outputs.version }}
+ run: |
+ dotnet nuget push (Join-Path $env:PACKAGES "formaui-net.DOMQL.NET.$env:VERSION.nupkg") --api-key $env:NUGET_API_KEY --source https://api.nuget.org/v3/index.json --skip-duplicate
+ if ($LASTEXITCODE -ne 0) {
+ throw 'Publishing to nuget.org failed.'
+ }
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9efe83b..99a17f0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,7 +9,9 @@ Each release of DOMQL.NET's package, `formaui-net.DOMQL.NET`, newest first, with
## `1.0.0-preview.1`
-*Unreleased · DOMQL `1.0.0-preview.4`*
+*December 3, 2026 · DOMQL `1.0.0-preview.5`*
- The first preview: DOMQL from a .NET application, over DOMQL's connection. `services.AddDomql()` registers a `DomqlConnection` for each browser runtime. Owners end every operation they started in one call. Watches keep a copy of their result by change sets, mapped onto a type. Subscriptions hand each event to a handler that may answer it, and executions run once or continuously. The operations one turn starts cross in one call.
-- The package serves its browser module at `_content/domql.net/domql.dotnet.js`, beside DOMQL's bundle, and references Microsoft.JSInterop.
+- A watch whose options set `WaitForAcknowledgment = false` has each change cross with the browser task it happened in, in order with the events after it.
+- Deliveries are taken in the order they crossed, a batch that crosses as a stream read before any after it is taken. Each is taken at its place, a watch's change applied and an event's handler started, and none waits for a handler to complete, so a handler finds the state before its event, and a handler that awaits a dialog holds no change that crossed after it.
+- The package serves its browser module at `_content/domql.net/domql.dotnet.js`, beside DOMQL's bundle, and depends on `formaui-net.DOMQL` `1.0.0-preview.5`, which serves that bundle, and on Microsoft.JSInterop.
diff --git a/CLAUDE.md b/CLAUDE.md
index 562f0f7..c442568 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -1,6 +1,6 @@
# Working on DOMQL.NET
-DOMQL.NET is DOMQL from a .NET application: a C# library over [DOMQL's connection](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.4/spec/connections.md), and the browser module that opens it. It ships as the NuGet package `formaui-net.DOMQL.NET`.
+DOMQL.NET is DOMQL from a .NET application: a C# library over [DOMQL's connection](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.5/spec/connections.md), and the browser module that opens it. It ships as the NuGet package `formaui-net.DOMQL.NET`.
DOMQL.NET follows [FormaUI Versioning `v1.0.0-preview.1`](https://github.com/FormaUI/Versioning/blob/v1.0.0-preview.1/README.md) for its [stages](https://github.com/FormaUI/Versioning/blob/v1.0.0-preview.1/docs/versions.md#stages), [branches](https://github.com/FormaUI/Versioning/blob/v1.0.0-preview.1/docs/branches.md), [commits](https://github.com/FormaUI/Versioning/blob/v1.0.0-preview.1/docs/commits.md), [releases](https://github.com/FormaUI/Versioning/blob/v1.0.0-preview.1/docs/releases.md) and [packages](https://github.com/FormaUI/Versioning/blob/v1.0.0-preview.1/docs/packages.md).
@@ -10,7 +10,7 @@ Read the documents that govern the affected contract:
| Document | Authority |
| --- | --- |
-| [DOMQL's specification](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.4/spec/README.md) | What a query means, and the connection DOMQL.NET speaks, at the DOMQL release DOMQL.NET builds against |
+| [DOMQL's specification](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.5/spec/README.md) | What a query means, and the connection DOMQL.NET speaks, at the DOMQL release DOMQL.NET builds against |
| [Specification](spec/README.md) | DOMQL.NET's API |
| [Design](docs/design.md) | How DOMQL.NET is built |
| [Status](docs/features-status.md) | What is implemented, and what remains |
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 335436c..9aef3f5 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -35,3 +35,17 @@ In your pull request, explain the problem, the resulting behavior and how you ve
## Commit messages
Commits follow [FormaUI Versioning's commits](https://github.com/FormaUI/Versioning/blob/v1.0.0-preview.1/docs/commits.md), with the scope `domql-net`: a title under 50 characters, lowercase and imperative, one purpose per commit.
+
+
+
+## Cut a release
+
+A release is a candidate that passed its full gate, promoted to `main` and tagged there, as [FormaUI Versioning's releases](https://github.com/FormaUI/Versioning/blob/v1.0.0-preview.1/docs/releases.md) set out. Publishing its package is the step after it.
+
+1. **Set the release on `dev`.** Pause merges unrelated to it, as [stabilizing a candidate](https://github.com/FormaUI/Versioning/blob/v1.0.0-preview.1/docs/branches.md#stabilizing-a-candidate) sets out. Check that the package project declares the release's version, ``, and the DOMQL release it depends on, with DOMQL's documents linked at that release, and date the changelog's newest entry by the day of the release.
+2. **Select the candidate.** Fast-forward `candidate` to `dev`'s tip, `git push origin dev:candidate`. `ci.yml` runs the full gate on it, against DOMQL checked out at the release the package depends on, and keeps the package. A fix lands on `dev`, and `candidate` moves to the corrected tip.
+3. **Promote it.** Open a pull request from `candidate` into `main`, which `promotion.yml` checks. Once the check passes, a release signer fast-forwards `main` to it, `git push origin candidate:main`.
+4. **Tag it.** A release signer tags `main`'s commit with an annotated, signed tag, `git tag -s v1.0.0-preview.1 -m "DOMQL.NET 1.0.0-preview.1"`, and pushes it, `git push origin v1.0.0-preview.1`. A pushed tag is never moved or deleted.
+5. **Publish it.** The tag's push runs `release.yml`, which publishes the package and its symbols to nuget.org through trusted publishing. A run that fails runs again for the same tag, and publishes what the feed lacks.
+
+After a release, the next change a caller can notice opens the changelog's next entry.
diff --git a/README.md b/README.md
index c75d3cf..90ebed5 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
DOMQL.NET runs [DOMQL](https://github.com/FormaUI/DOMQL) queries from a .NET application. It watches the DOM, subscribes to its events and carries out executions in the browser, and keeps a typed copy of each result in .NET. It is published by FormaUI, beside DOMQL and Forma.
-> **Preview, unreleased.** DOMQL.NET's first preview, `1.0.0-preview.1`, waits for DOMQL's release `1.0.0-preview.4`, which brings the connection it runs over. See [the status](docs/features-status.md).
+> **Preview.** DOMQL.NET's first preview, `1.0.0-preview.1`, is published to NuGet. It runs over DOMQL's connection, and its package depends on DOMQL's release `1.0.0-preview.5`. See [the status](https://github.com/FormaUI/DOMQL.NET/blob/main/docs/features-status.md).
```csharp
builder.Services.AddDomql();
@@ -25,20 +25,28 @@ await owner.DisposeAsync(); // Ends every operation the owner started, in one ca
- **A watch keeps a copy.** Each change arrives as a change set, applied to the watch's copy before the browser sends the next.
- **Events arrive as they happen,** and a subscription's handler can answer one.
+## Install
+
+```sh
+dotnet add package formaui-net.DOMQL.NET --prerelease
+```
+
+It brings DOMQL's package, `formaui-net.DOMQL`, whose bundle it serves beside its own browser module. A page needs no script of its own: `AddDomql` registers the connection, and its first request imports the module.
+
## Documents
| Document | What it holds |
| --- | --- |
-| [Specification](spec/README.md) | DOMQL.NET's API: its connection, queries and their types, owners, watches, subscriptions, executions, crossings and failures |
-| [Design](docs/design.md) | How DOMQL.NET is built |
-| [Status](docs/features-status.md) | What is implemented, and what remains |
-| [Decisions](docs/decisions.md) | Each decision, with why and what was declined |
-| [Changelog](CHANGELOG.md) | Each release of the package |
-| [Contributing](CONTRIBUTING.md) | Building and testing DOMQL.NET |
+| [Specification](https://github.com/FormaUI/DOMQL.NET/blob/main/spec/README.md) | DOMQL.NET's API: its connection, queries and their types, owners, watches, subscriptions, executions, crossings and failures |
+| [Design](https://github.com/FormaUI/DOMQL.NET/blob/main/docs/design.md) | How DOMQL.NET is built |
+| [Status](https://github.com/FormaUI/DOMQL.NET/blob/main/docs/features-status.md) | What is implemented, and what remains |
+| [Decisions](https://github.com/FormaUI/DOMQL.NET/blob/main/docs/decisions.md) | Each decision, with why and what was declined |
+| [Changelog](https://github.com/FormaUI/DOMQL.NET/blob/main/CHANGELOG.md) | Each release of the package |
+| [Contributing](https://github.com/FormaUI/DOMQL.NET/blob/main/CONTRIBUTING.md) | Building and testing DOMQL.NET |
## Build and try it
-DOMQL.NET builds and tests against a DOMQL checkout beside it, as [contributing](CONTRIBUTING.md) sets out:
+DOMQL.NET builds and tests against a DOMQL checkout beside it, as [contributing](https://github.com/FormaUI/DOMQL.NET/blob/main/CONTRIBUTING.md) sets out:
```powershell
git clone https://github.com/FormaUI/DOMQL.git formaui-net.DOMQL
@@ -49,4 +57,4 @@ cd formaui-net.DOMQL.NET
## License
-Apache License 2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE).
+Apache License 2.0. See [LICENSE](https://github.com/FormaUI/DOMQL.NET/blob/main/LICENSE) and [NOTICE](https://github.com/FormaUI/DOMQL.NET/blob/main/NOTICE).
diff --git a/docs/decisions.md b/docs/decisions.md
index b3d33c8..08a42d9 100644
--- a/docs/decisions.md
+++ b/docs/decisions.md
@@ -1,6 +1,6 @@
# Decisions
-Each decision taken without stopping to ask, with why and what was declined, for review. DOMQL's own decisions, which DOMQL.NET builds on, are [DOMQL's](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.4/docs/decisions.md).
+Each decision taken without stopping to ask, with why and what was declined, for review. DOMQL's own decisions, which DOMQL.NET builds on, are [DOMQL's](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.5/docs/decisions.md).
@@ -39,9 +39,32 @@ Each decision taken without stopping to ask, with why and what was declined, for
- **Decision:**
- DOMQL.NET has a repository of its own, `FormaUI/DOMQL.NET`, with its own solution, workspace, gate, records and package, `formaui-net.DOMQL.NET`. Its types keep the namespace `Domql`.
- DOMQL keeps the connection, `domql.connect`, which any host across a boundary speaks, and the change sets' conformance corpus, which is part of its contract.
- - DOMQL.NET builds and tests against a DOMQL checkout beside it, or the one `DOMQL_SOURCE` names, and its package depends on DOMQL's from the first DOMQL release with the connection, `1.0.0-preview.4`.
+ - DOMQL.NET builds and tests against a DOMQL checkout beside it, or the one `DOMQL_SOURCE` names, at the DOMQL release its package depends on, from the first with the connection, `1.0.0-preview.4`; CI checks DOMQL out at that release's tag.
- **Why:**
- DOMQL is a JavaScript library. Its gate, its package and its records had grown a .NET project, a C# test step and a dependency on Microsoft.JSInterop, which a JavaScript host never uses.
- The .NET half versions apart from DOMQL: a change to its API is no change to DOMQL's contract.
- The connection is DOMQL's API for every host, of which DOMQL.NET is one.
- **Declined:** Moving the connection too. DOMQL would keep no API for a host across a boundary, and DOMQL.NET would reach into DOMQL's internals.
+
+
+
+## D3 — Deliveries are taken in order, none waiting for a handler, and a watch can wait for no acknowledgment
+
+*December 3, 2026*
+
+- **Kind:** Contract, beside DOMQL's [D121](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.5/docs/decisions.md#d121).
+- **Decision:**
+ - `DomqlWatchOptions.WaitForAcknowledgment`, true by default, asks DOMQL's connection for a watch that waits for none where it is false, as the request's field, `waitForAcknowledgment`, is named: each change crosses with its browser task, in order with the events after it.
+ - Batches are taken in the order they cross. A batch is read, a stream among them, then taken once the batch before it has been.
+ - Each delivery is taken at its place: a watch's change applied, a value settled, an event's handler started. None waits for a handler to complete. A batch is answered once its handlers have.
+ - A delivery that is no object naming its handle by a number is answered with null. A batch that can't be read, or that the browser hears rejected, leaves every watch's copy uncertain until a refresh brings its snapshot, since a later change set may follow one it missed.
+- **Why:**
+ - A press or a key that acts on where the focus went needs the focus's every change before it. A watch's change could wait for its acknowledgment while an event crossed at once.
+ - Taken at its place, a handler finds every delivery before its event applied, and none after it, until it first awaits; a watch whose request is still unanswered applies its deliveries once it is.
+ - A watch that waits for no acknowledgment may have several deliveries in flight. Taken in the order they crossed, its changes apply in that order, a streamed batch's among them.
+ - A .NET UI framework's own event handlers start the same way: each as its event arrives, whatever handler before it still awaits.
+- **Declined:**
+ - Each handler of a batch waiting for the one before it, as DOMQL.NET did before this decision. A watch's change after a handler awaiting a dialog waited for the dialog, and a handler that waited behind another read the state from after its own event. Handlers of different batches never waited for each other, so the rule held only within one browser task.
+ - Applying a batch's state as it arrives while its handlers wait in turn. A handler that waited read state from after its event.
+ - Holding each batch until the one before it is answered. A handler awaiting a dialog would hold the dialog's own events, a deadlock.
+ - Answering a watch's change before the batch's handlers complete. DOMQL's connection settles a batch with one answer, so a watch that waits is answered with its batch's events; one a handler must not hold waits for no acknowledgment.
diff --git a/docs/design.md b/docs/design.md
index af97b80..3ab475b 100644
--- a/docs/design.md
+++ b/docs/design.md
@@ -1,6 +1,6 @@
# DOMQL.NET design
-How DOMQL.NET is built to meet [its specification](../spec/README.md). It is DOMQL's own host of a [connection](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.4/spec/connections.md), and keeps a copy of each result its watches deliver, as [keeping a copy of a result](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.4/spec/results.md#results-keeping-a-copy) sets out.
+How DOMQL.NET is built to meet [its specification](../spec/README.md). It is DOMQL's own host of a [connection](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.5/spec/connections.md), and keeps a copy of each result its watches deliver, as [keeping a copy of a result](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.5/spec/results.md#results-keeping-a-copy) sets out.
## Parts
@@ -14,19 +14,21 @@ How DOMQL.NET is built to meet [its specification](../spec/README.md). It is DOM
## A turn, a task
- **.NET's side.** A request is queued as it is made. The first of a turn posts a flush to the synchronization context it was made in, so it runs once the turn ends: every watch, subscription and execution the turn starts crosses in one call. The flush waits for the connection to open, and takes what is queued then, so the requests made while the module imports cross with the first batch.
-- **The browser's side** is DOMQL's connection, which answers each batch once its task has ended and sends each task's deliveries together, as [its design](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.4/docs/domql-design.md#connections) sets out.
+- **The browser's side** is DOMQL's connection, which answers each batch once its task has ended and sends each task's deliveries together, as [its design](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.5/docs/domql-design.md#connections) sets out.
- **Answers and deliveries race.** The runtime orders no call's result before the calls the browser makes while it runs, so a delivery sent during a request's task may reach .NET before its answer. A watch holds such deliveries, and applies them in order after its answer's snapshot.
## Watches and their copies
-- **.NET applies, then acknowledges.** A watch applies a change set to its copy, a `JsonNode`, and maps it onto the query's type before the batch is acknowledged. Its handler is called after, one call at a time, with the latest result, so a slow handler never holds the next change set, and never sees a copy partly applied.
+- **.NET applies, then acknowledges.** A watch applies a change set to its copy, a `JsonNode`, and maps it onto the query's type before the batch is acknowledged. Its `changed` handler is called after, one call at a time, with the latest result, so a slow `changed` handler never holds the next change set, and never sees a copy partly applied.
- **An uncertain copy.** A change set that doesn't apply makes the copy uncertain. The watch asks for its snapshot whole, and skips change sets until it arrives.
-- **A batch that can't be read** refreshes every watch, once: one that can't be read while that refresh is under way, as a snapshot past the size the connection reads is, refreshes nothing more until a batch is read.
+- **A batch that can't be read,** or one whose taking fails, so that the browser hears it rejected, leaves every copy uncertain, skipping change sets until its snapshot arrives, and refreshes every watch, once: one that can't be read while that refresh is under way, as a snapshot past the size the connection reads is, refreshes nothing more until a batch is read.
- **Reconnecting.** A host whose connection to the browser resumes calls `RefreshAsync`, which has every watch deliver its snapshot whole in one request.
## Events
- **.NET awaits an event's handler** before it answers the batch, so the event's acknowledgment in the browser follows the handler, and its answer answers the event source.
+- **Taken in order, waiting for no handler.** Batches are taken in the order they cross: each is read, a stream among them, then taken once the batch before it has been. Each delivery is taken at its place, a watch's change applied, a value settled, a handler started, and none waits for a handler to complete. So a handler that awaits a dialog holds no change that crossed after it, and the changes of a watch that waits for no acknowledgment, several of which may be in flight, apply in the order they crossed, as [D3](decisions.md#d3) records.
+- **What a handler still holds.** A batch is answered once its handlers have completed, so a watch that waits for its acknowledgment, whose change shares a batch with a handler awaiting a dialog, sends its next change only once the dialog closes. A watch a handler must not hold waits for no acknowledgment.
- **A handler's failure stays its own.** The batch is acknowledged, and the deliveries after it are applied; the connection's logger hears the failure.
## Handles that end
diff --git a/docs/features-status.md b/docs/features-status.md
index cf39b69..4697279 100644
--- a/docs/features-status.md
+++ b/docs/features-status.md
@@ -1,13 +1,15 @@
# Status
-**DOMQL.NET is in its first preview, `1.0.0-preview.1`, unreleased.** It implements [its specification](../spec/README.md) on DOMQL's connection, which DOMQL `1.0.0-preview.4` introduces.
+**DOMQL.NET is in its first preview, `1.0.0-preview.1`, released.** It implements [its specification](../spec/README.md) on DOMQL's connection, which DOMQL `1.0.0-preview.4` introduced. Its package depends on DOMQL's, `formaui-net.DOMQL`, from `1.0.0-preview.5`, whose connection carries a watch that waits for no acknowledgment, and CI runs its gate against a DOMQL checkout at that release's tag.
| Feature | Contract | State |
| --- | --- | --- |
| One connection for each browser runtime, `AddDomql`, each turn's requests in one call | [The connection](../spec/README.md#dotnet-connection) | Implemented |
| Queries mapped onto types: source-generated, by reflection, or as JSON | [Queries and their results](../spec/README.md#dotnet-queries) | Implemented |
| Owners, whose disposal ends every operation they started in one request | [Owners and operations](../spec/README.md#dotnet-operations) | Implemented |
-| Watches keeping a copy by change sets, one delivery in flight | [Watches](../spec/README.md#dotnet-watches) | Implemented |
+| Watches keeping a copy by change sets, one delivery in flight unless they wait for no acknowledgment | [Watches](../spec/README.md#dotnet-watches) | Implemented |
+| Watches that wait for no acknowledgment, each change crossing in order with the events after it | [Watches](../spec/README.md#dotnet-watches) | Implemented |
+| Deliveries taken in the order they crossed, a streamed batch among them, none waiting for a handler | [Subscriptions and executions](../spec/README.md#dotnet-subscriptions) | Implemented |
| Subscriptions whose handlers answer their events, and executions | [Subscriptions and executions](../spec/README.md#dotnet-subscriptions) | Implemented |
| Failures with their code, kind and location | [Failures](../spec/README.md#dotnet-failures) | Implemented |
@@ -17,7 +19,4 @@
| Work | Waits for |
| --- | --- |
-| The package's dependency on `formaui-net.DOMQL`, which serves the bundle the browser module imports; until then an application references both | DOMQL's release `1.0.0-preview.4` |
-| CI, checking DOMQL out at the release the dependency names; and the release and promotion workflows, as DOMQL's | DOMQL's release `1.0.0-preview.4` |
| A test that drives DOMQL.NET through a real browser and a .NET host, as DOMQL's full gate drives its packages | — |
-| The first release, `1.0.0-preview.1`, by [FormaUI Versioning](https://github.com/FormaUI/Versioning/blob/v1.0.0-preview.1/docs/releases.md) | The rest |
diff --git a/spec/README.md b/spec/README.md
index 19841fa..2a3595a 100644
--- a/spec/README.md
+++ b/spec/README.md
@@ -2,7 +2,7 @@
-DOMQL.NET is DOMQL from a .NET application. It ships in the NuGet package `formaui-net.DOMQL.NET`, which depends on DOMQL's own, `formaui-net.DOMQL`, for the bundle. A .NET application writes a query's text, names the type its result maps onto, and carries it out for an owner. DOMQL runs it in the browser, through a [connection](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.4/spec/connections.md), and keeps the application's copy of each result.
+DOMQL.NET is DOMQL from a .NET application. It ships in the NuGet package `formaui-net.DOMQL.NET`, which depends on DOMQL's own, `formaui-net.DOMQL`, for the bundle. A .NET application writes a query's text, names the type its result maps onto, and carries it out for an owner. DOMQL runs it in the browser, through a [connection](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.5/spec/connections.md), and keeps the application's copy of each result.
```csharp
public sealed record PanelState(double? Width, bool HasFocus);
@@ -48,7 +48,7 @@ In this document:
- **`DomqlQuery.Create(text, typeInfo, types?)`** makes a query whose result maps onto `T` through source-generated type information, as a trimmed or native application needs. `DomqlQuery.Create(text, options?, types?)` maps it by reflection, through the serializer's options, the web's defaults by default. `DomqlQuery.Create(text, types?)` keeps the result's JSON, as a `JsonElement`.
- **The text is checked in the browser.** It is read with `Domql` supplied, as `domql.query` reads it, by the first request that makes it there. A syntax or structure failure fails that request. .NET has no parser of its own.
-- **`types`** declares the type of a top-level binding by its notation, as [declared types](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.4/spec/queries.md#making-a-query-declared-types) do.
+- **`types`** declares the type of a top-level binding by its notation, as [declared types](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.5/spec/queries.md#making-a-query-declared-types) do.
- **Mapping.** A result's fields map onto `T`'s properties and constructor parameters as the serializer maps JSON. A result `T` can't hold is a failure, `DOMQL5028`, and a watch's current result stands.
- **Records a field discriminates.** A result that is one of several shapes maps onto a type the serializer reads polymorphically, by a field the query names first, as `[JsonPolymorphic(TypeDiscriminatorPropertyName = "kind")]` names one.
- **Bindings** are `IReadOnlyDictionary`. Each value crosses as the runtime serializes it, and an element reference the runtime serializes crosses as the element it refers to.
@@ -57,7 +57,7 @@ In this document:
## Owners and operations
-`connection.CreateOwner(name?)` makes a **`DomqlOwner`**, who carries operations out. Its name is its own among the connection's owners until it is disposed: one of its own where none is given, and a name in use is refused with an `ArgumentException`, since a release names one owner alone. Each implementation an operation reaches receives its name as `env.owner`, and a command reaches the behavior running for it, as [behaviors](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.4/spec/behaviors.md#behaviors-the-owner) set out. A part of a page that starts operations of its own holds one.
+`connection.CreateOwner(name?)` makes a **`DomqlOwner`**, who carries operations out. Its name is its own among the connection's owners until it is disposed: one of its own where none is given, and a name in use is refused with an `ArgumentException`, since a release names one owner alone. Each implementation an operation reaches receives its name as `env.owner`, and a command reaches the behavior running for it, as [behaviors](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.5/spec/behaviors.md#behaviors-the-owner) set out. A part of a page that starts operations of its own holds one.
| Operation | Answers | As in the browser |
| --- | --- | --- |
@@ -78,9 +78,11 @@ In this document:
A **`DomqlWatch`** keeps a copy of its query's result, which each delivery brings up to date.
+- **Its query** gives an object or a list that is never null, since the browser keeps the result as [live state](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.5/spec/results.md#live-state). Any other is refused with `DOMQL3001`, which `ReadyAsync()` throws: write `{ count = panel.children.count }` where the count alone is wanted.
- **Its first result** arrives with its request's answer, which `ReadyAsync()` waits for. Where the first evaluation waits for a maintained member, its snapshot is delivered whole once it has one.
-- **Each change set** is applied to the copy as it arrives, by DOMQL's rules for [applying change sets](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.4/spec/results.md#results-change-sets), and the copy is mapped onto `T`. A delivery that overtakes the request's answer waits for it.
-- **The browser's next change set** crosses once this one is applied, so a watch has one delivery in flight. What arises meanwhile is joined, as [pacing](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.4/spec/connections.md#connections-pacing) sets out.
+- **Each change set** is applied to the copy as it arrives, by DOMQL's rules for [applying change sets](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.5/spec/results.md#results-change-sets), and the copy is mapped onto `T`. A delivery that overtakes the request's answer waits for it.
+- **The browser's next change set** crosses once the batch this one crossed in is answered, by default, after that batch's handlers have completed, so a watch has one delivery in flight. What arises meanwhile is joined, as [pacing](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.5/spec/connections.md#connections-pacing) sets out. A handler that awaits a dialog holds the next change of a watch whose change shares its batch until it completes.
+- **A watch that waits for no acknowledgment,** `WaitForAcknowledgment = false` in its options, has each change cross with the browser task it happened in, joined to none, whatever handler its batch is still running. So a handler that acts on an event by the watch's `Current`, as a press acts on where the focus went, finds every change the watch evaluated before the event, once the watch's request is answered, and under the `immediate` schedule the state as it was then. Each change costs a delivery, as [pacing](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.5/spec/connections.md#connections-pacing) sets out.
- **`changed`** is called with each result once it is applied, one call at a time, with the latest where several arrived meanwhile. A handler that throws is reported to the connection's logger, and the copy stands.
- **`Current`**, **`HasCurrent`**, **`Status`** and **`Error`** read the copy: `Pending`, `Ready`, `Failed` or `Disposed`. A failed evaluation, or a result `T` can't hold, sets `Error` and `Failed`. The current result stands until the next result applied.
- **`UpdateAsync(bindings)`** watches with other bindings. Its next result is the first of the new ones, and a delivery made with the old ones is dropped by its generation.
@@ -91,8 +93,9 @@ A **`DomqlWatch`** keeps a copy of its query's result, which each delivery br
## Subscriptions and executions
-- **A `DomqlSubscription`** hands each event to its handler as it arrives, mapped onto `T`, in the order the browser heard them. An event never waits behind a watch's delivery.
-- **The event's acknowledgment** in the browser settles once the handler completes. A handler of `Subscribe` answers the event, and its answer answers the event source, as [answers](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.4/spec/behaviors.md#behaviors-answers) set out.
+- **A `DomqlSubscription`** hands each event to its handler as it is taken, mapped onto `T`, in the order the browser heard them. An event never waits for a watch's acknowledgment, nor for a handler; a batch that crossed before it as a stream is read first.
+- **Deliveries are taken in the order they crossed,** across batches, a batch that crosses as a stream read before any batch after it is taken. Each is taken at its place: a watch's change applied, its `changed` called as [watches](#dotnet-watches) set out, an execution's or an evaluation's value settled, an event's handler started. None waits for a handler to complete, so a handler finds every delivery before its event applied, and none after it, until it first awaits. A watch whose request is still unanswered applies its deliveries once its answer arrives, as [its first result](#dotnet-watches) sets out, so its changes reach a handler once it has answered. A batch is acknowledged once its handlers have completed, and an event for a handle that ended before its place goes no further.
+- **The event's acknowledgment** in the browser settles once the handler completes. A handler of `Subscribe` answers the event, and its answer answers the event source, as [answers](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.5/spec/behaviors.md#behaviors-answers) set out.
- **`UpdateAsync(bindings)`** subscribes with other bindings. An event of the old ones that arrives after it is dropped.
- **A `DomqlExecution`** runs until it, or its owner, is disposed. `UpdateAsync(bindings)` updates it in place, and a refusal fails the task and leaves it running as it was.
- **`Failed`**, in each handle's options, hears each failure an operation reports. The connection's logger hears those no `Failed` is given for.
@@ -105,6 +108,7 @@ A **`DomqlWatch`** keeps a copy of its query's result, which each delivery br
| --- | --- |
| Starts any number of operations in one turn | 1, its answers holding each watch's first result |
| A watch's change | 1, the deliveries of one browser task together |
+| A change of a watch that waits for no acknowledgment | 1 for each browser task with a change, each change a delivery of its own, with the other deliveries of its task |
| A subscription's event | 1, with the other deliveries of its task |
| An execution that settles in its request's task | 1 |
| Ends every operation of an owner | 1 |
@@ -118,6 +122,6 @@ A **`DomqlException`** carries a failure's `Code`, its `Kind` and its `Location`
- **A refused request** fails its operation: a watch's `ReadyAsync`, an execution's task, a handle's `Failed`.
- **A batch that can't cross** fails each request it carried with `DOMQL5030`, the runtime's failure its inner exception.
-- **A batch of deliveries that can't be read** is logged, and every watch delivers its snapshot whole, once: a batch that can't be read while that refresh is under way, as a snapshot past `MaximumDeliverySize` is, refreshes nothing more until a batch is read. A handler's failure stays its own: the batch is acknowledged, and the deliveries after it are applied.
+- **A batch of deliveries that can't be read** is logged, every watch's copy skips change sets until its snapshot whole arrives, and every watch delivers it, once: a batch that can't be read while that refresh is under way, as a snapshot past `MaximumDeliverySize` is, refreshes nothing more until a batch is read. A handler's failure stays its own: the batch is acknowledged, and the deliveries after it are applied.
- **A refused update** fails its handle, which ends in the browser too. So does a request whose batch could not cross, since the browser may have run it before its answer was lost.
-- **DOMQL.NET's own codes:** `DOMQL5028`, a result its type can't hold; `DOMQL5029`, a change set that doesn't apply to the copy; and `DOMQL5030`, a batch that could not cross or be read. DOMQL's [errors](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.4/spec/errors.md) reserve them for DOMQL.NET.
+- **DOMQL.NET's own codes:** `DOMQL5028`, a result its type can't hold; `DOMQL5029`, a change set that doesn't apply to the copy; and `DOMQL5030`, a batch that could not cross or be read. DOMQL's [errors](https://github.com/FormaUI/DOMQL/blob/v1.0.0-preview.5/spec/errors.md) reserve them for DOMQL.NET.
diff --git a/src/Forma.DOMQL.NET/DomqlConnection.cs b/src/Forma.DOMQL.NET/DomqlConnection.cs
index cb7cfa3..47838d3 100644
--- a/src/Forma.DOMQL.NET/DomqlConnection.cs
+++ b/src/Forma.DOMQL.NET/DomqlConnection.cs
@@ -31,6 +31,9 @@ public sealed class DomqlConnection : IAsyncDisposable
private bool _isDisposed;
private bool _isRefreshingUnread;
+ /// What completes once the latest batch received has been taken: each batch is taken once the one before it has been, for the connection's life. It never faults.
+ private Task _taken = Task.CompletedTask;
+
/// A connection through the JavaScript runtime given, which opens as its first request crosses.
/// The runtime of the browser it reaches.
/// Where it finds DOMQL, and how much it reads of a delivery.
@@ -199,10 +202,47 @@ internal Task SendAsync(DomqlRequest request)
}
///
- /// The deliveries of one browser task, applied in the order they happened, each answered: a subscription's event with its handler's answer, anything else with null. A delivery to a handle that has ended is
- /// answered with null and goes no further.
+ /// The deliveries of one browser task, each answered: a subscription's event with its handler's answer, anything else with null. The batch is taken after every batch that crossed before it, once it is
+ /// read, and answered once its handlers have completed.
///
internal async Task